@myoc/excalidraw 0.19.535 → 0.19.536

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 Mi,A as cx,B as Su,C as xs,D as kc,E as Cu,F as dx,G as mx,H as Mc,I as ys,J as Ac,K as Dc,L as ws,M as px,N as ux,O as hx,P as Lc,Q as Rr,R as v3,S as Nr,T as ki,V as gx,X as fx,Y as Ex,Z as _c,_ as bx,a as wu,aa as vs,b as Vn,ba as Is,c as fo,ca as xx,d as _r,da as Rc,e as Si,ea as yx,f as Yn,fa as wx,g as ox,ga as vx,h as Le,ha as Pu,i as rx,ia as Ix,j as ce,ja as Tx,k as Ci,ka as Sx,l as Yo,la as Br,m as ix,n as vu,o as ax,p as Es,q as sx,r as Pc,s as lx,t as Iu,u as Tu,v as Eo,w as Xo,x as rn,y as bs,z as Pi}from"./chunk-N4AOPKJK.js";import{a as S}from"./chunk-PLDSWNV5.js";import{G as yu}from"./chunk-DARW3V66.js";import{c as nx}from"./chunk-5XKZK2GL.js";import{b as tx,c as w3,d as v}from"./chunk-SRAX5OIU.js";import mK,{useCallback as pK,useContext as uK,useEffect as hK,useRef as gK,useState as fK}from"react";import{applyDarkModeFilter as DVe,DEFAULT_IMAGE_OPTIONS as Sn,DEFAULT_UI_OPTIONS as y3,getStrokeWidthByKey as LVe,isShallowEqual as EK}from"@excalidraw/common";import jk from"clsx";import YV from"lodash.throttle";import In,{useContext as Go}from"react";import{flushSync as Ot}from"react-dom";import XV from"roughjs/bin/rough";import{nanoid as KV}from"nanoid";import{clamp as cc,pointFrom as oe,pointDistance as so,vector as qk,pointRotateRads as gb,vectorFromPoint as fb,vectorSubtract as Jk,vectorDot as Qk,vectorNormalize as eM}from"@excalidraw/math";import{CODES as kr,shouldResizeFromCenter as tM,shouldMaintainAspectRatio as dc,shouldRotateWithDiscreteAngle as nM,isArrowKey as Eb,KEYS as $,APP_NAME as $V,CURSOR_TYPE as Ae,DEFAULT_STROKE_STREAMLINE as ZV,DEFAULT_STROKE_STREAMLINE_PRECISE as jV,DEFAULT_TRANSFORM_HANDLE_SPACING as qV,DEFAULT_VERTICAL_ALIGN as oM,DRAGGING_THRESHOLD as rM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as JV,ELEMENT_TRANSLATE_AMOUNT as iM,EVENT as Q,FRAME_STYLE as No,IMAGE_MIME_TYPES as QV,IMAGE_RENDER_TIMEOUT as eY,LINE_CONFIRM_THRESHOLD as bb,MIME_TYPES as lo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as tY,POINTER_BUTTON as Gn,ROUNDNESS as jp,SCROLL_TIMEOUT as nY,TAP_TWICE_TIMEOUT as aM,TEXT_TO_CENTER_SNAP_THRESHOLD as oY,THEME as mc,TOUCH_CTX_MENU_TIMEOUT as rY,VERTICAL_ALIGN as iY,YOUTUBE_STATES as qp,ZOOM_STEP as aY,MIN_ZOOM as sY,POINTER_EVENTS as cs,TOOL_TYPE as Hn,supportsResizeObserver as lY,DEFAULT_COLLISION_THRESHOLD as sM,DEFAULT_TEXT_ALIGN as cY,ARROW_TYPE as Mr,DEFAULT_REDUCED_GLOBAL_ALPHA as dY,isLocalLink as mY,normalizeLink as Jp,toValidURL as pY,getGridPoint as Mt,getLineHeight as lM,debounce as cM,distance as ds,getFontString as xb,getNearestScrollableContainer as uY,isInputLike as dM,isToolIcon as hY,isWritableElement as pc,sceneCoordsToViewportCoords as Qp,tupleToCoors as yb,viewportCoordsToSceneCoords as Me,wrapEvent as gY,updateObject as wb,updateActiveTool as nn,isTransparent as fY,muteFSAbortError as EY,isTestEnv as QM,isDevEnv as e3,updateStable as uc,addEventListener as ve,normalizeEOL as bY,getDateTime as mM,isShallowEqual as pM,arrayToMap as hc,applyDarkModeFilter as xY,AppEventBus as yY,randomInteger as wY,CLASSES as vb,Emitter as co,MINIMUM_ARROW_SIZE as vY,DOUBLE_TAP_POSITION_THRESHOLD as uM,BIND_MODE_TIMEOUT as IY,invariant as mo,getFeatureFlag as Bo,createUserAgentDescriptor as t3,getFormFactor as TY,deriveStylesPanelMode as mu,isIOS as SY,isBrave as CY,isSafari as PY,loadDesktopUIModePreference as kY,setDesktopUIMode as MY,isSelectionLikeTool as eu,oneOf as hM,getStrokeWidthByKey as AY}from"@excalidraw/common";import{getObservedAppState as DY,getCommonBounds as ms,getElementAbsoluteCoords as gM,bindOrUnbindBindingElements as fM,fixBindingsAfterDeletion as LY,getHoveredElementForBinding as Ar,isBindingEnabled as tu,updateBoundElements as nu,LinearElementEditor as fe,newElementWith as po,newFrameElement as _Y,newFreeDrawElement as RY,newEmbeddableElement as EM,newMagicFrameElement as NY,newIframeElement as BY,newArrowElement as FY,newElement as OY,newImageElement as zY,newLinearElement as GY,newTextElement as bM,refreshTextDimensions as HY,deepCopyElement as xM,duplicateElements as yM,hasBoundTextElement as wM,isArrowElement as gc,isBindingElement as uo,isBindingElementType as UY,isBoundToContainer as vM,isFrameLikeElement as Tt,isImageElement as Un,isEmbeddableElement as Fo,isInitializedImageElement as yi,isLinearElement as zt,isLinearElementType as WY,isUsingAdaptiveRadius as VY,isIframeElement as Ib,isIframeLikeElement as fc,isTextBindableContainer as IM,isElbowArrow as Xt,isBindableElement as Tb,isTextElement as Kt,getNormalizedDimensions as YY,isElementCompletelyInViewport as XY,isElementInViewport as TM,isInvisiblySmallElement as SM,generateThumbHash as KY,getCornerRadius as $Y,isPathALoop as CM,embeddableURLValidator as Sb,maybeParseEmbedSrc as ZY,getEmbedLink as ou,getInitializedImageElements as jY,normalizeSVG as PM,updateImageCache as Cb,getBoundTextElement as Pb,getContainerCenter as kb,getContainerElement as kM,isValidTextContainer as MM,redrawTextBoundingBox as qY,hasBoundingBox as JY,getCommonFrameId as AM,getFrameChildren as Mb,getFrameChildrenInsertionIndex as QY,isCursorInFrame as DM,addElementsToFrame as Ab,replaceAllElementsInFrame as eX,removeElementsFromFrame as tX,getElementsInResizingFrame as Db,getElementsInNewFrame as nX,getContainingFrame as Lb,elementOverlapsWithFrame as oX,updateFrameMembershipOfSelectedElements as LM,isElementInFrame as _M,getFrameLikeTitle as rX,filterElementsEligibleAsFrameChildren as iX,hitElementBoundText as aX,hitElementBoundingBoxOnly as sX,hitElementItself as Ec,getVisibleSceneBounds as lX,cropElement as cX,wrapText as dX,isElementLink as RM,isMeasureTextSupported as mX,normalizeText as pX,measureText as NM,getLineHeightInPx as BM,getApproxMinLineWidth as uX,getApproxMinLineHeight as hX,getMinTextElementWidth as gX,ShapeCache as wi,getRenderOpacity as fX,editGroupForSelectedElement as EX,getElementsInGroup as vi,getSelectedGroupIdForElement as bX,getSelectedGroupIds as xX,isElementInGroup as FM,isSelectedViaGroup as yX,selectGroupsForSelectedElements as Wn,syncInvalidIndices as n3,syncMovedIndices as OM,excludeElementsInFramesFromSelection as wX,getSelectionStateForElements as zM,makeNextSelectedElementIds as De,getResizeOffsetXY as vX,getResizeArrowDirection as IX,transformElements as TX,getCursorForResizingElement as GM,getElementWithTransformHandleType as HM,getTransformHandleTypeFromCoords as UM,dragNewElement as WM,dragSelectedElements as SX,getDragOffsetXY as CX,Scene as VM,Store as PX,CaptureUpdateAction as $t,hitElementBoundingBox as kX,isLineElement as _b,isSimpleArrow as Rb,StoreDelta as YM,positionElementsOnGrid as XM,calculateFixedPointForNonElbowArrowBinding as KM,bindOrUnbindBindingElement as MX,mutateElement as ru,getElementBounds as $M,doBoundsIntersect as AX,isPointInElement as ZM,maxBindingDistance_simple as jM,convertToExcalidrawElements as DX,getSnapOutlineMidPoint as Nb,handleFocusPointDrag as LX,handleFocusPointHover as _X,handleFocusPointPointerDown as RX,handleFocusPointPointerUp as NX,maybeHandleArrowPointlikeDrag as iu,getUncroppedWidthAndHeight as BX,getActiveTextElement as qM,isEligibleFrameChildType as FX,getBindingStrategyForDraggingBindingElementEndpoints as OX,isNonDeletedElement as au}from"@excalidraw/element";import{KEYS as ih,MOBILE_ACTION_BUTTON_BG as B3,updateActiveTool as F3}from"@excalidraw/common";import{getNonDeletedElements as ed}from"@excalidraw/element";import{fixBindingsAfterDeletion as O3}from"@excalidraw/element";import{LinearElementEditor as v0}from"@excalidraw/element/linearElementEditor";import{newElementWith as Qc}from"@excalidraw/element";import{getContainerElement as I0}from"@excalidraw/element";import{isBoundToContainer as qc,isElbowArrow as z3,isFrameLikeElement as G3}from"@excalidraw/element";import{getFrameChildren as H3}from"@excalidraw/element";import{getElementsInGroup as ah,selectGroupsForSelectedElements as U3}from"@excalidraw/element";import{CaptureUpdateAction as Jc}from"@excalidraw/element";import{isDevEnv as C3}from"@excalidraw/common";import{atom as Qe,createStore as I3}from"jotai";import{createIsolation as T3}from"jotai-scope";var Cx=T3();var{useAtom:He,useSetAtom:Px,useAtomValue:kx,useStore:IK}=Cx,Mx=Cx.Provider,Et=I3();var S3=tx({"./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-RNZ7CUK6.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 P3=85,Xn={code:"en",label:"English"},Di=[Xn,...[{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=>nx[e.code]>=P3).sort((e,n)=>e.label>n.label?1:-1)],Bc="__test__";C3()&&Di.unshift({code:Bc,label:"test language"},{code:`${Bc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ai=Xn,Nc={},Fc=async e=>{if(Ai=e,document.documentElement.dir=Ai.rtl?"rtl":"ltr",document.documentElement.lang=Ai.code,e.code.startsWith(Bc))Nc={};else try{Nc=await S3(`./locales/${Ai.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Nc=yu}Et.set(Dx,e.code)},Kn=()=>Ai,Ax=(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(Ai.code.startsWith(Bc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=Ax(Nc,o)||Ax(yu,o)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(S.PROD)return console.warn(i),"";throw new Error(i)}if(n)for(let i in n)r=r.replace(`{{${i}}}`,String(n[i]));return r},Dx=Qe(Xn.code),_e=()=>{let e=kx(Dx);return{t:f,langCode:e}};import k3 from"clsx";import et from"react";import{THEME as M3}from"@excalidraw/common";import{Fragment as Te,jsx as h,jsxs as R}from"react/jsx-runtime";var Cn=e=>"var(--icon-fill-color)",Lx=e=>e===M3.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:k3({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ae={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Dt={width:40,height:20},OK=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),zK=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),_x=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),Ts=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),Rx=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),Nx=A(R("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),H),ku=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),H),bo=A(R("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),ae),Ko=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),ae),Bx=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}),Fx=A(R(Te,{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"}),Ox=A(R(Te,{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"}),zx=A(R(Te,{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"}),GK=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"}),Oc=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}),Li=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}),_i=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),Ri=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),Ni=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),zc=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"}),ae),Gx=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),$n=A(R("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),ae),Pn=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),Hx=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),Fr=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),ae),Gc=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),Mu=A(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ae),Au=A(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ae),Ux=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),Or=A(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),ae),Zo=A(R("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),ae),Ss=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),ae),Cs=A(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),ae),Ps=A(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...ae,strokeWidth:1.5}),Wx=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),ks=A(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),ae),Bi=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),Vx=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),HK=A(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),ae),Yx=A(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),ae),Xx=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),ae),Kx=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),Hc=A(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Ms=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),ae),$x=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}),Zx=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}),Uc=A(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),ae),UK=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}),WK=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"),Du=["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"],Zn=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Du.map(e=>h("path",{d:e},e))]}),H),jx=A(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),qx=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),Jx=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}),VK=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}),YK=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}),Qx=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"),XK=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"),Lu=A(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),ae),_u=A(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),ae),e1=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}),t1=A(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),ae),KK=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"),$K=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}),ZK=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),jK=A(R(Te,{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}),qK=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}),n1=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"})]}),o1=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"})]}),Ru=A(o1,H),Nu=A(o1,{...H,style:{transform:"rotate(180deg)"}}),Bu=A(n1,H),Fu=A(n1,{...H,style:{transform:"rotate(180deg)"}}),Ou=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),zu=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Gu=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Hu=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),r1=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),i1=A(R(Te,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Uu=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),ae),Wu=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),ae),Wc=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),JK=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"),QK=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(Te,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),e$=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}),t$=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}),n$=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}),Vu=et.memo(({theme:e})=>A(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:Cn(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:Cn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Cn(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:Cn(e),strokeWidth:"2"}),R("g",{fill:Lx(e),stroke:Cn(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})),Yu=et.memo(({theme:e})=>A(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:Cn(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:Cn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Cn(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:Cn(e),strokeWidth:"2"}),R("g",{fill:Lx(e),stroke:Cn(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})),a1=A(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),ae),s1=A(R(Te,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),ae),l1=A(R(Te,{children:[R("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),c1=A(R(Te,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...ae,fill:"currentColor"}),Xu=A(h(Te,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ae),d1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ae),m1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ae),o$=et.memo(({theme:e})=>A(h("path",{d:"M6 10H34",stroke:Cn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),p1=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),u1=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),h1=A(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),ae),g1=A(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),ae),f1=A(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),ae),Ku=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),$u=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),E1=A(R("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),ae),b1=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),x1=et.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"})]}),Dt)),y1=et.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"})}),Dt)),w1=et.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"})]}),Dt)),v1=et.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"})]}),Dt)),I1=et.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"})]}),Dt)),T1=et.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"})]}),Dt)),S1=et.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"})]}),Dt)),C1=et.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"})]}),Dt)),P1=et.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"})}),Dt)),k1=et.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"})}),Dt)),M1=et.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"})}),Dt)),A1=et.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"})}),Dt)),D1=et.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"})}),Dt)),L1=et.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"})]}),Dt)),_1=et.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"})]}),Dt)),R1=A(R(Te,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),N1=A(R(Te,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),B1=A(R(Te,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),F1=A(h(Te,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ae),zr=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),O1=A(h(Te,{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),As=A(h(Te,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),ae),A3=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),Vc=A3,z1=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),G1=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),H1=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),U1=et.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)),W1=et.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)),V1=et.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)),Yc=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),r$=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}),i$=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"})),Y1=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),Zu=A(R(Te,{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),X1=A(R(Te,{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),K1=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),$1=A(R(Te,{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),a$=A(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),s$=A(R(Te,{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),Z1=A(R(Te,{children:[h("path",{d:"M7 5v14"}),h("path",{d:"M19 6l-9 6l9 6z"})]}),H),j1=A(R(Te,{children:[h("path",{d:"M17 5v14"}),h("path",{d:"M5 6l9 6l-9 6z"})]}),H),q1=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),J1=A(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),Q1=A(R(Te,{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),ju=["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"],Fi=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ju.map(e=>h("path",{d:e},e))]}),H),jn=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),l$=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),c$=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),d$=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),ae),Gr=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),qn=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),m$=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),p$=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),u$=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),h$=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),Hr=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),e0=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),g$=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),f$=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),Jn=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),E$=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),b$=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),t0=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),n0=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),x$=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),o0=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),r0=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),i0=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),a0=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),qu=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),Xc=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),s0=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),l0=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),jo=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),y$=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),c0=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}),w$=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),v$=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),d0=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),m0=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),qo=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),Jo=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),Qo=A(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),Kc=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),p0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),u0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),Ju=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),h0=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),Qu=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),eh=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),h("polyline",{points:"2 8 3 6 4 8"}),h("polyline",{points:"2 12 3 14 4 12"}),h("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),h("polyline",{points:"9 17 7 18 9 19"}),h("polyline",{points:"15 17 17 18 15 19"})]}),H),I$=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),h("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),H),th=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"})})),g0=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),f0=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),nh=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),T$=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),S$=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),C$=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),P$=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),$c=h("div",{style:{width:"1rem",height:"1rem"}}),E0=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),b0=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),x0=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 y0 from"clsx";import rh,{useEffect as _3,useRef as w0,useState as R3}from"react";import{isPromiseLike as N3}from"@excalidraw/common";import D3 from"react";import{jsx as oh}from"react/jsx-runtime";var L3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(D3.useRef(Date.now()).current%1600);return oh("div",{className:`Spinner ${o}`,children:oh("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:oh("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},xo=L3;import{jsx as Ds,jsxs as Zc}from"react/jsx-runtime";var Z=rh.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=rh.useRef(null);rh.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=R3(!1),c=w0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if(N3(u))try{l(!0),await u}catch(E){if(E instanceof Pc)console.warn(E);else throw E}finally{c.current&&l(!1)}};_3(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=w0(null);return o.type==="button"||o.type==="icon"?Zc("button",{className:y0("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)&&Zc("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&Ds("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&Ds(xo,{})]}),o.showAriaLabel&&Zc("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&Ds(xo,{})]}),o.children]}):Ds("button",{className:y0("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:Zc("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&Ds("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});Z.displayName="IconButton";var jc=[],O=e=>(jc=jc.concat(e),e);import{jsx as V3}from"react/jsx-runtime";var W3=(e,n,t)=>{let o=new Set(ce(e.filter(d=>G3(d)),n).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of o){let m=H3(e,d);for(let p of m)if(!a.has(p.id)){if(qc(p)){let u=I0(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=qc(d)?I0(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&&z3(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),Qc(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,qc(d)||(r[d.id]=!0),Qc(d,{frameId:null})):qc(d)&&n.selectedElementIds[d.containerId]?Qc(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=ah(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=ah(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...U3({selectedElementIds:r,editingGroupId:c},ed(l),n,null)}}},T0=(e,n)=>{if(e.editingGroupId){let t=ah(ed(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Ls=O({name:"deleteSelectedElements",label:"labels.delete",icon:Or,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=v0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?Qc(p,{isDeleted:!0}):p),m=T0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:Jc.IMMEDIATELY}}return v0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:Jc.IMMEDIATELY}}let{elements:r,appState:i}=W3(e,n,o);return O3(r,r.filter(a=>a.isDeleted)),i=T0(i,r),{elements:r,appState:{...i,activeTool:F3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Le(ed(e),n)?Jc.IMMEDIATELY:Jc.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===ih.BACKSPACE||e.key===ih.DELETE)&&!e[ih.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ct()==="mobile";return V3(Z,{type:"button",icon:Or,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Le(ed(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?B3:{}}})}});import{KEYS as Oi,CODES as zi,isDarwin as td}from"@excalidraw/common";import{moveOneLeft as Y3,moveOneRight as X3,moveAllLeft as K3,moveAllRight as $3}from"@excalidraw/element";import{CaptureUpdateAction as nd}from"@excalidraw/element";import{isDarwin as S0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,S0?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,S0?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 od}from"react/jsx-runtime";var sh=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Nu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Y3(e,n,o.scene),appState:n,captureUpdate:nd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Oi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===zi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Nu})}),lh=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Ru,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:X3(e,n,o.scene),appState:n,captureUpdate:nd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Oi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===zi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Ru})}),ch=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Fu,trackEvent:{category:"element"},perform:(e,n)=>({elements:K3(e,n),appState:n,captureUpdate:nd.IMMEDIATELY}),keyTest:e=>td?e[Oi.CTRL_OR_CMD]&&e.altKey&&e.code===zi.BRACKET_LEFT:e[Oi.CTRL_OR_CMD]&&e.shiftKey&&e.code===zi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${td?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Fu})}),dh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Bu,trackEvent:{category:"element"},perform:(e,n)=>({elements:$3(e,n),appState:n,captureUpdate:nd.IMMEDIATELY}),keyTest:e=>td?e[Oi.CTRL_OR_CMD]&&e.altKey&&e.code===zi.BRACKET_RIGHT:e[Oi.CTRL_OR_CMD]&&e.shiftKey&&e.code===zi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${td?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Bu})});import{getNonDeletedElements as Z3}from"@excalidraw/element";import{LinearElementEditor as j3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as q3,isTextElement as J3}from"@excalidraw/element";import{arrayToMap as Q3,KEYS as C0}from"@excalidraw/common";import{selectGroupsForSelectedElements as eA}from"@excalidraw/element";import{CaptureUpdateAction as tA}from"@excalidraw/element";var mh=O({name:"selectAll",label:"labels.selectAll",icon:o0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(J3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...eA({editingGroupId:null,selectedElementIds:r},Z3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&q3(e[0])?new j3(e[0],Q3(e)):null},captureUpdate:tA.IMMEDIATELY}},keyTest:e=>e[C0.CTRL_OR_CMD]&&e.key===C0.A});import{DEFAULT_GRID_SIZE as P0,KEYS as k0,MOBILE_ACTION_BUTTON_BG as nA,arrayToMap as M0}from"@excalidraw/common";import{getNonDeletedElements as A0}from"@excalidraw/element";import{LinearElementEditor as oA}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as rA,getSelectionStateForElements as iA}from"@excalidraw/element";import{syncMovedIndices as aA}from"@excalidraw/element";import{duplicateElements as sA}from"@excalidraw/element";import{CaptureUpdateAction as D0}from"@excalidraw/element";import{jsx as lA}from"react/jsx-runtime";var ph=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Ss,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=oA.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:D0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=sA({type:"in-place",elements:e,idsOfElementsToDuplicate:M0(rA(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+P0/2,y:a.y+P0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:aA(i,M0(r)),appState:{...n,...iA(r,A0(i),n)},captureUpdate:D0.IMMEDIATELY}},keyTest:e=>e[k0.CTRL_OR_CMD]&&e.key===k0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ct()==="mobile";return lA(Z,{type:"button",icon:Ss,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Le(A0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?nA:{}}})}});import{pointFrom as H4}from"@excalidraw/math";import{useEffect as _h,useMemo as Bh,useRef as Rh,useState as U4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as W4,COLOR_PALETTE as V4,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Oy,DEFAULT_ELEMENT_BACKGROUND_PICKS as Y4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as X4,DEFAULT_ELEMENT_STROKE_PICKS as K4,ARROW_TYPE as dn,DEFAULT_FONT_FAMILY as $4,DEFAULT_FONT_SIZE as Z4,FONT_FAMILY as j4,ROUNDNESS as Td,STROKE_WIDTH_KEYS as q4,VERTICAL_ALIGN as vd,KEYS as Zi,randomInteger as J4,arrayToMap as Fh,getFontFamilyString as Q4,getLineHeight as e6,isTransparent as t6,getStrokeWidthByKey as zy,reduceToCommonValue as n6,invariant as Cd,FONT_SIZES as Id}from"@excalidraw/common";import{canBecomePolygon as o6,getNonDeletedElements as Gy,isNonDeletedElement as r6}from"@excalidraw/element";import{bindBindingElement as _y,calculateFixedPointForElbowArrowBinding as Ry,updateBoundElements as i6}from"@excalidraw/element";import{LinearElementEditor as Wr}from"@excalidraw/element/linearElementEditor";import{newElementWith as at}from"@excalidraw/element";import{getArrowheadForPicker as Ny}from"@excalidraw/element";import{getBoundTextElement as sr,redrawTextBoundingBox as Ys}from"@excalidraw/element";import{isArrowElement as Sd,isBoundToContainer as a6,isElbowArrow as Hy,isLinearElement as Nh,isLineElement as By,isTextElement as Ht,isUsingAdaptiveRadius as s6}from"@excalidraw/element";import{hasStrokeColor as l6}from"@excalidraw/element";import{updateElbowArrowPoints as c6,CaptureUpdateAction as tt,toggleLinePolygonState as d6}from"@excalidraw/element";import{deriveStylesPanelMode as m6}from"@excalidraw/common";import{isDevEnv as cA}from"@excalidraw/common";var dA=new Set(["command_palette","export"]),Fe=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!dA.has(e)||cA())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 hA from"clsx";import mA from"clsx";import{forwardRef as pA}from"react";import{jsx as uA}from"react/jsx-runtime";var L0=pA((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return uA("button",{type:"button",ref:n,title:t,"data-testid":r,className:mA(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as fA,jsx as uh,jsxs as gA}from"react/jsx-runtime";var jt=e=>uh(fA,{children:e.options.map(n=>e.type==="button"?uh(L0,{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):gA("label",{className:hA({active:e.value===n.value}),title:n.text,children:[uh("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 my}from"radix-ui";import py from"clsx";import{memo as F5,useRef as uy,useEffect as O5}from"react";import{applyDarkModeFilter as z5,COLOR_OUTLINE_CONTRAST_THRESHOLD as cy,COLOR_PALETTE as hy,DEFAULT_ELEMENT_BACKGROUND_PICKS as G5,DEFAULT_ELEMENT_STROKE_PICKS as H5,isColorDark as dy,isWritableElement as U5,THEME as W5}from"@excalidraw/common";import{jsx as EA}from"react/jsx-runtime";var rd=()=>EA("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as IA,useLayoutEffect as TA,useRef as SA}from"react";import{createPortal as CA}from"react-dom";import{EVENT as er,isColorDark as PA,KEYS as kA,MIME_TYPES as MA,THEME as AA,removeDarkModeFilter as DA,rgbToHex as LA}from"@excalidraw/common";import _0 from"react";var hh=_0.createContext(null),ye=()=>_0.useContext(hh);import{useState as bA,useLayoutEffect as R0}from"react";import{THEME as xA}from"@excalidraw/common";var id=e=>{let[n,t]=bA(null),o=be(),{theme:r}=ye(),{container:i}=Ne();return R0(()=>{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===xA.DARK))},[n,r,o.formFactor,e?.className]),R0(()=>{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 yA}from"react";import{EVENT as ad}from"@excalidraw/common";function Gi(e,n,t){yA(()=>{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(ad.POINTER_DOWN,o),document.addEventListener(ad.TOUCH_START,o),()=>{document.removeEventListener(ad.POINTER_DOWN,o),document.removeEventListener(ad.TOUCH_START,o)}},[e,n,t])}import{useRef as wA}from"react";var Hi=e=>{let n=wA(e);return Object.assign(n.current,e),n.current};import{clamp as vA}from"@excalidraw/math";var N0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return vA(r,0,Math.max(0,t-n))},sd=({cursor:e,element:n,container:t,gap:o})=>({left:N0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:N0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as RA}from"react/jsx-runtime";var B0=ju.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),_A=`url(data:${MA.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">${B0}</g><g stroke="#1b1b1f" stroke-width="1.25">${B0}</g></svg>`)}) 2 21, auto`,Gt=Qe(null),F0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=id({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ye(),a=Ui(),s=St(),l=ce(a,i),c=Hi({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=Ne();TA(()=>{if(r)return r.style.cursor=_A,()=>{r.style.cursor=""}},[r]),IA(()=>{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 LA(D[0],D[1],D[2])},b=P=>i.theme===AA.DARK?DA(P):P,w=({clientX:P,clientY:M,altKey:D})=>{let{top:_,left:k}=sd({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",PA(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===kA.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(er.KEYDOWN,C),r.addEventListener(er.POINTER_DOWN,I),r.addEventListener(er.POINTER_UP,T),window.addEventListener("pointermove",w,{passive:!0}),window.addEventListener(er.BLUR,y),()=>{u=!1,r.removeEventListener(er.KEYDOWN,C),r.removeEventListener(er.POINTER_DOWN,I),r.removeEventListener(er.POINTER_UP,T),window.removeEventListener("pointermove",w),window.removeEventListener(er.BLUR,y)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=SA(null);return Gi(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?CA(RA("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as gh}from"radix-ui";import OA from"clsx";import zA from"react";import{isInteractive as GA}from"@excalidraw/common";import NA from"react";import BA from"clsx";import{jsx as FA}from"react/jsx-runtime";var Ue=NA.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>FA("div",{className:BA("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as fh,jsxs as HA}from"react/jsx-runtime";var yo=zA.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=be(),p=m.formFactor==="phone"&&!m.isLandscape;return fh(gh.Portal,{container:n,children:HA(gh.Content,{ref:d,className:OA("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&&!GA(document.activeElement)&&n.focus(),r()},children:[fh(Ue,{padding:3,style:o,children:t}),fh(gh.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 UA,useCallback as Eh}from"react";var ld=()=>document.querySelector(".excalidraw-wysiwyg"),cd=()=>{let e=ld();return e?{start:e.selectionStart,end:e.selectionEnd}:null},_s=e=>{setTimeout(()=>{let n=ld();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},Rs=(e,n,t,o)=>{n&&o&&o();let r=n&&t?cd():null;e(),n&&t&&_s(r)},O0=()=>{let[e,n]=UA(null),t=Eh(()=>{let i=cd();n(i)},[]),o=Eh(()=>{setTimeout(()=>{let i=ld();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=Eh(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},z0=(e=100)=>{let n=ld();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import H0 from"clsx";import{useCallback as YA,useEffect as xh,useRef as U0,useState as W0}from"react";import{KEYS as yh,normalizeInputColor as XA}from"@excalidraw/common";import{isTransparent as WA,MAX_CUSTOM_COLORS_USED_IN_CANVAS as VA}from"@excalidraw/common";var tr=({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},Ns=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),bh=({color:e,palette:n})=>!Object.values(n).flat().includes(e),G0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!WA(s)&&bh({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,VA)},sn=Qe(null);import{Fragment as KA,jsx as Bs,jsxs as wh}from"react/jsx-runtime";var V0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=be(),[a,s]=W0(e),[l,c]=W0(null),[d,m]=He(sn);xh(()=>{s(e)},[e]);let p=YA(w=>{let y=w.toLowerCase().trim(),x=XA(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=U0(null),E=U0(null);xh(()=>{u.current&&u.current.focus()},[d]);let[g,b]=He(Gt);return xh(()=>()=>{b(null)},[b]),wh("div",{className:"color-picker__input-label-container",children:[wh("div",{className:H0("color-picker__input-label",{"has-error":l}),children:[Bs("div",{className:"color-picker__input-hash",children:"#"}),Bs("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!==yh.TAB&&(w.key===yh.ESCAPE&&E.current?.focus(),w.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&wh(KA,{children:[Bs("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Bs("div",{ref:E,className:H0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(w=>w?null:{keepOpenOnAlt:!1,onSelect:y=>n(y),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${yh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:Fi})]})]}),l&&Bs("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import Th,{useEffect as Sh,useImperativeHandle as S5,useState as C5}from"react";import{EVENT as ry}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as P5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as k5,KEYS as M5}from"@excalidraw/common";import n5 from"clsx";import{useEffect as o5,useRef as r5}from"react";import{applyDarkModeFilter as i5,THEME as a5}from"@excalidraw/common";import{isColorDark as $A}from"@excalidraw/common";import{jsxs as jA}from"react/jsx-runtime";var ZA=({color:e,keyLabel:n,isShade:t=!1})=>jA("div",{className:"color-picker__button__hotkey-label",style:{color:$A(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),Wi=ZA;import{createContext as qA,useContext as JA,useEffect as QA,useMemo as Y0,useRef as X0,useState as e5}from"react";import{colorToHex as K0,isTransparent as t5}from"@excalidraw/common";var Ur="excalidraw-color-dnd-ghost",$0="excalidraw-color-dnd-active",Z0=10,j0=100,q0=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=K0(e);return t!==null&&t===K0(n)},vh=qA(null),ln=()=>JA(vh),J0=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=e5(null),i=X0(null),a=X0({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=Y0(()=>{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((V,G)=>Number(V.dataset.topPickIndex)-Number(G.dataset.topPickIndex));if(!L.length)return!1;l.slotRects=L.map(V=>V.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=Ur;let V=document.createElement("div");if(V.className=`${Ur}__swatch`,t5(z))V.classList.add("is-transparent");else{let G=getComputedStyle(Y).backgroundColor;V.style.backgroundColor=G&&G!=="rgba(0, 0, 0, 0)"?G:z}U.appendChild(V),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(`${Ur}--lifted`)}),document.body.classList.add($0),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 V=0,G=1/0;if(Y.forEach((re,B)=>{let W=Math.abs(k-(re.left+re.width/2));W<G&&(G=W,V=B)}),l.origin.kind==="swatch"){let re=a.current.picks.findIndex(B=>q0(B,l.color));re!==-1?U=re:z=V}else z=V}if(z!==l.overIndex||U!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=U;let{ghost:V}=l;V&&(V.classList.toggle(`${Ur}--over`,z!==null),V.classList.toggle(`${Ur}--blocked`,U!==null)),c()}if(z!==null){let V=l.slotRects[z];p(V.width,V.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(`${Ur}--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(`${Ur}--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($0),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)<Z0){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let L=performance.now()-l.startTime;if(L<j0){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=Z0&&T(l.lastX,l.lastY))},j0-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:V}=a.current;if(b(),L!==null){if(F.kind==="swatch"){if(!U.some(G=>q0(G,Y))){let G=[...U];G[L]=Y,V(G)}}else if(F.index!==L){let G=[...U],[re]=G.splice(F.index,1);G.splice(L,0,re),V(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 QA(()=>()=>s.destroy(),[s]),Y0(()=>({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 Ih,jsxs as s5}from"react/jsx-runtime";var Q0=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=He(sn),s=ln(),l=r5(null);return o5(()=>{l.current&&l.current.focus()},[t,i]),Ih("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=i5(c,e===a5.DARK);return s5("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:n5("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:[Ih("div",{className:"color-picker__button-outline"}),Ih(Wi,{color:m,keyLabel:d+1})]},d)})})};import l5 from"clsx";import{useEffect as c5,useRef as d5}from"react";import{applyDarkModeFilter as m5,isColorDark as p5,THEME as u5}from"@excalidraw/common";import{jsx as dd,jsxs as g5}from"react/jsx-runtime";var h5=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=tr({color:t,palette:n}),[l,c]=He(sn),d=ln(),m=d5(null);return c5(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),dd("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 dd("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=Ns[E],w=m5(g,e===u5.DARK),y=f(`colors.${p.replace(/\d+/,"")}`,null,"");return g5("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:l5("color-picker__button color-picker__button--large",{"has-outline":!p5(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:[dd("div",{className:"color-picker__button-outline"}),i&&dd(Wi,{color:w,keyLabel:b})]},p)})})},ey=h5;import{jsx as E5}from"react/jsx-runtime";var f5=({children:e})=>E5("div",{className:"color-picker__heading",children:e}),Vi=f5;import b5 from"clsx";import{useEffect as x5,useRef as y5}from"react";import{applyDarkModeFilter as w5,THEME as v5}from"@excalidraw/common";import{jsx as Fs,jsxs as ty}from"react/jsx-runtime";var ny=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=tr({color:n||"transparent",palette:o}),[a,s]=He(sn),l=ln(),c=y5(null);if(x5(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return Fs("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=w5(u,e===v5.DARK);return ty("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:b5("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:[Fs("div",{className:"color-picker__button-outline"}),r&&Fs(Wi,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return ty("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Fs("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Fs("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 Yi,COLOR_PALETTE as I5,KEYS as Os}from"@excalidraw/common";var md=(e,n,t)=>{let o=Math.ceil(t/Yi);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+Yi;return r>=t?n%Yi:r}case"ArrowUp":{let r=n-Yi,i=r<0?Yi*o+r:r;return i>=t?void 0:i}}},T5=({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(Ns.includes(e.key)){let l=Ns.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},oy=({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[Os.CTRL_OR_CMD])return!1;if(e.key===Os.ESCAPE)return d(e),!0;if(e.key===Os.ALT)return c(!0),!0;if(e.key===Os.I)return c(),!0;let p=tr({color:o,palette:t});if(e.key===Os.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(I5.black)),e.preventDefault(),e.stopPropagation(),!0}if(T5({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=md(e.key,u,Yi);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=md(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=md(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=md(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as wo,jsxs as pd}from"react/jsx-runtime";var iy=Th.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]=Th.useState(()=>o==="canvasBackground"?[]:G0(r,o,i)),[b,w]=He(sn),y=ln(),x=tr({color:n,palette:i});Sh(()=>{if(!b){let P=!!n&&bh({color:n,palette:i}),M=P&&!g.includes(n);w(M?null:P?"custom":x?.shade!=null?"shades":"baseColors")}},[b,n,i,w,x,g]);let[I,T]=C5(x?.shade??(o==="elementBackground"?P5:k5));Sh(()=>{x?.shade!=null&&T(x.shade);let P=M=>{M.key===M5.ALT&&c(!1)};return document.addEventListener(ry.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(ry.KEYUP,P,{capture:!0})}},[x,c]);let C=Th.useRef(null);return S5(u,()=>C.current),Sh(()=>{C?.current?.focus()},[]),wo("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:pd("div",{ref:C,onKeyDown:P=>{oy({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&&wo("div",{className:"color-picker__title",children:E}),!!g.length&&pd("div",{children:[wo(Vi,{children:f("colorPicker.mostUsedCustomColors")}),wo(Q0,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),pd("div",{children:[wo(Vi,{children:f("colorPicker.colors")}),wo(ey,{theme:e,color:n,palette:i,onChange:t,activeShade:I,showHotKey:m,excludedColors:p})]}),pd("div",{children:[wo(Vi,{children:f("colorPicker.shades")}),wo(ny,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,y&&wo("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import ay from"clsx";import{ContextMenu as zs}from"radix-ui";import{applyDarkModeFilter as A5,COLOR_OUTLINE_CONTRAST_THRESHOLD as D5,DEFAULT_CANVAS_BACKGROUND_PICKS as L5,DEFAULT_ELEMENT_BACKGROUND_PICKS as _5,DEFAULT_ELEMENT_STROKE_PICKS as R5,isColorDark as N5,THEME as B5}from"@excalidraw/common";import{jsx as nr,jsxs as sy}from"react/jsx-runtime";var ly=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=ln(),l=s?.dragState??null,{container:c}=Ne(),d;if(t==="elementStroke"&&(d=R5),t==="elementBackground"&&(d=_5),t==="canvasBackground"&&(d=L5),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=sy("div",{className:ay("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&nr("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:nr("rect",{})}),d.map((u,E)=>{let g=m(E),b=A5(u,e===B5.DARK);return nr("button",{className:ay("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!N5(u,D5),"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:nr("div",{className:"color-picker__button-outline"})},u)})]});return i?sy(zs.Root,{children:[nr(zs.Trigger,{asChild:!0,children:p}),nr(zs.Portal,{container:c,children:nr(zs.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:nr(zs.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as cn,jsxs as ud}from"react/jsx-runtime";var V5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=hy,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=Ne(),m=ct(),p=m!=="full",u=m==="mobile",[,E]=He(sn),[g,b]=He(Gt),w=ud("div",{children:[cn(Vi,{children:f("colorPicker.hexCode")}),cn(V0,{color:n||"",label:o,onChange:I=>{t(I)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),y=uy(null),x=()=>{y.current?.focus()};return cn(yo,{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}U5(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(iy,{ref:y,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:I=>{let T=l.editingTextElement?cd():null;t(I),l.editingTextElement&&T&&_s(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})},Y5=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",X5=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=ct(),l=s!=="full",c=s==="mobile",d=ln(),m=n?z5(n,o===W5.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&z0(),i()};return ud(my.Trigger,{type:"button",className:py("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!dy(n,cy),"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&&jx}),l&&n&&r==="stroke"&&cn("div",{className:"color-picker__button-background",children:cn("span",{style:{color:m&&dy(m,cy)?"#fff":"#111"},children:f0})})]})},K5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=hy,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=uy(l.openPopup);O5(()=>{m.current=l.openPopup},[l.openPopup]);let u=ct()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?H5:G5),w=J0({enabled:E,picks:b,onPicksChange:y=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:y}})}});return cn(vh.Provider,{value:E?w:null,children:ud("div",{role:"dialog","aria-modal":"true",className:py("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&cn(ly,{theme:l.theme,activeColor:n,onChange:y=>{t(y),Y5(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(rd,{}),ud(my.Root,{open:l.openPopup===e,onOpenChange:y=>{y&&s({openPopup:e})},children:[cn(X5,{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(V5,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},$5=(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,Xi=F5(K5,$5);import{Popover as v4}from"radix-ui";import I4 from"clsx";import T4,{useCallback as S4,useMemo as C4}from"react";import{FONT_FAMILY as Mh}from"@excalidraw/common";import p4,{useMemo as ir,useState as u4,useRef as by,useEffect as xy,useCallback as yy}from"react";import{arrayToList as h4,debounce as g4,FONT_FAMILY as ar,getFontFamilyString as f4}from"@excalidraw/common";import Z5 from"clsx";import j5 from"react";import{jsx as q5,jsxs as J5}from"react/jsx-runtime";var hd=j5.forwardRef(({className:e,placeholder:n,onChange:t},o)=>J5("div",{className:Z5("QuickSearch__wrapper",e),children:[Jn,q5("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import Q5 from"clsx";import{Children as e4}from"react";import{jsx as gy}from"react/jsx-runtime";var gd=({className:e,placeholder:n,children:t})=>{let o=!e4.count(t);return gy("div",{className:Q5("ScrollableList__wrapper",e),role:"menu",children:o?gy("div",{className:"empty",children:n}):t})};import{jsx as t4,jsxs as n4}from"react/jsx-runtime";var fy=({children:e,className:n="",style:t,title:o})=>n4("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&t4("p",{className:"dropdown-menu-group-title",children:o}),e]}),Gs=fy;fy.displayName="DropdownMenuGroup";import{THEME as d4}from"@excalidraw/common";import{DropdownMenu as m4}from"radix-ui";import o4,{useContext as r4}from"react";import{composeEventHandlers as i4}from"@excalidraw/common";var Ch=o4.createContext({}),or=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),fd=e=>{let n=r4(Ch);return i4(e,t=>{n.onSelect?.(t)})};import{jsx as a4}from"react/jsx-runtime";var Hs=({children:e,...n})=>a4("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as l4,jsx as Us,jsxs as c4}from"react/jsx-runtime";var s4=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=be();return c4(l4,{children:[n&&Us("div",{className:"dropdown-menu-item__icon",children:n}),Us("div",{style:e,className:"dropdown-menu-item__text",children:Us(Hs,{children:o})}),r&&Us("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Us("div",{className:"dropdown-menu-item__shortcut",children:t})]})},rr=s4;import{jsx as Ed}from"react/jsx-runtime";var Ph=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=fd(s);return Ed(m4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Ed("button",{...l,value:t,className:or(i,a),title:l.title??l["aria-label"],children:Ed(rr,{icon:e,shortcut:r,badge:n,children:o})})})};Ph.displayName="DropdownMenuItem";var Ki={GREEN:"green",RED:"red",BLUE:"blue"},bd=({type:e=Ki.BLUE,children:n})=>{let{theme:t}=Qn(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===d4.LIGHT?"1.5px solid white":"none"};switch(e){case Ki.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Ki.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Ki.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Ed("div",{className:"DropDownMenuItemBadge",style:o,children:n})};bd.displayName="DropdownMenuItemBadge";Ph.Badge=bd;var qt=Ph;import{KEYS as $i}from"@excalidraw/common";var Ey=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[$i.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===$i.F)return n.current?.focus(),!0;if(e.key===$i.ESCAPE)return r(),!0;if(e.key===$i.ENTER)return t?.value&&i(t.value),!0;if(e.key===$i.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===$i.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as vo,jsxs as x4}from"react/jsx-runtime";var E4=e=>{switch(e){case ar.Excalifont:case ar.Virgil:return $n;case ar.Nunito:case ar.Helvetica:return As;case ar["Lilita One"]:return O1;case ar["Comic Shanns"]:case ar.Cascadia:return Vc;default:return As}},b4=(e,n)=>Object.entries(ar).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",wy=p4.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=Ne(),l=St(),{fonts:c}=l,{showDeprecatedFonts:d}=kn(),m=ct(),[p,u]=u4(""),E=by(null),g=ir(()=>Array.from(Eo.registered.entries()).filter(([k,{metadata:L}])=>!L.private&&!L.fallback).map(([k,{metadata:L,fontFaces:F}])=>{let Y={value:k,icon:E4(k),text:b4(k,F)};return L.deprecated&&Object.assign(Y,{deprecated:L.deprecated,badge:{type:Ki.RED,placeholder:f("fontList.badge.old")}}),Y}).sort((k,L)=>k.text.toLowerCase()>L.text.toLowerCase()?1:-1),[]),b=ir(()=>new Set(c.getSceneFamilies()),[e]),w=ir(()=>g.filter(k=>b.has(k.value)),[g,b]),y=ir(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=ir(()=>h4([...w,...y].filter(k=>k.text?.toLowerCase().includes(p))),[w,y,p]),I=ir(()=>{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=yy(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=yy(k=>{Ey({event:k,inputRef:E,hoveredFont:I,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[I,x,T,o,a]);xy(()=>(i(),()=>{a()}),[]);let P=ir(()=>x.filter(k=>b.has(k.value)),[x,b]),M=ir(()=>x.filter(k=>!b.has(k.value)),[x,b]),D=({font:k,order:L})=>{let F=by(null),Y=k.value===I?.value,z=k.value===e;return xy(()=>{Y&&(L===0?F.current?.scrollIntoView?.({block:"end"}):F.current?.scrollIntoView?.({block:"nearest"}))},[Y,L]),vo("button",{ref:F,type:"button",value:k.value,className:or("",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:vo(rr,{icon:k.icon,badge:k.badge&&vo(bd,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:f4({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(vo(Gs,{title:f("fontList.sceneFonts"),children:P.map((k,L)=>vo(D,{font:k,order:L},k.value))},"group_1")),M.length&&_.push(vo(Gs,{title:f("fontList.availableFonts"),children:M.map((k,L)=>vo(D,{font:k,order:L+P.length},k.value))},"group_2")),x4(yo,{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"&&vo(hd,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:g4(u,20)}),vo(gd,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,n)=>e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as y4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as w4}from"@excalidraw/common";import{jsx as kh}from"react/jsx-runtime";var vy=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Oe(),r=t?{...w4,width:"2rem",height:"2rem"}:{};return kh(y4.Trigger,{asChild:!0,children:kh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:kh(Z,{type:"toggle",icon:Pn,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 Ws,jsxs as Iy}from"react/jsx-runtime";var Ty=[{value:Mh.Excalifont,icon:$n,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Mh.Nunito,icon:As,text:f("labels.normal"),testId:"font-family-normal"},{value:Mh["Comic Shanns"],icon:Vc,text:f("labels.code"),testId:"font-family-code"}],ete=new Set(Ty.map(e=>e.value));var Sy=T4.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=C4(()=>Ty,[]),c=S4(d=>{d&&o(d)},[o]);return Iy("div",{role:"dialog","aria-modal":"true",className:I4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&Ws("div",{className:"buttonList",children:Ws(jt,{type:"button",options:l,value:n,onClick:c})}),!s&&Ws(rd,{}),Iy(v4.Root,{open:e,onOpenChange:a,children:[Ws(vy,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&Ws(wy,{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 Ah}from"radix-ui";import A4 from"clsx";import My,{useEffect as D4,useMemo as L4}from"react";import{isArrowKey as _4,KEYS as Io}from"@excalidraw/common";import{jsx as P4}from"react/jsx-runtime";var xd=({className:e,icon:n,size:t="1em"})=>P4("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 M4,jsx as Cy,jsxs as Py}from"react/jsx-runtime";var k4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>Py(M4,{children:[Py("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Cy(xd,{icon:n?p0:Kc})]}),n&&Cy("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),Vs=k4;import{jsx as eo,jsxs as wd}from"react/jsx-runtime";var R4=Qe(!1),yd=4,N4="default",B4=e=>e.flatMap(n=>n.options),ky=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},F4=(e,n)=>e.some(t=>t.options.some(n)),O4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/yd)},(t,o)=>n.options.slice(o*yd,o*yd+yd)));function z4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=Ne(),[s,l]=He(R4),c=[...e,...n],d=B4(c),m=O4([...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===Io.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(_4(g.key)){let w=Kn().rtl,y=d.findIndex(x=>x.value===t);if(y!==-1){let x=d.length,I=y;switch(g.key){case(w?Io.ARROW_LEFT:Io.ARROW_RIGHT):I=(y+1)%x;break;case(w?Io.ARROW_RIGHT:Io.ARROW_LEFT):I=(x+y-1)%x;break;case Io.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 Io.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===Io.ESCAPE||g.key===Io.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};D4(()=>{F4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>eo("div",{className:"picker-content",children:g.map(b=>wd("button",{type:"button",className:A4("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&&eo("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,w)=>b.name===N4?eo(My.Fragment,{children:u(b.options)},`${b.name}-${w}`):wd("div",{className:"picker-section",children:[eo("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${w}`));return eo(Ah.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:wd("div",{className:"picker-sections",children:[E(e),n.length>0&&eo(Vs,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:eo("div",{className:"picker-sections",children:E(n)})})]})})}function Dh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=My.useState(!1),s=L4(()=>ky(t,l=>l.value===e)??ky(o??[],l=>l.value===e),[t,o,e]);return eo("div",{children:wd(Ah.Root,{open:i,onOpenChange:l=>a(l),children:[eo(Ah.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&eo(z4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import Ay,{useEffect as G4}from"react";import{jsx as Lh,jsxs as Dy}from"react/jsx-runtime";var Ly=({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=Ay.useRef(null),d=Ay.useRef(null);return G4(()=>{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]),Dy("label",{className:"control-label",children:[e,Dy("div",{className:"range-wrapper",children:[Lh("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}),Lh("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),Lh("div",{className:"zero-label",children:a})]})]})};import{Fragment as kd,jsx as ee,jsxs as bt}from"react/jsx-runtime";var Uy=.1,Vr=e=>{let n=m6(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Ct=(e,n,t,o=!1)=>{let r=Fh(ce(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(r6(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},mt=function(e,n,t,o,r){let i=n.state.editingTextElement,a=Gy(e),s=null;if(i&&(s=t(i)),!s)if(Le(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=n6(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},p6=(e,n,t)=>a6(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}),Oh=(e,n,t,o,r)=>{let i=new Set,a=Ct(e,n,s=>{if(Ht(s)){let l=o(s);i.add(l);let c=at(s,{fontSize:l});return Ys(c,t.scene.getContainerElement(s),t.scene),c=p6(s,c,t.scene),c}return s},!0);return ce(e,n,{includeBoundTextElement:!0}).forEach(s=>{Ht(s)&&i6(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:tt.IMMEDIATELY}},u6=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Ct(e,n,o=>l6(o.type)?at(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?tt.IMMEDIATELY:tt.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Vr(o);return bt(kd,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.stroke")}),ee(Xi,{topPicks:K4,palette:X4,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:mt(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),h6=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:tt.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!t6(t.currentItemBackgroundColor)&&i.every(s=>By(s)&&o6(s.points))){let s=Fh(i);r=e.map(l=>s.has(l.id)&&By(l)?at(l,{backgroundColor:t.currentItemBackgroundColor,...d6(l,!0)}):l)}else r=Ct(e,n,s=>at(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Vr(o);return bt(kd,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(Xi,{topPicks:Y4,palette:Oy,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:mt(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),Pd=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:tt.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=Vr(o);return bt(kd,{children:[r==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(Xi,{topPicks:W4,palette:Oy,excludedColors:[V4.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})]})}}),g6=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Fe("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Ct(e,n,r=>at(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ce(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return bt("fieldset",{children:[ee("legend",{children:f("labels.fill")}),ee("div",{className:"buttonList",children:ee(jt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?a1:s1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:l1,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:c1,testId:"fill-solid"}],value:mt(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)}})})]})}}),f6=e=>q4.find(n=>zy(e.type,n)===e.strokeWidth)??null,E6=(e,n)=>zy(e.type,n),b6=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(Cd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Ct(e,n,o=>at(o,{strokeWidth:E6(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[ee("legend",{children:f("labels.strokeWidth")}),ee("div",{className:"buttonList",children:ee(jt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:Xu,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:d1,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:m1,testId:"strokeWidth-bold"}],value:mt(e,o,f6,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),x6=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>at(o,{seed:J4(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[ee("legend",{children:f("labels.sloppiness")}),ee("div",{className:"buttonList",children:ee(jt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:h1},{value:1,text:f("labels.artist"),icon:g1},{value:2,text:f("labels.cartoonist"),icon:f1}],value:mt(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),y6=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:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=mt(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?$u:Ku,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return bt("fieldset",{children:[ee("legend",{children:f("labels.pressure")}),ee("div",{className:"buttonList",children:ee(jt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:Ku},{value:"variable",text:f("labels.pressure_variable"),icon:$u}],value:i,onChange:a=>t(a)})})]})}}),ane=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:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[ee("legend",{children:f("labels.strokeStyle")}),ee("div",{className:"buttonList",children:ee(jt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Xu},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:p1},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:u1}],value:mt(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),w6=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:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=mt(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return ee(Ly,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),v6=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>Oh(e,n,o,()=>(Cd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Vr(o);return bt("fieldset",{children:[ee("legend",{children:f("labels.fontSize")}),ee("div",{className:"buttonList",children:ee(jt,{group:"font-size",options:[{value:Id.sm,text:f("labels.small"),icon:R1,testId:"fontSize-small"},{value:Id.md,text:f("labels.medium"),icon:N1,testId:"fontSize-medium"},{value:Id.lg,text:f("labels.large"),icon:B1,testId:"fontSize-large"},{value:Id.xl,text:f("labels.veryLarge"),icon:F1,testId:"fontSize-veryLarge"}],value:mt(e,o,a=>{if(Ht(a))return a.fontSize;let s=sr(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Ht(a)||sr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||Z4),onChange:a=>{Rs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),zh=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:zr,trackEvent:!1,perform:(e,n,t,o)=>Oh(e,n,o,r=>Math.round(1/(1+Uy)*r.fontSize)),keyTest:e=>e[Zi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Zi.CHEVRON_LEFT||e.key===Zi.COMMA)}),Gh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:zr,trackEvent:!1,perform:(e,n,t,o)=>Oh(e,n,o,r=>Math.round(r.fontSize*(1+Uy))),keyTest:e=>e[Zi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Zi.CHEVRON_RIGHT||e.key===Zi.PERIOD)}),I6=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:tt.NEVER};Cd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=tt.EVENTUALLY,m,p=!1;if(l)m=l,d=tt.IMMEDIATELY;else if(c){m=c,d=tt.EVENTUALLY;let E=ce(e,n,{includeBoundTextElement:!0}).filter(g=>Ht(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(Eo.loadedFontsCache.values()),y=Object.entries(j4).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(Ht(T)&&(T.fontFamily!==m||l)){let C=at(T,{fontFamily:m,lineHeight:e6(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 ${Q4({fontFamily:m})}`,I=Array.from(g.values()).join();if(b||window.document.fonts.check(x,I))for(let[T,C]of E)Ys(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&&Ys(M,D,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=Rh(new Map),i=Rh(null),[a,s]=U4({}),l=Rh(!0),{stylesPanelMode:c,isCompact:d}=Vr(t),m=Bh(()=>{let p=(u,E)=>mt(u,t,g=>{if(Ht(g))return g.fontFamily;let b=sr(g,E);return b?b.fontFamily:null},g=>Ht(g)||sr(g,E)!==null,g=>g?null:n.currentItemFontFamily||$4);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 _h(()=>{i.current=m},[m]),_h(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),_h(()=>(l.current=!1,()=>{l.current=!0}),[]),bt(kd,{children:[c==="full"&&ee("legend",{children:f("labels.fontFamily")}),ee(Sy,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{Rs(()=>{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=ce(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&&_s(null)}}})]})}}),T6=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Ht(r)){let i=at(r,{textAlign:t});return Ys(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=Vr(o);return bt("fieldset",{children:[ee("legend",{children:f("labels.textAlign")}),ee("div",{className:"buttonList",children:ee(jt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:z1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:G1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:H1,testId:"align-right"}],value:mt(e,o,s=>{if(Ht(s))return s.textAlign;let l=sr(s,i);return l?l.textAlign:null},s=>Ht(s)||sr(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{Rs(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),S6=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Ht(r)){let i=at(r,{verticalAlign:t});return Ys(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Vr(o);return ee("fieldset",{children:ee("div",{className:"buttonList",children:ee(jt,{group:"text-align",options:[{value:vd.TOP,text:f("labels.alignTop"),icon:ee(U1,{theme:n.theme}),testId:"align-top"},{value:vd.MIDDLE,text:f("labels.centerVertically"),icon:ee(V1,{theme:n.theme}),testId:"align-middle"},{value:vd.BOTTOM,text:f("labels.alignBottom"),icon:ee(W1,{theme:n.theme}),testId:"align-bottom"}],value:mt(e,o,a=>{if(Ht(a)&&a.containerId)return a.verticalAlign;let s=sr(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Ht(a)||sr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:vd.MIDDLE),onChange:a=>{Rs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),sne=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>Hy(o)?o:at(o,{roundness:t==="round"?{type:s6(o.type)?Td.ADAPTIVE_RADIUS:Td.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=Ci(Gy(e),n).some(s=>s.roundness?.type===Td.LEGACY);return bt("fieldset",{children:[ee("legend",{children:f("labels.edges")}),bt("div",{className:"buttonList",children:[ee(jt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:E1},{value:"round",text:f("labels.round"),icon:b1}],value:mt(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!Sd(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),Fy=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:ee(x1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:ee(y1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:ee(w1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:ee(v1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:ee(I1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ee(T1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:ee(S1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:ee(C1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:ee(P1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:ee(k1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:ee(M1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:ee(A1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:ee(D1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:ee(L1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:ee(_1,{flip:e}),keyBinding:null}]}]}),lne=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(Cd(t,"actionChangeArrowhead: value must be defined"),{elements:Ct(e,n,o=>{if(Nh(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:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=Kn().rtl,i=Bh(()=>Fy(!r),[r]),a=Bh(()=>Fy(!!r),[r]);return bt("fieldset",{children:[ee("legend",{children:f("labels.arrowheads")}),bt("div",{className:"iconSelectList buttonList",children:[ee(Dh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:mt(e,o,s=>Nh(s)&&Es(s.type)?Ny(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),ee(Dh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:mt(e,o,s=>Nh(s)&&Es(s.type)?Ny(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),C6=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})=>bt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),cne=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Ct(e,n,s=>{if(!Sd(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=Wr.getPointAtIndexGlobalCoordinates(s,0,l),d=Wr.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:Td.PROPORTIONAL_RADIUS}:null,elbowed:t===dn.elbow,angle:t===dn.elbow?0:s.angle,points:t===dn.elbow||s.elbowed?[Wr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Wr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(Hy(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=Wr.getPointAtIndexGlobalCoordinates(m,0,p),E=Wr.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,...Ry(m,g,"start",p,n.isBindingEnabled)}:null,y=b&&m.endBinding?{...m.endBinding,...Ry(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:w,endBinding:y,...c6(m,p,{points:[u,E].map(x=>H4(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&&_y(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&_y(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 Wr(s,Fh(e)))}return{elements:r,appState:i,captureUpdate:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>bt("fieldset",{children:[ee("legend",{children:f("labels.arrowtypes")}),ee("div",{className:"buttonList",children:ee(jt,{group:"arrowtypes",options:[{value:dn.sharp,text:f("labels.arrowtype_sharp"),icon:qo,testId:"sharp-arrow"},{value:dn.round,text:f("labels.arrowtype_round"),icon:Qo,testId:"round-arrow"},{value:dn.elbow,text:f("labels.arrowtype_elbowed"),icon:Jo,testId:"elbow-arrow"}],value:mt(e,o,r=>Sd(r)?r.elbowed?dn.elbow:r.roundness?dn.round:dn.sharp:null,r=>Sd(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as _6,MAX_ZOOM as R6,MIN_ZOOM as N6,THEME as Xs,ZOOM_STEP as Yy,CODES as Yr,KEYS as Ad}from"@excalidraw/common";import{getNonDeletedElements as Ks}from"@excalidraw/element";import{getCommonBounds as $s}from"@excalidraw/element";import{CaptureUpdateAction as Ji}from"@excalidraw/element";import{useEffect as P6}from"react";import{jsx as M6}from"react/jsx-runtime";var ji=()=>{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},Hh=(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`})},k6=(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();Hh(n,r)},pt=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(P6(()=>()=>ji().classList.remove("excalidraw-tooltip--visible"),[]),r?null:M6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>k6(i.currentTarget,ji(),n,t),onPointerLeave:()=>ji().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as Wy,useRef as Vy,useState as A6}from"react";var D6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Uh=(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},Xo())}return D6(o,n)};function qi(e,n=!0){let t=Md(),[,o]=A6(0),r=Vy(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Uh(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Uh(t,e,n)),Wy(()=>{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 L6(e,n){let t=Md(),o=Vy({selector:e,callback:n});o.current.selector=e,o.current.callback=n,Wy(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Uh(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Nd,jsxs as O6}from"react/jsx-runtime";var B6=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?Ji.IMMEDIATELY:Ji.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Nd(Xi,{palette:null,topPicks:_6,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})}),Dd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:Mu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...fo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(n.zoom.value+Yy)},n)},captureUpdate:Ji.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=qi(t=>t.zoom.value);return Nd(Z,{type:"button",className:"zoom-in-button zoom-button",icon:Mu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=R6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Yr.EQUAL||e.code===Yr.NUM_ADD)&&(e[Ad.CTRL_OR_CMD]||e.shiftKey)}),Ld=O({name:"zoomOut",label:"buttons.zoomOut",icon:Au,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...fo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(n.zoom.value-Yy)},n)},captureUpdate:Ji.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=qi(t=>t.zoom.value);return Nd(Z,{type:"button",className:"zoom-out-button zoom-button",icon:Au,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=N6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Yr.MINUS||e.code===Yr.NUM_SUBTRACT)&&(e[Ad.CTRL_OR_CMD]||e.shiftKey)}),_d=O({name:"resetZoom",label:"buttons.resetZoom",icon:Ux,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,...fo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(r)},n)},captureUpdate:Ji.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=qi(t=>t.zoom.value);return Nd(pt,{label:f("buttons.resetZoom"),style:{height:"100%"},children:O6(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===Yr.ZERO||e.code===Yr.NUM_ZERO)&&(e[Ad.CTRL_OR_CMD]||e.shiftKey)}),Wh=e=>[e.x,e.y,e.x+e.width,e.y+e.height],Gne=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Xc,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?$s(Ks(r)):n.scrollConstraints?Wh(n.scrollConstraints):$s(Ks(e)),a=_r({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Vn(a.appState)}}},keyTest:void 0}),Hne=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Xc,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?$s(Ks(r)):n.scrollConstraints?Wh(n.scrollConstraints):$s(Ks(e)),a=_r({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Vn(a.appState)}}},keyTest:void 0}),F6=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Xc,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?Wh(n.scrollConstraints):$s(Ks(e)),i=_r({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Vn(i.appState)}}},keyTest:void 0}),Rd=O({name:"toggleTheme",label:(e,n)=>n.theme===Xs.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===Xs.LIGHT?Cs:Ps,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===Xs.LIGHT?Xs.DARK:Xs.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:Ji.EVENTUALLY}},keyTest:e=>!e[Ad.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Yr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as K6}from"@excalidraw/math";import{bindOrUnbindBindingElement as nw}from"@excalidraw/element/binding";import{isValidPolygon as ow,newElementWith as Xh}from"@excalidraw/element";import{LinearElementEditor as Qs}from"@excalidraw/element/linearElementEditor";import{isBindingElement as Kh,isFreeDrawElement as rw,isLinearElement as iw,isLineElement as Ud}from"@excalidraw/element";import{KEYS as Wd,arrayToMap as $6,invariant as aw,shouldRotateWithDiscreteAngle as Z6,updateActiveTool as sw}from"@excalidraw/common";import{isPathALoop as j6}from"@excalidraw/element";import{isInvisiblySmallElement as $h}from"@excalidraw/element";import{CaptureUpdateAction as Zh}from"@excalidraw/element";import U6 from"clsx";import{useEffect as W6,useState as V6}from"react";import{KEYS as mn,capitalizeString as Xr}from"@excalidraw/common";import{useEffect as z6,useState as G6}from"react";import Xy from"clsx";import{capitalizeString as Bd}from"@excalidraw/common";import{Popover as Vh}from"radix-ui";import{jsx as Fd,jsxs as H6}from"react/jsx-runtime";var Qi=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=G6(!1),c=t.type,d=a.type===c,m=16,{container:p}=Ne();return!n.some(u=>u.type===c)&&s&&l(!1),z6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),H6(Vh.Root,{open:s,children:[Fd(Vh.Trigger,{asChild:!0,children:Fd(Z,{className:Xy({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>Je(e,u.type)),title:Bd(a.title),"aria-label":Bd(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Fd(Vh.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Fd(Z,{className:Xy({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:Je(e,u),title:Bd(u),"aria-label":Bd(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Fe("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as Yh}from"react/jsx-runtime";var Y6=e=>e,Ye=Y6({hand:{icon:Y1,letterKey:mn.H,toggle:!0},selection:{icon:Oc,letterKey:mn.V,fillable:!0},rectangle:{icon:_i,letterKey:mn.R,fillable:!0},diamond:{icon:Ri,letterKey:mn.D,fillable:!0},ellipse:{icon:Ni,letterKey:mn.O,fillable:!0},arrow:{icon:zc,letterKey:mn.A,fillable:!0},line:{icon:$o,letterKey:mn.L,fillable:!0},freedraw:{icon:$n,letterKey:mn.P},text:{icon:Pn,letterKey:mn.T},image:{icon:Fr},eraser:{icon:Gc,letterKey:mn.E,toggle:!0},frame:{icon:jn,letterKey:mn.F},autoshape:{icon:Gr,letterKey:mn.X,fillable:!1},embeddable:{icon:Zo},laser:{icon:qn},bucketfill:{icon:Zn},lasso:{icon:Li,fillable:!1}});var ea=["autoshape","rectangle","diamond","ellipse","arrow","line"],ta=Object.keys(Ye).filter(e=>Ye[e].toggle),Od=e=>{let{letterKey:n,shiftKey:t}=Ye[e];if(!n)return n;let o=Xr(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},na=e=>Od(e),X6=e=>{let n=Od(e);return n?.length===1?n:void 0},Ky=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(Ye)){let{letterKey:i,shiftKey:a}=Ye[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},Je=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Ut=(e,n)=>{let t=Ye[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=Xr(f(`toolBar.${e}`)),d=l?null:na(o);return Yh(Z,{className:U6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:Je(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:s||l?void 0:X6(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&&(Fe("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Xr(e)}IconButton`,r},zd=Ut("hand"),$y=Ut("rectangle"),Zy=Ut("diamond"),jy=Ut("ellipse"),qy=Ut("arrow"),Jy=Ut("line"),Zs=Ut("freedraw"),js=Ut("text"),qs=Ut("image"),Js=Ut("eraser"),Qy=Ut("frame"),goe=Ut("autoshape"),ew=Ut("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Fe("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),tw=Ut("lasso",{shortcutType:"selection"}),Gd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:Ye.selection.icon,fillable:Ye.selection.fillable,title:Xr(f("toolBar.selection"))},{type:"lasso",icon:Ye.lasso.icon,fillable:Ye.lasso.fillable,title:Xr(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return Yh(Qi,{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})},Hd=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:Ye.freedraw.icon,fillable:Ye.freedraw.fillable,title:Xr(f("toolBar.freedraw"))},{type:"autoshape",icon:Ye.autoshape.icon,fillable:Ye.autoshape.fillable,title:Xr(f("toolBar.autoshape"))}],[o,r]=V6(n.type==="autoshape"?"autoshape":"freedraw");W6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return Yh(Qi,{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 q6}from"react/jsx-runtime";var ut=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=Qs.getElement(n.selectedLinearElement.elementId,l);aw(y,"Arrow element should exist if selectedLinearElement is set"),aw(w,"sceneCoords should be defined if actionFinalize is called with event");let x=Qs.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(Kh(y)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let I=!!n.newElement,T=I||!n.selectedLinearElement.selectedPointsIndices?[y.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=Z6(b),P=b[Wd.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),M=T.reduce((D,_)=>(D.set(_,{point:C?y.points[_]:Qs.createPointAt(y,l,w.x-x.pointerOffset.x,w.y-x.pointerOffset.y,P)}),D),new Map)??new Map;nw(y,M,w.x,w.y,s,n,{newArrow:I,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else Ud(y)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!ow(y.points)&&s.mutateElement(y,{polygon:!1});if(x!==n.selectedLinearElement){y&&$h(y)&&(i=i.map(T=>T.id===y.id?Xh(T,{isDeleted:!0}):T));let I=n.activeTool?.locked;return{elements:y.points.length<2||$h(y)?e.map(T=>T.id===y.id?Xh(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:Zh.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"||Kh(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)}),Kh(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=Qs.getPointAtIndexGlobalCoordinates(m,-1,l);nw(m,x,I[0],I[1],s,n,{newArrow:y})}}if(m&&$h(m)&&(i=i.map(b=>b.id===m?.id?Xh(b,{isDeleted:!0}):b)),iw(m)||rw(m)){if(j6(m.points,n.zoom.value)&&(Ud(m)||rw(m))){let w=m.points,y=w[0],x=w.map((I,T)=>T===w.length-1?K6(y[0],y[1]):I);Ud(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}Ud(m)&&!ow(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;ta.includes(n.activeTool.type)?p=sw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=sw(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&&iw(m)?new Qs(m,$6(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?Zh.IMMEDIATELY:Zh.NEVER}},keyTest:(e,n)=>e.key===Wd.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===Wd.ESCAPE||e.key===Wd.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>q6(Z,{type:"button",icon:Qx,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 dw,isSomeElementSelected as J6,makeNextSelectedElementIds as Q6,selectGroupsForSelectedElements as eD}from"@excalidraw/element";import{CaptureUpdateAction as lw}from"@excalidraw/element";import{KEYS as tD,isWritableElement as nD,updateActiveTool as cw}from"@excalidraw/common";var oD=(e,n)=>ta.includes(e.activeTool.type)?cw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):cw(e,{type:n.state.preferredSelectionTool.type}),rD=(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:dw(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},iD=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=oD(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:dw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...eD({editingGroupId:rD(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:lw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:Q6({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:lw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==tD.ESCAPE||nD(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||J6(o.scene.getNonDeletedElements(),n))});import{KEYS as Jd,THEME as ol}from"@excalidraw/common";import{CaptureUpdateAction as Mn}from"@excalidraw/element";import aD from"clsx";import{jsx as mw,jsxs as sD}from"react/jsx-runtime";var jh=({children:e,checked:n,onChange:t,className:o})=>sD("div",{className:aD("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[mw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:Hc}),mw("div",{className:"Checkbox-label",children:e})]});import{THEME as el}from"@excalidraw/common";import{jsx as tl}from"react/jsx-runtime";var uw=e=>{let n=e.title||(e.value===el.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return tl(Z,{type:"icon",icon:e.value===el.LIGHT?pw.MOON:pw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===el.DARK?el.LIGHT:el.DARK),"data-testid":"toggle-dark-mode"})},pw={SUN:tl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:tl("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:tl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:tl("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 lD}from"react";import{focusNearestParent as cD,KEYS as dD}from"@excalidraw/common";import{jsx as hw,jsxs as mD}from"react/jsx-runtime";var gw=e=>{let{id:n}=Ne(),[t,o]=lD(e.value),r=a=>{e.ignoreFocus||cD(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===dD.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return mD("div",{className:"ProjectName",children:[hw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),hw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as pD,useEffect as uD,useRef as hD}from"react";import{jsx as Vd,jsxs as bD}from"react/jsx-runtime";var gD=5e3,fD=({progress:e})=>Vd("div",{className:"Toast__progress-bar",children:Vd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),ED=({message:e,onClose:n,closable:t=!1,duration:o=gD,style:r})=>{let i=hD(0),a=o!==1/0,s=pD(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return uD(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),bD("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Vd("div",{className:"Toast__message",children:e}),t&&Vd(Z,{icon:an,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},Yd=Object.assign(ED,{ProgressBar:fD});import{DEFAULT_EXPORT_PADDING as BD,DEFAULT_FILENAME as FD,IMAGE_MIME_TYPES as ww,isFirefox as OD,MIME_TYPES as zD,cloneJSON as GD,SVG_DOCUMENT_PREAMBLE as HD,arrayToMap as UD}from"@excalidraw/common";import{getNonDeletedElements as WD}from"@excalidraw/element";import{isFrameLikeElement as VD}from"@excalidraw/element";import{getElementsOverlappingFrame as YD}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as xD,EXPORT_DATA_TYPES as nl,MIME_TYPES as ht,arrayToMap as yD,isMemberOf as wD,isPromiseLike as vD,EVENT as Xd}from"@excalidraw/common";import{mutateElement as ID}from"@excalidraw/element";import{deepCopyElement as TD}from"@excalidraw/element";import{isFrameLikeElement as SD,isInitializedImageElement as CD}from"@excalidraw/element";import{getContainingFrame as fw}from"@excalidraw/element";var _re="clipboard"in navigator&&"readText"in navigator.clipboard,Kd="clipboard"in navigator&&"writeText"in navigator.clipboard,lr="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,PD=e=>!!([nl.excalidraw,nl.excalidrawClipboard,nl.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Ew=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Xd.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},kD=({elements:e,files:n})=>{let t=yD(e),o=new Set(e.filter(s=>SD(s))),r=!1,i=e.reduce((s,l)=>(CD(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:nl.excalidrawClipboard,elements:e.map(s=>{if(fw(s,t)&&!o.has(fw(s,t))){let l=TD(s);return ID(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},$d=async(e,n,t)=>{let o=kD({elements:e,files:n});await To({[ht.excalidrawClipboard]:o,[ht.text]:o},t)};function bw(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(bw(t));return n}var MD=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,ht.html),o=bw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},xw=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{[ht.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(wD(xD,o))try{if(o===ht.text||o===ht.html)e[o]=await(await t.getType(o)).text();else if(bx(o)){let r=await t.getType(o),i=Sx(r,o,void 0);e[o]=i}else throw new Tu(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof Tu?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},AD=async(e,n=!1)=>{try{let t=e.findByType(ht.html),o=!n&&t&&MD(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(ht.text)??o.value.map(r=>r.value).join(`
2
- `).trim()}:o:{type:"text",value:(e.getData(ht.text)||"").trim()}}catch{return{type:"text",value:""}}},DD=function(e){return this.find(n=>n.type===e)||null},LD=function(e){return this.find(t=>t.type===e)?.value??null},_D=function(){return this.filter(e=>e.kind==="file")},qh=e=>{let n=Jh(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),ht.text,ht.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}},RD=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}}),Zd=(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===ht.html)try{let E=new DOMParser().parseFromString(u.value,ht.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===ht.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:RD(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},yw=e=>{let n;Jh(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},Kr=async e=>{let n;Jh(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 Tx(o);return r=await Br(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:DD,getData:LD,getFiles:_D})},jd=async(e,n=!1)=>{let t=await AD(e,n);if(t.type==="mixedContent")return{mixedContent:t.value};try{let o=JSON.parse(t.value),r=o.type===nl.excalidrawClipboardWithAPI;if(PD(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}},qd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[ht.png]:e})])}catch(n){if(vD(e))await navigator.clipboard.write([new ClipboardItem({[ht.png]:await e})]);else throw n}},To=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[ht.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===ht.text);if(Kd&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!ND(o[1]))throw new Error("Error copying to clipboard.")},ND=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},Jh=e=>e.type===Xd.PASTE||e.type===Xd.COPY||e.type===Xd.CUT;var $r=(e,{selectedElementIds:n},t)=>{let o=WD(e),r=UD(o),i=t&&Le(o,{selectedElementIds:n}),a=null,s=i?ce(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&VD(l)?(a=l,s=YD(o,l,r)):s.length>1&&(s=ce(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:GD(s)}},Zr=async(e,n,t,o,{exportBackground:r,exportPadding:i=BD,viewBackgroundColor:a,name:s=t.name||FD,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Rr(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 Su(m.then(p=>new Blob([HD+p.outerHTML],{type:zD.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[ww.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await To(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let d=Lc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Is(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-K4KCMBWW.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:xs(n,t,o,"local")})))),Su(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[ww.png],fileHandle:l})}else if(e==="clipboard")try{let m=Is(d);await qd(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):OD&&m.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
1
+ import{$ as Mi,A as mx,B as Cu,C as xs,D as kc,E as Pu,F as px,G as ux,H as Mc,I as ys,J as Ac,K as Dc,L as ws,M as hx,N as gx,O as fx,P as Lc,Q as Rr,R as P3,S as Nr,T as ki,V as Ex,X as bx,Y as xx,Z as _c,_ as yx,a as vu,aa as vs,b as Vn,ba as Is,c as go,ca as wx,d as _r,da as Rc,e as Ti,ea as vx,f as Yn,fa as Ix,g as ix,ga as Sx,h as Le,ha as ku,i as ax,ia as Tx,j as ce,ja as Cx,k as Ci,ka as Px,l as Yo,la as Br,m as sx,n as Iu,o as lx,p as Es,q as cx,r as Pc,s as dx,t as Su,u as Tu,v as fo,w as Ko,x as rn,y as bs,z as Pi}from"./chunk-HIDXO6YX.js";import{a as T}from"./chunk-U2M5DXIZ.js";import{G as wu}from"./chunk-DARW3V66.js";import{c as rx}from"./chunk-5XKZK2GL.js";import{b as ox,c as C3,d as v}from"./chunk-SRAX5OIU.js";import fX,{useCallback as EX,useContext as bX,useEffect as xX,useRef as yX,useState as wX}from"react";import{applyDarkModeFilter as UVe,DEFAULT_IMAGE_OPTIONS as Tn,DEFAULT_UI_OPTIONS as T3,getStrokeWidthByKey as WVe,isShallowEqual as vX}from"@excalidraw/common";import tM from"clsx";import jV from"lodash.throttle";import In,{useContext as zo}from"react";import{flushSync as Ot}from"react-dom";import qV from"roughjs/bin/rough";import{nanoid as JV}from"nanoid";import{clamp as cc,pointFrom as oe,pointDistance as so,vector as nM,pointRotateRads as fb,vectorFromPoint as Eb,vectorSubtract as oM,vectorDot as rM,vectorNormalize as iM}from"@excalidraw/math";import{CODES as kr,shouldResizeFromCenter as aM,shouldMaintainAspectRatio as dc,shouldRotateWithDiscreteAngle as sM,isArrowKey as bb,KEYS as $,APP_NAME as QV,CURSOR_TYPE as Ae,DEFAULT_STROKE_STREAMLINE as eY,DEFAULT_STROKE_STREAMLINE_PRECISE as tY,DEFAULT_TRANSFORM_HANDLE_SPACING as nY,DEFAULT_VERTICAL_ALIGN as lM,DRAGGING_THRESHOLD as cM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as oY,ELEMENT_TRANSLATE_AMOUNT as dM,EVENT as Q,FRAME_STYLE as Ro,IMAGE_MIME_TYPES as rY,IMAGE_RENDER_TIMEOUT as iY,LINE_CONFIRM_THRESHOLD as xb,MIME_TYPES as lo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as aY,POINTER_BUTTON as Gn,ROUNDNESS as jp,SCROLL_TIMEOUT as sY,TAP_TWICE_TIMEOUT as mM,TEXT_TO_CENTER_SNAP_THRESHOLD as lY,THEME as mc,TOUCH_CTX_MENU_TIMEOUT as cY,VERTICAL_ALIGN as dY,YOUTUBE_STATES as qp,ZOOM_STEP as mY,MIN_ZOOM as pY,POINTER_EVENTS as ds,TOOL_TYPE as Hn,supportsResizeObserver as uY,DEFAULT_COLLISION_THRESHOLD as pM,DEFAULT_TEXT_ALIGN as hY,ARROW_TYPE as Mr,DEFAULT_REDUCED_GLOBAL_ALPHA as gY,isLocalLink as fY,normalizeLink as Jp,toValidURL as EY,getGridPoint as Mt,getLineHeight as uM,debounce as hM,distance as ms,getFontString as yb,getNearestScrollableContainer as bY,isInputLike as gM,isToolIcon as xY,isWritableElement as pc,sceneCoordsToViewportCoords as Qp,tupleToCoors as wb,viewportCoordsToSceneCoords as Me,wrapEvent as yY,updateObject as vb,updateActiveTool as nn,isTransparent as wY,muteFSAbortError as vY,isTestEnv as r3,isDevEnv as i3,updateStable as uc,addEventListener as ve,normalizeEOL as IY,getDateTime as fM,isShallowEqual as EM,arrayToMap as hc,applyDarkModeFilter as SY,AppEventBus as TY,randomInteger as CY,CLASSES as Ib,Emitter as co,MINIMUM_ARROW_SIZE as PY,DOUBLE_TAP_POSITION_THRESHOLD as bM,BIND_MODE_TIMEOUT as kY,invariant as mo,getFeatureFlag as No,createUserAgentDescriptor as a3,getFormFactor as MY,deriveStylesPanelMode as mu,isIOS as AY,isBrave as DY,isSafari as LY,loadDesktopUIModePreference as _Y,setDesktopUIMode as RY,isSelectionLikeTool as eu,oneOf as xM,getStrokeWidthByKey as NY}from"@excalidraw/common";import{getObservedAppState as BY,getCommonBounds as ps,getElementAbsoluteCoords as yM,bindOrUnbindBindingElements as wM,fixBindingsAfterDeletion as FY,getHoveredElementForBinding as Ar,isBindingEnabled as tu,updateBoundElements as nu,LinearElementEditor as fe,newElementWith as po,newFrameElement as OY,newFreeDrawElement as zY,newEmbeddableElement as vM,newMagicFrameElement as GY,newIframeElement as HY,newArrowElement as UY,newElement as WY,newImageElement as VY,newLinearElement as YY,newTextElement as IM,refreshTextDimensions as KY,deepCopyElement as SM,duplicateElements as TM,hasBoundTextElement as CM,isArrowElement as gc,isBindingElement as uo,isBindingElementType as XY,isBoundToContainer as PM,isFrameLikeElement as St,isImageElement as Un,isEmbeddableElement as Bo,isInitializedImageElement as yi,isLinearElement as zt,isLinearElementType as $Y,isUsingAdaptiveRadius as ZY,isIframeElement as Sb,isIframeLikeElement as fc,isTextBindableContainer as kM,isElbowArrow as Kt,isBindableElement as Tb,isTextElement as Xt,getNormalizedDimensions as jY,isElementCompletelyInViewport as qY,isElementInViewport as MM,isInvisiblySmallElement as AM,generateThumbHash as JY,getCornerRadius as QY,isPathALoop as DM,embeddableURLValidator as Cb,maybeParseEmbedSrc as eK,getEmbedLink as ou,getInitializedImageElements as tK,normalizeSVG as LM,updateImageCache as Pb,getBoundTextElement as kb,getContainerCenter as Mb,getContainerElement as _M,isValidTextContainer as RM,redrawTextBoundingBox as nK,hasBoundingBox as oK,getCommonFrameId as NM,getFrameChildren as Ab,getFrameChildrenInsertionIndex as rK,isCursorInFrame as BM,addElementsToFrame as Db,replaceAllElementsInFrame as iK,removeElementsFromFrame as aK,getElementsInResizingFrame as Lb,getElementsInNewFrame as sK,getContainingFrame as _b,elementOverlapsWithFrame as lK,updateFrameMembershipOfSelectedElements as FM,isElementInFrame as OM,getFrameLikeTitle as cK,filterElementsEligibleAsFrameChildren as dK,hitElementBoundText as mK,hitElementBoundingBoxOnly as pK,hitElementItself as Ec,getVisibleSceneBounds as uK,cropElement as hK,wrapText as gK,isElementLink as zM,isMeasureTextSupported as fK,normalizeText as EK,measureText as GM,getLineHeightInPx as HM,getApproxMinLineWidth as bK,getApproxMinLineHeight as xK,getMinTextElementWidth as yK,ShapeCache as wi,getRenderOpacity as wK,editGroupForSelectedElement as vK,getElementsInGroup as vi,getSelectedGroupIdForElement as IK,getSelectedGroupIds as SK,isElementInGroup as UM,isSelectedViaGroup as TK,selectGroupsForSelectedElements as Wn,syncInvalidIndices as s3,syncMovedIndices as WM,excludeElementsInFramesFromSelection as CK,getSelectionStateForElements as VM,makeNextSelectedElementIds as De,getResizeOffsetXY as PK,getResizeArrowDirection as kK,transformElements as MK,getCursorForResizingElement as YM,getElementWithTransformHandleType as KM,getTransformHandleTypeFromCoords as XM,dragNewElement as $M,dragSelectedElements as AK,getDragOffsetXY as DK,Scene as ZM,Store as LK,CaptureUpdateAction as $t,hitElementBoundingBox as _K,isLineElement as Rb,isSimpleArrow as Nb,StoreDelta as jM,positionElementsOnGrid as qM,calculateFixedPointForNonElbowArrowBinding as JM,bindOrUnbindBindingElement as RK,mutateElement as ru,getElementBounds as QM,doBoundsIntersect as NK,isPointInElement as e3,maxBindingDistance_simple as t3,convertToExcalidrawElements as BK,getSnapOutlineMidPoint as Bb,handleFocusPointDrag as FK,handleFocusPointHover as OK,handleFocusPointPointerDown as zK,handleFocusPointPointerUp as GK,maybeHandleArrowPointlikeDrag as iu,getUncroppedWidthAndHeight as HK,getActiveTextElement as n3,isEligibleFrameChildType as UK,getBindingStrategyForDraggingBindingElementEndpoints as WK,isNonDeletedElement as au}from"@excalidraw/element";import{KEYS as ah,MOBILE_ACTION_BUTTON_BG as H3,updateActiveTool as U3}from"@excalidraw/common";import{getNonDeletedElements as ed}from"@excalidraw/element";import{fixBindingsAfterDeletion as W3}from"@excalidraw/element";import{LinearElementEditor as S0}from"@excalidraw/element/linearElementEditor";import{newElementWith as Qc}from"@excalidraw/element";import{getContainerElement as T0}from"@excalidraw/element";import{isBoundToContainer as qc,isElbowArrow as V3,isFrameLikeElement as Y3}from"@excalidraw/element";import{getFrameChildren as K3}from"@excalidraw/element";import{getElementsInGroup as sh,selectGroupsForSelectedElements as X3}from"@excalidraw/element";import{CaptureUpdateAction as Jc}from"@excalidraw/element";import{isDevEnv as D3}from"@excalidraw/common";import{atom as Qe,createStore as k3}from"jotai";import{createIsolation as M3}from"jotai-scope";var kx=M3();var{useAtom:Ue,useSetAtom:Mx,useAtomValue:Ax,useStore:kX}=kx,Dx=kx.Provider,Et=k3();var A3=ox({"./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-RNZ7CUK6.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 L3=85,Kn={code:"en",label:"English"},Di=[Kn,...[{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=>rx[e.code]>=L3).sort((e,n)=>e.label>n.label?1:-1)],Bc="__test__";D3()&&Di.unshift({code:Bc,label:"test language"},{code:`${Bc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Ai=Kn,Nc={},Fc=async e=>{if(Ai=e,document.documentElement.dir=Ai.rtl?"rtl":"ltr",document.documentElement.lang=Ai.code,e.code.startsWith(Bc))Nc={};else try{Nc=await A3(`./locales/${Ai.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Nc=wu}Et.set(_x,e.code)},Xn=()=>Ai,Lx=(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(Ai.code.startsWith(Bc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=Lx(Nc,o)||Lx(wu,o)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(T.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},_x=Qe(Kn.code),_e=()=>{let e=Ax(_x);return{t:f,langCode:e}};import _3 from"clsx";import et from"react";import{THEME as R3}from"@excalidraw/common";import{Fragment as Ie,jsx as h,jsxs as R}from"react/jsx-runtime";var Cn=e=>"var(--icon-fill-color)",Rx=e=>e===R3.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:_3({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ae={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Dt={width:40,height:20},WX=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),VX=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),Nx=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),Ss=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),Bx=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),Fx=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),Mu=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),Eo=A(R("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),ae),Xo=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),ae),Ox=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}),zx=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"}),Gx=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"}),Hx=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"}),YX=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"}),Oc=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}),Li=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}),_i=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),Ri=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),Ni=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),zc=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"}),ae),Ux=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),$n=A(R("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),ae),Pn=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),Wx=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),Fr=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),ae),Gc=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),Au=A(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ae),Du=A(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ae),Vx=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),Or=A(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),ae),Zo=A(R("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),ae),Ts=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),ae),Cs=A(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),ae),Ps=A(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...ae,strokeWidth:1.5}),Yx=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),ks=A(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),ae),Bi=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),Kx=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),KX=A(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),ae),Xx=A(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),ae),$x=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),ae),Zx=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),Hc=A(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Ms=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),ae),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}),Uc=A(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),ae),XX=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}),$X=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"),Lu=["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"],Zn=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Lu.map(e=>h("path",{d:e},e))]}),H),Jx=A(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),Qx=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),e1=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}),ZX=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}),jX=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}),t1=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"),qX=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"),_u=A(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),ae),Ru=A(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),ae),n1=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}),o1=A(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),ae),JX=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"),QX=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}),e$=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),t$=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}),n$=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}),r1=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"})]}),i1=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"})]}),Nu=A(i1,H),Bu=A(i1,{...H,style:{transform:"rotate(180deg)"}}),Fu=A(r1,H),Ou=A(r1,{...H,style:{transform:"rotate(180deg)"}}),zu=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Gu=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Hu=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Uu=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),a1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),s1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),Wu=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),ae),Vu=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),ae),Wc=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),o$=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"),r$=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"})})})]}),ae),i$=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}),a$=A("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),s$=A("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Yu=et.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:Cn(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:Cn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Cn(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:Cn(e),strokeWidth:"2"}),R("g",{fill:Rx(e),stroke:Cn(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})),Ku=et.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:Cn(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:Cn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Cn(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:Cn(e),strokeWidth:"2"}),R("g",{fill:Rx(e),stroke:Cn(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})),l1=A(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),ae),c1=A(R(Ie,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),ae),d1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),m1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...ae,fill:"currentColor"}),Xu=A(h(Ie,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ae),p1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ae),u1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ae),l$=et.memo(({theme:e})=>A(h("path",{d:"M6 10H34",stroke:Cn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),h1=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),g1=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),f1=A(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),ae),E1=A(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),ae),b1=A(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),ae),$u=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),Zu=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),x1=A(R("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),ae),y1=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),w1=et.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"})]}),Dt)),v1=et.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"})}),Dt)),I1=et.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"})]}),Dt)),S1=et.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"})]}),Dt)),T1=et.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"})]}),Dt)),C1=et.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"})]}),Dt)),P1=et.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"})]}),Dt)),k1=et.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"})]}),Dt)),M1=et.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"})}),Dt)),A1=et.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"})}),Dt)),D1=et.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"})}),Dt)),L1=et.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"})}),Dt)),_1=et.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"})}),Dt)),R1=et.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"})]}),Dt)),N1=et.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"})]}),Dt)),B1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),F1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),O1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ae),z1=A(h(Ie,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ae),zr=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),G1=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),As=A(h(Ie,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),ae),N3=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),Vc=N3,H1=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),U1=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),W1=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),V1=et.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)),Y1=et.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)),K1=et.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)),Yc=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),c$=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}),d$=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"})),X1=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),ju=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),$1=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),Z1=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),m$=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),p$=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),J1=A(R(Ie,{children:[h("path",{d:"M17 5v14"}),h("path",{d:"M5 6l9 6l-9 6z"})]}),H),Q1=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),e0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),t0=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),qu=["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"],Fi=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),qu.map(e=>h("path",{d:e},e))]}),H),jn=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),u$=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),h$=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),g$=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),ae),Gr=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),qn=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),f$=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),E$=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),b$=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),x$=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),Hr=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),n0=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),y$=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),w$=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),Jn=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),v$=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),I$=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),o0=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),r0=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),S$=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),i0=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),a0=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),s0=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),l0=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),Ju=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),Kc=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),c0=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),d0=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),jo=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),T$=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),m0=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}),C$=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),P$=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),p0=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),u0=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),qo=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),Jo=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),Qo=A(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),Xc=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),h0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),g0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),Qu=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),f0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),H),eh=A(R("g",{strokeWidth:"1.25",children:[h("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),H),th=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),k$=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),nh=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"})})),E0=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),b0=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),oh=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),M$=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),A$=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),D$=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),L$=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),$c=h("div",{style:{width:"1rem",height:"1rem"}}),x0=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),y0=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),w0=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 v0 from"clsx";import ih,{useEffect as O3,useRef as I0,useState as z3}from"react";import{isPromiseLike as G3}from"@excalidraw/common";import B3 from"react";import{jsx as rh}from"react/jsx-runtime";var F3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(B3.useRef(Date.now()).current%1600);return rh("div",{className:`Spinner ${o}`,children:rh("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:rh("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},bo=F3;import{jsx as Ds,jsxs as Zc}from"react/jsx-runtime";var Z=ih.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=ih.useRef(null);ih.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=z3(!1),d=I0(!0),c=async p=>{let u="onClick"in o&&o.onClick?.(p);if(G3(u))try{l(!0),await u}catch(E){if(E instanceof Pc)console.warn(E);else throw E}finally{d.current&&l(!1)}};O3(()=>(d.current=!0,()=>{d.current=!1}),[]);let m=I0(null);return o.type==="button"||o.type==="icon"?Zc("button",{className:v0("ToolIcon_type_button",a,t,n&&!o.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!o.hidden,"ToolIcon--plain":o.type==="icon"}),style:o.style,"data-testid":o["data-testid"],hidden:o.hidden,title:o.title,"aria-label":o["aria-label"],type:"button",onClick:c,ref:i,disabled:s||o.isLoading||!!o.disabled,children:[(o.icon||o.label)&&Zc("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&Ds("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&Ds(bo,{})]}),o.showAriaLabel&&Zc("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&Ds(bo,{})]}),o.children]}):Ds("button",{className:v0("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:Zc("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&Ds("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});Z.displayName="IconButton";var jc=[],O=e=>(jc=jc.concat(e),e);import{jsx as Z3}from"react/jsx-runtime";var $3=(e,n,t)=>{let o=new Set(ce(e.filter(c=>Y3(c)),n).map(c=>c.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let c of o){let m=K3(e,c);for(let p of m)if(!a.has(p.id)){if(qc(p)){let u=T0(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let s=!0,l=e.map(c=>{if(n.selectedElementIds[c.id]){let m=qc(c)?T0(c,i):null;return c.frameId&&o.has(c.frameId)?(s=!1,r[c.id]=!0,c):m?.frameId&&o.has(m?.frameId)?c:(c.boundElements&&c.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&V3(u)&&t.scene.mutateElement(u,{startBinding:c.id===u.startBinding?.elementId?null:u.startBinding,endBinding:c.id===u.endBinding?.elementId?null:u.endBinding})}),Qc(c,{isDeleted:!0}))}return c.frameId&&o.has(c.frameId)?(s=!1,qc(c)||(r[c.id]=!0),Qc(c,{frameId:null})):qc(c)&&n.selectedElementIds[c.containerId]?Qc(c,{isDeleted:!0}):c}),d=n.editingGroupId;if(s&&n.editingGroupId){let c=sh(l,n.editingGroupId).filter(m=>!m.isDeleted);if(c.length>1)c[0]&&(r[c[0].id]=!0);else{d=null,c[0]&&(r[c[0].id]=!0);let m=c[0];if(m){let p=m.groupIds.findIndex(E=>E===n.editingGroupId),u=m.groupIds[p+1];if(u){let E=sh(l,u).filter(g=>!g.isDeleted);E.length>1&&(d=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...X3({selectedElementIds:r,editingGroupId:d},ed(l),n,null)}}},C0=(e,n)=>{if(e.editingGroupId){let t=sh(ed(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Ls=O({name:"deleteSelectedElements",label:"labels.delete",icon:Or,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(),d=S0.getElement(a,l);if(!d||s==null)return!1;if(s.length>=d.points.length){let c=e.map(p=>p.id===d.id?Qc(p,{isDeleted:!0}):p),m=C0(n,c);return{elements:c,appState:{...m,selectedLinearElement:null},captureUpdate:Jc.IMMEDIATELY}}return S0.deletePoints(d,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:Jc.IMMEDIATELY}}let{elements:r,appState:i}=$3(e,n,o);return W3(r,r.filter(a=>a.isDeleted)),i=C0(i,r),{elements:r,appState:{...i,activeTool:U3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Le(ed(e),n)?Jc.IMMEDIATELY:Jc.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===ah.BACKSPACE||e.key===ah.DELETE)&&!e[ah.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ct()==="mobile";return Z3(Z,{type:"button",icon:Or,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Le(ed(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?H3:{}}})}});import{KEYS as Oi,CODES as zi,isDarwin as td}from"@excalidraw/common";import{moveOneLeft as j3,moveOneRight as q3,moveAllLeft as J3,moveAllRight as Q3}from"@excalidraw/element";import{CaptureUpdateAction as nd}from"@excalidraw/element";import{isDarwin as P0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,P0?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,P0?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 od}from"react/jsx-runtime";var lh=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Bu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:j3(e,n,o.scene),appState:n,captureUpdate:nd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Oi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===zi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Bu})}),ch=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Nu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:q3(e,n,o.scene),appState:n,captureUpdate:nd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Oi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===zi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Nu})}),dh=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Ou,trackEvent:{category:"element"},perform:(e,n)=>({elements:J3(e,n),appState:n,captureUpdate:nd.IMMEDIATELY}),keyTest:e=>td?e[Oi.CTRL_OR_CMD]&&e.altKey&&e.code===zi.BRACKET_LEFT:e[Oi.CTRL_OR_CMD]&&e.shiftKey&&e.code===zi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${td?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Ou})}),mh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Fu,trackEvent:{category:"element"},perform:(e,n)=>({elements:Q3(e,n),appState:n,captureUpdate:nd.IMMEDIATELY}),keyTest:e=>td?e[Oi.CTRL_OR_CMD]&&e.altKey&&e.code===zi.BRACKET_RIGHT:e[Oi.CTRL_OR_CMD]&&e.shiftKey&&e.code===zi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>od("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${td?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Fu})});import{getNonDeletedElements as eA}from"@excalidraw/element";import{LinearElementEditor as tA}from"@excalidraw/element/linearElementEditor";import{isLinearElement as nA,isTextElement as oA}from"@excalidraw/element";import{arrayToMap as rA,KEYS as k0}from"@excalidraw/common";import{selectGroupsForSelectedElements as iA}from"@excalidraw/element";import{CaptureUpdateAction as aA}from"@excalidraw/element";var ph=O({name:"selectAll",label:"labels.selectAll",icon:i0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(oA(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...iA({editingGroupId:null,selectedElementIds:r},eA(e),n,o),selectedLinearElement:Object.keys(r).length===1&&nA(e[0])?new tA(e[0],rA(e)):null},captureUpdate:aA.IMMEDIATELY}},keyTest:e=>e[k0.CTRL_OR_CMD]&&e.key===k0.A});import{DEFAULT_GRID_SIZE as M0,KEYS as A0,MOBILE_ACTION_BUTTON_BG as sA,arrayToMap as D0}from"@excalidraw/common";import{getNonDeletedElements as L0}from"@excalidraw/element";import{LinearElementEditor as lA}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as cA,getSelectionStateForElements as dA}from"@excalidraw/element";import{syncMovedIndices as mA}from"@excalidraw/element";import{duplicateElements as pA}from"@excalidraw/element";import{CaptureUpdateAction as _0}from"@excalidraw/element";import{jsx as uA}from"react/jsx-runtime";var uh=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Ts,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=lA.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:_0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=pA({type:"in-place",elements:e,idsOfElementsToDuplicate:D0(cA(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+M0/2,y:a.y+M0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:mA(i,D0(r)),appState:{...n,...dA(r,L0(i),n)},captureUpdate:_0.IMMEDIATELY}},keyTest:e=>e[A0.CTRL_OR_CMD]&&e.key===A0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ct()==="mobile";return uA(Z,{type:"button",icon:Ts,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Le(L0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?sA:{}}})}});import{pointFrom as K4}from"@excalidraw/math";import{useEffect as Rh,useMemo as Fh,useRef as Nh,useState as X4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as $4,COLOR_PALETTE as Z4,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Gy,DEFAULT_ELEMENT_BACKGROUND_PICKS as j4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as q4,DEFAULT_ELEMENT_STROKE_PICKS as J4,ARROW_TYPE as dn,DEFAULT_FONT_FAMILY as Q4,DEFAULT_FONT_SIZE as e6,FONT_FAMILY as t6,ROUNDNESS as Sd,STROKE_WIDTH_KEYS as n6,VERTICAL_ALIGN as vd,KEYS as Zi,randomInteger as o6,arrayToMap as Oh,getFontFamilyString as r6,getLineHeight as i6,isTransparent as a6,getStrokeWidthByKey as Hy,reduceToCommonValue as s6,invariant as Cd,FONT_SIZES as Id}from"@excalidraw/common";import{canBecomePolygon as l6,getNonDeletedElements as Uy,isNonDeletedElement as c6}from"@excalidraw/element";import{bindBindingElement as Ny,calculateFixedPointForElbowArrowBinding as By,updateBoundElements as d6}from"@excalidraw/element";import{LinearElementEditor as Wr}from"@excalidraw/element/linearElementEditor";import{newElementWith as at}from"@excalidraw/element";import{getArrowheadForPicker as Fy}from"@excalidraw/element";import{getBoundTextElement as sr,redrawTextBoundingBox as Ys}from"@excalidraw/element";import{isArrowElement as Td,isBoundToContainer as m6,isElbowArrow as Wy,isLinearElement as Bh,isLineElement as Oy,isTextElement as Ht,isUsingAdaptiveRadius as p6}from"@excalidraw/element";import{hasStrokeColor as u6}from"@excalidraw/element";import{updateElbowArrowPoints as h6,CaptureUpdateAction as tt,toggleLinePolygonState as g6}from"@excalidraw/element";import{deriveStylesPanelMode as f6}from"@excalidraw/common";import{isDevEnv as hA}from"@excalidraw/common";var gA=new Set(["command_palette","export"]),Fe=(e,n,t,o)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!gA.has(e)||hA())return;T.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 xA from"clsx";import fA from"clsx";import{forwardRef as EA}from"react";import{jsx as bA}from"react/jsx-runtime";var R0=EA((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return bA("button",{type:"button",ref:n,title:t,"data-testid":r,className:fA(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as wA,jsx as hh,jsxs as yA}from"react/jsx-runtime";var jt=e=>hh(wA,{children:e.options.map(n=>e.type==="button"?hh(R0,{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):yA("label",{className:xA({active:e.value===n.value}),title:n.text,children:[hh("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 uy}from"radix-ui";import hy from"clsx";import{memo as U5,useRef as gy,useEffect as W5}from"react";import{applyDarkModeFilter as V5,COLOR_OUTLINE_CONTRAST_THRESHOLD as my,COLOR_PALETTE as fy,DEFAULT_ELEMENT_BACKGROUND_PICKS as Y5,DEFAULT_ELEMENT_STROKE_PICKS as K5,isColorDark as py,isWritableElement as X5,THEME as $5}from"@excalidraw/common";import{jsx as vA}from"react/jsx-runtime";var rd=()=>vA("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as kA,useLayoutEffect as MA,useRef as AA}from"react";import{createPortal as DA}from"react-dom";import{EVENT as er,isColorDark as LA,KEYS as _A,MIME_TYPES as RA,THEME as NA,removeDarkModeFilter as BA,rgbToHex as FA}from"@excalidraw/common";import N0 from"react";var gh=N0.createContext(null),ye=()=>N0.useContext(gh);import{useState as IA,useLayoutEffect as B0}from"react";import{THEME as SA}from"@excalidraw/common";var id=e=>{let[n,t]=IA(null),o=be(),{theme:r}=ye(),{container:i}=Ne();return B0(()=>{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===SA.DARK))},[n,r,o.formFactor,e?.className]),B0(()=>{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 TA}from"react";import{EVENT as ad}from"@excalidraw/common";function Gi(e,n,t){TA(()=>{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(ad.POINTER_DOWN,o),document.addEventListener(ad.TOUCH_START,o),()=>{document.removeEventListener(ad.POINTER_DOWN,o),document.removeEventListener(ad.TOUCH_START,o)}},[e,n,t])}import{useRef as CA}from"react";var Hi=e=>{let n=CA(e);return Object.assign(n.current,e),n.current};import{clamp as PA}from"@excalidraw/math";var F0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return PA(r,0,Math.max(0,t-n))},sd=({cursor:e,element:n,container:t,gap:o})=>({left:F0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:F0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as zA}from"react/jsx-runtime";var O0=qu.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),OA=`url(data:${RA.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">${O0}</g><g stroke="#1b1b1f" stroke-width="1.25">${O0}</g></svg>`)}) 2 21, auto`,Gt=Qe(null),z0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=id({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ye(),a=Ui(),s=Tt(),l=ce(a,i),d=Hi({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:c}=Ne();MA(()=>{if(r)return r.style.cursor=OA,()=>{r.style.cursor=""}},[r]),kA(()=>{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 FA(D[0],D[1],D[2])},b=P=>i.theme===NA.DARK?BA(P):P,w=({clientX:P,clientY:M,altKey:D})=>{let{top:_,left:k}=sd({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&&d.onChange(o,b(L),d.selectedElements,{altKey:D}),p.style.background=L,p.style.setProperty("--eye-dropper-preview-border-color",LA(L)?"#fff":"#222")},y=()=>{d.onCancel()},x=(P,M)=>{d.onSelect(P,M)},I=P=>{u=!0,P.stopImmediatePropagation()},S=P=>{u=!1,c?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===_A.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),w({clientX:d.app.viewport.lastPosition.x,clientY:d.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(er.KEYDOWN,C),r.addEventListener(er.POINTER_DOWN,I),r.addEventListener(er.POINTER_UP,S),window.addEventListener("pointermove",w,{passive:!0}),window.addEventListener(er.BLUR,y),()=>{u=!1,r.removeEventListener(er.KEYDOWN,C),r.removeEventListener(er.POINTER_DOWN,I),r.removeEventListener(er.POINTER_UP,S),window.removeEventListener("pointermove",w),window.removeEventListener(er.BLUR,y)}},[d,s.canvas,r,o,c,i.offsetLeft,i.offsetTop,i.theme]);let m=AA(null);return Gi(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?DA(zA("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as fh}from"radix-ui";import WA from"clsx";import VA from"react";import{isInteractive as YA}from"@excalidraw/common";import GA from"react";import HA from"clsx";import{jsx as UA}from"react/jsx-runtime";var We=GA.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>UA("div",{className:HA("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as Eh,jsxs as KA}from"react/jsx-runtime";var xo=VA.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:d=!1},c)=>{let m=be(),p=m.formFactor==="phone"&&!m.isLandscape;return Eh(fh.Portal,{container:n,children:KA(fh.Content,{ref:c,className:WA("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=>{d&&m.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!YA(document.activeElement)&&n.focus(),r()},children:[Eh(We,{padding:3,style:o,children:t}),Eh(fh.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 XA,useCallback as bh}from"react";var ld=()=>document.querySelector(".excalidraw-wysiwyg"),cd=()=>{let e=ld();return e?{start:e.selectionStart,end:e.selectionEnd}:null},_s=e=>{setTimeout(()=>{let n=ld();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},Rs=(e,n,t,o)=>{n&&o&&o();let r=n&&t?cd():null;e(),n&&t&&_s(r)},G0=()=>{let[e,n]=XA(null),t=bh(()=>{let i=cd();n(i)},[]),o=bh(()=>{setTimeout(()=>{let i=ld();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=bh(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},H0=(e=100)=>{let n=ld();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import W0 from"clsx";import{useCallback as jA,useEffect as yh,useRef as V0,useState as Y0}from"react";import{KEYS as wh,normalizeInputColor as qA}from"@excalidraw/common";import{isTransparent as $A,MAX_CUSTOM_COLORS_USED_IN_CANVAS as ZA}from"@excalidraw/common";var tr=({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},Ns=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),xh=({color:e,palette:n})=>!Object.values(n).flat().includes(e),U0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!$A(s)&&xh({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,ZA)},sn=Qe(null);import{Fragment as JA,jsx as Bs,jsxs as vh}from"react/jsx-runtime";var K0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=be(),[a,s]=Y0(e),[l,d]=Y0(null),[c,m]=Ue(sn);yh(()=>{s(e)},[e]);let p=jA(w=>{let y=w.toLowerCase().trim(),x=qA(y);x?(n(x),d(null)):y.length===0?d(null):/^#?[0-9a-f]+$/.test(y)?d(f("colorPicker.invalidHexLength")):d(f("colorPicker.invalidColor")),s(y)},[n]),u=V0(null),E=V0(null);yh(()=>{u.current&&u.current.focus()},[c]);let[g,b]=Ue(Gt);return yh(()=>()=>{b(null)},[b]),vh("div",{className:"color-picker__input-label-container",children:[vh("div",{className:W0("color-picker__input-label",{"has-error":l}),children:[Bs("div",{className:"color-picker__input-hash",children:"#"}),Bs("input",{ref:c==="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),d(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:w=>{w.key!==wh.TAB&&(w.key===wh.ESCAPE&&E.current?.focus(),w.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&vh(JA,{children:[Bs("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Bs("div",{ref:E,className:W0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(w=>w?null:{keepOpenOnAlt:!1,onSelect:y=>n(y),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${wh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:Fi})]})]}),l&&Bs("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import Th,{useEffect as Ch,useImperativeHandle as A5,useState as D5}from"react";import{EVENT as ay}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as L5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as _5,KEYS as R5}from"@excalidraw/common";import s5 from"clsx";import{useEffect as l5,useRef as c5}from"react";import{applyDarkModeFilter as d5,THEME as m5}from"@excalidraw/common";import{isColorDark as QA}from"@excalidraw/common";import{jsxs as t5}from"react/jsx-runtime";var e5=({color:e,keyLabel:n,isShade:t=!1})=>t5("div",{className:"color-picker__button__hotkey-label",style:{color:QA(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),Wi=e5;import{createContext as n5,useContext as o5,useEffect as r5,useMemo as X0,useRef as $0,useState as i5}from"react";import{colorToHex as Z0,isTransparent as a5}from"@excalidraw/common";var Ur="excalidraw-color-dnd-ghost",j0="excalidraw-color-dnd-active",q0=10,J0=100,Q0=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=Z0(e);return t!==null&&t===Z0(n)},Ih=n5(null),ln=()=>o5(Ih),ey=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=i5(null),i=$0(null),a=$0({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=X0(()=>{let l=null,d=()=>{l?.activated?r({color:l.color,origin:l.origin,overIndex:l.overIndex,duplicateIndex:l.duplicateIndex,slotSpan:l.slotSpan}):r(null)},c=()=>{let k=i.current;if(!k||!l)return!1;let L=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((V,G)=>Number(V.dataset.topPickIndex)-Number(G.dataset.topPickIndex));if(!L.length)return!1;l.slotRects=L.map(V=>V.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=Ur;let V=document.createElement("div");if(V.className=`${Ur}__swatch`,a5(z))V.classList.add("is-transparent");else{let G=getComputedStyle(Y).backgroundColor;V.style.backgroundColor=G&&G!=="rgba(0, 0, 0, 0)"?G:z}U.appendChild(V),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(`${Ur}--lifted`)}),document.body.classList.add(j0),l.activated=!0,d()},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 V=0,G=1/0;if(Y.forEach((re,B)=>{let W=Math.abs(k-(re.left+re.width/2));W<G&&(G=W,V=B)}),l.origin.kind==="swatch"){let re=a.current.picks.findIndex(B=>Q0(B,l.color));re!==-1?U=re:z=V}else z=V}if(z!==l.overIndex||U!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=U;let{ghost:V}=l;V&&(V.classList.toggle(`${Ur}--over`,z!==null),V.classList.toggle(`${Ur}--blocked`,U!==null)),d()}if(z!==null){let V=l.slotRects[z];p(V.width,V.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(`${Ur}--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(`${Ur}--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())},S=(k,L)=>{if(!(!l||l.activated)){if(!c()){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<J0){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=q0&&S(l.lastX,l.lastY))},J0-L));return}if(S(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:V}=a.current;if(b(),L!==null){if(F.kind==="swatch"){if(!U.some(G=>Q0(G,Y))){let G=[...U];G[L]=Y,V(G)}}else if(F.index!==L){let G=[...U],[re]=G.splice(F.index,1);G.splice(L,0,re),V(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 r5(()=>()=>s.destroy(),[s]),X0(()=>({dragState:o,startSwatchDrag:(l,d)=>s.begin(l,d,{kind:"swatch"}),startPickDrag:(l,d,c)=>s.begin(l,c,{kind:"pick",index:d}),setStripEl:l=>{i.current=l}}),[o,s])};import{jsx as Sh,jsxs as p5}from"react/jsx-runtime";var ty=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=Ue(sn),s=ln(),l=c5(null);return l5(()=>{l.current&&l.current.focus()},[t,i]),Sh("div",{className:"color-picker-content--default",children:n.map((d,c)=>{let m=d5(d,e===m5.DARK);return p5("button",{ref:t===d?l:void 0,tabIndex:-1,type:"button",className:s5("color-picker__button color-picker__button--large has-outline",{active:t===d,"is-transparent":d==="transparent"||!d}),onClick:()=>{o(d),a("custom")},onPointerDown:s?p=>s.startSwatchDrag(p,d):void 0,title:d,"aria-label":r,style:{"--swatch-color":m},children:[Sh("div",{className:"color-picker__button-outline"}),Sh(Wi,{color:m,keyLabel:c+1})]},c)})})};import u5 from"clsx";import{useEffect as h5,useRef as g5}from"react";import{applyDarkModeFilter as f5,isColorDark as E5,THEME as b5}from"@excalidraw/common";import{jsx as dd,jsxs as y5}from"react/jsx-runtime";var x5=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=tr({color:t,palette:n}),[l,d]=Ue(sn),c=ln(),m=g5(null);return h5(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),dd("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 dd("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=Ns[E],w=f5(g,e===b5.DARK),y=f(`colors.${p.replace(/\d+/,"")}`,null,"");return y5("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:u5("color-picker__button color-picker__button--large",{"has-outline":!E5(g,255),active:s?.colorName===p,"is-transparent":g==="transparent"||!g}),onClick:()=>{o(g),d("baseColors")},onPointerDown:c?x=>c.startSwatchDrag(x,g):void 0,title:`${y}${g.startsWith("#")?` ${g}`:""} \u2014 ${b}`,"aria-label":`${y} \u2014 ${b}`,style:g?{"--swatch-color":w}:void 0,"data-testid":`color-${p}`,children:[dd("div",{className:"color-picker__button-outline"}),i&&dd(Wi,{color:w,keyLabel:b})]},p)})})},ny=x5;import{jsx as v5}from"react/jsx-runtime";var w5=({children:e})=>v5("div",{className:"color-picker__heading",children:e}),Vi=w5;import I5 from"clsx";import{useEffect as S5,useRef as T5}from"react";import{applyDarkModeFilter as C5,THEME as P5}from"@excalidraw/common";import{jsx as Fs,jsxs as oy}from"react/jsx-runtime";var ry=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=tr({color:n||"transparent",palette:o}),[a,s]=Ue(sn),l=ln(),d=T5(null);if(S5(()=>{d.current&&a==="shades"&&d.current.focus()},[i,a]),i){let{colorName:c,shade:m}=i,p=o[c];if(Array.isArray(p))return Fs("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=C5(u,e===P5.DARK);return oy("button",{ref:E===m&&a==="shades"?d:void 0,tabIndex:-1,type:"button",className:I5("color-picker__button color-picker__button--large",{active:E===m}),"aria-label":"Shade",title:`${c} - ${E+1}`,style:u?{"--swatch-color":g}:void 0,onClick:()=>{t(u),s("shades")},onPointerDown:l?b=>l.startSwatchDrag(b,u):void 0,children:[Fs("div",{className:"color-picker__button-outline"}),r&&Fs(Wi,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return oy("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Fs("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Fs("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 Yi,COLOR_PALETTE as k5,KEYS as Os}from"@excalidraw/common";var md=(e,n,t)=>{let o=Math.ceil(t/Yi);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+Yi;return r>=t?n%Yi:r}case"ArrowUp":{let r=n-Yi,i=r<0?Yi*o+r:r;return i>=t?void 0:i}}},M5=({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(Ns.includes(e.key)){let l=Ns.indexOf(e.key),d=Object.keys(o)[l],c=o[d],m=Array.isArray(c)?c[a]:c;return m==null||s?.includes(m)||(t(m),i("baseColors")),!0}return!1},iy=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:d,onEscape:c,excludedColors:m})=>{if(e[Os.CTRL_OR_CMD])return!1;if(e.key===Os.ESCAPE)return c(e),!0;if(e.key===Os.ALT)return d(!0),!0;if(e.key===Os.I)return d(),!0;let p=tr({color:o,palette:t});if(e.key===Os.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[I,S])=>(S&&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,S])=>Array.isArray(S)?S.includes(o):S===o?I:null)||r(k5.black)),e.preventDefault(),e.stopPropagation(),!0}if(M5({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=md(e.key,u,Yi);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=md(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=md(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=md(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as yo,jsxs as pd}from"react/jsx-runtime";var sy=Th.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:s,showTitle:l,onEyeDropperToggle:d,onEscape:c,showHotKey:m=!0,excludedColors:p},u)=>{let E=l?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=Th.useState(()=>o==="canvasBackground"?[]:U0(r,o,i)),[b,w]=Ue(sn),y=ln(),x=tr({color:n,palette:i});Ch(()=>{if(!b){let P=!!n&&xh({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,S]=D5(x?.shade??(o==="elementBackground"?L5:_5));Ch(()=>{x?.shade!=null&&S(x.shade);let P=M=>{M.key===R5.ALT&&d(!1)};return document.addEventListener(ay.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(ay.KEYUP,P,{capture:!0})}},[x,d]);let C=Th.useRef(null);return A5(u,()=>C.current),Ch(()=>{C?.current?.focus()},[]),yo("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:pd("div",{ref:C,onKeyDown:P=>{iy({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:d,customColors:g,setActiveColorPickerSection:w,updateData:a,activeShade:I,onEscape:c,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&yo("div",{className:"color-picker__title",children:E}),!!g.length&&pd("div",{children:[yo(Vi,{children:f("colorPicker.mostUsedCustomColors")}),yo(ty,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),pd("div",{children:[yo(Vi,{children:f("colorPicker.colors")}),yo(ny,{theme:e,color:n,palette:i,onChange:t,activeShade:I,showHotKey:m,excludedColors:p})]}),pd("div",{children:[yo(Vi,{children:f("colorPicker.shades")}),yo(ry,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,y&&yo("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import ly from"clsx";import{ContextMenu as zs}from"radix-ui";import{applyDarkModeFilter as N5,COLOR_OUTLINE_CONTRAST_THRESHOLD as B5,DEFAULT_CANVAS_BACKGROUND_PICKS as F5,DEFAULT_ELEMENT_BACKGROUND_PICKS as O5,DEFAULT_ELEMENT_STROKE_PICKS as z5,isColorDark as G5,THEME as H5}from"@excalidraw/common";import{jsx as nr,jsxs as cy}from"react/jsx-runtime";var dy=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=ln(),l=s?.dragState??null,{container:d}=Ne(),c;if(t==="elementStroke"&&(c=z5),t==="elementBackground"&&(c=O5),t==="canvasBackground"&&(c=F5),r&&(c=r),!c)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=cy("div",{className:ly("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&nr("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:nr("rect",{})}),c.map((u,E)=>{let g=m(E),b=N5(u,e===H5.DARK);return nr("button",{className:ly("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!G5(u,B5),"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:nr("div",{className:"color-picker__button-outline"})},u)})]});return i?cy(zs.Root,{children:[nr(zs.Trigger,{asChild:!0,children:p}),nr(zs.Portal,{container:d,children:nr(zs.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:nr(zs.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as cn,jsxs as ud}from"react/jsx-runtime";var Z5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=fy,updateData:a,getOpenPopup:s,appState:l,excludedColors:d})=>{let{container:c}=Ne(),m=ct(),p=m!=="full",u=m==="mobile",[,E]=Ue(sn),[g,b]=Ue(Gt),w=ud("div",{children:[cn(Vi,{children:f("colorPicker.hexCode")}),cn(K0,{color:n||"",label:o,onChange:I=>{t(I)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),y=gy(null),x=()=>{y.current?.focus()};return cn(xo,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:I=>{if(I.target instanceof HTMLElement&&I.target.closest(".color-picker__context-menu")){I.preventDefault();return}X5(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(sy,{ref:y,palette:i,excludedColors:d,color:n,theme:l.theme,onChange:I=>{let S=l.editingTextElement?cd():null;t(I),l.editingTextElement&&S&&_s(S)},onEyeDropperToggle:I=>{b(S=>I?(S=S||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},S.keepOpenOnAlt=!0,S):I===!1||S?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})},j5=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",q5=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=ct(),l=s!=="full",d=s==="mobile",c=ln(),m=n?V5(n,o===$5.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&H0(),i()};return ud(uy.Trigger,{type:"button",className:hy("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!py(n,my),"compact-sizing":l,"mobile-border":d}),"aria-label":e,style:m?{"--swatch-color":m}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:p,onPointerDown:c?u=>c.startSwatchDrag(u,n):void 0,children:[cn("div",{className:"color-picker__button-outline",children:!n&&Jx}),l&&n&&r==="stroke"&&cn("div",{className:"color-picker__button-background",children:cn("span",{style:{color:m&&py(m,my)?"#fff":"#111"},children:b0})})]})},J5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=fy,topPicks:a,updateData:s,appState:l,excludedColors:d,customizableTopPicks:c})=>{let m=gy(l.openPopup);W5(()=>{m.current=l.openPopup},[l.openPopup]);let u=ct()!=="full",E=!!c&&!u,g=E&&c?l.colorTopPicks?.[c]:null,b=g?.length?g:a??(e==="elementStroke"?K5:Y5),w=ey({enabled:E,picks:b,onPicksChange:y=>{c&&s({colorTopPicks:{...l.colorTopPicks,[c]:y}})}});return cn(Ih.Provider,{value:E?w:null,children:ud("div",{role:"dialog","aria-modal":"true",className:hy("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&cn(dy,{theme:l.theme,activeColor:n,onChange:y=>{t(y),j5(l.openPopup)&&l.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:g?.length?g:a,isCustomized:!!g?.length,onReset:E&&c?()=>{s({colorTopPicks:{...l.colorTopPicks,[c]:null}})}:void 0}),!u&&cn(rd,{}),ud(uy.Root,{open:l.openPopup===e,onOpenChange:y=>{y&&s({openPopup:e})},children:[cn(q5,{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(Z5,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:d,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},Q5=(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,Ki=U5(J5,Q5);import{Popover as P4}from"radix-ui";import k4 from"clsx";import M4,{useCallback as A4,useMemo as D4}from"react";import{FONT_FAMILY as Ah}from"@excalidraw/common";import E4,{useMemo as ir,useState as b4,useRef as yy,useEffect as wy,useCallback as vy}from"react";import{arrayToList as x4,debounce as y4,FONT_FAMILY as ar,getFontFamilyString as w4}from"@excalidraw/common";import e4 from"clsx";import t4 from"react";import{jsx as n4,jsxs as o4}from"react/jsx-runtime";var hd=t4.forwardRef(({className:e,placeholder:n,onChange:t},o)=>o4("div",{className:e4("QuickSearch__wrapper",e),children:[Jn,n4("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import r4 from"clsx";import{Children as i4}from"react";import{jsx as Ey}from"react/jsx-runtime";var gd=({className:e,placeholder:n,children:t})=>{let o=!i4.count(t);return Ey("div",{className:r4("ScrollableList__wrapper",e),role:"menu",children:o?Ey("div",{className:"empty",children:n}):t})};import{jsx as a4,jsxs as s4}from"react/jsx-runtime";var by=({children:e,className:n="",style:t,title:o})=>s4("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&a4("p",{className:"dropdown-menu-group-title",children:o}),e]}),Gs=by;by.displayName="DropdownMenuGroup";import{THEME as g4}from"@excalidraw/common";import{DropdownMenu as f4}from"radix-ui";import l4,{useContext as c4}from"react";import{composeEventHandlers as d4}from"@excalidraw/common";var Ph=l4.createContext({}),or=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),fd=e=>{let n=c4(Ph);return d4(e,t=>{n.onSelect?.(t)})};import{jsx as m4}from"react/jsx-runtime";var Hs=({children:e,...n})=>m4("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as u4,jsx as Us,jsxs as h4}from"react/jsx-runtime";var p4=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=be();return h4(u4,{children:[n&&Us("div",{className:"dropdown-menu-item__icon",children:n}),Us("div",{style:e,className:"dropdown-menu-item__text",children:Us(Hs,{children:o})}),r&&Us("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Us("div",{className:"dropdown-menu-item__shortcut",children:t})]})},rr=p4;import{jsx as Ed}from"react/jsx-runtime";var kh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let d=fd(s);return Ed(f4.Item,{className:"radix-menu-item",onSelect:d,asChild:!0,children:Ed("button",{...l,value:t,className:or(i,a),title:l.title??l["aria-label"],children:Ed(rr,{icon:e,shortcut:r,badge:n,children:o})})})};kh.displayName="DropdownMenuItem";var Xi={GREEN:"green",RED:"red",BLUE:"blue"},bd=({type:e=Xi.BLUE,children:n})=>{let{theme:t}=Qn(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===g4.LIGHT?"1.5px solid white":"none"};switch(e){case Xi.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Xi.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Xi.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Ed("div",{className:"DropDownMenuItemBadge",style:o,children:n})};bd.displayName="DropdownMenuItemBadge";kh.Badge=bd;var qt=kh;import{KEYS as $i}from"@excalidraw/common";var xy=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[$i.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===$i.F)return n.current?.focus(),!0;if(e.key===$i.ESCAPE)return r(),!0;if(e.key===$i.ENTER)return t?.value&&i(t.value),!0;if(e.key===$i.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===$i.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as wo,jsxs as S4}from"react/jsx-runtime";var v4=e=>{switch(e){case ar.Excalifont:case ar.Virgil:return $n;case ar.Nunito:case ar.Helvetica:return As;case ar["Lilita One"]:return G1;case ar["Comic Shanns"]:case ar.Cascadia:return Vc;default:return As}},I4=(e,n)=>Object.entries(ar).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",Iy=E4.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=Ne(),l=Tt(),{fonts:d}=l,{showDeprecatedFonts:c}=kn(),m=ct(),[p,u]=b4(""),E=yy(null),g=ir(()=>Array.from(fo.registered.entries()).filter(([k,{metadata:L}])=>!L.private&&!L.fallback).map(([k,{metadata:L,fontFaces:F}])=>{let Y={value:k,icon:v4(k),text:I4(k,F)};return L.deprecated&&Object.assign(Y,{deprecated:L.deprecated,badge:{type:Xi.RED,placeholder:f("fontList.badge.old")}}),Y}).sort((k,L)=>k.text.toLowerCase()>L.text.toLowerCase()?1:-1),[]),b=ir(()=>new Set(d.getSceneFamilies()),[e]),w=ir(()=>g.filter(k=>b.has(k.value)),[g,b]),y=ir(()=>g.filter(k=>!b.has(k.value)&&(c||!k.deprecated)),[g,b,c]),x=ir(()=>x4([...w,...y].filter(k=>k.text?.toLowerCase().includes(p))),[w,y,p]),I=ir(()=>{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]),S=vy(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=vy(k=>{xy({event:k,inputRef:E,hoveredFont:I,filteredFonts:x,onSelect:S,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[I,x,S,o,a]);wy(()=>(i(),()=>{a()}),[]);let P=ir(()=>x.filter(k=>b.has(k.value)),[x,b]),M=ir(()=>x.filter(k=>!b.has(k.value)),[x,b]),D=({font:k,order:L})=>{let F=yy(null),Y=k.value===I?.value,z=k.value===e;return wy(()=>{Y&&(L===0?F.current?.scrollIntoView?.({block:"end"}):F.current?.scrollIntoView?.({block:"nearest"}))},[Y,L]),wo("button",{ref:F,type:"button",value:k.value,className:or("",z,Y),title:k.text,tabIndex:z?0:-1,onClick:U=>{S(Number(U.currentTarget.value))},onMouseMove:()=>{I?.value!==k.value&&o(k.value)},children:wo(rr,{icon:k.icon,badge:k.badge&&wo(bd,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:w4({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(wo(Gs,{title:f("fontList.sceneFonts"),children:P.map((k,L)=>wo(D,{font:k,order:L},k.value))},"group_1")),M.length&&_.push(wo(Gs,{title:f("fontList.availableFonts"),children:M.map((k,L)=>wo(D,{font:k,order:L+P.length},k.value))},"group_2")),S4(xo,{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"&&wo(hd,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:y4(u,20)}),wo(gd,{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 T4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as C4}from"@excalidraw/common";import{jsx as Mh}from"react/jsx-runtime";var Sy=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Oe(),r=t?{...C4,width:"2rem",height:"2rem"}:{};return Mh(T4.Trigger,{asChild:!0,children:Mh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Mh(Z,{type:"toggle",icon:Pn,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 Ws,jsxs as Ty}from"react/jsx-runtime";var Cy=[{value:Ah.Excalifont,icon:$n,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Ah.Nunito,icon:As,text:f("labels.normal"),testId:"font-family-normal"},{value:Ah["Comic Shanns"],icon:Vc,text:f("labels.code"),testId:"font-family-code"}],ite=new Set(Cy.map(e=>e.value));var Py=M4.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=D4(()=>Cy,[]),d=A4(c=>{c&&o(c)},[o]);return Ty("div",{role:"dialog","aria-modal":"true",className:k4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&Ws("div",{className:"buttonList",children:Ws(jt,{type:"button",options:l,value:n,onClick:d})}),!s&&Ws(rd,{}),Ty(P4.Root,{open:e,onOpenChange:a,children:[Ws(Sy,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&Ws(Iy,{selectedFontFamily:n,hoveredFontFamily:t,onSelect:d,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,n)=>e.isOpened===n.isOpened&&e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as Dh}from"radix-ui";import N4 from"clsx";import Dy,{useEffect as B4,useMemo as F4}from"react";import{isArrowKey as O4,KEYS as vo}from"@excalidraw/common";import{jsx as L4}from"react/jsx-runtime";var xd=({className:e,icon:n,size:t="1em"})=>L4("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 R4,jsx as ky,jsxs as My}from"react/jsx-runtime";var _4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>My(R4,{children:[My("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&ky(xd,{icon:n?h0:Xc})]}),n&&ky("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),Vs=_4;import{jsx as eo,jsxs as wd}from"react/jsx-runtime";var z4=Qe(!1),yd=4,G4="default",H4=e=>e.flatMap(n=>n.options),Ay=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},U4=(e,n)=>e.some(t=>t.options.some(n)),W4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/yd)},(t,o)=>n.options.slice(o*yd,o*yd+yd)));function V4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=Ne(),[s,l]=Ue(z4),d=[...e,...n],c=H4(d),m=W4([...e,...s?n:[]]),p=g=>{let b=c.find(w=>w.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===vo.TAB){let w=c.findIndex(x=>x.value===t),y=g.shiftKey?(c.length+w-1)%c.length:(w+1)%c.length;r(c[y].value)}else if(O4(g.key)){let w=Xn().rtl,y=c.findIndex(x=>x.value===t);if(y!==-1){let x=c.length,I=y;switch(g.key){case(w?vo.ARROW_LEFT:vo.ARROW_RIGHT):I=(y+1)%x;break;case(w?vo.ARROW_RIGHT:vo.ARROW_LEFT):I=(x+y-1)%x;break;case vo.ARROW_DOWN:{let S=m.findIndex(P=>P.some(M=>M.value===t)),C=m[S];if(S!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(S+1)%m.length],D=M[Math.min(P,M.length-1)]??c[y];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case vo.ARROW_UP:{let S=m.findIndex(P=>P.some(M=>M.value===t)),C=m[S];if(S!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(m.length+S-1)%m.length],D=M[Math.min(P,M.length-1)]??c[y];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(c[I].value)}g.preventDefault()}else(g.key===vo.ESCAPE||g.key===vo.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};B4(()=>{U4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>eo("div",{className:"picker-content",children:g.map(b=>wd("button",{type:"button",className:N4("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&&eo("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,w)=>b.name===G4?eo(Dy.Fragment,{children:u(b.options)},`${b.name}-${w}`):wd("div",{className:"picker-section",children:[eo("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${w}`));return eo(Dh.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:wd("div",{className:"picker-sections",children:[E(e),n.length>0&&eo(Vs,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:eo("div",{className:"picker-sections",children:E(n)})})]})})}function Lh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=Dy.useState(!1),s=F4(()=>Ay(t,l=>l.value===e)??Ay(o??[],l=>l.value===e),[t,o,e]);return eo("div",{children:wd(Dh.Root,{open:i,onOpenChange:l=>a(l),children:[eo(Dh.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&eo(V4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import Ly,{useEffect as Y4}from"react";import{jsx as _h,jsxs as _y}from"react/jsx-runtime";var Ry=({label:e,value:n,onChange:t,min:o=0,max:r=100,step:i=10,minLabel:a=o,hasCommonValue:s=!0,testId:l})=>{let d=Ly.useRef(null),c=Ly.useRef(null);return Y4(()=>{if(d.current&&c.current){let m=d.current,p=c.current,u=m.offsetWidth,E=parseFloat(getComputedStyle(m).getPropertyValue("--slider-thumb-size"))||16,g=(n-o)/(r-o||1)*100,b=g/100*(u-E)+E/2;p.style.left=`${b}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${g}%, var(--button-bg) ${g}%, var(--button-bg) 100%)`}},[r,o,n]),_y("label",{className:"control-label",children:[e,_y("div",{className:"range-wrapper",children:[_h("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:d,type:"range",min:o,max:r,step:i,onChange:m=>{t(+m.target.value)},value:n,className:"range-input","data-testid":l}),_h("div",{className:"value-bubble",ref:c,children:n!==o?n:null}),_h("div",{className:"zero-label",children:a})]})]})};import{Fragment as kd,jsx as ee,jsxs as bt}from"react/jsx-runtime";var Vy=.1,Vr=e=>{let n=f6(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Ct=(e,n,t,o=!1)=>{let r=Oh(ce(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(c6(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},mt=function(e,n,t,o,r){let i=n.state.editingTextElement,a=Uy(e),s=null;if(i&&(s=t(i)),!s)if(Le(a,n.state)){let d=n.scene.getSelectedElements(n.state),c=o===!0?d:d.filter(m=>o(m));s=s6(c,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},E6=(e,n,t)=>m6(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}),zh=(e,n,t,o,r)=>{let i=new Set,a=Ct(e,n,s=>{if(Ht(s)){let l=o(s);i.add(l);let d=at(s,{fontSize:l});return Ys(d,t.scene.getContainerElement(s),t.scene),d=E6(s,d,t.scene),d}return s},!0);return ce(e,n,{includeBoundTextElement:!0}).forEach(s=>{Ht(s)&&d6(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:tt.IMMEDIATELY}},b6=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Ct(e,n,o=>u6(o.type)?at(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?tt.IMMEDIATELY:tt.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Vr(o);return bt(kd,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.stroke")}),ee(Ki,{topPicks:J4,palette:q4,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:mt(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),x6=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:tt.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!a6(t.currentItemBackgroundColor)&&i.every(s=>Oy(s)&&l6(s.points))){let s=Oh(i);r=e.map(l=>s.has(l.id)&&Oy(l)?at(l,{backgroundColor:t.currentItemBackgroundColor,...g6(l,!0)}):l)}else r=Ct(e,n,s=>at(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Vr(o);return bt(kd,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(Ki,{topPicks:j4,palette:Gy,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:mt(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),Pd=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:tt.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=Vr(o);return bt(kd,{children:[r==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(Ki,{topPicks:$4,palette:Gy,excludedColors:[Z4.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})]})}}),y6=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Fe("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Ct(e,n,r=>at(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ce(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return bt("fieldset",{children:[ee("legend",{children:f("labels.fill")}),ee("div",{className:"buttonList",children:ee(jt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?l1:c1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:d1,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:m1,testId:"fill-solid"}],value:mt(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(d=>d.fillStyle==="hachure")?"zigzag":a;t(l)}})})]})}}),w6=e=>n6.find(n=>Hy(e.type,n)===e.strokeWidth)??null,v6=(e,n)=>Hy(e.type,n),I6=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(Cd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Ct(e,n,o=>at(o,{strokeWidth:v6(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[ee("legend",{children:f("labels.strokeWidth")}),ee("div",{className:"buttonList",children:ee(jt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:Xu,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:p1,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:u1,testId:"strokeWidth-bold"}],value:mt(e,o,w6,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),S6=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>at(o,{seed:o6(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[ee("legend",{children:f("labels.sloppiness")}),ee("div",{className:"buttonList",children:ee(jt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:f1},{value:1,text:f("labels.artist"),icon:E1},{value:2,text:f("labels.cartoonist"),icon:b1}],value:mt(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),T6=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:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=mt(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?Zu:$u,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return bt("fieldset",{children:[ee("legend",{children:f("labels.pressure")}),ee("div",{className:"buttonList",children:ee(jt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:$u},{value:"variable",text:f("labels.pressure_variable"),icon:Zu}],value:i,onChange:a=>t(a)})})]})}}),mne=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:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>bt("fieldset",{children:[ee("legend",{children:f("labels.strokeStyle")}),ee("div",{className:"buttonList",children:ee(jt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Xu},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:h1},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:g1}],value:mt(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),C6=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:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=mt(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return ee(Ry,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),P6=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>zh(e,n,o,()=>(Cd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Vr(o);return bt("fieldset",{children:[ee("legend",{children:f("labels.fontSize")}),ee("div",{className:"buttonList",children:ee(jt,{group:"font-size",options:[{value:Id.sm,text:f("labels.small"),icon:B1,testId:"fontSize-small"},{value:Id.md,text:f("labels.medium"),icon:F1,testId:"fontSize-medium"},{value:Id.lg,text:f("labels.large"),icon:O1,testId:"fontSize-large"},{value:Id.xl,text:f("labels.veryLarge"),icon:z1,testId:"fontSize-veryLarge"}],value:mt(e,o,a=>{if(Ht(a))return a.fontSize;let s=sr(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Ht(a)||sr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||e6),onChange:a=>{Rs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),Gh=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:zr,trackEvent:!1,perform:(e,n,t,o)=>zh(e,n,o,r=>Math.round(1/(1+Vy)*r.fontSize)),keyTest:e=>e[Zi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Zi.CHEVRON_LEFT||e.key===Zi.COMMA)}),Hh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:zr,trackEvent:!1,perform:(e,n,t,o)=>zh(e,n,o,r=>Math.round(r.fontSize*(1+Vy))),keyTest:e=>e[Zi.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Zi.CHEVRON_RIGHT||e.key===Zi.PERIOD)}),k6=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:tt.NEVER};Cd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:d}=t,c=tt.EVENTUALLY,m,p=!1;if(l)m=l,c=tt.IMMEDIATELY;else if(d){m=d,c=tt.EVENTUALLY;let E=ce(e,n,{includeBoundTextElement:!0}).filter(g=>Ht(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:c};if(m&&!p){let E=new Map,g=new Set,b=!1,w=Array.from(fo.loadedFontsCache.values()),y=Object.entries(t6).find(([S,C])=>C===m)?.[0];d&&y&&w.some(S=>S.startsWith(y))&&(b=!0),Object.assign(u,{elements:Ct(e,n,S=>{if(Ht(S)&&(S.fontFamily!==m||l)){let C=at(S,{fontFamily:m,lineHeight:i6(m)}),P=r?.get(S.containerId||"")||{},M=o.scene.getContainerElement(S);return a&&M&&P&&o.scene.mutateElement(M,{...P}),b||(g=new Set([...g,...Array.from(C.originalText)])),E.set(C,M),C}return S},!0)});let x=`10px ${r6({fontFamily:m})}`,I=Array.from(g.values()).join();if(b||window.document.fonts.check(x,I))for(let[S,C]of E)Ys(S,C,o.scene);else window.document.fonts.load(x,I).then(S=>{for(let[C,P]of E){let M=o.scene.getElement(C.id),D=P?o.scene.getElement(P.id):null;M&&Ys(M,D,o.scene)}o.fonts.onLoaded(S)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=Nh(new Map),i=Nh(null),[a,s]=X4({}),l=Nh(!0),{stylesPanelMode:d,isCompact:c}=Vr(t),m=Fh(()=>{let p=(u,E)=>mt(u,t,g=>{if(Ht(g))return g.fontFamily;let b=sr(g,E);return b?b.fontFamily:null},g=>Ht(g)||sr(g,E)!==null,g=>g?null:n.currentItemFontFamily||Q4);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 Rh(()=>{i.current=m},[m]),Rh(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),Rh(()=>(l.current=!1,()=>{l.current=!0}),[]),bt(kd,{children:[d==="full"&&ee("legend",{children:f("labels.fontFamily")}),ee(Py,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:d!=="full",onSelect:p=>{Rs(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:p}),r.current.clear()},c,!!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=ce(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(),c&&n.editingTextElement&&_s(null)}}})]})}}),M6=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Ht(r)){let i=at(r,{textAlign:t});return Ys(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=Vr(o);return bt("fieldset",{children:[ee("legend",{children:f("labels.textAlign")}),ee("div",{className:"buttonList",children:ee(jt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:H1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:U1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:W1,testId:"align-right"}],value:mt(e,o,s=>{if(Ht(s))return s.textAlign;let l=sr(s,i);return l?l.textAlign:null},s=>Ht(s)||sr(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{Rs(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),A6=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Ht(r)){let i=at(r,{verticalAlign:t});return Ys(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Vr(o);return ee("fieldset",{children:ee("div",{className:"buttonList",children:ee(jt,{group:"text-align",options:[{value:vd.TOP,text:f("labels.alignTop"),icon:ee(V1,{theme:n.theme}),testId:"align-top"},{value:vd.MIDDLE,text:f("labels.centerVertically"),icon:ee(K1,{theme:n.theme}),testId:"align-middle"},{value:vd.BOTTOM,text:f("labels.alignBottom"),icon:ee(Y1,{theme:n.theme}),testId:"align-bottom"}],value:mt(e,o,a=>{if(Ht(a)&&a.containerId)return a.verticalAlign;let s=sr(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Ht(a)||sr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:vd.MIDDLE),onChange:a=>{Rs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),pne=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>Wy(o)?o:at(o,{roundness:t==="round"?{type:p6(o.type)?Sd.ADAPTIVE_RADIUS:Sd.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=Ci(Uy(e),n).some(s=>s.roundness?.type===Sd.LEGACY);return bt("fieldset",{children:[ee("legend",{children:f("labels.edges")}),bt("div",{className:"buttonList",children:[ee(jt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:x1},{value:"round",text:f("labels.round"),icon:y1}],value:mt(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!Td(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),zy=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:ee(w1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:ee(v1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:ee(I1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:ee(S1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:ee(T1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ee(C1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:ee(P1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:ee(k1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:ee(M1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:ee(A1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:ee(D1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:ee(L1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:ee(_1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:ee(R1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:ee(N1,{flip:e}),keyBinding:null}]}]}),une=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(Cd(t,"actionChangeArrowhead: value must be defined"),{elements:Ct(e,n,o=>{if(Bh(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:tt.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=Xn().rtl,i=Fh(()=>zy(!r),[r]),a=Fh(()=>zy(!!r),[r]);return bt("fieldset",{children:[ee("legend",{children:f("labels.arrowheads")}),bt("div",{className:"iconSelectList buttonList",children:[ee(Lh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:mt(e,o,s=>Bh(s)&&Es(s.type)?Fy(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),ee(Lh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:mt(e,o,s=>Bh(s)&&Es(s.type)?Fy(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),D6=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})=>bt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),hne=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Ct(e,n,s=>{if(!Td(s))return s;let l=o.scene.getNonDeletedElementsMap(),d=Wr.getPointAtIndexGlobalCoordinates(s,0,l),c=Wr.getPointAtIndexGlobalCoordinates(s,-1,l),m=at(s,{x:t===dn.elbow?d[0]:s.x,y:t===dn.elbow?d[1]:s.y,roundness:t===dn.round?{type:Sd.PROPORTIONAL_RADIUS}:null,elbowed:t===dn.elbow,angle:t===dn.elbow?0:s.angle,points:t===dn.elbow||s.elbowed?[Wr.pointFromAbsoluteCoords({...s,x:d[0],y:d[1],angle:0},d,l),Wr.pointFromAbsoluteCoords({...s,x:d[0],y:d[1],angle:0},c,l)]:s.points});if(Wy(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=Wr.getPointAtIndexGlobalCoordinates(m,0,p),E=Wr.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,...By(m,g,"start",p,n.isBindingEnabled)}:null,y=b&&m.endBinding?{...m.endBinding,...By(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:w,endBinding:y,...h6(m,p,{points:[u,E].map(x=>K4(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&&Ny(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&Ny(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 Wr(s,Oh(e)))}return{elements:r,appState:i,captureUpdate:tt.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>bt("fieldset",{children:[ee("legend",{children:f("labels.arrowtypes")}),ee("div",{className:"buttonList",children:ee(jt,{group:"arrowtypes",options:[{value:dn.sharp,text:f("labels.arrowtype_sharp"),icon:qo,testId:"sharp-arrow"},{value:dn.round,text:f("labels.arrowtype_round"),icon:Qo,testId:"round-arrow"},{value:dn.elbow,text:f("labels.arrowtype_elbowed"),icon:Jo,testId:"elbow-arrow"}],value:mt(e,o,r=>Td(r)?r.elbowed?dn.elbow:r.roundness?dn.round:dn.sharp:null,r=>Td(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as O6,MAX_ZOOM as z6,MIN_ZOOM as G6,THEME as Ks,ZOOM_STEP as Xy,CODES as Yr,KEYS as Ad}from"@excalidraw/common";import{getNonDeletedElements as Xs}from"@excalidraw/element";import{getCommonBounds as $s}from"@excalidraw/element";import{CaptureUpdateAction as Ji}from"@excalidraw/element";import{useEffect as L6}from"react";import{jsx as R6}from"react/jsx-runtime";var ji=()=>{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},Uh=(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`})},_6=(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();Uh(n,r)},pt=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(L6(()=>()=>ji().classList.remove("excalidraw-tooltip--visible"),[]),r?null:R6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>_6(i.currentTarget,ji(),n,t),onPointerLeave:()=>ji().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as Yy,useRef as Ky,useState as N6}from"react";var B6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Wh=(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 B6(o,n)};function qi(e,n=!0){let t=Md(),[,o]=N6(0),r=Ky(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Wh(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Wh(t,e,n)),Yy(()=>{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 F6(e,n){let t=Md(),o=Ky({selector:e,callback:n});o.current.selector=e,o.current.callback=n,Yy(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Wh(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Nd,jsxs as W6}from"react/jsx-runtime";var H6=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?Ji.IMMEDIATELY:Ji.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Nd(Ki,{palette:null,topPicks:O6,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})}),Dd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:Au,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...go({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(n.zoom.value+Xy)},n)},captureUpdate:Ji.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=qi(t=>t.zoom.value);return Nd(Z,{type:"button",className:"zoom-in-button zoom-button",icon:Au,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=z6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Yr.EQUAL||e.code===Yr.NUM_ADD)&&(e[Ad.CTRL_OR_CMD]||e.shiftKey)}),Ld=O({name:"zoomOut",label:"buttons.zoomOut",icon:Du,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...go({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(n.zoom.value-Xy)},n)},captureUpdate:Ji.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=qi(t=>t.zoom.value);return Nd(Z,{type:"button",className:"zoom-out-button zoom-button",icon:Du,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=G6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Yr.MINUS||e.code===Yr.NUM_SUBTRACT)&&(e[Ad.CTRL_OR_CMD]||e.shiftKey)}),_d=O({name:"resetZoom",label:"buttons.resetZoom",icon:Vx,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,...go({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Yn(r)},n)},captureUpdate:Ji.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=qi(t=>t.zoom.value);return Nd(pt,{label:f("buttons.resetZoom"),style:{height:"100%"},children:W6(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===Yr.ZERO||e.code===Yr.NUM_ZERO)&&(e[Ad.CTRL_OR_CMD]||e.shiftKey)}),Vh=e=>[e.x,e.y,e.x+e.width,e.y+e.height],Yne=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Kc,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?$s(Xs(r)):n.scrollConstraints?Vh(n.scrollConstraints):$s(Xs(e)),a=_r({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Vn(a.appState)}}},keyTest:void 0}),Kne=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Kc,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?$s(Xs(r)):n.scrollConstraints?Vh(n.scrollConstraints):$s(Xs(e)),a=_r({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Vn(a.appState)}}},keyTest:void 0}),U6=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Kc,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?Vh(n.scrollConstraints):$s(Xs(e)),i=_r({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Vn(i.appState)}}},keyTest:void 0}),Rd=O({name:"toggleTheme",label:(e,n)=>n.theme===Ks.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===Ks.LIGHT?Cs:Ps,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===Ks.LIGHT?Ks.DARK:Ks.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:Ji.EVENTUALLY}},keyTest:e=>!e[Ad.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Yr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as eD}from"@excalidraw/math";import{bindOrUnbindBindingElement as iw}from"@excalidraw/element/binding";import{isValidPolygon as aw,newElementWith as Xh}from"@excalidraw/element";import{LinearElementEditor as Qs}from"@excalidraw/element/linearElementEditor";import{isBindingElement as $h,isFreeDrawElement as sw,isLinearElement as lw,isLineElement as Ud}from"@excalidraw/element";import{KEYS as Wd,arrayToMap as tD,invariant as cw,shouldRotateWithDiscreteAngle as nD,updateActiveTool as dw}from"@excalidraw/common";import{isPathALoop as oD}from"@excalidraw/element";import{isInvisiblySmallElement as Zh}from"@excalidraw/element";import{CaptureUpdateAction as jh}from"@excalidraw/element";import $6 from"clsx";import{useEffect as Z6,useState as j6}from"react";import{KEYS as mn,capitalizeString as Kr}from"@excalidraw/common";var V6=(e,n)=>{if(!n.key&&!n.code)return!1;let t=n.key?n.key.length===1?e.key.toLocaleLowerCase()===n.key.toLocaleLowerCase():e.key===n.key:!0,o=n.code?e.code===n.code:!0,r=n.ctrlOrCmd===!0;return t&&o&&(r?e.ctrlKey||e.metaKey:e.ctrlKey===!!n.ctrl)&&(r?!0:e.metaKey===!!n.meta)&&e.altKey===!!n.alt&&e.shiftKey===!!n.shift},Qi=(e,n)=>n.some(t=>V6(e,t)),$y=e=>{let n=[e.ctrlOrCmd&&"CtrlOrCmd",e.ctrl&&"Ctrl",e.meta&&"Meta",e.alt&&"Alt",e.shift&&"Shift"].filter(Boolean),t=e.key??e.code??"";return N([...n,t.length===1?t.toLocaleUpperCase():t].join("+"))};import{useEffect as Y6,useState as K6}from"react";import Zy from"clsx";import{capitalizeString as Bd}from"@excalidraw/common";import{Popover as Yh}from"radix-ui";import{jsx as Fd,jsxs as X6}from"react/jsx-runtime";var ea=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=K6(!1),d=t.type,c=a.type===d,m=16,{container:p}=Ne();return!n.some(u=>u.type===d)&&s&&l(!1),Y6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),X6(Yh.Root,{open:s,children:[Fd(Yh.Trigger,{asChild:!0,children:Fd(Z,{className:Zy({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:c,disabled:n.every(u=>Je(e,u.type)),title:Bd(a.title),"aria-label":Bd(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Fd(Yh.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Fd(Z,{className:Zy({fillable:b}),type:"toggle",icon:E,checked:d===u,disabled:Je(e,u),title:Bd(u),"aria-label":Bd(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Fe("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as Kh}from"react/jsx-runtime";var q6=e=>e,ze=q6({hand:{icon:X1,letterKey:mn.H,toggle:!0},selection:{icon:Oc,letterKey:mn.V,fillable:!0},rectangle:{icon:_i,letterKey:mn.R,fillable:!0},diamond:{icon:Ri,letterKey:mn.D,fillable:!0},ellipse:{icon:Ni,letterKey:mn.O,fillable:!0},arrow:{icon:zc,letterKey:mn.A,fillable:!0},line:{icon:$o,letterKey:mn.L,fillable:!0},freedraw:{icon:$n,letterKey:mn.P},text:{icon:Pn,letterKey:mn.T},image:{icon:Fr},eraser:{icon:Gc,letterKey:mn.E,toggle:!0},frame:{icon:jn,letterKey:mn.F},autoshape:{icon:Gr,letterKey:mn.X,fillable:!1},embeddable:{icon:Zo},laser:{icon:qn},bucketfill:{icon:Zn},lasso:{icon:Li,fillable:!1}});var ta=["autoshape","rectangle","diamond","ellipse","arrow","line"],na=Object.keys(ze).filter(e=>ze[e].toggle),Od=e=>{let{letterKey:n,shiftKey:t}=ze[e];if(!n)return n;let o=Kr(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},oa=e=>Od(e),J6=e=>{let n=Od(e);return n?.length===1?n:void 0},Q6=(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},jy=(e,n)=>{for(let r of Object.keys(ze)){let i=n.props.keyboardShortcuts?.[`tool:${r}`];if(i!==void 0){if(Qi(e,i))return r==="selection"?n.state.preferredSelectionTool.type:r;continue}}if(e.ctrlKey||e.metaKey||e.altKey)return null;let t=Q6(e.key,n,e.shiftKey);if(!t)return null;let o=(t==="selection"||t==="lasso")&&ze.selection.letterKey===e.key.toLocaleLowerCase()?"tool:selection":`tool:${t}`;return n.props.keyboardShortcuts?.[o]===void 0?t:null},Je=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Ut=(e,n)=>{let t=ze[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let d=Kr(f(`toolBar.${e}`)),c=i.props.keyboardShortcuts?.[`tool:${o}`],m=l?null:c!==void 0?c[0]?$y(c[0]):null:oa(o);return Kh(Z,{className:$6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:Je(i,e),title:m?`${d} \u2014 ${m}`:d,keyBindingLabel:s||l?void 0:c!==void 0?m?.length===1?m:void 0:J6(o),"aria-label":d,"aria-keyshortcuts":m??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:p})=>{if(!i.state.penDetected&&p==="pen"&&i.togglePenMode(!0),n?.onSelect){n.onSelect(i,{pointerType:p});return}i.state.activeTool.type!==e&&(Fe("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Kr(e)}IconButton`,r},zd=Ut("hand"),qy=Ut("rectangle"),Jy=Ut("diamond"),Qy=Ut("ellipse"),ew=Ut("arrow"),tw=Ut("line"),Zs=Ut("freedraw"),js=Ut("text"),qs=Ut("image"),Js=Ut("eraser"),nw=Ut("frame"),Soe=Ut("autoshape"),ow=Ut("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Fe("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),rw=Ut("lasso",{shortcutType:"selection"}),Gd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:ze.selection.icon,fillable:ze.selection.fillable,title:Kr(f("toolBar.selection"))},{type:"lasso",icon:ze.lasso.icon,fillable:ze.lasso.fillable,title:Kr(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return Kh(ea,{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})},Hd=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:ze.freedraw.icon,fillable:ze.freedraw.fillable,title:Kr(f("toolBar.freedraw"))},{type:"autoshape",icon:ze.autoshape.icon,fillable:ze.autoshape.fillable,title:Kr(f("toolBar.autoshape"))}],[o,r]=j6(n.type==="autoshape"?"autoshape":"freedraw");Z6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return Kh(ea,{app:e,options:t,activeTool:n,defaultOption:o,"data-testid":"toolbar-freedraw",onToolChange:a=>{(a==="freedraw"||a==="autoshape")&&(r(a),e.setActiveTool({type:a}))},displayedOption:i})};import{jsx as rD}from"react/jsx-runtime";var ut=O({name:"finalize",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=!0,i=e,{focusContainer:a,scene:s}=o,l=s.getNonDeletedElementsMap(),d=n.activeTool.type==="autoshape";if(t&&n.selectedLinearElement){let{event:b,sceneCoords:w}=t,y=Qs.getElement(n.selectedLinearElement.elementId,l);cw(y,"Arrow element should exist if selectedLinearElement is set"),cw(w,"sceneCoords should be defined if actionFinalize is called with event");let x=Qs.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if($h(y)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let I=!!n.newElement,S=I||!n.selectedLinearElement.selectedPointsIndices?[y.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=nD(b),P=b[Wd.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),M=S.reduce((D,_)=>(D.set(_,{point:C?y.points[_]:Qs.createPointAt(y,l,w.x-x.pointerOffset.x,w.y-x.pointerOffset.y,P)}),D),new Map)??new Map;iw(y,M,w.x,w.y,s,n,{newArrow:I,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else Ud(y)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!aw(y.points)&&s.mutateElement(y,{polygon:!1});if(x!==n.selectedLinearElement){y&&Zh(y)&&(i=i.map(S=>S.id===y.id?Xh(S,{isDeleted:!0}):S));let I=n.activeTool?.locked;return{elements:y.points.length<2||Zh(y)?e.map(S=>S.id===y.id?Xh(S,{isDeleted:!0}):S):i,appState:{...n,cursorButton:"up",selectedElementIds:d?{}:n.selectedElementIds,selectedLinearElement:I||d?null:{...x,selectedPointsIndices:null,isEditing:!1,initialState:{...x.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:jh.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let c=o.drawShape.hasPendingGesture();(c||d)&&(o.drawShape.finalize(),c&&(i=o.scene.getElementsIncludingDeleted()));let m=null;if(n.multiElement)m=n.multiElement;else if(!d&&!c&&(n.newElement?.type==="freedraw"||$h(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)}),$h(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=Qs.getPointAtIndexGlobalCoordinates(m,-1,l);iw(m,x,I[0],I[1],s,n,{newArrow:y})}}if(m&&Zh(m)&&(i=i.map(b=>b.id===m?.id?Xh(b,{isDeleted:!0}):b)),lw(m)||sw(m)){if(oD(m.points,n.zoom.value)&&(Ud(m)||sw(m))){let w=m.points,y=w[0],x=w.map((I,S)=>S===w.length-1?eD(y[0],y[1]):I);Ud(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}Ud(m)&&!aw(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;na.includes(n.activeTool.type)?p=dw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=dw(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&&lw(m)?new Qs(m,tD(i)):n.selectedLinearElement;return g=g&&{...g,isEditing:n.newElement?!1:g.isEditing,initialState:{...g.initialState,lastClickedPoint:-1,origin:null}},{elements:i,appState:{...n,cursorButton:"up",activeTool:E?n.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:d?{}:m&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[m.id]:!0}:n.selectedElementIds,selectedLinearElement:d?null:g},captureUpdate:r?jh.IMMEDIATELY:jh.NEVER}},keyTest:(e,n)=>e.key===Wd.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===Wd.ESCAPE||e.key===Wd.ENTER)&&n.multiElement!==null,keyCondition:(e,n)=>!!n.selectedLinearElement?.isEditing||n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>rD(Z,{type:"button",icon:t1,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 gw,isSomeElementSelected as mw,makeNextSelectedElementIds as iD,selectGroupsForSelectedElements as aD}from"@excalidraw/element";import{CaptureUpdateAction as pw}from"@excalidraw/element";import{KEYS as sD,isWritableElement as uw,updateActiveTool as hw}from"@excalidraw/common";var lD=(e,n)=>na.includes(e.activeTool.type)?hw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):hw(e,{type:n.state.preferredSelectionTool.type}),cD=(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:gw(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},dD=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=lD(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:gw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...aD({editingGroupId:cD(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:iD({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:pw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==sD.ESCAPE||uw(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||mw(o.scene.getNonDeletedElements(),n)),keyCondition:(e,n,t,o)=>!uw(e.target)&&!n.newElement&&n.multiElement===null&&!n.selectedLinearElement?.isEditing&&(n.activeEmbeddable!==null||n.activeTool.type!==o.state.preferredSelectionTool.type||!!n.editingGroupId||!!n.selectedLinearElement||mw(o.scene.getNonDeletedElements(),n))});import{KEYS as Jd,THEME as ol}from"@excalidraw/common";import{CaptureUpdateAction as Mn}from"@excalidraw/element";import mD from"clsx";import{jsx as fw,jsxs as pD}from"react/jsx-runtime";var qh=({children:e,checked:n,onChange:t,className:o})=>pD("div",{className:mD("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[fw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:Hc}),fw("div",{className:"Checkbox-label",children:e})]});import{THEME as el}from"@excalidraw/common";import{jsx as tl}from"react/jsx-runtime";var bw=e=>{let n=e.title||(e.value===el.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return tl(Z,{type:"icon",icon:e.value===el.LIGHT?Ew.MOON:Ew.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===el.DARK?el.LIGHT:el.DARK),"data-testid":"toggle-dark-mode"})},Ew={SUN:tl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:tl("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:tl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:tl("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 uD}from"react";import{focusNearestParent as hD,KEYS as gD}from"@excalidraw/common";import{jsx as xw,jsxs as fD}from"react/jsx-runtime";var yw=e=>{let{id:n}=Ne(),[t,o]=uD(e.value),r=a=>{e.ignoreFocus||hD(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===gD.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return fD("div",{className:"ProjectName",children:[xw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),xw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as ED,useEffect as bD,useRef as xD}from"react";import{jsx as Vd,jsxs as ID}from"react/jsx-runtime";var yD=5e3,wD=({progress:e})=>Vd("div",{className:"Toast__progress-bar",children:Vd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),vD=({message:e,onClose:n,closable:t=!1,duration:o=yD,style:r})=>{let i=xD(0),a=o!==1/0,s=ED(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return bD(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),ID("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Vd("div",{className:"Toast__message",children:e}),t&&Vd(Z,{icon:an,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},Yd=Object.assign(vD,{ProgressBar:wD});import{DEFAULT_EXPORT_PADDING as HD,DEFAULT_FILENAME as UD,IMAGE_MIME_TYPES as Cw,isFirefox as WD,MIME_TYPES as VD,cloneJSON as YD,SVG_DOCUMENT_PREAMBLE as KD,arrayToMap as XD}from"@excalidraw/common";import{getNonDeletedElements as $D}from"@excalidraw/element";import{isFrameLikeElement as ZD}from"@excalidraw/element";import{getElementsOverlappingFrame as jD}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as SD,EXPORT_DATA_TYPES as nl,MIME_TYPES as ht,arrayToMap as TD,isMemberOf as CD,isPromiseLike as PD,EVENT as Kd}from"@excalidraw/common";import{mutateElement as kD}from"@excalidraw/element";import{deepCopyElement as MD}from"@excalidraw/element";import{isFrameLikeElement as AD,isInitializedImageElement as DD}from"@excalidraw/element";import{getContainingFrame as ww}from"@excalidraw/element";var Ure="clipboard"in navigator&&"readText"in navigator.clipboard,Xd="clipboard"in navigator&&"writeText"in navigator.clipboard,lr="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,LD=e=>!!([nl.excalidraw,nl.excalidrawClipboard,nl.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),vw=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Kd.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},_D=({elements:e,files:n})=>{let t=TD(e),o=new Set(e.filter(s=>AD(s))),r=!1,i=e.reduce((s,l)=>(DD(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:nl.excalidrawClipboard,elements:e.map(s=>{if(ww(s,t)&&!o.has(ww(s,t))){let l=MD(s);return kD(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},$d=async(e,n,t)=>{let o=_D({elements:e,files:n});await Io({[ht.excalidrawClipboard]:o,[ht.text]:o},t)};function Iw(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(Iw(t));return n}var RD=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,ht.html),o=Iw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Sw=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{[ht.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(CD(SD,o))try{if(o===ht.text||o===ht.html)e[o]=await(await t.getType(o)).text();else if(yx(o)){let r=await t.getType(o),i=Px(r,o,void 0);e[o]=i}else throw new Tu(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof Tu?r.message:`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},ND=async(e,n=!1)=>{try{let t=e.findByType(ht.html),o=!n&&t&&RD(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(ht.text)??o.value.map(r=>r.value).join(`
2
+ `).trim()}:o:{type:"text",value:(e.getData(ht.text)||"").trim()}}catch{return{type:"text",value:""}}},BD=function(e){return this.find(n=>n.type===e)||null},FD=function(e){return this.find(t=>t.type===e)?.value??null},OD=function(){return this.filter(e=>e.kind==="file")},Jh=e=>{let n=Qh(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),ht.text,ht.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}},zD=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}}),Zd=(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===ht.html)try{let E=new DOMParser().parseFromString(u.value,ht.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===ht.text?a(r,u.value):u.type==="text/uri-list"&&s(r,u.value)});let l=[...o,...r.filter(u=>!o.includes(u))],d=Array.from({length:n},()=>({})),c={...t??{items:[],files:[],types:[],data:{}},parsedItems:zD(e)};d.forEach((u,E)=>{let g=l[E],b=i[E];g&&(u.src=g),b&&(u.alt=b),u.rawDragData=c});let m=l.slice(d.length),p=d[0];return p&&m.length>0&&m.forEach((u,E)=>{p[`additionalUrl${E+1}`]=u}),d},Tw=e=>{let n;Qh(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},Xr=async e=>{let n;Qh(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 Cx(o);return r=await Br(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:BD,getData:FD,getFiles:OD})},jd=async(e,n=!1)=>{let t=await ND(e,n);if(t.type==="mixedContent")return{mixedContent:t.value};try{let o=JSON.parse(t.value),r=o.type===nl.excalidrawClipboardWithAPI;if(LD(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}},qd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[ht.png]:e})])}catch(n){if(PD(e))await navigator.clipboard.write([new ClipboardItem({[ht.png]:await e})]);else throw n}},Io=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[ht.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===ht.text);if(Xd&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!GD(o[1]))throw new Error("Error copying to clipboard.")},GD=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},Qh=e=>e.type===Kd.PASTE||e.type===Kd.COPY||e.type===Kd.CUT;var $r=(e,{selectedElementIds:n},t)=>{let o=$D(e),r=XD(o),i=t&&Le(o,{selectedElementIds:n}),a=null,s=i?ce(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&ZD(l)?(a=l,s=jD(o,l,r)):s.length>1&&(s=ce(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:YD(s)}},Zr=async(e,n,t,o,{exportBackground:r,exportPadding:i=HD,viewBackgroundColor:a,name:s=t.name||UD,fileHandle:l=null,exportingFrame:d=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Rr(n,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},o,{exportingFrame:d});if(e==="svg")return Cu(m.then(p=>new Blob([KD+p.outerHTML],{type:VD.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Cw.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await Io(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let c=Lc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:d});if(e==="png"){let m=Is(c);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-PXICHQZX.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:xs(n,t,o,"local")})))),Cu(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Cw.png],fileHandle:l})}else if(e==="clipboard")try{let m=Is(c);await qd(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):WD&&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 vw=async(e,n,t)=>{let o=fx(n);if(!Ex(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}=$r(r,i,!1);return await Zr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as KD,jsx as cr,jsxs as Cw}from"react/jsx-runtime";var eg=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>cr(gw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),Iw=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:Mn.EVENTUALLY})}),tg=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>cr(jh,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),Qd=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Cw(jh,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),cr(pt,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:cr("div",{className:"excalidraw-tooltip-icon",children:e1})})]})}),oa=!1,Qh=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?Cw(KD,{children:[t,cr(Yd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function XD(e,n){if(n.app.state.isLoading&&(Qh(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")Qh(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Qh(n.app,{progress:null}),await e)}function Tw(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await XD(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:ks,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(oa)return!1;oa=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=Tw(e,n,o.files,o);try{let{fileHandle:l}=_c(r)?await vw(s,r,i):await kc({data:s,filename:i,fileHandle:r});return{captureUpdate:Mn.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:Mn.NEVER,appState:{toast:null}}}finally{oa=!1}},keyTest:e=>!1}),rl=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:ks,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(oa)return!1;oa=!0;let{abortController:r,data:i}=Tw(e,n,o.files,o);try{let{fileHandle:a}=await kc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:Mn.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:Mn.NEVER,appState:{toast:null}}}finally{oa=!1}},keyTest:e=>e.key.toLowerCase()===Jd.S&&e.shiftKey&&e[Jd.CTRL_OR_CMD],PanelComponent:({updateData:e})=>cr(Z,{type:"button",icon:Zx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:be().formFactor==="phone",hidden:!Pi,onClick:()=>e(null),"data-testid":"save-as-button"})}),ra=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 Cu(n,e);return{elements:r,appState:i,files:a,captureUpdate:Mn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:Mn.EVENTUALLY}}},keyTest:e=>e[Jd.CTRL_OR_CMD]&&e.key===Jd.O}),Sw=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?ol.DARK:ol.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>cr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:cr(uw,{value:e.exportWithDarkMode?ol.DARK:ol.LIGHT,onChange:t=>{n(t===ol.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as $D,DEFAULT_FONT_FAMILY as ZD,DEFAULT_TEXT_ALIGN as jD,getLineHeight as qD}from"@excalidraw/common";import{newElementWith as em}from"@excalidraw/element";import{hasBoundTextElement as JD,canApplyRoundnessTypeToElement as QD,getDefaultRoundnessTypeForElement as eL,isFrameLikeElement as tL,isArrowElement as nL,isExcalidrawElement as oL,isTextElement as Pw}from"@excalidraw/element";import{getBoundTextElement as rL,redrawTextBoundingBox as iL}from"@excalidraw/element";import{CaptureUpdateAction as ng}from"@excalidraw/element";var kw="{}",aL=O({name:"copyStyles",label:"labels.copyStyles",icon:qu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&JD(i)){let a=rL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(kw=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:ng.EVENTUALLY}}}),sL=O({name:"pasteStyles",label:"labels.pasteStyles",icon:qu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(kw),i=r[0],a=r[1];if(!oL(i))return{elements:e,captureUpdate:ng.EVENTUALLY};let s=ce(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(Pw(c)&&c.containerId&&(d=a),!d)return c;let m=em(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?QD(d.roundness.type,c)?d.roundness:eL(c):null});if(Pw(m)){let p=d.fontSize||$D,u=d.fontFamily||ZD,E=em(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||jD,lineHeight:d.lineHeight||qD(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),iL(E,g,o.scene)}return m.type==="arrow"&&nL(d)&&(m=em(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),tL(c)&&(m=em(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:ng.IMMEDIATELY}}});import{KEYS as lL}from"@excalidraw/common";import{CaptureUpdateAction as cL}from"@excalidraw/element";var qr=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Vx,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:cL.EVENTUALLY}),keyTest:e=>e.key===lL.QUESTION_MARK});import{getNonDeletedElements as nm}from"@excalidraw/element";import{newElementWith as Aw}from"@excalidraw/element";import{isBoundToContainer as dL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as mL,getElementsInResizingFrame as pL,getFrameLikeElements as uL,getRootElements as hL,groupByFrameLikes as gL,removeElementsFromFrame as fL,replaceAllElementsInFrame as EL}from"@excalidraw/element";import{KEYS as om,randomId as bL,arrayToMap as rg}from"@excalidraw/common";import{getSelectedGroupIds as tm,selectGroup as xL,selectGroupsForSelectedElements as yL,getElementsInGroup as Mw,addToGroup as wL,removeFromSelectedGroups as vL,isElementInGroup as Dw}from"@excalidraw/element";import{syncMovedIndices as IL}from"@excalidraw/element";import{CaptureUpdateAction as il}from"@excalidraw/element";import{jsx as ia}from"react/jsx-runtime";var TL=(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=>Dw(i,r)))return!0}return!1},og=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!TL(t,e.editingGroupId)&&!mL(t)},ig=O({name:"group",label:"labels.group",icon:e=>ia(Vu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!og(n,o))return!1;let r=hL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:il.EVENTUALLY};let i=tm(n);if(i.length===1){let b=i[0],w=new Set(Mw(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:il.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&gL(r).forEach((w,y)=>{fL(w,o.scene.getNonDeletedElementsMap())});let l=bL(),c=rg(r);a=a.map(b=>c.get(b.id)?Aw(b,{groupIds:wL(b.groupIds,l,n.editingGroupId)}):b);let d=Mw(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!Dw(b,l)),g=IL([...E,...d,...u],rg(d));return{appState:{...n,...xL(l,{...n,selectedGroupIds:{}},nm(a))},elements:g,captureUpdate:il.IMMEDIATELY}},predicate:(e,n,t,o)=>og(n,o),keyTest:e=>!e.shiftKey&&e[om.CTRL_OR_CMD]&&e.key===om.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ia(Z,{hidden:!og(n,o),type:"button",icon:ia(Vu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Le(nm(e),n)})}),ag=O({name:"ungroup",label:"labels.ungroup",icon:e=>ia(Yu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=tm(n),i=rg(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:il.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{dL(p)&&s.push(p.id);let u=vL(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:Aw(p,{groupIds:u})});let l=yL(n,nm(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return uL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=EL(a,pL(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:il.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[om.CTRL_OR_CMD]&&e.key===om.G.toUpperCase(),predicate:(e,n)=>tm(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>ia(Z,{type:"button",hidden:tm(n).length===0,icon:ia(Yu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Le(nm(e),n)})});import DL from"clsx";import{CaptureUpdateAction as Bw}from"@excalidraw/element";import{invariant as LL}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as SL,COLOR_VOICE_CALL as CL,COLOR_WHITE as im,THEME as PL,UserIdleState as Lw}from"@excalidraw/common";var rm=(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 kL(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 Jr=(e,n)=>`hsl(${Math.abs(kL(n?.id||e))%37*10}, 100%, 83%)`,_w=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},Rw=({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=Jr(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===Lw.IDLE||E===Lw.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===PL.DARK?"#2f6330":CL,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=im,e.strokeStyle=im,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=im,e.stroke(),w&&(e.beginPath(),e.roundRect(_-2,k-2,L+4,F+4,8),e.strokeStyle=b,e.stroke())):rm(e,_,k,L,F,8,im),e.fillStyle=SL,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 ML from"clsx";import{useState as AL}from"react";import{jsx as Nw}from"react/jsx-runtime";var sg=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=_w(t),[a,s]=AL(!1),l=!a&&o,c=l?void 0:{background:e};return Nw("div",{className:ML("Avatar",r),style:c,onClick:n,children:l?Nw("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as to,jsxs as am}from"react/jsx-runtime";var _L=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(LL(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:Bw.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:Bw.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=Jr(o,r),l=DL({"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?am("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[to("div",{}),to("div",{}),to("div",{})]}):r.isMuted?to("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:n0}):to("div",{title:f("userList.hint.inCall"),children:t0}):null;return i?am("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:[to(sg,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),to("div",{className:"UserList__collaborator-name",children:r.username}),am("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&to("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Hr}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):am("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[to(sg,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&to("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as aa}from"@excalidraw/element";import{isFrameLikeElement as RL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as NL}from"@excalidraw/element";import{KEYS as dr,arrayToMap as BL}from"@excalidraw/common";import{alignElements as FL}from"@excalidraw/element";import{CaptureUpdateAction as sa}from"@excalidraw/element";import{getSelectedElementsByGroup as OL}from"@excalidraw/element";import{jsx as ca}from"react/jsx-runtime";var dt=(e,n)=>{let t=n.scene.getSelectedElements(e);return OL(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>RL(o))},la=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=FL(r,o,t.scene,n),a=BL(i);return NL(e.map(s=>a.get(s.id)||s),n,t)},zL=O({name:"alignTop",label:"labels.alignTop",icon:Ou,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"start",axis:"y"}),captureUpdate:sa.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:Ou,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Le(aa(e),n)})}),GL=O({name:"alignBottom",label:"labels.alignBottom",icon:zu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"end",axis:"y"}),captureUpdate:sa.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:zu,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Le(aa(e),n)})}),HL=O({name:"alignLeft",label:"labels.alignLeft",icon:Gu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"start",axis:"x"}),captureUpdate:sa.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:Gu,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Le(aa(e),n)})}),UL=O({name:"alignRight",label:"labels.alignRight",icon:Hu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"end",axis:"x"}),captureUpdate:sa.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:Hu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Le(aa(e),n)})}),WL=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Uu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"center",axis:"y"}),captureUpdate:sa.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:Uu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Le(aa(e),n)})}),VL=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Wu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:la(e,n,o,{position:"center",axis:"x"}),captureUpdate:sa.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ca(Z,{hidden:!dt(n,o),type:"button",icon:Wu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Le(aa(e),n)})});import{getNonDeletedElements as Fw}from"@excalidraw/element";import{isFrameLikeElement as YL}from"@excalidraw/element";import{CODES as Ow,KEYS as zw,arrayToMap as XL}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as KL}from"@excalidraw/element";import{distributeElements as $L}from"@excalidraw/element";import{CaptureUpdateAction as Gw}from"@excalidraw/element";import{getSelectedElementsByGroup as ZL}from"@excalidraw/element";import{jsx as Ww}from"react/jsx-runtime";var Hw=(e,n)=>{let t=n.scene.getSelectedElements(e);return ZL(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>YL(o))},Uw=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=$L(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=XL(i);return KL(e.map(s=>a.get(s.id)||s),n,t)},jL=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Uw(e,n,o,{space:"between",axis:"x"}),captureUpdate:Gw.IMMEDIATELY}),keyTest:e=>!e[zw.CTRL_OR_CMD]&&e.altKey&&e.code===Ow.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ww(Z,{hidden:!Hw(n,o),type:"button",icon:r1,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Le(Fw(e),n)})}),qL=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Uw(e,n,o,{space:"between",axis:"y"}),captureUpdate:Gw.IMMEDIATELY}),keyTest:e=>!e[zw.CTRL_OR_CMD]&&e.altKey&&e.code===Ow.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ww(Z,{hidden:!Hw(n,o),type:"button",icon:i1,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Le(Fw(e),n)})});import{arrayToMap as Vw,KEYS as QL,matchKey as e_}from"@excalidraw/common";import{CaptureUpdateAction as t_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as n_}from"@excalidraw/element/frame";import{arrangeElements as o_}from"@excalidraw/element/arrange";var JL={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},da=(e,n)=>({smartZoom:{...JL,...n?.smartZoom},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as a_}from"react/jsx-runtime";var r_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Vw(e),{arrange:i}=da(n,t.props.editorPreferences),a=o_(t.scene,o,r,i.algorithm,i.gap),s=Vw(a);return n_(e.map(l=>s.get(l.id)||l),n,t)},i_=dt,lg=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:Qu,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>i_(n,o),perform:(e,n,t,o)=>({appState:n,elements:r_(e,n,o),captureUpdate:t_.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e_(e,QL.R),PanelComponent:({updateData:e})=>a_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+R")}`,children:Qu})});import{arrayToMap as Yw}from"@excalidraw/common";import{CaptureUpdateAction as s_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as l_}from"@excalidraw/element/frame";import{normaliseElements as c_}from"@excalidraw/element/normalise";import{jsx as p_}from"react/jsx-runtime";var d_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Yw(e),{normalise:i}=da(n,t.props.editorPreferences),a=c_(t.scene,o,r,i.mode,i.metric),s=Yw(a);return l_(e.map(l=>s.get(l.id)||l),n,t)},m_=dt,cg=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:eh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>m_(n,o),perform:(e,n,t,o)=>({appState:n,elements:d_(e,n,o),captureUpdate:s_.IMMEDIATELY}),PanelComponent:({updateData:e})=>p_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:eh})});import{getNonDeletedElements as u_}from"@excalidraw/element";import{bindOrUnbindBindingElements as h_}from"@excalidraw/element";import{getCommonBoundingBox as Xw}from"@excalidraw/element";import{newElementWith as g_}from"@excalidraw/element";import{deepCopyElement as f_}from"@excalidraw/element";import{resizeMultipleElements as E_}from"@excalidraw/element";import{isArrowElement as Kw,isElbowArrow as b_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as $w}from"@excalidraw/element";import{CODES as Zw,KEYS as x_,arrayToMap as y_}from"@excalidraw/common";import{CaptureUpdateAction as jw}from"@excalidraw/element";var dg=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:a0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:$w(qw(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:jw.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Zw.H}),mg=O({name:"flipVertical",label:"labels.flipVertical",icon:i0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:$w(qw(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:jw.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Zw.V&&!e[x_.CTRL_OR_CMD]}),qw=(e,n,t,o,r)=>{let i=ce(u_(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=w_(i,n,o,r),s=y_(a);return e.map(l=>s.get(l.id)||l)},w_=(e,n,t,o)=>{if(e.every(p=>Kw(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return g_(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=Xw(e);E_(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,f_(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),h_(e.filter(Kw),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>b_(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=Xw(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{isTextElement as v_}from"@excalidraw/element";import{getTextFromElements as I_}from"@excalidraw/element";import{CODES as T_,KEYS as Jw,isFirefox as S_}from"@excalidraw/common";import{CaptureUpdateAction as Jt}from"@excalidraw/element";var ma=O({name:"copy",label:"labels.copy",icon:Ss,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await $d(r,o.files,t)}catch(i){return{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),pg=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await xw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),S_?{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(Ew({types:r}))}catch(i){return console.error(i),{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),sm=O({name:"cut",label:"labels.cut",icon:K1,trackEvent:{category:"element"},perform:(e,n,t,o)=>(ma.perform(e,n,t,o),Ls.perform(e,n,null,o)),keyTest:e=>e[Jw.CTRL_OR_CMD]&&e.key===Jw.X}),C_=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:s0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Jt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=$r(e,n,!0);try{await Zr("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:Jt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>Kd&&e.length>0,keywords:["svg","clipboard","copy"]}),P_=O({name:"copyAsPng",label:"labels.copyAsPng",icon:l0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Jt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=$r(e,n,!0);try{return await Zr("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:Jt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>lr&&e.length>0,keyTest:e=>e.code===T_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),k_=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{To(I_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Jt.EVENTUALLY}},predicate:(e,n,t,o)=>Kd&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(v_),keywords:["text","clipboard","copy"]});import{CODES as M_,KEYS as A_}from"@excalidraw/common";import{CaptureUpdateAction as D_}from"@excalidraw/element";var pa=O({name:"gridMode",icon:d0,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:D_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[A_.CTRL_OR_CMD]&&e.code===M_.QUOTE});import{KEYS as lm}from"@excalidraw/common";import{CaptureUpdateAction as L_}from"@excalidraw/element/store";import{jsx as __}from"react/jsx-runtime";var al=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:th,viewMode:!0,perform:(e,n,t,o)=>{let r=da(n,o.props.editorPreferences).smartZoom,i=ce(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:L_.NEVER}},keyTest:e=>!e[lm.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===lm.F,PanelComponent:({data:e,updateData:n})=>__(Z,{type:"button",icon:th,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${lm.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:lm.F.toLocaleUpperCase()})});import{CODES as R_,KEYS as N_}from"@excalidraw/common";import{CaptureUpdateAction as B_}from"@excalidraw/element";var Lt=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:jo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:B_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[N_.CTRL_OR_CMD]&&e.altKey&&e.code===R_.S});import{CaptureUpdateAction as F_}from"@excalidraw/element";var sl=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:F_.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as O_}from"@excalidraw/element";var ll=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:O_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as z_,KEYS as G_}from"@excalidraw/common";import{CaptureUpdateAction as H_}from"@excalidraw/element";var mr=O({name:"stats",label:"stats.fullTitle",icon:r0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:H_.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[G_.CTRL_OR_CMD]&&e.altKey&&e.code===z_.SLASH});import{BOUND_TEXT_PADDING as Qw,ROUNDNESS as ev,TEXT_ALIGN as ov,VERTICAL_ALIGN as rv,arrayToMap as iv,getFontString as U_,getStrokeWidthByKey as W_}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as V_,isBoundToContainer as tv,resetOriginalContainerCache as Y_,updateOriginalContainerCache as X_}from"@excalidraw/element";import{computeBoundTextPosition as K_,computeContainerDimensionForBoundText as nv,getBoundTextElement as av,redrawTextBoundingBox as sv}from"@excalidraw/element";import{hasBoundTextElement as $_,isArrowElement as Z_,isTextBindableContainer as ug,isTextElement as cl,isUsingAdaptiveRadius as j_}from"@excalidraw/element";import{measureText as q_}from"@excalidraw/element";import{syncMovedIndices as lv}from"@excalidraw/element";import{newElement as J_}from"@excalidraw/element";import{CaptureUpdateAction as hg}from"@excalidraw/element";var gg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>$_(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=av(a,i);if(s){let{width:l,height:c}=q_(s.originalText,U_(s),s.lineHeight),d=V_(a.id);Y_(a.id);let{x:m,y:p}=K_(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:hg.IMMEDIATELY}}}),fg=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=cl(r[0])||cl(r[1]),a;if(ug(r[0])?a=r[0]:ug(r[1])&&(a=r[1]),i&&a&&av(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;cl(r[0])&&ug(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:rv.MIDDLE,textAlign:ov.CENTER,autoResize:!0,angle:Z_(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return sv(i,a,o.scene),X_(a.id,s),{elements:Q_(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:hg.IMMEDIATELY}}}),Q_=(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),lv(o,iv([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),lv(o,iv([n,t])),o},cv=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>cl(a)&&!tv(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(cl(s)&&!tv(s)){let l=J_({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:W_("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:j_("rectangle")?ev.ADAPTIVE_RADIUS:ev.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-Qw,y:s.y-Qw,width:nv(s.width,"rectangle"),height:nv(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:rv.MIDDLE,boundElements:null,textAlign:ov.CENTER,autoResize:!0}),sv(s,l,o.scene),i=eR([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:hg.IMMEDIATELY}}});import{getNonDeletedElements as xv,isEmbeddableElement as ER}from"@excalidraw/element";import{KEYS as yv}from"@excalidraw/common";import{CaptureUpdateAction as bR}from"@excalidraw/element";import{pointFrom as uv}from"@excalidraw/math";import tR from"clsx";import{useCallback as dv,useEffect as mv,useLayoutEffect as nR,useRef as oR,useState as rR}from"react";import{EVENT as Eg,HYPERLINK_TOOLTIP_DELAY as iR,KEYS as cm}from"@excalidraw/common";import{getElementAbsoluteCoords as vg}from"@excalidraw/element";import{hitElementBoundingBox as aR}from"@excalidraw/element";import{isElementLink as sR}from"@excalidraw/element";import{getEmbedLink as lR,embeddableURLValidator as cR}from"@excalidraw/element";import{sceneCoordsToViewportCoords as hv,viewportCoordsToSceneCoords as dR,wrapEvent as mR,isLocalLink as pR,normalizeLink as bg}from"@excalidraw/common";import{isEmbeddableElement as xg}from"@excalidraw/element";import{jsx as ua,jsxs as pv}from"react/jsx-runtime";var Ig=380,uR=42,yg=5,gv=85,hR=500,wg=!1,dm=new Map,fv=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=Qn(),l=kn(),c=be(),d=e.link||"",[m,p]=rR(d),u=oR(null),E=s.showHyperlinkPopup==="editor",g=dv(()=>{if(!u.current)return;let I=bg(u.current.value)||null;if(!e.link&&I&&Fe("hyperlink","create"),xg(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&&dm.set(e.id,e.link),n.mutateElement(e,{link:I}),i(e,!1);else{let{width:T,height:C}=e,P=lR(I);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let M=P?P.intrinsicSize.w/P.intrinsicSize.h:1,D=dm.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),dm.has(e.id)&&dm.delete(e.id)}}else n.mutateElement(e,{link:I})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);nR(()=>()=>{g()},[g]),mv(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),mv(()=>{let I=null,T=C=>{if(E)return;I&&clearTimeout(I),fR(e,a,s,uv(C.clientX,C.clientY))&&(I=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},hR))};return window.addEventListener(Eg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(Eg.POINTER_MOVE,T,!1),I&&clearTimeout(I)}},[s,e,E,t,a]);let b=dv(()=>{Fe("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),w=()=>{Fe("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:x}=Ev(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:pv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${y}px`,width:Ig,padding:yg},children:[E?ua("input",{className:tR("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[cm.CTRL_OR_CMD]&&I.key===cm.K&&I.preventDefault(),(I.key===cm.ENTER||I.key===cm.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?ua("a",{href:bg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:pR(e.link)?"_self":"_blank",onClick:I=>{if(e.link&&o){let T=mR(Eg.EXCALIDRAW_LINK,I.nativeEvent);o({...e,link:bg(e.link)},T),T.defaultPrevented&&I.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ua("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),pv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&ua(Z,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:$n}),ua(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:h0}),d&&!xg(e)&&ua(Z,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Or})]})]})},Ev=(e,n,t)=>{let[o,r]=vg(e,t),{x:i,y:a}=hv({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-Ig/2,l=a-n.offsetTop-gv;return{x:s,y:l}},Tg=(e,n)=>{let t=ce(e,n);return xg(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},dl=null,bv=(e,n,t)=>{dl&&clearTimeout(dl),dl=window.setTimeout(()=>gR(e,n,t),iR)},gR=(e,n,t)=>{if(!e.link)return;let o=ji();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=sR(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=vg(e,t),[l,c,d,m]=dx([r,i,a,s],e.angle,n),p=hv({sceneX:l,sceneY:c},n);Hh(o,{left:p.x,top:p.y,width:d,height:m},"top"),Fe("hyperlink","tooltip","link-icon"),wg=!0},mm=()=>{dl&&clearTimeout(dl),wg&&(wg=!1,ji().classList.remove("excalidraw-tooltip--visible"))},fR=(e,n,t,[o,r])=>{let{x:i,y:a}=dR({clientX:o,clientY:r},t),s=15/t.zoom.value;if(aR(uv(i,a),e,n))return!1;let[l,c,d]=vg(e,n);if(i>=l&&i<=d&&a>=c-gv&&a<=c)return!1;let{x:m,y:p}=Ev(e,t,n);return!(o>=m-s&&o<=m+Ig+yg*2+s&&r>=p-s&&r<=p+s+yg*2+uR)};import{jsx as xR}from"react/jsx-runtime";var Sg=O({name:"hyperlink",label:(e,n)=>Tg(xv(e),n),icon:Ms,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:bR.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[yv.CTRL_OR_CMD]&&e.key===yv.K,predicate:(e,n)=>ce(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=ce(e,n);return xR(Z,{type:"toggle",icon:Ms,"aria-label":f(Tg(xv(e),n)),title:`${ER(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onSelect:()=>t(null),checked:o.length===1&&!!o[0].link})}});import{KEYS as wv,arrayToMap as Pg,randomId as yR}from"@excalidraw/common";import{elementsAreInSameGroup as wR,getNonDeletedElements as vv,newElementWith as Iv,selectGroupsFromGivenElements as Tv}from"@excalidraw/element";import{CaptureUpdateAction as Sv}from"@excalidraw/element";var Cg=e=>e.every(n=>!n.locked),ml=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return Cg(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=ce(n,e);return Cg(t)?Ko:bo},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=Cg(r),a=Pg(r),s=r.length>1&&wR(r),c=r.length===1||s?null:yR(),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]),Iv(w,{locked:i,groupIds:y.length!==w.groupIds.length?y:w.groupIds})}),p=Pg(m),u=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),E=r.map(w=>p.get(w.id)||w),g=i?{}:Tv(vv(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:Sv.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===wv.L&&e[wv.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),Cv=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:bo,predicate:(e,n)=>ce(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 Iv(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=Pg(o),i=t.map(s=>r.get(s.id)||s),a=vv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:Tv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:Sv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as _8,isLinearElement as R8,isLineElement as wa}from"@excalidraw/element";import{arrayToMap as N8,invariant as c2}from"@excalidraw/common";import{toggleLinePolygonState as B8,CaptureUpdateAction as d2}from"@excalidraw/element";import{getSizeFromPoints as CTe,randomInteger as D8,getUpdatedTimestamp as L8}from"@excalidraw/common";import{simplify as m8}from"points-on-curve";import{getStroke as p8,getStrokePoints as sTe}from"perfect-freehand";function Ze([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function ha([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function nt([e,n,t],o){return[e*o,n*o,t*o]}function ei([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function xt([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function Pv(e,n,t){return Ze(e,nt(ha(n,e),t))}function kg(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 Mg(e){return Math.atan2(Math.sin(e),Math.cos(e))}function Ag([e,n]){return Math.sqrt(e**2+n**2)}function Qr([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function kv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=Qr(e[t-1],e[t]);return n+=Qr(e[e.length-2],e[e.length-1]),n}var vR=(e,n,t)=>Math.max(n,Math.min(t,e));function Mv(e,n,t){let o=Qr(n,t);if(o===0)return Qr(e,n);let r=vR(((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 Qr(i,e)}function pl(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=Mv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...pl([t,...e.slice(1,i),a],n).slice(0,-1),a,...pl([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var pr=class pr{constructor(n){v(this,"options");v(this,"originalPoints",[]);v(this,"stablePoints",[]);v(this,"tailPoints",[]);v(this,"isFresh",!0);this.options=Object.assign({},pr.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=Pv(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),kv(this.tailPoints)>pr.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=pl(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(Ze(P,nt(xt([1,0,0],_),M)));return D.push(Ze(P,nt([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=kg(P,[P[0],P[1]-100,P[2]],M);for(let F=L;F<=Math.PI+L;F+=Math.PI/16)k.push(Ze(P,nt(xt([1,0,0],F),D)));for(let F=Math.PI+L;F<=Math.PI*2+L;F+=Math.PI/16)k.push(Ze(M,nt(xt([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=Qr(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=ei(ha(M,D)),z=ei(ha(_,D)),U=xt(Y,Math.PI/2),V=xt(Y,-Math.PI/2),G=xt(z,Math.PI/2),re=xt(z,-Math.PI/2),B=Ze(D,nt(U,F)),W=Ze(D,nt(V,F)),ue=Ze(D,nt(G,F)),Ee=Ze(D,nt(re,F)),le=Ze(U,re),he=Ze(V,G),ge=Ze(D,nt(Ag(le)===0?Y:ei(le),F)),se=Ze(D,nt(Ag(he)===0?z:ei(he),F)),xe=Mg(kg(D,M,_)),it=pr.constants.cornerDetectionMaxAngle/180*Math.PI*pr.constants.cornerDetectionVariance(a);if(Math.abs(xe)<it){let $e=Math.abs(Mg(Math.PI-xe));if($e===0)continue;if(xe<0){i.push(W,se);for(let ke=0;ke<=$e;ke+=$e/4)r.push(Ze(D,xt(nt(U,F),ke)));for(let ke=$e;ke>=0;ke-=$e/4)i.push(Ze(D,xt(nt(U,F),ke)));i.push(se,ue)}else{r.push(B,ge);for(let ke=0;ke<=$e;ke+=$e/4)i.push(Ze(D,xt(nt(U,-F),-ke)));for(let ke=$e;ke>=0;ke-=$e/4)r.push(Ze(D,xt(nt(U,-F),-ke)));r.push(ge,Ee)}}else r.push(ge),i.push(se);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(Ze(P,nt(xt([1,0,0],D),this.options.size)));return M.push(Ze(P,nt([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=ei(ha(m,d)),g=ei(ha(p,u)),b=xt(E,-Math.PI/2),w=xt(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(Ze(d,xt(nt(b,y),-P)));x.unshift(Ze(d,nt(b,-y)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push(Ze(u,xt(nt(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"?pl(C,this.options.simplify):C}};v(pr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),v(pr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var ga=pr;import{pointsOnBezierCurves as ode}from"points-on-curve";import{invariant as ide}from"@excalidraw/common";import{curve as sde,lineSegment as lde,pointFrom as cde,pointDistance as dde,pointFromArray as mde,pointFromVector as pde,pointRotateRads as ude,polygon as hde,polygonFromPoints as gde,PRECISION as fde,segmentsIntersectAt as Ede,vector as bde,vectorAdd as xde,vectorFromPoint as yde,vectorScale as wde}from"@excalidraw/math";import{getElementAbsoluteCoords as Ide}from"@excalidraw/element";var Dg=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 u8,pointDistance as o2,pointRotateRads as mTe}from"@excalidraw/math";import{ROUGHNESS as h8,THEME as jg,isTransparent as Sl,assertNever as g8,COLOR_PALETTE as f8,LINE_POLYGON_POINT_MERGE_DISTANCE as uTe,applyDarkModeFilter as Cl,DEFAULT_STROKE_STREAMLINE as E8}from"@excalidraw/common";import{RoughGenerator as b8}from"roughjs/bin/generator";import bIe from"roughjs/bin/rough";import{isRightAngleRads as yIe,lineSegment as wIe,pointFrom as vIe,pointRotateRads as IIe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as SIe,DEFAULT_REDUCED_GLOBAL_ALPHA as CIe,ELEMENT_READY_TO_ERASE_OPACITY as PIe,FRAME_STYLE as kIe,DARK_THEME_FILTER as MIe,MIME_TYPES as n2,THEME as AIe,distance as DIe,getFontString as LIe,isRTL as _Ie,getVerticalOffset as RIe,invariant as NIe,applyDarkModeFilter as BIe,isSafari as FIe}from"@excalidraw/common";import H2e from"roughjs/bin/rough";import{arrayToMap as W2e,invariant as t2,rescalePoints as V2e,sizeOf as Y2e}from"@excalidraw/common";import{degreesToRadians as Xg,lineSegment as K2e,pointFrom as yt,pointFromArray as r8,pointRotateRads as ya}from"@excalidraw/math";import{pointsOnBezierCurves as j2e}from"points-on-curve";import{pointCenter as i2e,pointFrom as a2e,pointRotateRads as s2e,pointsEqual as l2e,pointDistance as c2e,vectorFromPoint as d2e,curveLength as m2e,curvePointAtLength as p2e}from"@excalidraw/math";import{DRAGGING_THRESHOLD as g2e,KEYS as f2e,shouldRotateWithDiscreteAngle as E2e,getGridPoint as b2e,invariant as x2e,isShallowEqual as y2e,getFeatureFlag as w2e}from"@excalidraw/common";import{arrayToMap as yve,getFeatureFlag as wve,getGridPoint as vve,invariant as Ive,isTransparent as Tve}from"@excalidraw/common";import{PRECISION as Cve,clamp as Pve,lineSegment as kve,pointDistance as Mve,pointDistanceSq as Ave,pointFrom as Dve,pointFromArray as Lve,pointFromVector as _ve,pointRotateRads as Rve,pointsEqual as Nve,vectorFromPoint as Bve,vectorNormalize as Fve,vectorScale as Ove}from"@excalidraw/math";import{invariant as Hwe,isTransparent as Uwe}from"@excalidraw/common";import{curveIntersectLineSegment as Vwe,isPointWithinBounds as Ywe,lineSegment as Xwe,lineSegmentIntersectionPoints as Kwe,pointFrom as $we,pointFromVector as Zwe,pointRotateRads as jwe,pointsEqual as qwe,vectorFromPoint as Jwe,vectorNormalize as Qwe,vectorScale as eve}from"@excalidraw/math";import{ellipse as nve,ellipseSegmentInterceptPoints as ove}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as CR,DEFAULT_PROPORTIONAL_RADIUS as Rg,invariant as Rde,LINE_CONFIRM_THRESHOLD as PR,ROUNDNESS as Ng}from"@excalidraw/common";import{bezierEquation as Bde,curve as Fde,curveCatmullRomCubicApproxPoints as Ode,curveOffsetPoints as zde,lineSegment as Gde,lineSegmentIntersectionPoints as Hde,pointDistance as kR,pointFrom as Ude,pointFromArray as Wde,pointFromVector as Vde,pointRotateRads as Yde,pointTranslate as Xde,rectangle as Kde,vectorFromPoint as $de,vectorNormalize as Zde,vectorScale as jde}from"@excalidraw/math";import{ROUNDNESS as Pde,assertNever as kde}from"@excalidraw/common";import{pointsEqual as Ade}from"@excalidraw/math";var Av=e=>!!e&&e.type==="embeddable",Lg=e=>!!e&&e.type==="iframe",_g=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),pn=e=>e!=null&&e.type==="text";var no=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var un=e=>e!=null&&TR(e.type);var An=e=>e!=null&&e.type==="arrow",Dn=e=>An(e)&&e.elbowed;var TR=e=>e==="arrow"||e==="line";var So=e=>e!==null&&"containerId"in e&&e.containerId!==null&&pn(e);var fa=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return kR(t,o)<=PR/n}return!1},ul=(e,n)=>{if(n.roundness?.type===Ng.PROPORTIONAL_RADIUS||n.roundness?.type===Ng.LEGACY)return e*Rg;if(n.roundness?.type===Ng.ADAPTIVE_RADIUS){let t=n.roundness?.value??CR,o=t/Rg;return e<=o?e*Rg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as ywe,ARROW_LABEL_WIDTH_FRACTION as wwe,BOUND_TEXT_PADDING as vwe,DEFAULT_FONT_SIZE as Iwe,TEXT_ALIGN as Twe,VERTICAL_ALIGN as Swe,getFontString as Cwe,isProdEnv as Pwe,invariant as kwe}from"@excalidraw/common";import{pointFrom as Awe,pointRotateRads as Dwe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as dme,DEFAULT_FONT_SIZE as mme,DEFAULT_FONT_FAMILY as pme,getFontString as ume,isTestEnv as hme,normalizeEOL as gme}from"@excalidraw/common";var fme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Ime,isTestEnv as Tme}from"@excalidraw/common";import{toIterable as uye}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Mme,viewportCoordsToSceneCoords as Ame}from"@excalidraw/common";import{normalizeRadians as Lme,radiansBetweenAngles as _me,radiansDifference as Rme}from"@excalidraw/math";import{pointsEqual as Bme}from"@excalidraw/math";import{arrayToMap as ype,isShallowEqual as LR}from"@excalidraw/common";import{arrayToMap as epe}from"@excalidraw/common";import{isPointWithinBounds as npe,pointFrom as ope,segmentsIntersectAt as rpe}from"@excalidraw/math";import{arrayToMap as Ume}from"@excalidraw/common";import{validateOrderKey as Vme,generateNKeysBetween as Yme}from"@excalidraw/fractional-indexing";var Bg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var kpe=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}(),bl=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){ti(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&&So(i)&&ti(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{no(a)&&Bg(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var Og=(e,n)=>LR(n.selectedElementIds,e)?n.selectedElementIds:e;var _R=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:Og({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):bl(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Og(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var Xpe=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as Uue,VERTICAL_ALIGN as Wue}from"@excalidraw/common";import{pointDistance as Yue,pointFromVector as Xue,pointsEqual as Kue,vector as $ue,vectorDot as Zue,vectorFromPoint as jue,vectorNormalize as que,vectorScale as Jue}from"@excalidraw/math";import{invariant as rue,isDevEnv as iue,isTestEnv as aue}from"@excalidraw/common";import{pointFrom as lue,pointFromVector as cue,pointRotateRads as due,pointScaleFromOrigin as mue,pointsEqual as pue,triangleIncludesPoint as uue,vectorCross as hue,vectorFromPoint as BR,vectorScale as gue}from"@excalidraw/math";var wl=[1,0],fm=[0,1],vl=[-1,0],Em=[0,-1],bm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?wl:n<=-r?vl:t>o?fm:Em},zv=(e,n)=>bm(BR(e,n)),xm=(e,n)=>ym(zv(e,n)),yl=(e,n)=>e[0]===n[0]&&e[1]===n[1],ym=e=>yl(e,wl)||yl(e,vl);import{DEFAULT_ELEMENT_PROPS as yue,DEFAULT_FONT_FAMILY as wue,DEFAULT_FONT_SIZE as vue,DEFAULT_TEXT_ALIGN as Iue,DEFAULT_VERTICAL_ALIGN as Tue,DEFAULT_STROKE_STREAMLINE as Sue,VERTICAL_ALIGN as Cue,randomInteger as Pue,randomId as kue,getFontString as Mue,getUpdatedTimestamp as Aue,getLineHeight as Due}from"@excalidraw/common";import{pointsOnBezierCurves as whe,simplify as vhe}from"points-on-curve";import{curveToBezier as The}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as Che,lineSegment as Phe,lineSegmentIntersectionPoints as khe,pointDistance as Mhe,pointFrom as Ahe,pointRotateRads as Dhe,polygonArea as Lhe,polygonIncludesPoint as _he,polygonIncludesPointNonZero as Rhe,polygonSignedArea as Nhe}from"@excalidraw/math";import{isOpaqueColor as Fhe,isTransparent as Ohe}from"@excalidraw/common";var Wv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as che,distanceToLineSegment as dhe,pointRotateRads as mhe}from"@excalidraw/math";import{ellipse as uhe,ellipseDistanceFromPoint as hhe}from"@excalidraw/math/ellipse";import{pointFrom as Jhe,pointCenter as Qhe,pointRotateRads as ege,vectorFromPoint as tge,vectorNormalize as nge,vectorSubtract as oge,vectorAdd as rge,vectorScale as ige,pointFromVector as age,clamp as sge,isCloseTo as lge}from"@excalidraw/math";import{arrayToMap as Ffe,arrayToObject as Ofe,assertNever as zfe,isDevEnv as Gfe,isShallowEqual as Hfe,isTestEnv as Ufe,randomInteger as Wfe}from"@excalidraw/common";import{assertNever as Vge,COLOR_PALETTE as Yge,isDevEnv as Xge,isTestEnv as Kge,randomId as $ge,Emitter as Zge,toIterable as jge}from"@excalidraw/common";import{ORIG_ID as wge,randomId as vge,randomInteger as Ige,arrayToMap as Tge,castArray as Sge,findLastIndex as Cge,getUpdatedTimestamp as Pge,isTestEnv as kge}from"@excalidraw/common";import{arrayToMap as uge}from"@excalidraw/common";import zR from"lodash.throttle";import{randomInteger as mfe,arrayToMap as pfe,toBrandedType as ufe,isDevEnv as Xv,isTestEnv as Kv,toArray as hfe}from"@excalidraw/common";import{isNonDeletedElement as ffe}from"@excalidraw/element";import{isFrameLikeElement as bfe}from"@excalidraw/element";import{getElementsInGroup as yfe}from"@excalidraw/element";import{syncInvalidIndices as vfe,syncMovedIndices as Ife,validateFractionalIndices as GR}from"@excalidraw/element";import{getSelectedElements as Sfe}from"@excalidraw/element";import{mutateElement as Pfe}from"@excalidraw/element";var kfe=zR(e=>{(Xv()||Kv()||window?.DEBUG_FRACTIONAL_INDICES)&&GR(e,{shouldThrow:Xv()||Kv(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as hEe,getGridPoint as gEe,getFontString as fEe,DRAGGING_THRESHOLD as EEe}from"@excalidraw/common";import{clamp as kEe,pointDistance as MEe,pointFrom as AEe,pointScaleFromOrigin as DEe,pointsEqual as LEe,pointTranslate as _Ee,vector as REe,vectorCross as NEe,vectorFromPoint as BEe,vectorScale as FEe}from"@excalidraw/math";import{BinaryHeap as zEe,invariant as GEe,isAnyTrue as HEe,getSizeFromPoints as UEe,isDevEnv as WEe,arrayToMap as VEe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as rbe,normalizeLink as ibe}from"@excalidraw/common";import{FONT_FAMILY as dbe,VERTICAL_ALIGN as mbe,escapeDoubleQuotes as pbe,getFontString as ube}from"@excalidraw/common";import{invariant as vbe,toBrandedType as Ibe}from"@excalidraw/common";import{clamp as Sbe,pointFrom as Cbe}from"@excalidraw/math";import{pointDistance as txe,pointFrom as nxe}from"@excalidraw/math";import{invariant as rxe}from"@excalidraw/common";import{arrayToMap as Gbe,findIndex as Hbe,findLastIndex as Ube}from"@excalidraw/common";import{isFiniteNumber as Vbe}from"@excalidraw/math";import{decode as hxe,decodeFrames as gxe}from"modern-gif";import{DEFAULT_GIF_AUTO_DECODE_MAX_FILE_SIZE_BYTES as vxe,MIME_TYPES as Ixe,SVG_NS as Txe}from"@excalidraw/common";import{rgbaToThumbHash as Cxe,thumbHashToRGBA as Pxe}from"thumbhash";import{pointCenter as Xxe,normalizeRadians as Kxe,pointFrom as $xe,pointRotateRads as Zxe}from"@excalidraw/math";import{MIN_FONT_SIZE as qxe,SHIFT_LOCKING_ANGLE as Jxe,rescalePoints as Qxe,getFontString as e1e}from"@excalidraw/common";import{pointFrom as P1e,pointOnLineSegment as k1e,pointRotateRads as M1e}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as D1e}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as h1e}from"@excalidraw/common";import{pointFrom as f1e,pointRotateRads as E1e}from"@excalidraw/math";import{KEYS as _n}from"@excalidraw/common";var U1e=[{icon:Oc,value:"selection",key:_n.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:_i,value:"rectangle",key:_n.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ri,value:"diamond",key:_n.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ni,value:"ellipse",key:_n.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:zc,value:"arrow",key:_n.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:$o,value:"line",key:_n.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:$n,value:"freedraw",key:[_n.P,_n.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Pn,value:"text",key:_n.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Fr,value:"image",key:[_n.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Gc,value:"eraser",key:_n.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as e0e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as n0e,DEFAULT_FONT_SIZE as o0e,TEXT_ALIGN as r0e,VERTICAL_ALIGN as i0e,getSizeFromPoints as a0e,randomId as s0e,arrayToMap as l0e,assertNever as c0e,cloneJSON as d0e,getFontString as m0e,isDevEnv as p0e,toBrandedType as u0e,getLineHeight as h0e}from"@excalidraw/common";import{getBoundsFromPoints as F0e,getElementAbsoluteCoords as O0e}from"@excalidraw/element/bounds";import{newArrowElement as G0e,newElement as H0e,newLinearElement as U0e}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as V0e,getStrokeWidthByKey as Y0e,ROUNDNESS as X0e}from"@excalidraw/common";import{convexHull as $0e,distanceToLineSegment as Z0e,elongation as j0e,kurtosis as q0e,lineSegment as J0e,orientPrincipalAxes as Q0e,pointFrom as eye,polygonArea as tye,principalAxes as nye,principalCoords as oye,skewness as rye}from"@excalidraw/math";var lye=[{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 ti=e=>!e.isDeleted;var qR=10/1.5;var pm=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 i8=20,a8=15,s8=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 a8;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return i8;default:return 15}},l8=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Rt=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=Dg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;t2(s.length===6,"Op data length is not 6");let l=yt(s[4],s[5]),c=yt(s[2],s[3]),d=yt(s[0],s[1]),m=i[a-1],p=yt(0,0);if(m.op==="move"){let G=r8(m.data);t2(G!=null,"Op data is not a point"),p=G}else m.op==="bcurveTo"&&(p=yt(m.data[4],m.data[5]));let u=(G,re)=>Math.pow(1-G,3)*l[re]+3*G*Math.pow(1-G,2)*c[re]+3*Math.pow(G,2)*(1-G)*d[re]+p[re]*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=s8(o),C=0;{let[G,re]=t==="end"?e.points[e.points.length-1]:e.points[0],[B,W]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(G-B,re-W)}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=l8(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[G,re]=ya(yt(D,_),yt(k,L),Xg(-F)),[B,W]=ya(yt(D,_),yt(k,L),Xg(F));return[k,L,G,re,B,W]}let[Y,z]=ya(yt(k,L),yt(D,_),-F*Math.PI/180),[U,V]=ya(yt(k,L),yt(D,_),Xg(F));if(o==="diamond"||o==="diamond_outline"){let G,re;if(t==="start"){let[B,W]=e.points.length>1?e.points[1]:[0,0];[G,re]=ya(yt(D+M*2,_),yt(D,_),Math.atan2(W-_,B-D))}else{let[B,W]=e.points.length>1?e.points[e.points.length-2]:[0,0];[G,re]=ya(yt(D-M*2,_),yt(D,_),Math.atan2(_-W,D-B))}return[D,_,Y,z,G,re,U,V]}return[D,_,Y,z,U,V]};var c8=typeof document<"u"?document.createElement("img"):{src:""};c8.src=`data:${n2.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 d8=typeof document<"u"?document.createElement("img"):{src:""};d8.src=`data:${n2.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 Kg=new WeakMap;var Wt=class Wt{};v(Wt,"rg",new b8),v(Wt,"cache",new WeakMap),v(Wt,"get",(n,t)=>{let o=Wt.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),v(Wt,"delete",n=>{Wt.cache.delete(n),Kg.delete(n)}),v(Wt,"destroy",()=>{Wt.cache=new WeakMap}),v(Wt,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Wt.get(n,t?t.theme:null);if(o!==void 0)return o;Kg.delete(n);let r=w8(n,Wt.rg,t||{isExporting:!1,canvasBackgroundColor:f8.white,embedsValidationStatus:null,theme:jg.LIGHT});return t?.isExporting||Wt.cache.set(n,{shape:r,theme:t?.theme||jg.LIGHT}),r});var xa=Wt,x8=e=>[8,8+e],s2=e=>[1.5,6+e];function y8(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&&Wv(e.type)||un(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var Po=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?x8(e.strokeWidth):e.strokeStyle==="dotted"?s2(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:y8(e),stroke:Cl(e.strokeColor,t),preserveVertices:n||e.roughness<h8.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=Sl(e.backgroundColor)?void 0:Cl(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return fa(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:Cl(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},r2=(e,n,t)=>_g(e)&&(n||Av(e)&&t?.get(e.id)!==!0)&&Sl(e.backgroundColor)&&Sl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Lg(e)?{...e,strokeColor:Sl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Sl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Tl=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},vm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,s,l]=n;return[e.line(i,a,o,r,t),e.line(s,l,o,r,t)]},oi=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=s2(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},$g=(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)]},i2=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=Cl(e.strokeColor,s),c=Cl(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return $g(r,i,l,Rt(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=Rt(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=Rt(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 Tl(r,Rt(e,n,t,o),oi(e,i));case"cardinality_many":return vm(r,Rt(e,n,t,o),oi(e,i));case"cardinality_one_or_many":{let p=oi(e,i);return[...vm(r,Rt(e,n,t,"cardinality_many"),p),...Tl(r,Rt(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=oi(e,i);return[...Tl(r,Rt(e,n,t,"cardinality_one",-.5),p),...Tl(r,Rt(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=oi(e,i);return[...$g(r,i,l,Rt(e,n,t,"circle_outline",1.5),c,m),...Tl(r,Rt(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=oi(e,i);return[...vm(r,Rt(e,n,t,"cardinality_many"),p),...$g(r,i,l,Rt(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return vm(r,Rt(e,n,t,o),oi(e,i))}};var w8=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===jg.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=ul(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`,Po(r2(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,Po(r2(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=pm(e);if(e.roundness){let b=ul(Math.abs(l-E),e),w=ul(Math.abs(m-c),e);s=n.path(`M ${l+b} ${c+w} L ${d-b} ${m-w}
5
- C ${d} ${m}, ${d} ${m}, ${d-b} ${m+w}
4
+ ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Pw=async(e,n,t)=>{let o=bx(n);if(!xx(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:d,exportingFrame:c}=$r(r,i,!1);return await Zr(o,d,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:c}),{fileHandle:n}};import{Fragment as JD,jsx as cr,jsxs as Dw}from"react/jsx-runtime";var tg=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>cr(yw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),kw=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:Mn.EVENTUALLY})}),ng=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>cr(qh,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),Qd=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Dw(qh,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),cr(pt,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:cr("div",{className:"excalidraw-tooltip-icon",children:n1})})]})}),ra=!1,eg=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?Dw(JD,{children:[t,cr(Yd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function qD(e,n){if(n.app.state.isLoading&&(eg(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")eg(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(eg(n.app,{progress:null}),await e)}function Mw(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await qD(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:ks,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(ra)return!1;ra=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=Mw(e,n,o.files,o);try{let{fileHandle:l}=_c(r)?await Pw(s,r,i):await kc({data:s,filename:i,fileHandle:r});return{captureUpdate:Mn.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:Mn.NEVER,appState:{toast:null}}}finally{ra=!1}},keyTest:e=>!1}),rl=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:ks,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(ra)return!1;ra=!0;let{abortController:r,data:i}=Mw(e,n,o.files,o);try{let{fileHandle:a}=await kc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:Mn.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:Mn.NEVER,appState:{toast:null}}}finally{ra=!1}},keyTest:e=>e.key.toLowerCase()===Jd.S&&e.shiftKey&&e[Jd.CTRL_OR_CMD],PanelComponent:({updateData:e})=>cr(Z,{type:"button",icon:qx,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:be().formFactor==="phone",hidden:!Pi,onClick:()=>e(null),"data-testid":"save-as-button"})}),ia=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 Pu(n,e);return{elements:r,appState:i,files:a,captureUpdate:Mn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:Mn.EVENTUALLY}}},keyTest:e=>e[Jd.CTRL_OR_CMD]&&e.key===Jd.O}),Aw=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?ol.DARK:ol.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:Mn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>cr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:cr(bw,{value:e.exportWithDarkMode?ol.DARK:ol.LIGHT,onChange:t=>{n(t===ol.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as QD,DEFAULT_FONT_FAMILY as eL,DEFAULT_TEXT_ALIGN as tL,getLineHeight as nL}from"@excalidraw/common";import{newElementWith as em}from"@excalidraw/element";import{hasBoundTextElement as oL,canApplyRoundnessTypeToElement as rL,getDefaultRoundnessTypeForElement as iL,isFrameLikeElement as aL,isArrowElement as sL,isExcalidrawElement as lL,isTextElement as Lw}from"@excalidraw/element";import{getBoundTextElement as cL,redrawTextBoundingBox as dL}from"@excalidraw/element";import{CaptureUpdateAction as og}from"@excalidraw/element";var _w="{}",mL=O({name:"copyStyles",label:"labels.copyStyles",icon:Ju,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&oL(i)){let a=cL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(_w=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:og.EVENTUALLY}}}),pL=O({name:"pasteStyles",label:"labels.pasteStyles",icon:Ju,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(_w),i=r[0],a=r[1];if(!lL(i))return{elements:e,captureUpdate:og.EVENTUALLY};let s=ce(e,n,{includeBoundTextElement:!0}),l=s.map(d=>d.id);return{elements:e.map(d=>{if(l.includes(d.id)){let c=i;if(Lw(d)&&d.containerId&&(c=a),!c)return d;let m=em(d,{backgroundColor:c?.backgroundColor,strokeWidth:c?.strokeWidth,strokeColor:c?.strokeColor,strokeStyle:c?.strokeStyle,fillStyle:c?.fillStyle,opacity:c?.opacity,roughness:c?.roughness,roundness:c.roundness?rL(c.roundness.type,d)?c.roundness:iL(d):null});if(Lw(m)){let p=c.fontSize||QD,u=c.fontFamily||eL,E=em(m,{fontSize:p,fontFamily:u,textAlign:c.textAlign||tL,lineHeight:c.lineHeight||nL(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),dL(E,g,o.scene)}return m.type==="arrow"&&sL(c)&&(m=em(m,{startArrowhead:c.startArrowhead,endArrowhead:c.endArrowhead})),aL(d)&&(m=em(m,{roundness:null,backgroundColor:"transparent"})),m}return d}),captureUpdate:og.IMMEDIATELY}}});import{KEYS as uL}from"@excalidraw/common";import{CaptureUpdateAction as hL}from"@excalidraw/element";var qr=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Kx,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:hL.EVENTUALLY}),keyTest:e=>e.key===uL.QUESTION_MARK});import{getNonDeletedElements as nm}from"@excalidraw/element";import{newElementWith as Nw}from"@excalidraw/element";import{isBoundToContainer as gL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as fL,getElementsInResizingFrame as EL,getFrameLikeElements as bL,getRootElements as xL,groupByFrameLikes as yL,removeElementsFromFrame as wL,replaceAllElementsInFrame as vL}from"@excalidraw/element";import{KEYS as om,randomId as IL,arrayToMap as ig}from"@excalidraw/common";import{getSelectedGroupIds as tm,selectGroup as SL,selectGroupsForSelectedElements as TL,getElementsInGroup as Rw,addToGroup as CL,removeFromSelectedGroups as PL,isElementInGroup as Bw}from"@excalidraw/element";import{syncMovedIndices as kL}from"@excalidraw/element";import{CaptureUpdateAction as il}from"@excalidraw/element";import{jsx as aa}from"react/jsx-runtime";var ML=(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=>Bw(i,r)))return!0}return!1},rg=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!ML(t,e.editingGroupId)&&!fL(t)},ag=O({name:"group",label:"labels.group",icon:e=>aa(Yu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!rg(n,o))return!1;let r=xL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:il.EVENTUALLY};let i=tm(n);if(i.length===1){let b=i[0],w=new Set(Rw(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:il.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&yL(r).forEach((w,y)=>{wL(w,o.scene.getNonDeletedElementsMap())});let l=IL(),d=ig(r);a=a.map(b=>d.get(b.id)?Nw(b,{groupIds:CL(b.groupIds,l,n.editingGroupId)}):b);let c=Rw(a,l),m=c[c.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!Bw(b,l)),g=kL([...E,...c,...u],ig(c));return{appState:{...n,...SL(l,{...n,selectedGroupIds:{}},nm(a))},elements:g,captureUpdate:il.IMMEDIATELY}},predicate:(e,n,t,o)=>rg(n,o),keyTest:e=>!e.shiftKey&&e[om.CTRL_OR_CMD]&&e.key===om.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>aa(Z,{hidden:!rg(n,o),type:"button",icon:aa(Yu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Le(nm(e),n)})}),sg=O({name:"ungroup",label:"labels.ungroup",icon:e=>aa(Ku,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=tm(n),i=ig(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:il.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{gL(p)&&s.push(p.id);let u=PL(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:Nw(p,{groupIds:u})});let l=TL(n,nm(a),n,null),d=o.scene.getSelectedElements(n),c=new Set(d.filter(p=>p.frameId).map(p=>p.frameId));return bL(e).filter(p=>c.has(p.id)).forEach(p=>{p&&(a=vL(a,EL(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:il.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[om.CTRL_OR_CMD]&&e.key===om.G.toUpperCase(),predicate:(e,n)=>tm(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>aa(Z,{type:"button",hidden:tm(n).length===0,icon:aa(Ku,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Le(nm(e),n)})});import BL from"clsx";import{CaptureUpdateAction as Hw}from"@excalidraw/element";import{invariant as FL}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as AL,COLOR_VOICE_CALL as DL,COLOR_WHITE as im,THEME as LL,UserIdleState as Fw}from"@excalidraw/common";var rm=(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 _L(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 Jr=(e,n)=>`hsl(${Math.abs(_L(n?.id||e))%37*10}, 100%, 83%)`,Ow=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},zw=({context:e,renderConfig:n,appState:t,normalizedWidth:o,normalizedHeight:r})=>{for(let[i,a]of n.remotePointerViewportCoords){let{x:s,y:l}=a,d=t.collaborators.get(i);s-=t.offsetLeft,l-=t.offsetTop;let c=11,m=14,p=s<0||s>o-c||l<0||l>r-m;s=Math.max(s,0),s=Math.min(s,o-c),l=Math.max(l,0),l=Math.min(l,r-m);let u=Jr(i,d);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===Fw.IDLE||E===Fw.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===LL.DARK?"#2f6330":DL,w=d?.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=im,e.strokeStyle=im,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)+c/2,I=(w?l+0:l)+m+2,S=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+S*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=im,e.stroke(),w&&(e.beginPath(),e.roundRect(_-2,k-2,L+4,F+4,8),e.strokeStyle=b,e.stroke())):rm(e,_,k,L,F,8,im),e.fillStyle=AL,e.fillText(y,x+S+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 RL from"clsx";import{useState as NL}from"react";import{jsx as Gw}from"react/jsx-runtime";var lg=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=Ow(t),[a,s]=NL(!1),l=!a&&o,d=l?void 0:{background:e};return Gw("div",{className:RL("Avatar",r),style:d,onClick:n,children:l?Gw("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as to,jsxs as am}from"react/jsx-runtime";var OL=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(FL(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:Hw.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:Hw.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=Jr(o,r),l=BL({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),d=r.isInCall?r.isSpeaking?am("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[to("div",{}),to("div",{}),to("div",{})]}):r.isMuted?to("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:r0}):to("div",{title:f("userList.hint.inCall"),children:o0}):null;return i?am("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:[to(lg,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),to("div",{className:"UserList__collaborator-name",children:r.username}),am("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&to("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Hr}),r.isCurrentUser&&` (${f("labels.you")})`,d]})]}):am("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[to(lg,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),d&&to("div",{className:"UserList__collaborator-status-icon",children:d})]})}});import{getNonDeletedElements as sa}from"@excalidraw/element";import{isFrameLikeElement as zL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as GL}from"@excalidraw/element";import{KEYS as dr,arrayToMap as HL}from"@excalidraw/common";import{alignElements as UL}from"@excalidraw/element";import{CaptureUpdateAction as la}from"@excalidraw/element";import{getSelectedElementsByGroup as WL}from"@excalidraw/element";import{jsx as da}from"react/jsx-runtime";var dt=(e,n)=>{let t=n.scene.getSelectedElements(e);return WL(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>zL(o))},ca=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=UL(r,o,t.scene,n),a=HL(i);return GL(e.map(s=>a.get(s.id)||s),n,t)},VL=O({name:"alignTop",label:"labels.alignTop",icon:zu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ca(e,n,o,{position:"start",axis:"y"}),captureUpdate:la.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>da(Z,{hidden:!dt(n,o),type:"button",icon:zu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Le(sa(e),n)})}),YL=O({name:"alignBottom",label:"labels.alignBottom",icon:Gu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ca(e,n,o,{position:"end",axis:"y"}),captureUpdate:la.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>da(Z,{hidden:!dt(n,o),type:"button",icon:Gu,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Le(sa(e),n)})}),KL=O({name:"alignLeft",label:"labels.alignLeft",icon:Hu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ca(e,n,o,{position:"start",axis:"x"}),captureUpdate:la.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>da(Z,{hidden:!dt(n,o),type:"button",icon:Hu,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Le(sa(e),n)})}),XL=O({name:"alignRight",label:"labels.alignRight",icon:Uu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ca(e,n,o,{position:"end",axis:"x"}),captureUpdate:la.IMMEDIATELY}),keyTest:e=>e[dr.CTRL_OR_CMD]&&e.shiftKey&&e.key===dr.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>da(Z,{hidden:!dt(n,o),type:"button",icon:Uu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Le(sa(e),n)})}),$L=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Wu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ca(e,n,o,{position:"center",axis:"y"}),captureUpdate:la.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>da(Z,{hidden:!dt(n,o),type:"button",icon:Wu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Le(sa(e),n)})}),ZL=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Vu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>dt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ca(e,n,o,{position:"center",axis:"x"}),captureUpdate:la.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>da(Z,{hidden:!dt(n,o),type:"button",icon:Vu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Le(sa(e),n)})});import{getNonDeletedElements as Uw}from"@excalidraw/element";import{isFrameLikeElement as jL}from"@excalidraw/element";import{CODES as Ww,KEYS as Vw,arrayToMap as qL}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as JL}from"@excalidraw/element";import{distributeElements as QL}from"@excalidraw/element";import{CaptureUpdateAction as Yw}from"@excalidraw/element";import{getSelectedElementsByGroup as e_}from"@excalidraw/element";import{jsx as $w}from"react/jsx-runtime";var Kw=(e,n)=>{let t=n.scene.getSelectedElements(e);return e_(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>jL(o))},Xw=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=QL(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=qL(i);return JL(e.map(s=>a.get(s.id)||s),n,t)},t_=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Xw(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:!Kw(n,o),type:"button",icon:a1,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Le(Uw(e),n)})}),n_=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Xw(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:!Kw(n,o),type:"button",icon:s1,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Le(Uw(e),n)})});import{arrayToMap as Zw,KEYS as r_,matchKey as i_}from"@excalidraw/common";import{CaptureUpdateAction as a_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as s_}from"@excalidraw/element/frame";import{arrangeElements as l_}from"@excalidraw/element/arrange";var o_={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},ma=(e,n)=>({smartZoom:{...o_,...n?.smartZoom},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as m_}from"react/jsx-runtime";var c_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Zw(e),{arrange:i}=ma(n,t.props.editorPreferences),a=l_(t.scene,o,r,i.algorithm,i.gap),s=Zw(a);return s_(e.map(l=>s.get(l.id)||l),n,t)},d_=dt,cg=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:eh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>d_(n,o),perform:(e,n,t,o)=>({appState:n,elements:c_(e,n,o),captureUpdate:a_.IMMEDIATELY}),keyTest:e=>e.shiftKey&&i_(e,r_.R),PanelComponent:({updateData:e})=>m_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+R")}`,children:eh})});import{arrayToMap as jw}from"@excalidraw/common";import{CaptureUpdateAction as p_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as u_}from"@excalidraw/element/frame";import{normaliseElements as h_}from"@excalidraw/element/normalise";import{jsx as E_}from"react/jsx-runtime";var g_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=jw(e),{normalise:i}=ma(n,t.props.editorPreferences),a=h_(t.scene,o,r,i.mode,i.metric),s=jw(a);return u_(e.map(l=>s.get(l.id)||l),n,t)},f_=dt,dg=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:th,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>f_(n,o),perform:(e,n,t,o)=>({appState:n,elements:g_(e,n,o),captureUpdate:p_.IMMEDIATELY}),PanelComponent:({updateData:e})=>E_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:th})});import{getNonDeletedElements as b_}from"@excalidraw/element";import{bindOrUnbindBindingElements as x_}from"@excalidraw/element";import{getCommonBoundingBox as qw}from"@excalidraw/element";import{newElementWith as y_}from"@excalidraw/element";import{deepCopyElement as w_}from"@excalidraw/element";import{resizeMultipleElements as v_}from"@excalidraw/element";import{isArrowElement as Jw,isElbowArrow as I_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Qw}from"@excalidraw/element";import{CODES as ev,KEYS as S_,arrayToMap as T_}from"@excalidraw/common";import{CaptureUpdateAction as tv}from"@excalidraw/element";var mg=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:l0,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}),pg=O({name:"flipVertical",label:"labels.flipVertical",icon:s0,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[S_.CTRL_OR_CMD]}),nv=(e,n,t,o,r)=>{let i=ce(b_(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=C_(i,n,o,r),s=T_(a);return e.map(l=>s.get(l.id)||l)},C_=(e,n,t,o)=>{if(e.every(p=>Jw(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return y_(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=qw(e);v_(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,w_(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),x_(e.filter(Jw),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>I_(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:d}=qw(e),[c,m]=[r-l,i-d];return s.forEach(p=>o.scene.mutateElement(p,{x:p.x+c,y:p.y+m})),a.forEach(p=>o.scene.mutateElement(p,{x:p.x+c,y:p.y+m})),e};import{isTextElement as P_}from"@excalidraw/element";import{getTextFromElements as k_}from"@excalidraw/element";import{CODES as M_,KEYS as ov,isFirefox as A_}from"@excalidraw/common";import{CaptureUpdateAction as Jt}from"@excalidraw/element";var pa=O({name:"copy",label:"labels.copy",icon:Ts,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await $d(r,o.files,t)}catch(i){return{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),ug=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await Sw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),A_?{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(vw({types:r}))}catch(i){return console.error(i),{captureUpdate:Jt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Jt.EVENTUALLY}},keyTest:void 0}),sm=O({name:"cut",label:"labels.cut",icon:Z1,trackEvent:{category:"element"},perform:(e,n,t,o)=>(pa.perform(e,n,t,o),Ls.perform(e,n,null,o)),keyTest:e=>e[ov.CTRL_OR_CMD]&&e.key===ov.X}),D_=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:c0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Jt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=$r(e,n,!0);try{await Zr("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:Jt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>Xd&&e.length>0,keywords:["svg","clipboard","copy"]}),L_=O({name:"copyAsPng",label:"labels.copyAsPng",icon:d0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Jt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=$r(e,n,!0);try{return await Zr("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:Jt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Jt.EVENTUALLY}}},predicate:e=>lr&&e.length>0,keyTest:e=>e.code===M_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),__=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{Io(k_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Jt.EVENTUALLY}},predicate:(e,n,t,o)=>Xd&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(P_),keywords:["text","clipboard","copy"]});import{CODES as R_,KEYS as N_}from"@excalidraw/common";import{CaptureUpdateAction as B_}from"@excalidraw/element";var ua=O({name:"gridMode",icon:p0,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:B_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[N_.CTRL_OR_CMD]&&e.code===R_.QUOTE});import{KEYS as lm}from"@excalidraw/common";import{CaptureUpdateAction as F_}from"@excalidraw/element/store";import{jsx as O_}from"react/jsx-runtime";var al=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:nh,viewMode:!0,perform:(e,n,t,o)=>{let r=ma(n,o.props.editorPreferences).smartZoom,i=ce(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:F_.NEVER}},keyTest:e=>!e[lm.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===lm.F,PanelComponent:({data:e,updateData:n})=>O_(Z,{type:"button",icon:nh,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${lm.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:lm.F.toLocaleUpperCase()})});import{CODES as z_,KEYS as G_}from"@excalidraw/common";import{CaptureUpdateAction as H_}from"@excalidraw/element";var Lt=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:jo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:H_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[G_.CTRL_OR_CMD]&&e.altKey&&e.code===z_.S});import{CaptureUpdateAction as U_}from"@excalidraw/element";var sl=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:U_.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as W_}from"@excalidraw/element";var ll=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:W_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as V_,KEYS as Y_}from"@excalidraw/common";import{CaptureUpdateAction as K_}from"@excalidraw/element";var mr=O({name:"stats",label:"stats.fullTitle",icon:a0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:K_.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[Y_.CTRL_OR_CMD]&&e.altKey&&e.code===V_.SLASH});import{BOUND_TEXT_PADDING as rv,ROUNDNESS as iv,TEXT_ALIGN as lv,VERTICAL_ALIGN as cv,arrayToMap as dv,getFontString as X_,getStrokeWidthByKey as $_}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as Z_,isBoundToContainer as av,resetOriginalContainerCache as j_,updateOriginalContainerCache as q_}from"@excalidraw/element";import{computeBoundTextPosition as J_,computeContainerDimensionForBoundText as sv,getBoundTextElement as mv,redrawTextBoundingBox as pv}from"@excalidraw/element";import{hasBoundTextElement as Q_,isArrowElement as eR,isTextBindableContainer as hg,isTextElement as cl,isUsingAdaptiveRadius as tR}from"@excalidraw/element";import{measureText as nR}from"@excalidraw/element";import{syncMovedIndices as uv}from"@excalidraw/element";import{newElement as oR}from"@excalidraw/element";import{CaptureUpdateAction as gg}from"@excalidraw/element";var fg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>Q_(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=mv(a,i);if(s){let{width:l,height:d}=nR(s.originalText,X_(s),s.lineHeight),c=Z_(a.id);j_(a.id);let{x:m,y:p}=J_(a,s,i);o.scene.mutateElement(s,{containerId:null,width:l,height:d,text:s.originalText,x:m,y:p}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:c||a.height})}}),{elements:e,appState:n,captureUpdate:gg.IMMEDIATELY}}}),Eg=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=cl(r[0])||cl(r[1]),a;if(hg(r[0])?a=r[0]:hg(r[1])&&(a=r[1]),i&&a&&mv(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;cl(r[0])&&hg(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:cv.MIDDLE,textAlign:lv.CENTER,autoResize:!0,angle:eR(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return pv(i,a,o.scene),q_(a.id,s),{elements:rR(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:gg.IMMEDIATELY}}}),rR=(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),uv(o,dv([n,t])),o},iR=(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),uv(o,dv([n,t])),o},hv=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>cl(a)&&!av(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(cl(s)&&!av(s)){let l=oR({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:$_("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:tR("rectangle")?iv.ADAPTIVE_RADIUS:iv.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-rv,y:s.y-rv,width:sv(s.width,"rectangle"),height:sv(s.height,"rectangle"),groupIds:s.groupIds,frameId:s.frameId});if(s.boundElements?.length){let d=s.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>d.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===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:cv.MIDDLE,boundElements:null,textAlign:lv.CENTER,autoResize:!0}),pv(s,l,o.scene),i=iR([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:gg.IMMEDIATELY}}});import{getNonDeletedElements as Sv,isEmbeddableElement as vR}from"@excalidraw/element";import{KEYS as Tv}from"@excalidraw/common";import{CaptureUpdateAction as IR}from"@excalidraw/element";import{pointFrom as bv}from"@excalidraw/math";import aR from"clsx";import{useCallback as gv,useEffect as fv,useLayoutEffect as sR,useRef as lR,useState as cR}from"react";import{EVENT as bg,HYPERLINK_TOOLTIP_DELAY as dR,KEYS as cm}from"@excalidraw/common";import{getElementAbsoluteCoords as Ig}from"@excalidraw/element";import{hitElementBoundingBox as mR}from"@excalidraw/element";import{isElementLink as pR}from"@excalidraw/element";import{getEmbedLink as uR,embeddableURLValidator as hR}from"@excalidraw/element";import{sceneCoordsToViewportCoords as xv,viewportCoordsToSceneCoords as gR,wrapEvent as fR,isLocalLink as ER,normalizeLink as xg}from"@excalidraw/common";import{isEmbeddableElement as yg}from"@excalidraw/element";import{jsx as ha,jsxs as Ev}from"react/jsx-runtime";var Sg=380,bR=42,wg=5,yv=85,xR=500,vg=!1,dm=new Map,wv=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=Qn(),l=kn(),d=be(),c=e.link||"",[m,p]=cR(c),u=lR(null),E=s.showHyperlinkPopup==="editor",g=gv(()=>{if(!u.current)return;let I=xg(u.current.value)||null;if(!e.link&&I&&Fe("hyperlink","create"),yg(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!I){n.mutateElement(e,{link:null}),i(e,!1);return}if(!hR(I,l.validateEmbeddable))I&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&dm.set(e.id,e.link),n.mutateElement(e,{link:I}),i(e,!1);else{let{width:S,height:C}=e,P=uR(I);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let M=P?P.intrinsicSize.w/P.intrinsicSize.h:1,D=dm.get(e.id)!==e.link;n.mutateElement(e,{...D?{width:P?.type==="video"?S>C?S:C*M:S,height:P?.type==="video"&&S>C?S/M:C}:{},link:I}),i(e,!0),dm.has(e.id)&&dm.delete(e.id)}}else n.mutateElement(e,{link:I})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);sR(()=>()=>{g()},[g]),fv(()=>{E&&u?.current&&!(d.formFactor==="phone"||d.isTouchScreen)&&u.current.select()},[E,d.formFactor,d.isTouchScreen]),fv(()=>{let I=null,S=C=>{if(E)return;I&&clearTimeout(I),wR(e,a,s,bv(C.clientX,C.clientY))&&(I=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},xR))};return window.addEventListener(bg.POINTER_MOVE,S,!1),()=>{window.removeEventListener(bg.POINTER_MOVE,S,!1),I&&clearTimeout(I)}},[s,e,E,t,a]);let b=gv(()=>{Fe("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),w=()=>{Fe("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:x}=vv(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:Ev("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${y}px`,width:Sg,padding:wg},children:[E?ha("input",{className:aR("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[cm.CTRL_OR_CMD]&&I.key===cm.K&&I.preventDefault(),(I.key===cm.ENTER||I.key===cm.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?ha("a",{href:xg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:ER(e.link)?"_self":"_blank",onClick:I=>{if(e.link&&o){let S=fR(bg.EXCALIDRAW_LINK,I.nativeEvent);o({...e,link:xg(e.link)},S),S.defaultPrevented&&I.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ha("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),Ev("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&ha(Z,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:$n}),ha(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:f0}),c&&!yg(e)&&ha(Z,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Or})]})]})},vv=(e,n,t)=>{let[o,r]=Ig(e,t),{x:i,y:a}=xv({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-Sg/2,l=a-n.offsetTop-yv;return{x:s,y:l}},Tg=(e,n)=>{let t=ce(e,n);return yg(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},dl=null,Iv=(e,n,t)=>{dl&&clearTimeout(dl),dl=window.setTimeout(()=>yR(e,n,t),dR)},yR=(e,n,t)=>{if(!e.link)return;let o=ji();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=pR(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=Ig(e,t),[l,d,c,m]=px([r,i,a,s],e.angle,n),p=xv({sceneX:l,sceneY:d},n);Uh(o,{left:p.x,top:p.y,width:c,height:m},"top"),Fe("hyperlink","tooltip","link-icon"),vg=!0},mm=()=>{dl&&clearTimeout(dl),vg&&(vg=!1,ji().classList.remove("excalidraw-tooltip--visible"))},wR=(e,n,t,[o,r])=>{let{x:i,y:a}=gR({clientX:o,clientY:r},t),s=15/t.zoom.value;if(mR(bv(i,a),e,n))return!1;let[l,d,c]=Ig(e,n);if(i>=l&&i<=c&&a>=d-yv&&a<=d)return!1;let{x:m,y:p}=vv(e,t,n);return!(o>=m-s&&o<=m+Sg+wg*2+s&&r>=p-s&&r<=p+s+wg*2+bR)};import{jsx as SR}from"react/jsx-runtime";var Cg=O({name:"hyperlink",label:(e,n)=>Tg(Sv(e),n),icon:Ms,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:IR.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[Tv.CTRL_OR_CMD]&&e.key===Tv.K,predicate:(e,n)=>ce(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=ce(e,n);return SR(Z,{type:"toggle",icon:Ms,"aria-label":f(Tg(Sv(e),n)),title:`${vR(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 Cv,arrayToMap as kg,randomId as TR}from"@excalidraw/common";import{elementsAreInSameGroup as CR,getNonDeletedElements as Pv,newElementWith as kv,selectGroupsFromGivenElements as Mv}from"@excalidraw/element";import{CaptureUpdateAction as Av}from"@excalidraw/element";var Pg=e=>e.every(n=>!n.locked),ml=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return Pg(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=ce(n,e);return Pg(t)?Xo:Eo},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=Pg(r),a=kg(r),s=r.length>1&&CR(r),d=r.length===1||s?null:TR(),c={...n.lockedMultiSelections};if(i)c={...n.lockedMultiSelections,...d?{[d]:!0}:{}};else if(s){let w=r[0].groupIds.at(-1);delete c[w]}let m=e.map(w=>{if(!a.has(w.id))return w;let y=w.groupIds;return i?d&&(y=[...y,d]):y=y.filter(x=>!n.lockedMultiSelections[x]),kv(w,{locked:i,groupIds:y.length!==w.groupIds.length?y:w.groupIds})}),p=kg(m),u=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),E=r.map(w=>p.get(w.id)||w),g=i?{}:Mv(Pv(E),n),b=i?d||(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:c,activeLockedId:b},captureUpdate:Av.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===Cv.L&&e[Cv.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0,keyCondition:(e,n,t,o)=>o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),Dv=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Eo,predicate:(e,n)=>ce(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(d=>!n.lockedMultiSelections[d]);return kv(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=kg(o),i=t.map(s=>r.get(s.id)||s),a=Pv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:Mv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:Av.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as O8,isLinearElement as z8,isLineElement as va}from"@excalidraw/element";import{arrayToMap as G8,invariant as h2}from"@excalidraw/common";import{toggleLinePolygonState as H8,CaptureUpdateAction as g2}from"@excalidraw/element";import{getSizeFromPoints as NSe,randomInteger as B8,getUpdatedTimestamp as F8}from"@excalidraw/common";import{simplify as f8}from"points-on-curve";import{getStroke as E8,getStrokePoints as fSe}from"perfect-freehand";function Ze([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function ga([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function nt([e,n,t],o){return[e*o,n*o,t*o]}function ei([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function xt([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function Lv(e,n,t){return Ze(e,nt(ga(n,e),t))}function Mg(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 Ag(e){return Math.atan2(Math.sin(e),Math.cos(e))}function Dg([e,n]){return Math.sqrt(e**2+n**2)}function Qr([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function _v(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=Qr(e[t-1],e[t]);return n+=Qr(e[e.length-2],e[e.length-1]),n}var PR=(e,n,t)=>Math.max(n,Math.min(t,e));function Rv(e,n,t){let o=Qr(n,t);if(o===0)return Qr(e,n);let r=PR(((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 Qr(i,e)}function pl(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,d)=>{let c=Rv(l,t,o);return c>a?[c,d]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...pl([t,...e.slice(1,i),a],n).slice(0,-1),a,...pl([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var pr=class pr{constructor(n){v(this,"options");v(this,"originalPoints",[]);v(this,"stablePoints",[]);v(this,"tailPoints",[]);v(this,"isFresh",!0);this.options=Object.assign({},pr.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=Lv(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),_v(this.tailPoints)>pr.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=pl(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(Ze(P,nt(xt([1,0,0],_),M)));return D.push(Ze(P,nt([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=Mg(P,[P[0],P[1]-100,P[2]],M);for(let F=L;F<=Math.PI+L;F+=Math.PI/16)k.push(Ze(P,nt(xt([1,0,0],F),D)));for(let F=Math.PI+L;F<=Math.PI*2+L;F+=Math.PI/16)k.push(Ze(M,nt(xt([1,0,0],F),_)));return k.push(k[0]),k}let r=[],i=[],a=0,s=0,l=0,d=0;for(let P=1;P<o-1;P++){let M=t[P-1],D=t[P],_=t[P+1],k=D[2],L=Qr(M,D);d+=L,a=s+(L-s)*.2;let F=this.getSize(n,k,P,o,d);if(F===0){l=P+1;continue}let Y=ei(ga(M,D)),z=ei(ga(_,D)),U=xt(Y,Math.PI/2),V=xt(Y,-Math.PI/2),G=xt(z,Math.PI/2),re=xt(z,-Math.PI/2),B=Ze(D,nt(U,F)),W=Ze(D,nt(V,F)),ue=Ze(D,nt(G,F)),Ee=Ze(D,nt(re,F)),le=Ze(U,re),he=Ze(V,G),ge=Ze(D,nt(Dg(le)===0?Y:ei(le),F)),se=Ze(D,nt(Dg(he)===0?z:ei(he),F)),xe=Ag(Mg(D,M,_)),it=pr.constants.cornerDetectionMaxAngle/180*Math.PI*pr.constants.cornerDetectionVariance(a);if(Math.abs(xe)<it){let $e=Math.abs(Ag(Math.PI-xe));if($e===0)continue;if(xe<0){i.push(W,se);for(let ke=0;ke<=$e;ke+=$e/4)r.push(Ze(D,xt(nt(U,F),ke)));for(let ke=$e;ke>=0;ke-=$e/4)i.push(Ze(D,xt(nt(U,F),ke)));i.push(se,ue)}else{r.push(B,ge);for(let ke=0;ke<=$e;ke+=$e/4)i.push(Ze(D,xt(nt(U,-F),-ke)));for(let ke=$e;ke>=0;ke-=$e/4)r.push(Ze(D,xt(nt(U,-F),-ke)));r.push(ge,Ee)}}else r.push(ge),i.push(se);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(Ze(P,nt(xt([1,0,0],D),this.options.size)));return M.push(Ze(P,nt([1,0,0],this.options.size))),M}return[]}let c=t[l],m=t[l+1],p=t[o-2],u=t[o-1],E=ei(ga(m,c)),g=ei(ga(p,u)),b=xt(E,-Math.PI/2),w=xt(g,Math.PI/2),y=this.getSize(n,c[2],0,o,0),x=[],I=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,d),S=[];if(y>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift(Ze(c,xt(nt(b,y),-P)));x.unshift(Ze(c,nt(b,-y)))}else x.push(c);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)S.push(Ze(u,xt(nt(w,-I),-P)));let C=[...x,...r,...S.reverse(),...i.reverse()];return x.length>0&&C.push(x[0]),this.options.simplify>0&&this.options.simplifyPhase==="output"?pl(C,this.options.simplify):C}};v(pr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),v(pr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var fa=pr;import{pointsOnBezierCurves as pde}from"points-on-curve";import{invariant as hde}from"@excalidraw/common";import{curve as fde,lineSegment as Ede,pointFrom as bde,pointDistance as xde,pointFromArray as yde,pointFromVector as wde,pointRotateRads as vde,polygon as Ide,polygonFromPoints as Sde,PRECISION as Tde,segmentsIntersectAt as Cde,vector as Pde,vectorAdd as kde,vectorFromPoint as Mde,vectorScale as Ade}from"@excalidraw/math";import{getElementAbsoluteCoords as Lde}from"@excalidraw/element";var Lg=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 b8,pointDistance as l2,pointRotateRads as ySe}from"@excalidraw/math";import{ROUGHNESS as x8,THEME as qg,isTransparent as Tl,assertNever as y8,COLOR_PALETTE as w8,LINE_POLYGON_POINT_MERGE_DISTANCE as vSe,applyDarkModeFilter as Cl,DEFAULT_STROKE_STREAMLINE as v8}from"@excalidraw/common";import{RoughGenerator as I8}from"roughjs/bin/generator";import PIe from"roughjs/bin/rough";import{isRightAngleRads as MIe,lineSegment as AIe,pointFrom as DIe,pointRotateRads as LIe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as RIe,DEFAULT_REDUCED_GLOBAL_ALPHA as NIe,ELEMENT_READY_TO_ERASE_OPACITY as BIe,FRAME_STYLE as FIe,DARK_THEME_FILTER as OIe,MIME_TYPES as s2,THEME as zIe,distance as GIe,getFontString as HIe,isRTL as UIe,getVerticalOffset as WIe,invariant as VIe,applyDarkModeFilter as YIe,isSafari as KIe}from"@excalidraw/common";import j2e from"roughjs/bin/rough";import{arrayToMap as J2e,invariant as a2,rescalePoints as Q2e,sizeOf as eIe}from"@excalidraw/common";import{degreesToRadians as Xg,lineSegment as nIe,pointFrom as yt,pointFromArray as c8,pointRotateRads as wa}from"@excalidraw/math";import{pointsOnBezierCurves as iIe}from"points-on-curve";import{pointCenter as h2e,pointFrom as g2e,pointRotateRads as f2e,pointsEqual as E2e,pointDistance as b2e,vectorFromPoint as x2e,curveLength as y2e,curvePointAtLength as w2e}from"@excalidraw/math";import{DRAGGING_THRESHOLD as S2e,KEYS as T2e,shouldRotateWithDiscreteAngle as C2e,getGridPoint as P2e,invariant as k2e,isShallowEqual as M2e,getFeatureFlag as A2e}from"@excalidraw/common";import{arrayToMap as Mve,getFeatureFlag as Ave,getGridPoint as Dve,invariant as Lve,isTransparent as _ve}from"@excalidraw/common";import{PRECISION as Nve,clamp as Bve,lineSegment as Fve,pointDistance as Ove,pointDistanceSq as zve,pointFrom as Gve,pointFromArray as Hve,pointFromVector as Uve,pointRotateRads as Wve,pointsEqual as Vve,vectorFromPoint as Yve,vectorNormalize as Kve,vectorScale as Xve}from"@excalidraw/math";import{invariant as jwe,isTransparent as qwe}from"@excalidraw/common";import{curveIntersectLineSegment as Qwe,isPointWithinBounds as eve,lineSegment as tve,lineSegmentIntersectionPoints as nve,pointFrom as ove,pointFromVector as rve,pointRotateRads as ive,pointsEqual as ave,vectorFromPoint as sve,vectorNormalize as lve,vectorScale as cve}from"@excalidraw/math";import{ellipse as mve,ellipseSegmentInterceptPoints as pve}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as DR,DEFAULT_PROPORTIONAL_RADIUS as Ng,invariant as Wde,LINE_CONFIRM_THRESHOLD as LR,ROUNDNESS as Bg}from"@excalidraw/common";import{bezierEquation as Yde,curve as Kde,curveCatmullRomCubicApproxPoints as Xde,curveOffsetPoints as $de,lineSegment as Zde,lineSegmentIntersectionPoints as jde,pointDistance as _R,pointFrom as qde,pointFromArray as Jde,pointFromVector as Qde,pointRotateRads as eme,pointTranslate as tme,rectangle as nme,vectorFromPoint as ome,vectorNormalize as rme,vectorScale as ime}from"@excalidraw/math";import{ROUNDNESS as Bde,assertNever as Fde}from"@excalidraw/common";import{pointsEqual as zde}from"@excalidraw/math";var Nv=e=>!!e&&e.type==="embeddable",_g=e=>!!e&&e.type==="iframe",Rg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),pn=e=>e!=null&&e.type==="text";var no=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var un=e=>e!=null&&MR(e.type);var An=e=>e!=null&&e.type==="arrow",Dn=e=>An(e)&&e.elbowed;var MR=e=>e==="arrow"||e==="line";var So=e=>e!==null&&"containerId"in e&&e.containerId!==null&&pn(e);var Ea=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return _R(t,o)<=LR/n}return!1},ul=(e,n)=>{if(n.roundness?.type===Bg.PROPORTIONAL_RADIUS||n.roundness?.type===Bg.LEGACY)return e*Ng;if(n.roundness?.type===Bg.ADAPTIVE_RADIUS){let t=n.roundness?.value??DR,o=t/Ng;return e<=o?e*Ng:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Mwe,ARROW_LABEL_WIDTH_FRACTION as Awe,BOUND_TEXT_PADDING as Dwe,DEFAULT_FONT_SIZE as Lwe,TEXT_ALIGN as _we,VERTICAL_ALIGN as Rwe,getFontString as Nwe,isProdEnv as Bwe,invariant as Fwe}from"@excalidraw/common";import{pointFrom as zwe,pointRotateRads as Gwe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as xme,DEFAULT_FONT_SIZE as yme,DEFAULT_FONT_FAMILY as wme,getFontString as vme,isTestEnv as Ime,normalizeEOL as Sme}from"@excalidraw/common";var Tme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Lme,isTestEnv as _me}from"@excalidraw/common";import{toIterable as vye}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Ome,viewportCoordsToSceneCoords as zme}from"@excalidraw/common";import{normalizeRadians as Hme,radiansBetweenAngles as Ume,radiansDifference as Wme}from"@excalidraw/math";import{pointsEqual as Yme}from"@excalidraw/math";import{arrayToMap as Mpe,isShallowEqual as FR}from"@excalidraw/common";import{arrayToMap as cpe}from"@excalidraw/common";import{isPointWithinBounds as mpe,pointFrom as ppe,segmentsIntersectAt as upe}from"@excalidraw/math";import{arrayToMap as qme}from"@excalidraw/common";import{validateOrderKey as Qme,generateNKeysBetween as epe}from"@excalidraw/fractional-indexing";var Fg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var Fpe=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}(),bl=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){ti(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&&So(i)&&ti(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{no(a)&&Fg(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var zg=(e,n)=>FR(n.selectedElementIds,e)?n.selectedElementIds:e;var OR=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 d={};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];d[E]=!0}}let c={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let E=u.groupIds.find(g=>d[g]);return E&&(p[u.id]=!0,Array.isArray(c[E])?c[E].push(u.id):c[E]=[u.id]),p},{});for(let p of Object.keys(c))c[p].length<2&&d[p]&&(d[p]=!1);return n=a,e=i,t={editingGroupId:s.editingGroupId,selectedGroupIds:d,selectedElementIds:zg({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let d=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):bl(a,i);return d.length?o(d,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:zg(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 que,VERTICAL_ALIGN as Jue}from"@excalidraw/common";import{pointDistance as ehe,pointFromVector as the,pointsEqual as nhe,vector as ohe,vectorDot as rhe,vectorFromPoint as ihe,vectorNormalize as ahe,vectorScale as she}from"@excalidraw/math";import{invariant as uue,isDevEnv as hue,isTestEnv as gue}from"@excalidraw/common";import{pointFrom as Eue,pointFromVector as bue,pointRotateRads as xue,pointScaleFromOrigin as yue,pointsEqual as wue,triangleIncludesPoint as vue,vectorCross as Iue,vectorFromPoint as HR,vectorScale as Sue}from"@excalidraw/math";var wl=[1,0],fm=[0,1],vl=[-1,0],Em=[0,-1],bm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?wl:n<=-r?vl:t>o?fm:Em},Vv=(e,n)=>bm(HR(e,n)),xm=(e,n)=>ym(Vv(e,n)),yl=(e,n)=>e[0]===n[0]&&e[1]===n[1],ym=e=>yl(e,wl)||yl(e,vl);import{DEFAULT_ELEMENT_PROPS as Mue,DEFAULT_FONT_FAMILY as Aue,DEFAULT_FONT_SIZE as Due,DEFAULT_TEXT_ALIGN as Lue,DEFAULT_VERTICAL_ALIGN as _ue,DEFAULT_STROKE_STREAMLINE as Rue,VERTICAL_ALIGN as Nue,randomInteger as Bue,randomId as Fue,getFontString as Oue,getUpdatedTimestamp as zue,getLineHeight as Gue}from"@excalidraw/common";import{pointsOnBezierCurves as Ahe,simplify as Dhe}from"points-on-curve";import{curveToBezier as _he}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as Nhe,lineSegment as Bhe,lineSegmentIntersectionPoints as Fhe,pointDistance as Ohe,pointFrom as zhe,pointRotateRads as Ghe,polygonArea as Hhe,polygonIncludesPoint as Uhe,polygonIncludesPointNonZero as Whe,polygonSignedArea as Vhe}from"@excalidraw/math";import{isOpaqueColor as Khe,isTransparent as Xhe}from"@excalidraw/common";var $v=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as bhe,distanceToLineSegment as xhe,pointRotateRads as yhe}from"@excalidraw/math";import{ellipse as vhe,ellipseDistanceFromPoint as Ihe}from"@excalidraw/math/ellipse";import{pointFrom as sge,pointCenter as lge,pointRotateRads as cge,vectorFromPoint as dge,vectorNormalize as mge,vectorSubtract as pge,vectorAdd as uge,vectorScale as hge,pointFromVector as gge,clamp as fge,isCloseTo as Ege}from"@excalidraw/math";import{arrayToMap as Kfe,arrayToObject as Xfe,assertNever as $fe,isDevEnv as Zfe,isShallowEqual as jfe,isTestEnv as qfe,randomInteger as Jfe}from"@excalidraw/common";import{assertNever as Qge,COLOR_PALETTE as efe,isDevEnv as tfe,isTestEnv as nfe,randomId as ofe,Emitter as rfe,toIterable as ife}from"@excalidraw/common";import{ORIG_ID as Age,randomId as Dge,randomInteger as Lge,arrayToMap as _ge,castArray as Rge,findLastIndex as Nge,getUpdatedTimestamp as Bge,isTestEnv as Fge}from"@excalidraw/common";import{arrayToMap as vge}from"@excalidraw/common";import VR from"lodash.throttle";import{randomInteger as yfe,arrayToMap as wfe,toBrandedType as vfe,isDevEnv as qv,isTestEnv as Jv,toArray as Ife}from"@excalidraw/common";import{isNonDeletedElement as Tfe}from"@excalidraw/element";import{isFrameLikeElement as Pfe}from"@excalidraw/element";import{getElementsInGroup as Mfe}from"@excalidraw/element";import{syncInvalidIndices as Dfe,syncMovedIndices as Lfe,validateFractionalIndices as YR}from"@excalidraw/element";import{getSelectedElements as Rfe}from"@excalidraw/element";import{mutateElement as Bfe}from"@excalidraw/element";var Ffe=VR(e=>{(qv()||Jv()||window?.DEBUG_FRACTIONAL_INDICES)&&YR(e,{shouldThrow:qv()||Jv(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as IEe,getGridPoint as SEe,getFontString as TEe,DRAGGING_THRESHOLD as CEe}from"@excalidraw/common";import{clamp as FEe,pointDistance as OEe,pointFrom as zEe,pointScaleFromOrigin as GEe,pointsEqual as HEe,pointTranslate as UEe,vector as WEe,vectorCross as VEe,vectorFromPoint as YEe,vectorScale as KEe}from"@excalidraw/math";import{BinaryHeap as $Ee,invariant as ZEe,isAnyTrue as jEe,getSizeFromPoints as qEe,isDevEnv as JEe,arrayToMap as QEe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as ube,normalizeLink as hbe}from"@excalidraw/common";import{FONT_FAMILY as xbe,VERTICAL_ALIGN as ybe,escapeDoubleQuotes as wbe,getFontString as vbe}from"@excalidraw/common";import{invariant as Dbe,toBrandedType as Lbe}from"@excalidraw/common";import{clamp as Rbe,pointFrom as Nbe}from"@excalidraw/math";import{pointDistance as dxe,pointFrom as mxe}from"@excalidraw/math";import{invariant as uxe}from"@excalidraw/common";import{arrayToMap as Zbe,findIndex as jbe,findLastIndex as qbe}from"@excalidraw/common";import{isFiniteNumber as Qbe}from"@excalidraw/math";import{decode as Ixe,decodeFrames as Sxe}from"modern-gif";import{DEFAULT_GIF_AUTO_DECODE_MAX_FILE_SIZE_BYTES as Dxe,MIME_TYPES as Lxe,SVG_NS as _xe}from"@excalidraw/common";import{rgbaToThumbHash as Nxe,thumbHashToRGBA as Bxe}from"thumbhash";import{pointCenter as t1e,normalizeRadians as n1e,pointFrom as o1e,pointRotateRads as r1e}from"@excalidraw/math";import{MIN_FONT_SIZE as a1e,SHIFT_LOCKING_ANGLE as s1e,rescalePoints as l1e,getFontString as c1e}from"@excalidraw/common";import{pointFrom as B1e,pointOnLineSegment as F1e,pointRotateRads as O1e}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as G1e}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as I1e}from"@excalidraw/common";import{pointFrom as T1e,pointRotateRads as C1e}from"@excalidraw/math";import{KEYS as _n}from"@excalidraw/common";var q1e=[{icon:Oc,value:"selection",key:_n.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:_i,value:"rectangle",key:_n.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ri,value:"diamond",key:_n.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ni,value:"ellipse",key:_n.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:zc,value:"arrow",key:_n.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:$o,value:"line",key:_n.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:$n,value:"freedraw",key:[_n.P,_n.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Pn,value:"text",key:_n.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Fr,value:"image",key:[_n.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Gc,value:"eraser",key:_n.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as c0e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as m0e,DEFAULT_FONT_SIZE as p0e,TEXT_ALIGN as u0e,VERTICAL_ALIGN as h0e,getSizeFromPoints as g0e,randomId as f0e,arrayToMap as E0e,assertNever as b0e,cloneJSON as x0e,getFontString as y0e,isDevEnv as w0e,toBrandedType as v0e,getLineHeight as I0e}from"@excalidraw/common";import{getBoundsFromPoints as K0e,getElementAbsoluteCoords as X0e}from"@excalidraw/element/bounds";import{newArrowElement as Z0e,newElement as j0e,newLinearElement as q0e}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as Q0e,getStrokeWidthByKey as eye,ROUNDNESS as tye}from"@excalidraw/common";import{convexHull as oye,distanceToLineSegment as rye,elongation as iye,kurtosis as aye,lineSegment as sye,orientPrincipalAxes as lye,pointFrom as cye,polygonArea as dye,principalAxes as mye,principalCoords as pye,skewness as uye}from"@excalidraw/math";var Eye=[{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 ti=e=>!e.isDeleted;var n8=10/1.5;var pm=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 d8=20,m8=15,p8=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 m8;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return d8;default:return 15}},u8=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Rt=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=Lg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;a2(s.length===6,"Op data length is not 6");let l=yt(s[4],s[5]),d=yt(s[2],s[3]),c=yt(s[0],s[1]),m=i[a-1],p=yt(0,0);if(m.op==="move"){let G=c8(m.data);a2(G!=null,"Op data is not a point"),p=G}else m.op==="bcurveTo"&&(p=yt(m.data[4],m.data[5]));let u=(G,re)=>Math.pow(1-G,3)*l[re]+3*G*Math.pow(1-G,2)*d[re]+3*Math.pow(G,2)*(1-G)*c[re]+p[re]*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,S=p8(o),C=0;{let[G,re]=t==="end"?e.points[e.points.length-1]:e.points[0],[B,W]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(G-B,re-W)}let M=Math.min(S,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=u8(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[G,re]=wa(yt(D,_),yt(k,L),Xg(-F)),[B,W]=wa(yt(D,_),yt(k,L),Xg(F));return[k,L,G,re,B,W]}let[Y,z]=wa(yt(k,L),yt(D,_),-F*Math.PI/180),[U,V]=wa(yt(k,L),yt(D,_),Xg(F));if(o==="diamond"||o==="diamond_outline"){let G,re;if(t==="start"){let[B,W]=e.points.length>1?e.points[1]:[0,0];[G,re]=wa(yt(D+M*2,_),yt(D,_),Math.atan2(W-_,B-D))}else{let[B,W]=e.points.length>1?e.points[e.points.length-2]:[0,0];[G,re]=wa(yt(D-M*2,_),yt(D,_),Math.atan2(_-W,D-B))}return[D,_,Y,z,G,re,U,V]}return[D,_,Y,z,U,V]};var h8=typeof document<"u"?document.createElement("img"):{src:""};h8.src=`data:${s2.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 g8=typeof document<"u"?document.createElement("img"):{src:""};g8.src=`data:${s2.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 $g=new WeakMap;var Wt=class Wt{};v(Wt,"rg",new I8),v(Wt,"cache",new WeakMap),v(Wt,"get",(n,t)=>{let o=Wt.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),v(Wt,"delete",n=>{Wt.cache.delete(n),$g.delete(n)}),v(Wt,"destroy",()=>{Wt.cache=new WeakMap}),v(Wt,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Wt.get(n,t?t.theme:null);if(o!==void 0)return o;$g.delete(n);let r=C8(n,Wt.rg,t||{isExporting:!1,canvasBackgroundColor:w8.white,embedsValidationStatus:null,theme:qg.LIGHT});return t?.isExporting||Wt.cache.set(n,{shape:r,theme:t?.theme||qg.LIGHT}),r});var ya=Wt,S8=e=>[8,8+e],p2=e=>[1.5,6+e];function T8(e){let n=e.roughness,t=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&t>=50||o>=15&&e.roundness&&$v(e.type)||un(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var Co=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?S8(e.strokeWidth):e.strokeStyle==="dotted"?p2(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:T8(e),stroke:Cl(e.strokeColor,t),preserveVertices:n||e.roughness<x8.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=Tl(e.backgroundColor)?void 0:Cl(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return Ea(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:Cl(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},c2=(e,n,t)=>Rg(e)&&(n||Nv(e)&&t?.get(e.id)!==!0)&&Tl(e.backgroundColor)&&Tl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:_g(e)?{...e,strokeColor:Tl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Tl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Sl=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},vm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,s,l]=n;return[e.line(i,a,o,r,t),e.line(s,l,o,r,t)]},oi=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=p2(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Zg=(e,n,t,o,r,i=1)=>{if(o===null)return[];let[a,s,l]=o,d={...n,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,n.roughness||0)};return delete d.strokeLineDash,[e.circle(a,s,l*i,d)]},d2=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=Cl(e.strokeColor,s),d=Cl(a,s),c=-.25,m=.8;switch(o){case"circle":case"circle_outline":return Zg(r,i,l,Rt(e,n,t,o),o==="circle_outline"?d:l);case"triangle":case"triangle_outline":{let p=Rt(e,n,t,o);if(p===null)return[];let[u,E,g,b,w,y]=p,x={...i,fill:o==="triangle_outline"?d: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=Rt(e,n,t,o);if(p===null)return[];let[u,E,g,b,w,y,x,I]=p,S={...i,fill:o==="diamond_outline"?d:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete S.strokeLineDash,[r.polygon([[u,E],[g,b],[w,y],[x,I],[u,E]],S)]}case"cardinality_one":return Sl(r,Rt(e,n,t,o),oi(e,i));case"cardinality_many":return vm(r,Rt(e,n,t,o),oi(e,i));case"cardinality_one_or_many":{let p=oi(e,i);return[...vm(r,Rt(e,n,t,"cardinality_many"),p),...Sl(r,Rt(e,n,t,"cardinality_one",c),p)]}case"cardinality_exactly_one":{let p=oi(e,i);return[...Sl(r,Rt(e,n,t,"cardinality_one",-.5),p),...Sl(r,Rt(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=oi(e,i);return[...Zg(r,i,l,Rt(e,n,t,"circle_outline",1.5),d,m),...Sl(r,Rt(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=oi(e,i);return[...vm(r,Rt(e,n,t,"cardinality_many"),p),...Zg(r,i,l,Rt(e,n,t,"circle_outline",1.5),d,m)]}case"bar":case"arrow":default:return vm(r,Rt(e,n,t,o),oi(e,i))}};var C8=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===qg.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,d=e.height,c=ul(Math.min(l,d),e);s=n.path(`M ${c} 0 L ${l-c} 0 Q ${l} 0, ${l} ${c} L ${l} ${d-c} Q ${l} ${d}, ${l-c} ${d} L ${c} ${d} Q 0 ${d}, 0 ${d-c} L 0 ${c} Q 0 0, ${c} 0`,Co(c2(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,Co(c2(e,t,r),!1,a));return s}case"diamond":{let s,[l,d,c,m,p,u,E,g]=pm(e);if(e.roundness){let b=ul(Math.abs(l-E),e),w=ul(Math.abs(m-d),e);s=n.path(`M ${l+b} ${d+w} L ${c-b} ${m-w}
5
+ C ${c} ${m}, ${c} ${m}, ${c-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
- L ${l-b} ${c+w}
11
- C ${l} ${c}, ${l} ${c}, ${l+b} ${c+w}`,Po(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],Po(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,Po(e,!1,a));case"line":case"arrow":{let s,l=Po(e,!1,a),c=e.points.length?e.points:[u8(0,0)];if(Dn(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(v8(c,16),Po(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=i2(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=i2(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(fa(e.points)){let l=m8(e.points,.75);s.push(n.curve(l,{...Po(e,!1,a),stroke:"none"}))}return s.push(I8(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return g8(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},v8=(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=xm(s,i),c=xm(a,s),d=Math.min(n,o2(e[r],a)/2,o2(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 I8=e=>A8(k8(e)),Zg={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},T8={SIZE_FACTOR:1.4},l2=e=>e.strokeOptions?.streamline??E8,S8=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 p8(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*Zg.SIZE_FACTOR,thinning:Zg.THINNING,smoothing:Zg.SMOOTHING,streamline:l2(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},C8=e=>new ga({size:e.strokeWidth*T8.SIZE_FACTOR,streamline:l2(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),P8=e=>{let n=C8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},k8=e=>e.strokeOptions?.variability==="constant"?P8(e):S8(e);var a2=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],M8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,A8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,a2(o,i[0]),"L",i[0],"Z"):t.push(o,a2(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(M8,"$1")};var ni=(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??D8(),updated:L8()}};import{jsx as m2}from"react/jsx-runtime";var va=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&&R8(r[0])&&!_8(r[0]))},perform(e,n,t,o){c2(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);c2(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:d2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!o)return null;let r=f(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return m2(Z,{type:"button",icon:m0,title:r,"aria-label":r,onClick:()=>n(null)})}}),GTe=O({name:"togglePolygon",icon:ku,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!wa(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=>wa(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!wa(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=N8(i);return{elements:e.map(l=>!s.has(l.id)||!wa(l)?l:ni(l,{backgroundColor:a?l.backgroundColor:"transparent",...B8(l,a)})),appState:n,captureUpdate:d2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!wa(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>wa(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return m2(Z,{type:"toggle",icon:ku,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as p2,CANVAS_SEARCH_TAB as u2,CLASSES as F8,DEFAULT_SIDEBAR as h2}from"@excalidraw/common";import{CaptureUpdateAction as O8}from"@excalidraw/element";var Pl=O({name:"searchMenu",icon:Jn,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===h2.name&&n.openSidebar.tab===u2){let r=o.excalidrawContainerValue.container?.querySelector(`.${F8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:h2.name,tab:u2},openDialog:null},captureUpdate:O8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[p2.CTRL_OR_CMD]&&e.key===p2.F});import{isImageElement as z8}from"@excalidraw/element";import{CaptureUpdateAction as G8}from"@excalidraw/element";import{jsx as H8}from"react/jsx-runtime";var qg=O({name:"cropEditor",label:"helpDialog.cropStart",icon:Ju,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:G8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&z8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return H8(Z,{type:"button",icon:Ju,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as U8}from"@excalidraw/element";import{mutateElement as W8}from"@excalidraw/element";import{newFrameElement as V8}from"@excalidraw/element";import{isFrameLikeElement as Im}from"@excalidraw/element";import{addElementsToFrame as Y8,removeAllElementsFromFrame as X8}from"@excalidraw/element";import{getFrameChildren as K8}from"@excalidraw/element";import{getElementsInGroup as $8}from"@excalidraw/element";import{getCommonBounds as Z8}from"@excalidraw/element";import{CaptureUpdateAction as Ia}from"@excalidraw/element";var g2=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&Im(t[0])},f2=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(Im(r)){let i=K8(U8(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:Ia.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:Ia.EVENTUALLY}},predicate:(e,n,t,o)=>g2(n,o)}),E2=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return Im(r)?{elements:X8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:Ia.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:Ia.EVENTUALLY}},predicate:(e,n,t,o)=>g2(n,o)}),ZSe=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:Ia.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),b2=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=ce(e,n);return r.length>0&&!r.some(i=>Im(i))},perform:(e,n,t,o)=>{let r=ce(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=Z8(r,i),d=16,m=V8({x:a-d,y:s-d,width:l-a+d*2,height:c-s+d*2});if(n.editingGroupId){let u=$8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);W8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:Y8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:Ia.IMMEDIATELY}}});import{KEYS as Sa,matchKey as ef,arrayToMap as x2,MOBILE_ACTION_BUTTON_BG as y2}from"@excalidraw/common";import{CaptureUpdateAction as Qg}from"@excalidraw/element";import{orderByFractionalIndex as nN}from"@excalidraw/element";import{Emitter as j8}from"@excalidraw/common";import{CaptureUpdateAction as q8,StoreChange as J8,StoreDelta as Q8}from"@excalidraw/element";var Ta=class extends Q8{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)}},ri=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},kl=class e{constructor(n){this.store=n;v(this,"onHistoryChangedEmitter",new j8);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 Ta)return;let t=Ta.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new ri(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=q8.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=J8.create(s,p),E=Ta.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 ri(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=Ta.inverse(t);return n.push(o)}};import{useEffect as eN,useState as tN}from"react";var Jg=(e,n)=>{let[t,o]=tN(n);return eN(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as T2}from"react/jsx-runtime";var w2=(e,n,t)=>{if(!n.multiElement&&!n.resizingElement&&!n.editingTextElement&&!n.newElement&&!n.selectedElementsAreBeingDragged&&!n.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let o=t();if(!o)return{captureUpdate:Qg.EVENTUALLY};let[r,i]=o,a=nN(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Qg.NEVER}}return{captureUpdate:Qg.EVENTUALLY}},v2=e=>({name:"undo",label:"buttons.undo",icon:Lu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>w2(r,t,()=>e.undo(x2(n),t)),keyTest:n=>n[Sa.CTRL_OR_CMD]&&ef(n,Sa.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=Jg(e.onHistoryChangedEmitter,new ri(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=ct()==="mobile";return T2(Z,{type:"button",icon:Lu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?y2:{}}})}}),I2=e=>({name:"redo",label:"buttons.redo",icon:_u,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>w2(r,t,()=>e.redo(x2(n),t)),keyTest:n=>n[Sa.CTRL_OR_CMD]&&n.shiftKey&&ef(n,Sa.Z)||n[Sa.CTRL_OR_CMD]&&!n.shiftKey&&ef(n,Sa.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=Jg(e.onHistoryChangedEmitter,new ri(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=ct()==="mobile";return T2(Z,{type:"button",icon:_u,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?y2:{}}})}});import{getFontString as oN}from"@excalidraw/common";import{getTextAnchorRatios as rN,isExcalidrawElement as iN,isNonDeletedElement as aN,newElementWith as sN,updateBoundElements as lN}from"@excalidraw/element";import{measureText as cN}from"@excalidraw/element";import{isTextElement as tf}from"@excalidraw/element";import{CaptureUpdateAction as dN}from"@excalidraw/element";var nf=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=ce(e,n);return o.length===1&&tf(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=ce(e,n),i=iN(t)&&tf(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!tf(a))return!1;let s=cN(a.originalText,oN(a),a.lineHeight),l=rN(a),c=sN(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 aN(c)&&lN(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:dN.IMMEDIATELY}}});import{CODES as mN,KEYS as pN}from"@excalidraw/common";import uN from"clsx";import{CaptureUpdateAction as hN}from"@excalidraw/element";import{jsx as gN}from"react/jsx-runtime";var Ca=O({name:"viewMode",label:"labels.viewMode",icon:Hr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:hN.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[pN.CTRL_OR_CMD]&&e.altKey&&e.code===mN.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 gN(Z,{type:"button",icon:t.viewModeEnabled?nh:Hr,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:uN({enabled:t.viewModeEnabled})})}});import{isPromiseLike as fN}from"@excalidraw/common";import{jsx as EN}from"react/jsx-runtime";var of=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Fe(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Tm=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)||(of(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return EN(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(fN(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 of(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();of(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var rf=e=>{let n=Array.from(e.values());return{x:S2(n,t=>t.x)/n.length,y:S2(n,t=>t.y)/n.length}},af=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),S2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as X,pointRotateRads as ur,rangeInclusive as hn,rangeIntersection as Sm,rangesOverlap as Cm}from"@excalidraw/math";import{TOOL_TYPE as ii,KEYS as C2}from"@excalidraw/common";import{getCommonBounds as sf,getDraggedElementsBounds as lf,getElementAbsoluteCoords as bN}from"@excalidraw/element";import{isBoundToContainer as A2}from"@excalidraw/element";import{getMaximumGroups as D2}from"@excalidraw/element";import{getSelectedElements as xN,getVisibleAndNonSelectedElements as L2}from"@excalidraw/element";var yN=8,P2=99999,Pm=e=>yN/e,Nt=class Nt{};v(Nt,"referenceSnapPoints",null),v(Nt,"visibleGaps",null),v(Nt,"setReferenceSnapPoints",n=>{Nt.referenceSnapPoints=n}),v(Nt,"getReferenceSnapPoints",()=>Nt.referenceSnapPoints),v(Nt,"setVisibleGaps",n=>{Nt.visibleGaps=n}),v(Nt,"getVisibleGaps",()=>Nt.visibleGaps),v(Nt,"destroy",()=>{Nt.referenceSnapPoints=null,Nt.visibleGaps=null});var gn=Nt,hr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,ko=({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[C2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[C2.CTRL_OR_CMD]&&!hr(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},wN=(e,n,t=.01)=>Math.abs(e-n)<=t,Ml=(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]=bN(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=ur(X(s,l+E),X(m,p),a.angle),b=ur(X(s+u,l),X(m,p),a.angle),w=ur(X(c,l+E),X(m,p),a.angle),y=ur(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=ur(X(s,l),X(m,p),a.angle),b=ur(X(c,l),X(m,p),a.angle),w=ur(X(s,d),X(m,p),a.angle),y=ur(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]=lf(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(Xe(a[0]),Xe(a[1])))},_2=(e,n,t,o)=>L2(e,n,t,o),R2=(e,n,t,o)=>{let r=_2(e,n,t,o),i=D2(r,o).filter(m=>!(m.length===1&&A2(m[0]))).map(m=>sf(m).map(p=>Xe(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>P2)break e;let E=a[u],[,g,b,w]=p,[y,x,,I]=E;b<y&&Cm(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:Sm(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>P2)break e;let E=c[u],[g,,b,w]=p,[y,x,I]=E;w<x&&Cm(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:Sm(hn(g,b),hn(y,I))})}}return{horizontalGaps:s,verticalGaps:d}},k2=(e,n,t,o,r,i,a)=>{if(!ko({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]=lf(e,n).map(b=>Xe(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!Cm(hn(m,u),b.overlap))continue;let w=b.startSide[0][0]+b.length/2,y=Xe(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=Xe(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=Xe(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(!Cm(hn(d,p),b.overlap))continue;let w=b.startSide[0][1]+b.length/2,y=Xe(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=Xe(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=Xe(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}}}},N2=(e,n,t,o)=>{let r=_2(e,n,t,o);return D2(r,o).filter(i=>!(i.length===1&&A2(i[0]))).flatMap(i=>Ml(i,o))},Pa=(e,n,t,o,r,i,a)=>{if(!ko({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))}},B2=(e,n,t,o,r)=>{let i=t.state,a=xN(e,i);if(!ko({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=Xe(n.x),n.y=Xe(n.y);let s=[],l=[],c=Pm(i.zoom.value),d={x:c,y:c},m=Ml(a,r,{dragOffset:n});Pa(a,m,t,o,s,l,d),k2(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:Xe(n.x+p.x),y:Xe(n.y+p.y)};Pa(a,Ml(a,r,{dragOffset:u}),t,o,s,l,d),k2(a,u,t,o,s,l,d);let E=cf(s,l),g=IN(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},Xe=e=>Math.round(e*10**6)/10**6,M2=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())},cf=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Xe(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>X(Xe(a[0]),Xe(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=Xe(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>X(Xe(a[0]),Xe(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:M2(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:M2(i.map(a=>X(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},vN=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[Xe(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},IN=(e,n,t)=>{let[o,r,i,a]=lf(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,w=Sm(hn(r,a),l.gap.overlap),y=Sm(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 vN(s.map(l=>({...l,points:l.points.map(c=>X(Xe(c[0]),Xe(c[1])))})))},df=(e,n,t,o,r,i)=>{if(!ko({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!wN(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=sf(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=Pm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];Pa(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]=sf(e).map(C=>Xe(C)),I=[X(b,w),X(b,x),X(y,w),X(y,x)];Pa(e,I,t,o,u,E,p);let T=cf(u,E);return{snapOffset:g,snapLines:T}},F2=(e,n,t,o,r,i)=>{if(!ko({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=Pm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];Pa([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=Ml([e],i,{boundingBoxCorners:!0,omitCenter:!0});Pa([e],p,n,t,c,d,l);let u=cf(c,d);return{snapOffset:m,snapLines:u}},O2=(e,n,t,o,r)=>{if(!ko({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=L2(e,[],n.state,r),a=Pm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=Ml([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]}},z2=e=>e===ii.rectangle||e===ii.ellipse||e===ii.diamond||e===ii.frame||e===ii.magicframe||e===ii.image||e===ii.text;import{getCommonFrameId as TN,getFrameChildrenInsertionIndex as SN,isElementInViewport as CN}from"@excalidraw/element";import{arrayToMap as PN,memoize as kN,toBrandedType as MN}from"@excalidraw/common";var Al=class{constructor(n){v(this,"scene");v(this,"_getRenderableElements",kN(({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&&TN(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())CN(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=MN(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=PN(t),i=n.filter(s=>!r.has(s.id)),a=SN(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){ux.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as RN,easeOut as U2}from"@excalidraw/common";import{SVG_NS as H2,getSvgPathFromStroke as LN,sceneCoordsToViewportCoords as _N}from"@excalidraw/common";import{version as AN}from"react";import{unstable_batchedUpdates as G2}from"react-dom";import{throttleRAF as DN}from"@excalidraw/common";var Ke=e=>n=>{G2(e,n)},km=e=>DN(n=>{G2(e,n)}),ka=(()=>{let e;try{let t=AN.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 me=class me{static start(n,t){if(me.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};me.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw me.animations.get(n)===o&&(me.animations.delete(n),me.cancelScheduledFrameIfIdle()),i}if(me.animations.get(n)===o){if(!r){me.animations.delete(n),me.cancelScheduledFrameIfIdle();return}o.state=r,me.scheduleNextFrame()}}static scheduleNextFrame(){me.scheduledFrame||(ka()?me.scheduledFrame={id:requestAnimationFrame(me.tick),type:"raf"}:me.scheduledFrame={id:setTimeout(me.tick,0),type:"timeout"})}static cancelScheduledFrame(){me.scheduledFrame&&(me.scheduledFrame.type==="raf"?cancelAnimationFrame(me.scheduledFrame.id):clearTimeout(me.scheduledFrame.id),me.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return me.animations.size>0?!1:(me.cancelScheduledFrame(),!0)}static tick(){if(me.scheduledFrame=null,me.animations.size>0){let n=[...me.animations];for(let[t,o]of n){if(me.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(me.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(me.animations.delete(t),me.cancelScheduledFrameIfIdle())return}}if(me.cancelScheduledFrameIfIdle())return;me.scheduleNextFrame()}}static running(n){return me.animations.has(n)}static cancel(n){me.animations.delete(n),me.cancelScheduledFrameIfIdle()}static reset(){me.animations.clear(),me.cancelScheduledFrame()}};v(me,"scheduledFrame",null),v(me,"animations",new Map);var st=me;var Mm=class Mm{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-${Mm.counter++}`,this.trailElement=document.createElementNS(H2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(H2,"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),st.running(this.key)||st.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){st.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new ga(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=_N({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return LN(r,!0)}};v(Mm,"counter",0);var Rn=Mm;var Am=class{constructor(n){this.app=n;v(this,"localTrail");v(this,"collabTrails",new Map);v(this,"container");this.localTrail=new Rn(n,{...this.getTrailOptions(),fill:()=>RN})}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(U2(i),U2(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 Rn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||Jr(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 NN}from"@excalidraw/common";import{pointFrom as Dl,pointRotateRads as Dm}from"@excalidraw/math";var BN=12,mf=16,FN=10,ON=mf+2,zN=.8,pf=e=>NN*2/e,uf=(e,n,t)=>{let o=pf(n);if(t!=="desktop"||mf>(e.height+o*2)*n*zN)return null;let r=BN/n,i=mf/n,a=Dl(e.x+e.width/2,e.y+e.height/2),s=Dm(Dl(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:Dm(Dl(s[0],s[1]-i/2),s,e.angle),end:Dm(Dl(s[0],s[1]+i/2),s,e.angle),hitboxWidth:FN/n,hitboxHeight:ON/n}},W2=(e,n,t,o)=>{let r=uf(n,t,o);if(!r)return!1;let i=Dm(Dl(e.x,e.y),r.center,-n.angle);return Math.abs(i[0]-r.center[0])<=r.hitboxWidth/2&&Math.abs(i[1]-r.center[1])<=r.hitboxHeight/2};import{CODES as hf,KEYS as Ll,CLASSES as gf,POINTER_BUTTON as GN,THEME as HN,isWritableElement as UN,getFontString as V2,getFontFamilyString as Y2,isTestEnv as X2,MIME_TYPES as ff,applyDarkModeFilter as WN,isRTL as VN}from"@excalidraw/common";import{pointFrom as K2,pointRotateRads as YN}from"@excalidraw/math";import{getTextFromElements as XN,originalContainerCache as KN,updateBoundElements as $2,updateOriginalContainerCache as Z2}from"@excalidraw/element";import{LinearElementEditor as $N}from"@excalidraw/element/linearElementEditor";import{bumpVersion as ZN}from"@excalidraw/element";import{getBoundTextElementId as jN,getContainerElement as Ef,getTextElementAngle as qN,redrawTextBoundingBox as JN,getBoundTextMaxHeight as QN,getBoundTextMaxWidth as j2,computeContainerDimensionForBoundText as q2,computeBoundTextPosition as e7,getBoundTextElement as t7}from"@excalidraw/element";import{getTextWidth as n7}from"@excalidraw/element";import{getLineHeightInPx as o7}from"@excalidraw/element";import{getLineWidth as r7}from"@excalidraw/element";import{normalizeText as J2}from"@excalidraw/element";import{wrapText as i7}from"@excalidraw/element";import{getWrappedTextLines as a7}from"@excalidraw/element";import{isArrowElement as Lm,isBoundToContainer as s7,isTextElement as Q2}from"@excalidraw/element";var l7=(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}) rotate(${s}deg)`},c7=(e,n)=>{let t=e.lastIndexOf(`
10
+ L ${l-b} ${d+w}
11
+ C ${l} ${d}, ${l} ${d}, ${l+b} ${d+w}`,Co(e,!0,a))}else s=n.polygon([[l,d],[c,m],[p,u],[E,g]],Co(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,Co(e,!1,a));case"line":case"arrow":{let s,l=Co(e,!1,a),d=e.points.length?e.points:[b8(0,0)];if(Dn(e)?d.every(c=>Math.abs(c[0])<=1e6&&Math.abs(c[1])<=1e6)?s=[n.path(P8(d,16),Co(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(d)),s=[]):e.roundness?s=[n.curve(d,l)]:l.fill?s=[n.polygon(d,l)]:s=[n.linearPath(d,l)],e.type==="arrow"){let{startArrowhead:c=null,endArrowhead:m="arrow"}=e;if(c!==null){let p=d2(e,s,"start",c,n,l,o,a);s.push(...p)}if(m!==null){let p=d2(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(Ea(e.points)){let l=f8(e.points,.75);s.push(n.curve(l,{...Co(e,!1,a),stroke:"none"}))}return s.push(k8(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return y8(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},P8=(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=xm(s,i),d=xm(a,s),c=Math.min(n,l2(e[r],a)/2,l2(e[r],i)/2);l?i[0]<s[0]?t.push([e[r][0]-c,e[r][1]]):t.push([e[r][0]+c,e[r][1]]):i[1]<s[1]?t.push([e[r][0],e[r][1]-c]):t.push([e[r][0],e[r][1]+c]),t.push(e[r]),d?a[0]<s[0]?t.push([e[r][0]-c,e[r][1]]):t.push([e[r][0]+c,e[r][1]]):a[1]<s[1]?t.push([e[r][0],e[r][1]-c]):t.push([e[r][0],e[r][1]+c])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)o.push(`L ${t[r][0]} ${t[r][1]}`),o.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")};var k8=e=>N8(_8(e)),jg={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},M8={SIZE_FACTOR:1.4},u2=e=>e.strokeOptions?.streamline??v8,A8=e=>{let n=e.simulatePressure?e.points:e.points.length?e.points.map(([t,o],r)=>[t,o,e.pressures[r]]):[[0,0,.5]];return E8(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*jg.SIZE_FACTOR,thinning:jg.THINNING,smoothing:jg.SMOOTHING,streamline:u2(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},D8=e=>new fa({size:e.strokeWidth*M8.SIZE_FACTOR,streamline:u2(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),L8=e=>{let n=D8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},_8=e=>e.strokeOptions?.variability==="constant"?L8(e):A8(e);var m2=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],R8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,N8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,m2(o,i[0]),"L",i[0],"Z"):t.push(o,m2(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(R8,"$1")};var ni=(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??B8(),updated:F8()}};import{jsx as f2}from"react/jsx-runtime";var Ia=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&&z8(r[0])&&!O8(r[0]))},perform(e,n,t,o){h2(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);h2(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:g2.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 f2(Z,{type:"button",icon:u0,title:r,"aria-label":r,onClick:()=>n(null)})}}),ZSe=O({name:"togglePolygon",icon:Mu,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!va(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=>va(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!va(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=G8(i);return{elements:e.map(l=>!s.has(l.id)||!va(l)?l:ni(l,{backgroundColor:a?l.backgroundColor:"transparent",...H8(l,a)})),appState:n,captureUpdate:g2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!va(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>va(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return f2(Z,{type:"toggle",icon:Mu,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as E2,CANVAS_SEARCH_TAB as b2,CLASSES as U8,DEFAULT_SIDEBAR as x2}from"@excalidraw/common";import{CaptureUpdateAction as W8}from"@excalidraw/element";var Pl=O({name:"searchMenu",icon:Jn,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===x2.name&&n.openSidebar.tab===b2){let r=o.excalidrawContainerValue.container?.querySelector(`.${U8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:x2.name,tab:b2},openDialog:null},captureUpdate:W8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[E2.CTRL_OR_CMD]&&e.key===E2.F});import{isImageElement as V8}from"@excalidraw/element";import{CaptureUpdateAction as Y8}from"@excalidraw/element";import{jsx as K8}from"react/jsx-runtime";var Jg=O({name:"cropEditor",label:"helpDialog.cropStart",icon:Qu,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:Y8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&V8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return K8(Z,{type:"button",icon:Qu,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as X8}from"@excalidraw/element";import{mutateElement as $8}from"@excalidraw/element";import{newFrameElement as Z8}from"@excalidraw/element";import{isFrameLikeElement as Im}from"@excalidraw/element";import{addElementsToFrame as j8,removeAllElementsFromFrame as q8}from"@excalidraw/element";import{getFrameChildren as J8}from"@excalidraw/element";import{getElementsInGroup as Q8}from"@excalidraw/element";import{getCommonBounds as eN}from"@excalidraw/element";import{CaptureUpdateAction as Sa}from"@excalidraw/element";var y2=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&Im(t[0])},w2=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(Im(r)){let i=J8(X8(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:Sa.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:Sa.EVENTUALLY}},predicate:(e,n,t,o)=>y2(n,o)}),v2=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return Im(r)?{elements:q8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:Sa.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:Sa.EVENTUALLY}},predicate:(e,n,t,o)=>y2(n,o)}),rCe=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:Sa.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),I2=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=ce(e,n);return r.length>0&&!r.some(i=>Im(i))},perform:(e,n,t,o)=>{let r=ce(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,d]=eN(r,i),c=16,m=Z8({x:a-c,y:s-c,width:l-a+c*2,height:d-s+c*2});if(n.editingGroupId){let u=Q8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);$8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:j8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:Sa.IMMEDIATELY}}});import{KEYS as Ca,matchKey as tf,arrayToMap as S2,MOBILE_ACTION_BUTTON_BG as T2}from"@excalidraw/common";import{CaptureUpdateAction as ef}from"@excalidraw/element";import{orderByFractionalIndex as sN}from"@excalidraw/element";import{Emitter as tN}from"@excalidraw/common";import{CaptureUpdateAction as nN,StoreChange as oN,StoreDelta as rN}from"@excalidraw/element";var Ta=class extends rN{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)}},ri=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},kl=class e{constructor(n){this.store=n;v(this,"onHistoryChangedEmitter",new tN);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 Ta)return;let t=Ta.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new ri(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=nN.IMMEDIATELY,s=this.store.snapshot,l=n,d=t,c=!1;for(;i;){try{[l,d,c]=i.applyTo(l,d,s);let m=s.elements,p=s.maybeClone(a,l,d),u=oN.create(s,p),E=Ta.applyLatestChanges(i,m,l);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),s=p}finally{r(i)}if(c)break;i=o()}return[l,d]}finally{this.onHistoryChangedEmitter.trigger(new ri(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=Ta.inverse(t);return n.push(o)}};import{useEffect as iN,useState as aN}from"react";var Qg=(e,n)=>{let[t,o]=aN(n);return iN(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as M2}from"react/jsx-runtime";var C2=(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:ef.EVENTUALLY};let[r,i]=o,a=sN(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:ef.NEVER}}return{captureUpdate:ef.EVENTUALLY}},P2=e=>({name:"undo",label:"buttons.undo",icon:_u,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>C2(r,t,()=>e.undo(S2(n),t)),keyTest:n=>n[Ca.CTRL_OR_CMD]&&tf(n,Ca.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=Qg(e.onHistoryChangedEmitter,new ri(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=ct()==="mobile";return M2(Z,{type:"button",icon:_u,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?T2:{}}})}}),k2=e=>({name:"redo",label:"buttons.redo",icon:Ru,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>C2(r,t,()=>e.redo(S2(n),t)),keyTest:n=>n[Ca.CTRL_OR_CMD]&&n.shiftKey&&tf(n,Ca.Z)||n[Ca.CTRL_OR_CMD]&&!n.shiftKey&&tf(n,Ca.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=Qg(e.onHistoryChangedEmitter,new ri(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=ct()==="mobile";return M2(Z,{type:"button",icon:Ru,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?T2:{}}})}});import{getFontString as lN}from"@excalidraw/common";import{getTextAnchorRatios as cN,isExcalidrawElement as dN,isNonDeletedElement as mN,newElementWith as pN,updateBoundElements as uN}from"@excalidraw/element";import{measureText as hN}from"@excalidraw/element";import{isTextElement as nf}from"@excalidraw/element";import{CaptureUpdateAction as gN}from"@excalidraw/element";var of=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=ce(e,n);return o.length===1&&nf(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=ce(e,n),i=dN(t)&&nf(t)?t:r[0],a=e.find(c=>c.id===i?.id);if(!a||!nf(a))return!1;let s=hN(a.originalText,lN(a),a.lineHeight),l=cN(a),d=pN(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 mN(d)&&uN(d,o.scene,{changedElements:new Map([[d.id,d]])}),{appState:n,elements:e.map(c=>c.id===d.id?d:c),captureUpdate:gN.IMMEDIATELY}}});import{CODES as fN,KEYS as EN}from"@excalidraw/common";import bN from"clsx";import{CaptureUpdateAction as xN}from"@excalidraw/element";import{jsx as yN}from"react/jsx-runtime";var Pa=O({name:"viewMode",label:"labels.viewMode",icon:Hr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:xN.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[EN.CTRL_OR_CMD]&&e.altKey&&e.code===fN.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 yN(Z,{type:"button",icon:t.viewModeEnabled?oh:Hr,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:bN({enabled:t.viewModeEnabled})})}});import{isPromiseLike as wN}from"@excalidraw/common";import{jsx as vN}from"react/jsx-runtime";var rf=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Fe(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Sm=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)||(rf(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return vN(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(wN(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,d)=>(d.keyPriority||0)-(l.keyPriority||0)).filter(l=>{let d=this.app.props.keyboardShortcuts?.[l.name];return(l.name in t?t[l.name]:!0)&&(l.keyTest||d!==void 0)&&(d!==void 0?Qi(n,d)&&(!l.keyCondition||l.keyCondition(n,this.getAppState(),this.getElementsIncludingDeleted(),this.app)):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 rf(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();rf(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var af=e=>{let n=Array.from(e.values());return{x:A2(n,t=>t.x)/n.length,y:A2(n,t=>t.y)/n.length}},sf=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),A2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as X,pointRotateRads as ur,rangeInclusive as hn,rangeIntersection as Tm,rangesOverlap as Cm}from"@excalidraw/math";import{TOOL_TYPE as ii,KEYS as D2}from"@excalidraw/common";import{getCommonBounds as lf,getDraggedElementsBounds as cf,getElementAbsoluteCoords as IN}from"@excalidraw/element";import{isBoundToContainer as N2}from"@excalidraw/element";import{getMaximumGroups as B2}from"@excalidraw/element";import{getSelectedElements as SN,getVisibleAndNonSelectedElements as F2}from"@excalidraw/element";var TN=8,L2=99999,Pm=e=>TN/e,Nt=class Nt{};v(Nt,"referenceSnapPoints",null),v(Nt,"visibleGaps",null),v(Nt,"setReferenceSnapPoints",n=>{Nt.referenceSnapPoints=n}),v(Nt,"getReferenceSnapPoints",()=>Nt.referenceSnapPoints),v(Nt,"setVisibleGaps",n=>{Nt.visibleGaps=n}),v(Nt,"getVisibleGaps",()=>Nt.visibleGaps),v(Nt,"destroy",()=>{Nt.referenceSnapPoints=null,Nt.visibleGaps=null});var gn=Nt,hr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Po=({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[D2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[D2.CTRL_OR_CMD]&&!hr(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},CN=(e,n,t=.01)=>Math.abs(e-n)<=t,Ml=(e,n,{omitCenter:t,boundingBoxCorners:o,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,d,c,m,p]=IN(a,n);r&&(s+=r.x,d+=r.x,m+=r.x,l+=r.y,c+=r.y,p+=r.y);let u=(d-s)/2,E=(c-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=ur(X(s,l+E),X(m,p),a.angle),b=ur(X(s+u,l),X(m,p),a.angle),w=ur(X(d,l+E),X(m,p),a.angle),y=ur(X(s+u,c),X(m,p),a.angle),x=X(m,p);i=t?[g,b,w,y]:[g,b,w,y,x]}else{let g=ur(X(s,l),X(m,p),a.angle),b=ur(X(d,l),X(m,p),a.angle),w=ur(X(s,c),X(m,p),a.angle),y=ur(X(d,c),X(m,p),a.angle),x=X(m,p);i=t?[g,b,w,y]:[g,b,w,y,x]}}else if(e.length>1){let[a,s,l,d]=cf(e,r??{x:0,y:0}),c=l-a,m=d-s,p=X(a,s),u=X(l,s),E=X(a,d),g=X(l,d),b=X(a+c/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>X(Ke(a[0]),Ke(a[1])))},O2=(e,n,t,o)=>F2(e,n,t,o),z2=(e,n,t,o)=>{let r=O2(e,n,t,o),i=B2(r,o).filter(m=>!(m.length===1&&N2(m[0]))).map(m=>lf(m).map(p=>Ke(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>L2)break e;let E=a[u],[,g,b,w]=p,[y,x,,I]=E;b<y&&Cm(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:Tm(hn(g,w),hn(x,I))})}}let d=i.sort((m,p)=>m[1]-p[1]),c=[];l=0;e:for(let m=0;m<d.length;m++){let p=d[m];for(let u=m+1;u<d.length;u++){if(++l>L2)break e;let E=d[u],[g,,b,w]=p,[y,x,I]=E;w<x&&Cm(hn(g,b),hn(y,I))&&c.push({startBounds:p,endBounds:E,startSide:[X(g,w),X(b,w)],endSide:[X(y,x),X(I,x)],length:x-w,overlap:Tm(hn(g,b),hn(y,I))})}}return{horizontalGaps:s,verticalGaps:c}},_2=(e,n,t,o,r,i,a)=>{if(!Po({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=gn.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:d}=s,[c,m,p,u]=cf(e,n).map(b=>Ke(b)),E=(c+p)/2,g=(m+u)/2;for(let b of l){if(!Cm(hn(m,u),b.overlap))continue;let w=b.startSide[0][0]+b.length/2,y=Ke(w-E);if(b.length>p-c&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(r.length=0),a.x=Math.abs(y);let _={type:"gap",direction:"center_horizontal",gap:b,offset:y};r.push(_);continue}let[,,I]=b.endBounds,S=c-I,C=Ke(b.length-S);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=Ke(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 d){if(!Cm(hn(c,p),b.overlap))continue;let w=b.startSide[0][1]+b.length/2,y=Ke(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,S=I-u,C=Ke(S-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=Ke(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}}}},G2=(e,n,t,o)=>{let r=O2(e,n,t,o);return B2(r,o).filter(i=>!(i.length===1&&N2(i[0]))).flatMap(i=>Ml(i,o))},ka=(e,n,t,o,r,i,a)=>{if(!Po({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 d of s){let c=d[0]-l[0],m=d[1]-l[1];Math.abs(c)<=a.x&&(Math.abs(c)<a.x&&(r.length=0),r.push({type:"point",points:[l,d],offset:c}),a.x=Math.abs(c)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[l,d],offset:m}),a.y=Math.abs(m))}},H2=(e,n,t,o,r)=>{let i=t.state,a=SN(e,i);if(!Po({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=Ke(n.x),n.y=Ke(n.y);let s=[],l=[],d=Pm(i.zoom.value),c={x:d,y:d},m=Ml(a,r,{dragOffset:n});ka(a,m,t,o,s,l,c),_2(a,n,t,o,s,l,c);let p={x:s[0]?.offset??0,y:l[0]?.offset??0};c.x=0,c.y=0,s.length=0,l.length=0;let u={x:Ke(n.x+p.x),y:Ke(n.y+p.y)};ka(a,Ml(a,r,{dragOffset:u}),t,o,s,l,c),_2(a,u,t,o,s,l,c);let E=df(s,l),g=kN(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},Ke=e=>Math.round(e*10**6)/10**6,R2=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())},df=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Ke(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>X(Ke(a[0]),Ke(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=Ke(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>X(Ke(a[0]),Ke(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:R2(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:R2(i.map(a=>X(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},PN=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[Ke(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},kN=(e,n,t)=>{let[o,r,i,a]=cf(e,n),s=[];for(let l of t){let[d,c,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,w=Tm(hn(r,a),l.gap.overlap),y=Tm(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(d,x)]},{type:"gap",direction:"horizontal",points:[X(m,x),X(u,x)]})}break}case"side_top":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[X(x,a),X(x,c)]},{type:"gap",direction:"vertical",points:[X(x,p),X(x,E)]})}break}case"side_bottom":{if(y){let x=(y[0]+y[1])/2;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 PN(s.map(l=>({...l,points:l.points.map(d=>X(Ke(d[0]),Ke(d[1])))})))},mf=(e,n,t,o,r,i)=>{if(!Po({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!CN(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,d]=lf(n);i&&(i.includes("e")?l+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?s+=r.y:i.includes("s")&&(d+=r.y));let c=[];if(i)switch(i){case"e":{c.push(X(l,s),X(l,d));break}case"w":{c.push(X(a,s),X(a,d));break}case"n":{c.push(X(a,s),X(l,s));break}case"s":{c.push(X(a,d),X(l,d));break}case"ne":{c.push(X(l,s));break}case"nw":{c.push(X(a,s));break}case"se":{c.push(X(l,d));break}case"sw":{c.push(X(a,d));break}}let m=Pm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];ka(n,c,t,o,u,E,p);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};p.x=0,p.y=0,u.length=0,E.length=0;let[b,w,y,x]=lf(e).map(C=>Ke(C)),I=[X(b,w),X(b,x),X(y,w),X(y,x)];ka(e,I,t,o,u,E,p);let S=df(u,E);return{snapOffset:g,snapLines:S}},U2=(e,n,t,o,r,i)=>{if(!Po({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=Pm(n.state.zoom.value),l={x:s,y:s},d=[],c=[];ka([e],a,n,t,d,c,l);let m={x:d[0]?.offset??0,y:c[0]?.offset??0};l.x=0,l.y=0,d.length=0,c.length=0;let p=Ml([e],i,{boundingBoxCorners:!0,omitCenter:!0});ka([e],p,n,t,d,c,l);let u=df(d,c);return{snapOffset:m,snapLines:u}},W2=(e,n,t,o,r)=>{if(!Po({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=F2(e,[],n.state,r),a=Pm(n.state.zoom.value),s={x:a,y:a},l=[],d=[];for(let c of i){let m=Ml([c],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)&&(d.length=0),d.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:d.length>0?d[0].points[0][0]-t.x:0,y:l.length>0?l[0].points[0][1]-t.y:0},snapLines:[...d,...l]}},V2=e=>e===ii.rectangle||e===ii.ellipse||e===ii.diamond||e===ii.frame||e===ii.magicframe||e===ii.image||e===ii.text;import{getCommonFrameId as MN,getFrameChildrenInsertionIndex as AN,isElementInViewport as DN}from"@excalidraw/element";import{arrayToMap as LN,memoize as _N,toBrandedType as RN}from"@excalidraw/common";var Al=class{constructor(n){v(this,"scene");v(this,"_getRenderableElements",_N(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l,editingTextElement:d,newElement:c})=>{let m=this.scene.getNonDeletedElements(),{elementsMap:p,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:m,editingTextElement:d,newElement:c}),E=this.getVisibleCanvasElements({elementsMap:p,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height: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&&MN(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 d=[];for(let c of n.values())DN(c,l,s,{zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a},n)&&d.push(c);return d}getRenderableElementsMap({elements:n,editingTextElement:t,newElement:o}){let r=RN(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=LN(t),i=n.filter(s=>!r.has(s.id)),a=AN(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){gx.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as zN,easeOut as X2}from"@excalidraw/common";import{SVG_NS as K2,getSvgPathFromStroke as FN,sceneCoordsToViewportCoords as ON}from"@excalidraw/common";import{version as NN}from"react";import{unstable_batchedUpdates as Y2}from"react-dom";import{throttleRAF as BN}from"@excalidraw/common";var Xe=e=>n=>{Y2(e,n)},km=e=>BN(n=>{Y2(e,n)}),Ma=(()=>{let e;try{let t=NN.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 me=class me{static start(n,t){if(me.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};me.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw me.animations.get(n)===o&&(me.animations.delete(n),me.cancelScheduledFrameIfIdle()),i}if(me.animations.get(n)===o){if(!r){me.animations.delete(n),me.cancelScheduledFrameIfIdle();return}o.state=r,me.scheduleNextFrame()}}static scheduleNextFrame(){me.scheduledFrame||(Ma()?me.scheduledFrame={id:requestAnimationFrame(me.tick),type:"raf"}:me.scheduledFrame={id:setTimeout(me.tick,0),type:"timeout"})}static cancelScheduledFrame(){me.scheduledFrame&&(me.scheduledFrame.type==="raf"?cancelAnimationFrame(me.scheduledFrame.id):clearTimeout(me.scheduledFrame.id),me.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return me.animations.size>0?!1:(me.cancelScheduledFrame(),!0)}static tick(){if(me.scheduledFrame=null,me.animations.size>0){let n=[...me.animations];for(let[t,o]of n){if(me.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(me.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(me.animations.delete(t),me.cancelScheduledFrameIfIdle())return}}if(me.cancelScheduledFrameIfIdle())return;me.scheduleNextFrame()}}static running(n){return me.animations.has(n)}static cancel(n){me.animations.delete(n),me.cancelScheduledFrameIfIdle()}static reset(){me.animations.clear(),me.cancelScheduledFrame()}};v(me,"scheduledFrame",null),v(me,"animations",new Map);var st=me;var Mm=class Mm{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-${Mm.counter++}`,this.trailElement=document.createElementNS(K2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(K2,"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),st.running(this.key)||st.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){st.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new fa(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=ON({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return FN(r,!0)}};v(Mm,"counter",0);var Rn=Mm;var Am=class{constructor(n){this.app=n;v(this,"localTrail");v(this,"collabTrails",new Map);v(this,"container");this.localTrail=new Rn(n,{...this.getTrailOptions(),fill:()=>zN})}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(X2(i),X2(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 Rn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||Jr(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 GN}from"@excalidraw/common";import{pointFrom as Dl,pointRotateRads as Dm}from"@excalidraw/math";var HN=12,pf=16,UN=10,WN=pf+2,VN=.8,uf=e=>GN*2/e,hf=(e,n,t)=>{let o=uf(n);if(t!=="desktop"||pf>(e.height+o*2)*n*VN)return null;let r=HN/n,i=pf/n,a=Dl(e.x+e.width/2,e.y+e.height/2),s=Dm(Dl(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:Dm(Dl(s[0],s[1]-i/2),s,e.angle),end:Dm(Dl(s[0],s[1]+i/2),s,e.angle),hitboxWidth:UN/n,hitboxHeight:WN/n}},$2=(e,n,t,o)=>{let r=hf(n,t,o);if(!r)return!1;let i=Dm(Dl(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 gf,KEYS as Ll,CLASSES as ff,POINTER_BUTTON as YN,THEME as KN,isWritableElement as XN,getFontString as Z2,getFontFamilyString as j2,isTestEnv as q2,MIME_TYPES as Ef,applyDarkModeFilter as $N,isRTL as ZN}from"@excalidraw/common";import{pointFrom as J2,pointRotateRads as jN}from"@excalidraw/math";import{getTextFromElements as qN,originalContainerCache as JN,updateBoundElements as Q2,updateOriginalContainerCache as eI}from"@excalidraw/element";import{LinearElementEditor as QN}from"@excalidraw/element/linearElementEditor";import{bumpVersion as e7}from"@excalidraw/element";import{getBoundTextElementId as t7,getContainerElement as bf,getTextElementAngle as n7,redrawTextBoundingBox as o7,getBoundTextMaxHeight as r7,getBoundTextMaxWidth as tI,computeContainerDimensionForBoundText as nI,computeBoundTextPosition as i7,getBoundTextElement as a7}from"@excalidraw/element";import{getTextWidth as s7}from"@excalidraw/element";import{getLineHeightInPx as l7}from"@excalidraw/element";import{getLineWidth as c7}from"@excalidraw/element";import{normalizeText as oI}from"@excalidraw/element";import{wrapText as d7}from"@excalidraw/element";import{getWrappedTextLines as m7}from"@excalidraw/element";import{isArrowElement as Lm,isBoundToContainer as p7,isTextElement as rI}from"@excalidraw/element";var u7=(e,n,t,o,r,i)=>{let{zoom:a}=o,s=180*t/Math.PI,l=e*(a.value-1)/2,d=n*(a.value-1)/2;return e>r&&a.value!==1&&(l=r*(a.value-1)/2),n>i&&a.value!==1&&(d=i*(a.value-1)/2),`translate(${l}px, ${d}px) scale(${a.value}) rotate(${s}deg)`},h7=(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 VN(r)?"rtl":"ltr"},d7=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},m7=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=d7(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},eI=({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,W)=>{if(!W.style.fontFamily||!W.style.fontSize)return!1;let ue=W.style.fontFamily.replace(/"/g,"");return Y2({fontFamily:B.fontFamily})!==ue||`${B.fontSize}px`!==W.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let B=a.state,W=a.scene.getElement(o.id);if(!W)return;let{textAlign:ue,verticalAlign:Ee}=W,le=a.scene.getNonDeletedElementsMap();if(W&&Q2(W)){let he=W.x,ge=W.y,se=Ef(W,a.scene.getNonDeletedElementsMap()),xe=W.width,it=W.height,$e=W.width,ke=W.height;if(se&&W.containerId){if(Lm(se)){let on=$N.getBoundTextElementPosition(se,W,le);he=on.x,ge=on.y}let gs=d(W,u),ho;if(gs?ho=Z2(se.id,se.height):(ho=KN[se.id],ho||(ho=Z2(se.id,se.height))),$e=j2(se,W),ke=QN(se,W),!Lm(se)&&it>ke){let on=q2(it,se.type);a.scene.mutateElement(se,{height:on}),$2(se,a.scene);return}else if(!Lm(se)&&se.height>ho.height&&it<ke){let on=q2(it,se.type);a.scene.mutateElement(se,{height:on}),$2(se,a.scene)}else{let{x:on,y:Vo}=e7(se,W,le);he=on,ge=Vo}}let[Zt,Ho]=t(he,ge);se?xe+=.5:($e=(B.width-8-Zt)/B.zoom.value,xe=Math.min(xe,$e)),it*=1.05;let Uo=V2(W),Wo=qN(W,se),Ii=(B.height-Ho)/B.zoom.value;Object.assign(u.style,{font:Uo,lineHeight:W.lineHeight,width:`${xe}px`,height:`${it}px`,left:`${Zt}px`,top:`${Ho}px`,transform:l7(xe,it,Wo,B,$e,Ii),textAlign:ue,verticalAlign:Ee,color:WN(W.strokeColor,B.theme===HN.DARK),opacity:W.opacity/100,maxHeight:`${Ii}px`}),c={angle:Wo,font:Uo,height:W.height,lineHeightPx:o7(W.fontSize,W.lineHeight),textAlign:ue,width:W.width,x:he,y:ge},u.scrollTop=0,X2()&&(u.style.fontFamily=Y2(W)),a.scene.mutateElement(W,{x:he,y:ge})}},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";(s7(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,W=K2(B.x+B.width/2,B.y+B.height/2),[ue,Ee]=YN(K2(l.x,l.y),W,-B.angle),le=ue-B.x,he=Ee-B.y,ge=a7(u.value,B.font,E==="pre-wrap"?B.width:1/0),se=Math.max(0,Math.min(ge.length-1,Math.floor(he/B.lineHeightPx))),xe=ge[se],it=c7(u.value,xe.start),$e=r7(xe.text,B.font),ke=B.textAlign==="center"?(B.width-$e)/2:B.textAlign==="right"?B.width-$e:0,Zt=le-ke;if(!xe.text)return xe.start;let Ho=m7({text:xe.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:it,targetX:Zt});return xe.start+(Ho||0)},w=(()=>{let B=b();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let W=yw(B),ue=null;if(W.has(ff.excalidrawClipboard)||W.has(ff.excalidraw)){B.preventDefault(),ue=await Kr(B);try{let se=await jd(ue);if(se.elements){let xe=XN(se.elements);if(xe){let{selectionStart:it,selectionEnd:$e,value:ke}=u;u.value=ke.slice(0,it)+xe+ke.slice($e);let Zt=it+xe.length;u.selectionStart=u.selectionEnd=Zt,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}ue=ue||await Kr(B);let Ee=ue.findByType(ff.text);if(!Ee)return;let le=J2(Ee.value);if(!le)return;let he=Ef(o,a.scene.getNonDeletedElementsMap()),ge=V2({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(he){let se=t7(he,a.scene.getNonDeletedElementsMap()),xe=i7(`${u.value}${le}`,ge,j2(he,se)),it=n7(xe,ge);u.style.width=`${it}px`}},u.oninput=()=>{let B=J2(u.value);if(u.value!==B){let W=u.selectionStart;u.value=B,u.selectionStart=W,u.selectionEnd=W}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&Dd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Dd),p();else if(!B.shiftKey&&Ld.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Ld),p();else if(!B.shiftKey&&_d.keyTest(B))B.preventDefault(),a.actionManager.executeAction(_d),p();else if(zh.keyTest(B))a.actionManager.executeAction(zh);else if(Gh.keyTest(B))a.actionManager.executeAction(Gh);else if(B.key===Ll.ESCAPE)B.preventDefault(),D=!0,_();else if(jr.keyTest(B))B.preventDefault(),_(),a.actionManager.executeAction(jr);else if(B.key===Ll.ENTER&&B[Ll.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;D=!0,_()}else if(B.key===Ll.TAB||B[Ll.CTRL_OR_CMD]&&(B.code===hf.BRACKET_LEFT||B.code===hf.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===hf.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:W}=u,ue=P(),Ee=u.value;ue.forEach(le=>{let he=Ee.slice(0,le),ge=Ee.slice(le);Ee=`${he}${x}${ge}`}),u.value=Ee,u.selectionStart=B+y,u.selectionEnd=W+y*ue.length},C=()=>{let{selectionStart:B,selectionEnd:W}=u,ue=P(),Ee=[],le=u.value;ue.forEach(he=>{let ge=le.slice(he,he+y).match(I);if(ge){let se=le.slice(0,he),xe=le.slice(he+ge[0].length);le=`${se}${xe}`,Ee.push(he)}}),u.value=le,Ee.length&&(B>Ee[Ee.length-1]?u.selectionStart=Math.max(B-y,Ee[Ee.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,W-y*Ee.length))},P=()=>{let{selectionStart:B,selectionEnd:W,value:ue}=u,Ee=ue.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-Ee,ue.slice(B,W).split(`
14
- `).reduce((he,ge,se,xe)=>he.concat(se?he[se-1]+xe[se-1].length+1:B),[]).reverse()},M=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},D=!1,_=()=>{if(G)return;G=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let W=Ef(B,a.scene.getNonDeletedElementsMap());if(W){if(u.value.trim()){let ue=jN(W);!ue||ue!==o.id?a.scene.mutateElement(W,{boundElements:(W.boundElements||[]).concat({type:"text",id:o.id})}):Lm(W)&&ZN(W)}else a.scene.mutateElement(W,{boundElements:W.boundElements?.filter(ue=>!Q2(ue))});JN(B,W,a.scene)}n({viaKeyboard:D,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,re&&re.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(),V(),u.remove()},L=B=>{window.removeEventListener("pointerup",L);let W=B?.target,ue=W instanceof HTMLElement&&W.classList.contains("properties-trigger"),Ee=(W instanceof HTMLElement||W instanceof SVGElement)&&!!W.closest(".properties-content"),le=(W instanceof HTMLElement||W instanceof SVGElement)&&(!!W.closest(`.${gf.SHAPE_ACTIONS_MENU}`)||!!W.closest(".compact-shape-actions-island"));setTimeout(()=>{le||ue||Ee||(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 W=B?.target;if(B.button===GN.WHEEL){W instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),F();return}let ue=W instanceof HTMLElement&&W.classList.contains("properties-trigger"),Ee=(W instanceof HTMLElement||W instanceof SVGElement)&&!!W.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${gf.SHAPE_ACTIONS_MENU}, .${gf.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!UN(B.target)||ue||Ee?F():B.target instanceof HTMLCanvasElement&&!X2()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==m&&p()}),U=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),V=a.onScrollChangeEmitter.on(()=>{p()}),G=!1;s&&!w&&u.select(),L();let re=null;return r&&"ResizeObserver"in window?(re=new window.ResizeObserver(()=>{p()}),re.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 _m}from"@excalidraw/common";import{getCommonBounds as p7}from"@excalidraw/element";var Mo=4,fn=6,tI="rgba(0,0,0,0.3)",nI=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=p7(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(_m("sat"))||0,bottom:parseInt(_m("sab"))||0,left:parseInt(_m("sal"))||0,right:parseInt(_m("sar"))||0},m=Kn().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(Mo*2,d.left+d.right)+fn*2,D=n*(l/C)-M,_=Math.max(Mo*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,Mo)+fn+(p-b)/C*n,y:t-fn-Math.max(Mo,d.bottom),width:D,height:fn,deltaMultiplier:L},vertical:u===w&&g===x?null:{x:m?Math.max(d.left,Mo):n-fn-Math.max(d.right,Mo),y:Math.max(d.top,Mo)+fn+(u-w)/P*t,width:fn,height:k,deltaMultiplier:F}}},bf=(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 D7}from"@excalidraw/math";import{getElementLineSegments as L7}from"@excalidraw/element";import{LinearElementEditor as _7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as R7,isLinearElement as N7}from"@excalidraw/element";import{getFrameChildren as B7}from"@excalidraw/element";import{selectGroupsForSelectedElements as F7}from"@excalidraw/element";import{arrayToMap as O7,easeOut as cI,isShallowEqual as z7}from"@excalidraw/common";import{simplify as u7}from"points-on-curve";import{polygonFromPoints as h7,lineSegment as Nm,pointFrom as Ma,pointOnLineSegment as g7,polygonIncludesPointNonZero as f7,PRECISION as Rm}from"@excalidraw/math";import{boundsContainBounds as rI,computeBoundTextPosition as E7,doBoundsIntersect as b7,elementOverlapsWithFrame as x7,getBoundTextElement as iI,getContainingFrame as y7,getElementBounds as aI,intersectElementWithLineSegment as w7,isBoundToContainer as sI,pointInsideBoundsInclusive as v7}from"@excalidraw/element";var lI=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=u7(n,s));let d=t.filter(g=>!g.locked&&!sI(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=h7(c),u=[m[0]-Rm,m[1]-Rm,m[2]+Rm,m[3]+Rm];for(let g of d){let b=aI(g,o),w=I7(g,b,o),y=T7(b,w);if(b7(m,y)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!rI(u,y))continue;let x=S7(g,o,r,w),I=k7(p,x,y,l);l==="contain"?I&&!oI(c,g,o,w)&&a.add(g.id):I?a.add(g.id):oI(c,g,o,w)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?P7([...a],o):[...i,...a]}},I7=(e,n,t)=>{let o=y7(e,t);if(!o)return null;let r=aI(o,t);return rI(r,n)?null:x7(e,o,t)?r:null},T7=(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,S7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=iI(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?C7(s,o):s},C7=(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(Nm(Ma(s+u*m,l+u*p),Ma(s+E*m,l+E*p)))}return a},P7=(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||sI(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))})},k7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>f7(a,e)||o==="contain"&&A7(a,e);return n.length===0?M7(t)[r](i):n[r](a=>a[r](i))},M7=([e,n,t,o])=>[Ma(e,n),Ma(t,n),Ma(t,o),Ma(e,o)],A7=(e,n)=>n.some((t,o)=>o>0&&g7(e,Nm(n[o-1],t))),oI=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Nm(e[l],s)).concat([Nm(e[e.length-1],e[0])]),i=iI(n,t),a=(s,l)=>{let c=w7(s,t,l,0,!o);return o?c.some(d=>v7(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...E7(n,i,t)},s))};var Bm=class extends Rn{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(cI(s),cI(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&&R7(c)){let d=B7(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=F7({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&&N7(this.app.scene.getNonDeletedElement(a[0]))?new _7(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=>D7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!z7(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=O7(this.app.visibleElements);for(let i of this.app.visibleElements){let a=L7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=lI({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value,mode:this.app.state.boxSelectionMode});this.selectElementsFromIds(r)}})}startPath(t,o,r=!1){this.endPath(),super.startPath(t,o),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as G7,easeOut as dI,THEME as H7}from"@excalidraw/common";import{computeBoundTextPosition as U7,doBoundsIntersect as W7,getBoundTextElement as V7,getElementBounds as Y7,getElementLineSegments as X7,getFreedrawOutlineAsSegments as K7,getFreedrawOutlinePoints as $7,intersectElementWithLineSegment as mI,isArrowElement as Z7,isFreeDrawElement as pI,isLineElement as j7,isPointInElement as q7}from"@excalidraw/element";import{lineSegment as J7,lineSegmentsDistance as uI,pointFrom as xI,polygon as Q7,polygonIncludesPointNonZero as eB}from"@excalidraw/math";import{getElementsInGroup as hI}from"@excalidraw/element";import{shouldTestInside as tB}from"@excalidraw/element";import{hasBoundTextElement as gI,isBoundToContainer as fI}from"@excalidraw/element";import{getBoundTextElementId as EI}from"@excalidraw/element";var Fm=class extends Rn{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(dI(s),dI(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===H7.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=>xI(s[0],s[1]))||[];if(o.length<2)return[];let r=J7(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=G7(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(bI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=hI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(fI(s)&&this.elementsToErase.delete(s.containerId),gI(s)){let d=EI(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&bI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=hI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(gI(s)){let d=EI(s);d&&this.elementsToErase.add(d)}fI(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()}},bI=(e,n,t,o)=>{let r=e[1],i=pI(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=Y7(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!W7(a,l))return!1;if(tB(n)&&q7(r,n,t))return!0;if(pI(n)){let d=$7(n),m=K7(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if(uI(E,e)<=p)return!0;let u=Q7(...d.map(([E,g])=>xI(n.x+E,n.y+g)));return!!eB(e[0],u)}let c=V7(n,t);if(Z7(n)||j7(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=X7(n,t);for(let p of m)if(uI(p,e)<=d)return!0;return!1}return mI(n,t,e,0,!0).length>0||!!c&&mI({...c,...U7(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as EB}from"@excalidraw/common";import{newElement as bB}from"@excalidraw/element";import{COLOR_PALETTE as nB,DEFAULT_FONT_FAMILY as oB,DEFAULT_FONT_SIZE as rB,VERTICAL_ALIGN as iB}from"@excalidraw/common";var yI=44,wI=22,vI=66,II=48,_l=14,TI=304,SI=320,xf=5.87,CI=28,PI=4,kI=2,yf=10,MI=10,AI=8,oo=12,Aa=256,ai=10,wf=4,Da=oo*2,vf=oo*2,DI=100,LI=140,Rl=.35,_I=oo/2,gr=20,Om=oo*2,If=oo,Be={fillStyle:"hachure",fontFamily:oB,fontSize:rB,opacity:100,roughness:1,strokeColor:nB.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:iB.MIDDLE,locked:!1};import{pointFrom as La}from"@excalidraw/math";import{COLOR_PALETTE as OI,DEFAULT_CHART_COLOR_INDEX as aB,FONT_FAMILY as Cf,FONT_SIZES as zm,ROUNDNESS as RI,DEFAULT_FONT_SIZE as sB,getAllColorsSpecificShade as lB,getFontString as Pf,getLineHeight as kf,ROUGHNESS as NI}from"@excalidraw/common";import{getApproxMinLineWidth as Mf,measureText as fr,newElement as Sf,newLinearElement as Tf,newTextElement as _a,wrapText as zI}from"@excalidraw/element";var si=lB(aB),cB=e=>e.labels?.length??e.series[0]?.values.length??0,Ra=(e,n)=>{if(!e)return!1;let t=cB(e);return t<2?!1:n==="radar"?t>=3:!0},BI=(e,n)=>{let t=n<=1?0:Math.min(vI,(n-1)*wI);return e+t},Gm=(e,n)=>{if(e==="line"){let o=BI(II,n);return{slotWidth:o,gap:_l,chartHeight:SI,xLabelMaxWidth:o+_l*3+yf}}let t=BI(yI,n);return{slotWidth:t,gap:_l,chartHeight:TI,xLabelMaxWidth:t+_l*3+yf}},Na=(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}},GI=()=>{let e=Aa+vf*2,n=Aa+vf*2;return{chartWidth:e,chartHeight:n}},dB=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},Ba=(e,n)=>{if(e<=0||si.length===0)return[];let t=si.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=>dB(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)=>si[r[l%r.length]])},Fa=e=>{if(si.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*si.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)%si.length},Oa=e=>si[e],HI=(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>=DI;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},mB=e=>/\s/.test(e.trim()),Hm=(e,n,t)=>mB(e)?zI(e,n,t):e,UI=(e,n,t,o,r,i)=>{let a=Cf.Excalifont,s=zm.sm,l=kf(a),c=Pf({fontFamily:a,fontSize:s}),d=Math.min(LI,r*(e.length>8?.56:.72)),m=Mf(c,l),p=e.map((g,b)=>{let w=n[b],y=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>fr(z,c,l).width)),x=Math.max(m,d,y),I=Hm(g,c,x),T=fr(I,c,l),C=Math.cos(w),P=Math.sin(w),M=C>Rl?"left":C<-Rl?"right":"center",D=M==="center"?T.width/2:0,_=Math.abs(C)*D+Math.abs(P)*(T.height/2),k=Da+_+_I,L=t+C*(r+k),F=o+P*(r+k),Y=P>Rl?oo/3:P<-Rl?-oo/3:0;return _a({backgroundColor:i,...Be,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}},za=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=Cf["Lilita One"],s=zm.lg,l=kf(a),c=Pf({fontFamily:a,fontSize:s}),d=e.map((I,T)=>{let C=I.title?.trim()||`Series ${T+1}`,P=Hm(C,c,Aa),M=fr(P,c,l),D=gr+If+M.width;return{label:C,displayLabel:P,color:n[T],width:D,height:M.height}}),m=Math.max(gr/2,...d.map(I=>I.height/2)),p=Math.max(r,o+m+Da),u=Om,E=gr*.6,g=d.reduce((I,T)=>I+T.width,0)+Om*Math.max(0,d.length-1),b=g+u*2,w=m*2+E*2,y=[];y.push(Sf({...Be,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:OI.black,x:t-b/2,y:p-w/2,width:b,height:w,roughness:NI.architect,roundness:{type:RI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(I=>{y.push(Sf({...Be,backgroundColor:I.color,type:"rectangle",x,y:p-gr/2,width:gr,height:gr,fillStyle:"solid",strokeColor:I.color,roughness:NI.architect,roundness:{type:RI.PROPORTIONAL_RADIUS}})),y.push(_a({...Be,text:I.displayLabel,originalText:I.label,autoResize:!1,x:x+gr+If,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=I.width+Om}),y},pB=(e,n,t,o)=>{if(fr(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(fr(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},uB=(e,n,t,o)=>{if(fr(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=>fr(a,t,o).width>n)&&n>=Mf(t,o)?{wrapped:!0,text:zI(e,t,n)}:{wrapped:!1,text:pB(e,n,t,o)}},WI=(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}},FI=e=>e.includes("..."),hB=(e,n,t,o,r)=>{let i=Math.max(CI,Math.ceil(Mf(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=FI(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}=uB(e,u,o,r),b=fr(g,o,r),w=WI(b.width,b.height,xf),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}),!FI(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+AI?p.spec:m.spec)},Um=e=>{if(e.type!=="text")return e.y+e.height;let n=WI(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},Nl=(e,n,t,o,r)=>{let i=Be.fontFamily,a=zm.sm,s=kf(i),l=Pf({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-PI*2+MI),d=t;return e.labels?.map((m,p)=>{let u=hB(m,r.xLabelMaxWidth,c,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+kI+(u.rotatedHeight-u.metrics.height)/2;return _a({backgroundColor:o,...Be,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:xf,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},gB=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=_a({backgroundColor:o,...Be,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=_a({backgroundColor:o,...Be,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},fB=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=Na(e,r),s=Tf({backgroundColor:o,...Be,type:"line",x:n,y:t,width:i,points:[La(0,0),La(i,0)]}),l=Tf({backgroundColor:o,...Be,type:"line",x:n,y:t,height:a,points:[La(0,0),La(0,-a)]}),c=Tf({backgroundColor:o,...Be,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:ai,points:[La(0,0),La(i,0)]});return[s,l,c]},Wm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=Na(e,r),c=e.title?_a({backgroundColor:o,...Be,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-sB,roundness:null,textAlign:"center",fontSize:zm.xl,fontFamily:Cf["Lilita One"]}):null,d=a?Sf({backgroundColor:o,...Be,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:OI.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...Nl(e,n,t,o,r),...gB(e,n,t,o,r,i),...fB(e,n,t,o,r)]};var VI=(e,n,t,o)=>{let r=e.series,i=Gm("bar",r.length),a=Math.max(1,...r.flatMap(I=>I.values.map(T=>Math.max(0,T)))),s=Fa(o),l=Oa(s),c=Ba(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 bB({backgroundColor:_,...Be,type:"rectangle",fillStyle:r.length>1?"solid":Be.fillStyle,strokeColor:r.length>1?_:Be.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+P*(m+d),y:t-D-i.gap,width:m,height:D})})),g=Wm(e,n,t,l,i,a,EB()),b=Nl(e,n,t,l,i),w=Math.max(t+i.gap/2,...b.map(I=>Um(I))),{chartWidth:y}=Na(e,i),x=za(r,c,n+y/2,w,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as Af}from"@excalidraw/math";import{isDevEnv as xB}from"@excalidraw/common";import{newElement as yB,newLinearElement as YI}from"@excalidraw/element";var XI=(e,n,t,o)=>{let r=e.series,i=Gm("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=Fa(o),l=Oa(s),c=Ba(r.length,s),d=r.map((x,I)=>{let T=x.values.map((_,k)=>Af(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 YI({backgroundColor:"transparent",...Be,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 yB({backgroundColor:c[I],...Be,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 YI({backgroundColor:l,...Be,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:ai,points:[Af(0,0),Af(0,C)]})}),E=Wm(e,n,t,l,i,a,xB()),g=Nl(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>Um(x))),{chartWidth:w}=Na(e,i),y=za(r,c,n+w/2,b,t+i.gap*5,l);return[...E,...d,...u,...m,...y]};var Nn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},wB=(e,n)=>e.slice(1).every(t=>Nn(t[n])!==null),KI=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>Nn(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=>Nn(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=>Nn(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=>Nn(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(!wB(e,0))return{ok:!1,reason:"Value is not numeric"};let a=Nn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>Nn(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=Nn(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=>Nn(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=>Nn(a[1]))}]}}},Vm=e=>{let n=s=>e.replace(/\r\n?/g,`
13
+ `,n),r=e.slice(t,o===-1?e.length:o);return ZN(r)?"rtl":"ltr"},g7=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},f7=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=g7(e),a=document.createElement("div"),s=document.createTextNode(e),l=document.createRange(),d=[];a.dir=o,Object.assign(a.style,{position:"fixed",top:"0",left:"0",margin:0,padding:0,border:0,opacity:"0",pointerEvents:"none",whiteSpace:"pre",font:n,lineHeight:`${t}px`}),a.append(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;d.push(E.left)}}catch{return null}finally{a.remove()}let c=Math.min(...d),m=i[0],p=1/0;for(let u=0;u<i.length;u++){let E=Math.abs(d[u]-c-r);E<p&&(p=E,m=i[u])}return m},iI=({onChange:e,onSubmit:n,getViewportCoords:t,element:o,canvas:r,excalidrawContainer:i,app:a,autoSelect:s=!0,initialCaretSceneCoords:l=null})=>{let d=null,c=(B,W)=>{if(!W.style.fontFamily||!W.style.fontSize)return!1;let ue=W.style.fontFamily.replace(/"/g,"");return j2({fontFamily:B.fontFamily})!==ue||`${B.fontSize}px`!==W.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let B=a.state,W=a.scene.getElement(o.id);if(!W)return;let{textAlign:ue,verticalAlign:Ee}=W,le=a.scene.getNonDeletedElementsMap();if(W&&rI(W)){let he=W.x,ge=W.y,se=bf(W,a.scene.getNonDeletedElementsMap()),xe=W.width,it=W.height,$e=W.width,ke=W.height;if(se&&W.containerId){if(Lm(se)){let on=QN.getBoundTextElementPosition(se,W,le);he=on.x,ge=on.y}let fs=c(W,u),ho;if(fs?ho=eI(se.id,se.height):(ho=JN[se.id],ho||(ho=eI(se.id,se.height))),$e=tI(se,W),ke=r7(se,W),!Lm(se)&&it>ke){let on=nI(it,se.type);a.scene.mutateElement(se,{height:on}),Q2(se,a.scene);return}else if(!Lm(se)&&se.height>ho.height&&it<ke){let on=nI(it,se.type);a.scene.mutateElement(se,{height:on}),Q2(se,a.scene)}else{let{x:on,y:Wo}=i7(se,W,le);he=on,ge=Wo}}let[Zt,Go]=t(he,ge);se?xe+=.5:($e=(B.width-8-Zt)/B.zoom.value,xe=Math.min(xe,$e)),it*=1.05;let Ho=Z2(W),Uo=n7(W,se),Ii=(B.height-Go)/B.zoom.value;Object.assign(u.style,{font:Ho,lineHeight:W.lineHeight,width:`${xe}px`,height:`${it}px`,left:`${Zt}px`,top:`${Go}px`,transform:u7(xe,it,Uo,B,$e,Ii),textAlign:ue,verticalAlign:Ee,color:$N(W.strokeColor,B.theme===KN.DARK),opacity:W.opacity/100,maxHeight:`${Ii}px`}),d={angle:Uo,font:Ho,height:W.height,lineHeightPx:l7(W.fontSize,W.lineHeight),textAlign:ue,width:W.width,x:he,y:ge},u.scrollTop=0,q2()&&(u.style.fontFamily=j2(W)),a.scene.mutateElement(W,{x:he,y:ge})}},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";(p7(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||!d)return null;let B=d,W=J2(B.x+B.width/2,B.y+B.height/2),[ue,Ee]=jN(J2(l.x,l.y),W,-B.angle),le=ue-B.x,he=Ee-B.y,ge=m7(u.value,B.font,E==="pre-wrap"?B.width:1/0),se=Math.max(0,Math.min(ge.length-1,Math.floor(he/B.lineHeightPx))),xe=ge[se],it=h7(u.value,xe.start),$e=c7(xe.text,B.font),ke=B.textAlign==="center"?(B.width-$e)/2:B.textAlign==="right"?B.width-$e:0,Zt=le-ke;if(!xe.text)return xe.start;let Go=f7({text:xe.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:it,targetX:Zt});return xe.start+(Go||0)},w=(()=>{let B=b();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let W=Tw(B),ue=null;if(W.has(Ef.excalidrawClipboard)||W.has(Ef.excalidraw)){B.preventDefault(),ue=await Xr(B);try{let se=await jd(ue);if(se.elements){let xe=qN(se.elements);if(xe){let{selectionStart:it,selectionEnd:$e,value:ke}=u;u.value=ke.slice(0,it)+xe+ke.slice($e);let Zt=it+xe.length;u.selectionStart=u.selectionEnd=Zt,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}ue=ue||await Xr(B);let Ee=ue.findByType(Ef.text);if(!Ee)return;let le=oI(Ee.value);if(!le)return;let he=bf(o,a.scene.getNonDeletedElementsMap()),ge=Z2({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(he){let se=a7(he,a.scene.getNonDeletedElementsMap()),xe=d7(`${u.value}${le}`,ge,tI(he,se)),it=s7(xe,ge);u.style.width=`${it}px`}},u.oninput=()=>{let B=oI(u.value);if(u.value!==B){let W=u.selectionStart;u.value=B,u.selectionStart=W,u.selectionEnd=W}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&Dd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Dd),p();else if(!B.shiftKey&&Ld.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Ld),p();else if(!B.shiftKey&&_d.keyTest(B))B.preventDefault(),a.actionManager.executeAction(_d),p();else if(Gh.keyTest(B))a.actionManager.executeAction(Gh);else if(Hh.keyTest(B))a.actionManager.executeAction(Hh);else if(B.key===Ll.ESCAPE)B.preventDefault(),D=!0,_();else if(jr.keyTest(B))B.preventDefault(),_(),a.actionManager.executeAction(jr);else if(B.key===Ll.ENTER&&B[Ll.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;D=!0,_()}else if(B.key===Ll.TAB||B[Ll.CTRL_OR_CMD]&&(B.code===gf.BRACKET_LEFT||B.code===gf.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===gf.BRACKET_LEFT?C():S(),u.dispatchEvent(new Event("input"))}};let y=4,x=" ".repeat(y),I=new RegExp(`^ {1,${y}}`),S=()=>{let{selectionStart:B,selectionEnd:W}=u,ue=P(),Ee=u.value;ue.forEach(le=>{let he=Ee.slice(0,le),ge=Ee.slice(le);Ee=`${he}${x}${ge}`}),u.value=Ee,u.selectionStart=B+y,u.selectionEnd=W+y*ue.length},C=()=>{let{selectionStart:B,selectionEnd:W}=u,ue=P(),Ee=[],le=u.value;ue.forEach(he=>{let ge=le.slice(he,he+y).match(I);if(ge){let se=le.slice(0,he),xe=le.slice(he+ge[0].length);le=`${se}${xe}`,Ee.push(he)}}),u.value=le,Ee.length&&(B>Ee[Ee.length-1]?u.selectionStart=Math.max(B-y,Ee[Ee.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,W-y*Ee.length))},P=()=>{let{selectionStart:B,selectionEnd:W,value:ue}=u,Ee=ue.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-Ee,ue.slice(B,W).split(`
14
+ `).reduce((he,ge,se,xe)=>he.concat(se?he[se-1]+xe[se-1].length+1:B),[]).reverse()},M=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},D=!1,_=()=>{if(G)return;G=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let W=bf(B,a.scene.getNonDeletedElementsMap());if(W){if(u.value.trim()){let ue=t7(W);!ue||ue!==o.id?a.scene.mutateElement(W,{boundElements:(W.boundElements||[]).concat({type:"text",id:o.id})}):Lm(W)&&e7(W)}else a.scene.mutateElement(W,{boundElements:W.boundElements?.filter(ue=>!rI(ue))});o7(B,W,a.scene)}n({viaKeyboard:D,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,re&&re.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(),V(),u.remove()},L=B=>{window.removeEventListener("pointerup",L);let W=B?.target,ue=W instanceof HTMLElement&&W.classList.contains("properties-trigger"),Ee=(W instanceof HTMLElement||W instanceof SVGElement)&&!!W.closest(".properties-content"),le=(W instanceof HTMLElement||W instanceof SVGElement)&&(!!W.closest(`.${ff.SHAPE_ACTIONS_MENU}`)||!!W.closest(".compact-shape-actions-island"));setTimeout(()=>{le||ue||Ee||(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 W=B?.target;if(B.button===YN.WHEEL){W instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),F();return}let ue=W instanceof HTMLElement&&W.classList.contains("properties-trigger"),Ee=(W instanceof HTMLElement||W instanceof SVGElement)&&!!W.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${ff.SHAPE_ACTIONS_MENU}, .${ff.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!XN(B.target)||ue||Ee?F():B.target instanceof HTMLCanvasElement&&!q2()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==m&&p()}),U=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),V=a.onScrollChangeEmitter.on(()=>{p()}),G=!1;s&&!w&&u.select(),L();let re=null;return r&&"ResizeObserver"in window?(re=new window.ResizeObserver(()=>{p()}),re.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 _m}from"@excalidraw/common";import{getCommonBounds as E7}from"@excalidraw/element";var ko=4,fn=6,aI="rgba(0,0,0,0.3)",sI=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=E7(e),l=n/o.zoom.value,d=t/o.zoom.value,c={top:parseInt(_m("sat"))||0,bottom:parseInt(_m("sab"))||0,left:parseInt(_m("sal"))||0,right:parseInt(_m("sar"))||0},m=Xn().rtl,p=-o.scrollX+c.left,u=-o.scrollY+c.top,E=p+l-c.right,g=u+d-c.bottom,b=Math.min(r,p),w=Math.min(i,u),y=Math.max(a,E),x=Math.max(s,g),I=a-r,S=s-i,C=y-b,P=x-w,M=Math.max(ko*2,c.left+c.right)+fn*2,D=n*(l/C)-M,_=Math.max(ko*2,c.top+c.bottom)+fn*2,k=t*(d/P)-_,L=C>I?C*o.zoom.value/(D+M):n/(D+M),F=P>S?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===y?null:{x:Math.max(c.left,ko)+fn+(p-b)/C*n,y:t-fn-Math.max(ko,c.bottom),width:D,height:fn,deltaMultiplier:L},vertical:u===w&&g===x?null:{x:m?Math.max(c.left,ko):n-fn-Math.max(c.right,ko),y:Math.max(c.top,ko)+fn+(u-w)/P*t,width:fn,height:k,deltaMultiplier:F}}},xf=(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 B7}from"@excalidraw/math";import{getElementLineSegments as F7}from"@excalidraw/element";import{LinearElementEditor as O7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as z7,isLinearElement as G7}from"@excalidraw/element";import{getFrameChildren as H7}from"@excalidraw/element";import{selectGroupsForSelectedElements as U7}from"@excalidraw/element";import{arrayToMap as W7,easeOut as hI,isShallowEqual as V7}from"@excalidraw/common";import{simplify as b7}from"points-on-curve";import{polygonFromPoints as x7,lineSegment as Nm,pointFrom as Aa,pointOnLineSegment as y7,polygonIncludesPointNonZero as w7,PRECISION as Rm}from"@excalidraw/math";import{boundsContainBounds as cI,computeBoundTextPosition as v7,doBoundsIntersect as I7,elementOverlapsWithFrame as S7,getBoundTextElement as dI,getContainingFrame as T7,getElementBounds as mI,intersectElementWithLineSegment as C7,isBoundToContainer as pI,pointInsideBoundsInclusive as P7}from"@excalidraw/element";var uI=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,d=n;s&&(d=b7(n,s));let c=t.filter(g=>!g.locked&&!pI(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=x7(d),u=[m[0]-Rm,m[1]-Rm,m[2]+Rm,m[3]+Rm];for(let g of c){let b=mI(g,o),w=k7(g,b,o),y=M7(b,w);if(I7(m,y)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!cI(u,y))continue;let x=A7(g,o,r,w),I=_7(p,x,y,l);l==="contain"?I&&!lI(d,g,o,w)&&a.add(g.id):I?a.add(g.id):lI(d,g,o,w)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?L7([...a],o):[...i,...a]}},k7=(e,n,t)=>{let o=T7(e,t);if(!o)return null;let r=mI(o,t);return cI(r,n)?null:S7(e,o,t)?r:null},M7=(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,A7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=dI(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?D7(s,o):s},D7=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[s,l],[d,c]]of e){let m=d-s,p=c-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(Nm(Aa(s+u*m,l+u*p),Aa(s+E*m,l+E*p)))}return a},L7=(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||pI(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))})},_7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>w7(a,e)||o==="contain"&&N7(a,e);return n.length===0?R7(t)[r](i):n[r](a=>a[r](i))},R7=([e,n,t,o])=>[Aa(e,n),Aa(t,n),Aa(t,o),Aa(e,o)],N7=(e,n)=>n.some((t,o)=>o>0&&y7(e,Nm(n[o-1],t))),lI=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Nm(e[l],s)).concat([Nm(e[e.length-1],e[0])]),i=dI(n,t),a=(s,l)=>{let d=C7(s,t,l,0,!o);return o?d.some(c=>P7(c,o)):d.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...v7(n,i,t)},s))};var Bm=class extends Rn{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(hI(s),hI(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,d)=>(l[d]=!0,l),{});if(this.keepPreviousSelection)for(let l of Object.keys(o.selectedElementIds))r[l]=!0;for(let[l]of Object.entries(r)){let d=this.app.scene.getNonDeletedElement(l);if(d&&z7(d)){let c=H7(this.app.scene.getNonDeletedElementsMap(),d.id);for(let m of c)delete r[m.id]}}let i=U7({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&&G7(this.app.scene.getNonDeletedElement(a[0]))?new O7(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=>B7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!V7(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=W7(this.app.visibleElements);for(let i of this.app.visibleElements){let a=F7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=uI({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 Y7,easeOut as gI,THEME as K7}from"@excalidraw/common";import{computeBoundTextPosition as X7,doBoundsIntersect as $7,getBoundTextElement as Z7,getElementBounds as j7,getElementLineSegments as q7,getFreedrawOutlineAsSegments as J7,getFreedrawOutlinePoints as Q7,intersectElementWithLineSegment as fI,isArrowElement as eB,isFreeDrawElement as EI,isLineElement as tB,isPointInElement as nB}from"@excalidraw/element";import{lineSegment as oB,lineSegmentsDistance as bI,pointFrom as SI,polygon as rB,polygonIncludesPointNonZero as iB}from"@excalidraw/math";import{getElementsInGroup as xI}from"@excalidraw/element";import{shouldTestInside as aB}from"@excalidraw/element";import{hasBoundTextElement as yI,isBoundToContainer as wI}from"@excalidraw/element";import{getBoundTextElementId as vI}from"@excalidraw/element";var Fm=class extends Rn{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(gI(s),gI(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===K7.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=>SI(s[0],s[1]))||[];if(o.length<2)return[];let r=oB(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=Y7(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(II(r,s,a,this.app.state.zoom.value)){let d=s.groupIds.at(-1);if(this.groupsToErase.has(d)){let c=xI(this.app.scene.getNonDeletedElementsMap(),d);for(let m of c)this.elementsToErase.delete(m.id);this.groupsToErase.delete(d)}if(wI(s)&&this.elementsToErase.delete(s.containerId),yI(s)){let c=vI(s);c&&this.elementsToErase.delete(c)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&II(r,s,a,this.app.state.zoom.value)){let d=s.groupIds.at(-1);if(!this.groupsToErase.has(d)){let c=xI(this.app.scene.getNonDeletedElementsMap(),d);for(let m of c)this.elementsToErase.add(m.id);this.groupsToErase.add(d)}if(yI(s)){let c=vI(s);c&&this.elementsToErase.add(c)}wI(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()}},II=(e,n,t,o)=>{let r=e[1],i=EI(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=j7(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!$7(a,l))return!1;if(aB(n)&&nB(r,n,t))return!0;if(EI(n)){let c=Q7(n),m=J7(n,c,t),p=Math.max(2.25,5/o);for(let E of m)if(bI(E,e)<=p)return!0;let u=rB(...c.map(([E,g])=>SI(n.x+E,n.y+g)));return!!iB(e[0],u)}let d=Z7(n,t);if(eB(n)||tB(n)&&!n.polygon){let c=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=q7(n,t);for(let p of m)if(bI(p,e)<=c)return!0;return!1}return fI(n,t,e,0,!0).length>0||!!d&&fI({...d,...X7(n,d,t)},t,e,0,!0).length>0};import{isDevEnv as vB}from"@excalidraw/common";import{newElement as IB}from"@excalidraw/element";import{COLOR_PALETTE as sB,DEFAULT_FONT_FAMILY as lB,DEFAULT_FONT_SIZE as cB,VERTICAL_ALIGN as dB}from"@excalidraw/common";var TI=44,CI=22,PI=66,kI=48,_l=14,MI=304,AI=320,yf=5.87,DI=28,LI=4,_I=2,wf=10,RI=10,NI=8,oo=12,Da=256,ai=10,vf=4,La=oo*2,If=oo*2,BI=100,FI=140,Rl=.35,OI=oo/2,gr=20,Om=oo*2,Sf=oo,Be={fillStyle:"hachure",fontFamily:lB,fontSize:cB,opacity:100,roughness:1,strokeColor:sB.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:dB.MIDDLE,locked:!1};import{pointFrom as _a}from"@excalidraw/math";import{COLOR_PALETTE as WI,DEFAULT_CHART_COLOR_INDEX as mB,FONT_FAMILY as Pf,FONT_SIZES as zm,ROUNDNESS as zI,DEFAULT_FONT_SIZE as pB,getAllColorsSpecificShade as uB,getFontString as kf,getLineHeight as Mf,ROUGHNESS as GI}from"@excalidraw/common";import{getApproxMinLineWidth as Af,measureText as fr,newElement as Cf,newLinearElement as Tf,newTextElement as Ra,wrapText as VI}from"@excalidraw/element";var si=uB(mB),hB=e=>e.labels?.length??e.series[0]?.values.length??0,Na=(e,n)=>{if(!e)return!1;let t=hB(e);return t<2?!1:n==="radar"?t>=3:!0},HI=(e,n)=>{let t=n<=1?0:Math.min(PI,(n-1)*CI);return e+t},Gm=(e,n)=>{if(e==="line"){let o=HI(kI,n);return{slotWidth:o,gap:_l,chartHeight:AI,xLabelMaxWidth:o+_l*3+wf}}let t=HI(TI,n);return{slotWidth:t,gap:_l,chartHeight:MI,xLabelMaxWidth:t+_l*3+wf}},Ba=(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}},YI=()=>{let e=Da+If*2,n=Da+If*2;return{chartWidth:e,chartHeight:n}},gB=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},Fa=(e,n)=>{if(e<=0||si.length===0)return[];let t=si.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,d=-1;for(let c of a){let m=r.map(E=>gB(c,E,t)),p=Math.min(...m),u=m.reduce((E,g)=>E+g,0)/m.length;(p>l||p===l&&u>d)&&(s=c,l=p,d=u)}r.push(s),a.delete(s)}return Array.from({length:e},(s,l)=>si[r[l%r.length]])},Oa=e=>{if(si.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*si.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)%si.length},za=e=>si[e],KI=(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>=BI;return{renderSteps:!1,normalize:(s,l)=>{let d=Math.max(0,s);return a?Math.log10(d+1)/Math.log10(r+1):d/r}}},fB=e=>/\s/.test(e.trim()),Hm=(e,n,t)=>fB(e)?VI(e,n,t):e,XI=(e,n,t,o,r,i)=>{let a=Pf.Excalifont,s=zm.sm,l=Mf(a),d=kf({fontFamily:a,fontSize:s}),c=Math.min(FI,r*(e.length>8?.56:.72)),m=Af(d,l),p=e.map((g,b)=>{let w=n[b],y=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>fr(z,d,l).width)),x=Math.max(m,c,y),I=Hm(g,d,x),S=fr(I,d,l),C=Math.cos(w),P=Math.sin(w),M=C>Rl?"left":C<-Rl?"right":"center",D=M==="center"?S.width/2:0,_=Math.abs(C)*D+Math.abs(P)*(S.height/2),k=La+_+OI,L=t+C*(r+k),F=o+P*(r+k),Y=P>Rl?oo/3:P<-Rl?-oo/3:0;return Ra({backgroundColor:i,...Be,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}},Ga=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=Pf["Lilita One"],s=zm.lg,l=Mf(a),d=kf({fontFamily:a,fontSize:s}),c=e.map((I,S)=>{let C=I.title?.trim()||`Series ${S+1}`,P=Hm(C,d,Da),M=fr(P,d,l),D=gr+Sf+M.width;return{label:C,displayLabel:P,color:n[S],width:D,height:M.height}}),m=Math.max(gr/2,...c.map(I=>I.height/2)),p=Math.max(r,o+m+La),u=Om,E=gr*.6,g=c.reduce((I,S)=>I+S.width,0)+Om*Math.max(0,c.length-1),b=g+u*2,w=m*2+E*2,y=[];y.push(Cf({...Be,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:WI.black,x:t-b/2,y:p-w/2,width:b,height:w,roughness:GI.architect,roundness:{type:zI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return c.forEach(I=>{y.push(Cf({...Be,backgroundColor:I.color,type:"rectangle",x,y:p-gr/2,width:gr,height:gr,fillStyle:"solid",strokeColor:I.color,roughness:GI.architect,roundness:{type:zI.PROPORTIONAL_RADIUS}})),y.push(Ra({...Be,text:I.displayLabel,originalText:I.label,autoResize:!1,x:x+gr+Sf,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=I.width+Om}),y},EB=(e,n,t,o)=>{if(fr(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(fr(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},bB=(e,n,t,o)=>{if(fr(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=>fr(a,t,o).width>n)&&n>=Af(t,o)?{wrapped:!0,text:VI(e,t,n)}:{wrapped:!1,text:EB(e,n,t,o)}},$I=(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}},UI=e=>e.includes("..."),xB=(e,n,t,o,r)=>{let i=Math.max(DI,Math.ceil(Af(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=UI(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
15
+ `).length;return{ellipsified:E,visibleChars:g,lineCount:b}},d=(u,E)=>{let g=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},c=null,m=null,p=null;for(let u of s){let{wrapped:E,text:g}=bB(e,u,o,r),b=fr(g,o,r),w=$I(b.width,b.height,yf),y={originalText:e,text:g,metrics:b,rotatedWidth:w.width,rotatedHeight:w.height,wrapped:E},x=w.width-t;if(x<=0){(!c||d(y,c))&&(c=y);continue}(!m||x<m.overflow||x===m.overflow&&d(y,m.spec))&&(m={overflow:x,spec:y}),!UI(y.text)&&(!p||x<p.overflow||x===p.overflow&&d(y,p.spec))&&(p={overflow:x,spec:y})}return c||(p&&m&&p.overflow<=m.overflow+NI?p.spec:m.spec)},Um=e=>{if(e.type!=="text")return e.y+e.height;let n=$I(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},Nl=(e,n,t,o,r)=>{let i=Be.fontFamily,a=zm.sm,s=Mf(i),l=kf({fontFamily:i,fontSize:a}),d=Math.max(1,r.slotWidth+r.gap-LI*2+RI),c=t;return e.labels?.map((m,p)=>{let u=xB(m,r.xLabelMaxWidth,d,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=c+_I+(u.rotatedHeight-u.metrics.height)/2;return Ra({backgroundColor:o,...Be,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:yf,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},yB=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=Ra({backgroundColor:o,...Be,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=Ra({backgroundColor:o,...Be,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},wB=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=Ba(e,r),s=Tf({backgroundColor:o,...Be,type:"line",x:n,y:t,width:i,points:[_a(0,0),_a(i,0)]}),l=Tf({backgroundColor:o,...Be,type:"line",x:n,y:t,height:a,points:[_a(0,0),_a(0,-a)]}),d=Tf({backgroundColor:o,...Be,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:ai,points:[_a(0,0),_a(i,0)]});return[s,l,d]},Wm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=Ba(e,r),d=e.title?Ra({backgroundColor:o,...Be,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-pB,roundness:null,textAlign:"center",fontSize:zm.xl,fontFamily:Pf["Lilita One"]}):null,c=a?Cf({backgroundColor:o,...Be,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:WI.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...d?[d]:[],...Nl(e,n,t,o,r),...yB(e,n,t,o,r,i),...wB(e,n,t,o,r)]};var ZI=(e,n,t,o)=>{let r=e.series,i=Gm("bar",r.length),a=Math.max(1,...r.flatMap(I=>I.values.map(S=>Math.max(0,S)))),s=Oa(o),l=za(s),d=Fa(r.length,s),c=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,m=r.length>1?Math.max(2,(i.slotWidth-c*(r.length-1))/r.length):i.slotWidth,p=r.length*m+c*(r.length-1),u=(i.slotWidth-p)/2,E=r[0].values.flatMap((I,S)=>r.map((C,P)=>{let D=Math.max(0,C.values[S]??0)/a*i.chartHeight,_=r.length>1?d[P]:l;return IB({backgroundColor:_,...Be,type:"rectangle",fillStyle:r.length>1?"solid":Be.fillStyle,strokeColor:r.length>1?_:Be.strokeColor,x:n+S*(i.slotWidth+i.gap)+i.gap+u+P*(m+c),y:t-D-i.gap,width:m,height:D})})),g=Wm(e,n,t,l,i,a,vB()),b=Nl(e,n,t,l,i),w=Math.max(t+i.gap/2,...b.map(I=>Um(I))),{chartWidth:y}=Ba(e,i),x=Ga(r,d,n+y/2,w,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as Df}from"@excalidraw/math";import{isDevEnv as SB}from"@excalidraw/common";import{newElement as TB,newLinearElement as jI}from"@excalidraw/element";var qI=(e,n,t,o)=>{let r=e.series,i=Gm("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=Oa(o),l=za(s),d=Fa(r.length,s),c=r.map((x,I)=>{let S=x.values.map((_,k)=>Df(k*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),C=Math.max(...S.map(_=>_[0])),P=Math.max(...S.map(_=>_[1])),M=Math.min(...S.map(_=>_[0])),D=Math.min(...S.map(_=>_[1]));return jI({backgroundColor:"transparent",...Be,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-D,width:C-M,strokeColor:d[I],strokeWidth:2,points:S})}),m=r.flatMap((x,I)=>x.values.map((S,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,M=-(S/a)*i.chartHeight+i.gap/2;return TB({backgroundColor:d[I],...Be,fillStyle:"solid",strokeColor:d[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(S=>S.values[I]??0))).map((x,I)=>{let S=I*(i.slotWidth+i.gap)+i.gap/2,C=x/a*i.chartHeight+i.gap/2+i.gap;return jI({backgroundColor:l,...Be,type:"line",x:n+S+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:ai,points:[Df(0,0),Df(0,C)]})}),E=Wm(e,n,t,l,i,a,SB()),g=Nl(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>Um(x))),{chartWidth:w}=Ba(e,i),y=Ga(r,d,n+w/2,b,t+i.gap*5,l);return[...E,...c,...u,...m,...y]};var Nn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},CB=(e,n)=>e.slice(1).every(t=>Nn(t[n])!==null),JI=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>Nn(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=>Nn(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=>Nn(g))}));return{ok:!0,data:{title:p.length===1?p[0].title:a&&e[0][0].trim()||null,labels:m,series:p}}}let c=e[0].slice(1).map((m,p)=>{let u=p+1,E=`Series ${u}`;return{title:a&&m.trim()||E,values:s.map(g=>Nn(g[u]))}});return{ok:!0,data:{title:a&&e[0][0].trim()||null,labels:s.map(m=>m[0]),series:c}}}if(n===1){if(!CB(e,0))return{ok:!1,reason:"Value is not numeric"};let a=Nn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(d=>Nn(d[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=Nn(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=>Nn(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=>Nn(a[1]))}]}}},Vm=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)?KI(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ga}from"@excalidraw/math";import{FONT_FAMILY as vB,FONT_SIZES as IB,getFontString as TB,getLineHeight as SB,ROUGHNESS as $I}from"@excalidraw/common";import{measureText as CB,newLinearElement as Df,newTextElement as PB}from"@excalidraw/element";var ZI=(e,n,t,o)=>{if(!Ra(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}=HI(i,r.length),l=Fa(o),c=Oa(l),d=Ba(i.length,l),{chartWidth:m,chartHeight:p}=GI(),u=n+m/2,E=t-p/2,g=Aa/2,b=r.map((z,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:w,axisLabelTopY:y,axisLabelBottomY:x}=UI(r,b,u,E,g,c),I=vB["Lilita One"],T=IB.xl,C=SB(I),P=TB({fontFamily:I,fontSize:T}),M=e.title?Hm(e.title,P,m+Da*2):null,D=M?CB(M,P,C):null,_=M?PB({backgroundColor:c,...Be,text:M,originalText:e.title??M,x:n+m/2,y:y-Da-D.height/2,fontFamily:I,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:wf},(z,U)=>{let V=(U+1)/wf,G=g*V,re=b.map(B=>Ga(Math.cos(B)*G,Math.sin(B)*G));return re.push(Ga(re[0][0],re[0][1])),Df({backgroundColor:"transparent",...Be,type:"line",x:u,y:E,width:G*2,height:G*2,strokeStyle:"solid",roughness:$I.architect,opacity:ai,polygon:!0,points:re})}):[],L=b.map(z=>{let U=Math.cos(z)*g,V=Math.sin(z)*g;return Df({backgroundColor:"transparent",...Be,type:"line",x:u,y:E,width:Math.abs(U),height:Math.abs(V),strokeStyle:"solid",roughness:$I.architect,opacity:ai,points:[Ga(0,0),Ga(U,V)]})}),F=i.map((z,U)=>{let V=b.map((G,re)=>{let B=z.values[re]??0,W=a(B,re)*g;return Ga(Math.cos(G)*W,Math.sin(G)*W)});return V.push(Ga(V[0][0],V[0][1])),Df({backgroundColor:"transparent",...Be,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[U],strokeWidth:2,polygon:!0,points:V})}),Y=za(i,d,u,x,t+oo*5,c);return[..._?[_]:[],...w,...k,...L,...F,...Y]};var Lf=(e,n,t,o,r)=>e==="line"?XI(n,t,o,r):e==="radar"?ZI(n,t,o,r):VI(n,t,o,r);import{clamp as Ym,pointFrom as Ha,pointsEqual as RB,bezierEquation as iT,pointRotateRads as Xm,pointDistance as NB}from"@excalidraw/math";import{arrayToMap as BB,BIND_MODE_TIMEOUT as Bl,DEFAULT_TRANSFORM_HANDLE_SPACING as aT,FRAME_STYLE as bn,getFeatureFlag as FB,invariant as eT,shouldRotateWithDiscreteAngle as sT,THEME as Ao}from"@excalidraw/common";import{deconstructDiamondElement as Ff,deconstructRectanguloidElement as lT,elementCenterPoint as Ua,getDiamondBaseCorners as OB,FOCUS_POINT_SIZE as zB,getOmitSidesForEditorInterface as _f,getTransformHandles as GB,getTransformHandlesFromCoords as HB,hasBoundingBox as UB,hitElementItself as WB,isArrowElement as cT,isBindableElement as dT,isElbowArrow as Wa,isFrameLikeElement as Va,isImageElement as Km,isLinearElement as VB,isLineElement as YB,maxBindingDistance_simple as XB,isTextElement as KB,LinearElementEditor as xn,getActiveTextElement as $B,getElementsInGroup as Of,getSelectedGroupIds as ZB,isSelectedViaGroup as jB,selectGroupsFromGivenElements as qB}from"@excalidraw/element";import{renderSelectionElement as JB}from"@excalidraw/element";import{getCommonBounds as zf,getElementAbsoluteCoords as Ol}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as tT,isFocusPointVisible as QB}from"@excalidraw/element";import{pointFrom as Pt}from"@excalidraw/math";import{THEME as kB}from"@excalidraw/common";var MB="#ff6b6b",AB="#ff0000",jI=1,qI=2,JI=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===kB.LIGHT||n.zenModeEnabled?MB:AB,o=(n.zenModeEnabled?jI*1.5:jI)/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,LB(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,_B(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,DB(r,e,n));e.restore()},DB=(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)QI(o,t,n)},LB=(e,n,t)=>{QI(e.points[0],t,n),t.zenModeEnabled||En(e.points[0],e.points[1],n)},QI=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?qI*1.5:qI)/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()},_B=(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)=>{eT(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;eT(t,"midPointCoords is null"),$m(t,e,n)},tF=(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);$m(a,e,n)},$m=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",ys(n,e[0],e[1],xn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},nF=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!cT(i)||i.isDeleted)return;let a=r==="label"?xn.getBoundTextElementCenter(i,t):xn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);$m(a,e,n)},Rf=(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)"),ys(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},oF=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&Va(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===Ao.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=Ua(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=Ym(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===Ao.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]=Ff(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]=lT(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&&(Va(n.element)||dT(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&xn.getElement(s?.elementId,t),c=r&&WB({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&Wa(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=Ua(n.element,t),p;if(n.element.type==="diamond"){let b=Ua(n.element,t);p=OB(n.element).map(w=>{let y=iT(w,.5),x=Xm(y,b,n.element.angle);return Ha(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=Ha(w.x+n.element.x,w.y+n.element.y),x=Xm(y,m,n.element.angle);return Ha(x[0],x[1])});let u=r&&p.reduce((b,w,y)=>{let x=NB(w,r);return y===-1||x<b.distance?{idx:y,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=XB(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===Ao.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===Ao.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()}}},rF=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=Bl-(a?.runtime??(s?0:Bl)),c=Ym(1/Bl*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&Va(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===Ao.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=Ua(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=Ym(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===Ao.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]=Ff(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]=lT(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)>Bl)return;let p=.5*(Math.min(t.width,t.height)/2);if(!Va(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/Bl*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||!sT(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]=Ff(t),x=Ua(t,o);w=y.map(I=>{let T=iT(I,.5),C=Xm(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let y=Ua(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=Ha(I.x+t.x,I.y+t.y),C=Xm(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===Ao.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}},iF=(e,n,t,o,r,i,a)=>{if(t===null)return;if(FB("COMPLEX_BINDINGS"))return rF(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Ha(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&sT(e.lastPointerMoveEvent);oF(n,t,o,r,s,l),n.restore()},mT=(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??aT*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,ws(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},aF=(e,n,t,o)=>{let[r,i,a,s]=Ol(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),ws(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,bn.radius/n.zoom.value),e.restore()},nT=(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]=zf(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=Of(t,d);return l(m)};Object.entries(qB(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>mT(e,n,d))},Nf=(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=Wa(t),l=YB(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)&&RB(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),Rf(e,n,c,a,p,!1,m)}),Wa(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)||Rf(e,n,Ha((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&&!(Wa(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&Rf(e,n,d,i/2,!1,!0,!1)});e.restore()},sF=(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()},lF=(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)",ys(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},oT=({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||!dT(a)||a.isDeleted)return;let s=tT(i.fixedPoint,a,r);if(!QB(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&&$m(s,o,n),!(m&&c)){let p=tT(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=xn.getPointAtIndexGlobalCoordinates(e,d,r);sF(o,n,E,p),lF(o,n,p,zB/1.5,u)}},rT=(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"?ys(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()):ws(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]=Ol(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()},dF=(e,n,t,o)=>{n.save();let r=pf(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()},mF=(e,n,t,o,r)=>{let i=uf(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())},pF=(e,n,t,o,r,i)=>{for(let a of n){if(!Km(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let d=Fl(a,t,r,"center");d&&uT(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=Fl(a,t,r,"center");m&&pT(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=Fl(a,t,r,"top-right");d&&hF(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},Fl=(e,n,t,o)=>{if(!Km(e))return null;let[r,i,a,s]=Ol(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}},pT=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===Ao.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*Ym(i,0,1)),e.stroke()),e.restore()},Bf=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,uF=(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()},hF=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??Bf("--color-primary",s),d=i.color??Bf("--color-warning-darkest","#ec8b14");if(l==="failed"){uT(e,n,t,o,a,{color:i.color??Bf("--color-danger","#e03131")});return}if(l==="uploading"&&pT(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),uF(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())},uT=(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()},gF=({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]=Ac(n,a),E=d,g=Dc({canvas:n,scale:a,normalizedWidth:p,normalizedHeight:u});g.save(),g.scale(s.zoom.value,s.zoom.value);let b;if(o.forEach(C=>{s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===C.id&&C&&(b=C)}),b&&Nf(g,s,b,t),s.selectionElement&&!s.isCropping)try{JB(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let w=$B(r,s);if(w&&!w.autoResize&&mF(w,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&dF(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:iF(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&nF(g,s,i),s.frameToHighlight&&aF(g,s,s.frameToHighlight,t),s.elementsToHighlight&&nT(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:Of(i,s.activeLockedId);nT(g,s,P,{colors:["#ced4da"],dashed:!0})}let y=r.some(C=>Va(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&Nf(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):(Wa(I)?x.hoverPointIndex===0||x.hoverPointIndex===I.points.length-1:x.hoverPointIndex>=0)&&tF(g,s,t)),cT(I)&&(oT({arrow:I,elementsMap:i,appState:s,context:g,type:"start"}),oT({arrow:I,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=UB(r,s,c),P=r.length===1&&VB(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Nf(g,s,r[0],t);let M=l.selectionColor||"#000";if(C){let D=BB(r),_=[];for(let L of t.values()){let F=[],Y=l.remoteSelectedElementIds.get(L.id);if(P&&Wa(L)&&(L.startBinding||L.endBinding)||(D.has(L.id)&&!jB(s,L)&&F.push(M),Y&&F.push(...Y.map(z=>Jr(z,s.collaborators.get(z))))),F.length){let[z,U,V,G,re,B]=Ol(L,t,!0);_.push({angle:L.angle,x1:z,y1:U,x2:V,y2:G,selectionColors:L.locked?["#ced4da"]:F,dashed:!!Y||L.locked,cx:re,cy:B,activeEmbeddable:s.activeEmbeddable?.element===L&&s.activeEmbeddable.state==="active",padding:L.id===s.croppingElementId||Km(L)?0:void 0})}}let k=L=>{let F=Of(t,L),[Y,z,U,V]=zf(F);_.push({angle:0,x1:Y,x2:U,y1:z,y2:V,selectionColors:F.some(G=>G.locked)?["#ced4da"]:["#000"],dashed:!0,cx:Y+(U-Y)/2,cy:z+(V-z)/2,activeEmbeddable:!1})};for(let L of ZB(s))k(L);s.editingGroupId&&k(s.editingGroupId),_.forEach(L=>mT(g,s,L))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let D=GB(r[0],s.zoom,t,"mouse",_f(c));if(!s.viewModeEnabled&&C&&!KB(s.editingTextElement)&&!s.croppingElementId&&rT(g,l,s,D,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&Km(_)&&cF(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(D=>D.locked)){let D=aT*2/s.zoom.value;g.fillStyle="#fff";let[_,k,L,F]=zf(r,t),Y=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=M,ws(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=HB([_,k,L,F,(_+L)/2,(k+F)/2],0,s.zoom,"mouse",y?{..._f(c),rotation:!0}:_f(c));r.some(V=>!V.locked)&&rT(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]=Ol(D,t,!0);g.save(),s.theme===Ao.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=Va(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()}}),JI(g,s),pF(g,o,t,e,s,l.selectionColor),g.restore(),Rw({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=nI(t,p,u,s),g.save(),g.fillStyle=tI,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&rm(g,C.x,C.y,C.width,C.height,fn/2)}),g.restore()),{scrollBars:T,animationState:E}},Gf=e=>{let n=gF(e);return e.callback(n),n};import{useEffect as Ul,useMemo as hT,useRef as Yf,useState as fF}from"react";import{bumpVersion as zl,getLinearElementSubType as Xa,mutateElement as Xf,updateElbowArrowPoints as EF}from"@excalidraw/element";import{pointFrom as jm,pointRotateRads as bF}from"@excalidraw/math";import{hasBoundTextElement as xF,isArrowBoundToElement as yF,isArrowElement as wF,isElbowArrow as vF,isLinearElement as jf,isUsingAdaptiveRadius as IF}from"@excalidraw/element";import{getCommonBoundingBox as TF,getElementAbsoluteCoords as SF}from"@excalidraw/element";import{getBoundTextElement as xT,getBoundTextMaxHeight as CF,getBoundTextMaxWidth as PF,redrawTextBoundingBox as kF}from"@excalidraw/element";import{wrapText as MF}from"@excalidraw/element";import{assertNever as AF,CLASSES as DF,getFontString as Hf,isProdEnv as LF,mapFind as _F,reduceToCommonValue as RF,ROUNDNESS as Uf,sceneCoordsToViewportCoords as NF,updateActiveTool as gT}from"@excalidraw/common";import{measureText as fT}from"@excalidraw/element";import{LinearElementEditor as BF}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Wf,newElement as FF,newLinearElement as OF}from"@excalidraw/element";import{ShapeCache as zF}from"@excalidraw/element";import{updateBindings as GF}from"@excalidraw/element";import{jsx as Zf}from"react/jsx-runtime";var HF=8,UF=10,Gl=["rectangle","diamond","ellipse"],Hl=["line","sharpArrow","curvedArrow","elbowArrow"],WF=new Set(Gl),VF=new Set(Hl),Ka=e=>WF.has(e),qm=e=>e==="arrow"||VF.has(e),ro=Qe(null),Wl=new Map,Vl=new Map,YF=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=Yf(null);return Ul(()=>{if(n.length===0){e.updateEditorAtom(ro,null);return}let o=Jm(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(ro,null),t.current=null)},[n,e]),Ul(()=>()=>{Wl.clear(),Vl.clear()},[]),Zf(XF,{app:e,elements:n})},XF=({app:e,elements:n})=>{let t=Jm(n),o=hT(()=>t==="generic"?wT(n):[],[t,n]),r=hT(()=>t==="linear"?$f(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>Xa(m)===Xa(r[0])):!1,[a,s]=fF({x:0,y:0}),l=Yf(""),c=Yf(null);Ul(()=>{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]=SF(m[0],e.scene.getNonDeletedElementsMap());u=bF(jm(b,w),jm(y,x),m[0].angle)}else{let{minX:b,maxY:w}=TF(m);u=jm(b,w)}let{x:E,y:g}=NF({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),Ul(()=>{for(let m of r){let p=Kf(m.id,qF(m));Vl.has(p)||Vl.set(p,m)}},[r]),Ul(()=>{for(let m of o)if(!Wl.has(m.id)){let p=xT(m,e.scene.getNonDeletedElementsMap());p&&Wl.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",$o],["sharpArrow",qo],["curvedArrow",Qo],["elbowArrow",Jo]]:t==="generic"?[["rectangle",_i],["diamond",Ri],["ellipse",Ni]]:[];return Zf("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(UF+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-HF}px`,zIndex:2},className:DF.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&Xa(r[0])===m);return Zf(Z,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Fe("convertElementType",m,"ui"),qf(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},KF=(e,n,t)=>{let o=PF(e,n),r=CF(e,n),i=MF(n.text,Hf(n),o),a=fT(i,Hf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=fT(n.text,Hf(l),n.lineHeight)}Xf(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),kF(n,e,t)},qf=(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=wT(r),c=s.every(d=>d.type===s[0].type)?Gl.indexOf(s[0].type):-1;if(t=t??Gl[(c+Gl.length+a)%Gl.length],t&&Ka(t)){let d={};for(let p of s){let u=bT(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=xT(p,e.scene.getNonDeletedElementsMap());u&&(Wl.get(p.id)&&Xf(u,e.scene.getNonDeletedElementsMap(),{fontSize:Wl.get(p.id)?.fontSize??u.fontSize}),KF(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:gT(p,{type:"selection"})}))}}if(n==="linear"){let s=$f(r);if(!t){let c=RF(s,Xa),d=c?Hl.indexOf(c):-1;t=Hl[(d+Hl.length+a)%Hl.length]}if(qm(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Vl.get(Kf(m.id,t));if(p&&Xa(p)===t)d.set(p.id,p),c.push(p);else{let u=bT(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(jf(m))if(vF(m)){let p=$F(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=EF(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Xf(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=_F(["line","sharpArrow","curvedArrow"],u=>Vl.get(Kf(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=$f(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new BF(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:gT(c,{type:"selection"})}))}return!0},Jm=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(Ka(t.type))return"generic";yT(t)&&(n=!0)}return n?"linear":null},yT=e=>jf(e)&&(!wF(e)||!yF(e)&&!xF(e)),Kf=(e,n)=>`${e}:${n}`,wT=e=>e.filter(n=>Ka(n.type)),$f=e=>e.filter(n=>yT(n)),Zm=20,Ya=(e,n)=>e[0]===n[0],Vf=(e,n)=>e[1]===n[1],ET=(e,n)=>Ya(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),$F=e=>{let n=[e.points[0]],t=ZF(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])<Zm?s[0]=a[0]:Math.abs(s[1]-a[1])<Zm&&(s[1]=a[1]),Ya(a,s)||Vf(a,s)||n.push(jm(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)Ya(n[i-1],n[i])&&Ya(n[i],n[i+1])||Vf(n[i-1],n[i])&&Vf(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=Ya(a,s),d=Ya(s,l);if(c!==d){let m=ET(a,s),p=ET(s,l);if(m<Zm||p<Zm){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},ZF=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},bT=(e,n,t)=>{if(!jF(e.type,n)){if(!LF())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(zF.delete(e),Ka(n)){let o=zl(FF({...e,type:n,roundness:e.roundness?{type:IF(n)?Uf.ADAPTIVE_RADIUS:Uf.PROPORTIONAL_RADIUS}:e.roundness}));return GF(o,t.scene,t.state),o}if(qm(n))switch(n){case"line":return zl(OF({...e,type:"line"}));case"sharpArrow":return zl(Wf({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return zl(Wf({...e,type:"arrow",elbowed:!1,roundness:{type:Uf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return zl(Wf({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return AF(n,`unhandled conversion type: ${n}`),e},jF=(e,n)=>!!(Ka(e)&&Ka(n)||qm(e)&&qm(n)),qF=e=>jf(e)?Xa(e):e.type,vT=YF;import{bindBindingElementToFixedPoint as JF,dragNewTextElement as QF,getBoundTextElement as eO,getEndpointBoundTextDragAnchor as tO,getTextBindingForArrowEndpoint as nO,getUnboundArrowEndpointAtPoint as oO,isArrowElement as rO,isBindingEnabled as iO,isEndpointBoundText as aO,isTextElement as sO}from"@excalidraw/element";import{pointFrom as lO}from"@excalidraw/math";var Qm=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(!iO(this.app.state))return null;let o=oO(lO(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!rO(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 nO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){JF(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!sO(n)||!aO(n,this.app.scene.getNonDeletedElementsMap())?!1:(QF({newElement:n,...tO(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as cO,BUCKET_FILL_BACKGROUND_PICKS as dO,COLOR_PALETTE as TT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as mO,getSizeFromPoints as pO,isTransparent as uO,THEME as hO}from"@excalidraw/common";import{pointFrom as IT}from"@excalidraw/math";import{computeBucketFillPolygon as gO,isBucketFillCompatible as fO,isFrameLikeElement as EO,isRestylableFill as bO,newLinearElement as xO,ShapeCache as yO}from"@excalidraw/element";var Jf=dO.filter(e=>e!==TT.white),ep=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=Jf.indexOf(n),o=Jf[(t+1)%Jf.length];this.app.actionManager.executeAction(Pd,"keyboard",{currentItemBackgroundColor:o})});v(this,"openTemporaryEyeDropper",()=>{if(Et.get(Gt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(Pd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Gt,n)});v(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&Et.get(Gt)===n&&this.app.updateEditorAtom(Gt,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}),yO.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=IT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=gO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&fO(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&&bO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=pO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(y=>IT(y[0]-d,y[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?EO(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=xO({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)=>uO(n)?TT.green[mO]:cO(n,t===hO.DARK))}};import{CURSOR_TYPE as Yl,MIME_TYPES as np,THEME as ST}from"@excalidraw/common";var CT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',wO='<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"/>',PT='<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"/>',vO=`data:${np.svg},${encodeURIComponent(`${CT}${PT}</svg>`)}`,IO=`data:${np.svg},${encodeURIComponent(`${CT}${wO}${PT}</svg>`)}`,TO=e=>{let n=Du.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${np.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>`)}`},tp=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(Yl.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(bs({activeTool:n}))this.set(Yl.GRAB);else if(rn({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(Yl.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${TO(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===ST.LIGHT?vO:IO;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(Yl.AUTO):this.set(Yl.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===ST.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(np.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as MO}from"@excalidraw/common";import{bindBindingElement as AO,convertToShape as DO,convertToShapeHandlePointerMoveFromPointerDown as LO,getHoveredElementForBinding as kT,isBindingElement as _O,isLineElement as RO,LinearElementEditor as Qf,maxBindingDistance_simple as MT,newArrowElement as NO,updateBoundPoint as BO}from"@excalidraw/element";import{getStrokeWidthByKey as SO,THEME as CO}from"@excalidraw/common";import{clamp as PO,pointFrom as kO}from"@excalidraw/math";var op=class{constructor(n){this.app=n;v(this,"trail");this.trail=new Rn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===CO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>PO(SO("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])=>kO(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var rp=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(ut),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});v(this,"handlePointerMove",n=>LO(this.app,n));v(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=MT(t.state.zoom),a=["start","end"].map(d=>{let m=Qf.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:kT(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&&AO(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=BO(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&&Qf.movePoints(n,t.scene,c)});v(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=MT(t.state.zoom),[a,s]=[0,-1].map(l=>kT(Qf.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:NO({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||DO(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:MO(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&RO(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&_O(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new op(n)}};import{isArrowKey as FO,KEYS as li}from"@excalidraw/common";import{makeNextSelectedElementIds as OO,CaptureUpdateAction as zO,FlowChartCreator as GO,FlowChartNavigator as HO,getSelectedElements as AT,isFlowchartNodeElement as UO}from"@excalidraw/element";var ip=class e{constructor(n){this.app=n;v(this,"creator",new GO);v(this,"navigator",new HO);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===li.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!FO(n.key))return{type:"none"};if(n[li.CTRL_OR_CMD]&&!n.shiftKey){let a=AT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&UO(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=AT(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[li.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:OO({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:zO.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case li.ARROW_UP:return"up";case li.ARROW_DOWN:return"down";case li.ARROW_RIGHT:return"right";case li.ARROW_LEFT:return"left";default:return"right"}}};import{createGifPlaybackMetadata as DT,hasPlayableGif as WO,isInitializedImageElement as VO,newElementWith as LT,ShapeCache as YO}from"@excalidraw/element";import{MIME_TYPES as _T}from"@excalidraw/common";var ap=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||WO(this.app.scene.getNonDeletedElements(),this.app.imageCache)&&(this.playbackRaf=requestAnimationFrame(this.tick))});v(this,"createPlaceholderDecodeState",(n,t)=>{if(t.type!==_T.gif)return null;let o=n.id;this.app.imageCache.set(o,{image:new Promise(()=>{}),mimeType:_T.gif,gifDecodeStatus:"pending"});let r=LT(n,{fileId:o,gifPlayback:DT({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:LT(n,{gifPlayback:n.gifPlayback?{...n.gifPlayback,playing:t.playing??n.gifPlayback.playing}:DT(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(!VO(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,YO.delete(r),t=!0)}t&&this.app.imagePlaceholderUpdateEmitter.trigger(),o&&(this.playbackRaf=requestAnimationFrame(this.tick))})}};import{debounce as XO,easeOut as zT,isBounds as KO}from"@excalidraw/common";import{clamp as GT}from"@excalidraw/math";import{getCommonBounds as RT,getElementsInGroup as $O,isElementLink as ZO,isExcalidrawElement as jO,parseElementLinkFromURL as qO}from"@excalidraw/element";var sp="animateScrollToContent",$a="animateScrollConstraintsSnapBack",NT=500,JO=250,QO=200,eE=302,BT={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")},t9=(e,n)=>{let t=n.get(e);return t?[t]:$O(n,e)},FT=(e,n,t)=>{if(typeof e=="string"){let a=ZO(e),s=a?"link":"element",l=a?qO(e):e,c=l?t9(l,n):[];return c.length?{bounds:RT(c,n),type:s}:{bounds:null,type:s}}if(KO(e))return{bounds:e,type:"area"};if(e9(e)&&!jO(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:RT(r,n),type:"element"}},n9=e=>e===!1?0:e===!0||e==null?wu:Math.max(e,0),o9=(e,n,t="scale-down",o,r)=>{let{appState:i}=_r({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},OT=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=o9(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[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:n9(r.overscroll),offsets:o};return{...Vn({...e,...a,scrollConstraints:m}),scrollConstraints:m}},r9=({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}}},i9=e=>e===!1?null:e===!0||e==null?NT:e.duration??NT,a9=(e,n,t,o,r)=>{st.start(sp,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=zT(GT(l,0,1));return l<1?(o({...r9({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},s9=(e,n,t=JO)=>{let o=Vn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||st.running(sp))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;st.start($a,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-zT(GT(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=Vn(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})},lp=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=Kn().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"?BT.compact:BT.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:eE})}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}=FT(n.target,t,o);return r?OT(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});v(this,"setViewport",n=>{if(n===null){this.cancelTransition(),st.cancel($a),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}=FT(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=OT(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=i9(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),st.cancel($a),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}),a9(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||st.cancel($a),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(),Vn(r,a)}),!0});v(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Vn(t,n):null)});v(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});v(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||s9(this.app.state,n=>this.app.setState(t=>n(t)))});v(this,"snapBackDebounced",XO(this.snapBack,QO));v(this,"cancelTransition",()=>{this.activeTransition=null,st.cancel(sp)});v(this,"destroy",()=>{this.cancelTransition(),st.cancel($a),this.snapBackDebounced.cancel()})}get isAnimating(){return st.running(sp)||st.running($a)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import cp from"react";var l9=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,c9=/{{([\w-]+)}}/,d9=/<([\w-]+)>/,m9=/<\/([\w-]+)>/,p9=(e,n)=>{let t=[{name:"",children:[]}];return e.split(l9).filter(Boolean).forEach(o=>{let r=o.match(d9),i=o.match(m9),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=cp.createElement(cp.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},u9=({i18nKey:e,children:n,...t})=>{let{t:o}=_e();return cp.createElement(cp.Fragment,{},...p9(o(e),t))},ci=u9;import{jsx as yn,jsxs as HT}from"react/jsx-runtime";var h9=()=>HT("div",{"data-testid":"brave-measure-text-error",children:[yn("p",{children:yn(ci,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(ci,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(ci,{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(ci,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>yn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>HT("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),UT=h9;import v9 from"clsx";import I9 from"react";import{isDarwin as WT}from"@excalidraw/common";var g9={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:[WT?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[WT?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")],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+R")],toolLock:[N("Q")]},je=(e,n=0)=>{let t=g9[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as f9,useRef as VT,useEffect as YT}from"react";import{unstable_batchedUpdates as E9}from"react-dom";import{KEYS as b9,queryFocusableElements as x9}from"@excalidraw/common";import{clamp as XT}from"@excalidraw/math";import y9 from"clsx";import{jsx as w9}from"react/jsx-runtime";var Er=10,KT=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=VT(null);YT(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===b9.TAB){let u=x9(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=VT(null);return f9(()=>{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-Er*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${Er}px`,d.style.overflowX="scroll"):d.style.left=`${XT(n,Er,i-Er-m)}px`;let E=Math.max(0,a-Er*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${Er}px`,d.style.overflowY="scroll"):d.style.top=`${XT(t,Er,a-Er-p)}px`}},[t,n,r,i,a]),YT(()=>{if(o){let d=m=>{l.current?.contains(m.target)||E9(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),w9("div",{className:y9("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as Do,jsxs as ZT}from"react/jsx-runtime";var qe="separator",$T=e=>"onSelect"in e,jT=I9.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=Qn(),a=Ui(),s=n.reduce((l,c)=>c?c===qe||$T(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return Do(KT,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:Do("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===qe)return!s[c-1]||s[c-1]===qe?null:Do("hr",{className:"context-menu-item-separator"},c);if($T(l))return Do("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:ZT("button",{type:"button",className:"context-menu-item",children:[Do("div",{className:"context-menu-item__label",children:l.label}),Do("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)),Do("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:ZT("button",{type:"button",className:v9("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[Do("div",{className:"context-menu-item__label",children:m}),Do("kbd",{className:"context-menu-item__shortcut",children:d?je(d):""})]})},c)})})})});import{useId as T9}from"react";import S9 from"clsx";import{Fragment as C9,jsx as Xl,jsxs as qT}from"react/jsx-runtime";var dp=({border:e,style:n})=>Xl("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),mp=({label:e,border:n})=>{let t=T9(),o=qT(C9,{children:[e.icon&&Xl("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return qT("div",{className:S9("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&&Xl("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),Xl("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&Xl("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:an})]})};import ls from"clsx";import JW from"react";import{CLASSES as QW,TOOL_TYPE as Pk,arrayToMap as eV,isShallowEqual as Yp}from"@excalidraw/common";import{mutateElement as tV,ShapeCache as nV}from"@excalidraw/element";import{showSelectedShapeActions as oV}from"@excalidraw/element";import{createIsolation as P9}from"jotai-scope";import tE from"react";import Lo from"tunnel-rat";var nE=tE.createContext(null),ot=()=>tE.useContext(nE),k9=P9(),JT=()=>tE.useMemo(()=>({MainMenuTunnel:Lo(),WelcomeScreenMenuHintTunnel:Lo(),WelcomeScreenToolbarHintTunnel:Lo(),WelcomeScreenHelpHintTunnel:Lo(),WelcomeScreenCenterTunnel:Lo(),FooterCenterTunnel:Lo(),DefaultSidebarTriggerTunnel:Lo(),DefaultSidebarTabTriggersTunnel:Lo(),OverwriteConfirmDialogTunnel:Lo(),tunnelsJotai:k9}),[]);import xr from"clsx";import{useRef as F9}from"react";import{Popover as br}from"radix-ui";import{CLASSES as cS}from"@excalidraw/common";import{isArrowElement as lS}from"@excalidraw/element";import{forwardRef as QT}from"react";import eS from"clsx";import{jsx as tS}from"react/jsx-runtime";var M9=QT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>tS("div",{className:eS("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),A9=QT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>tS("div",{className:eS("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Bt={Row:M9,Col:A9};import{isTransparent as nS}from"@excalidraw/common";import{shouldAllowVerticalAlign as D9,suppportsHorizontalAlign as L9,hasBoundTextElement as oS,isElbowArrow as _9,isImageElement as rS,isLinearElement as R9,isTextElement as N9,hasStrokeColor as iS,toolIsArrow as B9}from"@excalidraw/element";var aS=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return iS(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>iS(o.type))},sS=(e,n)=>Yo(e.activeTool.type)||n.some(t=>Yo(t.type)),pp=(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&&(oS(n[0])||oS(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:aS(e,n),backgroundColor:sS(e,n),fill:r==="bucketfill"||Yo(r)&&!nS(e.currentItemBackgroundColor)||n.some(d=>Yo(d.type)&&!nS(d.backgroundColor)),strokeWidth:i(ix),freedrawMode:i(ax),strokeStyle:i(vu),sloppiness:i(vu),roundness:i(sx),arrowType:i(B9),arrowheads:i(Es),text:r==="text"||n.some(N9),textAlign:r==="text"||L9(n,t),verticalAlign:D9(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||ce(t,e).some(d=>d.type==="freedraw"),align:!s&&dt(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(rS)&&dt(e,o),link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&rS(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&R9(n[0])&&!_9(n[0])}};import{Fragment as Qt,jsx as q,jsxs as Ce}from"react/jsx-runtime";var oE=xr([cS.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),dS=({renderAction:e})=>Ce("fieldset",{children:[q("legend",{children:f("labels.layers")}),Ce("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),mS=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Ce("fieldset",{children:[q("legend",{children:f("labels.align")}),Ce("div",{className:"buttonList",children:[o?Ce(Qt,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Ce(Qt,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),q("div",{style:{flexBasis:"100%",height:0}}),Ce("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Ce(Qt,{children:[q("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},pS=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=Ci(n,e),i=pp(e,r,n,o);return e.activeTool.type==="bucketfill"?Ce("div",{className:"selected-shape-actions",children:[q("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Ce("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(Qt,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&q(Qt,{children:t("changeSloppiness")}),i.roundness&&q(Qt,{children:t("changeRoundness")}),i.arrowType&&q(Qt,{children:t("changeArrowType")}),i.text&&Ce(Qt,{children:[q("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&q(Qt,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&q(dS,{renderAction:t}),i.align&&q(mS,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Ce("fieldset",{children:[q("legend",{children:f("labels.actions")}),Ce("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")]})]})]})},uS=({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:Ce(br.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:g0})}),a&&q(yo,{className:oE,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Ce("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&q(Qt,{children:n("changeStrokeStyle")}),o.sloppiness&&q(Qt,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},hS=({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:Ce(br.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("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=mt(o,a,c=>lS(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>lS(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?Jo:l==="round"?Qo:qo})()})}),s&&q(yo,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},gS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=O0(),s=e.openPopup==="compactTextProperties";return q("div",{className:"compact-action-item",children:Ce(br.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("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:Hx})}),e.openPopup==="compactTextProperties"&&q(yo,{className:oE,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Ce("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},fS=({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:Ce(br.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:Rx})}),s&&q(yo,{className:oE,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Ce("div",{className:"selected-shape-actions",children:[t.layers&&q(dS,{renderAction:n}),t.align&&q(mS,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Ce("fieldset",{children:[q("legend",{children:f("labels.actions")}),Ce("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},O9=({renderAction:e,predicates:n})=>n.lineEditor?q("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,ES=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Ci(n,e),a=pp(e,i,n,o),{container:s}=Ne();return Ce("div",{className:"compact-shape-actions",children:[a.strokeColor&&q("div",{className:xr("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(uS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(hS,{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&&Ce(Qt,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(gS,{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(fS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},bS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Ci(n,e),a=pp(e,i,n,o),{container:s}=Ne(),l=F9(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 Ce(Ue,{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:[Ce("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&q("div",{className:xr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),q(uS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(hS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),q(O9,{renderAction:t,predicates:a}),a.text&&Ce(Qt,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(gS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),q(fS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Ce("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")})]})]})},xS=({renderAction:e})=>q(Bt.Col,{gap:1,className:cS.ZOOM_ACTIONS,children:Ce(Bt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),yS=({renderAction:e,className:n})=>Ce("div",{className:`undo-redo-buttons ${n}`,children:[q("div",{className:"undo-button-container",children:q(pt,{label:f("buttons.undo"),children:e("undo")})}),q("div",{className:"redo-button-container",children:Ce(pt,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),wS=({showExitZenModeBtn:e})=>q("button",{type:"button",className:xr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import z9 from"clsx";import{useState as G9,useEffect as H9}from"react";import{THEME as U9}from"@excalidraw/common";import{jsx as rE,jsxs as W9}from"react/jsx-runtime";var up=({delay:e,theme:n})=>{let[t,o]=G9(!!e);return H9(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:W9("div",{className:z9("LoadingMessage",{"LoadingMessage--dark":n===U9.DARK}),children:[rE("div",{children:rE(xo,{})}),rE("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as Ep,useEffect as WS}from"react";import bz from"clsx";import{KEYS as lE,capitalizeString as VS}from"@excalidraw/common";import US from"react";import{DropdownMenu as hz}from"radix-ui";import{CLASSES as gz}from"@excalidraw/common";import V9 from"clsx";import{useCallback as Y9,useEffect as X9,useRef as K9}from"react";import{CLASSES as $9,EVENT as vS,KEYS as Z9}from"@excalidraw/common";import{DropdownMenu as j9}from"radix-ui";import{jsx as hp}from"react/jsx-runtime";var IS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=be(),l=K9(null),c=Hi({onClickOutside:n});Gi(l,Y9(m=>{l.current?.closest(`.${$9.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),X9(()=>{if(!r)return;let m=u=>{u.key===Z9.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(vS.KEYDOWN,m,p),()=>{document.removeEventListener(vS.KEYDOWN,m,p)}},[c,r]);let d=V9(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return hp(Ch.Provider,{value:{onSelect:o},children:hp(j9.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?hp(Bt.Col,{className:"dropdown-menu-container",children:e}):hp(Ue,{className:"dropdown-menu-container",padding:2,children:e})})})};IS.displayName="DropdownMenuContent";var TS=IS;import{jsx as J9}from"react/jsx-runtime";var q9=({children:e,className:n="",selected:t,...o})=>J9("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),SS=q9;import{DropdownMenu as Q9}from"radix-ui";import{jsx as iE}from"react/jsx-runtime";var CS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=fd(r);return iE(Q9.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:iE("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:or(i,a),title:l.title??l["aria-label"],children:iE(rr,{icon:e,shortcut:n,children:o})})})},Za=CS;CS.displayName="DropdownMenuItemLink";import{jsx as ez}from"react/jsx-runtime";var PS=()=>ez("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),kS=PS;PS.displayName="DropdownMenuSeparator";import{DropdownMenu as sz}from"radix-ui";import tz from"clsx";import{DropdownMenu as nz}from"radix-ui";import{useCallback as oz,useState as MS}from"react";import{jsx as sE}from"react/jsx-runtime";var aE=-4,rz=4,AS=({children:e,className:n})=>{let t=be(),o=tz(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=oz(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+aE),l(aE+8))}}},[]),[i,a]=MS(rz),[s,l]=MS(aE);return sE(nz.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?sE(Bt.Col,{className:"dropdown-menu-container",children:e}):sE(Ue,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},DS=AS;AS.displayName="DropdownMenuSubContent";import{DropdownMenu as iz}from"radix-ui";import{jsx as LS,jsxs as az}from"react/jsx-runtime";var _S=({children:e,icon:n,shortcut:t,className:o})=>az(iz.SubTrigger,{className:`${or(o)} dropdown-menu__submenu-trigger`,children:[LS(rr,{icon:n,shortcut:t,children:e}),LS("div",{className:"dropdown-menu__submenu-trigger-icon",children:b0})]}),RS=_S;_S.displayName="DropdownMenuSubTrigger";import NS from"react";var gp=e=>n=>{let t=NS.Children.toArray(n).find(o=>NS.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},BS=gp("DropdownMenuTrigger"),FS=gp("DropdownMenuContent"),OS=gp("DropdownMenuSubTrigger"),zS=gp("DropdownMenuSubContent");import{jsxs as lz}from"react/jsx-runtime";var fp=({children:e})=>{let n=OS(e),t=zS(e);return lz(sz.Sub,{children:[n,t]})};fp.Trigger=RS;fp.Content=DS;fp.displayName="DropdownMenuSub";var yr=fp;import cz from"clsx";import{DropdownMenu as dz}from"radix-ui";import{jsx as mz}from"react/jsx-runtime";var GS=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=be(),a=cz(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return mz(dz.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},HS=GS;GS.displayName="DropdownMenuTrigger";import{jsx as uz}from"react/jsx-runtime";var pz=e=>uz(qt,{...e,icon:e.checked?Hc:$c}),io=pz;import{jsx as Ez,jsxs as fz}from"react/jsx-runtime";var Bn=({children:e,open:n})=>{let t=BS(e),o=FS(e),r=o&&US.isValidElement(o)?US.cloneElement(o,{open:n}):o;return Ez(hz.Root,{open:n,modal:!1,children:fz("div",{className:gz.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Bn.Trigger=HS;Bn.Content=TS;Bn.Item=qt;Bn.ItemCheckbox=io;Bn.ItemLink=Za;Bn.ItemCustom=SS;Bn.Group=Gs;Bn.Separator=kS;Bn.Sub=yr;var pe=Bn;Bn.displayName="DropdownMenu";import{Fragment as cE,jsx as Re,jsxs as ja}from"react/jsx-runtime";var xz=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Lt))return null;let t=f("buttons.objectsSnapMode");return Re(Z,{type:"toggle",icon:jo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Lt,"ui")})},yz=({app:e})=>Re(Z,{type:"button",icon:Fi,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),YS=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=Ep(!1),[l,c]=Ep("rectangle"),[d,m]=Ep("arrow");WS(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&c(o.type)},[o.type]),WS(()=>{(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:Ye[G].icon,title:VS(f(`toolBar.${G}`)),fillable:Ye[G].fillable})),y=["arrow","line"].map(G=>({type:G,icon:Ye[G].icon,title:VS(f(`toolBar.${G}`)),fillable:Ye[G].fillable})),[x,I]=Ep(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&&ea.includes(o.type),z=Y||F.includes(o.type),U=z?Y?Ye[o.type].icon:o.type==="text"?Pn:o.type==="image"?Fr:o.type==="frame"?jn:o.type==="embeddable"?Zo:o.type==="laser"?qn:o.type==="bucketfill"?Zn:Ts:Ts,V={app:e,activeTool:o,hideShortcut:!0};return ja("div",{className:"mobile-toolbar",ref:G=>{G&&I(G.getBoundingClientRect().width)},children:[Re(zd,{...V}),Re(Gd,{...V,setAppState:t}),r?Re(Zs,{...V}):Re(Hd,{...V}),Re(Js,{...V}),!r&&Re(Qi,{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&&Re(Qi,{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]}),_&&Re(js,{...V}),r&&k&&Re(yz,{app:e}),k&&Re(qs,{...V}),!r&&L&&Re(Qy,{...V,hideShortcut:!0}),ja(pe,{open:a,children:[Re(pe.Trigger,{className:bz("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}),ja(pe.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&ea.map(G=>Re(pe.Item,{onSelect:()=>e.setActiveTool({type:G}),icon:Ye[G].icon,"data-testid":`toolbar-${G}`,selected:o.type===G,shortcut:Od(G),disabled:Je(e,G),children:f(`toolBar.${G}`)},G)),!r&&Re("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(Lt)&&Re(pe.Item,{onSelect:()=>n.executeAction(Lt,"ui"),icon:jo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:je("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&ja(cE,{children:[r&&Re("div",{className:"App-toolbar__dropdown-divider"}),Re(pe.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Ko:bo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:lE.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Pn,shortcut:lE.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:Je(e,"text"),children:f("toolBar.text")}),i&&!k&&Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Fr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:Je(e,"image"),children:f("toolBar.image")}),!r&&!L&&Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:jn,shortcut:lE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:Je(e,"frame"),children:f("toolBar.frame")}),!r&&ja(cE,{children:[Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Zo,"data-testid":"toolbar-embeddable",selected:g,disabled:Je(e,"embeddable"),children:f("toolBar.embeddable")}),Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Gr,shortcut:na("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:Je(e,"autoshape"),children:f("toolBar.autoshape")}),Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:qn,"data-testid":"toolbar-laser",selected:E,disabled:Je(e,"laser"),children:f("toolBar.laser")}),Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Zn,"data-testid":"toolbar-bucketfill",selected:b,disabled:Je(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&ja(cE,{children:[Re("div",{className:"App-toolbar__divider"}),Re(xz,{actionManager:n,app:e})]})]})};import wz from"clsx";import{jsx as vz}from"react/jsx-runtime";var bp=({children:e,side:n,className:t})=>vz("div",{className:wz("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import Iz from"clsx";import{jsx as Tz}from"react/jsx-runtime";var qa=e=>e.penDetected?Tz(Z,{className:Iz("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Gx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as XS,jsx as wt,jsxs as di}from"react/jsx-runtime";var KS=({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}=ot(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=wt("div",{className:"excalidraw-ui-top-right",children:i?.(!0,e)??(!e.viewModeEnabled&&di(XS,{children:[l&&wt(qa,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),wt(E.Out,{})]}))}),M=di("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),wt(u.Out,{})]});return di("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[M,P]})},b=()=>wt(YS,{app:d,actionManager:t,setAppState:o}),w=c&&e.scrolledOutside,y=l,x=l&&(!e.viewModeEnabled||y),I=w&&!e.openMenu&&!e.openSidebar?wt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...Si(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?wt(mp,{label:T,border:d.props.viewportStatusFrame?.border}):null;return di(XS,{children:[a(),wt("div",{className:"App-welcome-screen",children:s&&wt(p.Out,{})}),x&&di("div",{className:"App-bottom-bar",style:{marginBottom:fn+Mo,left:14,transform:"none"},"data-viewport-ui":"bottom",children:[I&&wt("div",{className:"floating-status-stack",children:I}),di("div",{className:"App-bottom-bar__actions-row",children:[y&&di(Ue,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&wt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),wt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&wt(bS,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&wt(Ue,{className:"App-toolbar",style:{justifyContent:"flex-start"},children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&I&&wt("div",{className:"floating-status-stack",children:I}),C&&wt("div",{className:"viewport-status-frame__badge-row",children:C}),wt(bp,{side:"top",className:"App-top-bar",children:g()})]})};import eC,{useLayoutEffect as tC,useRef as nC,useState as oC}from"react";import{newTextElement as rC}from"@excalidraw/element";import Dz from"clsx";import{useEffect as Lz,useState as _z}from"react";import{KEYS as Rz,queryFocusableElements as JS}from"@excalidraw/common";import{useCallback as Sz,useState as Cz}from"react";var $S=()=>{let[e,n]=Cz(null),t=Sz(o=>n(o),[]);return[e,t]};import ZS from"clsx";import{useRef as Pz}from"react";import{createPortal as kz}from"react-dom";import{KEYS as Mz}from"@excalidraw/common";import{jsx as jS,jsxs as Az}from"react/jsx-runtime";var qS=e=>{let{closeOnClickOutside:n=!0}=e,t=id({className:ZS("excalidraw-modal-container",e.portalContainerClassName)}),o=Pz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===Mz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return kz(Az("div",{className:ZS("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[jS("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),jS("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as xp,jsxs as QS}from"react/jsx-runtime";function Nz(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]=$S(),[o]=_z(document.activeElement),{id:r}=Ne(),i=be().formFactor==="phone";Lz(()=>{if(!n)return;let l=JS(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===Rz.TAB){let m=JS(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=Oe(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return xp(qS,{className:Dz("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:Nz(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:QS(Ue,{ref:t,children:[e.title&&QS("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[xp("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&xp("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:an}),xp("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as _o,jsxs as yp}from"react/jsx-runtime";var Bz=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}},Fz=e=>{let n=nC(null),[t,o]=oC(null),{theme:r}=ye();tC(()=>{if(!e.spreadsheet){o(null);return}let a=Lf(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 Rr(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=Bz(e.chartType);return yp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[_o("div",{className:"ChartPreview__canvas",ref:n}),_o("div",{className:"ChartPreview__label",children:i})]})},Oz=e=>{let n=nC(null),{theme:t}=ye();return tC(()=>{if(!e.rawText)return;let o=rC({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Rr([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]),yp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[_o("div",{className:"ChartPreview__canvas",ref:n}),_o("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},iC=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=St(),[i,a]=oC(Math.random()),s=eC.useCallback(()=>{a(Math.random())},[]),l=eC.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),Fe("paste","chart",m),t(),r()},d=m=>{let p=rC({text:m,x:0,y:0});o([p]),Fe("paste","chart","plaintext"),t(),r()};return _o(wn,{size:"regular",onCloseRequest:l,title:yp("div",{className:"PasteChartDialog__title",children:[_o("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),_o("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:Zn})]}),className:"PasteChartDialog",autofocus:!1,children:yp("div",{className:"container",children:[["bar","line","radar"].map(m=>Ra(e,m)?_o(Fz,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&_o(Oz,{rawText:n,onClick:d})]})})};import{Fragment as zz,jsx as aC,jsxs as Gz}from"react/jsx-runtime";var Kl=({heading:e,children:n,...t})=>{let{id:o}=Ne(),r=aC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return aC("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):Gz(zz,{children:[r,n]})})};import{Popover as $l}from"radix-ui";import sC from"clsx";import wp,{useLayoutEffect as Hz}from"react";import{supportsResizeObserver as Uz,isShallowEqual as Wz}from"@excalidraw/common";import{Fragment as pE,jsx as vt,jsxs as Ja}from"react/jsx-runtime";var Vz=4,Yz=8,dE=38,lC=21,Xz=({shouldWrap:e,children:n,username:t})=>e?vt(pt,{label:t||"Unknown user",children:n}):vt(pE,{children:n}),mE=({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 vt(Xz,{username:n.username,shouldWrap:r,children:s},t)},Kz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],vp=wp.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=rt(),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]=wp.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=wp.useRef(null);Hz(()=>{if(u.current){let C=M=>{g(M)};if(C(u.current.clientWidth),!Uz)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]=wp.useState(Vz*dE),b=l?E-lC:E,w=Math.max(1,Math.min(8,Math.floor(b/dE))),y=l?Math.max(0,w-1):w,x=c.slice(0,y),I=l?[...x,l]:x,T=I.map(C=>{let P=mE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?Ja($l.Root,{children:[vt($l.Trigger,{asChild:!0,children:Ja("div",{className:"UserList__pill",children:[P,vt("div",{className:"UserList__pill-chevron",children:E0})]})}),vt($l.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Ja(Ue,{padding:2,children:[s.length>=Yz&&vt(hd,{placeholder:f("quickSearch.placeholder"),onChange:m}),vt(gd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[vt("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(M=>mE({actionManager:i,collaborator:M,socketId:M.socketId,withName:!0,isBeingFollowed:M.socketId===o}))]:[]}),a&&Ja(pE,{children:[vt("div",{className:"UserList__menu-divider"}),vt($l.Close,{asChild:!0,children:vt("div",{className:"dropdown-menu",children:a})})]}),vt($l.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?Ja("div",{className:sC("UserList UserList_mobile",e),children:[vt("div",{className:"UserList_mobile__avatars",children:s.map(C=>mE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&Ja(pE,{children:[vt("div",{className:"UserList__menu-divider"}),a]})]}):vt("div",{className:"UserList__wrapper",ref:u,children:vt("div",{className:sC("UserList",e),style:{"--max-avatars":I.length+(l?lC/dE: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||!Wz(r,i,Kz))return!1}return!0});import Zl from"clsx";import{jsx as cC}from"react/jsx-runtime";var dC=e=>cC(pt,{label:`${f("helpDialog.title")} \u2014 ?`,children:cC("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:Bi})});import{jsx as en,jsxs as uE}from"react/jsx-runtime";var mC=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=ot(),l=St();return uE("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&en("div",{className:Zl("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:en(Bt.Col,{gap:2,children:uE(Kl,{heading:"canvasActions",children:[!e.viewModeOnly&&en(pt,{label:e.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:en("div",{className:Zl("view-mode-button"),children:n.renderAction("viewMode")})}),en(pt,{label:f("buttons.smartZoom"),children:en("div",{className:Zl("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&en(xS,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&en(yS,{renderAction:n.renderAction,className:Zl("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),en(a.Out,{}),(r||o)&&en("div",{className:Zl("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:uE("div",{style:{position:"relative"},children:[o&&en(s.Out,{}),r&&en(dC,{onClick:()=>n.executeAction(qr)})]})}),r&&en(wS,{showExitZenModeBtn:t})]})},pC=mC;mC.displayName="Footer";import{composeEventHandlers as tG}from"@excalidraw/common";import{useLayoutEffect as $z,useRef as Zz}from"react";import{jsx as jz}from"react/jsx-runtime";var mi=(e,n)=>{let t=Qe(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=ot(),[,a]=i(t),s=Zz({preferHost:!1,counter:0});return $z(()=>{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:jz(n,{...r})};return o.displayName=e,o};var EE={};w3(EE,{ChangeCanvasBackground:()=>IC,Export:()=>TC,Help:()=>wC,LiveCollaborationTrigger:()=>CC,LoadScene:()=>EC,Preferences:()=>ao,PreferencesToggleGridModeItem:()=>fE,SaveAsImage:()=>xC,SaveToActiveFile:()=>bC,SearchMenu:()=>yC,Socials:()=>SC,ToggleTheme:()=>vC});import eG from"clsx";import{THEME as ql}from"@excalidraw/common";var hE=Qe({active:!1});async function uC({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{Et.set(hE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import qz from"clsx";import{jsx as hC,jsxs as Jz}from"react/jsx-runtime";var Ip=function({onChange:e,value:n,choices:t,name:o}){return hC("div",{className:"RadioGroup",children:t.map(r=>Jz("div",{className:qz("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[hC("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 Qz,jsx as jl,jsxs as gC}from"react/jsx-runtime";var fC=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=be();return gC(Qz,{children:[gC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&jl("div",{className:"dropdown-menu-item__icon",children:a}),jl("label",{className:"dropdown-menu-item__text",children:jl(Hs,{children:r})}),jl(Ip,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&jl("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};fC.displayName="DropdownMenuItemContentRadio";var gE=fC;import{Fragment as RC,jsx as we,jsxs as Jl}from"react/jsx-runtime";var EC=()=>{let{t:e}=_e(),n=rt(),t=Ui();return n.isActionEnabled(ra)?we(qt,{icon:Uc,onSelect:async()=>{(!t.length||await uC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:we(ci,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>we("strong",{children:r}),br:()=>we("br",{})})}))&&n.executeAction(ra)},"data-testid":"load-button",shortcut:je("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};EC.displayName="LoadScene";var bC=()=>{let{t:e}=_e(),n=rt();return n.isActionEnabled(jr)?we(qt,{shortcut:je("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(jr),icon:$x,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};bC.displayName="SaveToActiveFile";var xC=()=>{let e=Oe(),{t:n}=_e();return we(qt,{icon:qx,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:je("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};xC.displayName="SaveAsImage";var yC=e=>{let{t:n}=_e(),t=rt();return we(qt,{icon:Jn,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Pl)},shortcut:je("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};yC.displayName="SearchMenu";var wC=()=>{let{t:e}=_e(),n=rt();return we(qt,{"data-testid":"help-menu-item",icon:Bi,onSelect:()=>n.executeAction(qr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};wC.displayName="Help";var vC=e=>{let{t:n}=_e(),t=ye(),o=rt(),r=je("toggleTheme"),i=kn();return o.isActionEnabled(Rd)?e?.allowSystemTheme?we(gE,{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:ql.LIGHT,label:Ps,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:ql.DARK,label:Cs,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:c0,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):we(qt,{onSelect:a=>{a.preventDefault(),o.executeAction(Rd)},icon:t.theme===ql.DARK?Ps:Cs,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===ql.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===ql.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};vC.displayName="ToggleTheme";var IC=()=>{let{t:e}=_e(),n=ye(),t=rt(),o=kn();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:Jl("div",{style:{marginTop:"0.75rem"},children:[we("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),we("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};IC.displayName="ChangeCanvasBackground";var TC=()=>{let{t:e}=_e(),n=Oe();return we(qt,{icon:ks,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};TC.displayName="Export";var SC=()=>{let{t:e}=_e();return Jl(RC,{children:[we(Za,{icon:Yx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),we(Za,{icon:Kx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),we(Za,{icon:Xx,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};SC.displayName="Socials";var CC=({onSelect:e,isCollaborating:n})=>{let{t}=_e();return we(qt,{"data-testid":"collab-button",icon:Wc,className:eG({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};CC.displayName="LiveCollaborationTrigger";var PC=()=>{let{t:e}=_e(),n=St(),t=ye();return we(io,{checked:t.activeTool.locked,shortcut:je("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},kC=()=>{let{t:e}=_e(),n=ye(),t=Oe();return we(gE,{name:"boxSelectionMode",icon:$c,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")})},MC=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.objectsSnapModeEnabled,shortcut:je("objectsSnapMode"),onSelect:o=>{n.executeAction(Lt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},AC=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(sl),o.preventDefault()},children:e("labels.arrowBinding")})},DC=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(ll),o.preventDefault()},children:e("labels.midpointSnapping")})},fE=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.gridModeEnabled,shortcut:je("gridMode"),onSelect:o=>{n.executeAction(pa),o.preventDefault()},children:e("labels.toggleGrid")})},LC=()=>{let{t:e}=_e(),n=rt(),t=ye();return t.viewModeOnly?null:we(io,{checked:t.viewModeEnabled,shortcut:je("viewMode"),onSelect:o=>{n.executeAction(Ca),o.preventDefault()},children:e("labels.viewMode")})},_C=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.stats.open,shortcut:je("stats"),onSelect:o=>{n.executeAction(mr),o.preventDefault()},children:e("stats.fullTitle")})},ao=({children:e,additionalItems:n})=>{let{t}=_e();return Jl(yr,{children:[we(yr.Trigger,{icon:x0,children:t("labels.preferences")}),Jl(yr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Jl(RC,{children:[we(kC,{}),we(PC,{}),we(MC,{}),we(fE,{}),we(LC,{}),we(_C,{}),we(AC,{}),we(DC,{})]}),n]})]})};ao.ToggleToolLock=PC;ao.BoxSelectionMode=kC;ao.ToggleSnapMode=MC;ao.ToggleArrowBinding=AC;ao.ToggleMidpointSnapping=DC;ao.ToggleGridMode=fE;ao.ToggleViewMode=LC;ao.ToggleElementProperties=_C;ao.displayName="Preferences";import{jsx as Tp,jsxs as bE}from"react/jsx-runtime";var nG=Object.assign(mi("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=ot(),o=be(),r=ye(),i=kn(),a=Oe();return Tp(t.In,{children:bE(pe,{open:r.openMenu==="canvas",children:[Tp(pe.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Wx}),bE(pe.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:tG(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&bE("fieldset",{className:"UserList-Wrapper",children:[Tp("legend",{children:f("labels.collaborators")}),Tp(vp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:pe.Trigger,Item:pe.Item,ItemLink:pe.ItemLink,ItemCustom:pe.ItemCustom,Group:pe.Group,Separator:pe.Separator,Sub:yr,DefaultItems:EE}),Ft=nG;import oG from"clsx";import{forwardRef as rG,useState as iG}from"react";import{isPromiseLike as aG}from"@excalidraw/common";import{jsx as Sp,jsxs as sG}from"react/jsx-runtime";var wr=rG(({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]=iG(!1),E=async b=>{let w=t?.(b);if(aG(w)){let y=window.setTimeout(()=>{u(!0)},50);try{await w}catch(x){if(x instanceof Pc)console.warn(x);else throw x}finally{clearTimeout(y),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,Sp("button",{className:oG("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:sG("div",{className:"ExcButton__contents",children:[g==="loading"?Sp(xo,{className:"ExcButton__statusIcon"}):g==="success"&&Sp("div",{className:"ExcButton__statusIcon",children:J1}),n&&Sp("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as Qa,jsxs as dG}from"react/jsx-runtime";var Cp=({title:e,children:n,actionLabel:t,onClick:o})=>dG("div",{className:"OverwriteConfirm__Actions__Action",children:[Qa("h4",{children:e}),Qa("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),Qa(wr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),lG=()=>{let{t:e}=_e(),n=rt(),t=Oe();return Qa(Cp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(Qd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},cG=()=>{let{t:e}=_e(),n=rt();return Qa(Cp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(rl,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},xE=Object.assign(({children:e})=>Qa("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:lG,SaveToDisk:cG});import{jsx as vr,jsxs as NC}from"react/jsx-runtime";var Pp=Object.assign(mi("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=ot(),[t,o]=He(hE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return vr(n.In,{children:vr(wn,{onCloseRequest:r,title:!1,size:916,children:NC("div",{className:"OverwriteConfirm",children:[vr("h3",{children:t.title}),NC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[vr("div",{className:"OverwriteConfirm__Description__icon",children:Q1}),vr("div",{children:t.description}),vr("div",{className:"OverwriteConfirm__Description__spacer"}),vr(wr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),vr(xE,{children:e})]})})})}),{Actions:xE,Action:Cp});import{round as SP}from"@excalidraw/math";import kH from"clsx";import MH from"lodash.throttle";import{useEffect as CP,useMemo as _E,useState as AH,memo as DH}from"react";import{STATS_PANELS as Bp}from"@excalidraw/common";import{getCommonBounds as LH}from"@excalidraw/element";import{getUncroppedWidthAndHeight as _H}from"@excalidraw/element";import{isImageElement as RE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as RH}from"@excalidraw/element";import{elementsAreInSameGroup as NH}from"@excalidraw/element";import{degreesToRadians as WC,radiansToDegrees as KC}from"@excalidraw/math";import{getBoundTextElement as VC}from"@excalidraw/element";import{isArrowElement as YC,isElbowArrow as TG}from"@excalidraw/element";import{updateBindings as XC}from"@excalidraw/element";import bG from"clsx";import{useEffect as HC,useRef as Mp,useState as xG}from"react";import{EVENT as ns,KEYS as yG,cloneJSON as yE}from"@excalidraw/common";import{deepCopyElement as wG}from"@excalidraw/element";import{CaptureUpdateAction as UC}from"@excalidraw/element";import{pointFrom as Ir,pointRotateRads as kp}from"@excalidraw/math";import{getBoundTextElement as mG,getNonDeletedElements as pG,isBindingElement as uG,unbindBindingElement as BC}from"@excalidraw/element";import{isFrameLikeElement as zC}from"@excalidraw/element";import{getSelectedGroupIds as hG,getElementsInGroup as gG,isInGroup as fG}from"@excalidraw/element";import{getFrameChildren as EG}from"@excalidraw/element";import{updateBindings as FC}from"@excalidraw/element";import{DRAGGING_THRESHOLD as OC}from"@excalidraw/common";var GC=.01,Ql=10,Vt=(e,n)=>!(n==="angle"&&zC(e)),We=(e,n)=>{let t=e+n/2;return t-t%n},es=(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 pi=(e,n,t,o,r,i,a=!0)=>{if(uG(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<OC&&Math.abs(n-t.y)<OC)return;BC(t,"start",o),BC(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]=kp(Ir(t.x,t.y),Ir(c,d),t.angle),u=e-m,E=n-p,[g,b]=kp(Ir(e,n),Ir(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),FC(l,o,r);let w=mG(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(zC(t)){let y=EG(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]=kp(Ir(x.x,x.y),Ir(T,C),x.angle),D=Math.round(P+u),_=Math.round(M+E),[k,L]=kp(Ir(D,_),Ir(T+u,C+E),-x.angle);o.mutateElement(I,{x:k,y:L},{informMutation:a,isDragging:!1}),FC(I,o,r,{simultaneouslyUpdated:pG(y)})})}},ts=(e,n)=>{let o=hG(n).map(r=>gG(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!fG(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as wE,jsxs as IG}from"react/jsx-runtime";var vG=({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=Oe(),E=Mp(null),g=Mp(null),[b,w]=xG(o.toString()),y=Mp(null);y.current||(y.current={originalAppState:yE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),HC(()=>{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-_)>=GC)&&(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:UC.IMMEDIATELY}))},I=Mp({});return I.current.handleInputValue=x,HC(()=>{let T=E.current,C=I.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,y.current.originalElements,y.current.originalAppState),window.removeEventListener(ns.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(ns.POINTER_UP,C.onPointerUp,!1)}},[i]),i?IG("div",{className:bG("drag-input-container",!i&&"disabled"),"data-testid":e,children:[wE("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,wG(U)),z),new Map),D=r.map(z=>M.get(z.id)),_=yE(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:V=>w(String(V)),app:p,setAppState:u}),L=0))}P={x:z.clientX,y:z.clientY}},Y=()=>{window.removeEventListener(ns.POINTER_MOVE,F,!1),p.syncActionResult({captureUpdate:UC.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(ns.POINTER_UP,Y,!1)};I.current.onPointerMove=F,I.current.onPointerUp=Y,window.addEventListener(ns.POINTER_MOVE,F,!1),window.addEventListener(ns.POINTER_UP,Y,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?wE(xd,{icon:n}):e}),wE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===yG.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=yE(c)},onBlur:T=>{b?i&&x(T.target.value,y.current.originalElements,y.current.originalAppState):w(o.toString())},disabled:!i})]}):null},gt=vG;import{jsx as kG}from"react/jsx-runtime";var SG=15,CG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!TG(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=WC(o);r.mutateElement(l,{angle:E}),XC(l,r,i.state);let g=VC(l,a);g&&!YC(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(KC(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=We(m,SG)),m=m<0?m+360:m;let p=WC(m);r.mutateElement(l,{angle:p}),XC(l,r,i.state);let u=VC(l,a);u&&!YC(l)&&r.mutateElement(u,{angle:p})}},PG=({element:e,scene:n,appState:t,property:o})=>kG(gt,{label:"A",icon:Yc,value:Math.round(KC(e.angle)%360*100)/100,elements:[e],dragInputCallback:CG,editable:Vt(e,"angle"),scene:n,appState:t,property:o}),$C=PG;import{jsx as AG}from"react/jsx-runtime";var ZC=5,MG=({property:e,scene:n,appState:t,setAppState:o})=>AG(gt,{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?We(l.gridStep+ZC*Math.sign(i),ZC):l.gridStep+i),c?(c=ox(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),jC=MG;import{clamp as Ap,round as vE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Dp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as qC,getNonDeletedElements as DG,getUncroppedWidthAndHeight as eP}from"@excalidraw/element";import{resizeSingleElement as JC}from"@excalidraw/element";import{isImageElement as tP}from"@excalidraw/element";import{isFrameLikeElement as IE}from"@excalidraw/element";import{getElementsInResizingFrame as TE}from"@excalidraw/element";import{replaceAllElementsInFrame as nP}from"@excalidraw/element";import{jsx as BG}from"react/jsx-runtime";var QC=10,LG=e=>e.type==="image",_G=({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||LG(u),b=u.width/u.height;if(s.croppingElementId===u.id){let w=p.get(u.id);if(!w||!tP(w)||!w.crop)return;let y=w.crop,x={...y},I=w.scale[0]===-1,T=w.scale[1]===-1,{width:C,height:P}=eP(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=qC*M,F=qC*D;if(i!==void 0){if(a==="width"){let G=i*M,re=Ap(G,L,_);x={...x,width:re,x:I?y.x+y.width-re:y.x}}else if(a==="height"){let G=i*D,re=Ap(G,F,k);x={...x,height:re,y:T?y.y+y.height-re: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=Ap(y.width+Y,L,_),V=Ap(y.height+z,L,k);x={...y,x:I?y.x+y.width-U:y.x,y:T?y.y+y.height-V:y.y,width:U,height:V},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,Dp),y=Math.max(a==="height"?i:g?i/b:u.height,Dp);if(JC(w,y,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),IE(E)){let x=TE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),I=nP(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=We(x,QC):x=Math.round(x));let I=Math.max(0,u.height+y);if(a==="height"&&(r?I=We(I,QC):I=Math.round(I)),g&&(a==="width"?I=Math.round(x/b*100)/100:x=Math.round(I*b*100)/100),I=Math.max(Dp,I),x=Math.max(Dp,x),JC(x,I,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),IE(E)){let T=DG(TE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},RG=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&IE(a)){let s=TE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=nP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},NG=({property:e,element:n,scene:t,appState:o})=>{let r=vE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&tP(n)&&n.crop){let{width:i,height:a}=eP(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=vE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=vE(n.crop.height*s,2)}}return BG(gt,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:_G,value:r,editable:Vt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:RG})},SE=NG;import{getBoundTextElement as FG,redrawTextBoundingBox as OG}from"@excalidraw/element";import{hasBoundTextElement as zG,isTextElement as rP}from"@excalidraw/element";import{jsx as WG}from"react/jsx-runtime";var oP=4,GG=4,HG=({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||!rP(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),oP);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,oP),t&&(l=We(l,GG))}l&&(r.mutateElement(s,{fontSize:l}),OG(s,r.getContainerElement(s),r))}},UG=({element:e,scene:n,appState:t,property:o})=>{let r=rP(e)?e:zG(e)?FG(e,n.getNonDeletedElementsMap()):null;return r?WG(gt,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:HG,icon:zr,appState:t,scene:n,property:o}):null},iP=UG;import{degreesToRadians as aP,radiansToDegrees as cP}from"@excalidraw/math";import{getBoundTextElement as sP}from"@excalidraw/element";import{isArrowElement as lP}from"@excalidraw/element";import{isInGroup as CE}from"@excalidraw/element";import{jsx as KG}from"react/jsx-runtime";var VG=15,YG=({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&&!CE(c)&&Vt(c,r)),l=n.filter(c=>!CE(c)&&Vt(c,r));if(o!==void 0){let c=aP(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=sP(d,a);m&&!lP(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(cP(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=We(E,VG)),E=E<0?E+360:E;let g=aP(E);i.mutateElement(d,{angle:g});let b=sP(d,a);b&&!lP(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},XG=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!CE(l)&&Vt(l,"angle")),i=r.map(l=>Math.round(cP(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Vt(l,"angle"));return KG(gt,{label:"A",icon:Yc,value:a,elements:e,dragInputCallback:YG,editable:s,appState:t,scene:n,property:o})},dP=XG;import{pointFrom as hP}from"@excalidraw/math";import{useMemo as ZG}from"react";import{MIN_WIDTH_OR_HEIGHT as Tr}from"@excalidraw/common";import{getElementsInResizingFrame as PE,getNonDeletedElements as jG,isFrameLikeElement as kE,replaceAllElementsInFrame as EP,updateBoundElements as qG}from"@excalidraw/element";import{rescalePointsInElement as JG,resizeSingleElement as gP}from"@excalidraw/element";import{getBoundTextElement as QG,handleBindTextResize as eH}from"@excalidraw/element";import{isTextElement as bP}from"@excalidraw/element";import{MIME_TYPES as ui}from"@excalidraw/common";import{getNonDeletedElements as mP}from"@excalidraw/element";var Lp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=mP(Nr(e,null,{deleteInvisibleElements:!0})),l=ki(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return Lc(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}})},pP=async e=>{let{mimeType:n=ui.png,quality:t}=e;n===ui.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ui.png}" mimeType`),n==="image/jpg"&&(n=ui.jpg),n===ui.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ui.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Lp(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===ui.png&&e.appState?.exportEmbedScene&&(a=await gx({blob:a,metadata:xs(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},uP=async({elements:e,appState:n=Xo(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=mP(Nr(e,null,{deleteInvisibleElements:!0})),d={...ki(n,null),exportPadding:o};return Rr(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},$G=async e=>{if(e.type==="svg"){let n=await uP(e);await To(n.outerHTML)}else if(e.type==="png")await qd(pP(e));else if(e.type==="json")await $d(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as nNe}from"@excalidraw/element";import{getCommonBounds as _p}from"@excalidraw/element";import{jsx as aH}from"react/jsx-runtime";var os=10,tH=(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,...JG(o,a,s,!1),...bP(o)?{fontSize:o.fontSize*t}:{}}},nH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=tH(e,n,o,i);s.mutateElement(r,c);let d=QG(i,a);if(d){let m=d.fontSize*o;qG(r,s);let p=l.get(d.id);p&&bP(p)&&(s.mutateElement(p,{fontSize:m}),eH(r,s,t==="width"?"e":"s",!0))}},fP=(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];nH(r[0],r[1],i,d,u,p,l,c)}},oH=({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=ts(n,o);if(i!==void 0){for(let g of m){let b=es(g,d,t);if(b.length>1){let w=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,T,C]=_p(y),P=T-x,M=C-I,D=P/M,_=Math.max(Tr,s==="width"?Math.max(0,i):P),k=Math.max(Tr,s==="height"?Math.max(0,i):M);fP(_,k,M,D,hP(x,I),s,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Vt(y,s)){let I=s==="width"?Math.max(0,i):y.width;s==="width"&&(r?I=We(I,os):I=Math.round(I));let T=s==="height"?Math.max(0,i):y.height;if(s==="height"&&(r?T=We(T,os):T=Math.round(T)),I=Math.max(Tr,I),T=Math.max(Tr,T),gP(I,T,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),kE(y)){let C=PE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()),P=EP(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=es(g,d,t);if(b.length>1){let w=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,T,C]=_p(y),P=T-x,M=C-I,D=P/M,_=Math.max(0,P+p);s==="width"&&(r?_=We(_,os):_=Math.round(_));let k=Math.max(0,M+u);s==="height"&&(r?k=We(k,os):k=Math.round(k)),_=Math.max(Tr,_),k=Math.max(Tr,k),fP(_,k,M,D,hP(x,I),s,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Vt(y,s)){let I=Math.max(0,x.width+p);s==="width"&&(r?I=We(I,os):I=Math.round(I));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=We(T,os):T=Math.round(T)),I=Math.max(Tr,I),T=Math.max(Tr,T),gP(I,T,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),kE(y)){let C=jG(PE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},rH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&kE(a)){let s=PE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=EP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},iH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=ZG(()=>o.map(c=>{let d=es(c,t);if(d.length>1){let[p,u,E,g]=_p(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 aH(gt,{label:e==="width"?"W":"H",elements:n,dragInputCallback:oH,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:rH})},ME=iH;import{getBoundTextElement as sH,redrawTextBoundingBox as xP}from"@excalidraw/element";import{hasBoundTextElement as lH,isTextElement as cH}from"@excalidraw/element";import{isInGroup as dH}from"@excalidraw/element";import{jsx as gH}from"react/jsx-runtime";var yP=4,mH=4,pH=(e,n)=>e.reduce((t,o)=>{if(!o||dH(o))return t;if(cH(o))return t.push(o),t;if(lH(o)){let r=sH(o,n);if(r)return t.push(r),t}return t},[]),uH=({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),yP);for(let l of a)r.mutateElement(l,{fontSize:s}),xP(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,yP);t&&(E=We(E,mH)),r.mutateElement(d,{fontSize:E}),xP(d,r.getContainerElement(d),r)}r.triggerUpdate()}},hH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=pH(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 gH(gt,{label:"F",icon:zr,elements:i,dragInputCallback:uH,value:s,editable:l,scene:n,property:o,appState:t})},wP=hH;import{pointFrom as Sr,pointRotateRads as Rp}from"@excalidraw/math";import{useMemo as fH}from"react";import{isTextElement as EH}from"@excalidraw/element";import{getCommonBounds as AE}from"@excalidraw/element";import{jsx as vH}from"react/jsx-runtime";var bH=(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]=Rp(Sr(l.x,l.y),Sr(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;pi(u,E,l,i,a,r,!1)}},xH=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=AE(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&&(!EH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,w]=Rp(Sr(u.x,u.y),Sr(E,g),u.angle);pi(b+c,w+d,p,r,i,o,!1)}}},yH=({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 ts(n,s)){let E=es(u,c,t);if(E.length>1){let[g,b,,]=AE(E.map(x=>x.latest));xH(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&&Vt(b,i)){let[w,y]=[g.x+g.width/2,g.y+g.height/2],[x,I]=Rp(Sr(g.x,g.y),Sr(w,y),g.angle);pi(i==="x"?r:x,i==="y"?r:I,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?We(e,Ql):e;bH(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},wH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=fH(()=>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]=AE(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]=Rp(Sr(d.x,d.y),Sr(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 vH(gt,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:yH,value:s,property:e,scene:r,appState:i})},DE=wH;import{clamp as ec,pointFrom as Np,pointRotateRads as IP,round as vP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as IH,getUncroppedWidthAndHeight as TH}from"@excalidraw/element";import{isImageElement as TP}from"@excalidraw/element";import{jsx as PH}from"react/jsx-runtime";var SH=({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]=IP(Np(m.x,m.y),Np(p,u),m.angle);if(l.croppingElementId===m.id){let I=d.get(m.id);if(!I||!TP(I)||!I.crop)return;let T=I.crop,C=T,P=I.scale[0]===-1,M=I.scale[1]===-1,{width:D,height:_}=TH(I);if(i!==void 0){if(a==="x"){let F=i*(T.naturalWidth/D);P?C={...T,x:ec(T.naturalWidth-F-T.width,0,T.naturalWidth-T.width)}:C={...T,x:ec(i*(T.naturalWidth/D),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:ec(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:ec(T.x+k,0,T.naturalWidth-T.width),y:ec(T.y+L,0,T.naturalHeight-T.height)},s.mutateElement(I,{crop:C});return}if(i!==void 0){pi(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?We(m.x+b,Ql):E+b):E,x=a==="y"?Math.round(r?We(m.y+w,Ql):g+w):g;pi(y,x,m,s,c.state,o)},CH=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=IP(Np(n.x,n.y),Np(n.x+n.width/2,n.y+n.height/2),n.angle),a=vP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&TP(n)&&n.crop){let s=IH(n);s&&(a=vP(e==="x"?s.x:s.y,2))}return PH(gt,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:SH,scene:t,value:a,property:e,appState:o})},LE=CH;import{Fragment as NE,jsx as ne,jsxs as Yt}from"react/jsx-runtime";var BH=50,tc=e=>{let n=Qn(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=hr(e.app);return ne(FH,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},ze=({children:e,columns:n=1,heading:t,style:o,...r})=>ne("div",{className:kH("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});ze.displayName="StatsRow";var Fp=({children:e,order:n,style:t,...o})=>ne("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Fp.displayName="StatsRows";tc.StatsRow=ze;tc.StatsRows=Fp;var FH=DH(({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=Oe(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&RE(m),E=u?_H(m):null,[g,b]=AH({width:0,height:0}),w=_E(()=>MH(I=>{let T=LH(I);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},BH),[]);CP(()=>{w(l)},[i,l,w]),CP(()=>()=>w.cancel(),[w]);let y=_E(()=>ts(o,r),[o,r]),x=_E(()=>RH(o),[o]);return ne("div",{className:"exc-stats",children:Yt(Ue,{padding:3,children:[Yt("div",{className:"title",children:[ne("h2",{children:f("stats.title")}),ne("div",{className:"close",onClick:n,children:an})]}),Yt(Vs,{label:ne("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Bp.generalStats),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Bp.generalStats}})),children:[Yt(Fp,{children:[ne(ze,{heading:!0,children:f("stats.scene")}),Yt(ze,{columns:2,children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:l.length})]}),Yt(ze,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:g.width})]}),Yt(ze,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:g.height})]}),a&&Yt(NE,{children:[ne(ze,{heading:!0,children:"Canvas"}),ne(ze,{children:ne(jC,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&ne("div",{id:"elementStats",style:{marginTop:12},children:ne(Vs,{label:ne("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Bp.elementProperties),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Bp.elementProperties}})),children:Yt(Fp,{children:[m&&Yt(NE,{children:[u&&ne(ze,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&RE(m)&&E&&Yt(ze,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:SP(E.width,2)})]}),r.croppingElementId&&RE(m)&&E&&Yt(ze,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:SP(E.height,2)})]}),ne(ze,{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(ze,{children:ne(LE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),ne(ze,{children:ne(LE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),ne(ze,{children:ne(SE,{property:"width",element:m,scene:s,appState:r})}),ne(ze,{children:ne(SE,{property:"height",element:m,scene:s,appState:r})}),ne(ze,{children:ne($C,{property:"angle",element:m,scene:s,appState:r})}),ne(ze,{children:ne(iP,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Yt(NE,{children:[NH(p)&&ne(ze,{heading:!0,children:f("element.group")}),Yt(ze,{columns:2,style:{margin:"0.3125rem 0"},children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:o.length})]}),ne(ze,{children:ne(DE,{property:"x",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(ze,{children:ne(DE,{property:"y",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(ze,{children:ne(ME,{property:"width",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(ze,{children:ne(ME,{property:"height",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(ze,{children:ne(dP,{property:"angle",elements:p,scene:s,appState:r})}),ne(ze,{children:ne(wP,{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 ZH,useEffect as kP,useState as MP}from"react";import{normalizeLink as jH,KEYS as zE}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as qH,getLinkIdAndTypeFromSelection as JH}from"@excalidraw/element";import OH from"clsx";import{jsx as Op,jsxs as GH}from"react/jsx-runtime";var zH=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return GH("button",{className:OH("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Op("div",{style:a?{visibility:"hidden"}:{},children:o}),Op("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Op("div",{style:{position:"absolute",inset:0},children:Op(xo,{})})]})},BE=zH;import FE from"clsx";import{forwardRef as VH,useRef as YH,useImperativeHandle as XH,useLayoutEffect as KH,useState as $H}from"react";import HH from"clsx";import{composeEventHandlers as UH}from"@excalidraw/common";import{jsx as WH}from"react/jsx-runtime";var vn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>WH("button",{onClick:UH(i.onClick,a=>{n()}),type:e,className:HH("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as OE,jsxs as PP}from"react/jsx-runtime";var zp=VH(({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=YH(null);XH(p,()=>u.current),KH(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=$H(!1);return PP("div",{className:FE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&OE("div",{className:"ExcTextField__label",children:n}),PP("div",{className:FE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[OE("input",{className:FE({"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&&OE(vn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?e0:Hr})]})]})});import{jsx as rs,jsxs as Gp}from"react/jsx-runtime";var QH=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=qH})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=MP(a),[c,d]=MP(!1);kP(()=>{let p=ce(i,t),u=a;if(p.length>0&&r){let E=JH(p,t);E&&(u=jH(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=ZH(()=>{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 kP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===zE.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===zE.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),Gp("div",{className:"ElementLinkDialog",children:[Gp("div",{className:"ElementLinkDialog__header",children:[rs("h2",{children:f("elementLink.title")}),rs("p",{children:f("elementLink.desc")})]}),Gp("div",{className:"ElementLinkDialog__input",children:[rs(zp,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===zE.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&rs(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:Or})]}),Gp("div",{className:"ElementLinkDialog__actions",children:[rs(BE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),rs(BE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},AP=QH;import eU,{useState as tU}from"react";import{Fragment as nU,jsx as GE}from"react/jsx-runtime";var DP=({children:e,onClose:n})=>{let[t,o]=tU(!!e),{container:r}=Ne(),i=eU.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return GE(nU,{children:t&&GE(wn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:GE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import HE from"clsx";import Fn from"react";import{MIME_TYPES as LP,sceneCoordsToViewportCoords as UE}from"@excalidraw/common";import{getCommonBounds as BP,isInitializedImageElement as _P,ShapeCache as oU}from"@excalidraw/element";import{Fragment as lU,jsx as kt,jsxs as hi}from"react/jsx-runtime";var rU=kt("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:kt("path",{d:"M8 5v14l11 -7z"})}),iU=hi("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[kt("path",{d:"M8 5v14"}),kt("path",{d:"M16 5v14"})]}),aU=76,FP=4,nc=aU+FP,RP=8,gi=8,sU=(e,n)=>{let t=n/2;return Math.min(Math.max(e,t+gi),window.innerWidth-t-gi)},NP=(e,n)=>{let[,,t,o]=BP([e]),r=UE({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)}},OP=({app:e,files:n,setAppState:t})=>{let o=Qn(),[,r]=Fn.useReducer(T=>T+1,0),[i,a]=Fn.useState(0),[s,l]=Fn.useState(!1),c=Fn.useRef(null),d=Fn.useRef(null),m=Fn.useRef(null),p=Fn.useRef(null),u=Fn.useRef(null),E=Fn.useRef(!1),[g,b]=Fn.useState(null);Fn.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(),_=sU(M.left+M.width/2,D.width),k=T==="gifSpeedPicker"?Math.max(gi,M.top-D.height-gi):Math.min(window.innerHeight-D.height-gi,M.bottom+gi),L={left:_,top:Math.max(gi,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)=>{oU.delete(T),e.scene.mutateElement(T,{gifPlayback:C}),e.scheduleUpdate(),t({}),r(),C.playing&&e.ensureGifPlaybackLoop()},y=e.scene.getNonDeletedElements().filter(T=>_P(T)&&!o.selectedElementIds[T.id]&&n[T.fileId]?.mimeType===LP.gif&&e.imageCache.get(T.fileId)?.gifDecodeStatus==="deferred").map(T=>{let C=NP(T,o);return kt("span",{className:"gif-playback-controls gif-playback-controls__deferred-badge",role:"img","aria-label":"GIF paused",style:C,children:_x},T.id)}),x=e.scene.getSelectedElements(o);return hi(lU,{children:[y,(()=>{if(x.length!==1)return null;let T=x[0];if(!_P(T)||n[T.fileId]?.mimeType!==LP.gif)return null;let C=e.imageCache.get(T.fileId),P=C?.gif,[M,,D,_]=BP([T]),k=UE({sceneX:M,sceneY:_},o),F=UE({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=NP(T,o);return kt("div",{className:"gif-playback-controls gif-playback-controls--deferred",style:K,onPointerDown:Ie=>Ie.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 V=T.gifPlayback??{frameIndex:0,speed:1,playing:!1},G=e.state,re=e.getGifPlaybackFrameIndex(T)??V.frameIndex,B=Math.min(Math.max(re,0),U-1),W=Math.min(G.height-120,z+48),ue=Math.max(12,z-52),Ee=K=>{let Ie=(K+U)%U;e.setGifPlaybackFrameIndex(T,Ie),w(T,{...V,frameIndex:Ie,playing:!1})},le=K=>{K.stopPropagation(),Ee(B+(K.deltaY<0?1:-1))},he=K=>{e.setGifPlaybackFrameIndex(T,B),w(T,{...V,frameIndex:B,playing:K})},ge=[.25,.5,.75,1,1.25,1.5,1.75,2,4],se=K=>{let Ie=ge.indexOf(K);return Ie!==-1?Ie:ge.reduce((At,fs,Cc)=>Math.abs(fs-K)<Math.abs(ge[At]-K)?Cc:At,0)},xe=K=>{w(T,{...V,speed:K})},it=K=>{let Ie=se(V.speed);xe(ge[Math.min(Math.max(Ie+K,0),ge.length-1)])},$e=Number.isInteger(V.speed)?`${V.speed}`:`${V.speed}`,ke=U*nc-FP,Zt=Math.min(Math.max(G.width*.9,1),ke),Ho=Math.max(ke-Zt,0),Uo=Math.min(i,Ho),Wo=Math.max(Math.floor(Uo/nc)-RP,0),Ii=Math.ceil(Zt/nc)+RP*2,gs=Math.min(Wo+Ii,U),ho=P.frames.slice(Wo,gs),on=K=>{K.pointerType!=="mouse"||K.button!==0||(u.current={pointerId:K.pointerId,startClientX:K.clientX,startScrollLeft:K.currentTarget.scrollLeft,didDrag:!1},K.stopPropagation())},Vo=K=>{let Ie=u.current;if(!Ie||Ie.pointerId!==K.pointerId)return;let At=K.clientX-Ie.startClientX;!Ie.didDrag&&Math.abs(At)<=3||(Ie.didDrag||(Ie.didDrag=!0,K.currentTarget.setPointerCapture?.(K.pointerId),l(!0)),K.currentTarget.scrollLeft=Ie.startScrollLeft-At,a(K.currentTarget.scrollLeft),K.preventDefault(),K.stopPropagation())},Eu=K=>{let Ie=u.current;!Ie||Ie.pointerId!==K.pointerId||(E.current=Ie.didDrag,u.current=null,K.currentTarget.hasPointerCapture?.(K.pointerId)&&K.currentTarget.releasePointerCapture(K.pointerId),l(!1),K.stopPropagation())},Ti=K=>{let Ie=u.current;!Ie||Ie.pointerId!==K.pointerId||(u.current=null,l(!1),K.stopPropagation())},go=K=>{K.pointerType!=="mouse"&&K.stopPropagation()};return hi("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:ue},children:ge.map(K=>{let Ie=Number.isInteger(K)?`${K}`:`${K}`;return hi("button",{type:"button",className:HE("gif-speed-picker__speed",{"gif-speed-picker__speed--selected":K===V.speed}),onClick:()=>xe(K),title:`${Ie}x`,children:["x",Ie]},K)})}),hi("div",{className:"gif-playback-controls__bar",children:[hi("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(),it(K.deltaY<0?1:-1)},title:"Speed",children:["x",$e]}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>Ee(B-1),onWheel:le,title:"Previous frame",children:Z1}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>he(!V.playing),onWheel:le,title:V.playing?"Pause":"Play",children:V.playing?iU:rU}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>Ee(B+1),onWheel:le,title:"Next frame",children:j1}),kt("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--frames",ref:d,onClick:()=>{o.openPopup!=="gifFrameGallery"&&a(Math.max(B*nc-Zt/2,0)),t({openPopup:o.openPopup==="gifFrameGallery"?null:"gifFrameGallery"})},onWheel:le,title:"Frames",children:q1})]}),o.openPopup==="gifFrameGallery"&&kt("div",{className:HE("gif-frame-gallery",{"gif-frame-gallery--dragging":s}),style:{...g??{left:Y,top:W},width:Zt},ref:K=>{p.current=K,K&&K.scrollLeft!==Uo&&(K.scrollLeft=Uo)},onScroll:K=>{a(K.currentTarget.scrollLeft)},onPointerDownCapture:go,onPointerMoveCapture:go,onPointerUpCapture:go,onPointerCancelCapture:go,onPointerDown:on,onPointerMove:Vo,onPointerUp:Eu,onPointerCancel:Ti,onLostPointerCapture:Ti,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:ke},children:ho.map((K,Ie)=>{let At=Wo+Ie;return hi("button",{type:"button",className:HE("gif-frame-gallery__frame",{"gif-frame-gallery__frame--selected":At===B}),style:{left:At*nc},onClick:()=>Ee(At),title:`Frame ${At+1}`,children:[kt("canvas",{width:K.width,height:K.height,ref:fs=>{fs?.getContext("2d")?.drawImage(K,0,0)}}),kt("span",{children:At+1})]},At)})})})]})})()]})};import zP,{useMemo as fU}from"react";import GP from"clsx";import{isDarwin as HP,isFirefox as EU,isWindows as bU}from"@excalidraw/common";import{KEYS as is}from"@excalidraw/common";import{SHAPES as xU}from"@excalidraw/element/shapes";import{isFirefox as cU,KEYS as WE}from"@excalidraw/common";import{SHAPES as dU}from"@excalidraw/element/shapes";import{Fragment as gU,jsx as Ve,jsxs as fi}from"react/jsx-runtime";var mU=e=>fi(gU,{children:[Ve("h3",{children:e.title}),Ve("div",{className:"HelpDialog__islands-container",children:e.children})]}),VE=e=>fi("div",{className:`HelpDialog__island ${e.className}`,children:[Ve("h4",{className:"HelpDialog__island-title",children:e.caption}),Ve("div",{className:"HelpDialog__island-content",children:e.children})]});function*pU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var uU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),It=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ve(hU,{children:uU(a)},a)));return fi("div",{className:"HelpDialog__shortcut",children:[Ve("div",{children:e}),Ve("div",{className:"HelpDialog__key-container",children:[...pU(o,t?f("helpDialog.or"):null)]})]})},hU=e=>Ve("kbd",{className:"HelpDialog__key",...e});function YE(){return fi(mU,{title:f("helpDialog.shortcuts"),children:[fi(VE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ve(It,{label:f("toolBar.hand"),shortcuts:[WE.H]}),dU.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ve(It,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ve(It,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ve(It,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),fi(VE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ve(It,{label:f("helpDialog.smartZoom"),shortcuts:[WE.F]}),Ve(It,{label:f("helpDialog.dragToZoom"),shortcuts:[`${WE.Z}+${f("helpDialog.drag")}`]}),Ve(It,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),fi(VE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ve(It,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ve(It,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ve(It,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ve(It,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(lr||cU)&&Ve(It,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ve(It,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ve(It,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ve(It,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ve(It,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ve(It,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as WP,jsx as j,jsxs as Ei}from"react/jsx-runtime";var yU=e=>Ei(WP,{children:[j("h3",{children:e.title}),j("div",{className:"HelpDialog__islands-container",children:e.children})]}),XE=e=>Ei("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*wU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var vU=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(IU,{children:vU(a)},a)));return Ei("div",{className:"HelpDialog__shortcut",children:[j("div",{children:e}),j("div",{className:"HelpDialog__key-container",children:[...wU(o,t?f("helpDialog.or"):null)]})]})},IU=e=>j("kbd",{className:"HelpDialog__key",...e}),UP=({onClose:e})=>{let[n,t]=zP.useState(!1),o=zP.useCallback(()=>{e&&e()},[e]),r=fU(()=>n?j("button",{className:GP("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):j("button",{className:GP("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return j(WP,{children:j(wn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?Ei(yU,{title:f("helpDialog.shortcuts"),children:[Ei(XE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[j(J,{label:f("toolBar.hand"),shortcuts:[is.H]}),xU.map(({value:i,key:a})=>j(J,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),j(J,{label:f("toolBar.frame"),shortcuts:[is.F]}),j(J,{label:f("labels.eyeDropper"),shortcuts:[is.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:[is.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})]}),Ei(XE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[j(J,{label:f("helpDialog.smartZoom"),shortcuts:[is.F]}),j(J,{label:f("helpDialog.dragToZoom"),shortcuts:[`${is.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("stats.fullTitle"),shortcuts:[N("Alt+/")]}),j(J,{label:f("search.title"),shortcuts:[je("searchMenu")]})]}),Ei(XE,{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")}`)]}),(lr||EU)&&j(J,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),j(J,{label:f("labels.sendToBack"),shortcuts:[HP?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),j(J,{label:f("labels.bringToFront"),shortcuts:[HP?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+R")]}),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:bU?[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(YE,{})})})};import{useEffect as XP,useRef as KP,useState as bi}from"react";import{DEFAULT_EXPORT_PADDING as MU,EXPORT_IMAGE_TYPES as KE,isFirefox as AU,EXPORT_SCALES as DU,cloneJSON as $P}from"@excalidraw/common";import{useCallback as TU,useRef as SU,useState as CU}from"react";var PU=2e3,VP=()=>{let[e,n]=CU(null),t=SU(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},PU)},r=TU(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import kU from"clsx";import{jsx as YP}from"react/jsx-runtime";var oc=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>YP("div",{className:kU("Switch",{toggled:t,disabled:r}),children:YP("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});import{jsx as Ge,jsxs as Cr}from"react/jsx-runtime";var LU=()=>Cr("div",{children:[Ge("h3",{children:f("canvasError.cannotShowPreview")}),Ge("p",{children:Ge("span",{children:f("canvasError.canvasTooBig")})}),Cr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),_U=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=Le(n,e),[l,c]=bi(i),[d,m]=bi(s),[p,u]=bi(e.exportBackground),[E,g]=bi(e.exportEmbedScene),[b,w]=bi(e.exportScale),y=KP(null),x=KP(0),[I,T]=bi(null),{onCopy:C,copyStatus:P,resetCopyStatus:M}=VP();XP(()=>{M()},[l,p,a,b,E,M]);let{exportedElements:D,exportingFrame:_}=$r(n,e,d);return XP(()=>{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 Lp({elements:D,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:MU,maxWidthOrHeight:Math.max(L,F),exportingFrame:_}).then(async U=>{if(!z()){try{await Is(U)}catch(V){throw V.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):V}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]),Cr("div",{className:"ImageExportModal",children:[Ge("h3",{children:f("imageExportDialog.header")}),Cr("div",{className:"ImageExportModal__preview",children:[Ge("div",{className:"ImageExportModal__preview__canvas",ref:y,children:I&&Ge(LU,{})}),Ge("div",{className:"ImageExportModal__preview__filename",children:!Pi&&Ge("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction(eg,"ui",k.target.value)}})})]}),Cr("div",{className:"ImageExportModal__settings",children:[Ge("h3",{children:f("imageExportDialog.header")}),s&&Ge(rc,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ge(oc,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),Ge(rc,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ge(oc,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(tg,"ui",k)}})}),Ge(rc,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ge(oc,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(Sw,"ui",k)}})}),Ge(rc,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ge(oc,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(Qd,"ui",k)}})}),Ge(rc,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Ge(Ip,{name:"exportScale",value:b,onChange:k=>{w(k),o.executeAction(Iw,"ui",k)},choices:DU.map(k=>({value:k,label:`${k}\xD7`}))})}),Cr("div",{className:"ImageExportModal__settings__buttons",children:[Ge(wr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(KE.png,D,{exportingFrame:_}),icon:Zu,children:f("imageExportDialog.button.exportToPng")}),Ge(wr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(KE.svg,D,{exportingFrame:_}),icon:Zu,children:f("imageExportDialog.button.exportToSvg")}),(lr||AU)&&Ge(wr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(KE.clipboard,D,{exportingFrame:_}),C()},icon:X1,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},rc=({label:e,children:n,tooltip:t,name:o})=>Cr("div",{className:"ImageExportModal__settings__setting",title:e,children:[Cr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ge(pt,{label:t,long:!0,children:$1})]}),Ge("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),ZP=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=bi(()=>({appStateSnapshot:$P(n),elementsSnapshot:$P(e)}));return Ge(wn,{onCloseRequest:i,size:"wide",title:!1,children:Ge(_U,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import wW from"clsx";import{CANVAS_SEARCH_TAB as hk,DEFAULT_SIDEBAR as vW}from"@excalidraw/common";import RU from"clsx";import NU from"lodash.debounce";import{Fragment as BU,memo as FU,useEffect as ic,useMemo as jP,useRef as $E,useState as qP}from"react";import{CLASSES as OU,EVENT as zU,FONT_FAMILY as ZE,FRAME_STYLE as jE,getLineHeight as GU}from"@excalidraw/common";import{getCommonBounds as HU,isElementCompletelyInViewport as UU}from"@excalidraw/element";import{measureText as ac}from"@excalidraw/element";import{KEYS as as,randomInteger as JP,addEventListener as WU,getFontString as Hp}from"@excalidraw/common";import{newTextElement as VU}from"@excalidraw/element";import{isTextElement as nk,isFrameLikeElement as Up}from"@excalidraw/element";import{getDefaultFrameName as ok}from"@excalidraw/element/frame";import{Fragment as eW,jsx as ft,jsxs as On}from"react/jsx-runtime";var YU=Qe(""),qE=Qe(null),XU=350,rk=()=>{let e=St(),n=Oe(),t=$E(null),[o,r]=He(YU),i=o.trim(),[a,s]=qP(!1),[l,c]=qP({nonce:null,items:[]}),d=$E(null),m=$E(void 0),[p,u]=He(qE),E=e.scene.getNonDeletedElementsMap();ic(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,tk(i,e,(x,I)=>{c({nonce:JP(),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)};ic(()=>{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]),ic(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let I=e.state.zoom.value,T=VU({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:Up(x.element)?jE.nameFontSize:x.element.fontSize,fontFamily:Up(x.element)?ZE.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,M=P*I<C;if(!UU([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:HU([T]),fit:D,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),ic(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let w=Hi({goToNextItem:g,goToPreviousItem:b,searchMatches:l});ic(()=>{let x=I=>{if(I.key===as.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){I.preventDefault(),I.stopPropagation(),n({openSidebar:null});return}if(I[as.CTRL_OR_CMD]&&I.key===as.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===as.ENTER&&(I.stopPropagation(),w.goToNextItem()),I.key===as.ARROW_UP?(I.stopPropagation(),w.goToPreviousItem()):I.key===as.ARROW_DOWN&&(I.stopPropagation(),w.goToNextItem()))};return WU(window,zU.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 On("div",{className:"layer-ui__search",children:[On("div",{className:"layer-ui__search-header",children:[ft(zp,{className:OU.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:Jn,onChange:x=>{r(x),s(!0);let I=x.trim();tk(I,e,(T,C)=>{c({nonce:JP(),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}),ft(vn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:an})]}),On("div",{className:"layer-ui__search-count",children:[l.items.length>0&&On(eW,{children:[p!==null&&p>-1?On("div",{children:[p+1," / ",y]}):ft("div",{children:y}),On("div",{className:"result-nav",children:[ft(vn,{onSelect:()=>{g()},className:"result-nav-btn",children:Kc}),ft(vn,{onSelect:()=>{b()},className:"result-nav-btn",children:u0})]})]}),l.items.length===0&&i&&d.current&&ft("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),ft(ZU,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},QP=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 ft("div",{tabIndex:-1,className:RU("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ft("div",{className:"preview-text",children:n.flatMap((t,o)=>ft(BU,{children:o===2?ft("b",{children:t}):t},o))})})},KU=e=>{let n=jP(()=>e.matches.items.filter(o=>Up(o.element)),[e.matches]),t=jP(()=>e.matches.items.filter(o=>nk(o.element)),[e.matches]);return On("div",{className:"layer-ui__search-results",children:[n.length>0&&On("div",{className:"layer-ui__search-result-container",children:[On("div",{className:"layer-ui__search-result-title",children:[ft("div",{className:"title-icon",children:jn}),ft("div",{children:f("search.frames")})]}),n.map((o,r)=>ft(QP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&ft("div",{className:"layer-ui__divider"})]}),t.length>0&&On("div",{className:"layer-ui__search-result-container",children:[On("div",{className:"layer-ui__search-result-title",children:[ft("div",{className:"title-icon",children:Pn}),ft("div",{children:f("search.texts")})]}),t.map((o,r)=>ft(QP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},$U=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,ZU=FU(KU,$U),ek=(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}},jU=(e,n)=>{let t=e.split(`
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
- `)},qU=(e,n,t)=>{let r=jU(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=ac(u,Hp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let I=ac(m.line,Hp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-I.width)/2:e.width-I.width;g.width+=T}let{width:b,height:w}=ac(E,Hp(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},JU=(e,n,t,o)=>{let r=e.name??ok(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=Hp({fontSize:jE.nameFontSize,fontFamily:ZE.Assistant}),l=GU(ZE.Assistant),c=ac(a,s,l);a===""&&(c.width=0);let d=ac(i,s,l),m=c.width,p=-c.height-jE.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},QU=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),tk=NU((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>nk(p)),i=o.filter(p=>Up(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(QU(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=ek(E,u.index,e),b=qU(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??ok(p);for(;(u=s.exec(E))!==null;){let g=ek(E,u.index,e),b=JU(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)},XU);import uW from"clsx";import{useEffect as dk,useLayoutEffect as mk,useRef as ab,useState as hW,forwardRef as pk,useImperativeHandle as gW,useCallback as sk}from"react";import{CLASSES as fW,EVENT as lk,isDevEnv as EW,KEYS as bW,updateObject as xW}from"@excalidraw/common";import nW from"clsx";import{useContext as oW}from"react";import tW from"react";var Wp=tW.createContext({});import{jsx as JE,jsxs as ik}from"react/jsx-runtime";var QE=({children:e,className:n})=>{let t=be(),o=oW(Wp),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return ik("div",{className:nW("sidebar__header",n),"data-testid":"sidebar-header",children:[e,ik("div",{className:"sidebar__header__buttons",children:[r&&JE(pt,{label:f("labels.sidebarLock"),children:JE(vn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:Nx})}),JE(vn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:an})]})]})};QE.displayName="SidebarHeader";import{Tabs as rW}from"radix-ui";import{jsx as ak}from"react/jsx-runtime";var eb=({children:e,tab:n,onSelect:t,...o})=>ak(rW.Trigger,{value:n,asChild:!0,onSelect:t,children:ak("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});eb.displayName="SidebarTabTrigger";import{Tabs as iW}from"radix-ui";import{jsx as aW}from"react/jsx-runtime";var tb=({children:e,...n})=>aW(iW.List,{className:"sidebar-triggers",...n,children:e});tb.displayName="SidebarTabTriggers";import sW from"clsx";import{jsx as nb,jsxs as lW}from"react/jsx-runtime";var ob=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Oe(),d=ye().openSidebar?.name===e;return nb("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:lW("div",{className:sW("sidebar-trigger",a),style:s,children:[t&&nb("div",{children:t}),r&&nb("div",{className:"sidebar-trigger__label",children:r})]})})};ob.displayName="SidebarTrigger";import{Tabs as cW}from"radix-ui";import{jsx as dW}from"react/jsx-runtime";var rb=({children:e,...n})=>{let t=ye(),o=Oe();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return dW(cW.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};rb.displayName="SidebarTabs";import{Tabs as mW}from"radix-ui";import{jsx as pW}from"react/jsx-runtime";var ib=({tab:e,children:n,...t})=>pW(mW.Content,{...t,value:e,"data-testid":e,children:n});ib.displayName="SidebarTab";import{jsx as ck}from"react/jsx-runtime";import{createElement as yW}from"react";var sb=Qe(!1),uk=pk(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{EW()&&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=Oe(),l=Px(sb);mk(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=ab({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=xW(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=ab(null);gW(a,()=>d.current);let m=be(),p=sk(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Gi(d,sk(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),dk(()=>{let u=E=>{E.key===bW.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(lk.KEYDOWN,u),()=>{document.removeEventListener(lk.KEYDOWN,u)}},[p,o,m.canFitSidebar]),ck(Ue,{...i,className:uW(fW.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:ck(Wp.Provider,{value:c.current,children:n})})});uk.displayName="SidebarInner";var Pr=Object.assign(pk((e,n)=>{let t=ye(),{onStateChange:o}=e,r=ab(t.openSidebar);dk(()=>{(!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]=hW(!1);return mk(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?yW(uk,{...e,ref:n,key:e.name}):null}),{Header:QE,TabTriggers:tb,TabTrigger:eb,Tabs:rb,Tab:ib,Trigger:ob});Pr.displayName="Sidebar";import{jsx as ss,jsxs as IW}from"react/jsx-runtime";import{createElement as TW}from"react";var gk=mi("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=ot();return ss(n.In,{children:ss(Pr.Trigger,{...e,className:"default-sidebar-trigger",name:vW.name})})});gk.displayName="DefaultSidebarTrigger";var fk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=ot();return ss(n.In,{children:e})};fk.displayName="DefaultTabTriggers";var lb=Object.assign(mi("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=ye(),a=Oe(),s=i.openSidebar?.tab===hk,l=s?!1:t??i.defaultSidebarDockedPreference,c=!s&&t==null&&o!==!1;return TW(Pr,{...r,name:"default",key:"default",className:wW("default-sidebar",{"default-sidebar--search-only":s},n),docked:l,onDock:c?d=>{a({defaultSidebarDockedPreference:d}),o?.(d)}:void 0},IW(Pr.Tabs,{children:[!s&&ss(Pr.Header,{}),ss(Pr.Tab,{tab:hk,children:ss(rk,{})}),!s&&e]}))}),{Trigger:gk,TabTriggers:fk});import CW from"react";import{getFrame as PW}from"@excalidraw/common";import{jsx as SW}from"react/jsx-runtime";var cb={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"}},db=({children:e,color:n})=>SW("div",{className:"Card",style:{"--card-color":cb[n].base,"--card-color-darker":cb[n].darker,"--card-color-darkest":cb[n].darkest},children:e});import{Fragment as MW,jsx as zn,jsxs as Vp}from"react/jsx-runtime";var kW=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return zn("div",{className:"ExportDialog ExportDialog--json",children:Vp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Vp(db,{color:"lime",children:[zn("div",{className:"Card-icon",children:Jx}),zn("h2",{children:f("exportDialog.disk_title")}),Vp("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Pi&&r.renderAction("changeProjectName")]}),zn(Z,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(rl,"ui")}})]}),l&&Vp(db,{color:"pink",children:[zn("div",{className:"Card-icon",children:Ms}),zn("h2",{children:f("exportDialog.link_title")}),zn("div",{className:"Card-details",children:f("exportDialog.link_details")}),zn(Z,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Fe("export","link",`ui (${PW()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},Ek=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=CW.useCallback(()=>{a({openDialog:null})},[a]);return zn(MW,{children:n.openDialog?.name==="jsonExport"&&zn(wn,{onCloseRequest:s,title:f("buttons.export"),children:zn(kW,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import AW from"clsx";import{jsx as DW}from"react/jsx-runtime";var bk=e=>DW(Z,{className:AW("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:qn,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import Sk from"clsx";import{useState as WW}from"react";import{CANVAS_SEARCH_TAB as VW,DEFAULT_SIDEBAR as YW,KEYS as sc}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as LW,DEFAULT_SIDEBAR as _W}from"@excalidraw/common";import{isArrowElement as RW,isFlowchartNodeElement as NW,isImageElement as xk,isLinearElement as yk,isLineElement as BW,isTextBindableContainer as FW,isTextElement as OW}from"@excalidraw/element";import{isNodeInFlowchart as zW}from"@excalidraw/element";import{jsx as mb}from"react/jsx-runtime";var Se=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,GW=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar?.name===_W.name&&e.openSidebar.tab===LW&&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 yk(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:Se("Shift")}):xk(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&&OW(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&&xk(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(hr(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(yk(c[0]))return RW(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")}):BW(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&&FW(c[0])){let d=f("hints.bindTextToElement",{shortcut:Se("Enter")}),m=f("hints.createFlowchart",{shortcut:Se(["CtrlOrCmd","\u2191\u2193"])});return NW(c[0])?zW(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},wk=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=GW({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 mb("kbd",{children:c?c[1]:s},l)}return s});return mb("div",{className:"HintViewer",children:mb("span",{children:a})})};import HW from"clsx";import{jsx as UW}from"react/jsx-runtime";var vk=e=>UW(Z,{className:HW("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?Ko:bo,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 xi,jsx as ie,jsxs as Ro}from"react/jsx-runtime";var XW=(e,n)=>e==="image"&&n.tools?.image===!1,KW=({app:e,activeTool:n,type:t,shortcut:o})=>ie(pe.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:Ye[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??na(t),disabled:Je(e,t),children:f(`toolBar.${t}`)}),Ik=({app:e})=>ie(pe.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Ko:bo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:sc.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),$W=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Lt))return null;let t=je("objectsSnapMode");return ie(pe.Item,{onSelect:()=>e.executeAction(Lt,"ui"),icon:jo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},ZW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Lt))return null;let t=f("buttons.objectsSnapMode"),o=je("objectsSnapMode");return ie(Z,{type:"toggle",icon:jo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Lt,"ui")})},Tk=({actionManager:e,appState:n})=>{let t=f("search.title"),o=je("searchMenu");return ie(pe.Item,{onSelect:()=>e.executeAction(Pl,"ui"),icon:Jn,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===YW.name&&n.openSidebar.tab===VW,shortcut:o,children:t})},jW=({app:e})=>ie(Z,{type:"button",icon:Fi,title:`${f("labels.eyeDropper")} - ${sc.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":sc.I.toLocaleUpperCase(),keyBindingLabel:sc.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),qW=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=WW(!1),l=ct()==="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&&ea.includes(n.type);return Ro(pe,{open:a,children:[ie(pe.Trigger,{className:Sk("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?Ye[n.type].icon:c?jn:E?Zo:!r&&l&&d?Gr:m&&!e.props.isCollaborating?qn:u?Li:p?Zn:Ts}),ie(pe.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?Ro(xi,{children:[l&&ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Li,"data-testid":"toolbar-lasso",selected:u,disabled:Je(e,"lasso"),children:f("toolBar.lasso")}),ea.filter(b=>!XW(b,o)).map(b=>ie(KW,{app:e,activeTool:n,type:b},b)),ie("div",{className:"App-toolbar__dropdown-divider"}),ie(Tk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ie(xi,{children:ie(Ik,{app:e})})]}):Ro(xi,{children:[ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:jn,shortcut:sc.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:Je(e,"frame"),children:f("toolBar.frame")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Zo,"data-testid":"toolbar-embeddable",selected:E,disabled:Je(e,"embeddable"),children:f("toolBar.embeddable")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Gr,shortcut:na("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:Je(e,"autoshape"),children:f("toolBar.autoshape")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:qn,"data-testid":"toolbar-laser",selected:m,disabled:Je(e,"laser"),children:f("toolBar.laser")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Zn,"data-testid":"toolbar-bucketfill",selected:p,disabled:Je(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Li,"data-testid":"toolbar-lasso",selected:u,disabled:Je(e,"lasso"),children:f("toolBar.lasso")}),ie("div",{className:"App-toolbar__dropdown-divider"}),ie($W,{actionManager:i,app:e}),ie(Tk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ie(Ik,{app:e})]})})]})},Ck=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=be(),c=ct()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?ie(Gd,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?ie(tw,{...m}):ie(ew,{...m});return Ro(Ue,{padding:1,className:Sk("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[ie(wk,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,Ro(Bt.Row,{gap:c?.5:1,children:[!c&&ie(qa,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&Ro(xi,{children:[ie(vk,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),ie("div",{className:"App-toolbar__divider"})]}),ie(zd,{...m}),u,p?Ro(xi,{children:[ie(Zs,{...m}),ie(js,{...m}),ie(jW,{app:e}),o.tools?.image!==!1&&ie(qs,{...m}),ie(Js,{...m})]}):Ro(xi,{children:[ie($y,{...m}),ie(Zy,{...m}),ie(jy,{...m}),ie(qy,{...m}),ie(Jy,{...m}),c?ie(Hd,{...m}):ie(Zs,{...m}),ie(js,{...m}),o.tools?.image!==!1&&ie(qs,{...m}),ie(Js,{...m})]}),ie("div",{className:"App-toolbar__divider"}),ie(qW,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&Ro(xi,{children:[ie("div",{className:"App-toolbar__divider"}),ie(ZW,{actionManager:r,app:e})]})]})]})};import{Fragment as pb,jsx as te,jsxs as tn}from"react/jsx-runtime";var rV=({UIOptions:e})=>tn(Ft,{__fallback:!0,children:[te(Ft.DefaultItems.LoadScene,{}),te(Ft.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&te(Ft.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&te(Ft.DefaultItems.SaveAsImage,{}),te(Ft.DefaultItems.SearchMenu,{}),te(Ft.DefaultItems.Help,{}),te(Ft.Separator,{}),te(Ft.Group,{title:"Excalidraw links",children:te(Ft.DefaultItems.Socials,{})}),te(Ft.Separator,{}),te(Ft.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),te(Ft.DefaultItems.ChangeCanvasBackground,{})]}),iV=()=>tn(Pp,{__fallback:!0,children:[te(Pp.Actions.SaveToDisk,{}),te(Pp.Actions.ExportToImage,{})]}),aV=({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=be(),M=kn(),_=ct()==="compact",k=JT(),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]=He(Gt),U=()=>p.canvasActions.export?te(Ek,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,V=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:te(ZP,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),G=()=>tn("div",{style:{position:"relative"},children:[tn("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),te(k.MainMenuTunnel.Out,{}),te(k.DefaultSidebarTriggerTunnel.Out,{})]}),E&&te(k.WelcomeScreenMenuHintTunnel.Out,{})]}),re=()=>te(Kl,{heading:"selectedShapeActions",className:ls("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?te(Ue,{className:ls("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:te(ES,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):te(Ue,{className:QW.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:te(pS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),B=()=>{let le=w&&oV(n,r),he=w&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return te(bp,{side:"top",children:tn("div",{className:"App-menu App-menu_top",children:[tn(Bt.Col,{gap:L.menuTopGap,className:ls("App-menu_top__left"),children:[G(),w&&te("div",{className:ls("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:le&&re()}),w&&_&&!n.viewModeEnabled&&le&&te(qa,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),w&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&te(Kl,{heading:"shapes",className:"shapes-section",children:ge=>tn("div",{style:{position:"relative"},children:[E&&te(k.WelcomeScreenToolbarHintTunnel.Out,{}),te(Bt.Col,{gap:L.toolbarColGap,align:"start",children:tn(Bt.Row,{gap:L.toolbarRowGap,className:ls("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[te(Ck,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ge}),I&&te(Ue,{style:{marginLeft:L.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:te(bk,{title:f("toolBar.laser"),checked:n.activeTool.type===Pk.laser,onChange:()=>b.setActiveTool({type:Pk.laser}),isMobile:!0})})]})})]})}),tn("div",{className:ls("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(vp,{collaborators:n.collaborators,userToFollow:M.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),he&&te(tc,{app:b,onClose:()=>{e.executeAction(mr)},renderCustomStats:m})]})]})})},W=()=>te(lb,{}),ue=!1,Ee=tn(pb,{children:[g,w&&te(pb,{children:te(rV,{UIOptions:p})}),te(iV,{}),w&&n.isLoading&&te(up,{delay:250}),w&&n.errorMessage&&te(DP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),w&&Y&&P.formFactor!=="phone"&&te(F0,{colorPickerType:Y.colorPickerType,onCancel:()=>{z(null)},onChange:(le,he,ge,{altKey:se})=>{if(!(le!=="elementBackground"&&le!=="elementStroke"))if(ge.length){for(let xe of ge)tV(xe,eV(r),{[se&&Y.swapPreviewOnAlt?le==="elementBackground"?"strokeColor":"backgroundColor":le==="elementBackground"?"backgroundColor":"strokeColor"]:he}),nV.delete(xe);b.scene.triggerUpdate()}else o(le==="elementBackground"?{currentItemBackgroundColor:he}:{currentItemStrokeColor:he})},onSelect:(le,he)=>{z(ge=>ge?.keepOpenOnAlt&&he.altKey?ge:null),Y?.onSelect?.(le,he)}}),n.openDialog?.name==="help"&&te(UP,{onClose:()=>{o({openDialog:null})}}),w&&n.openDialog?.name==="elementLinkSelector"&&te(AP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),te(k.OverwriteConfirmDialogTunnel.Out,{}),V(),U(),w&&n.openDialog?.name==="charts"&&te(iC,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),w&&te(OP,{app:b,files:t,setAppState:o}),P.formFactor==="phone"&&te(KS,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:U,renderImageExportDialog:V,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:W,renderWelcomeScreen:E,defaultUIEnabled:w,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&tn(pb,{children:[M.viewportStatusFrame?.border&&te(dp,{border:M.viewportStatusFrame.border,style:ue?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),tn("div",{className:"layer-ui__wrapper",style:ue?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&te(k.WelcomeScreenCenterTunnel.Out,{}),B(),te(pC,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:w,zoomUIEnabled:y}),(n.toast||x&&n.scrolledOutside||M.viewportStatusFrame?.label)&&tn("div",{className:"floating-status-stack",children:[n.toast&&te(Yd,{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(le=>({...Si(r,le)}))},children:f("buttons.scrollBackToContent")}),M.viewportStatusFrame?.label&&te(mp,{label:M.viewportStatusFrame.label,border:M.viewportStatusFrame.border})]})]})]}),W()]});return te(hh.Provider,{value:n,children:te(F,{children:te(nE.Provider,{value:k,children:Ee})})})},kk=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},sV=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return Yp(kk(o),kk(a),{selectedElementIds:Yp,selectedGroupIds:Yp})&&Yp(r,s)},Mk=JW.memo(aV,sV);import{useEffect as lV,useRef as cV}from"react";import{jsx as Ak}from"react/jsx-runtime";var Dk=({trails:e})=>{let n=cV(null);return lV(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),Ak("div",{className:"SVGLayer",children:Ak("svg",{ref:n})})};import dV,{useEffect as Lk,useRef as _k}from"react";import{isShallowEqual as mV,sceneCoordsToViewportCoords as pV}from"@excalidraw/common";import{jsx as gV}from"react/jsx-runtime";var Rk="animateInteractiveScene",uV=e=>{let n=_k(!1),t=_k(null);return Lk(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&Gf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),Lk(()=>{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,pV({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},st.running(Rk)||st.start(Rk,({deltaTime:c,state:d})=>{let m=Gf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),gV("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")})},Nk=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,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}),hV=(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:mV(Nk(e.appState),Nk(n.appState)),ub=dV.memo(uV,hV);import Ok,{useEffect as Xp,useRef as lc}from"react";import{isShallowEqual as Bk}from"@excalidraw/common";import{hasActiveGifDecode as fV}from"@excalidraw/element";import{jsx as xV}from"react/jsx-runtime";var EV=e=>{let n=lc(null),t=lc(!1),o=lc(e),r=lc(()=>{}),i=lc(null);o.current=e;let a=Ok.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();hx({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}},ka());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=fV(s.visibleElements,s.renderConfig.imageCache);(p||u)&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,Xp(()=>{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]),Xp(()=>{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()}),Xp(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),Xp(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),xV("div",{className:"excalidraw__canvas-wrapper",ref:n})},Fk=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId,suggestedBinding:e.suggestedBinding}),bV=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:Bk(Fk(e.appState),Fk(n.appState))&&Bk(e.renderConfig,n.renderConfig),hb=Ok.memo(EV,bV);import{useEffect as CV,useRef as PV}from"react";import{throttleRAF as yV}from"@excalidraw/common";import{getTargetFrame as wV,isInvisiblySmallElement as vV,renderElement as IV,shouldApplyFrameClip as TV}from"@excalidraw/element";var zk=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Ac(e,i),d=Dc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(vV(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=wV(t,o,a);u&&TV(t,u,a,o)&&px(u,d,s,a)}IV(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},SV=yV(e=>{zk(e)}),Gk=(e,n)=>{if(n){SV(e);return}zk(e)};import{jsx as MV}from"react/jsx-runtime";var kV=e=>{let n=PV(null);return CV(()=>{n.current&&Gk({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},ka())}),MV("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})},Hk=kV;import AV from"clsx";import{useLayoutEffect as DV,useEffect as Uk,useRef as LV,useState as _V}from"react";import{ARROW_TYPE as Wk,EVENT as Kp}from"@excalidraw/common";import{jsx as FV}from"react/jsx-runtime";var Vk=700,RV=100,NV=16,BV=5*60*1e3,Xk=Qe(null),Yk=e=>e===Wk.elbow?Jo:e===Wk.round?Qo:qo,$p=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(Xk,{content:n,nonce:Math.random()}))});v(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<BV);v(this,"onArrowTypeCycled",n=>{this.show(Yk(n))});v(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?$o:Yk(this.app.state.currentItemArrowType))});this.app=n}},Kk=()=>{let[e,n]=He(Xk),t=St(),{container:o}=Ne(),r=LV(null),[i,a]=_V(!1),s=e?.nonce;return DV(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=sd({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:NV});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(Kp.POINTER_MOVE,c),()=>{window.removeEventListener(Kp.POINTER_MOVE,c)}},[s,o,t]),Uk(()=>()=>{n(null)},[n]),Uk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},Vk),c=window.setTimeout(()=>{n(null)},Vk+RV),d=()=>{n(null)};return window.addEventListener(Kp.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(Kp.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?FV("div",{ref:r,className:AV("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var Zp=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 OV,getElementsInGroup as zV,isNonDeletedElement as $k,selectGroupsFromGivenElements as GV}from"@excalidraw/element";import{sceneCoordsToViewportCoords as HV}from"@excalidraw/common";import{flushSync as UV}from"react-dom";import{jsx as VV}from"react/jsx-runtime";var WV=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!$k(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&$k(t)?t:null,r=o?[o]:zV(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=OV(r),{x:s,y:l}=HV({sceneX:i,sceneY:a},e.state);return VV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{UV(()=>{let c=GV(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(ml)},title:f("labels.elementLock.unlock"),children:Bx})},Zk=WV;import{Fragment as UX,jsx as Pe,jsxs as Fb}from"react/jsx-runtime";var o3=In.createContext(null),r3=In.createContext(null),Ob={formFactor:"desktop",desktopUIMode:"full",userAgent:t3(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},Gb=In.createContext(Ob);Gb.displayName="EditorInterfaceContext";var zX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},Hb=In.createContext({container:null,id:null});Hb.displayName="ExcalidrawContainerContext";var Ub=In.createContext([]);Ub.displayName="ExcalidrawElementsContext";var Wb=In.createContext({...Xo(),width:0,height:0,offsetLeft:0,offsetTop:0});Wb.displayName="ExcalidrawAppStateContext";var Vb=In.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Vb.displayName="ExcalidrawSetAppStateContext";var Yb=In.createContext(null);Yb.displayName="ExcalidrawActionManagerContext";var us=In.createContext(null);us.displayName="ExcalidrawAPIContext";var pu=In.createContext(null);pu.displayName="ExcalidrawAPISetContext";var St=()=>Go(o3),kn=()=>Go(r3),be=()=>Go(Gb),ct=()=>mu(be()),Ne=()=>Go(Hb),Ui=()=>Go(Ub),Qn=()=>Go(Wb),Oe=()=>Go(Vb),rt=()=>Go(Yb),Md=()=>Go(us),bc=!1,xc=0,yc=null,Oo=!1,su=!1,zo=!1,lu=!1,wc={horizontal:null,vertical:null},Dr=0,vc=!1,Bb=new Map,GX=4,cu=!1,du=0,JM=!1,ps=null,de={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},zb=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",Ob);v(this,"stylesPanelMode",mu(Ob));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 co);v(this,"imageStatus",new Map);v(this,"imageStatusEmitter",new co);v(this,"imagePlaceholderUpdateEmitter",new co);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 yY(zX));v(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));v(this,"appStateObserver",new Zp(()=>this.state));v(this,"onStateChange",this.appStateObserver.onStateChange);v(this,"bucketFill",new ep(this));v(this,"flowchart",new ip(this));v(this,"cursor",new tp(this));v(this,"gifPlayback",new ap(this));v(this,"zDragZoom",null);v(this,"arrowText",new Qm(this));v(this,"viewport",new lp(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>de.pointers.size>=2||zo}));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 rp(this));v(this,"laserTrails",new Am(this));v(this,"eraserTrail",new Fm(this));v(this,"lassoTrail",new Bm(this));v(this,"cursorHints",new $p(this));v(this,"onChangeEmitter",new co);v(this,"onPointerDownEmitter",new co);v(this,"onPointerUpEmitter",new co);v(this,"onUserFollowEmitter",new co);v(this,"onScrollChangeEmitter",new co);v(this,"missingPointerEventCleanupEmitter",new co);v(this,"onRemoveEventListenersEmitter",new co);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=Et.set(t,...o);return this.triggerRender(),r});v(this,"previousHoveredBindableElement",null);v(this,"getEffectiveGridSize",()=>hr(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&&fc(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Ae.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<=aM);v(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),wi.delete(t)});v(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Fo(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=Sb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else Ib(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.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Me({clientX:i.x,clientY:i.y},this.state),s=Me({clientX:i.right,clientY:i.bottom},this.state);return o={x:a.x,y:a.y,width:s.x-a.x,height:s.y-a.y,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,o),o}return null}return o},_cache:new Map});v(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});v(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===mc.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&Tt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!TM(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}=Qp({sceneX:i.x,sceneY:i.y},this.state),l=6,c,d=rX(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:xY(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:`${No.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?No.nameColorDarkTheme:No.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:vb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+No.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:No.nameFontSize,color:t?No.nameColorDarkTheme:No.nameColorLightTheme,lineHeight:No.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:Ae.MOVE,pointerEvents:this.state.viewModeEnabled?cs.disabled:cs.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)=>{Fe("export",t,"ui");let i=await Zr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(EY).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&_c(i)&&this.setState({fileHandle:i})});v(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Gt,{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:$t.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:$t.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?po(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:$t.IMMEDIATELY})},keepOpenOnAlt:!1})});v(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});v(this,"syncActionResult",Ke(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let o=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),o=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled??this.state.viewModeEnabled,a=t?.appState?.theme||this.props.theme||mc.LIGHT,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&&au(d)&&Kt(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($t.NEVER));v(this,"onBlur",Ke(()=>{Oo=!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===kr.EQUAL||t.code===kr.MINUS||t.code===kr.ZERO||t.code===kr.NUM_ADD||t.code===kr.NUM_SUBTRACT||t.code===kr.NUM_ZERO)&&t.preventDefault()});v(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Oo=!1,su=!1,zo=!1,lu=!1,ps=null,de.pointers.clear(),de.lastCenter=null,de.initialDistance=null,de.initialScale=null,clearTimeout(xc),xc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(du),du=0,cu=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),Et.set(Gt,null),Et.set(ro,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,mm(),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:nn(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",Ke(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...Xo(),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=Nr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=ki(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=hc(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...Si(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:$t.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),RM(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)??TY(t,o));v(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=kY(),a=t3(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:tY,l=wb(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=mu(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=MY(t);this.editorInterface=wb(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});v(this,"onResize",Ke(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>wi.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&&(wc=t),this.scheduleImageRefresh()});v(this,"onScroll",cM(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},nY));v(this,"onCut",Ke(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||pc(t.target)||(this.actionManager.executeAction(sm,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onCopy",Ke(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||pc(t.target)||(this.actionManager.executeAction(ma,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(SY&&t.preventDefault(),!bc){bc=!0,t.touches.length===1&&(yc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(xc),xc=window.setTimeout(e.resetTapTwice,aM);return}if(bc&&t.touches.length===1&&yc){let o=t.touches[0];so(oe(o.clientX,o.clientY),oe(yc.x,yc.y))<=uM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),bc=!1,clearTimeout(xc)}t.touches.length===2&&this.setState({selectedElementIds:De({},this.state),activeEmbeddable:null})}});v(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:De(this.state.previousSelectedElementIds,this.state)}):de.pointers.clear())});v(this,"pasteFromClipboard",Ke(async t=>{if(!this.isInteractionEnabled())return;let o=!!cu,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||pc(r)))return;let s=await Kr(t),l=s.getFiles(),c=await jd(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=Nr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=ms(o),l=ds(r,a)/2,c=ds(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}=Me({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,w]=Mt(E,g,this.getEffectiveGridSize()),{duplicatedElements:y}=yM({type:"everything",elements:o.map(M=>po(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,OM(I,hc(y));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let M=iX(y,C);I=Ab(I,M,C)}this.scene.replaceAllElements(I),y.forEach(M=>{if(Kt(M)&&vM(M)){let D=kM(M,this.scene.getElementsMapIncludingDeleted());qY(M,D,this.scene)}}),PY&&Eo.loadElementsFonts(y).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let P=wX(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Et.get(sb)?this.state.openSidebar:null,...zM(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=>{Dr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=de.pointers.size>=2;de.pointers.delete(t.pointerId),o&&de.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});v(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Fe("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...nn(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||XY(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:ms(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:Yn(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,$V,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});v(this,"addFiles",Ke(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());Cb({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 Br(s),customData:l??{}}))),a=i.find(({file:s})=>!Mi(s));if(a)throw new Iu(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 Br(o);if(!Mi(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===lo.gif?"pending":void 0};this.imageCache.set(t,s),s.gifDecodeStatus==="pending"&&this.imagePlaceholderUpdateEmitter.trigger(),i.src=await Rc(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=cc(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:cc(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())yi(o)&&o.fileId===t&&wi.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===lo.svg))try{let l=yx(PM(wx(s.dataURL)),lo.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",Ke(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?DY({...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=YM.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return YM.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",Ke(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));v(this,"onKeyDown",Ke(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}})),!dM(t.target)){if((t.key===$.ESCAPE||t.key===$.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=ce(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&Un(l[0])&&t.key===$.ENTER){this.startImageCropping(l[0]);return}if(t.key===$.ESCAPE)this.updateEditorAtom(ro,null);else if(t.key===$.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(vb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=Jm(l);Et.get(ro)?.type==="panel"&&qf(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(ro,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[$.CTRL_OR_CMD]&&t.key.toLowerCase()===$.V&&(cu=t.shiftKey,clearTimeout(du),du=window.setTimeout(()=>{cu=!1},100)),t[$.CTRL_OR_CMD]&&pc(t.target)&&(t.code===kr.MINUS||t.code===kr.EQUAL)){t.preventDefault();return}if(pc(t.target)&&t.key!==$.ESCAPE||Eb(t.key)&&dM(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 Bo("COMPLEX_BINDINGS")?this.handleSkipBindMode():iu({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=Ky(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!hM(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&Fe("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===Mr.sharp?Mr.round:this.state.currentItemArrowType===Mr.round?Mr.elbow:Mr.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&&(Bo("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Ot(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),iu({app:this,event:t})),Eb(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),c=new Set;l.filter(u=>uo(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?iM:this.getEffectiveGridSize())||(t.shiftKey?JV:iM),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),l.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),nu(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]||_b(c))zt(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),Xt(c)||this.actionManager.executeAction(va));else if(Kt(c)||MM(c)){let d;Kt(c)||(d=c);let m=kb(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&&de.pointers.size===0&&(Oo=!0,this.cursor.set(Ae.GRAB),t.preventDefault()),t.key.toLowerCase()===$.Z&&!t[$.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(su=!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&&(Yo(this.state.activeTool.type)||l.some(c=>Yo(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=>Kt(c)||Pb(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",Ke(t=>{if(this.isInteractionEnabled()){if(t.key===$.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Ae.GRAB):eu(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Oo=!1),t.key.toLowerCase()===$.Z&&(su=!1,this.cursor.reset()),t.key===$.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),iu({app:this,event:t})),(t.key===$.ALT&&this.state.bindMode==="skip"||!t[$.CTRL_OR_CMD]&&!tu(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Bo("COMPLEX_BINDINGS"))){let o=Me({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Ar(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());uo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[$.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Ot(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),iu({app:this,event:t})}if(Eb(t.key)){fM(this.scene.getSelectedElements(this.state).filter(gc),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Rb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...KM(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...KM(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(ut);let i=ta.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?nn(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?nn(this.state,{...t,lastActiveTool:this.state.activeTool}):nn(this.state,t);s.type==="hand"?this.cursor.set(Ae.GRAB):Oo||this.cursor.applyForTool(s),hY(document.activeElement)&&this.focusContainer(),WY(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:eu(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:De({},l),selectedGroupIds:De({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:De({},l),selectedGroupIds:De({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});v(this,"setOpenDialog",t=>{this.setState({openDialog:t})});v(this,"isTouchScreenMultiTouchGesture",()=>de.pointers.size>=2);v(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${mM()}`);v(this,"onGestureStart",Ke(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:De({},this.state),activeEmbeddable:null}),de.initialScale=this.state.zoom.value)}));v(this,"onGestureChange",Ke(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=de.initialScale;o&&this.viewport.translate(r=>({...fo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Yn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));v(this,"onGestureEnd",Ke(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:De(this.state.previousSelectedElementIds,this.state)}),de.initialScale=null)}));v(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=qM(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&W2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});v(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=qM(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(nf,"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&&(Pb(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||lM(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!gc(i)){let C=uX(xb({fontSize:g,fontFamily:u}),E),P=hX(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-BM(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||bM({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?iY.MIDDLE:oM),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?gc(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 so(oe(o.x,o.y),oe(r.x,r.y))<=uM});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}=Me(t,this.state);if(o.length===1&&zt(o[0])){let s=o[0];if((t[$.CTRL_OR_CMD]&&Rb(s)||_b(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(va);return}else if(this.state.selectedLinearElement&&Xt(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&&_b(s))return}if(o.length===1&&Un(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),xX(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&bX(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(c=>({...c,...Wn({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(fc(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"||wM(l)||!fY(l.backgroundColor)||Ec({point:oe(r,i),element:l,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(l)}))){let c=kb(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!==Gn.MAIN){this.lastCompletedCanvasClicks=[];return}let o=Me(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(!Un(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=Fl(o,r,this.state,i);return!!a&&so(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&&Mc(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&&mx(a,i,this.state,oe(t.x,t.y)))return a});v(this,"handleElementLinkClick",t=>{let o=d=>d===Gn.MAIN||d===Gn.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=so(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>rM)return;let i=Me(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),s=Mc(this.hitLinkElement,a,this.state,oe(i.x,i.y),this.editorInterface.formFactor==="phone"),l=Me(this.lastPointerUpEvent,this.state),c=Mc(this.hitLinkElement,a,this.state,oe(l.x,l.y),this.editorInterface.formFactor==="phone");s&&c&&(mm(),this.openElementLink(this.hitLinkElement,t))});v(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=Jp(r);let i;if(this.props.onLinkOpen&&o&&(i=gY(Q.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=mY(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(Ae.POINTER),bv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(mm(),!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=Me(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=Me(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&&DM(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&&FX(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?QY(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=Yn(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...fo({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())&&!zo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Me(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),Oo||zo||lu||bs(this.state))return;let s=bf(wc,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(Ae.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Ae.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&z2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=O2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(w=>{let y=uc(w.snapLines,b),x=w.originSnapOffset?uc(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&&Ot(()=>{this.setState({selectedLinearElement:g})})}if(UY(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&tu(this.state)){let b=oe(r,i),w=this.scene.getNonDeletedElementsMap(),y=Ar(b,this.scene.getNonDeletedElements(),w,jM(this.state.zoom));y?this.setState({suggestedBinding:{element:y,midPoint:Nb(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)so(oe(r-w,i-y),I)>=bb?(this.store.scheduleCapture(),Ot(()=>{mo(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(Ae.POINTER);else if(x.length>2&&T&&so(oe(r-w,i-y),T)<bb){this.cursor.set(Ae.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{CM(x,this.state.zoom.value)&&this.cursor.set(Ae.POINTER);let C=this.scene.getNonDeletedElementsMap();if(Rb(g)){let M=Ar(oe(r,i),this.scene.getNonDeletedElements(),C);Bo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,M)}mo(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=Ar(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),jM(this.state.zoom)),w=this.scene.getNonDeletedElementsMap();b&&!ZM(g,b,w)&&this.setState({suggestedBinding:{element:b,midPoint:Nb(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(Ae.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&&Xt(m[0]))&&!(zt(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=HM(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(GM(g));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=UM(ms(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(GM({transformHandleType:g}));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||Fo(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?Ae.POINTER:Kt(u)?Ae.TEXT:Ae.CROSSHAIR):!t[$.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Ae.MOVE):this.state.viewModeEnabled?this.cursor.set(Ae.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Ae.AUTO):s?this.cursor.set(Ae.AUTO):!t[$.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Xt(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Ae.MOVE):this.cursor.set(Ae.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:uc(g.hoveredElementIds,Wn({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:uc(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()&&(vc=!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),zo||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=Me(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(qE,null)),Et.get(ro)&&this.updateEditorAtom(ro,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),su){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:De(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"?$t.EVENTUALLY:$t.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=wb(this.editorInterface,{isTouchScreen:!0})),zo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Gn.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Hn.eraser){this.setState({activeTool:nn(this.state,{type:Hn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),w?.(),rn(this.state)&&this.setState({activeTool:nn(this.state,{...this.state.activeTool.lastActiveTool||{type:Hn.selection},lastActiveTool:null})})},b=ve(window,Q.POINTER_UP,g,{once:!0}),w;requestAnimationFrame(()=>{w=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==Gn.MAIN&&t.button!==Gn.TOUCH&&t.button!==Gn.ERASER||de.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))Mb(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=>vi(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=>vi(this.scene.getNonDeletedElements(),D)).forEach(D=>{delete x[D.id]}))})}return{...Wn({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:T.link||Fo(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===Hn.frame||this.state.activeTool.type===Hn.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===Hn.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(Bo("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=Me({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"&&(vc=!1,Dr?vc=!0:Dr=window.setTimeout(()=>{Dr=0,vc||this.handleCanvasContextMenu(t)},rY))});v(this,"resetContextMenuTimer",()=>{clearTimeout(Dr),Dr=0,vc=!1});v(this,"maybeCleanupAfterMissingPointerUp",t=>{ps?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});v(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(de.pointers.size<=1&&((t.button===Gn.WHEEL||t.button===Gn.MAIN&&Oo||bs(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;zo=!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(Ae.GRABBING);let{clientX:i,clientY:a}=t,s=km(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/this.state.zoom.value,scrollY:this.state.scrollY-m/this.state.zoom.value})}),l=Ke(ps=()=>{ps=null,zo=!1,Oo||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=>{de.pointers.has(t.pointerId)&&de.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=de.initialScale;if(de.pointers.size===2&&de.lastCenter&&o&&de.initialDistance){let r=rf(de.pointers),i=r.x-de.lastCenter.x,a=r.y-de.lastCenter.y;de.lastCenter=r;let s=af(Array.from(de.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/de.initialDistance,c=l?Yn(o*l):this.state.zoom.value;this.setState(d=>{let m=fo({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/p,scrollY:m.scrollY+2*a/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else de.lastCenter=de.initialDistance=de.initialScale=null});v(this,"clearSelectionIfNotUsingSelection",()=>{eu(this.state.activeTool.type)||this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});v(this,"handleSelectionOnPointerDown",(t,o)=>{if(eu(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&&!Xt(a[0])&&!(zt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=HM(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=UM(ms(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=yb(vX(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&zt(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=IX(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&&uo(g)){let{hitFocusPoint:b,pointerOffset:w,arrowOtherEndpointInitialBinding:y}=RX(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?De({[p.selectedLinearElement.elementId]:!0},this.state):De({},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=>({...EX(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!FM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:De({},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))Mb(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=>vi(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=>vi(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})),{...Wn({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||Fo(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);wM(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:nn(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=RY({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"?jV:ZV},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:De(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=BY({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=ou(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=EM({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 zY({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&&Ot(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(mo(a,"selectedLinearElement is expected to be set"),i.type==="line"&&CM(i.points,this.state.zoom.value)){Ot(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(ut);return}if(Xt(i)&&i.points.length>1){this.actionManager.executeAction(ut,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=Me(t,this.state),{start:m,end:p}=uo(i)&&tu(this.state)?OX(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&&!ZM(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&so(oe(r.origin.x-s,r.origin.y-l),c)<bb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(ut,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(w=>({selectedElementIds:De({...w.selectedElementIds,[i.id]:!0},w)})),this.cursor.set(Ae.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"?FY({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===Mr.round?{type:jp.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===Mr.elbow,fixedSegments:this.state.currentItemArrowType===Mr.elbow?[]:null}):GY({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:jp.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=oe(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=tu(this.state)?Ar(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[oe(0,0),oe(0,0)]}),this.insertNewElement(p),uo(p)&&MX(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:nM(t.nativeEvent)}),Ot(()=>{this.setState(b=>{let w=null,y=b.selectedElementIds;if(zt(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:De({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&uo(p)?{element:g,midPoint:Nb(u,g,E,this.state.zoom)}:null,selectedElementIds:y,selectedLinearElement:w}})}),uo(p)&&Bo("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=EM({type:"embeddable",...s}):l=OY({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,...No},s=o===Hn.magicframe?NY(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(uo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);ru(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);ru(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else Tb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&ru(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&ru(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)||vM(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,po(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});v(this,"initializeImage",async(t,o)=>{if(!Mi(o))throw new Error(f("errors.unsupportedFileType"));this.cursor.set("wait");let r=this.gifPlayback.createPlaceholderDecodeState(t,o);if(o.type===lo.svg)try{o=Pu(PM(await o.text()),o.name)}catch(d){throw console.warn(d),new Error(f("errors.svgImageInsertError"))}else if(o.type!==lo.gif){let{maxWidthOrHeight:d}=this.props.imageOptions;try{o=await(this.props.compressImageFile??vx)(o,{maxWidthOrHeight:d})}catch(m){console.error("Error trying to resize image file on insertion",m)}}let i=o.type,a=i===lo.gif,s=await(this.props.generateIdForFile?.(o)||xx(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 Rc(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?KY(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=po(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 po(r,{fileId:o})});v(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Me({clientX:t,clientY:o},this.state),a=await cx({description:"Image",extensions:Object.keys(QV),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:nn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(ut)})}});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())yi(o)&&o.fileId===t&&wi.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 Cb({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($t.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(yi(s)){if(a.has(s.fileId))return po(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return po(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!==lo.gif||!o||(this.imageCache.set(t,{...o,gifDecodeStatus:"pending"}),this.handleImageCacheUpdate(t),await Cb({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=jY(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)&&wi.delete(a);i.size&&this.scene.triggerUpdate()}});v(this,"scheduleImageRefresh",YV(()=>{this.addNewImagesToImageCache()},eY));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=XM(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 Br(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),po(u,{isDeleted:!0})}})),c=hc(l),d=XM(l.filter(u=>!u.isDeleted),o,r,a),m=hc(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:De(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:$t.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(ut)})});v(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Me(t,this.state),i=qh(t),a=await Kr(t),s=a.getFiles(),l=s.map(d=>d.file).filter(d=>Mi(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,Zd(a,l.length,i));if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===lo.png||d.type===lo.svg))try{let p=await vs(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:$t.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,Zd(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(lo.text);if(c){let d=c.value;if(d&&Sb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||ou(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:Jp(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});v(this,"loadFileToCanvas",async(t,o)=>{t=await Br(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await vs(t,this.state,r,o)}catch(a){let s=a instanceof lx;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;n3(r.concat(i.elements)),this.store.scheduleMicroAction({action:$t.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:$t.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!==Gn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Me(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;Fe("contextMenu","openContextMenu",m),this.setState({...d&&!this.state.selectedElementIds[d.id]?{...this.state,...Wn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:zt(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"){WM({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:ds(t.origin.x,a.x),height:ds(t.origin.y,a.y),shouldMaintainAspectRatio:dc(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=yi(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}=F2(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}),uo(s)||WM({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:ds(t.originInGrid.x,l),height:ds(t.originInGrid.y,c),shouldMaintainAspectRatio:Un(s)?!dc(o):dc(o),shouldResizeFromCenter:tM(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===Hn.frame||this.state.activeTool.type===Hn.magicframe)&&this.setState({elementsToHighlight:Db(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&&Un(l)){let c=t.originalElements.get(l.id),d=yi(l)&&this.imageCache.get(l.fileId)?.image;if(c&&Un(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}=df([l],[c],this,o,u,r);this.scene.mutateElement(l,cX(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),nu(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&&Xt(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=>{Mb(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}=df(r,ce(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(TX(t.originalElements,a,r,this.scene,nM(o),tM(o),r.some(m=>Un(m))?!dc(o):dc(o),l,c,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{Db(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{au(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=>Un(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&Un(t)?[...o([t.id])]:[]});v(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>Un(r))&&(!t||this.state.selectedElementIds[t.id])?[lg,cg]:[]});v(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=Jp(t.link),r=RM(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 To(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?[al,pa,Ca,mr]:[pg,qe,mh,Cv,qe,pa,Lt,sl,ll,Ca,mr];if(this.state.viewModeEnabled)return[...a,a.length>0&&qe,al,ma,r.length>0&&qe,...r];let s=this.editorInterface.formFactor==="desktop"?[qe,sh,lh,ch,dh]:[];return[qe,al,qe,sm,ma,pg,r.length>0&&qe,...r,i.length>0&&qe,...i,qe,f2,E2,b2,qe,qg,qe,ig,nf,gg,fg,cv,ag,qe,...s,qe,dg,mg,qe,va,qe,Sg,a.length>0&&qe,...a,qe,ph,ml,qe,Ls]});v(this,"handleWheel",Ke(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(vb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[$.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),zo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=aY*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:sY;c=Math.max(c,d),this.viewport.translate(p=>({...fo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Yn(c)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a})=>({scrollX:a-(r||o)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:s})=>({scrollX:a-o/i.value,scrollY:s-r/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}=Me({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:de.pointers})});v(this,"resetShouldCacheIgnoreZoomDebounced",cM(()=>{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=Xo(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${mM()}`,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=nn(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===mc.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=mu(this.editorInterface),this.id=KV(),this.actionManager=new Tm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new VM,this.canvas=document.createElement("canvas"),this.rc=XV.canvas(this.canvas),this.renderer=new Al(this.scene),this.visibleElements=[],this.store=new PX(this),this.history=new kl(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Eo(this.scene),this.history=new kl(this.store),this.actionManager.registerAll(jc),this.actionManager.registerAction(v2(this.history)),this.actionManager.registerAction(I2(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(qp).includes(i)&&Bb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){mo(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=Ar(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),Ot(()=>{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;mo(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||Xt(t))return;let r=()=>{if(this.bindModeHandler=null,mo(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=Ar(oe(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){mo(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;Ot(()=>{mo(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;mo(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&&$M(E,m),w=g&&$M(g,m);i=!!(b&&w&&E.id!==g.id&&AX(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"&&Ot(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,IY)),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!==Gn.MAIN||Oo||!hM(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(Me({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=oe(Me({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(so(t,o)>rM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&de.pointers.size<2&&fc(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),Ib(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=Bb.get(s.id);switch(c||(Bb.set(s.id,qp.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case qp.PLAYING:case qp.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=>Fo(a)&&this.embedsValidationStatus.get(a.id)===!0||Ib(a));return Pe(UX,{children:i.map(a=>{let{x:s,y:l}=Qp({sceneX:a.x,sceneY:a.y},this.state),c=TM(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=ou(pY(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=cc(g?t:1,.75,GX);return Pe("div",{className:jk("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:c?`translate(${s-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:fX(a,Lb(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?dY:1),"--embeddable-radius":`${$Y(Math.min(a.width,a.height),a)}px`},children:Fb("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?cs.enabled:cs.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:(Fo(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=Et.get(ro)?.type==="panel";return Pe("div",{translate:"no",className:jk("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?cs.disabled:cs.enabled,"--right-sidebar-width":`${eE}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(us.Provider,{value:this.api,children:Pe(o3.Provider,{value:this,children:Pe(r3.Provider,{value:this.props,children:Pe(Hb.Provider,{value:this.excalidrawContainerValue,children:Pe(Gb.Provider,{value:this.editorInterface,children:Pe(Vb.Provider,{value:this.setAppState,children:Pe(Wb.Provider,{value:this.state,children:Fb(Ub.Provider,{value:this.scene.getNonDeletedElements(),children:[Fb(Yb.Provider,{value:this.actionManager,children:[Pe(Mk,{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:Kn().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(Dk,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Pe(Kk,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Pe(fv,{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(jT,{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(hb,{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:hr(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(Hk,{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(ub,{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(dp,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Pe(Zk,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Pe(vT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{yi(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),wi.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,QM()||e3()){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(),lY&&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),CY()&&!mX()&&this.setState({errorMessage:Pe(UT,{})});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 VM,this.fonts=new Eo(this.scene),this.renderer=new Al(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(),wi.destroy(),gn.destroy(),clearTimeout(Dr),Le.clearCache(),Wn.clearCache(),Dr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(ve(window,Q.MESSAGE,this.onWindowMessage,!1),ve(document,Q.POINTER_UP,this.removePointer,{passive:!1}),ve(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),ve(window,Q.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),ve(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.handleNavigationModeKeyDown,!1),ve(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ve(document,Q.GESTURE_START,this.onGestureStart,!1),ve(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),ve(document,Q.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,Q.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),ve(this.excalidrawContainerRef.current,Q.GESTURE_START,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,Q.GESTURE_CHANGE,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,Q.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(ve(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(ve(document,Q.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),ve(document,Q.COPY,this.onCopy,{passive:!1}),ve(document,Q.KEYUP,this.onKeyUp,{passive:!0}),ve(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ve(document,Q.GESTURE_START,this.onGestureStart,!1),ve(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),ve(document,Q.GESTURE_END,this.onGestureEnd,!1),ve(document,Q.PASTE,this.pasteFromClipboard,{passive:!1}),ve(this.excalidrawContainerRef.current,Q.DRAG_OVER,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,Q.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(ve(document,Q.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),ve(document,Q.CUT,this.onCut,{passive:!1}),ve(window,Q.RESIZE,this.onResize,!1),ve(window,Q.UNLOAD,this.onUnload,!1),ve(window,Q.BLUR,this.onBlur,!1),ve(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(ve(uY(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)===mc.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),(o.zoom.value!==this.state.zoom.value||o.scrollX!==this.state.scrollX||o.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),Object.keys(this.state.selectedElementIds).length&&rn(this.state)&&this.setState({activeTool:nn(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===mc.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(ut)});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:De(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(){bc=!1,yc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Me({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=Vm(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(Pu(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?DX(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=bY(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>ZY(d)).filter(d=>Sb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||ou(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:Jp(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=>Mi(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):(Ot(()=>{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 Ix(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(`
17
+ `).filter(l=>l.trim().length>0).map(l=>l.split(s).map(d=>d.trim())),t=[" ",",",";"].map(s=>{let l=n(s),d=l[0]?.length??0,c=l.length>0&&l.every(m=>m.length===d);return{delimiter:s,parsed:l,numCols:d,isConsistent:c}}),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)?JI(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ha}from"@excalidraw/math";import{FONT_FAMILY as PB,FONT_SIZES as kB,getFontString as MB,getLineHeight as AB,ROUGHNESS as QI}from"@excalidraw/common";import{measureText as DB,newLinearElement as Lf,newTextElement as LB}from"@excalidraw/element";var eS=(e,n,t,o)=>{if(!Na(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}=KI(i,r.length),l=Oa(o),d=za(l),c=Fa(i.length,l),{chartWidth:m,chartHeight:p}=YI(),u=n+m/2,E=t-p/2,g=Da/2,b=r.map((z,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:w,axisLabelTopY:y,axisLabelBottomY:x}=XI(r,b,u,E,g,d),I=PB["Lilita One"],S=kB.xl,C=AB(I),P=MB({fontFamily:I,fontSize:S}),M=e.title?Hm(e.title,P,m+La*2):null,D=M?DB(M,P,C):null,_=M?LB({backgroundColor:d,...Be,text:M,originalText:e.title??M,x:n+m/2,y:y-La-D.height/2,fontFamily:I,fontSize:S,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:vf},(z,U)=>{let V=(U+1)/vf,G=g*V,re=b.map(B=>Ha(Math.cos(B)*G,Math.sin(B)*G));return re.push(Ha(re[0][0],re[0][1])),Lf({backgroundColor:"transparent",...Be,type:"line",x:u,y:E,width:G*2,height:G*2,strokeStyle:"solid",roughness:QI.architect,opacity:ai,polygon:!0,points:re})}):[],L=b.map(z=>{let U=Math.cos(z)*g,V=Math.sin(z)*g;return Lf({backgroundColor:"transparent",...Be,type:"line",x:u,y:E,width:Math.abs(U),height:Math.abs(V),strokeStyle:"solid",roughness:QI.architect,opacity:ai,points:[Ha(0,0),Ha(U,V)]})}),F=i.map((z,U)=>{let V=b.map((G,re)=>{let B=z.values[re]??0,W=a(B,re)*g;return Ha(Math.cos(G)*W,Math.sin(G)*W)});return V.push(Ha(V[0][0],V[0][1])),Lf({backgroundColor:"transparent",...Be,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:c[U],strokeWidth:2,polygon:!0,points:V})}),Y=Ga(i,c,u,x,t+oo*5,d);return[..._?[_]:[],...w,...k,...L,...F,...Y]};var _f=(e,n,t,o,r)=>e==="line"?qI(n,t,o,r):e==="radar"?eS(n,t,o,r):ZI(n,t,o,r);import{clamp as Ym,pointFrom as Ua,pointsEqual as zB,bezierEquation as dS,pointRotateRads as Km,pointDistance as GB}from"@excalidraw/math";import{arrayToMap as HB,BIND_MODE_TIMEOUT as Bl,DEFAULT_TRANSFORM_HANDLE_SPACING as mS,FRAME_STYLE as bn,getFeatureFlag as UB,invariant as iS,shouldRotateWithDiscreteAngle as pS,THEME as Mo}from"@excalidraw/common";import{deconstructDiamondElement as Of,deconstructRectanguloidElement as uS,elementCenterPoint as Wa,getDiamondBaseCorners as WB,FOCUS_POINT_SIZE as VB,getOmitSidesForEditorInterface as Rf,getTransformHandles as YB,getTransformHandlesFromCoords as KB,hasBoundingBox as XB,hitElementItself as $B,isArrowElement as hS,isBindableElement as gS,isElbowArrow as Va,isFrameLikeElement as Ya,isImageElement as Xm,isLinearElement as ZB,isLineElement as jB,maxBindingDistance_simple as qB,isTextElement as JB,LinearElementEditor as xn,getActiveTextElement as QB,getElementsInGroup as zf,getSelectedGroupIds as eF,isSelectedViaGroup as tF,selectGroupsFromGivenElements as nF}from"@excalidraw/element";import{renderSelectionElement as oF}from"@excalidraw/element";import{getCommonBounds as Gf,getElementAbsoluteCoords as Ol}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as aS,isFocusPointVisible as rF}from"@excalidraw/element";import{pointFrom as Pt}from"@excalidraw/math";import{THEME as _B}from"@excalidraw/common";var RB="#ff6b6b",NB="#ff0000",tS=1,nS=2,oS=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===_B.LIGHT||n.zenModeEnabled?RB:NB,o=(n.zenModeEnabled?tS*1.5:tS)/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,FB(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,OB(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,BB(r,e,n));e.restore()},BB=(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)rS(o,t,n)},FB=(e,n,t)=>{rS(e.points[0],t,n),t.zenModeEnabled||En(e.points[0],e.points[1],n)},rS=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?nS*1.5:nS)/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()},OB=(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 iF=(e,n)=>{iS(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;iS(t,"midPointCoords is null"),$m(t,e,n)},aF=(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);$m(a,e,n)},$m=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",ys(n,e[0],e[1],xn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},sF=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!hS(i)||i.isDeleted)return;let a=r==="label"?xn.getBoundTextElementCenter(i,t):xn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);$m(a,e,n)},Nf=(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)"),ys(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},lF=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&Ya(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===Mo.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=Wa(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=Ym(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===Mo.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,d]=Of(n.element);l.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-n.element.x,c[0][1]-n.element.y),e.lineTo(c[1][0]-n.element.x,c[1][1]-n.element.y),e.stroke()}),d.forEach(c=>{let[m,p,u,E]=c;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break;default:{let[l,d]=uS(n.element);l.forEach(c=>{e.beginPath(),e.moveTo(c[0][0]-n.element.x,c[0][1]-n.element.y),e.lineTo(c[1][0]-n.element.x,c[1][1]-n.element.y),e.stroke()}),d.forEach(c=>{let[m,p,u,E]=c;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break}e.restore();break}if(o.isMidpointSnappingEnabled&&!o.gridModeEnabled&&!i&&(Ya(n.element)||gS(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&xn.getElement(s?.elementId,t),d=r&&$B({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),c=l&&Va(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!d||c){e.save();let m=Wa(n.element,t),p;if(n.element.type==="diamond"){let b=Wa(n.element,t);p=WB(n.element).map(w=>{let y=dS(w,.5),x=Km(y,b,n.element.angle);return Ua(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=Ua(w.x+n.element.x,w.y+n.element.y),x=Km(y,m,n.element.angle);return Ua(x[0],x[1])});let u=r&&p.reduce((b,w,y)=>{let x=GB(w,r);return y===-1||x<b.distance?{idx:y,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=qB(o.zoom)+n.element.strokeWidth/2;p.forEach((b,w)=>{let y=(!d||c)&&u?.idx===w&&u.distance<=g,x=!y&&(c||w===u?.idx&&u.distance<=g*2);y?(e.fillStyle=o.theme===Mo.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===Mo.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()}}},cF=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=Bl-(a?.runtime??(s?0:Bl)),d=Ym(1/Bl*l,1e-4,1),c=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&Ya(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===Mo.DARK?`rgba(3, 93, 161, ${d})`:`rgba(106, 189, 252, ${d})`,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=Wa(t,o),E=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(n.translate(E,g),n.rotate(t.angle),n.translate(-E,-g),n.translate(t.x+r.scrollX-c,t.y+r.scrollY-c),n.lineWidth=Ym(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===Mo.DARK?`rgba(3, 93, 161, ${d/2})`:`rgba(106, 189, 252, ${d/2})`,t.type){case"ellipse":n.beginPath(),n.ellipse((t.width+c*2)/2,(t.height+c*2)/2,(t.width+c*2)/2,(t.height+c*2)/2,0,0,2*Math.PI),n.closePath(),n.stroke();break;case"diamond":{let[b,w]=Of(t,c);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+c,y[0][1]-t.y+c),n.lineTo(y[1][0]-t.x+c,y[1][1]-t.y+c),n.stroke()}),w.forEach(y=>{let[x,I,S,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+c,x[1]-t.y+c),n.bezierCurveTo(I[0]-t.x+c,I[1]-t.y+c,S[0]-t.x+c,S[1]-t.y+c,C[0]-t.x+c,C[1]-t.y+c),n.stroke()})}break;default:{let[b,w]=uS(t,c);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+c,y[0][1]-t.y+c),n.lineTo(y[1][0]-t.x+c,y[1][1]-t.y+c),n.stroke()}),w.forEach(y=>{let[x,I,S,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+c,x[1]-t.y+c),n.bezierCurveTo(I[0]-t.x+c,I[1]-t.y+c,S[0]-t.x+c,S[1]-t.y+c,C[0]-t.x+c,C[1]-t.y+c),n.stroke()})}break}n.restore();break}if(!s||(a?.runtime??0)>Bl)return;let p=.5*(Math.min(t.width,t.height)/2);if(!Ya(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/Bl*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-d),p*(1-d),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!pS(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]=Of(t),x=Wa(t,o);w=y.map(I=>{let S=dS(I,.5),C=Km(S,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let y=Wa(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 S=Ua(I.x+t.x,I.y+t.y),C=Km(S,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===Mo.DARK?`rgba(3, 93, 161, ${d})`:`rgba(106, 189, 252, ${d})`,w.forEach(y=>{n.beginPath(),n.arc(y.x,y.y,E,0,2*Math.PI),n.fill()}),n.restore()}}return{runtime:(a?.runtime??0)+i}},dF=(e,n,t,o,r,i,a)=>{if(t===null)return;if(UB("COMPLEX_BINDINGS"))return cF(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Ua(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&pS(e.lastPointerMoveEvent);lF(n,t,o,r,s,l),n.restore()},fS=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:s,selectionColors:l,cx:d,cy:c,dashed:m,activeEmbeddable:p}=t,u=a-r,E=s-i,b=(t.padding??mS*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,ws(e,r-b,i-b,u+b*2,E+b*2,d,c,o);e.restore()},mF=(e,n,t,o)=>{let[r,i,a,s]=Ol(t,o),l=a-r,d=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=bn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),ws(e,r,i,l,d,r+l/2,i+d/2,t.angle,!1,bn.radius/n.zoom.value),e.restore()},sS=(e,n,t,o)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=o||{},a=t.filter(c=>c.groupIds.length===0),s=t.filter(c=>c.groupIds.length>0),l=c=>{let[m,p,u,E]=Gf(c);return{angle:0,x1:m,x2:u,y1:p,y2:E,selectionColors:r,dashed:i,cx:m+(u-m)/2,cy:p+(E-p)/2,activeEmbeddable:!1}},d=c=>{let m=zf(t,c);return l(m)};Object.entries(nF(s,n)).filter(([c,m])=>m).map(([c,m])=>c).map(c=>d(c)).concat(a.map(c=>l([c]))).forEach(c=>fS(e,n,c))},Bf=(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=Va(t),l=jB(t);if(r.forEach((d,c)=>{if(s&&c!==0&&c!==r.length-1)return;let m=c>0&&(c!==r.length-1||!l||!t.polygon)&&zB(d,c===r.length-1?r[0]:r[c-1],2/n.zoom.value),p=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(c);l&&t.polygon&&!p&&c===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Nf(e,n,d,a,p,!1,m)}),Va(t)){let d=t.fixedSegments?.map(c=>c.index)||[];r.slice(0,-1).forEach((c,m)=>{xn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||Nf(e,n,Ua((c[0]+r[m+1][0])/2,(c[1]+r[m+1][1])/2),i/2,!1,!d.includes(m+1),!1)})}else xn.getEditorMidPoints(t,o,n).filter((c,m,p)=>c!==null&&!(Va(t)&&(m===0||m===p.length-1))).forEach(c=>{(n.selectedLinearElement?.isEditing||r.length===2)&&Nf(e,n,c,i/2,!1,!0,!1)});e.restore()},pF=(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()},uF=(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)",ys(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},lS=({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||!gS(a)||a.isDeleted)return;let s=aS(i.fixedPoint,a,r);if(!rF(s,e,a,r,n,t))return;let l=n.selectedLinearElement,d=!!l?.isDragging,c=t==="start"?0:e.points.length-1,m=!!l?.selectedPointsIndices?.includes(c);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&$m(s,o,n),!(m&&d)){let p=aS(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=xn.getPointAtIndexGlobalCoordinates(e,c,r);pF(o,n,E,p),uF(o,n,p,VB/1.5,u)}},cS=(e,n,t,o,r)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,d,c]=a;e.save(),e.lineWidth=1/t.zoom.value,n.selectionColor&&(e.strokeStyle=n.selectionColor),i==="rotation"?ys(e,s+d/2,l+c/2,d/2,!0):e.roundRect?(e.beginPath(),e.roundRect(s,l,d,c,2/t.zoom.value),e.fill(),e.stroke()):ws(e,s,l,d,c,s+d/2,l+c/2,r,!0),e.restore()}})},hF=(e,n,t,o,r)=>{let[i,a,,,s,l]=Ol(o,r),d=3,c=20,m=d/t.zoom.value,p=m/2,u=s-i+m,E=l-a+m,g=Math.min(c/t.zoom.value,u),b=Math.min(c/t.zoom.value,E);e.save(),e.fillStyle=n.selectionColor,e.strokeStyle=n.selectionColor,e.lineWidth=m,[[[-u,-E],[0,p],[g,p],[p,0],[p,b]],[[u-p,-E],[p,p],[-g+p,p],[0,0],[0,b]],[[-u,E],[0,-p],[g,-p],[p,0],[p,-b]],[[u-p,E],[p,-p],[-g+p,-p],[0,0],[0,-b]]].forEach(y=>{let[[x,I],[S,C],[P,M],[D,_],[k,L]]=y;e.save(),e.translate(s,l),e.rotate(o.angle),e.beginPath(),e.moveTo(x+S,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()},gF=(e,n,t,o)=>{n.save();let r=uf(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,d=-(e.width/2+r),c=-(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(d,c,i,a),n.restore()},fF=(e,n,t,o,r)=>{let i=hf(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())},EF=(e,n,t,o,r,i)=>{for(let a of n){if(!Xm(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let c=Fl(a,t,r,"center");c&&bS(e,c.centerX+r.scrollX,c.centerY+r.scrollY,c.radius,r,s?.downloadError??void 0)}else{let c=o.imageLoadingProgress.get(a.fileId);if(c!==void 0){let m=Fl(a,t,r,"center");m&&ES(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,c,r,i)}}let d=s?.uploadProgress;if(d){let c=Fl(a,t,r,"top-right");c&&xF(e,c.centerX+r.scrollX,c.centerY+r.scrollY,c.radius,c.lineWidth,d,r,i)}}},Fl=(e,n,t,o)=>{if(!Xm(e))return null;let[r,i,a,s]=Ol(e,n),l=t.zoom.value,d=Math.min(a-r,s-i)*l,c=Math.min(o==="center"?14:11.7,d/(o==="center"?4:4.62))/l,m=Math.min((o==="center"?3:2.6)/l,c/2);if(c<=0||m<=0)return null;if(o==="top-right"){let p=6/l;return{centerX:a-p-c,centerY:i+p+c,radius:c,lineWidth:m}}return{centerX:(r+a)/2,centerY:(i+s)/2,radius:c,lineWidth:m}},ES=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===Mo.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*Ym(i,0,1)),e.stroke()),e.restore()},Ff=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,bF=(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()},xF=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",d=i.color??Ff("--color-primary",s),c=i.color??Ff("--color-warning-darkest","#ec8b14");if(l==="failed"){bS(e,n,t,o,a,{color:i.color??Ff("--color-danger","#e03131")});return}if(l==="uploading"&&ES(e,n,t,o,r,i.progress??0,a,s,{color:d,trackColor:i.trackColor}),bF(e,n,t-o*.02,o*1.125,{color:l==="error"?c:d,lineWidth:Math.max(r*.75,1/a.zoom.value)}),l==="error"){e.save(),e.strokeStyle=c,e.fillStyle=c,e.lineWidth=Math.max(r*.75,1/a.zoom.value),e.lineCap="round",e.beginPath();let m=o*.18,p=t-o*.09;e.moveTo(n-m,p-m),e.lineTo(n+m,p+m),e.moveTo(n+m,p-m),e.lineTo(n-m,p+m),e.stroke(),e.restore()}else l==="pending"&&(e.save(),e.strokeStyle=d,e.lineWidth=Math.max(r*.65,1/a.zoom.value),e.lineCap="round",e.beginPath(),e.moveTo(n,t+o*.072),e.lineTo(n,t-o*.18),e.moveTo(n-o*.144,t-o*.036),e.lineTo(n,t-o*.18),e.lineTo(n+o*.144,t-o*.036),e.stroke(),e.restore())},bS=(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()},yF=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:s,renderConfig:l,editorInterface:d,animationState:c,deltaTime:m})=>{if(n===null)return{};let[p,u]=Ac(n,a),E=c,g=Dc({canvas:n,scale:a,normalizedWidth:p,normalizedHeight:u});g.save(),g.scale(s.zoom.value,s.zoom.value);let b;if(o.forEach(C=>{s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===C.id&&C&&(b=C)}),b&&Bf(g,s,b,t),s.selectionElement&&!s.isCropping)try{oF(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let w=QB(r,s);if(w&&!w.autoResize&&fF(w,g,s,l.selectionColor,d.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&gF(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...c,bindingHighlight:dF(e,g,s.suggestedBinding,i,s,m,c?.bindingHighlight)}:E={...c,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&sF(g,s,i),s.frameToHighlight&&mF(g,s,s.frameToHighlight,t),s.elementsToHighlight&&sS(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:zf(i,s.activeLockedId);sS(g,s,P,{colors:["#ced4da"],dashed:!0})}let y=r.some(C=>Ya(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&Bf(g,s,r[0],t);let x=s.selectedLinearElement,I=x&&xn.getElement(x.elementId,i);if(I&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?iF(g,s):(Va(I)?x.hoverPointIndex===0||x.hoverPointIndex===I.points.length-1:x.hoverPointIndex>=0)&&aF(g,s,t)),hS(I)&&(lS({arrow:I,elementsMap:i,appState:s,context:g,type:"start"}),lS({arrow:I,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=XB(r,s,d),P=r.length===1&&ZB(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Bf(g,s,r[0],t);let M=l.selectionColor||"#000";if(C){let D=HB(r),_=[];for(let L of t.values()){let F=[],Y=l.remoteSelectedElementIds.get(L.id);if(P&&Va(L)&&(L.startBinding||L.endBinding)||(D.has(L.id)&&!tF(s,L)&&F.push(M),Y&&F.push(...Y.map(z=>Jr(z,s.collaborators.get(z))))),F.length){let[z,U,V,G,re,B]=Ol(L,t,!0);_.push({angle:L.angle,x1:z,y1:U,x2:V,y2:G,selectionColors:L.locked?["#ced4da"]:F,dashed:!!Y||L.locked,cx:re,cy:B,activeEmbeddable:s.activeEmbeddable?.element===L&&s.activeEmbeddable.state==="active",padding:L.id===s.croppingElementId||Xm(L)?0:void 0})}}let k=L=>{let F=zf(t,L),[Y,z,U,V]=Gf(F);_.push({angle:0,x1:Y,x2:U,y1:z,y2:V,selectionColors:F.some(G=>G.locked)?["#ced4da"]:["#000"],dashed:!0,cx:Y+(U-Y)/2,cy:z+(V-z)/2,activeEmbeddable:!1})};for(let L of eF(s))k(L);s.editingGroupId&&k(s.editingGroupId),_.forEach(L=>fS(g,s,L))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let D=YB(r[0],s.zoom,t,"mouse",Rf(d));if(!s.viewModeEnabled&&C&&!JB(s.editingTextElement)&&!s.croppingElementId&&cS(g,l,s,D,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&Xm(_)&&hF(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(D=>D.locked)){let D=mS*2/s.zoom.value;g.fillStyle="#fff";let[_,k,L,F]=Gf(r,t),Y=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=M,ws(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=KB([_,k,L,F,(_+L)/2,(k+F)/2],0,s.zoom,"mouse",y?{...Rf(d),rotation:!0}:Rf(d));r.some(V=>!V.locked)&&cS(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]=Ol(D,t,!0);g.save(),s.theme===Mo.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=Ya(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()}}),oS(g,s),EF(g,o,t,e,s,l.selectionColor),g.restore(),zw({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let S;return l.renderScrollbars&&(S=sI(t,p,u,s),g.save(),g.fillStyle=aI,g.strokeStyle="rgba(255,255,255,0.8)",[S.horizontal,S.vertical].forEach(C=>{C&&rm(g,C.x,C.y,C.width,C.height,fn/2)}),g.restore()),{scrollBars:S,animationState:E}},Hf=e=>{let n=yF(e);return e.callback(n),n};import{useEffect as Ul,useMemo as xS,useRef as Kf,useState as wF}from"react";import{bumpVersion as zl,getLinearElementSubType as Xa,mutateElement as Xf,updateElbowArrowPoints as vF}from"@excalidraw/element";import{pointFrom as jm,pointRotateRads as IF}from"@excalidraw/math";import{hasBoundTextElement as SF,isArrowBoundToElement as TF,isArrowElement as CF,isElbowArrow as PF,isLinearElement as qf,isUsingAdaptiveRadius as kF}from"@excalidraw/element";import{getCommonBoundingBox as MF,getElementAbsoluteCoords as AF}from"@excalidraw/element";import{getBoundTextElement as SS,getBoundTextMaxHeight as DF,getBoundTextMaxWidth as LF,redrawTextBoundingBox as _F}from"@excalidraw/element";import{wrapText as RF}from"@excalidraw/element";import{assertNever as NF,CLASSES as BF,getFontString as Uf,isProdEnv as FF,mapFind as OF,reduceToCommonValue as zF,ROUNDNESS as Wf,sceneCoordsToViewportCoords as GF,updateActiveTool as yS}from"@excalidraw/common";import{measureText as wS}from"@excalidraw/element";import{LinearElementEditor as HF}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Vf,newElement as UF,newLinearElement as WF}from"@excalidraw/element";import{ShapeCache as VF}from"@excalidraw/element";import{updateBindings as YF}from"@excalidraw/element";import{jsx as jf}from"react/jsx-runtime";var KF=8,XF=10,Gl=["rectangle","diamond","ellipse"],Hl=["line","sharpArrow","curvedArrow","elbowArrow"],$F=new Set(Gl),ZF=new Set(Hl),$a=e=>$F.has(e),qm=e=>e==="arrow"||ZF.has(e),ro=Qe(null),Wl=new Map,Vl=new Map,jF=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=Kf(null);return Ul(()=>{if(n.length===0){e.updateEditorAtom(ro,null);return}let o=Jm(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(ro,null),t.current=null)},[n,e]),Ul(()=>()=>{Wl.clear(),Vl.clear()},[]),jf(qF,{app:e,elements:n})},qF=({app:e,elements:n})=>{let t=Jm(n),o=xS(()=>t==="generic"?CS(n):[],[t,n]),r=xS(()=>t==="linear"?Zf(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>Xa(m)===Xa(r[0])):!1,[a,s]=wF({x:0,y:0}),l=Kf(""),d=Kf(null);Ul(()=>{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]=AF(m[0],e.scene.getNonDeletedElementsMap());u=IF(jm(b,w),jm(y,x),m[0].angle)}else{let{minX:b,maxY:w}=MF(m);u=jm(b,w)}let{x:E,y:g}=GF({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),Ul(()=>{for(let m of r){let p=$f(m.id,nO(m));Vl.has(p)||Vl.set(p,m)}},[r]),Ul(()=>{for(let m of o)if(!Wl.has(m.id)){let p=SS(m,e.scene.getNonDeletedElementsMap());p&&Wl.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let c=t==="linear"?[["line",$o],["sharpArrow",qo],["curvedArrow",Qo],["elbowArrow",Jo]]:t==="generic"?[["rectangle",_i],["diamond",Ri],["ellipse",Ni]]:[];return jf("div",{ref:d,tabIndex:-1,style:{position:"absolute",top:`${a.y+(XF+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-KF}px`,zIndex:2},className:BF.CONVERT_ELEMENT_TYPE_POPUP,children:c.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&Xa(r[0])===m);return jf(Z,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Fe("convertElementType",m,"ui"),Jf(e,{conversionType:t,nextType:m}),d.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},JF=(e,n,t)=>{let o=LF(e,n),r=DF(e,n),i=RF(n.text,Uf(n),o),a=wS(i,Uf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=wS(n.text,Uf(l),n.lineHeight)}Xf(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),_F(n,e,t)},Jf=(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=CS(r),d=s.every(c=>c.type===s[0].type)?Gl.indexOf(s[0].type):-1;if(t=t??Gl[(d+Gl.length+a)%Gl.length],t&&$a(t)){let c={};for(let p of s){let u=IS(p,t,e);c[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())c[p.id]?m.push(c[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(c)){let u=SS(p,e.scene.getNonDeletedElementsMap());u&&(Wl.get(p.id)&&Xf(u,e.scene.getNonDeletedElementsMap(),{fontSize:Wl.get(p.id)?.fontSize??u.fontSize}),JF(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:yS(p,{type:"selection"})}))}}if(n==="linear"){let s=Zf(r);if(!t){let d=zF(s,Xa),c=d?Hl.indexOf(d):-1;t=Hl[(c+Hl.length+a)%Hl.length]}if(qm(t)){let d=[],c=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Vl.get($f(m.id,t));if(p&&Xa(p)===t)c.set(p.id,p),d.push(p);else{let u=IS(m,t,e);c.set(u.id,u),d.push(u)}}e.scene.replaceAllElements(c);for(let m of d)if(qf(m))if(PF(m)){let p=QF(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=vF(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Xf(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=OF(["line","sharpArrow","curvedArrow"],u=>Vl.get($f(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=Zf(e.scene.getSelectedElements(e.state));e.setState(d=>({selectedElementIds:i,selectedLinearElement:l.length===1?new HF(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:yS(d,{type:"selection"})}))}return!0},Jm=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if($a(t.type))return"generic";TS(t)&&(n=!0)}return n?"linear":null},TS=e=>qf(e)&&(!CF(e)||!TF(e)&&!SF(e)),$f=(e,n)=>`${e}:${n}`,CS=e=>e.filter(n=>$a(n.type)),Zf=e=>e.filter(n=>TS(n)),Zm=20,Ka=(e,n)=>e[0]===n[0],Yf=(e,n)=>e[1]===n[1],vS=(e,n)=>Ka(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),QF=e=>{let n=[e.points[0]],t=eO(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])<Zm?s[0]=a[0]:Math.abs(s[1]-a[1])<Zm&&(s[1]=a[1]),Ka(a,s)||Yf(a,s)||n.push(jm(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)Ka(n[i-1],n[i])&&Ka(n[i],n[i+1])||Yf(n[i-1],n[i])&&Yf(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],d=Ka(a,s),c=Ka(s,l);if(d!==c){let m=vS(a,s),p=vS(s,l);if(m<Zm||p<Zm){if(p<m)d?l[0]=a[0]:l[1]=a[1];else if(c)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},eO=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},IS=(e,n,t)=>{if(!tO(e.type,n)){if(!FF())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(VF.delete(e),$a(n)){let o=zl(UF({...e,type:n,roundness:e.roundness?{type:kF(n)?Wf.ADAPTIVE_RADIUS:Wf.PROPORTIONAL_RADIUS}:e.roundness}));return YF(o,t.scene,t.state),o}if(qm(n))switch(n){case"line":return zl(WF({...e,type:"line"}));case"sharpArrow":return zl(Vf({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return zl(Vf({...e,type:"arrow",elbowed:!1,roundness:{type:Wf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return zl(Vf({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return NF(n,`unhandled conversion type: ${n}`),e},tO=(e,n)=>!!($a(e)&&$a(n)||qm(e)&&qm(n)),nO=e=>qf(e)?Xa(e):e.type,PS=jF;import{bindBindingElementToFixedPoint as oO,dragNewTextElement as rO,getBoundTextElement as iO,getEndpointBoundTextDragAnchor as aO,getTextBindingForArrowEndpoint as sO,getUnboundArrowEndpointAtPoint as lO,isArrowElement as cO,isBindingEnabled as dO,isEndpointBoundText as mO,isTextElement as pO}from"@excalidraw/element";import{pointFrom as uO}from"@excalidraw/math";var Qm=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(!dO(this.app.state))return null;let o=lO(uO(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!cO(r)||iO(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 sO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){oO(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!pO(n)||!mO(n,this.app.scene.getNonDeletedElementsMap())?!1:(rO({newElement:n,...aO(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as hO,BUCKET_FILL_BACKGROUND_PICKS as gO,COLOR_PALETTE as MS,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as fO,getSizeFromPoints as EO,isTransparent as bO,THEME as xO}from"@excalidraw/common";import{pointFrom as kS}from"@excalidraw/math";import{computeBucketFillPolygon as yO,isBucketFillCompatible as wO,isFrameLikeElement as vO,isRestylableFill as IO,newLinearElement as SO,ShapeCache as TO}from"@excalidraw/element";var Qf=gO.filter(e=>e!==MS.white),ep=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=Qf.indexOf(n),o=Qf[(t+1)%Qf.length];this.app.actionManager.executeAction(Pd,"keyboard",{currentItemBackgroundColor:o})});v(this,"openTemporaryEyeDropper",()=>{if(Et.get(Gt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(Pd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Gt,n)});v(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&Et.get(Gt)===n&&this.app.updateEditorAtom(Gt,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}),TO.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=kS(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=yO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&wO(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&&IO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:d}=EO(s.scenePoints),[c,m]=s.scenePoints[0],p=s.scenePoints.map(y=>kS(y[0]-c,y[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?vO(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=SO({type:"line",x:c,y:m,width:l,height:d,points:p,polygon:!0,strokeColor:"transparent",backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:"solid",roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:E,groupIds:g}),w=this.app.scene.getElementsIncludingDeleted().findIndex(y=>y.id===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)=>bO(n)?MS.green[fO]:hO(n,t===xO.DARK))}};import{CURSOR_TYPE as Yl,MIME_TYPES as np,THEME as AS}from"@excalidraw/common";var DS='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',CO='<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"/>',LS='<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"/>',PO=`data:${np.svg},${encodeURIComponent(`${DS}${LS}</svg>`)}`,kO=`data:${np.svg},${encodeURIComponent(`${DS}${CO}${LS}</svg>`)}`,MO=e=>{let n=Lu.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${np.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>`)}`},tp=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(Yl.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(bs({activeTool:n}))this.set(Yl.GRAB);else if(rn({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(Yl.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${MO(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===AS.LIGHT?PO:kO;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(Yl.AUTO):this.set(Yl.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===AS.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(np.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as RO}from"@excalidraw/common";import{bindBindingElement as NO,convertToShape as BO,convertToShapeHandlePointerMoveFromPointerDown as FO,getHoveredElementForBinding as _S,isBindingElement as OO,isLineElement as zO,LinearElementEditor as eE,maxBindingDistance_simple as RS,newArrowElement as GO,updateBoundPoint as HO}from"@excalidraw/element";import{getStrokeWidthByKey as AO,THEME as DO}from"@excalidraw/common";import{clamp as LO,pointFrom as _O}from"@excalidraw/math";var op=class{constructor(n){this.app=n;v(this,"trail");this.trail=new Rn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===DO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>LO(AO("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])=>_O(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var rp=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(ut),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});v(this,"handlePointerMove",n=>FO(this.app,n));v(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=RS(t.state.zoom),a=["start","end"].map(c=>{let m=eE.getPointAtIndexGlobalCoordinates(n,c==="start"?0:-1,o);return{startOrEnd:c,globalPoint:m,target:_S(m,r,o,i)}}),s=!!a[0].target&&a[0].target===a[1].target,l=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:c,globalPoint:m,target:p}of a)p&&NO(n,p,s?"inside":"orbit",c,t.scene,m,t.state.isBindingEnabled,l);if(s)return;let d=new Map;for(let{startOrEnd:c,target:m}of a){if(!m)continue;let p=HO(n,c==="start"?"startBinding":"endBinding",c==="start"?n.startBinding:n.endBinding,m,o);p&&d.set(c==="start"?0:n.points.length-1,{point:p})}d.size&&eE.movePoints(n,t.scene,d)});v(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=RS(t.state.zoom),[a,s]=[0,-1].map(l=>_S(eE.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:GO({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||BO(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:RO(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&zO(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&OO(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new op(n)}};import{isArrowKey as UO,KEYS as li}from"@excalidraw/common";import{makeNextSelectedElementIds as WO,CaptureUpdateAction as VO,FlowChartCreator as YO,FlowChartNavigator as KO,getSelectedElements as NS,isFlowchartNodeElement as XO}from"@excalidraw/element";var ip=class e{constructor(n){this.app=n;v(this,"creator",new YO);v(this,"navigator",new KO);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===li.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!UO(n.key))return{type:"none"};if(n[li.CTRL_OR_CMD]&&!n.shiftKey){let a=NS(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&XO(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=NS(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[li.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:WO({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:VO.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case li.ARROW_UP:return"up";case li.ARROW_DOWN:return"down";case li.ARROW_RIGHT:return"right";case li.ARROW_LEFT:return"left";default:return"right"}}};import{createGifPlaybackMetadata as BS,hasPlayableGif as $O,isInitializedImageElement as ZO,newElementWith as FS,ShapeCache as jO}from"@excalidraw/element";import{MIME_TYPES as OS}from"@excalidraw/common";var ap=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||$O(this.app.scene.getNonDeletedElements(),this.app.imageCache)&&(this.playbackRaf=requestAnimationFrame(this.tick))});v(this,"createPlaceholderDecodeState",(n,t)=>{if(t.type!==OS.gif)return null;let o=n.id;this.app.imageCache.set(o,{image:new Promise(()=>{}),mimeType:OS.gif,gifDecodeStatus:"pending"});let r=FS(n,{fileId:o,gifPlayback:BS({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:FS(n,{gifPlayback:n.gifPlayback?{...n.gifPlayback,playing:t.playing??n.gifPlayback.playing}:BS(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(!ZO(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,d=i.delays[l]??100;n-s.lastFrameTime>=d/a&&(s.frameIndex=(l+1)%i.frames.length,s.lastFrameTime=n,jO.delete(r),t=!0)}t&&this.app.imagePlaceholderUpdateEmitter.trigger(),o&&(this.playbackRaf=requestAnimationFrame(this.tick))})}};import{debounce as qO,easeOut as VS,isBounds as JO}from"@excalidraw/common";import{clamp as YS}from"@excalidraw/math";import{getCommonBounds as zS,getElementsInGroup as QO,isElementLink as e9,isExcalidrawElement as t9,parseElementLinkFromURL as n9}from"@excalidraw/element";var sp="animateScrollToContent",Za="animateScrollConstraintsSnapBack",GS=500,o9=250,r9=200,tE=302,HS={full:216,compact:64},i9=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")},a9=(e,n)=>{let t=n.get(e);return t?[t]:QO(n,e)},US=(e,n,t)=>{if(typeof e=="string"){let a=e9(e),s=a?"link":"element",l=a?n9(e):e,d=l?a9(l,n):[];return d.length?{bounds:zS(d,n),type:s}:{bounds:null,type:s}}if(JO(e))return{bounds:e,type:"area"};if(i9(e)&&!t9(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:zS(r,n),type:"element"}},s9=e=>e===!1?0:e===!0||e==null?vu:Math.max(e,0),l9=(e,n,t="scale-down",o,r)=>{let{appState:i}=_r({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},WS=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=l9(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[s,l,d,c]=n,m={x:s,y:l,width:d-s,height:c-l,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:a.zoom.value,overscroll:s9(r.overscroll),offsets:o};return{...Vn({...e,...a,scrollConstraints:m}),scrollConstraints:m}},c9=({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}}},d9=e=>e===!1?null:e===!0||e==null?GS:e.duration??GS,m9=(e,n,t,o,r)=>{st.start(sp,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),d=VS(YS(l,0,1));return l<1?(o({...c9({from:e,target:n,factor:d}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},p9=(e,n,t=o9)=>{let o=Vn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||st.running(sp))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;st.start(Za,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,d=Math.min(l/t,1),c=1-VS(YS(d,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=Vn(m),u=p.zoom.value;return{scrollX:p.scrollX+r*c/u,scrollY:p.scrollY+i*c/u,zoom:p.zoom}}),d<1?{elapsed:l}:null})},lp=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=Xn().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"?HS.compact:HS.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:tE})}let s=n?.padding??24,l=n?.paddingTop??s,d=(r?n?.paddingLeft:n?.paddingRight)??s,c=n?.paddingBottom??s,m=(r?n?.paddingRight:n?.paddingLeft)??s,p={top:i.top+l,right:i.right+d,bottom:i.bottom+c,left:i.left+m};return{top:n?.top??p.top,right:(r?n?.left:n?.right)??p.right,bottom:n?.bottom??p.bottom,left:(r?n?.right:n?.left)??p.left}});v(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=US(n.target,t,o);return r?WS(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});v(this,"setViewport",n=>{if(n===null){this.cancelTransition(),st.cancel(Za),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:d}=US(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!l){d==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let c=WS(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=d9(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),st.cancel(Za),this.snapBackDebounced.cancel(),m===null){this.app.setState({...c,shouldCacheIgnoreZoom:!1});return}let u={target:c};this.activeTransition=u,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),m9(p,c,m,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});v(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||st.cancel(Za),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(),Vn(r,a)}),!0});v(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Vn(t,n):null)});v(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});v(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||p9(this.app.state,n=>this.app.setState(t=>n(t)))});v(this,"snapBackDebounced",qO(this.snapBack,r9));v(this,"cancelTransition",()=>{this.activeTransition=null,st.cancel(sp)});v(this,"destroy",()=>{this.cancelTransition(),st.cancel(Za),this.snapBackDebounced.cancel()})}get isAnimating(){return st.running(sp)||st.running(Za)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import cp from"react";var u9=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,h9=/{{([\w-]+)}}/,g9=/<([\w-]+)>/,f9=/<\/([\w-]+)>/,E9=(e,n)=>{let t=[{name:"",children:[]}];return e.split(u9).filter(Boolean).forEach(o=>{let r=o.match(g9),i=o.match(f9),a=o.match(h9);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(),d=cp.createElement(cp.Fragment,{},...l.children),c=n[l.name];typeof c=="function"&&t[t.length-1].children.push(c(d))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let 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},b9=({i18nKey:e,children:n,...t})=>{let{t:o}=_e();return cp.createElement(cp.Fragment,{},...E9(o(e),t))},ci=b9;import{jsx as yn,jsxs as KS}from"react/jsx-runtime";var x9=()=>KS("div",{"data-testid":"brave-measure-text-error",children:[yn("p",{children:yn(ci,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(ci,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(ci,{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(ci,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>yn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>KS("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),XS=x9;import P9 from"clsx";import k9 from"react";import{isDarwin as $S}from"@excalidraw/common";var y9={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:[$S?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[$S?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")],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+R")],toolLock:[N("Q")]},je=(e,n=0)=>{let t=y9[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as w9,useRef as ZS,useEffect as jS}from"react";import{unstable_batchedUpdates as v9}from"react-dom";import{KEYS as I9,queryFocusableElements as S9}from"@excalidraw/common";import{clamp as qS}from"@excalidraw/math";import T9 from"clsx";import{jsx as C9}from"react/jsx-runtime";var Er=10,JS=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=ZS(null);jS(()=>{let c=l.current;if(!c)return;c.contains(document.activeElement)||c.focus();let m=p=>{if(p.key===I9.TAB){let u=S9(c),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===c?(p.shiftKey?u[u.length-1]?.focus():u[0].focus(),p.preventDefault(),p.stopImmediatePropagation()):g===0&&p.shiftKey?(u[u.length-1]?.focus(),p.preventDefault(),p.stopImmediatePropagation()):g===u.length-1&&!p.shiftKey&&(u[0]?.focus(),p.preventDefault(),p.stopImmediatePropagation())}};return c.addEventListener("keydown",m),()=>c.removeEventListener("keydown",m)},[]);let d=ZS(null);return w9(()=>{if(r&&l.current&&t!=null&&n!=null){let c=l.current,{width:m,height:p}=c.getBoundingClientRect();if(d.current?.top===t&&d.current?.left===n)return;d.current={top:t,left:n};let u=Math.max(0,i-Er*2);m>=u?(c.style.width=`${u}px`,c.style.left=`${Er}px`,c.style.overflowX="scroll"):c.style.left=`${qS(n,Er,i-Er-m)}px`;let E=Math.max(0,a-Er*2);p>=E?(c.style.height=`${E}px`,c.style.top=`${Er}px`,c.style.overflowY="scroll"):c.style.top=`${qS(t,Er,a-Er-p)}px`}},[t,n,r,i,a]),jS(()=>{if(o){let c=m=>{l.current?.contains(m.target)||v9(()=>o(m))};return document.addEventListener("pointerdown",c,!1),()=>document.removeEventListener("pointerdown",c,!1)}},[o]),C9("div",{className:T9("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as Ao,jsxs as eT}from"react/jsx-runtime";var qe="separator",QS=e=>"onSelect"in e,tT=k9.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=Qn(),a=Ui(),s=n.reduce((l,d)=>d?d===qe||QS(d)?(l.push(d),l):((!d.predicate||d.predicate(a,i,e.app.props,e.app))&&l.push(d),l):l,[]);return Ao(JS,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:Ao("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,d)=>{if(l===qe)return!s[d-1]||s[d-1]===qe?null:Ao("hr",{className:"context-menu-item-separator"},d);if(QS(l))return Ao("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:eT("button",{type:"button",className:"context-menu-item",children:[Ao("div",{className:"context-menu-item__label",children:l.label}),Ao("kbd",{className:"context-menu-item__shortcut"})]})},l.key);let c=l.name,m="";return l.label&&(typeof l.label=="function"?m=f(l.label(a,i,e.app)):m=f(l.label)),Ao("li",{"data-testid":c,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:eT("button",{type:"button",className:P9("context-menu-item",{dangerous:c==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[Ao("div",{className:"context-menu-item__label",children:m}),Ao("kbd",{className:"context-menu-item__shortcut",children:c?je(c):""})]})},d)})})})});import{useId as M9}from"react";import A9 from"clsx";import{Fragment as D9,jsx as Kl,jsxs as nT}from"react/jsx-runtime";var dp=({border:e,style:n})=>Kl("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),mp=({label:e,border:n})=>{let t=M9(),o=nT(D9,{children:[e.icon&&Kl("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return nT("div",{className:A9("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&&Kl("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),Kl("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&Kl("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:an})]})};import cs from"clsx";import oV from"react";import{CLASSES as rV,TOOL_TYPE as Lk,arrayToMap as iV,isShallowEqual as Yp}from"@excalidraw/common";import{mutateElement as aV,ShapeCache as sV}from"@excalidraw/element";import{showSelectedShapeActions as lV}from"@excalidraw/element";import{createIsolation as L9}from"jotai-scope";import nE from"react";import Do from"tunnel-rat";var oE=nE.createContext(null),ot=()=>nE.useContext(oE),_9=L9(),oT=()=>nE.useMemo(()=>({MainMenuTunnel:Do(),WelcomeScreenMenuHintTunnel:Do(),WelcomeScreenToolbarHintTunnel:Do(),WelcomeScreenHelpHintTunnel:Do(),WelcomeScreenCenterTunnel:Do(),FooterCenterTunnel:Do(),DefaultSidebarTriggerTunnel:Do(),DefaultSidebarTabTriggersTunnel:Do(),OverwriteConfirmDialogTunnel:Do(),tunnelsJotai:_9}),[]);import xr from"clsx";import{useRef as U9}from"react";import{Popover as br}from"radix-ui";import{CLASSES as hT}from"@excalidraw/common";import{isArrowElement as uT}from"@excalidraw/element";import{forwardRef as rT}from"react";import iT from"clsx";import{jsx as aT}from"react/jsx-runtime";var R9=rT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>aT("div",{className:iT("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),N9=rT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>aT("div",{className:iT("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Bt={Row:R9,Col:N9};import{isTransparent as sT}from"@excalidraw/common";import{shouldAllowVerticalAlign as B9,suppportsHorizontalAlign as F9,hasBoundTextElement as lT,isElbowArrow as O9,isImageElement as cT,isLinearElement as z9,isTextElement as G9,hasStrokeColor as dT,toolIsArrow as H9}from"@excalidraw/element";var mT=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return dT(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>dT(o.type))},pT=(e,n)=>Yo(e.activeTool.type)||n.some(t=>Yo(t.type)),pp=(e,n,t,o)=>{let r=e.activeTool.type,i=c=>c(r)||n.some(m=>c(m.type)),a=n.length===1,s=n.length===2&&(lT(n[0])||lT(n[1])),l=!!(e.editingTextElement||e.newElement),d=n.length>0;return{hasSelection:d,showExtraActions:d&&!l,strokeColor:mT(e,n),backgroundColor:pT(e,n),fill:r==="bucketfill"||Yo(r)&&!sT(e.currentItemBackgroundColor)||n.some(c=>Yo(c.type)&&!sT(c.backgroundColor)),strokeWidth:i(sx),freedrawMode:i(lx),strokeStyle:i(Iu),sloppiness:i(Iu),roundness:i(cx),arrowType:i(H9),arrowheads:i(Es),text:r==="text"||n.some(G9),textAlign:r==="text"||F9(n,t),verticalAlign:B9(n,t),opacity:r!=="autoshape"||d,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(c=>c.type==="freedraw")||ce(t,e).some(c=>c.type==="freedraw"),align:!s&&dt(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(cT)&&dt(e,o),link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&cT(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&z9(n[0])&&!O9(n[0])}};import{Fragment as Qt,jsx as q,jsxs as Ce}from"react/jsx-runtime";var rE=xr([hT.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),gT=({renderAction:e})=>Ce("fieldset",{children:[q("legend",{children:f("labels.layers")}),Ce("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),fT=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Ce("fieldset",{children:[q("legend",{children:f("labels.align")}),Ce("div",{className:"buttonList",children:[o?Ce(Qt,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Ce(Qt,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),q("div",{style:{flexBasis:"100%",height:0}}),Ce("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Ce(Qt,{children:[q("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},ET=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=Ci(n,e),i=pp(e,r,n,o);return e.activeTool.type==="bucketfill"?Ce("div",{className:"selected-shape-actions",children:[q("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Ce("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(Qt,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&q(Qt,{children:t("changeSloppiness")}),i.roundness&&q(Qt,{children:t("changeRoundness")}),i.arrowType&&q(Qt,{children:t("changeArrowType")}),i.text&&Ce(Qt,{children:[q("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&q(Qt,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&q(gT,{renderAction:t}),i.align&&q(fT,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Ce("fieldset",{children:[q("legend",{children:f("labels.actions")}),Ce("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")]})]})]})},bT=({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:Ce(br.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:E0})}),a&&q(xo,{className:rE,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Ce("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&q(Qt,{children:n("changeStrokeStyle")}),o.sloppiness&&q(Qt,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},xT=({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:Ce(br.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("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=mt(o,a,d=>uT(d)?d.elbowed?"elbow":d.roundness?"round":"sharp":null,d=>uT(d),d=>d?null:e.currentItemArrowType);return l==="elbow"?Jo:l==="round"?Qo:qo})()})}),s&&q(xo,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},yT=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=G0(),s=e.openPopup==="compactTextProperties";return q("div",{className:"compact-action-item",children:Ce(br.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("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:Wx})}),e.openPopup==="compactTextProperties"&&q(xo,{className:rE,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Ce("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},wT=({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:Ce(br.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[q(br.Trigger,{asChild:!0,children:q("button",{type:"button",className:xr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:Bx})}),s&&q(xo,{className:rE,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Ce("div",{className:"selected-shape-actions",children:[t.layers&&q(gT,{renderAction:n}),t.align&&q(fT,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Ce("fieldset",{children:[q("legend",{children:f("labels.actions")}),Ce("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},W9=({renderAction:e,predicates:n})=>n.lineEditor?q("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,vT=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Ci(n,e),a=pp(e,i,n,o),{container:s}=Ne();return Ce("div",{className:"compact-shape-actions",children:[a.strokeColor&&q("div",{className:xr("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(bT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(xT,{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&&Ce(Qt,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(yT,{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(wT,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},IT=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Ci(n,e),a=pp(e,i,n,o),{container:s}=Ne(),l=U9(null),d=l.current?.getBoundingClientRect()?.width??0,c=9,m=6,p=32,u=c*p+(c-1)*m,E=p+m,g=d>=u+E,b=d>=u+2*E;return Ce(We,{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:[Ce("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&q("div",{className:xr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),q(bT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(xT,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),q(W9,{renderAction:t,predicates:a}),a.text&&Ce(Qt,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(yT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),q(wT,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Ce("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")})]})]})},ST=({renderAction:e})=>q(Bt.Col,{gap:1,className:hT.ZOOM_ACTIONS,children:Ce(Bt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),TT=({renderAction:e,className:n})=>Ce("div",{className:`undo-redo-buttons ${n}`,children:[q("div",{className:"undo-button-container",children:q(pt,{label:f("buttons.undo"),children:e("undo")})}),q("div",{className:"redo-button-container",children:Ce(pt,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),CT=({showExitZenModeBtn:e})=>q("button",{type:"button",className:xr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import V9 from"clsx";import{useState as Y9,useEffect as K9}from"react";import{THEME as X9}from"@excalidraw/common";import{jsx as iE,jsxs as $9}from"react/jsx-runtime";var up=({delay:e,theme:n})=>{let[t,o]=Y9(!!e);return K9(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:$9("div",{className:V9("LoadingMessage",{"LoadingMessage--dark":n===X9.DARK}),children:[iE("div",{children:iE(bo,{})}),iE("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as Ep,useEffect as $T}from"react";import Iz from"clsx";import{KEYS as cE,capitalizeString as ZT}from"@excalidraw/common";import XT from"react";import{DropdownMenu as xz}from"radix-ui";import{CLASSES as yz}from"@excalidraw/common";import Z9 from"clsx";import{useCallback as j9,useEffect as q9,useRef as J9}from"react";import{CLASSES as Q9,EVENT as PT,KEYS as ez}from"@excalidraw/common";import{DropdownMenu as tz}from"radix-ui";import{jsx as hp}from"react/jsx-runtime";var kT=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=be(),l=J9(null),d=Hi({onClickOutside:n});Gi(l,j9(m=>{l.current?.closest(`.${Q9.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||d.onClickOutside?.()},[d])),q9(()=>{if(!r)return;let m=u=>{u.key===ez.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),d.onClickOutside?.())},p={capture:!0};return document.addEventListener(PT.KEYDOWN,m,p),()=>{document.removeEventListener(PT.KEYDOWN,m,p)}},[d,r]);let c=Z9(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return hp(Ph.Provider,{value:{onSelect:o},children:hp(tz.Content,{ref:l,className:c,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?hp(Bt.Col,{className:"dropdown-menu-container",children:e}):hp(We,{className:"dropdown-menu-container",padding:2,children:e})})})};kT.displayName="DropdownMenuContent";var MT=kT;import{jsx as oz}from"react/jsx-runtime";var nz=({children:e,className:n="",selected:t,...o})=>oz("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),AT=nz;import{DropdownMenu as rz}from"radix-ui";import{jsx as aE}from"react/jsx-runtime";var DT=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let d=fd(r);return aE(rz.Item,{className:"radix-menu-item",onSelect:d,asChild:!0,children:aE("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:or(i,a),title:l.title??l["aria-label"],children:aE(rr,{icon:e,shortcut:n,children:o})})})},ja=DT;DT.displayName="DropdownMenuItemLink";import{jsx as iz}from"react/jsx-runtime";var LT=()=>iz("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),_T=LT;LT.displayName="DropdownMenuSeparator";import{DropdownMenu as pz}from"radix-ui";import az from"clsx";import{DropdownMenu as sz}from"radix-ui";import{useCallback as lz,useState as RT}from"react";import{jsx as lE}from"react/jsx-runtime";var sE=-4,cz=4,NT=({children:e,className:n})=>{let t=be(),o=az(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=lz(d=>{if(d){let m=d.closest(".dropdown-menu-container")?.getBoundingClientRect();if(m){let p=d.getBoundingClientRect().width,E=window.innerWidth-m.right;E<p+20&&(a(E-p+sE),l(sE+8))}}},[]),[i,a]=RT(cz),[s,l]=RT(sE);return lE(sz.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?lE(Bt.Col,{className:"dropdown-menu-container",children:e}):lE(We,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},BT=NT;NT.displayName="DropdownMenuSubContent";import{DropdownMenu as dz}from"radix-ui";import{jsx as FT,jsxs as mz}from"react/jsx-runtime";var OT=({children:e,icon:n,shortcut:t,className:o})=>mz(dz.SubTrigger,{className:`${or(o)} dropdown-menu__submenu-trigger`,children:[FT(rr,{icon:n,shortcut:t,children:e}),FT("div",{className:"dropdown-menu__submenu-trigger-icon",children:y0})]}),zT=OT;OT.displayName="DropdownMenuSubTrigger";import GT from"react";var gp=e=>n=>{let t=GT.Children.toArray(n).find(o=>GT.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},HT=gp("DropdownMenuTrigger"),UT=gp("DropdownMenuContent"),WT=gp("DropdownMenuSubTrigger"),VT=gp("DropdownMenuSubContent");import{jsxs as uz}from"react/jsx-runtime";var fp=({children:e})=>{let n=WT(e),t=VT(e);return uz(pz.Sub,{children:[n,t]})};fp.Trigger=zT;fp.Content=BT;fp.displayName="DropdownMenuSub";var yr=fp;import hz from"clsx";import{DropdownMenu as gz}from"radix-ui";import{jsx as fz}from"react/jsx-runtime";var YT=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=be(),a=hz(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return fz(gz.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},KT=YT;YT.displayName="DropdownMenuTrigger";import{jsx as bz}from"react/jsx-runtime";var Ez=e=>bz(qt,{...e,icon:e.checked?Hc:$c}),io=Ez;import{jsx as vz,jsxs as wz}from"react/jsx-runtime";var Bn=({children:e,open:n})=>{let t=HT(e),o=UT(e),r=o&&XT.isValidElement(o)?XT.cloneElement(o,{open:n}):o;return vz(xz.Root,{open:n,modal:!1,children:wz("div",{className:yz.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Bn.Trigger=KT;Bn.Content=MT;Bn.Item=qt;Bn.ItemCheckbox=io;Bn.ItemLink=ja;Bn.ItemCustom=AT;Bn.Group=Gs;Bn.Separator=_T;Bn.Sub=yr;var pe=Bn;Bn.displayName="DropdownMenu";import{Fragment as dE,jsx as Re,jsxs as qa}from"react/jsx-runtime";var Sz=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Lt))return null;let t=f("buttons.objectsSnapMode");return Re(Z,{type:"toggle",icon:jo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Lt,"ui")})},Tz=({app:e})=>Re(Z,{type:"button",icon:Fi,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),jT=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=Ep(!1),[l,d]=Ep("rectangle"),[c,m]=Ep("arrow");$T(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&d(o.type)},[o.type]),$T(()=>{(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:ZT(f(`toolBar.${G}`)),fillable:ze[G].fillable})),y=["arrow","line"].map(G=>({type:G,icon:ze[G].icon,title:ZT(f(`toolBar.${G}`)),fillable:ze[G].fillable})),[x,I]=Ep(0),S=36,C=4,P=7,M=P*S+(P-1)*C,D=S+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&&ta.includes(o.type),z=Y||F.includes(o.type),U=z?Y?ze[o.type].icon:o.type==="text"?Pn:o.type==="image"?Fr:o.type==="frame"?jn:o.type==="embeddable"?Zo:o.type==="laser"?qn:o.type==="bucketfill"?Zn:Ss:Ss,V={app:e,activeTool:o,hideShortcut:!0};return qa("div",{className:"mobile-toolbar",ref:G=>{G&&I(G.getBoundingClientRect().width)},children:[Re(zd,{...V}),Re(Gd,{...V,setAppState:t}),r?Re(Zs,{...V}):Re(Hd,{...V}),Re(Js,{...V}),!r&&Re(ea,{app:e,options:w,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:G=>{(G==="rectangle"||G==="diamond"||G==="ellipse")&&(d(G),e.setActiveTool({type:G}))},displayedOption:w.find(G=>G.type===l)||w[0]}),!r&&Re(ea,{app:e,options:y,activeTool:o,defaultOption:c,"data-testid":"toolbar-arrow",onToolChange:G=>{(G==="arrow"||G==="line")&&(m(G),e.setActiveTool({type:G}))},displayedOption:y.find(G=>G.type===c)||y[0]}),_&&Re(js,{...V}),r&&k&&Re(Tz,{app:e}),k&&Re(qs,{...V}),!r&&L&&Re(nw,{...V,hideShortcut:!0}),qa(pe,{open:a,children:[Re(pe.Trigger,{className:Iz("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:S,height:S,display:"flex",alignItems:"center",justifyContent:"center"},children:U}),qa(pe.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&ta.map(G=>Re(pe.Item,{onSelect:()=>e.setActiveTool({type:G}),icon:ze[G].icon,"data-testid":`toolbar-${G}`,selected:o.type===G,shortcut:Od(G),disabled:Je(e,G),children:f(`toolBar.${G}`)},G)),!r&&Re("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(Lt)&&Re(pe.Item,{onSelect:()=>n.executeAction(Lt,"ui"),icon:jo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:je("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&qa(dE,{children:[r&&Re("div",{className:"App-toolbar__dropdown-divider"}),Re(pe.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Xo:Eo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:cE.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Pn,shortcut:cE.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:Je(e,"text"),children:f("toolBar.text")}),i&&!k&&Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Fr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:Je(e,"image"),children:f("toolBar.image")}),!r&&!L&&Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:jn,shortcut:cE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:Je(e,"frame"),children:f("toolBar.frame")}),!r&&qa(dE,{children:[Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Zo,"data-testid":"toolbar-embeddable",selected:g,disabled:Je(e,"embeddable"),children:f("toolBar.embeddable")}),Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Gr,shortcut:oa("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:Je(e,"autoshape"),children:f("toolBar.autoshape")}),Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:qn,"data-testid":"toolbar-laser",selected:E,disabled:Je(e,"laser"),children:f("toolBar.laser")}),Re(pe.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Zn,"data-testid":"toolbar-bucketfill",selected:b,disabled:Je(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&qa(dE,{children:[Re("div",{className:"App-toolbar__divider"}),Re(Sz,{actionManager:n,app:e})]})]})};import Cz from"clsx";import{jsx as Pz}from"react/jsx-runtime";var bp=({children:e,side:n,className:t})=>Pz("div",{className:Cz("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import kz from"clsx";import{jsx as Mz}from"react/jsx-runtime";var Ja=e=>e.penDetected?Mz(Z,{className:kz("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Ux,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as qT,jsx as wt,jsxs as di}from"react/jsx-runtime";var JT=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:s,defaultUIEnabled:l,scrollBackToContentUIEnabled:d,app:c,onPenModeToggle:m})=>{let{WelcomeScreenCenterTunnel:p,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:E}=ot(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=wt("div",{className:"excalidraw-ui-top-right",children:i?.(!0,e)??(!e.viewModeEnabled&&di(qT,{children:[l&&wt(Ja,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),wt(E.Out,{})]}))}),M=di("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),wt(u.Out,{})]});return di("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[M,P]})},b=()=>wt(jT,{app:c,actionManager:t,setAppState:o}),w=d&&e.scrolledOutside,y=l,x=l&&(!e.viewModeEnabled||y),I=w&&!e.openMenu&&!e.openSidebar?wt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...Ti(n,P)}))},children:f("buttons.scrollBackToContent")}):null,S=c.props.viewportStatusFrame?.label,C=S?wt(mp,{label:S,border:c.props.viewportStatusFrame?.border}):null;return di(qT,{children:[a(),wt("div",{className:"App-welcome-screen",children:s&&wt(p.Out,{})}),x&&di("div",{className:"App-bottom-bar",style:{marginBottom:fn+ko,left:14,transform:"none"},"data-viewport-ui":"bottom",children:[I&&wt("div",{className:"floating-status-stack",children:I}),di("div",{className:"App-bottom-bar__actions-row",children:[y&&di(We,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&wt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),wt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&wt(IT,{appState:e,elementsMap:c.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:c,setAppState:o})]}),!e.viewModeEnabled&&wt(We,{className:"App-toolbar",style:{justifyContent:"flex-start"},children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&I&&wt("div",{className:"floating-status-stack",children:I}),C&&wt("div",{className:"viewport-status-frame__badge-row",children:C}),wt(bp,{side:"top",className:"App-top-bar",children:g()})]})};import iC,{useLayoutEffect as aC,useRef as sC,useState as lC}from"react";import{newTextElement as cC}from"@excalidraw/element";import Bz from"clsx";import{useEffect as Fz,useState as Oz}from"react";import{KEYS as zz,queryFocusableElements as oC}from"@excalidraw/common";import{useCallback as Az,useState as Dz}from"react";var QT=()=>{let[e,n]=Dz(null),t=Az(o=>n(o),[]);return[e,t]};import eC from"clsx";import{useRef as Lz}from"react";import{createPortal as _z}from"react-dom";import{KEYS as Rz}from"@excalidraw/common";import{jsx as tC,jsxs as Nz}from"react/jsx-runtime";var nC=e=>{let{closeOnClickOutside:n=!0}=e,t=id({className:eC("excalidraw-modal-container",e.portalContainerClassName)}),o=Lz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===Rz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return _z(Nz("div",{className:eC("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[tC("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),tC("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as xp,jsxs as rC}from"react/jsx-runtime";function Gz(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]=QT(),[o]=Oz(document.activeElement),{id:r}=Ne(),i=be().formFactor==="phone";Fz(()=>{if(!n)return;let l=oC(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let d=c=>{if(c.key===zz.TAB){let m=oC(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&c.shiftKey?(m[m.length-1].focus(),c.preventDefault()):u===m.length-1&&!c.shiftKey&&(m[0].focus(),c.preventDefault())}};return n.addEventListener("keydown",d),()=>n.removeEventListener("keydown",d)},[n,e.autofocus]);let a=Oe(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return xp(nC,{className:Bz("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:Gz(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:rC(We,{ref:t,children:[e.title&&rC("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[xp("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&xp("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:an}),xp("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as Lo,jsxs as yp}from"react/jsx-runtime";var Hz=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}},Uz=e=>{let n=sC(null),[t,o]=lC(null),{theme:r}=ye();aC(()=>{if(!e.spreadsheet){o(null);return}let a=_f(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 Rr(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=Hz(e.chartType);return yp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Lo("div",{className:"ChartPreview__canvas",ref:n}),Lo("div",{className:"ChartPreview__label",children:i})]})},Wz=e=>{let n=sC(null),{theme:t}=ye();return aC(()=>{if(!e.rawText)return;let o=cC({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Rr([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]),yp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Lo("div",{className:"ChartPreview__canvas",ref:n}),Lo("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},dC=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=Tt(),[i,a]=lC(Math.random()),s=iC.useCallback(()=>{a(Math.random())},[]),l=iC.useCallback(()=>{t&&t()},[t]),d=(m,p)=>{o(p),Fe("paste","chart",m),t(),r()},c=m=>{let p=cC({text:m,x:0,y:0});o([p]),Fe("paste","chart","plaintext"),t(),r()};return Lo(wn,{size:"regular",onCloseRequest:l,title:yp("div",{className:"PasteChartDialog__title",children:[Lo("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),Lo("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:Zn})]}),className:"PasteChartDialog",autofocus:!1,children:yp("div",{className:"container",children:[["bar","line","radar"].map(m=>Na(e,m)?Lo(Uz,{chartType:m,spreadsheet:e,colorSeed:i,onClick:d},m):null),n&&Lo(Wz,{rawText:n,onClick:c})]})})};import{Fragment as Vz,jsx as mC,jsxs as Yz}from"react/jsx-runtime";var Xl=({heading:e,children:n,...t})=>{let{id:o}=Ne(),r=mC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return mC("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):Yz(Vz,{children:[r,n]})})};import{Popover as $l}from"radix-ui";import pC from"clsx";import wp,{useLayoutEffect as Kz}from"react";import{supportsResizeObserver as Xz,isShallowEqual as $z}from"@excalidraw/common";import{Fragment as uE,jsx as vt,jsxs as Qa}from"react/jsx-runtime";var Zz=4,jz=8,mE=38,uC=21,qz=({shouldWrap:e,children:n,username:t})=>e?vt(pt,{label:t||"Unknown user",children:n}):vt(uE,{children:n}),pE=({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 vt(qz,{username:n.username,shouldWrap:r,children:s},t)},Jz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],vp=wp.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=rt(),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),d=s.filter(C=>!C.isCurrentUser),[c,m]=wp.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(c)),u=wp.useRef(null);Kz(()=>{if(u.current){let C=M=>{g(M)};if(C(u.current.clientWidth),!Xz)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]=wp.useState(Zz*mE),b=l?E-uC:E,w=Math.max(1,Math.min(8,Math.floor(b/mE))),y=l?Math.max(0,w-1):w,x=d.slice(0,y),I=l?[...x,l]:x,S=I.map(C=>{let P=pE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?Qa($l.Root,{children:[vt($l.Trigger,{asChild:!0,children:Qa("div",{className:"UserList__pill",children:[P,vt("div",{className:"UserList__pill-chevron",children:x0})]})}),vt($l.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Qa(We,{padding:2,children:[s.length>=jz&&vt(hd,{placeholder:f("quickSearch.placeholder"),onChange:m}),vt(gd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[vt("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(M=>pE({actionManager:i,collaborator:M,socketId:M.socketId,withName:!0,isBeingFollowed:M.socketId===o}))]:[]}),a&&Qa(uE,{children:[vt("div",{className:"UserList__menu-divider"}),vt($l.Close,{asChild:!0,children:vt("div",{className:"dropdown-menu",children:a})})]}),vt($l.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?Qa("div",{className:pC("UserList UserList_mobile",e),children:[vt("div",{className:"UserList_mobile__avatars",children:s.map(C=>pE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&Qa(uE,{children:[vt("div",{className:"UserList__menu-divider"}),a]})]}):vt("div",{className:"UserList__wrapper",ref:u,children:vt("div",{className:pC("UserList",e),style:{"--max-avatars":I.length+(l?uC/mE:0)},children:S})})},(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||!$z(r,i,Jz))return!1}return!0});import Zl from"clsx";import{jsx as hC}from"react/jsx-runtime";var gC=e=>hC(pt,{label:`${f("helpDialog.title")} \u2014 ?`,children:hC("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:Bi})});import{jsx as en,jsxs as hE}from"react/jsx-runtime";var fC=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=ot(),l=Tt();return hE("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&en("div",{className:Zl("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:en(Bt.Col,{gap:2,children:hE(Xl,{heading:"canvasActions",children:[!e.viewModeOnly&&en(pt,{label:e.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:en("div",{className:Zl("view-mode-button"),children:n.renderAction("viewMode")})}),en(pt,{label:f("buttons.smartZoom"),children:en("div",{className:Zl("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&en(ST,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&en(TT,{renderAction:n.renderAction,className:Zl("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),en(a.Out,{}),(r||o)&&en("div",{className:Zl("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:hE("div",{style:{position:"relative"},children:[o&&en(s.Out,{}),r&&en(gC,{onClick:()=>n.executeAction(qr)})]})}),r&&en(CT,{showExitZenModeBtn:t})]})},EC=fC;fC.displayName="Footer";import{composeEventHandlers as aG}from"@excalidraw/common";import{useLayoutEffect as Qz,useRef as eG}from"react";import{jsx as tG}from"react/jsx-runtime";var mi=(e,n)=>{let t=Qe(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=ot(),[,a]=i(t),s=eG({preferHost:!1,counter:0});return Qz(()=>{let l=s.current;return a(d=>{let c=d+1;return l.counter=c,c}),()=>{a(d=>{let c=d-1;return l.counter=c,c||(l.preferHost=!1),c})}},[a]),r.__fallback||(s.current.preferHost=!0),!s.current.counter&&r.__fallback&&s.current.preferHost||s.current.counter>1&&r.__fallback?null:tG(n,{...r})};return o.displayName=e,o};var bE={};C3(bE,{ChangeCanvasBackground:()=>kC,Export:()=>MC,Help:()=>CC,LiveCollaborationTrigger:()=>DC,LoadScene:()=>vC,Preferences:()=>ao,PreferencesToggleGridModeItem:()=>EE,SaveAsImage:()=>SC,SaveToActiveFile:()=>IC,SearchMenu:()=>TC,Socials:()=>AC,ToggleTheme:()=>PC});import iG from"clsx";import{THEME as ql}from"@excalidraw/common";var gE=Qe({active:!1});async function bC({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{Et.set(gE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import nG from"clsx";import{jsx as xC,jsxs as oG}from"react/jsx-runtime";var Ip=function({onChange:e,value:n,choices:t,name:o}){return xC("div",{className:"RadioGroup",children:t.map(r=>oG("div",{className:nG("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[xC("input",{name:o,type:"radio",checked:r.value===n,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as rG,jsx as jl,jsxs as yC}from"react/jsx-runtime";var wC=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=be();return yC(rG,{children:[yC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&jl("div",{className:"dropdown-menu-item__icon",children:a}),jl("label",{className:"dropdown-menu-item__text",children:jl(Hs,{children:r})}),jl(Ip,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&jl("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};wC.displayName="DropdownMenuItemContentRadio";var fE=wC;import{Fragment as zC,jsx as we,jsxs as Jl}from"react/jsx-runtime";var vC=()=>{let{t:e}=_e(),n=rt(),t=Ui();return n.isActionEnabled(ia)?we(qt,{icon:Uc,onSelect:async()=>{(!t.length||await bC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:we(ci,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>we("strong",{children:r}),br:()=>we("br",{})})}))&&n.executeAction(ia)},"data-testid":"load-button",shortcut:je("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};vC.displayName="LoadScene";var IC=()=>{let{t:e}=_e(),n=rt();return n.isActionEnabled(jr)?we(qt,{shortcut:je("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(jr),icon:jx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};IC.displayName="SaveToActiveFile";var SC=()=>{let e=Oe(),{t:n}=_e();return we(qt,{icon:Qx,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:je("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};SC.displayName="SaveAsImage";var TC=e=>{let{t:n}=_e(),t=rt();return we(qt,{icon:Jn,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Pl)},shortcut:je("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};TC.displayName="SearchMenu";var CC=()=>{let{t:e}=_e(),n=rt();return we(qt,{"data-testid":"help-menu-item",icon:Bi,onSelect:()=>n.executeAction(qr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};CC.displayName="Help";var PC=e=>{let{t:n}=_e(),t=ye(),o=rt(),r=je("toggleTheme"),i=kn();return o.isActionEnabled(Rd)?e?.allowSystemTheme?we(fE,{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:ql.LIGHT,label:Ps,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:ql.DARK,label:Cs,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:m0,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):we(qt,{onSelect:a=>{a.preventDefault(),o.executeAction(Rd)},icon:t.theme===ql.DARK?Ps:Cs,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===ql.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===ql.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};PC.displayName="ToggleTheme";var kC=()=>{let{t:e}=_e(),n=ye(),t=rt(),o=kn();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:Jl("div",{style:{marginTop:"0.75rem"},children:[we("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),we("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};kC.displayName="ChangeCanvasBackground";var MC=()=>{let{t:e}=_e(),n=Oe();return we(qt,{icon:ks,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};MC.displayName="Export";var AC=()=>{let{t:e}=_e();return Jl(zC,{children:[we(ja,{icon:Xx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),we(ja,{icon:Zx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),we(ja,{icon:$x,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};AC.displayName="Socials";var DC=({onSelect:e,isCollaborating:n})=>{let{t}=_e();return we(qt,{"data-testid":"collab-button",icon:Wc,className:iG({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};DC.displayName="LiveCollaborationTrigger";var LC=()=>{let{t:e}=_e(),n=Tt(),t=ye();return we(io,{checked:t.activeTool.locked,shortcut:je("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},_C=()=>{let{t:e}=_e(),n=ye(),t=Oe();return we(fE,{name:"boxSelectionMode",icon:$c,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")})},RC=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.objectsSnapModeEnabled,shortcut:je("objectsSnapMode"),onSelect:o=>{n.executeAction(Lt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},NC=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(sl),o.preventDefault()},children:e("labels.arrowBinding")})},BC=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(ll),o.preventDefault()},children:e("labels.midpointSnapping")})},EE=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.gridModeEnabled,shortcut:je("gridMode"),onSelect:o=>{n.executeAction(ua),o.preventDefault()},children:e("labels.toggleGrid")})},FC=()=>{let{t:e}=_e(),n=rt(),t=ye();return t.viewModeOnly?null:we(io,{checked:t.viewModeEnabled,shortcut:je("viewMode"),onSelect:o=>{n.executeAction(Pa),o.preventDefault()},children:e("labels.viewMode")})},OC=()=>{let{t:e}=_e(),n=rt(),t=ye();return we(io,{checked:t.stats.open,shortcut:je("stats"),onSelect:o=>{n.executeAction(mr),o.preventDefault()},children:e("stats.fullTitle")})},ao=({children:e,additionalItems:n})=>{let{t}=_e();return Jl(yr,{children:[we(yr.Trigger,{icon:w0,children:t("labels.preferences")}),Jl(yr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Jl(zC,{children:[we(_C,{}),we(LC,{}),we(RC,{}),we(EE,{}),we(FC,{}),we(OC,{}),we(NC,{}),we(BC,{})]}),n]})]})};ao.ToggleToolLock=LC;ao.BoxSelectionMode=_C;ao.ToggleSnapMode=RC;ao.ToggleArrowBinding=NC;ao.ToggleMidpointSnapping=BC;ao.ToggleGridMode=EE;ao.ToggleViewMode=FC;ao.ToggleElementProperties=OC;ao.displayName="Preferences";import{jsx as Sp,jsxs as xE}from"react/jsx-runtime";var sG=Object.assign(mi("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=ot(),o=be(),r=ye(),i=kn(),a=Oe();return Sp(t.In,{children:xE(pe,{open:r.openMenu==="canvas",children:[Sp(pe.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Yx}),xE(pe.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:aG(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&xE("fieldset",{className:"UserList-Wrapper",children:[Sp("legend",{children:f("labels.collaborators")}),Sp(vp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:pe.Trigger,Item:pe.Item,ItemLink:pe.ItemLink,ItemCustom:pe.ItemCustom,Group:pe.Group,Separator:pe.Separator,Sub:yr,DefaultItems:bE}),Ft=sG;import lG from"clsx";import{forwardRef as cG,useState as dG}from"react";import{isPromiseLike as mG}from"@excalidraw/common";import{jsx as Tp,jsxs as pG}from"react/jsx-runtime";var wr=cG(({children:e,icon:n,onClick:t,label:o,variant:r="filled",color:i="primary",size:a="medium",fullWidth:s,className:l,status:d,disabled:c},m)=>{let[p,u]=dG(!1),E=async b=>{let w=t?.(b);if(mG(w)){let y=window.setTimeout(()=>{u(!0)},50);try{await w}catch(x){if(x instanceof Pc)console.warn(x);else throw x}finally{clearTimeout(y),u(!1)}}},g=p?"loading":d;return i=g==="success"?"success":i,Tp("button",{className:lG("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:c||g==="loading"||g==="success",children:pG("div",{className:"ExcButton__contents",children:[g==="loading"?Tp(bo,{className:"ExcButton__statusIcon"}):g==="success"&&Tp("div",{className:"ExcButton__statusIcon",children:e0}),n&&Tp("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as es,jsxs as gG}from"react/jsx-runtime";var Cp=({title:e,children:n,actionLabel:t,onClick:o})=>gG("div",{className:"OverwriteConfirm__Actions__Action",children:[es("h4",{children:e}),es("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),es(wr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),uG=()=>{let{t:e}=_e(),n=rt(),t=Oe();return es(Cp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(Qd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},hG=()=>{let{t:e}=_e(),n=rt();return es(Cp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(rl,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},yE=Object.assign(({children:e})=>es("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:uG,SaveToDisk:hG});import{jsx as vr,jsxs as GC}from"react/jsx-runtime";var Pp=Object.assign(mi("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=ot(),[t,o]=Ue(gE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return vr(n.In,{children:vr(wn,{onCloseRequest:r,title:!1,size:916,children:GC("div",{className:"OverwriteConfirm",children:[vr("h3",{children:t.title}),GC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[vr("div",{className:"OverwriteConfirm__Description__icon",children:t0}),vr("div",{children:t.description}),vr("div",{className:"OverwriteConfirm__Description__spacer"}),vr(wr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),vr(yE,{children:e})]})})})}),{Actions:yE,Action:Cp});import{round as AP}from"@excalidraw/math";import _H from"clsx";import RH from"lodash.throttle";import{useEffect as DP,useMemo as RE,useState as NH,memo as BH}from"react";import{STATS_PANELS as Bp}from"@excalidraw/common";import{getCommonBounds as FH}from"@excalidraw/element";import{getUncroppedWidthAndHeight as OH}from"@excalidraw/element";import{isImageElement as NE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as zH}from"@excalidraw/element";import{elementsAreInSameGroup as GH}from"@excalidraw/element";import{degreesToRadians as $C,radiansToDegrees as JC}from"@excalidraw/math";import{getBoundTextElement as ZC}from"@excalidraw/element";import{isArrowElement as jC,isElbowArrow as MG}from"@excalidraw/element";import{updateBindings as qC}from"@excalidraw/element";import IG from"clsx";import{useEffect as KC,useRef as Mp,useState as SG}from"react";import{EVENT as os,KEYS as TG,cloneJSON as wE}from"@excalidraw/common";import{deepCopyElement as CG}from"@excalidraw/element";import{CaptureUpdateAction as XC}from"@excalidraw/element";import{pointFrom as Ir,pointRotateRads as kp}from"@excalidraw/math";import{getBoundTextElement as fG,getNonDeletedElements as EG,isBindingElement as bG,unbindBindingElement as HC}from"@excalidraw/element";import{isFrameLikeElement as VC}from"@excalidraw/element";import{getSelectedGroupIds as xG,getElementsInGroup as yG,isInGroup as wG}from"@excalidraw/element";import{getFrameChildren as vG}from"@excalidraw/element";import{updateBindings as UC}from"@excalidraw/element";import{DRAGGING_THRESHOLD as WC}from"@excalidraw/common";var YC=.01,Ql=10,Vt=(e,n)=>!(n==="angle"&&VC(e)),Ve=(e,n)=>{let t=e+n/2;return t-t%n},ts=(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 pi=(e,n,t,o,r,i,a=!0)=>{if(bG(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<WC&&Math.abs(n-t.y)<WC)return;HC(t,"start",o),HC(t,"end",o)}let s=o.getNonDeletedElementsMap(),l=s.get(t.id);if(!l)return;let[d,c]=[t.x+t.width/2,t.y+t.height/2],[m,p]=kp(Ir(t.x,t.y),Ir(d,c),t.angle),u=e-m,E=n-p,[g,b]=kp(Ir(e,n),Ir(d+u,c+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),UC(l,o,r);let w=fG(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(VC(t)){let y=vG(i,t.id);y.forEach(x=>{let I=s.get(x.id);if(!I)return;let[S,C]=[x.x+x.width/2,x.y+x.height/2],[P,M]=kp(Ir(x.x,x.y),Ir(S,C),x.angle),D=Math.round(P+u),_=Math.round(M+E),[k,L]=kp(Ir(D,_),Ir(S+u,C+E),-x.angle);o.mutateElement(I,{x:k,y:L},{informMutation:a,isDragging:!1}),UC(I,o,r,{simultaneouslyUpdated:EG(y)})})}},ns=(e,n)=>{let o=xG(n).map(r=>yG(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!wG(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as vE,jsxs as kG}from"react/jsx-runtime";var PG=({label:e,icon:n,dragInputCallback:t,value:o,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:d,sensitivity:c=1,dragFinishedCallback:m})=>{let p=Tt(),u=Oe(),E=Mp(null),g=Mp(null),[b,w]=SG(o.toString()),y=Mp(null);y.current||(y.current={originalAppState:wE(d),originalElements:r,lastUpdatedValue:b,updatePending:!1}),KC(()=>{let S=o.toString();w(S),y.current.lastUpdatedValue=S},[o]);let x=(S,C,P)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let M=Number(S);if(isNaN(M)){w(o.toString());return}let D=Number(M.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(D-_)>=YC)&&(y.current.lastUpdatedValue=S,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:XC.IMMEDIATELY}))},I=Mp({});return I.current.handleInputValue=x,KC(()=>{let S=E.current,C=I.current;return()=>{let P=S?.value;P&&C.handleInputValue?.(P,y.current.originalElements,y.current.originalAppState),window.removeEventListener(os.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(os.POINTER_UP,C.onPointerUp,!1)}},[i]),i?kG("div",{className:IG("drag-input-container",!i&&"disabled"),"data-testid":e,children:[vE("div",{className:"drag-input-label",ref:g,onPointerDown:S=>{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,CG(U)),z),new Map),D=r.map(z=>M.get(z.id)),_=wE(d),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)>=c&&(L=Math.sign(L)*Math.floor(Math.abs(L)/c),k+=L,t({accumulatedChange:k,instantChange:L,originalElements:D,originalElementsMap:M,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:V=>w(String(V)),app:p,setAppState:u}),L=0))}P={x:z.clientX,y:z.clientY}},Y=()=>{window.removeEventListener(os.POINTER_MOVE,F,!1),p.syncActionResult({captureUpdate:XC.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(os.POINTER_UP,Y,!1)};I.current.onPointerMove=F,I.current.onPointerUp=Y,window.addEventListener(os.POINTER_MOVE,F,!1),window.addEventListener(os.POINTER_UP,Y,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?vE(xd,{icon:n}):e}),vE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:S=>{if(i){let C=S.target;C instanceof HTMLInputElement&&S.key===TG.ENTER&&(x(C.value,r,d),p.focusContainer())}},ref:E,value:b,onChange:S=>{y.current.updatePending=!0,w(S.target.value)},onFocus:S=>{S.target.select(),y.current.originalElements=r,y.current.originalAppState=wE(d)},onBlur:S=>{b?i&&x(S.target.value,y.current.originalElements,y.current.originalAppState):w(o.toString())},disabled:!i})]}):null},gt=PG;import{jsx as _G}from"react/jsx-runtime";var AG=15,DG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!MG(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=$C(o);r.mutateElement(l,{angle:E}),qC(l,r,i.state);let g=ZC(l,a);g&&!jC(l)&&r.mutateElement(g,{angle:E});return}let d=Math.round(JC(s.angle)*100)/100,c=Math.round(e),m=(d+c)%360;t&&(m=Ve(m,AG)),m=m<0?m+360:m;let p=$C(m);r.mutateElement(l,{angle:p}),qC(l,r,i.state);let u=ZC(l,a);u&&!jC(l)&&r.mutateElement(u,{angle:p})}},LG=({element:e,scene:n,appState:t,property:o})=>_G(gt,{label:"A",icon:Yc,value:Math.round(JC(e.angle)%360*100)/100,elements:[e],dragInputCallback:DG,editable:Vt(e,"angle"),scene:n,appState:t,property:o}),QC=LG;import{jsx as NG}from"react/jsx-runtime";var eP=5,RG=({property:e,scene:n,appState:t,setAppState:o})=>NG(gt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:s})=>{o(l=>{let d;return r?d=r:i&&(d=a?Ve(l.gridStep+eP*Math.sign(i),eP):l.gridStep+i),d?(d=ix(d),s(d),{gridStep:d}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),tP=RG;import{clamp as Ap,round as IE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Dp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as nP,getNonDeletedElements as BG,getUncroppedWidthAndHeight as iP}from"@excalidraw/element";import{resizeSingleElement as oP}from"@excalidraw/element";import{isImageElement as aP}from"@excalidraw/element";import{isFrameLikeElement as SE}from"@excalidraw/element";import{getElementsInResizingFrame as TE}from"@excalidraw/element";import{replaceAllElementsInFrame as sP}from"@excalidraw/element";import{jsx as HG}from"react/jsx-runtime";var rP=10,FG=e=>e.type==="image",OG=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:s,instantChange:l,scene:d,app:c,setAppState:m})=>{let p=d.getNonDeletedElementsMap(),u=n[0],E=p.get(u.id);if(u&&E){let g=o||FG(u),b=u.width/u.height;if(s.croppingElementId===u.id){let w=p.get(u.id);if(!w||!aP(w)||!w.crop)return;let y=w.crop,x={...y},I=w.scale[0]===-1,S=w.scale[1]===-1,{width:C,height:P}=iP(w),M=y.naturalWidth/C,D=y.naturalHeight/P,_=I?y.width+y.x:y.naturalWidth-y.x,k=S?y.height+y.y:y.naturalHeight-y.y,L=nP*M,F=nP*D;if(i!==void 0){if(a==="width"){let G=i*M,re=Ap(G,L,_);x={...x,width:re,x:I?y.x+y.width-re:y.x}}else if(a==="height"){let G=i*D,re=Ap(G,F,k);x={...x,height:re,y:S?y.y+y.height-re:y.y}}d.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=Ap(y.width+Y,L,_),V=Ap(y.height+z,L,k);x={...y,x:I?y.x+y.width-U:y.x,y:S?y.y+y.height-V:y.y,width:U,height:V},d.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}if(i!==void 0){let w=Math.max(a==="width"?i:g?i*b:u.width,Dp),y=Math.max(a==="height"?i:g?i/b:u.height,Dp);if(oP(w,y,E,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),SE(E)){let x=TE(d.getElementsIncludingDeleted(),E,s,d.getNonDeletedElementsMap()),I=sP(d.getElementsIncludingDeleted(),x,E);d.replaceAllElements(I)}return}{let w=a==="width"?e:0,y=a==="height"?e:0,x=Math.max(0,u.width+w);a==="width"&&(r?x=Ve(x,rP):x=Math.round(x));let I=Math.max(0,u.height+y);if(a==="height"&&(r?I=Ve(I,rP):I=Math.round(I)),g&&(a==="width"?I=Math.round(x/b*100)/100:x=Math.round(I*b*100)/100),I=Math.max(Dp,I),x=Math.max(Dp,x),oP(x,I,E,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),SE(E)){let S=BG(TE(d.getElementsIncludingDeleted(),E,s,d.getNonDeletedElementsMap()));m({elementsToHighlight:S})}}}},zG=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&SE(a)){let s=TE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=sP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},GG=({property:e,element:n,scene:t,appState:o})=>{let r=IE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&aP(n)&&n.crop){let{width:i,height:a}=iP(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=IE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=IE(n.crop.height*s,2)}}return HG(gt,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:OG,value:r,editable:Vt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:zG})},CE=GG;import{getBoundTextElement as UG,redrawTextBoundingBox as WG}from"@excalidraw/element";import{hasBoundTextElement as VG,isTextElement as cP}from"@excalidraw/element";import{jsx as $G}from"react/jsx-runtime";var lP=4,YG=4,KG=({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||!cP(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),lP);else if(a.type==="text"){let d=Math.round(a.fontSize),c=Math.round(e);l=Math.max(d+c,lP),t&&(l=Ve(l,YG))}l&&(r.mutateElement(s,{fontSize:l}),WG(s,r.getContainerElement(s),r))}},XG=({element:e,scene:n,appState:t,property:o})=>{let r=cP(e)?e:VG(e)?UG(e,n.getNonDeletedElementsMap()):null;return r?$G(gt,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:KG,icon:zr,appState:t,scene:n,property:o}):null},dP=XG;import{degreesToRadians as mP,radiansToDegrees as hP}from"@excalidraw/math";import{getBoundTextElement as pP}from"@excalidraw/element";import{isArrowElement as uP}from"@excalidraw/element";import{isInGroup as PE}from"@excalidraw/element";import{jsx as JG}from"react/jsx-runtime";var ZG=15,jG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=n.map(d=>a.get(d.id)).filter(d=>d&&!PE(d)&&Vt(d,r)),l=n.filter(d=>!PE(d)&&Vt(d,r));if(o!==void 0){let d=mP(o);for(let c of s){if(!c)continue;i.mutateElement(c,{angle:d});let m=pP(c,a);m&&!uP(c)&&i.mutateElement(m,{angle:d})}i.triggerUpdate();return}for(let d=0;d<s.length;d++){let c=s[d];if(!c)continue;let m=l[d],p=Math.round(hP(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=Ve(E,ZG)),E=E<0?E+360:E;let g=mP(E);i.mutateElement(c,{angle:g});let b=pP(c,a);b&&!uP(c)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},qG=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!PE(l)&&Vt(l,"angle")),i=r.map(l=>Math.round(hP(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Vt(l,"angle"));return JG(gt,{label:"A",icon:Yc,value:a,elements:e,dragInputCallback:jG,editable:s,appState:t,scene:n,property:o})},gP=qG;import{pointFrom as xP}from"@excalidraw/math";import{useMemo as eH}from"react";import{MIN_WIDTH_OR_HEIGHT as Sr}from"@excalidraw/common";import{getElementsInResizingFrame as kE,getNonDeletedElements as tH,isFrameLikeElement as ME,replaceAllElementsInFrame as vP,updateBoundElements as nH}from"@excalidraw/element";import{rescalePointsInElement as oH,resizeSingleElement as yP}from"@excalidraw/element";import{getBoundTextElement as rH,handleBindTextResize as iH}from"@excalidraw/element";import{isTextElement as IP}from"@excalidraw/element";import{MIME_TYPES as ui}from"@excalidraw/common";import{getNonDeletedElements as fP}from"@excalidraw/element";var Lp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=fP(Nr(e,null,{deleteInvisibleElements:!0})),l=ki(n,null),{exportBackground:d,viewBackgroundColor:c}=l;return Lc(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:d,exportPadding:i,viewBackgroundColor:c,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(m,p),b=o<g?o/g:n?.exportScale??1;return u.width=m*b,u.height=p*b,{canvas:u,scale:b}}let E=r?.(m,p)||{width:m,height:p};return u.width=E.width,u.height=E.height,{canvas:u,scale:E.scale??1}})},EP=async e=>{let{mimeType:n=ui.png,quality:t}=e;n===ui.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ui.png}" mimeType`),n==="image/jpg"&&(n=ui.jpg),n===ui.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ui.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Lp(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===ui.png&&e.appState?.exportEmbedScene&&(a=await Ex({blob:a,metadata:xs(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},bP=async({elements:e,appState:n=Ko(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=fP(Nr(e,null,{deleteInvisibleElements:!0})),c={...ki(n,null),exportPadding:o};return Rr(l,c,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},QG=async e=>{if(e.type==="svg"){let n=await bP(e);await Io(n.outerHTML)}else if(e.type==="png")await qd(EP(e));else if(e.type==="json")await $d(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as pNe}from"@excalidraw/element";import{getCommonBounds as _p}from"@excalidraw/element";import{jsx as mH}from"react/jsx-runtime";var rs=10,aH=(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,d=n+i*t;return{width:a,height:s,x:l,y:d,...oH(o,a,s,!1),...IP(o)?{fontSize:o.fontSize*t}:{}}},sH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),d=aH(e,n,o,i);s.mutateElement(r,d);let c=rH(i,a);if(c){let m=c.fontSize*o;nH(r,s);let p=l.get(c.id);p&&IP(p)&&(s.mutateElement(p,{fontSize:m}),iH(r,s,t==="width"?"e":"s",!0))}},wP=(e,n,t,o,r,i,a,s,l,d)=>{i==="width"?n=Math.round(e/o*100)/100:e=Math.round(n*o*100)/100;let c=n/t;for(let m=0;m<s.length;m++){let p=s[m],u=a[m];sH(r[0],r[1],i,c,u,p,l,d)}},lH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:s,setAppState:l,app:d})=>{let c=a.getNonDeletedElementsMap(),m=ns(n,o);if(i!==void 0){for(let g of m){let b=ts(g,c,t);if(b.length>1){let w=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,S,C]=_p(y),P=S-x,M=C-I,D=P/M,_=Math.max(Sr,s==="width"?Math.max(0,i):P),k=Math.max(Sr,s==="height"?Math.max(0,i):M);wP(_,k,M,D,xP(x,I),s,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Vt(y,s)){let I=s==="width"?Math.max(0,i):y.width;s==="width"&&(r?I=Ve(I,rs):I=Math.round(I));let S=s==="height"?Math.max(0,i):y.height;if(s==="height"&&(r?S=Ve(S,rs):S=Math.round(S)),I=Math.max(Sr,I),S=Math.max(Sr,S),yP(I,S,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),ME(y)){let C=kE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()),P=vP(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=ts(g,c,t);if(b.length>1){let w=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,S,C]=_p(y),P=S-x,M=C-I,D=P/M,_=Math.max(0,P+p);s==="width"&&(r?_=Ve(_,rs):_=Math.round(_));let k=Math.max(0,M+u);s==="height"&&(r?k=Ve(k,rs):k=Math.round(k)),_=Math.max(Sr,_),k=Math.max(Sr,k),wP(_,k,M,D,xP(x,I),s,w,y,t,a)}else{let[w]=b,y=w?.latest,x=w?.original;if(y&&x&&Vt(y,s)){let I=Math.max(0,x.width+p);s==="width"&&(r?I=Ve(I,rs):I=Math.round(I));let S=Math.max(0,x.height+u);if(s==="height"&&(r?S=Ve(S,rs):S=Math.round(S)),I=Math.max(Sr,I),S=Math.max(Sr,S),yP(I,S,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),ME(y)){let C=tH(kE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},cH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&ME(a)){let s=kE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=vP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},dH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=eH(()=>o.map(d=>{let c=ts(d,t);if(c.length>1){let[p,u,E,g]=_p(c.map(b=>b.latest));return Math.round((e==="width"?E-p:g-u)*100)/100}let[m]=c;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[t,o,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return mH(gt,{label:e==="width"?"W":"H",elements:n,dragInputCallback:lH,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:cH})},AE=dH;import{getBoundTextElement as pH,redrawTextBoundingBox as SP}from"@excalidraw/element";import{hasBoundTextElement as uH,isTextElement as hH}from"@excalidraw/element";import{isInGroup as gH}from"@excalidraw/element";import{jsx as yH}from"react/jsx-runtime";var TP=4,fH=4,EH=(e,n)=>e.reduce((t,o)=>{if(!o||gH(o))return t;if(hH(o))return t.push(o),t;if(uH(o)){let r=pH(o,n);if(r)return t.push(r),t}return t},[]),bH=({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),TP);for(let l of a)r.mutateElement(l,{fontSize:s}),SP(l,r.getContainerElement(l),r);r.triggerUpdate()}else{let l=n;for(let d=0;d<a.length;d++){let c=a[d],m=l[d],p=Math.round(m.fontSize),u=Math.round(e),E=Math.max(p+u,TP);t&&(E=Ve(E,fH)),r.mutateElement(c,{fontSize:E}),SP(c,r.getContainerElement(c),r)}r.triggerUpdate()}},xH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=EH(e,r);if(!i.length)return null;let a=i.map(d=>Math.round(d.fontSize*10)/10),s=new Set(a).size===1?a[0]:"Mixed",l=a.length>0;return yH(gt,{label:"F",icon:zr,elements:i,dragInputCallback:bH,value:s,editable:l,scene:n,property:o,appState:t})},CP=xH;import{pointFrom as Tr,pointRotateRads as Rp}from"@excalidraw/math";import{useMemo as wH}from"react";import{isTextElement as vH}from"@excalidraw/element";import{getCommonBounds as DE}from"@excalidraw/element";import{jsx as PH}from"react/jsx-runtime";var IH=(e,n,t,o,r,i,a)=>{for(let s=0;s<o.length;s++){let l=o[s],[d,c]=[l.x+l.width/2,l.y+l.height/2],[m,p]=Rp(Tr(l.x,l.y),Tr(d,c),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;pi(u,E,l,i,a,r,!1)}},SH=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=DE(t),d=e-s,c=n-l;for(let m=0;m<t.length;m++){let p=t[m],u=a.get(p.id);if(u&&(!vH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,w]=Rp(Tr(u.x,u.y),Tr(E,g),u.angle);pi(b+d,w+c,p,r,i,o,!1)}}},TH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldChangeByStepSize:o,nextValue:r,property:i,scene:a,originalAppState:s,app:l})=>{let d=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of ns(n,s)){let E=ts(u,d,t);if(E.length>1){let[g,b,,]=DE(E.map(x=>x.latest));SH(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&&Vt(b,i)){let[w,y]=[g.x+g.width/2,g.y+g.height/2],[x,I]=Rp(Tr(g.x,g.y),Tr(w,y),g.angle);pi(i==="x"?r:x,i==="y"?r:I,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let c=o?Ve(e,Ql):e;IH(i,i==="x"?c:0,i==="y"?c:0,n,t,a,l.state),a.triggerUpdate()},CH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=wH(()=>o.map(l=>{let d=Object.keys(l).map(g=>t.get(g)).filter(g=>g!==void 0);if(d.length>1){let[g,b]=DE(d);return Math.round((e==="x"?g:b)*100)/100}let[c]=d,[m,p]=[c.x+c.width/2,c.y+c.height/2],[u,E]=Rp(Tr(c.x,c.y),Tr(m,p),c.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),s=new Set(a).size===1?a[0]:"Mixed";return PH(gt,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:TH,value:s,property:e,scene:r,appState:i})},LE=CH;import{clamp as ec,pointFrom as Np,pointRotateRads as kP,round as PP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as kH,getUncroppedWidthAndHeight as MH}from"@excalidraw/element";import{isImageElement as MP}from"@excalidraw/element";import{jsx as LH}from"react/jsx-runtime";var AH=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:s,originalAppState:l,app:d})=>{let c=s.getNonDeletedElementsMap(),m=t[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[E,g]=kP(Np(m.x,m.y),Np(p,u),m.angle);if(l.croppingElementId===m.id){let I=c.get(m.id);if(!I||!MP(I)||!I.crop)return;let S=I.crop,C=S,P=I.scale[0]===-1,M=I.scale[1]===-1,{width:D,height:_}=MH(I);if(i!==void 0){if(a==="x"){let F=i*(S.naturalWidth/D);P?C={...S,x:ec(S.naturalWidth-F-S.width,0,S.naturalWidth-S.width)}:C={...S,x:ec(i*(S.naturalWidth/D),0,S.naturalWidth-S.width)}}a==="y"&&(C={...S,y:ec(i*(S.naturalHeight/_),0,S.naturalHeight-S.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={...S,x:ec(S.x+k,0,S.naturalWidth-S.width),y:ec(S.y+L,0,S.naturalHeight-S.height)},s.mutateElement(I,{crop:C});return}if(i!==void 0){pi(a==="x"?i:E,a==="y"?i:g,m,s,d.state,o);return}let b=a==="x"?e:0,w=a==="y"?e:0,y=a==="x"?Math.round(r?Ve(m.x+b,Ql):E+b):E,x=a==="y"?Math.round(r?Ve(m.y+w,Ql):g+w):g;pi(y,x,m,s,d.state,o)},DH=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=kP(Np(n.x,n.y),Np(n.x+n.width/2,n.y+n.height/2),n.angle),a=PP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&MP(n)&&n.crop){let s=kH(n);s&&(a=PP(e==="x"?s.x:s.y,2))}return LH(gt,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:AH,scene:t,value:a,property:e,appState:o})},_E=DH;import{Fragment as BE,jsx as ne,jsxs as Yt}from"react/jsx-runtime";var HH=50,tc=e=>{let n=Qn(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=hr(e.app);return ne(UH,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Ge=({children:e,columns:n=1,heading:t,style:o,...r})=>ne("div",{className:_H("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Ge.displayName="StatsRow";var Fp=({children:e,order:n,style:t,...o})=>ne("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Fp.displayName="StatsRows";tc.StatsRow=Ge;tc.StatsRows=Fp;var UH=BH(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),d=s.getNonDeletedElementsMap(),c=Oe(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&NE(m),E=u?OH(m):null,[g,b]=NH({width:0,height:0}),w=RE(()=>RH(I=>{let S=FH(I);b({width:Math.round(S[2])-Math.round(S[0]),height:Math.round(S[3])-Math.round(S[1])})},HH),[]);DP(()=>{w(l)},[i,l,w]),DP(()=>()=>w.cancel(),[w]);let y=RE(()=>ns(o,r),[o,r]),x=RE(()=>zH(o),[o]);return ne("div",{className:"exc-stats",children:Yt(We,{padding:3,children:[Yt("div",{className:"title",children:[ne("h2",{children:f("stats.title")}),ne("div",{className:"close",onClick:n,children:an})]}),Yt(Vs,{label:ne("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Bp.generalStats),openTrigger:()=>c(I=>({stats:{open:!0,panels:I.stats.panels^Bp.generalStats}})),children:[Yt(Fp,{children:[ne(Ge,{heading:!0,children:f("stats.scene")}),Yt(Ge,{columns:2,children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:l.length})]}),Yt(Ge,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:g.width})]}),Yt(Ge,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:g.height})]}),a&&Yt(BE,{children:[ne(Ge,{heading:!0,children:"Canvas"}),ne(Ge,{children:ne(tP,{property:"gridStep",scene:s,appState:r,setAppState:c})})]})]}),t?.(l,r)]}),!x&&o.length>0&&ne("div",{id:"elementStats",style:{marginTop:12},children:ne(Vs,{label:ne("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Bp.elementProperties),openTrigger:()=>c(I=>({stats:{open:!0,panels:I.stats.panels^Bp.elementProperties}})),children:Yt(Fp,{children:[m&&Yt(BE,{children:[u&&ne(Ge,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&NE(m)&&E&&Yt(Ge,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:AP(E.width,2)})]}),r.croppingElementId&&NE(m)&&E&&Yt(Ge,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:AP(E.height,2)})]}),ne(Ge,{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(Ge,{children:ne(_E,{element:m,property:"x",elementsMap:d,scene:s,appState:r})}),ne(Ge,{children:ne(_E,{element:m,property:"y",elementsMap:d,scene:s,appState:r})}),ne(Ge,{children:ne(CE,{property:"width",element:m,scene:s,appState:r})}),ne(Ge,{children:ne(CE,{property:"height",element:m,scene:s,appState:r})}),ne(Ge,{children:ne(QC,{property:"angle",element:m,scene:s,appState:r})}),ne(Ge,{children:ne(dP,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Yt(BE,{children:[GH(p)&&ne(Ge,{heading:!0,children:f("element.group")}),Yt(Ge,{columns:2,style:{margin:"0.3125rem 0"},children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:o.length})]}),ne(Ge,{children:ne(LE,{property:"x",elements:p,elementsMap:d,atomicUnits:y,scene:s,appState:r})}),ne(Ge,{children:ne(LE,{property:"y",elements:p,elementsMap:d,atomicUnits:y,scene:s,appState:r})}),ne(Ge,{children:ne(AE,{property:"width",elements:p,elementsMap:d,atomicUnits:y,scene:s,appState:r})}),ne(Ge,{children:ne(AE,{property:"height",elements:p,elementsMap:d,atomicUnits:y,scene:s,appState:r})}),ne(Ge,{children:ne(gP,{property:"angle",elements:p,scene:s,appState:r})}),ne(Ge,{children:ne(CP,{property:"fontSize",elements:p,scene:s,appState:r,elementsMap:d})})]})]})})})]})})},(e,n)=>e.sceneNonce===n.sceneNonce&&e.selectedElements===n.selectedElements&&e.appState.stats.panels===n.appState.stats.panels&&e.gridModeEnabled===n.gridModeEnabled&&e.appState.gridStep===n.appState.gridStep&&e.appState.croppingElementId===n.appState.croppingElementId);import{useCallback as eU,useEffect as _P,useState as RP}from"react";import{normalizeLink as tU,KEYS as GE}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as nU,getLinkIdAndTypeFromSelection as oU}from"@excalidraw/element";import WH from"clsx";import{jsx as Op,jsxs as YH}from"react/jsx-runtime";var VH=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return YH("button",{className:WH("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Op("div",{style:a?{visibility:"hidden"}:{},children:o}),Op("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Op("div",{style:{position:"absolute",inset:0},children:Op(bo,{})})]})},FE=VH;import OE from"clsx";import{forwardRef as ZH,useRef as jH,useImperativeHandle as qH,useLayoutEffect as JH,useState as QH}from"react";import KH from"clsx";import{composeEventHandlers as XH}from"@excalidraw/common";import{jsx as $H}from"react/jsx-runtime";var vn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>$H("button",{onClick:XH(i.onClick,a=>{n()}),type:e,className:KH("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as zE,jsxs as LP}from"react/jsx-runtime";var zp=ZH(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,icon:l,className:d,type:c,...m},p)=>{let u=jH(null);qH(p,()=>u.current),JH(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=QH(!1);return LP("div",{className:OE("ExcTextField",d,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&zE("div",{className:"ExcTextField__label",children:n}),LP("div",{className:OE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[zE("input",{className:OE({"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:c}),s&&zE(vn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?n0:Hr})]})]})});import{jsx as is,jsxs as Gp}from"react/jsx-runtime";var rU=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=nU})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=RP(a),[d,c]=RP(!1);_P(()=>{let p=ce(i,t),u=a;if(p.length>0&&r){let E=oU(p,t);E&&(u=tU(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=eU(()=>{if(s&&s!==i.get(e)?.link){let p=i.get(e);p&&o.mutateElement(p,{link:s})}if(!s&&d&&e){let p=i.get(e);p&&o.mutateElement(p,{link:null})}n?.()},[e,s,i,d,o,n]);return _P(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===GE.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===GE.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),Gp("div",{className:"ElementLinkDialog",children:[Gp("div",{className:"ElementLinkDialog__header",children:[is("h2",{children:f("elementLink.title")}),is("p",{children:f("elementLink.desc")})]}),Gp("div",{className:"ElementLinkDialog__input",children:[is(zp,{value:s??"",onChange:p=>{d||c(!0),l(p)},onKeyDown:p=>{p.key===GE.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&is(Z,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),c(!0)},className:"ElementLinkDialog__remove",icon:Or})]}),Gp("div",{className:"ElementLinkDialog__actions",children:[is(FE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),is(FE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},NP=rU;import iU,{useState as aU}from"react";import{Fragment as sU,jsx as HE}from"react/jsx-runtime";var BP=({children:e,onClose:n})=>{let[t,o]=aU(!!e),{container:r}=Ne(),i=iU.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return HE(sU,{children:t&&HE(wn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:HE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import UE from"clsx";import Fn from"react";import{MIME_TYPES as FP,sceneCoordsToViewportCoords as WE}from"@excalidraw/common";import{getCommonBounds as HP,isInitializedImageElement as OP,ShapeCache as lU}from"@excalidraw/element";import{Fragment as uU,jsx as kt,jsxs as hi}from"react/jsx-runtime";var cU=kt("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:kt("path",{d:"M8 5v14l11 -7z"})}),dU=hi("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[kt("path",{d:"M8 5v14"}),kt("path",{d:"M16 5v14"})]}),mU=76,UP=4,nc=mU+UP,zP=8,gi=8,pU=(e,n)=>{let t=n/2;return Math.min(Math.max(e,t+gi),window.innerWidth-t-gi)},GP=(e,n)=>{let[,,t,o]=HP([e]),r=WE({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)}},WP=({app:e,files:n,setAppState:t})=>{let o=Qn(),[,r]=Fn.useReducer(S=>S+1,0),[i,a]=Fn.useState(0),[s,l]=Fn.useState(!1),d=Fn.useRef(null),c=Fn.useRef(null),m=Fn.useRef(null),p=Fn.useRef(null),u=Fn.useRef(null),E=Fn.useRef(!1),[g,b]=Fn.useState(null);Fn.useLayoutEffect(()=>{let S=o.openPopup;if(S!=="gifSpeedPicker"&&S!=="gifFrameGallery"){g!==null&&b(null);return}let C=S==="gifSpeedPicker"?d.current:c.current,P=S==="gifSpeedPicker"?m.current:p.current;if(!C||!P)return;let M=C.getBoundingClientRect(),D=P.getBoundingClientRect(),_=pU(M.left+M.width/2,D.width),k=S==="gifSpeedPicker"?Math.max(gi,M.top-D.height-gi):Math.min(window.innerHeight-D.height-gi,M.bottom+gi),L={left:_,top:Math.max(gi,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=(S,C)=>{lU.delete(S),e.scene.mutateElement(S,{gifPlayback:C}),e.scheduleUpdate(),t({}),r(),C.playing&&e.ensureGifPlaybackLoop()},y=e.scene.getNonDeletedElements().filter(S=>OP(S)&&!o.selectedElementIds[S.id]&&n[S.fileId]?.mimeType===FP.gif&&e.imageCache.get(S.fileId)?.gifDecodeStatus==="deferred").map(S=>{let C=GP(S,o);return kt("span",{className:"gif-playback-controls gif-playback-controls__deferred-badge",role:"img","aria-label":"GIF paused",style:C,children:Nx},S.id)}),x=e.scene.getSelectedElements(o);return hi(uU,{children:[y,(()=>{if(x.length!==1)return null;let S=x[0];if(!OP(S)||n[S.fileId]?.mimeType!==FP.gif)return null;let C=e.imageCache.get(S.fileId),P=C?.gif,[M,,D,_]=HP([S]),k=WE({sceneX:M,sceneY:_},o),F=WE({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=GP(S,o);return kt("div",{className:"gif-playback-controls gif-playback-controls--deferred",style:K,onPointerDown:Te=>Te.stopPropagation(),children:kt("button",{type:"button",className:"gif-playback-controls__load-large",title:"Load Large GIF",onClick:()=>{e.loadDeferredGif(S.fileId)},children:"Load Large GIF"})})}if(C?.gifDecodeStatus==="pending")return null;let U=P?.frames.length??0;if(!P||U<2)return null;let V=S.gifPlayback??{frameIndex:0,speed:1,playing:!1},G=e.state,re=e.getGifPlaybackFrameIndex(S)??V.frameIndex,B=Math.min(Math.max(re,0),U-1),W=Math.min(G.height-120,z+48),ue=Math.max(12,z-52),Ee=K=>{let Te=(K+U)%U;e.setGifPlaybackFrameIndex(S,Te),w(S,{...V,frameIndex:Te,playing:!1})},le=K=>{K.stopPropagation(),Ee(B+(K.deltaY<0?1:-1))},he=K=>{e.setGifPlaybackFrameIndex(S,B),w(S,{...V,frameIndex:B,playing:K})},ge=[.25,.5,.75,1,1.25,1.5,1.75,2,4],se=K=>{let Te=ge.indexOf(K);return Te!==-1?Te:ge.reduce((At,Si,bu)=>Math.abs(Si-K)<Math.abs(ge[At]-K)?bu:At,0)},xe=K=>{w(S,{...V,speed:K})},it=K=>{let Te=se(V.speed);xe(ge[Math.min(Math.max(Te+K,0),ge.length-1)])},$e=Number.isInteger(V.speed)?`${V.speed}`:`${V.speed}`,ke=U*nc-UP,Zt=Math.min(Math.max(G.width*.9,1),ke),Go=Math.max(ke-Zt,0),Ho=Math.min(i,Go),Uo=Math.max(Math.floor(Ho/nc)-zP,0),Ii=Math.ceil(Zt/nc)+zP*2,fs=Math.min(Uo+Ii,U),ho=P.frames.slice(Uo,fs),on=K=>{K.pointerType!=="mouse"||K.button!==0||(u.current={pointerId:K.pointerId,startClientX:K.clientX,startScrollLeft:K.currentTarget.scrollLeft,didDrag:!1},K.stopPropagation())},Wo=K=>{let Te=u.current;if(!Te||Te.pointerId!==K.pointerId)return;let At=K.clientX-Te.startClientX;!Te.didDrag&&Math.abs(At)<=3||(Te.didDrag||(Te.didDrag=!0,K.currentTarget.setPointerCapture?.(K.pointerId),l(!0)),K.currentTarget.scrollLeft=Te.startScrollLeft-At,a(K.currentTarget.scrollLeft),K.preventDefault(),K.stopPropagation())},Eu=K=>{let Te=u.current;!Te||Te.pointerId!==K.pointerId||(E.current=Te.didDrag,u.current=null,K.currentTarget.hasPointerCapture?.(K.pointerId)&&K.currentTarget.releasePointerCapture(K.pointerId),l(!1),K.stopPropagation())},Cc=K=>{let Te=u.current;!Te||Te.pointerId!==K.pointerId||(u.current=null,l(!1),K.stopPropagation())},Vo=K=>{K.pointerType!=="mouse"&&K.stopPropagation()};return hi("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:ue},children:ge.map(K=>{let Te=Number.isInteger(K)?`${K}`:`${K}`;return hi("button",{type:"button",className:UE("gif-speed-picker__speed",{"gif-speed-picker__speed--selected":K===V.speed}),onClick:()=>xe(K),title:`${Te}x`,children:["x",Te]},K)})}),hi("div",{className:"gif-playback-controls__bar",children:[hi("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--speed",ref:d,onClick:()=>t({openPopup:o.openPopup==="gifSpeedPicker"?null:"gifSpeedPicker"}),onWheel:K=>{K.stopPropagation(),it(K.deltaY<0?1:-1)},title:"Speed",children:["x",$e]}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>Ee(B-1),onWheel:le,title:"Previous frame",children:q1}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>he(!V.playing),onWheel:le,title:V.playing?"Pause":"Play",children:V.playing?dU:cU}),kt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>Ee(B+1),onWheel:le,title:"Next frame",children:J1}),kt("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--frames",ref:c,onClick:()=>{o.openPopup!=="gifFrameGallery"&&a(Math.max(B*nc-Zt/2,0)),t({openPopup:o.openPopup==="gifFrameGallery"?null:"gifFrameGallery"})},onWheel:le,title:"Frames",children:Q1})]}),o.openPopup==="gifFrameGallery"&&kt("div",{className:UE("gif-frame-gallery",{"gif-frame-gallery--dragging":s}),style:{...g??{left:Y,top:W},width:Zt},ref:K=>{p.current=K,K&&K.scrollLeft!==Ho&&(K.scrollLeft=Ho)},onScroll:K=>{a(K.currentTarget.scrollLeft)},onPointerDownCapture:Vo,onPointerMoveCapture:Vo,onPointerUpCapture:Vo,onPointerCancelCapture:Vo,onPointerDown:on,onPointerMove:Wo,onPointerUp:Eu,onPointerCancel:Cc,onLostPointerCapture:Cc,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:ke},children:ho.map((K,Te)=>{let At=Uo+Te;return hi("button",{type:"button",className:UE("gif-frame-gallery__frame",{"gif-frame-gallery__frame--selected":At===B}),style:{left:At*nc},onClick:()=>Ee(At),title:`Frame ${At+1}`,children:[kt("canvas",{width:K.width,height:K.height,ref:Si=>{Si?.getContext("2d")?.drawImage(K,0,0)}}),kt("span",{children:At+1})]},At)})})})]})})()]})};import VP,{useMemo as wU}from"react";import YP from"clsx";import{isDarwin as KP,isFirefox as vU,isWindows as IU}from"@excalidraw/common";import{KEYS as as}from"@excalidraw/common";import{SHAPES as SU}from"@excalidraw/element/shapes";import{isFirefox as hU,KEYS as VE}from"@excalidraw/common";import{SHAPES as gU}from"@excalidraw/element/shapes";import{Fragment as yU,jsx as Ye,jsxs as fi}from"react/jsx-runtime";var fU=e=>fi(yU,{children:[Ye("h3",{children:e.title}),Ye("div",{className:"HelpDialog__islands-container",children:e.children})]}),YE=e=>fi("div",{className:`HelpDialog__island ${e.className}`,children:[Ye("h4",{className:"HelpDialog__island-title",children:e.caption}),Ye("div",{className:"HelpDialog__island-content",children:e.children})]});function*EU(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()),It=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ye(xU,{children:bU(a)},a)));return fi("div",{className:"HelpDialog__shortcut",children:[Ye("div",{children:e}),Ye("div",{className:"HelpDialog__key-container",children:[...EU(o,t?f("helpDialog.or"):null)]})]})},xU=e=>Ye("kbd",{className:"HelpDialog__key",...e});function KE(){return fi(fU,{title:f("helpDialog.shortcuts"),children:[fi(YE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ye(It,{label:f("toolBar.hand"),shortcuts:[VE.H]}),gU.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ye(It,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ye(It,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ye(It,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),fi(YE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ye(It,{label:f("helpDialog.smartZoom"),shortcuts:[VE.F]}),Ye(It,{label:f("helpDialog.dragToZoom"),shortcuts:[`${VE.Z}+${f("helpDialog.drag")}`]}),Ye(It,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),fi(YE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ye(It,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ye(It,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ye(It,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ye(It,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(lr||hU)&&Ye(It,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ye(It,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ye(It,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ye(It,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ye(It,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ye(It,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as $P,jsx as j,jsxs as Ei}from"react/jsx-runtime";var TU=e=>Ei($P,{children:[j("h3",{children:e.title}),j("div",{className:"HelpDialog__islands-container",children:e.children})]}),XE=e=>Ei("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*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()),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(kU,{children:PU(a)},a)));return Ei("div",{className:"HelpDialog__shortcut",children:[j("div",{children:e}),j("div",{className:"HelpDialog__key-container",children:[...CU(o,t?f("helpDialog.or"):null)]})]})},kU=e=>j("kbd",{className:"HelpDialog__key",...e}),XP=({onClose:e})=>{let[n,t]=VP.useState(!1),o=VP.useCallback(()=>{e&&e()},[e]),r=wU(()=>n?j("button",{className:YP("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):j("button",{className:YP("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return j($P,{children:j(wn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?Ei(TU,{title:f("helpDialog.shortcuts"),children:[Ei(XE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[j(J,{label:f("toolBar.hand"),shortcuts:[as.H]}),SU.map(({value:i,key:a})=>j(J,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),j(J,{label:f("toolBar.frame"),shortcuts:[as.F]}),j(J,{label:f("labels.eyeDropper"),shortcuts:[as.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:[as.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})]}),Ei(XE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[j(J,{label:f("helpDialog.smartZoom"),shortcuts:[as.F]}),j(J,{label:f("helpDialog.dragToZoom"),shortcuts:[`${as.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("stats.fullTitle"),shortcuts:[N("Alt+/")]}),j(J,{label:f("search.title"),shortcuts:[je("searchMenu")]})]}),Ei(XE,{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")}`)]}),(lr||vU)&&j(J,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),j(J,{label:f("labels.sendToBack"),shortcuts:[KP?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),j(J,{label:f("labels.bringToFront"),shortcuts:[KP?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+R")]}),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:IU?[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(KE,{})})})};import{useEffect as qP,useRef as JP,useState as bi}from"react";import{DEFAULT_EXPORT_PADDING as RU,EXPORT_IMAGE_TYPES as $E,isFirefox as NU,EXPORT_SCALES as BU,cloneJSON as QP}from"@excalidraw/common";import{useCallback as MU,useRef as AU,useState as DU}from"react";var LU=2e3,ZP=()=>{let[e,n]=DU(null),t=AU(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},LU)},r=MU(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import _U from"clsx";import{jsx as jP}from"react/jsx-runtime";var oc=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>jP("div",{className:_U("Switch",{toggled:t,disabled:r}),children:jP("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});import{jsx as He,jsxs as Cr}from"react/jsx-runtime";var FU=()=>Cr("div",{children:[He("h3",{children:f("canvasError.cannotShowPreview")}),He("p",{children:He("span",{children:f("canvasError.canvasTooBig")})}),Cr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),OU=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=Le(n,e),[l,d]=bi(i),[c,m]=bi(s),[p,u]=bi(e.exportBackground),[E,g]=bi(e.exportEmbedScene),[b,w]=bi(e.exportScale),y=JP(null),x=JP(0),[I,S]=bi(null),{onCopy:C,copyStatus:P,resetCopyStatus:M}=ZP();qP(()=>{M()},[l,p,a,b,E,M]);let{exportedElements:D,exportingFrame:_}=$r(n,e,c);return qP(()=>{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 Lp({elements:D,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:RU,maxWidthOrHeight:Math.max(L,F),exportingFrame:_}).then(async U=>{if(!z()){try{await Is(U)}catch(V){throw V.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):V}z()||(S(null),k.replaceChildren(U))}}).catch(U=>{z()||(console.error(U),S(U))}),()=>{x.current+=1}},[e,t,D,_,l,p,a,b,E]),Cr("div",{className:"ImageExportModal",children:[He("h3",{children:f("imageExportDialog.header")}),Cr("div",{className:"ImageExportModal__preview",children:[He("div",{className:"ImageExportModal__preview__canvas",ref:y,children:I&&He(FU,{})}),He("div",{className:"ImageExportModal__preview__filename",children:!Pi&&He("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{d(k.target.value),o.executeAction(tg,"ui",k.target.value)}})})]}),Cr("div",{className:"ImageExportModal__settings",children:[He("h3",{children:f("imageExportDialog.header")}),s&&He(rc,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:He(oc,{name:"exportOnlySelected",checked:c,onChange:k=>{m(k)}})}),He(rc,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:He(oc,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(ng,"ui",k)}})}),He(rc,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:He(oc,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(Aw,"ui",k)}})}),He(rc,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:He(oc,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(Qd,"ui",k)}})}),He(rc,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:He(Ip,{name:"exportScale",value:b,onChange:k=>{w(k),o.executeAction(kw,"ui",k)},choices:BU.map(k=>({value:k,label:`${k}\xD7`}))})}),Cr("div",{className:"ImageExportModal__settings__buttons",children:[He(wr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r($E.png,D,{exportingFrame:_}),icon:ju,children:f("imageExportDialog.button.exportToPng")}),He(wr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r($E.svg,D,{exportingFrame:_}),icon:ju,children:f("imageExportDialog.button.exportToSvg")}),(lr||NU)&&He(wr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r($E.clipboard,D,{exportingFrame:_}),C()},icon:$1,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},rc=({label:e,children:n,tooltip:t,name:o})=>Cr("div",{className:"ImageExportModal__settings__setting",title:e,children:[Cr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&He(pt,{label:t,long:!0,children:j1})]}),He("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),ek=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=bi(()=>({appStateSnapshot:QP(n),elementsSnapshot:QP(e)}));return He(wn,{onCloseRequest:i,size:"wide",title:!1,children:He(OU,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import CW from"clsx";import{CANVAS_SEARCH_TAB as xk,DEFAULT_SIDEBAR as PW}from"@excalidraw/common";import zU from"clsx";import GU from"lodash.debounce";import{Fragment as HU,memo as UU,useEffect as ic,useMemo as tk,useRef as ZE,useState as nk}from"react";import{CLASSES as WU,EVENT as VU,FONT_FAMILY as jE,FRAME_STYLE as qE,getLineHeight as YU}from"@excalidraw/common";import{getCommonBounds as KU,isElementCompletelyInViewport as XU}from"@excalidraw/element";import{measureText as ac}from"@excalidraw/element";import{KEYS as ss,randomInteger as ok,addEventListener as $U,getFontString as Hp}from"@excalidraw/common";import{newTextElement as ZU}from"@excalidraw/element";import{isTextElement as sk,isFrameLikeElement as Up}from"@excalidraw/element";import{getDefaultFrameName as lk}from"@excalidraw/element/frame";import{Fragment as iW,jsx as ft,jsxs as On}from"react/jsx-runtime";var jU=Qe(""),JE=Qe(null),qU=350,ck=()=>{let e=Tt(),n=Oe(),t=ZE(null),[o,r]=Ue(jU),i=o.trim(),[a,s]=nk(!1),[l,d]=nk({nonce:null,items:[]}),c=ZE(null),m=ZE(void 0),[p,u]=Ue(JE),E=e.scene.getNonDeletedElementsMap();ic(()=>{a||(i!==c.current||e.scene.getSceneNonce()!==m.current)&&(c.current=null,ak(i,e,(x,I)=>{d({nonce:ok(),items:x}),c.current=i,m.current=e.scene.getSceneNonce(),n({searchMatches:x.length?{focusedId:null,matches:x.map(S=>({id:S.element.id,focus:!1,matchedLines:S.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)};ic(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:p!==null&&x.searchMatches?.matches[p]?.id||null,matches:x.searchMatches.matches.map((S,C)=>C===p?{...S,focus:!0}:{...S,focus:!1})}}:null)},[p,n]),ic(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let I=e.state.zoom.value,S=ZU({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:Up(x.element)?qE.nameFontSize:x.element.fontSize,fontFamily:Up(x.element)?jE.Assistant:x.element.fontFamily}),C=14,P=S.fontSize,M=P*I<C;if(!XU([S],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:KU([S]),fit:D,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),ic(()=>()=>{u(null),c.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let w=Hi({goToNextItem:g,goToPreviousItem:b,searchMatches:l});ic(()=>{let x=I=>{if(I.key===ss.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){I.preventDefault(),I.stopPropagation(),n({openSidebar:null});return}if(I[ss.CTRL_OR_CMD]&&I.key===ss.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===ss.ENTER&&(I.stopPropagation(),w.goToNextItem()),I.key===ss.ARROW_UP?(I.stopPropagation(),w.goToPreviousItem()):I.key===ss.ARROW_DOWN&&(I.stopPropagation(),w.goToNextItem()))};return $U(window,VU.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 On("div",{className:"layer-ui__search",children:[On("div",{className:"layer-ui__search-header",children:[ft(zp,{className:WU.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:Jn,onChange:x=>{r(x),s(!0);let I=x.trim();ak(I,e,(S,C)=>{d({nonce:ok(),items:S}),u(C),c.current=I,m.current=e.scene.getSceneNonce(),n({searchMatches:S.length?{focusedId:null,matches:S.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),s(!1)})},selectOnRender:!0}),ft(vn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:an})]}),On("div",{className:"layer-ui__search-count",children:[l.items.length>0&&On(iW,{children:[p!==null&&p>-1?On("div",{children:[p+1," / ",y]}):ft("div",{children:y}),On("div",{className:"result-nav",children:[ft(vn,{onSelect:()=>{g()},className:"result-nav-btn",children:Xc}),ft(vn,{onSelect:()=>{b()},className:"result-nav-btn",children:g0})]})]}),l.items.length===0&&i&&c.current&&ft("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),ft(eW,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},rk=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 ft("div",{tabIndex:-1,className:zU("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ft("div",{className:"preview-text",children:n.flatMap((t,o)=>ft(HU,{children:o===2?ft("b",{children:t}):t},o))})})},JU=e=>{let n=tk(()=>e.matches.items.filter(o=>Up(o.element)),[e.matches]),t=tk(()=>e.matches.items.filter(o=>sk(o.element)),[e.matches]);return On("div",{className:"layer-ui__search-results",children:[n.length>0&&On("div",{className:"layer-ui__search-result-container",children:[On("div",{className:"layer-ui__search-result-title",children:[ft("div",{className:"title-icon",children:jn}),ft("div",{children:f("search.frames")})]}),n.map((o,r)=>ft(rk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&ft("div",{className:"layer-ui__divider"})]}),t.length>0&&On("div",{className:"layer-ui__search-result-container",children:[On("div",{className:"layer-ui__search-result-title",children:[ft("div",{className:"title-icon",children:Pn}),ft("div",{children:f("search.texts")})]}),t.map((o,r)=>ft(rk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},QU=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,eW=UU(JU,QU),ik=(e,n,t)=>{let i=e.slice(0,n),a=i.split(/\s+/),s=i.endsWith(" "),l=a.length-2-1-(s?0:1),d=a.slice(l<=0?0:l).join(" ")+(s?" ":""),c=20;d=d.length>c?d.slice(-c):d;let m=e.slice(n+t.length),p=m.split(/\s+/),u=!m.startsWith(" "),E=u?6:5,g=(u?"":" ")+p.slice(0,E).join(" ");return{indexInSearchQuery:d.length,previewText:d+t+g,moreBefore:l>0,moreAfter:p.length>E}},tW=(e,n)=>{let t=e.split(`
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 d=l-(a.length+r);for(;d>0;)a+=" ",d--}}o.push(a),r=r+a.length}return o.join(`
20
+ `)},nW=(e,n,t)=>{let r=tW(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,d=e.originalText.slice(t,t+n.length),c=[];for(let m of i){if(d==="")break;if(l>=m.startIndex&&l<=m.endIndex){let p=m.endIndex+1-l,u=m.line.slice(0,l-m.startIndex),E=d.slice(0,p);d=d.slice(p);let g=ac(u,Hp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let I=ac(m.line,Hp(e),e.lineHeight),S=e.textAlign==="center"?(e.width-I.width)/2:e.width-I.width;g.width+=S}let{width:b,height:w}=ac(E,Hp(e),e.lineHeight),y=g.width,x=m.lineNumber*g.height;c.push({offsetX:y,offsetY:x,width:b,height:w,showOnCanvas:!0}),l+=p}}return c},oW=(e,n,t,o)=>{let r=e.name??lk(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=Hp({fontSize:qE.nameFontSize,fontFamily:jE.Assistant}),l=YU(jE.Assistant),d=ac(a,s,l);a===""&&(d.width=0);let c=ac(i,s,l),m=d.width,p=-d.height-qE.strokeWidth,u=c.width;return[{offsetX:m,offsetY:p,width:u,height:c.height,showOnCanvas:m+u<=e.width*o}]},rW=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),ak=GU((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>sk(p)),i=o.filter(p=>Up(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(rW(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=ik(E,u.index,e),b=nW(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??lk(p);for(;(u=s.exec(E))!==null;){let g=ik(E,u.index,e),b=oW(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 d=new Set(n.visibleElements.map(p=>p.id)),c=[...l,...a],m=c.findIndex(p=>d.has(p.element.id))??null;t(c,m)},qU);import bW from"clsx";import{useEffect as gk,useLayoutEffect as fk,useRef as sb,useState as xW,forwardRef as Ek,useImperativeHandle as yW,useCallback as pk}from"react";import{CLASSES as wW,EVENT as uk,isDevEnv as vW,KEYS as IW,updateObject as SW}from"@excalidraw/common";import sW from"clsx";import{useContext as lW}from"react";import aW from"react";var Wp=aW.createContext({});import{jsx as QE,jsxs as dk}from"react/jsx-runtime";var eb=({children:e,className:n})=>{let t=be(),o=lW(Wp),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return dk("div",{className:sW("sidebar__header",n),"data-testid":"sidebar-header",children:[e,dk("div",{className:"sidebar__header__buttons",children:[r&&QE(pt,{label:f("labels.sidebarLock"),children:QE(vn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:Fx})}),QE(vn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:an})]})]})};eb.displayName="SidebarHeader";import{Tabs as cW}from"radix-ui";import{jsx as mk}from"react/jsx-runtime";var tb=({children:e,tab:n,onSelect:t,...o})=>mk(cW.Trigger,{value:n,asChild:!0,onSelect:t,children:mk("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});tb.displayName="SidebarTabTrigger";import{Tabs as dW}from"radix-ui";import{jsx as mW}from"react/jsx-runtime";var nb=({children:e,...n})=>mW(dW.List,{className:"sidebar-triggers",...n,children:e});nb.displayName="SidebarTabTriggers";import pW from"clsx";import{jsx as ob,jsxs as uW}from"react/jsx-runtime";var rb=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Oe(),c=ye().openSidebar?.name===e;return ob("button",{type:"button",title:o,className:"sidebar-trigger__label-element","aria-label":o,"aria-keyshortcuts":"0","aria-pressed":c,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=!c;l({openSidebar:m?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(m)},children:uW("div",{className:pW("sidebar-trigger",a),style:s,children:[t&&ob("div",{children:t}),r&&ob("div",{className:"sidebar-trigger__label",children:r})]})})};rb.displayName="SidebarTrigger";import{Tabs as hW}from"radix-ui";import{jsx as gW}from"react/jsx-runtime";var ib=({children:e,...n})=>{let t=ye(),o=Oe();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return gW(hW.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};ib.displayName="SidebarTabs";import{Tabs as fW}from"radix-ui";import{jsx as EW}from"react/jsx-runtime";var ab=({tab:e,children:n,...t})=>EW(fW.Content,{...t,value:e,"data-testid":e,children:n});ab.displayName="SidebarTab";import{jsx as hk}from"react/jsx-runtime";import{createElement as TW}from"react";var lb=Qe(!1),bk=Ek(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{vW()&&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=Oe(),l=Mx(lb);fk(()=>(l(!!o),()=>{l(!1)}),[l,o]);let d=sb({});d.current.onCloseRequest=()=>{s({openSidebar:null})},d.current.onDock=u=>t?.(u),d.current=SW(d.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let c=sb(null);yW(a,()=>c.current);let m=be(),p=pk(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Gi(c,pk(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),gk(()=>{let u=E=>{E.key===IW.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(uk.KEYDOWN,u),()=>{document.removeEventListener(uk.KEYDOWN,u)}},[p,o,m.canFitSidebar]),hk(We,{...i,className:bW(wW.SIDEBAR,{"sidebar--docked":o},r),"data-viewport-ui":m.formFactor!=="phone"?"side":void 0,"data-viewport-ui-name":m.formFactor!=="phone"?"sidebar":void 0,ref:c,children:hk(Wp.Provider,{value:d.current,children:n})})});bk.displayName="SidebarInner";var Pr=Object.assign(Ek((e,n)=>{let t=ye(),{onStateChange:o}=e,r=sb(t.openSidebar);gk(()=>{(!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]=xW(!1);return fk(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?TW(bk,{...e,ref:n,key:e.name}):null}),{Header:eb,TabTriggers:nb,TabTrigger:tb,Tabs:ib,Tab:ab,Trigger:rb});Pr.displayName="Sidebar";import{jsx as ls,jsxs as kW}from"react/jsx-runtime";import{createElement as MW}from"react";var yk=mi("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=ot();return ls(n.In,{children:ls(Pr.Trigger,{...e,className:"default-sidebar-trigger",name:PW.name})})});yk.displayName="DefaultSidebarTrigger";var wk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=ot();return ls(n.In,{children:e})};wk.displayName="DefaultTabTriggers";var cb=Object.assign(mi("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=ye(),a=Oe(),s=i.openSidebar?.tab===xk,l=s?!1:t??i.defaultSidebarDockedPreference,d=!s&&t==null&&o!==!1;return MW(Pr,{...r,name:"default",key:"default",className:CW("default-sidebar",{"default-sidebar--search-only":s},n),docked:l,onDock:d?c=>{a({defaultSidebarDockedPreference:c}),o?.(c)}:void 0},kW(Pr.Tabs,{children:[!s&&ls(Pr.Header,{}),ls(Pr.Tab,{tab:xk,children:ls(ck,{})}),!s&&e]}))}),{Trigger:yk,TabTriggers:wk});import DW from"react";import{getFrame as LW}from"@excalidraw/common";import{jsx as AW}from"react/jsx-runtime";var db={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"}},mb=({children:e,color:n})=>AW("div",{className:"Card",style:{"--card-color":db[n].base,"--card-color-darker":db[n].darker,"--card-color-darkest":db[n].darkest},children:e});import{Fragment as RW,jsx as zn,jsxs as Vp}from"react/jsx-runtime";var _W=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return zn("div",{className:"ExportDialog ExportDialog--json",children:Vp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Vp(mb,{color:"lime",children:[zn("div",{className:"Card-icon",children:e1}),zn("h2",{children:f("exportDialog.disk_title")}),Vp("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Pi&&r.renderAction("changeProjectName")]}),zn(Z,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(rl,"ui")}})]}),l&&Vp(mb,{color:"pink",children:[zn("div",{className:"Card-icon",children:Ms}),zn("h2",{children:f("exportDialog.link_title")}),zn("div",{className:"Card-details",children:f("exportDialog.link_details")}),zn(Z,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Fe("export","link",`ui (${LW()})`),await l(e,n,o),s()}catch(d){t({errorMessage:d.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},vk=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=DW.useCallback(()=>{a({openDialog:null})},[a]);return zn(RW,{children:n.openDialog?.name==="jsonExport"&&zn(wn,{onCloseRequest:s,title:f("buttons.export"),children:zn(_W,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import NW from"clsx";import{jsx as BW}from"react/jsx-runtime";var Ik=e=>BW(Z,{className:NW("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:qn,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import Ak from"clsx";import{useState as $W}from"react";import{CANVAS_SEARCH_TAB as ZW,DEFAULT_SIDEBAR as jW,KEYS as sc}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as FW,DEFAULT_SIDEBAR as OW}from"@excalidraw/common";import{isArrowElement as zW,isFlowchartNodeElement as GW,isImageElement as Sk,isLinearElement as Tk,isLineElement as HW,isTextBindableContainer as UW,isTextElement as WW}from"@excalidraw/element";import{isNodeInFlowchart as VW}from"@excalidraw/element";import{jsx as pb}from"react/jsx-runtime";var Se=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,YW=({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===OW.name&&e.openSidebar.tab===FW&&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 d=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&d[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"&&d.length===1){let c=d[0];return Tk(c)&&c.points.length===2?f("hints.lockAngle",{shortcut:Se("Shift")}):Sk(c)?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(d.length===1&&WW(d[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(d.length===1&&Sk(d[0]))return f("hints.enterCropEditor",{shortcut:Se("Enter")});if(r.type==="selection"){if(e.selectionElement&&!d.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:Se("CtrlOrCmd")});if(hr(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:Se("CtrlOrCmd")});if(!d.length&&!n)return f("hints.canvasPanning",{shortcut_1:Se(f("keys.mmb")),shortcut_2:Se("Space")});if(d.length===1){if(Tk(d[0]))return zW(d[0])&&e.selectedLinearElement?.elementId===d[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===d[0].points.length-1)?f("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:Se("Delete"),shortcut_2:Se(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:Se("Shift"),shortcut_2:Se("Alt")}):HW(d[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&&UW(d[0])){let c=f("hints.bindTextToElement",{shortcut:Se("Enter")}),m=f("hints.createFlowchart",{shortcut:Se(["CtrlOrCmd","\u2191\u2193"])});return GW(d[0])?VW(d[0],o.scene.getNonDeletedElementsMap())?[c,m]:[c,m]:c}}}return null},Ck=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=YW({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 d=s[0]==="<"&&s.match(/^<kbd>([^<]+)<\/kbd>$/);return pb("kbd",{children:d?d[1]:s},l)}return s});return pb("div",{className:"HintViewer",children:pb("span",{children:a})})};import KW from"clsx";import{jsx as XW}from"react/jsx-runtime";var Pk=e=>XW(Z,{className:KW("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?Xo:Eo,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 xi,jsx as ie,jsxs as _o}from"react/jsx-runtime";var qW=(e,n)=>e==="image"&&n.tools?.image===!1,JW=({app:e,activeTool:n,type:t,shortcut:o})=>ie(pe.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:ze[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??oa(t),disabled:Je(e,t),children:f(`toolBar.${t}`)}),kk=({app:e})=>ie(pe.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?Xo:Eo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:sc.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),QW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Lt))return null;let t=je("objectsSnapMode");return ie(pe.Item,{onSelect:()=>e.executeAction(Lt,"ui"),icon:jo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},eV=({actionManager:e,app:n})=>{if(!e.isActionEnabled(Lt))return null;let t=f("buttons.objectsSnapMode"),o=je("objectsSnapMode");return ie(Z,{type:"toggle",icon:jo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(Lt,"ui")})},Mk=({actionManager:e,appState:n})=>{let t=f("search.title"),o=je("searchMenu");return ie(pe.Item,{onSelect:()=>e.executeAction(Pl,"ui"),icon:Jn,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===jW.name&&n.openSidebar.tab===ZW,shortcut:o,children:t})},tV=({app:e})=>ie(Z,{type:"button",icon:Fi,title:`${f("labels.eyeDropper")} - ${sc.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":sc.I.toLocaleUpperCase(),keyBindingLabel:sc.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),nV=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=$W(!1),l=ct()==="full",d=n.type==="frame",c=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&&ta.includes(n.type);return _o(pe,{open:a,children:[ie(pe.Trigger,{className:Ak("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":g||d||E||!r&&l&&c||u||p||m&&!e.props.isCollaborating}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:g?ze[n.type].icon:d?jn:E?Zo:!r&&l&&c?Gr:m&&!e.props.isCollaborating?qn:u?Li:p?Zn:Ss}),ie(pe.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?_o(xi,{children:[l&&ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Li,"data-testid":"toolbar-lasso",selected:u,disabled:Je(e,"lasso"),children:f("toolBar.lasso")}),ta.filter(b=>!qW(b,o)).map(b=>ie(JW,{app:e,activeTool:n,type:b},b)),ie("div",{className:"App-toolbar__dropdown-divider"}),ie(Mk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ie(xi,{children:ie(kk,{app:e})})]}):_o(xi,{children:[ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:jn,shortcut:sc.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:d,disabled:Je(e,"frame"),children:f("toolBar.frame")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Zo,"data-testid":"toolbar-embeddable",selected:E,disabled:Je(e,"embeddable"),children:f("toolBar.embeddable")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Gr,shortcut:oa("autoshape"),"data-testid":"toolbar-autoshape",selected:c,disabled:Je(e,"autoshape"),children:f("toolBar.autoshape")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:qn,"data-testid":"toolbar-laser",selected:m,disabled:Je(e,"laser"),children:f("toolBar.laser")}),ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Zn,"data-testid":"toolbar-bucketfill",selected:p,disabled:Je(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&ie(pe.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Li,"data-testid":"toolbar-lasso",selected:u,disabled:Je(e,"lasso"),children:f("toolBar.lasso")}),ie("div",{className:"App-toolbar__dropdown-divider"}),ie(QW,{actionManager:i,app:e}),ie(Mk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&ie(kk,{app:e})]})})]})},Dk=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=be(),d=ct()==="compact",c=n.activeTool,m={app:e,activeTool:c},p=n.myocSimplifiedMode,u=d?ie(Gd,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?ie(rw,{...m}):ie(ow,{...m});return _o(We,{padding:1,className:Ak("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":d}),"data-viewport-ui":"top",children:[ie(Ck,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,_o(Bt.Row,{gap:d?.5:1,children:[!d&&ie(Ja,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&_o(xi,{children:[ie(Pk,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),ie("div",{className:"App-toolbar__divider"})]}),ie(zd,{...m}),u,p?_o(xi,{children:[ie(Zs,{...m}),ie(js,{...m}),ie(tV,{app:e}),o.tools?.image!==!1&&ie(qs,{...m}),ie(Js,{...m})]}):_o(xi,{children:[ie(qy,{...m}),ie(Jy,{...m}),ie(Qy,{...m}),ie(ew,{...m}),ie(tw,{...m}),d?ie(Hd,{...m}):ie(Zs,{...m}),ie(js,{...m}),o.tools?.image!==!1&&ie(qs,{...m}),ie(Js,{...m})]}),ie("div",{className:"App-toolbar__divider"}),ie(nV,{app:e,activeTool:c,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&_o(xi,{children:[ie("div",{className:"App-toolbar__divider"}),ie(eV,{actionManager:r,app:e})]})]})]})};import{Fragment as ub,jsx as te,jsxs as tn}from"react/jsx-runtime";var cV=({UIOptions:e})=>tn(Ft,{__fallback:!0,children:[te(Ft.DefaultItems.LoadScene,{}),te(Ft.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&te(Ft.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&te(Ft.DefaultItems.SaveAsImage,{}),te(Ft.DefaultItems.SearchMenu,{}),te(Ft.DefaultItems.Help,{}),te(Ft.Separator,{}),te(Ft.Group,{title:"Excalidraw links",children:te(Ft.DefaultItems.Socials,{})}),te(Ft.Separator,{}),te(Ft.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),te(Ft.DefaultItems.ChangeCanvasBackground,{})]}),dV=()=>tn(Pp,{__fallback:!0,children:[te(Pp.Actions.SaveToDisk,{}),te(Pp.Actions.ExportToImage,{})]}),mV=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:s,showExitZenModeBtn:l,renderTopLeftUI:d,renderTopRightUI:c,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:w,zoomUIEnabled:y,scrollBackToContentUIEnabled:x,isCollaborating:I,generateLinkForSelection:S,currentUserControls:C})=>{let P=be(),M=kn(),_=ct()==="compact",k=oT(),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]=Ue(Gt),U=()=>p.canvasActions.export?te(vk,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,V=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:te(ek,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),G=()=>tn("div",{style:{position:"relative"},children:[tn("div",{className:"excalidraw-ui-top-left",children:[d?.(!1,n),te(k.MainMenuTunnel.Out,{}),te(k.DefaultSidebarTriggerTunnel.Out,{})]}),E&&te(k.WelcomeScreenMenuHintTunnel.Out,{})]}),re=()=>te(Xl,{heading:"selectedShapeActions",className:cs("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?te(We,{className:cs("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:te(vT,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):te(We,{className:rV.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:te(ET,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),B=()=>{let le=w&&lV(n,r),he=w&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return te(bp,{side:"top",children:tn("div",{className:"App-menu App-menu_top",children:[tn(Bt.Col,{gap:L.menuTopGap,className:cs("App-menu_top__left"),children:[G(),w&&te("div",{className:cs("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:le&&re()}),w&&_&&!n.viewModeEnabled&&le&&te(Ja,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),w&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&te(Xl,{heading:"shapes",className:"shapes-section",children:ge=>tn("div",{style:{position:"relative"},children:[E&&te(k.WelcomeScreenToolbarHintTunnel.Out,{}),te(Bt.Col,{gap:L.toolbarColGap,align:"start",children:tn(Bt.Row,{gap:L.toolbarRowGap,className:cs("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[te(Dk,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ge}),I&&te(We,{style:{marginLeft:L.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:te(Ik,{title:f("toolBar.laser"),checked:n.activeTool.type===Lk.laser,onChange:()=>b.setActiveTool({type:Lk.laser}),isMobile:!0})})]})})]})}),tn("div",{className:cs("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(vp,{collaborators:n.collaborators,userToFollow:M.userToFollow?.socketId||null,currentUserControls:C}),c?.(P.formFactor==="phone",n),he&&te(tc,{app:b,onClose:()=>{e.executeAction(mr)},renderCustomStats:m})]})]})})},W=()=>te(cb,{}),ue=!1,Ee=tn(ub,{children:[g,w&&te(ub,{children:te(cV,{UIOptions:p})}),te(dV,{}),w&&n.isLoading&&te(up,{delay:250}),w&&n.errorMessage&&te(BP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),w&&Y&&P.formFactor!=="phone"&&te(z0,{colorPickerType:Y.colorPickerType,onCancel:()=>{z(null)},onChange:(le,he,ge,{altKey:se})=>{if(!(le!=="elementBackground"&&le!=="elementStroke"))if(ge.length){for(let xe of ge)aV(xe,iV(r),{[se&&Y.swapPreviewOnAlt?le==="elementBackground"?"strokeColor":"backgroundColor":le==="elementBackground"?"backgroundColor":"strokeColor"]:he}),sV.delete(xe);b.scene.triggerUpdate()}else o(le==="elementBackground"?{currentItemBackgroundColor:he}:{currentItemStrokeColor:he})},onSelect:(le,he)=>{z(ge=>ge?.keepOpenOnAlt&&he.altKey?ge:null),Y?.onSelect?.(le,he)}}),n.openDialog?.name==="help"&&te(XP,{onClose:()=>{o({openDialog:null})}}),w&&n.openDialog?.name==="elementLinkSelector"&&te(NP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:S}),te(k.OverwriteConfirmDialogTunnel.Out,{}),V(),U(),w&&n.openDialog?.name==="charts"&&te(dC,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),w&&te(WP,{app:b,files:t,setAppState:o}),P.formFactor==="phone"&&te(JT,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:U,renderImageExportDialog:V,setAppState:o,onPenModeToggle:s,renderTopLeftUI:d,renderTopRightUI:c,renderSidebars:W,renderWelcomeScreen:E,defaultUIEnabled:w,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&tn(ub,{children:[M.viewportStatusFrame?.border&&te(dp,{border:M.viewportStatusFrame.border,style:ue?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),tn("div",{className:"layer-ui__wrapper",style:ue?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&te(k.WelcomeScreenCenterTunnel.Out,{}),B(),te(EC,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:w,zoomUIEnabled:y}),(n.toast||x&&n.scrolledOutside||M.viewportStatusFrame?.label)&&tn("div",{className:"floating-status-stack",children:[n.toast&&te(Yd,{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(le=>({...Ti(r,le)}))},children:f("buttons.scrollBackToContent")}),M.viewportStatusFrame?.label&&te(mp,{label:M.viewportStatusFrame.label,border:M.viewportStatusFrame.border})]})]})]}),W()]});return te(gh.Provider,{value:n,children:te(F,{children:te(oE.Provider,{value:k,children:Ee})})})},_k=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:s,suggestedBinding:l,frameToHighlight:d,elementsToHighlight:c,...m}=e;return m},pV=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return Yp(_k(o),_k(a),{selectedElementIds:Yp,selectedGroupIds:Yp})&&Yp(r,s)},Rk=oV.memo(mV,pV);import{useEffect as uV,useRef as hV}from"react";import{jsx as Nk}from"react/jsx-runtime";var Bk=({trails:e})=>{let n=hV(null);return uV(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),Nk("div",{className:"SVGLayer",children:Nk("svg",{ref:n})})};import gV,{useEffect as Fk,useRef as Ok}from"react";import{isShallowEqual as fV,sceneCoordsToViewportCoords as EV}from"@excalidraw/common";import{jsx as yV}from"react/jsx-runtime";var zk="animateInteractiveScene",bV=e=>{let n=Ok(!1),t=Ok(null);return Fk(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&Hf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),Fk(()=>{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((d,c)=>{if(d.selectedElementIds)for(let m of Object.keys(d.selectedElementIds))i.has(m)||i.set(m,[]),i.get(m).push(c);!d.pointer||d.pointer.renderCursor===!1||(d.username&&a.set(c,d.username),d.userState&&s.set(c,d.userState),r.set(c,EV({sceneX:d.pointer.x,sceneY:d.pointer.y},e.appState)),o.set(c,d.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},st.running(zk)||st.start(zk,({deltaTime:d,state:c})=>{let m=Hf({...t.current,deltaTime:d,animationState:c}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),yV("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")})},Gk=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,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}),xV=(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:fV(Gk(e.appState),Gk(n.appState)),hb=gV.memo(bV,xV);import Wk,{useEffect as Kp,useRef as lc}from"react";import{isShallowEqual as Hk}from"@excalidraw/common";import{hasActiveGifDecode as wV}from"@excalidraw/element";import{jsx as SV}from"react/jsx-runtime";var vV=e=>{let n=lc(null),t=lc(!1),o=lc(e),r=lc(()=>{}),i=lc(null);o.current=e;let a=Wk.useCallback(()=>{let s=o.current,l=n.current;if(!l)return;let d=getComputedStyle(l).getPropertyValue("--color-grid-bold").trim(),c=getComputedStyle(l).getPropertyValue("--color-grid-regular").trim();fx({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:d,gridColorRegular:c}},Ma());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=wV(s.visibleElements,s.renderConfig.imageCache);(p||u)&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,Kp(()=>{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]),Kp(()=>{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()}),Kp(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),Kp(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),SV("div",{className:"excalidraw__canvas-wrapper",ref:n})},Uk=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId,suggestedBinding:e.suggestedBinding}),IV=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:Hk(Uk(e.appState),Uk(n.appState))&&Hk(e.renderConfig,n.renderConfig),gb=Wk.memo(vV,IV);import{useEffect as DV,useRef as LV}from"react";import{throttleRAF as TV}from"@excalidraw/common";import{getTargetFrame as CV,isInvisiblySmallElement as PV,renderElement as kV,shouldApplyFrameClip as MV}from"@excalidraw/element";var Vk=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,d]=Ac(e,i),c=Dc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:d});if(c.save(),c.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(PV(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=CV(t,o,a);u&&MV(t,u,a,o)&&hx(u,c,s,a)}kV(t,o,r,n,c,s,a)}else c.clearRect(0,0,l,d);c.restore()}},AV=TV(e=>{Vk(e)}),Yk=(e,n)=>{if(n){AV(e);return}Vk(e)};import{jsx as RV}from"react/jsx-runtime";var _V=e=>{let n=LV(null);return DV(()=>{n.current&&Yk({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Ma())}),RV("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})},Kk=_V;import NV from"clsx";import{useLayoutEffect as BV,useEffect as Xk,useRef as FV,useState as OV}from"react";import{ARROW_TYPE as $k,EVENT as Xp}from"@excalidraw/common";import{jsx as UV}from"react/jsx-runtime";var Zk=700,zV=100,GV=16,HV=5*60*1e3,qk=Qe(null),jk=e=>e===$k.elbow?Jo:e===$k.round?Qo:qo,$p=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(qk,{content:n,nonce:Math.random()}))});v(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<HV);v(this,"onArrowTypeCycled",n=>{this.show(jk(n))});v(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?$o:jk(this.app.state.currentItemArrowType))});this.app=n}},Jk=()=>{let[e,n]=Ue(qk),t=Tt(),{container:o}=Ne(),r=FV(null),[i,a]=OV(!1),s=e?.nonce;return BV(()=>{if(s==null||!o)return;let l=(c,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=sd({cursor:{x:c,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:GV});p.style.transform=`translate(${u}px, ${E}px)`};l(t.viewport.lastPosition.x,t.viewport.lastPosition.y);let d=c=>{l(c.clientX,c.clientY)};return window.addEventListener(Xp.POINTER_MOVE,d),()=>{window.removeEventListener(Xp.POINTER_MOVE,d)}},[s,o,t]),Xk(()=>()=>{n(null)},[n]),Xk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},Zk),d=window.setTimeout(()=>{n(null)},Zk+zV),c=()=>{n(null)};return window.addEventListener(Xp.POINTER_DOWN,c,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(d),window.removeEventListener(Xp.POINTER_DOWN,c,{capture:!0})}},[s,n]),e?UV("div",{ref:r,className:NV("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var Zp=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 d=this.getState();a(i(d),d)}),s)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:s}):l?Promise.resolve(i(this.getState())):new Promise(d=>{this.subscribe({predicate:r,getValue:i,callback:c=>d(c),once:!0})})})}isStateChangePredicateOptions(n){return typeof n=="object"&&!Array.isArray(n)&&"predicate"in n}subscribe(n){return this.listeners.push(n),()=>{this.listeners=this.listeners.filter(t=>t!==n)}}normalize(n,t,o){let r,i,a=t,s=o?.once??!1,l=!1;if(this.isStateChangePredicateOptions(n)){let{predicate:d,callback:c,once:m}=n;r=d,i=p=>p,a=c?(p,u)=>c(u):void 0,s=m??!1,l=d(this.getState())}else if(typeof n=="function"){let d=n;r=(c,m)=>d(c)!==d(m),i=c=>d(c)}else if(Array.isArray(n)){let d=n;r=(c,m)=>d.some(p=>c[p]!==m[p]),i=c=>c}else{let d=n;r=(c,m)=>c[d]!==m[d],i=c=>c[d]}return{predicate:r,getValue:i,callback:a,once: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 WV,getElementsInGroup as VV,isNonDeletedElement as Qk,selectGroupsFromGivenElements as YV}from"@excalidraw/element";import{sceneCoordsToViewportCoords as KV}from"@excalidraw/common";import{flushSync as XV}from"react-dom";import{jsx as ZV}from"react/jsx-runtime";var $V=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!Qk(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&Qk(t)?t:null,r=o?[o]:VV(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=WV(r),{x:s,y:l}=KV({sceneX:i,sceneY:a},e.state);return ZV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{XV(()=>{let d=YV(r,e.state);e.setState({selectedElementIds:r.reduce((c,m)=>({...c,[m.id]:!0}),{}),selectedGroupIds:d,activeLockedId:null})}),e.actionManager.executeAction(ml)},title:f("labels.elementLock.unlock"),children:Ox})},eM=$V;import{Fragment as XK,jsx as Pe,jsxs as Ob}from"react/jsx-runtime";var l3=In.createContext(null),c3=In.createContext(null),zb={formFactor:"desktop",desktopUIMode:"full",userAgent:a3(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},Hb=In.createContext(zb);Hb.displayName="EditorInterfaceContext";var VK={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},Ub=In.createContext({container:null,id:null});Ub.displayName="ExcalidrawContainerContext";var Wb=In.createContext([]);Wb.displayName="ExcalidrawElementsContext";var Vb=In.createContext({...Ko(),width:0,height:0,offsetLeft:0,offsetTop:0});Vb.displayName="ExcalidrawAppStateContext";var Yb=In.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Yb.displayName="ExcalidrawSetAppStateContext";var Kb=In.createContext(null);Kb.displayName="ExcalidrawActionManagerContext";var hs=In.createContext(null);hs.displayName="ExcalidrawAPIContext";var pu=In.createContext(null);pu.displayName="ExcalidrawAPISetContext";var Tt=()=>zo(l3),kn=()=>zo(c3),be=()=>zo(Hb),ct=()=>mu(be()),Ne=()=>zo(Ub),Ui=()=>zo(Wb),Qn=()=>zo(Vb),Oe=()=>zo(Yb),rt=()=>zo(Kb),Md=()=>zo(hs),bc=!1,xc=0,yc=null,Fo=!1,su=!1,Oo=!1,lu=!1,wc={horizontal:null,vertical:null},Dr=0,vc=!1,Fb=new Map,YK=4,cu=!1,du=0,o3=!1,us=null,de={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Gb=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",zb);v(this,"stylesPanelMode",mu(zb));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 co);v(this,"imageStatus",new Map);v(this,"imageStatusEmitter",new co);v(this,"imagePlaceholderUpdateEmitter",new co);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 TY(VK));v(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));v(this,"appStateObserver",new Zp(()=>this.state));v(this,"onStateChange",this.appStateObserver.onStateChange);v(this,"bucketFill",new ep(this));v(this,"flowchart",new ip(this));v(this,"cursor",new tp(this));v(this,"gifPlayback",new ap(this));v(this,"zDragZoom",null);v(this,"arrowText",new Qm(this));v(this,"viewport",new lp(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>de.pointers.size>=2||Oo}));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 rp(this));v(this,"laserTrails",new Am(this));v(this,"eraserTrail",new Fm(this));v(this,"lassoTrail",new Bm(this));v(this,"cursorHints",new $p(this));v(this,"onChangeEmitter",new co);v(this,"onPointerDownEmitter",new co);v(this,"onPointerUpEmitter",new co);v(this,"onUserFollowEmitter",new co);v(this,"onScrollChangeEmitter",new co);v(this,"missingPointerEventCleanupEmitter",new co);v(this,"onRemoveEventListenersEmitter",new co);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=Et.set(t,...o);return this.triggerRender(),r});v(this,"previousHoveredBindableElement",null);v(this,"getEffectiveGridSize",()=>hr(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&&fc(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Ae.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));v(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=mM);v(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),wi.delete(t)});v(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Bo(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=Cb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else Sb(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.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Me({clientX:i.x,clientY:i.y},this.state),s=Me({clientX:i.right,clientY:i.bottom},this.state);return o={x:a.x,y:a.y,width:s.x-a.x,height:s.y-a.y,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,o),o}return null}return o},_cache:new Map});v(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});v(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===mc.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&St(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!MM(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}=Qp({sceneX:i.x,sceneY:i.y},this.state),l=6,d,c=cK(i);if(i.id===this.state.editingFrame){let m=c;d=Pe("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===$.ESCAPE||p.key===$.ENTER)&&this.resetEditingFrame(i)},style:{background:SY(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:`${Ro.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?Ro.nameColorDarkTheme:Ro.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else d=c;return Pe("div",{id:this.getFrameNameDOMId(i),className:Ib.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+Ro.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Ro.nameFontSize,color:t?Ro.nameColorDarkTheme:Ro.nameColorLightTheme,lineHeight:Ro.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:Ae.MOVE,pointerEvents:this.state.viewModeEnabled?ds.disabled:ds.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:d},i.id)})});v(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});v(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());v(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());v(this,"getSceneElements",()=>this.scene.getNonDeletedElements());v(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});v(this,"onExportImage",async(t,o,r)=>{Fe("export",t,"ui");let i=await Zr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(vY).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&_c(i)&&this.setState({fileHandle:i})});v(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Gt,{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:$t.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:$t.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?po(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:$t.IMMEDIATELY})},keepOpenOnAlt:!1})});v(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});v(this,"syncActionResult",Xe(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let o=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),o=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled??this.state.viewModeEnabled,a=t?.appState?.theme||this.props.theme||mc.LIGHT,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 d=r.id,c=t.elements.find(m=>m.id===d);r=c&&au(c)&&Xt(c)?c:null}this.setState(d=>{let c=t.appState||{};return{...d,...c,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($t.NEVER));v(this,"onBlur",Xe(()=>{Fo=!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===kr.EQUAL||t.code===kr.MINUS||t.code===kr.ZERO||t.code===kr.NUM_ADD||t.code===kr.NUM_SUBTRACT||t.code===kr.NUM_ZERO)&&t.preventDefault()});v(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Fo=!1,su=!1,Oo=!1,lu=!1,us=null,de.pointers.clear(),de.lastCenter=null,de.initialDistance=null,de.initialScale=null,clearTimeout(xc),xc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(du),du=0,cu=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),Et.set(Gt,null),Et.set(ro,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&St(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,d=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||l&&!d)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(t)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,mm(),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:nn(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",Xe(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 d=l.files[0],c=await d.getFile();this.loadFileToCanvas(new File([c],c.name||"",{type:c.type}),d)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null}catch(l){console.error(l),t={appState:{errorMessage:l.message||"Encountered an error during importing or restoring scene data"}}}let o=Nr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=ki(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),d=hc(l),c=this.viewport.resolveInitialViewport(s,d,a);c&&(r={...r,...c})}else t?.scrollToContent&&(r={...r,...Ti(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:$t.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),zM(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)??MY(t,o));v(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=_Y(),a=a3(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:aY,l=vb(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=mu(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=RY(t);this.editorInterface=vb(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});v(this,"onResize",Xe(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>wi.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&&(wc=t),this.scheduleImageRefresh()});v(this,"onScroll",hM(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},sY));v(this,"onCut",Xe(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||pc(t.target)||(this.actionManager.executeAction(sm,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onCopy",Xe(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||pc(t.target)||(this.actionManager.executeAction(pa,"keyboard",t),t.preventDefault(),t.stopPropagation())}));v(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(AY&&t.preventDefault(),!bc){bc=!0,t.touches.length===1&&(yc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(xc),xc=window.setTimeout(e.resetTapTwice,mM);return}if(bc&&t.touches.length===1&&yc){let o=t.touches[0];so(oe(o.clientX,o.clientY),oe(yc.x,yc.y))<=bM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),bc=!1,clearTimeout(xc)}t.touches.length===2&&this.setState({selectedElementIds:De({},this.state),activeEmbeddable:null})}});v(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:De(this.state.previousSelectedElementIds,this.state)}):de.pointers.clear())});v(this,"pasteFromClipboard",Xe(async t=>{if(!this.isInteractionEnabled())return;let o=!!cu,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||pc(r)))return;let s=await Xr(t),l=s.getFiles(),d=await jd(s,o);if(this.state.viewModeEnabled){if(!this.containsImagePaste(d,l,o))return;if(!this.shouldInsertImageInViewMode({source:"paste",files:l.map(c=>c.file),data:d,event:t})){t?.preventDefault();return}}if(this.props.onPaste)try{if(await this.props.onPaste(d,t)===!1)return}catch(c){console.error(c)}await this.insertClipboardContent(d,l,o),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t?.preventDefault()}));v(this,"addElementsFromPasteOrLibrary",t=>{let o=Nr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=ps(o),l=ms(r,a)/2,d=ms(i,s)/2,c=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,m=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Me({clientX:c,clientY:m},this.state),E=p-l,g=u-d,[b,w]=Mt(E,g,this.getEffectiveGridSize()),{duplicatedElements:y}=TM({type:"everything",elements:o.map(M=>po(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,WM(I,hc(y));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let M=dK(y,C);I=Db(I,M,C)}this.scene.replaceAllElements(I),y.forEach(M=>{if(Xt(M)&&PM(M)){let D=_M(M,this.scene.getElementsMapIncludingDeleted());nK(M,D,this.scene)}}),LY&&fo.loadElementsFonts(y).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let P=CK(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&Et.get(lb)?this.state.openSidebar:null,...VM(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=>{Dr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=de.pointers.size>=2;de.pointers.delete(t.pointerId),o&&de.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});v(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Fe("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...nn(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||qY(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:ps(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:Yn(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,QV,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});v(this,"addFiles",Xe(t=>{let o=new Map;for(let s of t){let l=s.id,d=this.imageCache.get(l);d&&!this.files[l]&&o.set(l,Promise.resolve(d.image))}let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate();let i=new Set(o.keys());Pb({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,d]of o){let c=this.imageCache.get(l);!c||!s.has(l)||(this.imageCache.set(l,{...c,placeholderImage:await d,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 Br(s),customData:l??{}}))),a=i.find(({file:s})=>!Mi(s));if(a)throw new Su(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 Br(o);if(!Mi(r))throw new Error(f("errors.unsupportedFileType"));let i=new Image,a=new Promise((l,d)=>{i.onload=()=>l(i),i.onerror=()=>d(new Error(f("errors.imageInsertError")))}),s={image:a,mimeType:r.type,isPlaceholder:!0,gifDecodeStatus:r.type===lo.gif?"pending":void 0};this.imageCache.set(t,s),s.gifDecodeStatus==="pending"&&this.imagePlaceholderUpdateEmitter.trigger(),i.src=await Rc(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=cc(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:cc(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())yi(o)&&o.fileId===t&&wi.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===lo.svg))try{let l=vx(LM(Ix(s.dataURL)),lo.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",Xe(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?BY({...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=jM.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return jM.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",Xe(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));v(this,"matchesShortcut",(t,o,r)=>{let i=this.props.keyboardShortcuts?.[t];return i===void 0?r:Qi(o,i)});v(this,"onKeyDown",Xe(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(c,m){let p=c[m];return typeof p=="function"?p.bind(c):m==="key"?t.shiftKey?c.key.toUpperCase():c.key.toLowerCase():p}})),!gM(t.target)){if((t.key===$.ESCAPE||t.key===$.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let c=ce(this.scene.getNonDeletedElementsMap(),this.state);if(c.length===1&&Un(c[0])&&t.key===$.ENTER){this.startImageCropping(c[0]);return}if(t.key===$.ESCAPE)this.updateEditorAtom(ro,null);else if(t.key===$.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(Ib.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let m=Jm(c);Et.get(ro)?.type==="panel"&&Jf(this,{conversionType:m,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),m&&this.updateEditorAtom(ro,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[$.CTRL_OR_CMD]&&t.key.toLowerCase()===$.V&&(cu=t.shiftKey,clearTimeout(du),du=window.setTimeout(()=>{cu=!1},100)),t[$.CTRL_OR_CMD]&&pc(t.target)&&(t.code===kr.MINUS||t.code===kr.EQUAL)){t.preventDefault();return}if(pc(t.target)&&t.key!==$.ESCAPE||bb(t.key)&&gM(t.target))return;if(this.matchesShortcut("helpDialog",t,t.key===$.QUESTION_MARK)){this.setState({openDialog:{name:"help"}});return}else if(this.matchesShortcut("imageExport",t,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 No("COMPLEX_BINDINGS")?this.handleSkipBindMode():iu({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&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let c=jy(t,this);if(this.state.viewModeEnabled&&!xM(c,["laser","hand"]))return;if(c){if(this.state.activeTool.type!==c&&Fe("toolbar",c,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),c==="arrow"&&this.state.activeTool.type==="arrow"){let m=this.state.currentItemArrowType===Mr.sharp?Mr.round:this.state.currentItemArrowType===Mr.round?Mr.elbow:Mr.sharp;this.setState({currentItemArrowType:m}),this.cursorHints.onArrowTypeCycled(m)}else(c==="arrow"||c==="line")&&this.cursorHints.onToolShortcut(c,/^\d$/.test(t.key)?"digit":"letter");c==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():c==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:c},{toggle:!0}),t.stopPropagation();return}else if(this.matchesShortcut("toolLock",t,t.key===$.Q)){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[$.CTRL_OR_CMD]&&!t.repeat&&(No("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Ot(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),iu({app:this,event:t})),bb(t.key)){let c=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),m=new Set;c.filter(g=>uo(g)).filter(g=>{let b=g.startBinding&&!c.some(y=>y.id===g.startBinding?.elementId),w=g.endBinding&&!c.some(y=>y.id===g.endBinding?.elementId);return b||w}).forEach(g=>m.add(g.id)),c=c.filter(g=>!m.has(g.id));let p=this.getEffectiveGridSize()&&(t.shiftKey?dM:this.getEffectiveGridSize())||(t.shiftKey?oY:dM),u=0,E=0;t.key===$.ARROW_LEFT?u=-p:t.key===$.ARROW_RIGHT?u=p:t.key===$.ARROW_UP?E=-p:t.key===$.ARROW_DOWN&&(E=p),c.forEach(g=>{this.scene.mutateElement(g,{x:g.x+u,y:g.y+E},{informMutation:!1,isDragging:!1}),nu(g,this.scene,{simultaneouslyUpdated:c})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===$.ENTER){let c=this.scene.getSelectedElements(this.state);if(c.length===1){let m=c[0];if(t[$.CTRL_OR_CMD]||Rb(m))zt(m)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==m.id)&&(this.store.scheduleCapture(),Kt(m)||this.actionManager.executeAction(Ia));else if(Xt(m)||RM(m)){let p;Xt(m)||(p=m);let u=Mb(m,this.scene.getNonDeletedElementsMap()),E=u.x,g=u.y;this.startTextEditing({sceneX:E,sceneY:g,container:p}),t.preventDefault();return}else St(m)&&this.setState({editingFrame:m.id})}}if(t.key===$.SPACE&&de.pointers.size===0&&(Fo=!0,this.cursor.set(Ae.GRAB),t.preventDefault()),t.key.toLowerCase()===$.Z&&!t[$.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(su=!0,this.cursor.set("zoom-in"),t.preventDefault()),this.matchesShortcut("elementBackground",t,(t.key===$.G||t.key===$.S)&&!t.altKey&&!t[$.CTRL_OR_CMD])||this.matchesShortcut("elementStroke",t,(t.key===$.G||t.key===$.S)&&!t.altKey&&!t[$.CTRL_OR_CMD])){let c=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!c.length)return;this.matchesShortcut("elementBackground",t,t.key===$.G)&&(Yo(this.state.activeTool.type)||c.some(m=>Yo(m.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),this.matchesShortcut("elementStroke",t,t.key===$.S)&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(this.matchesShortcut("fontFamily",t,!t[$.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===$.F)){let c=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!c.length)return;(this.state.activeTool.type==="text"||c.find(m=>Xt(m)||kb(m,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],l=this.matchesShortcut("strokeEyeDropper",t,a),d=this.matchesShortcut("backgroundEyeDropper",t,s);(l||d)&&this.openEyeDropper({type:l?"stroke":"background",swapPreviewOnAlt:!i})}));v(this,"onKeyUp",Xe(t=>{if(this.isInteractionEnabled()){if(t.key===$.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Ae.GRAB):eu(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Fo=!1),t.key.toLowerCase()===$.Z&&(su=!1,this.cursor.reset()),t.key===$.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),iu({app:this,event:t})),(t.key===$.ALT&&this.state.bindMode==="skip"||!t[$.CTRL_OR_CMD]&&!tu(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&No("COMPLEX_BINDINGS"))){let o=Me({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Ar(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());uo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[$.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Ot(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),iu({app:this,event:t})}if(bb(t.key)){wM(this.scene.getSelectedElements(this.state).filter(gc),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Nb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...JM(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...JM(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(ut);let i=na.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?nn(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?nn(this.state,{...t,lastActiveTool:this.state.activeTool}):nn(this.state,t);s.type==="hand"?this.cursor.set(Ae.GRAB):Fo||this.cursor.applyForTool(s),xY(document.activeElement)&&this.focusContainer(),$Y(s.type)||this.setState({suggestedBinding:null}),s.type==="image"&&this.onImageToolbarButtonClick(),this.setState(l=>{let d={snapLines:l.snapLines.length?[]:l.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:eu(s.type)?l.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return s.type==="freedraw"&&this.store.scheduleCapture(),s.type==="lasso"?{...l,...d,activeTool:s,...r?{}:{selectedElementIds:De({},l),selectedGroupIds:De({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...d,activeTool:s,selectedElementIds:De({},l),selectedGroupIds:De({},l),editingGroupId:null,multiElement:null}:{...l,...d,activeTool:s}})});v(this,"setOpenDialog",t=>{this.setState({openDialog:t})});v(this,"isTouchScreenMultiTouchGesture",()=>de.pointers.size>=2);v(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${fM()}`);v(this,"onGestureStart",Xe(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:De({},this.state),activeEmbeddable:null}),de.initialScale=this.state.zoom.value)}));v(this,"onGestureChange",Xe(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=de.initialScale;o&&this.viewport.translate(r=>({...go({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Yn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));v(this,"onGestureEnd",Xe(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:De(this.state.previousSelectedElementIds,this.state)}),de.initialScale=null)}));v(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=n3(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&$2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});v(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=n3(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(of,"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 d=!1,c=l&&this.arrowText.getTextBinding(l,this.getCurrentItemStrokeWidth("text"));c&&(i=null,r=!1,t=c.anchor[0],o=c.anchor[1]);let m=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&m&&(kb(i,this.scene.getNonDeletedElementsMap())||(d=!0));let p=c?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=p?.fontFamily||this.state.currentItemFontFamily,E=p?.lineHeight||uM(u),g=this.state.currentItemFontSize;if(!p&&d&&i&&!gc(i)){let C=bK(yb({fontSize:g,fontFamily:u}),E),P=xK(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=c?{x:t,y:o}:m?{x:m.elementCenterX,y:m.elementCenterY}:p?{x:t,y:o}:{x:b?.x??t,y:b===null?o-HM(g,E)/2:b.y},y=this.getTopLayerFrameAtSceneCoords({x:w.x,y:w.y}),x=y&&(!d||!i||i.frameId===y.id)?y.id:null,I=p||IM({x:w.x,y:w.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:g,fontFamily:u,textAlign:c?.textAlign??(m?"center":this.state.currentItemTextAlign),verticalAlign:c?.verticalAlign??(m?dY.MIDDLE:lM),containerId:d?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?gc(i)?0:i.angle:0,frameId:x});if(!p&&d&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:I.id})}),this.setState({editingTextElement:I}),!p)if(i&&d){let S=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([I],S+1)}else this.insertNewElement(I);l&&c&&this.arrowText.bindText(l,I,c.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 so(oe(o.x,o.y),oe(r.x,r.y))<=bM});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}=Me(t,this.state);if(o.length===1&&zt(o[0])){let s=o[0];if((t[$.CTRL_OR_CMD]&&Nb(s)||Rb(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(Ia);return}else if(this.state.selectedLinearElement&&Kt(o[0])){let l=fe.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=l?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(d&&d>-1){this.store.scheduleCapture(),fe.deleteFixedSegment(o[0],this.scene,d);let c=fe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=c?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:c}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===s.id&&Rb(s))return}if(o.length===1&&Un(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),SK(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&IK(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(d=>({...d,...Wn({editingGroupId:l,selectedElementIds:{[s.id]:!0}},this.scene.getNonDeletedElements(),d,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let s=this.getElementAtPosition(r,i);if(fc(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"||CM(l)||!wY(l.backgroundColor)||Ec({point:oe(r,i),element:l,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(l)}))){let d=Mb(l,this.scene.getNonDeletedElementsMap());r=d.x,i=d.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l||null})}}});v(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==Gn.MAIN){this.lastCompletedCanvasClicks=[];return}let o=Me(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(!Un(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 d=s?.downloadError?.onClick;if(d&&this.isPointInsideImageStatusOverlay(t,a,o,"center"))return()=>d(a.fileId)}return null});v(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=Fl(o,r,this.state,i);return!!a&&so(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&&Mc(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&&ux(a,i,this.state,oe(t.x,t.y)))return a});v(this,"handleElementLinkClick",t=>{let o=c=>c===Gn.MAIN||c===Gn.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=so(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>cM)return;let i=Me(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),s=Mc(this.hitLinkElement,a,this.state,oe(i.x,i.y),this.editorInterface.formFactor==="phone"),l=Me(this.lastPointerUpEvent,this.state),d=Mc(this.hitLinkElement,a,this.state,oe(l.x,l.y),this.editorInterface.formFactor==="phone");s&&d&&(mm(),this.openElementLink(this.hitLinkElement,t))});v(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=Jp(r);let i;if(this.props.onLinkOpen&&o&&(i=yY(Q.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=fY(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(Ae.POINTER),Iv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(mm(),!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=Me(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=Me(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&&BM(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(St(s)&&!s.locked)return a;let l=this.scene.getElementIndex(s.id),d=this.scene.getElementIndex(a.id);if(l!==-1&&d!==-1&&l<=d)return a;let c=o?.currentFrameId?i.find(m=>m.id===o.currentFrameId)??null:null;return c||(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&&UK(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?rK(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&&St(o)?o:null)});v(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=Yn(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...go({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())&&!Oo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Me(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),Fo||Oo||lu||bs(this.state))return;let s=xf(wc,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(Ae.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Ae.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&V2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=W2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(w=>{let y=uc(w.snapLines,b),x=w.originSnapOffset?uc(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&&Ot(()=>{this.setState({selectedLinearElement:g})})}if(XY(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&tu(this.state)){let b=oe(r,i),w=this.scene.getNonDeletedElementsMap(),y=Ar(b,this.scene.getNonDeletedElements(),w,t3(this.state.zoom));y?this.setState({suggestedBinding:{element:y,midPoint:Bb(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:S}=b;if(this.cursor.applyForTool(),I===S)so(oe(r-w,i-y),I)>=xb?(this.store.scheduleCapture(),Ot(()=>{mo(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(Ae.POINTER);else if(x.length>2&&S&&so(oe(r-w,i-y),S)<xb){this.cursor.set(Ae.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{DM(x,this.state.zoom.value)&&this.cursor.set(Ae.POINTER);let C=this.scene.getNonDeletedElementsMap();if(Nb(g)){let M=Ar(oe(r,i),this.scene.getNonDeletedElements(),C);No("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,M)}mo(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=Ar(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),t3(this.state.zoom)),w=this.scene.getNonDeletedElementsMap();b&&!e3(g,b,w)&&this.setState({suggestedBinding:{element:b,midPoint:Bb(g,b,w,this.state.zoom)}})}let l=!!t.buttons,d=this.state.activeTool.type==="laser";if(l||!d&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,o)){this.cursor.set(Ae.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&&Kt(m[0]))&&!(zt(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=KM(c,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(YM(g));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=XM(ps(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(YM({transformHandleType:g}));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(d)return;u&&(u.link||Bo(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?Ae.POINTER:Xt(u)?Ae.TEXT:Ae.CROSSHAIR):!t[$.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Ae.MOVE):this.state.viewModeEnabled?this.cursor.set(Ae.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Ae.AUTO):s?this.cursor.set(Ae.AUTO):!t[$.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Kt(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Ae.MOVE):this.cursor.set(Ae.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:uc(g.hoveredElementIds,Wn({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:uc(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()&&(vc=!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),Oo||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=Me(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(JE,null)),Et.get(ro)&&this.updateEditorAtom(ro,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),su){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:De(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"?$t.EVENTUALLY:$t.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=vb(this.editorInterface,{isTouchScreen:!0})),Oo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Gn.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Hn.eraser){this.setState({activeTool:nn(this.state,{type:Hn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),w?.(),rn(this.state)&&this.setState({activeTool:nn(this.state,{...this.state.activeTool.lastActiveTool||{type:Hn.selection},lastActiveTool:null})})},b=ve(window,Q.POINTER_UP,g,{once:!0}),w;requestAnimationFrame(()=>{w=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==Gn.MAIN&&t.button!==Gn.TOUCH&&t.button!==Gn.ERASER||de.pointers.size>1)return;let d=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,d.origin)||this.handleDraggingScrollBar(t,d)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,d))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let g=d.hit.element&&this.isASelectedElement(d.hit.element);(t.altKey&&t[$.CTRL_OR_CMD]&&!d.resize.handleType||!d.hit.hasHitCommonBoundingBoxOfSelectedElements&&!d.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(d.origin.x,d.origin.y,t.shiftKey),d.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&d.hit.element&&!g&&(this.setState(y=>{let x={...y.selectedElementIds,[d.hit.element.id]:!0},I=[];Object.keys(y.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&I.push(P)});let S=d.hit.element;if(St(S))Ab(I,S.id).forEach(C=>{delete x[C.id]});else if(S.frameId)x[S.frameId]&&delete x[S.id];else{let C=S.groupIds,P=new Set(C.flatMap(M=>vi(this.scene.getNonDeletedElements(),M)).filter(M=>St(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=>vi(this.scene.getNonDeletedElements(),D)).forEach(D=>{delete x[D.id]}))})}return{...Wn({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:S.link||Bo(S)?"info":!1}}),d.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,d):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,d):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,d):this.state.activeTool.type==="custom"?this.cursor.applyForTool():this.state.activeTool.type===Hn.frame||this.state.activeTool.type===Hn.magicframe?this.createFrameElementOnPointerDown(d,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(d.lastCoords.x,d.lastCoords.y):this.state.activeTool.type==="autoshape"?this.drawShape.handlePointerDown(d):this.state.activeTool.type===Hn.bucketfill?this.bucketFill.handlePointerDown(r):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,d);this.props?.onPointerDown?.(this.state.activeTool,d),this.onPointerDownEmitter.trigger(this.state.activeTool,d,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(d.lastCoords.x,d.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(d),p=this.onPointerUpFromPointerDownHandler(d),u=this.onKeyDownFromPointerDownHandler(d),E=this.onKeyUpFromPointerDownHandler(d);this.missingPointerEventCleanupEmitter.once(g=>p(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(Q.POINTER_MOVE,m),window.addEventListener(Q.POINTER_UP,p),window.addEventListener(Q.KEYDOWN,u),window.addEventListener(Q.KEYUP,E),d.eventListeners.onMove=m,d.eventListeners.onUp=p,d.eventListeners.onKeyUp=E,d.eventListeners.onKeyDown=u)});v(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(No("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=Me({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"&&(vc=!1,Dr?vc=!0:Dr=window.setTimeout(()=>{Dr=0,vc||this.handleCanvasContextMenu(t)},cY))});v(this,"resetContextMenuTimer",()=>{clearTimeout(Dr),Dr=0,vc=!1});v(this,"maybeCleanupAfterMissingPointerUp",t=>{us?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});v(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(de.pointers.size<=1&&((t.button===Gn.WHEEL||t.button===Gn.MAIN&&Fo||bs(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Oo=!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(Ae.GRABBING);let{clientX:i,clientY:a}=t,s=km(d=>{let c=i-d.clientX,m=a-d.clientY;if(i=d.clientX,a=d.clientY,r&&!o&&(Math.abs(c)>1||Math.abs(m)>1)){o=!0;let p=E=>{document.body.removeEventListener(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-c/this.state.zoom.value,scrollY:this.state.scrollY-m/this.state.zoom.value})}),l=Xe(us=()=>{us=null,Oo=!1,Fo||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=>{de.pointers.has(t.pointerId)&&de.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=de.initialScale;if(de.pointers.size===2&&de.lastCenter&&o&&de.initialDistance){let r=af(de.pointers),i=r.x-de.lastCenter.x,a=r.y-de.lastCenter.y;de.lastCenter=r;let s=sf(Array.from(de.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/de.initialDistance,d=l?Yn(o*l):this.state.zoom.value;this.setState(c=>{let m=go({viewportX:r.x,viewportY:r.y,nextZoom:d},c),p=m.zoom.value;return this.viewport.translate({zoom:m.zoom,scrollX:m.scrollX+2*i/p,scrollY:m.scrollY+2*a/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else de.lastCenter=de.initialDistance=de.initialScale=null});v(this,"clearSelectionIfNotUsingSelection",()=>{eu(this.state.activeTool.type)||this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});v(this,"handleSelectionOnPointerDown",(t,o)=>{if(eu(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&&!Kt(a[0])&&!(zt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=KM(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=XM(ps(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=wb(PK(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&zt(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=kK(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&&uo(g)){let{hitFocusPoint:b,pointerOffset:w,arrowOtherEndpointInitialBinding:y}=zK(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),d=this.getElementAtPosition(o.origin.x,o.origin.y,{allHitElements:s});if((!d||d.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),d&&d.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,d),this.hitLinkElement)return!0;if(this.state.croppingElementId&&o.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),o.hit.element&&this.getElementLinkAtPosition({x:o.origin.x,y:o.origin.y},o.hit.element))return!1;o.hit.allHitElements=l;let c=o.hit.element,m=o.hit.allHitElements.some(p=>this.isASelectedElement(p));if((c===null||!m)&&!t.shiftKey&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||c&&c?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(c),this.state.selectedLinearElement?.isEditing)this.setState(p=>({selectedLinearElement:p.selectedLinearElement?{...p.selectedLinearElement,isEditing:!!c&&c.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:p.selectedLinearElement?De({[p.selectedLinearElement.elementId]:!0},this.state):De({},p)}));else if(c!=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[c.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({...vK(p,c),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[c.id]||(this.state.editingGroupId&&!UM(c,this.state.editingGroupId)&&this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[c.id]:!0},E=[];if(Object.keys(p.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),St(c))Ab(E,c.id).forEach(g=>{delete u[g.id]});else if(c.frameId)u[c.frameId]&&delete u[c.id];else{let g=c.groupIds,b=new Set(g.flatMap(w=>vi(this.scene.getNonDeletedElements(),w)).filter(w=>St(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=>vi(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(c.groupIds.some(g=>p.selectedGroupIds[g])||(u={[c.id]:!0})),{...Wn({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:c.link||Bo(c)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});v(this,"handleTextOnPointerDown",(t,o)=>{if(this.state.editingTextElement)return;let r=o.origin.x,i=o.origin.y;this.setState({hoveredArrowTextAnchor:null});let a=this.arrowText.getBindableEndpointAtPosition(r,i);if(a)this.startTextEditing({sceneX:r,sceneY:i,autoEdit:!1,arrowEndpoint:a});else{let s=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);CM(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:nn(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,d=this.state.currentItemStrokeVariability,c=zY({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:d,streamline:t.pointerType!=="mouse"?tY:eY},locked:!1,frameId:s?s.id:null,points:[oe(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(c),this.setState(m=>{let p={...m.selectedElementIds};return delete p[c.id],{selectedElementIds:De(p,m)}}),this.setState({newElement:c,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=HY({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=ou(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=vM({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,d=100/this.state.zoom.value;return VY({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-d/2,y:s-d/2,width:d,height:d})});v(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Ot(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(mo(a,"selectedLinearElement is expected to be set"),i.type==="line"&&DM(i.points,this.state.zoom.value)){Ot(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(ut);return}if(Kt(i)&&i.points.length>1){this.actionManager.executeAction(ut,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:d}=a,c=Me(t,this.state),{start:m,end:p}=uo(i)&&tu(this.state)?WK(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),c.x,c.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),E=m?.mode!=null&&p.mode!=null&&m.element.id===p.element.id&&!e3(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=d&&so(oe(r.origin.x-s,r.origin.y-l),d)<xb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(ut,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(w=>({selectedElementIds:De({...w.selectedElementIds,[i.id]:!0},w)})),this.cursor.set(Ae.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:d}=this.state,[c,m]=o==="arrow"?[l,d]:[null,null],p=o==="arrow"?UY({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===Mr.round?{type:jp.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===Mr.elbow,fixedSegments:this.state.currentItemArrowType===Mr.elbow?[]:null}):YY({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:jp.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=oe(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=tu(this.state)?Ar(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[oe(0,0),oe(0,0)]}),this.insertNewElement(p),uo(p)&&RK(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:sM(t.nativeEvent)}),Ot(()=>{this.setState(b=>{let w=null,y=b.selectedElementIds;if(zt(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:De({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&uo(p)?{element:g,midPoint:Bb(u,g,E,this.state.zoom)}:null,selectedElementIds:y,selectedLinearElement:w}})}),uo(p)&&No("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=vM({type:"embeddable",...s}):l=WY({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,...Ro},s=o===Hn.magicframe?GY(a):OY(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(uo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);ru(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);ru(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else Tb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&ru(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&ru(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)||PM(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,po(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});v(this,"initializeImage",async(t,o)=>{if(!Mi(o))throw new Error(f("errors.unsupportedFileType"));this.cursor.set("wait");let r=this.gifPlayback.createPlaceholderDecodeState(t,o);if(o.type===lo.svg)try{o=ku(LM(await o.text()),o.name)}catch(c){throw console.warn(c),new Error(f("errors.svgImageInsertError"))}else if(o.type!==lo.gif){let{maxWidthOrHeight:c}=this.props.imageOptions;try{o=await(this.props.compressImageFile??Sx)(o,{maxWidthOrHeight:c})}catch(m){console.error("Error trying to resize image file on insertion",m)}}let i=o.type,a=i===lo.gif,s=await(this.props.generateIdForFile?.(o)||wx(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:c}=this.props.imageOptions;if(o.size>c)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(c/1024/1024)}MB`}))}let d=this.files[s]?.dataURL||await Rc(o);return new Promise(async(c,m)=>{try{let p=this.getLatestInitializedImageElement(t,s);if(this.addMissingFiles([{mimeType:i,id:s,dataURL:d,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),a&&(p=this.gifPlayback.ensureElementPlaybackMetadata(p),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(g=>g.id===p.id?p:g)),this.imagePlaceholderUpdateEmitter.trigger()),!this.imageCache.get(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?JY(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=po(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),c(p)}catch(p){this.gifPlayback.removePlaceholderDecodeState(r),console.error(p),m(new Error(f("errors.imageInsertError")))}})});v(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return po(r,{fileId:o})});v(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Me({clientX:t,clientY:o},this.state),a=await mx({description:"Image",extensions:Object.keys(rY),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:nn(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(ut)})}});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,d=t.y+t.height/2-a/2;return{x:l,y:d,width:s,height:a,crop:null}});v(this,"handleImageCacheUpdate",t=>{for(let o of this.scene.getNonDeletedElements())yi(o)&&o.fileId===t&&wi.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 Pb({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 d=this.imageCache.get(s);!d||!i.has(s)||this.imageCache.set(s,{...d,placeholderImage:await l,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction($t.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(yi(s)){if(a.has(s.fileId))return po(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return po(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!==lo.gif||!o||(this.imageCache.set(t,{...o,gifDecodeStatus:"pending"}),this.handleImageCacheUpdate(t),await Pb({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=tK(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)&&wi.delete(a);i.size&&this.scene.triggerUpdate()}});v(this,"scheduleImageRefresh",jV(()=>{this.addNewImagesToImageCache()},iY));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=qM(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 Br(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),po(u,{isDeleted:!0})}})),d=hc(l),c=qM(l.filter(u=>!u.isDeleted),o,r,a),m=hc(c),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??d.get(u.id)??u);this.updateScene({appState:{selectedElementIds:De(Object.fromEntries(c.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:$t.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(ut)})});v(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Me(t,this.state),i=Jh(t),a=await Xr(t),s=a.getFiles(),l=s.map(c=>c.file).filter(c=>Mi(c));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,Zd(a,l.length,i));if(s.length===1){let{file:c,fileHandle:m}=s[0];if(c&&(c.type===lo.png||c.type===lo.svg))try{let p=await vs(c,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:$t.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,Zd(a,l.length,i));if(s.length>0){let{file:c,fileHandle:m}=s[0];c&&await this.loadFileToCanvas(c,m)}let d=a.findByType(lo.text);if(d){let c=d.value;if(c&&Cb(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||ou(c)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:Jp(c)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});v(this,"loadFileToCanvas",async(t,o)=>{t=await Br(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await vs(t,this.state,r,o)}catch(a){let s=a instanceof dx;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;s3(r.concat(i.elements)),this.store.scheduleMicroAction({action:$t.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:$t.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!==Gn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Me(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),d=l&&s.length===1&&s[0].link?s[0]:void 0,c=i??a??d,m=c||l?"element":"canvas",p=this.excalidrawContainerRef.current,{top:u,left:E}=p.getBoundingClientRect(),g=t.clientX-E,b=t.clientY-u;Fe("contextMenu","openContextMenu",m),this.setState({...c&&!this.state.selectedElementIds[c.id]?{...this.state,...Wn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[c.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:zt(c)?new fe(c,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(m,c)}})})});v(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){$M({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:ms(t.origin.x,a.x),height:ms(t.origin.y,a.y),shouldMaintainAspectRatio:dc(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,d]=Mt(a.x,a.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=yi(s)&&this.imageCache.get(s.fileId)?.image,m=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:p,snapLines:u}=U2(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:d-t.originInGrid.y},this.scene.getNonDeletedElementsMap());l+=p.x,d+=p.y,this.setState({snapLines:u}),uo(s)||$M({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:d,width:ms(t.originInGrid.x,l),height:ms(t.originInGrid.y,d),shouldMaintainAspectRatio:Un(s)?!dc(o):dc(o),shouldResizeFromCenter:aM(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===Hn.frame||this.state.activeTool.type===Hn.magicframe)&&this.setState({elementsToHighlight:Lb(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&&Un(l)){let d=t.originalElements.get(l.id),c=yi(l)&&this.imageCache.get(l.fileId)?.image;if(d&&Un(d)&&c&&!(c 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}=mf([l],[d],this,o,u,r);this.scene.mutateElement(l,hK(l,this.scene.getNonDeletedElementsMap(),r,c.naturalWidth,c.naturalHeight,a+E.x,s+E.y,o.shiftKey?d.width/d.height:void 0)),nu(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(St),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Kt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,d]=Mt(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[$.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(i.forEach(m=>{Ab(this.scene.getNonDeletedElements(),m.id).forEach(u=>{c.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=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}=mf(r,ce(E,this.state),this,o,u,a);l+=g.x,d+=g.y,this.setState({snapLines:b})}if(MK(t.originalElements,a,r,this.scene,sM(o),aM(o),r.some(m=>Un(m))?!dc(o):dc(o),l,d,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{Lb(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{au(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=>Un(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&Un(t)?[...o([t.id])]:[]});v(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>Un(r))&&(!t||this.state.selectedElementIds[t.id])?[cg,dg]:[]});v(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=Jp(t.link),r=zM(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 Io(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?[al,ua,Pa,mr]:[ug,qe,ph,Dv,qe,ua,Lt,sl,ll,Pa,mr];if(this.state.viewModeEnabled)return[...a,a.length>0&&qe,al,pa,r.length>0&&qe,...r];let s=this.editorInterface.formFactor==="desktop"?[qe,lh,ch,dh,mh]:[];return[qe,al,qe,sm,pa,ug,r.length>0&&qe,...r,i.length>0&&qe,...i,qe,w2,v2,I2,qe,Jg,qe,ag,of,fg,Eg,hv,sg,qe,...s,qe,mg,pg,qe,Ia,qe,Cg,a.length>0&&qe,...a,qe,uh,ml,qe,Ls]});v(this,"handleWheel",Xe(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(Ib.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[$.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Oo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=mY*100,s=Math.abs(r),l=r;s>a&&(l=a*i);let d=this.state.zoom.value-l/100;d+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,s/20);let c=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:pY;d=Math.max(d,c),this.viewport.translate(p=>({...go({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Yn(d)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a})=>({scrollX:a-(r||o)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:s})=>({scrollX:a-o/i.value,scrollY:s-r/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}=Me({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:de.pointers})});v(this,"resetShouldCacheIgnoreZoomDebounced",hM(()=>{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:d,offsetTop:c,offsetLeft:m}=this.state;if(r===l&&i===d&&a===m&&s===c){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:d=`${f("labels.untitled")}-${fM()}`,wheelZoomsOnDefault:c=!1}=t,m=null;t.activeTool&&(t.activeTool.type==="image"?console.warn('"image" tool cannot be forced via "props.activeTool"'):this.isToolSupported(t.activeTool.type,t)?m=nn(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===mc.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:d,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:c},this.refreshEditorInterface(),this.stylesPanelMode=mu(this.editorInterface),this.id=JV(),this.actionManager=new Sm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new ZM,this.canvas=document.createElement("canvas"),this.rc=qV.canvas(this.canvas),this.renderer=new Al(this.scene),this.visibleElements=[],this.store=new LK(this),this.history=new kl(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new fo(this.scene),this.history=new kl(this.store),this.actionManager.registerAll(jc),this.actionManager.registerAction(P2(this.history)),this.actionManager.registerAction(k2(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(qp).includes(i)&&Fb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){mo(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=Ar(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),Ot(()=>{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;mo(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||Kt(t))return;let r=()=>{if(this.bindModeHandler=null,mo(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=Ar(oe(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){mo(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;Ot(()=>{mo(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;mo(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&&QM(E,m),w=g&&QM(g,m);i=!!(b&&w&&E.id!==g.id&&NK(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,d=a?"endBinding":s?"startBinding":null,c=d&&t[d]?.mode==="inside"&&t[d]?.elementId===o?.id||l&&t[l]?.mode==="inside"&&o?.id===t[l]?.elementId;l&&d&&t[l]?.mode==="inside"&&o?.id!==t[l]?.elementId&&t[d]?.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"&&Ot(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!c&&(this.bindModeHandler=setTimeout(r,kY)),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!==Gn.MAIN||Fo||!xM(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(Me({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=oe(Me({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(so(t,o)>cM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&de.pointers.size<2&&fc(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),Sb(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let d=Fb.get(s.id);switch(d||(Fb.set(s.id,qp.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),d){case qp.PLAYING:case qp.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=>Bo(a)&&this.embedsValidationStatus.get(a.id)===!0||Sb(a));return Pe(XK,{children:i.map(a=>{let{x:s,y:l}=Qp({sceneX:a.x,sceneY:a.y},this.state),d=MM(a,o,r,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(a.id);if(d&&!c&&this.initializedEmbeds.add(a.id),!(d||c))return null;let p=ou(EY(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=cc(g?t:1,.75,YK);return Pe("div",{className:tM("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:d?`translate(${s-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t})`:"none",display:d?"block":"none",opacity:wK(a,_b(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?gY:1),"--embeddable-radius":`${QY(Math.min(a.width,a.height),a)}px`},children:Ob("div",{className:"excalidraw__embeddable-container__inner",style:{width:d?`${a.width}px`:0,height:d?`${a.height}px`:0,transform:d?`rotate(${a.angle}rad)`:"none",pointerEvents:u?ds.enabled:ds.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:(Bo(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:d}=this.renderer.getRenderableElements({zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElement:this.state.newElement,selectedElements:t,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=s,this.hasRenderableElements=a.size>0;let c=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",p=t[0],u=Et.get(ro)?.type==="panel";return Pe("div",{translate:"no",className:tM("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?ds.disabled:ds.enabled,"--right-sidebar-width":`${tE}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(hs.Provider,{value:this.api,children:Pe(l3.Provider,{value:this,children:Pe(c3.Provider,{value:this.props,children:Pe(Ub.Provider,{value:this.excalidrawContainerValue,children:Pe(Hb.Provider,{value:this.editorInterface,children:Pe(Yb.Provider,{value:this.setAppState,children:Pe(Vb.Provider,{value:this.state,children:Ob(Wb.Provider,{value:this.scene.getNonDeletedElements(),children:[Ob(Kb.Provider,{value:this.actionManager,children:[Pe(Rk,{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:Xn().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(Bk,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Pe(Jk,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Pe(wv,{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(tT,{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(gb,{app:this,canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:c,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:hr(this),renderLinks:this.isLinksEnabled(),imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),d&&Pe(Kk,{appState:this.state,newElement:d,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:c,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Pe(hb,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:s,allElementsMap:c,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(dp,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Pe(eM,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Pe(PS,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{yi(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),wi.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,r3()||i3()){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(),uY&&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),DY()&&!fK()&&this.setState({errorMessage:Pe(XS,{})});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 ZM,this.fonts=new fo(this.scene),this.renderer=new Al(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(),wi.destroy(),gn.destroy(),clearTimeout(Dr),Le.clearCache(),Wn.clearCache(),Dr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(ve(window,Q.MESSAGE,this.onWindowMessage,!1),ve(document,Q.POINTER_UP,this.removePointer,{passive:!1}),ve(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),ve(window,Q.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),ve(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.handleNavigationModeKeyDown,!1),ve(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ve(document,Q.GESTURE_START,this.onGestureStart,!1),ve(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),ve(document,Q.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,Q.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),ve(this.excalidrawContainerRef.current,Q.GESTURE_START,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,Q.GESTURE_CHANGE,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,Q.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(ve(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(ve(document,Q.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(ve(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),ve(document,Q.COPY,this.onCopy,{passive:!1}),ve(document,Q.KEYUP,this.onKeyUp,{passive:!0}),ve(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),ve(document,Q.GESTURE_START,this.onGestureStart,!1),ve(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),ve(document,Q.GESTURE_END,this.onGestureEnd,!1),ve(document,Q.PASTE,this.pasteFromClipboard,{passive:!1}),ve(this.excalidrawContainerRef.current,Q.DRAG_OVER,this.disableEvent,!1),ve(this.excalidrawContainerRef.current,Q.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(ve(document,Q.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),ve(document,Q.CUT,this.onCut,{passive:!1}),ve(window,Q.RESIZE,this.onResize,!1),ve(window,Q.UNLOAD,this.onUnload,!1),ve(window,Q.BLUR,this.onBlur,!1),ve(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(ve(bY(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)===mc.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),(o.zoom.value!==this.state.zoom.value||o.scrollX!==this.state.scrollX||o.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),Object.keys(this.state.selectedElementIds).length&&rn(this.state)&&this.setState({activeTool:nn(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===mc.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(ut)});let s=Object.keys(this.state.selectedElementIds);if(s.length){let d=s.filter(c=>{let m=this.scene.getElement(c);return!m||m.isDeleted});d.length&&this.setState(c=>{let m={...c.selectedElementIds};for(let p of d)delete m[p];return{selectedElementIds:De(m,c)}})}if(this.state.editingTextElement){let d=this.scene.getElement(this.state.editingTextElement.id);(!d||d.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(){bc=!1,yc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Me({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(o.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&t.text){let c=Vm(t.text);if(c.ok){this.setState({openDialog:{name:"charts",data:c.data,rawText:t.text}});return}}let s=o.map(c=>c.file);if(s.length===0&&t.text&&!r){let c=t.text.trim();c.startsWith("<svg")&&c.endsWith("</svg>")&&s.push(ku(c))}if(s.length>0){this.isToolSupported("image")?await this.insertImages(s,i,a):this.setState({errorMessage:f("errors.imageToolNotSupported")});return}if(t.elements){let c=t.programmaticAPI?BK(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:c,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r,preserveFrameChildrenOrder:!0});return}if(!t.text)return;let l=IY(t.text).split(/\n+/).map(c=>c.trim()).filter(Boolean),d=l.map(c=>eK(c)).filter(c=>Cb(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||ou(c)?.type==="video"));if(!r&&d.length>0&&d.length===l.length){let c=[];for(let m of d){let p=c[c.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:Jp(m)});u&&c.push(u)}c.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(c.map(m=>[m.id,!0]))}));return}this.addTextFromPaste(t.text,r)}containsImagePaste(t,o,r){if(o.some(a=>Mi(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):(Ot(()=>{this.setState({viewModeEnabled:!1})}),!0):!0}async addElementsFromMixedContentPaste(t,{isPlainPaste:o,sceneX:r,sceneY:i}){if(!o&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(c=>c.type==="imageUrl").map(c=>c.value),s=await Promise.all(a.map(async c=>{try{return{file:await Tx(c)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=f("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=f("errors.unsupportedFileType")),{errorMessage:p}}})),l=s.filter(c=>!!c.file).map(c=>c.file);await this.insertImages(l,r,i);let d=s.find(c=>!!c.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.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}=Me({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:cY,verticalAlign:oM,locked:!1},s=xb({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=lM(a.fontFamily),[c,,d]=lX(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=pX(w).trim();if(x.length){let I=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=NM(x,s,l),C=T.width>m,P=C?dX(x,s,m):x;T=C?NM(P,s,l):T;let M=r-T.width/2,D=u-T.height/2,_=bM({...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+=BM(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:De(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&JM===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),JM=!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&&Kt(c)?po(c,{originalText:s,isDeleted:l??c.isDeleted,...HY(c,kM(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=eI({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=Qp({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Ke(s=>{a(s,!1),au(t)&&nu(t,this.scene)}),onSubmit:Ke(({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&&Ot(()=>{this.setState(m=>({selectedElementIds:De({...m.selectedElementIds,[d]:!0},m)}))}),c&&LY(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Ot(()=>{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:De({},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 Kt(r)?r:t?Pb(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(Kt(i))return null;if(!MM(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&&Kt(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 Ec({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||!(Kt(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=Lb(l,a);return c&&!au(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!fc(l)?DM({x:t,y:o},c,a):!0}).filter(l=>fc(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(sM/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&JY([r],this.state,this.editorInterface)&&kX(oe(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||aX(oe(t,o),r,this.scene.getNonDeletedElementsMap())?!0:Ec({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 IM(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]=gM(r[s],this.scene.getNonDeletedElementsMap());if(gc(r[s])&&Ec({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 IM(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Kt(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;Ec({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()),(Xt(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Ae.POINTER):this.hitElement(o,r,a)&&(!Xt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Ae.MOVE)):this.hitElement(o,r,a)&&(!Xt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Ae.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(Ae.POINTER)}else this.cursor.set(Ae.AUTO)}updateGestureOnPointerDown(t){de.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),de.pointers.size===2&&(de.lastCenter=rf(de.pointers),de.initialScale=this.state.zoom.value,de.initialDistance=af(Array.from(de.pointers.values())))}initialPointerDownState(t){let o=Me(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=ms(r),c=r.findIndex(Xt)===0;return{origin:o,withCmdOrCtrl:t[$.CTRL_OR_CMD],originInGrid:yb(Mt(o.x,o.y,t[$.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:bf(wc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,xM(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;lu=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=km(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Ke(()=>{ps=null,lu=!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 ps=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(sM/this.state.zoom.value,1),i=qV*2/this.state.zoom.value,[a,s,l,c]=ms(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:VY(t)?jp.ADAPTIVE_RADIUS:jp.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return AY(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){ko({event:t,app:this,selectedElements:o})&&(r||!gn.getReferenceSnapPoints())&&gn.setReferenceSnapPoints(N2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){ko({event:t,app:this,selectedElements:o})&&(r||!gn.getVisibleGaps())&&gn.setVisibleGaps(R2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ke(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Ke(o=>{o.key===$.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return km(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Me(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=yb(CX(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){LX(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;Ot(()=>{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(uo(u)){let g=Ar(oe(r.x,r.y),this.scene.getNonDeletedElements(),c);Bo("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Bo("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||!pM(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:AM(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&&Un(I)&&I.crop!==null&&t.hit.element===I){let T=I.crop,C=yi(I)&&this.imageCache.get(I.fileId)?.image;if(C&&!(C instanceof Promise)){let P=BX(I),M=qk(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]=gM(I,c),z=fb(gb(oe(D,_),oe(F,Y),I.angle)),U=fb(gb(oe(k,_),oe(F,Y),I.angle)),V=fb(gb(oe(D,L),oe(F,Y),I.angle)),G=eM(Jk(U,z)),re=eM(Jk(V,z)),B=qk(Qk(M,G),Qk(M,re)),W={...T,x:cc(T.x-B[0]*Math.sign(I.scale[0]),0,C.naturalWidth-T.width),y:cc(T.y-B[1]*Math.sign(I.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(I,{crop:W});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:y,snapLines:x}=B2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||SX(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}=yM({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:U})=>({frameId:z.frameId??U.frameId,seed:wY()})});M.forEach(z=>{t.originalElements.set(z.id,xM(z))});let L=_.map(z=>{if(P.has(z.id)){let U=t.originalElements.get(z.id);if(U)return po(z,{x:U.x,y:U.y})}return z}),F=this.props.onDuplicate?.(L,I),Y=OM(F||L,hc(M));Ot(()=>{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 V=k.get(U.id),G=V&&D.get(V);return G&&z.push(G),z},[]),t.drag.origin=Me(o,this.state),this.setState(z=>({...zM(M,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(Y),C.forEach(z=>{Tb(z)&&z.boundElements?.some(U=>U.type==="arrow")&&nu(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(zt(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;mo(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&&Le(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Wn({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?rx(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},{...Wn({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&zt(E[0])?new fe(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Fo(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*(wc.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*(wc.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ke(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===Hn.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:uc(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=Me({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(Bo("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);Tb(x)&&x.boundElements?.filter(I=>I.type==="arrow").map(I=>r.get(I.id)).filter(I=>Xt(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(ut);else{let x=fe.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(ut,"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?(NX(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(ut,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&zt(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=Me(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(ut);return}if(zt(i)&&this.state.activeTool.type!=="autoshape"){let x=Me(o,this.state),I=so(oe(x.x,x.y),oe(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||I<vY)&&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(ut)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),zt(i)&&this.actionManager.executeAction(ut,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:nn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:De({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new fe(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Kt(i)){let x=gX(xb({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<x&&this.scene.mutateElement(i,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&SM(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:$t.NEVER});return}if(Tt(i)){let x=nX(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Ab(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,YY(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Me(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=Lb(I,r);T&&I&&(oX(I,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(I,{groupIds:[]}),tX([I],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let I=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:AM(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&&vi(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=>_M(D,C,this.state));this.state.editingGroupId&&P(M),C=Ab(C,M,T)}else if(!T&&this.state.editingGroupId){let M=I.filter(D=>D.frameId&&!_M(D,C,this.state));P(M)}C=LM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&SM(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:$t.NEVER}),t.resize.isResizing){let x=LM(this.scene.getElementsIncludingDeleted(),this.state,this),I=this.scene.getSelectedElements(this.state).filter(Tt);for(let T of I)x=eX(x,Db(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&zt(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(),so(oe(b.clientX,b.clientY),oe(w.clientX,w.clientY))===0){let I=Me({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]?yX(this.state,g)?this.setState(x=>{let I={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>vi(this.scene.getNonDeletedElements(),C)))delete I[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:De(I,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let I={...x.selectedElementIds};delete I[g.id];let T=ce(this.scene.getNonDeletedElements(),{selectedElementIds:I});return{...Wn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&zt(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=>vi(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete I[T.id]}),{...Wn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Fo(g)?"info":!1}}):this.setState(x=>({selectedElementIds:De({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Wn({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:zt(g)&&x.selectedLinearElement?.elementId!==g.id?new fe(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Xt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&sX({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(va):this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Ae.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&&(Kt(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:De({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Fo(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||Le(this.scene.getNonDeletedElements(),this.state)||!pM(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(gc);fM(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(ut);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==Hn.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:nn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:De({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&FM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:De({},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=kb(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<oY){let{x:m,y:p}=Qp({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=Di.find(o=>o.code===this.props.langCode)||Xn;await Fc(t),this.setAppState({})}},HX=()=>{(QM()||e3())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(n3(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};HX();var i3=zb;import{useEffect as WX,useState as VX}from"react";import{jsx as YX}from"react/jsx-runtime";var a3=e=>{let[n,t]=VX(!0);return WX(()=>{let o=async()=>{await Fc(r),t(!1)},r=Di.find(i=>i.code===e.langCode)||Xn;o()},[e.langCode]),n?YX(up,{theme:e.theme}):e.children};import XX from"clsx";import{jsx as s3}from"react/jsx-runtime";var l3=({children:e})=>{let{FooterCenterTunnel:n}=ot(),t=ye();return s3(n.In,{children:s3("div",{className:XX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},KX=l3;l3.displayName="FooterCenter";import $X from"clsx";import{MQ_MIN_WIDTH_DESKTOP as ZX}from"@excalidraw/common";import{jsx as qX,jsxs as JX}from"react/jsx-runtime";var c3=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=ye(),i=t?.formFactor!=="desktop"||r.width<ZX;return JX(vn,{...o,className:$X("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?t1:f("labels.share"),r.collaborators.size>0&&qX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},jX=c3;c3.displayName="LiveCollaborationTrigger";import{jsx as Lr,jsxs as m3}from"react/jsx-runtime";var QX=()=>Lr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Lr("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"})}),eK=()=>m3("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Lr("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)"}),Lr("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)"}),Lr("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)"}),Lr("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)"})]}),d3=({style:e,size:n="small",withText:t})=>m3("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[Lr(QX,{}),t&&Lr(eK,{})]});import{Fragment as h3,jsx as lt,jsxs as Xb}from"react/jsx-runtime";var Kb=({icon:e,shortcut:n,children:t})=>{let o=be();return Xb(h3,{children:[lt("div",{className:"welcome-screen-menu-item__icon",children:e}),lt("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&lt("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};Kb.displayName="WelcomeScreenMenuItemContent";var Ic=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>lt("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:lt(Kb,{icon:t,shortcut:o,children:n})});Ic.displayName="WelcomeScreenMenuItem";var p3=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>lt("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:lt(Kb,{icon:t,shortcut:o,children:e})});p3.displayName="WelcomeScreenMenuItemLink";var Tn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=ot();return lt(n.In,{children:lt("div",{className:"welcome-screen-center",children:e||Xb(h3,{children:[lt($b,{}),lt(Zb,{children:f("welcomeScreen.defaults.center_heading")}),Xb(jb,{children:[lt(Jb,{}),lt(qb,{})]})]})})})};Tn.displayName="Center";var $b=({children:e})=>lt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||lt(d3,{withText:!0})});$b.displayName="Logo";var Zb=({children:e})=>lt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Zb.displayName="Heading";var jb=({children:e})=>lt("div",{className:"welcome-screen-menu",children:e});jb.displayName="Menu";var qb=()=>{let e=rt();return lt(Ic,{onSelect:()=>e.executeAction(qr),shortcut:"?",icon:Bi,children:f("helpDialog.title")})};qb.displayName="MenuItemHelp";var Jb=()=>{let e=ye(),n=rt();return e.viewModeEnabled?null:lt(Ic,{onSelect:()=>n.executeAction(ra),shortcut:je("loadScene"),icon:Uc,children:f("buttons.load")})};Jb.displayName="MenuItemLoadScene";var u3=({onSelect:e})=>{let{t:n}=_e();return lt(Ic,{shortcut:null,onSelect:e,icon:Wc,children:n("labels.liveCollaboration")})};u3.displayName="MenuItemLiveCollaborationTrigger";Tn.Logo=$b;Tn.Heading=Zb;Tn.Menu=jb;Tn.MenuItem=Ic;Tn.MenuItemLink=p3;Tn.MenuItemHelp=qb;Tn.MenuItemLoadScene=Jb;Tn.MenuItemLiveCollaborationTrigger=u3;import{jsx as hs,jsxs as Qb}from"react/jsx-runtime";var uu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=ot();return hs(n.In,{children:Qb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Fx,hs("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};uu.displayName="MenuHint";var hu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=ot();return hs(n.In,{children:Qb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[hs("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),zx]})})};hu.displayName="ToolbarHint";var gu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=ot();return hs(n.In,{children:Qb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[hs("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Ox]})})};gu.displayName="HelpHint";import{Fragment as g3,jsx as Tc,jsxs as nK}from"react/jsx-runtime";var fu=e=>Tc(g3,{children:e.children||nK(g3,{children:[Tc(Tn,{}),Tc(uu,{}),Tc(hu,{}),Tc(gu,{})]})});fu.displayName="WelcomeScreen";fu.Center=Tn;fu.Hints={MenuHint:uu,ToolbarHint:hu,HelpHint:gu};var tK=fu;var oK=()=>{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)})},f3=oK;import{configureGifWorkerUrl as qVe,getSceneVersion as JVe,hashElementsVersion as QVe,hashString as eYe,getNonDeletedElements as tYe}from"@excalidraw/element";import{getTextFromElements as oYe}from"@excalidraw/element";import{isInvisiblySmallElement as iYe}from"@excalidraw/element";import rK from"lodash.throttle";import{arrayToMap as iK,isDevEnv as E3,isTestEnv as b3}from"@excalidraw/common";import{orderByFractionalIndex as aK,syncInvalidIndices as x3,validateFractionalIndices as sK}from"@excalidraw/element";var lK=(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)),cK=rK((e,n,t)=>{if(E3()||b3()||window?.DEBUG_FRACTIONAL_INDICES){let o=x3(e.map(r=>({...r})));sK(o,{shouldThrow:b3()||E3(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),dK=(e,n,t)=>{let o=iK(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=lK(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=aK(r);return cK(a,e,n),x3(a),a};import{isLinearElement as gYe}from"@excalidraw/element";import{FONT_FAMILY as EYe,THEME as bYe,MIME_TYPES as xYe,ROUNDNESS as yYe,DEFAULT_LASER_COLOR as wYe,UserIdleState as vYe,normalizeLink as IYe,sceneCoordsToViewportCoords as TYe,viewportCoordsToSceneCoords as SYe,getFormFactor as CYe,throttleRAF as PYe}from"@excalidraw/common";import{mutateElement as MYe,newElementWith as AYe,bumpVersion as DYe}from"@excalidraw/element";import{CaptureUpdateAction as _Ye}from"@excalidraw/element";import{getCommonBounds as UYe,getVisibleSceneBounds as WYe,convertToExcalidrawElements as VYe}from"@excalidraw/element";import{elementsOverlappingBBox as XYe}from"@excalidraw/element";import{isElementLink as ZYe}from"@excalidraw/element";import{setCustomTextMetricsProvider as JYe}from"@excalidraw/element";import{jsx as Sc}from"react/jsx-runtime";f3();var XVe=({children:e})=>{let[n,t]=fK(null);return Sc(us.Provider,{value:n,children:Sc(pu.Provider,{value:t,children:e})})},bK=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=Xn.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:V=!1,autoFocus:G=!1,compressImageFile:re,generateIdForFile:B,onLinkOpen:W,generateLinkForSelection:ue,onPointerDown:Ee,onPointerUp:le,onScrollChange:he,onUserFollow:ge,userToFollow:se,onDuplicate:xe,imageContextMenuItems:it,children:$e,validateEmbeddable:ke,renderEmbeddable:Zt,showDeprecatedFonts:Ho,wheelZoomsOnDefault:Uo,strokeColorTopPicks:Wo,backgroundColorTopPicks:Ii,renderScrollbars:gs,viewportStatusFrame:ho,currentUserControls:on,imageOptions:Vo,showDropEventDebugAlert:Eu}=e,Ti=e.UIOptions?.canvasActions,go={...e.UIOptions,canvasActions:{...y3.canvasActions,...Ti},tools:{image:e.UIOptions?.tools?.image??!0}};Ti?.export&&(go.canvasActions.export.saveFileToDisk=Ti.export?.saveFileToDisk??y3.canvasActions.export.saveFileToDisk),go.canvasActions.toggleTheme===null&&(P==null||r)&&(go.canvasActions.toggleTheme=!0);let K={maxFileSizeBytes:Vo?.maxFileSizeBytes??Sn.maxFileSizeBytes,maxWidthOrHeight:Vo?.maxWidthOrHeight??Sn.maxWidthOrHeight,gifAutoDecodeMaxFileSizeBytes:Vo?.gifAutoDecodeMaxFileSizeBytes??Sn.gifAutoDecodeMaxFileSizeBytes,placeholderTransitionDuration:Vo?.placeholderTransitionDuration??Sn.placeholderTransitionDuration},Ie=uK(pu),At=gK(l);At.current=l;let fs=pK(bu=>{Ie?.(bu),At.current?.(bu)},[Ie]),Cc=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return hK(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),Cc)return;let ex=xu=>{typeof xu.scale=="number"&&xu.scale!==1&&xu.preventDefault()};return document.addEventListener("touchmove",ex,{passive:!1}),()=>{document.removeEventListener("touchmove",ex)}},[Cc]),Sc(Mx,{store:Et,children:Sc(a3,{langCode:b,theme:P,children:Sc(i3,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:fs,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:go,onPaste:F,viewModeImageInsertBehavior:Y,onViewModeImageInsertRejected:z,detectScroll:U,handleKeyboardGlobally:V,autoFocus:G,compressImageFile:re,generateIdForFile:B,onLinkOpen:W,generateLinkForSelection:ue,onPointerDown:Ee,onPointerUp:le,onScrollChange:he,onUserFollow:ge,userToFollow:se,onDuplicate:xe,imageContextMenuItems:it,validateEmbeddable:ke,renderEmbeddable:Zt,showDeprecatedFonts:Ho,wheelZoomsOnDefault:Uo,strokeColorTopPicks:Wo,backgroundColorTopPicks:Ii,renderScrollbars:gs,viewportStatusFrame:ho,currentUserControls:on,imageOptions:K,showDropEventDebugAlert:Eu,children:$e})})})},xK=(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&&EK(l,g)},yK=mK.memo(bK,xK);yK.displayName="Excalidraw";function KVe(e){return qi(e,!1)}export{vn as Button,_Ye as CaptureUpdateAction,wYe as DEFAULT_LASER_COLOR,wu as DEFAULT_OVERSCROLL,lb as DefaultSidebar,Hs as Ellipsify,yK as Excalidraw,us as ExcalidrawAPIContext,XVe as ExcalidrawAPIProvider,EYe as FONT_FAMILY,Eo as Fonts,KX as Footer,jX as LiveCollaborationTrigger,xYe as MIME_TYPES,Ft as MainMenu,yYe as ROUNDNESS,Pr as Sidebar,tc as Stats,bYe as THEME,Iu as UnsupportedImageFileTypeError,vYe as UserIdleState,tK as WelcomeScreen,DVe as applyDarkModeFilter,DYe as bumpVersion,qh as captureDragEventData,qVe as configureGifWorkerUrl,VYe as convertToExcalidrawElements,Xn as defaultLang,XYe as elementsOverlappingBBox,pP as exportToBlob,Lp as exportToCanvas,$G as exportToClipboard,uP as exportToSvg,UYe as getCommonBounds,Rc as getDataURL,CYe as getFormFactor,tYe as getNonDeletedElements,JVe as getSceneVersion,LVe as getStrokeWidthByKey,oYe as getTextFromElements,WYe as getVisibleSceneBounds,QVe as hashElementsVersion,eYe as hashString,ZYe as isElementLink,iYe as isInvisiblySmallElement,gYe as isLinearElement,Ra as isSpreadsheetValidForChartType,Di as languages,vs as loadFromBlob,MYe as mutateElement,AYe as newElementWith,IYe as normalizeLink,Kr as parseDataTransferEvent,Zd as parseDragImageMetadata,dK as reconcileElements,Lf as renderSpreadsheet,ki as restoreAppState,v3 as restoreElement,Nr as restoreElements,TYe as sceneCoordsToViewportCoords,xs as serializeAsJSON,JYe as setCustomTextMetricsProvider,PYe as throttleRAF,Vm as tryParseSpreadsheet,be as useEditorInterface,Md as useExcalidrawAPI,KVe as useExcalidrawStateValue,_e as useI18n,L6 as useOnExcalidrawStateChange,ct as useStylesPanelMode,SYe as viewportCoordsToSceneCoords,_r as zoomToFitBounds};
23
+ `),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=Me({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:hY,verticalAlign:lM,locked:!1},s=yb({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=uM(a.fontFamily),[d,,c]=uK(this.state),m=Math.max(Math.min((c-d)*.5,800),200),p=10,u=i,E=o?[t]:t.split(`
24
+ `),g=E.reduce((b,w,y)=>{let x=EK(w).trim();if(x.length){let I=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),S=GM(x,s,l),C=S.width>m,P=C?gK(x,s,m):x;S=C?GM(P,s,l):S;let M=r-S.width/2,D=u-S.height/2,_=IM({...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+=HM(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:De(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&o3===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),o3=!0))}handleTextWysiwyg(t,{isExistingElement:o=!1,initialCaretSceneCoords:r=null}){let i=this.scene.getElementsMapIncludingDeleted(),a=(s,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(d=>d.id===t.id&&Xt(d)?po(d,{originalText:s,isDeleted:l??d.isDeleted,...KY(d,_M(d,i),i,s)}):d)])};this.textWysiwygSubmitHandler=iI({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:d,y:c}=Qp({sceneX:s,sceneY:l},this.state);return[d-this.state.offsetLeft,c-this.state.offsetTop]},onChange:Xe(s=>{a(s,!1),au(t)&&nu(t,this.scene)}),onSubmit:Xe(({viaKeyboard:s,nextOriginalText:l})=>{this.textWysiwygSubmitHandler=null;let d=!l.trim();a(l,d);let c=s&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(d?null:t.id):null;c&&Ot(()=>{this.setState(m=>({selectedElementIds:De({...m.selectedElementIds,[c]:!0},m)}))}),d&&FY(this.scene.getNonDeletedElements(),[t]),(!d||o)&&this.store.scheduleCapture(),Ot(()=>{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:De({},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 Xt(r)?r:t?kb(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(Xt(i))return null;if(!RM(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&&Xt(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 Ec({point:oe(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:St(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||!(Xt(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let d=_b(l,a);return d&&!au(d)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),d&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!fc(l)?BM({x:t,y:o},d,a):!0}).filter(l=>fc(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(pM/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&oK([r],this.state,this.editorInterface)&&_K(oe(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||mK(oe(t,o),r,this.scene.getNonDeletedElementsMap())?!0:Ec({point:oe(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:St(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,o){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return kM(i[0],!1)?i[0]:null;let a=null;for(let s=r.length-1;s>=0;--s){if(r[s].isDeleted)continue;let[l,d,c,m]=yM(r[s],this.scene.getNonDeletedElementsMap());if(gc(r[s])&&Ec({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<c&&d<o&&o<m){if(St(r[s]))continue;a=r[s];break}}return kM(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Xt(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;Ec({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()),(Kt(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Ae.POINTER):this.hitElement(o,r,a)&&(!Kt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Ae.MOVE)):this.hitElement(o,r,a)&&(!Kt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Ae.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 d=null,c=a;(c.startBinding||c.endBinding)&&(d=OK(a,o,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==d&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:d}}),d&&this.cursor.set(Ae.POINTER)}else this.cursor.set(Ae.AUTO)}updateGestureOnPointerDown(t){de.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),de.pointers.size===2&&(de.lastCenter=af(de.pointers),de.initialScale=this.state.zoom.value,de.initialDistance=sf(Array.from(de.pointers.values())))}initialPointerDownState(t){let o=Me(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=ps(r),d=r.findIndex(Kt)===0;return{origin:o,withCmdOrCtrl:t[$.CTRL_OR_CMD],originInGrid:wb(Mt(o.x,o.y,t[$.CTRL_OR_CMD]||d?null:this.getEffectiveGridSize())),scrollbars:xf(wc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((c,m)=>(c.set(m.id,SM(m)),c),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;lu=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=km(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Xe(()=>{us=null,lu=!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 us=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(pM/this.state.zoom.value,1),i=nY*2/this.state.zoom.value,[a,s,l,d]=ps(o);return t.x>a-i-r&&t.x<l+i+r&&t.y>s-i-r&&t.y<d+i+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:ZY(t)?jp.ADAPTIVE_RADIUS:jp.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return NY(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){Po({event:t,app:this,selectedElements:o})&&(r||!gn.getReferenceSnapPoints())&&gn.setReferenceSnapPoints(G2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){Po({event:t,app:this,selectedElements:o})&&(r||!gn.getVisibleGaps())&&gn.setVisibleGaps(z2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Xe(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Xe(o=>{o.key===$.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return km(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Me(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=wb(DK(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 d=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){FK(p,d,r,this.scene,this.state,this.getEffectiveGridSize(),o.altKey),this.setState({selectedLinearElement:{...p,isDragging:!1,selectedPointsIndices:[],initialState:{...p.initialState,lastClickedPoint:-1}}});return}if(fe.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,d)){let u=fe.addMidpoint(this.state.selectedLinearElement,r,this,!o[$.CTRL_OR_CMD],this.scene);if(!u)return;Ot(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(p.initialState.segmentMidpoint.value!==null&&!p.initialState.segmentMidpoint.added)return;if(p.initialState.lastClickedPoint>-1){let u=fe.getElement(p.elementId,d);if(u?.isDeleted)return;if(uo(u)){let g=Ar(oe(r.x,r.y),this.scene.getNonDeletedElements(),d);No("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&No("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||!EM(E.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||E.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||E.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==E.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==E.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(E);return}}}}let c=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((c||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!m&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(g=>g.locked))return;let E=p.some(g=>St(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:NM(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),S=Math.abs(g.y),C=w&&I<S,P=w&&I>S;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&Un(I)&&I.crop!==null&&t.hit.element===I){let S=I.crop,C=yi(I)&&this.imageCache.get(I.fileId)?.image;if(C&&!(C instanceof Promise)){let P=HK(I),M=nM(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]=yM(I,d),z=Eb(fb(oe(D,_),oe(F,Y),I.angle)),U=Eb(fb(oe(k,_),oe(F,Y),I.angle)),V=Eb(fb(oe(D,L),oe(F,Y),I.angle)),G=iM(oM(U,z)),re=iM(oM(V,z)),B=nM(rM(M,G),rM(M,re)),W={...S,x:cc(S.x-B[0]*Math.sign(I.scale[0]),0,C.naturalWidth-S.width),y:cc(S.y-B[1]*Math.sign(I.scale[1]),0,C.naturalHeight-S.height)};this.scene.mutateElement(I,{crop:W});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:y,snapLines:x}=H2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||AK(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(),S=t.hit.element,C=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!C.find(z=>z.id===S.id)&&C.push(S);let P=new Map(C.map(z=>[z.id,z])),{duplicatedElements:M,duplicateElementsMap:D,elementsWithDuplicates:_,origIdToDuplicateId:k}=TM({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:U})=>({frameId:z.frameId??U.frameId,seed:CY()})});M.forEach(z=>{t.originalElements.set(z.id,SM(z))});let L=_.map(z=>{if(P.has(z.id)){let U=t.originalElements.get(z.id);if(U)return po(z,{x:U.x,y:U.y})}return z}),F=this.props.onDuplicate?.(L,I),Y=WM(F||L,hc(M));Ot(()=>{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 V=k.get(U.id),G=V&&D.get(V);return G&&z.push(G),z},[]),t.drag.origin=Me(o,this.state),this.setState(z=>({...VM(M,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(Y),C.forEach(z=>{Tb(z)&&z.boundElements?.some(U=>U.type==="arrow")&&nu(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(zt(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;mo(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&&Le(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Wn({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?ax(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},{...Wn({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&zt(E[0])?new fe(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Bo(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*(wc.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*(wc.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Xe(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===Hn.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:s,multiElement:l,activeTool:d,isResizing:c,isRotating:m,isCropping:p}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:uc(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=Me({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(No("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);Tb(x)&&x.boundElements?.filter(I=>I.type==="arrow").map(I=>r.get(I.id)).filter(I=>Kt(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(ut);else{let x=fe.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(ut,"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?(GK(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(ut,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&zt(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?.(d,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=Me(o,this.state),I=i.points,S=x.x-i.x,C=x.y-i.y;S===I[0][0]&&C===I[0][1]&&(C+=1e-4,S+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...I,oe(S,C)],pressures:P}),this.actionManager.executeAction(ut);return}if(zt(i)&&this.state.activeTool.type!=="autoshape"){let x=Me(o,this.state),I=so(oe(x.x,x.y),oe(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||I<PY)&&i&&!l)if(this.editorInterface.isTouchScreen){let S=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-S/2,points:[oe(0,0),oe(S,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(ut)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),zt(i)&&this.actionManager.executeAction(ut,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(S=>({newElement:null,activeTool:nn(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:De({...S.selectedElementIds,[i.id]:!0},S),selectedLinearElement:new fe(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Xt(i)){let x=yK(yb({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<x&&this.scene.mutateElement(i,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(d.type!=="selection"&&i&&AM(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:$t.NEVER});return}if(St(i)){let x=sK(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Db(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,jY(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Me(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let I=this.scene.getElement(this.state.selectedLinearElement.elementId);if(I?.frameId){let S=_b(I,r);S&&I&&(lK(I,S,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(I,{groupIds:[]}),aK([I],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let I=this.scene.getSelectedElements(this.state),S=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:NM(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&&vi(C,D.groupIds[D.groupIds.length-1]).length<2&&this.scene.mutateElement(D,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(S&&!this.state.selectedElementIds[S.id]){let M=I.filter(D=>OM(D,C,this.state));this.state.editingGroupId&&P(M),C=Db(C,M,S)}else if(!S&&this.state.editingGroupId){let M=I.filter(D=>D.frameId&&!OM(D,C,this.state));P(M)}C=FM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&AM(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:$t.NEVER}),t.resize.isResizing){let x=FM(this.scene.getElementsIncludingDeleted(),this.state,this),I=this.scene.getSelectedElements(this.state).filter(St);for(let S of I)x=iK(x,Lb(this.scene.getElementsIncludingDeleted(),S,this.state,r),S);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&zt(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(),so(oe(b.clientX,b.clientY),oe(w.clientX,w.clientY))===0){let I=Me({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]?TK(this.state,g)?this.setState(x=>{let I={...x.selectedElementIds};for(let S of g.groupIds.flatMap(C=>vi(this.scene.getNonDeletedElements(),C)))delete I[S.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(S=>({[S]:!1})).reduce((S,C)=>({...S,...C}),{})},selectedElementIds:De(I,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let I={...x.selectedElementIds};delete I[g.id];let S=ce(this.scene.getNonDeletedElements(),{selectedElementIds:I});return{...Wn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:S.length===1&&zt(S[0])?new fe(S[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(S=>vi(this.scene.getNonDeletedElements(),S)).forEach(S=>{delete I[S.id]}),{...Wn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Bo(g)?"info":!1}}):this.setState(x=>({selectedElementIds:De({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Wn({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:zt(g)&&x.selectedLinearElement?.elementId!==g.id?new fe(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Kt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&pK({point:oe(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:St(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Ia):this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Ae.AUTO);return}let y=this.getSelectedTextEditingContainerAtPosition(g,E);if(d.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[$.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&(Xt(g)&&this.state.selectedElementIds[g.id]&&this.scene.getSelectedElements(this.state).length===1||y)){this.startTextEditing({sceneX:E.x,sceneY:E.y,container:y,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:E});return}if(!this.isToolLocked()&&d.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:De({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Bo(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(d.type!=="selection"||Le(this.scene.getNonDeletedElements(),this.state)||!EM(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||c||m||p){let x=this.scene.getSelectedElements(this.state).filter(gc);wM(x,this.scene,this.state)}if(d.type==="laser"){this.laserTrails.endPath();return}if(d.type==="autoshape"){this.actionManager.executeAction(ut);return}!this.isToolLocked()&&d.type!=="freedraw"&&d.type!==Hn.bucketfill&&(d.type!=="lasso"||d.type==="lasso"&&d.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:nn(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:De({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&UM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:De({},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=Mb(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<lY){let{x:m,y:p}=Qp({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=Di.find(o=>o.code===this.props.langCode)||Kn;await Fc(t),this.setAppState({})}},KK=()=>{(r3()||i3())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(s3(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};KK();var d3=Gb;import{useEffect as $K,useState as ZK}from"react";import{jsx as jK}from"react/jsx-runtime";var m3=e=>{let[n,t]=ZK(!0);return $K(()=>{let o=async()=>{await Fc(r),t(!1)},r=Di.find(i=>i.code===e.langCode)||Kn;o()},[e.langCode]),n?jK(up,{theme:e.theme}):e.children};import qK from"clsx";import{jsx as p3}from"react/jsx-runtime";var u3=({children:e})=>{let{FooterCenterTunnel:n}=ot(),t=ye();return p3(n.In,{children:p3("div",{className:qK("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},JK=u3;u3.displayName="FooterCenter";import QK from"clsx";import{MQ_MIN_WIDTH_DESKTOP as eX}from"@excalidraw/common";import{jsx as nX,jsxs as oX}from"react/jsx-runtime";var h3=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=ye(),i=t?.formFactor!=="desktop"||r.width<eX;return oX(vn,{...o,className:QK("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?o1:f("labels.share"),r.collaborators.size>0&&nX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},tX=h3;h3.displayName="LiveCollaborationTrigger";import{jsx as Lr,jsxs as f3}from"react/jsx-runtime";var rX=()=>Lr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Lr("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"})}),iX=()=>f3("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Lr("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)"}),Lr("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)"}),Lr("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)"}),Lr("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)"})]}),g3=({style:e,size:n="small",withText:t})=>f3("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[Lr(rX,{}),t&&Lr(iX,{})]});import{Fragment as x3,jsx as lt,jsxs as Xb}from"react/jsx-runtime";var $b=({icon:e,shortcut:n,children:t})=>{let o=be();return Xb(x3,{children:[lt("div",{className:"welcome-screen-menu-item__icon",children:e}),lt("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&lt("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};$b.displayName="WelcomeScreenMenuItemContent";var Ic=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>lt("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:lt($b,{icon:t,shortcut:o,children:n})});Ic.displayName="WelcomeScreenMenuItem";var E3=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>lt("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:lt($b,{icon:t,shortcut:o,children:e})});E3.displayName="WelcomeScreenMenuItemLink";var Sn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=ot();return lt(n.In,{children:lt("div",{className:"welcome-screen-center",children:e||Xb(x3,{children:[lt(Zb,{}),lt(jb,{children:f("welcomeScreen.defaults.center_heading")}),Xb(qb,{children:[lt(Qb,{}),lt(Jb,{})]})]})})})};Sn.displayName="Center";var Zb=({children:e})=>lt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||lt(g3,{withText:!0})});Zb.displayName="Logo";var jb=({children:e})=>lt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});jb.displayName="Heading";var qb=({children:e})=>lt("div",{className:"welcome-screen-menu",children:e});qb.displayName="Menu";var Jb=()=>{let e=rt();return lt(Ic,{onSelect:()=>e.executeAction(qr),shortcut:"?",icon:Bi,children:f("helpDialog.title")})};Jb.displayName="MenuItemHelp";var Qb=()=>{let e=ye(),n=rt();return e.viewModeEnabled?null:lt(Ic,{onSelect:()=>n.executeAction(ia),shortcut:je("loadScene"),icon:Uc,children:f("buttons.load")})};Qb.displayName="MenuItemLoadScene";var b3=({onSelect:e})=>{let{t:n}=_e();return lt(Ic,{shortcut:null,onSelect:e,icon:Wc,children:n("labels.liveCollaboration")})};b3.displayName="MenuItemLiveCollaborationTrigger";Sn.Logo=Zb;Sn.Heading=jb;Sn.Menu=qb;Sn.MenuItem=Ic;Sn.MenuItemLink=E3;Sn.MenuItemHelp=Jb;Sn.MenuItemLoadScene=Qb;Sn.MenuItemLiveCollaborationTrigger=b3;import{jsx as gs,jsxs as ex}from"react/jsx-runtime";var uu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=ot();return gs(n.In,{children:ex("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[zx,gs("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};uu.displayName="MenuHint";var hu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=ot();return gs(n.In,{children:ex("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[gs("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),Hx]})})};hu.displayName="ToolbarHint";var gu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=ot();return gs(n.In,{children:ex("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[gs("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Gx]})})};gu.displayName="HelpHint";import{Fragment as y3,jsx as Sc,jsxs as sX}from"react/jsx-runtime";var fu=e=>Sc(y3,{children:e.children||sX(y3,{children:[Sc(Sn,{}),Sc(uu,{}),Sc(hu,{}),Sc(gu,{})]})});fu.displayName="WelcomeScreen";fu.Center=Sn;fu.Hints={MenuHint:uu,ToolbarHint:hu,HelpHint:gu};var aX=fu;var lX=()=>{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)})},w3=lX;import{configureGifWorkerUrl as lYe,getSceneVersion as cYe,hashElementsVersion as dYe,hashString as mYe,getNonDeletedElements as pYe}from"@excalidraw/element";import{getTextFromElements as hYe}from"@excalidraw/element";import{isInvisiblySmallElement as fYe}from"@excalidraw/element";import cX from"lodash.throttle";import{arrayToMap as dX,isDevEnv as v3,isTestEnv as I3}from"@excalidraw/common";import{orderByFractionalIndex as mX,syncInvalidIndices as S3,validateFractionalIndices as pX}from"@excalidraw/element";var uX=(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)),hX=cX((e,n,t)=>{if(v3()||I3()||window?.DEBUG_FRACTIONAL_INDICES){let o=S3(e.map(r=>({...r})));pX(o,{shouldThrow:I3()||v3(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),gX=(e,n,t)=>{let o=dX(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),d=uX(t,l,s);l&&d?(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=mX(r);return hX(a,e,n),S3(a),a};import{isLinearElement as CYe}from"@excalidraw/element";import{FONT_FAMILY as kYe,THEME as MYe,MIME_TYPES as AYe,ROUNDNESS as DYe,DEFAULT_LASER_COLOR as LYe,UserIdleState as _Ye,normalizeLink as RYe,sceneCoordsToViewportCoords as NYe,viewportCoordsToSceneCoords as BYe,getFormFactor as FYe,throttleRAF as OYe}from"@excalidraw/common";import{mutateElement as GYe,newElementWith as HYe,bumpVersion as UYe}from"@excalidraw/element";import{CaptureUpdateAction as VYe}from"@excalidraw/element";import{getCommonBounds as QYe,getVisibleSceneBounds as eKe,convertToExcalidrawElements as tKe}from"@excalidraw/element";import{elementsOverlappingBBox as oKe}from"@excalidraw/element";import{isElementLink as aKe}from"@excalidraw/element";import{setCustomTextMetricsProvider as cKe}from"@excalidraw/element";import{jsx as Tc}from"react/jsx-runtime";w3();var oYe=({children:e})=>{let[n,t]=wX(null);return Tc(hs.Provider,{value:n,children:Tc(pu.Provider,{value:t,children:e})})},IX=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:l,onMount:d,onUnmount:c,onInitialize:m,isCollaborating:p=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=Kn.code,viewModeEnabled:w,viewModeOnly:y,interaction:x,ui:I,activeTool:S,gridModeEnabled:C,theme:P,renderCustomizations:M,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,onPaste:F,viewModeImageInsertBehavior:Y,onViewModeImageInsertRejected:z,detectScroll:U=!0,handleKeyboardGlobally:V=!1,autoFocus:G=!1,compressImageFile:re,generateIdForFile:B,onLinkOpen:W,generateLinkForSelection:ue,onPointerDown:Ee,onPointerUp:le,onScrollChange:he,onUserFollow:ge,userToFollow:se,onDuplicate:xe,imageContextMenuItems:it,children:$e,validateEmbeddable:ke,renderEmbeddable:Zt,showDeprecatedFonts:Go,wheelZoomsOnDefault:Ho,strokeColorTopPicks:Uo,backgroundColorTopPicks:Ii,renderScrollbars:fs,viewportStatusFrame:ho,currentUserControls:on,imageOptions:Wo,showDropEventDebugAlert:Eu,keyboardShortcuts:Cc}=e,Vo=e.UIOptions?.canvasActions,K={...e.UIOptions,canvasActions:{...T3.canvasActions,...Vo},tools:{image:e.UIOptions?.tools?.image??!0}};Vo?.export&&(K.canvasActions.export.saveFileToDisk=Vo.export?.saveFileToDisk??T3.canvasActions.export.saveFileToDisk),K.canvasActions.toggleTheme===null&&(P==null||r)&&(K.canvasActions.toggleTheme=!0);let Te={maxFileSizeBytes:Wo?.maxFileSizeBytes??Tn.maxFileSizeBytes,maxWidthOrHeight:Wo?.maxWidthOrHeight??Tn.maxWidthOrHeight,gifAutoDecodeMaxFileSizeBytes:Wo?.gifAutoDecodeMaxFileSizeBytes??Tn.gifAutoDecodeMaxFileSizeBytes,placeholderTransitionDuration:Wo?.placeholderTransitionDuration??Tn.placeholderTransitionDuration},At=bX(pu),Si=yX(l);Si.current=l;let bu=EX(xu=>{At?.(xu),Si.current?.(xu)},[At]),tx=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return xX(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),tx)return;let nx=yu=>{typeof yu.scale=="number"&&yu.scale!==1&&yu.preventDefault()};return document.addEventListener("touchmove",nx,{passive:!1}),()=>{document.removeEventListener("touchmove",nx)}},[tx]),Tc(Dx,{store:Et,children:Tc(m3,{langCode:b,theme:P,children:Tc(d3,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:bu,onMount:d,onUnmount:c,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:w,viewModeOnly:y,interaction:x,ui:I,activeTool:S,gridModeEnabled:C,theme:P,renderCustomizations:M,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,UIOptions:K,onPaste:F,viewModeImageInsertBehavior:Y,onViewModeImageInsertRejected:z,detectScroll:U,handleKeyboardGlobally:V,autoFocus:G,compressImageFile:re,generateIdForFile:B,onLinkOpen:W,generateLinkForSelection:ue,onPointerDown:Ee,onPointerUp:le,onScrollChange:he,onUserFollow:ge,userToFollow:se,onDuplicate:xe,imageContextMenuItems:it,validateEmbeddable:ke,renderEmbeddable:Zt,showDeprecatedFonts:Go,wheelZoomsOnDefault:Ho,strokeColorTopPicks:Uo,backgroundColorTopPicks:Ii,renderScrollbars:fs,viewportStatusFrame:ho,currentUserControls:on,imageOptions:Te,showDropEventDebugAlert:Eu,keyboardShortcuts:Cc,children:$e})})})},SX=(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:d,UIOptions:c={},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(c);if(x.length!==I.length)return!1;let S=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(D=>D==="export"&&o?.canvasActions?.export&&c?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===c.canvasActions.export.saveFileToDisk:o?.canvasActions?.[D]===c?.canvasActions?.[D]):o[P]===c[P]),C=(r?.maxWidthOrHeight??Tn.maxWidthOrHeight)===(m?.maxWidthOrHeight??Tn.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Tn.maxFileSizeBytes)===(m?.maxFileSizeBytes??Tn.maxFileSizeBytes)&&(r?.gifAutoDecodeMaxFileSizeBytes??Tn.gifAutoDecodeMaxFileSizeBytes)===(m?.gifAutoDecodeMaxFileSizeBytes??Tn.gifAutoDecodeMaxFileSizeBytes)&&(r?.placeholderTransitionDuration??Tn.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Tn.placeholderTransitionDuration);return S&&C&&vX(l,g)},TX=fX.memo(IX,SX);TX.displayName="Excalidraw";function rYe(e){return qi(e,!1)}export{vn as Button,VYe as CaptureUpdateAction,LYe as DEFAULT_LASER_COLOR,vu as DEFAULT_OVERSCROLL,cb as DefaultSidebar,Hs as Ellipsify,TX as Excalidraw,hs as ExcalidrawAPIContext,oYe as ExcalidrawAPIProvider,kYe as FONT_FAMILY,fo as Fonts,JK as Footer,tX as LiveCollaborationTrigger,AYe as MIME_TYPES,Ft as MainMenu,DYe as ROUNDNESS,Pr as Sidebar,tc as Stats,MYe as THEME,Su as UnsupportedImageFileTypeError,_Ye as UserIdleState,aX as WelcomeScreen,UVe as applyDarkModeFilter,UYe as bumpVersion,Jh as captureDragEventData,lYe as configureGifWorkerUrl,tKe as convertToExcalidrawElements,Kn as defaultLang,oKe as elementsOverlappingBBox,EP as exportToBlob,Lp as exportToCanvas,QG as exportToClipboard,bP as exportToSvg,QYe as getCommonBounds,Rc as getDataURL,FYe as getFormFactor,pYe as getNonDeletedElements,cYe as getSceneVersion,WVe as getStrokeWidthByKey,hYe as getTextFromElements,eKe as getVisibleSceneBounds,dYe as hashElementsVersion,mYe as hashString,aKe as isElementLink,fYe as isInvisiblySmallElement,CYe as isLinearElement,Na as isSpreadsheetValidForChartType,Di as languages,vs as loadFromBlob,GYe as mutateElement,HYe as newElementWith,RYe as normalizeLink,Xr as parseDataTransferEvent,Zd as parseDragImageMetadata,gX as reconcileElements,_f as renderSpreadsheet,ki as restoreAppState,P3 as restoreElement,Nr as restoreElements,NYe as sceneCoordsToViewportCoords,xs as serializeAsJSON,cKe as setCustomTextMetricsProvider,OYe as throttleRAF,Vm as tryParseSpreadsheet,be as useEditorInterface,Md as useExcalidrawAPI,rYe as useExcalidrawStateValue,_e as useI18n,F6 as useOnExcalidrawStateChange,ct as useStylesPanelMode,BYe as viewportCoordsToSceneCoords,_r as zoomToFitBounds};