@myoc/excalidraw 0.19.526 → 0.19.528

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 ls,A as mu,B as rs,C as fc,D as pu,E as jb,F as Ec,G as is,H as bc,I as xc,J as as,K as qb,L as Jb,M as Qb,N as wc,O as Tr,P as jM,Q as Sr,R as pi,T as ex,V as tx,W as nx,X as yc,Y as ox,Z as vc,_ as ss,a as lu,aa as rx,b as Nn,ba as Ic,c as ro,ca as ix,d as Ir,da as ax,e as ci,ea as sx,f as Bn,fa as uu,g as Wb,ga as lx,h as Me,ha as cx,i as Vb,ia as dx,j as ie,ja as ui,k as di,l as _o,m as Yb,n as cu,o as Xb,p as ns,q as Kb,r as gc,s as Zb,t as du,u as io,v as Ro,w as qt,x as os,y as mi,z as $b}from"./chunk-HNA67ODG.js";import{a as S}from"./chunk-Q5HWUYDM.js";import{G as su}from"./chunk-DARW3V66.js";import{c as Ub}from"./chunk-5XKZK2GL.js";import{b as Gb,c as $M,d as I}from"./chunk-SRAX5OIU.js";import NX,{useCallback as BX,useContext as OX,useEffect as FX,useRef as zX,useState as HX}from"react";import{applyDarkModeFilter as kWe,DEFAULT_IMAGE_OPTIONS as Lo,DEFAULT_UI_OPTIONS as XM,getStrokeWidthByKey as MWe,isShallowEqual as GX}from"@excalidraw/common";import vk from"clsx";import hV from"lodash.throttle";import En,{useContext as Ao}from"react";import{flushSync as Gt}from"react-dom";import gV from"roughjs/bin/rough";import{nanoid as fV}from"nanoid";import{clamp as Zl,pointFrom as ne,pointDistance as qn,vector as Ik,pointRotateRads as JE,vectorFromPoint as QE,vectorSubtract as Tk,vectorDot as Sk,vectorNormalize as Ck}from"@excalidraw/math";import{CODES as br,shouldResizeFromCenter as Pk,shouldMaintainAspectRatio as $l,shouldRotateWithDiscreteAngle as kk,isArrowKey as eb,KEYS as X,APP_NAME as EV,CURSOR_TYPE as Pe,DEFAULT_STROKE_STREAMLINE as bV,DEFAULT_STROKE_STREAMLINE_PRECISE as xV,DEFAULT_TRANSFORM_HANDLE_SPACING as wV,DEFAULT_VERTICAL_ALIGN as Mk,DRAGGING_THRESHOLD as Ak,ELEMENT_SHIFT_TRANSLATE_AMOUNT as yV,ELEMENT_TRANSLATE_AMOUNT as Lk,EVENT as J,FRAME_STYLE as To,IMAGE_MIME_TYPES as vV,IMAGE_RENDER_TIMEOUT as IV,LINE_CONFIRM_THRESHOLD as tb,MIME_TYPES as Xa,MQ_RIGHT_SIDEBAR_MIN_WIDTH as TV,POINTER_BUTTON as So,ROUNDNESS as Fp,SCROLL_TIMEOUT as SV,TAP_TWICE_TIMEOUT as Dk,TEXT_TO_CENTER_SNAP_THRESHOLD as CV,THEME as jl,TOUCH_CTX_MENU_TIMEOUT as PV,VERTICAL_ALIGN as kV,YOUTUBE_STATES as zp,ZOOM_STEP as MV,MIN_ZOOM as AV,POINTER_EVENTS as Ka,TOOL_TYPE as Dn,supportsResizeObserver as LV,DEFAULT_COLLISION_THRESHOLD as _k,DEFAULT_TEXT_ALIGN as DV,ARROW_TYPE as xr,DEFAULT_REDUCED_GLOBAL_ALPHA as _V,isLocalLink as RV,normalizeLink as nb,toValidURL as NV,getGridPoint as Ct,getLineHeight as Rk,debounce as Nk,distance as Za,getFontString as ob,getNearestScrollableContainer as BV,isInputLike as Bk,isToolIcon as OV,isWritableElement as ql,sceneCoordsToViewportCoords as Hp,tupleToCoors as rb,viewportCoordsToSceneCoords as Ce,wrapEvent as FV,updateObject as ib,updateActiveTool as $t,isTransparent as zV,muteFSAbortError as HV,isTestEnv as SM,isDevEnv as CM,updateStable as Jl,addEventListener as be,normalizeEOL as GV,getDateTime as Ok,isShallowEqual as Fk,arrayToMap as Ql,applyDarkModeFilter as UV,AppEventBus as WV,randomInteger as VV,CLASSES as ab,Emitter as Jn,MINIMUM_ARROW_SIZE as YV,DOUBLE_TAP_POSITION_THRESHOLD as zk,BIND_MODE_TIMEOUT as XV,invariant as Qn,getFeatureFlag as Co,createUserAgentDescriptor as PM,getFormFactor as KV,deriveStylesPanelMode as Jp,isIOS as ZV,isBrave as $V,isSafari as jV,loadDesktopUIModePreference as qV,setDesktopUIMode as JV,isSelectionLikeTool as Gp,oneOf as Hk,getStrokeWidthByKey as QV}from"@excalidraw/common";import{getObservedAppState as eY,getCommonBounds as $a,getElementAbsoluteCoords as Gk,bindOrUnbindBindingElements as Uk,fixBindingsAfterDeletion as tY,getHoveredElementForBinding as wr,isBindingEnabled as Up,updateBoundElements as Wp,LinearElementEditor as me,newElementWith as eo,newFrameElement as nY,newFreeDrawElement as oY,newEmbeddableElement as Wk,newMagicFrameElement as rY,newIframeElement as iY,newArrowElement as aY,newElement as sY,newImageElement as lY,newLinearElement as cY,newTextElement as Vk,refreshTextDimensions as dY,deepCopyElement as Yk,duplicateElements as Xk,hasBoundTextElement as Kk,isArrowElement as ec,isBindingElement as to,isBindingElementType as mY,isBoundToContainer as Zk,isFrameLikeElement as vt,isImageElement as no,isEmbeddableElement as Po,isInitializedImageElement as ja,isLinearElement as Rt,isLinearElementType as pY,isUsingAdaptiveRadius as uY,isIframeElement as sb,isIframeLikeElement as tc,isTextBindableContainer as $k,isElbowArrow as Ut,isBindableElement as lb,isTextElement as Wt,getNormalizedDimensions as hY,isElementCompletelyInViewport as gY,isElementInViewport as jk,isInvisiblySmallElement as qk,generateThumbHash as fY,getCornerRadius as EY,isPathALoop as Jk,embeddableURLValidator as cb,maybeParseEmbedSrc as bY,getEmbedLink as Vp,getInitializedImageElements as xY,normalizeSVG as Qk,updateImageCache as eM,getBoundTextElement as db,getContainerCenter as mb,getContainerElement as tM,isValidTextContainer as nM,redrawTextBoundingBox as wY,hasBoundingBox as yY,getCommonFrameId as oM,getFrameChildren as pb,getFrameChildrenInsertionIndex as vY,isCursorInFrame as rM,addElementsToFrame as ub,replaceAllElementsInFrame as IY,removeElementsFromFrame as TY,getElementsInResizingFrame as hb,getElementsInNewFrame as SY,getContainingFrame as gb,elementOverlapsWithFrame as CY,updateFrameMembershipOfSelectedElements as iM,isElementInFrame as aM,getFrameLikeTitle as PY,filterElementsEligibleAsFrameChildren as kY,hitElementBoundText as MY,hitElementBoundingBoxOnly as AY,hitElementItself as nc,getVisibleSceneBounds as LY,cropElement as DY,wrapText as _Y,isElementLink as RY,isMeasureTextSupported as NY,normalizeText as BY,measureText as sM,getLineHeightInPx as lM,getApproxMinLineWidth as OY,getApproxMinLineHeight as FY,getMinTextElementWidth as zY,ShapeCache as qa,getRenderOpacity as HY,editGroupForSelectedElement as GY,getElementsInGroup as si,getSelectedGroupIdForElement as UY,getSelectedGroupIds as WY,isElementInGroup as cM,isSelectedViaGroup as VY,selectGroupsForSelectedElements as _n,syncInvalidIndices as kM,syncMovedIndices as dM,excludeElementsInFramesFromSelection as YY,getSelectionStateForElements as mM,makeNextSelectedElementIds as ke,getResizeOffsetXY as XY,getResizeArrowDirection as KY,transformElements as ZY,getCursorForResizingElement as pM,getElementWithTransformHandleType as uM,getTransformHandleTypeFromCoords as hM,dragNewElement as gM,dragSelectedElements as $Y,getDragOffsetXY as jY,Scene as fM,Store as qY,CaptureUpdateAction as jt,hitElementBoundingBox as JY,isLineElement as fb,isSimpleArrow as Eb,StoreDelta as EM,positionElementsOnGrid as bM,calculateFixedPointForNonElbowArrowBinding as xM,bindOrUnbindBindingElement as QY,mutateElement as Yp,getElementBounds as wM,doBoundsIntersect as eX,isPointInElement as yM,maxBindingDistance_simple as vM,convertToExcalidrawElements as tX,getSnapOutlineMidPoint as bb,handleFocusPointDrag as nX,handleFocusPointHover as oX,handleFocusPointPointerDown as rX,handleFocusPointPointerUp as iX,maybeHandleArrowPointlikeDrag as Xp,getUncroppedWidthAndHeight as aX,getActiveTextElement as IM,isEligibleFrameChildType as sX,getBindingStrategyForDraggingBindingElementEndpoints as lX,isNonDeletedElement as Kp}from"@excalidraw/element";import{KEYS as Vu,MOBILE_ACTION_BUTTON_BG as d3,updateActiveTool as m3}from"@excalidraw/common";import{getNonDeletedElements as Yc}from"@excalidraw/element";import{fixBindingsAfterDeletion as p3}from"@excalidraw/element";import{LinearElementEditor as n0}from"@excalidraw/element/linearElementEditor";import{newElementWith as Vc}from"@excalidraw/element";import{getContainerElement as o0}from"@excalidraw/element";import{isBoundToContainer as Uc,isElbowArrow as u3,isFrameLikeElement as h3}from"@excalidraw/element";import{getFrameChildren as g3}from"@excalidraw/element";import{getElementsInGroup as Yu,selectGroupsForSelectedElements as f3}from"@excalidraw/element";import{CaptureUpdateAction as Wc}from"@excalidraw/element";import{isDevEnv as e3}from"@excalidraw/common";import{atom as je,createStore as qM}from"jotai";import{createIsolation as JM}from"jotai-scope";var mx=JM();var{useAtom:Fe,useSetAtom:px,useAtomValue:ux,useStore:KX}=mx,hx=mx.Provider,gt=qM();var QM=Gb({"./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 t3=85,On={code:"en",label:"English"},gi=[On,...[{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=>Ub[e.code]>=t3).sort((e,n)=>e.label>n.label?1:-1)],Sc="__test__";e3()&&gi.unshift({code:Sc,label:"test language"},{code:`${Sc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var hi=On,Tc={},Cc=async e=>{if(hi=e,document.documentElement.dir=hi.rtl?"rtl":"ltr",document.documentElement.lang=hi.code,e.code.startsWith(Sc))Tc={};else try{Tc=await QM(`./locales/${hi.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Tc=su}gt.set(fx,e.code)},Fn=()=>hi,gx=(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(hi.code.startsWith(Sc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=gx(Tc,o)||gx(su,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},fx=je(On.code),Ae=()=>{let e=ux(fx);return{t:f,langCode:e}};import n3 from"clsx";import qe from"react";import{THEME as o3}from"@excalidraw/common";import{Fragment as Te,jsx as h,jsxs as R}from"react/jsx-runtime";var xn=e=>"var(--icon-fill-color)",Ex=e=>e===o3.LIGHT?"#fff":"#1e1e1e",M=(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:n3({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},G={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"},Pt={width:40,height:20},lK=M(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"})]}),G),cK=M(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"})]}),G),cs=M(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"})]}),G),bx=M(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"})]}),G),xx=M(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"})]}),G),hu=M(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"})]}),G),ao=M(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),No=M(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),wx=M(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}),yx=M(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"}),vx=M(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"}),Ix=M(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"}),dK=M(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"}),Pc=M(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),fi=M(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}),Ei=M(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"})]}),G),bi=M(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"})]}),G),xi=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),G),kc=M(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"})]}),G),Bo=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ae),Tx=M(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"})]}),G),zn=M(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),wn=M(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"})]}),G),Sx=M(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"})]}),G),Cr=M(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),Mc=M(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"})]}),G),gu=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ae),fu=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ae),Cx=M(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"})]}),G),Pr=M(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),Oo=M(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),ds=M(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),ms=M(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=M(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}),Px=M(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"})]}),G),us=M(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),wi=M(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"})]}),G),kx=M(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"})]}),G),mK=M(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),Mx=M(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),Ax=M(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),Lx=M(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"})]}),G),Ac=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),hs=M(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),Dx=M("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}),_x=M("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}),Lc=M(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),pK=M("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}),uK=M("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"),Eu=["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"],Hn=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Eu.map(e=>h("path",{d:e},e))]}),G),Rx=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),G),Nx=M(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"})]}),G),Bx=M("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}),hK=M("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}),gK=M("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}),Ox=M("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"),fK=M("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),bu=M(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),xu=M(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),Fx=M("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}),zx=M(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),EK=M("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"),bK=M("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}),xK=M(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"})]}),G),wK=M(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}),yK=M(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}),Hx=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"})]}),Gx=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"})]}),wu=M(Gx,G),yu=M(Gx,{...G,style:{transform:"rotate(180deg)"}}),vu=M(Hx,G),Iu=M(Hx,{...G,style:{transform:"rotate(180deg)"}}),Tu=M(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),Su=M(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),Cu=M(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),Pu=M(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),Ux=M(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),Wx=M(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),ku=M(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),Mu=M(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),Dc=M(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"})]}),G),vK=M("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"),IK=M("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"),Jt=M(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),TK=M("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}),SK=M("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}),CK=M("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}),Au=qe.memo(({theme:e})=>M(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:xn(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:xn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:xn(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:xn(e),strokeWidth:"2"}),R("g",{fill:Ex(e),stroke:xn(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})),Lu=qe.memo(({theme:e})=>M(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:xn(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:xn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:xn(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:xn(e),strokeWidth:"2"}),R("g",{fill:Ex(e),stroke:xn(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})),Vx=M(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),Yx=M(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),Xx=M(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),Kx=M(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"}),Du=M(h(Te,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ae),Zx=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ae),$x=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ae),PK=qe.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:xn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),jx=M(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"})]}),G),qx=M(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"})]}),G),Jx=M(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),Qx=M(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),e1=M(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=M(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"})]}),G),Ru=M(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"})]}),G),t1=M(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),n1=M(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"})]}),G),o1=qe.memo(({flip:e=!1})=>M(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"})]}),Pt)),r1=qe.memo(({flip:e=!1})=>M(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"})}),Pt)),i1=qe.memo(({flip:e=!1})=>M(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"})]}),Pt)),a1=qe.memo(({flip:e=!1})=>M(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"})]}),Pt)),s1=qe.memo(({flip:e=!1})=>M(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"})]}),Pt)),l1=qe.memo(({flip:e=!1})=>M(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"})]}),Pt)),c1=qe.memo(({flip:e=!1})=>M(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"})]}),Pt)),d1=qe.memo(({flip:e=!1})=>M(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"})]}),Pt)),m1=qe.memo(({flip:e=!1})=>M(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"})}),Pt)),p1=qe.memo(({flip:e=!1})=>M(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"})}),Pt)),u1=qe.memo(({flip:e=!1})=>M(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"})}),Pt)),h1=qe.memo(({flip:e=!1})=>M(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"})}),Pt)),g1=qe.memo(({flip:e=!1})=>M(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"})}),Pt)),f1=qe.memo(({flip:e=!1})=>M(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"})]}),Pt)),E1=qe.memo(({flip:e=!1})=>M(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"})]}),Pt)),b1=M(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),x1=M(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),w1=M(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),y1=M(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),kr=M(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"})]}),G),v1=M(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"})]})}),G),gs=M(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),r3=M(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"})]}),G),_c=r3,I1=M(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"})]}),G),T1=M(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"})]}),G),S1=M(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"})]}),G),C1=qe.memo(({theme:e})=>M(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"})]}),G)),P1=qe.memo(({theme:e})=>M(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"})]}),G)),k1=qe.memo(({theme:e})=>M(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"})]}),G)),Rc=M(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"})]}),G),kK=M(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}),MK=M(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"})),M1=M(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"})]}),G),Nu=M(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"})]}),G),Nc=M(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"})]}),G),A1=M(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"})]}),G),L1=M(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"})]}),G),AK=M(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),G),LK=M(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"})]}),G),D1=M(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),G),_1=M(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"})]}),G),Bu=["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"],yi=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Bu.map(e=>h("path",{d:e},e))]}),G),Gn=M(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"})]}),G),DK=M(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"})]}),G),_K=M(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"})]}),G),RK=M(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),Mr=M(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"})]}),G),Un=M(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),NK=M(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"})]}),G),BK=M(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"})]}),G),OK=M(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"})]}),G),FK=M(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"})]}),G),Ar=M(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"})]}),G),R1=M(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"})]}),G),zK=M(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"})]}),G),HK=M(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"})]}),G),Wn=M(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"})]}),G),GK=M(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"})]}),G),UK=M(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"})]}),G),N1=M(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"})]}),G),B1=M(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"})]}),G),WK=M(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"})]}),G),O1=M(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"})]}),G),F1=M(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"})]}),G),z1=M(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"})]}),G),H1=M(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"})]}),G),Ou=M(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"})]}),G),Bc=M(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"})]}),G),G1=M(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"})]}),G),U1=M(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"})]}),G),Fo=M(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"})]}),G),VK=M(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"})]}),G),W1=M(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"})]}),{...G,strokeWidth:1.5}),YK=M(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"})]}),G),XK=M(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"})]}),G),V1=M(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"})]}),G),Y1=M(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"})]}),G),zo=M(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"})]}),G),Ho=M(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"})]}),G),Go=M(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),G),Oc=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),G),X1=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),G),K1=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),G),Fu=M(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"})]}),G),Fc=M(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"})]}),G),zu=M(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"})]}),G),Hu=M(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"})]}),G),KK=M(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"})]}),G),Gu=M(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"})})),Z1=M(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"})]}),G),$1=M(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"})]}),G),j1=M(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"})]}),G),ZK=M(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"})]}),G),$K=M(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"})]}),G),jK=M(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"})]}),G),qK=M(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"})]}),G),zc=h("div",{style:{width:"1rem",height:"1rem"}}),q1=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"6 9 12 15 18 9"})]}),G),J1=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"9 6 15 12 9 18"})]}),G),Q1=M(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"})]}),G);import e0 from"clsx";import Wu,{useEffect as s3,useRef as t0,useState as l3}from"react";import{isPromiseLike as c3}from"@excalidraw/common";import i3 from"react";import{jsx as Uu}from"react/jsx-runtime";var a3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(i3.useRef(Date.now()).current%1600);return Uu("div",{className:`Spinner ${o}`,children:Uu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Uu("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},so=a3;import{jsx as fs,jsxs as Hc}from"react/jsx-runtime";var K=Wu.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=Wu.useRef(null);Wu.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=l3(!1),c=t0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if(c3(u))try{l(!0),await u}catch(E){if(E instanceof gc)console.warn(E);else throw E}finally{c.current&&l(!1)}};s3(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=t0(null);return o.type==="button"||o.type==="icon"?Hc("button",{className:e0("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)&&Hc("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&fs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&fs(so,{})]}),o.showAriaLabel&&Hc("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&fs(so,{})]}),o.children]}):fs("button",{className:e0("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:Hc("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&fs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});K.displayName="IconButton";var Gc=[],O=e=>(Gc=Gc.concat(e),e);import{jsx as b3}from"react/jsx-runtime";var E3=(e,n,t)=>{let o=new Set(ie(e.filter(d=>h3(d)),n).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of o){let m=g3(e,d);for(let p of m)if(!a.has(p.id)){if(Uc(p)){let u=o0(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=Uc(d)?o0(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&&u3(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),Vc(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,Uc(d)||(r[d.id]=!0),Vc(d,{frameId:null})):Uc(d)&&n.selectedElementIds[d.containerId]?Vc(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=Yu(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=Yu(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...f3({selectedElementIds:r,editingGroupId:c},Yc(l),n,null)}}},r0=(e,n)=>{if(e.editingGroupId){let t=Yu(Yc(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Es=O({name:"deleteSelectedElements",label:"labels.delete",icon:Pr,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=n0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?Vc(p,{isDeleted:!0}):p),m=r0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:Wc.IMMEDIATELY}}return n0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:Wc.IMMEDIATELY}}let{elements:r,appState:i}=E3(e,n,o);return p3(r,r.filter(a=>a.isDeleted)),i=r0(i,r),{elements:r,appState:{...i,activeTool:m3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Me(Yc(e),n)?Wc.IMMEDIATELY:Wc.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===Vu.BACKSPACE||e.key===Vu.DELETE)&&!e[Vu.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=at()==="mobile";return b3(K,{type:"button",icon:Pr,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Me(Yc(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?d3:{}}})}});import{KEYS as vi,CODES as Ii,isDarwin as Xc}from"@excalidraw/common";import{moveOneLeft as x3,moveOneRight as w3,moveAllLeft as y3,moveAllRight as v3}from"@excalidraw/element";import{CaptureUpdateAction as Kc}from"@excalidraw/element";import{isDarwin as i0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,i0?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,i0?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 Zc}from"react/jsx-runtime";var Xu=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:yu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:x3(e,n,o.scene),appState:n,captureUpdate:Kc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[vi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ii.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Zc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:yu})}),Ku=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:wu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:w3(e,n,o.scene),appState:n,captureUpdate:Kc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[vi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ii.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Zc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:wu})}),Zu=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Iu,trackEvent:{category:"element"},perform:(e,n)=>({elements:y3(e,n),appState:n,captureUpdate:Kc.IMMEDIATELY}),keyTest:e=>Xc?e[vi.CTRL_OR_CMD]&&e.altKey&&e.code===Ii.BRACKET_LEFT:e[vi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ii.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Zc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Xc?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Iu})}),$u=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:vu,trackEvent:{category:"element"},perform:(e,n)=>({elements:v3(e,n),appState:n,captureUpdate:Kc.IMMEDIATELY}),keyTest:e=>Xc?e[vi.CTRL_OR_CMD]&&e.altKey&&e.code===Ii.BRACKET_RIGHT:e[vi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ii.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Zc("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Xc?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:vu})});import{getNonDeletedElements as I3}from"@excalidraw/element";import{LinearElementEditor as T3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as S3,isTextElement as C3}from"@excalidraw/element";import{arrayToMap as P3,KEYS as a0}from"@excalidraw/common";import{selectGroupsForSelectedElements as k3}from"@excalidraw/element";import{CaptureUpdateAction as M3}from"@excalidraw/element";var ju=O({name:"selectAll",label:"labels.selectAll",icon:O1,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(C3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...k3({editingGroupId:null,selectedElementIds:r},I3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&S3(e[0])?new T3(e[0],P3(e)):null},captureUpdate:M3.IMMEDIATELY}},keyTest:e=>e[a0.CTRL_OR_CMD]&&e.key===a0.A});import{DEFAULT_GRID_SIZE as s0,KEYS as l0,MOBILE_ACTION_BUTTON_BG as A3,arrayToMap as c0}from"@excalidraw/common";import{getNonDeletedElements as d0}from"@excalidraw/element";import{LinearElementEditor as L3}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as D3,getSelectionStateForElements as _3}from"@excalidraw/element";import{syncMovedIndices as R3}from"@excalidraw/element";import{duplicateElements as N3}from"@excalidraw/element";import{CaptureUpdateAction as m0}from"@excalidraw/element";import{jsx as B3}from"react/jsx-runtime";var qu=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:ds,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=L3.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:m0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=N3({type:"in-place",elements:e,idsOfElementsToDuplicate:c0(D3(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+s0/2,y:a.y+s0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:R3(i,c0(r)),appState:{...n,..._3(r,d0(i),n)},captureUpdate:m0.IMMEDIATELY}},keyTest:e=>e[l0.CTRL_OR_CMD]&&e.key===l0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=at()==="mobile";return B3(K,{type:"button",icon:ds,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Me(d0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?A3:{}}})}});import{pointFrom as g4}from"@excalidraw/math";import{useEffect as bh,useMemo as yh,useRef as xh,useState as f4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as E4,COLOR_PALETTE as b4,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as bw,DEFAULT_ELEMENT_BACKGROUND_PICKS as x4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as w4,DEFAULT_ELEMENT_STROKE_PICKS as y4,ARROW_TYPE as nn,DEFAULT_FONT_FAMILY as v4,DEFAULT_FONT_SIZE as I4,FONT_FAMILY as T4,ROUNDNESS as gd,STROKE_WIDTH_KEYS as S4,VERTICAL_ALIGN as ud,KEYS as _i,randomInteger as C4,arrayToMap as vh,getFontFamilyString as P4,getLineHeight as k4,isTransparent as M4,getStrokeWidthByKey as xw,reduceToCommonValue as A4,invariant as Ed,FONT_SIZES as hd}from"@excalidraw/common";import{canBecomePolygon as L4,getNonDeletedElements as ww,isNonDeletedElement as D4}from"@excalidraw/element";import{bindBindingElement as uw,calculateFixedPointForElbowArrowBinding as hw,updateBoundElements as _4}from"@excalidraw/element";import{LinearElementEditor as Dr}from"@excalidraw/element/linearElementEditor";import{newElementWith as nt}from"@excalidraw/element";import{getArrowheadForPicker as gw}from"@excalidraw/element";import{getBoundTextElement as jo,redrawTextBoundingBox as As}from"@excalidraw/element";import{isArrowElement as fd,isBoundToContainer as R4,isElbowArrow as yw,isLinearElement as wh,isLineElement as fw,isTextElement as Bt,isUsingAdaptiveRadius as N4}from"@excalidraw/element";import{hasStrokeColor as B4}from"@excalidraw/element";import{updateElbowArrowPoints as O4,CaptureUpdateAction as Je,toggleLinePolygonState as F4}from"@excalidraw/element";import{deriveStylesPanelMode as z4}from"@excalidraw/common";import{isDevEnv as O3}from"@excalidraw/common";var F3=new Set(["command_palette","export"]),Ne=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!F3.has(e)||O3())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 U3 from"clsx";import z3 from"clsx";import{forwardRef as H3}from"react";import{jsx as G3}from"react/jsx-runtime";var p0=H3((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return G3("button",{type:"button",ref:n,title:t,"data-testid":r,className:z3(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as V3,jsx as Ju,jsxs as W3}from"react/jsx-runtime";var Vt=e=>Ju(V3,{children:e.options.map(n=>e.type==="button"?Ju(p0,{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):W3("label",{className:U3({active:e.value===n.value}),title:n.text,children:[Ju("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 Y0}from"radix-ui";import X0 from"clsx";import{memo as m5,useRef as K0,useEffect as p5}from"react";import{applyDarkModeFilter as u5,COLOR_OUTLINE_CONTRAST_THRESHOLD as W0,COLOR_PALETTE as Z0,DEFAULT_ELEMENT_BACKGROUND_PICKS as h5,DEFAULT_ELEMENT_STROKE_PICKS as g5,isColorDark as V0,isWritableElement as f5,THEME as E5}from"@excalidraw/common";import{jsx as Y3}from"react/jsx-runtime";var $c=()=>Y3("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as q3,useLayoutEffect as J3,useRef as Q3}from"react";import{createPortal as eA}from"react-dom";import{EVENT as Uo,isColorDark as tA,KEYS as nA,MIME_TYPES as oA,THEME as rA,removeDarkModeFilter as iA,rgbToHex as aA}from"@excalidraw/common";import u0 from"react";var Qu=u0.createContext(null),fe=()=>u0.useContext(Qu);import{useState as X3,useLayoutEffect as h0}from"react";import{THEME as K3}from"@excalidraw/common";var jc=e=>{let[n,t]=X3(null),o=ge(),{theme:r}=fe(),{container:i}=De();return h0(()=>{n&&(n.className="",n.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),n.classList.toggle("excalidraw--mobile",o.formFactor==="phone"),n.classList.toggle("theme--dark",r===K3.DARK))},[n,r,o.formFactor,e?.className]),h0(()=>{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 Z3}from"react";import{EVENT as qc}from"@excalidraw/common";function Ti(e,n,t){Z3(()=>{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(qc.POINTER_DOWN,o),document.addEventListener(qc.TOUCH_START,o),()=>{document.removeEventListener(qc.POINTER_DOWN,o),document.removeEventListener(qc.TOUCH_START,o)}},[e,n,t])}import{useRef as $3}from"react";var Si=e=>{let n=$3(e);return Object.assign(n.current,e),n.current};import{clamp as j3}from"@excalidraw/math";var g0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return j3(r,0,Math.max(0,t-n))},Jc=({cursor:e,element:n,container:t,gap:o})=>({left:g0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:g0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as lA}from"react/jsx-runtime";var f0=Bu.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),sA=`url(data:${oA.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">${f0}</g><g stroke="#1b1b1f" stroke-width="1.25">${f0}</g></svg>`)}) 2 21, auto`,Nt=je(null),E0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=jc({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=fe(),a=Ci(),s=It(),l=ie(a,i),c=Si({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=De();J3(()=>{if(r)return r.style.cursor=sA,()=>{r.style.cursor=""}},[r]),q3(()=>{let p=m.current;if(!p||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:A})=>{let L=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(A-i.offsetTop)*window.devicePixelRatio,1,1).data;return aA(L[0],L[1],L[2])},b=P=>i.theme===rA.DARK?iA(P):P,y=({clientX:P,clientY:A,altKey:L})=>{let{top:_,left:k}=Jc({cursor:{x:P,y:A},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:7});p.style.top=`${_}px`,p.style.left=`${k}px`;let D=g({clientX:P,clientY:A});u&&c.onChange(o,b(D),c.selectedElements,{altKey:L}),p.style.background=D,p.style.setProperty("--eye-dropper-preview-border-color",tA(D)?"#fff":"#222")},w=()=>{c.onCancel()},x=(P,A)=>{c.onSelect(P,A)},v=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===nA.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),y({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(Uo.KEYDOWN,C),r.addEventListener(Uo.POINTER_DOWN,v),r.addEventListener(Uo.POINTER_UP,T),window.addEventListener("pointermove",y,{passive:!0}),window.addEventListener(Uo.BLUR,w),()=>{u=!1,r.removeEventListener(Uo.KEYDOWN,C),r.removeEventListener(Uo.POINTER_DOWN,v),r.removeEventListener(Uo.POINTER_UP,T),window.removeEventListener("pointermove",y),window.removeEventListener(Uo.BLUR,w)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=Q3(null);return Ti(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?eA(lA("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as eh}from"radix-ui";import pA from"clsx";import uA from"react";import{isInteractive as hA}from"@excalidraw/common";import cA from"react";import dA from"clsx";import{jsx as mA}from"react/jsx-runtime";var ze=cA.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>mA("div",{className:dA("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as th,jsxs as gA}from"react/jsx-runtime";var lo=uA.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=ge(),p=m.formFactor==="phone"&&!m.isLandscape;return th(eh.Portal,{container:n,children:gA(eh.Content,{ref:d,className:pA("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&&!hA(document.activeElement)&&n.focus(),r()},children:[th(ze,{padding:3,style:o,children:t}),th(eh.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 fA,useCallback as nh}from"react";var Qc=()=>document.querySelector(".excalidraw-wysiwyg"),ed=()=>{let e=Qc();return e?{start:e.selectionStart,end:e.selectionEnd}:null},bs=e=>{setTimeout(()=>{let n=Qc();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},xs=(e,n,t,o)=>{n&&o&&o();let r=n&&t?ed():null;e(),n&&t&&bs(r)},b0=()=>{let[e,n]=fA(null),t=nh(()=>{let i=ed();n(i)},[]),o=nh(()=>{setTimeout(()=>{let i=Qc();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=nh(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},x0=(e=100)=>{let n=Qc();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import y0 from"clsx";import{useCallback as xA,useEffect as rh,useRef as v0,useState as I0}from"react";import{KEYS as ih,normalizeInputColor as wA}from"@excalidraw/common";import{isTransparent as EA,MAX_CUSTOM_COLORS_USED_IN_CANVAS as bA}from"@excalidraw/common";var Wo=({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},ws=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),oh=({color:e,palette:n})=>!Object.values(n).flat().includes(e),w0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!EA(s)&&oh({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,bA)},Qt=je(null);import{Fragment as yA,jsx as ys,jsxs as ah}from"react/jsx-runtime";var T0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=ge(),[a,s]=I0(e),[l,c]=I0(null),[d,m]=Fe(Qt);rh(()=>{s(e)},[e]);let p=xA(y=>{let w=y.toLowerCase().trim(),x=wA(w);x?(n(x),c(null)):w.length===0?c(null):/^#?[0-9a-f]+$/.test(w)?c(f("colorPicker.invalidHexLength")):c(f("colorPicker.invalidColor")),s(w)},[n]),u=v0(null),E=v0(null);rh(()=>{u.current&&u.current.focus()},[d]);let[g,b]=Fe(Nt);return rh(()=>()=>{b(null)},[b]),ah("div",{className:"color-picker__input-label-container",children:[ah("div",{className:y0("color-picker__input-label",{"has-error":l}),children:[ys("div",{className:"color-picker__input-hash",children:"#"}),ys("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:y=>{p(y.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e),c(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:y=>{y.key!==ih.TAB&&(y.key===ih.ESCAPE&&E.current?.focus(),y.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&ah(yA,{children:[ys("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),ys("div",{ref:E,className:y0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(y=>y?null:{keepOpenOnAlt:!1,onSelect:w=>n(w),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${ih.I.toLocaleUpperCase()} or ${N("Alt")} `,children:yi})]})]}),l&&ys("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import ch,{useEffect as dh,useImperativeHandle as QA,useState as e5}from"react";import{EVENT as F0}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as t5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as n5,KEYS as o5}from"@excalidraw/common";import AA from"clsx";import{useEffect as LA,useRef as DA}from"react";import{applyDarkModeFilter as _A,THEME as RA}from"@excalidraw/common";import{isColorDark as vA}from"@excalidraw/common";import{jsxs as TA}from"react/jsx-runtime";var IA=({color:e,keyLabel:n,isShade:t=!1})=>TA("div",{className:"color-picker__button__hotkey-label",style:{color:vA(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),Pi=IA;import{createContext as SA,useContext as CA,useEffect as PA,useMemo as S0,useRef as C0,useState as kA}from"react";import{colorToHex as P0,isTransparent as MA}from"@excalidraw/common";var Lr="excalidraw-color-dnd-ghost",k0="excalidraw-color-dnd-active",M0=10,A0=100,L0=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=P0(e);return t!==null&&t===P0(n)},sh=SA(null),en=()=>CA(sh),D0=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=kA(null),i=C0(null),a=C0({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=S0(()=>{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 D=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((Z,H)=>Number(Z.dataset.topPickIndex)-Number(H.dataset.topPickIndex));if(!D.length)return!1;l.slotRects=D.map(Z=>Z.getBoundingClientRect());let[F,Y]=l.slotRects;l.slotSpan=Y?Y.left-F.left:F.width+4;let z=k.getBoundingClientRect(),W=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-W,right:z.right+W,top:z.top-14,bottom:z.bottom+14},!0},m=(k,D)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${D-l.ghostH/2}px)`)},p=(k,D,F,Y)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==D)&&(l.ghostW=k,l.ghostH=D,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${D}px`,m(F,Y))},u=(k,D)=>{if(!l)return;let{sourceRect:F,sourceEl:Y,color:z}=l,W=document.createElement("div");W.className=Lr;let Z=document.createElement("div");if(Z.className=`${Lr}__swatch`,MA(z))Z.classList.add("is-transparent");else{let H=getComputedStyle(Y).backgroundColor;Z.style.backgroundColor=H&&H!=="rgba(0, 0, 0, 0)"?H:z}W.appendChild(Z),document.body.appendChild(W),l.ghost=W,l.ghostW=F.width,l.ghostH=F.height,W.style.width=`${F.width}px`,W.style.height=`${F.height}px`,m(k,D),requestAnimationFrame(()=>{l?.ghost===W&&W.classList.add(`${Lr}--lifted`)}),document.body.classList.add(k0),l.activated=!0,c()},E=(k,D)=>{if(!l?.hitRect)return;let{hitRect:F,slotRects:Y}=l,z=null,W=null;if(k>=F.left&&k<=F.right&&D>=F.top&&D<=F.bottom){let Z=0,H=1/0;if(Y.forEach((re,B)=>{let U=Math.abs(k-(re.left+re.width/2));U<H&&(H=U,Z=B)}),l.origin.kind==="swatch"){let re=a.current.picks.findIndex(B=>L0(B,l.color));re!==-1?W=re:z=Z}else z=Z}if(z!==l.overIndex||W!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=W;let{ghost:Z}=l;Z&&(Z.classList.toggle(`${Lr}--over`,z!==null),Z.classList.toggle(`${Lr}--blocked`,W!==null)),c()}if(z!==null){let Z=l.slotRects[z];p(Z.width,Z.height,k,D)}else p(l.sourceRect.width,l.sourceRect.height,k,D)},g=k=>{if(!l?.ghost)return;let{ghost:D}=l;l.ghost=null,D.classList.add(`${Lr}--dropping`);let F=k.rect;F&&(D.style.width=`${F.width}px`,D.style.height=`${F.height}px`,D.style.transform=`translate(${F.left}px, ${F.top}px)`),window.setTimeout(()=>{D.classList.add(`${Lr}--fade`)},160),window.setTimeout(()=>{D.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let D=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let F of D)F.style.transition="none",F.style.transform="none";k.offsetWidth;for(let F of D)F.style.transition=""},y=()=>{let k=D=>{D.preventDefault(),D.stopPropagation()};window.addEventListener("click",k,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener("click",k,{capture:!0})},100)},w=()=>{window.removeEventListener("pointermove",C,!0),window.removeEventListener("pointerup",P,!0),window.removeEventListener("pointercancel",A,!0),window.removeEventListener("keydown",L,!0)},x=()=>{w(),document.body.classList.remove(k0),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},v=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},T=(k,D)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,D),E(k,D)}},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)<M0){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let D=performance.now()-l.startTime;if(D<A0){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=M0&&T(l.lastX,l.lastY))},A0-D));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(),y();let{overIndex:D,origin:F,color:Y,slotRects:z}=l,{picks:W,onPicksChange:Z}=a.current;if(b(),D!==null){if(F.kind==="swatch"){if(!W.some(H=>L0(H,Y))){let H=[...W];H[D]=Y,Z(H)}}else if(F.index!==D){let H=[...W],[re]=H.splice(F.index,1);H.splice(D,0,re),Z(H)}g({rect:z[D]})}else g({rect:l.sourceRect});x()},A=k=>{l&&k.pointerId===l.pointerId&&v(!0)},L=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),v(!0))};return{begin:(k,D,F)=>{!a.current.enabled||l||k.button!==0||!D||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:D,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",A,!0),window.addEventListener("keydown",L,!0))},destroy:()=>v(!1)}},[]);return PA(()=>()=>s.destroy(),[s]),S0(()=>({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 lh,jsxs as NA}from"react/jsx-runtime";var _0=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=Fe(Qt),s=en(),l=DA(null);return LA(()=>{l.current&&l.current.focus()},[t,i]),lh("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=_A(c,e===RA.DARK);return NA("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:AA("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:[lh("div",{className:"color-picker__button-outline"}),lh(Pi,{color:m,keyLabel:d+1})]},d)})})};import BA from"clsx";import{useEffect as OA,useRef as FA}from"react";import{applyDarkModeFilter as zA,isColorDark as HA,THEME as GA}from"@excalidraw/common";import{jsx as td,jsxs as WA}from"react/jsx-runtime";var UA=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=Wo({color:t,palette:n}),[l,c]=Fe(Qt),d=en(),m=FA(null);return OA(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),td("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 td("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=ws[E],y=zA(g,e===GA.DARK),w=f(`colors.${p.replace(/\d+/,"")}`,null,"");return WA("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:BA("color-picker__button color-picker__button--large",{"has-outline":!HA(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:`${w}${g.startsWith("#")?` ${g}`:""} \u2014 ${b}`,"aria-label":`${w} \u2014 ${b}`,style:g?{"--swatch-color":y}:void 0,"data-testid":`color-${p}`,children:[td("div",{className:"color-picker__button-outline"}),i&&td(Pi,{color:y,keyLabel:b})]},p)})})},R0=UA;import{jsx as YA}from"react/jsx-runtime";var VA=({children:e})=>YA("div",{className:"color-picker__heading",children:e}),ki=VA;import XA from"clsx";import{useEffect as KA,useRef as ZA}from"react";import{applyDarkModeFilter as $A,THEME as jA}from"@excalidraw/common";import{jsx as vs,jsxs as N0}from"react/jsx-runtime";var B0=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=Wo({color:n||"transparent",palette:o}),[a,s]=Fe(Qt),l=en(),c=ZA(null);if(KA(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return vs("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=$A(u,e===jA.DARK);return N0("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:XA("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:[vs("div",{className:"color-picker__button-outline"}),r&&vs(Pi,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return N0("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[vs("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),vs("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 Mi,COLOR_PALETTE as qA,KEYS as Is}from"@excalidraw/common";var nd=(e,n,t)=>{let o=Math.ceil(t/Mi);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+Mi;return r>=t?n%Mi:r}case"ArrowUp":{let r=n-Mi,i=r<0?Mi*o+r:r;return i>=t?void 0:i}}},JA=({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(ws.includes(e.key)){let l=ws.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},O0=({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[Is.CTRL_OR_CMD])return!1;if(e.key===Is.ESCAPE)return d(e),!0;if(e.key===Is.ALT)return c(!0),!0;if(e.key===Is.I)return c(),!0;let p=Wo({color:o,palette:t});if(e.key===Is.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[v,T])=>(T&&x.push(v),x),[]),g=E.indexOf(n),b=e.shiftKey?-1:1,y=g+b>E.length-1?0:g+b<0?E.length-1:g+b,w=E[y];return w&&a(w),w==="custom"?r(i[0]):w==="baseColors"&&(Object.entries(t).find(([v,T])=>Array.isArray(T)?T.includes(o):T===o?v:null)||r(qA.black)),e.preventDefault(),e.stopPropagation(),!0}if(JA({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=nd(e.key,u,Mi);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=nd(e.key,g,E.length),y=0;for(;b!==void 0&&y++<E.length;){let w=t[E[b]],x=Array.isArray(w)?w[l]:w;if(!m?.includes(x))break;b=nd(e.key,b,E.length)}if(b!==void 0){let w=E[b],x=t[w];return r(Array.isArray(x)?x[l]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=nd(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as co,jsxs as od}from"react/jsx-runtime";var z0=ch.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]=ch.useState(()=>o==="canvasBackground"?[]:w0(r,o,i)),[b,y]=Fe(Qt),w=en(),x=Wo({color:n,palette:i});dh(()=>{if(!b){let P=!!n&&oh({color:n,palette:i}),A=P&&!g.includes(n);y(A?null:P?"custom":x?.shade!=null?"shades":"baseColors")}},[b,n,i,y,x,g]);let[v,T]=e5(x?.shade??(o==="elementBackground"?t5:n5));dh(()=>{x?.shade!=null&&T(x.shade);let P=A=>{A.key===o5.ALT&&c(!1)};return document.addEventListener(F0.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(F0.KEYUP,P,{capture:!0})}},[x,c]);let C=ch.useRef(null);return QA(u,()=>C.current),dh(()=>{C?.current?.focus()},[]),co("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:od("div",{ref:C,onKeyDown:P=>{O0({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:y,updateData:a,activeShade:v,onEscape:d,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&co("div",{className:"color-picker__title",children:E}),!!g.length&&od("div",{children:[co(ki,{children:f("colorPicker.mostUsedCustomColors")}),co(_0,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),od("div",{children:[co(ki,{children:f("colorPicker.colors")}),co(R0,{theme:e,color:n,palette:i,onChange:t,activeShade:v,showHotKey:m,excludedColors:p})]}),od("div",{children:[co(ki,{children:f("colorPicker.shades")}),co(B0,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,w&&co("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import H0 from"clsx";import{ContextMenu as Ts}from"radix-ui";import{applyDarkModeFilter as r5,COLOR_OUTLINE_CONTRAST_THRESHOLD as i5,DEFAULT_CANVAS_BACKGROUND_PICKS as a5,DEFAULT_ELEMENT_BACKGROUND_PICKS as s5,DEFAULT_ELEMENT_STROKE_PICKS as l5,isColorDark as c5,THEME as d5}from"@excalidraw/common";import{jsx as Vo,jsxs as G0}from"react/jsx-runtime";var U0=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=en(),l=s?.dragState??null,{container:c}=De(),d;if(t==="elementStroke"&&(d=l5),t==="elementBackground"&&(d=s5),t==="canvasBackground"&&(d=a5),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=G0("div",{className:H0("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&Vo("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:Vo("rect",{})}),d.map((u,E)=>{let g=m(E),b=r5(u,e===d5.DARK);return Vo("button",{className:H0("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!c5(u,i5),"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?y=>s.startPickDrag(y,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:Vo("div",{className:"color-picker__button-outline"})},u)})]});return i?G0(Ts.Root,{children:[Vo(Ts.Trigger,{asChild:!0,children:p}),Vo(Ts.Portal,{container:c,children:Vo(Ts.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:Vo(Ts.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as tn,jsxs as rd}from"react/jsx-runtime";var b5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=Z0,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=De(),m=at(),p=m!=="full",u=m==="mobile",[,E]=Fe(Qt),[g,b]=Fe(Nt),y=rd("div",{children:[tn(ki,{children:f("colorPicker.hexCode")}),tn(T0,{color:n||"",label:o,onChange:v=>{t(v)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),w=K0(null),x=()=>{w.current?.focus()};return tn(lo,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:v=>{if(v.target instanceof HTMLElement&&v.target.closest(".color-picker__context-menu")){v.preventDefault();return}f5(v.target)||(v.target instanceof HTMLElement&&v.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),v.preventDefault()},onPointerDownOutside:v=>{g&&v.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let v=document.querySelector(".excalidraw-wysiwyg");v&&v.focus()},0)},children:i?tn(z0,{ref:w,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:v=>{let T=l.editingTextElement?ed():null;t(v),l.editingTextElement&&T&&bs(T)},onEyeDropperToggle:v=>{b(T=>v?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):v===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:v=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!u,children:y}):y})},x5=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",w5=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=at(),l=s!=="full",c=s==="mobile",d=en(),m=n?u5(n,o===E5.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&x0(),i()};return rd(Y0.Trigger,{type:"button",className:X0("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!V0(n,W0),"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:[tn("div",{className:"color-picker__button-outline",children:!n&&Rx}),l&&n&&r==="stroke"&&tn("div",{className:"color-picker__button-background",children:tn("span",{style:{color:m&&V0(m,W0)?"#fff":"#111"},children:$1})})]})},y5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=Z0,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=K0(l.openPopup);p5(()=>{m.current=l.openPopup},[l.openPopup]);let u=at()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?g5:h5),y=D0({enabled:E,picks:b,onPicksChange:w=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:w}})}});return tn(sh.Provider,{value:E?y:null,children:rd("div",{role:"dialog","aria-modal":"true",className:X0("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&tn(U0,{theme:l.theme,activeColor:n,onChange:w=>{t(w),x5(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&&tn($c,{}),rd(Y0.Root,{open:l.openPopup===e,onOpenChange:w=>{w&&s({openPopup:e})},children:[tn(w5,{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&&tn(b5,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},v5=(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,Ai=m5(y5,v5);import{Popover as j5}from"radix-ui";import q5 from"clsx";import J5,{useCallback as Q5,useMemo as e4}from"react";import{FONT_FAMILY as hh}from"@excalidraw/common";import H5,{useMemo as Zo,useState as G5,useRef as J0,useEffect as Q0,useCallback as ew}from"react";import{arrayToList as U5,debounce as W5,FONT_FAMILY as $o,getFontFamilyString as V5}from"@excalidraw/common";import I5 from"clsx";import T5 from"react";import{jsx as S5,jsxs as C5}from"react/jsx-runtime";var id=T5.forwardRef(({className:e,placeholder:n,onChange:t},o)=>C5("div",{className:I5("QuickSearch__wrapper",e),children:[Wn,S5("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import P5 from"clsx";import{Children as k5}from"react";import{jsx as $0}from"react/jsx-runtime";var ad=({className:e,placeholder:n,children:t})=>{let o=!k5.count(t);return $0("div",{className:P5("ScrollableList__wrapper",e),role:"menu",children:o?$0("div",{className:"empty",children:n}):t})};import{jsx as M5,jsxs as A5}from"react/jsx-runtime";var j0=({children:e,className:n="",style:t,title:o})=>A5("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&M5("p",{className:"dropdown-menu-group-title",children:o}),e]}),Ss=j0;j0.displayName="DropdownMenuGroup";import{THEME as F5}from"@excalidraw/common";import{DropdownMenu as z5}from"radix-ui";import L5,{useContext as D5}from"react";import{composeEventHandlers as _5}from"@excalidraw/common";var mh=L5.createContext({}),Yo=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),sd=e=>{let n=D5(mh);return _5(e,t=>{n.onSelect?.(t)})};import{jsx as R5}from"react/jsx-runtime";var Cs=({children:e,...n})=>R5("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as B5,jsx as Ps,jsxs as O5}from"react/jsx-runtime";var N5=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=ge();return O5(B5,{children:[n&&Ps("div",{className:"dropdown-menu-item__icon",children:n}),Ps("div",{style:e,className:"dropdown-menu-item__text",children:Ps(Cs,{children:o})}),r&&Ps("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Ps("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Xo=N5;import{jsx as ld}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=sd(s);return ld(z5.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:ld("button",{...l,value:t,className:Yo(i,a),title:l.title??l["aria-label"],children:ld(Xo,{icon:e,shortcut:r,badge:n,children:o})})})};ph.displayName="DropdownMenuItem";var Li={GREEN:"green",RED:"red",BLUE:"blue"},cd=({type:e=Li.BLUE,children:n})=>{let{theme:t}=Ko(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===F5.LIGHT?"1.5px solid white":"none"};switch(e){case Li.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Li.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Li.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return ld("div",{className:"DropDownMenuItemBadge",style:o,children:n})};cd.displayName="DropdownMenuItemBadge";ph.Badge=cd;var Yt=ph;import{KEYS as Di}from"@excalidraw/common";var q0=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[Di.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Di.F)return n.current?.focus(),!0;if(e.key===Di.ESCAPE)return r(),!0;if(e.key===Di.ENTER)return t?.value&&i(t.value),!0;if(e.key===Di.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===Di.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as mo,jsxs as K5}from"react/jsx-runtime";var Y5=e=>{switch(e){case $o.Excalifont:case $o.Virgil:return zn;case $o.Nunito:case $o.Helvetica:return gs;case $o["Lilita One"]:return v1;case $o["Comic Shanns"]:case $o.Cascadia:return _c;default:return gs}},X5=(e,n)=>Object.entries($o).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",tw=H5.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=De(),l=It(),{fonts:c}=l,{showDeprecatedFonts:d}=yn(),m=at(),[p,u]=G5(""),E=J0(null),g=Zo(()=>Array.from(io.registered.entries()).filter(([k,{metadata:D}])=>!D.private&&!D.fallback).map(([k,{metadata:D,fontFaces:F}])=>{let Y={value:k,icon:Y5(k),text:X5(k,F)};return D.deprecated&&Object.assign(Y,{deprecated:D.deprecated,badge:{type:Li.RED,placeholder:f("fontList.badge.old")}}),Y}).sort((k,D)=>k.text.toLowerCase()>D.text.toLowerCase()?1:-1),[]),b=Zo(()=>new Set(c.getSceneFamilies()),[e]),y=Zo(()=>g.filter(k=>b.has(k.value)),[g,b]),w=Zo(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=Zo(()=>U5([...y,...w].filter(k=>k.text?.toLowerCase().includes(p))),[y,w,p]),v=Zo(()=>{let k;return n?k=x.find(D=>D.value===n):e&&(k=x.find(D=>D.value===e)),!k&&p&&(x[0]?.value?o(x[0].value):r()),k},[n,e,p,x,o,r]),T=ew(k=>{let D=null;if(l.state.editingTextElement){let F=document.querySelector(".excalidraw-wysiwyg");F&&(D={start:F.selectionStart,end:F.selectionEnd})}t(k),l.state.editingTextElement&&D&&setTimeout(()=>{let F=document.querySelector(".excalidraw-wysiwyg");F&&D&&(F.focus(),F.selectionStart=D.start,F.selectionEnd=D.end)},0)},[t,l.state.editingTextElement]),C=ew(k=>{q0({event:k,inputRef:E,hoveredFont:v,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[v,x,T,o,a]);Q0(()=>(i(),()=>{a()}),[]);let P=Zo(()=>x.filter(k=>b.has(k.value)),[x,b]),A=Zo(()=>x.filter(k=>!b.has(k.value)),[x,b]),L=({font:k,order:D})=>{let F=J0(null),Y=k.value===v?.value,z=k.value===e;return Q0(()=>{Y&&(D===0?F.current?.scrollIntoView?.({block:"end"}):F.current?.scrollIntoView?.({block:"nearest"}))},[Y,D]),mo("button",{ref:F,type:"button",value:k.value,className:Yo("",z,Y),title:k.text,tabIndex:z?0:-1,onClick:W=>{T(Number(W.currentTarget.value))},onMouseMove:()=>{v?.value!==k.value&&o(k.value)},children:mo(Xo,{icon:k.icon,badge:k.badge&&mo(cd,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:V5({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(mo(Ss,{title:f("fontList.sceneFonts"),children:P.map((k,D)=>mo(L,{font:k,order:D},k.value))},"group_1")),A.length&&_.push(mo(Ss,{title:f("fontList.availableFonts"),children:A.map((k,D)=>mo(L,{font:k,order:D+P.length},k.value))},"group_2")),K5(lo,{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"&&mo(id,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:W5(u,20)}),mo(ad,{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 Z5}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as $5}from"@excalidraw/common";import{jsx as uh}from"react/jsx-runtime";var nw=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Ue(),r=t?{...$5,width:"2rem",height:"2rem"}:{};return uh(Z5.Trigger,{asChild:!0,children:uh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:uh(K,{type:"toggle",icon:wn,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 ks,jsxs as ow}from"react/jsx-runtime";var rw=[{value:hh.Excalifont,icon:zn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:hh.Nunito,icon:gs,text:f("labels.normal"),testId:"font-family-normal"},{value:hh["Comic Shanns"],icon:_c,text:f("labels.code"),testId:"font-family-code"}],Tee=new Set(rw.map(e=>e.value));var iw=J5.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=e4(()=>rw,[]),c=Q5(d=>{d&&o(d)},[o]);return ow("div",{role:"dialog","aria-modal":"true",className:q5("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&ks("div",{className:"buttonList",children:ks(Vt,{type:"button",options:l,value:n,onClick:c})}),!s&&ks($c,{}),ow(j5.Root,{open:e,onOpenChange:a,children:[ks(nw,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&ks(tw,{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 gh}from"radix-ui";import r4 from"clsx";import cw,{useEffect as i4,useMemo as a4}from"react";import{isArrowKey as s4,KEYS as po}from"@excalidraw/common";import{jsx as t4}from"react/jsx-runtime";var dd=({className:e,icon:n,size:t="1em"})=>t4("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:n});import{Fragment as o4,jsx as aw,jsxs as sw}from"react/jsx-runtime";var n4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>sw(o4,{children:[sw("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&aw(dd,{icon:n?X1:Oc})]}),n&&aw("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),Ms=n4;import{jsx as Vn,jsxs as pd}from"react/jsx-runtime";var l4=je(!1),md=4,c4="default",d4=e=>e.flatMap(n=>n.options),lw=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},m4=(e,n)=>e.some(t=>t.options.some(n)),p4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/md)},(t,o)=>n.options.slice(o*md,o*md+md)));function u4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=De(),[s,l]=Fe(l4),c=[...e,...n],d=d4(c),m=p4([...e,...s?n:[]]),p=g=>{let b=d.find(y=>y.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===po.TAB){let y=d.findIndex(x=>x.value===t),w=g.shiftKey?(d.length+y-1)%d.length:(y+1)%d.length;r(d[w].value)}else if(s4(g.key)){let y=Fn().rtl,w=d.findIndex(x=>x.value===t);if(w!==-1){let x=d.length,v=w;switch(g.key){case(y?po.ARROW_LEFT:po.ARROW_RIGHT):v=(w+1)%x;break;case(y?po.ARROW_RIGHT:po.ARROW_LEFT):v=(x+w-1)%x;break;case po.ARROW_DOWN:{let T=m.findIndex(P=>P.some(A=>A.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),A=m[(T+1)%m.length],L=A[Math.min(P,A.length-1)]??d[w];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case po.ARROW_UP:{let T=m.findIndex(P=>P.some(A=>A.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),A=m[(m.length+T-1)%m.length],L=A[Math.min(P,A.length-1)]??d[w];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[v].value)}g.preventDefault()}else(g.key===po.ESCAPE||g.key===po.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};i4(()=>{m4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>Vn("div",{className:"picker-content",children:g.map(b=>pd("button",{type:"button",className:r4("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:y=>{t===b.value&&setTimeout(()=>{y?.focus()},0)},children:[b.icon,b.keyBinding&&Vn("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,y)=>b.name===c4?Vn(cw.Fragment,{children:u(b.options)},`${b.name}-${y}`):pd("div",{className:"picker-section",children:[Vn("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${y}`));return Vn(gh.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:pd("div",{className:"picker-sections",children:[E(e),n.length>0&&Vn(Ms,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:Vn("div",{className:"picker-sections",children:E(n)})})]})})}function fh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=cw.useState(!1),s=a4(()=>lw(t,l=>l.value===e)??lw(o??[],l=>l.value===e),[t,o,e]);return Vn("div",{children:pd(gh.Root,{open:i,onOpenChange:l=>a(l),children:[Vn(gh.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&Vn(u4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import dw,{useEffect as h4}from"react";import{jsx as Eh,jsxs as mw}from"react/jsx-runtime";var pw=({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=dw.useRef(null),d=dw.useRef(null);return h4(()=>{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]),mw("label",{className:"control-label",children:[e,mw("div",{className:"range-wrapper",children:[Eh("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}),Eh("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),Eh("div",{className:"zero-label",children:a})]})]})};import{Fragment as xd,jsx as Q,jsxs as ft}from"react/jsx-runtime";var vw=.1,_r=e=>{let n=z4(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Tt=(e,n,t,o=!1)=>{let r=vh(ie(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(D4(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},lt=function(e,n,t,o,r){let i=n.state.editingTextElement,a=ww(e),s=null;if(i&&(s=t(i)),!s)if(Me(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=A4(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},H4=(e,n,t)=>R4(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}),Ih=(e,n,t,o,r)=>{let i=new Set,a=Tt(e,n,s=>{if(Bt(s)){let l=o(s);i.add(l);let c=nt(s,{fontSize:l});return As(c,t.scene.getContainerElement(s),t.scene),c=H4(s,c,t.scene),c}return s},!0);return ie(e,n,{includeBoundTextElement:!0}).forEach(s=>{Bt(s)&&_4(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:Je.IMMEDIATELY}},G4=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Tt(e,n,o=>B4(o.type)?nt(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?Je.IMMEDIATELY:Je.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=_r(o);return ft(xd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.stroke")}),Q(Ai,{topPicks:y4,palette:w4,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:lt(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),U4=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:Je.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!M4(t.currentItemBackgroundColor)&&i.every(s=>fw(s)&&L4(s.points))){let s=vh(i);r=e.map(l=>s.has(l.id)&&fw(l)?nt(l,{backgroundColor:t.currentItemBackgroundColor,...F4(l,!0)}):l)}else r=Tt(e,n,s=>nt(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:Je.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=_r(o);return ft(xd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ai,{topPicks:x4,palette:bw,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:lt(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),bd=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:Je.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=_r(o);return ft(xd,{children:[r==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ai,{topPicks:E4,palette:bw,excludedColors:[b4.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})]})}}),W4=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Ne("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Tt(e,n,r=>nt(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=ie(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return ft("fieldset",{children:[Q("legend",{children:f("labels.fill")}),Q("div",{className:"buttonList",children:Q(Vt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?Vx:Yx,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:Xx,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:Kx,testId:"fill-solid"}],value:lt(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)}})})]})}}),V4=e=>S4.find(n=>xw(e.type,n)===e.strokeWidth)??null,Y4=(e,n)=>xw(e.type,n),X4=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(Ed(t,"actionChangeStrokeWidth: value must be defined"),{elements:Tt(e,n,o=>nt(o,{strokeWidth:Y4(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:Du,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:Zx,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:$x,testId:"strokeWidth-bold"}],value:lt(e,o,V4,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),K4=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>nt(o,{seed:C4(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:Jx},{value:1,text:f("labels.artist"),icon:Qx},{value:2,text:f("labels.cartoonist"),icon:e1}],value:lt(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),Z4=O({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Tt(e,n,r=>r.type!=="freedraw"?r:nt(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:Je.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=lt(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 Q(K,{type:"button",icon:a?Ru:_u,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return ft("fieldset",{children:[Q("legend",{children:f("labels.pressure")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:_u},{value:"variable",text:f("labels.pressure_variable"),icon:Ru}],value:i,onChange:a=>t(a)})})]})}}),Ate=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>nt(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Du},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:jx},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:qx}],value:lt(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),$4=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>nt(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=lt(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return Q(pw,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),j4=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>Ih(e,n,o,()=>(Ed(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=_r(o);return ft("fieldset",{children:[Q("legend",{children:f("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"font-size",options:[{value:hd.sm,text:f("labels.small"),icon:b1,testId:"fontSize-small"},{value:hd.md,text:f("labels.medium"),icon:x1,testId:"fontSize-medium"},{value:hd.lg,text:f("labels.large"),icon:w1,testId:"fontSize-large"},{value:hd.xl,text:f("labels.veryLarge"),icon:y1,testId:"fontSize-veryLarge"}],value:lt(e,o,a=>{if(Bt(a))return a.fontSize;let s=jo(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Bt(a)||jo(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||I4),onChange:a=>{xs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),Th=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:kr,trackEvent:!1,perform:(e,n,t,o)=>Ih(e,n,o,r=>Math.round(1/(1+vw)*r.fontSize)),keyTest:e=>e[_i.CTRL_OR_CMD]&&e.shiftKey&&(e.key===_i.CHEVRON_LEFT||e.key===_i.COMMA)}),Sh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:kr,trackEvent:!1,perform:(e,n,t,o)=>Ih(e,n,o,r=>Math.round(r.fontSize*(1+vw))),keyTest:e=>e[_i.CTRL_OR_CMD]&&e.shiftKey&&(e.key===_i.CHEVRON_RIGHT||e.key===_i.PERIOD)}),q4=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:Tt(e,n,g=>{let b=r?.get(g.id);return b?nt(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:Je.NEVER};Ed(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=Je.EVENTUALLY,m,p=!1;if(l)m=l,d=Je.IMMEDIATELY;else if(c){m=c,d=Je.EVENTUALLY;let E=ie(e,n,{includeBoundTextElement:!0}).filter(g=>Bt(g));if(E.length>200)p=!0;else{let g=0,b=0;for(;g<E.length&&b<5e3;){let y=E[g];b+=y?.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,y=Array.from(io.loadedFontsCache.values()),w=Object.entries(T4).find(([T,C])=>C===m)?.[0];c&&w&&y.some(T=>T.startsWith(w))&&(b=!0),Object.assign(u,{elements:Tt(e,n,T=>{if(Bt(T)&&(T.fontFamily!==m||l)){let C=nt(T,{fontFamily:m,lineHeight:k4(m)}),P=r?.get(T.containerId||"")||{},A=o.scene.getContainerElement(T);return a&&A&&P&&o.scene.mutateElement(A,{...P}),b||(g=new Set([...g,...Array.from(C.originalText)])),E.set(C,A),C}return T},!0)});let x=`10px ${P4({fontFamily:m})}`,v=Array.from(g.values()).join();if(b||window.document.fonts.check(x,v))for(let[T,C]of E)As(T,C,o.scene);else window.document.fonts.load(x,v).then(T=>{for(let[C,P]of E){let A=o.scene.getElement(C.id),L=P?o.scene.getElement(P.id):null;A&&As(A,L,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=xh(new Map),i=xh(null),[a,s]=f4({}),l=xh(!0),{stylesPanelMode:c,isCompact:d}=_r(t),m=yh(()=>{let p=(u,E)=>lt(u,t,g=>{if(Bt(g))return g.fontFamily;let b=jo(g,E);return b?b.fontFamily:null},g=>Bt(g)||jo(g,E)!==null,g=>g?null:n.currentItemFontFamily||v4);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 bh(()=>{i.current=m},[m]),bh(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),bh(()=>(l.current=!1,()=>{l.current=!0}),[]),ft(xd,{children:[c==="full"&&Q("legend",{children:f("labels.fontFamily")}),Q(iw,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{xs(()=>{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,nt(E||u,{},!0))}else{let E=ie(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,nt(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&&bs(null)}}})]})}}),J4=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Tt(e,n,r=>{if(Bt(r)){let i=nt(r,{textAlign:t});return As(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=_r(o);return ft("fieldset",{children:[Q("legend",{children:f("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:I1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:T1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:S1,testId:"align-right"}],value:lt(e,o,s=>{if(Bt(s))return s.textAlign;let l=jo(s,i);return l?l.textAlign:null},s=>Bt(s)||jo(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{xs(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),Q4=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Tt(e,n,r=>{if(Bt(r)){let i=nt(r,{verticalAlign:t});return As(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=_r(o);return Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Vt,{group:"text-align",options:[{value:ud.TOP,text:f("labels.alignTop"),icon:Q(C1,{theme:n.theme}),testId:"align-top"},{value:ud.MIDDLE,text:f("labels.centerVertically"),icon:Q(k1,{theme:n.theme}),testId:"align-middle"},{value:ud.BOTTOM,text:f("labels.alignBottom"),icon:Q(P1,{theme:n.theme}),testId:"align-bottom"}],value:lt(e,o,a=>{if(Bt(a)&&a.containerId)return a.verticalAlign;let s=jo(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Bt(a)||jo(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:ud.MIDDLE),onChange:a=>{xs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),Lte=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>yw(o)?o:nt(o,{roundness:t==="round"?{type:N4(o.type)?gd.ADAPTIVE_RADIUS:gd.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=di(ww(e),n).some(s=>s.roundness?.type===gd.LEGACY);return ft("fieldset",{children:[Q("legend",{children:f("labels.edges")}),ft("div",{className:"buttonList",children:[Q(Vt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:t1},{value:"round",text:f("labels.round"),icon:n1}],value:lt(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!fd(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),Ew=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Q(o1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(r1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:Q(i1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:Q(a1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:Q(s1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(l1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:Q(c1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:Q(d1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:Q(m1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:Q(p1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:Q(u1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:Q(h1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:Q(g1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:Q(f1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:Q(E1,{flip:e}),keyBinding:null}]}]}),Dte=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(Ed(t,"actionChangeArrowhead: value must be defined"),{elements:Tt(e,n,o=>{if(wh(o)){let{position:r,type:i}=t;if(r==="start")return nt(o,{startArrowhead:i});if(r==="end")return nt(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Je.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=Fn().rtl,i=yh(()=>Ew(!r),[r]),a=yh(()=>Ew(!!r),[r]);return ft("fieldset",{children:[Q("legend",{children:f("labels.arrowheads")}),ft("div",{className:"iconSelectList buttonList",children:[Q(fh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:lt(e,o,s=>wh(s)&&ns(s.type)?gw(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),Q(fh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:lt(e,o,s=>wh(s)&&ns(s.type)?gw(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),e6=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})=>ft("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),_te=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Tt(e,n,s=>{if(!fd(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=Dr.getPointAtIndexGlobalCoordinates(s,0,l),d=Dr.getPointAtIndexGlobalCoordinates(s,-1,l),m=nt(s,{x:t===nn.elbow?c[0]:s.x,y:t===nn.elbow?c[1]:s.y,roundness:t===nn.round?{type:gd.PROPORTIONAL_RADIUS}:null,elbowed:t===nn.elbow,angle:t===nn.elbow?0:s.angle,points:t===nn.elbow||s.elbowed?[Dr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Dr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(yw(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=Dr.getPointAtIndexGlobalCoordinates(m,0,p),E=Dr.getPointAtIndexGlobalCoordinates(m,-1,p),g=m.startBinding&&p.get(m.startBinding.elementId),b=m.endBinding&&p.get(m.endBinding.elementId),y=g&&m.startBinding?{...m.startBinding,...hw(m,g,"start",p,n.isBindingEnabled)}:null,w=b&&m.endBinding?{...m.endBinding,...hw(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:y,endBinding:w,...O4(m,p,{points:[u,E].map(x=>g4(x[0]-m.x,x[1]-m.y)),startBinding:y,endBinding:w,fixedSegments:null})}}else{let p=o.scene.getNonDeletedElementsMap();if(m.startBinding){let u=p.get(m.startBinding.elementId);u&&uw(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&uw(m,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return m}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new Dr(s,vh(e)))}return{elements:r,appState:i,captureUpdate:Je.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ft("fieldset",{children:[Q("legend",{children:f("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"arrowtypes",options:[{value:nn.sharp,text:f("labels.arrowtype_sharp"),icon:zo,testId:"sharp-arrow"},{value:nn.round,text:f("labels.arrowtype_round"),icon:Go,testId:"round-arrow"},{value:nn.elbow,text:f("labels.arrowtype_elbowed"),icon:Ho,testId:"elbow-arrow"}],value:lt(e,o,r=>fd(r)?r.elbowed?nn.elbow:r.roundness?nn.round:nn.sharp:null,r=>fd(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as s6,MAX_ZOOM as l6,MIN_ZOOM as c6,THEME as Ls,ZOOM_STEP as Sw,CODES as Rr,KEYS as yd}from"@excalidraw/common";import{getNonDeletedElements as Ds}from"@excalidraw/element";import{getCommonBounds as _s}from"@excalidraw/element";import{CaptureUpdateAction as Bi}from"@excalidraw/element";import{useEffect as t6}from"react";import{jsx as o6}from"react/jsx-runtime";var Ri=()=>{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},Ch=(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`})},n6=(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();Ch(n,r)},ct=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(t6(()=>()=>Ri().classList.remove("excalidraw-tooltip--visible"),[]),r?null:o6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>n6(i.currentTarget,Ri(),n,t),onPointerLeave:()=>Ri().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as Iw,useRef as Tw,useState as r6}from"react";var i6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Ph=(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},Ro())}return i6(o,n)};function Ni(e,n=!0){let t=wd(),[,o]=r6(0),r=Tw(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Ph(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Ph(t,e,n)),Iw(()=>{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 a6(e,n){let t=wd(),o=Tw({selector:e,callback:n});o.current.selector=e,o.current.callback=n,Iw(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Ph(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Cd,jsxs as p6}from"react/jsx-runtime";var d6=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?Bi.IMMEDIATELY:Bi.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Cd(Ai,{palette:null,topPicks:s6,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})}),vd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:gu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...ro({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Bn(n.zoom.value+Sw)},n)},captureUpdate:Bi.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Cd(K,{type:"button",className:"zoom-in-button zoom-button",icon:gu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=l6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Rr.EQUAL||e.code===Rr.NUM_ADD)&&(e[yd.CTRL_OR_CMD]||e.shiftKey)}),Id=O({name:"zoomOut",label:"buttons.zoomOut",icon:fu,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...ro({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Bn(n.zoom.value-Sw)},n)},captureUpdate:Bi.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Cd(K,{type:"button",className:"zoom-out-button zoom-button",icon:fu,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=c6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Rr.MINUS||e.code===Rr.NUM_SUBTRACT)&&(e[yd.CTRL_OR_CMD]||e.shiftKey)}),Td=O({name:"resetZoom",label:"buttons.resetZoom",icon:Cx,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,...ro({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:Bn(r)},n)},captureUpdate:Bi.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Cd(ct,{label:f("buttons.resetZoom"),style:{height:"100%"},children:p6(K,{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===Rr.ZERO||e.code===Rr.NUM_ZERO)&&(e[yd.CTRL_OR_CMD]||e.shiftKey)}),kh=e=>[e.x,e.y,e.x+e.width,e.y+e.height],dne=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Bc,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(Ds(r)):n.scrollConstraints?kh(n.scrollConstraints):_s(Ds(e)),a=Ir({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Nn(a.appState)}}},keyTest:void 0}),mne=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Bc,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(Ds(r)):n.scrollConstraints?kh(n.scrollConstraints):_s(Ds(e)),a=Ir({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Nn(a.appState)}}},keyTest:void 0}),m6=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Bc,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?kh(n.scrollConstraints):_s(Ds(e)),i=Ir({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Nn(i.appState)}}},keyTest:void 0}),Sd=O({name:"toggleTheme",label:(e,n)=>n.theme===Ls.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===Ls.LIGHT?ms:ps,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===Ls.LIGHT?Ls.DARK:Ls.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:Bi.EVENTUALLY}},keyTest:e=>!e[yd.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Rr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as y6}from"@excalidraw/math";import{bindOrUnbindBindingElement as Bw}from"@excalidraw/element/binding";import{isValidPolygon as Ow,newElementWith as Lh}from"@excalidraw/element";import{LinearElementEditor as Fs}from"@excalidraw/element/linearElementEditor";import{isBindingElement as Dh,isFreeDrawElement as Fw,isLinearElement as zw,isLineElement as _d}from"@excalidraw/element";import{KEYS as Rd,arrayToMap as v6,invariant as Hw,shouldRotateWithDiscreteAngle as I6,updateActiveTool as Gw}from"@excalidraw/common";import{isPathALoop as T6}from"@excalidraw/element";import{isInvisiblySmallElement as _h}from"@excalidraw/element";import{CaptureUpdateAction as Rh}from"@excalidraw/element";import f6 from"clsx";import{useEffect as E6,useState as b6}from"react";import{KEYS as on,capitalizeString as Nr}from"@excalidraw/common";import{useEffect as u6,useState as h6}from"react";import Cw from"clsx";import{capitalizeString as Pd}from"@excalidraw/common";import{Popover as Mh}from"radix-ui";import{jsx as kd,jsxs as g6}from"react/jsx-runtime";var Oi=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=h6(!1),c=t.type,d=a.type===c,m=16,{container:p}=De();return!n.some(u=>u.type===c)&&s&&l(!1),u6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),g6(Mh.Root,{open:s,children:[kd(Mh.Trigger,{asChild:!0,children:kd(K,{className:Cw({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>Ze(e,u.type)),title:Pd(a.title),"aria-label":Pd(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),kd(Mh.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>kd(K,{className:Cw({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:Ze(e,u),title:Pd(u),"aria-label":Pd(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Ne("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as Ah}from"react/jsx-runtime";var x6=e=>e,We=x6({hand:{icon:M1,letterKey:on.H,toggle:!0},selection:{icon:Pc,letterKey:on.V,fillable:!0},rectangle:{icon:Ei,letterKey:on.R,fillable:!0},diamond:{icon:bi,letterKey:on.D,fillable:!0},ellipse:{icon:xi,letterKey:on.O,fillable:!0},arrow:{icon:kc,letterKey:on.A,fillable:!0},line:{icon:Bo,letterKey:on.L,fillable:!0},freedraw:{icon:zn,letterKey:on.P},text:{icon:wn,letterKey:on.T},image:{icon:Cr},eraser:{icon:Mc,letterKey:on.E,toggle:!0},frame:{icon:Gn,letterKey:on.F},autoshape:{icon:Mr,letterKey:on.X,fillable:!1},embeddable:{icon:Oo},laser:{icon:Un},bucketfill:{icon:Hn},lasso:{icon:fi,fillable:!1}});var Fi=["autoshape","rectangle","diamond","ellipse","arrow","line"],zi=Object.keys(We).filter(e=>We[e].toggle),Md=e=>{let{letterKey:n,shiftKey:t}=We[e];if(!n)return n;let o=Nr(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},Hi=e=>Md(e),w6=e=>{let n=Md(e);return n?.length===1?n:void 0},Pw=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(We)){let{letterKey:i,shiftKey:a}=We[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},Ze=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Ot=(e,n)=>{let t=We[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=Nr(f(`toolBar.${e}`)),d=l?null:Hi(o);return Ah(K,{className:f6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:Ze(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:s||l?void 0:w6(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&&(Ne("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Nr(e)}IconButton`,r},Ad=Ot("hand"),kw=Ot("rectangle"),Mw=Ot("diamond"),Aw=Ot("ellipse"),Lw=Ot("arrow"),Dw=Ot("line"),Rs=Ot("freedraw"),Ns=Ot("text"),Bs=Ot("image"),Os=Ot("eraser"),_w=Ot("frame"),zne=Ot("autoshape"),Rw=Ot("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Ne("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),Nw=Ot("lasso",{shortcutType:"selection"}),Ld=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:We.selection.icon,fillable:We.selection.fillable,title:Nr(f("toolBar.selection"))},{type:"lasso",icon:We.lasso.icon,fillable:We.lasso.fillable,title:Nr(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return Ah(Oi,{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})},Dd=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:We.freedraw.icon,fillable:We.freedraw.fillable,title:Nr(f("toolBar.freedraw"))},{type:"autoshape",icon:We.autoshape.icon,fillable:We.autoshape.fillable,title:Nr(f("toolBar.autoshape"))}],[o,r]=b6(n.type==="autoshape"?"autoshape":"freedraw");E6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return Ah(Oi,{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 S6}from"react/jsx-runtime";var dt=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:y}=t,w=Fs.getElement(n.selectedLinearElement.elementId,l);Hw(w,"Arrow element should exist if selectedLinearElement is set"),Hw(y,"sceneCoords should be defined if actionFinalize is called with event");let x=Fs.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(Dh(w)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let v=!!n.newElement,T=v||!n.selectedLinearElement.selectedPointsIndices?[w.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=I6(b),P=b[Rd.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),A=T.reduce((L,_)=>(L.set(_,{point:C?w.points[_]:Fs.createPointAt(w,l,y.x-x.pointerOffset.x,y.y-x.pointerOffset.y,P)}),L),new Map)??new Map;Bw(w,A,y.x,y.y,s,n,{newArrow:v,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else _d(w)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!Ow(w.points)&&s.mutateElement(w,{polygon:!1});if(x!==n.selectedLinearElement){w&&_h(w)&&(i=i.map(T=>T.id===w.id?Lh(T,{isDeleted:!0}):T));let v=n.activeTool?.locked;return{elements:w.points.length<2||_h(w)?e.map(T=>T.id===w.id?Lh(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:v||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:Rh.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"||Dh(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:y}=n.selectedLinearElement;if((!y||b[b.length-1]!==y)&&(r=!1,s.mutateElement(m,{points:m.points.slice(0,-1)}),Dh(m)&&m.endBinding&&m.points.length>1)){let w=!!n.newElement,x=new Map([[m.points.length-1,{point:m.points[m.points.length-1],isDragging:!1}]]),v=Fs.getPointAtIndexGlobalCoordinates(m,-1,l);Bw(m,x,v[0],v[1],s,n,{newArrow:w})}}if(m&&_h(m)&&(i=i.map(b=>b.id===m?.id?Lh(b,{isDeleted:!0}):b)),zw(m)||Fw(m)){if(T6(m.points,n.zoom.value)&&(_d(m)||Fw(m))){let y=m.points,w=y[0],x=y.map((v,T)=>T===y.length-1?y6(w[0],w[1]):v);_d(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}_d(m)&&!Ow(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;zi.includes(n.activeTool.type)?p=Gw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=Gw(n,{type:o.state.preferredSelectionTool.type});let u=o.isToolLocked(),E=n.activeTool.type==="autoshape"||(u||n.activeTool.type==="freedraw")&&!!m;E||o.cursor.applyForTool(p);let g=m&&zw(m)?new Fs(m,v6(i)):n.selectedLinearElement;return g=g&&{...g,isEditing:n.newElement?!1:g.isEditing,initialState:{...g.initialState,lastClickedPoint:-1,origin:null}},{elements:i,appState:{...n,cursorButton:"up",activeTool:E?n.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:c?{}:m&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[m.id]:!0}:n.selectedElementIds,selectedLinearElement:c?null:g},captureUpdate:r?Rh.IMMEDIATELY:Rh.NEVER}},keyTest:(e,n)=>e.key===Rd.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===Rd.ESCAPE||e.key===Rd.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>S6(K,{type:"button",icon:Ox,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 Vw,isSomeElementSelected as C6,makeNextSelectedElementIds as P6,selectGroupsForSelectedElements as k6}from"@excalidraw/element";import{CaptureUpdateAction as Uw}from"@excalidraw/element";import{KEYS as M6,isWritableElement as A6,updateActiveTool as Ww}from"@excalidraw/common";var L6=(e,n)=>zi.includes(e.activeTool.type)?Ww(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):Ww(e,{type:n.state.preferredSelectionTool.type}),D6=(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:Vw(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},_6=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=L6(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:Vw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...k6({editingGroupId:D6(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:Uw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:P6({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Uw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==M6.ESCAPE||A6(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||C6(o.scene.getNonDeletedElements(),n))});import{KEYS as Ud,THEME as Us}from"@excalidraw/common";import{CaptureUpdateAction as vn}from"@excalidraw/element";import R6 from"clsx";import{jsx as Yw,jsxs as N6}from"react/jsx-runtime";var Nh=({children:e,checked:n,onChange:t,className:o})=>N6("div",{className:R6("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[Yw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:Ac}),Yw("div",{className:"Checkbox-label",children:e})]});import{THEME as zs}from"@excalidraw/common";import{jsx as Hs}from"react/jsx-runtime";var Kw=e=>{let n=e.title||(e.value===zs.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return Hs(K,{type:"icon",icon:e.value===zs.LIGHT?Xw.MOON:Xw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===zs.DARK?zs.LIGHT:zs.DARK),"data-testid":"toggle-dark-mode"})},Xw={SUN:Hs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Hs("path",{fill:"currentColor",d:"M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z"})}),MOON:Hs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Hs("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};import{useState as B6}from"react";import{focusNearestParent as O6,KEYS as F6}from"@excalidraw/common";import{jsx as Zw,jsxs as z6}from"react/jsx-runtime";var $w=e=>{let{id:n}=De(),[t,o]=B6(e.value),r=a=>{e.ignoreFocus||O6(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===F6.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return z6("div",{className:"ProjectName",children:[Zw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Zw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as H6,useEffect as G6,useRef as U6}from"react";import{jsx as Nd,jsxs as X6}from"react/jsx-runtime";var W6=5e3,V6=({progress:e})=>Nd("div",{className:"Toast__progress-bar",children:Nd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),Y6=({message:e,onClose:n,closable:t=!1,duration:o=W6,style:r})=>{let i=U6(0),a=o!==1/0,s=H6(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return G6(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),X6("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Nd("div",{className:"Toast__message",children:e}),t&&Nd(K,{icon:Jt,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},Bd=Object.assign(Y6,{ProgressBar:V6});import{DEFAULT_EXPORT_PADDING as dL,DEFAULT_FILENAME as mL,IMAGE_MIME_TYPES as ty,isFirefox as pL,MIME_TYPES as uL,cloneJSON as hL,SVG_DOCUMENT_PREAMBLE as gL,arrayToMap as fL}from"@excalidraw/common";import{getNonDeletedElements as EL}from"@excalidraw/element";import{isFrameLikeElement as bL}from"@excalidraw/element";import{getElementsOverlappingFrame as xL}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as K6,EXPORT_DATA_TYPES as Gs,MIME_TYPES as mt,arrayToMap as Z6,isMemberOf as $6,isPromiseLike as j6,EVENT as Od}from"@excalidraw/common";import{mutateElement as q6}from"@excalidraw/element";import{deepCopyElement as J6}from"@excalidraw/element";import{isFrameLikeElement as Q6,isInitializedImageElement as eL}from"@excalidraw/element";import{getContainingFrame as jw}from"@excalidraw/element";var ore="clipboard"in navigator&&"readText"in navigator.clipboard,Fd="clipboard"in navigator&&"writeText"in navigator.clipboard,qo="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,tL=e=>!!([Gs.excalidraw,Gs.excalidrawClipboard,Gs.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),qw=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Od.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},nL=({elements:e,files:n})=>{let t=Z6(e),o=new Set(e.filter(s=>Q6(s))),r=!1,i=e.reduce((s,l)=>(eL(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:Gs.excalidrawClipboard,elements:e.map(s=>{if(jw(s,t)&&!o.has(jw(s,t))){let l=J6(s);return q6(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},zd=async(e,n,t)=>{let o=nL({elements:e,files:n});await uo({[mt.excalidrawClipboard]:o,[mt.text]:o},t)};function Jw(e){let n=[];for(let t of e.childNodes)if(t.nodeType===3){let o=t.textContent?.trim();o&&n.push({type:"text",value:o})}else if(t instanceof HTMLImageElement){let o=t.getAttribute("src");o&&o.startsWith("http")&&n.push({type:"imageUrl",value:o})}else n=n.concat(Jw(t));return n}var oL=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,mt.html),o=Jw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Qw=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{[mt.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($6(K6,o))try{if(o===mt.text||o===mt.html)e[o]=await(await t.getType(o)).text();else if(ox(o)){let r=await t.getType(o),i=dx(r,o,void 0);e[o]=i}else throw new du(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof du?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},rL=async(e,n=!1)=>{try{let t=e.findByType(mt.html),o=!n&&t&&oL(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(mt.text)??o.value.map(r=>r.value).join(`
2
- `).trim()}:o:{type:"text",value:(e.getData(mt.text)||"").trim()}}catch{return{type:"text",value:""}}},iL=function(e){return this.find(n=>n.type===e)||null},aL=function(e){return this.find(t=>t.type===e)?.value??null},sL=function(){return this.filter(e=>e.kind==="file")},Bh=e=>{let n=Fh(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),mt.text,mt.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}},lL=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}}),Oh=(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===mt.html)try{let E=new DOMParser().parseFromString(u.value,mt.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===mt.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:lL(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},ey=e=>{let n;Fh(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},Br=async e=>{let n;Fh(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 ui(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:iL,getData:aL,getFiles:sL})},Hd=async(e,n=!1)=>{let t=await rL(e,n);if(t.type==="mixedContent")return{mixedContent:t.value};try{let o=JSON.parse(t.value),r=o.type===Gs.excalidrawClipboardWithAPI;if(tL(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}},Gd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[mt.png]:e})])}catch(n){if(j6(e))await navigator.clipboard.write([new ClipboardItem({[mt.png]:await e})]);else throw n}},uo=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[mt.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===mt.text);if(Fd&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!cL(o[1]))throw new Error("Error copying to clipboard.")},cL=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},Fh=e=>e.type===Od.PASTE||e.type===Od.COPY||e.type===Od.CUT;var Or=(e,{selectedElementIds:n},t)=>{let o=EL(e),r=fL(o),i=t&&Me(o,{selectedElementIds:n}),a=null,s=i?ie(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&bL(l)?(a=l,s=xL(o,l,r)):s.length>1&&(s=ie(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:hL(s)}},Fr=async(e,n,t,o,{exportBackground:r,exportPadding:i=dL,viewBackgroundColor:a,name:s=t.name||mL,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Tr(n,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return mu(m.then(p=>new Blob([gL+p.outerHTML],{type:uL.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[ty.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await uo(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let d=wc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=ls(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-WGUGXKQD.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:rs(n,t,o,"local")})))),mu(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[ty.png],fileHandle:l})}else if(e==="clipboard")try{let m=ls(d);await Gd(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):pL&&m.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
1
+ import{$ as ss,A as cu,B as rs,C as gc,D as du,E as Xb,F as Kb,G as fc,H as is,I as Ec,J as bc,K as as,L as Zb,M as $b,N as jb,O as xc,P as Tr,Q as $M,R as Sr,S as pi,U as qb,W as Jb,X as Qb,Y as wc,Z as ex,_ as yc,a as au,aa as ls,b as Bn,ba as tx,c as io,ca as vc,d as Ir,da as nx,e as ci,ea as ox,f as On,fa as rx,g as zb,ga as mu,h as Me,ha as ix,i as Hb,ia as ax,j as se,ja as sx,k as di,ka as ui,l as _o,m as Gb,n as su,o as Ub,p as ns,q as Wb,r as hc,s as Vb,t as lu,u as ao,v as Ro,w as qt,x as os,y as mi,z as Yb}from"./chunk-JCJ2YNSV.js";import{a as S}from"./chunk-ELA2R5XK.js";import{G as iu}from"./chunk-DARW3V66.js";import{c as Fb}from"./chunk-5XKZK2GL.js";import{b as Ob,c as ZM,d as I}from"./chunk-SRAX5OIU.js";import LX,{useCallback as DX,useContext as _X,useEffect as RX,useRef as NX,useState as BX}from"react";import{applyDarkModeFilter as uWe,DEFAULT_IMAGE_OPTIONS as Lo,DEFAULT_UI_OPTIONS as YM,getStrokeWidthByKey as hWe,isShallowEqual as OX}from"@excalidraw/common";import wk from"clsx";import mV from"lodash.throttle";import En,{useContext as Ao}from"react";import{flushSync as Gt}from"react-dom";import pV from"roughjs/bin/rough";import{nanoid as uV}from"nanoid";import{clamp as Kl,pointFrom as ne,pointDistance as Jn,vector as yk,pointRotateRads as $E,vectorFromPoint as jE,vectorSubtract as vk,vectorDot as Ik,vectorNormalize as Tk}from"@excalidraw/math";import{CODES as br,shouldResizeFromCenter as Sk,shouldMaintainAspectRatio as Zl,shouldRotateWithDiscreteAngle as Ck,isArrowKey as qE,KEYS as X,APP_NAME as hV,CURSOR_TYPE as Pe,DEFAULT_STROKE_STREAMLINE as gV,DEFAULT_STROKE_STREAMLINE_PRECISE as fV,DEFAULT_TRANSFORM_HANDLE_SPACING as EV,DEFAULT_VERTICAL_ALIGN as Pk,DRAGGING_THRESHOLD as kk,ELEMENT_SHIFT_TRANSLATE_AMOUNT as bV,ELEMENT_TRANSLATE_AMOUNT as Mk,EVENT as J,FRAME_STYLE as So,IMAGE_MIME_TYPES as xV,IMAGE_RENDER_TIMEOUT as wV,LINE_CONFIRM_THRESHOLD as JE,MIME_TYPES as Xa,MQ_RIGHT_SIDEBAR_MIN_WIDTH as yV,POINTER_BUTTON as Dn,ROUNDNESS as Np,SCROLL_TIMEOUT as vV,TAP_TWICE_TIMEOUT as Ak,TEXT_TO_CENTER_SNAP_THRESHOLD as IV,THEME as $l,TOUCH_CTX_MENU_TIMEOUT as TV,VERTICAL_ALIGN as SV,YOUTUBE_STATES as Bp,ZOOM_STEP as CV,MIN_ZOOM as PV,POINTER_EVENTS as Ka,TOOL_TYPE as _n,supportsResizeObserver as kV,DEFAULT_COLLISION_THRESHOLD as Lk,DEFAULT_TEXT_ALIGN as MV,ARROW_TYPE as xr,DEFAULT_REDUCED_GLOBAL_ALPHA as AV,isLocalLink as LV,normalizeLink as Op,toValidURL as DV,getGridPoint as Ct,getLineHeight as Dk,debounce as _k,distance as Za,getFontString as QE,getNearestScrollableContainer as _V,isInputLike as Rk,isToolIcon as RV,isWritableElement as jl,sceneCoordsToViewportCoords as Fp,tupleToCoors as eb,viewportCoordsToSceneCoords as Ce,wrapEvent as NV,updateObject as tb,updateActiveTool as $t,isTransparent as BV,muteFSAbortError as OV,isTestEnv as TM,isDevEnv as SM,updateStable as ql,addEventListener as be,normalizeEOL as FV,getDateTime as Nk,isShallowEqual as Bk,arrayToMap as Jl,applyDarkModeFilter as zV,AppEventBus as HV,randomInteger as GV,CLASSES as nb,Emitter as Qn,MINIMUM_ARROW_SIZE as UV,DOUBLE_TAP_POSITION_THRESHOLD as Ok,BIND_MODE_TIMEOUT as WV,invariant as eo,getFeatureFlag as Co,createUserAgentDescriptor as CM,getFormFactor as VV,deriveStylesPanelMode as jp,isIOS as YV,isBrave as XV,isSafari as KV,loadDesktopUIModePreference as ZV,setDesktopUIMode as $V,isSelectionLikeTool as zp,oneOf as Fk,getStrokeWidthByKey as jV}from"@excalidraw/common";import{getObservedAppState as qV,getCommonBounds as $a,getElementAbsoluteCoords as zk,bindOrUnbindBindingElements as Hk,fixBindingsAfterDeletion as JV,getHoveredElementForBinding as wr,isBindingEnabled as Hp,updateBoundElements as Gp,LinearElementEditor as me,newElementWith as to,newFrameElement as QV,newFreeDrawElement as eY,newEmbeddableElement as Gk,newMagicFrameElement as tY,newIframeElement as nY,newArrowElement as oY,newElement as rY,newImageElement as iY,newLinearElement as aY,newTextElement as Uk,refreshTextDimensions as sY,deepCopyElement as Wk,duplicateElements as Vk,hasBoundTextElement as Yk,isArrowElement as Ql,isBindingElement as no,isBindingElementType as lY,isBoundToContainer as Xk,isFrameLikeElement as vt,isImageElement as oo,isEmbeddableElement as Po,isInitializedImageElement as ja,isLinearElement as Rt,isLinearElementType as cY,isUsingAdaptiveRadius as dY,isIframeElement as ob,isIframeLikeElement as ec,isTextBindableContainer as Kk,isElbowArrow as Ut,isBindableElement as rb,isTextElement as Wt,getNormalizedDimensions as mY,isElementCompletelyInViewport as pY,isElementInViewport as Zk,isInvisiblySmallElement as $k,generateThumbHash as uY,getCornerRadius as hY,isPathALoop as jk,embeddableURLValidator as ib,maybeParseEmbedSrc as gY,getEmbedLink as Up,getInitializedImageElements as fY,normalizeSVG as qk,updateImageCache as Jk,getBoundTextElement as ab,getContainerCenter as sb,getContainerElement as Qk,isValidTextContainer as eM,redrawTextBoundingBox as EY,hasBoundingBox as bY,getCommonFrameId as tM,getFrameChildren as lb,getFrameChildrenInsertionIndex as xY,isCursorInFrame as nM,addElementsToFrame as cb,replaceAllElementsInFrame as wY,removeElementsFromFrame as yY,getElementsInResizingFrame as db,getElementsInNewFrame as vY,getContainingFrame as mb,elementOverlapsWithFrame as IY,updateFrameMembershipOfSelectedElements as oM,isElementInFrame as rM,getFrameLikeTitle as TY,filterElementsEligibleAsFrameChildren as SY,hitElementBoundText as CY,hitElementBoundingBoxOnly as PY,hitElementItself as tc,getVisibleSceneBounds as kY,cropElement as MY,wrapText as AY,isElementLink as iM,isMeasureTextSupported as LY,normalizeText as DY,measureText as aM,getLineHeightInPx as sM,getApproxMinLineWidth as _Y,getApproxMinLineHeight as RY,getMinTextElementWidth as NY,ShapeCache as qa,getRenderOpacity as BY,editGroupForSelectedElement as OY,getElementsInGroup as si,getSelectedGroupIdForElement as FY,getSelectedGroupIds as zY,isElementInGroup as lM,isSelectedViaGroup as HY,selectGroupsForSelectedElements as Rn,syncInvalidIndices as PM,syncMovedIndices as cM,excludeElementsInFramesFromSelection as GY,getSelectionStateForElements as dM,makeNextSelectedElementIds as ke,getResizeOffsetXY as UY,getResizeArrowDirection as WY,transformElements as VY,getCursorForResizingElement as mM,getElementWithTransformHandleType as pM,getTransformHandleTypeFromCoords as uM,dragNewElement as hM,dragSelectedElements as YY,getDragOffsetXY as XY,Scene as gM,Store as KY,CaptureUpdateAction as jt,hitElementBoundingBox as ZY,isLineElement as pb,isSimpleArrow as ub,StoreDelta as fM,positionElementsOnGrid as EM,calculateFixedPointForNonElbowArrowBinding as bM,bindOrUnbindBindingElement as $Y,mutateElement as Wp,getElementBounds as xM,doBoundsIntersect as jY,isPointInElement as wM,maxBindingDistance_simple as yM,convertToExcalidrawElements as qY,getSnapOutlineMidPoint as hb,handleFocusPointDrag as JY,handleFocusPointHover as QY,handleFocusPointPointerDown as eX,handleFocusPointPointerUp as tX,maybeHandleArrowPointlikeDrag as Vp,getUncroppedWidthAndHeight as nX,getActiveTextElement as vM,isEligibleFrameChildType as oX,getBindingStrategyForDraggingBindingElementEndpoints as rX,isNonDeletedElement as Yp}from"@excalidraw/element";import{KEYS as Uu,MOBILE_ACTION_BUTTON_BG as c3,updateActiveTool as d3}from"@excalidraw/common";import{getNonDeletedElements as Uc}from"@excalidraw/element";import{fixBindingsAfterDeletion as m3}from"@excalidraw/element";import{LinearElementEditor as t0}from"@excalidraw/element/linearElementEditor";import{newElementWith as Gc}from"@excalidraw/element";import{getContainerElement as n0}from"@excalidraw/element";import{isBoundToContainer as zc,isElbowArrow as p3,isFrameLikeElement as u3}from"@excalidraw/element";import{getFrameChildren as h3}from"@excalidraw/element";import{getElementsInGroup as Wu,selectGroupsForSelectedElements as g3}from"@excalidraw/element";import{CaptureUpdateAction as Hc}from"@excalidraw/element";import{isDevEnv as QM}from"@excalidraw/common";import{atom as qe,createStore as jM}from"jotai";import{createIsolation as qM}from"jotai-scope";var lx=qM();var{useAtom:Fe,useSetAtom:cx,useAtomValue:dx,useStore:WX}=lx,mx=lx.Provider,gt=jM();var JM=Ob({"./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 e3=85,Fn={code:"en",label:"English"},gi=[Fn,...[{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=>Fb[e.code]>=e3).sort((e,n)=>e.label>n.label?1:-1)],Tc="__test__";QM()&&gi.unshift({code:Tc,label:"test language"},{code:`${Tc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var hi=Fn,Ic={},Sc=async e=>{if(hi=e,document.documentElement.dir=hi.rtl?"rtl":"ltr",document.documentElement.lang=hi.code,e.code.startsWith(Tc))Ic={};else try{Ic=await JM(`./locales/${hi.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Ic=iu}gt.set(ux,e.code)},zn=()=>hi,px=(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(hi.code.startsWith(Tc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=px(Ic,o)||px(iu,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},ux=qe(Fn.code),Ae=()=>{let e=dx(ux);return{t:f,langCode:e}};import t3 from"clsx";import Je from"react";import{THEME as n3}from"@excalidraw/common";import{Fragment as Te,jsx as h,jsxs as R}from"react/jsx-runtime";var xn=e=>"var(--icon-fill-color)",hx=e=>e===n3.LIGHT?"#fff":"#1e1e1e",M=(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:t3({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},G={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ie={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Pt={width:40,height:20},rK=M(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"})]}),G),iK=M(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"})]}),G),cs=M(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"})]}),G),gx=M(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"})]}),G),fx=M(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"})]}),G),pu=M(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"})]}),G),so=M(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"})})]}),ie),No=M(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"})]}),ie),Ex=M(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}),bx=M(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"}),xx=M(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"}),wx=M(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"}),aK=M(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"}),Cc=M(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),fi=M(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}),Ei=M(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"})]}),G),bi=M(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"})]}),G),xi=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),G),Pc=M(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"})]}),G),Bo=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ie),yx=M(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"})]}),G),Hn=M(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"})]}),ie),wn=M(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"})]}),G),vx=M(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"})]}),G),Cr=M(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"})]}),ie),kc=M(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"})]}),G),uu=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ie),hu=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ie),Ix=M(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"})]}),G),Pr=M(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"}),ie),Oo=M(R("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),ie),ds=M(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"})]}),ie),ms=M(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"}),ie),ps=M(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"})}),{...ie,strokeWidth:1.5}),Tx=M(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"})]}),G),us=M(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"}),ie),wi=M(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"})]}),G),Sx=M(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"})]}),G),sK=M(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"}),ie),Cx=M(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"}),ie),Px=M(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"})]}),ie),kx=M(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"})]}),G),Mc=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),hs=M(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"})]}),ie),Mx=M("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}),Ax=M("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}),Ac=M(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"}),ie),lK=M("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}),cK=M("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"),gu=["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"],Gn=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),gu.map(e=>h("path",{d:e},e))]}),G),Lx=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),G),Dx=M(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"})]}),G),_x=M("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}),dK=M("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}),mK=M("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}),Rx=M("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"),pK=M("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"),fu=M(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"}),ie),Eu=M(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"}),ie),Nx=M("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}),Bx=M(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"}),ie),uK=M("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"),hK=M("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}),gK=M(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"})]}),G),fK=M(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}),EK=M(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}),Ox=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"})]}),Fx=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"})]}),bu=M(Fx,G),xu=M(Fx,{...G,style:{transform:"rotate(180deg)"}}),wu=M(Ox,G),yu=M(Ox,{...G,style:{transform:"rotate(180deg)"}}),vu=M(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"})})})]}),ie),Iu=M(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"})})})]}),ie),Tu=M(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"})})})]}),ie),Su=M(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"})})})]}),ie),zx=M(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"})})})]}),ie),Hx=M(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"})})})]}),ie),Cu=M(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"})]}),ie),Pu=M(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"})]}),ie),Lc=M(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"})]}),G),bK=M("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"),xK=M("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"),Jt=M(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"})})})]}),ie),wK=M("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}),yK=M("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}),vK=M("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}),ku=Je.memo(({theme:e})=>M(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:xn(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:xn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:xn(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:xn(e),strokeWidth:"2"}),R("g",{fill:hx(e),stroke:xn(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})),Mu=Je.memo(({theme:e})=>M(R(Te,{children:[h("path",{d:"M25 26H111V111H25",fill:xn(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:xn(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:xn(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:xn(e),strokeWidth:"2"}),R("g",{fill:hx(e),stroke:xn(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})),Gx=M(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"})}),ie),Ux=M(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"})})]}),ie),Wx=M(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"})})})]}),ie),Vx=M(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"})})})]}),{...ie,fill:"currentColor"}),Au=M(h(Te,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ie),Yx=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ie),Xx=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ie),IK=Je.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:xn(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Kx=M(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"})]}),G),Zx=M(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"})]}),G),$x=M(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"}),ie),jx=M(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"}),ie),qx=M(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"}),ie),Lu=M(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"})]}),G),Du=M(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"})]}),G),Jx=M(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"})]}),ie),Qx=M(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"})]}),G),e1=Je.memo(({flip:e=!1})=>M(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"})]}),Pt)),t1=Je.memo(({flip:e=!1})=>M(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"})}),Pt)),n1=Je.memo(({flip:e=!1})=>M(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"})]}),Pt)),o1=Je.memo(({flip:e=!1})=>M(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"})]}),Pt)),r1=Je.memo(({flip:e=!1})=>M(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"})]}),Pt)),i1=Je.memo(({flip:e=!1})=>M(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"})]}),Pt)),a1=Je.memo(({flip:e=!1})=>M(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"})]}),Pt)),s1=Je.memo(({flip:e=!1})=>M(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"})]}),Pt)),l1=Je.memo(({flip:e=!1})=>M(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"})}),Pt)),c1=Je.memo(({flip:e=!1})=>M(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"})}),Pt)),d1=Je.memo(({flip:e=!1})=>M(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"})}),Pt)),m1=Je.memo(({flip:e=!1})=>M(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"})}),Pt)),p1=Je.memo(({flip:e=!1})=>M(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"})}),Pt)),u1=Je.memo(({flip:e=!1})=>M(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"})]}),Pt)),h1=Je.memo(({flip:e=!1})=>M(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"})]}),Pt)),g1=M(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"})})})]}),ie),f1=M(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"})})})]}),ie),E1=M(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"})})})]}),ie),b1=M(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"})}),ie),kr=M(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"})]}),G),x1=M(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"})]})}),G),gs=M(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"})})}),ie),o3=M(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"})]}),G),Dc=o3,w1=M(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"})]}),G),y1=M(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"})]}),G),v1=M(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"})]}),G),I1=Je.memo(({theme:e})=>M(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"})]}),G)),T1=Je.memo(({theme:e})=>M(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"})]}),G)),S1=Je.memo(({theme:e})=>M(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"})]}),G)),_c=M(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"})]}),G),TK=M(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}),SK=M(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"})),C1=M(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"})]}),G),_u=M(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"})]}),G),P1=M(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"})]}),G),k1=M(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"})]}),G),M1=M(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"})]}),G),CK=M(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),G),PK=M(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"})]}),G),A1=M(R(Te,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),G),L1=M(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"})]}),G),Ru=["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"],yi=M(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Ru.map(e=>h("path",{d:e},e))]}),G),Un=M(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"})]}),G),kK=M(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"})]}),G),MK=M(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"})]}),G),AK=M(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"})]}),ie),Mr=M(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"})]}),G),Wn=M(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),LK=M(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"})]}),G),DK=M(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"})]}),G),_K=M(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"})]}),G),RK=M(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"})]}),G),Ar=M(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"})]}),G),D1=M(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"})]}),G),NK=M(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"})]}),G),BK=M(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"})]}),G),Vn=M(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"})]}),G),OK=M(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"})]}),G),FK=M(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"})]}),G),_1=M(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"})]}),G),R1=M(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"})]}),G),zK=M(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"})]}),G),N1=M(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"})]}),G),B1=M(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"})]}),G),O1=M(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"})]}),G),F1=M(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"})]}),G),Nu=M(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"})]}),G),Rc=M(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"})]}),G),z1=M(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"})]}),G),H1=M(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"})]}),G),Fo=M(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"})]}),G),HK=M(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"})]}),G),G1=M(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"})]}),{...G,strokeWidth:1.5}),GK=M(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"})]}),G),UK=M(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"})]}),G),U1=M(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"})]}),G),W1=M(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"})]}),G),zo=M(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"})]}),G),Ho=M(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"})]}),G),Go=M(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),G),Nc=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),G),V1=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),G),Y1=M(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),G),Bu=M(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"})]}),G),X1=M(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"})]}),G),Ou=M(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"})]}),G),Fu=M(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"})]}),G),WK=M(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"})]}),G),zu=M(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"})})),K1=M(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"})]}),G),Z1=M(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"})]}),G),$1=M(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"})]}),G),VK=M(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"})]}),G),YK=M(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"})]}),G),XK=M(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"})]}),G),KK=M(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"})]}),G),Bc=h("div",{style:{width:"1rem",height:"1rem"}}),j1=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"6 9 12 15 18 9"})]}),G),q1=M(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"9 6 15 12 9 18"})]}),G),J1=M(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"})]}),G);import Q1 from"clsx";import Gu,{useEffect as a3,useRef as e0,useState as s3}from"react";import{isPromiseLike as l3}from"@excalidraw/common";import r3 from"react";import{jsx as Hu}from"react/jsx-runtime";var i3=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(r3.useRef(Date.now()).current%1600);return Hu("div",{className:`Spinner ${o}`,children:Hu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Hu("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},lo=i3;import{jsx as fs,jsxs as Oc}from"react/jsx-runtime";var K=Gu.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=Gu.useRef(null);Gu.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=s3(!1),c=e0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if(l3(u))try{l(!0),await u}catch(E){if(E instanceof hc)console.warn(E);else throw E}finally{c.current&&l(!1)}};a3(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=e0(null);return o.type==="button"||o.type==="icon"?Oc("button",{className:Q1("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)&&Oc("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&fs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&fs(lo,{})]}),o.showAriaLabel&&Oc("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&fs(lo,{})]}),o.children]}):fs("button",{className:Q1("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:Oc("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&fs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});K.displayName="IconButton";var Fc=[],F=e=>(Fc=Fc.concat(e),e);import{jsx as E3}from"react/jsx-runtime";var f3=(e,n,t)=>{let o=new Set(se(e.filter(d=>u3(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(zc(p)){let u=n0(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=zc(d)?n0(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&&p3(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),Gc(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,zc(d)||(r[d.id]=!0),Gc(d,{frameId:null})):zc(d)&&n.selectedElementIds[d.containerId]?Gc(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=Wu(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=Wu(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...g3({selectedElementIds:r,editingGroupId:c},Uc(l),n,null)}}},o0=(e,n)=>{if(e.editingGroupId){let t=Wu(Uc(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Es=F({name:"deleteSelectedElements",label:"labels.delete",icon:Pr,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=t0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?Gc(p,{isDeleted:!0}):p),m=o0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:Hc.IMMEDIATELY}}return t0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:Hc.IMMEDIATELY}}let{elements:r,appState:i}=f3(e,n,o);return m3(r,r.filter(a=>a.isDeleted)),i=o0(i,r),{elements:r,appState:{...i,activeTool:d3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Me(Uc(e),n)?Hc.IMMEDIATELY:Hc.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===Uu.BACKSPACE||e.key===Uu.DELETE)&&!e[Uu.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=at()==="mobile";return E3(K,{type:"button",icon:Pr,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Me(Uc(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?c3:{}}})}});import{KEYS as vi,CODES as Ii,isDarwin as Wc}from"@excalidraw/common";import{moveOneLeft as b3,moveOneRight as x3,moveAllLeft as w3,moveAllRight as y3}from"@excalidraw/element";import{CaptureUpdateAction as Vc}from"@excalidraw/element";import{isDarwin as r0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,r0?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,r0?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 Yc}from"react/jsx-runtime";var Vu=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:xu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:b3(e,n,o.scene),appState:n,captureUpdate:Vc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[vi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ii.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Yc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:xu})}),Yu=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:bu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:x3(e,n,o.scene),appState:n,captureUpdate:Vc.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[vi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ii.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Yc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:bu})}),Xu=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:yu,trackEvent:{category:"element"},perform:(e,n)=>({elements:w3(e,n),appState:n,captureUpdate:Vc.IMMEDIATELY}),keyTest:e=>Wc?e[vi.CTRL_OR_CMD]&&e.altKey&&e.code===Ii.BRACKET_LEFT:e[vi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ii.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>Yc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Wc?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:yu})}),Ku=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:wu,trackEvent:{category:"element"},perform:(e,n)=>({elements:y3(e,n),appState:n,captureUpdate:Vc.IMMEDIATELY}),keyTest:e=>Wc?e[vi.CTRL_OR_CMD]&&e.altKey&&e.code===Ii.BRACKET_RIGHT:e[vi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ii.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>Yc("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Wc?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:wu})});import{getNonDeletedElements as v3}from"@excalidraw/element";import{LinearElementEditor as I3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as T3,isTextElement as S3}from"@excalidraw/element";import{arrayToMap as C3,KEYS as i0}from"@excalidraw/common";import{selectGroupsForSelectedElements as P3}from"@excalidraw/element";import{CaptureUpdateAction as k3}from"@excalidraw/element";var Zu=F({name:"selectAll",label:"labels.selectAll",icon:N1,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(S3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...P3({editingGroupId:null,selectedElementIds:r},v3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&T3(e[0])?new I3(e[0],C3(e)):null},captureUpdate:k3.IMMEDIATELY}},keyTest:e=>e[i0.CTRL_OR_CMD]&&e.key===i0.A});import{DEFAULT_GRID_SIZE as a0,KEYS as s0,MOBILE_ACTION_BUTTON_BG as M3,arrayToMap as l0}from"@excalidraw/common";import{getNonDeletedElements as c0}from"@excalidraw/element";import{LinearElementEditor as A3}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as L3,getSelectionStateForElements as D3}from"@excalidraw/element";import{syncMovedIndices as _3}from"@excalidraw/element";import{duplicateElements as R3}from"@excalidraw/element";import{CaptureUpdateAction as d0}from"@excalidraw/element";import{jsx as N3}from"react/jsx-runtime";var $u=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:ds,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=A3.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:d0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=R3({type:"in-place",elements:e,idsOfElementsToDuplicate:l0(L3(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+a0/2,y:a.y+a0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:_3(i,l0(r)),appState:{...n,...D3(r,c0(i),n)},captureUpdate:d0.IMMEDIATELY}},keyTest:e=>e[s0.CTRL_OR_CMD]&&e.key===s0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=at()==="mobile";return N3(K,{type:"button",icon:ds,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Me(c0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?M3:{}}})}});import{pointFrom as h4}from"@excalidraw/math";import{useEffect as fh,useMemo as xh,useRef as Eh,useState as g4}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as f4,COLOR_PALETTE as E4,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Ew,DEFAULT_ELEMENT_BACKGROUND_PICKS as b4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as x4,DEFAULT_ELEMENT_STROKE_PICKS as w4,ARROW_TYPE as nn,DEFAULT_FONT_FAMILY as y4,DEFAULT_FONT_SIZE as v4,FONT_FAMILY as I4,ROUNDNESS as pd,STROKE_WIDTH_KEYS as T4,VERTICAL_ALIGN as dd,KEYS as _i,randomInteger as S4,arrayToMap as wh,getFontFamilyString as C4,getLineHeight as P4,isTransparent as k4,getStrokeWidthByKey as bw,reduceToCommonValue as M4,invariant as hd,FONT_SIZES as md}from"@excalidraw/common";import{canBecomePolygon as A4,getNonDeletedElements as xw,isNonDeletedElement as L4}from"@excalidraw/element";import{bindBindingElement as pw,calculateFixedPointForElbowArrowBinding as uw,updateBoundElements as D4}from"@excalidraw/element";import{LinearElementEditor as Dr}from"@excalidraw/element/linearElementEditor";import{newElementWith as ot}from"@excalidraw/element";import{getArrowheadForPicker as hw}from"@excalidraw/element";import{getBoundTextElement as jo,redrawTextBoundingBox as As}from"@excalidraw/element";import{isArrowElement as ud,isBoundToContainer as _4,isElbowArrow as ww,isLinearElement as bh,isLineElement as gw,isTextElement as Bt,isUsingAdaptiveRadius as R4}from"@excalidraw/element";import{hasStrokeColor as N4}from"@excalidraw/element";import{updateElbowArrowPoints as B4,CaptureUpdateAction as Qe,toggleLinePolygonState as O4}from"@excalidraw/element";import{deriveStylesPanelMode as F4}from"@excalidraw/common";import{isDevEnv as B3}from"@excalidraw/common";var O3=new Set(["command_palette","export"]),Ne=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!O3.has(e)||B3())return;S.PROD||console.info("trackEvent",{category:e,action:n,label:t,value:o}),window.sa_event&&window.sa_event(n,{category:e,label:t,value:o})}catch(r){console.error("error during analytics",r)}};import G3 from"clsx";import F3 from"clsx";import{forwardRef as z3}from"react";import{jsx as H3}from"react/jsx-runtime";var m0=z3((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return H3("button",{type:"button",ref:n,title:t,"data-testid":r,className:F3(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as W3,jsx as ju,jsxs as U3}from"react/jsx-runtime";var Vt=e=>ju(W3,{children:e.options.map(n=>e.type==="button"?ju(m0,{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):U3("label",{className:G3({active:e.value===n.value}),title:n.text,children:[ju("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 V0}from"radix-ui";import Y0 from"clsx";import{memo as d5,useRef as X0,useEffect as m5}from"react";import{applyDarkModeFilter as p5,COLOR_OUTLINE_CONTRAST_THRESHOLD as U0,COLOR_PALETTE as K0,DEFAULT_ELEMENT_BACKGROUND_PICKS as u5,DEFAULT_ELEMENT_STROKE_PICKS as h5,isColorDark as W0,isWritableElement as g5,THEME as f5}from"@excalidraw/common";import{jsx as V3}from"react/jsx-runtime";var Xc=()=>V3("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as j3,useLayoutEffect as q3,useRef as J3}from"react";import{createPortal as Q3}from"react-dom";import{EVENT as Uo,isColorDark as eA,KEYS as tA,MIME_TYPES as nA,THEME as oA,removeDarkModeFilter as rA,rgbToHex as iA}from"@excalidraw/common";import p0 from"react";var qu=p0.createContext(null),fe=()=>p0.useContext(qu);import{useState as Y3,useLayoutEffect as u0}from"react";import{THEME as X3}from"@excalidraw/common";var Kc=e=>{let[n,t]=Y3(null),o=ge(),{theme:r}=fe(),{container:i}=De();return u0(()=>{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===X3.DARK))},[n,r,o.formFactor,e?.className]),u0(()=>{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 K3}from"react";import{EVENT as Zc}from"@excalidraw/common";function Ti(e,n,t){K3(()=>{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(Zc.POINTER_DOWN,o),document.addEventListener(Zc.TOUCH_START,o),()=>{document.removeEventListener(Zc.POINTER_DOWN,o),document.removeEventListener(Zc.TOUCH_START,o)}},[e,n,t])}import{useRef as Z3}from"react";var Si=e=>{let n=Z3(e);return Object.assign(n.current,e),n.current};import{clamp as $3}from"@excalidraw/math";var h0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return $3(r,0,Math.max(0,t-n))},$c=({cursor:e,element:n,container:t,gap:o})=>({left:h0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:h0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as sA}from"react/jsx-runtime";var g0=Ru.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),aA=`url(data:${nA.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" stroke-width="5">${g0}</g><g stroke="#1b1b1f" stroke-width="1.25">${g0}</g></svg>`)}) 2 21, auto`,Nt=qe(null),f0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=Kc({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=fe(),a=Ci(),s=It(),l=se(a,i),c=Si({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=De();q3(()=>{if(r)return r.style.cursor=aA,()=>{r.style.cursor=""}},[r]),j3(()=>{let p=m.current;if(!p||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:A})=>{let L=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(A-i.offsetTop)*window.devicePixelRatio,1,1).data;return iA(L[0],L[1],L[2])},b=P=>i.theme===oA.DARK?rA(P):P,y=({clientX:P,clientY:A,altKey:L})=>{let{top:_,left:k}=$c({cursor:{x:P,y:A},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:7});p.style.top=`${_}px`,p.style.left=`${k}px`;let D=g({clientX:P,clientY:A});u&&c.onChange(o,b(D),c.selectedElements,{altKey:L}),p.style.background=D,p.style.setProperty("--eye-dropper-preview-border-color",eA(D)?"#fff":"#222")},w=()=>{c.onCancel()},x=(P,A)=>{c.onSelect(P,A)},v=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===tA.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),y({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(Uo.KEYDOWN,C),r.addEventListener(Uo.POINTER_DOWN,v),r.addEventListener(Uo.POINTER_UP,T),window.addEventListener("pointermove",y,{passive:!0}),window.addEventListener(Uo.BLUR,w),()=>{u=!1,r.removeEventListener(Uo.KEYDOWN,C),r.removeEventListener(Uo.POINTER_DOWN,v),r.removeEventListener(Uo.POINTER_UP,T),window.removeEventListener("pointermove",y),window.removeEventListener(Uo.BLUR,w)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=J3(null);return Ti(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?Q3(sA("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as Ju}from"radix-ui";import mA from"clsx";import pA from"react";import{isInteractive as uA}from"@excalidraw/common";import lA from"react";import cA from"clsx";import{jsx as dA}from"react/jsx-runtime";var ze=lA.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>dA("div",{className:cA("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as Qu,jsxs as hA}from"react/jsx-runtime";var co=pA.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=ge(),p=m.formFactor==="phone"&&!m.isLandscape;return Qu(Ju.Portal,{container:n,children:hA(Ju.Content,{ref:d,className:mA("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&&!uA(document.activeElement)&&n.focus(),r()},children:[Qu(ze,{padding:3,style:o,children:t}),Qu(Ju.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 gA,useCallback as eh}from"react";var jc=()=>document.querySelector(".excalidraw-wysiwyg"),qc=()=>{let e=jc();return e?{start:e.selectionStart,end:e.selectionEnd}:null},bs=e=>{setTimeout(()=>{let n=jc();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},xs=(e,n,t,o)=>{n&&o&&o();let r=n&&t?qc():null;e(),n&&t&&bs(r)},E0=()=>{let[e,n]=gA(null),t=eh(()=>{let i=qc();n(i)},[]),o=eh(()=>{setTimeout(()=>{let i=jc();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}},b0=(e=100)=>{let n=jc();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import w0 from"clsx";import{useCallback as bA,useEffect as nh,useRef as y0,useState as v0}from"react";import{KEYS as oh,normalizeInputColor as xA}from"@excalidraw/common";import{isTransparent as fA,MAX_CUSTOM_COLORS_USED_IN_CANVAS as EA}from"@excalidraw/common";var Wo=({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},ws=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),th=({color:e,palette:n})=>!Object.values(n).flat().includes(e),x0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!fA(s)&&th({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,EA)},Qt=qe(null);import{Fragment as wA,jsx as ys,jsxs as rh}from"react/jsx-runtime";var I0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=ge(),[a,s]=v0(e),[l,c]=v0(null),[d,m]=Fe(Qt);nh(()=>{s(e)},[e]);let p=bA(y=>{let w=y.toLowerCase().trim(),x=xA(w);x?(n(x),c(null)):w.length===0?c(null):/^#?[0-9a-f]+$/.test(w)?c(f("colorPicker.invalidHexLength")):c(f("colorPicker.invalidColor")),s(w)},[n]),u=y0(null),E=y0(null);nh(()=>{u.current&&u.current.focus()},[d]);let[g,b]=Fe(Nt);return nh(()=>()=>{b(null)},[b]),rh("div",{className:"color-picker__input-label-container",children:[rh("div",{className:w0("color-picker__input-label",{"has-error":l}),children:[ys("div",{className:"color-picker__input-hash",children:"#"}),ys("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:y=>{p(y.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e),c(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:y=>{y.key!==oh.TAB&&(y.key===oh.ESCAPE&&E.current?.focus(),y.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&rh(wA,{children:[ys("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),ys("div",{ref:E,className:w0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(y=>y?null:{keepOpenOnAlt:!1,onSelect:w=>n(w),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${oh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:yi})]})]}),l&&ys("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import sh,{useEffect as lh,useImperativeHandle as JA,useState as QA}from"react";import{EVENT as O0}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as e5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as t5,KEYS as n5}from"@excalidraw/common";import MA from"clsx";import{useEffect as AA,useRef as LA}from"react";import{applyDarkModeFilter as DA,THEME as _A}from"@excalidraw/common";import{isColorDark as yA}from"@excalidraw/common";import{jsxs as IA}from"react/jsx-runtime";var vA=({color:e,keyLabel:n,isShade:t=!1})=>IA("div",{className:"color-picker__button__hotkey-label",style:{color:yA(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),Pi=vA;import{createContext as TA,useContext as SA,useEffect as CA,useMemo as T0,useRef as S0,useState as PA}from"react";import{colorToHex as C0,isTransparent as kA}from"@excalidraw/common";var Lr="excalidraw-color-dnd-ghost",P0="excalidraw-color-dnd-active",k0=10,M0=100,A0=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=C0(e);return t!==null&&t===C0(n)},ih=TA(null),en=()=>SA(ih),L0=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=PA(null),i=S0(null),a=S0({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=T0(()=>{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 D=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((Z,H)=>Number(Z.dataset.topPickIndex)-Number(H.dataset.topPickIndex));if(!D.length)return!1;l.slotRects=D.map(Z=>Z.getBoundingClientRect());let[O,Y]=l.slotRects;l.slotSpan=Y?Y.left-O.left:O.width+4;let z=k.getBoundingClientRect(),W=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-W,right:z.right+W,top:z.top-14,bottom:z.bottom+14},!0},m=(k,D)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${D-l.ghostH/2}px)`)},p=(k,D,O,Y)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==D)&&(l.ghostW=k,l.ghostH=D,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${D}px`,m(O,Y))},u=(k,D)=>{if(!l)return;let{sourceRect:O,sourceEl:Y,color:z}=l,W=document.createElement("div");W.className=Lr;let Z=document.createElement("div");if(Z.className=`${Lr}__swatch`,kA(z))Z.classList.add("is-transparent");else{let H=getComputedStyle(Y).backgroundColor;Z.style.backgroundColor=H&&H!=="rgba(0, 0, 0, 0)"?H:z}W.appendChild(Z),document.body.appendChild(W),l.ghost=W,l.ghostW=O.width,l.ghostH=O.height,W.style.width=`${O.width}px`,W.style.height=`${O.height}px`,m(k,D),requestAnimationFrame(()=>{l?.ghost===W&&W.classList.add(`${Lr}--lifted`)}),document.body.classList.add(P0),l.activated=!0,c()},E=(k,D)=>{if(!l?.hitRect)return;let{hitRect:O,slotRects:Y}=l,z=null,W=null;if(k>=O.left&&k<=O.right&&D>=O.top&&D<=O.bottom){let Z=0,H=1/0;if(Y.forEach((re,B)=>{let U=Math.abs(k-(re.left+re.width/2));U<H&&(H=U,Z=B)}),l.origin.kind==="swatch"){let re=a.current.picks.findIndex(B=>A0(B,l.color));re!==-1?W=re:z=Z}else z=Z}if(z!==l.overIndex||W!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=W;let{ghost:Z}=l;Z&&(Z.classList.toggle(`${Lr}--over`,z!==null),Z.classList.toggle(`${Lr}--blocked`,W!==null)),c()}if(z!==null){let Z=l.slotRects[z];p(Z.width,Z.height,k,D)}else p(l.sourceRect.width,l.sourceRect.height,k,D)},g=k=>{if(!l?.ghost)return;let{ghost:D}=l;l.ghost=null,D.classList.add(`${Lr}--dropping`);let O=k.rect;O&&(D.style.width=`${O.width}px`,D.style.height=`${O.height}px`,D.style.transform=`translate(${O.left}px, ${O.top}px)`),window.setTimeout(()=>{D.classList.add(`${Lr}--fade`)},160),window.setTimeout(()=>{D.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let D=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let O of D)O.style.transition="none",O.style.transform="none";k.offsetWidth;for(let O of D)O.style.transition=""},y=()=>{let k=D=>{D.preventDefault(),D.stopPropagation()};window.addEventListener("click",k,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener("click",k,{capture:!0})},100)},w=()=>{window.removeEventListener("pointermove",C,!0),window.removeEventListener("pointerup",P,!0),window.removeEventListener("pointercancel",A,!0),window.removeEventListener("keydown",L,!0)},x=()=>{w(),document.body.classList.remove(P0),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},v=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},T=(k,D)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,D),E(k,D)}},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)<k0){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let D=performance.now()-l.startTime;if(D<M0){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=k0&&T(l.lastX,l.lastY))},M0-D));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(),y();let{overIndex:D,origin:O,color:Y,slotRects:z}=l,{picks:W,onPicksChange:Z}=a.current;if(b(),D!==null){if(O.kind==="swatch"){if(!W.some(H=>A0(H,Y))){let H=[...W];H[D]=Y,Z(H)}}else if(O.index!==D){let H=[...W],[re]=H.splice(O.index,1);H.splice(D,0,re),Z(H)}g({rect:z[D]})}else g({rect:l.sourceRect});x()},A=k=>{l&&k.pointerId===l.pointerId&&v(!0)},L=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),v(!0))};return{begin:(k,D,O)=>{!a.current.enabled||l||k.button!==0||!D||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:D,origin:O,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",A,!0),window.addEventListener("keydown",L,!0))},destroy:()=>v(!1)}},[]);return CA(()=>()=>s.destroy(),[s]),T0(()=>({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 ah,jsxs as RA}from"react/jsx-runtime";var D0=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=Fe(Qt),s=en(),l=LA(null);return AA(()=>{l.current&&l.current.focus()},[t,i]),ah("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=DA(c,e===_A.DARK);return RA("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:MA("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:[ah("div",{className:"color-picker__button-outline"}),ah(Pi,{color:m,keyLabel:d+1})]},d)})})};import NA from"clsx";import{useEffect as BA,useRef as OA}from"react";import{applyDarkModeFilter as FA,isColorDark as zA,THEME as HA}from"@excalidraw/common";import{jsx as Jc,jsxs as UA}from"react/jsx-runtime";var GA=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=Wo({color:t,palette:n}),[l,c]=Fe(Qt),d=en(),m=OA(null);return BA(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),Jc("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 Jc("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=ws[E],y=FA(g,e===HA.DARK),w=f(`colors.${p.replace(/\d+/,"")}`,null,"");return UA("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:NA("color-picker__button color-picker__button--large",{"has-outline":!zA(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:`${w}${g.startsWith("#")?` ${g}`:""} \u2014 ${b}`,"aria-label":`${w} \u2014 ${b}`,style:g?{"--swatch-color":y}:void 0,"data-testid":`color-${p}`,children:[Jc("div",{className:"color-picker__button-outline"}),i&&Jc(Pi,{color:y,keyLabel:b})]},p)})})},_0=GA;import{jsx as VA}from"react/jsx-runtime";var WA=({children:e})=>VA("div",{className:"color-picker__heading",children:e}),ki=WA;import YA from"clsx";import{useEffect as XA,useRef as KA}from"react";import{applyDarkModeFilter as ZA,THEME as $A}from"@excalidraw/common";import{jsx as vs,jsxs as R0}from"react/jsx-runtime";var N0=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=Wo({color:n||"transparent",palette:o}),[a,s]=Fe(Qt),l=en(),c=KA(null);if(XA(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return vs("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=ZA(u,e===$A.DARK);return R0("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:YA("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:[vs("div",{className:"color-picker__button-outline"}),r&&vs(Pi,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return R0("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[vs("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),vs("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 Mi,COLOR_PALETTE as jA,KEYS as Is}from"@excalidraw/common";var Qc=(e,n,t)=>{let o=Math.ceil(t/Mi);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+Mi;return r>=t?n%Mi:r}case"ArrowUp":{let r=n-Mi,i=r<0?Mi*o+r:r;return i>=t?void 0:i}}},qA=({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(ws.includes(e.key)){let l=ws.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},B0=({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[Is.CTRL_OR_CMD])return!1;if(e.key===Is.ESCAPE)return d(e),!0;if(e.key===Is.ALT)return c(!0),!0;if(e.key===Is.I)return c(),!0;let p=Wo({color:o,palette:t});if(e.key===Is.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[v,T])=>(T&&x.push(v),x),[]),g=E.indexOf(n),b=e.shiftKey?-1:1,y=g+b>E.length-1?0:g+b<0?E.length-1:g+b,w=E[y];return w&&a(w),w==="custom"?r(i[0]):w==="baseColors"&&(Object.entries(t).find(([v,T])=>Array.isArray(T)?T.includes(o):T===o?v:null)||r(jA.black)),e.preventDefault(),e.stopPropagation(),!0}if(qA({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=Qc(e.key,u,Mi);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=Qc(e.key,g,E.length),y=0;for(;b!==void 0&&y++<E.length;){let w=t[E[b]],x=Array.isArray(w)?w[l]:w;if(!m?.includes(x))break;b=Qc(e.key,b,E.length)}if(b!==void 0){let w=E[b],x=t[w];return r(Array.isArray(x)?x[l]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=Qc(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as mo,jsxs as ed}from"react/jsx-runtime";var F0=sh.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]=sh.useState(()=>o==="canvasBackground"?[]:x0(r,o,i)),[b,y]=Fe(Qt),w=en(),x=Wo({color:n,palette:i});lh(()=>{if(!b){let P=!!n&&th({color:n,palette:i}),A=P&&!g.includes(n);y(A?null:P?"custom":x?.shade!=null?"shades":"baseColors")}},[b,n,i,y,x,g]);let[v,T]=QA(x?.shade??(o==="elementBackground"?e5:t5));lh(()=>{x?.shade!=null&&T(x.shade);let P=A=>{A.key===n5.ALT&&c(!1)};return document.addEventListener(O0.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(O0.KEYUP,P,{capture:!0})}},[x,c]);let C=sh.useRef(null);return JA(u,()=>C.current),lh(()=>{C?.current?.focus()},[]),mo("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:ed("div",{ref:C,onKeyDown:P=>{B0({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:y,updateData:a,activeShade:v,onEscape:d,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&mo("div",{className:"color-picker__title",children:E}),!!g.length&&ed("div",{children:[mo(ki,{children:f("colorPicker.mostUsedCustomColors")}),mo(D0,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),ed("div",{children:[mo(ki,{children:f("colorPicker.colors")}),mo(_0,{theme:e,color:n,palette:i,onChange:t,activeShade:v,showHotKey:m,excludedColors:p})]}),ed("div",{children:[mo(ki,{children:f("colorPicker.shades")}),mo(N0,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,w&&mo("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import z0 from"clsx";import{ContextMenu as Ts}from"radix-ui";import{applyDarkModeFilter as o5,COLOR_OUTLINE_CONTRAST_THRESHOLD as r5,DEFAULT_CANVAS_BACKGROUND_PICKS as i5,DEFAULT_ELEMENT_BACKGROUND_PICKS as a5,DEFAULT_ELEMENT_STROKE_PICKS as s5,isColorDark as l5,THEME as c5}from"@excalidraw/common";import{jsx as Vo,jsxs as H0}from"react/jsx-runtime";var G0=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=en(),l=s?.dragState??null,{container:c}=De(),d;if(t==="elementStroke"&&(d=s5),t==="elementBackground"&&(d=a5),t==="canvasBackground"&&(d=i5),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=H0("div",{className:z0("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&Vo("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:Vo("rect",{})}),d.map((u,E)=>{let g=m(E),b=o5(u,e===c5.DARK);return Vo("button",{className:z0("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!l5(u,r5),"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?y=>s.startPickDrag(y,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:Vo("div",{className:"color-picker__button-outline"})},u)})]});return i?H0(Ts.Root,{children:[Vo(Ts.Trigger,{asChild:!0,children:p}),Vo(Ts.Portal,{container:c,children:Vo(Ts.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:Vo(Ts.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as tn,jsxs as td}from"react/jsx-runtime";var E5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=K0,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=De(),m=at(),p=m!=="full",u=m==="mobile",[,E]=Fe(Qt),[g,b]=Fe(Nt),y=td("div",{children:[tn(ki,{children:f("colorPicker.hexCode")}),tn(I0,{color:n||"",label:o,onChange:v=>{t(v)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),w=X0(null),x=()=>{w.current?.focus()};return tn(co,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:v=>{if(v.target instanceof HTMLElement&&v.target.closest(".color-picker__context-menu")){v.preventDefault();return}g5(v.target)||(v.target instanceof HTMLElement&&v.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),v.preventDefault()},onPointerDownOutside:v=>{g&&v.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let v=document.querySelector(".excalidraw-wysiwyg");v&&v.focus()},0)},children:i?tn(F0,{ref:w,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:v=>{let T=l.editingTextElement?qc():null;t(v),l.editingTextElement&&T&&bs(T)},onEyeDropperToggle:v=>{b(T=>v?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):v===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:v=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!u,children:y}):y})},b5=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=at(),l=s!=="full",c=s==="mobile",d=en(),m=n?p5(n,o===f5.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&b0(),i()};return td(V0.Trigger,{type:"button",className:Y0("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!W0(n,U0),"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:[tn("div",{className:"color-picker__button-outline",children:!n&&Lx}),l&&n&&r==="stroke"&&tn("div",{className:"color-picker__button-background",children:tn("span",{style:{color:m&&W0(m,U0)?"#fff":"#111"},children:Z1})})]})},w5=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=K0,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=X0(l.openPopup);m5(()=>{m.current=l.openPopup},[l.openPopup]);let u=at()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?h5:u5),y=L0({enabled:E,picks:b,onPicksChange:w=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:w}})}});return tn(ih.Provider,{value:E?y:null,children:td("div",{role:"dialog","aria-modal":"true",className:Y0("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&tn(G0,{theme:l.theme,activeColor:n,onChange:w=>{t(w),b5(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&&tn(Xc,{}),td(V0.Root,{open:l.openPopup===e,onOpenChange:w=>{w&&s({openPopup:e})},children:[tn(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&&tn(E5,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},y5=(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,Ai=d5(w5,y5);import{Popover as $5}from"radix-ui";import j5 from"clsx";import q5,{useCallback as J5,useMemo as Q5}from"react";import{FONT_FAMILY as ph}from"@excalidraw/common";import z5,{useMemo as Zo,useState as H5,useRef as q0,useEffect as J0,useCallback as Q0}from"react";import{arrayToList as G5,debounce as U5,FONT_FAMILY as $o,getFontFamilyString as W5}from"@excalidraw/common";import v5 from"clsx";import I5 from"react";import{jsx as T5,jsxs as S5}from"react/jsx-runtime";var nd=I5.forwardRef(({className:e,placeholder:n,onChange:t},o)=>S5("div",{className:v5("QuickSearch__wrapper",e),children:[Vn,T5("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import C5 from"clsx";import{Children as P5}from"react";import{jsx as Z0}from"react/jsx-runtime";var od=({className:e,placeholder:n,children:t})=>{let o=!P5.count(t);return Z0("div",{className:C5("ScrollableList__wrapper",e),role:"menu",children:o?Z0("div",{className:"empty",children:n}):t})};import{jsx as k5,jsxs as M5}from"react/jsx-runtime";var $0=({children:e,className:n="",style:t,title:o})=>M5("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&k5("p",{className:"dropdown-menu-group-title",children:o}),e]}),Ss=$0;$0.displayName="DropdownMenuGroup";import{THEME as O5}from"@excalidraw/common";import{DropdownMenu as F5}from"radix-ui";import A5,{useContext as L5}from"react";import{composeEventHandlers as D5}from"@excalidraw/common";var ch=A5.createContext({}),Yo=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),rd=e=>{let n=L5(ch);return D5(e,t=>{n.onSelect?.(t)})};import{jsx as _5}from"react/jsx-runtime";var Cs=({children:e,...n})=>_5("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as N5,jsx as Ps,jsxs as B5}from"react/jsx-runtime";var R5=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=ge();return B5(N5,{children:[n&&Ps("div",{className:"dropdown-menu-item__icon",children:n}),Ps("div",{style:e,className:"dropdown-menu-item__text",children:Ps(Cs,{children:o})}),r&&Ps("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Ps("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Xo=R5;import{jsx as id}from"react/jsx-runtime";var dh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=rd(s);return id(F5.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:id("button",{...l,value:t,className:Yo(i,a),title:l.title??l["aria-label"],children:id(Xo,{icon:e,shortcut:r,badge:n,children:o})})})};dh.displayName="DropdownMenuItem";var Li={GREEN:"green",RED:"red",BLUE:"blue"},ad=({type:e=Li.BLUE,children:n})=>{let{theme:t}=Ko(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===O5.LIGHT?"1.5px solid white":"none"};switch(e){case Li.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Li.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case Li.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return id("div",{className:"DropDownMenuItemBadge",style:o,children:n})};ad.displayName="DropdownMenuItemBadge";dh.Badge=ad;var Yt=dh;import{KEYS as Di}from"@excalidraw/common";var j0=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[Di.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Di.F)return n.current?.focus(),!0;if(e.key===Di.ESCAPE)return r(),!0;if(e.key===Di.ENTER)return t?.value&&i(t.value),!0;if(e.key===Di.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===Di.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as po,jsxs as X5}from"react/jsx-runtime";var V5=e=>{switch(e){case $o.Excalifont:case $o.Virgil:return Hn;case $o.Nunito:case $o.Helvetica:return gs;case $o["Lilita One"]:return x1;case $o["Comic Shanns"]:case $o.Cascadia:return Dc;default:return gs}},Y5=(e,n)=>Object.entries($o).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",ew=z5.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=De(),l=It(),{fonts:c}=l,{showDeprecatedFonts:d}=yn(),m=at(),[p,u]=H5(""),E=q0(null),g=Zo(()=>Array.from(ao.registered.entries()).filter(([k,{metadata:D}])=>!D.private&&!D.fallback).map(([k,{metadata:D,fontFaces:O}])=>{let Y={value:k,icon:V5(k),text:Y5(k,O)};return D.deprecated&&Object.assign(Y,{deprecated:D.deprecated,badge:{type:Li.RED,placeholder:f("fontList.badge.old")}}),Y}).sort((k,D)=>k.text.toLowerCase()>D.text.toLowerCase()?1:-1),[]),b=Zo(()=>new Set(c.getSceneFamilies()),[e]),y=Zo(()=>g.filter(k=>b.has(k.value)),[g,b]),w=Zo(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=Zo(()=>G5([...y,...w].filter(k=>k.text?.toLowerCase().includes(p))),[y,w,p]),v=Zo(()=>{let k;return n?k=x.find(D=>D.value===n):e&&(k=x.find(D=>D.value===e)),!k&&p&&(x[0]?.value?o(x[0].value):r()),k},[n,e,p,x,o,r]),T=Q0(k=>{let D=null;if(l.state.editingTextElement){let O=document.querySelector(".excalidraw-wysiwyg");O&&(D={start:O.selectionStart,end:O.selectionEnd})}t(k),l.state.editingTextElement&&D&&setTimeout(()=>{let O=document.querySelector(".excalidraw-wysiwyg");O&&D&&(O.focus(),O.selectionStart=D.start,O.selectionEnd=D.end)},0)},[t,l.state.editingTextElement]),C=Q0(k=>{j0({event:k,inputRef:E,hoveredFont:v,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[v,x,T,o,a]);J0(()=>(i(),()=>{a()}),[]);let P=Zo(()=>x.filter(k=>b.has(k.value)),[x,b]),A=Zo(()=>x.filter(k=>!b.has(k.value)),[x,b]),L=({font:k,order:D})=>{let O=q0(null),Y=k.value===v?.value,z=k.value===e;return J0(()=>{Y&&(D===0?O.current?.scrollIntoView?.({block:"end"}):O.current?.scrollIntoView?.({block:"nearest"}))},[Y,D]),po("button",{ref:O,type:"button",value:k.value,className:Yo("",z,Y),title:k.text,tabIndex:z?0:-1,onClick:W=>{T(Number(W.currentTarget.value))},onMouseMove:()=>{v?.value!==k.value&&o(k.value)},children:po(Xo,{icon:k.icon,badge:k.badge&&po(ad,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:W5({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(po(Ss,{title:f("fontList.sceneFonts"),children:P.map((k,D)=>po(L,{font:k,order:D},k.value))},"group_1")),A.length&&_.push(po(Ss,{title:f("fontList.availableFonts"),children:A.map((k,D)=>po(L,{font:k,order:D+P.length},k.value))},"group_2")),X5(co,{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"&&po(nd,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:U5(u,20)}),po(od,{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 K5}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as Z5}from"@excalidraw/common";import{jsx as mh}from"react/jsx-runtime";var tw=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Ue(),r=t?{...Z5,width:"2rem",height:"2rem"}:{};return mh(K5.Trigger,{asChild:!0,children:mh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:mh(K,{type:"toggle",icon:wn,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 ks,jsxs as nw}from"react/jsx-runtime";var ow=[{value:ph.Excalifont,icon:Hn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:ph.Nunito,icon:gs,text:f("labels.normal"),testId:"font-family-normal"},{value:ph["Comic Shanns"],icon:Dc,text:f("labels.code"),testId:"font-family-code"}],wee=new Set(ow.map(e=>e.value));var rw=q5.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=Q5(()=>ow,[]),c=J5(d=>{d&&o(d)},[o]);return nw("div",{role:"dialog","aria-modal":"true",className:j5("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&ks("div",{className:"buttonList",children:ks(Vt,{type:"button",options:l,value:n,onClick:c})}),!s&&ks(Xc,{}),nw($5.Root,{open:e,onOpenChange:a,children:[ks(tw,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&ks(ew,{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 uh}from"radix-ui";import o4 from"clsx";import lw,{useEffect as r4,useMemo as i4}from"react";import{isArrowKey as a4,KEYS as uo}from"@excalidraw/common";import{jsx as e4}from"react/jsx-runtime";var sd=({className:e,icon:n,size:t="1em"})=>e4("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 n4,jsx as iw,jsxs as aw}from"react/jsx-runtime";var t4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>aw(n4,{children:[aw("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&iw(sd,{icon:n?V1:Nc})]}),n&&iw("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),Ms=t4;import{jsx as Yn,jsxs as cd}from"react/jsx-runtime";var s4=qe(!1),ld=4,l4="default",c4=e=>e.flatMap(n=>n.options),sw=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},d4=(e,n)=>e.some(t=>t.options.some(n)),m4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/ld)},(t,o)=>n.options.slice(o*ld,o*ld+ld)));function p4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=De(),[s,l]=Fe(s4),c=[...e,...n],d=c4(c),m=m4([...e,...s?n:[]]),p=g=>{let b=d.find(y=>y.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===uo.TAB){let y=d.findIndex(x=>x.value===t),w=g.shiftKey?(d.length+y-1)%d.length:(y+1)%d.length;r(d[w].value)}else if(a4(g.key)){let y=zn().rtl,w=d.findIndex(x=>x.value===t);if(w!==-1){let x=d.length,v=w;switch(g.key){case(y?uo.ARROW_LEFT:uo.ARROW_RIGHT):v=(w+1)%x;break;case(y?uo.ARROW_RIGHT:uo.ARROW_LEFT):v=(x+w-1)%x;break;case uo.ARROW_DOWN:{let T=m.findIndex(P=>P.some(A=>A.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),A=m[(T+1)%m.length],L=A[Math.min(P,A.length-1)]??d[w];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case uo.ARROW_UP:{let T=m.findIndex(P=>P.some(A=>A.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),A=m[(m.length+T-1)%m.length],L=A[Math.min(P,A.length-1)]??d[w];r(L.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[v].value)}g.preventDefault()}else(g.key===uo.ESCAPE||g.key===uo.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};r4(()=>{d4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>Yn("div",{className:"picker-content",children:g.map(b=>cd("button",{type:"button",className:o4("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:y=>{t===b.value&&setTimeout(()=>{y?.focus()},0)},children:[b.icon,b.keyBinding&&Yn("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,y)=>b.name===l4?Yn(lw.Fragment,{children:u(b.options)},`${b.name}-${y}`):cd("div",{className:"picker-section",children:[Yn("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${y}`));return Yn(uh.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:p,collisionBoundary:a??void 0,children:cd("div",{className:"picker-sections",children:[E(e),n.length>0&&Yn(Ms,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:Yn("div",{className:"picker-sections",children:E(n)})})]})})}function hh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=lw.useState(!1),s=i4(()=>sw(t,l=>l.value===e)??sw(o??[],l=>l.value===e),[t,o,e]);return Yn("div",{children:cd(uh.Root,{open:i,onOpenChange:l=>a(l),children:[Yn(uh.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&Yn(p4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import cw,{useEffect as u4}from"react";import{jsx as gh,jsxs as dw}from"react/jsx-runtime";var mw=({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=cw.useRef(null),d=cw.useRef(null);return u4(()=>{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]),dw("label",{className:"control-label",children:[e,dw("div",{className:"range-wrapper",children:[gh("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}),gh("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),gh("div",{className:"zero-label",children:a})]})]})};import{Fragment as fd,jsx as Q,jsxs as ft}from"react/jsx-runtime";var yw=.1,_r=e=>{let n=F4(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Tt=(e,n,t,o=!1)=>{let r=wh(se(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(L4(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},lt=function(e,n,t,o,r){let i=n.state.editingTextElement,a=xw(e),s=null;if(i&&(s=t(i)),!s)if(Me(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=M4(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},z4=(e,n,t)=>_4(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}),yh=(e,n,t,o,r)=>{let i=new Set,a=Tt(e,n,s=>{if(Bt(s)){let l=o(s);i.add(l);let c=ot(s,{fontSize:l});return As(c,t.scene.getContainerElement(s),t.scene),c=z4(s,c,t.scene),c}return s},!0);return se(e,n,{includeBoundTextElement:!0}).forEach(s=>{Bt(s)&&D4(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:Qe.IMMEDIATELY}},H4=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Tt(e,n,o=>N4(o.type)?ot(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?Qe.IMMEDIATELY:Qe.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=_r(o);return ft(fd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.stroke")}),Q(Ai,{topPicks:w4,palette:x4,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:lt(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),G4=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:Qe.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!k4(t.currentItemBackgroundColor)&&i.every(s=>gw(s)&&A4(s.points))){let s=wh(i);r=e.map(l=>s.has(l.id)&&gw(l)?ot(l,{backgroundColor:t.currentItemBackgroundColor,...O4(l,!0)}):l)}else r=Tt(e,n,s=>ot(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:Qe.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=_r(o);return ft(fd,{children:[i==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ai,{topPicks:b4,palette:Ew,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:lt(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),gd=F({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:Qe.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=_r(o);return ft(fd,{children:[r==="full"&&Q("h3",{"aria-hidden":"true",children:f("labels.background")}),Q(Ai,{topPicks:f4,palette:Ew,excludedColors:[E4.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})]})}}),U4=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Ne("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Tt(e,n,r=>ot(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=se(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return ft("fieldset",{children:[Q("legend",{children:f("labels.fill")}),Q("div",{className:"buttonList",children:Q(Vt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?Gx:Ux,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:Wx,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:Vx,testId:"fill-solid"}],value:lt(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)}})})]})}}),W4=e=>T4.find(n=>bw(e.type,n)===e.strokeWidth)??null,V4=(e,n)=>bw(e.type,n),Y4=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(hd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Tt(e,n,o=>ot(o,{strokeWidth:V4(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:Au,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:Yx,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:Xx,testId:"strokeWidth-bold"}],value:lt(e,o,W4,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),X4=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>ot(o,{seed:S4(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:$x},{value:1,text:f("labels.artist"),icon:jx},{value:2,text:f("labels.cartoonist"),icon:qx}],value:lt(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),K4=F({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Tt(e,n,r=>r.type!=="freedraw"?r:ot(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:Qe.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=lt(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 Q(K,{type:"button",icon:a?Du:Lu,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return ft("fieldset",{children:[Q("legend",{children:f("labels.pressure")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:Lu},{value:"variable",text:f("labels.pressure_variable"),icon:Du}],value:i,onChange:a=>t(a)})})]})}}),Cte=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>ot(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>ft("fieldset",{children:[Q("legend",{children:f("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Au},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:Kx},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:Zx}],value:lt(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),Z4=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>ot(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=lt(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return Q(mw,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),$4=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>yh(e,n,o,()=>(hd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=_r(o);return ft("fieldset",{children:[Q("legend",{children:f("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"font-size",options:[{value:md.sm,text:f("labels.small"),icon:g1,testId:"fontSize-small"},{value:md.md,text:f("labels.medium"),icon:f1,testId:"fontSize-medium"},{value:md.lg,text:f("labels.large"),icon:E1,testId:"fontSize-large"},{value:md.xl,text:f("labels.veryLarge"),icon:b1,testId:"fontSize-veryLarge"}],value:lt(e,o,a=>{if(Bt(a))return a.fontSize;let s=jo(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Bt(a)||jo(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||v4),onChange:a=>{xs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),vh=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:kr,trackEvent:!1,perform:(e,n,t,o)=>yh(e,n,o,r=>Math.round(1/(1+yw)*r.fontSize)),keyTest:e=>e[_i.CTRL_OR_CMD]&&e.shiftKey&&(e.key===_i.CHEVRON_LEFT||e.key===_i.COMMA)}),Ih=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:kr,trackEvent:!1,perform:(e,n,t,o)=>yh(e,n,o,r=>Math.round(r.fontSize*(1+yw))),keyTest:e=>e[_i.CTRL_OR_CMD]&&e.shiftKey&&(e.key===_i.CHEVRON_RIGHT||e.key===_i.PERIOD)}),j4=F({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:Tt(e,n,g=>{let b=r?.get(g.id);return b?ot(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:Qe.NEVER};hd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=Qe.EVENTUALLY,m,p=!1;if(l)m=l,d=Qe.IMMEDIATELY;else if(c){m=c,d=Qe.EVENTUALLY;let E=se(e,n,{includeBoundTextElement:!0}).filter(g=>Bt(g));if(E.length>200)p=!0;else{let g=0,b=0;for(;g<E.length&&b<5e3;){let y=E[g];b+=y?.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,y=Array.from(ao.loadedFontsCache.values()),w=Object.entries(I4).find(([T,C])=>C===m)?.[0];c&&w&&y.some(T=>T.startsWith(w))&&(b=!0),Object.assign(u,{elements:Tt(e,n,T=>{if(Bt(T)&&(T.fontFamily!==m||l)){let C=ot(T,{fontFamily:m,lineHeight:P4(m)}),P=r?.get(T.containerId||"")||{},A=o.scene.getContainerElement(T);return a&&A&&P&&o.scene.mutateElement(A,{...P}),b||(g=new Set([...g,...Array.from(C.originalText)])),E.set(C,A),C}return T},!0)});let x=`10px ${C4({fontFamily:m})}`,v=Array.from(g.values()).join();if(b||window.document.fonts.check(x,v))for(let[T,C]of E)As(T,C,o.scene);else window.document.fonts.load(x,v).then(T=>{for(let[C,P]of E){let A=o.scene.getElement(C.id),L=P?o.scene.getElement(P.id):null;A&&As(A,L,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=Eh(new Map),i=Eh(null),[a,s]=g4({}),l=Eh(!0),{stylesPanelMode:c,isCompact:d}=_r(t),m=xh(()=>{let p=(u,E)=>lt(u,t,g=>{if(Bt(g))return g.fontFamily;let b=jo(g,E);return b?b.fontFamily:null},g=>Bt(g)||jo(g,E)!==null,g=>g?null:n.currentItemFontFamily||y4);return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?p(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?p(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]);return fh(()=>{i.current=m},[m]),fh(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),fh(()=>(l.current=!1,()=>{l.current=!0}),[]),ft(fd,{children:[c==="full"&&Q("legend",{children:f("labels.fontFamily")}),Q(rw,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{xs(()=>{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,ot(E||u,{},!0))}else{let E=se(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,ot(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&&bs(null)}}})]})}}),q4=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Tt(e,n,r=>{if(Bt(r)){let i=ot(r,{textAlign:t});return As(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=_r(o);return ft("fieldset",{children:[Q("legend",{children:f("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:w1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:y1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:v1,testId:"align-right"}],value:lt(e,o,s=>{if(Bt(s))return s.textAlign;let l=jo(s,i);return l?l.textAlign:null},s=>Bt(s)||jo(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{xs(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),J4=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Tt(e,n,r=>{if(Bt(r)){let i=ot(r,{verticalAlign:t});return As(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=_r(o);return Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Vt,{group:"text-align",options:[{value:dd.TOP,text:f("labels.alignTop"),icon:Q(I1,{theme:n.theme}),testId:"align-top"},{value:dd.MIDDLE,text:f("labels.centerVertically"),icon:Q(S1,{theme:n.theme}),testId:"align-middle"},{value:dd.BOTTOM,text:f("labels.alignBottom"),icon:Q(T1,{theme:n.theme}),testId:"align-bottom"}],value:lt(e,o,a=>{if(Bt(a)&&a.containerId)return a.verticalAlign;let s=jo(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Bt(a)||jo(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:dd.MIDDLE),onChange:a=>{xs(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),Pte=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Tt(e,n,o=>ww(o)?o:ot(o,{roundness:t==="round"?{type:R4(o.type)?pd.ADAPTIVE_RADIUS:pd.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=di(xw(e),n).some(s=>s.roundness?.type===pd.LEGACY);return ft("fieldset",{children:[Q("legend",{children:f("labels.edges")}),ft("div",{className:"buttonList",children:[Q(Vt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:Jx},{value:"round",text:f("labels.round"),icon:Qx}],value:lt(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!ud(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),fw=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Q(e1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(t1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:Q(n1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:Q(o1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:Q(r1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(i1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:Q(a1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:Q(s1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:Q(l1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:Q(c1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:Q(d1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:Q(m1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:Q(p1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:Q(u1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:Q(h1,{flip:e}),keyBinding:null}]}]}),kte=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(hd(t,"actionChangeArrowhead: value must be defined"),{elements:Tt(e,n,o=>{if(bh(o)){let{position:r,type:i}=t;if(r==="start")return ot(o,{startArrowhead:i});if(r==="end")return ot(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Qe.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=zn().rtl,i=xh(()=>fw(!r),[r]),a=xh(()=>fw(!!r),[r]);return ft("fieldset",{children:[Q("legend",{children:f("labels.arrowheads")}),ft("div",{className:"iconSelectList buttonList",children:[Q(hh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:lt(e,o,s=>bh(s)&&ns(s.type)?hw(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),Q(hh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:lt(e,o,s=>bh(s)&&ns(s.type)?hw(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),Q4=F({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})=>ft("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),Mte=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Tt(e,n,s=>{if(!ud(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=Dr.getPointAtIndexGlobalCoordinates(s,0,l),d=Dr.getPointAtIndexGlobalCoordinates(s,-1,l),m=ot(s,{x:t===nn.elbow?c[0]:s.x,y:t===nn.elbow?c[1]:s.y,roundness:t===nn.round?{type:pd.PROPORTIONAL_RADIUS}:null,elbowed:t===nn.elbow,angle:t===nn.elbow?0:s.angle,points:t===nn.elbow||s.elbowed?[Dr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Dr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if(ww(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=Dr.getPointAtIndexGlobalCoordinates(m,0,p),E=Dr.getPointAtIndexGlobalCoordinates(m,-1,p),g=m.startBinding&&p.get(m.startBinding.elementId),b=m.endBinding&&p.get(m.endBinding.elementId),y=g&&m.startBinding?{...m.startBinding,...uw(m,g,"start",p,n.isBindingEnabled)}:null,w=b&&m.endBinding?{...m.endBinding,...uw(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:y,endBinding:w,...B4(m,p,{points:[u,E].map(x=>h4(x[0]-m.x,x[1]-m.y)),startBinding:y,endBinding:w,fixedSegments:null})}}else{let p=o.scene.getNonDeletedElementsMap();if(m.startBinding){let u=p.get(m.startBinding.elementId);u&&pw(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&pw(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 Dr(s,wh(e)))}return{elements:r,appState:i,captureUpdate:Qe.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>ft("fieldset",{children:[Q("legend",{children:f("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Vt,{group:"arrowtypes",options:[{value:nn.sharp,text:f("labels.arrowtype_sharp"),icon:zo,testId:"sharp-arrow"},{value:nn.round,text:f("labels.arrowtype_round"),icon:Go,testId:"round-arrow"},{value:nn.elbow,text:f("labels.arrowtype_elbowed"),icon:Ho,testId:"elbow-arrow"}],value:lt(e,o,r=>ud(r)?r.elbowed?nn.elbow:r.roundness?nn.round:nn.sharp:null,r=>ud(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as a6,MAX_ZOOM as s6,MIN_ZOOM as l6,THEME as Ls,ZOOM_STEP as Tw,CODES as Rr,KEYS as bd}from"@excalidraw/common";import{getNonDeletedElements as Ds}from"@excalidraw/element";import{getCommonBounds as _s}from"@excalidraw/element";import{CaptureUpdateAction as Bi}from"@excalidraw/element";import{useEffect as e6}from"react";import{jsx as n6}from"react/jsx-runtime";var Ri=()=>{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},Th=(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`})},t6=(e,n,t,o)=>{n.classList.add("excalidraw-tooltip--visible"),n.style.minWidth=o?"50ch":"10ch",n.style.maxWidth=o?"50ch":"15ch",n.textContent=t;let r=e.getBoundingClientRect();Th(n,r)},ct=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(e6(()=>()=>Ri().classList.remove("excalidraw-tooltip--visible"),[]),r?null:n6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>t6(i.currentTarget,Ri(),n,t),onPointerLeave:()=>Ri().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as vw,useRef as Iw,useState as o6}from"react";var r6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Sh=(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},Ro())}return r6(o,n)};function Ni(e,n=!0){let t=Ed(),[,o]=o6(0),r=Iw(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Sh(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Sh(t,e,n)),vw(()=>{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 i6(e,n){let t=Ed(),o=Iw({selector:e,callback:n});o.current.selector=e,o.current.callback=n,vw(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Sh(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Id,jsxs as m6}from"react/jsx-runtime";var c6=F({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?Bi.IMMEDIATELY:Bi.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Id(Ai,{palette:null,topPicks:a6,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})}),xd=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:uu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...io({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:On(n.zoom.value+Tw)},n)},captureUpdate:Bi.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Id(K,{type:"button",className:"zoom-in-button zoom-button",icon:uu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=s6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Rr.EQUAL||e.code===Rr.NUM_ADD)&&(e[bd.CTRL_OR_CMD]||e.shiftKey)}),wd=F({name:"zoomOut",label:"buttons.zoomOut",icon:hu,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...io({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:On(n.zoom.value-Tw)},n)},captureUpdate:Bi.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Id(K,{type:"button",className:"zoom-out-button zoom-button",icon:hu,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=l6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===Rr.MINUS||e.code===Rr.NUM_SUBTRACT)&&(e[bd.CTRL_OR_CMD]||e.shiftKey)}),yd=F({name:"resetZoom",label:"buttons.resetZoom",icon:Ix,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?.lockZoom?n.scrollConstraints.zoom:1;return{appState:{...n,...io({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:On(r)},n)},captureUpdate:Bi.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=Ni(t=>t.zoom.value);return Id(ct,{label:f("buttons.resetZoom"),style:{height:"100%"},children:m6(K,{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===Rr.ZERO||e.code===Rr.NUM_ZERO)&&(e[bd.CTRL_OR_CMD]||e.shiftKey)}),Ch=e=>[e.x,e.y,e.x+e.width,e.y+e.height],ane=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Rc,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(Ds(r)):n.scrollConstraints?Ch(n.scrollConstraints):_s(Ds(e)),a=Ir({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Bn(a.appState)}}},keyTest:void 0}),sne=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Rc,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(Ds(r)):n.scrollConstraints?Ch(n.scrollConstraints):_s(Ds(e)),a=Ir({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...Bn(a.appState)}}},keyTest:void 0}),d6=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Rc,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?Ch(n.scrollConstraints):_s(Ds(e)),i=Ir({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...Bn(i.appState)}}},keyTest:void 0}),vd=F({name:"toggleTheme",label:(e,n)=>n.theme===Ls.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===Ls.LIGHT?ms:ps,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===Ls.LIGHT?Ls.DARK:Ls.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:Bi.EVENTUALLY}},keyTest:e=>!e[bd.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===Rr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as w6}from"@excalidraw/math";import{bindOrUnbindBindingElement as Nw}from"@excalidraw/element/binding";import{isValidPolygon as Bw,newElementWith as Mh}from"@excalidraw/element";import{LinearElementEditor as Fs}from"@excalidraw/element/linearElementEditor";import{isBindingElement as Ah,isFreeDrawElement as Ow,isLinearElement as Fw,isLineElement as Ad}from"@excalidraw/element";import{KEYS as Ld,arrayToMap as y6,invariant as zw,shouldRotateWithDiscreteAngle as v6,updateActiveTool as Hw}from"@excalidraw/common";import{isPathALoop as I6}from"@excalidraw/element";import{isInvisiblySmallElement as Lh}from"@excalidraw/element";import{CaptureUpdateAction as Dh}from"@excalidraw/element";import g6 from"clsx";import{useEffect as f6,useState as E6}from"react";import{KEYS as on,capitalizeString as Nr}from"@excalidraw/common";import{useEffect as p6,useState as u6}from"react";import Sw from"clsx";import{capitalizeString as Td}from"@excalidraw/common";import{Popover as Ph}from"radix-ui";import{jsx as Sd,jsxs as h6}from"react/jsx-runtime";var Oi=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=u6(!1),c=t.type,d=a.type===c,m=16,{container:p}=De();return!n.some(u=>u.type===c)&&s&&l(!1),p6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),h6(Ph.Root,{open:s,children:[Sd(Ph.Trigger,{asChild:!0,children:Sd(K,{className:Sw({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>Ze(e,u.type)),title:Td(a.title),"aria-label":Td(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Sd(Ph.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Sd(K,{className:Sw({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:Ze(e,u),title:Td(u),"aria-label":Td(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Ne("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as kh}from"react/jsx-runtime";var b6=e=>e,We=b6({hand:{icon:C1,letterKey:on.H,toggle:!0},selection:{icon:Cc,letterKey:on.V,fillable:!0},rectangle:{icon:Ei,letterKey:on.R,fillable:!0},diamond:{icon:bi,letterKey:on.D,fillable:!0},ellipse:{icon:xi,letterKey:on.O,fillable:!0},arrow:{icon:Pc,letterKey:on.A,fillable:!0},line:{icon:Bo,letterKey:on.L,fillable:!0},freedraw:{icon:Hn,letterKey:on.P},text:{icon:wn,letterKey:on.T},image:{icon:Cr},eraser:{icon:kc,letterKey:on.E,toggle:!0},frame:{icon:Un,letterKey:on.F},autoshape:{icon:Mr,letterKey:on.X,fillable:!1},embeddable:{icon:Oo},laser:{icon:Wn},bucketfill:{icon:Gn},lasso:{icon:fi,fillable:!1}});var Fi=["autoshape","rectangle","diamond","ellipse","arrow","line"],zi=Object.keys(We).filter(e=>We[e].toggle),Cd=e=>{let{letterKey:n,shiftKey:t}=We[e];if(!n)return n;let o=Nr(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},Hi=e=>Cd(e),x6=e=>{let n=Cd(e);return n?.length===1?n:void 0},Cw=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(We)){let{letterKey:i,shiftKey:a}=We[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},Ze=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Ot=(e,n)=>{let t=We[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=Nr(f(`toolBar.${e}`)),d=l?null:Hi(o);return kh(K,{className:g6({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:Ze(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&&(Ne("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Nr(e)}IconButton`,r},Pd=Ot("hand"),Pw=Ot("rectangle"),kw=Ot("diamond"),Mw=Ot("ellipse"),Aw=Ot("arrow"),Lw=Ot("line"),Rs=Ot("freedraw"),Ns=Ot("text"),Bs=Ot("image"),Os=Ot("eraser"),Dw=Ot("frame"),Nne=Ot("autoshape"),_w=Ot("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Ne("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),Rw=Ot("lasso",{shortcutType:"selection"}),kd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:We.selection.icon,fillable:We.selection.fillable,title:Nr(f("toolBar.selection"))},{type:"lasso",icon:We.lasso.icon,fillable:We.lasso.fillable,title:Nr(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return kh(Oi,{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})},Md=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:We.freedraw.icon,fillable:We.freedraw.fillable,title:Nr(f("toolBar.freedraw"))},{type:"autoshape",icon:We.autoshape.icon,fillable:We.autoshape.fillable,title:Nr(f("toolBar.autoshape"))}],[o,r]=E6(n.type==="autoshape"?"autoshape":"freedraw");f6(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return kh(Oi,{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 T6}from"react/jsx-runtime";var dt=F({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:y}=t,w=Fs.getElement(n.selectedLinearElement.elementId,l);zw(w,"Arrow element should exist if selectedLinearElement is set"),zw(y,"sceneCoords should be defined if actionFinalize is called with event");let x=Fs.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(Ah(w)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let v=!!n.newElement,T=v||!n.selectedLinearElement.selectedPointsIndices?[w.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=v6(b),P=b[Ld.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),A=T.reduce((L,_)=>(L.set(_,{point:C?w.points[_]:Fs.createPointAt(w,l,y.x-x.pointerOffset.x,y.y-x.pointerOffset.y,P)}),L),new Map)??new Map;Nw(w,A,y.x,y.y,s,n,{newArrow:v,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else Ad(w)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!Bw(w.points)&&s.mutateElement(w,{polygon:!1});if(x!==n.selectedLinearElement){w&&Lh(w)&&(i=i.map(T=>T.id===w.id?Mh(T,{isDeleted:!0}):T));let v=n.activeTool?.locked;return{elements:w.points.length<2||Lh(w)?e.map(T=>T.id===w.id?Mh(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:v||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:Dh.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"||Ah(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:y}=n.selectedLinearElement;if((!y||b[b.length-1]!==y)&&(r=!1,s.mutateElement(m,{points:m.points.slice(0,-1)}),Ah(m)&&m.endBinding&&m.points.length>1)){let w=!!n.newElement,x=new Map([[m.points.length-1,{point:m.points[m.points.length-1],isDragging:!1}]]),v=Fs.getPointAtIndexGlobalCoordinates(m,-1,l);Nw(m,x,v[0],v[1],s,n,{newArrow:w})}}if(m&&Lh(m)&&(i=i.map(b=>b.id===m?.id?Mh(b,{isDeleted:!0}):b)),Fw(m)||Ow(m)){if(I6(m.points,n.zoom.value)&&(Ad(m)||Ow(m))){let y=m.points,w=y[0],x=y.map((v,T)=>T===y.length-1?w6(w[0],w[1]):v);Ad(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}Ad(m)&&!Bw(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;zi.includes(n.activeTool.type)?p=Hw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=Hw(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&&Fw(m)?new Fs(m,y6(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?Dh.IMMEDIATELY:Dh.NEVER}},keyTest:(e,n)=>e.key===Ld.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===Ld.ESCAPE||e.key===Ld.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>T6(K,{type:"button",icon:Rx,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:n,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as Ww,isSomeElementSelected as S6,makeNextSelectedElementIds as C6,selectGroupsForSelectedElements as P6}from"@excalidraw/element";import{CaptureUpdateAction as Gw}from"@excalidraw/element";import{KEYS as k6,isWritableElement as M6,updateActiveTool as Uw}from"@excalidraw/common";var A6=(e,n)=>zi.includes(e.activeTool.type)?Uw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):Uw(e,{type:n.state.preferredSelectionTool.type}),L6=(e,n,t)=>{if(!e.editingGroupId)return null;let o=n.scene.getNonDeletedElements(),r=n.scene.getSelectedElements({selectedElementIds:t,elements:o}),i=r.length?r:Ww(o,e.editingGroupId);for(let a of i){let s=a.groupIds.indexOf(e.editingGroupId);if(s!==-1&&a.groupIds[s+1])return a.groupIds[s+1]}return null},D6=F({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=A6(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:Ww(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...P6({editingGroupId:L6(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:Gw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:C6({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Gw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==k6.ESCAPE||M6(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||S6(o.scene.getNonDeletedElements(),n))});import{KEYS as zd,THEME as Us}from"@excalidraw/common";import{CaptureUpdateAction as vn}from"@excalidraw/element";import _6 from"clsx";import{jsx as Vw,jsxs as R6}from"react/jsx-runtime";var _h=({children:e,checked:n,onChange:t,className:o})=>R6("div",{className:_6("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[Vw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:Mc}),Vw("div",{className:"Checkbox-label",children:e})]});import{THEME as zs}from"@excalidraw/common";import{jsx as Hs}from"react/jsx-runtime";var Xw=e=>{let n=e.title||(e.value===zs.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return Hs(K,{type:"icon",icon:e.value===zs.LIGHT?Yw.MOON:Yw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===zs.DARK?zs.LIGHT:zs.DARK),"data-testid":"toggle-dark-mode"})},Yw={SUN:Hs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Hs("path",{fill:"currentColor",d:"M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z"})}),MOON:Hs("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Hs("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};import{useState as N6}from"react";import{focusNearestParent as B6,KEYS as O6}from"@excalidraw/common";import{jsx as Kw,jsxs as F6}from"react/jsx-runtime";var Zw=e=>{let{id:n}=De(),[t,o]=N6(e.value),r=a=>{e.ignoreFocus||B6(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===O6.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return F6("div",{className:"ProjectName",children:[Kw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Kw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as z6,useEffect as H6,useRef as G6}from"react";import{jsx as Dd,jsxs as Y6}from"react/jsx-runtime";var U6=5e3,W6=({progress:e})=>Dd("div",{className:"Toast__progress-bar",children:Dd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),V6=({message:e,onClose:n,closable:t=!1,duration:o=U6,style:r})=>{let i=G6(0),a=o!==1/0,s=z6(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return H6(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),Y6("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Dd("div",{className:"Toast__message",children:e}),t&&Dd(K,{icon:Jt,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},_d=Object.assign(V6,{ProgressBar:W6});import{DEFAULT_EXPORT_PADDING as cL,DEFAULT_FILENAME as dL,IMAGE_MIME_TYPES as ey,isFirefox as mL,MIME_TYPES as pL,cloneJSON as uL,SVG_DOCUMENT_PREAMBLE as hL,arrayToMap as gL}from"@excalidraw/common";import{getNonDeletedElements as fL}from"@excalidraw/element";import{isFrameLikeElement as EL}from"@excalidraw/element";import{getElementsOverlappingFrame as bL}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as X6,EXPORT_DATA_TYPES as Gs,MIME_TYPES as mt,arrayToMap as K6,isMemberOf as Z6,isPromiseLike as $6,EVENT as Rd}from"@excalidraw/common";import{mutateElement as j6}from"@excalidraw/element";import{deepCopyElement as q6}from"@excalidraw/element";import{isFrameLikeElement as J6,isInitializedImageElement as Q6}from"@excalidraw/element";import{getContainingFrame as $w}from"@excalidraw/element";var Qoe="clipboard"in navigator&&"readText"in navigator.clipboard,Nd="clipboard"in navigator&&"writeText"in navigator.clipboard,qo="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,eL=e=>!!([Gs.excalidraw,Gs.excalidrawClipboard,Gs.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),jw=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(Rd.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},tL=({elements:e,files:n})=>{let t=K6(e),o=new Set(e.filter(s=>J6(s))),r=!1,i=e.reduce((s,l)=>(Q6(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:Gs.excalidrawClipboard,elements:e.map(s=>{if($w(s,t)&&!o.has($w(s,t))){let l=q6(s);return j6(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},Bd=async(e,n,t)=>{let o=tL({elements:e,files:n});await ho({[mt.excalidrawClipboard]:o,[mt.text]:o},t)};function qw(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(qw(t));return n}var nL=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,mt.html),o=qw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Jw=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{[mt.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(Z6(X6,o))try{if(o===mt.text||o===mt.html)e[o]=await(await t.getType(o)).text();else if(ex(o)){let r=await t.getType(o),i=sx(r,o,void 0);e[o]=i}else throw new lu(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof lu?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},oL=async(e,n=!1)=>{try{let t=e.findByType(mt.html),o=!n&&t&&nL(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(mt.text)??o.value.map(r=>r.value).join(`
2
+ `).trim()}:o:{type:"text",value:(e.getData(mt.text)||"").trim()}}catch{return{type:"text",value:""}}},rL=function(e){return this.find(n=>n.type===e)||null},iL=function(e){return this.find(t=>t.type===e)?.value??null},aL=function(){return this.filter(e=>e.kind==="file")},Rh=e=>{let n=Bh(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),mt.text,mt.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}},sL=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}}),Nh=(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===mt.html)try{let E=new DOMParser().parseFromString(u.value,mt.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===mt.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:sL(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},Qw=e=>{let n;Bh(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},Br=async e=>{let n;Bh(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 ax(o);return r=await ui(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:rL,getData:iL,getFiles:aL})},Od=async(e,n=!1)=>{let t=await oL(e,n);if(t.type==="mixedContent")return{mixedContent:t.value};try{let o=JSON.parse(t.value),r=o.type===Gs.excalidrawClipboardWithAPI;if(eL(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}},Fd=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[mt.png]:e})])}catch(n){if($6(e))await navigator.clipboard.write([new ClipboardItem({[mt.png]:await e})]);else throw n}},ho=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[mt.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===mt.text);if(Nd&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!lL(o[1]))throw new Error("Error copying to clipboard.")},lL=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},Bh=e=>e.type===Rd.PASTE||e.type===Rd.COPY||e.type===Rd.CUT;var Or=(e,{selectedElementIds:n},t)=>{let o=fL(e),r=gL(o),i=t&&Me(o,{selectedElementIds:n}),a=null,s=i?se(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&EL(l)?(a=l,s=bL(o,l,r)):s.length>1&&(s=se(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:uL(s)}},Fr=async(e,n,t,o,{exportBackground:r,exportPadding:i=cL,viewBackgroundColor:a,name:s=t.name||dL,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Tr(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 cu(m.then(p=>new Blob([hL+p.outerHTML],{type:pL.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[ey.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await ho(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let d=xc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=ls(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-OSFJHW22.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:rs(n,t,o,"local")})))),cu(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[ey.png],fileHandle:l})}else if(e==="clipboard")try{let m=ls(d);await Fd(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):mL&&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 ny=async(e,n,t)=>{let o=tx(n);if(!nx(o))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:r,appState:i,files:a}=await e,{exportBackground:s,viewBackgroundColor:l}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:d}=Or(r,i,!1);return await Fr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as yL,jsx as Jo,jsxs as ay}from"react/jsx-runtime";var Hh=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>Jo($w,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),oy=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:vn.EVENTUALLY})}),Gh=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Jo(Nh,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),Wd=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>ay(Nh,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),Jo(ct,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:Jo("div",{className:"excalidraw-tooltip-icon",children:Fx})})]})}),Gi=!1,zh=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?ay(yL,{children:[t,Jo(Bd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function wL(e,n){if(n.app.state.isLoading&&(zh(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")zh(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(zh(n.app,{progress:null}),await e)}function ry(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await wL(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 zr=O({name:"saveToActiveFile",label:"buttons.save",icon:us,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(Gi)return!1;Gi=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=ry(e,n,o.files,o);try{let{fileHandle:l}=yc(r)?await ny(s,r,i):await fc({data:s,filename:i,fileHandle:r});return{captureUpdate:vn.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:vn.NEVER,appState:{toast:null}}}finally{Gi=!1}},keyTest:e=>!1}),Ws=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:us,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(Gi)return!1;Gi=!0;let{abortController:r,data:i}=ry(e,n,o.files,o);try{let{fileHandle:a}=await fc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:vn.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:vn.NEVER,appState:{toast:null}}}finally{Gi=!1}},keyTest:e=>e.key.toLowerCase()===Ud.S&&e.shiftKey&&e[Ud.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Jo(K,{type:"button",icon:_x,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:ge().formFactor==="phone",hidden:!mi,onClick:()=>e(null),"data-testid":"save-as-button"})}),Ui=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:vn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:vn.EVENTUALLY}}},keyTest:e=>e[Ud.CTRL_OR_CMD]&&e.key===Ud.O}),iy=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?Us.DARK:Us.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Jo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Jo(Kw,{value:e.exportWithDarkMode?Us.DARK:Us.LIGHT,onChange:t=>{n(t===Us.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as vL,DEFAULT_FONT_FAMILY as IL,DEFAULT_TEXT_ALIGN as TL,getLineHeight as SL}from"@excalidraw/common";import{newElementWith as Vd}from"@excalidraw/element";import{hasBoundTextElement as CL,canApplyRoundnessTypeToElement as PL,getDefaultRoundnessTypeForElement as kL,isFrameLikeElement as ML,isArrowElement as AL,isExcalidrawElement as LL,isTextElement as sy}from"@excalidraw/element";import{getBoundTextElement as DL,redrawTextBoundingBox as _L}from"@excalidraw/element";import{CaptureUpdateAction as Uh}from"@excalidraw/element";var ly="{}",RL=O({name:"copyStyles",label:"labels.copyStyles",icon:Ou,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&CL(i)){let a=DL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(ly=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:Uh.EVENTUALLY}}}),NL=O({name:"pasteStyles",label:"labels.pasteStyles",icon:Ou,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(ly),i=r[0],a=r[1];if(!LL(i))return{elements:e,captureUpdate:Uh.EVENTUALLY};let s=ie(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(sy(c)&&c.containerId&&(d=a),!d)return c;let m=Vd(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?PL(d.roundness.type,c)?d.roundness:kL(c):null});if(sy(m)){let p=d.fontSize||vL,u=d.fontFamily||IL,E=Vd(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||TL,lineHeight:d.lineHeight||SL(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),_L(E,g,o.scene)}return m.type==="arrow"&&AL(d)&&(m=Vd(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),ML(c)&&(m=Vd(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:Uh.IMMEDIATELY}}});import{KEYS as BL}from"@excalidraw/common";import{CaptureUpdateAction as OL}from"@excalidraw/element";var Hr=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:OL.EVENTUALLY}),keyTest:e=>e.key===BL.QUESTION_MARK});import{getNonDeletedElements as Xd}from"@excalidraw/element";import{newElementWith as dy}from"@excalidraw/element";import{isBoundToContainer as FL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as zL,getElementsInResizingFrame as HL,getFrameLikeElements as GL,getRootElements as UL,groupByFrameLikes as WL,removeElementsFromFrame as VL,replaceAllElementsInFrame as YL}from"@excalidraw/element";import{KEYS as Kd,randomId as XL,arrayToMap as Vh}from"@excalidraw/common";import{getSelectedGroupIds as Yd,selectGroup as KL,selectGroupsForSelectedElements as ZL,getElementsInGroup as cy,addToGroup as $L,removeFromSelectedGroups as jL,isElementInGroup as my}from"@excalidraw/element";import{syncMovedIndices as qL}from"@excalidraw/element";import{CaptureUpdateAction as Vs}from"@excalidraw/element";import{jsx as Wi}from"react/jsx-runtime";var JL=(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=>my(i,r)))return!0}return!1},Wh=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!JL(t,e.editingGroupId)&&!zL(t)},Yh=O({name:"group",label:"labels.group",icon:e=>Wi(Au,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!Wh(n,o))return!1;let r=UL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:Vs.EVENTUALLY};let i=Yd(n);if(i.length===1){let b=i[0],y=new Set(cy(e,b).map(v=>v.id)),w=new Set(r.map(v=>v.id));if(new Set([...Array.from(y),...Array.from(w)]).size===y.size)return{appState:n,elements:e,captureUpdate:Vs.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&WL(r).forEach((y,w)=>{VL(y,o.scene.getNonDeletedElementsMap())});let l=XL(),c=Vh(r);a=a.map(b=>c.get(b.id)?dy(b,{groupIds:$L(b.groupIds,l,n.editingGroupId)}):b);let d=cy(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!my(b,l)),g=qL([...E,...d,...u],Vh(d));return{appState:{...n,...KL(l,{...n,selectedGroupIds:{}},Xd(a))},elements:g,captureUpdate:Vs.IMMEDIATELY}},predicate:(e,n,t,o)=>Wh(n,o),keyTest:e=>!e.shiftKey&&e[Kd.CTRL_OR_CMD]&&e.key===Kd.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Wi(K,{hidden:!Wh(n,o),type:"button",icon:Wi(Au,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Me(Xd(e),n)})}),Xh=O({name:"ungroup",label:"labels.ungroup",icon:e=>Wi(Lu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=Yd(n),i=Vh(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:Vs.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{FL(p)&&s.push(p.id);let u=jL(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:dy(p,{groupIds:u})});let l=ZL(n,Xd(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return GL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=YL(a,HL(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:Vs.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Kd.CTRL_OR_CMD]&&e.key===Kd.G.toUpperCase(),predicate:(e,n)=>Yd(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>Wi(K,{type:"button",hidden:Yd(n).length===0,icon:Wi(Lu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Me(Xd(e),n)})});import iD from"clsx";import{CaptureUpdateAction as fy}from"@excalidraw/element";import{invariant as aD}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as QL,COLOR_VOICE_CALL as eD,COLOR_WHITE as $d,THEME as tD,UserIdleState as py}from"@excalidraw/common";var Zd=(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 nD(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 Gr=(e,n)=>`hsl(${Math.abs(nD(n?.id||e))%37*10}, 100%, 83%)`,uy=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},hy=({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=Gr(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===py.IDLE||E===py.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===tD.DARK?"#2f6330":eD,y=c?.isSpeaking;y&&(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=$d,e.strokeStyle=$d,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 w=n.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let x=(y?s+0:s)+d/2,v=(y?l+0:l)+m+2,T=5,C=3,P=e.measureText(w),A=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,L=Math.max(A,12),_=x-1,k=v-1,D=P.width+2+T*2+2,F=L+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,D,F,8),e.fillStyle=u,e.fill(),e.strokeStyle=$d,e.stroke(),y&&(e.beginPath(),e.roundRect(_-2,k-2,D+4,F+4,8),e.strokeStyle=b,e.stroke())):Zd(e,_,k,D,F,8,$d),e.fillStyle=QL,e.fillText(w,x+T+1,v+C+P.actualBoundingBoxAscent+Math.floor((L-A)/2)+2),y){e.fillStyle=b;let Y=8,z=8,W=5;e.fillRect(_+D+z,k+(F/2-Y/2),2,Y),e.fillRect(_+D+z+W,k+(F/2-Y*2/2),2,Y*2),e.fillRect(_+D+z+W*2,k+(F/2-Y/2),2,Y)}}e.restore(),e.closePath()}};import oD from"clsx";import{useState as rD}from"react";import{jsx as gy}from"react/jsx-runtime";var Kh=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=uy(t),[a,s]=rD(!1),l=!a&&o,c=l?void 0:{background:e};return gy("div",{className:oD("Avatar",r),style:c,onClick:n,children:l?gy("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as Yn,jsxs as jd}from"react/jsx-runtime";var sD=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(aD(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:fy.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:fy.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=Gr(o,r),l=iD({"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?jd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[Yn("div",{}),Yn("div",{}),Yn("div",{})]}):r.isMuted?Yn("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:B1}):Yn("div",{title:f("userList.hint.inCall"),children:N1}):null;return i?jd("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:[Yn(Kh,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),Yn("div",{className:"UserList__collaborator-name",children:r.username}),jd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Yn("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Ar}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):jd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[Yn(Kh,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&Yn("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as Vi}from"@excalidraw/element";import{isFrameLikeElement as lD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as cD}from"@excalidraw/element";import{KEYS as Qo,arrayToMap as dD}from"@excalidraw/common";import{alignElements as mD}from"@excalidraw/element";import{CaptureUpdateAction as Yi}from"@excalidraw/element";import{getSelectedElementsByGroup as pD}from"@excalidraw/element";import{jsx as Ki}from"react/jsx-runtime";var pt=(e,n)=>{let t=n.scene.getSelectedElements(e);return pD(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>lD(o))},Xi=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=mD(r,o,t.scene,n),a=dD(i);return cD(e.map(s=>a.get(s.id)||s),n,t)},uD=O({name:"alignTop",label:"labels.alignTop",icon:Tu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"start",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Tu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Me(Vi(e),n)})}),hD=O({name:"alignBottom",label:"labels.alignBottom",icon:Su,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"end",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Su,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Me(Vi(e),n)})}),gD=O({name:"alignLeft",label:"labels.alignLeft",icon:Cu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"start",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Cu,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Me(Vi(e),n)})}),fD=O({name:"alignRight",label:"labels.alignRight",icon:Pu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"end",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Pu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Me(Vi(e),n)})}),ED=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:ku,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"center",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:ku,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Me(Vi(e),n)})}),bD=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Mu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"center",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Mu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Me(Vi(e),n)})});import{getNonDeletedElements as Ey}from"@excalidraw/element";import{isFrameLikeElement as xD}from"@excalidraw/element";import{CODES as by,KEYS as xy,arrayToMap as wD}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as yD}from"@excalidraw/element";import{distributeElements as vD}from"@excalidraw/element";import{CaptureUpdateAction as wy}from"@excalidraw/element";import{getSelectedElementsByGroup as ID}from"@excalidraw/element";import{jsx as Iy}from"react/jsx-runtime";var yy=(e,n)=>{let t=n.scene.getSelectedElements(e);return ID(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>xD(o))},vy=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=vD(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=wD(i);return yD(e.map(s=>a.get(s.id)||s),n,t)},TD=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:vy(e,n,o,{space:"between",axis:"x"}),captureUpdate:wy.IMMEDIATELY}),keyTest:e=>!e[xy.CTRL_OR_CMD]&&e.altKey&&e.code===by.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Iy(K,{hidden:!yy(n,o),type:"button",icon:Ux,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Me(Ey(e),n)})}),SD=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:vy(e,n,o,{space:"between",axis:"y"}),captureUpdate:wy.IMMEDIATELY}),keyTest:e=>!e[xy.CTRL_OR_CMD]&&e.altKey&&e.code===by.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Iy(K,{hidden:!yy(n,o),type:"button",icon:Wx,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Me(Ey(e),n)})});import{arrayToMap as Ty,KEYS as PD,matchKey as kD}from"@excalidraw/common";import{CaptureUpdateAction as MD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as AD}from"@excalidraw/element/frame";import{arrangeElements as LD}from"@excalidraw/element/arrange";var CD={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},Zi=(e,n)=>({smartZoom:{...CD,...n?.smartZoom},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as ND}from"react/jsx-runtime";var DD=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Ty(e),{arrange:i}=Zi(n,t.props.editorPreferences),a=LD(t.scene,o,r,i.algorithm,i.gap),s=Ty(a);return AD(e.map(l=>s.get(l.id)||l),n,t)},_D=pt,RD=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:zu,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>_D(n,o),perform:(e,n,t,o)=>({appState:n,elements:DD(e,n,o),captureUpdate:MD.IMMEDIATELY}),keyTest:e=>e.shiftKey&&kD(e,PD.R),PanelComponent:({updateData:e})=>ND("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+R")}`,children:zu})});import{arrayToMap as Sy}from"@excalidraw/common";import{CaptureUpdateAction as BD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as OD}from"@excalidraw/element/frame";import{normaliseElements as FD}from"@excalidraw/element/normalise";import{jsx as UD}from"react/jsx-runtime";var zD=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Sy(e),{normalise:i}=Zi(n,t.props.editorPreferences),a=FD(t.scene,o,r,i.mode,i.metric),s=Sy(a);return OD(e.map(l=>s.get(l.id)||l),n,t)},HD=pt,GD=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:Hu,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>HD(n,o),perform:(e,n,t,o)=>({appState:n,elements:zD(e,n,o),captureUpdate:BD.IMMEDIATELY}),PanelComponent:({updateData:e})=>UD("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:Hu})});import{getNonDeletedElements as WD}from"@excalidraw/element";import{bindOrUnbindBindingElements as VD}from"@excalidraw/element";import{getCommonBoundingBox as Cy}from"@excalidraw/element";import{newElementWith as YD}from"@excalidraw/element";import{deepCopyElement as XD}from"@excalidraw/element";import{resizeMultipleElements as KD}from"@excalidraw/element";import{isArrowElement as Py,isElbowArrow as ZD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as ky}from"@excalidraw/element";import{CODES as My,KEYS as $D,arrayToMap as jD}from"@excalidraw/common";import{CaptureUpdateAction as Ay}from"@excalidraw/element";var Zh=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:H1,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:ky(Ly(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:Ay.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===My.H}),$h=O({name:"flipVertical",label:"labels.flipVertical",icon:z1,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:ky(Ly(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:Ay.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===My.V&&!e[$D.CTRL_OR_CMD]}),Ly=(e,n,t,o,r)=>{let i=ie(WD(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=qD(i,n,o,r),s=jD(a);return e.map(l=>s.get(l.id)||l)},qD=(e,n,t,o)=>{if(e.every(p=>Py(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return YD(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=Cy(e);KD(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,XD(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),VD(e.filter(Py),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>ZD(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=Cy(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 JD}from"@excalidraw/element";import{getTextFromElements as QD}from"@excalidraw/element";import{CODES as e_,KEYS as Dy,isFirefox as t_}from"@excalidraw/common";import{CaptureUpdateAction as Xt}from"@excalidraw/element";var $i=O({name:"copy",label:"labels.copy",icon:ds,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await zd(r,o.files,t)}catch(i){return{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Xt.EVENTUALLY}},keyTest:void 0}),jh=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await Qw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),t_?{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(qw({types:r}))}catch(i){return console.error(i),{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Xt.EVENTUALLY}},keyTest:void 0}),qd=O({name:"cut",label:"labels.cut",icon:A1,trackEvent:{category:"element"},perform:(e,n,t,o)=>($i.perform(e,n,t,o),Es.perform(e,n,null,o)),keyTest:e=>e[Dy.CTRL_OR_CMD]&&e.key===Dy.X}),n_=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:G1,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Xt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Or(e,n,!0);try{await Fr("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:Xt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Xt.EVENTUALLY}}},predicate:e=>Fd&&e.length>0,keywords:["svg","clipboard","copy"]}),o_=O({name:"copyAsPng",label:"labels.copyAsPng",icon:U1,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Xt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Or(e,n,!0);try{return await Fr("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:Xt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Xt.EVENTUALLY}}},predicate:e=>qo&&e.length>0,keyTest:e=>e.code===e_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),r_=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{uo(QD(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Xt.EVENTUALLY}},predicate:(e,n,t,o)=>Fd&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(JD),keywords:["text","clipboard","copy"]});import{CODES as i_,KEYS as a_}from"@excalidraw/common";import{CaptureUpdateAction as s_}from"@excalidraw/element";var ji=O({name:"gridMode",icon:V1,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:s_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[a_.CTRL_OR_CMD]&&e.code===i_.QUOTE});import{KEYS as qh}from"@excalidraw/common";import{CaptureUpdateAction as l_}from"@excalidraw/element/store";import{jsx as c_}from"react/jsx-runtime";var Ys=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:Gu,viewMode:!0,perform:(e,n,t,o)=>{let r=Zi(n,o.props.editorPreferences).smartZoom,i=ie(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[qh.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===qh.F,PanelComponent:({data:e,updateData:n})=>c_(K,{type:"button",icon:Gu,"aria-label":f("labels.smartZoom"),onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:qh.F.toLocaleUpperCase()})});import{CODES as d_,KEYS as m_}from"@excalidraw/common";import{CaptureUpdateAction as p_}from"@excalidraw/element";var kt=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Fo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:p_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[m_.CTRL_OR_CMD]&&e.altKey&&e.code===d_.S});import{CaptureUpdateAction as u_}from"@excalidraw/element";var Xs=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 h_}from"@excalidraw/element";var Ks=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:h_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as g_,KEYS as f_}from"@excalidraw/common";import{CaptureUpdateAction as E_}from"@excalidraw/element";var er=O({name:"stats",label:"stats.fullTitle",icon:F1,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:E_.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[f_.CTRL_OR_CMD]&&e.altKey&&e.code===g_.SLASH});import{BOUND_TEXT_PADDING as _y,ROUNDNESS as Ry,TEXT_ALIGN as Oy,VERTICAL_ALIGN as Fy,arrayToMap as zy,getFontString as b_,getStrokeWidthByKey as x_}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as w_,isBoundToContainer as Ny,resetOriginalContainerCache as y_,updateOriginalContainerCache as v_}from"@excalidraw/element";import{computeBoundTextPosition as I_,computeContainerDimensionForBoundText as By,getBoundTextElement as Hy,redrawTextBoundingBox as Gy}from"@excalidraw/element";import{hasBoundTextElement as T_,isArrowElement as S_,isTextBindableContainer as Jh,isTextElement as Zs,isUsingAdaptiveRadius as C_}from"@excalidraw/element";import{measureText as P_}from"@excalidraw/element";import{syncMovedIndices as Uy}from"@excalidraw/element";import{newElement as k_}from"@excalidraw/element";import{CaptureUpdateAction as Qh}from"@excalidraw/element";var eg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>T_(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=Hy(a,i);if(s){let{width:l,height:c}=P_(s.originalText,b_(s),s.lineHeight),d=w_(a.id);y_(a.id);let{x:m,y:p}=I_(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:Qh.IMMEDIATELY}}}),tg=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=Zs(r[0])||Zs(r[1]),a;if(Jh(r[0])?a=r[0]:Jh(r[1])&&(a=r[1]),i&&a&&Hy(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;Zs(r[0])&&Jh(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:Fy.MIDDLE,textAlign:Oy.CENTER,autoResize:!0,angle:S_(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return Gy(i,a,o.scene),v_(a.id,s),{elements:M_(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:Qh.IMMEDIATELY}}}),M_=(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),Uy(o,zy([n,t])),o},A_=(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),Uy(o,zy([n,t])),o},Wy=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>Zs(a)&&!Ny(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(Zs(s)&&!Ny(s)){let l=k_({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:x_("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:C_("rectangle")?Ry.ADAPTIVE_RADIUS:Ry.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-_y,y:s.y-_y,width:By(s.width,"rectangle"),height:By(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:Fy.MIDDLE,boundElements:null,textAlign:Oy.CENTER,autoResize:!0}),Gy(s,l,o.scene),i=A_([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:Qh.IMMEDIATELY}}});import{getNonDeletedElements as Qy,isEmbeddableElement as K_}from"@excalidraw/element";import{KEYS as ev}from"@excalidraw/common";import{CaptureUpdateAction as Z_}from"@excalidraw/element";import{pointFrom as Ky}from"@excalidraw/math";import L_ from"clsx";import{useCallback as Vy,useEffect as Yy,useLayoutEffect as D_,useRef as __,useState as R_}from"react";import{EVENT as ng,HYPERLINK_TOOLTIP_DELAY as N_,KEYS as Jd}from"@excalidraw/common";import{getElementAbsoluteCoords as sg}from"@excalidraw/element";import{hitElementBoundingBox as B_}from"@excalidraw/element";import{isElementLink as O_}from"@excalidraw/element";import{getEmbedLink as F_,embeddableURLValidator as z_}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Zy,viewportCoordsToSceneCoords as H_,wrapEvent as G_,isLocalLink as U_,normalizeLink as og}from"@excalidraw/common";import{isEmbeddableElement as rg}from"@excalidraw/element";import{jsx as qi,jsxs as Xy}from"react/jsx-runtime";var lg=380,W_=42,ig=5,$y=85,V_=500,ag=!1,Qd=new Map,jy=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=Ko(),l=yn(),c=ge(),d=e.link||"",[m,p]=R_(d),u=__(null),E=s.showHyperlinkPopup==="editor",g=Vy(()=>{if(!u.current)return;let v=og(u.current.value)||null;if(!e.link&&v&&Ne("hyperlink","create"),rg(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){n.mutateElement(e,{link:null}),i(e,!1);return}if(!z_(v,l.validateEmbeddable))v&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&Qd.set(e.id,e.link),n.mutateElement(e,{link:v}),i(e,!1);else{let{width:T,height:C}=e,P=F_(v);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let A=P?P.intrinsicSize.w/P.intrinsicSize.h:1,L=Qd.get(e.id)!==e.link;n.mutateElement(e,{...L?{width:P?.type==="video"?T>C?T:C*A:T,height:P?.type==="video"&&T>C?T/A:C}:{},link:v}),i(e,!0),Qd.has(e.id)&&Qd.delete(e.id)}}else n.mutateElement(e,{link:v})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);D_(()=>()=>{g()},[g]),Yy(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),Yy(()=>{let v=null,T=C=>{if(E)return;v&&clearTimeout(v),X_(e,a,s,Ky(C.clientX,C.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},V_))};return window.addEventListener(ng.POINTER_MOVE,T,!1),()=>{window.removeEventListener(ng.POINTER_MOVE,T,!1),v&&clearTimeout(v)}},[s,e,E,t,a]);let b=Vy(()=>{Ne("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),y=()=>{Ne("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:w,y:x}=qy(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:Xy("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${w}px`,width:lg,padding:ig},children:[E?qi("input",{className:L_("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:m,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[Jd.CTRL_OR_CMD]&&v.key===Jd.K&&v.preventDefault(),(v.key===Jd.ENTER||v.key===Jd.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?qi("a",{href:og(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:U_(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&o){let T=G_(ng.EXCALIDRAW_LINK,v.nativeEvent);o({...e,link:og(e.link)},T),T.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):qi("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),Xy("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&qi(K,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:y,className:"excalidraw-hyperlinkContainer--edit",icon:zn}),qi(K,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Fc}),d&&!rg(e)&&qi(K,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Pr})]})]})},qy=(e,n,t)=>{let[o,r]=sg(e,t),{x:i,y:a}=Zy({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-lg/2,l=a-n.offsetTop-$y;return{x:s,y:l}},cg=(e,n)=>{let t=ie(e,n);return rg(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},$s=null,Jy=(e,n,t)=>{$s&&clearTimeout($s),$s=window.setTimeout(()=>Y_(e,n,t),N_)},Y_=(e,n,t)=>{if(!e.link)return;let o=Ri();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=O_(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=sg(e,t),[l,c,d,m]=jb([r,i,a,s],e.angle,n),p=Zy({sceneX:l,sceneY:c},n);Ch(o,{left:p.x,top:p.y,width:d,height:m},"top"),Ne("hyperlink","tooltip","link-icon"),ag=!0},em=()=>{$s&&clearTimeout($s),ag&&(ag=!1,Ri().classList.remove("excalidraw-tooltip--visible"))},X_=(e,n,t,[o,r])=>{let{x:i,y:a}=H_({clientX:o,clientY:r},t),s=15/t.zoom.value;if(B_(Ky(i,a),e,n))return!1;let[l,c,d]=sg(e,n);if(i>=l&&i<=d&&a>=c-$y&&a<=c)return!1;let{x:m,y:p}=qy(e,t,n);return!(o>=m-s&&o<=m+lg+ig*2+s&&r>=p-s&&r<=p+s+ig*2+W_)};import{jsx as $_}from"react/jsx-runtime";var dg=O({name:"hyperlink",label:(e,n)=>cg(Qy(e),n),icon:hs,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:Z_.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[ev.CTRL_OR_CMD]&&e.key===ev.K,predicate:(e,n)=>ie(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=ie(e,n);return $_(K,{type:"toggle",icon:hs,"aria-label":f(cg(Qy(e),n)),title:`${K_(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 tv,arrayToMap as pg,randomId as j_}from"@excalidraw/common";import{elementsAreInSameGroup as q_,getNonDeletedElements as nv,newElementWith as ov,selectGroupsFromGivenElements as rv}from"@excalidraw/element";import{CaptureUpdateAction as iv}from"@excalidraw/element";var mg=e=>e.every(n=>!n.locked),js=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return mg(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=ie(n,e);return mg(t)?No:ao},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=mg(r),a=pg(r),s=r.length>1&&q_(r),c=r.length===1||s?null:j_(),d={...n.lockedMultiSelections};if(i)d={...n.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let y=r[0].groupIds.at(-1);delete d[y]}let m=e.map(y=>{if(!a.has(y.id))return y;let w=y.groupIds;return i?c&&(w=[...w,c]):w=w.filter(x=>!n.lockedMultiSelections[x]),ov(y,{locked:i,groupIds:w.length!==y.groupIds.length?w:y.groupIds})}),p=pg(m),u=i?{}:Object.fromEntries(r.map(y=>[y.id,!0])),E=r.map(y=>p.get(y.id)||y),g=i?{}:rv(nv(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:iv.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===tv.L&&e[tv.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),av=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:ao,predicate:(e,n)=>ie(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 ov(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=nv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:rv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:iv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as c8,isLinearElement as d8,isLineElement as ia}from"@excalidraw/element";import{arrayToMap as m8,invariant as Vv}from"@excalidraw/common";import{toggleLinePolygonState as p8,CaptureUpdateAction as Yv}from"@excalidraw/element";import{getSizeFromPoints as DIe,randomInteger as s8,getUpdatedTimestamp as l8}from"@excalidraw/common";import{simplify as GR}from"points-on-curve";import{getStroke as UR,getStrokePoints as uIe}from"perfect-freehand";function Xe([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function Ji([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function Qe([e,n,t],o){return[e*o,n*o,t*o]}function Wr([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function Et([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function sv(e,n,t){return Xe(e,Qe(Ji(n,e),t))}function ug(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 hg(e){return Math.atan2(Math.sin(e),Math.cos(e))}function gg([e,n]){return Math.sqrt(e**2+n**2)}function Ur([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function lv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=Ur(e[t-1],e[t]);return n+=Ur(e[e.length-2],e[e.length-1]),n}var J_=(e,n,t)=>Math.max(n,Math.min(t,e));function cv(e,n,t){let o=Ur(n,t);if(o===0)return Ur(e,n);let r=J_(((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 Ur(i,e)}function qs(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=cv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...qs([t,...e.slice(1,i),a],n).slice(0,-1),a,...qs([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var tr=class tr{constructor(n){I(this,"options");I(this,"originalPoints",[]);I(this,"stablePoints",[]);I(this,"tailPoints",[]);I(this,"isFresh",!0);this.options=Object.assign({},tr.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=sv(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),lv(this.tailPoints)>tr.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=qs(t,this.options.simplify));let o=t.length;if(o===0)return[];if(o===1){let P=t[0],A=this.getSize(n,P[2],0,o,0);if(A<.5)return[];let L=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)L.push(Xe(P,Qe(Et([1,0,0],_),A)));return L.push(Xe(P,Qe([1,0,0],this.getSize(n,P[2],0,o,0)))),L}if(o===2){let P=t[0],A=t[1],L=this.getSize(n,P[2],0,o,0),_=this.getSize(n,A[2],0,o,0);if(L<.5||_<.5)return[];let k=[],D=ug(P,[P[0],P[1]-100,P[2]],A);for(let F=D;F<=Math.PI+D;F+=Math.PI/16)k.push(Xe(P,Qe(Et([1,0,0],F),L)));for(let F=Math.PI+D;F<=Math.PI*2+D;F+=Math.PI/16)k.push(Xe(A,Qe(Et([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 A=t[P-1],L=t[P],_=t[P+1],k=L[2],D=Ur(A,L);c+=D,a=s+(D-s)*.2;let F=this.getSize(n,k,P,o,c);if(F===0){l=P+1;continue}let Y=Wr(Ji(A,L)),z=Wr(Ji(_,L)),W=Et(Y,Math.PI/2),Z=Et(Y,-Math.PI/2),H=Et(z,Math.PI/2),re=Et(z,-Math.PI/2),B=Xe(L,Qe(W,F)),U=Xe(L,Qe(Z,F)),ue=Xe(L,Qe(H,F)),we=Xe(L,Qe(re,F)),pe=Xe(W,re),he=Xe(Z,H),ye=Xe(L,Qe(gg(pe)===0?Y:Wr(pe),F)),se=Xe(L,Qe(gg(he)===0?z:Wr(he),F)),ve=hg(ug(L,A,_)),st=tr.constants.cornerDetectionMaxAngle/180*Math.PI*tr.constants.cornerDetectionVariance(a);if(Math.abs(ve)<st){let $e=Math.abs(hg(Math.PI-ve));if($e===0)continue;if(ve<0){i.push(U,se);for(let Re=0;Re<=$e;Re+=$e/4)r.push(Xe(L,Et(Qe(W,F),Re)));for(let Re=$e;Re>=0;Re-=$e/4)i.push(Xe(L,Et(Qe(W,F),Re)));i.push(se,ue)}else{r.push(B,ye);for(let Re=0;Re<=$e;Re+=$e/4)i.push(Xe(L,Et(Qe(W,-F),-Re)));for(let Re=$e;Re>=0;Re-=$e/4)r.push(Xe(L,Et(Qe(W,-F),-Re)));r.push(ye,we)}}else r.push(ye),i.push(se);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],A=[];for(let L=0;L<=Math.PI*2;L+=Math.PI/16)A.push(Xe(P,Qe(Et([1,0,0],L),this.options.size)));return A.push(Xe(P,Qe([1,0,0],this.options.size))),A}return[]}let d=t[l],m=t[l+1],p=t[o-2],u=t[o-1],E=Wr(Ji(m,d)),g=Wr(Ji(p,u)),b=Et(E,-Math.PI/2),y=Et(g,Math.PI/2),w=this.getSize(n,d[2],0,o,0),x=[],v=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,c),T=[];if(w>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift(Xe(d,Et(Qe(b,w),-P)));x.unshift(Xe(d,Qe(b,-w)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push(Xe(u,Et(Qe(y,-v),-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"?qs(C,this.options.simplify):C}};I(tr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),I(tr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var Qi=tr;import{pointsOnBezierCurves as Pce}from"points-on-curve";import{invariant as Mce}from"@excalidraw/common";import{curve as Lce,lineSegment as Dce,pointFrom as _ce,pointDistance as Rce,pointFromArray as Nce,pointFromVector as Bce,pointRotateRads as Oce,polygon as Fce,polygonFromPoints as zce,PRECISION as Hce,segmentsIntersectAt as Gce,vector as Uce,vectorAdd as Wce,vectorFromPoint as Vce,vectorScale as Yce}from"@excalidraw/math";import{getElementAbsoluteCoords as Kce}from"@excalidraw/element";var fg=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 WR,pointDistance as Fv,pointRotateRads as EIe}from"@excalidraw/math";import{ROUGHNESS as VR,THEME as Rg,isTransparent as dl,assertNever as YR,COLOR_PALETTE as XR,LINE_POLYGON_POINT_MERGE_DISTANCE as xIe,applyDarkModeFilter as ml,DEFAULT_STROKE_STREAMLINE as KR}from"@excalidraw/common";import{RoughGenerator as ZR}from"roughjs/bin/generator";import C2e from"roughjs/bin/rough";import{isRightAngleRads as k2e,lineSegment as M2e,pointFrom as A2e,pointRotateRads as L2e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as _2e,DEFAULT_REDUCED_GLOBAL_ALPHA as R2e,ELEMENT_READY_TO_ERASE_OPACITY as N2e,FRAME_STYLE as B2e,DARK_THEME_FILTER as O2e,MIME_TYPES as Ov,THEME as F2e,distance as z2e,getFontString as H2e,isRTL as G2e,getVerticalOffset as U2e,invariant as W2e,applyDarkModeFilter as V2e,isSafari as Y2e}from"@excalidraw/common";import qve from"roughjs/bin/rough";import{arrayToMap as Qve,invariant as Bv,rescalePoints as e2e,sizeOf as t2e}from"@excalidraw/common";import{degreesToRadians as Ag,lineSegment as o2e,pointFrom as bt,pointFromArray as RR,pointRotateRads as ra}from"@excalidraw/math";import{pointsOnBezierCurves as a2e}from"points-on-curve";import{pointCenter as gve,pointFrom as fve,pointRotateRads as Eve,pointsEqual as bve,pointDistance as xve,vectorFromPoint as wve,curveLength as yve,curvePointAtLength as vve}from"@excalidraw/math";import{DRAGGING_THRESHOLD as Sve,KEYS as Cve,shouldRotateWithDiscreteAngle as Pve,getGridPoint as kve,invariant as Mve,isShallowEqual as Ave,getFeatureFlag as Lve}from"@excalidraw/common";import{arrayToMap as Aye,getFeatureFlag as Lye,getGridPoint as Dye,invariant as _ye,isTransparent as Rye}from"@excalidraw/common";import{PRECISION as Bye,clamp as Oye,lineSegment as Fye,pointDistance as zye,pointDistanceSq as Hye,pointFrom as Gye,pointFromArray as Uye,pointFromVector as Wye,pointRotateRads as Vye,pointsEqual as Yye,vectorFromPoint as Xye,vectorNormalize as Kye,vectorScale as Zye}from"@excalidraw/math";import{invariant as qwe,isTransparent as Jwe}from"@excalidraw/common";import{curveIntersectLineSegment as eye,isPointWithinBounds as tye,lineSegment as nye,lineSegmentIntersectionPoints as oye,pointFrom as rye,pointFromVector as iye,pointRotateRads as aye,pointsEqual as sye,vectorFromPoint as lye,vectorNormalize as cye,vectorScale as dye}from"@excalidraw/math";import{ellipse as pye,ellipseSegmentInterceptPoints as uye}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as nR,DEFAULT_PROPORTIONAL_RADIUS as xg,invariant as rde,LINE_CONFIRM_THRESHOLD as oR,ROUNDNESS as wg}from"@excalidraw/common";import{bezierEquation as ade,curve as sde,curveCatmullRomCubicApproxPoints as lde,curveOffsetPoints as cde,lineSegment as dde,lineSegmentIntersectionPoints as mde,pointDistance as rR,pointFrom as pde,pointFromArray as ude,pointFromVector as hde,pointRotateRads as gde,pointTranslate as fde,rectangle as Ede,vectorFromPoint as bde,vectorNormalize as xde,vectorScale as wde}from"@excalidraw/math";import{ROUNDNESS as qce,assertNever as Jce}from"@excalidraw/common";import{pointsEqual as ede}from"@excalidraw/math";var dv=e=>!!e&&e.type==="embeddable",Eg=e=>!!e&&e.type==="iframe",bg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),rn=e=>e!=null&&e.type==="text";var Xn=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var an=e=>e!=null&&eR(e.type);var In=e=>e!=null&&e.type==="arrow",Tn=e=>In(e)&&e.elbowed;var eR=e=>e==="arrow"||e==="line";var ho=e=>e!==null&&"containerId"in e&&e.containerId!==null&&rn(e);var ea=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return rR(t,o)<=oR/n}return!1},Js=(e,n)=>{if(n.roundness?.type===wg.PROPORTIONAL_RADIUS||n.roundness?.type===wg.LEGACY)return e*xg;if(n.roundness?.type===wg.ADAPTIVE_RADIUS){let t=n.roundness?.value??nR,o=t/xg;return e<=o?e*xg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Awe,ARROW_LABEL_WIDTH_FRACTION as Lwe,BOUND_TEXT_PADDING as Dwe,DEFAULT_FONT_SIZE as _we,TEXT_ALIGN as Rwe,VERTICAL_ALIGN as Nwe,getFontString as Bwe,isProdEnv as Owe,invariant as Fwe}from"@excalidraw/common";import{pointFrom as Hwe,pointRotateRads as Gwe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Rde,DEFAULT_FONT_SIZE as Nde,DEFAULT_FONT_FAMILY as Bde,getFontString as Ode,isTestEnv as Fde,normalizeEOL as zde}from"@excalidraw/common";var Hde="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Kde,isTestEnv as Zde}from"@excalidraw/common";import{toIterable as S0e}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Qde,viewportCoordsToSceneCoords as eme}from"@excalidraw/common";import{normalizeRadians as nme,radiansBetweenAngles as ome,radiansDifference as rme}from"@excalidraw/math";import{pointsEqual as ame}from"@excalidraw/math";import{arrayToMap as Vme,isShallowEqual as lR}from"@excalidraw/common";import{arrayToMap as Tme}from"@excalidraw/common";import{isPointWithinBounds as Cme,pointFrom as Pme,segmentsIntersectAt as kme}from"@excalidraw/math";import{arrayToMap as pme}from"@excalidraw/common";import{validateOrderKey as hme,generateNKeysBetween as gme}from"@excalidraw/fractional-indexing";var yg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var Jme=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}(),ol=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){Vr(i)?(r.push(i),o.add(i.id)):console.error("[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection");continue}if(t?.includeBoundTextElement&&ho(i)&&Vr(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{Xn(a)&&yg(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var Ig=(e,n)=>lR(n.selectedElementIds,e)?n.selectedElementIds:e;var cR=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:Ig({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):ol(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Ig(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var fpe=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as pue,VERTICAL_ALIGN as uue}from"@excalidraw/common";import{pointDistance as gue,pointFromVector as fue,pointsEqual as Eue,vector as bue,vectorDot as xue,vectorFromPoint as wue,vectorNormalize as yue,vectorScale as vue}from"@excalidraw/math";import{invariant as kpe,isDevEnv as Mpe,isTestEnv as Ape}from"@excalidraw/common";import{pointFrom as Dpe,pointFromVector as _pe,pointRotateRads as Rpe,pointScaleFromOrigin as Npe,pointsEqual as Bpe,triangleIncludesPoint as Ope,vectorCross as Fpe,vectorFromPoint as pR,vectorScale as zpe}from"@excalidraw/math";var al=[1,0],im=[0,1],sl=[-1,0],am=[0,-1],sm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?al:n<=-r?sl:t>o?im:am},xv=(e,n)=>sm(pR(e,n)),lm=(e,n)=>cm(xv(e,n)),il=(e,n)=>e[0]===n[0]&&e[1]===n[1],cm=e=>il(e,al)||il(e,sl);import{DEFAULT_ELEMENT_PROPS as Vpe,DEFAULT_FONT_FAMILY as Ype,DEFAULT_FONT_SIZE as Xpe,DEFAULT_TEXT_ALIGN as Kpe,DEFAULT_VERTICAL_ALIGN as Zpe,DEFAULT_STROKE_STREAMLINE as $pe,VERTICAL_ALIGN as jpe,randomInteger as qpe,randomId as Jpe,getFontString as Qpe,getUpdatedTimestamp as eue,getLineHeight as tue}from"@excalidraw/common";import{pointsOnBezierCurves as Yue,simplify as Xue}from"points-on-curve";import{curveToBezier as Zue}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as jue,lineSegment as que,lineSegmentIntersectionPoints as Jue,pointDistance as Que,pointFrom as ehe,pointRotateRads as the,polygonArea as nhe,polygonIncludesPoint as ohe,polygonIncludesPointNonZero as rhe,polygonSignedArea as ihe}from"@excalidraw/math";import{isOpaqueColor as she,isTransparent as lhe}from"@excalidraw/common";var Iv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as _ue,distanceToLineSegment as Rue,pointRotateRads as Nue}from"@excalidraw/math";import{ellipse as Oue,ellipseDistanceFromPoint as Fue}from"@excalidraw/math/ellipse";import{pointFrom as vhe,pointCenter as Ihe,pointRotateRads as The,vectorFromPoint as She,vectorNormalize as Che,vectorSubtract as Phe,vectorAdd as khe,vectorScale as Mhe,pointFromVector as Ahe,clamp as Lhe,isCloseTo as Dhe}from"@excalidraw/math";import{arrayToMap as sfe,arrayToObject as lfe,assertNever as cfe,isDevEnv as dfe,isShallowEqual as mfe,isTestEnv as pfe,randomInteger as ufe}from"@excalidraw/common";import{assertNever as hge,COLOR_PALETTE as gge,isDevEnv as fge,isTestEnv as Ege,randomId as bge,Emitter as xge,toIterable as wge}from"@excalidraw/common";import{ORIG_ID as Yhe,randomId as Xhe,randomInteger as Khe,arrayToMap as Zhe,castArray as $he,findLastIndex as jhe,getUpdatedTimestamp as qhe,isTestEnv as Jhe}from"@excalidraw/common";import{arrayToMap as Ohe}from"@excalidraw/common";import gR from"lodash.throttle";import{randomInteger as Nge,arrayToMap as Bge,toBrandedType as Oge,isDevEnv as Pv,isTestEnv as kv,toArray as Fge}from"@excalidraw/common";import{isNonDeletedElement as Hge}from"@excalidraw/element";import{isFrameLikeElement as Uge}from"@excalidraw/element";import{getElementsInGroup as Vge}from"@excalidraw/element";import{syncInvalidIndices as Xge,syncMovedIndices as Kge,validateFractionalIndices as fR}from"@excalidraw/element";import{getSelectedElements as $ge}from"@excalidraw/element";import{mutateElement as qge}from"@excalidraw/element";var Jge=gR(e=>{(Pv()||kv()||window?.DEBUG_FRACTIONAL_INDICES)&&fR(e,{shouldThrow:Pv()||kv(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as Ffe,getGridPoint as zfe,getFontString as Hfe,DRAGGING_THRESHOLD as Gfe}from"@excalidraw/common";import{clamp as Jfe,pointDistance as Qfe,pointFrom as eEe,pointScaleFromOrigin as tEe,pointsEqual as nEe,pointTranslate as oEe,vector as rEe,vectorCross as iEe,vectorFromPoint as aEe,vectorScale as sEe}from"@excalidraw/math";import{BinaryHeap as cEe,invariant as dEe,isAnyTrue as mEe,getSizeFromPoints as pEe,isDevEnv as uEe,arrayToMap as hEe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as kEe,normalizeLink as MEe}from"@excalidraw/common";import{FONT_FAMILY as REe,VERTICAL_ALIGN as NEe,escapeDoubleQuotes as BEe,getFontString as OEe}from"@excalidraw/common";import{invariant as XEe,toBrandedType as KEe}from"@excalidraw/common";import{clamp as $Ee,pointFrom as jEe}from"@excalidraw/math";import{pointDistance as Sbe,pointFrom as Cbe}from"@excalidraw/math";import{invariant as kbe}from"@excalidraw/common";import{arrayToMap as dbe,findIndex as mbe,findLastIndex as pbe}from"@excalidraw/common";import{isFiniteNumber as hbe}from"@excalidraw/math";import{MIME_TYPES as Fbe,SVG_NS as zbe}from"@excalidraw/common";import{rgbaToThumbHash as Gbe,thumbHashToRGBA as Ube}from"thumbhash";import{pointCenter as rxe,normalizeRadians as ixe,pointFrom as axe,pointRotateRads as sxe}from"@excalidraw/math";import{MIN_FONT_SIZE as cxe,SHIFT_LOCKING_ANGLE as dxe,rescalePoints as mxe,getFontString as pxe}from"@excalidraw/common";import{pointFrom as zxe,pointOnLineSegment as Hxe,pointRotateRads as Gxe}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as Wxe}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as Cxe}from"@excalidraw/common";import{pointFrom as kxe,pointRotateRads as Mxe}from"@excalidraw/math";import{KEYS as Cn}from"@excalidraw/common";var e1e=[{icon:Pc,value:"selection",key:Cn.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:Ei,value:"rectangle",key:Cn.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:bi,value:"diamond",key:Cn.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:xi,value:"ellipse",key:Cn.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:kc,value:"arrow",key:Cn.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Bo,value:"line",key:Cn.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:zn,value:"freedraw",key:[Cn.P,Cn.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:wn,value:"text",key:Cn.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Cr,value:"image",key:[Cn.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Mc,value:"eraser",key:Cn.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as p1e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as h1e,DEFAULT_FONT_SIZE as g1e,TEXT_ALIGN as f1e,VERTICAL_ALIGN as E1e,getSizeFromPoints as b1e,randomId as x1e,arrayToMap as w1e,assertNever as y1e,cloneJSON as v1e,getFontString as I1e,isDevEnv as T1e,toBrandedType as S1e,getLineHeight as C1e}from"@excalidraw/common";import{getBoundsFromPoints as $1e,getElementAbsoluteCoords as j1e}from"@excalidraw/element/bounds";import{newArrowElement as J1e,newElement as Q1e,newLinearElement as e0e}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as n0e,getStrokeWidthByKey as o0e,ROUNDNESS as r0e}from"@excalidraw/common";import{convexHull as a0e,distanceToLineSegment as s0e,elongation as l0e,kurtosis as c0e,lineSegment as d0e,orientPrincipalAxes as m0e,pointFrom as p0e,polygonArea as u0e,principalAxes as h0e,principalCoords as g0e,skewness as f0e}from"@excalidraw/math";var w0e=[{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 Vr=e=>!e.isDeleted;var PR=10/1.5;var tm=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 NR=20,BR=15,OR=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 BR;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return NR;default:return 15}},FR=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},At=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=fg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;Bv(s.length===6,"Op data length is not 6");let l=bt(s[4],s[5]),c=bt(s[2],s[3]),d=bt(s[0],s[1]),m=i[a-1],p=bt(0,0);if(m.op==="move"){let H=RR(m.data);Bv(H!=null,"Op data is not a point"),p=H}else m.op==="bcurveTo"&&(p=bt(m.data[4],m.data[5]));let u=(H,re)=>Math.pow(1-H,3)*l[re]+3*H*Math.pow(1-H,2)*c[re]+3*Math.pow(H,2)*(1-H)*d[re]+p[re]*Math.pow(H,3),[E,g]=t==="start"?p:l,[b,y]=[u(.3,0),u(.3,1)],w=Math.hypot(E-b,g-y),x=(E-b)/w,v=(g-y)/w,T=OR(o),C=0;{let[H,re]=t==="end"?e.points[e.points.length-1]:e.points[0],[B,U]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(H-B,re-U)}let A=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),L=E-x*A*r,_=g-v*A*r,k=L-x*A,D=_-v*A;if(o==="circle"||o==="circle_outline"){let H=Math.hypot(D-_,k-L)+e.strokeWidth-2;return[L,_,H]}let F=FR(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[H,re]=ra(bt(L,_),bt(k,D),Ag(-F)),[B,U]=ra(bt(L,_),bt(k,D),Ag(F));return[k,D,H,re,B,U]}let[Y,z]=ra(bt(k,D),bt(L,_),-F*Math.PI/180),[W,Z]=ra(bt(k,D),bt(L,_),Ag(F));if(o==="diamond"||o==="diamond_outline"){let H,re;if(t==="start"){let[B,U]=e.points.length>1?e.points[1]:[0,0];[H,re]=ra(bt(L+A*2,_),bt(L,_),Math.atan2(U-_,B-L))}else{let[B,U]=e.points.length>1?e.points[e.points.length-2]:[0,0];[H,re]=ra(bt(L-A*2,_),bt(L,_),Math.atan2(_-U,L-B))}return[L,_,Y,z,H,re,W,Z]}return[L,_,Y,z,W,Z]};var zR=typeof document<"u"?document.createElement("img"):{src:""};zR.src=`data:${Ov.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 HR=typeof document<"u"?document.createElement("img"):{src:""};HR.src=`data:${Ov.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 Lg=new WeakMap;var Ft=class Ft{};I(Ft,"rg",new ZR),I(Ft,"cache",new WeakMap),I(Ft,"get",(n,t)=>{let o=Ft.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),I(Ft,"delete",n=>{Ft.cache.delete(n),Lg.delete(n)}),I(Ft,"destroy",()=>{Ft.cache=new WeakMap}),I(Ft,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Ft.get(n,t?t.theme:null);if(o!==void 0)return o;Lg.delete(n);let r=qR(n,Ft.rg,t||{isExporting:!1,canvasBackgroundColor:XR.white,embedsValidationStatus:null,theme:Rg.LIGHT});return t?.isExporting||Ft.cache.set(n,{shape:r,theme:t?.theme||Rg.LIGHT}),r});var oa=Ft,$R=e=>[8,8+e],Uv=e=>[1.5,6+e];function jR(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&&Iv(e.type)||an(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var fo=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?$R(e.strokeWidth):e.strokeStyle==="dotted"?Uv(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:jR(e),stroke:ml(e.strokeColor,t),preserveVertices:n||e.roughness<VR.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=dl(e.backgroundColor)?void 0:ml(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:ml(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},zv=(e,n,t)=>bg(e)&&(n||dv(e)&&t?.get(e.id)!==!0)&&dl(e.backgroundColor)&&dl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Eg(e)?{...e,strokeColor:dl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:dl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,cl=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},mm=(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)]},Xr=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=Uv(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Dg=(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)]},Hv=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=ml(e.strokeColor,s),c=ml(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return Dg(r,i,l,At(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=At(e,n,t,o);if(p===null)return[];let[u,E,g,b,y,w]=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],[y,w],[u,E]],x)]}case"diamond":case"diamond_outline":{let p=At(e,n,t,o);if(p===null)return[];let[u,E,g,b,y,w,x,v]=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],[y,w],[x,v],[u,E]],T)]}case"cardinality_one":return cl(r,At(e,n,t,o),Xr(e,i));case"cardinality_many":return mm(r,At(e,n,t,o),Xr(e,i));case"cardinality_one_or_many":{let p=Xr(e,i);return[...mm(r,At(e,n,t,"cardinality_many"),p),...cl(r,At(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=Xr(e,i);return[...cl(r,At(e,n,t,"cardinality_one",-.5),p),...cl(r,At(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=Xr(e,i);return[...Dg(r,i,l,At(e,n,t,"circle_outline",1.5),c,m),...cl(r,At(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=Xr(e,i);return[...mm(r,At(e,n,t,"cardinality_many"),p),...Dg(r,i,l,At(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return mm(r,At(e,n,t,o),Xr(e,i))}};var qR=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===Rg.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=Js(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`,fo(zv(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,fo(zv(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=tm(e);if(e.roundness){let b=Js(Math.abs(l-E),e),y=Js(Math.abs(m-c),e);s=n.path(`M ${l+b} ${c+y} L ${d-b} ${m-y}
4
+ ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var ty=async(e,n,t)=>{let o=Jb(n);if(!Qb(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}=Or(r,i,!1);return await Fr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as wL,jsx as Jo,jsxs as iy}from"react/jsx-runtime";var Fh=F({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>Jo(Zw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),ny=F({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:vn.EVENTUALLY})}),zh=F({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Jo(_h,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),Hd=F({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>iy(_h,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),Jo(ct,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:Jo("div",{className:"excalidraw-tooltip-icon",children:Nx})})]})}),Gi=!1,Oh=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?iy(wL,{children:[t,Jo(_d.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function xL(e,n){if(n.app.state.isLoading&&(Oh(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")Oh(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(Oh(n.app,{progress:null}),await e)}function oy(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await xL(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 zr=F({name:"saveToActiveFile",label:"buttons.save",icon:us,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(Gi)return!1;Gi=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=oy(e,n,o.files,o);try{let{fileHandle:l}=wc(r)?await ty(s,r,i):await gc({data:s,filename:i,fileHandle:r});return{captureUpdate:vn.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:vn.NEVER,appState:{toast:null}}}finally{Gi=!1}},keyTest:e=>!1}),Ws=F({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:us,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(Gi)return!1;Gi=!0;let{abortController:r,data:i}=oy(e,n,o.files,o);try{let{fileHandle:a}=await gc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:vn.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:vn.NEVER,appState:{toast:null}}}finally{Gi=!1}},keyTest:e=>e.key.toLowerCase()===zd.S&&e.shiftKey&&e[zd.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Jo(K,{type:"button",icon:Ax,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:ge().formFactor==="phone",hidden:!mi,onClick:()=>e(null),"data-testid":"save-as-button"})}),Ui=F({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 du(n,e);return{elements:r,appState:i,files:a,captureUpdate:vn.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:vn.EVENTUALLY}}},keyTest:e=>e[zd.CTRL_OR_CMD]&&e.key===zd.O}),ry=F({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?Us.DARK:Us.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:vn.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Jo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Jo(Xw,{value:e.exportWithDarkMode?Us.DARK:Us.LIGHT,onChange:t=>{n(t===Us.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as yL,DEFAULT_FONT_FAMILY as vL,DEFAULT_TEXT_ALIGN as IL,getLineHeight as TL}from"@excalidraw/common";import{newElementWith as Gd}from"@excalidraw/element";import{hasBoundTextElement as SL,canApplyRoundnessTypeToElement as CL,getDefaultRoundnessTypeForElement as PL,isFrameLikeElement as kL,isArrowElement as ML,isExcalidrawElement as AL,isTextElement as ay}from"@excalidraw/element";import{getBoundTextElement as LL,redrawTextBoundingBox as DL}from"@excalidraw/element";import{CaptureUpdateAction as Hh}from"@excalidraw/element";var sy="{}",_L=F({name:"copyStyles",label:"labels.copyStyles",icon:Nu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&SL(i)){let a=LL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(sy=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:Hh.EVENTUALLY}}}),RL=F({name:"pasteStyles",label:"labels.pasteStyles",icon:Nu,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(sy),i=r[0],a=r[1];if(!AL(i))return{elements:e,captureUpdate:Hh.EVENTUALLY};let s=se(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(ay(c)&&c.containerId&&(d=a),!d)return c;let m=Gd(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?CL(d.roundness.type,c)?d.roundness:PL(c):null});if(ay(m)){let p=d.fontSize||yL,u=d.fontFamily||vL,E=Gd(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||IL,lineHeight:d.lineHeight||TL(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"&&ML(d)&&(m=Gd(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),kL(c)&&(m=Gd(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:Hh.IMMEDIATELY}}});import{KEYS as NL}from"@excalidraw/common";import{CaptureUpdateAction as BL}from"@excalidraw/element";var Hr=F({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Sx,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,n,t,{focusContainer:o})=>(n.openDialog?.name==="help"&&o(),{appState:{...n,openDialog:n.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:BL.EVENTUALLY}),keyTest:e=>e.key===NL.QUESTION_MARK});import{getNonDeletedElements as Wd}from"@excalidraw/element";import{newElementWith as cy}from"@excalidraw/element";import{isBoundToContainer as OL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as FL,getElementsInResizingFrame as zL,getFrameLikeElements as HL,getRootElements as GL,groupByFrameLikes as UL,removeElementsFromFrame as WL,replaceAllElementsInFrame as VL}from"@excalidraw/element";import{KEYS as Vd,randomId as YL,arrayToMap as Uh}from"@excalidraw/common";import{getSelectedGroupIds as Ud,selectGroup as XL,selectGroupsForSelectedElements as KL,getElementsInGroup as ly,addToGroup as ZL,removeFromSelectedGroups as $L,isElementInGroup as dy}from"@excalidraw/element";import{syncMovedIndices as jL}from"@excalidraw/element";import{CaptureUpdateAction as Vs}from"@excalidraw/element";import{jsx as Wi}from"react/jsx-runtime";var qL=(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=>dy(i,r)))return!0}return!1},Gh=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!qL(t,e.editingGroupId)&&!FL(t)},Wh=F({name:"group",label:"labels.group",icon:e=>Wi(ku,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!Gh(n,o))return!1;let r=GL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:Vs.EVENTUALLY};let i=Ud(n);if(i.length===1){let b=i[0],y=new Set(ly(e,b).map(v=>v.id)),w=new Set(r.map(v=>v.id));if(new Set([...Array.from(y),...Array.from(w)]).size===y.size)return{appState:n,elements:e,captureUpdate:Vs.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&UL(r).forEach((y,w)=>{WL(y,o.scene.getNonDeletedElementsMap())});let l=YL(),c=Uh(r);a=a.map(b=>c.get(b.id)?cy(b,{groupIds:ZL(b.groupIds,l,n.editingGroupId)}):b);let d=ly(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!dy(b,l)),g=jL([...E,...d,...u],Uh(d));return{appState:{...n,...XL(l,{...n,selectedGroupIds:{}},Wd(a))},elements:g,captureUpdate:Vs.IMMEDIATELY}},predicate:(e,n,t,o)=>Gh(n,o),keyTest:e=>!e.shiftKey&&e[Vd.CTRL_OR_CMD]&&e.key===Vd.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Wi(K,{hidden:!Gh(n,o),type:"button",icon:Wi(ku,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Me(Wd(e),n)})}),Vh=F({name:"ungroup",label:"labels.ungroup",icon:e=>Wi(Mu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=Ud(n),i=Uh(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:Vs.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{OL(p)&&s.push(p.id);let u=$L(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:cy(p,{groupIds:u})});let l=KL(n,Wd(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return HL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=VL(a,zL(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:Vs.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Vd.CTRL_OR_CMD]&&e.key===Vd.G.toUpperCase(),predicate:(e,n)=>Ud(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>Wi(K,{type:"button",hidden:Ud(n).length===0,icon:Wi(Mu,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Me(Wd(e),n)})});import rD from"clsx";import{CaptureUpdateAction as gy}from"@excalidraw/element";import{invariant as iD}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as JL,COLOR_VOICE_CALL as QL,COLOR_WHITE as Xd,THEME as eD,UserIdleState as my}from"@excalidraw/common";var Yd=(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 tD(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 Gr=(e,n)=>`hsl(${Math.abs(tD(n?.id||e))%37*10}, 100%, 83%)`,py=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},uy=({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=Gr(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===my.IDLE||E===my.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===eD.DARK?"#2f6330":QL,y=c?.isSpeaking;y&&(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=Xd,e.strokeStyle=Xd,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 w=n.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let x=(y?s+0:s)+d/2,v=(y?l+0:l)+m+2,T=5,C=3,P=e.measureText(w),A=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,L=Math.max(A,12),_=x-1,k=v-1,D=P.width+2+T*2+2,O=L+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,D,O,8),e.fillStyle=u,e.fill(),e.strokeStyle=Xd,e.stroke(),y&&(e.beginPath(),e.roundRect(_-2,k-2,D+4,O+4,8),e.strokeStyle=b,e.stroke())):Yd(e,_,k,D,O,8,Xd),e.fillStyle=JL,e.fillText(w,x+T+1,v+C+P.actualBoundingBoxAscent+Math.floor((L-A)/2)+2),y){e.fillStyle=b;let Y=8,z=8,W=5;e.fillRect(_+D+z,k+(O/2-Y/2),2,Y),e.fillRect(_+D+z+W,k+(O/2-Y*2/2),2,Y*2),e.fillRect(_+D+z+W*2,k+(O/2-Y/2),2,Y)}}e.restore(),e.closePath()}};import nD from"clsx";import{useState as oD}from"react";import{jsx as hy}from"react/jsx-runtime";var Yh=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=py(t),[a,s]=oD(!1),l=!a&&o,c=l?void 0:{background:e};return hy("div",{className:nD("Avatar",r),style:c,onClick:n,children:l?hy("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as Xn,jsxs as Kd}from"react/jsx-runtime";var aD=F({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(iD(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:gy.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:gy.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=Gr(o,r),l=rD({"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?Kd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[Xn("div",{}),Xn("div",{}),Xn("div",{})]}):r.isMuted?Xn("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:R1}):Xn("div",{title:f("userList.hint.inCall"),children:_1}):null;return i?Kd("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:[Xn(Yh,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),Xn("div",{className:"UserList__collaborator-name",children:r.username}),Kd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Xn("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Ar}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):Kd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[Xn(Yh,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&Xn("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as Vi}from"@excalidraw/element";import{isFrameLikeElement as sD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as lD}from"@excalidraw/element";import{KEYS as Qo,arrayToMap as cD}from"@excalidraw/common";import{alignElements as dD}from"@excalidraw/element";import{CaptureUpdateAction as Yi}from"@excalidraw/element";import{getSelectedElementsByGroup as mD}from"@excalidraw/element";import{jsx as Ki}from"react/jsx-runtime";var pt=(e,n)=>{let t=n.scene.getSelectedElements(e);return mD(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>sD(o))},Xi=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=dD(r,o,t.scene,n),a=cD(i);return lD(e.map(s=>a.get(s.id)||s),n,t)},pD=F({name:"alignTop",label:"labels.alignTop",icon:vu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"start",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:vu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Me(Vi(e),n)})}),uD=F({name:"alignBottom",label:"labels.alignBottom",icon:Iu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"end",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Iu,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Me(Vi(e),n)})}),hD=F({name:"alignLeft",label:"labels.alignLeft",icon:Tu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"start",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Tu,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Me(Vi(e),n)})}),gD=F({name:"alignRight",label:"labels.alignRight",icon:Su,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"end",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),keyTest:e=>e[Qo.CTRL_OR_CMD]&&e.shiftKey&&e.key===Qo.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Su,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Me(Vi(e),n)})}),fD=F({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Cu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"center",axis:"y"}),captureUpdate:Yi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Cu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Me(Vi(e),n)})}),ED=F({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Pu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>pt(n,o),perform:(e,n,t,o)=>({appState:n,elements:Xi(e,n,o,{position:"center",axis:"x"}),captureUpdate:Yi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Ki(K,{hidden:!pt(n,o),type:"button",icon:Pu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Me(Vi(e),n)})});import{getNonDeletedElements as fy}from"@excalidraw/element";import{isFrameLikeElement as bD}from"@excalidraw/element";import{CODES as Ey,KEYS as by,arrayToMap as xD}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as wD}from"@excalidraw/element";import{distributeElements as yD}from"@excalidraw/element";import{CaptureUpdateAction as xy}from"@excalidraw/element";import{getSelectedElementsByGroup as vD}from"@excalidraw/element";import{jsx as vy}from"react/jsx-runtime";var wy=(e,n)=>{let t=n.scene.getSelectedElements(e);return vD(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>bD(o))},yy=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=yD(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=xD(i);return wD(e.map(s=>a.get(s.id)||s),n,t)},ID=F({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:yy(e,n,o,{space:"between",axis:"x"}),captureUpdate:xy.IMMEDIATELY}),keyTest:e=>!e[by.CTRL_OR_CMD]&&e.altKey&&e.code===Ey.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>vy(K,{hidden:!wy(n,o),type:"button",icon:zx,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Me(fy(e),n)})}),TD=F({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:yy(e,n,o,{space:"between",axis:"y"}),captureUpdate:xy.IMMEDIATELY}),keyTest:e=>!e[by.CTRL_OR_CMD]&&e.altKey&&e.code===Ey.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>vy(K,{hidden:!wy(n,o),type:"button",icon:Hx,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Me(fy(e),n)})});import{arrayToMap as Iy,KEYS as CD,matchKey as PD}from"@excalidraw/common";import{CaptureUpdateAction as kD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as MD}from"@excalidraw/element/frame";import{arrangeElements as AD}from"@excalidraw/element/arrange";var SD={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},Zi=(e,n)=>({smartZoom:{...SD,...n?.smartZoom},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as RD}from"react/jsx-runtime";var LD=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Iy(e),{arrange:i}=Zi(n,t.props.editorPreferences),a=AD(t.scene,o,r,i.algorithm,i.gap),s=Iy(a);return MD(e.map(l=>s.get(l.id)||l),n,t)},DD=pt,_D=F({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:Ou,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>DD(n,o),perform:(e,n,t,o)=>({appState:n,elements:LD(e,n,o),captureUpdate:kD.IMMEDIATELY}),keyTest:e=>e.shiftKey&&PD(e,CD.R),PanelComponent:({updateData:e})=>RD("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+R")}`,children:Ou})});import{arrayToMap as Ty}from"@excalidraw/common";import{CaptureUpdateAction as ND}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as BD}from"@excalidraw/element/frame";import{normaliseElements as OD}from"@excalidraw/element/normalise";import{jsx as GD}from"react/jsx-runtime";var FD=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Ty(e),{normalise:i}=Zi(n,t.props.editorPreferences),a=OD(t.scene,o,r,i.mode,i.metric),s=Ty(a);return BD(e.map(l=>s.get(l.id)||l),n,t)},zD=pt,HD=F({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:Fu,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>zD(n,o),perform:(e,n,t,o)=>({appState:n,elements:FD(e,n,o),captureUpdate:ND.IMMEDIATELY}),PanelComponent:({updateData:e})=>GD("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:Fu})});import{getNonDeletedElements as UD}from"@excalidraw/element";import{bindOrUnbindBindingElements as WD}from"@excalidraw/element";import{getCommonBoundingBox as Sy}from"@excalidraw/element";import{newElementWith as VD}from"@excalidraw/element";import{deepCopyElement as YD}from"@excalidraw/element";import{resizeMultipleElements as XD}from"@excalidraw/element";import{isArrowElement as Cy,isElbowArrow as KD}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Py}from"@excalidraw/element";import{CODES as ky,KEYS as ZD,arrayToMap as $D}from"@excalidraw/common";import{CaptureUpdateAction as My}from"@excalidraw/element";var Xh=F({name:"flipHorizontal",label:"labels.flipHorizontal",icon:F1,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Py(Ay(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:My.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ky.H}),Kh=F({name:"flipVertical",label:"labels.flipVertical",icon:O1,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Py(Ay(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:My.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ky.V&&!e[ZD.CTRL_OR_CMD]}),Ay=(e,n,t,o,r)=>{let i=se(UD(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=jD(i,n,o,r),s=$D(a);return e.map(l=>s.get(l.id)||l)},jD=(e,n,t,o)=>{if(e.every(p=>Cy(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return VD(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=Sy(e);XD(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,YD(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),WD(e.filter(Cy),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>KD(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=Sy(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 qD}from"@excalidraw/element";import{getTextFromElements as JD}from"@excalidraw/element";import{CODES as QD,KEYS as Ly,isFirefox as e_}from"@excalidraw/common";import{CaptureUpdateAction as Xt}from"@excalidraw/element";var $i=F({name:"copy",label:"labels.copy",icon:ds,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Bd(r,o.files,t)}catch(i){return{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Xt.EVENTUALLY}},keyTest:void 0}),Zh=F({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await Jw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),e_?{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(jw({types:r}))}catch(i){return console.error(i),{captureUpdate:Xt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Xt.EVENTUALLY}},keyTest:void 0}),Zd=F({name:"cut",label:"labels.cut",icon:k1,trackEvent:{category:"element"},perform:(e,n,t,o)=>($i.perform(e,n,t,o),Es.perform(e,n,null,o)),keyTest:e=>e[Ly.CTRL_OR_CMD]&&e.key===Ly.X}),t_=F({name:"copyAsSvg",label:"labels.copyAsSvg",icon:z1,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Xt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Or(e,n,!0);try{await Fr("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:Xt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Xt.EVENTUALLY}}},predicate:e=>Nd&&e.length>0,keywords:["svg","clipboard","copy"]}),n_=F({name:"copyAsPng",label:"labels.copyAsPng",icon:H1,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Xt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Or(e,n,!0);try{return await Fr("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:Xt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Xt.EVENTUALLY}}},predicate:e=>qo&&e.length>0,keyTest:e=>e.code===QD.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),o_=F({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0});try{ho(JD(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Xt.EVENTUALLY}},predicate:(e,n,t,o)=>Nd&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(qD),keywords:["text","clipboard","copy"]});import{CODES as r_,KEYS as i_}from"@excalidraw/common";import{CaptureUpdateAction as a_}from"@excalidraw/element";var ji=F({name:"gridMode",icon:U1,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:a_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[i_.CTRL_OR_CMD]&&e.code===r_.QUOTE});import{KEYS as $h}from"@excalidraw/common";import{CaptureUpdateAction as s_}from"@excalidraw/element/store";import{jsx as l_}from"react/jsx-runtime";var Ys=F({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:zu,viewMode:!0,perform:(e,n,t,o)=>{let r=Zi(n,o.props.editorPreferences).smartZoom,i=se(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:s_.NEVER}},keyTest:e=>!e[$h.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===$h.F,PanelComponent:({data:e,updateData:n})=>l_(K,{type:"button",icon:zu,"aria-label":f("labels.smartZoom"),onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:$h.F.toLocaleUpperCase()})});import{CODES as c_,KEYS as d_}from"@excalidraw/common";import{CaptureUpdateAction as m_}from"@excalidraw/element";var kt=F({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Fo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:m_.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[d_.CTRL_OR_CMD]&&e.altKey&&e.code===c_.S});import{CaptureUpdateAction as p_}from"@excalidraw/element";var Xs=F({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:p_.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as u_}from"@excalidraw/element";var Ks=F({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:u_.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as h_,KEYS as g_}from"@excalidraw/common";import{CaptureUpdateAction as f_}from"@excalidraw/element";var er=F({name:"stats",label:"stats.fullTitle",icon:B1,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:f_.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[g_.CTRL_OR_CMD]&&e.altKey&&e.code===h_.SLASH});import{BOUND_TEXT_PADDING as Dy,ROUNDNESS as _y,TEXT_ALIGN as By,VERTICAL_ALIGN as Oy,arrayToMap as Fy,getFontString as E_,getStrokeWidthByKey as b_}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as x_,isBoundToContainer as Ry,resetOriginalContainerCache as w_,updateOriginalContainerCache as y_}from"@excalidraw/element";import{computeBoundTextPosition as v_,computeContainerDimensionForBoundText as Ny,getBoundTextElement as zy,redrawTextBoundingBox as Hy}from"@excalidraw/element";import{hasBoundTextElement as I_,isArrowElement as T_,isTextBindableContainer as jh,isTextElement as Zs,isUsingAdaptiveRadius as S_}from"@excalidraw/element";import{measureText as C_}from"@excalidraw/element";import{syncMovedIndices as Gy}from"@excalidraw/element";import{newElement as P_}from"@excalidraw/element";import{CaptureUpdateAction as qh}from"@excalidraw/element";var Jh=F({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>I_(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=zy(a,i);if(s){let{width:l,height:c}=C_(s.originalText,E_(s),s.lineHeight),d=x_(a.id);w_(a.id);let{x:m,y:p}=v_(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:qh.IMMEDIATELY}}}),Qh=F({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=Zs(r[0])||Zs(r[1]),a;if(jh(r[0])?a=r[0]:jh(r[1])&&(a=r[1]),i&&a&&zy(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;Zs(r[0])&&jh(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:Oy.MIDDLE,textAlign:By.CENTER,autoResize:!0,angle:T_(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return Hy(i,a,o.scene),y_(a.id,s),{elements:k_(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:qh.IMMEDIATELY}}}),k_=(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),Gy(o,Fy([n,t])),o},M_=(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),Gy(o,Fy([n,t])),o},Uy=F({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>Zs(a)&&!Ry(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(Zs(s)&&!Ry(s)){let l=P_({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:b_("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:S_("rectangle")?_y.ADAPTIVE_RADIUS:_y.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-Dy,y:s.y-Dy,width:Ny(s.width,"rectangle"),height:Ny(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:Oy.MIDDLE,boundElements:null,textAlign:By.CENTER,autoResize:!0}),Hy(s,l,o.scene),i=M_([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:qh.IMMEDIATELY}}});import{getNonDeletedElements as Jy,isEmbeddableElement as X_}from"@excalidraw/element";import{KEYS as Qy}from"@excalidraw/common";import{CaptureUpdateAction as K_}from"@excalidraw/element";import{pointFrom as Xy}from"@excalidraw/math";import A_ from"clsx";import{useCallback as Wy,useEffect as Vy,useLayoutEffect as L_,useRef as D_,useState as __}from"react";import{EVENT as eg,HYPERLINK_TOOLTIP_DELAY as R_,KEYS as $d}from"@excalidraw/common";import{getElementAbsoluteCoords as ig}from"@excalidraw/element";import{hitElementBoundingBox as N_}from"@excalidraw/element";import{isElementLink as B_}from"@excalidraw/element";import{getEmbedLink as O_,embeddableURLValidator as F_}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Ky,viewportCoordsToSceneCoords as z_,wrapEvent as H_,isLocalLink as G_,normalizeLink as tg}from"@excalidraw/common";import{isEmbeddableElement as ng}from"@excalidraw/element";import{jsx as qi,jsxs as Yy}from"react/jsx-runtime";var ag=380,U_=42,og=5,Zy=85,W_=500,rg=!1,jd=new Map,$y=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=Ko(),l=yn(),c=ge(),d=e.link||"",[m,p]=__(d),u=D_(null),E=s.showHyperlinkPopup==="editor",g=Wy(()=>{if(!u.current)return;let v=tg(u.current.value)||null;if(!e.link&&v&&Ne("hyperlink","create"),ng(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){n.mutateElement(e,{link:null}),i(e,!1);return}if(!F_(v,l.validateEmbeddable))v&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&jd.set(e.id,e.link),n.mutateElement(e,{link:v}),i(e,!1);else{let{width:T,height:C}=e,P=O_(v);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let A=P?P.intrinsicSize.w/P.intrinsicSize.h:1,L=jd.get(e.id)!==e.link;n.mutateElement(e,{...L?{width:P?.type==="video"?T>C?T:C*A:T,height:P?.type==="video"&&T>C?T/A:C}:{},link:v}),i(e,!0),jd.has(e.id)&&jd.delete(e.id)}}else n.mutateElement(e,{link:v})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);L_(()=>()=>{g()},[g]),Vy(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),Vy(()=>{let v=null,T=C=>{if(E)return;v&&clearTimeout(v),Y_(e,a,s,Xy(C.clientX,C.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},W_))};return window.addEventListener(eg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(eg.POINTER_MOVE,T,!1),v&&clearTimeout(v)}},[s,e,E,t,a]);let b=Wy(()=>{Ne("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),y=()=>{Ne("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:w,y:x}=jy(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:Yy("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${w}px`,width:ag,padding:og},children:[E?qi("input",{className:A_("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:m,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[$d.CTRL_OR_CMD]&&v.key===$d.K&&v.preventDefault(),(v.key===$d.ENTER||v.key===$d.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?qi("a",{href:tg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:G_(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&o){let T=H_(eg.EXCALIDRAW_LINK,v.nativeEvent);o({...e,link:tg(e.link)},T),T.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):qi("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),Yy("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&qi(K,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:y,className:"excalidraw-hyperlinkContainer--edit",icon:Hn}),qi(K,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:X1}),d&&!ng(e)&&qi(K,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Pr})]})]})},jy=(e,n,t)=>{let[o,r]=ig(e,t),{x:i,y:a}=Ky({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-ag/2,l=a-n.offsetTop-Zy;return{x:s,y:l}},sg=(e,n)=>{let t=se(e,n);return ng(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},$s=null,qy=(e,n,t)=>{$s&&clearTimeout($s),$s=window.setTimeout(()=>V_(e,n,t),R_)},V_=(e,n,t)=>{if(!e.link)return;let o=Ri();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=B_(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=ig(e,t),[l,c,d,m]=Xb([r,i,a,s],e.angle,n),p=Ky({sceneX:l,sceneY:c},n);Th(o,{left:p.x,top:p.y,width:d,height:m},"top"),Ne("hyperlink","tooltip","link-icon"),rg=!0},qd=()=>{$s&&clearTimeout($s),rg&&(rg=!1,Ri().classList.remove("excalidraw-tooltip--visible"))},Y_=(e,n,t,[o,r])=>{let{x:i,y:a}=z_({clientX:o,clientY:r},t),s=15/t.zoom.value;if(N_(Xy(i,a),e,n))return!1;let[l,c,d]=ig(e,n);if(i>=l&&i<=d&&a>=c-Zy&&a<=c)return!1;let{x:m,y:p}=jy(e,t,n);return!(o>=m-s&&o<=m+ag+og*2+s&&r>=p-s&&r<=p+s+og*2+U_)};import{jsx as Z_}from"react/jsx-runtime";var lg=F({name:"hyperlink",label:(e,n)=>sg(Jy(e),n),icon:hs,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:K_.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[Qy.CTRL_OR_CMD]&&e.key===Qy.K,predicate:(e,n)=>se(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=se(e,n);return Z_(K,{type:"toggle",icon:hs,"aria-label":f(sg(Jy(e),n)),title:`${X_(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 ev,arrayToMap as dg,randomId as $_}from"@excalidraw/common";import{elementsAreInSameGroup as j_,getNonDeletedElements as tv,newElementWith as nv,selectGroupsFromGivenElements as ov}from"@excalidraw/element";import{CaptureUpdateAction as rv}from"@excalidraw/element";var cg=e=>e.every(n=>!n.locked),js=F({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=se(n,e);return cg(t)?No:so},trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=cg(r),a=dg(r),s=r.length>1&&j_(r),c=r.length===1||s?null:$_(),d={...n.lockedMultiSelections};if(i)d={...n.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let y=r[0].groupIds.at(-1);delete d[y]}let m=e.map(y=>{if(!a.has(y.id))return y;let w=y.groupIds;return i?c&&(w=[...w,c]):w=w.filter(x=>!n.lockedMultiSelections[x]),nv(y,{locked:i,groupIds:w.length!==y.groupIds.length?w:y.groupIds})}),p=dg(m),u=i?{}:Object.fromEntries(r.map(y=>[y.id,!0])),E=r.map(y=>p.get(y.id)||y),g=i?{}:ov(tv(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:rv.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===ev.L&&e[ev.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),iv=F({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:so,predicate:(e,n)=>se(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 nv(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=dg(o),i=t.map(s=>r.get(s.id)||s),a=tv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:ov(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:rv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as l8,isLinearElement as c8,isLineElement as ia}from"@excalidraw/element";import{arrayToMap as d8,invariant as Wv}from"@excalidraw/common";import{toggleLinePolygonState as m8,CaptureUpdateAction as Vv}from"@excalidraw/element";import{getSizeFromPoints as kIe,randomInteger as a8,getUpdatedTimestamp as s8}from"@excalidraw/common";import{simplify as HR}from"points-on-curve";import{getStroke as GR,getStrokePoints as cIe}from"perfect-freehand";function Xe([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function Ji([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function et([e,n,t],o){return[e*o,n*o,t*o]}function Wr([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function Et([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function av(e,n,t){return Xe(e,et(Ji(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 pg(e){return Math.atan2(Math.sin(e),Math.cos(e))}function ug([e,n]){return Math.sqrt(e**2+n**2)}function Ur([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function sv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=Ur(e[t-1],e[t]);return n+=Ur(e[e.length-2],e[e.length-1]),n}var q_=(e,n,t)=>Math.max(n,Math.min(t,e));function lv(e,n,t){let o=Ur(n,t);if(o===0)return Ur(e,n);let r=q_(((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 Ur(i,e)}function qs(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=lv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...qs([t,...e.slice(1,i),a],n).slice(0,-1),a,...qs([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var tr=class tr{constructor(n){I(this,"options");I(this,"originalPoints",[]);I(this,"stablePoints",[]);I(this,"tailPoints",[]);I(this,"isFresh",!0);this.options=Object.assign({},tr.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=av(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),sv(this.tailPoints)>tr.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=qs(t,this.options.simplify));let o=t.length;if(o===0)return[];if(o===1){let P=t[0],A=this.getSize(n,P[2],0,o,0);if(A<.5)return[];let L=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)L.push(Xe(P,et(Et([1,0,0],_),A)));return L.push(Xe(P,et([1,0,0],this.getSize(n,P[2],0,o,0)))),L}if(o===2){let P=t[0],A=t[1],L=this.getSize(n,P[2],0,o,0),_=this.getSize(n,A[2],0,o,0);if(L<.5||_<.5)return[];let k=[],D=mg(P,[P[0],P[1]-100,P[2]],A);for(let O=D;O<=Math.PI+D;O+=Math.PI/16)k.push(Xe(P,et(Et([1,0,0],O),L)));for(let O=Math.PI+D;O<=Math.PI*2+D;O+=Math.PI/16)k.push(Xe(A,et(Et([1,0,0],O),_)));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 A=t[P-1],L=t[P],_=t[P+1],k=L[2],D=Ur(A,L);c+=D,a=s+(D-s)*.2;let O=this.getSize(n,k,P,o,c);if(O===0){l=P+1;continue}let Y=Wr(Ji(A,L)),z=Wr(Ji(_,L)),W=Et(Y,Math.PI/2),Z=Et(Y,-Math.PI/2),H=Et(z,Math.PI/2),re=Et(z,-Math.PI/2),B=Xe(L,et(W,O)),U=Xe(L,et(Z,O)),ue=Xe(L,et(H,O)),we=Xe(L,et(re,O)),pe=Xe(W,re),he=Xe(Z,H),ye=Xe(L,et(ug(pe)===0?Y:Wr(pe),O)),ae=Xe(L,et(ug(he)===0?z:Wr(he),O)),ve=pg(mg(L,A,_)),st=tr.constants.cornerDetectionMaxAngle/180*Math.PI*tr.constants.cornerDetectionVariance(a);if(Math.abs(ve)<st){let je=Math.abs(pg(Math.PI-ve));if(je===0)continue;if(ve<0){i.push(U,ae);for(let Re=0;Re<=je;Re+=je/4)r.push(Xe(L,Et(et(W,O),Re)));for(let Re=je;Re>=0;Re-=je/4)i.push(Xe(L,Et(et(W,O),Re)));i.push(ae,ue)}else{r.push(B,ye);for(let Re=0;Re<=je;Re+=je/4)i.push(Xe(L,Et(et(W,-O),-Re)));for(let Re=je;Re>=0;Re-=je/4)r.push(Xe(L,Et(et(W,-O),-Re)));r.push(ye,we)}}else r.push(ye),i.push(ae);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],A=[];for(let L=0;L<=Math.PI*2;L+=Math.PI/16)A.push(Xe(P,et(Et([1,0,0],L),this.options.size)));return A.push(Xe(P,et([1,0,0],this.options.size))),A}return[]}let d=t[l],m=t[l+1],p=t[o-2],u=t[o-1],E=Wr(Ji(m,d)),g=Wr(Ji(p,u)),b=Et(E,-Math.PI/2),y=Et(g,Math.PI/2),w=this.getSize(n,d[2],0,o,0),x=[],v=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,c),T=[];if(w>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift(Xe(d,Et(et(b,w),-P)));x.unshift(Xe(d,et(b,-w)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push(Xe(u,Et(et(y,-v),-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"?qs(C,this.options.simplify):C}};I(tr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),I(tr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var Qi=tr;import{pointsOnBezierCurves as Ice}from"points-on-curve";import{invariant as Sce}from"@excalidraw/common";import{curve as Pce,lineSegment as kce,pointFrom as Mce,pointDistance as Ace,pointFromArray as Lce,pointFromVector as Dce,pointRotateRads as _ce,polygon as Rce,polygonFromPoints as Nce,PRECISION as Bce,segmentsIntersectAt as Oce,vector as Fce,vectorAdd as zce,vectorFromPoint as Hce,vectorScale as Gce}from"@excalidraw/math";import{getElementAbsoluteCoords as Wce}from"@excalidraw/element";var hg=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 UR,pointDistance as Ov,pointRotateRads as uIe}from"@excalidraw/math";import{ROUGHNESS as WR,THEME as Dg,isTransparent as dl,assertNever as VR,COLOR_PALETTE as YR,LINE_POLYGON_POINT_MERGE_DISTANCE as gIe,applyDarkModeFilter as ml,DEFAULT_STROKE_STREAMLINE as XR}from"@excalidraw/common";import{RoughGenerator as KR}from"roughjs/bin/generator";import v2e from"roughjs/bin/rough";import{isRightAngleRads as T2e,lineSegment as S2e,pointFrom as C2e,pointRotateRads as P2e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as M2e,DEFAULT_REDUCED_GLOBAL_ALPHA as A2e,ELEMENT_READY_TO_ERASE_OPACITY as L2e,FRAME_STYLE as D2e,DARK_THEME_FILTER as _2e,MIME_TYPES as Bv,THEME as R2e,distance as N2e,getFontString as B2e,isRTL as O2e,getVerticalOffset as F2e,invariant as z2e,applyDarkModeFilter as H2e,isSafari as G2e}from"@excalidraw/common";import Kve from"roughjs/bin/rough";import{arrayToMap as $ve,invariant as Nv,rescalePoints as jve,sizeOf as qve}from"@excalidraw/common";import{degreesToRadians as kg,lineSegment as Qve,pointFrom as bt,pointFromArray as _R,pointRotateRads as ra}from"@excalidraw/math";import{pointsOnBezierCurves as n2e}from"points-on-curve";import{pointCenter as mve,pointFrom as pve,pointRotateRads as uve,pointsEqual as hve,pointDistance as gve,vectorFromPoint as fve,curveLength as Eve,curvePointAtLength as bve}from"@excalidraw/math";import{DRAGGING_THRESHOLD as yve,KEYS as vve,shouldRotateWithDiscreteAngle as Ive,getGridPoint as Tve,invariant as Sve,isShallowEqual as Cve,getFeatureFlag as Pve}from"@excalidraw/common";import{arrayToMap as Cye,getFeatureFlag as Pye,getGridPoint as kye,invariant as Mye,isTransparent as Aye}from"@excalidraw/common";import{PRECISION as Dye,clamp as _ye,lineSegment as Rye,pointDistance as Nye,pointDistanceSq as Bye,pointFrom as Oye,pointFromArray as Fye,pointFromVector as zye,pointRotateRads as Hye,pointsEqual as Gye,vectorFromPoint as Uye,vectorNormalize as Wye,vectorScale as Vye}from"@excalidraw/math";import{invariant as Kwe,isTransparent as Zwe}from"@excalidraw/common";import{curveIntersectLineSegment as jwe,isPointWithinBounds as qwe,lineSegment as Jwe,lineSegmentIntersectionPoints as Qwe,pointFrom as eye,pointFromVector as tye,pointRotateRads as nye,pointsEqual as oye,vectorFromPoint as rye,vectorNormalize as iye,vectorScale as aye}from"@excalidraw/math";import{ellipse as lye,ellipseSegmentInterceptPoints as cye}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as tR,DEFAULT_PROPORTIONAL_RADIUS as Eg,invariant as ede,LINE_CONFIRM_THRESHOLD as nR,ROUNDNESS as bg}from"@excalidraw/common";import{bezierEquation as nde,curve as ode,curveCatmullRomCubicApproxPoints as rde,curveOffsetPoints as ide,lineSegment as ade,lineSegmentIntersectionPoints as sde,pointDistance as oR,pointFrom as lde,pointFromArray as cde,pointFromVector as dde,pointRotateRads as mde,pointTranslate as pde,rectangle as ude,vectorFromPoint as hde,vectorNormalize as gde,vectorScale as fde}from"@excalidraw/math";import{ROUNDNESS as Kce,assertNever as Zce}from"@excalidraw/common";import{pointsEqual as jce}from"@excalidraw/math";var cv=e=>!!e&&e.type==="embeddable",gg=e=>!!e&&e.type==="iframe",fg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),rn=e=>e!=null&&e.type==="text";var Kn=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var an=e=>e!=null&&Q_(e.type);var In=e=>e!=null&&e.type==="arrow",Tn=e=>In(e)&&e.elbowed;var Q_=e=>e==="arrow"||e==="line";var go=e=>e!==null&&"containerId"in e&&e.containerId!==null&&rn(e);var ea=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return oR(t,o)<=nR/n}return!1},Js=(e,n)=>{if(n.roundness?.type===bg.PROPORTIONAL_RADIUS||n.roundness?.type===bg.LEGACY)return e*Eg;if(n.roundness?.type===bg.ADAPTIVE_RADIUS){let t=n.roundness?.value??tR,o=t/Eg;return e<=o?e*Eg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Cwe,ARROW_LABEL_WIDTH_FRACTION as Pwe,BOUND_TEXT_PADDING as kwe,DEFAULT_FONT_SIZE as Mwe,TEXT_ALIGN as Awe,VERTICAL_ALIGN as Lwe,getFontString as Dwe,isProdEnv as _we,invariant as Rwe}from"@excalidraw/common";import{pointFrom as Bwe,pointRotateRads as Owe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Ade,DEFAULT_FONT_SIZE as Lde,DEFAULT_FONT_FAMILY as Dde,getFontString as _de,isTestEnv as Rde,normalizeEOL as Nde}from"@excalidraw/common";var Bde="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Wde,isTestEnv as Vde}from"@excalidraw/common";import{toIterable as y0e}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as $de,viewportCoordsToSceneCoords as jde}from"@excalidraw/common";import{normalizeRadians as Jde,radiansBetweenAngles as Qde,radiansDifference as eme}from"@excalidraw/math";import{pointsEqual as nme}from"@excalidraw/math";import{arrayToMap as Hme,isShallowEqual as sR}from"@excalidraw/common";import{arrayToMap as wme}from"@excalidraw/common";import{isPointWithinBounds as vme,pointFrom as Ime,segmentsIntersectAt as Tme}from"@excalidraw/math";import{arrayToMap as lme}from"@excalidraw/common";import{validateOrderKey as dme,generateNKeysBetween as mme}from"@excalidraw/fractional-indexing";var xg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var Zme=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}(),ol=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){Vr(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&&go(i)&&Vr(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{Kn(a)&&xg(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var yg=(e,n)=>sR(n.selectedElementIds,e)?n.selectedElementIds:e;var lR=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:yg({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):ol(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:yg(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var ppe=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as lue,VERTICAL_ALIGN as cue}from"@excalidraw/common";import{pointDistance as mue,pointFromVector as pue,pointsEqual as uue,vector as hue,vectorDot as gue,vectorFromPoint as fue,vectorNormalize as Eue,vectorScale as bue}from"@excalidraw/math";import{invariant as Tpe,isDevEnv as Spe,isTestEnv as Cpe}from"@excalidraw/common";import{pointFrom as kpe,pointFromVector as Mpe,pointRotateRads as Ape,pointScaleFromOrigin as Lpe,pointsEqual as Dpe,triangleIncludesPoint as _pe,vectorCross as Rpe,vectorFromPoint as mR,vectorScale as Npe}from"@excalidraw/math";var al=[1,0],nm=[0,1],sl=[-1,0],om=[0,-1],rm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?al:n<=-r?sl:t>o?nm:om},bv=(e,n)=>rm(mR(e,n)),im=(e,n)=>am(bv(e,n)),il=(e,n)=>e[0]===n[0]&&e[1]===n[1],am=e=>il(e,al)||il(e,sl);import{DEFAULT_ELEMENT_PROPS as Hpe,DEFAULT_FONT_FAMILY as Gpe,DEFAULT_FONT_SIZE as Upe,DEFAULT_TEXT_ALIGN as Wpe,DEFAULT_VERTICAL_ALIGN as Vpe,DEFAULT_STROKE_STREAMLINE as Ype,VERTICAL_ALIGN as Xpe,randomInteger as Kpe,randomId as Zpe,getFontString as $pe,getUpdatedTimestamp as jpe,getLineHeight as qpe}from"@excalidraw/common";import{pointsOnBezierCurves as Gue,simplify as Uue}from"points-on-curve";import{curveToBezier as Vue}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as Xue,lineSegment as Kue,lineSegmentIntersectionPoints as Zue,pointDistance as $ue,pointFrom as jue,pointRotateRads as que,polygonArea as Jue,polygonIncludesPoint as Que,polygonIncludesPointNonZero as ehe,polygonSignedArea as the}from"@excalidraw/math";import{isOpaqueColor as ohe,isTransparent as rhe}from"@excalidraw/common";var vv=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as Mue,distanceToLineSegment as Aue,pointRotateRads as Lue}from"@excalidraw/math";import{ellipse as _ue,ellipseDistanceFromPoint as Rue}from"@excalidraw/math/ellipse";import{pointFrom as bhe,pointCenter as xhe,pointRotateRads as whe,vectorFromPoint as yhe,vectorNormalize as vhe,vectorSubtract as Ihe,vectorAdd as The,vectorScale as She,pointFromVector as Che,clamp as Phe,isCloseTo as khe}from"@excalidraw/math";import{arrayToMap as ofe,arrayToObject as rfe,assertNever as ife,isDevEnv as afe,isShallowEqual as sfe,isTestEnv as lfe,randomInteger as cfe}from"@excalidraw/common";import{assertNever as dge,COLOR_PALETTE as mge,isDevEnv as pge,isTestEnv as uge,randomId as hge,Emitter as gge,toIterable as fge}from"@excalidraw/common";import{ORIG_ID as Ghe,randomId as Uhe,randomInteger as Whe,arrayToMap as Vhe,castArray as Yhe,findLastIndex as Xhe,getUpdatedTimestamp as Khe,isTestEnv as Zhe}from"@excalidraw/common";import{arrayToMap as _he}from"@excalidraw/common";import hR from"lodash.throttle";import{randomInteger as Lge,arrayToMap as Dge,toBrandedType as _ge,isDevEnv as Cv,isTestEnv as Pv,toArray as Rge}from"@excalidraw/common";import{isNonDeletedElement as Bge}from"@excalidraw/element";import{isFrameLikeElement as Fge}from"@excalidraw/element";import{getElementsInGroup as Hge}from"@excalidraw/element";import{syncInvalidIndices as Uge,syncMovedIndices as Wge,validateFractionalIndices as gR}from"@excalidraw/element";import{getSelectedElements as Yge}from"@excalidraw/element";import{mutateElement as Kge}from"@excalidraw/element";var Zge=hR(e=>{(Cv()||Pv()||window?.DEBUG_FRACTIONAL_INDICES)&&gR(e,{shouldThrow:Cv()||Pv(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as Rfe,getGridPoint as Nfe,getFontString as Bfe,DRAGGING_THRESHOLD as Ofe}from"@excalidraw/common";import{clamp as Zfe,pointDistance as $fe,pointFrom as jfe,pointScaleFromOrigin as qfe,pointsEqual as Jfe,pointTranslate as Qfe,vector as eEe,vectorCross as tEe,vectorFromPoint as nEe,vectorScale as oEe}from"@excalidraw/math";import{BinaryHeap as iEe,invariant as aEe,isAnyTrue as sEe,getSizeFromPoints as lEe,isDevEnv as cEe,arrayToMap as dEe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as TEe,normalizeLink as SEe}from"@excalidraw/common";import{FONT_FAMILY as AEe,VERTICAL_ALIGN as LEe,escapeDoubleQuotes as DEe,getFontString as _Ee}from"@excalidraw/common";import{invariant as UEe,toBrandedType as WEe}from"@excalidraw/common";import{clamp as YEe,pointFrom as XEe}from"@excalidraw/math";import{pointDistance as ybe,pointFrom as vbe}from"@excalidraw/math";import{invariant as Tbe}from"@excalidraw/common";import{arrayToMap as abe,findIndex as sbe,findLastIndex as lbe}from"@excalidraw/common";import{isFiniteNumber as dbe}from"@excalidraw/math";import{MIME_TYPES as Rbe,SVG_NS as Nbe}from"@excalidraw/common";import{rgbaToThumbHash as Obe,thumbHashToRGBA as Fbe}from"thumbhash";import{pointCenter as exe,normalizeRadians as txe,pointFrom as nxe,pointRotateRads as oxe}from"@excalidraw/math";import{MIN_FONT_SIZE as ixe,SHIFT_LOCKING_ANGLE as axe,rescalePoints as sxe,getFontString as lxe}from"@excalidraw/common";import{pointFrom as Nxe,pointOnLineSegment as Bxe,pointRotateRads as Oxe}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as zxe}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as vxe}from"@excalidraw/common";import{pointFrom as Txe,pointRotateRads as Sxe}from"@excalidraw/math";import{KEYS as Cn}from"@excalidraw/common";var jxe=[{icon:Cc,value:"selection",key:Cn.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:Ei,value:"rectangle",key:Cn.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:bi,value:"diamond",key:Cn.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:xi,value:"ellipse",key:Cn.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Pc,value:"arrow",key:Cn.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Bo,value:"line",key:Cn.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Hn,value:"freedraw",key:[Cn.P,Cn.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:wn,value:"text",key:Cn.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Cr,value:"image",key:[Cn.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:kc,value:"eraser",key:Cn.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as l1e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as d1e,DEFAULT_FONT_SIZE as m1e,TEXT_ALIGN as p1e,VERTICAL_ALIGN as u1e,getSizeFromPoints as h1e,randomId as g1e,arrayToMap as f1e,assertNever as E1e,cloneJSON as b1e,getFontString as x1e,isDevEnv as w1e,toBrandedType as y1e,getLineHeight as v1e}from"@excalidraw/common";import{getBoundsFromPoints as Y1e,getElementAbsoluteCoords as X1e}from"@excalidraw/element/bounds";import{newArrowElement as Z1e,newElement as $1e,newLinearElement as j1e}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as J1e,getStrokeWidthByKey as Q1e,ROUNDNESS as e0e}from"@excalidraw/common";import{convexHull as n0e,distanceToLineSegment as o0e,elongation as r0e,kurtosis as i0e,lineSegment as a0e,orientPrincipalAxes as s0e,pointFrom as l0e,polygonArea as c0e,principalAxes as d0e,principalCoords as m0e,skewness as p0e}from"@excalidraw/math";var f0e=[{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 Vr=e=>!e.isDeleted;var CR=10/1.5;var Jd=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 RR=20,NR=15,BR=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 NR;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return RR;default:return 15}},OR=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},At=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=hg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;Nv(s.length===6,"Op data length is not 6");let l=bt(s[4],s[5]),c=bt(s[2],s[3]),d=bt(s[0],s[1]),m=i[a-1],p=bt(0,0);if(m.op==="move"){let H=_R(m.data);Nv(H!=null,"Op data is not a point"),p=H}else m.op==="bcurveTo"&&(p=bt(m.data[4],m.data[5]));let u=(H,re)=>Math.pow(1-H,3)*l[re]+3*H*Math.pow(1-H,2)*c[re]+3*Math.pow(H,2)*(1-H)*d[re]+p[re]*Math.pow(H,3),[E,g]=t==="start"?p:l,[b,y]=[u(.3,0),u(.3,1)],w=Math.hypot(E-b,g-y),x=(E-b)/w,v=(g-y)/w,T=BR(o),C=0;{let[H,re]=t==="end"?e.points[e.points.length-1]:e.points[0],[B,U]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(H-B,re-U)}let A=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),L=E-x*A*r,_=g-v*A*r,k=L-x*A,D=_-v*A;if(o==="circle"||o==="circle_outline"){let H=Math.hypot(D-_,k-L)+e.strokeWidth-2;return[L,_,H]}let O=OR(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[H,re]=ra(bt(L,_),bt(k,D),kg(-O)),[B,U]=ra(bt(L,_),bt(k,D),kg(O));return[k,D,H,re,B,U]}let[Y,z]=ra(bt(k,D),bt(L,_),-O*Math.PI/180),[W,Z]=ra(bt(k,D),bt(L,_),kg(O));if(o==="diamond"||o==="diamond_outline"){let H,re;if(t==="start"){let[B,U]=e.points.length>1?e.points[1]:[0,0];[H,re]=ra(bt(L+A*2,_),bt(L,_),Math.atan2(U-_,B-L))}else{let[B,U]=e.points.length>1?e.points[e.points.length-2]:[0,0];[H,re]=ra(bt(L-A*2,_),bt(L,_),Math.atan2(_-U,L-B))}return[L,_,Y,z,H,re,W,Z]}return[L,_,Y,z,W,Z]};var FR=typeof document<"u"?document.createElement("img"):{src:""};FR.src=`data:${Bv.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 zR=typeof document<"u"?document.createElement("img"):{src:""};zR.src=`data:${Bv.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 Mg=new WeakMap;var Ft=class Ft{};I(Ft,"rg",new KR),I(Ft,"cache",new WeakMap),I(Ft,"get",(n,t)=>{let o=Ft.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),I(Ft,"delete",n=>{Ft.cache.delete(n),Mg.delete(n)}),I(Ft,"destroy",()=>{Ft.cache=new WeakMap}),I(Ft,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Ft.get(n,t?t.theme:null);if(o!==void 0)return o;Mg.delete(n);let r=jR(n,Ft.rg,t||{isExporting:!1,canvasBackgroundColor:YR.white,embedsValidationStatus:null,theme:Dg.LIGHT});return t?.isExporting||Ft.cache.set(n,{shape:r,theme:t?.theme||Dg.LIGHT}),r});var oa=Ft,ZR=e=>[8,8+e],Gv=e=>[1.5,6+e];function $R(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&&vv(e.type)||an(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var Eo=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?ZR(e.strokeWidth):e.strokeStyle==="dotted"?Gv(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:$R(e),stroke:ml(e.strokeColor,t),preserveVertices:n||e.roughness<WR.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=dl(e.backgroundColor)?void 0:ml(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:ml(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},Fv=(e,n,t)=>fg(e)&&(n||cv(e)&&t?.get(e.id)!==!0)&&dl(e.backgroundColor)&&dl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:gg(e)?{...e,strokeColor:dl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:dl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,cl=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},lm=(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)]},Xr=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=Gv(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},Ag=(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)]},zv=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=ml(e.strokeColor,s),c=ml(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return Ag(r,i,l,At(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=At(e,n,t,o);if(p===null)return[];let[u,E,g,b,y,w]=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],[y,w],[u,E]],x)]}case"diamond":case"diamond_outline":{let p=At(e,n,t,o);if(p===null)return[];let[u,E,g,b,y,w,x,v]=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],[y,w],[x,v],[u,E]],T)]}case"cardinality_one":return cl(r,At(e,n,t,o),Xr(e,i));case"cardinality_many":return lm(r,At(e,n,t,o),Xr(e,i));case"cardinality_one_or_many":{let p=Xr(e,i);return[...lm(r,At(e,n,t,"cardinality_many"),p),...cl(r,At(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=Xr(e,i);return[...cl(r,At(e,n,t,"cardinality_one",-.5),p),...cl(r,At(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=Xr(e,i);return[...Ag(r,i,l,At(e,n,t,"circle_outline",1.5),c,m),...cl(r,At(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=Xr(e,i);return[...lm(r,At(e,n,t,"cardinality_many"),p),...Ag(r,i,l,At(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return lm(r,At(e,n,t,o),Xr(e,i))}};var jR=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===Dg.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=Js(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`,Eo(Fv(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,Eo(Fv(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=Jd(e);if(e.roundness){let b=Js(Math.abs(l-E),e),y=Js(Math.abs(m-c),e);s=n.path(`M ${l+b} ${c+y} L ${d-b} ${m-y}
5
5
  C ${d} ${m}, ${d} ${m}, ${d-b} ${m+y}
6
6
  L ${p+b} ${u-y}
7
7
  C ${p} ${u}, ${p} ${u}, ${p-b} ${u-y}
8
8
  L ${E+b} ${g+y}
9
9
  C ${E} ${g}, ${E} ${g}, ${E+b} ${g-y}
10
10
  L ${l-b} ${c+y}
11
- C ${l} ${c}, ${l} ${c}, ${l+b} ${c+y}`,fo(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],fo(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,fo(e,!1,a));case"line":case"arrow":{let s,l=fo(e,!1,a),c=e.points.length?e.points:[WR(0,0)];if(Tn(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(JR(c,16),fo(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=Hv(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=Hv(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(ea(e.points)){let l=GR(e.points,.75);s.push(n.curve(l,{...fo(e,!1,a),stroke:"none"}))}return s.push(QR(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return YR(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},JR=(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=lm(s,i),c=lm(a,s),d=Math.min(n,Fv(e[r],a)/2,Fv(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 QR=e=>a8(r8(e)),_g={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},e8={SIZE_FACTOR:1.4},Wv=e=>e.strokeOptions?.streamline??KR,t8=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 UR(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*_g.SIZE_FACTOR,thinning:_g.THINNING,smoothing:_g.SMOOTHING,streamline:Wv(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},n8=e=>new Qi({size:e.strokeWidth*e8.SIZE_FACTOR,streamline:Wv(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),o8=e=>{let n=n8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},r8=e=>e.strokeOptions?.variability==="constant"?o8(e):t8(e);var Gv=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],i8=/(\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,Gv(o,i[0]),"L",i[0],"Z"):t.push(o,Gv(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(i8,"$1")};var Yr=(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??s8(),updated:l8()}};import{jsx as Xv}from"react/jsx-runtime";var aa=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&&d8(r[0])&&!c8(r[0]))},perform(e,n,t,o){Vv(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);Vv(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:Yv.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 Xv(K,{type:"button",icon:Y1,title:r,"aria-label":r,onClick:()=>n(null)})}}),XIe=O({name:"togglePolygon",icon:hu,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!ia(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=>ia(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!ia(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=m8(i);return{elements:e.map(l=>!s.has(l.id)||!ia(l)?l:Yr(l,{backgroundColor:a?l.backgroundColor:"transparent",...p8(l,a)})),appState:n,captureUpdate:Yv.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!ia(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>ia(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return Xv(K,{type:"toggle",icon:hu,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as Kv,CANVAS_SEARCH_TAB as Zv,CLASSES as u8,DEFAULT_SIDEBAR as $v}from"@excalidraw/common";import{CaptureUpdateAction as h8}from"@excalidraw/element";var pl=O({name:"searchMenu",icon:Wn,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===$v.name&&n.openSidebar.tab===Zv){let r=o.excalidrawContainerValue.container?.querySelector(`.${u8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:$v.name,tab:Zv},openDialog:null},captureUpdate:h8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[Kv.CTRL_OR_CMD]&&e.key===Kv.F});import{isImageElement as g8}from"@excalidraw/element";import{CaptureUpdateAction as f8}from"@excalidraw/element";import{jsx as E8}from"react/jsx-runtime";var Ng=O({name:"cropEditor",label:"helpDialog.cropStart",icon:Fu,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:f8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&g8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return E8(K,{type:"button",icon:Fu,title:o,"aria-label":o,onClick:()=>n(null)})}});import{canCreateLinkFromElements as Bg,defaultGetElementLinkFromSelection as b8,getLinkIdAndTypeFromSelection as x8}from"@excalidraw/element";import{CaptureUpdateAction as ul}from"@excalidraw/element";var jv=O({name:"copyElementLink",label:"labels.copyElementLink",icon:Nc,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=ie(e,n);try{if(window.location){let i=x8(r,n);return i?(await uo(o.props.generateLinkForSelection?o.props.generateLinkForSelection(i.id,i.type):b8(i.id,i.type)),{appState:{toast:{message:f("toast.elementLinkCopied"),closable:!0}},captureUpdate:ul.EVENTUALLY}):{appState:n,elements:e,app:o,captureUpdate:ul.EVENTUALLY}}}catch(i){console.error(i)}return{appState:n,elements:e,app:o,captureUpdate:ul.EVENTUALLY}},predicate:(e,n)=>Bg(ie(e,n))}),qTe=O({name:"linkToElement",label:"labels.linkToElement",icon:Fc,perform:(e,n,t,o)=>{let r=ie(e,n);return r.length!==1||!Bg(r)?{elements:e,appState:n,app:o,captureUpdate:ul.EVENTUALLY}:{appState:{...n,openDialog:{name:"elementLinkSelector",sourceElementId:ie(e,n)[0].id}},captureUpdate:ul.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=ie(e,n);return n.openDialog?.name!=="elementLinkSelector"&&r.length===1&&Bg(r)},trackEvent:!1});import{getNonDeletedElements as w8}from"@excalidraw/element";import{mutateElement as y8}from"@excalidraw/element";import{newFrameElement as v8}from"@excalidraw/element";import{isFrameLikeElement as pm}from"@excalidraw/element";import{addElementsToFrame as I8,removeAllElementsFromFrame as T8}from"@excalidraw/element";import{getFrameChildren as S8}from"@excalidraw/element";import{getElementsInGroup as C8}from"@excalidraw/element";import{getCommonBounds as P8}from"@excalidraw/element";import{CaptureUpdateAction as sa}from"@excalidraw/element";var qv=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&pm(t[0])},Jv=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(pm(r)){let i=S8(w8(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)=>qv(n,o)}),Qv=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return pm(r)?{elements:T8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:sa.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:sa.EVENTUALLY}},predicate:(e,n,t,o)=>qv(n,o)}),mSe=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}),e2=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=ie(e,n);return r.length>0&&!r.some(i=>pm(i))},perform:(e,n,t,o)=>{let r=ie(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=P8(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=C8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);y8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:I8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:sa.IMMEDIATELY}}});import{KEYS as ca,matchKey as zg,arrayToMap as t2,MOBILE_ACTION_BUTTON_BG as n2}from"@excalidraw/common";import{CaptureUpdateAction as Fg}from"@excalidraw/element";import{orderByFractionalIndex as R8}from"@excalidraw/element";import{Emitter as k8}from"@excalidraw/common";import{CaptureUpdateAction as M8,StoreChange as A8,StoreDelta as L8}from"@excalidraw/element";var la=class extends L8{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)}},Kr=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},hl=class e{constructor(n){this.store=n;I(this,"onHistoryChangedEmitter",new k8);I(this,"undoStack",[]);I(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 la)return;let t=la.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Kr(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=M8.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=A8.create(s,p),E=la.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 Kr(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=la.inverse(t);return n.push(o)}};import{useEffect as D8,useState as _8}from"react";var Og=(e,n)=>{let[t,o]=_8(n);return D8(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as a2}from"react/jsx-runtime";var o2=(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:Fg.EVENTUALLY};let[r,i]=o,a=R8(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Fg.NEVER}}return{captureUpdate:Fg.EVENTUALLY}},r2=e=>({name:"undo",label:"buttons.undo",icon:bu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>o2(r,t,()=>e.undo(t2(n),t)),keyTest:n=>n[ca.CTRL_OR_CMD]&&zg(n,ca.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=Og(e.onHistoryChangedEmitter,new Kr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=at()==="mobile";return a2(K,{type:"button",icon:bu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?n2:{}}})}}),i2=e=>({name:"redo",label:"buttons.redo",icon:xu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>o2(r,t,()=>e.redo(t2(n),t)),keyTest:n=>n[ca.CTRL_OR_CMD]&&n.shiftKey&&zg(n,ca.Z)||n[ca.CTRL_OR_CMD]&&!n.shiftKey&&zg(n,ca.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=Og(e.onHistoryChangedEmitter,new Kr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=at()==="mobile";return a2(K,{type:"button",icon:xu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?n2:{}}})}});import{getFontString as N8}from"@excalidraw/common";import{getTextAnchorRatios as B8,isExcalidrawElement as O8,isNonDeletedElement as F8,newElementWith as z8,updateBoundElements as H8}from"@excalidraw/element";import{measureText as G8}from"@excalidraw/element";import{isTextElement as Hg}from"@excalidraw/element";import{CaptureUpdateAction as U8}from"@excalidraw/element";var Gg=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=ie(e,n);return o.length===1&&Hg(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=ie(e,n),i=O8(t)&&Hg(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!Hg(a))return!1;let s=G8(a.originalText,N8(a),a.lineHeight),l=B8(a),c=z8(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 F8(c)&&H8(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:U8.IMMEDIATELY}}});import{CODES as W8,KEYS as V8}from"@excalidraw/common";import Y8 from"clsx";import{CaptureUpdateAction as X8}from"@excalidraw/element";import{jsx as K8}from"react/jsx-runtime";var Zr=O({name:"viewMode",label:"labels.viewMode",icon:Ar,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:X8.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[V8.CTRL_OR_CMD]&&e.altKey&&e.code===W8.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>t.viewModeOnly||o.viewModeOnly?null:K8(K,{type:"button",icon:Ar,"aria-label":f("labels.viewMode"),onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:Y8({enabled:t.viewModeEnabled})})});import{isPromiseLike as Z8}from"@excalidraw/common";import{jsx as $8}from"react/jsx-runtime";var Ug=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Ne(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},um=class{constructor(n,t,o,r){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);I(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)||(Ug(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return $8(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(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(Z8(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 Ug(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();Ug(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var Wg=e=>{let n=Array.from(e.values());return{x:s2(n,t=>t.x)/n.length,y:s2(n,t=>t.y)/n.length}},Vg=([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 V,pointRotateRads as nr,rangeInclusive as sn,rangeIntersection as hm,rangesOverlap as gm}from"@excalidraw/math";import{TOOL_TYPE as $r,KEYS as l2}from"@excalidraw/common";import{getCommonBounds as Yg,getDraggedElementsBounds as Xg,getElementAbsoluteCoords as j8}from"@excalidraw/element";import{isBoundToContainer as p2}from"@excalidraw/element";import{getMaximumGroups as u2}from"@excalidraw/element";import{getSelectedElements as q8,getVisibleAndNonSelectedElements as h2}from"@excalidraw/element";var J8=8,c2=99999,fm=e=>J8/e,Lt=class Lt{};I(Lt,"referenceSnapPoints",null),I(Lt,"visibleGaps",null),I(Lt,"setReferenceSnapPoints",n=>{Lt.referenceSnapPoints=n}),I(Lt,"getReferenceSnapPoints",()=>Lt.referenceSnapPoints),I(Lt,"setVisibleGaps",n=>{Lt.visibleGaps=n}),I(Lt,"getVisibleGaps",()=>Lt.visibleGaps),I(Lt,"destroy",()=>{Lt.referenceSnapPoints=null,Lt.visibleGaps=null});var ln=Lt,or=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Eo=({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[l2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[l2.CTRL_OR_CMD]&&!or(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},Q8=(e,n,t=.01)=>Math.abs(e-n)<=t,gl=(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]=j8(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=nr(V(s,l+E),V(m,p),a.angle),b=nr(V(s+u,l),V(m,p),a.angle),y=nr(V(c,l+E),V(m,p),a.angle),w=nr(V(s+u,d),V(m,p),a.angle),x=V(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}else{let g=nr(V(s,l),V(m,p),a.angle),b=nr(V(c,l),V(m,p),a.angle),y=nr(V(s,d),V(m,p),a.angle),w=nr(V(c,d),V(m,p),a.angle),x=V(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}}else if(e.length>1){let[a,s,l,c]=Xg(e,r??{x:0,y:0}),d=l-a,m=c-s,p=V(a,s),u=V(l,s),E=V(a,c),g=V(l,c),b=V(a+d/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>V(Ve(a[0]),Ve(a[1])))},g2=(e,n,t,o)=>h2(e,n,t,o),f2=(e,n,t,o)=>{let r=g2(e,n,t,o),i=u2(r,o).filter(m=>!(m.length===1&&p2(m[0]))).map(m=>Yg(m).map(p=>Ve(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>c2)break e;let E=a[u],[,g,b,y]=p,[w,x,,v]=E;b<w&&gm(sn(g,y),sn(x,v))&&s.push({startBounds:p,endBounds:E,startSide:[V(b,g),V(b,y)],endSide:[V(w,x),V(w,v)],length:w-b,overlap:hm(sn(g,y),sn(x,v))})}}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>c2)break e;let E=c[u],[g,,b,y]=p,[w,x,v]=E;y<x&&gm(sn(g,b),sn(w,v))&&d.push({startBounds:p,endBounds:E,startSide:[V(g,y),V(b,y)],endSide:[V(w,x),V(v,x)],length:x-y,overlap:hm(sn(g,b),sn(w,v))})}}return{horizontalGaps:s,verticalGaps:d}},d2=(e,n,t,o,r,i,a)=>{if(!Eo({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=ln.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=Xg(e,n).map(b=>Ve(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!gm(sn(m,u),b.overlap))continue;let y=b.startSide[0][0]+b.length/2,w=Ve(y-E);if(b.length>p-d&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(r.length=0),a.x=Math.abs(w);let _={type:"gap",direction:"center_horizontal",gap:b,offset:w};r.push(_);continue}let[,,v]=b.endBounds,T=d-v,C=Ve(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,A=P-p,L=Ve(A-b.length);if(Math.abs(L)<=a.x){Math.abs(L)<a.x&&(r.length=0),a.x=Math.abs(L);let _={type:"gap",direction:"side_left",gap:b,offset:L};r.push(_);continue}}for(let b of c){if(!gm(sn(d,p),b.overlap))continue;let y=b.startSide[0][1]+b.length/2,w=Ve(y-g);if(b.length>u-m&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let _={type:"gap",direction:"center_vertical",gap:b,offset:w};i.push(_);continue}let[,v,,]=b.startBounds,T=v-u,C=Ve(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,A=Ve(m-P),L=b.length-A;if(Math.abs(L)<=a.y){Math.abs(L)<a.y&&(i.length=0),a.y=Math.abs(L);let _={type:"gap",direction:"side_bottom",gap:b,offset:L};i.push(_);continue}}}},E2=(e,n,t,o)=>{let r=g2(e,n,t,o);return u2(r,o).filter(i=>!(i.length===1&&p2(i[0]))).flatMap(i=>gl(i,o))},da=(e,n,t,o,r,i,a)=>{if(!Eo({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=ln.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=q8(e,i);if(!Eo({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=Ve(n.x),n.y=Ve(n.y);let s=[],l=[],c=fm(i.zoom.value),d={x:c,y:c},m=gl(a,r,{dragOffset:n});da(a,m,t,o,s,l,d),d2(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:Ve(n.x+p.x),y:Ve(n.y+p.y)};da(a,gl(a,r,{dragOffset:u}),t,o,s,l,d),d2(a,u,t,o,s,l,d);let E=Kg(s,l),g=tN(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},Ve=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())},Kg=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Ve(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>V(Ve(a[0]),Ve(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=Ve(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>V(Ve(a[0]),Ve(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:m2(i.map(a=>V(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=>V(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},eN=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[Ve(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},tN=(e,n,t)=>{let[o,r,i,a]=Xg(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,y=hm(sn(r,a),l.gap.overlap),w=hm(sn(o,i),l.gap.overlap);switch(l.direction){case"center_horizontal":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[V(l.gap.startSide[0][0],x),V(o,x)]},{type:"gap",direction:"horizontal",points:[V(i,x),V(l.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,l.gap.startSide[0][1]),V(x,r)]},{type:"gap",direction:"vertical",points:[V(x,a),V(x,l.gap.endSide[0][1])]})}break}case"side_right":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[V(m,x),V(u,x)]},{type:"gap",direction:"horizontal",points:[V(g,x),V(o,x)]})}break}case"side_left":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[V(i,x),V(c,x)]},{type:"gap",direction:"horizontal",points:[V(m,x),V(u,x)]})}break}case"side_top":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,a),V(x,d)]},{type:"gap",direction:"vertical",points:[V(x,p),V(x,E)]})}break}case"side_bottom":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,p),V(x,E)]},{type:"gap",direction:"vertical",points:[V(x,b),V(x,r)]})}break}}}return eN(s.map(l=>({...l,points:l.points.map(c=>V(Ve(c[0]),Ve(c[1])))})))},Zg=(e,n,t,o,r,i)=>{if(!Eo({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!Q8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=Yg(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(V(l,s),V(l,c));break}case"w":{d.push(V(a,s),V(a,c));break}case"n":{d.push(V(a,s),V(l,s));break}case"s":{d.push(V(a,c),V(l,c));break}case"ne":{d.push(V(l,s));break}case"nw":{d.push(V(a,s));break}case"se":{d.push(V(l,c));break}case"sw":{d.push(V(a,c));break}}let m=fm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];da(n,d,t,o,u,E,p);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};p.x=0,p.y=0,u.length=0,E.length=0;let[b,y,w,x]=Yg(e).map(C=>Ve(C)),v=[V(b,y),V(b,x),V(w,y),V(w,x)];da(e,v,t,o,u,E,p);let T=Kg(u,E);return{snapOffset:g,snapLines:T}},x2=(e,n,t,o,r,i)=>{if(!Eo({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[V(o.x+r.x,o.y+r.y)],s=fm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];da([e],a,n,t,c,d,l);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let p=gl([e],i,{boundingBoxCorners:!0,omitCenter:!0});da([e],p,n,t,c,d,l);let u=Kg(c,d);return{snapOffset:m,snapLines:u}},w2=(e,n,t,o,r)=>{if(!Eo({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=h2(e,[],n.state,r),a=fm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=gl([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,V(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,V(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]}},y2=e=>e===$r.rectangle||e===$r.ellipse||e===$r.diamond||e===$r.frame||e===$r.magicframe||e===$r.image||e===$r.text;import{getCommonFrameId as nN,getFrameChildrenInsertionIndex as oN,isElementInViewport as rN}from"@excalidraw/element";import{arrayToMap as iN,memoize as aN,toBrandedType as sN}from"@excalidraw/common";var fl=class{constructor(n){I(this,"scene");I(this,"_getRenderableElements",aN(({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}}));I(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&&nN(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())rN(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=sN(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=iN(t),i=n.filter(s=>!r.has(s.id)),a=oN(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){Jb.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as pN,easeOut as T2}from"@excalidraw/common";import{SVG_NS as I2,getSvgPathFromStroke as dN,sceneCoordsToViewportCoords as mN}from"@excalidraw/common";import{version as lN}from"react";import{unstable_batchedUpdates as v2}from"react-dom";import{throttleRAF as cN}from"@excalidraw/common";var Ye=e=>n=>{v2(e,n)},Em=e=>cN(n=>{v2(e,n)}),ma=(()=>{let e;try{let t=lN.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 ce=class ce{static start(n,t){if(ce.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};ce.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw ce.animations.get(n)===o&&(ce.animations.delete(n),ce.cancelScheduledFrameIfIdle()),i}if(ce.animations.get(n)===o){if(!r){ce.animations.delete(n),ce.cancelScheduledFrameIfIdle();return}o.state=r,ce.scheduleNextFrame()}}static scheduleNextFrame(){ce.scheduledFrame||(ma()?ce.scheduledFrame={id:requestAnimationFrame(ce.tick),type:"raf"}:ce.scheduledFrame={id:setTimeout(ce.tick,0),type:"timeout"})}static cancelScheduledFrame(){ce.scheduledFrame&&(ce.scheduledFrame.type==="raf"?cancelAnimationFrame(ce.scheduledFrame.id):clearTimeout(ce.scheduledFrame.id),ce.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return ce.animations.size>0?!1:(ce.cancelScheduledFrame(),!0)}static tick(){if(ce.scheduledFrame=null,ce.animations.size>0){let n=[...ce.animations];for(let[t,o]of n){if(ce.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(ce.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(ce.animations.delete(t),ce.cancelScheduledFrameIfIdle())return}}if(ce.cancelScheduledFrameIfIdle())return;ce.scheduleNextFrame()}}static running(n){return ce.animations.has(n)}static cancel(n){ce.animations.delete(n),ce.cancelScheduledFrameIfIdle()}static reset(){ce.animations.clear(),ce.cancelScheduledFrame()}};I(ce,"scheduledFrame",null),I(ce,"animations",new Map);var ot=ce;var bm=class bm{constructor(n,t){this.app=n;this.options=t;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");I(this,"key");this.key=`animated-trail-${bm.counter++}`,this.trailElement=document.createElementNS(I2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(I2,"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),ot.running(this.key)||ot.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){ot.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new Qi(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=mN({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return dN(r,!0)}};I(bm,"counter",0);var Pn=bm;var xm=class{constructor(n){this.app=n;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");this.localTrail=new Pn(n,{...this.getTrailOptions(),fill:()=>pN})}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(T2(i),T2(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 Pn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||Gr(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 uN}from"@excalidraw/common";import{pointFrom as El,pointRotateRads as wm}from"@excalidraw/math";var hN=12,$g=16,gN=10,fN=$g+2,EN=.8,jg=e=>uN*2/e,qg=(e,n,t)=>{let o=jg(n);if(t!=="desktop"||$g>(e.height+o*2)*n*EN)return null;let r=hN/n,i=$g/n,a=El(e.x+e.width/2,e.y+e.height/2),s=wm(El(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:wm(El(s[0],s[1]-i/2),s,e.angle),end:wm(El(s[0],s[1]+i/2),s,e.angle),hitboxWidth:gN/n,hitboxHeight:fN/n}},S2=(e,n,t,o)=>{let r=qg(n,t,o);if(!r)return!1;let i=wm(El(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 Jg,KEYS as bl,CLASSES as Qg,POINTER_BUTTON as bN,THEME as xN,isWritableElement as wN,getFontString as C2,getFontFamilyString as P2,isTestEnv as k2,MIME_TYPES as ef,applyDarkModeFilter as yN,isRTL as vN}from"@excalidraw/common";import{pointFrom as M2,pointRotateRads as IN}from"@excalidraw/math";import{getTextFromElements as TN,originalContainerCache as SN,updateBoundElements as A2,updateOriginalContainerCache as L2}from"@excalidraw/element";import{LinearElementEditor as CN}from"@excalidraw/element/linearElementEditor";import{bumpVersion as PN}from"@excalidraw/element";import{getBoundTextElementId as kN,getContainerElement as tf,getTextElementAngle as MN,redrawTextBoundingBox as AN,getBoundTextMaxHeight as LN,getBoundTextMaxWidth as D2,computeContainerDimensionForBoundText as _2,computeBoundTextPosition as DN,getBoundTextElement as _N}from"@excalidraw/element";import{getTextWidth as RN}from"@excalidraw/element";import{getLineHeightInPx as NN}from"@excalidraw/element";import{getLineWidth as BN}from"@excalidraw/element";import{normalizeText as R2}from"@excalidraw/element";import{wrapText as ON}from"@excalidraw/element";import{getWrappedTextLines as FN}from"@excalidraw/element";import{isArrowElement as ym,isBoundToContainer as zN,isTextElement as N2}from"@excalidraw/element";var HN=(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)`},GN=(e,n)=>{let t=e.lastIndexOf(`
11
+ C ${l} ${c}, ${l} ${c}, ${l+b} ${c+y}`,Eo(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],Eo(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,Eo(e,!1,a));case"line":case"arrow":{let s,l=Eo(e,!1,a),c=e.points.length?e.points:[UR(0,0)];if(Tn(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(qR(c,16),Eo(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=zv(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=zv(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(ea(e.points)){let l=HR(e.points,.75);s.push(n.curve(l,{...Eo(e,!1,a),stroke:"none"}))}return s.push(JR(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return VR(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},qR=(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=im(s,i),c=im(a,s),d=Math.min(n,Ov(e[r],a)/2,Ov(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 JR=e=>i8(o8(e)),Lg={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},QR={SIZE_FACTOR:1.4},Uv=e=>e.strokeOptions?.streamline??XR,e8=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 GR(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*Lg.SIZE_FACTOR,thinning:Lg.THINNING,smoothing:Lg.SMOOTHING,streamline:Uv(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},t8=e=>new Qi({size:e.strokeWidth*QR.SIZE_FACTOR,streamline:Uv(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),n8=e=>{let n=t8(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},o8=e=>e.strokeOptions?.variability==="constant"?n8(e):e8(e);var Hv=(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,i8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,Hv(o,i[0]),"L",i[0],"Z"):t.push(o,Hv(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(r8,"$1")};var Yr=(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??a8(),updated:s8()}};import{jsx as Yv}from"react/jsx-runtime";var aa=F({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&&c8(r[0])&&!l8(r[0]))},perform(e,n,t,o){Wv(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);Wv(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:Vv.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 Yv(K,{type:"button",icon:W1,title:r,"aria-label":r,onClick:()=>n(null)})}}),UIe=F({name:"togglePolygon",icon:pu,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!ia(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=>ia(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!ia(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=d8(i);return{elements:e.map(l=>!s.has(l.id)||!ia(l)?l:Yr(l,{backgroundColor:a?l.backgroundColor:"transparent",...m8(l,a)})),appState:n,captureUpdate:Vv.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!ia(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>ia(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return Yv(K,{type:"toggle",icon:pu,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as Xv,CANVAS_SEARCH_TAB as Kv,CLASSES as p8,DEFAULT_SIDEBAR as Zv}from"@excalidraw/common";import{CaptureUpdateAction as u8}from"@excalidraw/element";var pl=F({name:"searchMenu",icon:Vn,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===Zv.name&&n.openSidebar.tab===Kv){let r=o.excalidrawContainerValue.container?.querySelector(`.${p8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:Zv.name,tab:Kv},openDialog:null},captureUpdate:u8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[Xv.CTRL_OR_CMD]&&e.key===Xv.F});import{isImageElement as h8}from"@excalidraw/element";import{CaptureUpdateAction as g8}from"@excalidraw/element";import{jsx as f8}from"react/jsx-runtime";var _g=F({name:"cropEditor",label:"helpDialog.cropStart",icon:Bu,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&&h8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return f8(K,{type:"button",icon:Bu,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as E8}from"@excalidraw/element";import{mutateElement as b8}from"@excalidraw/element";import{newFrameElement as x8}from"@excalidraw/element";import{isFrameLikeElement as cm}from"@excalidraw/element";import{addElementsToFrame as w8,removeAllElementsFromFrame as y8}from"@excalidraw/element";import{getFrameChildren as v8}from"@excalidraw/element";import{getElementsInGroup as I8}from"@excalidraw/element";import{getCommonBounds as T8}from"@excalidraw/element";import{CaptureUpdateAction as sa}from"@excalidraw/element";var $v=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&cm(t[0])},jv=F({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(cm(r)){let i=v8(E8(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)=>$v(n,o)}),qv=F({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return cm(r)?{elements:y8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:sa.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:sa.EVENTUALLY}},predicate:(e,n,t,o)=>$v(n,o)}),qTe=F({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}),Jv=F({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=se(e,n);return r.length>0&&!r.some(i=>cm(i))},perform:(e,n,t,o)=>{let r=se(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=T8(r,i),d=16,m=x8({x:a-d,y:s-d,width:l-a+d*2,height:c-s+d*2});if(n.editingGroupId){let u=I8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);b8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:w8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:sa.IMMEDIATELY}}});import{KEYS as ca,matchKey as Bg,arrayToMap as Qv,MOBILE_ACTION_BUTTON_BG as e2}from"@excalidraw/common";import{CaptureUpdateAction as Ng}from"@excalidraw/element";import{orderByFractionalIndex as L8}from"@excalidraw/element";import{Emitter as S8}from"@excalidraw/common";import{CaptureUpdateAction as C8,StoreChange as P8,StoreDelta as k8}from"@excalidraw/element";var la=class extends k8{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)}},Kr=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},ul=class e{constructor(n){this.store=n;I(this,"onHistoryChangedEmitter",new S8);I(this,"undoStack",[]);I(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 la)return;let t=la.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Kr(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=C8.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=P8.create(s,p),E=la.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 Kr(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=la.inverse(t);return n.push(o)}};import{useEffect as M8,useState as A8}from"react";var Rg=(e,n)=>{let[t,o]=A8(n);return M8(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as r2}from"react/jsx-runtime";var t2=(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:Ng.EVENTUALLY};let[r,i]=o,a=L8(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Ng.NEVER}}return{captureUpdate:Ng.EVENTUALLY}},n2=e=>({name:"undo",label:"buttons.undo",icon:fu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>t2(r,t,()=>e.undo(Qv(n),t)),keyTest:n=>n[ca.CTRL_OR_CMD]&&Bg(n,ca.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=Rg(e.onHistoryChangedEmitter,new Kr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=at()==="mobile";return r2(K,{type:"button",icon:fu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?e2:{}}})}}),o2=e=>({name:"redo",label:"buttons.redo",icon:Eu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>t2(r,t,()=>e.redo(Qv(n),t)),keyTest:n=>n[ca.CTRL_OR_CMD]&&n.shiftKey&&Bg(n,ca.Z)||n[ca.CTRL_OR_CMD]&&!n.shiftKey&&Bg(n,ca.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=Rg(e.onHistoryChangedEmitter,new Kr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=at()==="mobile";return r2(K,{type:"button",icon:Eu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?e2:{}}})}});import{getFontString as D8}from"@excalidraw/common";import{getTextAnchorRatios as _8,isExcalidrawElement as R8,isNonDeletedElement as N8,newElementWith as B8,updateBoundElements as O8}from"@excalidraw/element";import{measureText as F8}from"@excalidraw/element";import{isTextElement as Og}from"@excalidraw/element";import{CaptureUpdateAction as z8}from"@excalidraw/element";var Fg=F({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=se(e,n);return o.length===1&&Og(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=se(e,n),i=R8(t)&&Og(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!Og(a))return!1;let s=F8(a.originalText,D8(a),a.lineHeight),l=_8(a),c=B8(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 N8(c)&&O8(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:z8.IMMEDIATELY}}});import{CODES as H8,KEYS as G8}from"@excalidraw/common";import U8 from"clsx";import{CaptureUpdateAction as W8}from"@excalidraw/element";import{jsx as V8}from"react/jsx-runtime";var Zr=F({name:"viewMode",label:"labels.viewMode",icon:Ar,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:W8.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[G8.CTRL_OR_CMD]&&e.altKey&&e.code===H8.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>t.viewModeOnly||o.viewModeOnly?null:V8(K,{type:"button",icon:Ar,"aria-label":f("labels.viewMode"),onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:U8({enabled:t.viewModeEnabled})})});import{isPromiseLike as Y8}from"@excalidraw/common";import{jsx as X8}from"react/jsx-runtime";var zg=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Ne(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},dm=class{constructor(n,t,o,r){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);I(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)||(zg(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return X8(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(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(Y8(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 zg(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();zg(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var Hg=e=>{let n=Array.from(e.values());return{x:i2(n,t=>t.x)/n.length,y:i2(n,t=>t.y)/n.length}},Gg=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),i2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as V,pointRotateRads as nr,rangeInclusive as sn,rangeIntersection as mm,rangesOverlap as pm}from"@excalidraw/math";import{TOOL_TYPE as $r,KEYS as a2}from"@excalidraw/common";import{getCommonBounds as Ug,getDraggedElementsBounds as Wg,getElementAbsoluteCoords as K8}from"@excalidraw/element";import{isBoundToContainer as d2}from"@excalidraw/element";import{getMaximumGroups as m2}from"@excalidraw/element";import{getSelectedElements as Z8,getVisibleAndNonSelectedElements as p2}from"@excalidraw/element";var $8=8,s2=99999,um=e=>$8/e,Lt=class Lt{};I(Lt,"referenceSnapPoints",null),I(Lt,"visibleGaps",null),I(Lt,"setReferenceSnapPoints",n=>{Lt.referenceSnapPoints=n}),I(Lt,"getReferenceSnapPoints",()=>Lt.referenceSnapPoints),I(Lt,"setVisibleGaps",n=>{Lt.visibleGaps=n}),I(Lt,"getVisibleGaps",()=>Lt.visibleGaps),I(Lt,"destroy",()=>{Lt.referenceSnapPoints=null,Lt.visibleGaps=null});var ln=Lt,or=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,bo=({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[a2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[a2.CTRL_OR_CMD]&&!or(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},j8=(e,n,t=.01)=>Math.abs(e-n)<=t,hl=(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]=K8(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=nr(V(s,l+E),V(m,p),a.angle),b=nr(V(s+u,l),V(m,p),a.angle),y=nr(V(c,l+E),V(m,p),a.angle),w=nr(V(s+u,d),V(m,p),a.angle),x=V(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}else{let g=nr(V(s,l),V(m,p),a.angle),b=nr(V(c,l),V(m,p),a.angle),y=nr(V(s,d),V(m,p),a.angle),w=nr(V(c,d),V(m,p),a.angle),x=V(m,p);i=t?[g,b,y,w]:[g,b,y,w,x]}}else if(e.length>1){let[a,s,l,c]=Wg(e,r??{x:0,y:0}),d=l-a,m=c-s,p=V(a,s),u=V(l,s),E=V(a,c),g=V(l,c),b=V(a+d/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>V(Ve(a[0]),Ve(a[1])))},u2=(e,n,t,o)=>p2(e,n,t,o),h2=(e,n,t,o)=>{let r=u2(e,n,t,o),i=m2(r,o).filter(m=>!(m.length===1&&d2(m[0]))).map(m=>Ug(m).map(p=>Ve(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>s2)break e;let E=a[u],[,g,b,y]=p,[w,x,,v]=E;b<w&&pm(sn(g,y),sn(x,v))&&s.push({startBounds:p,endBounds:E,startSide:[V(b,g),V(b,y)],endSide:[V(w,x),V(w,v)],length:w-b,overlap:mm(sn(g,y),sn(x,v))})}}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>s2)break e;let E=c[u],[g,,b,y]=p,[w,x,v]=E;y<x&&pm(sn(g,b),sn(w,v))&&d.push({startBounds:p,endBounds:E,startSide:[V(g,y),V(b,y)],endSide:[V(w,x),V(v,x)],length:x-y,overlap:mm(sn(g,b),sn(w,v))})}}return{horizontalGaps:s,verticalGaps:d}},l2=(e,n,t,o,r,i,a)=>{if(!bo({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=ln.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=Wg(e,n).map(b=>Ve(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!pm(sn(m,u),b.overlap))continue;let y=b.startSide[0][0]+b.length/2,w=Ve(y-E);if(b.length>p-d&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(r.length=0),a.x=Math.abs(w);let _={type:"gap",direction:"center_horizontal",gap:b,offset:w};r.push(_);continue}let[,,v]=b.endBounds,T=d-v,C=Ve(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,A=P-p,L=Ve(A-b.length);if(Math.abs(L)<=a.x){Math.abs(L)<a.x&&(r.length=0),a.x=Math.abs(L);let _={type:"gap",direction:"side_left",gap:b,offset:L};r.push(_);continue}}for(let b of c){if(!pm(sn(d,p),b.overlap))continue;let y=b.startSide[0][1]+b.length/2,w=Ve(y-g);if(b.length>u-m&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let _={type:"gap",direction:"center_vertical",gap:b,offset:w};i.push(_);continue}let[,v,,]=b.startBounds,T=v-u,C=Ve(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,A=Ve(m-P),L=b.length-A;if(Math.abs(L)<=a.y){Math.abs(L)<a.y&&(i.length=0),a.y=Math.abs(L);let _={type:"gap",direction:"side_bottom",gap:b,offset:L};i.push(_);continue}}}},g2=(e,n,t,o)=>{let r=u2(e,n,t,o);return m2(r,o).filter(i=>!(i.length===1&&d2(i[0]))).flatMap(i=>hl(i,o))},da=(e,n,t,o,r,i,a)=>{if(!bo({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=ln.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))}},f2=(e,n,t,o,r)=>{let i=t.state,a=Z8(e,i);if(!bo({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=Ve(n.x),n.y=Ve(n.y);let s=[],l=[],c=um(i.zoom.value),d={x:c,y:c},m=hl(a,r,{dragOffset:n});da(a,m,t,o,s,l,d),l2(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:Ve(n.x+p.x),y:Ve(n.y+p.y)};da(a,hl(a,r,{dragOffset:u}),t,o,s,l,d),l2(a,u,t,o,s,l,d);let E=Vg(s,l),g=J8(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},Ve=e=>Math.round(e*10**6)/10**6,c2=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())},Vg=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Ve(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>V(Ve(a[0]),Ve(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=Ve(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>V(Ve(a[0]),Ve(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:c2(i.map(a=>V(Number(r),a[1])).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:c2(i.map(a=>V(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},q8=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[Ve(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},J8=(e,n,t)=>{let[o,r,i,a]=Wg(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,y=mm(sn(r,a),l.gap.overlap),w=mm(sn(o,i),l.gap.overlap);switch(l.direction){case"center_horizontal":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[V(l.gap.startSide[0][0],x),V(o,x)]},{type:"gap",direction:"horizontal",points:[V(i,x),V(l.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,l.gap.startSide[0][1]),V(x,r)]},{type:"gap",direction:"vertical",points:[V(x,a),V(x,l.gap.endSide[0][1])]})}break}case"side_right":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[V(m,x),V(u,x)]},{type:"gap",direction:"horizontal",points:[V(g,x),V(o,x)]})}break}case"side_left":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"horizontal",points:[V(i,x),V(c,x)]},{type:"gap",direction:"horizontal",points:[V(m,x),V(u,x)]})}break}case"side_top":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,a),V(x,d)]},{type:"gap",direction:"vertical",points:[V(x,p),V(x,E)]})}break}case"side_bottom":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[V(x,p),V(x,E)]},{type:"gap",direction:"vertical",points:[V(x,b),V(x,r)]})}break}}}return q8(s.map(l=>({...l,points:l.points.map(c=>V(Ve(c[0]),Ve(c[1])))})))},Yg=(e,n,t,o,r,i)=>{if(!bo({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!j8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=Ug(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(V(l,s),V(l,c));break}case"w":{d.push(V(a,s),V(a,c));break}case"n":{d.push(V(a,s),V(l,s));break}case"s":{d.push(V(a,c),V(l,c));break}case"ne":{d.push(V(l,s));break}case"nw":{d.push(V(a,s));break}case"se":{d.push(V(l,c));break}case"sw":{d.push(V(a,c));break}}let m=um(t.state.zoom.value),p={x:m,y:m},u=[],E=[];da(n,d,t,o,u,E,p);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};p.x=0,p.y=0,u.length=0,E.length=0;let[b,y,w,x]=Ug(e).map(C=>Ve(C)),v=[V(b,y),V(b,x),V(w,y),V(w,x)];da(e,v,t,o,u,E,p);let T=Vg(u,E);return{snapOffset:g,snapLines:T}},E2=(e,n,t,o,r,i)=>{if(!bo({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[V(o.x+r.x,o.y+r.y)],s=um(n.state.zoom.value),l={x:s,y:s},c=[],d=[];da([e],a,n,t,c,d,l);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let p=hl([e],i,{boundingBoxCorners:!0,omitCenter:!0});da([e],p,n,t,c,d,l);let u=Vg(c,d);return{snapOffset:m,snapLines:u}},b2=(e,n,t,o,r)=>{if(!bo({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=p2(e,[],n.state,r),a=um(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=hl([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,V(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,V(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]}},x2=e=>e===$r.rectangle||e===$r.ellipse||e===$r.diamond||e===$r.frame||e===$r.magicframe||e===$r.image||e===$r.text;import{getCommonFrameId as Q8,getFrameChildrenInsertionIndex as eN,isElementInViewport as tN}from"@excalidraw/element";import{arrayToMap as nN,memoize as oN,toBrandedType as rN}from"@excalidraw/common";var gl=class{constructor(n){I(this,"scene");I(this,"_getRenderableElements",oN(({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}}));I(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&&Q8(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())tN(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=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=nN(t),i=n.filter(s=>!r.has(s.id)),a=eN(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){$b.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as cN,easeOut as v2}from"@excalidraw/common";import{SVG_NS as y2,getSvgPathFromStroke as sN,sceneCoordsToViewportCoords as lN}from"@excalidraw/common";import{version as iN}from"react";import{unstable_batchedUpdates as w2}from"react-dom";import{throttleRAF as aN}from"@excalidraw/common";var Ye=e=>n=>{w2(e,n)},hm=e=>aN(n=>{w2(e,n)}),ma=(()=>{let e;try{let t=iN.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 ce=class ce{static start(n,t){if(ce.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};ce.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw ce.animations.get(n)===o&&(ce.animations.delete(n),ce.cancelScheduledFrameIfIdle()),i}if(ce.animations.get(n)===o){if(!r){ce.animations.delete(n),ce.cancelScheduledFrameIfIdle();return}o.state=r,ce.scheduleNextFrame()}}static scheduleNextFrame(){ce.scheduledFrame||(ma()?ce.scheduledFrame={id:requestAnimationFrame(ce.tick),type:"raf"}:ce.scheduledFrame={id:setTimeout(ce.tick,0),type:"timeout"})}static cancelScheduledFrame(){ce.scheduledFrame&&(ce.scheduledFrame.type==="raf"?cancelAnimationFrame(ce.scheduledFrame.id):clearTimeout(ce.scheduledFrame.id),ce.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return ce.animations.size>0?!1:(ce.cancelScheduledFrame(),!0)}static tick(){if(ce.scheduledFrame=null,ce.animations.size>0){let n=[...ce.animations];for(let[t,o]of n){if(ce.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(ce.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(ce.animations.delete(t),ce.cancelScheduledFrameIfIdle())return}}if(ce.cancelScheduledFrameIfIdle())return;ce.scheduleNextFrame()}}static running(n){return ce.animations.has(n)}static cancel(n){ce.animations.delete(n),ce.cancelScheduledFrameIfIdle()}static reset(){ce.animations.clear(),ce.cancelScheduledFrame()}};I(ce,"scheduledFrame",null),I(ce,"animations",new Map);var rt=ce;var gm=class gm{constructor(n,t){this.app=n;this.options=t;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");I(this,"key");this.key=`animated-trail-${gm.counter++}`,this.trailElement=document.createElementNS(y2,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(y2,"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),rt.running(this.key)||rt.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){rt.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new Qi(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=lN({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return sN(r,!0)}};I(gm,"counter",0);var Pn=gm;var fm=class{constructor(n){this.app=n;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");this.localTrail=new Pn(n,{...this.getTrailOptions(),fill:()=>cN})}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(v2(i),v2(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 Pn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||Gr(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 dN}from"@excalidraw/common";import{pointFrom as fl,pointRotateRads as Em}from"@excalidraw/math";var mN=12,Xg=16,pN=10,uN=Xg+2,hN=.8,Kg=e=>dN*2/e,Zg=(e,n,t)=>{let o=Kg(n);if(t!=="desktop"||Xg>(e.height+o*2)*n*hN)return null;let r=mN/n,i=Xg/n,a=fl(e.x+e.width/2,e.y+e.height/2),s=Em(fl(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:Em(fl(s[0],s[1]-i/2),s,e.angle),end:Em(fl(s[0],s[1]+i/2),s,e.angle),hitboxWidth:pN/n,hitboxHeight:uN/n}},I2=(e,n,t,o)=>{let r=Zg(n,t,o);if(!r)return!1;let i=Em(fl(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 $g,KEYS as El,CLASSES as jg,POINTER_BUTTON as gN,THEME as fN,isWritableElement as EN,getFontString as T2,getFontFamilyString as S2,isTestEnv as C2,MIME_TYPES as qg,applyDarkModeFilter as bN,isRTL as xN}from"@excalidraw/common";import{pointFrom as P2,pointRotateRads as wN}from"@excalidraw/math";import{getTextFromElements as yN,originalContainerCache as vN,updateBoundElements as k2,updateOriginalContainerCache as M2}from"@excalidraw/element";import{LinearElementEditor as IN}from"@excalidraw/element/linearElementEditor";import{bumpVersion as TN}from"@excalidraw/element";import{getBoundTextElementId as SN,getContainerElement as Jg,getTextElementAngle as CN,redrawTextBoundingBox as PN,getBoundTextMaxHeight as kN,getBoundTextMaxWidth as A2,computeContainerDimensionForBoundText as L2,computeBoundTextPosition as MN,getBoundTextElement as AN}from"@excalidraw/element";import{getTextWidth as LN}from"@excalidraw/element";import{getLineHeightInPx as DN}from"@excalidraw/element";import{getLineWidth as _N}from"@excalidraw/element";import{normalizeText as D2}from"@excalidraw/element";import{wrapText as RN}from"@excalidraw/element";import{getWrappedTextLines as NN}from"@excalidraw/element";import{isArrowElement as bm,isBoundToContainer as BN,isTextElement as _2}from"@excalidraw/element";var ON=(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)`},FN=(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"},UN=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},WN=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=UN(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},B2=({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,U)=>{if(!U.style.fontFamily||!U.style.fontSize)return!1;let ue=U.style.fontFamily.replace(/"/g,"");return P2({fontFamily:B.fontFamily})!==ue||`${B.fontSize}px`!==U.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let B=a.state,U=a.scene.getElement(o.id);if(!U)return;let{textAlign:ue,verticalAlign:we}=U,pe=a.scene.getNonDeletedElementsMap();if(U&&N2(U)){let he=U.x,ye=U.y,se=tf(U,a.scene.getNonDeletedElementsMap()),ve=U.width,st=U.height,$e=U.width,Re=U.height;if(se&&U.containerId){if(ym(se)){let Rn=CN.getBoundTextElementPosition(se,U,pe);he=Rn.x,ye=Rn.y}let ru=d(U,u),oo;if(ru?oo=L2(se.id,se.height):(oo=SN[se.id],oo||(oo=L2(se.id,se.height))),$e=D2(se,U),Re=LN(se,U),!ym(se)&&st>Re){let Rn=_2(st,se.type);a.scene.mutateElement(se,{height:Rn}),A2(se,a.scene);return}else if(!ym(se)&&se.height>oo.height&&st<Re){let Rn=_2(st,se.type);a.scene.mutateElement(se,{height:Rn}),A2(se,a.scene)}else{let{x:Rn,y:ts}=DN(se,U,pe);he=Rn,ye=ts}}let[Do,li]=t(he,ye);se?ve+=.5:($e=(B.width-8-Do)/B.zoom.value,ve=Math.min(ve,$e)),st*=1.05;let mc=C2(U),pc=MN(U,se),uc=(B.height-li)/B.zoom.value;Object.assign(u.style,{font:mc,lineHeight:U.lineHeight,width:`${ve}px`,height:`${st}px`,left:`${Do}px`,top:`${li}px`,transform:HN(ve,st,pc,B,$e,uc),textAlign:ue,verticalAlign:we,color:yN(U.strokeColor,B.theme===xN.DARK),opacity:U.opacity/100,maxHeight:`${uc}px`}),c={angle:pc,font:mc,height:U.height,lineHeightPx:NN(U.fontSize,U.lineHeight),textAlign:ue,width:U.width,x:he,y:ye},u.scrollTop=0,k2()&&(u.style.fontFamily=P2(U)),a.scene.mutateElement(U,{x:he,y:ye})}},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";(zN(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,U=M2(B.x+B.width/2,B.y+B.height/2),[ue,we]=IN(M2(l.x,l.y),U,-B.angle),pe=ue-B.x,he=we-B.y,ye=FN(u.value,B.font,E==="pre-wrap"?B.width:1/0),se=Math.max(0,Math.min(ye.length-1,Math.floor(he/B.lineHeightPx))),ve=ye[se],st=GN(u.value,ve.start),$e=BN(ve.text,B.font),Re=B.textAlign==="center"?(B.width-$e)/2:B.textAlign==="right"?B.width-$e:0,Do=pe-Re;if(!ve.text)return ve.start;let li=WN({text:ve.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:st,targetX:Do});return ve.start+(li||0)},y=(()=>{let B=b();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let U=ey(B),ue=null;if(U.has(ef.excalidrawClipboard)||U.has(ef.excalidraw)){B.preventDefault(),ue=await Br(B);try{let se=await Hd(ue);if(se.elements){let ve=TN(se.elements);if(ve){let{selectionStart:st,selectionEnd:$e,value:Re}=u;u.value=Re.slice(0,st)+ve+Re.slice($e);let Do=st+ve.length;u.selectionStart=u.selectionEnd=Do,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}ue=ue||await Br(B);let we=ue.findByType(ef.text);if(!we)return;let pe=R2(we.value);if(!pe)return;let he=tf(o,a.scene.getNonDeletedElementsMap()),ye=C2({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(he){let se=_N(he,a.scene.getNonDeletedElementsMap()),ve=ON(`${u.value}${pe}`,ye,D2(he,se)),st=RN(ve,ye);u.style.width=`${st}px`}},u.oninput=()=>{let B=R2(u.value);if(u.value!==B){let U=u.selectionStart;u.value=B,u.selectionStart=U,u.selectionEnd=U}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&vd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(vd),p();else if(!B.shiftKey&&Id.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Id),p();else if(!B.shiftKey&&Td.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Td),p();else if(Th.keyTest(B))a.actionManager.executeAction(Th);else if(Sh.keyTest(B))a.actionManager.executeAction(Sh);else if(B.key===bl.ESCAPE)B.preventDefault(),L=!0,_();else if(zr.keyTest(B))B.preventDefault(),_(),a.actionManager.executeAction(zr);else if(B.key===bl.ENTER&&B[bl.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;L=!0,_()}else if(B.key===bl.TAB||B[bl.CTRL_OR_CMD]&&(B.code===Jg.BRACKET_LEFT||B.code===Jg.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===Jg.BRACKET_LEFT?C():T(),u.dispatchEvent(new Event("input"))}};let w=4,x=" ".repeat(w),v=new RegExp(`^ {1,${w}}`),T=()=>{let{selectionStart:B,selectionEnd:U}=u,ue=P(),we=u.value;ue.forEach(pe=>{let he=we.slice(0,pe),ye=we.slice(pe);we=`${he}${x}${ye}`}),u.value=we,u.selectionStart=B+w,u.selectionEnd=U+w*ue.length},C=()=>{let{selectionStart:B,selectionEnd:U}=u,ue=P(),we=[],pe=u.value;ue.forEach(he=>{let ye=pe.slice(he,he+w).match(v);if(ye){let se=pe.slice(0,he),ve=pe.slice(he+ye[0].length);pe=`${se}${ve}`,we.push(he)}}),u.value=pe,we.length&&(B>we[we.length-1]?u.selectionStart=Math.max(B-w,we[we.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,U-w*we.length))},P=()=>{let{selectionStart:B,selectionEnd:U,value:ue}=u,we=ue.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-we,ue.slice(B,U).split(`
14
- `).reduce((he,ye,se,ve)=>he.concat(se?he[se-1]+ve[se-1].length+1:B),[]).reverse()},A=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},L=!1,_=()=>{if(H)return;H=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let U=tf(B,a.scene.getNonDeletedElementsMap());if(U){if(u.value.trim()){let ue=kN(U);!ue||ue!==o.id?a.scene.mutateElement(U,{boundElements:(U.boundElements||[]).concat({type:"text",id:o.id})}):ym(U)&&PN(U)}else a.scene.mutateElement(U,{boundElements:U.boundElements?.filter(ue=>!N2(ue))});AN(B,U,a.scene)}n({viaKeyboard:L,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,re&&re.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",A,!0),window.removeEventListener("pointerdown",Y),window.removeEventListener("pointerup",D),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),W(),z(),Z(),u.remove()},D=B=>{window.removeEventListener("pointerup",D);let U=B?.target,ue=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),we=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content"),pe=(U instanceof HTMLElement||U instanceof SVGElement)&&(!!U.closest(`.${Qg.SHAPE_ACTIONS_MENU}`)||!!U.closest(".compact-shape-actions-island"));setTimeout(()=>{pe||ue||we||(u.onblur=_,u.focus(),y&&(u.setSelectionRange(y.start,y.end),y=null))})},F=()=>{u.onblur=null,window.addEventListener("pointerup",D),window.addEventListener("blur",_)},Y=B=>{let U=B?.target;if(B.button===bN.WHEEL){U instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),F();return}let ue=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),we=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${Qg.SHAPE_ACTIONS_MENU}, .${Qg.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!wN(B.target)||ue||we?F():B.target instanceof HTMLCanvasElement&&!k2()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==m&&p()}),W=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),Z=a.onScrollChangeEmitter.on(()=>{p()}),H=!1;s&&!y&&u.select(),D();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 vm}from"@excalidraw/common";import{getCommonBounds as VN}from"@excalidraw/element";var bo=4,cn=6,O2="rgba(0,0,0,0.3)",F2=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=VN(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(vm("sat"))||0,bottom:parseInt(vm("sab"))||0,left:parseInt(vm("sal"))||0,right:parseInt(vm("sar"))||0},m=Fn().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),y=Math.min(i,u),w=Math.max(a,E),x=Math.max(s,g),v=a-r,T=s-i,C=w-b,P=x-y,A=Math.max(bo*2,d.left+d.right)+cn*2,L=n*(l/C)-A,_=Math.max(bo*2,d.top+d.bottom)+cn*2,k=t*(c/P)-_,D=C>v?C*o.zoom.value/(L+A):n/(L+A),F=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===w?null:{x:Math.max(d.left,bo)+cn+(p-b)/C*n,y:t-cn-Math.max(bo,d.bottom),width:L,height:cn,deltaMultiplier:D},vertical:u===y&&g===x?null:{x:m?Math.max(d.left,bo):n-cn-Math.max(d.right,bo),y:Math.max(d.top,bo)+cn+(u-y)/P*t,width:cn,height:k,deltaMultiplier:F}}},nf=(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 c7}from"@excalidraw/math";import{getElementLineSegments as d7}from"@excalidraw/element";import{LinearElementEditor as m7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as p7,isLinearElement as u7}from"@excalidraw/element";import{getFrameChildren as h7}from"@excalidraw/element";import{selectGroupsForSelectedElements as g7}from"@excalidraw/element";import{arrayToMap as f7,easeOut as Y2,isShallowEqual as E7}from"@excalidraw/common";import{simplify as YN}from"points-on-curve";import{polygonFromPoints as XN,lineSegment as Tm,pointFrom as pa,pointOnLineSegment as KN,polygonIncludesPointNonZero as ZN,PRECISION as Im}from"@excalidraw/math";import{boundsContainBounds as H2,computeBoundTextPosition as $N,doBoundsIntersect as jN,elementOverlapsWithFrame as qN,getBoundTextElement as G2,getContainingFrame as JN,getElementBounds as U2,intersectElementWithLineSegment as QN,isBoundToContainer as W2,pointInsideBoundsInclusive as e7}from"@excalidraw/element";var V2=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=YN(n,s));let d=t.filter(g=>!g.locked&&!W2(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=XN(c),u=[m[0]-Im,m[1]-Im,m[2]+Im,m[3]+Im];for(let g of d){let b=U2(g,o),y=t7(g,b,o),w=n7(b,y);if(jN(m,w)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!H2(u,w))continue;let x=o7(g,o,r,y),v=a7(p,x,w,l);l==="contain"?v&&!z2(c,g,o,y)&&a.add(g.id):v?a.add(g.id):z2(c,g,o,y)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?i7([...a],o):[...i,...a]}},t7=(e,n,t)=>{let o=JN(e,t);if(!o)return null;let r=U2(o,t);return H2(r,n)?null:qN(e,o,t)?r:null},n7=(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,o7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=G2(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?r7(s,o):s},r7=(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,y]of[[-m,s-t],[m,r-s],[-p,l-o],[p,i-l]]){if(b===0){if(y<0){g=!1;break}continue}let w=y/b;if(b<0){if(w>E){g=!1;break}u=Math.max(u,w)}else{if(w<u){g=!1;break}E=Math.min(E,w)}}g&&a.push(Tm(pa(s+u*m,l+u*p),pa(s+E*m,l+E*p)))}return a},i7=(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||W2(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))})},a7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>ZN(a,e)||o==="contain"&&l7(a,e);return n.length===0?s7(t)[r](i):n[r](a=>a[r](i))},s7=([e,n,t,o])=>[pa(e,n),pa(t,n),pa(t,o),pa(e,o)],l7=(e,n)=>n.some((t,o)=>o>0&&KN(e,Tm(n[o-1],t))),z2=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Tm(e[l],s)).concat([Tm(e[e.length-1],e[0])]),i=G2(n,t),a=(s,l)=>{let c=QN(s,t,l,0,!o);return o?c.some(d=>e7(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...$N(n,i,t)},s))};var Sm=class extends Pn{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(Y2(s),Y2(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(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&&p7(c)){let d=h7(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=g7({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&&u7(this.app.scene.getNonDeletedElement(a[0]))?new m7(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>c7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!E7(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=f7(this.app.visibleElements);for(let i of this.app.visibleElements){let a=d7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=V2({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 b7,easeOut as X2,THEME as x7}from"@excalidraw/common";import{computeBoundTextPosition as w7,doBoundsIntersect as y7,getBoundTextElement as v7,getElementBounds as I7,getElementLineSegments as T7,getFreedrawOutlineAsSegments as S7,getFreedrawOutlinePoints as C7,intersectElementWithLineSegment as K2,isArrowElement as P7,isFreeDrawElement as Z2,isLineElement as k7,isPointInElement as M7}from"@excalidraw/element";import{lineSegment as A7,lineSegmentsDistance as $2,pointFrom as tI,polygon as L7,polygonIncludesPointNonZero as D7}from"@excalidraw/math";import{getElementsInGroup as j2}from"@excalidraw/element";import{shouldTestInside as _7}from"@excalidraw/element";import{hasBoundTextElement as q2,isBoundToContainer as J2}from"@excalidraw/element";import{getBoundTextElementId as Q2}from"@excalidraw/element";var Cm=class extends Pn{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(X2(s),X2(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===x7.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")});I(this,"elementsToErase",new Set);I(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=>tI(s[0],s[1]))||[];if(o.length<2)return[];let r=A7(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=b7(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(eI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=j2(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(J2(s)&&this.elementsToErase.delete(s.containerId),q2(s)){let d=Q2(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&eI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=j2(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(q2(s)){let d=Q2(s);d&&this.elementsToErase.add(d)}J2(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()}},eI=(e,n,t,o)=>{let r=e[1],i=Z2(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=I7(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!y7(a,l))return!1;if(_7(n)&&M7(r,n,t))return!0;if(Z2(n)){let d=C7(n),m=S7(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if($2(E,e)<=p)return!0;let u=L7(...d.map(([E,g])=>tI(n.x+E,n.y+g)));return!!D7(e[0],u)}let c=v7(n,t);if(P7(n)||k7(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=T7(n,t);for(let p of m)if($2(p,e)<=d)return!0;return!1}return K2(n,t,e,0,!0).length>0||!!c&&K2({...c,...w7(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as $7}from"@excalidraw/common";import{newElement as j7}from"@excalidraw/element";import{COLOR_PALETTE as R7,DEFAULT_FONT_FAMILY as N7,DEFAULT_FONT_SIZE as B7,VERTICAL_ALIGN as O7}from"@excalidraw/common";var nI=44,oI=22,rI=66,iI=48,xl=14,aI=304,sI=320,of=5.87,lI=28,cI=4,dI=2,rf=10,mI=10,pI=8,Kn=12,ua=256,jr=10,af=4,ha=Kn*2,sf=Kn*2,uI=100,hI=140,wl=.35,gI=Kn/2,rr=20,Pm=Kn*2,lf=Kn,_e={fillStyle:"hachure",fontFamily:N7,fontSize:B7,opacity:100,roughness:1,strokeColor:R7.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:O7.MIDDLE,locked:!1};import{pointFrom as ga}from"@excalidraw/math";import{COLOR_PALETTE as wI,DEFAULT_CHART_COLOR_INDEX as F7,FONT_FAMILY as mf,FONT_SIZES as km,ROUNDNESS as fI,DEFAULT_FONT_SIZE as z7,getAllColorsSpecificShade as H7,getFontString as pf,getLineHeight as uf,ROUGHNESS as EI}from"@excalidraw/common";import{getApproxMinLineWidth as hf,measureText as ir,newElement as df,newLinearElement as cf,newTextElement as fa,wrapText as yI}from"@excalidraw/element";var qr=H7(F7),G7=e=>e.labels?.length??e.series[0]?.values.length??0,Ea=(e,n)=>{if(!e)return!1;let t=G7(e);return t<2?!1:n==="radar"?t>=3:!0},bI=(e,n)=>{let t=n<=1?0:Math.min(rI,(n-1)*oI);return e+t},Mm=(e,n)=>{if(e==="line"){let o=bI(iI,n);return{slotWidth:o,gap:xl,chartHeight:sI,xLabelMaxWidth:o+xl*3+rf}}let t=bI(nI,n);return{slotWidth:t,gap:xl,chartHeight:aI,xLabelMaxWidth:t+xl*3+rf}},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}},vI=()=>{let e=ua+sf*2,n=ua+sf*2;return{chartWidth:e,chartHeight:n}},U7=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},xa=(e,n)=>{if(e<=0||qr.length===0)return[];let t=qr.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=>U7(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)=>qr[r[l%r.length]])},wa=e=>{if(qr.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*qr.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)%qr.length},ya=e=>qr[e],II=(e,n)=>{let t=e.flatMap(s=>s.values.map(l=>Math.max(0,l))),o=t.filter(s=>s>0),r=Math.max(1,...t),i=o.length>0?Math.min(...o):1,a=e.length===1&&i>0&&r/i>=uI;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},W7=e=>/\s/.test(e.trim()),Am=(e,n,t)=>W7(e)?yI(e,n,t):e,TI=(e,n,t,o,r,i)=>{let a=mf.Excalifont,s=km.sm,l=uf(a),c=pf({fontFamily:a,fontSize:s}),d=Math.min(hI,r*(e.length>8?.56:.72)),m=hf(c,l),p=e.map((g,b)=>{let y=n[b],w=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>ir(z,c,l).width)),x=Math.max(m,d,w),v=Am(g,c,x),T=ir(v,c,l),C=Math.cos(y),P=Math.sin(y),A=C>wl?"left":C<-wl?"right":"center",L=A==="center"?T.width/2:0,_=Math.abs(C)*L+Math.abs(P)*(T.height/2),k=ha+_+gI,D=t+C*(r+k),F=o+P*(r+k),Y=P>wl?Kn/3:P<-wl?-Kn/3:0;return fa({backgroundColor:i,..._e,text:v,originalText:g,x:D,y:F+Y,fontFamily:a,fontSize:s,lineHeight:l,textAlign:A,verticalAlign:"middle"})}),u=Math.min(...p.map(g=>g.y)),E=Math.max(...p.map(g=>g.y+g.height));return{axisLabels:p,axisLabelTopY:u,axisLabelBottomY:E}},va=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=mf["Lilita One"],s=km.lg,l=uf(a),c=pf({fontFamily:a,fontSize:s}),d=e.map((v,T)=>{let C=v.title?.trim()||`Series ${T+1}`,P=Am(C,c,ua),A=ir(P,c,l),L=rr+lf+A.width;return{label:C,displayLabel:P,color:n[T],width:L,height:A.height}}),m=Math.max(rr/2,...d.map(v=>v.height/2)),p=Math.max(r,o+m+ha),u=Pm,E=rr*.6,g=d.reduce((v,T)=>v+T.width,0)+Pm*Math.max(0,d.length-1),b=g+u*2,y=m*2+E*2,w=[];w.push(df({..._e,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:wI.black,x:t-b/2,y:p-y/2,width:b,height:y,roughness:EI.architect,roundness:{type:fI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(v=>{w.push(df({..._e,backgroundColor:v.color,type:"rectangle",x,y:p-rr/2,width:rr,height:rr,fillStyle:"solid",strokeColor:v.color,roughness:EI.architect,roundness:{type:fI.PROPORTIONAL_RADIUS}})),w.push(fa({..._e,text:v.displayLabel,originalText:v.label,autoResize:!1,x:x+rr+lf,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=v.width+Pm}),w},V7=(e,n,t,o)=>{if(ir(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(ir(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},Y7=(e,n,t,o)=>{if(ir(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=>ir(a,t,o).width>n)&&n>=hf(t,o)?{wrapped:!0,text:yI(e,t,n)}:{wrapped:!1,text:V7(e,n,t,o)}},SI=(e,n,t)=>{let o=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return{width:e*o+n*r,height:e*r+n*o}},xI=e=>e.includes("..."),X7=(e,n,t,o,r)=>{let i=Math.max(lI,Math.ceil(hf(o,r))),a=Math.max(i,Math.floor(n)),s=[];for(let u=a;u>=i;u-=4)s.push(u);s[s.length-1]!==i&&s.push(i);let l=u=>{let E=xI(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
15
- `).length;return{ellipsified:E,visibleChars:g,lineCount:b}},c=(u,E)=>{let g=l(u),b=l(E);return g.ellipsified!==b.ellipsified?!g.ellipsified:g.visibleChars!==b.visibleChars?g.visibleChars>b.visibleChars:g.lineCount!==b.lineCount?g.lineCount<b.lineCount:u.rotatedHeight<E.rotatedHeight},d=null,m=null,p=null;for(let u of s){let{wrapped:E,text:g}=Y7(e,u,o,r),b=ir(g,o,r),y=SI(b.width,b.height,of),w={originalText:e,text:g,metrics:b,rotatedWidth:y.width,rotatedHeight:y.height,wrapped:E},x=y.width-t;if(x<=0){(!d||c(w,d))&&(d=w);continue}(!m||x<m.overflow||x===m.overflow&&c(w,m.spec))&&(m={overflow:x,spec:w}),!xI(w.text)&&(!p||x<p.overflow||x===p.overflow&&c(w,p.spec))&&(p={overflow:x,spec:w})}return d||(p&&m&&p.overflow<=m.overflow+pI?p.spec:m.spec)},Lm=e=>{if(e.type!=="text")return e.y+e.height;let n=SI(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},yl=(e,n,t,o,r)=>{let i=_e.fontFamily,a=km.sm,s=uf(i),l=pf({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-cI*2+mI),d=t;return e.labels?.map((m,p)=>{let u=X7(m,r.xLabelMaxWidth,c,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+dI+(u.rotatedHeight-u.metrics.height)/2;return fa({backgroundColor:o,..._e,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:of,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},K7=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=fa({backgroundColor:o,..._e,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=fa({backgroundColor:o,..._e,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},Z7=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=ba(e,r),s=cf({backgroundColor:o,..._e,type:"line",x:n,y:t,width:i,points:[ga(0,0),ga(i,0)]}),l=cf({backgroundColor:o,..._e,type:"line",x:n,y:t,height:a,points:[ga(0,0),ga(0,-a)]}),c=cf({backgroundColor:o,..._e,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:jr,points:[ga(0,0),ga(i,0)]});return[s,l,c]},Dm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=ba(e,r),c=e.title?fa({backgroundColor:o,..._e,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-z7,roundness:null,textAlign:"center",fontSize:km.xl,fontFamily:mf["Lilita One"]}):null,d=a?df({backgroundColor:o,..._e,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:wI.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...yl(e,n,t,o,r),...K7(e,n,t,o,r,i),...Z7(e,n,t,o,r)]};var CI=(e,n,t,o)=>{let r=e.series,i=Mm("bar",r.length),a=Math.max(1,...r.flatMap(v=>v.values.map(T=>Math.max(0,T)))),s=wa(o),l=ya(s),c=xa(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((v,T)=>r.map((C,P)=>{let L=Math.max(0,C.values[T]??0)/a*i.chartHeight,_=r.length>1?c[P]:l;return j7({backgroundColor:_,..._e,type:"rectangle",fillStyle:r.length>1?"solid":_e.fillStyle,strokeColor:r.length>1?_:_e.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+P*(m+d),y:t-L-i.gap,width:m,height:L})})),g=Dm(e,n,t,l,i,a,$7()),b=yl(e,n,t,l,i),y=Math.max(t+i.gap/2,...b.map(v=>Lm(v))),{chartWidth:w}=ba(e,i),x=va(r,c,n+w/2,y,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as gf}from"@excalidraw/math";import{isDevEnv as q7}from"@excalidraw/common";import{newElement as J7,newLinearElement as PI}from"@excalidraw/element";var kI=(e,n,t,o)=>{let r=e.series,i=Mm("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=wa(o),l=ya(s),c=xa(r.length,s),d=r.map((x,v)=>{let T=x.values.map((_,k)=>gf(k*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),C=Math.max(...T.map(_=>_[0])),P=Math.max(...T.map(_=>_[1])),A=Math.min(...T.map(_=>_[0])),L=Math.min(...T.map(_=>_[1]));return PI({backgroundColor:"transparent",..._e,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-L,width:C-A,strokeColor:c[v],strokeWidth:2,points:T})}),m=r.flatMap((x,v)=>x.values.map((T,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,A=-(T/a)*i.chartHeight+i.gap/2;return J7({backgroundColor:c[v],..._e,fillStyle:"solid",strokeColor:c[v],strokeWidth:2,type:"ellipse",x:n+P+i.slotWidth/2,y:t+A-i.gap*2,width:i.gap,height:i.gap})})),u=r[0].values.map((x,v)=>Math.max(0,...r.map(T=>T.values[v]??0))).map((x,v)=>{let T=v*(i.slotWidth+i.gap)+i.gap/2,C=x/a*i.chartHeight+i.gap/2+i.gap;return PI({backgroundColor:l,..._e,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:jr,points:[gf(0,0),gf(0,C)]})}),E=Dm(e,n,t,l,i,a,q7()),g=yl(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>Lm(x))),{chartWidth:y}=ba(e,i),w=va(r,c,n+y/2,b,t+i.gap*5,l);return[...E,...d,...u,...m,...w]};var kn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},Q7=(e,n)=>e.slice(1).every(t=>kn(t[n])!==null),MI=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>kn(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=>kn(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=>kn(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=>kn(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(!Q7(e,0))return{ok:!1,reason:"Value is not numeric"};let a=kn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>kn(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=kn(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=>kn(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=>kn(a[1]))}]}}},_m=e=>{let n=s=>e.replace(/\r\n?/g,`
13
+ `,n),r=e.slice(t,o===-1?e.length:o);return xN(r)?"rtl":"ltr"},zN=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},HN=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=zN(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},R2=({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,U)=>{if(!U.style.fontFamily||!U.style.fontSize)return!1;let ue=U.style.fontFamily.replace(/"/g,"");return S2({fontFamily:B.fontFamily})!==ue||`${B.fontSize}px`!==U.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let B=a.state,U=a.scene.getElement(o.id);if(!U)return;let{textAlign:ue,verticalAlign:we}=U,pe=a.scene.getNonDeletedElementsMap();if(U&&_2(U)){let he=U.x,ye=U.y,ae=Jg(U,a.scene.getNonDeletedElementsMap()),ve=U.width,st=U.height,je=U.width,Re=U.height;if(ae&&U.containerId){if(bm(ae)){let Nn=IN.getBoundTextElementPosition(ae,U,pe);he=Nn.x,ye=Nn.y}let nu=d(U,u),ro;if(nu?ro=M2(ae.id,ae.height):(ro=vN[ae.id],ro||(ro=M2(ae.id,ae.height))),je=A2(ae,U),Re=kN(ae,U),!bm(ae)&&st>Re){let Nn=L2(st,ae.type);a.scene.mutateElement(ae,{height:Nn}),k2(ae,a.scene);return}else if(!bm(ae)&&ae.height>ro.height&&st<Re){let Nn=L2(st,ae.type);a.scene.mutateElement(ae,{height:Nn}),k2(ae,a.scene)}else{let{x:Nn,y:ts}=MN(ae,U,pe);he=Nn,ye=ts}}let[Do,li]=t(he,ye);ae?ve+=.5:(je=(B.width-8-Do)/B.zoom.value,ve=Math.min(ve,je)),st*=1.05;let dc=T2(U),mc=CN(U,ae),pc=(B.height-li)/B.zoom.value;Object.assign(u.style,{font:dc,lineHeight:U.lineHeight,width:`${ve}px`,height:`${st}px`,left:`${Do}px`,top:`${li}px`,transform:ON(ve,st,mc,B,je,pc),textAlign:ue,verticalAlign:we,color:bN(U.strokeColor,B.theme===fN.DARK),opacity:U.opacity/100,maxHeight:`${pc}px`}),c={angle:mc,font:dc,height:U.height,lineHeightPx:DN(U.fontSize,U.lineHeight),textAlign:ue,width:U.width,x:he,y:ye},u.scrollTop=0,C2()&&(u.style.fontFamily=S2(U)),a.scene.mutateElement(U,{x:he,y:ye})}},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";(BN(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,U=P2(B.x+B.width/2,B.y+B.height/2),[ue,we]=wN(P2(l.x,l.y),U,-B.angle),pe=ue-B.x,he=we-B.y,ye=NN(u.value,B.font,E==="pre-wrap"?B.width:1/0),ae=Math.max(0,Math.min(ye.length-1,Math.floor(he/B.lineHeightPx))),ve=ye[ae],st=FN(u.value,ve.start),je=_N(ve.text,B.font),Re=B.textAlign==="center"?(B.width-je)/2:B.textAlign==="right"?B.width-je:0,Do=pe-Re;if(!ve.text)return ve.start;let li=HN({text:ve.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:st,targetX:Do});return ve.start+(li||0)},y=(()=>{let B=b();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let U=Qw(B),ue=null;if(U.has(qg.excalidrawClipboard)||U.has(qg.excalidraw)){B.preventDefault(),ue=await Br(B);try{let ae=await Od(ue);if(ae.elements){let ve=yN(ae.elements);if(ve){let{selectionStart:st,selectionEnd:je,value:Re}=u;u.value=Re.slice(0,st)+ve+Re.slice(je);let Do=st+ve.length;u.selectionStart=u.selectionEnd=Do,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}ue=ue||await Br(B);let we=ue.findByType(qg.text);if(!we)return;let pe=D2(we.value);if(!pe)return;let he=Jg(o,a.scene.getNonDeletedElementsMap()),ye=T2({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(he){let ae=AN(he,a.scene.getNonDeletedElementsMap()),ve=RN(`${u.value}${pe}`,ye,A2(he,ae)),st=LN(ve,ye);u.style.width=`${st}px`}},u.oninput=()=>{let B=D2(u.value);if(u.value!==B){let U=u.selectionStart;u.value=B,u.selectionStart=U,u.selectionEnd=U}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&xd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(xd),p();else if(!B.shiftKey&&wd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(wd),p();else if(!B.shiftKey&&yd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(yd),p();else if(vh.keyTest(B))a.actionManager.executeAction(vh);else if(Ih.keyTest(B))a.actionManager.executeAction(Ih);else if(B.key===El.ESCAPE)B.preventDefault(),L=!0,_();else if(zr.keyTest(B))B.preventDefault(),_(),a.actionManager.executeAction(zr);else if(B.key===El.ENTER&&B[El.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;L=!0,_()}else if(B.key===El.TAB||B[El.CTRL_OR_CMD]&&(B.code===$g.BRACKET_LEFT||B.code===$g.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===$g.BRACKET_LEFT?C():T(),u.dispatchEvent(new Event("input"))}};let w=4,x=" ".repeat(w),v=new RegExp(`^ {1,${w}}`),T=()=>{let{selectionStart:B,selectionEnd:U}=u,ue=P(),we=u.value;ue.forEach(pe=>{let he=we.slice(0,pe),ye=we.slice(pe);we=`${he}${x}${ye}`}),u.value=we,u.selectionStart=B+w,u.selectionEnd=U+w*ue.length},C=()=>{let{selectionStart:B,selectionEnd:U}=u,ue=P(),we=[],pe=u.value;ue.forEach(he=>{let ye=pe.slice(he,he+w).match(v);if(ye){let ae=pe.slice(0,he),ve=pe.slice(he+ye[0].length);pe=`${ae}${ve}`,we.push(he)}}),u.value=pe,we.length&&(B>we[we.length-1]?u.selectionStart=Math.max(B-w,we[we.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,U-w*we.length))},P=()=>{let{selectionStart:B,selectionEnd:U,value:ue}=u,we=ue.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-we,ue.slice(B,U).split(`
14
+ `).reduce((he,ye,ae,ve)=>he.concat(ae?he[ae-1]+ve[ae-1].length+1:B),[]).reverse()},A=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},L=!1,_=()=>{if(H)return;H=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let U=Jg(B,a.scene.getNonDeletedElementsMap());if(U){if(u.value.trim()){let ue=SN(U);!ue||ue!==o.id?a.scene.mutateElement(U,{boundElements:(U.boundElements||[]).concat({type:"text",id:o.id})}):bm(U)&&TN(U)}else a.scene.mutateElement(U,{boundElements:U.boundElements?.filter(ue=>!_2(ue))});PN(B,U,a.scene)}n({viaKeyboard:L,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,re&&re.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",A,!0),window.removeEventListener("pointerdown",Y),window.removeEventListener("pointerup",D),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),W(),z(),Z(),u.remove()},D=B=>{window.removeEventListener("pointerup",D);let U=B?.target,ue=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),we=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content"),pe=(U instanceof HTMLElement||U instanceof SVGElement)&&(!!U.closest(`.${jg.SHAPE_ACTIONS_MENU}`)||!!U.closest(".compact-shape-actions-island"));setTimeout(()=>{pe||ue||we||(u.onblur=_,u.focus(),y&&(u.setSelectionRange(y.start,y.end),y=null))})},O=()=>{u.onblur=null,window.addEventListener("pointerup",D),window.addEventListener("blur",_)},Y=B=>{let U=B?.target;if(B.button===gN.WHEEL){U instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),O();return}let ue=U instanceof HTMLElement&&U.classList.contains("properties-trigger"),we=(U instanceof HTMLElement||U instanceof SVGElement)&&!!U.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${jg.SHAPE_ACTIONS_MENU}, .${jg.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!EN(B.target)||ue||we?O():B.target instanceof HTMLCanvasElement&&!C2()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==m&&p()}),W=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),Z=a.onScrollChangeEmitter.on(()=>{p()}),H=!1;s&&!y&&u.select(),D();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 xm}from"@excalidraw/common";import{getCommonBounds as GN}from"@excalidraw/element";var xo=4,cn=6,N2="rgba(0,0,0,0.3)",B2=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=GN(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(xm("sat"))||0,bottom:parseInt(xm("sab"))||0,left:parseInt(xm("sal"))||0,right:parseInt(xm("sar"))||0},m=zn().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),y=Math.min(i,u),w=Math.max(a,E),x=Math.max(s,g),v=a-r,T=s-i,C=w-b,P=x-y,A=Math.max(xo*2,d.left+d.right)+cn*2,L=n*(l/C)-A,_=Math.max(xo*2,d.top+d.bottom)+cn*2,k=t*(c/P)-_,D=C>v?C*o.zoom.value/(L+A):n/(L+A),O=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===w?null:{x:Math.max(d.left,xo)+cn+(p-b)/C*n,y:t-cn-Math.max(xo,d.bottom),width:L,height:cn,deltaMultiplier:D},vertical:u===y&&g===x?null:{x:m?Math.max(d.left,xo):n-cn-Math.max(d.right,xo),y:Math.max(d.top,xo)+cn+(u-y)/P*t,width:cn,height:k,deltaMultiplier:O}}},Qg=(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 a7}from"@excalidraw/math";import{getElementLineSegments as s7}from"@excalidraw/element";import{LinearElementEditor as l7}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as c7,isLinearElement as d7}from"@excalidraw/element";import{getFrameChildren as m7}from"@excalidraw/element";import{selectGroupsForSelectedElements as p7}from"@excalidraw/element";import{arrayToMap as u7,easeOut as W2,isShallowEqual as h7}from"@excalidraw/common";import{simplify as UN}from"points-on-curve";import{polygonFromPoints as WN,lineSegment as ym,pointFrom as pa,pointOnLineSegment as VN,polygonIncludesPointNonZero as YN,PRECISION as wm}from"@excalidraw/math";import{boundsContainBounds as F2,computeBoundTextPosition as XN,doBoundsIntersect as KN,elementOverlapsWithFrame as ZN,getBoundTextElement as z2,getContainingFrame as $N,getElementBounds as H2,intersectElementWithLineSegment as jN,isBoundToContainer as G2,pointInsideBoundsInclusive as qN}from"@excalidraw/element";var U2=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=UN(n,s));let d=t.filter(g=>!g.locked&&!G2(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=WN(c),u=[m[0]-wm,m[1]-wm,m[2]+wm,m[3]+wm];for(let g of d){let b=H2(g,o),y=JN(g,b,o),w=QN(b,y);if(KN(m,w)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!F2(u,w))continue;let x=e7(g,o,r,y),v=o7(p,x,w,l);l==="contain"?v&&!O2(c,g,o,y)&&a.add(g.id):v?a.add(g.id):O2(c,g,o,y)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?n7([...a],o):[...i,...a]}},JN=(e,n,t)=>{let o=$N(e,t);if(!o)return null;let r=H2(o,t);return F2(r,n)?null:ZN(e,o,t)?r:null},QN=(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,e7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=z2(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?t7(s,o):s},t7=(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,y]of[[-m,s-t],[m,r-s],[-p,l-o],[p,i-l]]){if(b===0){if(y<0){g=!1;break}continue}let w=y/b;if(b<0){if(w>E){g=!1;break}u=Math.max(u,w)}else{if(w<u){g=!1;break}E=Math.min(E,w)}}g&&a.push(ym(pa(s+u*m,l+u*p),pa(s+E*m,l+E*p)))}return a},n7=(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||G2(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))})},o7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>YN(a,e)||o==="contain"&&i7(a,e);return n.length===0?r7(t)[r](i):n[r](a=>a[r](i))},r7=([e,n,t,o])=>[pa(e,n),pa(t,n),pa(t,o),pa(e,o)],i7=(e,n)=>n.some((t,o)=>o>0&&VN(e,ym(n[o-1],t))),O2=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>ym(e[l],s)).concat([ym(e[e.length-1],e[0])]),i=z2(n,t),a=(s,l)=>{let c=jN(s,t,l,0,!o);return o?c.some(d=>qN(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...XN(n,i,t)},s))};var vm=class extends Pn{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(W2(s),W2(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(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&&c7(c)){let d=m7(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=p7({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&&d7(this.app.scene.getNonDeletedElement(a[0]))?new l7(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>a7(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!h7(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=u7(this.app.visibleElements);for(let i of this.app.visibleElements){let a=s7(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=U2({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 V2,THEME as f7}from"@excalidraw/common";import{computeBoundTextPosition as E7,doBoundsIntersect as b7,getBoundTextElement as x7,getElementBounds as w7,getElementLineSegments as y7,getFreedrawOutlineAsSegments as v7,getFreedrawOutlinePoints as I7,intersectElementWithLineSegment as Y2,isArrowElement as T7,isFreeDrawElement as X2,isLineElement as S7,isPointInElement as C7}from"@excalidraw/element";import{lineSegment as P7,lineSegmentsDistance as K2,pointFrom as Q2,polygon as k7,polygonIncludesPointNonZero as M7}from"@excalidraw/math";import{getElementsInGroup as Z2}from"@excalidraw/element";import{shouldTestInside as A7}from"@excalidraw/element";import{hasBoundTextElement as $2,isBoundToContainer as j2}from"@excalidraw/element";import{getBoundTextElementId as q2}from"@excalidraw/element";var Im=class extends Pn{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(V2(s),V2(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===f7.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")});I(this,"elementsToErase",new Set);I(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=>Q2(s[0],s[1]))||[];if(o.length<2)return[];let r=P7(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(J2(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=Z2(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(j2(s)&&this.elementsToErase.delete(s.containerId),$2(s)){let d=q2(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&J2(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=Z2(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if($2(s)){let d=q2(s);d&&this.elementsToErase.add(d)}j2(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()}},J2=(e,n,t,o)=>{let r=e[1],i=X2(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=w7(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!b7(a,l))return!1;if(A7(n)&&C7(r,n,t))return!0;if(X2(n)){let d=I7(n),m=v7(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if(K2(E,e)<=p)return!0;let u=k7(...d.map(([E,g])=>Q2(n.x+E,n.y+g)));return!!M7(e[0],u)}let c=x7(n,t);if(T7(n)||S7(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=y7(n,t);for(let p of m)if(K2(p,e)<=d)return!0;return!1}return Y2(n,t,e,0,!0).length>0||!!c&&Y2({...c,...E7(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as X7}from"@excalidraw/common";import{newElement as K7}from"@excalidraw/element";import{COLOR_PALETTE as L7,DEFAULT_FONT_FAMILY as D7,DEFAULT_FONT_SIZE as _7,VERTICAL_ALIGN as R7}from"@excalidraw/common";var eI=44,tI=22,nI=66,oI=48,bl=14,rI=304,iI=320,ef=5.87,aI=28,sI=4,lI=2,tf=10,cI=10,dI=8,Zn=12,ua=256,jr=10,nf=4,ha=Zn*2,of=Zn*2,mI=100,pI=140,xl=.35,uI=Zn/2,rr=20,Tm=Zn*2,rf=Zn,_e={fillStyle:"hachure",fontFamily:D7,fontSize:_7,opacity:100,roughness:1,strokeColor:L7.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:R7.MIDDLE,locked:!1};import{pointFrom as ga}from"@excalidraw/math";import{COLOR_PALETTE as bI,DEFAULT_CHART_COLOR_INDEX as N7,FONT_FAMILY as lf,FONT_SIZES as Sm,ROUNDNESS as hI,DEFAULT_FONT_SIZE as B7,getAllColorsSpecificShade as O7,getFontString as cf,getLineHeight as df,ROUGHNESS as gI}from"@excalidraw/common";import{getApproxMinLineWidth as mf,measureText as ir,newElement as sf,newLinearElement as af,newTextElement as fa,wrapText as xI}from"@excalidraw/element";var qr=O7(N7),F7=e=>e.labels?.length??e.series[0]?.values.length??0,Ea=(e,n)=>{if(!e)return!1;let t=F7(e);return t<2?!1:n==="radar"?t>=3:!0},fI=(e,n)=>{let t=n<=1?0:Math.min(nI,(n-1)*tI);return e+t},Cm=(e,n)=>{if(e==="line"){let o=fI(oI,n);return{slotWidth:o,gap:bl,chartHeight:iI,xLabelMaxWidth:o+bl*3+tf}}let t=fI(eI,n);return{slotWidth:t,gap:bl,chartHeight:rI,xLabelMaxWidth:t+bl*3+tf}},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}},wI=()=>{let e=ua+of*2,n=ua+of*2;return{chartWidth:e,chartHeight:n}},z7=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},xa=(e,n)=>{if(e<=0||qr.length===0)return[];let t=qr.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=>z7(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)=>qr[r[l%r.length]])},wa=e=>{if(qr.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*qr.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)%qr.length},ya=e=>qr[e],yI=(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>=mI;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},H7=e=>/\s/.test(e.trim()),Pm=(e,n,t)=>H7(e)?xI(e,n,t):e,vI=(e,n,t,o,r,i)=>{let a=lf.Excalifont,s=Sm.sm,l=df(a),c=cf({fontFamily:a,fontSize:s}),d=Math.min(pI,r*(e.length>8?.56:.72)),m=mf(c,l),p=e.map((g,b)=>{let y=n[b],w=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>ir(z,c,l).width)),x=Math.max(m,d,w),v=Pm(g,c,x),T=ir(v,c,l),C=Math.cos(y),P=Math.sin(y),A=C>xl?"left":C<-xl?"right":"center",L=A==="center"?T.width/2:0,_=Math.abs(C)*L+Math.abs(P)*(T.height/2),k=ha+_+uI,D=t+C*(r+k),O=o+P*(r+k),Y=P>xl?Zn/3:P<-xl?-Zn/3:0;return fa({backgroundColor:i,..._e,text:v,originalText:g,x:D,y:O+Y,fontFamily:a,fontSize:s,lineHeight:l,textAlign:A,verticalAlign:"middle"})}),u=Math.min(...p.map(g=>g.y)),E=Math.max(...p.map(g=>g.y+g.height));return{axisLabels:p,axisLabelTopY:u,axisLabelBottomY:E}},va=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=lf["Lilita One"],s=Sm.lg,l=df(a),c=cf({fontFamily:a,fontSize:s}),d=e.map((v,T)=>{let C=v.title?.trim()||`Series ${T+1}`,P=Pm(C,c,ua),A=ir(P,c,l),L=rr+rf+A.width;return{label:C,displayLabel:P,color:n[T],width:L,height:A.height}}),m=Math.max(rr/2,...d.map(v=>v.height/2)),p=Math.max(r,o+m+ha),u=Tm,E=rr*.6,g=d.reduce((v,T)=>v+T.width,0)+Tm*Math.max(0,d.length-1),b=g+u*2,y=m*2+E*2,w=[];w.push(sf({..._e,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:bI.black,x:t-b/2,y:p-y/2,width:b,height:y,roughness:gI.architect,roundness:{type:hI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(v=>{w.push(sf({..._e,backgroundColor:v.color,type:"rectangle",x,y:p-rr/2,width:rr,height:rr,fillStyle:"solid",strokeColor:v.color,roughness:gI.architect,roundness:{type:hI.PROPORTIONAL_RADIUS}})),w.push(fa({..._e,text:v.displayLabel,originalText:v.label,autoResize:!1,x:x+rr+rf,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=v.width+Tm}),w},G7=(e,n,t,o)=>{if(ir(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(ir(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},U7=(e,n,t,o)=>{if(ir(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=>ir(a,t,o).width>n)&&n>=mf(t,o)?{wrapped:!0,text:xI(e,t,n)}:{wrapped:!1,text:G7(e,n,t,o)}},II=(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}},EI=e=>e.includes("..."),W7=(e,n,t,o,r)=>{let i=Math.max(aI,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=EI(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}=U7(e,u,o,r),b=ir(g,o,r),y=II(b.width,b.height,ef),w={originalText:e,text:g,metrics:b,rotatedWidth:y.width,rotatedHeight:y.height,wrapped:E},x=y.width-t;if(x<=0){(!d||c(w,d))&&(d=w);continue}(!m||x<m.overflow||x===m.overflow&&c(w,m.spec))&&(m={overflow:x,spec:w}),!EI(w.text)&&(!p||x<p.overflow||x===p.overflow&&c(w,p.spec))&&(p={overflow:x,spec:w})}return d||(p&&m&&p.overflow<=m.overflow+dI?p.spec:m.spec)},km=e=>{if(e.type!=="text")return e.y+e.height;let n=II(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},wl=(e,n,t,o,r)=>{let i=_e.fontFamily,a=Sm.sm,s=df(i),l=cf({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-sI*2+cI),d=t;return e.labels?.map((m,p)=>{let u=W7(m,r.xLabelMaxWidth,c,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+lI+(u.rotatedHeight-u.metrics.height)/2;return fa({backgroundColor:o,..._e,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:ef,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},V7=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=fa({backgroundColor:o,..._e,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=fa({backgroundColor:o,..._e,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},Y7=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=ba(e,r),s=af({backgroundColor:o,..._e,type:"line",x:n,y:t,width:i,points:[ga(0,0),ga(i,0)]}),l=af({backgroundColor:o,..._e,type:"line",x:n,y:t,height:a,points:[ga(0,0),ga(0,-a)]}),c=af({backgroundColor:o,..._e,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:jr,points:[ga(0,0),ga(i,0)]});return[s,l,c]},Mm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=ba(e,r),c=e.title?fa({backgroundColor:o,..._e,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-B7,roundness:null,textAlign:"center",fontSize:Sm.xl,fontFamily:lf["Lilita One"]}):null,d=a?sf({backgroundColor:o,..._e,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:bI.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...wl(e,n,t,o,r),...V7(e,n,t,o,r,i),...Y7(e,n,t,o,r)]};var TI=(e,n,t,o)=>{let r=e.series,i=Cm("bar",r.length),a=Math.max(1,...r.flatMap(v=>v.values.map(T=>Math.max(0,T)))),s=wa(o),l=ya(s),c=xa(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((v,T)=>r.map((C,P)=>{let L=Math.max(0,C.values[T]??0)/a*i.chartHeight,_=r.length>1?c[P]:l;return K7({backgroundColor:_,..._e,type:"rectangle",fillStyle:r.length>1?"solid":_e.fillStyle,strokeColor:r.length>1?_:_e.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+P*(m+d),y:t-L-i.gap,width:m,height:L})})),g=Mm(e,n,t,l,i,a,X7()),b=wl(e,n,t,l,i),y=Math.max(t+i.gap/2,...b.map(v=>km(v))),{chartWidth:w}=ba(e,i),x=va(r,c,n+w/2,y,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as pf}from"@excalidraw/math";import{isDevEnv as Z7}from"@excalidraw/common";import{newElement as $7,newLinearElement as SI}from"@excalidraw/element";var CI=(e,n,t,o)=>{let r=e.series,i=Cm("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=wa(o),l=ya(s),c=xa(r.length,s),d=r.map((x,v)=>{let T=x.values.map((_,k)=>pf(k*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),C=Math.max(...T.map(_=>_[0])),P=Math.max(...T.map(_=>_[1])),A=Math.min(...T.map(_=>_[0])),L=Math.min(...T.map(_=>_[1]));return SI({backgroundColor:"transparent",..._e,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-L,width:C-A,strokeColor:c[v],strokeWidth:2,points:T})}),m=r.flatMap((x,v)=>x.values.map((T,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,A=-(T/a)*i.chartHeight+i.gap/2;return $7({backgroundColor:c[v],..._e,fillStyle:"solid",strokeColor:c[v],strokeWidth:2,type:"ellipse",x:n+P+i.slotWidth/2,y:t+A-i.gap*2,width:i.gap,height:i.gap})})),u=r[0].values.map((x,v)=>Math.max(0,...r.map(T=>T.values[v]??0))).map((x,v)=>{let T=v*(i.slotWidth+i.gap)+i.gap/2,C=x/a*i.chartHeight+i.gap/2+i.gap;return SI({backgroundColor:l,..._e,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:jr,points:[pf(0,0),pf(0,C)]})}),E=Mm(e,n,t,l,i,a,Z7()),g=wl(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>km(x))),{chartWidth:y}=ba(e,i),w=va(r,c,n+y/2,b,t+i.gap*5,l);return[...E,...d,...u,...m,...w]};var kn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},j7=(e,n)=>e.slice(1).every(t=>kn(t[n])!==null),PI=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>kn(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=>kn(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=>kn(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=>kn(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(!j7(e,0))return{ok:!1,reason:"Value is not numeric"};let a=kn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>kn(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=kn(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=>kn(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=>kn(a[1]))}]}}},Am=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)?MI(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ia}from"@excalidraw/math";import{FONT_FAMILY as eB,FONT_SIZES as tB,getFontString as nB,getLineHeight as oB,ROUGHNESS as AI}from"@excalidraw/common";import{measureText as rB,newLinearElement as ff,newTextElement as iB}from"@excalidraw/element";var LI=(e,n,t,o)=>{if(!Ea(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,W)=>`Value ${W+1}`),i=e.series,{normalize:a,renderSteps:s}=II(i,r.length),l=wa(o),c=ya(l),d=xa(i.length,l),{chartWidth:m,chartHeight:p}=vI(),u=n+m/2,E=t-p/2,g=ua/2,b=r.map((z,W)=>-Math.PI/2+Math.PI*2*W/r.length),{axisLabels:y,axisLabelTopY:w,axisLabelBottomY:x}=TI(r,b,u,E,g,c),v=eB["Lilita One"],T=tB.xl,C=oB(v),P=nB({fontFamily:v,fontSize:T}),A=e.title?Am(e.title,P,m+ha*2):null,L=A?rB(A,P,C):null,_=A?iB({backgroundColor:c,..._e,text:A,originalText:e.title??A,x:n+m/2,y:w-ha-L.height/2,fontFamily:v,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:af},(z,W)=>{let Z=(W+1)/af,H=g*Z,re=b.map(B=>Ia(Math.cos(B)*H,Math.sin(B)*H));return re.push(Ia(re[0][0],re[0][1])),ff({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:H*2,height:H*2,strokeStyle:"solid",roughness:AI.architect,opacity:jr,polygon:!0,points:re})}):[],D=b.map(z=>{let W=Math.cos(z)*g,Z=Math.sin(z)*g;return ff({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:Math.abs(W),height:Math.abs(Z),strokeStyle:"solid",roughness:AI.architect,opacity:jr,points:[Ia(0,0),Ia(W,Z)]})}),F=i.map((z,W)=>{let Z=b.map((H,re)=>{let B=z.values[re]??0,U=a(B,re)*g;return Ia(Math.cos(H)*U,Math.sin(H)*U)});return Z.push(Ia(Z[0][0],Z[0][1])),ff({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[W],strokeWidth:2,polygon:!0,points:Z})}),Y=va(i,d,u,x,t+Kn*5,c);return[..._?[_]:[],...y,...k,...D,...F,...Y]};var Ef=(e,n,t,o,r)=>e==="line"?kI(n,t,o,r):e==="radar"?LI(n,t,o,r):CI(n,t,o,r);import{clamp as Rm,pointFrom as Ta,pointsEqual as pB,bezierEquation as GI,pointRotateRads as Nm,pointDistance as uB}from"@excalidraw/math";import{arrayToMap as hB,BIND_MODE_TIMEOUT as vl,DEFAULT_TRANSFORM_HANDLE_SPACING as UI,FRAME_STYLE as mn,getFeatureFlag as gB,invariant as BI,shouldRotateWithDiscreteAngle as WI,THEME as xo}from"@excalidraw/common";import{deconstructDiamondElement as vf,deconstructRectanguloidElement as VI,elementCenterPoint as Sa,getDiamondBaseCorners as fB,FOCUS_POINT_SIZE as EB,getOmitSidesForEditorInterface as bf,getTransformHandles as bB,getTransformHandlesFromCoords as xB,hasBoundingBox as wB,hitElementItself as yB,isArrowElement as YI,isBindableElement as XI,isElbowArrow as Ca,isFrameLikeElement as Pa,isImageElement as Bm,isLinearElement as vB,isLineElement as IB,maxBindingDistance_simple as TB,isTextElement as SB,LinearElementEditor as pn,getActiveTextElement as CB,getElementsInGroup as If,getSelectedGroupIds as PB,isSelectedViaGroup as kB,selectGroupsFromGivenElements as MB}from"@excalidraw/element";import{renderSelectionElement as AB}from"@excalidraw/element";import{getCommonBounds as Tf,getElementAbsoluteCoords as Tl}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as OI,isFocusPointVisible as LB}from"@excalidraw/element";import{pointFrom as St}from"@excalidraw/math";import{THEME as aB}from"@excalidraw/common";var sB="#ff6b6b",lB="#ff0000",DI=1,_I=2,RI=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===aB.LIGHT||n.zenModeEnabled?sB:lB,o=(n.zenModeEnabled?DI*1.5:DI)/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,dB(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,mB(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,cB(r,e,n));e.restore()},cB=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];dn(o,r,n)}for(let o of e.points)NI(o,t,n)},dB=(e,n,t)=>{NI(e.points[0],t,n),t.zenModeEnabled||dn(e.points[0],e.points[1],n)},NI=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?_I*1.5:_I)/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()},dn=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},mB=(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||dn(St(e[0],e[1]-i),St(e[0],e[1]+i),r),dn(St(l[0]-s,l[1]-a),St(l[0]-s,l[1]+a),r),dn(St(l[0]+s,l[1]-a),St(l[0]+s,l[1]+a),r),o.zenModeEnabled||(dn(St(n[0],n[1]-i),St(n[0],n[1]+i),r),dn(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||dn(St(e[0]-i,e[1]),St(e[0]+i,e[1]),r),dn(St(l[0]-a,l[1]-s),St(l[0]+a,l[1]-s),r),dn(St(l[0]-a,l[1]+s),St(l[0]+a,l[1]+s),r),o.zenModeEnabled||(dn(St(n[0]-i,n[1]),St(n[0]+i,n[1]),r),dn(e,n,r))}};var DB=(e,n)=>{BI(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;BI(t,"midPointCoords is null"),Om(t,e,n)},_B=(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=pn.getElement(o,t);if(!i)return;let a=pn.getPointAtIndexGlobalCoordinates(i,r,t);Om(a,e,n)},Om=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",is(n,e[0],e[1],pn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},RB=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!YI(i)||i.isDeleted)return;let a=r==="label"?pn.getBoundTextElementCenter(i,t):pn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);Om(a,e,n)},xf=(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)"),is(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},NB=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&Pa(a)&&(e.translate(a.x,a.y),e.beginPath(),mn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,mn.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=mn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===xo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",mn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,mn.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=Sa(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=Rm(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===xo.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]=vf(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]=VI(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&&(Pa(n.element)||XI(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&pn.getElement(s?.elementId,t),c=r&&yB({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&Ca(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=Sa(n.element,t),p;if(n.element.type==="diamond"){let b=Sa(n.element,t);p=fB(n.element).map(y=>{let w=GI(y,.5),x=Nm(w,b,n.element.angle);return Ta(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(y=>{let w=Ta(y.x+n.element.x,y.y+n.element.y),x=Nm(w,m,n.element.angle);return Ta(x[0],x[1])});let u=r&&p.reduce((b,y,w)=>{let x=uB(y,r);return w===-1||x<b.distance?{idx:w,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=TB(o.zoom)+n.element.strokeWidth/2;p.forEach((b,y)=>{let w=(!c||d)&&u?.idx===y&&u.distance<=g,x=!w&&(d||y===u?.idx&&u.distance<=g*2);w?(e.fillStyle=o.theme===xo.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===xo.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()}}},BB=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=vl-(a?.runtime??(s?0:vl)),c=Rm(1/vl*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&Pa(m)&&(n.translate(m.x,m.y),n.beginPath(),mn.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,mn.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=mn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===xo.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,mn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,mn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=Sa(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=Rm(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===xo.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,y]=vf(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),y.forEach(w=>{let[x,v,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(v[0]-t.x+d,v[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,y]=VI(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),y.forEach(w=>{let[x,v,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(v[0]-t.x+d,v[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)>vl)return;let p=.5*(Math.min(t.width,t.height)/2);if(!Pa(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/vl*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||!WI(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,y;if(t.type==="diamond"){let[,w]=vf(t),x=Sa(t,o);y=w.map(v=>{let T=GI(v,.5),C=Nm(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let w=Sa(t,o);y=[{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(v=>{let T=Ta(v.x+t.x,v.y+t.y),C=Nm(T,w,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}y.forEach(w=>{n.clearRect(w.x-b,w.y-b,b*2,b*2)}),n.fillStyle=r.theme===xo.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,y.forEach(w=>{n.beginPath(),n.arc(w.x,w.y,E,0,2*Math.PI),n.fill()}),n.restore()}}return{runtime:(a?.runtime??0)+i}},OB=(e,n,t,o,r,i,a)=>{if(t===null)return;if(gB("COMPLEX_BINDINGS"))return BB(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Ta(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&WI(e.lastPointerMoveEvent);NB(n,t,o,r,s,l),n.restore()},KI=(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??UI*2)/n.zoom.value,y=8/n.zoom.value,w=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 v=0;v<x;++v)e.strokeStyle=l[v],m&&e.setLineDash([y,w+(y+w)*(x-1)]),e.lineDashOffset=(y+w)*v,as(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},FB=(e,n,t,o)=>{let[r,i,a,s]=Tl(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=mn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),as(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,mn.radius/n.zoom.value),e.restore()},FI=(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]=Tf(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=If(t,d);return l(m)};Object.entries(MB(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>KI(e,n,d))},wf=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=pn.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=pn,a=n.selectedLinearElement?.isEditing?i:i/2,s=Ca(t),l=IB(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)&&pB(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),xf(e,n,c,a,p,!1,m)}),Ca(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{pn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||xf(e,n,Ta((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else pn.getEditorMidPoints(t,o,n).filter((d,m,p)=>d!==null&&!(Ca(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&xf(e,n,d,i/2,!1,!0,!1)});e.restore()},zB=(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()},HB=(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)",is(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},zI=({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||!XI(a)||a.isDeleted)return;let s=OI(i.fixedPoint,a,r);if(!LB(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&&Om(s,o,n),!(m&&c)){let p=OI(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=pn.getPointAtIndexGlobalCoordinates(e,d,r);zB(o,n,E,p),HB(o,n,p,EB/1.5,u)}},HI=(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"?is(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()):as(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},GB=(e,n,t,o,r)=>{let[i,a,,,s,l]=Tl(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(w=>{let[[x,v],[T,C],[P,A],[L,_],[k,D]]=w;e.save(),e.translate(s,l),e.rotate(o.angle),e.beginPath(),e.moveTo(x+T,v+C),e.lineTo(x+P,v+A),e.stroke(),e.beginPath(),e.moveTo(x+L,v+_),e.lineTo(x+k,v+D),e.stroke(),e.restore()}),e.restore()},UB=(e,n,t,o)=>{n.save();let r=jg(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()},WB=(e,n,t,o,r)=>{let i=qg(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())},VB=(e,n,t,o,r,i)=>{for(let a of n){if(!Bm(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let d=Il(a,t,r,"center");d&&$I(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=Il(a,t,r,"center");m&&ZI(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=Il(a,t,r,"top-right");d&&XB(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},Il=(e,n,t,o)=>{if(!Bm(e))return null;let[r,i,a,s]=Tl(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}},ZI=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===xo.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*Rm(i,0,1)),e.stroke()),e.restore()},yf=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,YB=(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()},XB=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??yf("--color-primary",s),d=i.color??yf("--color-warning-darkest","#ec8b14");if(l==="failed"){$I(e,n,t,o,a,{color:i.color??yf("--color-danger","#e03131")});return}if(l==="uploading"&&ZI(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),YB(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())},$I=(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()},KB=({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]=bc(n,a),E=d,g=xc({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&&wf(g,s,b,t),s.selectionElement&&!s.isCropping)try{AB(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let y=CB(r,s);if(y&&!y.autoResize&&WB(y,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&UB(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:OB(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&RB(g,s,i),s.frameToHighlight&&FB(g,s,s.frameToHighlight,t),s.elementsToHighlight&&FI(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:If(i,s.activeLockedId);FI(g,s,P,{colors:["#ced4da"],dashed:!0})}let w=r.some(C=>Pa(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&wf(g,s,r[0],t);let x=s.selectedLinearElement,v=x&&pn.getElement(x.elementId,i);if(v&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?DB(g,s):(Ca(v)?x.hoverPointIndex===0||x.hoverPointIndex===v.points.length-1:x.hoverPointIndex>=0)&&_B(g,s,t)),YI(v)&&(zI({arrow:v,elementsMap:i,appState:s,context:g,type:"start"}),zI({arrow:v,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=wB(r,s,c),P=r.length===1&&vB(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&wf(g,s,r[0],t);let A=l.selectionColor||"#000";if(C){let L=hB(r),_=[];for(let D of t.values()){let F=[],Y=l.remoteSelectedElementIds.get(D.id);if(P&&Ca(D)&&(D.startBinding||D.endBinding)||(L.has(D.id)&&!kB(s,D)&&F.push(A),Y&&F.push(...Y.map(z=>Gr(z,s.collaborators.get(z))))),F.length){let[z,W,Z,H,re,B]=Tl(D,t,!0);_.push({angle:D.angle,x1:z,y1:W,x2:Z,y2:H,selectionColors:D.locked?["#ced4da"]:F,dashed:!!Y||D.locked,cx:re,cy:B,activeEmbeddable:s.activeEmbeddable?.element===D&&s.activeEmbeddable.state==="active",padding:D.id===s.croppingElementId||Bm(D)?0:void 0})}}let k=D=>{let F=If(t,D),[Y,z,W,Z]=Tf(F);_.push({angle:0,x1:Y,x2:W,y1:z,y2:Z,selectionColors:F.some(H=>H.locked)?["#ced4da"]:["#000"],dashed:!0,cx:Y+(W-Y)/2,cy:z+(Z-z)/2,activeEmbeddable:!1})};for(let D of PB(s))k(D);s.editingGroupId&&k(s.editingGroupId),_.forEach(D=>KI(g,s,D))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let L=bB(r[0],s.zoom,t,"mouse",bf(c));if(!s.viewModeEnabled&&C&&!SB(s.editingTextElement)&&!s.croppingElementId&&HI(g,l,s,L,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&Bm(_)&&GB(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(L=>L.locked)){let L=UI*2/s.zoom.value;g.fillStyle="#fff";let[_,k,D,F]=Tf(r,t),Y=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=A,as(g,_-L,k-L,D-_+L*2,F-k+L*2,(_+D)/2,(k+F)/2,0),g.lineWidth=z,g.setLineDash(Y);let W=xB([_,k,D,F,(_+D)/2,(k+F)/2],0,s.zoom,"mouse",w?{...bf(c),rotation:!0}:bf(c));r.some(Z=>!Z.locked)&&HI(g,l,s,W,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:A})=>{let L=t.get(C);if(L){let[_,k,,,D,F]=Tl(L,t,!0);g.save(),s.theme===xo.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=Pa(L)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(D,F),g.rotate(L.angle),A.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/Y-D,k+z.offsetY/Y-F,z.width/Y,z.height/Y)}),g.restore()}}),RI(g,s),VB(g,o,t,e,s,l.selectionColor),g.restore(),hy({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=F2(t,p,u,s),g.save(),g.fillStyle=O2,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&Zd(g,C.x,C.y,C.width,C.height,cn/2)}),g.restore()),{scrollBars:T,animationState:E}},Sf=e=>{let n=KB(e);return e.callback(n),n};import{useEffect as kl,useMemo as jI,useRef as Af,useState as ZB}from"react";import{bumpVersion as Sl,getLinearElementSubType as Ma,mutateElement as Lf,updateElbowArrowPoints as $B}from"@excalidraw/element";import{pointFrom as zm,pointRotateRads as jB}from"@excalidraw/math";import{hasBoundTextElement as qB,isArrowBoundToElement as JB,isArrowElement as QB,isElbowArrow as eO,isLinearElement as Nf,isUsingAdaptiveRadius as tO}from"@excalidraw/element";import{getCommonBoundingBox as nO,getElementAbsoluteCoords as oO}from"@excalidraw/element";import{getBoundTextElement as tT,getBoundTextMaxHeight as rO,getBoundTextMaxWidth as iO,redrawTextBoundingBox as aO}from"@excalidraw/element";import{wrapText as sO}from"@excalidraw/element";import{assertNever as lO,CLASSES as cO,getFontString as Cf,isProdEnv as dO,mapFind as mO,reduceToCommonValue as pO,ROUNDNESS as Pf,sceneCoordsToViewportCoords as uO,updateActiveTool as qI}from"@excalidraw/common";import{measureText as JI}from"@excalidraw/element";import{LinearElementEditor as hO}from"@excalidraw/element/linearElementEditor";import{newArrowElement as kf,newElement as gO,newLinearElement as fO}from"@excalidraw/element";import{ShapeCache as EO}from"@excalidraw/element";import{updateBindings as bO}from"@excalidraw/element";import{jsx as Rf}from"react/jsx-runtime";var xO=8,wO=10,Cl=["rectangle","diamond","ellipse"],Pl=["line","sharpArrow","curvedArrow","elbowArrow"],yO=new Set(Cl),vO=new Set(Pl),Aa=e=>yO.has(e),Hm=e=>e==="arrow"||vO.has(e),Zn=je(null),Ml=new Map,Al=new Map,IO=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=Af(null);return kl(()=>{if(n.length===0){e.updateEditorAtom(Zn,null);return}let o=Gm(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(Zn,null),t.current=null)},[n,e]),kl(()=>()=>{Ml.clear(),Al.clear()},[]),Rf(TO,{app:e,elements:n})},TO=({app:e,elements:n})=>{let t=Gm(n),o=jI(()=>t==="generic"?oT(n):[],[t,n]),r=jI(()=>t==="linear"?_f(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>Ma(m)===Ma(r[0])):!1,[a,s]=ZB({x:0,y:0}),l=Af(""),c=Af(null);kl(()=>{let m=[...o,...r].sort((b,y)=>b.id.localeCompare(y.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,,,y,w,x]=oO(m[0],e.scene.getNonDeletedElementsMap());u=jB(zm(b,y),zm(w,x),m[0].angle)}else{let{minX:b,maxY:y}=nO(m);u=zm(b,y)}let{x:E,y:g}=uO({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),kl(()=>{for(let m of r){let p=Df(m.id,MO(m));Al.has(p)||Al.set(p,m)}},[r]),kl(()=>{for(let m of o)if(!Ml.has(m.id)){let p=tT(m,e.scene.getNonDeletedElementsMap());p&&Ml.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",Bo],["sharpArrow",zo],["curvedArrow",Go],["elbowArrow",Ho]]:t==="generic"?[["rectangle",Ei],["diamond",bi],["ellipse",xi]]:[];return Rf("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(wO+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-xO}px`,zIndex:2},className:cO.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&Ma(r[0])===m);return Rf(K,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Ne("convertElementType",m,"ui"),Bf(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},SO=(e,n,t)=>{let o=iO(e,n),r=rO(e,n),i=sO(n.text,Cf(n),o),a=JI(i,Cf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=JI(n.text,Cf(l),n.lineHeight)}Lf(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),aO(n,e,t)},Bf=(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=oT(r),c=s.every(d=>d.type===s[0].type)?Cl.indexOf(s[0].type):-1;if(t=t??Cl[(c+Cl.length+a)%Cl.length],t&&Aa(t)){let d={};for(let p of s){let u=eT(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=tT(p,e.scene.getNonDeletedElementsMap());u&&(Ml.get(p.id)&&Lf(u,e.scene.getNonDeletedElementsMap(),{fontSize:Ml.get(p.id)?.fontSize??u.fontSize}),SO(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:qI(p,{type:"selection"})}))}}if(n==="linear"){let s=_f(r);if(!t){let c=pO(s,Ma),d=c?Pl.indexOf(c):-1;t=Pl[(d+Pl.length+a)%Pl.length]}if(Hm(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Al.get(Df(m.id,t));if(p&&Ma(p)===t)d.set(p.id,p),c.push(p);else{let u=eT(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(Nf(m))if(eO(m)){let p=CO(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=$B(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Lf(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=mO(["line","sharpArrow","curvedArrow"],u=>Al.get(Df(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 hO(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:qI(c,{type:"selection"})}))}return!0},Gm=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(Aa(t.type))return"generic";nT(t)&&(n=!0)}return n?"linear":null},nT=e=>Nf(e)&&(!QB(e)||!JB(e)&&!qB(e)),Df=(e,n)=>`${e}:${n}`,oT=e=>e.filter(n=>Aa(n.type)),_f=e=>e.filter(n=>nT(n)),Fm=20,ka=(e,n)=>e[0]===n[0],Mf=(e,n)=>e[1]===n[1],QI=(e,n)=>ka(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),CO=e=>{let n=[e.points[0]],t=PO(e.points);for(let i=1;i<t.length;++i){let a=n[n.length-1],s=[...t[i]];Math.abs(s[0]-a[0])<Fm?s[0]=a[0]:Math.abs(s[1]-a[1])<Fm&&(s[1]=a[1]),ka(a,s)||Mf(a,s)||n.push(zm(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])||Mf(n[i-1],n[i])&&Mf(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=ka(a,s),d=ka(s,l);if(c!==d){let m=QI(a,s),p=QI(s,l);if(m<Fm||p<Fm){if(p<m)c?l[0]=a[0]:l[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=s[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=s[1];continue}}r.push(s)}return r.push(o[o.length-1]),r},PO=e=>{if(e.length===0)return[];let n=[e[0]];for(let t=1;t<e.length;t++){let[o,r]=n[n.length-1],[i,a]=e[t];(o!==i||r!==a)&&n.push(e[t])}return n},eT=(e,n,t)=>{if(!kO(e.type,n)){if(!dO())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(EO.delete(e),Aa(n)){let o=Sl(gO({...e,type:n,roundness:e.roundness?{type:tO(n)?Pf.ADAPTIVE_RADIUS:Pf.PROPORTIONAL_RADIUS}:e.roundness}));return bO(o,t.scene,t.state),o}if(Hm(n))switch(n){case"line":return Sl(fO({...e,type:"line"}));case"sharpArrow":return Sl(kf({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Sl(kf({...e,type:"arrow",elbowed:!1,roundness:{type:Pf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Sl(kf({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return lO(n,`unhandled conversion type: ${n}`),e},kO=(e,n)=>!!(Aa(e)&&Aa(n)||Hm(e)&&Hm(n)),MO=e=>Nf(e)?Ma(e):e.type,rT=IO;import{bindBindingElementToFixedPoint as AO,dragNewTextElement as LO,getBoundTextElement as DO,getEndpointBoundTextDragAnchor as _O,getTextBindingForArrowEndpoint as RO,getUnboundArrowEndpointAtPoint as NO,isArrowElement as BO,isBindingEnabled as OO,isEndpointBoundText as FO,isTextElement as zO}from"@excalidraw/element";import{pointFrom as HO}from"@excalidraw/math";var Um=class{constructor(n){this.app=n;I(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});I(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!OO(this.app.state))return null;let o=NO(HO(n,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!o||this.app.getTextElementAtPosition(n,t))return null;let r=this.app.getElementAtPosition(n,t,{includeLockedElements:!0});return r&&r.id!==o.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(o.arrow.id)?null:o}getAnchorAtPosition(n,t){let o=this.getBindableEndpointAtPosition(n,t);if(o)return{elementId:o.arrow.id,anchor:o.startOrEnd};let r=this.app.getTextBindableContainerAtPosition(n,t);return!BO(r)||DO(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 RO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){AO(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!zO(n)||!FO(n,this.app.scene.getNonDeletedElementsMap())?!1:(LO({newElement:n,..._O(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as GO,BUCKET_FILL_BACKGROUND_PICKS as UO,COLOR_PALETTE as aT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as WO,getSizeFromPoints as VO,isTransparent as YO,THEME as XO}from"@excalidraw/common";import{pointFrom as iT}from"@excalidraw/math";import{computeBucketFillPolygon as KO,isBucketFillCompatible as ZO,isFrameLikeElement as $O,isRestylableFill as jO,newLinearElement as qO,ShapeCache as JO}from"@excalidraw/element";var Of=UO.filter(e=>e!==aT.white),Wm=class{constructor(n){this.app=n;I(this,"temporaryEyeDropper",null);I(this,"pending",null);I(this,"handlePointerDown",n=>{this.pending=n});I(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});I(this,"cancel",()=>{this.pending=null});I(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=Of.indexOf(n),o=Of[(t+1)%Of.length];this.app.actionManager.executeAction(bd,"keyboard",{currentItemBackgroundColor:o})});I(this,"openTemporaryEyeDropper",()=>{if(gt.get(Nt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(bd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Nt,n)});I(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&gt.get(Nt)===n&&this.app.updateEditorAtom(Nt,null)});I(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}),JO.delete(n),this.app.scheduleCapture())});I(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=KO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&ZO(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&&jO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=VO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(w=>iT(w[0]-d,w[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?$O(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:s.boundaryElementIds.map(w=>r.get(w)?.groupIds).filter(w=>!!w).reduce((w,x)=>w===null?x:w.filter(v=>x.includes(v)),null)??[],b=qO({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}),y=this.app.scene.getElementsIncludingDeleted().findIndex(w=>w.id===s.insertion.elementId);this.app.scene.insertElementsAtIndex([b],y<0?null:s.insertion.placement==="above"?y+1:y),this.app.scheduleCapture()});I(this,"getBucketFillBackgroundColor",(n,t)=>YO(n)?aT.green[WO]:GO(n,t===XO.DARK))}};import{CURSOR_TYPE as Ll,MIME_TYPES as Ym,THEME as sT}from"@excalidraw/common";var lT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',QO='<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"/>',cT='<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"/>',eF=`data:${Ym.svg},${encodeURIComponent(`${lT}${cT}</svg>`)}`,tF=`data:${Ym.svg},${encodeURIComponent(`${lT}${QO}${cT}</svg>`)}`,nF=e=>{let n=Eu.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${Ym.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>`)}`},Vm=class{constructor(n){this.app=n;I(this,"toolCursorMemo",null);I(this,"eraserCanvasCache",null);I(this,"eraserPreviewDataURL",null);I(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});I(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(Ll.GRAB):this.clear():this.applyForTool()});I(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(os({activeTool:n}))this.set(Ll.GRAB);else if(qt({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(Ll.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${nF(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===sT.LIGHT?eF:tF;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(Ll.AUTO):this.set(Ll.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});I(this,"clear",()=>{this.set("")});I(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(Ym.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as sF}from"@excalidraw/common";import{bindBindingElement as lF,convertToShape as cF,convertToShapeHandlePointerMoveFromPointerDown as dF,getHoveredElementForBinding as dT,isBindingElement as mF,isLineElement as pF,LinearElementEditor as Ff,maxBindingDistance_simple as mT,newArrowElement as uF,updateBoundPoint as hF}from"@excalidraw/element";import{getStrokeWidthByKey as oF,THEME as rF}from"@excalidraw/common";import{clamp as iF,pointFrom as aF}from"@excalidraw/math";var Xm=class{constructor(n){this.app=n;I(this,"trail");this.trail=new Pn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===rF.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>iF(oF("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])=>aF(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var Km=class{constructor(n){this.app=n;I(this,"trail");I(this,"gestureInProgress",!1);I(this,"stop",()=>{this.trail.stop()});I(this,"hasPendingGesture",()=>this.gestureInProgress);I(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(dt),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});I(this,"handlePointerMove",n=>dF(this.app,n));I(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=Ff.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:dT(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&&lF(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=hF(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&&Ff.movePoints(n,t.scene,c)});I(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=>dT(Ff.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:uF({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})});I(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||cF(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:sF(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&pF(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&mF(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new Xm(n)}};import{isArrowKey as gF,KEYS as Jr}from"@excalidraw/common";import{makeNextSelectedElementIds as fF,CaptureUpdateAction as EF,FlowChartCreator as bF,FlowChartNavigator as xF,getSelectedElements as pT,isFlowchartNodeElement as wF}from"@excalidraw/element";var Zm=class e{constructor(n){this.app=n;I(this,"creator",new bF);I(this,"navigator",new xF);I(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});I(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===Jr.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!gF(n.key))return{type:"none"};if(n[Jr.CTRL_OR_CMD]&&!n.shiftKey){let a=pT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&wF(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=pT(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[Jr.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:fF({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:EF.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case Jr.ARROW_UP:return"up";case Jr.ARROW_DOWN:return"down";case Jr.ARROW_RIGHT:return"right";case Jr.ARROW_LEFT:return"left";default:return"right"}}};import{debounce as yF,easeOut as bT,isBounds as vF}from"@excalidraw/common";import{clamp as xT}from"@excalidraw/math";import{getCommonBounds as uT,getElementsInGroup as IF,isElementLink as TF,isExcalidrawElement as SF,parseElementLinkFromURL as CF}from"@excalidraw/element";var $m="animateScrollToContent",La="animateScrollConstraintsSnapBack",hT=500,PF=250,kF=200,zf=302,gT={full:216,compact:64},MF=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")},AF=(e,n)=>{let t=n.get(e);return t?[t]:IF(n,e)},fT=(e,n,t)=>{if(typeof e=="string"){let a=TF(e),s=a?"link":"element",l=a?CF(e):e,c=l?AF(l,n):[];return c.length?{bounds:uT(c,n),type:s}:{bounds:null,type:s}}if(vF(e))return{bounds:e,type:"area"};if(MF(e)&&!SF(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:uT(r,n),type:"element"}},LF=e=>e===!1?0:e===!0||e==null?lu:Math.max(e,0),DF=(e,n,t="scale-down",o,r)=>{let{appState:i}=Ir({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},ET=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=DF(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:LF(r.overscroll),offsets:o};return{...Nn({...e,...a,scrollConstraints:m}),scrollConstraints:m}},_F=({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}}},RF=e=>e===!1?null:e===!0||e==null?hT:e.duration??hT,NF=(e,n,t,o,r)=>{ot.start($m,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=bT(xT(l,0,1));return l<1?(o({..._F({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},BF=(e,n,t=PF)=>{let o=Nn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||ot.running($m))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;ot.start(La,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-bT(xT(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=Nn(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})},jm=class{constructor(n,t){this.app=n;this.dependencies=t;I(this,"lastPosition",{x:0,y:0});I(this,"activeTransition",null);I(this,"uiLastMeasured",new Map);I(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});I(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}});I(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=Fn().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,y]=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],y);let w=u.dataset.viewportUiName;w&&(a.add(w),y>0&&this.uiLastMeasured.set(w,{side:b,offset:y}));break}}}if(n?.reserve&&this.app.editorInterface.formFactor!=="phone"){let u=(E,g)=>{if(a.has(E))return;let{side:b,offset:y}=this.uiLastMeasured.get(E)??g;i[b]=Math.max(i[b],y)};n.reserve.stylesPanel&&u("stylesPanel",{side:r?"right":"left",offset:this.dependencies.getStylesPanelMode()==="compact"?gT.compact:gT.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:zf})}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}});I(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=fT(n.target,t,o);return r?ET(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});I(this,"setViewport",n=>{if(n===null){this.cancelTransition(),ot.cancel(La),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=ET(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=RF(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),ot.cancel(La),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}),NF(p,d,m,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});I(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||ot.cancel(La),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(),Nn(r,a)}),!0});I(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Nn(t,n):null)});I(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});I(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||BF(this.app.state,n=>this.app.setState(t=>n(t)))});I(this,"snapBackDebounced",yF(this.snapBack,kF));I(this,"cancelTransition",()=>{this.activeTransition=null,ot.cancel($m)});I(this,"destroy",()=>{this.cancelTransition(),ot.cancel(La),this.snapBackDebounced.cancel()})}get isAnimating(){return ot.running($m)||ot.running(La)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import qm from"react";var OF=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,FF=/{{([\w-]+)}}/,zF=/<([\w-]+)>/,HF=/<\/([\w-]+)>/,GF=(e,n)=>{let t=[{name:"",children:[]}];return e.split(OF).filter(Boolean).forEach(o=>{let r=o.match(zF),i=o.match(HF),a=o.match(FF);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=qm.createElement(qm.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},UF=({i18nKey:e,children:n,...t})=>{let{t:o}=Ae();return qm.createElement(qm.Fragment,{},...GF(o(e),t))},Qr=UF;import{jsx as un,jsxs as wT}from"react/jsx-runtime";var WF=()=>wT("div",{"data-testid":"brave-measure-text-error",children:[un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>un("span",{style:{fontWeight:600},children:e})})}),un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>un("span",{style:{fontWeight:600},children:e})})}),un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>un("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>un("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>wT("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),yT=WF;import qF from"clsx";import JF from"react";import{isDarwin as vT}from"@excalidraw/common";var VF={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:[vT?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[vT?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")]},Ke=(e,n=0)=>{let t=VF[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as YF,useRef as IT,useEffect as TT}from"react";import{unstable_batchedUpdates as XF}from"react-dom";import{KEYS as KF,queryFocusableElements as ZF}from"@excalidraw/common";import{clamp as ST}from"@excalidraw/math";import $F from"clsx";import{jsx as jF}from"react/jsx-runtime";var ar=10,CT=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=IT(null);TT(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===KF.TAB){let u=ZF(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=IT(null);return YF(()=>{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-ar*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${ar}px`,d.style.overflowX="scroll"):d.style.left=`${ST(n,ar,i-ar-m)}px`;let E=Math.max(0,a-ar*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${ar}px`,d.style.overflowY="scroll"):d.style.top=`${ST(t,ar,a-ar-p)}px`}},[t,n,r,i,a]),TT(()=>{if(o){let d=m=>{l.current?.contains(m.target)||XF(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),jF("div",{className:$F("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as wo,jsxs as kT}from"react/jsx-runtime";var rt="separator",PT=e=>"onSelect"in e,MT=JF.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=Ko(),a=Ci(),s=n.reduce((l,c)=>c?c===rt||PT(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return wo(CT,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:wo("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===rt)return!s[c-1]||s[c-1]===rt?null:wo("hr",{className:"context-menu-item-separator"},c);if(PT(l))return wo("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:kT("button",{type:"button",className:"context-menu-item",children:[wo("div",{className:"context-menu-item__label",children:l.label}),wo("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)),wo("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:kT("button",{type:"button",className:qF("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[wo("div",{className:"context-menu-item__label",children:m}),wo("kbd",{className:"context-menu-item__shortcut",children:d?Ke(d):""})]})},c)})})})});import{useId as QF}from"react";import e9 from"clsx";import{Fragment as t9,jsx as Dl,jsxs as AT}from"react/jsx-runtime";var Jm=({border:e,style:n})=>Dl("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),Qm=({label:e,border:n})=>{let t=QF(),o=AT(t9,{children:[e.icon&&Dl("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return AT("div",{className:e9("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&&Dl("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),Dl("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&Dl("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:Jt})]})};import Ya from"clsx";import vW from"react";import{CLASSES as IW,TOOL_TYPE as QP,arrayToMap as TW,isShallowEqual as _p}from"@excalidraw/common";import{mutateElement as SW}from"@excalidraw/element";import{showSelectedShapeActions as CW}from"@excalidraw/element";import{ShapeCache as PW}from"@excalidraw/element";import{createIsolation as n9}from"jotai-scope";import Hf from"react";import yo from"tunnel-rat";var Gf=Hf.createContext(null),et=()=>Hf.useContext(Gf),o9=n9(),LT=()=>Hf.useMemo(()=>({MainMenuTunnel:yo(),WelcomeScreenMenuHintTunnel:yo(),WelcomeScreenToolbarHintTunnel:yo(),WelcomeScreenHelpHintTunnel:yo(),WelcomeScreenCenterTunnel:yo(),FooterCenterTunnel:yo(),DefaultSidebarTriggerTunnel:yo(),DefaultSidebarTabTriggersTunnel:yo(),OverwriteConfirmDialogTunnel:yo(),tunnelsJotai:o9}),[]);import lr from"clsx";import{useRef as u9}from"react";import{Popover as sr}from"radix-ui";import{CLASSES as GT}from"@excalidraw/common";import{isArrowElement as HT}from"@excalidraw/element";import{forwardRef as DT}from"react";import _T from"clsx";import{jsx as RT}from"react/jsx-runtime";var r9=DT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>RT("div",{className:_T("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),i9=DT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>RT("div",{className:_T("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Dt={Row:r9,Col:i9};import{isTransparent as NT}from"@excalidraw/common";import{shouldAllowVerticalAlign as a9,suppportsHorizontalAlign as s9,hasBoundTextElement as BT,isElbowArrow as l9,isImageElement as c9,isLinearElement as d9,isTextElement as m9,hasStrokeColor as OT,toolIsArrow as p9}from"@excalidraw/element";var FT=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return OT(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>OT(o.type))},zT=(e,n)=>_o(e.activeTool.type)||n.some(t=>_o(t.type)),ep=(e,n,t,o)=>{let r=e.activeTool.type,i=d=>d(r)||n.some(m=>d(m.type)),a=n.length===1,s=n.length===2&&(BT(n[0])||BT(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:FT(e,n),backgroundColor:zT(e,n),fill:r==="bucketfill"||_o(r)&&!NT(e.currentItemBackgroundColor)||n.some(d=>_o(d.type)&&!NT(d.backgroundColor)),strokeWidth:i(Yb),freedrawMode:i(Xb),strokeStyle:i(cu),sloppiness:i(cu),roundness:i(Kb),arrowType:i(p9),arrowheads:i(ns),text:r==="text"||n.some(m9),textAlign:r==="text"||s9(n,t),verticalAlign:a9(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||ie(t,e).some(d=>d.type==="freedraw"),align:!s&&pt(e,o),distribute:n.length>2,link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&c9(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&d9(n[0])&&!l9(n[0])}};import{Fragment as hn,jsx as j,jsxs as Se}from"react/jsx-runtime";var Uf=lr([GT.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),UT=({renderAction:e})=>Se("fieldset",{children:[j("legend",{children:f("labels.layers")}),Se("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),WT=({renderAction:e,showDistribute:n})=>{let t=document.documentElement.getAttribute("dir")==="rtl";return Se("fieldset",{children:[j("legend",{children:f("labels.align")}),Se("div",{className:"buttonList",children:[t?Se(hn,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Se(hn,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),j("div",{style:{flexBasis:"100%",height:0}}),Se("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]})]})]})},VT=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=di(n,e),i=ep(e,r,n,o);return e.activeTool.type==="bucketfill"?Se("div",{className:"selected-shape-actions",children:[j("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Se("div",{className:"selected-shape-actions",children:[j("div",{children:i.strokeColor&&t("changeStrokeColor")}),i.backgroundColor&&j("div",{children:t("changeBackgroundColor")}),i.fill&&t("changeFillStyle"),i.strokeWidth&&t("changeStrokeWidth"),i.strokeStyle&&j(hn,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&j(hn,{children:t("changeSloppiness")}),i.roundness&&j(hn,{children:t("changeRoundness")}),i.arrowType&&j(hn,{children:t("changeArrowType")}),i.text&&Se(hn,{children:[j("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&j(hn,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&j(UT,{renderAction:t}),i.align&&j(WT,{renderAction:t,showDistribute:i.distribute}),i.showExtraActions&&Se("fieldset",{children:[j("legend",{children:f("labels.actions")}),Se("div",{className:"buttonList",children:[t("duplicateSelection"),t("deleteSelectedElements"),t("group"),t("ungroup"),i.link&&t("hyperlink"),i.cropEditor&&t("cropEditor"),i.lineEditor&&t("toggleLinearEditor")]})]})]})},YT=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let i=o.hasSelection||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",a=e.openPopup==="compactStrokeStyles";return i?j("div",{className:"compact-action-item",children:Se(sr.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:Z1})}),a&&j(lo,{className:Uf,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Se("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&j(hn,{children:n("changeStrokeStyle")}),o.sloppiness&&j(hn,{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 j("div",{className:"compact-action-item",children:Se(sr.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("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=lt(o,a,c=>HT(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>HT(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?Ho:l==="round"?Go:zo})()})}),s&&j(lo,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},KT=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=b0(),s=e.openPopup==="compactTextProperties";return j("div",{className:"compact-action-item",children:Se(sr.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("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:Sx})}),e.openPopup==="compactTextProperties"&&j(lo,{className:Uf,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Se("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},ZT=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let s=e.openPopup==="compactOtherProperties";return t.showExtraActions?j("div",{className:"compact-action-item",children:Se(sr.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("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&&j(lo,{className:Uf,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Se("div",{className:"selected-shape-actions",children:[t.layers&&j(UT,{renderAction:n}),t.align&&j(WT,{renderAction:n,showDistribute:t.distribute}),Se("fieldset",{children:[j("legend",{children:f("labels.actions")}),Se("div",{className:"buttonList",children:[n("group"),n("ungroup"),t.linkSingleOnly&&n("hyperlink"),t.cropEditor&&n("cropEditor"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},h9=({renderAction:e,predicates:n})=>n.lineEditor?j("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,$T=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=di(n,e),a=ep(e,i,n,o),{container:s}=De();return Se("div",{className:"compact-shape-actions",children:[a.strokeColor&&j("div",{className:lr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&j("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),a.freedrawMode&&j("div",{className:"compact-action-item",children:t("changeFreedrawMode",{cycle:!0})}),j(YT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j(XT,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),a.lineEditor&&j("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Se(hn,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(KT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),a.showExtraActions&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),j(ZT,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},jT=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=di(n,e),a=ep(e,i,n,o),{container:s}=De(),l=u9(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 Se(ze,{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:[Se("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&j("div",{className:lr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&j("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),j(YT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j(XT,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),j(h9,{renderAction:t,predicates:a}),a.text&&Se(hn,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(KT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),j(ZT,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Se("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[j("div",{className:"compact-action-item",children:t("undo")}),j("div",{className:"compact-action-item",children:t("redo")}),b&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),g&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},qT=({renderAction:e})=>j(Dt.Col,{gap:1,className:GT.ZOOM_ACTIONS,children:Se(Dt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),JT=({renderAction:e,className:n})=>Se("div",{className:`undo-redo-buttons ${n}`,children:[j("div",{className:"undo-button-container",children:j(ct,{label:f("buttons.undo"),children:e("undo")})}),j("div",{className:"redo-button-container",children:Se(ct,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),QT=({showExitZenModeBtn:e})=>j("button",{type:"button",className:lr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")}),eS=({actionManager:e})=>j("button",{type:"button",className:"disable-view-mode",onClick:()=>e.executeAction(Zr),children:j1});import g9 from"clsx";import{useState as f9,useEffect as E9}from"react";import{THEME as b9}from"@excalidraw/common";import{jsx as Wf,jsxs as x9}from"react/jsx-runtime";var tp=({delay:e,theme:n})=>{let[t,o]=f9(!!e);return E9(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:x9("div",{className:g9("LoadingMessage",{"LoadingMessage--dark":n===b9.DARK}),children:[Wf("div",{children:Wf(so,{})}),Wf("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as ip,useEffect as vS}from"react";import Z9 from"clsx";import{KEYS as Kf,capitalizeString as IS}from"@excalidraw/common";import yS from"react";import{DropdownMenu as V9}from"radix-ui";import{CLASSES as Y9}from"@excalidraw/common";import w9 from"clsx";import{useCallback as y9,useEffect as v9,useRef as I9}from"react";import{CLASSES as T9,EVENT as tS,KEYS as S9}from"@excalidraw/common";import{DropdownMenu as C9}from"radix-ui";import{jsx as np}from"react/jsx-runtime";var nS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=ge(),l=I9(null),c=Si({onClickOutside:n});Ti(l,y9(m=>{l.current?.closest(`.${T9.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),v9(()=>{if(!r)return;let m=u=>{u.key===S9.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(tS.KEYDOWN,m,p),()=>{document.removeEventListener(tS.KEYDOWN,m,p)}},[c,r]);let d=w9(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return np(mh.Provider,{value:{onSelect:o},children:np(C9.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?np(Dt.Col,{className:"dropdown-menu-container",children:e}):np(ze,{className:"dropdown-menu-container",padding:2,children:e})})})};nS.displayName="DropdownMenuContent";var oS=nS;import{jsx as k9}from"react/jsx-runtime";var P9=({children:e,className:n="",selected:t,...o})=>k9("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),rS=P9;import{DropdownMenu as M9}from"radix-ui";import{jsx as Vf}from"react/jsx-runtime";var iS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=sd(r);return Vf(M9.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Vf("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:Yo(i,a),title:l.title??l["aria-label"],children:Vf(Xo,{icon:e,shortcut:n,children:o})})})},Da=iS;iS.displayName="DropdownMenuItemLink";import{jsx as A9}from"react/jsx-runtime";var aS=()=>A9("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),sS=aS;aS.displayName="DropdownMenuSeparator";import{DropdownMenu as O9}from"radix-ui";import L9 from"clsx";import{DropdownMenu as D9}from"radix-ui";import{useCallback as _9,useState as lS}from"react";import{jsx as Xf}from"react/jsx-runtime";var Yf=-4,R9=4,cS=({children:e,className:n})=>{let t=ge(),o=L9(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=_9(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+Yf),l(Yf+8))}}},[]),[i,a]=lS(R9),[s,l]=lS(Yf);return Xf(D9.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?Xf(Dt.Col,{className:"dropdown-menu-container",children:e}):Xf(ze,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},dS=cS;cS.displayName="DropdownMenuSubContent";import{DropdownMenu as N9}from"radix-ui";import{jsx as mS,jsxs as B9}from"react/jsx-runtime";var pS=({children:e,icon:n,shortcut:t,className:o})=>B9(N9.SubTrigger,{className:`${Yo(o)} dropdown-menu__submenu-trigger`,children:[mS(Xo,{icon:n,shortcut:t,children:e}),mS("div",{className:"dropdown-menu__submenu-trigger-icon",children:J1})]}),uS=pS;pS.displayName="DropdownMenuSubTrigger";import hS from"react";var op=e=>n=>{let t=hS.Children.toArray(n).find(o=>hS.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},gS=op("DropdownMenuTrigger"),fS=op("DropdownMenuContent"),ES=op("DropdownMenuSubTrigger"),bS=op("DropdownMenuSubContent");import{jsxs as F9}from"react/jsx-runtime";var rp=({children:e})=>{let n=ES(e),t=bS(e);return F9(O9.Sub,{children:[n,t]})};rp.Trigger=uS;rp.Content=dS;rp.displayName="DropdownMenuSub";var cr=rp;import z9 from"clsx";import{DropdownMenu as H9}from"radix-ui";import{jsx as G9}from"react/jsx-runtime";var xS=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=ge(),a=z9(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return G9(H9.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},wS=xS;xS.displayName="DropdownMenuTrigger";import{jsx as W9}from"react/jsx-runtime";var U9=e=>W9(Yt,{...e,icon:e.checked?Ac:zc}),$n=U9;import{jsx as K9,jsxs as X9}from"react/jsx-runtime";var Mn=({children:e,open:n})=>{let t=gS(e),o=fS(e),r=o&&yS.isValidElement(o)?yS.cloneElement(o,{open:n}):o;return K9(V9.Root,{open:n,modal:!1,children:X9("div",{className:Y9.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Mn.Trigger=wS;Mn.Content=oS;Mn.Item=Yt;Mn.ItemCheckbox=$n;Mn.ItemLink=Da;Mn.ItemCustom=rS;Mn.Group=Ss;Mn.Separator=sS;Mn.Sub=cr;var de=Mn;Mn.displayName="DropdownMenu";import{Fragment as Zf,jsx as Le,jsxs as _a}from"react/jsx-runtime";var $9=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=f("buttons.objectsSnapMode");return Le(K,{type:"toggle",icon:Fo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(kt,"ui")})},j9=({app:e})=>Le(K,{type:"button",icon:yi,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),TS=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=ip(!1),[l,c]=ip("rectangle"),[d,m]=ip("arrow");vS(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&c(o.type)},[o.type]),vS(()=>{(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",y=["rectangle","diamond","ellipse"].map(H=>({type:H,icon:We[H].icon,title:IS(f(`toolBar.${H}`)),fillable:We[H].fillable})),w=["arrow","line"].map(H=>({type:H,icon:We[H].icon,title:IS(f(`toolBar.${H}`)),fillable:We[H].fillable})),[x,v]=ip(0),T=36,C=4,P=7,A=P*T+(P-1)*C,L=T+C,_=x>=A+1*L,k=i&&x>=A+2*L,D=x>=A+3*L,F=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(H=>!(_&&H==="text"||(!i||k)&&H==="image"||D&&H==="frame")),Y=r&&Fi.includes(o.type),z=Y||F.includes(o.type),W=z?Y?We[o.type].icon:o.type==="text"?wn:o.type==="image"?Cr:o.type==="frame"?Gn:o.type==="embeddable"?Oo:o.type==="laser"?Un:o.type==="bucketfill"?Hn:cs:cs,Z={app:e,activeTool:o,hideShortcut:!0};return _a("div",{className:"mobile-toolbar",ref:H=>{H&&v(H.getBoundingClientRect().width)},children:[Le(Ad,{...Z}),Le(Ld,{...Z,setAppState:t}),r?Le(Rs,{...Z}):Le(Dd,{...Z}),Le(Os,{...Z}),!r&&Le(Oi,{app:e,options:y,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:H=>{(H==="rectangle"||H==="diamond"||H==="ellipse")&&(c(H),e.setActiveTool({type:H}))},displayedOption:y.find(H=>H.type===l)||y[0]}),!r&&Le(Oi,{app:e,options:w,activeTool:o,defaultOption:d,"data-testid":"toolbar-arrow",onToolChange:H=>{(H==="arrow"||H==="line")&&(m(H),e.setActiveTool({type:H}))},displayedOption:w.find(H=>H.type===d)||w[0]}),_&&Le(Ns,{...Z}),r&&k&&Le(j9,{app:e}),k&&Le(Bs,{...Z}),!r&&D&&Le(_w,{...Z,hideShortcut:!0}),_a(de,{open:a,children:[Le(de.Trigger,{className:Z9("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:W}),_a(de.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&Fi.map(H=>Le(de.Item,{onSelect:()=>e.setActiveTool({type:H}),icon:We[H].icon,"data-testid":`toolbar-${H}`,selected:o.type===H,shortcut:Md(H),disabled:Ze(e,H),children:f(`toolBar.${H}`)},H)),!r&&Le("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(kt)&&Le(de.Item,{onSelect:()=>n.executeAction(kt,"ui"),icon:Fo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:Ke("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&_a(Zf,{children:[r&&Le("div",{className:"App-toolbar__dropdown-divider"}),Le(de.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?No:ao,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:Kf.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:wn,shortcut:Kf.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:Ze(e,"text"),children:f("toolBar.text")}),i&&!k&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Cr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:Ze(e,"image"),children:f("toolBar.image")}),!r&&!D&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Gn,shortcut:Kf.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:Ze(e,"frame"),children:f("toolBar.frame")}),!r&&_a(Zf,{children:[Le(de.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Oo,"data-testid":"toolbar-embeddable",selected:g,disabled:Ze(e,"embeddable"),children:f("toolBar.embeddable")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Mr,shortcut:Hi("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:Ze(e,"autoshape"),children:f("toolBar.autoshape")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Un,"data-testid":"toolbar-laser",selected:E,disabled:Ze(e,"laser"),children:f("toolBar.laser")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Hn,"data-testid":"toolbar-bucketfill",selected:b,disabled:Ze(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&_a(Zf,{children:[Le("div",{className:"App-toolbar__divider"}),Le($9,{actionManager:n,app:e})]})]})};import q9 from"clsx";import{jsx as J9}from"react/jsx-runtime";var ap=({children:e,side:n,className:t})=>J9("div",{className:q9("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import Q9 from"clsx";import{jsx as ez}from"react/jsx-runtime";var Ra=e=>e.penDetected?ez(K,{className:Q9("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Tx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as SS,jsx as xt,jsxs as dr}from"react/jsx-runtime";var CS=({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}=et(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=dr("div",{className:"excalidraw-ui-top-right",children:[i?.(!0,e)??(!e.viewModeEnabled&&dr(SS,{children:[l&&xt(Ra,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),xt(E.Out,{})]})),l&&e.viewModeEnabled&&d.isInteractionEnabled()&&xt(eS,{actionManager:t})]}),A=dr("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),xt(u.Out,{})]});return dr("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[A,P]})},b=()=>xt(TS,{app:d,actionManager:t,setAppState:o}),y=c&&e.scrolledOutside,w=l,x=l&&(!e.viewModeEnabled||w),v=y&&!e.openMenu&&!e.openSidebar?xt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...ci(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?xt(Qm,{label:T,border:d.props.viewportStatusFrame?.border}):null;return dr(SS,{children:[a(),xt("div",{className:"App-welcome-screen",children:s&&xt(p.Out,{})}),x&&dr("div",{className:"App-bottom-bar",style:{marginBottom:cn+bo},"data-viewport-ui":"bottom",children:[v&&xt("div",{className:"floating-status-stack",children:v}),dr("div",{className:"App-bottom-bar__actions-row",children:[w&&dr(ze,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&xt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),xt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&xt(jT,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&xt(ze,{className:"App-toolbar",children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&v&&xt("div",{className:"floating-status-stack",children:v}),C&&xt("div",{className:"viewport-status-frame__badge-row",children:C}),xt(ap,{side:"top",className:"App-top-bar",children:g()})]})};import _S,{useLayoutEffect as RS,useRef as NS,useState as BS}from"react";import{newTextElement as OS}from"@excalidraw/element";import sz from"clsx";import{useEffect as lz,useState as cz}from"react";import{KEYS as dz,queryFocusableElements as LS}from"@excalidraw/common";import{useCallback as tz,useState as nz}from"react";var PS=()=>{let[e,n]=nz(null),t=tz(o=>n(o),[]);return[e,t]};import kS from"clsx";import{useRef as oz}from"react";import{createPortal as rz}from"react-dom";import{KEYS as iz}from"@excalidraw/common";import{jsx as MS,jsxs as az}from"react/jsx-runtime";var AS=e=>{let{closeOnClickOutside:n=!0}=e,t=jc({className:kS("excalidraw-modal-container",e.portalContainerClassName)}),o=oz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===iz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return rz(az("div",{className:kS("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[MS("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),MS("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as sp,jsxs as DS}from"react/jsx-runtime";function mz(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var gn=e=>{let[n,t]=PS(),[o]=cz(document.activeElement),{id:r}=De(),i=ge().formFactor==="phone";lz(()=>{if(!n)return;let l=LS(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===dz.TAB){let m=LS(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&d.shiftKey?(m[m.length-1].focus(),d.preventDefault()):u===m.length-1&&!d.shiftKey&&(m[0].focus(),d.preventDefault())}};return n.addEventListener("keydown",c),()=>n.removeEventListener("keydown",c)},[n,e.autofocus]);let a=Ue(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return sp(AS,{className:sz("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:mz(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:DS(ze,{ref:t,children:[e.title&&DS("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[sp("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&sp("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:Jt}),sp("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as vo,jsxs as lp}from"react/jsx-runtime";var pz=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=NS(null),[t,o]=BS(null),{theme:r}=fe();RS(()=>{if(!e.spreadsheet){o(null);return}let a=Ef(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 Tr(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=pz(e.chartType);return lp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[vo("div",{className:"ChartPreview__canvas",ref:n}),vo("div",{className:"ChartPreview__label",children:i})]})},hz=e=>{let n=NS(null),{theme:t}=fe();return RS(()=>{if(!e.rawText)return;let o=OS({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Tr([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]),lp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[vo("div",{className:"ChartPreview__canvas",ref:n}),vo("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},FS=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=It(),[i,a]=BS(Math.random()),s=_S.useCallback(()=>{a(Math.random())},[]),l=_S.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),Ne("paste","chart",m),t(),r()},d=m=>{let p=OS({text:m,x:0,y:0});o([p]),Ne("paste","chart","plaintext"),t(),r()};return vo(gn,{size:"regular",onCloseRequest:l,title:lp("div",{className:"PasteChartDialog__title",children:[vo("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),vo("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:Hn})]}),className:"PasteChartDialog",autofocus:!1,children:lp("div",{className:"container",children:[["bar","line","radar"].map(m=>Ea(e,m)?vo(uz,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&vo(hz,{rawText:n,onClick:d})]})})};import{Fragment as gz,jsx as zS,jsxs as fz}from"react/jsx-runtime";var _l=({heading:e,children:n,...t})=>{let{id:o}=De(),r=zS("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return zS("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):fz(gz,{children:[r,n]})})};import{Popover as Rl}from"radix-ui";import HS from"clsx";import cp,{useLayoutEffect as Ez}from"react";import{supportsResizeObserver as bz,isShallowEqual as xz}from"@excalidraw/common";import{Fragment as qf,jsx as wt,jsxs as Na}from"react/jsx-runtime";var wz=4,yz=8,$f=38,GS=21,vz=({shouldWrap:e,children:n,username:t})=>e?wt(ct,{label:t||"Unknown user",children:n}):wt(qf,{children:n}),jf=({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 wt(vz,{username:n.username,shouldWrap:r,children:s},t)},Iz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],dp=cp.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=tt(),a=typeof r=="function"?r(!!n):r,s=Array.from(t,([C,P])=>({...P,socketId:C})).filter(C=>C.username?.trim()),l=s.find(C=>C.isCurrentUser),c=s.filter(C=>!C.isCurrentUser),[d,m]=cp.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=cp.useRef(null);Ez(()=>{if(u.current){let C=A=>{g(A)};if(C(u.current.clientWidth),!bz)return;let P=new ResizeObserver(A=>{for(let L of A){let{width:_}=L.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=cp.useState(wz*$f),b=l?E-GS:E,y=Math.max(1,Math.min(8,Math.floor(b/$f))),w=l?Math.max(0,y-1):y,x=c.slice(0,w),v=l?[...x,l]:x,T=v.map(C=>{let P=jf({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?Na(Rl.Root,{children:[wt(Rl.Trigger,{asChild:!0,children:Na("div",{className:"UserList__pill",children:[P,wt("div",{className:"UserList__pill-chevron",children:q1})]})}),wt(Rl.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Na(ze,{padding:2,children:[s.length>=yz&&wt(id,{placeholder:f("quickSearch.placeholder"),onChange:m}),wt(ad,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[wt("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(A=>jf({actionManager:i,collaborator:A,socketId:A.socketId,withName:!0,isBeingFollowed:A.socketId===o}))]:[]}),a&&Na(qf,{children:[wt("div",{className:"UserList__menu-divider"}),wt(Rl.Close,{asChild:!0,children:wt("div",{className:"dropdown-menu",children:a})})]}),wt(Rl.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?Na("div",{className:HS("UserList UserList_mobile",e),children:[wt("div",{className:"UserList_mobile__avatars",children:s.map(C=>jf({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&Na(qf,{children:[wt("div",{className:"UserList__menu-divider"}),a]})]}):wt("div",{className:"UserList__wrapper",ref:u,children:wt("div",{className:HS("UserList",e),style:{"--max-avatars":v.length+(l?GS/$f: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||!xz(r,i,Iz))return!1}return!0});import Nl from"clsx";import{jsx as US}from"react/jsx-runtime";var WS=e=>US(ct,{label:`${f("helpDialog.title")} \u2014 ?`,children:US("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:wi})});import{jsx as Kt,jsxs as Jf}from"react/jsx-runtime";var VS=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=et(),l=It();return Jf("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&Kt("div",{className:Nl("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Kt(Dt.Col,{gap:2,children:Jf(_l,{heading:"canvasActions",children:[!e.viewModeOnly&&Kt(ct,{label:f("labels.viewMode"),children:Kt("div",{className:Nl("view-mode-button"),children:n.renderAction("viewMode")})}),Kt(ct,{label:f("buttons.smartZoom"),children:Kt("div",{className:Nl("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&Kt(qT,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&Kt(JT,{renderAction:n.renderAction,className:Nl("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Kt(a.Out,{}),(r||o)&&Kt("div",{className:Nl("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Jf("div",{style:{position:"relative"},children:[o&&Kt(s.Out,{}),r&&Kt(WS,{onClick:()=>n.executeAction(Hr)})]})}),r&&Kt(QT,{showExitZenModeBtn:t})]})},YS=VS;VS.displayName="Footer";import{composeEventHandlers as Lz}from"@excalidraw/common";import{useLayoutEffect as Tz,useRef as Sz}from"react";import{jsx as Cz}from"react/jsx-runtime";var ei=(e,n)=>{let t=je(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=et(),[,a]=i(t),s=Sz({preferHost:!1,counter:0});return Tz(()=>{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:Cz(n,{...r})};return o.displayName=e,o};var nE={};$M(nE,{ChangeCanvasBackground:()=>nC,Export:()=>oC,Help:()=>eC,LiveCollaborationTrigger:()=>iC,LoadScene:()=>jS,Preferences:()=>jn,PreferencesToggleGridModeItem:()=>tE,SaveAsImage:()=>JS,SaveToActiveFile:()=>qS,SearchMenu:()=>QS,Socials:()=>rC,ToggleTheme:()=>tC});import Az from"clsx";import{THEME as Ol}from"@excalidraw/common";var Qf=je({active:!1});async function XS({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{gt.set(Qf,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import Pz from"clsx";import{jsx as KS,jsxs as kz}from"react/jsx-runtime";var mp=function({onChange:e,value:n,choices:t,name:o}){return KS("div",{className:"RadioGroup",children:t.map(r=>kz("div",{className:Pz("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[KS("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 Mz,jsx as Bl,jsxs as ZS}from"react/jsx-runtime";var $S=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=ge();return ZS(Mz,{children:[ZS("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&Bl("div",{className:"dropdown-menu-item__icon",children:a}),Bl("label",{className:"dropdown-menu-item__text",children:Bl(Cs,{children:r})}),Bl(mp,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&Bl("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};$S.displayName="DropdownMenuItemContentRadio";var eE=$S;import{Fragment as uC,jsx as Ee,jsxs as Fl}from"react/jsx-runtime";var jS=()=>{let{t:e}=Ae(),n=tt(),t=Ci();return n.isActionEnabled(Ui)?Ee(Yt,{icon:Lc,onSelect:async()=>{(!t.length||await XS({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:Ee(Qr,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>Ee("strong",{children:r}),br:()=>Ee("br",{})})}))&&n.executeAction(Ui)},"data-testid":"load-button",shortcut:Ke("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};jS.displayName="LoadScene";var qS=()=>{let{t:e}=Ae(),n=tt();return n.isActionEnabled(zr)?Ee(Yt,{shortcut:Ke("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(zr),icon:Dx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};qS.displayName="SaveToActiveFile";var JS=()=>{let e=Ue(),{t:n}=Ae();return Ee(Yt,{icon:Nx,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Ke("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};JS.displayName="SaveAsImage";var QS=e=>{let{t:n}=Ae(),t=tt();return Ee(Yt,{icon:Wn,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(pl)},shortcut:Ke("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};QS.displayName="SearchMenu";var eC=()=>{let{t:e}=Ae(),n=tt();return Ee(Yt,{"data-testid":"help-menu-item",icon:wi,onSelect:()=>n.executeAction(Hr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};eC.displayName="Help";var tC=e=>{let{t:n}=Ae(),t=fe(),o=tt(),r=Ke("toggleTheme"),i=yn();return o.isActionEnabled(Sd)?e?.allowSystemTheme?Ee(eE,{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:Ol.LIGHT,label:ps,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:Ol.DARK,label:ms,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:W1,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):Ee(Yt,{onSelect:a=>{a.preventDefault(),o.executeAction(Sd)},icon:t.theme===Ol.DARK?ps:ms,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Ol.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===Ol.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};tC.displayName="ToggleTheme";var nC=()=>{let{t:e}=Ae(),n=fe(),t=tt(),o=yn();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:Fl("div",{style:{marginTop:"0.75rem"},children:[Ee("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),Ee("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};nC.displayName="ChangeCanvasBackground";var oC=()=>{let{t:e}=Ae(),n=Ue();return Ee(Yt,{icon:us,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};oC.displayName="Export";var rC=()=>{let{t:e}=Ae();return Fl(uC,{children:[Ee(Da,{icon:Mx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),Ee(Da,{icon:Lx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),Ee(Da,{icon:Ax,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};rC.displayName="Socials";var iC=({onSelect:e,isCollaborating:n})=>{let{t}=Ae();return Ee(Yt,{"data-testid":"collab-button",icon:Dc,className:Az({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};iC.displayName="LiveCollaborationTrigger";var aC=()=>{let{t:e}=Ae(),n=It(),t=fe();return Ee($n,{checked:t.activeTool.locked,shortcut:Ke("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},sC=()=>{let{t:e}=Ae(),n=fe(),t=Ue();return Ee(eE,{name:"boxSelectionMode",icon:zc,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")})},lC=()=>{let{t:e}=Ae(),n=tt(),t=fe();return Ee($n,{checked:t.objectsSnapModeEnabled,shortcut:Ke("objectsSnapMode"),onSelect:o=>{n.executeAction(kt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},cC=()=>{let{t:e}=Ae(),n=tt(),t=fe();return Ee($n,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(Xs),o.preventDefault()},children:e("labels.arrowBinding")})},dC=()=>{let{t:e}=Ae(),n=tt(),t=fe();return Ee($n,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(Ks),o.preventDefault()},children:e("labels.midpointSnapping")})},tE=()=>{let{t:e}=Ae(),n=tt(),t=fe();return Ee($n,{checked:t.gridModeEnabled,shortcut:Ke("gridMode"),onSelect:o=>{n.executeAction(ji),o.preventDefault()},children:e("labels.toggleGrid")})},mC=()=>{let{t:e}=Ae(),n=tt(),t=fe();return t.viewModeOnly?null:Ee($n,{checked:t.viewModeEnabled,shortcut:Ke("viewMode"),onSelect:o=>{n.executeAction(Zr),o.preventDefault()},children:e("labels.viewMode")})},pC=()=>{let{t:e}=Ae(),n=tt(),t=fe();return Ee($n,{checked:t.stats.open,shortcut:Ke("stats"),onSelect:o=>{n.executeAction(er),o.preventDefault()},children:e("stats.fullTitle")})},jn=({children:e,additionalItems:n})=>{let{t}=Ae();return Fl(cr,{children:[Ee(cr.Trigger,{icon:Q1,children:t("labels.preferences")}),Fl(cr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Fl(uC,{children:[Ee(sC,{}),Ee(aC,{}),Ee(lC,{}),Ee(tE,{}),Ee(mC,{}),Ee(pC,{}),Ee(cC,{}),Ee(dC,{})]}),n]})]})};jn.ToggleToolLock=aC;jn.BoxSelectionMode=sC;jn.ToggleSnapMode=lC;jn.ToggleArrowBinding=cC;jn.ToggleMidpointSnapping=dC;jn.ToggleGridMode=tE;jn.ToggleViewMode=mC;jn.ToggleElementProperties=pC;jn.displayName="Preferences";import{jsx as pp,jsxs as oE}from"react/jsx-runtime";var Dz=Object.assign(ei("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=et(),o=ge(),r=fe(),i=yn(),a=Ue();return pp(t.In,{children:oE(de,{open:r.openMenu==="canvas",children:[pp(de.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Px}),oE(de.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:Lz(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&oE("fieldset",{className:"UserList-Wrapper",children:[pp("legend",{children:f("labels.collaborators")}),pp(dp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:de.Trigger,Item:de.Item,ItemLink:de.ItemLink,ItemCustom:de.ItemCustom,Group:de.Group,Separator:de.Separator,Sub:cr,DefaultItems:nE}),_t=Dz;import _z from"clsx";import{forwardRef as Rz,useState as Nz}from"react";import{isPromiseLike as Bz}from"@excalidraw/common";import{jsx as up,jsxs as Oz}from"react/jsx-runtime";var mr=Rz(({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]=Nz(!1),E=async b=>{let y=t?.(b);if(Bz(y)){let w=window.setTimeout(()=>{u(!0)},50);try{await y}catch(x){if(x instanceof gc)console.warn(x);else throw x}finally{clearTimeout(w),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,up("button",{className:_z("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:Oz("div",{className:"ExcButton__contents",children:[g==="loading"?up(so,{className:"ExcButton__statusIcon"}):g==="success"&&up("div",{className:"ExcButton__statusIcon",children:D1}),n&&up("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as Ba,jsxs as Hz}from"react/jsx-runtime";var hp=({title:e,children:n,actionLabel:t,onClick:o})=>Hz("div",{className:"OverwriteConfirm__Actions__Action",children:[Ba("h4",{children:e}),Ba("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),Ba(mr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),Fz=()=>{let{t:e}=Ae(),n=tt(),t=Ue();return Ba(hp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(Wd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},zz=()=>{let{t:e}=Ae(),n=tt();return Ba(hp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(Ws,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},rE=Object.assign(({children:e})=>Ba("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:Fz,SaveToDisk:zz});import{jsx as pr,jsxs as hC}from"react/jsx-runtime";var gp=Object.assign(ei("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=et(),[t,o]=Fe(Qf);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return pr(n.In,{children:pr(gn,{onCloseRequest:r,title:!1,size:916,children:hC("div",{className:"OverwriteConfirm",children:[pr("h3",{children:t.title}),hC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[pr("div",{className:"OverwriteConfirm__Description__icon",children:_1}),pr("div",{children:t.description}),pr("div",{className:"OverwriteConfirm__Description__spacer"}),pr(mr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),pr(rE,{children:e})]})})})}),{Actions:rE,Action:hp});import{round as rP}from"@excalidraw/math";import rG from"clsx";import iG from"lodash.throttle";import{useEffect as iP,useMemo as bE,useState as aG,memo as sG}from"react";import{STATS_PANELS as Tp}from"@excalidraw/common";import{getCommonBounds as lG}from"@excalidraw/element";import{getUncroppedWidthAndHeight as cG}from"@excalidraw/element";import{isImageElement as xE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as dG}from"@excalidraw/element";import{elementsAreInSameGroup as mG}from"@excalidraw/element";import{degreesToRadians as vC,radiansToDegrees as CC}from"@excalidraw/math";import{getBoundTextElement as IC}from"@excalidraw/element";import{isArrowElement as TC,isElbowArrow as eH}from"@excalidraw/element";import{updateBindings as SC}from"@excalidraw/element";import Zz from"clsx";import{useEffect as wC,useRef as Ep,useState as $z}from"react";import{EVENT as za,KEYS as jz,cloneJSON as iE}from"@excalidraw/common";import{deepCopyElement as qz}from"@excalidraw/element";import{CaptureUpdateAction as yC}from"@excalidraw/element";import{pointFrom as ur,pointRotateRads as fp}from"@excalidraw/math";import{getBoundTextElement as Gz,getNonDeletedElements as Uz,isBindingElement as Wz,unbindBindingElement as gC}from"@excalidraw/element";import{isFrameLikeElement as bC}from"@excalidraw/element";import{getSelectedGroupIds as Vz,getElementsInGroup as Yz,isInGroup as Xz}from"@excalidraw/element";import{getFrameChildren as Kz}from"@excalidraw/element";import{updateBindings as fC}from"@excalidraw/element";import{DRAGGING_THRESHOLD as EC}from"@excalidraw/common";var xC=.01,zl=10,zt=(e,n)=>!(n==="angle"&&bC(e)),He=(e,n)=>{let t=e+n/2;return t-t%n},Oa=(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 ti=(e,n,t,o,r,i,a=!0)=>{if(Wz(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<EC&&Math.abs(n-t.y)<EC)return;gC(t,"start",o),gC(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]=fp(ur(t.x,t.y),ur(c,d),t.angle),u=e-m,E=n-p,[g,b]=fp(ur(e,n),ur(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),fC(l,o,r);let y=Gz(t,i);if(y){let w=s.get(y.id);w&&o.mutateElement(w,{x:y.x+u,y:y.y+E},{informMutation:a,isDragging:!1})}if(bC(t)){let w=Kz(i,t.id);w.forEach(x=>{let v=s.get(x.id);if(!v)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,A]=fp(ur(x.x,x.y),ur(T,C),x.angle),L=Math.round(P+u),_=Math.round(A+E),[k,D]=fp(ur(L,_),ur(T+u,C+E),-x.angle);o.mutateElement(v,{x:k,y:D},{informMutation:a,isDragging:!1}),fC(v,o,r,{simultaneouslyUpdated:Uz(w)})})}},Fa=(e,n)=>{let o=Vz(n).map(r=>Yz(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!Xz(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as aE,jsxs as Qz}from"react/jsx-runtime";var Jz=({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=It(),u=Ue(),E=Ep(null),g=Ep(null),[b,y]=$z(o.toString()),w=Ep(null);w.current||(w.current={originalAppState:iE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),wC(()=>{let T=o.toString();y(T),w.current.lastUpdatedValue=T},[o]);let x=(T,C,P)=>{if(!w.current.updatePending)return!1;w.current.updatePending=!1;let A=Number(T);if(isNaN(A)){y(o.toString());return}let L=Number(A.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(L-_)>=xC)&&(w.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:L,property:s,originalAppState:P,setInputValue:k=>y(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:yC.IMMEDIATELY}))},v=Ep({});return v.current.handleInputValue=x,wC(()=>{let T=E.current,C=v.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,w.current.originalElements,w.current.originalAppState),window.removeEventListener(za.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(za.POINTER_UP,C.onPointerUp,!1)}},[i]),i?Qz("div",{className:Zz("drag-input-container",!i&&"disabled"),"data-testid":e,children:[aE("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,A=p.scene.getNonDeletedElements().reduce((z,W)=>(z.set(W.id,qz(W)),z),new Map),L=r.map(z=>A.get(z.id)),_=iE(c),k=0,D=0,F=z=>{if(P&&A!==null&&L!==null){let W=z.clientX-P.x;W!==0&&(D+=W,Math.abs(D)>=d&&(D=Math.sign(D)*Math.floor(Math.abs(D)/d),k+=D,t({accumulatedChange:k,instantChange:D,originalElements:L,originalElementsMap:A,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:Z=>y(String(Z)),app:p,setAppState:u}),D=0))}P={x:z.clientX,y:z.clientY}},Y=()=>{window.removeEventListener(za.POINTER_MOVE,F,!1),p.syncActionResult({captureUpdate:yC.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:L,originalAppState:_}),P=null,k=0,D=0,L=null,A=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(za.POINTER_UP,Y,!1)};v.current.onPointerMove=F,v.current.onPointerUp=Y,window.addEventListener(za.POINTER_MOVE,F,!1),window.addEventListener(za.POINTER_UP,Y,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?aE(dd,{icon:n}):e}),aE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===jz.ENTER&&(x(C.value,r,c),p.focusContainer())}},ref:E,value:b,onChange:T=>{w.current.updatePending=!0,y(T.target.value)},onFocus:T=>{T.target.select(),w.current.originalElements=r,w.current.originalAppState=iE(c)},onBlur:T=>{b?i&&x(T.target.value,w.current.originalElements,w.current.originalAppState):y(o.toString())},disabled:!i})]}):null},ut=Jz;import{jsx as rH}from"react/jsx-runtime";var tH=15,nH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!eH(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=vC(o);r.mutateElement(l,{angle:E}),SC(l,r,i.state);let g=IC(l,a);g&&!TC(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(CC(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=He(m,tH)),m=m<0?m+360:m;let p=vC(m);r.mutateElement(l,{angle:p}),SC(l,r,i.state);let u=IC(l,a);u&&!TC(l)&&r.mutateElement(u,{angle:p})}},oH=({element:e,scene:n,appState:t,property:o})=>rH(ut,{label:"A",icon:Rc,value:Math.round(CC(e.angle)%360*100)/100,elements:[e],dragInputCallback:nH,editable:zt(e,"angle"),scene:n,appState:t,property:o}),PC=oH;import{jsx as aH}from"react/jsx-runtime";var kC=5,iH=({property:e,scene:n,appState:t,setAppState:o})=>aH(ut,{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?He(l.gridStep+kC*Math.sign(i),kC):l.gridStep+i),c?(c=Wb(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),MC=iH;import{clamp as bp,round as sE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as xp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as AC,getNonDeletedElements as sH,getUncroppedWidthAndHeight as _C}from"@excalidraw/element";import{resizeSingleElement as LC}from"@excalidraw/element";import{isImageElement as RC}from"@excalidraw/element";import{isFrameLikeElement as lE}from"@excalidraw/element";import{getElementsInResizingFrame as cE}from"@excalidraw/element";import{replaceAllElementsInFrame as NC}from"@excalidraw/element";import{jsx as pH}from"react/jsx-runtime";var DC=10,lH=e=>e.type==="image",cH=({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||lH(u),b=u.width/u.height;if(s.croppingElementId===u.id){let y=p.get(u.id);if(!y||!RC(y)||!y.crop)return;let w=y.crop,x={...w},v=y.scale[0]===-1,T=y.scale[1]===-1,{width:C,height:P}=_C(y),A=w.naturalWidth/C,L=w.naturalHeight/P,_=v?w.width+w.x:w.naturalWidth-w.x,k=T?w.height+w.y:w.naturalHeight-w.y,D=AC*A,F=AC*L;if(i!==void 0){if(a==="width"){let H=i*A,re=bp(H,D,_);x={...x,width:re,x:v?w.x+w.width-re:w.x}}else if(a==="height"){let H=i*L,re=bp(H,F,k);x={...x,height:re,y:T?w.y+w.height-re:w.y}}c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}let Y=a==="width"?l:0,z=a==="height"?l:0,W=bp(w.width+Y,D,_),Z=bp(w.height+z,D,k);x={...w,x:v?w.x+w.width-W:w.x,y:T?w.y+w.height-Z:w.y,width:W,height:Z},c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}if(i!==void 0){let y=Math.max(a==="width"?i:g?i*b:u.width,xp),w=Math.max(a==="height"?i:g?i/b:u.height,xp);if(LC(y,w,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),lE(E)){let x=cE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),v=NC(c.getElementsIncludingDeleted(),x,E);c.replaceAllElements(v)}return}{let y=a==="width"?e:0,w=a==="height"?e:0,x=Math.max(0,u.width+y);a==="width"&&(r?x=He(x,DC):x=Math.round(x));let v=Math.max(0,u.height+w);if(a==="height"&&(r?v=He(v,DC):v=Math.round(v)),g&&(a==="width"?v=Math.round(x/b*100)/100:x=Math.round(v*b*100)/100),v=Math.max(xp,v),x=Math.max(xp,x),LC(x,v,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),lE(E)){let T=sH(cE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},dH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&lE(a)){let s=cE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=NC(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},mH=({property:e,element:n,scene:t,appState:o})=>{let r=sE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&RC(n)&&n.crop){let{width:i,height:a}=_C(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=sE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=sE(n.crop.height*s,2)}}return pH(ut,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:cH,value:r,editable:zt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:dH})},dE=mH;import{getBoundTextElement as uH,redrawTextBoundingBox as hH}from"@excalidraw/element";import{hasBoundTextElement as gH,isTextElement as OC}from"@excalidraw/element";import{jsx as xH}from"react/jsx-runtime";var BC=4,fH=4,EH=({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||!OC(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),BC);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,BC),t&&(l=He(l,fH))}l&&(r.mutateElement(s,{fontSize:l}),hH(s,r.getContainerElement(s),r))}},bH=({element:e,scene:n,appState:t,property:o})=>{let r=OC(e)?e:gH(e)?uH(e,n.getNonDeletedElementsMap()):null;return r?xH(ut,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:EH,icon:kr,appState:t,scene:n,property:o}):null},FC=bH;import{degreesToRadians as zC,radiansToDegrees as UC}from"@excalidraw/math";import{getBoundTextElement as HC}from"@excalidraw/element";import{isArrowElement as GC}from"@excalidraw/element";import{isInGroup as mE}from"@excalidraw/element";import{jsx as IH}from"react/jsx-runtime";var wH=15,yH=({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&&!mE(c)&&zt(c,r)),l=n.filter(c=>!mE(c)&&zt(c,r));if(o!==void 0){let c=zC(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=HC(d,a);m&&!GC(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(UC(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=He(E,wH)),E=E<0?E+360:E;let g=zC(E);i.mutateElement(d,{angle:g});let b=HC(d,a);b&&!GC(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},vH=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!mE(l)&&zt(l,"angle")),i=r.map(l=>Math.round(UC(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>zt(l,"angle"));return IH(ut,{label:"A",icon:Rc,value:a,elements:e,dragInputCallback:yH,editable:s,appState:t,scene:n,property:o})},WC=vH;import{pointFrom as KC}from"@excalidraw/math";import{useMemo as SH}from"react";import{MIN_WIDTH_OR_HEIGHT as hr}from"@excalidraw/common";import{getElementsInResizingFrame as pE,getNonDeletedElements as CH,isFrameLikeElement as uE,replaceAllElementsInFrame as jC,updateBoundElements as PH}from"@excalidraw/element";import{rescalePointsInElement as kH,resizeSingleElement as ZC}from"@excalidraw/element";import{getBoundTextElement as MH,handleBindTextResize as AH}from"@excalidraw/element";import{isTextElement as qC}from"@excalidraw/element";import{MIME_TYPES as ni}from"@excalidraw/common";import{getNonDeletedElements as VC}from"@excalidraw/element";var wp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=VC(Sr(e,null,{deleteInvisibleElements:!0})),l=pi(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return wc(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}})},YC=async e=>{let{mimeType:n=ni.png,quality:t}=e;n===ni.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ni.png}" mimeType`),n==="image/jpg"&&(n=ni.jpg),n===ni.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ni.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await wp(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===ni.png&&e.appState?.exportEmbedScene&&(a=await ex({blob:a,metadata:rs(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},XC=async({elements:e,appState:n=Ro(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=VC(Sr(e,null,{deleteInvisibleElements:!0})),d={...pi(n,null),exportPadding:o};return Tr(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},TH=async e=>{if(e.type==="svg"){let n=await XC(e);await uo(n.outerHTML)}else if(e.type==="png")await Gd(YC(e));else if(e.type==="json")await zd(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as u8e}from"@excalidraw/element";import{getCommonBounds as yp}from"@excalidraw/element";import{jsx as BH}from"react/jsx-runtime";var Ha=10,LH=(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,...kH(o,a,s,!1),...qC(o)?{fontSize:o.fontSize*t}:{}}},DH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=LH(e,n,o,i);s.mutateElement(r,c);let d=MH(i,a);if(d){let m=d.fontSize*o;PH(r,s);let p=l.get(d.id);p&&qC(p)&&(s.mutateElement(p,{fontSize:m}),AH(r,s,t==="width"?"e":"s",!0))}},$C=(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];DH(r[0],r[1],i,d,u,p,l,c)}},_H=({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=Fa(n,o);if(i!==void 0){for(let g of m){let b=Oa(g,d,t);if(b.length>1){let y=b.map(D=>D.latest),w=b.map(D=>D.original),[x,v,T,C]=yp(w),P=T-x,A=C-v,L=P/A,_=Math.max(hr,s==="width"?Math.max(0,i):P),k=Math.max(hr,s==="height"?Math.max(0,i):A);$C(_,k,A,L,KC(x,v),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&zt(w,s)){let v=s==="width"?Math.max(0,i):w.width;s==="width"&&(r?v=He(v,Ha):v=Math.round(v));let T=s==="height"?Math.max(0,i):w.height;if(s==="height"&&(r?T=He(T,Ha):T=Math.round(T)),v=Math.max(hr,v),T=Math.max(hr,T),ZC(v,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),uE(w)){let C=pE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()),P=jC(a.getElementsIncludingDeleted(),C,w);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=Oa(g,d,t);if(b.length>1){let y=b.map(D=>D.latest),w=b.map(D=>D.original),[x,v,T,C]=yp(w),P=T-x,A=C-v,L=P/A,_=Math.max(0,P+p);s==="width"&&(r?_=He(_,Ha):_=Math.round(_));let k=Math.max(0,A+u);s==="height"&&(r?k=He(k,Ha):k=Math.round(k)),_=Math.max(hr,_),k=Math.max(hr,k),$C(_,k,A,L,KC(x,v),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&zt(w,s)){let v=Math.max(0,x.width+p);s==="width"&&(r?v=He(v,Ha):v=Math.round(v));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=He(T,Ha):T=Math.round(T)),v=Math.max(hr,v),T=Math.max(hr,T),ZC(v,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),uE(w)){let C=CH(pE(a.getElementsIncludingDeleted(),w,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&&uE(a)){let s=pE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=jC(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},NH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=SH(()=>o.map(c=>{let d=Oa(c,t);if(d.length>1){let[p,u,E,g]=yp(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 BH(ut,{label:e==="width"?"W":"H",elements:n,dragInputCallback:_H,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:RH})},hE=NH;import{getBoundTextElement as OH,redrawTextBoundingBox as JC}from"@excalidraw/element";import{hasBoundTextElement as FH,isTextElement as zH}from"@excalidraw/element";import{isInGroup as HH}from"@excalidraw/element";import{jsx as YH}from"react/jsx-runtime";var QC=4,GH=4,UH=(e,n)=>e.reduce((t,o)=>{if(!o||HH(o))return t;if(zH(o))return t.push(o),t;if(FH(o)){let r=OH(o,n);if(r)return t.push(r),t}return t},[]),WH=({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),QC);for(let l of a)r.mutateElement(l,{fontSize:s}),JC(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,QC);t&&(E=He(E,GH)),r.mutateElement(d,{fontSize:E}),JC(d,r.getContainerElement(d),r)}r.triggerUpdate()}},VH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=UH(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 YH(ut,{label:"F",icon:kr,elements:i,dragInputCallback:WH,value:s,editable:l,scene:n,property:o,appState:t})},eP=VH;import{pointFrom as gr,pointRotateRads as vp}from"@excalidraw/math";import{useMemo as XH}from"react";import{isTextElement as KH}from"@excalidraw/element";import{getCommonBounds as gE}from"@excalidraw/element";import{jsx as JH}from"react/jsx-runtime";var ZH=(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]=vp(gr(l.x,l.y),gr(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;ti(u,E,l,i,a,r,!1)}},$H=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=gE(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&&(!KH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,y]=vp(gr(u.x,u.y),gr(E,g),u.angle);ti(b+c,y+d,p,r,i,o,!1)}}},jH=({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 Fa(n,s)){let E=Oa(u,c,t);if(E.length>1){let[g,b,,]=gE(E.map(x=>x.latest));$H(i==="x"?r:g,i==="y"?r:b,E.map(x=>x.original),t,a,l.state)}else{let g=E[0]?.original,b=E[0]?.latest;if(g&&b&&zt(b,i)){let[y,w]=[g.x+g.width/2,g.y+g.height/2],[x,v]=vp(gr(g.x,g.y),gr(y,w),g.angle);ti(i==="x"?r:x,i==="y"?r:v,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?He(e,zl):e;ZH(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},qH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=XH(()=>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]=gE(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]=vp(gr(d.x,d.y),gr(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 JH(ut,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:jH,value:s,property:e,scene:r,appState:i})},fE=qH;import{clamp as Hl,pointFrom as Ip,pointRotateRads as nP,round as tP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as QH,getUncroppedWidthAndHeight as eG}from"@excalidraw/element";import{isImageElement as oP}from"@excalidraw/element";import{jsx as oG}from"react/jsx-runtime";var tG=({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]=nP(Ip(m.x,m.y),Ip(p,u),m.angle);if(l.croppingElementId===m.id){let v=d.get(m.id);if(!v||!oP(v)||!v.crop)return;let T=v.crop,C=T,P=v.scale[0]===-1,A=v.scale[1]===-1,{width:L,height:_}=eG(v);if(i!==void 0){if(a==="x"){let F=i*(T.naturalWidth/L);P?C={...T,x:Hl(T.naturalWidth-F-T.width,0,T.naturalWidth-T.width)}:C={...T,x:Hl(i*(T.naturalWidth/L),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:Hl(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),s.mutateElement(v,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),D=(a==="y"?n:0)*(A?-1:1);C={...T,x:Hl(T.x+k,0,T.naturalWidth-T.width),y:Hl(T.y+D,0,T.naturalHeight-T.height)},s.mutateElement(v,{crop:C});return}if(i!==void 0){ti(a==="x"?i:E,a==="y"?i:g,m,s,c.state,o);return}let b=a==="x"?e:0,y=a==="y"?e:0,w=a==="x"?Math.round(r?He(m.x+b,zl):E+b):E,x=a==="y"?Math.round(r?He(m.y+y,zl):g+y):g;ti(w,x,m,s,c.state,o)},nG=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=nP(Ip(n.x,n.y),Ip(n.x+n.width/2,n.y+n.height/2),n.angle),a=tP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&oP(n)&&n.crop){let s=QH(n);s&&(a=tP(e==="x"?s.x:s.y,2))}return oG(ut,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:tG,scene:t,value:a,property:e,appState:o})},EE=nG;import{Fragment as wE,jsx as te,jsxs as Ht}from"react/jsx-runtime";var pG=50,Gl=e=>{let n=Ko(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=or(e.app);return te(uG,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Be=({children:e,columns:n=1,heading:t,style:o,...r})=>te("div",{className:rG("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Be.displayName="StatsRow";var Sp=({children:e,order:n,style:t,...o})=>te("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Sp.displayName="StatsRows";Gl.StatsRow=Be;Gl.StatsRows=Sp;var uG=sG(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),c=s.getNonDeletedElementsMap(),d=Ue(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&xE(m),E=u?cG(m):null,[g,b]=aG({width:0,height:0}),y=bE(()=>iG(v=>{let T=lG(v);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},pG),[]);iP(()=>{y(l)},[i,l,y]),iP(()=>()=>y.cancel(),[y]);let w=bE(()=>Fa(o,r),[o,r]),x=bE(()=>dG(o),[o]);return te("div",{className:"exc-stats",children:Ht(ze,{padding:3,children:[Ht("div",{className:"title",children:[te("h2",{children:f("stats.title")}),te("div",{className:"close",onClick:n,children:Jt})]}),Ht(Ms,{label:te("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Tp.generalStats),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^Tp.generalStats}})),children:[Ht(Sp,{children:[te(Be,{heading:!0,children:f("stats.scene")}),Ht(Be,{columns:2,children:[te("div",{children:f("stats.shapes")}),te("div",{children:l.length})]}),Ht(Be,{columns:2,children:[te("div",{children:f("stats.width")}),te("div",{children:g.width})]}),Ht(Be,{columns:2,children:[te("div",{children:f("stats.height")}),te("div",{children:g.height})]}),a&&Ht(wE,{children:[te(Be,{heading:!0,children:"Canvas"}),te(Be,{children:te(MC,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&te("div",{id:"elementStats",style:{marginTop:12},children:te(Ms,{label:te("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Tp.elementProperties),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^Tp.elementProperties}})),children:Ht(Sp,{children:[m&&Ht(wE,{children:[u&&te(Be,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&xE(m)&&E&&Ht(Be,{columns:2,children:[te("div",{children:f("stats.width")}),te("div",{children:rP(E.width,2)})]}),r.croppingElementId&&xE(m)&&E&&Ht(Be,{columns:2,children:[te("div",{children:f("stats.height")}),te("div",{children:rP(E.height,2)})]}),te(Be,{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}`)}),te(Be,{children:te(EE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),te(Be,{children:te(EE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),te(Be,{children:te(dE,{property:"width",element:m,scene:s,appState:r})}),te(Be,{children:te(dE,{property:"height",element:m,scene:s,appState:r})}),te(Be,{children:te(PC,{property:"angle",element:m,scene:s,appState:r})}),te(Be,{children:te(FC,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Ht(wE,{children:[mG(p)&&te(Be,{heading:!0,children:f("element.group")}),Ht(Be,{columns:2,style:{margin:"0.3125rem 0"},children:[te("div",{children:f("stats.shapes")}),te("div",{children:o.length})]}),te(Be,{children:te(fE,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(fE,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(hE,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(hE,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(WC,{property:"angle",elements:p,scene:s,appState:r})}),te(Be,{children:te(eP,{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 SG,useEffect as sP,useState as lP}from"react";import{normalizeLink as CG,KEYS as TE}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as PG,getLinkIdAndTypeFromSelection as kG}from"@excalidraw/element";import hG from"clsx";import{jsx as Cp,jsxs as fG}from"react/jsx-runtime";var gG=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return fG("button",{className:hG("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Cp("div",{style:a?{visibility:"hidden"}:{},children:o}),Cp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Cp("div",{style:{position:"absolute",inset:0},children:Cp(so,{})})]})},yE=gG;import vE from"clsx";import{forwardRef as wG,useRef as yG,useImperativeHandle as vG,useLayoutEffect as IG,useState as TG}from"react";import EG from"clsx";import{composeEventHandlers as bG}from"@excalidraw/common";import{jsx as xG}from"react/jsx-runtime";var fn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>xG("button",{onClick:bG(i.onClick,a=>{n()}),type:e,className:EG("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as IE,jsxs as aP}from"react/jsx-runtime";var Pp=wG(({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=yG(null);vG(p,()=>u.current),IG(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=TG(!1);return aP("div",{className:vE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&IE("div",{className:"ExcTextField__label",children:n}),aP("div",{className:vE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[IE("input",{className:vE({"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&&IE(fn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?R1:Ar})]})]})});import{jsx as Ga,jsxs as kp}from"react/jsx-runtime";var MG=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=PG})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=lP(a),[c,d]=lP(!1);sP(()=>{let p=ie(i,t),u=a;if(p.length>0&&r){let E=kG(p,t);E&&(u=CG(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=SG(()=>{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 sP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===TE.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===TE.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),kp("div",{className:"ElementLinkDialog",children:[kp("div",{className:"ElementLinkDialog__header",children:[Ga("h2",{children:f("elementLink.title")}),Ga("p",{children:f("elementLink.desc")})]}),kp("div",{className:"ElementLinkDialog__input",children:[Ga(Pp,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===TE.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&Ga(K,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Pr})]}),kp("div",{className:"ElementLinkDialog__actions",children:[Ga(yE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),Ga(yE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},cP=MG;import AG,{useState as LG}from"react";import{Fragment as DG,jsx as SE}from"react/jsx-runtime";var dP=({children:e,onClose:n})=>{let[t,o]=LG(!!e),{container:r}=De(),i=AG.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return SE(DG,{children:t&&SE(gn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:SE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import mP,{useMemo as HG}from"react";import pP from"clsx";import{isDarwin as uP,isFirefox as GG,isWindows as UG}from"@excalidraw/common";import{KEYS as Ua}from"@excalidraw/common";import{SHAPES as WG}from"@excalidraw/element/shapes";import{isFirefox as _G,KEYS as CE}from"@excalidraw/common";import{SHAPES as RG}from"@excalidraw/element/shapes";import{Fragment as zG,jsx as Ge,jsxs as oi}from"react/jsx-runtime";var NG=e=>oi(zG,{children:[Ge("h3",{children:e.title}),Ge("div",{className:"HelpDialog__islands-container",children:e.children})]}),PE=e=>oi("div",{className:`HelpDialog__island ${e.className}`,children:[Ge("h4",{className:"HelpDialog__island-title",children:e.caption}),Ge("div",{className:"HelpDialog__island-content",children:e.children})]});function*BG(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var OG=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),yt=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ge(FG,{children:OG(a)},a)));return oi("div",{className:"HelpDialog__shortcut",children:[Ge("div",{children:e}),Ge("div",{className:"HelpDialog__key-container",children:[...BG(o,t?f("helpDialog.or"):null)]})]})},FG=e=>Ge("kbd",{className:"HelpDialog__key",...e});function kE(){return oi(NG,{title:f("helpDialog.shortcuts"),children:[oi(PE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ge(yt,{label:f("toolBar.hand"),shortcuts:[CE.H]}),RG.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ge(yt,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ge(yt,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ge(yt,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),oi(PE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ge(yt,{label:f("helpDialog.smartZoom"),shortcuts:[CE.F]}),Ge(yt,{label:f("helpDialog.dragToZoom"),shortcuts:[`${CE.Z}+${f("helpDialog.drag")}`]}),Ge(yt,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),oi(PE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ge(yt,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ge(yt,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ge(yt,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ge(yt,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(qo||_G)&&Ge(yt,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ge(yt,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ge(yt,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ge(yt,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ge(yt,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ge(yt,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as gP,jsx as $,jsxs as ri}from"react/jsx-runtime";var VG=e=>ri(gP,{children:[$("h3",{children:e.title}),$("div",{className:"HelpDialog__islands-container",children:e.children})]}),ME=e=>ri("div",{className:`HelpDialog__island ${e.className}`,children:[$("h4",{className:"HelpDialog__island-title",children:e.caption}),$("div",{className:"HelpDialog__island-content",children:e.children})]});function*YG(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var XG=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),q=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>$(KG,{children:XG(a)},a)));return ri("div",{className:"HelpDialog__shortcut",children:[$("div",{children:e}),$("div",{className:"HelpDialog__key-container",children:[...YG(o,t?f("helpDialog.or"):null)]})]})},KG=e=>$("kbd",{className:"HelpDialog__key",...e}),hP=({onClose:e})=>{let[n,t]=mP.useState(!1),o=mP.useCallback(()=>{e&&e()},[e]),r=HG(()=>n?$("button",{className:pP("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):$("button",{className:pP("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return $(gP,{children:$(gn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?ri(VG,{title:f("helpDialog.shortcuts"),children:[ri(ME,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[$(q,{label:f("toolBar.hand"),shortcuts:[Ua.H]}),WG.map(({value:i,key:a})=>$(q,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),$(q,{label:f("toolBar.frame"),shortcuts:[Ua.F]}),$(q,{label:f("labels.eyeDropper"),shortcuts:[Ua.I,"Shift+S","Shift+I"]}),$(q,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),$(q,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),$(q,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),$(q,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),$(q,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),$(q,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),$(q,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),$(q,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),$(q,{label:f("toolBar.lock"),shortcuts:[Ua.Q]}),$(q,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),$(q,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),$(q,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),ri(ME,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[$(q,{label:f("helpDialog.smartZoom"),shortcuts:[Ua.F]}),$(q,{label:f("helpDialog.dragToZoom"),shortcuts:[`${Ua.Z}+${f("helpDialog.drag")}`]}),$(q,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),$(q,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),$(q,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),$(q,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),$(q,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),$(q,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),$(q,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),$(q,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),$(q,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),$(q,{label:f("search.title"),shortcuts:[Ke("searchMenu")]})]}),ri(ME,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[$(q,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),$(q,{label:f("labels.delete"),shortcuts:[N("Delete")]}),$(q,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),$(q,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),$(q,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),$(q,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),$(q,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),$(q,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),$(q,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),$(q,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(qo||GG)&&$(q,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),$(q,{label:f("labels.sendToBack"),shortcuts:[uP?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),$(q,{label:f("labels.bringToFront"),shortcuts:[uP?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),$(q,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),$(q,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),$(q,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),$(q,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),$(q,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),$(q,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),$(q,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+R")]}),$(q,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),$(q,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),$(q,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),$(q,{label:f("buttons.redo"),shortcuts:UG?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),$(q,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),$(q,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),$(q,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),$(q,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),$(q,{label:f("labels.showStroke"),shortcuts:[N("S")]}),$(q,{label:f("labels.showBackground"),shortcuts:[N("G")]}),$(q,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),$(q,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),$(q,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):$(kE,{})})})};import{useEffect as bP,useRef as xP,useState as ii}from"react";import{DEFAULT_EXPORT_PADDING as QG,EXPORT_IMAGE_TYPES as AE,isFirefox as eU,EXPORT_SCALES as tU,cloneJSON as wP}from"@excalidraw/common";import{useCallback as ZG,useRef as $G,useState as jG}from"react";var qG=2e3,fP=()=>{let[e,n]=jG(null),t=$G(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},qG)},r=ZG(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import JG from"clsx";import{jsx as EP}from"react/jsx-runtime";var Ul=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>EP("div",{className:JG("Switch",{toggled:t,disabled:r}),children:EP("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 Oe,jsxs as fr}from"react/jsx-runtime";var nU=()=>fr("div",{children:[Oe("h3",{children:f("canvasError.cannotShowPreview")}),Oe("p",{children:Oe("span",{children:f("canvasError.canvasTooBig")})}),fr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),oU=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=Me(n,e),[l,c]=ii(i),[d,m]=ii(s),[p,u]=ii(e.exportBackground),[E,g]=ii(e.exportEmbedScene),[b,y]=ii(e.exportScale),w=xP(null),x=xP(0),[v,T]=ii(null),{onCopy:C,copyStatus:P,resetCopyStatus:A}=fP();bP(()=>{A()},[l,p,a,b,E,A]);let{exportedElements:L,exportingFrame:_}=Or(n,e,d);return bP(()=>{let k=w.current;if(!k)return;let D=k.offsetWidth,F=k.offsetHeight;if(!D)return;let Y=++x.current,z=()=>Y!==x.current;return wp({elements:L,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:QG,maxWidthOrHeight:Math.max(D,F),exportingFrame:_}).then(async W=>{if(!z()){try{await ls(W)}catch(Z){throw Z.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):Z}z()||(T(null),k.replaceChildren(W))}}).catch(W=>{z()||(console.error(W),T(W))}),()=>{x.current+=1}},[e,t,L,_,l,p,a,b,E]),fr("div",{className:"ImageExportModal",children:[Oe("h3",{children:f("imageExportDialog.header")}),fr("div",{className:"ImageExportModal__preview",children:[Oe("div",{className:"ImageExportModal__preview__canvas",ref:w,children:v&&Oe(nU,{})}),Oe("div",{className:"ImageExportModal__preview__filename",children:!mi&&Oe("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction(Hh,"ui",k.target.value)}})})]}),fr("div",{className:"ImageExportModal__settings",children:[Oe("h3",{children:f("imageExportDialog.header")}),s&&Oe(Wl,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Oe(Ul,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),Oe(Wl,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Oe(Ul,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(Gh,"ui",k)}})}),Oe(Wl,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Oe(Ul,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(iy,"ui",k)}})}),Oe(Wl,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Oe(Ul,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(Wd,"ui",k)}})}),Oe(Wl,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Oe(mp,{name:"exportScale",value:b,onChange:k=>{y(k),o.executeAction(oy,"ui",k)},choices:tU.map(k=>({value:k,label:`${k}\xD7`}))})}),fr("div",{className:"ImageExportModal__settings__buttons",children:[Oe(mr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(AE.png,L,{exportingFrame:_}),icon:Nu,children:f("imageExportDialog.button.exportToPng")}),Oe(mr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(AE.svg,L,{exportingFrame:_}),icon:Nu,children:f("imageExportDialog.button.exportToSvg")}),(qo||eU)&&Oe(mr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(AE.clipboard,L,{exportingFrame:_}),C()},icon:Nc,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Wl=({label:e,children:n,tooltip:t,name:o})=>fr("div",{className:"ImageExportModal__settings__setting",title:e,children:[fr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Oe(ct,{label:t,long:!0,children:L1})]}),Oe("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),yP=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=ii(()=>({appStateSnapshot:wP(n),elementsSnapshot:wP(e)}));return Oe(gn,{onCloseRequest:i,size:"wide",title:!1,children:Oe(oU,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import YU from"clsx";import{CANVAS_SEARCH_TAB as HP,DEFAULT_SIDEBAR as XU}from"@excalidraw/common";import rU from"clsx";import iU from"lodash.debounce";import{Fragment as aU,memo as sU,useEffect as Vl,useMemo as vP,useRef as LE,useState as IP}from"react";import{CLASSES as lU,EVENT as cU,FONT_FAMILY as DE,FRAME_STYLE as _E,getLineHeight as dU}from"@excalidraw/common";import{getCommonBounds as mU,isElementCompletelyInViewport as pU}from"@excalidraw/element";import{measureText as Yl}from"@excalidraw/element";import{KEYS as Wa,randomInteger as TP,addEventListener as uU,getFontString as Mp}from"@excalidraw/common";import{newTextElement as hU}from"@excalidraw/element";import{isTextElement as kP,isFrameLikeElement as Ap}from"@excalidraw/element";import{getDefaultFrameName as MP}from"@excalidraw/element/frame";import{Fragment as TU,jsx as ht,jsxs as An}from"react/jsx-runtime";var gU=je(""),RE=je(null),fU=350,AP=()=>{let e=It(),n=Ue(),t=LE(null),[o,r]=Fe(gU),i=o.trim(),[a,s]=IP(!1),[l,c]=IP({nonce:null,items:[]}),d=LE(null),m=LE(void 0),[p,u]=Fe(RE),E=e.scene.getNonDeletedElementsMap();Vl(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,PP(i,e,(x,v)=>{c({nonce:TP(),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)};Vl(()=>{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]),Vl(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let v=e.state.zoom.value,T=hU({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:Ap(x.element)?_E.nameFontSize:x.element.fontSize,fontFamily:Ap(x.element)?DE.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,A=P*v<C;if(!pU([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())||A){let L=A&&P<C?"contain":"scale-down";e.viewport.setViewport({target:mU([T]),fit:L,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),Vl(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let y=Si({goToNextItem:g,goToPreviousItem:b,searchMatches:l});Vl(()=>{let x=v=>{if(v.key===Wa.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),n({openSidebar:null});return}if(v[Wa.CTRL_OR_CMD]&&v.key===Wa.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&y.searchMatches.items.length&&(v.key===Wa.ENTER&&(v.stopPropagation(),y.goToNextItem()),v.key===Wa.ARROW_UP?(v.stopPropagation(),y.goToPreviousItem()):v.key===Wa.ARROW_DOWN&&(v.stopPropagation(),y.goToNextItem()))};return uU(window,cU.KEYDOWN,x,{capture:!0,passive:!1})},[n,y,e]);let w=`${l.items.length} ${l.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return An("div",{className:"layer-ui__search",children:[An("div",{className:"layer-ui__search-header",children:[ht(Pp,{className:lU.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:Wn,onChange:x=>{r(x),s(!0);let v=x.trim();PP(v,e,(T,C)=>{c({nonce:TP(),items:T}),u(C),d.current=v,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}),ht(fn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:Jt})]}),An("div",{className:"layer-ui__search-count",children:[l.items.length>0&&An(TU,{children:[p!==null&&p>-1?An("div",{children:[p+1," / ",w]}):ht("div",{children:w}),An("div",{className:"result-nav",children:[ht(fn,{onSelect:()=>{g()},className:"result-nav-btn",children:Oc}),ht(fn,{onSelect:()=>{b()},className:"result-nav-btn",children:K1})]})]}),l.items.length===0&&i&&d.current&&ht("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),ht(xU,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},SP=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 ht("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:ht("div",{className:"preview-text",children:n.flatMap((t,o)=>ht(aU,{children:o===2?ht("b",{children:t}):t},o))})})},EU=e=>{let n=vP(()=>e.matches.items.filter(o=>Ap(o.element)),[e.matches]),t=vP(()=>e.matches.items.filter(o=>kP(o.element)),[e.matches]);return An("div",{className:"layer-ui__search-results",children:[n.length>0&&An("div",{className:"layer-ui__search-result-container",children:[An("div",{className:"layer-ui__search-result-title",children:[ht("div",{className:"title-icon",children:Gn}),ht("div",{children:f("search.frames")})]}),n.map((o,r)=>ht(SP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&ht("div",{className:"layer-ui__divider"})]}),t.length>0&&An("div",{className:"layer-ui__search-result-container",children:[An("div",{className:"layer-ui__search-result-title",children:[ht("div",{className:"title-icon",children:wn}),ht("div",{children:f("search.texts")})]}),t.map((o,r)=>ht(SP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},bU=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,xU=sU(EU,bU),CP=(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}},wU=(e,n)=>{let t=e.split(`
17
+ `).filter(l=>l.trim().length>0).map(l=>l.split(s).map(c=>c.trim())),t=[" ",",",";"].map(s=>{let l=n(s),c=l[0]?.length??0,d=l.length>0&&l.every(m=>m.length===c);return{delimiter:s,parsed:l,numCols:c,isConsistent:d}}),r=(t.find(s=>s.isConsistent&&s.numCols>1)??t.find(s=>s.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(s=>s.length===i)?PI(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Ia}from"@excalidraw/math";import{FONT_FAMILY as q7,FONT_SIZES as J7,getFontString as Q7,getLineHeight as eB,ROUGHNESS as kI}from"@excalidraw/common";import{measureText as tB,newLinearElement as uf,newTextElement as nB}from"@excalidraw/element";var MI=(e,n,t,o)=>{if(!Ea(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,W)=>`Value ${W+1}`),i=e.series,{normalize:a,renderSteps:s}=yI(i,r.length),l=wa(o),c=ya(l),d=xa(i.length,l),{chartWidth:m,chartHeight:p}=wI(),u=n+m/2,E=t-p/2,g=ua/2,b=r.map((z,W)=>-Math.PI/2+Math.PI*2*W/r.length),{axisLabels:y,axisLabelTopY:w,axisLabelBottomY:x}=vI(r,b,u,E,g,c),v=q7["Lilita One"],T=J7.xl,C=eB(v),P=Q7({fontFamily:v,fontSize:T}),A=e.title?Pm(e.title,P,m+ha*2):null,L=A?tB(A,P,C):null,_=A?nB({backgroundColor:c,..._e,text:A,originalText:e.title??A,x:n+m/2,y:w-ha-L.height/2,fontFamily:v,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:nf},(z,W)=>{let Z=(W+1)/nf,H=g*Z,re=b.map(B=>Ia(Math.cos(B)*H,Math.sin(B)*H));return re.push(Ia(re[0][0],re[0][1])),uf({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:H*2,height:H*2,strokeStyle:"solid",roughness:kI.architect,opacity:jr,polygon:!0,points:re})}):[],D=b.map(z=>{let W=Math.cos(z)*g,Z=Math.sin(z)*g;return uf({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:Math.abs(W),height:Math.abs(Z),strokeStyle:"solid",roughness:kI.architect,opacity:jr,points:[Ia(0,0),Ia(W,Z)]})}),O=i.map((z,W)=>{let Z=b.map((H,re)=>{let B=z.values[re]??0,U=a(B,re)*g;return Ia(Math.cos(H)*U,Math.sin(H)*U)});return Z.push(Ia(Z[0][0],Z[0][1])),uf({backgroundColor:"transparent",..._e,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[W],strokeWidth:2,polygon:!0,points:Z})}),Y=va(i,d,u,x,t+Zn*5,c);return[..._?[_]:[],...y,...k,...D,...O,...Y]};var hf=(e,n,t,o,r)=>e==="line"?CI(n,t,o,r):e==="radar"?MI(n,t,o,r):TI(n,t,o,r);import{clamp as Lm,pointFrom as Ta,pointsEqual as cB,bezierEquation as zI,pointRotateRads as Dm,pointDistance as dB}from"@excalidraw/math";import{arrayToMap as mB,BIND_MODE_TIMEOUT as yl,DEFAULT_TRANSFORM_HANDLE_SPACING as HI,FRAME_STYLE as mn,getFeatureFlag as pB,invariant as RI,shouldRotateWithDiscreteAngle as GI,THEME as wo}from"@excalidraw/common";import{deconstructDiamondElement as xf,deconstructRectanguloidElement as UI,elementCenterPoint as Sa,getDiamondBaseCorners as uB,FOCUS_POINT_SIZE as hB,getOmitSidesForEditorInterface as gf,getTransformHandles as gB,getTransformHandlesFromCoords as fB,hasBoundingBox as EB,hitElementItself as bB,isArrowElement as WI,isBindableElement as VI,isElbowArrow as Ca,isFrameLikeElement as Pa,isImageElement as _m,isLinearElement as xB,isLineElement as wB,maxBindingDistance_simple as yB,isTextElement as vB,LinearElementEditor as pn,getActiveTextElement as IB,getElementsInGroup as wf,getSelectedGroupIds as TB,isSelectedViaGroup as SB,selectGroupsFromGivenElements as CB}from"@excalidraw/element";import{renderSelectionElement as PB}from"@excalidraw/element";import{getCommonBounds as yf,getElementAbsoluteCoords as Il}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as NI,isFocusPointVisible as kB}from"@excalidraw/element";import{pointFrom as St}from"@excalidraw/math";import{THEME as oB}from"@excalidraw/common";var rB="#ff6b6b",iB="#ff0000",AI=1,LI=2,DI=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===oB.LIGHT||n.zenModeEnabled?rB:iB,o=(n.zenModeEnabled?AI*1.5:AI)/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,sB(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,lB(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,aB(r,e,n));e.restore()},aB=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];dn(o,r,n)}for(let o of e.points)_I(o,t,n)},sB=(e,n,t)=>{_I(e.points[0],t,n),t.zenModeEnabled||dn(e.points[0],e.points[1],n)},_I=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?LI*1.5:LI)/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()},dn=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},lB=(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||dn(St(e[0],e[1]-i),St(e[0],e[1]+i),r),dn(St(l[0]-s,l[1]-a),St(l[0]-s,l[1]+a),r),dn(St(l[0]+s,l[1]-a),St(l[0]+s,l[1]+a),r),o.zenModeEnabled||(dn(St(n[0],n[1]-i),St(n[0],n[1]+i),r),dn(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||dn(St(e[0]-i,e[1]),St(e[0]+i,e[1]),r),dn(St(l[0]-a,l[1]-s),St(l[0]+a,l[1]-s),r),dn(St(l[0]-a,l[1]+s),St(l[0]+a,l[1]+s),r),o.zenModeEnabled||(dn(St(n[0]-i,n[1]),St(n[0]+i,n[1]),r),dn(e,n,r))}};var MB=(e,n)=>{RI(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;RI(t,"midPointCoords is null"),Rm(t,e,n)},AB=(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=pn.getElement(o,t);if(!i)return;let a=pn.getPointAtIndexGlobalCoordinates(i,r,t);Rm(a,e,n)},Rm=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",is(n,e[0],e[1],pn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},LB=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!WI(i)||i.isDeleted)return;let a=r==="label"?pn.getBoundTextElementCenter(i,t):pn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);Rm(a,e,n)},ff=(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)"),is(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},DB=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&Pa(a)&&(e.translate(a.x,a.y),e.beginPath(),mn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,mn.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=mn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===wo.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",mn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,mn.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=Sa(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=Lm(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===wo.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]=xf(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]=UI(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&&(Pa(n.element)||VI(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&pn.getElement(s?.elementId,t),c=r&&bB({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&Ca(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=Sa(n.element,t),p;if(n.element.type==="diamond"){let b=Sa(n.element,t);p=uB(n.element).map(y=>{let w=zI(y,.5),x=Dm(w,b,n.element.angle);return Ta(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(y=>{let w=Ta(y.x+n.element.x,y.y+n.element.y),x=Dm(w,m,n.element.angle);return Ta(x[0],x[1])});let u=r&&p.reduce((b,y,w)=>{let x=dB(y,r);return w===-1||x<b.distance?{idx:w,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=yB(o.zoom)+n.element.strokeWidth/2;p.forEach((b,y)=>{let w=(!c||d)&&u?.idx===y&&u.distance<=g,x=!w&&(d||y===u?.idx&&u.distance<=g*2);w?(e.fillStyle=o.theme===wo.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===wo.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()}}},_B=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=yl-(a?.runtime??(s?0:yl)),c=Lm(1/yl*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&Pa(m)&&(n.translate(m.x,m.y),n.beginPath(),mn.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,mn.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=mn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===wo.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,mn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,mn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=Sa(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=Lm(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===wo.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,y]=xf(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),y.forEach(w=>{let[x,v,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(v[0]-t.x+d,v[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,y]=UI(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),y.forEach(w=>{let[x,v,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(v[0]-t.x+d,v[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)>yl)return;let p=.5*(Math.min(t.width,t.height)/2);if(!Pa(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/yl*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||!GI(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,y;if(t.type==="diamond"){let[,w]=xf(t),x=Sa(t,o);y=w.map(v=>{let T=zI(v,.5),C=Dm(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let w=Sa(t,o);y=[{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(v=>{let T=Ta(v.x+t.x,v.y+t.y),C=Dm(T,w,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}y.forEach(w=>{n.clearRect(w.x-b,w.y-b,b*2,b*2)}),n.fillStyle=r.theme===wo.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,y.forEach(w=>{n.beginPath(),n.arc(w.x,w.y,E,0,2*Math.PI),n.fill()}),n.restore()}}return{runtime:(a?.runtime??0)+i}},RB=(e,n,t,o,r,i,a)=>{if(t===null)return;if(pB("COMPLEX_BINDINGS"))return _B(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Ta(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&GI(e.lastPointerMoveEvent);DB(n,t,o,r,s,l),n.restore()},YI=(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??HI*2)/n.zoom.value,y=8/n.zoom.value,w=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 v=0;v<x;++v)e.strokeStyle=l[v],m&&e.setLineDash([y,w+(y+w)*(x-1)]),e.lineDashOffset=(y+w)*v,as(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},NB=(e,n,t,o)=>{let[r,i,a,s]=Il(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=mn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),as(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,mn.radius/n.zoom.value),e.restore()},BI=(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]=yf(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=wf(t,d);return l(m)};Object.entries(CB(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>YI(e,n,d))},Ef=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=pn.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=pn,a=n.selectedLinearElement?.isEditing?i:i/2,s=Ca(t),l=wB(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)&&cB(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),ff(e,n,c,a,p,!1,m)}),Ca(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{pn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||ff(e,n,Ta((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else pn.getEditorMidPoints(t,o,n).filter((d,m,p)=>d!==null&&!(Ca(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&ff(e,n,d,i/2,!1,!0,!1)});e.restore()},BB=(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()},OB=(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)",is(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},OI=({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||!VI(a)||a.isDeleted)return;let s=NI(i.fixedPoint,a,r);if(!kB(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&&Rm(s,o,n),!(m&&c)){let p=NI(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=pn.getPointAtIndexGlobalCoordinates(e,d,r);BB(o,n,E,p),OB(o,n,p,hB/1.5,u)}},FI=(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"?is(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()):as(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},FB=(e,n,t,o,r)=>{let[i,a,,,s,l]=Il(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(w=>{let[[x,v],[T,C],[P,A],[L,_],[k,D]]=w;e.save(),e.translate(s,l),e.rotate(o.angle),e.beginPath(),e.moveTo(x+T,v+C),e.lineTo(x+P,v+A),e.stroke(),e.beginPath(),e.moveTo(x+L,v+_),e.lineTo(x+k,v+D),e.stroke(),e.restore()}),e.restore()},zB=(e,n,t,o)=>{n.save();let r=Kg(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()},HB=(e,n,t,o,r)=>{let i=Zg(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())},GB=(e,n,t,o,r,i)=>{for(let a of n){if(!_m(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let d=vl(a,t,r,"center");d&&KI(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=vl(a,t,r,"center");m&&XI(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=vl(a,t,r,"top-right");d&&WB(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},vl=(e,n,t,o)=>{if(!_m(e))return null;let[r,i,a,s]=Il(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}},XI=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===wo.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*Lm(i,0,1)),e.stroke()),e.restore()},bf=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,UB=(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()},WB=(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"){KI(e,n,t,o,a,{color:i.color??bf("--color-danger","#e03131")});return}if(l==="uploading"&&XI(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),UB(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())},KI=(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()},VB=({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]=Ec(n,a),E=d,g=bc({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&&Ef(g,s,b,t),s.selectionElement&&!s.isCropping)try{PB(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let y=IB(r,s);if(y&&!y.autoResize&&HB(y,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&zB(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:RB(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&LB(g,s,i),s.frameToHighlight&&NB(g,s,s.frameToHighlight,t),s.elementsToHighlight&&BI(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:wf(i,s.activeLockedId);BI(g,s,P,{colors:["#ced4da"],dashed:!0})}let w=r.some(C=>Pa(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&Ef(g,s,r[0],t);let x=s.selectedLinearElement,v=x&&pn.getElement(x.elementId,i);if(v&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?MB(g,s):(Ca(v)?x.hoverPointIndex===0||x.hoverPointIndex===v.points.length-1:x.hoverPointIndex>=0)&&AB(g,s,t)),WI(v)&&(OI({arrow:v,elementsMap:i,appState:s,context:g,type:"start"}),OI({arrow:v,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=EB(r,s,c),P=r.length===1&&xB(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Ef(g,s,r[0],t);let A=l.selectionColor||"#000";if(C){let L=mB(r),_=[];for(let D of t.values()){let O=[],Y=l.remoteSelectedElementIds.get(D.id);if(P&&Ca(D)&&(D.startBinding||D.endBinding)||(L.has(D.id)&&!SB(s,D)&&O.push(A),Y&&O.push(...Y.map(z=>Gr(z,s.collaborators.get(z))))),O.length){let[z,W,Z,H,re,B]=Il(D,t,!0);_.push({angle:D.angle,x1:z,y1:W,x2:Z,y2:H,selectionColors:D.locked?["#ced4da"]:O,dashed:!!Y||D.locked,cx:re,cy:B,activeEmbeddable:s.activeEmbeddable?.element===D&&s.activeEmbeddable.state==="active",padding:D.id===s.croppingElementId||_m(D)?0:void 0})}}let k=D=>{let O=wf(t,D),[Y,z,W,Z]=yf(O);_.push({angle:0,x1:Y,x2:W,y1:z,y2:Z,selectionColors:O.some(H=>H.locked)?["#ced4da"]:["#000"],dashed:!0,cx:Y+(W-Y)/2,cy:z+(Z-z)/2,activeEmbeddable:!1})};for(let D of TB(s))k(D);s.editingGroupId&&k(s.editingGroupId),_.forEach(D=>YI(g,s,D))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let L=gB(r[0],s.zoom,t,"mouse",gf(c));if(!s.viewModeEnabled&&C&&!vB(s.editingTextElement)&&!s.croppingElementId&&FI(g,l,s,L,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&_m(_)&&FB(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(L=>L.locked)){let L=HI*2/s.zoom.value;g.fillStyle="#fff";let[_,k,D,O]=yf(r,t),Y=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=A,as(g,_-L,k-L,D-_+L*2,O-k+L*2,(_+D)/2,(k+O)/2,0),g.lineWidth=z,g.setLineDash(Y);let W=fB([_,k,D,O,(_+D)/2,(k+O)/2],0,s.zoom,"mouse",w?{...gf(c),rotation:!0}:gf(c));r.some(Z=>!Z.locked)&&FI(g,l,s,W,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:A})=>{let L=t.get(C);if(L){let[_,k,,,D,O]=Il(L,t,!0);g.save(),s.theme===wo.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=Pa(L)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(D,O),g.rotate(L.angle),A.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/Y-D,k+z.offsetY/Y-O,z.width/Y,z.height/Y)}),g.restore()}}),DI(g,s),GB(g,o,t,e,s,l.selectionColor),g.restore(),uy({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=B2(t,p,u,s),g.save(),g.fillStyle=N2,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&Yd(g,C.x,C.y,C.width,C.height,cn/2)}),g.restore()),{scrollBars:T,animationState:E}},vf=e=>{let n=VB(e);return e.callback(n),n};import{useEffect as Pl,useMemo as ZI,useRef as Pf,useState as YB}from"react";import{bumpVersion as Tl,getLinearElementSubType as Ma,mutateElement as kf,updateElbowArrowPoints as XB}from"@excalidraw/element";import{pointFrom as Bm,pointRotateRads as KB}from"@excalidraw/math";import{hasBoundTextElement as ZB,isArrowBoundToElement as $B,isArrowElement as jB,isElbowArrow as qB,isLinearElement as Df,isUsingAdaptiveRadius as JB}from"@excalidraw/element";import{getCommonBoundingBox as QB,getElementAbsoluteCoords as eO}from"@excalidraw/element";import{getBoundTextElement as QI,getBoundTextMaxHeight as tO,getBoundTextMaxWidth as nO,redrawTextBoundingBox as oO}from"@excalidraw/element";import{wrapText as rO}from"@excalidraw/element";import{assertNever as iO,CLASSES as aO,getFontString as If,isProdEnv as sO,mapFind as lO,reduceToCommonValue as cO,ROUNDNESS as Tf,sceneCoordsToViewportCoords as dO,updateActiveTool as $I}from"@excalidraw/common";import{measureText as jI}from"@excalidraw/element";import{LinearElementEditor as mO}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Sf,newElement as pO,newLinearElement as uO}from"@excalidraw/element";import{ShapeCache as hO}from"@excalidraw/element";import{updateBindings as gO}from"@excalidraw/element";import{jsx as Lf}from"react/jsx-runtime";var fO=8,EO=10,Sl=["rectangle","diamond","ellipse"],Cl=["line","sharpArrow","curvedArrow","elbowArrow"],bO=new Set(Sl),xO=new Set(Cl),Aa=e=>bO.has(e),Om=e=>e==="arrow"||xO.has(e),$n=qe(null),kl=new Map,Ml=new Map,wO=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=Pf(null);return Pl(()=>{if(n.length===0){e.updateEditorAtom($n,null);return}let o=Fm(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom($n,null),t.current=null)},[n,e]),Pl(()=>()=>{kl.clear(),Ml.clear()},[]),Lf(yO,{app:e,elements:n})},yO=({app:e,elements:n})=>{let t=Fm(n),o=ZI(()=>t==="generic"?tT(n):[],[t,n]),r=ZI(()=>t==="linear"?Af(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>Ma(m)===Ma(r[0])):!1,[a,s]=YB({x:0,y:0}),l=Pf(""),c=Pf(null);Pl(()=>{let m=[...o,...r].sort((b,y)=>b.id.localeCompare(y.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,,,y,w,x]=eO(m[0],e.scene.getNonDeletedElementsMap());u=KB(Bm(b,y),Bm(w,x),m[0].angle)}else{let{minX:b,maxY:y}=QB(m);u=Bm(b,y)}let{x:E,y:g}=dO({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),Pl(()=>{for(let m of r){let p=Mf(m.id,CO(m));Ml.has(p)||Ml.set(p,m)}},[r]),Pl(()=>{for(let m of o)if(!kl.has(m.id)){let p=QI(m,e.scene.getNonDeletedElementsMap());p&&kl.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",Bo],["sharpArrow",zo],["curvedArrow",Go],["elbowArrow",Ho]]:t==="generic"?[["rectangle",Ei],["diamond",bi],["ellipse",xi]]:[];return Lf("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(EO+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-fO}px`,zIndex:2},className:aO.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&Ma(r[0])===m);return Lf(K,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Ne("convertElementType",m,"ui"),_f(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},vO=(e,n,t)=>{let o=nO(e,n),r=tO(e,n),i=rO(n.text,If(n),o),a=jI(i,If(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=jI(n.text,If(l),n.lineHeight)}kf(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),oO(n,e,t)},_f=(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=tT(r),c=s.every(d=>d.type===s[0].type)?Sl.indexOf(s[0].type):-1;if(t=t??Sl[(c+Sl.length+a)%Sl.length],t&&Aa(t)){let d={};for(let p of s){let u=JI(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=QI(p,e.scene.getNonDeletedElementsMap());u&&(kl.get(p.id)&&kf(u,e.scene.getNonDeletedElementsMap(),{fontSize:kl.get(p.id)?.fontSize??u.fontSize}),vO(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:$I(p,{type:"selection"})}))}}if(n==="linear"){let s=Af(r);if(!t){let c=cO(s,Ma),d=c?Cl.indexOf(c):-1;t=Cl[(d+Cl.length+a)%Cl.length]}if(Om(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Ml.get(Mf(m.id,t));if(p&&Ma(p)===t)d.set(p.id,p),c.push(p);else{let u=JI(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(Df(m))if(qB(m)){let p=IO(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=XB(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});kf(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=lO(["line","sharpArrow","curvedArrow"],u=>Ml.get(Mf(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=Af(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new mO(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:$I(c,{type:"selection"})}))}return!0},Fm=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(Aa(t.type))return"generic";eT(t)&&(n=!0)}return n?"linear":null},eT=e=>Df(e)&&(!jB(e)||!$B(e)&&!ZB(e)),Mf=(e,n)=>`${e}:${n}`,tT=e=>e.filter(n=>Aa(n.type)),Af=e=>e.filter(n=>eT(n)),Nm=20,ka=(e,n)=>e[0]===n[0],Cf=(e,n)=>e[1]===n[1],qI=(e,n)=>ka(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),IO=e=>{let n=[e.points[0]],t=TO(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])<Nm?s[0]=a[0]:Math.abs(s[1]-a[1])<Nm&&(s[1]=a[1]),ka(a,s)||Cf(a,s)||n.push(Bm(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])||Cf(n[i-1],n[i])&&Cf(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=ka(a,s),d=ka(s,l);if(c!==d){let m=qI(a,s),p=qI(s,l);if(m<Nm||p<Nm){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},TO=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},JI=(e,n,t)=>{if(!SO(e.type,n)){if(!sO())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(hO.delete(e),Aa(n)){let o=Tl(pO({...e,type:n,roundness:e.roundness?{type:JB(n)?Tf.ADAPTIVE_RADIUS:Tf.PROPORTIONAL_RADIUS}:e.roundness}));return gO(o,t.scene,t.state),o}if(Om(n))switch(n){case"line":return Tl(uO({...e,type:"line"}));case"sharpArrow":return Tl(Sf({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Tl(Sf({...e,type:"arrow",elbowed:!1,roundness:{type:Tf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Tl(Sf({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return iO(n,`unhandled conversion type: ${n}`),e},SO=(e,n)=>!!(Aa(e)&&Aa(n)||Om(e)&&Om(n)),CO=e=>Df(e)?Ma(e):e.type,nT=wO;import{bindBindingElementToFixedPoint as PO,dragNewTextElement as kO,getBoundTextElement as MO,getEndpointBoundTextDragAnchor as AO,getTextBindingForArrowEndpoint as LO,getUnboundArrowEndpointAtPoint as DO,isArrowElement as _O,isBindingEnabled as RO,isEndpointBoundText as NO,isTextElement as BO}from"@excalidraw/element";import{pointFrom as OO}from"@excalidraw/math";var zm=class{constructor(n){this.app=n;I(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});I(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!RO(this.app.state))return null;let o=DO(OO(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!_O(r)||MO(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 LO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){PO(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!BO(n)||!NO(n,this.app.scene.getNonDeletedElementsMap())?!1:(kO({newElement:n,...AO(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as FO,BUCKET_FILL_BACKGROUND_PICKS as zO,COLOR_PALETTE as rT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as HO,getSizeFromPoints as GO,isTransparent as UO,THEME as WO}from"@excalidraw/common";import{pointFrom as oT}from"@excalidraw/math";import{computeBucketFillPolygon as VO,isBucketFillCompatible as YO,isFrameLikeElement as XO,isRestylableFill as KO,newLinearElement as ZO,ShapeCache as $O}from"@excalidraw/element";var Rf=zO.filter(e=>e!==rT.white),Hm=class{constructor(n){this.app=n;I(this,"temporaryEyeDropper",null);I(this,"pending",null);I(this,"handlePointerDown",n=>{this.pending=n});I(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});I(this,"cancel",()=>{this.pending=null});I(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=Rf.indexOf(n),o=Rf[(t+1)%Rf.length];this.app.actionManager.executeAction(gd,"keyboard",{currentItemBackgroundColor:o})});I(this,"openTemporaryEyeDropper",()=>{if(gt.get(Nt))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(gd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Nt,n)});I(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&gt.get(Nt)===n&&this.app.updateEditorAtom(Nt,null)});I(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}),$O.delete(n),this.app.scheduleCapture())});I(this,"fill",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=oT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=VO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&YO(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&&KO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=GO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(w=>oT(w[0]-d,w[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?XO(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:s.boundaryElementIds.map(w=>r.get(w)?.groupIds).filter(w=>!!w).reduce((w,x)=>w===null?x:w.filter(v=>x.includes(v)),null)??[],b=ZO({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}),y=this.app.scene.getElementsIncludingDeleted().findIndex(w=>w.id===s.insertion.elementId);this.app.scene.insertElementsAtIndex([b],y<0?null:s.insertion.placement==="above"?y+1:y),this.app.scheduleCapture()});I(this,"getBucketFillBackgroundColor",(n,t)=>UO(n)?rT.green[HO]:FO(n,t===WO.DARK))}};import{CURSOR_TYPE as Al,MIME_TYPES as Um,THEME as iT}from"@excalidraw/common";var aT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',jO='<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"/>',sT='<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"/>',qO=`data:${Um.svg},${encodeURIComponent(`${aT}${sT}</svg>`)}`,JO=`data:${Um.svg},${encodeURIComponent(`${aT}${jO}${sT}</svg>`)}`,QO=e=>{let n=gu.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${Um.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>`)}`},Gm=class{constructor(n){this.app=n;I(this,"toolCursorMemo",null);I(this,"eraserCanvasCache",null);I(this,"eraserPreviewDataURL",null);I(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});I(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(Al.GRAB):this.clear():this.applyForTool()});I(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(os({activeTool:n}))this.set(Al.GRAB);else if(qt({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(Al.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${QO(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===iT.LIGHT?qO:JO;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(Al.AUTO):this.set(Al.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});I(this,"clear",()=>{this.set("")});I(this,"applyEraser",()=>{let t=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==t){let o=t===iT.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(Um.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as rF}from"@excalidraw/common";import{bindBindingElement as iF,convertToShape as aF,convertToShapeHandlePointerMoveFromPointerDown as sF,getHoveredElementForBinding as lT,isBindingElement as lF,isLineElement as cF,LinearElementEditor as Nf,maxBindingDistance_simple as cT,newArrowElement as dF,updateBoundPoint as mF}from"@excalidraw/element";import{getStrokeWidthByKey as eF,THEME as tF}from"@excalidraw/common";import{clamp as nF,pointFrom as oF}from"@excalidraw/math";var Wm=class{constructor(n){this.app=n;I(this,"trail");this.trail=new Pn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===tF.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>nF(eF("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])=>oF(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var Vm=class{constructor(n){this.app=n;I(this,"trail");I(this,"gestureInProgress",!1);I(this,"stop",()=>{this.trail.stop()});I(this,"hasPendingGesture",()=>this.gestureInProgress);I(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(dt),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});I(this,"handlePointerMove",n=>sF(this.app,n));I(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=cT(t.state.zoom),a=["start","end"].map(d=>{let m=Nf.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:lT(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&&iF(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=mF(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&&Nf.movePoints(n,t.scene,c)});I(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=cT(t.state.zoom),[a,s]=[0,-1].map(l=>lT(Nf.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:dF({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})});I(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||aF(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:rF(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&cF(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&lF(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new Wm(n)}};import{isArrowKey as pF,KEYS as Jr}from"@excalidraw/common";import{makeNextSelectedElementIds as uF,CaptureUpdateAction as hF,FlowChartCreator as gF,FlowChartNavigator as fF,getSelectedElements as dT,isFlowchartNodeElement as EF}from"@excalidraw/element";var Ym=class e{constructor(n){this.app=n;I(this,"creator",new gF);I(this,"navigator",new fF);I(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});I(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===Jr.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!pF(n.key))return{type:"none"};if(n[Jr.CTRL_OR_CMD]&&!n.shiftKey){let a=dT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&EF(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=dT(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[Jr.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:uF({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:hF.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case Jr.ARROW_UP:return"up";case Jr.ARROW_DOWN:return"down";case Jr.ARROW_RIGHT:return"right";case Jr.ARROW_LEFT:return"left";default:return"right"}}};import{debounce as bF,easeOut as fT,isBounds as xF}from"@excalidraw/common";import{clamp as ET}from"@excalidraw/math";import{getCommonBounds as mT,getElementsInGroup as wF,isElementLink as yF,isExcalidrawElement as vF,parseElementLinkFromURL as IF}from"@excalidraw/element";var Xm="animateScrollToContent",La="animateScrollConstraintsSnapBack",pT=500,TF=250,SF=200,Bf=302,uT={full:216,compact:64},CF=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")},PF=(e,n)=>{let t=n.get(e);return t?[t]:wF(n,e)},hT=(e,n,t)=>{if(typeof e=="string"){let a=yF(e),s=a?"link":"element",l=a?IF(e):e,c=l?PF(l,n):[];return c.length?{bounds:mT(c,n),type:s}:{bounds:null,type:s}}if(xF(e))return{bounds:e,type:"area"};if(CF(e)&&!vF(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:mT(r,n),type:"element"}},kF=e=>e===!1?0:e===!0||e==null?au:Math.max(e,0),MF=(e,n,t="scale-down",o,r)=>{let{appState:i}=Ir({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},gT=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=MF(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:kF(r.overscroll),offsets:o};return{...Bn({...e,...a,scrollConstraints:m}),scrollConstraints:m}},AF=({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}}},LF=e=>e===!1?null:e===!0||e==null?pT:e.duration??pT,DF=(e,n,t,o,r)=>{rt.start(Xm,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=fT(ET(l,0,1));return l<1?(o({...AF({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},_F=(e,n,t=TF)=>{let o=Bn(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||rt.running(Xm))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;rt.start(La,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-fT(ET(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=Bn(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})},Km=class{constructor(n,t){this.app=n;this.dependencies=t;I(this,"lastPosition",{x:0,y:0});I(this,"activeTransition",null);I(this,"uiLastMeasured",new Map);I(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});I(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}});I(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=zn().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,y]=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],y);let w=u.dataset.viewportUiName;w&&(a.add(w),y>0&&this.uiLastMeasured.set(w,{side:b,offset:y}));break}}}if(n?.reserve&&this.app.editorInterface.formFactor!=="phone"){let u=(E,g)=>{if(a.has(E))return;let{side:b,offset:y}=this.uiLastMeasured.get(E)??g;i[b]=Math.max(i[b],y)};n.reserve.stylesPanel&&u("stylesPanel",{side:r?"right":"left",offset:this.dependencies.getStylesPanelMode()==="compact"?uT.compact:uT.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:Bf})}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}});I(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=hT(n.target,t,o);return r?gT(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});I(this,"setViewport",n=>{if(n===null){this.cancelTransition(),rt.cancel(La),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}=hT(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=gT(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=LF(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),rt.cancel(La),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}),DF(p,d,m,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});I(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||rt.cancel(La),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(),Bn(r,a)}),!0});I(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?Bn(t,n):null)});I(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});I(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||_F(this.app.state,n=>this.app.setState(t=>n(t)))});I(this,"snapBackDebounced",bF(this.snapBack,SF));I(this,"cancelTransition",()=>{this.activeTransition=null,rt.cancel(Xm)});I(this,"destroy",()=>{this.cancelTransition(),rt.cancel(La),this.snapBackDebounced.cancel()})}get isAnimating(){return rt.running(Xm)||rt.running(La)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import Zm from"react";var RF=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,NF=/{{([\w-]+)}}/,BF=/<([\w-]+)>/,OF=/<\/([\w-]+)>/,FF=(e,n)=>{let t=[{name:"",children:[]}];return e.split(RF).filter(Boolean).forEach(o=>{let r=o.match(BF),i=o.match(OF),a=o.match(NF);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=Zm.createElement(Zm.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},zF=({i18nKey:e,children:n,...t})=>{let{t:o}=Ae();return Zm.createElement(Zm.Fragment,{},...FF(o(e),t))},Qr=zF;import{jsx as un,jsxs as bT}from"react/jsx-runtime";var HF=()=>bT("div",{"data-testid":"brave-measure-text-error",children:[un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>un("span",{style:{fontWeight:600},children:e})})}),un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>un("span",{style:{fontWeight:600},children:e})})}),un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>un("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),un("p",{children:un(Qr,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>un("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>bT("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),xT=HF;import ZF from"clsx";import $F from"react";import{isDarwin as wT}from"@excalidraw/common";var GF={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")]},Ke=(e,n=0)=>{let t=GF[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as UF,useRef as yT,useEffect as vT}from"react";import{unstable_batchedUpdates as WF}from"react-dom";import{KEYS as VF,queryFocusableElements as YF}from"@excalidraw/common";import{clamp as IT}from"@excalidraw/math";import XF from"clsx";import{jsx as KF}from"react/jsx-runtime";var ar=10,TT=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=yT(null);vT(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===VF.TAB){let u=YF(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=yT(null);return UF(()=>{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-ar*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${ar}px`,d.style.overflowX="scroll"):d.style.left=`${IT(n,ar,i-ar-m)}px`;let E=Math.max(0,a-ar*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${ar}px`,d.style.overflowY="scroll"):d.style.top=`${IT(t,ar,a-ar-p)}px`}},[t,n,r,i,a]),vT(()=>{if(o){let d=m=>{l.current?.contains(m.target)||WF(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),KF("div",{className:XF("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as yo,jsxs as CT}from"react/jsx-runtime";var $e="separator",ST=e=>"onSelect"in e,PT=$F.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=Ko(),a=Ci(),s=n.reduce((l,c)=>c?c===$e||ST(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return yo(TT,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:yo("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===$e)return!s[c-1]||s[c-1]===$e?null:yo("hr",{className:"context-menu-item-separator"},c);if(ST(l))return yo("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:CT("button",{type:"button",className:"context-menu-item",children:[yo("div",{className:"context-menu-item__label",children:l.label}),yo("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)),yo("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:CT("button",{type:"button",className:ZF("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[yo("div",{className:"context-menu-item__label",children:m}),yo("kbd",{className:"context-menu-item__shortcut",children:d?Ke(d):""})]})},c)})})})});import{useId as jF}from"react";import qF from"clsx";import{Fragment as JF,jsx as Ll,jsxs as kT}from"react/jsx-runtime";var $m=({border:e,style:n})=>Ll("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),jm=({label:e,border:n})=>{let t=jF(),o=kT(JF,{children:[e.icon&&Ll("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return kT("div",{className:qF("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&&Ll("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),Ll("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&Ll("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:Jt})]})};import Ya from"clsx";import xW from"react";import{CLASSES as wW,TOOL_TYPE as qP,arrayToMap as yW,isShallowEqual as Ap}from"@excalidraw/common";import{mutateElement as vW}from"@excalidraw/element";import{showSelectedShapeActions as IW}from"@excalidraw/element";import{ShapeCache as TW}from"@excalidraw/element";import{createIsolation as QF}from"jotai-scope";import Of from"react";import vo from"tunnel-rat";var Ff=Of.createContext(null),tt=()=>Of.useContext(Ff),e9=QF(),MT=()=>Of.useMemo(()=>({MainMenuTunnel:vo(),WelcomeScreenMenuHintTunnel:vo(),WelcomeScreenToolbarHintTunnel:vo(),WelcomeScreenHelpHintTunnel:vo(),WelcomeScreenCenterTunnel:vo(),FooterCenterTunnel:vo(),DefaultSidebarTriggerTunnel:vo(),DefaultSidebarTabTriggersTunnel:vo(),OverwriteConfirmDialogTunnel:vo(),tunnelsJotai:e9}),[]);import lr from"clsx";import{useRef as d9}from"react";import{Popover as sr}from"radix-ui";import{CLASSES as zT}from"@excalidraw/common";import{isArrowElement as FT}from"@excalidraw/element";import{forwardRef as AT}from"react";import LT from"clsx";import{jsx as DT}from"react/jsx-runtime";var t9=AT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>DT("div",{className:LT("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),n9=AT(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>DT("div",{className:LT("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Dt={Row:t9,Col:n9};import{isTransparent as _T}from"@excalidraw/common";import{shouldAllowVerticalAlign as o9,suppportsHorizontalAlign as r9,hasBoundTextElement as RT,isElbowArrow as i9,isImageElement as a9,isLinearElement as s9,isTextElement as l9,hasStrokeColor as NT,toolIsArrow as c9}from"@excalidraw/element";var BT=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return NT(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>NT(o.type))},OT=(e,n)=>_o(e.activeTool.type)||n.some(t=>_o(t.type)),qm=(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&&(RT(n[0])||RT(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:BT(e,n),backgroundColor:OT(e,n),fill:r==="bucketfill"||_o(r)&&!_T(e.currentItemBackgroundColor)||n.some(d=>_o(d.type)&&!_T(d.backgroundColor)),strokeWidth:i(Gb),freedrawMode:i(Ub),strokeStyle:i(su),sloppiness:i(su),roundness:i(Wb),arrowType:i(c9),arrowheads:i(ns),text:r==="text"||n.some(l9),textAlign:r==="text"||r9(n,t),verticalAlign:o9(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||se(t,e).some(d=>d.type==="freedraw"),align:!s&&pt(e,o),distribute:n.length>2,link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&a9(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&s9(n[0])&&!i9(n[0])}};import{Fragment as hn,jsx as j,jsxs as Se}from"react/jsx-runtime";var zf=lr([zT.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),HT=({renderAction:e})=>Se("fieldset",{children:[j("legend",{children:f("labels.layers")}),Se("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),GT=({renderAction:e,showDistribute:n})=>{let t=document.documentElement.getAttribute("dir")==="rtl";return Se("fieldset",{children:[j("legend",{children:f("labels.align")}),Se("div",{className:"buttonList",children:[t?Se(hn,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Se(hn,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),j("div",{style:{flexBasis:"100%",height:0}}),Se("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]})]})]})},UT=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=di(n,e),i=qm(e,r,n,o);return e.activeTool.type==="bucketfill"?Se("div",{className:"selected-shape-actions",children:[j("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Se("div",{className:"selected-shape-actions",children:[j("div",{children:i.strokeColor&&t("changeStrokeColor")}),i.backgroundColor&&j("div",{children:t("changeBackgroundColor")}),i.fill&&t("changeFillStyle"),i.strokeWidth&&t("changeStrokeWidth"),i.strokeStyle&&j(hn,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&j(hn,{children:t("changeSloppiness")}),i.roundness&&j(hn,{children:t("changeRoundness")}),i.arrowType&&j(hn,{children:t("changeArrowType")}),i.text&&Se(hn,{children:[j("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&j(hn,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&j(HT,{renderAction:t}),i.align&&j(GT,{renderAction:t,showDistribute:i.distribute}),i.showExtraActions&&Se("fieldset",{children:[j("legend",{children:f("labels.actions")}),Se("div",{className:"buttonList",children:[t("duplicateSelection"),t("deleteSelectedElements"),t("group"),t("ungroup"),i.link&&t("hyperlink"),i.cropEditor&&t("cropEditor"),i.lineEditor&&t("toggleLinearEditor")]})]})]})},WT=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let i=o.hasSelection||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",a=e.openPopup==="compactStrokeStyles";return i?j("div",{className:"compact-action-item",children:Se(sr.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:K1})}),a&&j(co,{className:zf,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Se("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&j(hn,{children:n("changeStrokeStyle")}),o.sloppiness&&j(hn,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},VT=({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 j("div",{className:"compact-action-item",children:Se(sr.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("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=lt(o,a,c=>FT(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>FT(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?Ho:l==="round"?Go:zo})()})}),s&&j(co,{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}=E0(),s=e.openPopup==="compactTextProperties";return j("div",{className:"compact-action-item",children:Se(sr.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("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:vx})}),e.openPopup==="compactTextProperties"&&j(co,{className:zf,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Se("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},XT=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let s=e.openPopup==="compactOtherProperties";return t.showExtraActions?j("div",{className:"compact-action-item",children:Se(sr.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[j(sr.Trigger,{asChild:!0,children:j("button",{type:"button",className:lr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:gx})}),s&&j(co,{className:zf,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Se("div",{className:"selected-shape-actions",children:[t.layers&&j(HT,{renderAction:n}),t.align&&j(GT,{renderAction:n,showDistribute:t.distribute}),Se("fieldset",{children:[j("legend",{children:f("labels.actions")}),Se("div",{className:"buttonList",children:[n("group"),n("ungroup"),t.linkSingleOnly&&n("hyperlink"),t.cropEditor&&n("cropEditor"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},m9=({renderAction:e,predicates:n})=>n.lineEditor?j("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,KT=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=di(n,e),a=qm(e,i,n,o),{container:s}=De();return Se("div",{className:"compact-shape-actions",children:[a.strokeColor&&j("div",{className:lr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&j("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),a.freedrawMode&&j("div",{className:"compact-action-item",children:t("changeFreedrawMode",{cycle:!0})}),j(WT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j(VT,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),a.lineEditor&&j("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Se(hn,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(YT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),a.showExtraActions&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),j(XT,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},ZT=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=di(n,e),a=qm(e,i,n,o),{container:s}=De(),l=d9(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 Se(ze,{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:[Se("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&j("div",{className:lr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&j("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),j(WT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),j(VT,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),j(m9,{renderAction:t,predicates:a}),a.text&&Se(hn,{children:[j("div",{className:"compact-action-item",children:t("changeFontFamily")}),j(YT,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),j(XT,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Se("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[j("div",{className:"compact-action-item",children:t("undo")}),j("div",{className:"compact-action-item",children:t("redo")}),b&&j("div",{className:"compact-action-item",children:t("duplicateSelection")}),g&&j("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},$T=({renderAction:e})=>j(Dt.Col,{gap:1,className:zT.ZOOM_ACTIONS,children:Se(Dt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),jT=({renderAction:e,className:n})=>Se("div",{className:`undo-redo-buttons ${n}`,children:[j("div",{className:"undo-button-container",children:j(ct,{label:f("buttons.undo"),children:e("undo")})}),j("div",{className:"redo-button-container",children:Se(ct,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),qT=({showExitZenModeBtn:e})=>j("button",{type:"button",className:lr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")}),JT=({actionManager:e})=>j("button",{type:"button",className:"disable-view-mode",onClick:()=>e.executeAction(Zr),children:$1});import p9 from"clsx";import{useState as u9,useEffect as h9}from"react";import{THEME as g9}from"@excalidraw/common";import{jsx as Hf,jsxs as f9}from"react/jsx-runtime";var Jm=({delay:e,theme:n})=>{let[t,o]=u9(!!e);return h9(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:f9("div",{className:p9("LoadingMessage",{"LoadingMessage--dark":n===g9.DARK}),children:[Hf("div",{children:Hf(lo,{})}),Hf("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as np,useEffect as wS}from"react";import Y9 from"clsx";import{KEYS as Vf,capitalizeString as yS}from"@excalidraw/common";import xS from"react";import{DropdownMenu as G9}from"radix-ui";import{CLASSES as U9}from"@excalidraw/common";import E9 from"clsx";import{useCallback as b9,useEffect as x9,useRef as w9}from"react";import{CLASSES as y9,EVENT as QT,KEYS as v9}from"@excalidraw/common";import{DropdownMenu as I9}from"radix-ui";import{jsx as Qm}from"react/jsx-runtime";var eS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=ge(),l=w9(null),c=Si({onClickOutside:n});Ti(l,b9(m=>{l.current?.closest(`.${y9.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),x9(()=>{if(!r)return;let m=u=>{u.key===v9.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(QT.KEYDOWN,m,p),()=>{document.removeEventListener(QT.KEYDOWN,m,p)}},[c,r]);let d=E9(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return Qm(ch.Provider,{value:{onSelect:o},children:Qm(I9.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?Qm(Dt.Col,{className:"dropdown-menu-container",children:e}):Qm(ze,{className:"dropdown-menu-container",padding:2,children:e})})})};eS.displayName="DropdownMenuContent";var tS=eS;import{jsx as S9}from"react/jsx-runtime";var T9=({children:e,className:n="",selected:t,...o})=>S9("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),nS=T9;import{DropdownMenu as C9}from"radix-ui";import{jsx as Gf}from"react/jsx-runtime";var oS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=rd(r);return Gf(C9.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Gf("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:Yo(i,a),title:l.title??l["aria-label"],children:Gf(Xo,{icon:e,shortcut:n,children:o})})})},Da=oS;oS.displayName="DropdownMenuItemLink";import{jsx as P9}from"react/jsx-runtime";var rS=()=>P9("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),iS=rS;rS.displayName="DropdownMenuSeparator";import{DropdownMenu as R9}from"radix-ui";import k9 from"clsx";import{DropdownMenu as M9}from"radix-ui";import{useCallback as A9,useState as aS}from"react";import{jsx as Wf}from"react/jsx-runtime";var Uf=-4,L9=4,sS=({children:e,className:n})=>{let t=ge(),o=k9(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=A9(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+Uf),l(Uf+8))}}},[]),[i,a]=aS(L9),[s,l]=aS(Uf);return Wf(M9.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?Wf(Dt.Col,{className:"dropdown-menu-container",children:e}):Wf(ze,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},lS=sS;sS.displayName="DropdownMenuSubContent";import{DropdownMenu as D9}from"radix-ui";import{jsx as cS,jsxs as _9}from"react/jsx-runtime";var dS=({children:e,icon:n,shortcut:t,className:o})=>_9(D9.SubTrigger,{className:`${Yo(o)} dropdown-menu__submenu-trigger`,children:[cS(Xo,{icon:n,shortcut:t,children:e}),cS("div",{className:"dropdown-menu__submenu-trigger-icon",children:q1})]}),mS=dS;dS.displayName="DropdownMenuSubTrigger";import pS from"react";var ep=e=>n=>{let t=pS.Children.toArray(n).find(o=>pS.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},uS=ep("DropdownMenuTrigger"),hS=ep("DropdownMenuContent"),gS=ep("DropdownMenuSubTrigger"),fS=ep("DropdownMenuSubContent");import{jsxs as N9}from"react/jsx-runtime";var tp=({children:e})=>{let n=gS(e),t=fS(e);return N9(R9.Sub,{children:[n,t]})};tp.Trigger=mS;tp.Content=lS;tp.displayName="DropdownMenuSub";var cr=tp;import B9 from"clsx";import{DropdownMenu as O9}from"radix-ui";import{jsx as F9}from"react/jsx-runtime";var ES=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=ge(),a=B9(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return F9(O9.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},bS=ES;ES.displayName="DropdownMenuTrigger";import{jsx as H9}from"react/jsx-runtime";var z9=e=>H9(Yt,{...e,icon:e.checked?Mc:Bc}),jn=z9;import{jsx as V9,jsxs as W9}from"react/jsx-runtime";var Mn=({children:e,open:n})=>{let t=uS(e),o=hS(e),r=o&&xS.isValidElement(o)?xS.cloneElement(o,{open:n}):o;return V9(G9.Root,{open:n,modal:!1,children:W9("div",{className:U9.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Mn.Trigger=bS;Mn.Content=tS;Mn.Item=Yt;Mn.ItemCheckbox=jn;Mn.ItemLink=Da;Mn.ItemCustom=nS;Mn.Group=Ss;Mn.Separator=iS;Mn.Sub=cr;var de=Mn;Mn.displayName="DropdownMenu";import{Fragment as Yf,jsx as Le,jsxs as _a}from"react/jsx-runtime";var X9=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=f("buttons.objectsSnapMode");return Le(K,{type:"toggle",icon:Fo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(kt,"ui")})},K9=({app:e})=>Le(K,{type:"button",icon:yi,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),vS=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=np(!1),[l,c]=np("rectangle"),[d,m]=np("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",y=["rectangle","diamond","ellipse"].map(H=>({type:H,icon:We[H].icon,title:yS(f(`toolBar.${H}`)),fillable:We[H].fillable})),w=["arrow","line"].map(H=>({type:H,icon:We[H].icon,title:yS(f(`toolBar.${H}`)),fillable:We[H].fillable})),[x,v]=np(0),T=36,C=4,P=7,A=P*T+(P-1)*C,L=T+C,_=x>=A+1*L,k=i&&x>=A+2*L,D=x>=A+3*L,O=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(H=>!(_&&H==="text"||(!i||k)&&H==="image"||D&&H==="frame")),Y=r&&Fi.includes(o.type),z=Y||O.includes(o.type),W=z?Y?We[o.type].icon:o.type==="text"?wn:o.type==="image"?Cr:o.type==="frame"?Un:o.type==="embeddable"?Oo:o.type==="laser"?Wn:o.type==="bucketfill"?Gn:cs:cs,Z={app:e,activeTool:o,hideShortcut:!0};return _a("div",{className:"mobile-toolbar",ref:H=>{H&&v(H.getBoundingClientRect().width)},children:[Le(Pd,{...Z}),Le(kd,{...Z,setAppState:t}),r?Le(Rs,{...Z}):Le(Md,{...Z}),Le(Os,{...Z}),!r&&Le(Oi,{app:e,options:y,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:H=>{(H==="rectangle"||H==="diamond"||H==="ellipse")&&(c(H),e.setActiveTool({type:H}))},displayedOption:y.find(H=>H.type===l)||y[0]}),!r&&Le(Oi,{app:e,options:w,activeTool:o,defaultOption:d,"data-testid":"toolbar-arrow",onToolChange:H=>{(H==="arrow"||H==="line")&&(m(H),e.setActiveTool({type:H}))},displayedOption:w.find(H=>H.type===d)||w[0]}),_&&Le(Ns,{...Z}),r&&k&&Le(K9,{app:e}),k&&Le(Bs,{...Z}),!r&&D&&Le(Dw,{...Z,hideShortcut:!0}),_a(de,{open:a,children:[Le(de.Trigger,{className:Y9("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:W}),_a(de.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&Fi.map(H=>Le(de.Item,{onSelect:()=>e.setActiveTool({type:H}),icon:We[H].icon,"data-testid":`toolbar-${H}`,selected:o.type===H,shortcut:Cd(H),disabled:Ze(e,H),children:f(`toolBar.${H}`)},H)),!r&&Le("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(kt)&&Le(de.Item,{onSelect:()=>n.executeAction(kt,"ui"),icon:Fo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:Ke("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&_a(Yf,{children:[r&&Le("div",{className:"App-toolbar__dropdown-divider"}),Le(de.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?No:so,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:Vf.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:wn,shortcut:Vf.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:Ze(e,"text"),children:f("toolBar.text")}),i&&!k&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Cr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:Ze(e,"image"),children:f("toolBar.image")}),!r&&!D&&Le(de.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Un,shortcut:Vf.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:Ze(e,"frame"),children:f("toolBar.frame")}),!r&&_a(Yf,{children:[Le(de.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Oo,"data-testid":"toolbar-embeddable",selected:g,disabled:Ze(e,"embeddable"),children:f("toolBar.embeddable")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Mr,shortcut:Hi("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:Ze(e,"autoshape"),children:f("toolBar.autoshape")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Wn,"data-testid":"toolbar-laser",selected:E,disabled:Ze(e,"laser"),children:f("toolBar.laser")}),Le(de.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Gn,"data-testid":"toolbar-bucketfill",selected:b,disabled:Ze(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&_a(Yf,{children:[Le("div",{className:"App-toolbar__divider"}),Le(X9,{actionManager:n,app:e})]})]})};import Z9 from"clsx";import{jsx as $9}from"react/jsx-runtime";var op=({children:e,side:n,className:t})=>$9("div",{className:Z9("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import j9 from"clsx";import{jsx as q9}from"react/jsx-runtime";var Ra=e=>e.penDetected?q9(K,{className:j9("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:yx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as IS,jsx as xt,jsxs as dr}from"react/jsx-runtime";var TS=({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}=tt(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=dr("div",{className:"excalidraw-ui-top-right",children:[i?.(!0,e)??(!e.viewModeEnabled&&dr(IS,{children:[l&&xt(Ra,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),xt(E.Out,{})]})),l&&e.viewModeEnabled&&d.isInteractionEnabled()&&xt(JT,{actionManager:t})]}),A=dr("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),xt(u.Out,{})]});return dr("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[A,P]})},b=()=>xt(vS,{app:d,actionManager:t,setAppState:o}),y=c&&e.scrolledOutside,w=l,x=l&&(!e.viewModeEnabled||w),v=y&&!e.openMenu&&!e.openSidebar?xt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...ci(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?xt(jm,{label:T,border:d.props.viewportStatusFrame?.border}):null;return dr(IS,{children:[a(),xt("div",{className:"App-welcome-screen",children:s&&xt(p.Out,{})}),x&&dr("div",{className:"App-bottom-bar",style:{marginBottom:cn+xo},"data-viewport-ui":"bottom",children:[v&&xt("div",{className:"floating-status-stack",children:v}),dr("div",{className:"App-bottom-bar__actions-row",children:[w&&dr(ze,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&xt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),xt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&xt(ZT,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&xt(ze,{className:"App-toolbar",children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&v&&xt("div",{className:"floating-status-stack",children:v}),C&&xt("div",{className:"viewport-status-frame__badge-row",children:C}),xt(op,{side:"top",className:"App-top-bar",children:g()})]})};import LS,{useLayoutEffect as DS,useRef as _S,useState as RS}from"react";import{newTextElement as NS}from"@excalidraw/element";import rz from"clsx";import{useEffect as iz,useState as az}from"react";import{KEYS as sz,queryFocusableElements as MS}from"@excalidraw/common";import{useCallback as J9,useState as Q9}from"react";var SS=()=>{let[e,n]=Q9(null),t=J9(o=>n(o),[]);return[e,t]};import CS from"clsx";import{useRef as ez}from"react";import{createPortal as tz}from"react-dom";import{KEYS as nz}from"@excalidraw/common";import{jsx as PS,jsxs as oz}from"react/jsx-runtime";var kS=e=>{let{closeOnClickOutside:n=!0}=e,t=Kc({className:CS("excalidraw-modal-container",e.portalContainerClassName)}),o=ez(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===nz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return tz(oz("div",{className:CS("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[PS("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),PS("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as rp,jsxs as AS}from"react/jsx-runtime";function lz(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var gn=e=>{let[n,t]=SS(),[o]=az(document.activeElement),{id:r}=De(),i=ge().formFactor==="phone";iz(()=>{if(!n)return;let l=MS(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===sz.TAB){let m=MS(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&d.shiftKey?(m[m.length-1].focus(),d.preventDefault()):u===m.length-1&&!d.shiftKey&&(m[0].focus(),d.preventDefault())}};return n.addEventListener("keydown",c),()=>n.removeEventListener("keydown",c)},[n,e.autofocus]);let a=Ue(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return rp(kS,{className:rz("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:lz(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:AS(ze,{ref:t,children:[e.title&&AS("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[rp("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&rp("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:Jt}),rp("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as Io,jsxs as ip}from"react/jsx-runtime";var cz=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}},dz=e=>{let n=_S(null),[t,o]=RS(null),{theme:r}=fe();DS(()=>{if(!e.spreadsheet){o(null);return}let a=hf(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 Tr(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=cz(e.chartType);return ip("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Io("div",{className:"ChartPreview__canvas",ref:n}),Io("div",{className:"ChartPreview__label",children:i})]})},mz=e=>{let n=_S(null),{theme:t}=fe();return DS(()=>{if(!e.rawText)return;let o=NS({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Tr([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]),ip("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Io("div",{className:"ChartPreview__canvas",ref:n}),Io("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},BS=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=It(),[i,a]=RS(Math.random()),s=LS.useCallback(()=>{a(Math.random())},[]),l=LS.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),Ne("paste","chart",m),t(),r()},d=m=>{let p=NS({text:m,x:0,y:0});o([p]),Ne("paste","chart","plaintext"),t(),r()};return Io(gn,{size:"regular",onCloseRequest:l,title:ip("div",{className:"PasteChartDialog__title",children:[Io("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),Io("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:Gn})]}),className:"PasteChartDialog",autofocus:!1,children:ip("div",{className:"container",children:[["bar","line","radar"].map(m=>Ea(e,m)?Io(dz,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&Io(mz,{rawText:n,onClick:d})]})})};import{Fragment as pz,jsx as OS,jsxs as uz}from"react/jsx-runtime";var Dl=({heading:e,children:n,...t})=>{let{id:o}=De(),r=OS("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return OS("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):uz(pz,{children:[r,n]})})};import{Popover as _l}from"radix-ui";import FS from"clsx";import ap,{useLayoutEffect as hz}from"react";import{supportsResizeObserver as gz,isShallowEqual as fz}from"@excalidraw/common";import{Fragment as Zf,jsx as wt,jsxs as Na}from"react/jsx-runtime";var Ez=4,bz=8,Xf=38,zS=21,xz=({shouldWrap:e,children:n,username:t})=>e?wt(ct,{label:t||"Unknown user",children:n}):wt(Zf,{children:n}),Kf=({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 wt(xz,{username:n.username,shouldWrap:r,children:s},t)},wz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],sp=ap.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=nt(),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]=ap.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=ap.useRef(null);hz(()=>{if(u.current){let C=A=>{g(A)};if(C(u.current.clientWidth),!gz)return;let P=new ResizeObserver(A=>{for(let L of A){let{width:_}=L.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=ap.useState(Ez*Xf),b=l?E-zS:E,y=Math.max(1,Math.min(8,Math.floor(b/Xf))),w=l?Math.max(0,y-1):y,x=c.slice(0,w),v=l?[...x,l]:x,T=v.map(C=>{let P=Kf({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?Na(_l.Root,{children:[wt(_l.Trigger,{asChild:!0,children:Na("div",{className:"UserList__pill",children:[P,wt("div",{className:"UserList__pill-chevron",children:j1})]})}),wt(_l.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Na(ze,{padding:2,children:[s.length>=bz&&wt(nd,{placeholder:f("quickSearch.placeholder"),onChange:m}),wt(od,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[wt("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(A=>Kf({actionManager:i,collaborator:A,socketId:A.socketId,withName:!0,isBeingFollowed:A.socketId===o}))]:[]}),a&&Na(Zf,{children:[wt("div",{className:"UserList__menu-divider"}),wt(_l.Close,{asChild:!0,children:wt("div",{className:"dropdown-menu",children:a})})]}),wt(_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?Na("div",{className:FS("UserList UserList_mobile",e),children:[wt("div",{className:"UserList_mobile__avatars",children:s.map(C=>Kf({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&Na(Zf,{children:[wt("div",{className:"UserList__menu-divider"}),a]})]}):wt("div",{className:"UserList__wrapper",ref:u,children:wt("div",{className:FS("UserList",e),style:{"--max-avatars":v.length+(l?zS/Xf: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||!fz(r,i,wz))return!1}return!0});import Rl from"clsx";import{jsx as HS}from"react/jsx-runtime";var GS=e=>HS(ct,{label:`${f("helpDialog.title")} \u2014 ?`,children:HS("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:wi})});import{jsx as Kt,jsxs as $f}from"react/jsx-runtime";var US=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=tt(),l=It();return $f("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&Kt("div",{className:Rl("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Kt(Dt.Col,{gap:2,children:$f(Dl,{heading:"canvasActions",children:[!e.viewModeOnly&&Kt(ct,{label:f("labels.viewMode"),children:Kt("div",{className:Rl("view-mode-button"),children:n.renderAction("viewMode")})}),Kt(ct,{label:f("buttons.smartZoom"),children:Kt("div",{className:Rl("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&Kt($T,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&Kt(jT,{renderAction:n.renderAction,className:Rl("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Kt(a.Out,{}),(r||o)&&Kt("div",{className:Rl("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:$f("div",{style:{position:"relative"},children:[o&&Kt(s.Out,{}),r&&Kt(GS,{onClick:()=>n.executeAction(Hr)})]})}),r&&Kt(qT,{showExitZenModeBtn:t})]})},WS=US;US.displayName="Footer";import{composeEventHandlers as kz}from"@excalidraw/common";import{useLayoutEffect as yz,useRef as vz}from"react";import{jsx as Iz}from"react/jsx-runtime";var ei=(e,n)=>{let t=qe(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=tt(),[,a]=i(t),s=vz({preferHost:!1,counter:0});return yz(()=>{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:Iz(n,{...r})};return o.displayName=e,o};var Qf={};ZM(Qf,{ChangeCanvasBackground:()=>eC,Export:()=>tC,Help:()=>JS,LiveCollaborationTrigger:()=>oC,LoadScene:()=>ZS,Preferences:()=>qn,PreferencesToggleGridModeItem:()=>Jf,SaveAsImage:()=>jS,SaveToActiveFile:()=>$S,SearchMenu:()=>qS,Socials:()=>nC,ToggleTheme:()=>QS});import Pz from"clsx";import{THEME as Bl}from"@excalidraw/common";var jf=qe({active:!1});async function VS({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{gt.set(jf,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import Tz from"clsx";import{jsx as YS,jsxs as Sz}from"react/jsx-runtime";var lp=function({onChange:e,value:n,choices:t,name:o}){return YS("div",{className:"RadioGroup",children:t.map(r=>Sz("div",{className:Tz("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[YS("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 Cz,jsx as Nl,jsxs as XS}from"react/jsx-runtime";var KS=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=ge();return XS(Cz,{children:[XS("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&Nl("div",{className:"dropdown-menu-item__icon",children:a}),Nl("label",{className:"dropdown-menu-item__text",children:Nl(Cs,{children:r})}),Nl(lp,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&Nl("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};KS.displayName="DropdownMenuItemContentRadio";var qf=KS;import{Fragment as mC,jsx as Ee,jsxs as Ol}from"react/jsx-runtime";var ZS=()=>{let{t:e}=Ae(),n=nt(),t=Ci();return n.isActionEnabled(Ui)?Ee(Yt,{icon:Ac,onSelect:async()=>{(!t.length||await VS({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:Ee(Qr,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>Ee("strong",{children:r}),br:()=>Ee("br",{})})}))&&n.executeAction(Ui)},"data-testid":"load-button",shortcut:Ke("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};ZS.displayName="LoadScene";var $S=()=>{let{t:e}=Ae(),n=nt();return n.isActionEnabled(zr)?Ee(Yt,{shortcut:Ke("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(zr),icon:Mx,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};$S.displayName="SaveToActiveFile";var jS=()=>{let e=Ue(),{t:n}=Ae();return Ee(Yt,{icon:Dx,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Ke("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};jS.displayName="SaveAsImage";var qS=e=>{let{t:n}=Ae(),t=nt();return Ee(Yt,{icon:Vn,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(pl)},shortcut:Ke("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};qS.displayName="SearchMenu";var JS=()=>{let{t:e}=Ae(),n=nt();return Ee(Yt,{"data-testid":"help-menu-item",icon:wi,onSelect:()=>n.executeAction(Hr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};JS.displayName="Help";var QS=e=>{let{t:n}=Ae(),t=fe(),o=nt(),r=Ke("toggleTheme"),i=yn();return o.isActionEnabled(vd)?e?.allowSystemTheme?Ee(qf,{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:Bl.LIGHT,label:ps,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:Bl.DARK,label:ms,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:G1,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):Ee(Yt,{onSelect:a=>{a.preventDefault(),o.executeAction(vd)},icon:t.theme===Bl.DARK?ps:ms,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Bl.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===Bl.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};QS.displayName="ToggleTheme";var eC=()=>{let{t:e}=Ae(),n=fe(),t=nt(),o=yn();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:Ol("div",{style:{marginTop:"0.75rem"},children:[Ee("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),Ee("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};eC.displayName="ChangeCanvasBackground";var tC=()=>{let{t:e}=Ae(),n=Ue();return Ee(Yt,{icon:us,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};tC.displayName="Export";var nC=()=>{let{t:e}=Ae();return Ol(mC,{children:[Ee(Da,{icon:Cx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),Ee(Da,{icon:kx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),Ee(Da,{icon:Px,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};nC.displayName="Socials";var oC=({onSelect:e,isCollaborating:n})=>{let{t}=Ae();return Ee(Yt,{"data-testid":"collab-button",icon:Lc,className:Pz({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};oC.displayName="LiveCollaborationTrigger";var rC=()=>{let{t:e}=Ae(),n=It(),t=fe();return Ee(jn,{checked:t.activeTool.locked,shortcut:Ke("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},iC=()=>{let{t:e}=Ae(),n=fe(),t=Ue();return Ee(qf,{name:"boxSelectionMode",icon:Bc,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")})},aC=()=>{let{t:e}=Ae(),n=nt(),t=fe();return Ee(jn,{checked:t.objectsSnapModeEnabled,shortcut:Ke("objectsSnapMode"),onSelect:o=>{n.executeAction(kt),o.preventDefault()},children:e("buttons.objectsSnapMode")})},sC=()=>{let{t:e}=Ae(),n=nt(),t=fe();return Ee(jn,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(Xs),o.preventDefault()},children:e("labels.arrowBinding")})},lC=()=>{let{t:e}=Ae(),n=nt(),t=fe();return Ee(jn,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(Ks),o.preventDefault()},children:e("labels.midpointSnapping")})},Jf=()=>{let{t:e}=Ae(),n=nt(),t=fe();return Ee(jn,{checked:t.gridModeEnabled,shortcut:Ke("gridMode"),onSelect:o=>{n.executeAction(ji),o.preventDefault()},children:e("labels.toggleGrid")})},cC=()=>{let{t:e}=Ae(),n=nt(),t=fe();return t.viewModeOnly?null:Ee(jn,{checked:t.viewModeEnabled,shortcut:Ke("viewMode"),onSelect:o=>{n.executeAction(Zr),o.preventDefault()},children:e("labels.viewMode")})},dC=()=>{let{t:e}=Ae(),n=nt(),t=fe();return Ee(jn,{checked:t.stats.open,shortcut:Ke("stats"),onSelect:o=>{n.executeAction(er),o.preventDefault()},children:e("stats.fullTitle")})},qn=({children:e,additionalItems:n})=>{let{t}=Ae();return Ol(cr,{children:[Ee(cr.Trigger,{icon:J1,children:t("labels.preferences")}),Ol(cr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||Ol(mC,{children:[Ee(iC,{}),Ee(rC,{}),Ee(aC,{}),Ee(Jf,{}),Ee(cC,{}),Ee(dC,{}),Ee(sC,{}),Ee(lC,{})]}),n]})]})};qn.ToggleToolLock=rC;qn.BoxSelectionMode=iC;qn.ToggleSnapMode=aC;qn.ToggleArrowBinding=sC;qn.ToggleMidpointSnapping=lC;qn.ToggleGridMode=Jf;qn.ToggleViewMode=cC;qn.ToggleElementProperties=dC;qn.displayName="Preferences";import{jsx as cp,jsxs as eE}from"react/jsx-runtime";var Mz=Object.assign(ei("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=tt(),o=ge(),r=fe(),i=yn(),a=Ue();return cp(t.In,{children:eE(de,{open:r.openMenu==="canvas",children:[cp(de.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Tx}),eE(de.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:kz(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&eE("fieldset",{className:"UserList-Wrapper",children:[cp("legend",{children:f("labels.collaborators")}),cp(sp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:de.Trigger,Item:de.Item,ItemLink:de.ItemLink,ItemCustom:de.ItemCustom,Group:de.Group,Separator:de.Separator,Sub:cr,DefaultItems:Qf}),_t=Mz;import Az from"clsx";import{forwardRef as Lz,useState as Dz}from"react";import{isPromiseLike as _z}from"@excalidraw/common";import{jsx as dp,jsxs as Rz}from"react/jsx-runtime";var mr=Lz(({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]=Dz(!1),E=async b=>{let y=t?.(b);if(_z(y)){let w=window.setTimeout(()=>{u(!0)},50);try{await y}catch(x){if(x instanceof hc)console.warn(x);else throw x}finally{clearTimeout(w),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,dp("button",{className:Az("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:Rz("div",{className:"ExcButton__contents",children:[g==="loading"?dp(lo,{className:"ExcButton__statusIcon"}):g==="success"&&dp("div",{className:"ExcButton__statusIcon",children:A1}),n&&dp("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as Ba,jsxs as Oz}from"react/jsx-runtime";var mp=({title:e,children:n,actionLabel:t,onClick:o})=>Oz("div",{className:"OverwriteConfirm__Actions__Action",children:[Ba("h4",{children:e}),Ba("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),Ba(mr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),Nz=()=>{let{t:e}=Ae(),n=nt(),t=Ue();return Ba(mp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(Hd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},Bz=()=>{let{t:e}=Ae(),n=nt();return Ba(mp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(Ws,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},tE=Object.assign(({children:e})=>Ba("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:Nz,SaveToDisk:Bz});import{jsx as pr,jsxs as pC}from"react/jsx-runtime";var pp=Object.assign(ei("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=tt(),[t,o]=Fe(jf);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return pr(n.In,{children:pr(gn,{onCloseRequest:r,title:!1,size:916,children:pC("div",{className:"OverwriteConfirm",children:[pr("h3",{children:t.title}),pC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[pr("div",{className:"OverwriteConfirm__Description__icon",children:L1}),pr("div",{children:t.description}),pr("div",{className:"OverwriteConfirm__Description__spacer"}),pr(mr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),pr(tE,{children:e})]})})})}),{Actions:tE,Action:mp});import{round as nP}from"@excalidraw/math";import tG from"clsx";import nG from"lodash.throttle";import{useEffect as oP,useMemo as gE,useState as oG,memo as rG}from"react";import{STATS_PANELS as yp}from"@excalidraw/common";import{getCommonBounds as iG}from"@excalidraw/element";import{getUncroppedWidthAndHeight as aG}from"@excalidraw/element";import{isImageElement as fE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as sG}from"@excalidraw/element";import{elementsAreInSameGroup as lG}from"@excalidraw/element";import{degreesToRadians as wC,radiansToDegrees as TC}from"@excalidraw/math";import{getBoundTextElement as yC}from"@excalidraw/element";import{isArrowElement as vC,isElbowArrow as qz}from"@excalidraw/element";import{updateBindings as IC}from"@excalidraw/element";import Yz from"clsx";import{useEffect as bC,useRef as hp,useState as Xz}from"react";import{EVENT as za,KEYS as Kz,cloneJSON as nE}from"@excalidraw/common";import{deepCopyElement as Zz}from"@excalidraw/element";import{CaptureUpdateAction as xC}from"@excalidraw/element";import{pointFrom as ur,pointRotateRads as up}from"@excalidraw/math";import{getBoundTextElement as Fz,getNonDeletedElements as zz,isBindingElement as Hz,unbindBindingElement as uC}from"@excalidraw/element";import{isFrameLikeElement as fC}from"@excalidraw/element";import{getSelectedGroupIds as Gz,getElementsInGroup as Uz,isInGroup as Wz}from"@excalidraw/element";import{getFrameChildren as Vz}from"@excalidraw/element";import{updateBindings as hC}from"@excalidraw/element";import{DRAGGING_THRESHOLD as gC}from"@excalidraw/common";var EC=.01,Fl=10,zt=(e,n)=>!(n==="angle"&&fC(e)),He=(e,n)=>{let t=e+n/2;return t-t%n},Oa=(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 ti=(e,n,t,o,r,i,a=!0)=>{if(Hz(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<gC&&Math.abs(n-t.y)<gC)return;uC(t,"start",o),uC(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]=up(ur(t.x,t.y),ur(c,d),t.angle),u=e-m,E=n-p,[g,b]=up(ur(e,n),ur(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),hC(l,o,r);let y=Fz(t,i);if(y){let w=s.get(y.id);w&&o.mutateElement(w,{x:y.x+u,y:y.y+E},{informMutation:a,isDragging:!1})}if(fC(t)){let w=Vz(i,t.id);w.forEach(x=>{let v=s.get(x.id);if(!v)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,A]=up(ur(x.x,x.y),ur(T,C),x.angle),L=Math.round(P+u),_=Math.round(A+E),[k,D]=up(ur(L,_),ur(T+u,C+E),-x.angle);o.mutateElement(v,{x:k,y:D},{informMutation:a,isDragging:!1}),hC(v,o,r,{simultaneouslyUpdated:zz(w)})})}},Fa=(e,n)=>{let o=Gz(n).map(r=>Uz(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!Wz(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as oE,jsxs as jz}from"react/jsx-runtime";var $z=({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=It(),u=Ue(),E=hp(null),g=hp(null),[b,y]=Xz(o.toString()),w=hp(null);w.current||(w.current={originalAppState:nE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),bC(()=>{let T=o.toString();y(T),w.current.lastUpdatedValue=T},[o]);let x=(T,C,P)=>{if(!w.current.updatePending)return!1;w.current.updatePending=!1;let A=Number(T);if(isNaN(A)){y(o.toString());return}let L=Number(A.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(L-_)>=EC)&&(w.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:L,property:s,originalAppState:P,setInputValue:k=>y(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:xC.IMMEDIATELY}))},v=hp({});return v.current.handleInputValue=x,bC(()=>{let T=E.current,C=v.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,w.current.originalElements,w.current.originalAppState),window.removeEventListener(za.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(za.POINTER_UP,C.onPointerUp,!1)}},[i]),i?jz("div",{className:Yz("drag-input-container",!i&&"disabled"),"data-testid":e,children:[oE("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,A=p.scene.getNonDeletedElements().reduce((z,W)=>(z.set(W.id,Zz(W)),z),new Map),L=r.map(z=>A.get(z.id)),_=nE(c),k=0,D=0,O=z=>{if(P&&A!==null&&L!==null){let W=z.clientX-P.x;W!==0&&(D+=W,Math.abs(D)>=d&&(D=Math.sign(D)*Math.floor(Math.abs(D)/d),k+=D,t({accumulatedChange:k,instantChange:D,originalElements:L,originalElementsMap:A,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:Z=>y(String(Z)),app:p,setAppState:u}),D=0))}P={x:z.clientX,y:z.clientY}},Y=()=>{window.removeEventListener(za.POINTER_MOVE,O,!1),p.syncActionResult({captureUpdate:xC.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:L,originalAppState:_}),P=null,k=0,D=0,L=null,A=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(za.POINTER_UP,Y,!1)};v.current.onPointerMove=O,v.current.onPointerUp=Y,window.addEventListener(za.POINTER_MOVE,O,!1),window.addEventListener(za.POINTER_UP,Y,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?oE(sd,{icon:n}):e}),oE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===Kz.ENTER&&(x(C.value,r,c),p.focusContainer())}},ref:E,value:b,onChange:T=>{w.current.updatePending=!0,y(T.target.value)},onFocus:T=>{T.target.select(),w.current.originalElements=r,w.current.originalAppState=nE(c)},onBlur:T=>{b?i&&x(T.target.value,w.current.originalElements,w.current.originalAppState):y(o.toString())},disabled:!i})]}):null},ut=$z;import{jsx as tH}from"react/jsx-runtime";var Jz=15,Qz=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!qz(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=wC(o);r.mutateElement(l,{angle:E}),IC(l,r,i.state);let g=yC(l,a);g&&!vC(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(TC(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=He(m,Jz)),m=m<0?m+360:m;let p=wC(m);r.mutateElement(l,{angle:p}),IC(l,r,i.state);let u=yC(l,a);u&&!vC(l)&&r.mutateElement(u,{angle:p})}},eH=({element:e,scene:n,appState:t,property:o})=>tH(ut,{label:"A",icon:_c,value:Math.round(TC(e.angle)%360*100)/100,elements:[e],dragInputCallback:Qz,editable:zt(e,"angle"),scene:n,appState:t,property:o}),SC=eH;import{jsx as oH}from"react/jsx-runtime";var CC=5,nH=({property:e,scene:n,appState:t,setAppState:o})=>oH(ut,{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?He(l.gridStep+CC*Math.sign(i),CC):l.gridStep+i),c?(c=zb(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),PC=nH;import{clamp as gp,round as rE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as fp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as kC,getNonDeletedElements as rH,getUncroppedWidthAndHeight as LC}from"@excalidraw/element";import{resizeSingleElement as MC}from"@excalidraw/element";import{isImageElement as DC}from"@excalidraw/element";import{isFrameLikeElement as iE}from"@excalidraw/element";import{getElementsInResizingFrame as aE}from"@excalidraw/element";import{replaceAllElementsInFrame as _C}from"@excalidraw/element";import{jsx as cH}from"react/jsx-runtime";var AC=10,iH=e=>e.type==="image",aH=({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||iH(u),b=u.width/u.height;if(s.croppingElementId===u.id){let y=p.get(u.id);if(!y||!DC(y)||!y.crop)return;let w=y.crop,x={...w},v=y.scale[0]===-1,T=y.scale[1]===-1,{width:C,height:P}=LC(y),A=w.naturalWidth/C,L=w.naturalHeight/P,_=v?w.width+w.x:w.naturalWidth-w.x,k=T?w.height+w.y:w.naturalHeight-w.y,D=kC*A,O=kC*L;if(i!==void 0){if(a==="width"){let H=i*A,re=gp(H,D,_);x={...x,width:re,x:v?w.x+w.width-re:w.x}}else if(a==="height"){let H=i*L,re=gp(H,O,k);x={...x,height:re,y:T?w.y+w.height-re:w.y}}c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}let Y=a==="width"?l:0,z=a==="height"?l:0,W=gp(w.width+Y,D,_),Z=gp(w.height+z,D,k);x={...w,x:v?w.x+w.width-W:w.x,y:T?w.y+w.height-Z:w.y,width:W,height:Z},c.mutateElement(y,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}if(i!==void 0){let y=Math.max(a==="width"?i:g?i*b:u.width,fp),w=Math.max(a==="height"?i:g?i/b:u.height,fp);if(MC(y,w,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),iE(E)){let x=aE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),v=_C(c.getElementsIncludingDeleted(),x,E);c.replaceAllElements(v)}return}{let y=a==="width"?e:0,w=a==="height"?e:0,x=Math.max(0,u.width+y);a==="width"&&(r?x=He(x,AC):x=Math.round(x));let v=Math.max(0,u.height+w);if(a==="height"&&(r?v=He(v,AC):v=Math.round(v)),g&&(a==="width"?v=Math.round(x/b*100)/100:x=Math.round(v*b*100)/100),v=Math.max(fp,v),x=Math.max(fp,x),MC(x,v,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),iE(E)){let T=rH(aE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},sH=({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=aE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=_C(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},lH=({property:e,element:n,scene:t,appState:o})=>{let r=rE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&DC(n)&&n.crop){let{width:i,height:a}=LC(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=rE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=rE(n.crop.height*s,2)}}return cH(ut,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:aH,value:r,editable:zt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:sH})},sE=lH;import{getBoundTextElement as dH,redrawTextBoundingBox as mH}from"@excalidraw/element";import{hasBoundTextElement as pH,isTextElement as NC}from"@excalidraw/element";import{jsx as fH}from"react/jsx-runtime";var RC=4,uH=4,hH=({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||!NC(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),RC);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,RC),t&&(l=He(l,uH))}l&&(r.mutateElement(s,{fontSize:l}),mH(s,r.getContainerElement(s),r))}},gH=({element:e,scene:n,appState:t,property:o})=>{let r=NC(e)?e:pH(e)?dH(e,n.getNonDeletedElementsMap()):null;return r?fH(ut,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:hH,icon:kr,appState:t,scene:n,property:o}):null},BC=gH;import{degreesToRadians as OC,radiansToDegrees as HC}from"@excalidraw/math";import{getBoundTextElement as FC}from"@excalidraw/element";import{isArrowElement as zC}from"@excalidraw/element";import{isInGroup as lE}from"@excalidraw/element";import{jsx as wH}from"react/jsx-runtime";var EH=15,bH=({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&&!lE(c)&&zt(c,r)),l=n.filter(c=>!lE(c)&&zt(c,r));if(o!==void 0){let c=OC(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=FC(d,a);m&&!zC(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(HC(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=He(E,EH)),E=E<0?E+360:E;let g=OC(E);i.mutateElement(d,{angle:g});let b=FC(d,a);b&&!zC(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},xH=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!lE(l)&&zt(l,"angle")),i=r.map(l=>Math.round(HC(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>zt(l,"angle"));return wH(ut,{label:"A",icon:_c,value:a,elements:e,dragInputCallback:bH,editable:s,appState:t,scene:n,property:o})},GC=xH;import{pointFrom as YC}from"@excalidraw/math";import{useMemo as vH}from"react";import{MIN_WIDTH_OR_HEIGHT as hr}from"@excalidraw/common";import{getElementsInResizingFrame as cE,getNonDeletedElements as IH,isFrameLikeElement as dE,replaceAllElementsInFrame as ZC,updateBoundElements as TH}from"@excalidraw/element";import{rescalePointsInElement as SH,resizeSingleElement as XC}from"@excalidraw/element";import{getBoundTextElement as CH,handleBindTextResize as PH}from"@excalidraw/element";import{isTextElement as $C}from"@excalidraw/element";import{MIME_TYPES as ni}from"@excalidraw/common";import{getNonDeletedElements as UC}from"@excalidraw/element";var Ep=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=UC(Sr(e,null,{deleteInvisibleElements:!0})),l=pi(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return xc(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}})},WC=async e=>{let{mimeType:n=ni.png,quality:t}=e;n===ni.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ni.png}" mimeType`),n==="image/jpg"&&(n=ni.jpg),n===ni.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ni.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Ep(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===ni.png&&e.appState?.exportEmbedScene&&(a=await qb({blob:a,metadata:rs(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},VC=async({elements:e,appState:n=Ro(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=UC(Sr(e,null,{deleteInvisibleElements:!0})),d={...pi(n,null),exportPadding:o};return Tr(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},yH=async e=>{if(e.type==="svg"){let n=await VC(e);await ho(n.outerHTML)}else if(e.type==="png")await Fd(WC(e));else if(e.type==="json")await Bd(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as QRe}from"@excalidraw/element";import{getCommonBounds as bp}from"@excalidraw/element";import{jsx as _H}from"react/jsx-runtime";var Ha=10,kH=(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,...SH(o,a,s,!1),...$C(o)?{fontSize:o.fontSize*t}:{}}},MH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=kH(e,n,o,i);s.mutateElement(r,c);let d=CH(i,a);if(d){let m=d.fontSize*o;TH(r,s);let p=l.get(d.id);p&&$C(p)&&(s.mutateElement(p,{fontSize:m}),PH(r,s,t==="width"?"e":"s",!0))}},KC=(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];MH(r[0],r[1],i,d,u,p,l,c)}},AH=({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=Fa(n,o);if(i!==void 0){for(let g of m){let b=Oa(g,d,t);if(b.length>1){let y=b.map(D=>D.latest),w=b.map(D=>D.original),[x,v,T,C]=bp(w),P=T-x,A=C-v,L=P/A,_=Math.max(hr,s==="width"?Math.max(0,i):P),k=Math.max(hr,s==="height"?Math.max(0,i):A);KC(_,k,A,L,YC(x,v),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&zt(w,s)){let v=s==="width"?Math.max(0,i):w.width;s==="width"&&(r?v=He(v,Ha):v=Math.round(v));let T=s==="height"?Math.max(0,i):w.height;if(s==="height"&&(r?T=He(T,Ha):T=Math.round(T)),v=Math.max(hr,v),T=Math.max(hr,T),XC(v,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),dE(w)){let C=cE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()),P=ZC(a.getElementsIncludingDeleted(),C,w);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=Oa(g,d,t);if(b.length>1){let y=b.map(D=>D.latest),w=b.map(D=>D.original),[x,v,T,C]=bp(w),P=T-x,A=C-v,L=P/A,_=Math.max(0,P+p);s==="width"&&(r?_=He(_,Ha):_=Math.round(_));let k=Math.max(0,A+u);s==="height"&&(r?k=He(k,Ha):k=Math.round(k)),_=Math.max(hr,_),k=Math.max(hr,k),KC(_,k,A,L,YC(x,v),s,y,w,t,a)}else{let[y]=b,w=y?.latest,x=y?.original;if(w&&x&&zt(w,s)){let v=Math.max(0,x.width+p);s==="width"&&(r?v=He(v,Ha):v=Math.round(v));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=He(T,Ha):T=Math.round(T)),v=Math.max(hr,v),T=Math.max(hr,T),XC(v,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),dE(w)){let C=IH(cE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},LH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&dE(a)){let s=cE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=ZC(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=vH(()=>o.map(c=>{let d=Oa(c,t);if(d.length>1){let[p,u,E,g]=bp(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 _H(ut,{label:e==="width"?"W":"H",elements:n,dragInputCallback:AH,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:LH})},mE=DH;import{getBoundTextElement as RH,redrawTextBoundingBox as jC}from"@excalidraw/element";import{hasBoundTextElement as NH,isTextElement as BH}from"@excalidraw/element";import{isInGroup as OH}from"@excalidraw/element";import{jsx as UH}from"react/jsx-runtime";var qC=4,FH=4,zH=(e,n)=>e.reduce((t,o)=>{if(!o||OH(o))return t;if(BH(o))return t.push(o),t;if(NH(o)){let r=RH(o,n);if(r)return t.push(r),t}return t},[]),HH=({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),qC);for(let l of a)r.mutateElement(l,{fontSize:s}),jC(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,qC);t&&(E=He(E,FH)),r.mutateElement(d,{fontSize:E}),jC(d,r.getContainerElement(d),r)}r.triggerUpdate()}},GH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=zH(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 UH(ut,{label:"F",icon:kr,elements:i,dragInputCallback:HH,value:s,editable:l,scene:n,property:o,appState:t})},JC=GH;import{pointFrom as gr,pointRotateRads as xp}from"@excalidraw/math";import{useMemo as WH}from"react";import{isTextElement as VH}from"@excalidraw/element";import{getCommonBounds as pE}from"@excalidraw/element";import{jsx as $H}from"react/jsx-runtime";var YH=(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]=xp(gr(l.x,l.y),gr(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;ti(u,E,l,i,a,r,!1)}},XH=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=pE(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&&(!VH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,y]=xp(gr(u.x,u.y),gr(E,g),u.angle);ti(b+c,y+d,p,r,i,o,!1)}}},KH=({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 Fa(n,s)){let E=Oa(u,c,t);if(E.length>1){let[g,b,,]=pE(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&&zt(b,i)){let[y,w]=[g.x+g.width/2,g.y+g.height/2],[x,v]=xp(gr(g.x,g.y),gr(y,w),g.angle);ti(i==="x"?r:x,i==="y"?r:v,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?He(e,Fl):e;YH(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},ZH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=WH(()=>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]=pE(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]=xp(gr(d.x,d.y),gr(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 $H(ut,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:KH,value:s,property:e,scene:r,appState:i})},uE=ZH;import{clamp as zl,pointFrom as wp,pointRotateRads as eP,round as QC}from"@excalidraw/math";import{getFlipAdjustedCropPosition as jH,getUncroppedWidthAndHeight as qH}from"@excalidraw/element";import{isImageElement as tP}from"@excalidraw/element";import{jsx as eG}from"react/jsx-runtime";var JH=({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]=eP(wp(m.x,m.y),wp(p,u),m.angle);if(l.croppingElementId===m.id){let v=d.get(m.id);if(!v||!tP(v)||!v.crop)return;let T=v.crop,C=T,P=v.scale[0]===-1,A=v.scale[1]===-1,{width:L,height:_}=qH(v);if(i!==void 0){if(a==="x"){let O=i*(T.naturalWidth/L);P?C={...T,x:zl(T.naturalWidth-O-T.width,0,T.naturalWidth-T.width)}:C={...T,x:zl(i*(T.naturalWidth/L),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:zl(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),s.mutateElement(v,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),D=(a==="y"?n:0)*(A?-1:1);C={...T,x:zl(T.x+k,0,T.naturalWidth-T.width),y:zl(T.y+D,0,T.naturalHeight-T.height)},s.mutateElement(v,{crop:C});return}if(i!==void 0){ti(a==="x"?i:E,a==="y"?i:g,m,s,c.state,o);return}let b=a==="x"?e:0,y=a==="y"?e:0,w=a==="x"?Math.round(r?He(m.x+b,Fl):E+b):E,x=a==="y"?Math.round(r?He(m.y+y,Fl):g+y):g;ti(w,x,m,s,c.state,o)},QH=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=eP(wp(n.x,n.y),wp(n.x+n.width/2,n.y+n.height/2),n.angle),a=QC(e==="x"?r:i,2);if(o.croppingElementId===n.id&&tP(n)&&n.crop){let s=jH(n);s&&(a=QC(e==="x"?s.x:s.y,2))}return eG(ut,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:JH,scene:t,value:a,property:e,appState:o})},hE=QH;import{Fragment as EE,jsx as te,jsxs as Ht}from"react/jsx-runtime";var cG=50,Hl=e=>{let n=Ko(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=or(e.app);return te(dG,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Be=({children:e,columns:n=1,heading:t,style:o,...r})=>te("div",{className:tG("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Be.displayName="StatsRow";var vp=({children:e,order:n,style:t,...o})=>te("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});vp.displayName="StatsRows";Hl.StatsRow=Be;Hl.StatsRows=vp;var dG=rG(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),c=s.getNonDeletedElementsMap(),d=Ue(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&fE(m),E=u?aG(m):null,[g,b]=oG({width:0,height:0}),y=gE(()=>nG(v=>{let T=iG(v);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},cG),[]);oP(()=>{y(l)},[i,l,y]),oP(()=>()=>y.cancel(),[y]);let w=gE(()=>Fa(o,r),[o,r]),x=gE(()=>sG(o),[o]);return te("div",{className:"exc-stats",children:Ht(ze,{padding:3,children:[Ht("div",{className:"title",children:[te("h2",{children:f("stats.title")}),te("div",{className:"close",onClick:n,children:Jt})]}),Ht(Ms,{label:te("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&yp.generalStats),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^yp.generalStats}})),children:[Ht(vp,{children:[te(Be,{heading:!0,children:f("stats.scene")}),Ht(Be,{columns:2,children:[te("div",{children:f("stats.shapes")}),te("div",{children:l.length})]}),Ht(Be,{columns:2,children:[te("div",{children:f("stats.width")}),te("div",{children:g.width})]}),Ht(Be,{columns:2,children:[te("div",{children:f("stats.height")}),te("div",{children:g.height})]}),a&&Ht(EE,{children:[te(Be,{heading:!0,children:"Canvas"}),te(Be,{children:te(PC,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&te("div",{id:"elementStats",style:{marginTop:12},children:te(Ms,{label:te("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&yp.elementProperties),openTrigger:()=>d(v=>({stats:{open:!0,panels:v.stats.panels^yp.elementProperties}})),children:Ht(vp,{children:[m&&Ht(EE,{children:[u&&te(Be,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&fE(m)&&E&&Ht(Be,{columns:2,children:[te("div",{children:f("stats.width")}),te("div",{children:nP(E.width,2)})]}),r.croppingElementId&&fE(m)&&E&&Ht(Be,{columns:2,children:[te("div",{children:f("stats.height")}),te("div",{children:nP(E.height,2)})]}),te(Be,{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}`)}),te(Be,{children:te(hE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),te(Be,{children:te(hE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),te(Be,{children:te(sE,{property:"width",element:m,scene:s,appState:r})}),te(Be,{children:te(sE,{property:"height",element:m,scene:s,appState:r})}),te(Be,{children:te(SC,{property:"angle",element:m,scene:s,appState:r})}),te(Be,{children:te(BC,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Ht(EE,{children:[lG(p)&&te(Be,{heading:!0,children:f("element.group")}),Ht(Be,{columns:2,style:{margin:"0.3125rem 0"},children:[te("div",{children:f("stats.shapes")}),te("div",{children:o.length})]}),te(Be,{children:te(uE,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(uE,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(mE,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(mE,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),te(Be,{children:te(GC,{property:"angle",elements:p,scene:s,appState:r})}),te(Be,{children:te(JC,{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 vG,useEffect as iP,useState as aP}from"react";import{normalizeLink as IG,KEYS as yE}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as TG,getLinkIdAndTypeFromSelection as SG}from"@excalidraw/element";import mG from"clsx";import{jsx as Ip,jsxs as uG}from"react/jsx-runtime";var pG=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return uG("button",{className:mG("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Ip("div",{style:a?{visibility:"hidden"}:{},children:o}),Ip("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Ip("div",{style:{position:"absolute",inset:0},children:Ip(lo,{})})]})},bE=pG;import xE from"clsx";import{forwardRef as EG,useRef as bG,useImperativeHandle as xG,useLayoutEffect as wG,useState as yG}from"react";import hG from"clsx";import{composeEventHandlers as gG}from"@excalidraw/common";import{jsx as fG}from"react/jsx-runtime";var fn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>fG("button",{onClick:gG(i.onClick,a=>{n()}),type:e,className:hG("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as wE,jsxs as rP}from"react/jsx-runtime";var Tp=EG(({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=bG(null);xG(p,()=>u.current),wG(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=yG(!1);return rP("div",{className:xE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&wE("div",{className:"ExcTextField__label",children:n}),rP("div",{className:xE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[wE("input",{className:xE({"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&&wE(fn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?D1:Ar})]})]})});import{jsx as Ga,jsxs as Sp}from"react/jsx-runtime";var CG=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=TG})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=aP(a),[c,d]=aP(!1);iP(()=>{let p=se(i,t),u=a;if(p.length>0&&r){let E=SG(p,t);E&&(u=IG(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=vG(()=>{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 iP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===yE.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===yE.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),Sp("div",{className:"ElementLinkDialog",children:[Sp("div",{className:"ElementLinkDialog__header",children:[Ga("h2",{children:f("elementLink.title")}),Ga("p",{children:f("elementLink.desc")})]}),Sp("div",{className:"ElementLinkDialog__input",children:[Ga(Tp,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===yE.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&Ga(K,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Pr})]}),Sp("div",{className:"ElementLinkDialog__actions",children:[Ga(bE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),Ga(bE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},sP=CG;import PG,{useState as kG}from"react";import{Fragment as MG,jsx as vE}from"react/jsx-runtime";var lP=({children:e,onClose:n})=>{let[t,o]=kG(!!e),{container:r}=De(),i=PG.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return vE(MG,{children:t&&vE(gn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:vE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import cP,{useMemo as OG}from"react";import dP from"clsx";import{isDarwin as mP,isFirefox as FG,isWindows as zG}from"@excalidraw/common";import{KEYS as Ua}from"@excalidraw/common";import{SHAPES as HG}from"@excalidraw/element/shapes";import{isFirefox as AG,KEYS as IE}from"@excalidraw/common";import{SHAPES as LG}from"@excalidraw/element/shapes";import{Fragment as BG,jsx as Ge,jsxs as oi}from"react/jsx-runtime";var DG=e=>oi(BG,{children:[Ge("h3",{children:e.title}),Ge("div",{className:"HelpDialog__islands-container",children:e.children})]}),TE=e=>oi("div",{className:`HelpDialog__island ${e.className}`,children:[Ge("h4",{className:"HelpDialog__island-title",children:e.caption}),Ge("div",{className:"HelpDialog__island-content",children:e.children})]});function*_G(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var RG=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),yt=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ge(NG,{children:RG(a)},a)));return oi("div",{className:"HelpDialog__shortcut",children:[Ge("div",{children:e}),Ge("div",{className:"HelpDialog__key-container",children:[..._G(o,t?f("helpDialog.or"):null)]})]})},NG=e=>Ge("kbd",{className:"HelpDialog__key",...e});function SE(){return oi(DG,{title:f("helpDialog.shortcuts"),children:[oi(TE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ge(yt,{label:f("toolBar.hand"),shortcuts:[IE.H]}),LG.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ge(yt,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ge(yt,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ge(yt,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),oi(TE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ge(yt,{label:f("helpDialog.smartZoom"),shortcuts:[IE.F]}),Ge(yt,{label:f("helpDialog.dragToZoom"),shortcuts:[`${IE.Z}+${f("helpDialog.drag")}`]}),Ge(yt,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),oi(TE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ge(yt,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ge(yt,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ge(yt,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ge(yt,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(qo||AG)&&Ge(yt,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ge(yt,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ge(yt,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ge(yt,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ge(yt,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ge(yt,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as uP,jsx as $,jsxs as ri}from"react/jsx-runtime";var GG=e=>ri(uP,{children:[$("h3",{children:e.title}),$("div",{className:"HelpDialog__islands-container",children:e.children})]}),CE=e=>ri("div",{className:`HelpDialog__island ${e.className}`,children:[$("h4",{className:"HelpDialog__island-title",children:e.caption}),$("div",{className:"HelpDialog__island-content",children:e.children})]});function*UG(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var WG=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),q=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>$(VG,{children:WG(a)},a)));return ri("div",{className:"HelpDialog__shortcut",children:[$("div",{children:e}),$("div",{className:"HelpDialog__key-container",children:[...UG(o,t?f("helpDialog.or"):null)]})]})},VG=e=>$("kbd",{className:"HelpDialog__key",...e}),pP=({onClose:e})=>{let[n,t]=cP.useState(!1),o=cP.useCallback(()=>{e&&e()},[e]),r=OG(()=>n?$("button",{className:dP("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):$("button",{className:dP("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return $(uP,{children:$(gn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?ri(GG,{title:f("helpDialog.shortcuts"),children:[ri(CE,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[$(q,{label:f("toolBar.hand"),shortcuts:[Ua.H]}),HG.map(({value:i,key:a})=>$(q,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),$(q,{label:f("toolBar.frame"),shortcuts:[Ua.F]}),$(q,{label:f("labels.eyeDropper"),shortcuts:[Ua.I,"Shift+S","Shift+I"]}),$(q,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),$(q,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),$(q,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),$(q,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),$(q,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),$(q,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),$(q,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),$(q,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),$(q,{label:f("toolBar.lock"),shortcuts:[Ua.Q]}),$(q,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),$(q,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),$(q,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),ri(CE,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[$(q,{label:f("helpDialog.smartZoom"),shortcuts:[Ua.F]}),$(q,{label:f("helpDialog.dragToZoom"),shortcuts:[`${Ua.Z}+${f("helpDialog.drag")}`]}),$(q,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),$(q,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),$(q,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),$(q,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),$(q,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),$(q,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),$(q,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),$(q,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),$(q,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),$(q,{label:f("search.title"),shortcuts:[Ke("searchMenu")]})]}),ri(CE,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[$(q,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),$(q,{label:f("labels.delete"),shortcuts:[N("Delete")]}),$(q,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),$(q,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),$(q,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),$(q,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),$(q,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),$(q,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),$(q,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),$(q,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(qo||FG)&&$(q,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),$(q,{label:f("labels.sendToBack"),shortcuts:[mP?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),$(q,{label:f("labels.bringToFront"),shortcuts:[mP?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),$(q,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),$(q,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),$(q,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),$(q,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),$(q,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),$(q,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),$(q,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+R")]}),$(q,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),$(q,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),$(q,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),$(q,{label:f("buttons.redo"),shortcuts:zG?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),$(q,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),$(q,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),$(q,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),$(q,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),$(q,{label:f("labels.showStroke"),shortcuts:[N("S")]}),$(q,{label:f("labels.showBackground"),shortcuts:[N("G")]}),$(q,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),$(q,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),$(q,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):$(SE,{})})})};import{useEffect as fP,useRef as EP,useState as ii}from"react";import{DEFAULT_EXPORT_PADDING as jG,EXPORT_IMAGE_TYPES as PE,isFirefox as qG,EXPORT_SCALES as JG,cloneJSON as bP}from"@excalidraw/common";import{useCallback as YG,useRef as XG,useState as KG}from"react";var ZG=2e3,hP=()=>{let[e,n]=KG(null),t=XG(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},ZG)},r=YG(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import $G from"clsx";import{jsx as gP}from"react/jsx-runtime";var Gl=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>gP("div",{className:$G("Switch",{toggled:t,disabled:r}),children:gP("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 Oe,jsxs as fr}from"react/jsx-runtime";var QG=()=>fr("div",{children:[Oe("h3",{children:f("canvasError.cannotShowPreview")}),Oe("p",{children:Oe("span",{children:f("canvasError.canvasTooBig")})}),fr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),eU=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=Me(n,e),[l,c]=ii(i),[d,m]=ii(s),[p,u]=ii(e.exportBackground),[E,g]=ii(e.exportEmbedScene),[b,y]=ii(e.exportScale),w=EP(null),x=EP(0),[v,T]=ii(null),{onCopy:C,copyStatus:P,resetCopyStatus:A}=hP();fP(()=>{A()},[l,p,a,b,E,A]);let{exportedElements:L,exportingFrame:_}=Or(n,e,d);return fP(()=>{let k=w.current;if(!k)return;let D=k.offsetWidth,O=k.offsetHeight;if(!D)return;let Y=++x.current,z=()=>Y!==x.current;return Ep({elements:L,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:jG,maxWidthOrHeight:Math.max(D,O),exportingFrame:_}).then(async W=>{if(!z()){try{await ls(W)}catch(Z){throw Z.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):Z}z()||(T(null),k.replaceChildren(W))}}).catch(W=>{z()||(console.error(W),T(W))}),()=>{x.current+=1}},[e,t,L,_,l,p,a,b,E]),fr("div",{className:"ImageExportModal",children:[Oe("h3",{children:f("imageExportDialog.header")}),fr("div",{className:"ImageExportModal__preview",children:[Oe("div",{className:"ImageExportModal__preview__canvas",ref:w,children:v&&Oe(QG,{})}),Oe("div",{className:"ImageExportModal__preview__filename",children:!mi&&Oe("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction(Fh,"ui",k.target.value)}})})]}),fr("div",{className:"ImageExportModal__settings",children:[Oe("h3",{children:f("imageExportDialog.header")}),s&&Oe(Ul,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Oe(Gl,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),Oe(Ul,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Oe(Gl,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(zh,"ui",k)}})}),Oe(Ul,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Oe(Gl,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(ry,"ui",k)}})}),Oe(Ul,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Oe(Gl,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(Hd,"ui",k)}})}),Oe(Ul,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Oe(lp,{name:"exportScale",value:b,onChange:k=>{y(k),o.executeAction(ny,"ui",k)},choices:JG.map(k=>({value:k,label:`${k}\xD7`}))})}),fr("div",{className:"ImageExportModal__settings__buttons",children:[Oe(mr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(PE.png,L,{exportingFrame:_}),icon:_u,children:f("imageExportDialog.button.exportToPng")}),Oe(mr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(PE.svg,L,{exportingFrame:_}),icon:_u,children:f("imageExportDialog.button.exportToSvg")}),(qo||qG)&&Oe(mr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(PE.clipboard,L,{exportingFrame:_}),C()},icon:P1,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Ul=({label:e,children:n,tooltip:t,name:o})=>fr("div",{className:"ImageExportModal__settings__setting",title:e,children:[fr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Oe(ct,{label:t,long:!0,children:M1})]}),Oe("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),xP=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=ii(()=>({appStateSnapshot:bP(n),elementsSnapshot:bP(e)}));return Oe(gn,{onCloseRequest:i,size:"wide",title:!1,children:Oe(eU,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import UU from"clsx";import{CANVAS_SEARCH_TAB as FP,DEFAULT_SIDEBAR as WU}from"@excalidraw/common";import tU from"clsx";import nU from"lodash.debounce";import{Fragment as oU,memo as rU,useEffect as Wl,useMemo as wP,useRef as kE,useState as yP}from"react";import{CLASSES as iU,EVENT as aU,FONT_FAMILY as ME,FRAME_STYLE as AE,getLineHeight as sU}from"@excalidraw/common";import{getCommonBounds as lU,isElementCompletelyInViewport as cU}from"@excalidraw/element";import{measureText as Vl}from"@excalidraw/element";import{KEYS as Wa,randomInteger as vP,addEventListener as dU,getFontString as Cp}from"@excalidraw/common";import{newTextElement as mU}from"@excalidraw/element";import{isTextElement as CP,isFrameLikeElement as Pp}from"@excalidraw/element";import{getDefaultFrameName as PP}from"@excalidraw/element/frame";import{Fragment as yU,jsx as ht,jsxs as An}from"react/jsx-runtime";var pU=qe(""),LE=qe(null),uU=350,kP=()=>{let e=It(),n=Ue(),t=kE(null),[o,r]=Fe(pU),i=o.trim(),[a,s]=yP(!1),[l,c]=yP({nonce:null,items:[]}),d=kE(null),m=kE(void 0),[p,u]=Fe(LE),E=e.scene.getNonDeletedElementsMap();Wl(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,SP(i,e,(x,v)=>{c({nonce:vP(),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)};Wl(()=>{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]),Wl(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let v=e.state.zoom.value,T=mU({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:Pp(x.element)?AE.nameFontSize:x.element.fontSize,fontFamily:Pp(x.element)?ME.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,A=P*v<C;if(!cU([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())||A){let L=A&&P<C?"contain":"scale-down";e.viewport.setViewport({target:lU([T]),fit:L,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),Wl(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let y=Si({goToNextItem:g,goToPreviousItem:b,searchMatches:l});Wl(()=>{let x=v=>{if(v.key===Wa.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),n({openSidebar:null});return}if(v[Wa.CTRL_OR_CMD]&&v.key===Wa.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&y.searchMatches.items.length&&(v.key===Wa.ENTER&&(v.stopPropagation(),y.goToNextItem()),v.key===Wa.ARROW_UP?(v.stopPropagation(),y.goToPreviousItem()):v.key===Wa.ARROW_DOWN&&(v.stopPropagation(),y.goToNextItem()))};return dU(window,aU.KEYDOWN,x,{capture:!0,passive:!1})},[n,y,e]);let w=`${l.items.length} ${l.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return An("div",{className:"layer-ui__search",children:[An("div",{className:"layer-ui__search-header",children:[ht(Tp,{className:iU.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:Vn,onChange:x=>{r(x),s(!0);let v=x.trim();SP(v,e,(T,C)=>{c({nonce:vP(),items:T}),u(C),d.current=v,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}),ht(fn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:Jt})]}),An("div",{className:"layer-ui__search-count",children:[l.items.length>0&&An(yU,{children:[p!==null&&p>-1?An("div",{children:[p+1," / ",w]}):ht("div",{children:w}),An("div",{className:"result-nav",children:[ht(fn,{onSelect:()=>{g()},className:"result-nav-btn",children:Nc}),ht(fn,{onSelect:()=>{b()},className:"result-nav-btn",children:Y1})]})]}),l.items.length===0&&i&&d.current&&ht("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),ht(fU,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},IP=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 ht("div",{tabIndex:-1,className:tU("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ht("div",{className:"preview-text",children:n.flatMap((t,o)=>ht(oU,{children:o===2?ht("b",{children:t}):t},o))})})},hU=e=>{let n=wP(()=>e.matches.items.filter(o=>Pp(o.element)),[e.matches]),t=wP(()=>e.matches.items.filter(o=>CP(o.element)),[e.matches]);return An("div",{className:"layer-ui__search-results",children:[n.length>0&&An("div",{className:"layer-ui__search-result-container",children:[An("div",{className:"layer-ui__search-result-title",children:[ht("div",{className:"title-icon",children:Un}),ht("div",{children:f("search.frames")})]}),n.map((o,r)=>ht(IP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&ht("div",{className:"layer-ui__divider"})]}),t.length>0&&An("div",{className:"layer-ui__search-result-container",children:[An("div",{className:"layer-ui__search-result-title",children:[ht("div",{className:"title-icon",children:wn}),ht("div",{children:f("search.texts")})]}),t.map((o,r)=>ht(IP,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},gU=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,fU=rU(hU,gU),TP=(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}},EU=(e,n)=>{let t=e.split(`
19
19
  `),o=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],s=t[i+1];if(s){let l=n.indexOf(s,r);if(l>a.length+r){let c=l-(a.length+r);for(;c>0;)a+=" ",c--}}o.push(a),r=r+a.length}return o.join(`
20
- `)},yU=(e,n,t)=>{let r=wU(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=Yl(u,Mp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let v=Yl(m.line,Mp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;g.width+=T}let{width:b,height:y}=Yl(E,Mp(e),e.lineHeight),w=g.width,x=m.lineNumber*g.height;d.push({offsetX:w,offsetY:x,width:b,height:y,showOnCanvas:!0}),l+=p}}return d},vU=(e,n,t,o)=>{let r=e.name??MP(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=Mp({fontSize:_E.nameFontSize,fontFamily:DE.Assistant}),l=dU(DE.Assistant),c=Yl(a,s,l);a===""&&(c.width=0);let d=Yl(i,s,l),m=c.width,p=-c.height-_E.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},IU=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),PP=iU((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>kP(p)),i=o.filter(p=>Ap(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(IU(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=CP(E,u.index,e),b=yU(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??MP(p);for(;(u=s.exec(E))!==null;){let g=CP(E,u.index,e),b=vU(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)},fU);import OU from"clsx";import{useEffect as BP,useLayoutEffect as OP,useRef as WE,useState as FU,forwardRef as FP,useImperativeHandle as zU,useCallback as _P}from"react";import{CLASSES as HU,EVENT as RP,isDevEnv as GU,KEYS as UU,updateObject as WU}from"@excalidraw/common";import CU from"clsx";import{useContext as PU}from"react";import SU from"react";var Lp=SU.createContext({});import{jsx as NE,jsxs as LP}from"react/jsx-runtime";var BE=({children:e,className:n})=>{let t=ge(),o=PU(Lp),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return LP("div",{className:CU("sidebar__header",n),"data-testid":"sidebar-header",children:[e,LP("div",{className:"sidebar__header__buttons",children:[r&&NE(ct,{label:f("labels.sidebarLock"),children:NE(fn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:xx})}),NE(fn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:Jt})]})]})};BE.displayName="SidebarHeader";import{Tabs as kU}from"radix-ui";import{jsx as DP}from"react/jsx-runtime";var OE=({children:e,tab:n,onSelect:t,...o})=>DP(kU.Trigger,{value:n,asChild:!0,onSelect:t,children:DP("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});OE.displayName="SidebarTabTrigger";import{Tabs as MU}from"radix-ui";import{jsx as AU}from"react/jsx-runtime";var FE=({children:e,...n})=>AU(MU.List,{className:"sidebar-triggers",...n,children:e});FE.displayName="SidebarTabTriggers";import LU from"clsx";import{jsx as zE,jsxs as DU}from"react/jsx-runtime";var HE=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Ue(),d=fe().openSidebar?.name===e;return zE("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:DU("div",{className:LU("sidebar-trigger",a),style:s,children:[t&&zE("div",{children:t}),r&&zE("div",{className:"sidebar-trigger__label",children:r})]})})};HE.displayName="SidebarTrigger";import{Tabs as _U}from"radix-ui";import{jsx as RU}from"react/jsx-runtime";var GE=({children:e,...n})=>{let t=fe(),o=Ue();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return RU(_U.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};GE.displayName="SidebarTabs";import{Tabs as NU}from"radix-ui";import{jsx as BU}from"react/jsx-runtime";var UE=({tab:e,children:n,...t})=>BU(NU.Content,{...t,value:e,"data-testid":e,children:n});UE.displayName="SidebarTab";import{jsx as NP}from"react/jsx-runtime";import{createElement as VU}from"react";var VE=je(!1),zP=FP(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{GU()&&t&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=Ue(),l=px(VE);OP(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=WE({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=WU(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=WE(null);zU(a,()=>d.current);let m=ge(),p=_P(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Ti(d,_P(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),BP(()=>{let u=E=>{E.key===UU.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(RP.KEYDOWN,u),()=>{document.removeEventListener(RP.KEYDOWN,u)}},[p,o,m.canFitSidebar]),NP(ze,{...i,className:OU(HU.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:NP(Lp.Provider,{value:c.current,children:n})})});zP.displayName="SidebarInner";var Er=Object.assign(FP((e,n)=>{let t=fe(),{onStateChange:o}=e,r=WE(t.openSidebar);BP(()=>{(!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]=FU(!1);return OP(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?VU(zP,{...e,ref:n,key:e.name}):null}),{Header:BE,TabTriggers:FE,TabTrigger:OE,Tabs:GE,Tab:UE,Trigger:HE});Er.displayName="Sidebar";import{jsx as Va,jsxs as KU}from"react/jsx-runtime";import{createElement as ZU}from"react";var GP=ei("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=et();return Va(n.In,{children:Va(Er.Trigger,{...e,className:"default-sidebar-trigger",name:XU.name})})});GP.displayName="DefaultSidebarTrigger";var UP=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=et();return Va(n.In,{children:e})};UP.displayName="DefaultTabTriggers";var YE=Object.assign(ei("DefaultSidebar",({children:e,className:n,docked:t,...o})=>{let r=fe(),i=r.openSidebar?.tab===HP;return ZU(Er,{...o,name:"default",key:"default",className:YU("default-sidebar",{"default-sidebar--search-only":i},n),docked:i?!1:t??r.defaultSidebarDockedPreference,onDock:void 0},KU(Er.Tabs,{children:[!i&&Va(Er.Header,{}),Va(Er.Tab,{tab:HP,children:Va(AP,{})}),!i&&e]}))}),{Trigger:GP,TabTriggers:UP});import jU from"react";import{getFrame as qU}from"@excalidraw/common";import{jsx as $U}from"react/jsx-runtime";var XE={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"}},KE=({children:e,color:n})=>$U("div",{className:"Card",style:{"--card-color":XE[n].base,"--card-color-darker":XE[n].darker,"--card-color-darkest":XE[n].darkest},children:e});import{Fragment as QU,jsx as Ln,jsxs as Dp}from"react/jsx-runtime";var JU=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return Ln("div",{className:"ExportDialog ExportDialog--json",children:Dp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Dp(KE,{color:"lime",children:[Ln("div",{className:"Card-icon",children:Bx}),Ln("h2",{children:f("exportDialog.disk_title")}),Dp("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!mi&&r.renderAction("changeProjectName")]}),Ln(K,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Ws,"ui")}})]}),l&&Dp(KE,{color:"pink",children:[Ln("div",{className:"Card-icon",children:hs}),Ln("h2",{children:f("exportDialog.link_title")}),Ln("div",{className:"Card-details",children:f("exportDialog.link_details")}),Ln(K,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ne("export","link",`ui (${qU()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},WP=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=jU.useCallback(()=>{a({openDialog:null})},[a]);return Ln(QU,{children:n.openDialog?.name==="jsonExport"&&Ln(gn,{onCloseRequest:s,title:f("buttons.export"),children:Ln(JU,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import eW from"clsx";import{jsx as tW}from"react/jsx-runtime";var VP=e=>tW(K,{className:eW("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:Un,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import qP from"clsx";import{useState as uW}from"react";import{CANVAS_SEARCH_TAB as hW,DEFAULT_SIDEBAR as gW,KEYS as Xl}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as nW,DEFAULT_SIDEBAR as oW}from"@excalidraw/common";import{isArrowElement as rW,isFlowchartNodeElement as iW,isImageElement as YP,isLinearElement as XP,isLineElement as aW,isTextBindableContainer as sW,isTextElement as lW}from"@excalidraw/element";import{isNodeInFlowchart as cW}from"@excalidraw/element";import{jsx as ZE}from"react/jsx-runtime";var xe=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,dW=({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===nW&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:xe("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(qt(e))return f("hints.eraserRevert",{shortcut:xe("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:xe("Ctrl"),shortcut_2:xe("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:xe("Escape"),shortcut_2:xe("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:xe("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 XP(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:xe("Shift")}):YP(d)?f("hints.resizeImage",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")}):f("hints.resize",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:xe("Shift")});if(c.length===1&&lW(c[0]))return f("hints.text_selected",{shortcut:xe("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:xe("Escape"),shortcut_2:xe(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:xe("Enter"),shortcut_2:xe("Escape")});if(c.length===1&&YP(c[0]))return f("hints.enterCropEditor",{shortcut:xe("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:xe("CtrlOrCmd")});if(or(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:xe("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:xe(f("keys.mmb")),shortcut_2:xe("Space")});if(c.length===1){if(XP(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:xe("Delete"),shortcut_2:xe(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")}):aW(c[0])?f("hints.lineEditor_line_info",{shortcut:xe("Enter")}):f("hints.lineEditor_info",{shortcut_1:xe("CtrlOrCmd"),shortcut_2:xe(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&sW(c[0])){let d=f("hints.bindTextToElement",{shortcut:xe("Enter")}),m=f("hints.createFlowchart",{shortcut:xe(["CtrlOrCmd","\u2191\u2193"])});return iW(c[0])?cW(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},KP=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=dW({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 ZE("kbd",{children:c?c[1]:s},l)}return s});return ZE("div",{className:"HintViewer",children:ZE("span",{children:a})})};import mW from"clsx";import{jsx as pW}from"react/jsx-runtime";var ZP=e=>pW(K,{className:mW("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?No:ao,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 ai,jsx as oe,jsxs as Io}from"react/jsx-runtime";var fW=(e,n)=>e==="image"&&n.tools?.image===!1,EW=({app:e,activeTool:n,type:t,shortcut:o})=>oe(de.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:We[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??Hi(t),disabled:Ze(e,t),children:f(`toolBar.${t}`)}),$P=({app:e})=>oe(de.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?No:ao,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:Xl.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),bW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=Ke("objectsSnapMode");return oe(de.Item,{onSelect:()=>e.executeAction(kt,"ui"),icon:Fo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},xW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=f("buttons.objectsSnapMode"),o=Ke("objectsSnapMode");return oe(K,{type:"toggle",icon:Fo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(kt,"ui")})},jP=({actionManager:e,appState:n})=>{let t=f("search.title"),o=Ke("searchMenu");return oe(de.Item,{onSelect:()=>e.executeAction(pl,"ui"),icon:Wn,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===gW.name&&n.openSidebar.tab===hW,shortcut:o,children:t})},wW=({app:e})=>oe(K,{type:"button",icon:yi,title:`${f("labels.eyeDropper")} - ${Xl.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":Xl.I.toLocaleUpperCase(),keyBindingLabel:Xl.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),yW=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=uW(!1),l=at()==="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&&Fi.includes(n.type);return Io(de,{open:a,children:[oe(de.Trigger,{className:qP("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?We[n.type].icon:c?Gn:E?Oo:!r&&l&&d?Mr:m&&!e.props.isCollaborating?Un:u?fi:p?Hn:cs}),oe(de.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?Io(ai,{children:[l&&oe(de.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:fi,"data-testid":"toolbar-lasso",selected:u,disabled:Ze(e,"lasso"),children:f("toolBar.lasso")}),Fi.filter(b=>!fW(b,o)).map(b=>oe(EW,{app:e,activeTool:n,type:b},b)),oe("div",{className:"App-toolbar__dropdown-divider"}),oe(jP,{actionManager:i,appState:e.state}),e.props.activeTool==null&&oe(ai,{children:oe($P,{app:e})})]}):Io(ai,{children:[oe(de.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Gn,shortcut:Xl.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:Ze(e,"frame"),children:f("toolBar.frame")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Oo,"data-testid":"toolbar-embeddable",selected:E,disabled:Ze(e,"embeddable"),children:f("toolBar.embeddable")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Mr,shortcut:Hi("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:Ze(e,"autoshape"),children:f("toolBar.autoshape")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Un,"data-testid":"toolbar-laser",selected:m,disabled:Ze(e,"laser"),children:f("toolBar.laser")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Hn,"data-testid":"toolbar-bucketfill",selected:p,disabled:Ze(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&oe(de.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:fi,"data-testid":"toolbar-lasso",selected:u,disabled:Ze(e,"lasso"),children:f("toolBar.lasso")}),oe("div",{className:"App-toolbar__dropdown-divider"}),oe(bW,{actionManager:i,app:e}),oe(jP,{actionManager:i,appState:e.state}),e.props.activeTool==null&&oe($P,{app:e})]})})]})},JP=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=ge(),c=at()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?oe(Ld,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?oe(Nw,{...m}):oe(Rw,{...m});return Io(ze,{padding:1,className:qP("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[oe(KP,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,Io(Dt.Row,{gap:c?.5:1,children:[!c&&oe(Ra,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&Io(ai,{children:[oe(ZP,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),oe("div",{className:"App-toolbar__divider"})]}),oe(Ad,{...m}),u,p?Io(ai,{children:[oe(Rs,{...m}),oe(Ns,{...m}),oe(wW,{app:e}),o.tools?.image!==!1&&oe(Bs,{...m}),oe(Os,{...m})]}):Io(ai,{children:[oe(kw,{...m}),oe(Mw,{...m}),oe(Aw,{...m}),oe(Lw,{...m}),oe(Dw,{...m}),c?oe(Dd,{...m}):oe(Rs,{...m}),oe(Ns,{...m}),o.tools?.image!==!1&&oe(Bs,{...m}),oe(Os,{...m})]}),oe("div",{className:"App-toolbar__divider"}),oe(yW,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&Io(ai,{children:[oe("div",{className:"App-toolbar__divider"}),oe(xW,{actionManager:r,app:e})]})]})]})};import{Fragment as $E,jsx as ee,jsxs as Zt}from"react/jsx-runtime";var kW=({UIOptions:e})=>Zt(_t,{__fallback:!0,children:[ee(_t.DefaultItems.LoadScene,{}),ee(_t.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ee(_t.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ee(_t.DefaultItems.SaveAsImage,{}),ee(_t.DefaultItems.SearchMenu,{}),ee(_t.DefaultItems.Help,{}),ee(_t.Separator,{}),ee(_t.Group,{title:"Excalidraw links",children:ee(_t.DefaultItems.Socials,{})}),ee(_t.Separator,{}),ee(_t.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),ee(_t.DefaultItems.ChangeCanvasBackground,{})]}),MW=()=>Zt(gp,{__fallback:!0,children:[ee(gp.Actions.SaveToDisk,{}),ee(gp.Actions.ExportToImage,{})]}),AW=({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:y,zoomUIEnabled:w,scrollBackToContentUIEnabled:x,isCollaborating:v,generateLinkForSelection:T,currentUserControls:C})=>{let P=ge(),A=yn(),_=at()==="compact",k=LT(),D=_?{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]=Fe(Nt),W=()=>p.canvasActions.export?ee(WP,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,Z=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:ee(yP,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),H=()=>Zt("div",{style:{position:"relative"},children:[Zt("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),ee(k.MainMenuTunnel.Out,{})]}),E&&ee(k.WelcomeScreenMenuHintTunnel.Out,{})]}),re=()=>ee(_l,{heading:"selectedShapeActions",className:Ya("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?ee(ze,{className:Ya("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:ee($T,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):ee(ze,{className:IW.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:ee(VT,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),B=()=>{let pe=y&&CW(n,r),he=y&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return ee(ap,{side:"top",children:Zt("div",{className:"App-menu App-menu_top",children:[Zt(Dt.Col,{gap:D.menuTopGap,className:Ya("App-menu_top__left"),children:[H(),y&&ee("div",{className:Ya("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:pe&&re()}),y&&_&&!n.viewModeEnabled&&pe&&ee(Ra,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),y&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&ee(_l,{heading:"shapes",className:"shapes-section",children:ye=>Zt("div",{style:{position:"relative"},children:[E&&ee(k.WelcomeScreenToolbarHintTunnel.Out,{}),ee(Dt.Col,{gap:D.toolbarColGap,align:"start",children:Zt(Dt.Row,{gap:D.toolbarRowGap,className:Ya("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[ee(JP,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ye}),v&&ee(ze,{style:{marginLeft:D.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:ee(VP,{title:f("toolBar.laser"),checked:n.activeTool.type===QP.laser,onChange:()=>b.setActiveTool({type:QP.laser}),isMobile:!0})})]})})]})}),Zt("div",{className:Ya("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":n.zenModeEnabled,"layer-ui__wrapper__top-right--compact":_}),children:[y&&n.collaborators.size>0&&ee(dp,{collaborators:n.collaborators,userToFollow:A.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),he&&ee(Gl,{app:b,onClose:()=>{e.executeAction(er)},renderCustomStats:m})]})]})})},U=()=>ee(YE,{}),ue=!1,we=Zt($E,{children:[g,y&&ee($E,{children:ee(kW,{UIOptions:p})}),ee(MW,{}),y&&n.isLoading&&ee(tp,{delay:250}),y&&n.errorMessage&&ee(dP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),y&&Y&&P.formFactor!=="phone"&&ee(E0,{colorPickerType:Y.colorPickerType,onCancel:()=>{z(null)},onChange:(pe,he,ye,{altKey:se})=>{if(!(pe!=="elementBackground"&&pe!=="elementStroke"))if(ye.length){for(let ve of ye)SW(ve,TW(r),{[se&&Y.swapPreviewOnAlt?pe==="elementBackground"?"strokeColor":"backgroundColor":pe==="elementBackground"?"backgroundColor":"strokeColor"]:he}),PW.delete(ve);b.scene.triggerUpdate()}else o(pe==="elementBackground"?{currentItemBackgroundColor:he}:{currentItemStrokeColor:he})},onSelect:(pe,he)=>{z(ye=>ye?.keepOpenOnAlt&&he.altKey?ye:null),Y?.onSelect?.(pe,he)}}),n.openDialog?.name==="help"&&ee(hP,{onClose:()=>{o({openDialog:null})}}),y&&n.openDialog?.name==="elementLinkSelector"&&ee(cP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),ee(k.OverwriteConfirmDialogTunnel.Out,{}),Z(),W(),y&&n.openDialog?.name==="charts"&&ee(FS,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),P.formFactor==="phone"&&ee(CS,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:W,renderImageExportDialog:Z,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:U,renderWelcomeScreen:E,defaultUIEnabled:y,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&Zt($E,{children:[A.viewportStatusFrame?.border&&ee(Jm,{border:A.viewportStatusFrame.border,style:ue?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),Zt("div",{className:"layer-ui__wrapper",style:ue?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&ee(k.WelcomeScreenCenterTunnel.Out,{}),B(),ee(YS,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:y,zoomUIEnabled:w}),(n.toast||x&&n.scrolledOutside||A.viewportStatusFrame?.label)&&Zt("div",{className:"floating-status-stack",children:[n.toast&&ee(Bd,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&ee("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(pe=>({...ci(r,pe)}))},children:f("buttons.scrollBackToContent")}),A.viewportStatusFrame?.label&&ee(Qm,{label:A.viewportStatusFrame.label,border:A.viewportStatusFrame.border})]})]}),U()]})]});return ee(Qu.Provider,{value:n,children:ee(F,{children:ee(Gf.Provider,{value:k,children:we})})})},ek=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},LW=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return _p(ek(o),ek(a),{selectedElementIds:_p,selectedGroupIds:_p})&&_p(r,s)},tk=vW.memo(AW,LW);import{useEffect as DW,useRef as _W}from"react";import{jsx as nk}from"react/jsx-runtime";var ok=({trails:e})=>{let n=_W(null);return DW(()=>{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 RW,{useEffect as rk,useRef as ik}from"react";import{isShallowEqual as NW,sceneCoordsToViewportCoords as BW}from"@excalidraw/common";import{jsx as zW}from"react/jsx-runtime";var ak="animateInteractiveScene",OW=e=>{let n=ik(!1),t=ik(null);return rk(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&Sf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),rk(()=>{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,BW({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},ot.running(ak)||ot.start(ak,({deltaTime:c,state:d})=>{let m=Sf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),zW("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")})},sk=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}),FW=(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:NW(sk(e.appState),sk(n.appState)),jE=RW.memo(OW,FW);import dk,{useEffect as Rp,useRef as Kl}from"react";import{isShallowEqual as lk}from"@excalidraw/common";import{jsx as UW}from"react/jsx-runtime";var HW=e=>{let n=Kl(null),t=Kl(!1),o=Kl(e),r=Kl(()=>{}),i=Kl(null);o.current=e;let a=dk.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();Qb({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}},ma());let m=s.renderConfig.imageTransitionDuration??0;m>0&&s.visibleElements.some(u=>{if(u.type!=="image"||!u.fileId)return!1;let E=s.renderConfig.imageCache.get(u.fileId)?.transitionStart;return E!==void 0&&performance.now()-E<m})&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,Rp(()=>{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]),Rp(()=>{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()}),Rp(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),Rp(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),UW("div",{className:"excalidraw__canvas-wrapper",ref:n})},ck=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}),GW=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:lk(ck(e.appState),ck(n.appState))&&lk(e.renderConfig,n.renderConfig),qE=dk.memo(HW,GW);import{useEffect as $W,useRef as jW}from"react";import{throttleRAF as WW}from"@excalidraw/common";import{getTargetFrame as VW,isInvisiblySmallElement as YW,renderElement as XW,shouldApplyFrameClip as KW}from"@excalidraw/element";var mk=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=bc(e,i),d=xc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(YW(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=VW(t,o,a);u&&KW(t,u,a,o)&&qb(u,d,s,a)}XW(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},ZW=WW(e=>{mk(e)}),pk=(e,n)=>{if(n){ZW(e);return}mk(e)};import{jsx as JW}from"react/jsx-runtime";var qW=e=>{let n=jW(null);return $W(()=>{n.current&&pk({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())}),JW("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})},uk=qW;import QW from"clsx";import{useLayoutEffect as eV,useEffect as hk,useRef as tV,useState as nV}from"react";import{ARROW_TYPE as gk,EVENT as Np}from"@excalidraw/common";import{jsx as aV}from"react/jsx-runtime";var fk=700,oV=100,rV=16,iV=5*60*1e3,bk=je(null),Ek=e=>e===gk.elbow?Ho:e===gk.round?Go:zo,Bp=class{constructor(n){I(this,"app");I(this,"lastShownAt",0);I(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(bk,{content:n,nonce:Math.random()}))});I(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<iV);I(this,"onArrowTypeCycled",n=>{this.show(Ek(n))});I(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?Bo:Ek(this.app.state.currentItemArrowType))});this.app=n}},xk=()=>{let[e,n]=Fe(bk),t=It(),{container:o}=De(),r=tV(null),[i,a]=nV(!1),s=e?.nonce;return eV(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=Jc({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:rV});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(Np.POINTER_MOVE,c),()=>{window.removeEventListener(Np.POINTER_MOVE,c)}},[s,o,t]),hk(()=>()=>{n(null)},[n]),hk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},fk),c=window.setTimeout(()=>{n(null)},fk+oV),d=()=>{n(null)};return window.addEventListener(Np.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(Np.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?aV("div",{ref:r,className:QW("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var Op=class{constructor(n){this.getState=n;I(this,"listeners",[]);I(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 sV,getElementsInGroup as lV,isNonDeletedElement as wk,selectGroupsFromGivenElements as cV}from"@excalidraw/element";import{sceneCoordsToViewportCoords as dV}from"@excalidraw/common";import{flushSync as mV}from"react-dom";import{jsx as uV}from"react/jsx-runtime";var pV=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!wk(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&wk(t)?t:null,r=o?[o]:lV(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=sV(r),{x:s,y:l}=dV({sceneX:i,sceneY:a},e.state);return uV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{mV(()=>{let c=cV(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(js)},title:f("labels.elementLock.unlock"),children:wx})},yk=pV;import{Fragment as pX,jsx as Ie,jsxs as wb}from"react/jsx-runtime";var MM=En.createContext(null),AM=En.createContext(null),yb={formFactor:"desktop",desktopUIMode:"full",userAgent:PM(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},Ib=En.createContext(yb);Ib.displayName="EditorInterfaceContext";var cX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},Tb=En.createContext({container:null,id:null});Tb.displayName="ExcalidrawContainerContext";var Sb=En.createContext([]);Sb.displayName="ExcalidrawElementsContext";var Cb=En.createContext({...Ro(),width:0,height:0,offsetLeft:0,offsetTop:0});Cb.displayName="ExcalidrawAppStateContext";var Pb=En.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Pb.displayName="ExcalidrawSetAppStateContext";var kb=En.createContext(null);kb.displayName="ExcalidrawActionManagerContext";var Qa=En.createContext(null);Qa.displayName="ExcalidrawAPIContext";var Qp=En.createContext(null);Qp.displayName="ExcalidrawAPISetContext";var It=()=>Ao(MM),yn=()=>Ao(AM),ge=()=>Ao(Ib),at=()=>Jp(ge()),De=()=>Ao(Tb),Ci=()=>Ao(Sb),Ko=()=>Ao(Cb),Ue=()=>Ao(Pb),tt=()=>Ao(kb),wd=()=>Ao(Qa),oc=!1,rc=0,ic=null,ko=!1,Zp=!1,Mo=!1,$p=!1,ac={horizontal:null,vertical:null},yr=0,sc=!1,xb=new Map,dX=4,jp=!1,qp=0,TM=!1,Ja=null,le={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},vb=class e extends En.Component{constructor(t){super(t);I(this,"canvas");I(this,"interactiveCanvas",null);I(this,"sessionExportThemeOverride");I(this,"rc");I(this,"unmounted",!1);I(this,"actionManager");I(this,"editorInterface",yb);I(this,"stylesPanelMode",Jp(yb));I(this,"excalidrawContainerRef",En.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"hasRenderableElements",!1);I(this,"resizeObserver");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"imageLoadingProgress",new Map);I(this,"imageLoadingProgressEmitter",new Jn);I(this,"imageStatus",new Map);I(this,"imageStatusEmitter",new Jn);I(this,"imagePlaceholderUpdateEmitter",new Jn);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"elementsPendingErasure",new Set);I(this,"_initialized",!1);I(this,"editorLifecycleEvents",new WV(cX));I(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));I(this,"appStateObserver",new Op(()=>this.state));I(this,"onStateChange",this.appStateObserver.onStateChange);I(this,"bucketFill",new Wm(this));I(this,"flowchart",new Zm(this));I(this,"cursor",new Vm(this));I(this,"zDragZoom",null);I(this,"arrowText",new Um(this));I(this,"viewport",new jm(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>le.pointers.size>=2||Mo}));I(this,"bindModeHandler",null);I(this,"textWysiwygSubmitHandler",null);I(this,"hitLinkElement");I(this,"lastPointerDownEvent",null);I(this,"lastPointerUpEvent",null);I(this,"lastPointerUpIsDoubleClick",!1);I(this,"lastPointerMoveEvent",null);I(this,"lastPointerMoveCoords",null);I(this,"lastCompletedCanvasClicks",[]);I(this,"previousPointerMoveCoords",null);I(this,"drawShape",new Km(this));I(this,"laserTrails",new xm(this));I(this,"eraserTrail",new Cm(this));I(this,"lassoTrail",new Sm(this));I(this,"cursorHints",new Bp(this));I(this,"onChangeEmitter",new Jn);I(this,"onPointerDownEmitter",new Jn);I(this,"onPointerUpEmitter",new Jn);I(this,"onUserFollowEmitter",new Jn);I(this,"onScrollChangeEmitter",new Jn);I(this,"missingPointerEventCleanupEmitter",new Jn);I(this,"onRemoveEventListenersEmitter",new Jn);I(this,"api");I(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});I(this,"updateEditorAtom",(t,...o)=>{let r=gt.set(t,...o);return this.triggerRender(),r});I(this,"previousHoveredBindableElement",null);I(this,"getEffectiveGridSize",()=>or(this)?this.state.gridSize:null);I(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)}});I(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&tc(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Pe.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));I(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=Dk);I(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),qa.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Po(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)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(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=Ce({clientX:i.x,clientY:i.y},this.state),s=Ce({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});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===jl.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&vt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!jk(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}=Hp({sceneX:i.x,sceneY:i.y},this.state),l=6,c,d=PY(i);if(i.id===this.state.editingFrame){let m=d;c=Ie("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===X.ESCAPE||p.key===X.ENTER)&&this.resetEditingFrame(i)},style:{background:UV(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:`${To.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?To.nameColorDarkTheme:To.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 Ie("div",{id:this.getFrameNameDOMId(i),className:ab.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+To.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:To.nameFontSize,color:t?To.nameColorDarkTheme:To.nameColorLightTheme,lineHeight:To.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:Pe.MOVE,pointerEvents:this.state.viewModeEnabled?Ka.disabled:Ka.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,o,r)=>{Ne("export",t,"ui");let i=await Fr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(HV).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&yc(i)&&this.setState({fileHandle:i})});I(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Nt,{swapPreviewOnAlt:o,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,i)=>{let a=t==="stroke"?!o||!i.altKey:o&&i.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:jt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:jt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?eo(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:jt.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Ye(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||jl.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&&Kp(d)&&Wt(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()}));I(this,"scheduleCapture",()=>this.store.scheduleCapture());I(this,"onBlur",Ye(()=>{ko=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"preventBrowserZoomWheel",t=>{t[X.CTRL_OR_CMD]&&t.preventDefault()});I(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});I(this,"maybeHandlePageScrollKeyDown",t=>{if(t.key!==X.PAGE_UP&&t.key!==X.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===X.PAGE_DOWN&&(o=-o),t.shiftKey?this.viewport.translate(r=>({scrollX:r.scrollX+o})):this.viewport.translate(r=>({scrollY:r.scrollY+o})),!0});I(this,"preventBrowserZoomKeyDown",t=>{t[X.CTRL_OR_CMD]&&(t.code===br.EQUAL||t.code===br.MINUS||t.code===br.ZERO||t.code===br.NUM_ADD||t.code===br.NUM_SUBTRACT||t.code===br.NUM_ZERO)&&t.preventDefault()});I(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),ko=!1,Zp=!1,Mo=!1,$p=!1,Ja=null,le.pointers.clear(),le.lastCenter=null,le.initialDistance=null,le.initialScale=null,clearTimeout(rc),rc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(qp),qp=0,jp=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),gt.set(Nt,null),gt.set(Zn,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&vt(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())});I(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,em(),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:$t(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())});I(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));I(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)});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",Ye(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...Ro(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(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=Sr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=pi(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=Ql(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...ci(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:jt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),RY(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});I(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??KV(t,o));I(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=qV(),a=PM(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:TV,l=ib(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)});I(this,"reconcileStylesPanelMode",t=>{let o=Jp(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}}))});I(this,"setDesktopUIMode",t=>{let o=JV(t);this.editorInterface=ib(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});I(this,"onResize",Ye(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>qa.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&(ac=t),this.scheduleImageRefresh()});I(this,"onScroll",Nk(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},SV));I(this,"onCut",Ye(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||ql(t.target)||(this.actionManager.executeAction(qd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Ye(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||ql(t.target)||(this.actionManager.executeAction($i,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(ZV&&t.preventDefault(),!oc){oc=!0,t.touches.length===1&&(ic={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(rc),rc=window.setTimeout(e.resetTapTwice,Dk);return}if(oc&&t.touches.length===1&&ic){let o=t.touches[0];qn(ne(o.clientX,o.clientY),ne(ic.x,ic.y))<=zk&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),oc=!1,clearTimeout(rc)}t.touches.length===2&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null})}});I(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}):le.pointers.clear())});I(this,"pasteFromClipboard",Ye(async t=>{if(!this.isInteractionEnabled())return;let o=!!jp,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)||ql(r)))return;let s=await Br(t),l=s.getFiles(),c=await Hd(s,o);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()}));I(this,"addElementsFromPasteOrLibrary",t=>{let o=Sr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=$a(o),l=Za(r,a)/2,c=Za(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}=Ce({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,y]=Ct(E,g,this.getEffectiveGridSize()),{duplicatedElements:w}=Xk({type:"everything",elements:o.map(A=>eo(A,{x:A.x+b-r,y:A.y+y-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),v=[...x,...w];v=this.props.onDuplicate?.(v,x)||v,dM(v,Ql(w));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let A=kY(w,C);v=ub(v,A,C)}this.scene.replaceAllElements(v),w.forEach(A=>{if(Wt(A)&&Zk(A)){let L=tM(A,this.scene.getElementsMapIncludingDeleted());wY(A,L,this.scene)}}),jV&&io.loadElementsFonts(w).then(A=>{this.fonts.onLoaded(A)}),t.files&&this.addMissingFiles(t.files);let P=YY(w);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&gt.get(VE)?this.state.openSidebar:null,...mM(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:w,fit:t.fit,animation:!1,offsets:{ui:!0}})});I(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});I(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)});I(this,"removePointer",t=>{yr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=le.pointers.size>=2;le.pointers.delete(t.pointerId),o&&le.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});I(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Ne("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...$t(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});I(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}}})});I(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});I(this,"revealIfHidden",t=>{!t.length||gY(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:$a(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});I(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:Bn(t.zoom)},shouldCacheIgnoreZoom:!1})});I(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}})});I(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});I(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});I(this,"setToast",t=>{this.setState({toast:t})});I(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,EV,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Ye(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());eM({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files}).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()}));I(this,"addImageElementsToScene",async(t,o,r)=>{await this.insertImages(t.map(({file:i})=>i),o,r)});I(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await ui(o);if(!vc(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};this.imageCache.set(t,s),i.src=await Ic(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}});I(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=Zl(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});I(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>{let i=o===null&&r?.uploadProgress?.state==="error"?null:r?.uploadProgress;return{...r,downloadError:o===!0?{}:o||null,uploadProgress:i}})});I(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:Zl(o,0,1)}:{progress:void 0}}}})});I(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())});I(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);I(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});I(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())ja(o)&&o.fileId===t&&qa.delete(o)});I(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===Xa.svg))try{let l=ix(Qk(ax(s.dataURL)),Xa.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});I(this,"updateScene",Ye(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?eY({...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}))}));I(this,"applyDeltas",(t,o)=>{let r=EM.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return EM.applyTo(r,a,i,o)});I(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(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});I(this,"updateCurrentCursorPosition",Ye(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));I(this,"onKeyDown",Ye(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}})),!Bk(t.target)){if((t.key===X.ESCAPE||t.key===X.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=ie(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&no(l[0])&&t.key===X.ENTER){this.startImageCropping(l[0]);return}if(t.key===X.ESCAPE)this.updateEditorAtom(Zn,null);else if(t.key===X.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(ab.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=Gm(l);gt.get(Zn)?.type==="panel"&&Bf(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(Zn,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[X.CTRL_OR_CMD]&&t.key.toLowerCase()===X.V&&(jp=t.shiftKey,clearTimeout(qp),qp=window.setTimeout(()=>{jp=!1},100)),t[X.CTRL_OR_CMD]&&ql(t.target)&&(t.code===br.MINUS||t.code===br.EQUAL)){t.preventDefault();return}if(ql(t.target)&&t.key!==X.ESCAPE||eb(t.key)&&Bk(t.target))return;if(t.key===X.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===X.E&&t.shiftKey&&t[X.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}if(this.state.openDialog?.name==="elementLinkSelector")return;if(t.key===X.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else Co("COMPLEX_BINDINGS")?this.handleSkipBindMode():Xp({app:this,event:t});if(this.actionManager.handleKeyDown(t))return;let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===X.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=Pw(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!Hk(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&Ne("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===xr.sharp?xr.round:this.state.currentItemArrowType===xr.round?xr.elbow:xr.sharp;this.setState({currentItemArrowType:c}),this.cursorHints.onArrowTypeCycled(c)}else(l==="arrow"||l==="line")&&this.cursorHints.onToolShortcut(l,/^\d$/.test(t.key)?"digit":"letter");l==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l},{toggle:!0}),t.stopPropagation();return}else if(t.key===X.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[X.CTRL_OR_CMD]&&!t.repeat&&(Co("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),Xp({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=>to(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?Lk:this.getEffectiveGridSize())||(t.shiftKey?yV:Lk),m=0,p=0;t.key===X.ARROW_LEFT?m=-d:t.key===X.ARROW_RIGHT?m=d:t.key===X.ARROW_UP?p=-d:t.key===X.ARROW_DOWN&&(p=d),l.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),Wp(u,this.scene,{simultaneouslyUpdated:l})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===X.ENTER){let l=this.scene.getSelectedElements(this.state);if(l.length===1){let c=l[0];if(t[X.CTRL_OR_CMD]||fb(c))Rt(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),Ut(c)||this.actionManager.executeAction(aa));else if(Wt(c)||nM(c)){let d;Wt(c)||(d=c);let m=mb(c,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:d}),t.preventDefault();return}else vt(c)&&this.setState({editingFrame:c.id})}}if(t.key===X.SPACE&&le.pointers.size===0&&(ko=!0,this.cursor.set(Pe.GRAB),t.preventDefault()),t.key.toLowerCase()===X.Z&&!t[X.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(Zp=!0,this.cursor.set("zoom-in"),t.preventDefault()),(t.key===X.G||t.key===X.S)&&!t.altKey&&!t[X.CTRL_OR_CMD]){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;t.key===X.G&&(_o(this.state.activeTool.type)||l.some(c=>_o(c.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===X.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[X.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===X.F){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;(this.state.activeTool.type==="text"||l.find(c=>Wt(c)||db(c,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===X.I&&!t.shiftKey&&!t[X.CTRL_OR_CMD],a=r===X.S&&t.shiftKey&&!t[X.CTRL_OR_CMD]||i,s=r===X.I&&t.shiftKey&&!t[X.CTRL_OR_CMD];(a||s)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));I(this,"onKeyUp",Ye(t=>{if(this.isInteractionEnabled()){if(t.key===X.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Pe.GRAB):Gp(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),ko=!1),t.key.toLowerCase()===X.Z&&(Zp=!1,this.cursor.reset()),t.key===X.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Xp({app:this,event:t})),(t.key===X.ALT&&this.state.bindMode==="skip"||!t[X.CTRL_OR_CMD]&&!Up(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Co("COMPLEX_BINDINGS"))){let o=Ce({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=wr(ne(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=me.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());to(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[X.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Gt(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),Xp({app:this,event:t})}if(eb(t.key)){Uk(this.scene.getSelectedElements(this.state).filter(ec),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Eb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...xM(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...xM(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));I(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(dt);let i=zi.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?$t(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?$t(this.state,{...t,lastActiveTool:this.state.activeTool}):$t(this.state,t);s.type==="hand"?this.cursor.set(Pe.GRAB):ko||this.cursor.applyForTool(s),OV(document.activeElement)&&this.focusContainer(),pY(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:Gp(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:ke({},l),selectedGroupIds:ke({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:ke({},l),selectedGroupIds:ke({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"isTouchScreenMultiTouchGesture",()=>le.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${Ok()}`);I(this,"onGestureStart",Ye(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null}),le.initialScale=this.state.zoom.value)}));I(this,"onGestureChange",Ye(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=le.initialScale;o&&this.viewport.translate(r=>({...ro({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Bn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));I(this,"onGestureEnd",Ye(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}),le.initialScale=null)}));I(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=IM(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&S2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});I(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=IM(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(Gg,"ui",r),this.cursor.reset(),!0)});I(this,"startTextEditing",({sceneX:t,sceneY:o,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:s,arrowEndpoint:l})=>{let c=!1,d=l&&this.arrowText.getTextBinding(l,this.getCurrentItemStrokeWidth("text"));d&&(i=null,r=!1,t=d.anchor[0],o=d.anchor[1]);let m=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&m&&(db(i,this.scene.getNonDeletedElementsMap())||(c=!0));let p=d?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=p?.fontFamily||this.state.currentItemFontFamily,E=p?.lineHeight||Rk(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!ec(i)){let C=OY(ob({fontSize:g,fontFamily:u}),E),P=FY(g,E),A=Math.max(i.height,P),L=Math.max(i.width,C);this.scene.mutateElement(i,{height:A,width:L}),t=i.x+L/2,o=i.y+A/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),y=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-lM(g,E)/2:b.y},w=this.getTopLayerFrameAtSceneCoords({x:y.x,y:y.y}),x=w&&(!c||!i||i.frameId===w.id)?w.id:null,v=p||Vk({x:y.x,y:y.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?kV.MIDDLE:Mk),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?ec(i)?0:i.angle:0,frameId:x});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:v.id})}),this.setState({editingTextElement:v}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([v],T+1)}else this.insertNewElement(v);l&&d&&this.arrowText.bindText(l,v,d.fixedPoint),a||p||i?this.handleTextWysiwyg(v,{isExistingElement:!!p,initialCaretSceneCoords:p?s:null}):this.setState({newElement:v,multiElement:null})});I(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(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 qn(ne(o.x,o.y),ne(r.x,r.y))<=zk});I(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}=Ce(t,this.state);if(o.length===1&&Rt(o[0])){let s=o[0];if((t[X.CTRL_OR_CMD]&&Eb(s)||fb(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(aa);return}else if(this.state.selectedLinearElement&&Ut(o[0])){let l=me.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=l?me.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),me.deleteFixedSegment(o[0],this.scene,c);let d=me.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?me.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===s.id&&fb(s))return}if(o.length===1&&no(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),WY(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&UY(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(c=>({...c,..._n({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(tc(s)){this.setState({activeEmbeddable:{element:s,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let l=!t[X.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(l&&(this.state.activeTool.type==="autoshape"||Kk(l)||!zV(l.backgroundColor)||nc({point:ne(r,i),element:l,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(l)}))){let c=mb(l,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l||null})}}});I(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==So.MAIN){this.lastCompletedCanvasClicks=[];return}let o=Ce(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}]});I(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(!no(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});I(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=Il(o,r,this.state,i);return!!a&&qn(ne(t.x,t.y),ne(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});I(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&&Ec(s,this.scene.getNonDeletedElementsMap(),this.state,ne(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});I(this,"handleElementLinkClick",t=>{let o=qn(ne(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ne(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||o>Ak)return;let r=Ce(this.lastPointerDownEvent,this.state),i=this.scene.getNonDeletedElementsMap(),a=Ec(this.hitLinkElement,i,this.state,ne(r.x,r.y),this.editorInterface.formFactor==="phone"),s=Ce(this.lastPointerUpEvent,this.state),l=Ec(this.hitLinkElement,i,this.state,ne(s.x,s.y),this.editorInterface.formFactor==="phone");if(a&&l){em();let c=this.hitLinkElement.link;if(c){c=nb(c);let d;if(this.props.onLinkOpen&&(d=FV(J.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let m=RV(c)?"_self":"_blank",p=window.open(void 0,m);p&&(p.opener=null,p.location=c)}}}});I(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Pe.POINTER),Jy(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(em(),!1));I(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});I(this,"handleInteractiveContentPointerMove",t=>{let o=Ce(t,this.state),r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let i=r?.locked?null:r;if(this.handleIframeLikeElementHover({hitElement:i,scenePointer:o,moveEvent:t}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(o,r):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()});I(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=Ce(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(l=>!l.locked&&rM(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(vt(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});I(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});I(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&sX(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});I(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?vY(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});I(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&vt(o)?o:null)});I(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=Bn(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...ro({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},s),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0}),this.resetShouldCacheIgnoreZoomDebounced()});I(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())&&!Mo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Ce(t,this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t);return}if(this.updateMultiTouchGesture(t),ko||Mo||$p||os(this.state))return;let s=nf(ac,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(Pe.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Pe.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&y2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=w2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(y=>{let w=Jl(y.snapLines,b),x=y.originSnapOffset?Jl(y.originSnapOffset,g):g;return y.snapLines===w&&y.originSnapOffset===x?null:{snapLines:w,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:me.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Gt(()=>{this.setState({selectedLinearElement:g})})}if(mY(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&Up(this.state)){let b=ne(r,i),y=this.scene.getNonDeletedElementsMap(),w=wr(b,this.scene.getNonDeletedElements(),y,vM(this.state.zoom));w?this.setState({suggestedBinding:{element:w,midPoint:bb(b,w,y,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:y,y:w,points:x}=g,v=x[x.length-1],{lastCommittedPoint:T}=b;if(this.cursor.applyForTool(),v===T)qn(ne(r-y,i-w),v)>=tb?(this.store.scheduleCapture(),Gt(()=>{Qn(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,ne(r-y,i-w)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Pe.POINTER);else if(x.length>2&&T&&qn(ne(r-y,i-w),T)<tb){this.cursor.set(Pe.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{Jk(x,this.state.zoom.value)&&this.cursor.set(Pe.POINTER);let C=this.scene.getNonDeletedElementsMap();if(Eb(g)){let A=wr(ne(r,i),this.scene.getNonDeletedElements(),C);Co("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,A)}Qn(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=me.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=ne(r,i),b=wr(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),vM(this.state.zoom)),y=this.scene.getNonDeletedElementsMap();b&&!yM(g,b,y)&&this.setState({suggestedBinding:{element:b,midPoint:bb(g,b,y,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(Pe.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&&Ut(m[0]))&&!(Rt(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=uM(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(pM(g));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=hM($a(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(pM({transformHandleType:g}));return}}if(qt(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||Po(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?Pe.POINTER:Wt(u)?Pe.TEXT:Pe.CROSSHAIR):!t[X.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Pe.MOVE):this.state.viewModeEnabled?this.cursor.set(Pe.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Pe.AUTO):s?this.cursor.set(Pe.AUTO):!t[X.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Ut(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Pe.MOVE):this.cursor.set(Pe.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:Jl(g.hoveredElementIds,_n({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:Jl(g.hoveredElementIds,{})}))});I(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});I(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(sc=!0)});I(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),Mo||this.handleCanvasPanUsingWheelOrSpaceDrag(t));return}let o=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=Ce(t,this.state),{x:i,y:a}=r;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(RE,null)),gt.get(Zn)&&this.updateEditorAtom(Zn,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),Zp){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:ke(Object.keys(this.state.selectedElementIds).filter(b=>b!==g.id).reduce((b,y)=>(b[y]=this.state.selectedElementIds[y],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?jt.EVENTUALLY:jt.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:"variable"})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=ib(this.editorInterface,{isTouchScreen:!0})),Mo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===So.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Dn.eraser){this.setState({activeTool:$t(this.state,{type:Dn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),y?.(),qt(this.state)&&this.setState({activeTool:$t(this.state,{...this.state.activeTool.lastActiveTool||{type:Dn.selection},lastActiveTool:null})})},b=be(window,J.POINTER_UP,g,{once:!0}),y;requestAnimationFrame(()=>{y=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==So.MAIN&&t.button!==So.TOUCH&&t.button!==So.ERASER||le.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let g=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[X.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(c.origin.x,c.origin.y,t.shiftKey),c.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&c.hit.element&&!g&&(this.setState(w=>{let x={...w.selectedElementIds,[c.hit.element.id]:!0},v=[];Object.keys(w.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&v.push(P)});let T=c.hit.element;if(vt(T))pb(v,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(A=>si(this.scene.getNonDeletedElements(),A)).filter(A=>vt(A)).map(A=>A.id));P.size>0&&v.forEach(A=>{A.frameId&&P.has(A.frameId)&&(delete x[A.id],A.groupIds.flatMap(L=>si(this.scene.getNonDeletedElements(),L)).forEach(L=>{delete x[L.id]}))})}return{..._n({editingGroupId:w.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),w,this),showHyperlinkPopup:T.link||Po(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===Dn.frame||this.state.activeTool.type===Dn.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===Dn.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(J.POINTER_MOVE,m),window.addEventListener(J.POINTER_UP,p),window.addEventListener(J.KEYDOWN,u),window.addEventListener(J.KEYUP,E),c.eventListeners.onMove=m,c.eventListeners.onUp=p,c.eventListeners.onKeyUp=E,c.eventListeners.onKeyDown=u)});I(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(Co("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let o=Ce({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t),this.zDragZoom=null,this.setState({cursorButton:"up"});return}this.handleIframeLikeCenterClick()||!this.maybeHandleElementLinkClick(t,o)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(sc=!1,yr?sc=!0:yr=window.setTimeout(()=>{yr=0,sc||this.handleCanvasContextMenu(t)},PV))});I(this,"resetContextMenuTimer",()=>{clearTimeout(yr),yr=0,sc=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{Ja?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(le.pointers.size<=1&&((t.button===So.WHEEL||t.button===So.MAIN&&ko||os(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Mo=!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(Pe.GRABBING);let{clientX:i,clientY:a}=t,s=Em(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(J.PASTE,p),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(J.PASTE,p),window.removeEventListener(J.POINTER_UP,u)},100)};document.body.addEventListener(J.PASTE,p),window.addEventListener(J.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=Ye(Ja=()=>{Ja=null,Mo=!1,ko||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(J.POINTER_MOVE,s),window.removeEventListener(J.POINTER_UP,l),window.removeEventListener(J.BLUR,l),s.flush()});return window.addEventListener(J.BLUR,l),window.addEventListener(J.POINTER_MOVE,s,{passive:!0}),window.addEventListener(J.POINTER_UP,l),!0});I(this,"updateMultiTouchGesture",t=>{le.pointers.has(t.pointerId)&&le.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=le.initialScale;if(le.pointers.size===2&&le.lastCenter&&o&&le.initialDistance){let r=Wg(le.pointers),i=r.x-le.lastCenter.x,a=r.y-le.lastCenter.y;le.lastCenter=r;let s=Vg(Array.from(le.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/le.initialDistance,c=l?Bn(o*l):this.state.zoom.value;this.setState(d=>{let m=ro({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 le.lastCenter=le.initialDistance=le.initialScale=null});I(this,"clearSelectionIfNotUsingSelection",()=>{Gp(this.state.activeTool.type)||this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,o)=>{if(Gp(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&&!Ut(a[0])&&!(Rt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=uM(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=hM($a(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=rb(XY(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Rt(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=KY(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=me.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=me.getElement(p.elementId,E);if(g&&to(g)){let{hitFocusPoint:b,pointerOffset:y,arrowOtherEndpointInitialBinding:w}=rX(g,o,E,this.state);if(b)return this.setState({selectedLinearElement:{...p,hoveredFocusPointBinding:b,draggedFocusPointBinding:b,pointerOffset:y,initialState:{...p.initialState,arrowOtherEndpointInitialBinding:w}}}),!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?ke({[p.selectedLinearElement.elementId]:!0},this.state):ke({},p)}));else if(d!=null){if(t[X.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(o.origin.x,o.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({...GY(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!cM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:ke({},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)}),vt(d))pb(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(y=>si(this.scene.getNonDeletedElements(),y)).filter(y=>vt(y)).map(y=>y.id));b.size>0&&E.forEach(y=>{y.frameId&&b.has(y.frameId)&&(delete u[y.id],y.groupIds.flatMap(w=>si(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(g=>p.selectedGroupIds[g])||(u={[d.id]:!0})),{..._n({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||Po(d)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(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);Kk(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:$t(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});I(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Ct(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=oY({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"?xV:bV},locked:!1,frameId:s?s.id:null,points:[ne(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:ke(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});I(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=Ct(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=iY({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});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Ct(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=Vp(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=Wk({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});I(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,s]=Ct(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:a,y:s}):null,c=100/this.state.zoom.value;return lY({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})});I(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(Qn(a,"selectedLinearElement is expected to be set"),i.type==="line"&&Jk(i.points,this.state.zoom.value)){Gt(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(dt);return}if(Ut(i)&&i.points.length>1){this.actionManager.executeAction(dt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=Ce(t,this.state),{start:m,end:p}=to(i)&&Up(this.state)?lX(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&&!yM(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&qn(ne(r.origin.x-s,r.origin.y-l),c)<tb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(dt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(y=>({selectedElementIds:ke({...y.selectedElementIds,[i.id]:!0},y)})),this.cursor.set(Pe.POINTER)}else{let[i,a]=Ct(r.origin.x,r.origin.y,t[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,m]=o==="arrow"?[l,c]:[null,null],p=o==="arrow"?aY({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===xr.round?{type:Fp.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===xr.elbow,fixedSegments:this.state.currentItemArrowType===xr.elbow?[]:null}):cY({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:Fp.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=ne(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=Up(this.state)?wr(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[ne(0,0),ne(0,0)]}),this.insertNewElement(p),to(p)&&QY(p,new Map([[0,{point:ne(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:kk(t.nativeEvent)}),Gt(()=>{this.setState(b=>{let y=null,w=b.selectedElementIds;if(Rt(p)){y=new me(p,this.scene.getNonDeletedElementsMap());let x=p.points.length-1;y={...y,selectedPointsIndices:[x],initialState:{...y.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:ne(r.origin.x,r.origin.y)}}}return w=this.isToolLocked()?b.selectedElementIds:ke({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&to(p)?{element:g,midPoint:bb(u,g,E,this.state.zoom)}:null,selectedElementIds:w,selectedLinearElement:y}})}),to(p)&&Co("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});I(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Ct(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),s={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},l;t==="embeddable"?l=Wk({type:"embeddable",...s}):l=sY({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});I(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Ct(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...To},s=o===Dn.magicframe?rY(a):nY(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(to(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);Yp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);Yp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else lb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&Yp(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&Yp(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)||Zk(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,eo(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});I(this,"initializeImage",async(t,o)=>{if(!vc(o))throw new Error(f("errors.unsupportedFileType"));let r=o.type;if(this.cursor.set("wait"),r===Xa.svg)try{o=uu(Qk(await o.text()),o.name)}catch(l){throw console.warn(l),new Error(f("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(o)||rx(o));if(!i)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[i]?.dataURL){let{maxWidthOrHeight:l,maxFileSizeBytes:c}=this.props.imageOptions;try{o=await(this.props.compressImageFile??sx)(o,{maxWidthOrHeight:l})}catch(d){console.error("Error trying to resize image file on insertion",d)}if(o.size>c)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(c/1024/1024)}MB`}))}let s=this.files[i]?.dataURL||await Ic(o);return new Promise(async(l,c)=>{try{let d=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:s,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:u}=await this.updateImageCache([d]);if(u.size)throw new Error("Image cache update resulted with an error.")}let m=await this.imageCache.get(i)?.image,p=m?fY(m):null;if(m&&this.state.newElement?.id!==d.id){d=this.getLatestInitializedImageElement(t,i);let u=this.getImageNaturalDimensions(d,m);Object.assign(d,u)}d=eo(d,{fileName:o.name,thumbHash:p,status:"saved"}),this.files={...this.files,[i]:{...this.files[i],fileName:o.name,thumbHash:p??void 0}},l(d)}catch(d){console.error(d),c(new Error(f("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return eo(r,{fileId:o})});I(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Ce({clientX:t,clientY:o},this.state),a=await $b({description:"Image",extensions:Object.keys(vV),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:$t(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(dt)})}});I(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}});I(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 eM({imageCache:this.imageCache,fileIds:t.map(s=>s.fileId),files:o});for(let[s,l]of r){let c=this.imageCache.get(s);!c||!i.has(s)||this.imageCache.set(s,{...c,placeholderImage:await l,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction(jt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(ja(s)){if(a.has(s.fileId))return eo(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return eo(s,{status:"saved"})}return s}))),{updatedFiles:i,erroredFiles:a}});I(this,"addNewImagesToImageCache",async(t=xY(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)&&qa.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",hV(()=>{this.addNewImagesToImageCache()},IV));I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),this.interactiveCanvas.addEventListener(J.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(J.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(J.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(J.TOUCH_END,this.onTouchEnd))});I(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,s=bM(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 ui(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),eo(u,{isDeleted:!0})}})),c=Ql(l),d=bM(l.filter(u=>!u.isDeleted),o,r,a),m=Ql(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:ke(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:jt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(dt)})});I(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Ce(t,this.state),i=Bh(t),a=await Br(t),s=a.getFiles();if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===Xa.png||d.type===Xa.svg))try{let p=await ss(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}let l=s.map(d=>d.file).filter(d=>vc(d));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,o,r,Oh(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(Xa.text);if(c){let d=c.value;if(d&&cb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||Vp(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:nb(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,o)=>{t=await ui(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await ss(t,this.state,r,o)}catch(a){let s=a instanceof Zb;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;kM(r.concat(i.elements)),this.store.scheduleMicroAction({action:jt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({elements:i.elements,files:i.files,appState:{...i.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});I(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!==So.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Ce(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),s=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},a),l=i||s?"element":"canvas",c=this.excalidrawContainerRef.current,{top:d,left:m}=c.getBoundingClientRect(),p=t.clientX-m,u=t.clientY-d;Ne("contextMenu","openContextMenu",l),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,..._n({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Rt(i)?new me(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(l,i)}})})});I(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){gM({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Za(t.origin.x,a.x),height:Za(t.origin.y,a.y),shouldMaintainAspectRatio:$l(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]=Ct(a.x,a.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=ja(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}=x2(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}),to(s)||gM({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:Za(t.originInGrid.x,l),height:Za(t.originInGrid.y,c),shouldMaintainAspectRatio:no(s)?!$l(o):$l(o),shouldResizeFromCenter:Pk(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===Dn.frame||this.state.activeTool.type===Dn.magicframe)&&this.setState({elementsToHighlight:hb(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=Ct(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&no(l)){let c=t.originalElements.get(l.id),d=ja(l)&&this.imageCache.get(l.fileId)?.image;if(c&&no(c)&&d&&!(d instanceof Promise)){let[m,p]=Ct(i.x,i.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:E,snapLines:g}=Zg([l],[c],this,o,u,r);this.scene.mutateElement(l,DY(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),Wp(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});I(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(vt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Ut(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=Ct(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{pb(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]=Ct(s.x,s.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y},E=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(o,r);let{snapOffset:g,snapLines:b}=Zg(r,ie(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(ZY(t.originalElements,a,r,this.scene,kk(o),Pk(o),r.some(m=>no(m))?!$l(o):$l(o),l,c,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{hb(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{Kp(u)?m.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...m]}),!0}return!1});I(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=>no(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&no(t)?[...o([t.id])]:[]});I(this,"getContextMenuItems",(t,o)=>{let r=this.getImageContextMenuItems(o);if(t==="canvas")return this.state.viewModeEnabled?[Ys,ji,Zr,er]:[jh,rt,ju,av,rt,ji,kt,Xs,Ks,Zr,er];if(this.state.viewModeEnabled)return[Ys,$i,r.length>0&&rt,...r];let i=this.editorInterface.formFactor==="desktop"?[rt,Xu,Ku,Zu,$u]:[];return[rt,Ys,rt,qd,$i,jh,r.length>0&&rt,...r,rt,Jv,Qv,e2,rt,Ng,rt,Yh,Gg,eg,tg,Wy,Xh,rt,...i,rt,Zh,$h,rt,aa,rt,dg,jv,rt,qu,js,rt,Es]});I(this,"handleWheel",Ye(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(ab.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[X.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Mo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=MV*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:AV;c=Math.max(c,d),this.viewport.translate(p=>({...ro({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:Bn(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}))}));I(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=Ce({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let s={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:s,button:r,pointersMap:le.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",Nk(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(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()}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});I(this,"watchState",()=>{});let o=Ro(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${Ok()}`,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=$t(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===jl.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=Jp(this.editorInterface),this.id=fV(),this.actionManager=new um(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new fM,this.canvas=document.createElement("canvas"),this.rc=gV.canvas(this.canvas),this.renderer=new fl(this.scene),this.visibleElements=[],this.store=new qY(this),this.history=new hl(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new io(this.scene),this.history=new hl(this.store),this.actionManager.registerAll(Gc),this.actionManager.registerAction(r2(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(zp).includes(i)&&xb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){Qn(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=wr(ne(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=me.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&o?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Gt(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:o}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;Qn(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?me.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):me.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||Ut(t))return;let r=()=>{if(this.bindModeHandler=null,Qn(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=wr(ne(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){Qn(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let E=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Gt(()=>{Qn(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;Qn(g,"Last event must exist");let b=m-this.state.selectedLinearElement.pointerOffset.x,y=p-this.state.selectedLinearElement.pointerOffset.y,w=this.state.multiElement?me.handlePointerMove(g,this,b,y,this.state.selectedLinearElement):me.handlePointDragging(g,this,b,y,this.state.selectedLinearElement);w&&this.setState(w)}},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&&wM(E,m),y=g&&wM(g,m);i=!!(b&&y&&E.id!==g.id&&eX(b,y))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),s=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),l=a?"startBinding":s?"endBinding":null,c=a?"endBinding":s?"startBinding":null,d=c&&t[c]?.mode==="inside"&&t[c]?.elementId===o?.id||l&&t[l]?.mode==="inside"&&o?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&o?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!o||this.previousHoveredBindableElement&&o.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Gt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,XV)),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!==So.MAIN||ko||!Hk(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=ne(Ce({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=ne(Ce({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(qn(t,o)>Ak)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&le.pointers.size<2&&tc(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 c=xb.get(s.id);switch(c||(xb.set(s.id,zp.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case zp.PLAYING:case zp.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=>Po(a)&&this.embedsValidationStatus.get(a.id)===!0||sb(a));return Ie(pX,{children:i.map(a=>{let{x:s,y:l}=Hp({sceneX:a.x,sceneY:a.y},this.state),c=jk(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=Vp(NV(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=Zl(g?t:1,.75,dX);return Ie("div",{className:vk("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:HY(a,gb(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?_V:1),"--embeddable-radius":`${EY(Math.min(a.width,a.height),a)}px`},children:wb("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?Ka.enabled:Ka.disabled},children:[E&&Ie("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Ie("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:Ie("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(Po(a)?this.props.renderEmbeddable?.(a,this.state):null)??Ie("iframe",{ref:y=>this.cacheEmbeddableRef(a,y),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=gt.get(Zn)?.type==="panel";return Ie("div",{translate:"no",className:vk("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?Ka.disabled:Ka.enabled,"--right-sidebar-width":`${zf}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:Ie(Qa.Provider,{value:this.api,children:Ie(MM.Provider,{value:this,children:Ie(AM.Provider,{value:this.props,children:Ie(Tb.Provider,{value:this.excalidrawContainerValue,children:Ie(Ib.Provider,{value:this.editorInterface,children:Ie(Pb.Provider,{value:this.setAppState,children:Ie(Cb.Provider,{value:this.state,children:wb(Sb.Provider,{value:this.scene.getNonDeletedElements(),children:[wb(kb.Provider,{value:this.actionManager,children:[Ie(tk,{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:Fn().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}),Ie("div",{className:"excalidraw-textEditorContainer"}),Ie("div",{className:"excalidraw-contextMenuContainer"}),Ie("div",{className:"excalidraw-eye-dropper-container"}),Ie(ok,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Ie(xk,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Ie(jy,{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&&Ie(MT,{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?.()})}}),Ie(qE,{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,isExporting:!1,renderGrid:or(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&&Ie(uk,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,renderConfig:{imageCache:this.imageCache,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}}),Ie(jE,{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"&&Ie(Jm,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Ie(yk,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Ie(rT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{ja(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),qa.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,SM()||CM()){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(),LV&&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),$V()&&!NY()&&this.setState({errorMessage:Ie(yT,{})});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.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 fM,this.fonts=new io(this.scene),this.renderer=new fl(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(),qa.destroy(),ln.destroy(),clearTimeout(yr),Me.clearCache(),_n.clearCache(),yr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(be(window,J.MESSAGE,this.onWindowMessage,!1),be(document,J.POINTER_UP,this.removePointer,{passive:!1}),be(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),be(window,J.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),be(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.handleNavigationModeKeyDown,!1),be(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),be(document,J.GESTURE_START,this.onGestureStart,!1),be(document,J.GESTURE_CHANGE,this.onGestureChange,!1),be(document,J.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),be(this.excalidrawContainerRef.current,J.GESTURE_START,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.GESTURE_CHANGE,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(be(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(be(document,J.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),be(document,J.COPY,this.onCopy,{passive:!1}),be(document,J.KEYUP,this.onKeyUp,{passive:!0}),be(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),be(document,J.GESTURE_START,this.onGestureStart,!1),be(document,J.GESTURE_CHANGE,this.onGestureChange,!1),be(document,J.GESTURE_END,this.onGestureEnd,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(be(document,J.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),be(document,J.PASTE,this.pasteFromClipboard,{passive:!1}),be(document,J.CUT,this.onCut,{passive:!1}),be(window,J.RESIZE,this.onResize,!1),be(window,J.UNLOAD,this.onUnload,!1),be(window,J.BLUR,this.onBlur,!1),be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),be(this.excalidrawContainerRef.current,J.DRAG_OVER,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(be(BV(this.excalidrawContainerRef.current),J.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.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===jl.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&&qt(this.state)&&this.setState({activeTool:$t(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(),qt(o)&&!qt(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===jl.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(dt)});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:ke(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(){oc=!1,ic=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Ce({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(o.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&t.text){let d=_m(t.text);if(d.ok){this.setState({openDialog:{name:"charts",data:d.data,rawText:t.text}});return}}let s=o.map(d=>d.file);if(s.length===0&&t.text&&!r){let d=t.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&s.push(uu(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?tX(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=GV(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>bY(d)).filter(d=>cb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||Vp(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:nb(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)}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 lx(d)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=f("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=f("errors.unsupportedFileType")),{errorMessage:p}}})),l=s.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(l,r,i);let c=s.find(d=>!!d.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(s=>s.type==="text");a.length&&this.addTextFromPaste(a.map(s=>s.value).join(`
20
+ `)},bU=(e,n,t)=>{let r=EU(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=Vl(u,Cp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let v=Vl(m.line,Cp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;g.width+=T}let{width:b,height:y}=Vl(E,Cp(e),e.lineHeight),w=g.width,x=m.lineNumber*g.height;d.push({offsetX:w,offsetY:x,width:b,height:y,showOnCanvas:!0}),l+=p}}return d},xU=(e,n,t,o)=>{let r=e.name??PP(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=Cp({fontSize:AE.nameFontSize,fontFamily:ME.Assistant}),l=sU(ME.Assistant),c=Vl(a,s,l);a===""&&(c.width=0);let d=Vl(i,s,l),m=c.width,p=-c.height-AE.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},wU=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),SP=nU((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>CP(p)),i=o.filter(p=>Pp(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(wU(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=TP(E,u.index,e),b=bU(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??PP(p);for(;(u=s.exec(E))!==null;){let g=TP(E,u.index,e),b=xU(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)},uU);import RU from"clsx";import{useEffect as RP,useLayoutEffect as NP,useRef as HE,useState as NU,forwardRef as BP,useImperativeHandle as BU,useCallback as LP}from"react";import{CLASSES as OU,EVENT as DP,isDevEnv as FU,KEYS as zU,updateObject as HU}from"@excalidraw/common";import IU from"clsx";import{useContext as TU}from"react";import vU from"react";var kp=vU.createContext({});import{jsx as DE,jsxs as MP}from"react/jsx-runtime";var _E=({children:e,className:n})=>{let t=ge(),o=TU(kp),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return MP("div",{className:IU("sidebar__header",n),"data-testid":"sidebar-header",children:[e,MP("div",{className:"sidebar__header__buttons",children:[r&&DE(ct,{label:f("labels.sidebarLock"),children:DE(fn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:fx})}),DE(fn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:Jt})]})]})};_E.displayName="SidebarHeader";import{Tabs as SU}from"radix-ui";import{jsx as AP}from"react/jsx-runtime";var RE=({children:e,tab:n,onSelect:t,...o})=>AP(SU.Trigger,{value:n,asChild:!0,onSelect:t,children:AP("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});RE.displayName="SidebarTabTrigger";import{Tabs as CU}from"radix-ui";import{jsx as PU}from"react/jsx-runtime";var NE=({children:e,...n})=>PU(CU.List,{className:"sidebar-triggers",...n,children:e});NE.displayName="SidebarTabTriggers";import kU from"clsx";import{jsx as BE,jsxs as MU}from"react/jsx-runtime";var OE=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Ue(),d=fe().openSidebar?.name===e;return BE("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:MU("div",{className:kU("sidebar-trigger",a),style:s,children:[t&&BE("div",{children:t}),r&&BE("div",{className:"sidebar-trigger__label",children:r})]})})};OE.displayName="SidebarTrigger";import{Tabs as AU}from"radix-ui";import{jsx as LU}from"react/jsx-runtime";var FE=({children:e,...n})=>{let t=fe(),o=Ue();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return LU(AU.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};FE.displayName="SidebarTabs";import{Tabs as DU}from"radix-ui";import{jsx as _U}from"react/jsx-runtime";var zE=({tab:e,children:n,...t})=>_U(DU.Content,{...t,value:e,"data-testid":e,children:n});zE.displayName="SidebarTab";import{jsx as _P}from"react/jsx-runtime";import{createElement as GU}from"react";var GE=qe(!1),OP=BP(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{FU()&&t&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=Ue(),l=cx(GE);NP(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=HE({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=HU(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=HE(null);BU(a,()=>d.current);let m=ge(),p=LP(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Ti(d,LP(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),RP(()=>{let u=E=>{E.key===zU.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(DP.KEYDOWN,u),()=>{document.removeEventListener(DP.KEYDOWN,u)}},[p,o,m.canFitSidebar]),_P(ze,{...i,className:RU(OU.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:_P(kp.Provider,{value:c.current,children:n})})});OP.displayName="SidebarInner";var Er=Object.assign(BP((e,n)=>{let t=fe(),{onStateChange:o}=e,r=HE(t.openSidebar);RP(()=>{(!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]=NU(!1);return NP(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?GU(OP,{...e,ref:n,key:e.name}):null}),{Header:_E,TabTriggers:NE,TabTrigger:RE,Tabs:FE,Tab:zE,Trigger:OE});Er.displayName="Sidebar";import{jsx as Va,jsxs as VU}from"react/jsx-runtime";import{createElement as YU}from"react";var zP=ei("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=tt();return Va(n.In,{children:Va(Er.Trigger,{...e,className:"default-sidebar-trigger",name:WU.name})})});zP.displayName="DefaultSidebarTrigger";var HP=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=tt();return Va(n.In,{children:e})};HP.displayName="DefaultTabTriggers";var UE=Object.assign(ei("DefaultSidebar",({children:e,className:n,docked:t,...o})=>{let r=fe(),i=r.openSidebar?.tab===FP;return YU(Er,{...o,name:"default",key:"default",className:UU("default-sidebar",{"default-sidebar--search-only":i},n),docked:i?!1:t??r.defaultSidebarDockedPreference,onDock:void 0},VU(Er.Tabs,{children:[!i&&Va(Er.Header,{}),Va(Er.Tab,{tab:FP,children:Va(kP,{})}),!i&&e]}))}),{Trigger:zP,TabTriggers:HP});import KU from"react";import{getFrame as ZU}from"@excalidraw/common";import{jsx as XU}from"react/jsx-runtime";var WE={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"}},VE=({children:e,color:n})=>XU("div",{className:"Card",style:{"--card-color":WE[n].base,"--card-color-darker":WE[n].darker,"--card-color-darkest":WE[n].darkest},children:e});import{Fragment as jU,jsx as Ln,jsxs as Mp}from"react/jsx-runtime";var $U=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return Ln("div",{className:"ExportDialog ExportDialog--json",children:Mp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Mp(VE,{color:"lime",children:[Ln("div",{className:"Card-icon",children:_x}),Ln("h2",{children:f("exportDialog.disk_title")}),Mp("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!mi&&r.renderAction("changeProjectName")]}),Ln(K,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Ws,"ui")}})]}),l&&Mp(VE,{color:"pink",children:[Ln("div",{className:"Card-icon",children:hs}),Ln("h2",{children:f("exportDialog.link_title")}),Ln("div",{className:"Card-details",children:f("exportDialog.link_details")}),Ln(K,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ne("export","link",`ui (${ZU()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},GP=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=KU.useCallback(()=>{a({openDialog:null})},[a]);return Ln(jU,{children:n.openDialog?.name==="jsonExport"&&Ln(gn,{onCloseRequest:s,title:f("buttons.export"),children:Ln($U,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import qU from"clsx";import{jsx as JU}from"react/jsx-runtime";var UP=e=>JU(K,{className:qU("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:Wn,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import $P from"clsx";import{useState as dW}from"react";import{CANVAS_SEARCH_TAB as mW,DEFAULT_SIDEBAR as pW,KEYS as Yl}from"@excalidraw/common";import{CANVAS_SEARCH_TAB as QU,DEFAULT_SIDEBAR as eW}from"@excalidraw/common";import{isArrowElement as tW,isFlowchartNodeElement as nW,isImageElement as WP,isLinearElement as VP,isLineElement as oW,isTextBindableContainer as rW,isTextElement as iW}from"@excalidraw/element";import{isNodeInFlowchart as aW}from"@excalidraw/element";import{jsx as YE}from"react/jsx-runtime";var xe=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,sW=({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===eW.name&&e.openSidebar.tab===QU&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:xe("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(qt(e))return f("hints.eraserRevert",{shortcut:xe("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:xe("Ctrl"),shortcut_2:xe("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:xe("Escape"),shortcut_2:xe("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:xe("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 VP(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:xe("Shift")}):WP(d)?f("hints.resizeImage",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")}):f("hints.resize",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:xe("Shift")});if(c.length===1&&iW(c[0]))return f("hints.text_selected",{shortcut:xe("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:xe("Escape"),shortcut_2:xe(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:xe("Enter"),shortcut_2:xe("Escape")});if(c.length===1&&WP(c[0]))return f("hints.enterCropEditor",{shortcut:xe("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:xe("CtrlOrCmd")});if(or(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:xe("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:xe(f("keys.mmb")),shortcut_2:xe("Space")});if(c.length===1){if(VP(c[0]))return tW(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:xe("Delete"),shortcut_2:xe(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:xe("Shift"),shortcut_2:xe("Alt")}):oW(c[0])?f("hints.lineEditor_line_info",{shortcut:xe("Enter")}):f("hints.lineEditor_info",{shortcut_1:xe("CtrlOrCmd"),shortcut_2:xe(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&rW(c[0])){let d=f("hints.bindTextToElement",{shortcut:xe("Enter")}),m=f("hints.createFlowchart",{shortcut:xe(["CtrlOrCmd","\u2191\u2193"])});return nW(c[0])?aW(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},YP=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let r=sW({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 YE("kbd",{children:c?c[1]:s},l)}return s});return YE("div",{className:"HintViewer",children:YE("span",{children:a})})};import lW from"clsx";import{jsx as cW}from"react/jsx-runtime";var XP=e=>cW(K,{className:lW("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?No:so,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":"toolbar-lock",onSelect:()=>e.onChange?.()});import{Fragment as ai,jsx as oe,jsxs as To}from"react/jsx-runtime";var uW=(e,n)=>e==="image"&&n.tools?.image===!1,hW=({app:e,activeTool:n,type:t,shortcut:o})=>oe(de.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:We[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??Hi(t),disabled:Ze(e,t),children:f(`toolBar.${t}`)}),KP=({app:e})=>oe(de.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?No:so,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:Yl.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),gW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=Ke("objectsSnapMode");return oe(de.Item,{onSelect:()=>e.executeAction(kt,"ui"),icon:Fo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},fW=({actionManager:e,app:n})=>{if(!e.isActionEnabled(kt))return null;let t=f("buttons.objectsSnapMode"),o=Ke("objectsSnapMode");return oe(K,{type:"toggle",icon:Fo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(kt,"ui")})},ZP=({actionManager:e,appState:n})=>{let t=f("search.title"),o=Ke("searchMenu");return oe(de.Item,{onSelect:()=>e.executeAction(pl,"ui"),icon:Vn,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===pW.name&&n.openSidebar.tab===mW,shortcut:o,children:t})},EW=({app:e})=>oe(K,{type:"button",icon:yi,title:`${f("labels.eyeDropper")} - ${Yl.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":Yl.I.toLocaleUpperCase(),keyBindingLabel:Yl.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),bW=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=dW(!1),l=at()==="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&&Fi.includes(n.type);return To(de,{open:a,children:[oe(de.Trigger,{className:$P("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?We[n.type].icon:c?Un:E?Oo:!r&&l&&d?Mr:m&&!e.props.isCollaborating?Wn:u?fi:p?Gn:cs}),oe(de.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?To(ai,{children:[l&&oe(de.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:fi,"data-testid":"toolbar-lasso",selected:u,disabled:Ze(e,"lasso"),children:f("toolBar.lasso")}),Fi.filter(b=>!uW(b,o)).map(b=>oe(hW,{app:e,activeTool:n,type:b},b)),oe("div",{className:"App-toolbar__dropdown-divider"}),oe(ZP,{actionManager:i,appState:e.state}),e.props.activeTool==null&&oe(ai,{children:oe(KP,{app:e})})]}):To(ai,{children:[oe(de.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:Un,shortcut:Yl.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:Ze(e,"frame"),children:f("toolBar.frame")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:Oo,"data-testid":"toolbar-embeddable",selected:E,disabled:Ze(e,"embeddable"),children:f("toolBar.embeddable")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Mr,shortcut:Hi("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:Ze(e,"autoshape"),children:f("toolBar.autoshape")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:Wn,"data-testid":"toolbar-laser",selected:m,disabled:Ze(e,"laser"),children:f("toolBar.laser")}),oe(de.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:Gn,"data-testid":"toolbar-bucketfill",selected:p,disabled:Ze(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&oe(de.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:fi,"data-testid":"toolbar-lasso",selected:u,disabled:Ze(e,"lasso"),children:f("toolBar.lasso")}),oe("div",{className:"App-toolbar__dropdown-divider"}),oe(gW,{actionManager:i,app:e}),oe(ZP,{actionManager:i,appState:e.state}),e.props.activeTool==null&&oe(KP,{app:e})]})})]})},jP=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=ge(),c=at()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?oe(kd,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?oe(Rw,{...m}):oe(_w,{...m});return To(ze,{padding:1,className:$P("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[oe(YP,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,To(Dt.Row,{gap:c?.5:1,children:[!c&&oe(Ra,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&To(ai,{children:[oe(XP,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),oe("div",{className:"App-toolbar__divider"})]}),oe(Pd,{...m}),u,p?To(ai,{children:[oe(Rs,{...m}),oe(Ns,{...m}),oe(EW,{app:e}),o.tools?.image!==!1&&oe(Bs,{...m}),oe(Os,{...m})]}):To(ai,{children:[oe(Pw,{...m}),oe(kw,{...m}),oe(Mw,{...m}),oe(Aw,{...m}),oe(Lw,{...m}),c?oe(Md,{...m}):oe(Rs,{...m}),oe(Ns,{...m}),o.tools?.image!==!1&&oe(Bs,{...m}),oe(Os,{...m})]}),oe("div",{className:"App-toolbar__divider"}),oe(bW,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&To(ai,{children:[oe("div",{className:"App-toolbar__divider"}),oe(fW,{actionManager:r,app:e})]})]})]})};import{Fragment as XE,jsx as ee,jsxs as Zt}from"react/jsx-runtime";var SW=({UIOptions:e})=>Zt(_t,{__fallback:!0,children:[ee(_t.DefaultItems.LoadScene,{}),ee(_t.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ee(_t.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ee(_t.DefaultItems.SaveAsImage,{}),ee(_t.DefaultItems.SearchMenu,{}),ee(_t.DefaultItems.Help,{}),ee(_t.Separator,{}),ee(_t.Group,{title:"Excalidraw links",children:ee(_t.DefaultItems.Socials,{})}),ee(_t.Separator,{}),ee(_t.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),ee(_t.DefaultItems.ChangeCanvasBackground,{})]}),CW=()=>Zt(pp,{__fallback:!0,children:[ee(pp.Actions.SaveToDisk,{}),ee(pp.Actions.ExportToImage,{})]}),PW=({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:y,zoomUIEnabled:w,scrollBackToContentUIEnabled:x,isCollaborating:v,generateLinkForSelection:T,currentUserControls:C})=>{let P=ge(),A=yn(),_=at()==="compact",k=MT(),D=_?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},O=k.tunnelsJotai.Provider,[Y,z]=Fe(Nt),W=()=>p.canvasActions.export?ee(GP,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,Z=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:ee(xP,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),H=()=>Zt("div",{style:{position:"relative"},children:[Zt("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),ee(k.MainMenuTunnel.Out,{})]}),E&&ee(k.WelcomeScreenMenuHintTunnel.Out,{})]}),re=()=>ee(Dl,{heading:"selectedShapeActions",className:Ya("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?ee(ze,{className:Ya("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:ee(KT,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):ee(ze,{className:wW.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:ee(UT,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),B=()=>{let pe=y&&IW(n,r),he=y&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return ee(op,{side:"top",children:Zt("div",{className:"App-menu App-menu_top",children:[Zt(Dt.Col,{gap:D.menuTopGap,className:Ya("App-menu_top__left"),children:[H(),y&&ee("div",{className:Ya("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:pe&&re()}),y&&_&&!n.viewModeEnabled&&pe&&ee(Ra,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),y&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&ee(Dl,{heading:"shapes",className:"shapes-section",children:ye=>Zt("div",{style:{position:"relative"},children:[E&&ee(k.WelcomeScreenToolbarHintTunnel.Out,{}),ee(Dt.Col,{gap:D.toolbarColGap,align:"start",children:Zt(Dt.Row,{gap:D.toolbarRowGap,className:Ya("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[ee(jP,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ye}),v&&ee(ze,{style:{marginLeft:D.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:ee(UP,{title:f("toolBar.laser"),checked:n.activeTool.type===qP.laser,onChange:()=>b.setActiveTool({type:qP.laser}),isMobile:!0})})]})})]})}),Zt("div",{className:Ya("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":n.zenModeEnabled,"layer-ui__wrapper__top-right--compact":_}),children:[y&&n.collaborators.size>0&&ee(sp,{collaborators:n.collaborators,userToFollow:A.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),he&&ee(Hl,{app:b,onClose:()=>{e.executeAction(er)},renderCustomStats:m})]})]})})},U=()=>ee(UE,{}),ue=!1,we=Zt(XE,{children:[g,y&&ee(XE,{children:ee(SW,{UIOptions:p})}),ee(CW,{}),y&&n.isLoading&&ee(Jm,{delay:250}),y&&n.errorMessage&&ee(lP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),y&&Y&&P.formFactor!=="phone"&&ee(f0,{colorPickerType:Y.colorPickerType,onCancel:()=>{z(null)},onChange:(pe,he,ye,{altKey:ae})=>{if(!(pe!=="elementBackground"&&pe!=="elementStroke"))if(ye.length){for(let ve of ye)vW(ve,yW(r),{[ae&&Y.swapPreviewOnAlt?pe==="elementBackground"?"strokeColor":"backgroundColor":pe==="elementBackground"?"backgroundColor":"strokeColor"]:he}),TW.delete(ve);b.scene.triggerUpdate()}else o(pe==="elementBackground"?{currentItemBackgroundColor:he}:{currentItemStrokeColor:he})},onSelect:(pe,he)=>{z(ye=>ye?.keepOpenOnAlt&&he.altKey?ye:null),Y?.onSelect?.(pe,he)}}),n.openDialog?.name==="help"&&ee(pP,{onClose:()=>{o({openDialog:null})}}),y&&n.openDialog?.name==="elementLinkSelector"&&ee(sP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),ee(k.OverwriteConfirmDialogTunnel.Out,{}),Z(),W(),y&&n.openDialog?.name==="charts"&&ee(BS,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),P.formFactor==="phone"&&ee(TS,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:W,renderImageExportDialog:Z,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:U,renderWelcomeScreen:E,defaultUIEnabled:y,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&Zt(XE,{children:[A.viewportStatusFrame?.border&&ee($m,{border:A.viewportStatusFrame.border,style:ue?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),Zt("div",{className:"layer-ui__wrapper",style:ue?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&ee(k.WelcomeScreenCenterTunnel.Out,{}),B(),ee(WS,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:y,zoomUIEnabled:w}),(n.toast||x&&n.scrolledOutside||A.viewportStatusFrame?.label)&&Zt("div",{className:"floating-status-stack",children:[n.toast&&ee(_d,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&ee("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(pe=>({...ci(r,pe)}))},children:f("buttons.scrollBackToContent")}),A.viewportStatusFrame?.label&&ee(jm,{label:A.viewportStatusFrame.label,border:A.viewportStatusFrame.border})]})]}),U()]})]});return ee(qu.Provider,{value:n,children:ee(O,{children:ee(Ff.Provider,{value:k,children:we})})})},JP=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},kW=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return Ap(JP(o),JP(a),{selectedElementIds:Ap,selectedGroupIds:Ap})&&Ap(r,s)},QP=xW.memo(PW,kW);import{useEffect as MW,useRef as AW}from"react";import{jsx as ek}from"react/jsx-runtime";var tk=({trails:e})=>{let n=AW(null);return MW(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),ek("div",{className:"SVGLayer",children:ek("svg",{ref:n})})};import LW,{useEffect as nk,useRef as ok}from"react";import{isShallowEqual as DW,sceneCoordsToViewportCoords as _W}from"@excalidraw/common";import{jsx as BW}from"react/jsx-runtime";var rk="animateInteractiveScene",RW=e=>{let n=ok(!1),t=ok(null);return nk(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&vf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),nk(()=>{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,_W({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},rt.running(rk)||rt.start(rk,({deltaTime:c,state:d})=>{let m=vf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),BW("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")})},ik=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}),NW=(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:DW(ik(e.appState),ik(n.appState)),KE=LW.memo(RW,NW);import lk,{useEffect as Lp,useRef as Xl}from"react";import{isShallowEqual as ak}from"@excalidraw/common";import{jsx as zW}from"react/jsx-runtime";var OW=e=>{let n=Xl(null),t=Xl(!1),o=Xl(e),r=Xl(()=>{}),i=Xl(null);o.current=e;let a=lk.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();jb({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}},ma());let m=s.renderConfig.imageTransitionDuration??0;m>0&&s.visibleElements.some(u=>{if(u.type!=="image"||!u.fileId)return!1;let E=s.renderConfig.imageCache.get(u.fileId)?.transitionStart;return E!==void 0&&performance.now()-E<m})&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,Lp(()=>{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]),Lp(()=>{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()}),Lp(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),Lp(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),zW("div",{className:"excalidraw__canvas-wrapper",ref:n})},sk=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}),FW=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:ak(sk(e.appState),sk(n.appState))&&ak(e.renderConfig,n.renderConfig),ZE=lk.memo(OW,FW);import{useEffect as XW,useRef as KW}from"react";import{throttleRAF as HW}from"@excalidraw/common";import{getTargetFrame as GW,isInvisiblySmallElement as UW,renderElement as WW,shouldApplyFrameClip as VW}from"@excalidraw/element";var ck=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Ec(e,i),d=bc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),d.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(UW(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=GW(t,o,a);u&&VW(t,u,a,o)&&Zb(u,d,s,a)}WW(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},YW=HW(e=>{ck(e)}),dk=(e,n)=>{if(n){YW(e);return}ck(e)};import{jsx as $W}from"react/jsx-runtime";var ZW=e=>{let n=KW(null);return XW(()=>{n.current&&dk({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())}),$W("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})},mk=ZW;import jW from"clsx";import{useLayoutEffect as qW,useEffect as pk,useRef as JW,useState as QW}from"react";import{ARROW_TYPE as uk,EVENT as Dp}from"@excalidraw/common";import{jsx as oV}from"react/jsx-runtime";var hk=700,eV=100,tV=16,nV=5*60*1e3,fk=qe(null),gk=e=>e===uk.elbow?Ho:e===uk.round?Go:zo,_p=class{constructor(n){I(this,"app");I(this,"lastShownAt",0);I(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(fk,{content:n,nonce:Math.random()}))});I(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<nV);I(this,"onArrowTypeCycled",n=>{this.show(gk(n))});I(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?Bo:gk(this.app.state.currentItemArrowType))});this.app=n}},Ek=()=>{let[e,n]=Fe(fk),t=It(),{container:o}=De(),r=JW(null),[i,a]=QW(!1),s=e?.nonce;return qW(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=$c({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:tV});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(Dp.POINTER_MOVE,c),()=>{window.removeEventListener(Dp.POINTER_MOVE,c)}},[s,o,t]),pk(()=>()=>{n(null)},[n]),pk(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},hk),c=window.setTimeout(()=>{n(null)},hk+eV),d=()=>{n(null)};return window.addEventListener(Dp.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(Dp.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?oV("div",{ref:r,className:jW("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var Rp=class{constructor(n){this.getState=n;I(this,"listeners",[]);I(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 rV,getElementsInGroup as iV,isNonDeletedElement as bk,selectGroupsFromGivenElements as aV}from"@excalidraw/element";import{sceneCoordsToViewportCoords as sV}from"@excalidraw/common";import{flushSync as lV}from"react-dom";import{jsx as dV}from"react/jsx-runtime";var cV=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!bk(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&bk(t)?t:null,r=o?[o]:iV(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=rV(r),{x:s,y:l}=sV({sceneX:i,sceneY:a},e.state);return dV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{lV(()=>{let c=aV(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(js)},title:f("labels.elementLock.unlock"),children:Ex})},xk=cV;import{Fragment as lX,jsx as Ie,jsxs as fb}from"react/jsx-runtime";var kM=En.createContext(null),MM=En.createContext(null),Eb={formFactor:"desktop",desktopUIMode:"full",userAgent:CM(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},xb=En.createContext(Eb);xb.displayName="EditorInterfaceContext";var iX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},wb=En.createContext({container:null,id:null});wb.displayName="ExcalidrawContainerContext";var yb=En.createContext([]);yb.displayName="ExcalidrawElementsContext";var vb=En.createContext({...Ro(),width:0,height:0,offsetLeft:0,offsetTop:0});vb.displayName="ExcalidrawAppStateContext";var Ib=En.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Ib.displayName="ExcalidrawSetAppStateContext";var Tb=En.createContext(null);Tb.displayName="ExcalidrawActionManagerContext";var Qa=En.createContext(null);Qa.displayName="ExcalidrawAPIContext";var qp=En.createContext(null);qp.displayName="ExcalidrawAPISetContext";var It=()=>Ao(kM),yn=()=>Ao(MM),ge=()=>Ao(xb),at=()=>jp(ge()),De=()=>Ao(wb),Ci=()=>Ao(yb),Ko=()=>Ao(vb),Ue=()=>Ao(Ib),nt=()=>Ao(Tb),Ed=()=>Ao(Qa),nc=!1,oc=0,rc=null,ko=!1,Xp=!1,Mo=!1,Kp=!1,ic={horizontal:null,vertical:null},yr=0,ac=!1,gb=new Map,aX=4,Zp=!1,$p=0,IM=!1,Ja=null,le={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},bb=class e extends En.Component{constructor(t){super(t);I(this,"canvas");I(this,"interactiveCanvas",null);I(this,"sessionExportThemeOverride");I(this,"rc");I(this,"unmounted",!1);I(this,"actionManager");I(this,"editorInterface",Eb);I(this,"stylesPanelMode",jp(Eb));I(this,"excalidrawContainerRef",En.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"hasRenderableElements",!1);I(this,"resizeObserver");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"imageLoadingProgress",new Map);I(this,"imageLoadingProgressEmitter",new Qn);I(this,"imageStatus",new Map);I(this,"imageStatusEmitter",new Qn);I(this,"imagePlaceholderUpdateEmitter",new Qn);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"elementsPendingErasure",new Set);I(this,"_initialized",!1);I(this,"editorLifecycleEvents",new HV(iX));I(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));I(this,"appStateObserver",new Rp(()=>this.state));I(this,"onStateChange",this.appStateObserver.onStateChange);I(this,"bucketFill",new Hm(this));I(this,"flowchart",new Ym(this));I(this,"cursor",new Gm(this));I(this,"zDragZoom",null);I(this,"arrowText",new zm(this));I(this,"viewport",new Km(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>le.pointers.size>=2||Mo}));I(this,"bindModeHandler",null);I(this,"textWysiwygSubmitHandler",null);I(this,"hitLinkElement");I(this,"lastPointerDownEvent",null);I(this,"lastPointerUpEvent",null);I(this,"lastPointerUpIsDoubleClick",!1);I(this,"lastPointerMoveEvent",null);I(this,"lastPointerMoveCoords",null);I(this,"lastCompletedCanvasClicks",[]);I(this,"previousPointerMoveCoords",null);I(this,"drawShape",new Vm(this));I(this,"laserTrails",new fm(this));I(this,"eraserTrail",new Im(this));I(this,"lassoTrail",new vm(this));I(this,"cursorHints",new _p(this));I(this,"onChangeEmitter",new Qn);I(this,"onPointerDownEmitter",new Qn);I(this,"onPointerUpEmitter",new Qn);I(this,"onUserFollowEmitter",new Qn);I(this,"onScrollChangeEmitter",new Qn);I(this,"missingPointerEventCleanupEmitter",new Qn);I(this,"onRemoveEventListenersEmitter",new Qn);I(this,"api");I(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});I(this,"updateEditorAtom",(t,...o)=>{let r=gt.set(t,...o);return this.triggerRender(),r});I(this,"previousHoveredBindableElement",null);I(this,"getEffectiveGridSize",()=>or(this)?this.state.gridSize:null);I(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)}});I(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&ec(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Pe.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));I(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=Ak);I(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),qa.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Po(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=ib(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else ob(r)&&t.add(r.id);return!1}),o&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(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=Ce({clientX:i.x,clientY:i.y},this.state),s=Ce({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});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===$l.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&vt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!Zk(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}=Fp({sceneX:i.x,sceneY:i.y},this.state),l=6,c,d=TY(i);if(i.id===this.state.editingFrame){let m=d;c=Ie("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===X.ESCAPE||p.key===X.ENTER)&&this.resetEditingFrame(i)},style:{background:zV(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:`${So.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?So.nameColorDarkTheme:So.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 Ie("div",{id:this.getFrameNameDOMId(i),className:nb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+So.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:So.nameFontSize,color:t?So.nameColorDarkTheme:So.nameColorLightTheme,lineHeight:So.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:Pe.MOVE,pointerEvents:this.state.viewModeEnabled?Ka.disabled:Ka.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,o,r)=>{Ne("export",t,"ui");let i=await Fr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(OV).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&wc(i)&&this.setState({fileHandle:i})});I(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Nt,{swapPreviewOnAlt:o,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,i)=>{let a=t==="stroke"?!o||!i.altKey:o&&i.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:jt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:jt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?to(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:jt.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Ye(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||$l.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&&Yp(d)&&Wt(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()}));I(this,"scheduleCapture",()=>this.store.scheduleCapture());I(this,"onBlur",Ye(()=>{ko=!1,this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"preventBrowserZoomWheel",t=>{t[X.CTRL_OR_CMD]&&t.preventDefault()});I(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});I(this,"maybeHandlePageScrollKeyDown",t=>{if(t.key!==X.PAGE_UP&&t.key!==X.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===X.PAGE_DOWN&&(o=-o),t.shiftKey?this.viewport.translate(r=>({scrollX:r.scrollX+o})):this.viewport.translate(r=>({scrollY:r.scrollY+o})),!0});I(this,"preventBrowserZoomKeyDown",t=>{t[X.CTRL_OR_CMD]&&(t.code===br.EQUAL||t.code===br.MINUS||t.code===br.ZERO||t.code===br.NUM_ADD||t.code===br.NUM_SUBTRACT||t.code===br.NUM_ZERO)&&t.preventDefault()});I(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),ko=!1,Xp=!1,Mo=!1,Kp=!1,Ja=null,le.pointers.clear(),le.lastCenter=null,le.initialDistance=null,le.initialScale=null,clearTimeout(oc),oc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout($p),$p=0,Zp=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),gt.set(Nt,null),gt.set($n,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&vt(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())});I(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,qd(),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:$t(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())});I(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));I(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)});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",Ye(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...Ro(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(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=Sr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=pi(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=Jl(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...ci(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:jt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),iM(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});I(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??VV(t,o));I(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=ZV(),a=CM(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:yV,l=tb(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)});I(this,"reconcileStylesPanelMode",t=>{let o=jp(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}}))});I(this,"setDesktopUIMode",t=>{let o=$V(t);this.editorInterface=tb(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});I(this,"onResize",Ye(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>qa.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&(ic=t),this.scheduleImageRefresh()});I(this,"onScroll",_k(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},vV));I(this,"onCut",Ye(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||jl(t.target)||(this.actionManager.executeAction(Zd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Ye(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||jl(t.target)||(this.actionManager.executeAction($i,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(YV&&t.preventDefault(),!nc){nc=!0,t.touches.length===1&&(rc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(oc),oc=window.setTimeout(e.resetTapTwice,Ak);return}if(nc&&t.touches.length===1&&rc){let o=t.touches[0];Jn(ne(o.clientX,o.clientY),ne(rc.x,rc.y))<=Ok&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),nc=!1,clearTimeout(oc)}t.touches.length===2&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null})}});I(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}):le.pointers.clear())});I(this,"pasteFromClipboard",Ye(async t=>{if(!this.isInteractionEnabled())return;let o=!!Zp,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)||jl(r)))return;let s=await Br(t),l=s.getFiles(),c=await Od(s,o);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()}));I(this,"addElementsFromPasteOrLibrary",t=>{let o=Sr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=$a(o),l=Za(r,a)/2,c=Za(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}=Ce({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,y]=Ct(E,g,this.getEffectiveGridSize()),{duplicatedElements:w}=Vk({type:"everything",elements:o.map(A=>to(A,{x:A.x+b-r,y:A.y+y-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),v=[...x,...w];v=this.props.onDuplicate?.(v,x)||v,cM(v,Jl(w));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let A=SY(w,C);v=cb(v,A,C)}this.scene.replaceAllElements(v),w.forEach(A=>{if(Wt(A)&&Xk(A)){let L=Qk(A,this.scene.getElementsMapIncludingDeleted());EY(A,L,this.scene)}}),KV&&ao.loadElementsFonts(w).then(A=>{this.fonts.onLoaded(A)}),t.files&&this.addMissingFiles(t.files);let P=GY(w);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&gt.get(GE)?this.state.openSidebar:null,...dM(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:w,fit:t.fit,animation:!1,offsets:{ui:!0}})});I(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});I(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)});I(this,"removePointer",t=>{yr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=le.pointers.size>=2;le.pointers.delete(t.pointerId),o&&le.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});I(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Ne("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...$t(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});I(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}}})});I(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});I(this,"revealIfHidden",t=>{!t.length||pY(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:$a(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});I(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:On(t.zoom)},shouldCacheIgnoreZoom:!1})});I(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}})});I(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});I(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});I(this,"setToast",t=>{this.setState({toast:t})});I(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,hV,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Ye(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());Jk({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files}).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()}));I(this,"addImageElementsToScene",async(t,o,r)=>{await this.insertImages(t.map(({file:i})=>i),o,r)});I(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await ui(o);if(!yc(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};this.imageCache.set(t,s),i.src=await vc(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}});I(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=Kl(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});I(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>({...r,downloadError:o===!0?{}:o||null}))});I(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:Kl(o,0,1)}:{progress:void 0}}}})});I(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())});I(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);I(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});I(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())ja(o)&&o.fileId===t&&qa.delete(o)});I(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===Xa.svg))try{let l=nx(qk(ox(s.dataURL)),Xa.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});I(this,"updateScene",Ye(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?qV({...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}))}));I(this,"applyDeltas",(t,o)=>{let r=fM.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return fM.applyTo(r,a,i,o)});I(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(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});I(this,"updateCurrentCursorPosition",Ye(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));I(this,"onKeyDown",Ye(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}})),!Rk(t.target)){if((t.key===X.ESCAPE||t.key===X.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=se(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&oo(l[0])&&t.key===X.ENTER){this.startImageCropping(l[0]);return}if(t.key===X.ESCAPE)this.updateEditorAtom($n,null);else if(t.key===X.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(nb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=Fm(l);gt.get($n)?.type==="panel"&&_f(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom($n,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[X.CTRL_OR_CMD]&&t.key.toLowerCase()===X.V&&(Zp=t.shiftKey,clearTimeout($p),$p=window.setTimeout(()=>{Zp=!1},100)),t[X.CTRL_OR_CMD]&&jl(t.target)&&(t.code===br.MINUS||t.code===br.EQUAL)){t.preventDefault();return}if(jl(t.target)&&t.key!==X.ESCAPE||qE(t.key)&&Rk(t.target))return;if(t.key===X.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===X.E&&t.shiftKey&&t[X.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}if(this.state.openDialog?.name==="elementLinkSelector")return;if(t.key===X.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else Co("COMPLEX_BINDINGS")?this.handleSkipBindMode():Vp({app:this,event:t});if(this.actionManager.handleKeyDown(t))return;let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===X.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=Cw(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!Fk(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&Ne("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===xr.sharp?xr.round:this.state.currentItemArrowType===xr.round?xr.elbow:xr.sharp;this.setState({currentItemArrowType:c}),this.cursorHints.onArrowTypeCycled(c)}else(l==="arrow"||l==="line")&&this.cursorHints.onToolShortcut(l,/^\d$/.test(t.key)?"digit":"letter");l==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l},{toggle:!0}),t.stopPropagation();return}else if(t.key===X.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[X.CTRL_OR_CMD]&&!t.repeat&&(Co("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),Vp({app:this,event:t})),qE(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),c=new Set;l.filter(u=>no(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?Mk:this.getEffectiveGridSize())||(t.shiftKey?bV:Mk),m=0,p=0;t.key===X.ARROW_LEFT?m=-d:t.key===X.ARROW_RIGHT?m=d:t.key===X.ARROW_UP?p=-d:t.key===X.ARROW_DOWN&&(p=d),l.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),Gp(u,this.scene,{simultaneouslyUpdated:l})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===X.ENTER){let l=this.scene.getSelectedElements(this.state);if(l.length===1){let c=l[0];if(t[X.CTRL_OR_CMD]||pb(c))Rt(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),Ut(c)||this.actionManager.executeAction(aa));else if(Wt(c)||eM(c)){let d;Wt(c)||(d=c);let m=sb(c,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:d}),t.preventDefault();return}else vt(c)&&this.setState({editingFrame:c.id})}}if(t.key===X.SPACE&&le.pointers.size===0&&(ko=!0,this.cursor.set(Pe.GRAB),t.preventDefault()),t.key.toLowerCase()===X.Z&&!t[X.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(Xp=!0,this.cursor.set("zoom-in"),t.preventDefault()),(t.key===X.G||t.key===X.S)&&!t.altKey&&!t[X.CTRL_OR_CMD]){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;t.key===X.G&&(_o(this.state.activeTool.type)||l.some(c=>_o(c.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===X.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[X.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===X.F){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;(this.state.activeTool.type==="text"||l.find(c=>Wt(c)||ab(c,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===X.I&&!t.shiftKey&&!t[X.CTRL_OR_CMD],a=r===X.S&&t.shiftKey&&!t[X.CTRL_OR_CMD]||i,s=r===X.I&&t.shiftKey&&!t[X.CTRL_OR_CMD];(a||s)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));I(this,"onKeyUp",Ye(t=>{if(this.isInteractionEnabled()){if(t.key===X.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Pe.GRAB):zp(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),ko=!1),t.key.toLowerCase()===X.Z&&(Xp=!1,this.cursor.reset()),t.key===X.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),Vp({app:this,event:t})),(t.key===X.ALT&&this.state.bindMode==="skip"||!t[X.CTRL_OR_CMD]&&!Hp(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Co("COMPLEX_BINDINGS"))){let o=Ce({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=wr(ne(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=me.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());no(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[X.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Gt(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),Vp({app:this,event:t})}if(qE(t.key)){Hk(this.scene.getSelectedElements(this.state).filter(Ql),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(ub).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...bM(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...bM(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));I(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(dt);let i=zi.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?$t(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?$t(this.state,{...t,lastActiveTool:this.state.activeTool}):$t(this.state,t);s.type==="hand"?this.cursor.set(Pe.GRAB):ko||this.cursor.applyForTool(s),RV(document.activeElement)&&this.focusContainer(),cY(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:zp(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:ke({},l),selectedGroupIds:ke({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:ke({},l),selectedGroupIds:ke({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"isTouchScreenMultiTouchGesture",()=>le.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${Nk()}`);I(this,"onGestureStart",Ye(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ke({},this.state),activeEmbeddable:null}),le.initialScale=this.state.zoom.value)}));I(this,"onGestureChange",Ye(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=le.initialScale;o&&this.viewport.translate(r=>({...io({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:On(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));I(this,"onGestureEnd",Ye(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ke(this.state.previousSelectedElementIds,this.state)}),le.initialScale=null)}));I(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=vM(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&I2(o,r,this.state.zoom.value,this.editorInterface.formFactor))});I(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=vM(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(Fg,"ui",r),this.cursor.reset(),!0)});I(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&&(ab(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||Dk(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!Ql(i)){let C=_Y(QE({fontSize:g,fontFamily:u}),E),P=RY(g,E),A=Math.max(i.height,P),L=Math.max(i.width,C);this.scene.mutateElement(i,{height:A,width:L}),t=i.x+L/2,o=i.y+A/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),y=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-sM(g,E)/2:b.y},w=this.getTopLayerFrameAtSceneCoords({x:y.x,y:y.y}),x=w&&(!c||!i||i.frameId===w.id)?w.id:null,v=p||Uk({x:y.x,y:y.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?SV.MIDDLE:Pk),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?Ql(i)?0:i.angle:0,frameId:x});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:v.id})}),this.setState({editingTextElement:v}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([v],T+1)}else this.insertNewElement(v);l&&d&&this.arrowText.bindText(l,v,d.fixedPoint),a||p||i?this.handleTextWysiwyg(v,{isExistingElement:!!p,initialCaretSceneCoords:p?s:null}):this.setState({newElement:v,multiElement:null})});I(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(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 Jn(ne(o.x,o.y),ne(r.x,r.y))<=Ok});I(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}=Ce(t,this.state);if(o.length===1&&Rt(o[0])){let s=o[0];if((t[X.CTRL_OR_CMD]&&ub(s)||pb(s))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==s.id)){this.actionManager.executeAction(aa);return}else if(this.state.selectedLinearElement&&Ut(o[0])){let l=me.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=l?me.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),me.deleteFixedSegment(o[0],this.scene,c);let d=me.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?me.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&&pb(s))return}if(o.length===1&&oo(o[0])){this.startImageCropping(o[0]);return}if(this.cursor.reset(),zY(this.state).length>0){let s=this.getElementAtPosition(r,i),l=s&&FY(s,this.state.selectedGroupIds);if(l){this.store.scheduleCapture(),this.setState(c=>({...c,...Rn({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(ec(s)){this.setState({activeEmbeddable:{element:s,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let l=!t[X.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(l&&(this.state.activeTool.type==="autoshape"||Yk(l)||!BV(l.backgroundColor)||tc({point:ne(r,i),element:l,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(l)}))){let c=sb(l,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l||null})}}});I(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==Dn.MAIN){this.lastCompletedCanvasClicks=[];return}let o=Ce(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}]});I(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(!oo(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});I(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=vl(o,r,this.state,i);return!!a&&Jn(ne(t.x,t.y),ne(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});I(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&&fc(s,this.scene.getNonDeletedElementsMap(),this.state,ne(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});I(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&&Kb(a,i,this.state,ne(t.x,t.y)))return a});I(this,"handleElementLinkClick",t=>{let o=d=>d===Dn.MAIN||d===Dn.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=Jn(ne(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ne(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>kk)return;let i=Ce(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),s=fc(this.hitLinkElement,a,this.state,ne(i.x,i.y),this.editorInterface.formFactor==="phone"),l=Ce(this.lastPointerUpEvent,this.state),c=fc(this.hitLinkElement,a,this.state,ne(l.x,l.y),this.editorInterface.formFactor==="phone");s&&c&&(qd(),this.openElementLink(this.hitLinkElement,t))});I(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=Op(r);let i;if(this.props.onLinkOpen&&o&&(i=NV(J.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=LV(r)?"_self":"_blank",s=window.open(void 0,a);s&&(s.opener=null,s.location=r)}});I(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Pe.POINTER),qy(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(qd(),!1));I(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});I(this,"handleInteractiveContentPointerMove",t=>{let o=Ce(t,this.state),r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let i=r?.locked?null:r;if(this.handleIframeLikeElementHover({hitElement:i,scenePointer:o,moveEvent:t}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(o,r):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()});I(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=Ce(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(l=>!l.locked&&nM(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(vt(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});I(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});I(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&oX(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});I(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?xY(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});I(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&vt(o)?o:null)});I(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=On(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...io({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},s),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0}),this.resetShouldCacheIgnoreZoomDebounced()});I(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())&&!Mo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Ce(t,this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t);return}if(this.updateMultiTouchGesture(t),ko||Mo||Kp||os(this.state))return;let s=Qg(ic,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(Pe.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Pe.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&x2(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=b2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(y=>{let w=ql(y.snapLines,b),x=y.originSnapOffset?ql(y.originSnapOffset,g):g;return y.snapLines===w&&y.originSnapOffset===x?null:{snapLines:w,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:me.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Gt(()=>{this.setState({selectedLinearElement:g})})}if(lY(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&Hp(this.state)){let b=ne(r,i),y=this.scene.getNonDeletedElementsMap(),w=wr(b,this.scene.getNonDeletedElements(),y,yM(this.state.zoom));w?this.setState({suggestedBinding:{element:w,midPoint:hb(b,w,y,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:y,y:w,points:x}=g,v=x[x.length-1],{lastCommittedPoint:T}=b;if(this.cursor.applyForTool(),v===T)Jn(ne(r-y,i-w),v)>=JE?(this.store.scheduleCapture(),Gt(()=>{eo(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,ne(r-y,i-w)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Pe.POINTER);else if(x.length>2&&T&&Jn(ne(r-y,i-w),T)<JE){this.cursor.set(Pe.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{jk(x,this.state.zoom.value)&&this.cursor.set(Pe.POINTER);let C=this.scene.getNonDeletedElementsMap();if(ub(g)){let A=wr(ne(r,i),this.scene.getNonDeletedElements(),C);Co("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,A)}eo(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=me.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=ne(r,i),b=wr(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),yM(this.state.zoom)),y=this.scene.getNonDeletedElementsMap();b&&!wM(g,b,y)&&this.setState({suggestedBinding:{element:b,midPoint:hb(g,b,y,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(Pe.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&&Ut(m[0]))&&!(Rt(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=pM(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(mM(g));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=uM($a(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(mM({transformHandleType:g}));return}}if(qt(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||Po(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?Pe.POINTER:Wt(u)?Pe.TEXT:Pe.CROSSHAIR):!t[X.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Pe.MOVE):this.state.viewModeEnabled?this.cursor.set(Pe.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Pe.AUTO):s?this.cursor.set(Pe.AUTO):!t[X.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Ut(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Pe.MOVE):this.cursor.set(Pe.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:ql(g.hoveredElementIds,Rn({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:ql(g.hoveredElementIds,{})}))});I(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});I(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(ac=!0)});I(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),Mo||this.handleCanvasPanUsingWheelOrSpaceDrag(t));return}let o=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=Ce(t,this.state),{x:i,y:a}=r;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(LE,null)),gt.get($n)&&this.updateEditorAtom($n,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),Xp){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:ke(Object.keys(this.state.selectedElementIds).filter(b=>b!==g.id).reduce((b,y)=>(b[y]=this.state.selectedElementIds[y],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?jt.EVENTUALLY:jt.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:"variable"})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=tb(this.editorInterface,{isTouchScreen:!0})),Mo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Dn.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==_n.eraser){this.setState({activeTool:$t(this.state,{type:_n.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),y?.(),qt(this.state)&&this.setState({activeTool:$t(this.state,{...this.state.activeTool.lastActiveTool||{type:_n.selection},lastActiveTool:null})})},b=be(window,J.POINTER_UP,g,{once:!0}),y;requestAnimationFrame(()=>{y=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==Dn.MAIN&&t.button!==Dn.TOUCH&&t.button!==Dn.ERASER||le.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let g=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[X.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(c.origin.x,c.origin.y,t.shiftKey),c.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&c.hit.element&&!g&&(this.setState(w=>{let x={...w.selectedElementIds,[c.hit.element.id]:!0},v=[];Object.keys(w.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&v.push(P)});let T=c.hit.element;if(vt(T))lb(v,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(A=>si(this.scene.getNonDeletedElements(),A)).filter(A=>vt(A)).map(A=>A.id));P.size>0&&v.forEach(A=>{A.frameId&&P.has(A.frameId)&&(delete x[A.id],A.groupIds.flatMap(L=>si(this.scene.getNonDeletedElements(),L)).forEach(L=>{delete x[L.id]}))})}return{...Rn({editingGroupId:w.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),w,this),showHyperlinkPopup:T.link||Po(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===_n.frame||this.state.activeTool.type===_n.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===_n.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(J.POINTER_MOVE,m),window.addEventListener(J.POINTER_UP,p),window.addEventListener(J.KEYDOWN,u),window.addEventListener(J.KEYUP,E),c.eventListeners.onMove=m,c.eventListeners.onUp=p,c.eventListeners.onKeyUp=E,c.eventListeners.onKeyDown=u)});I(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(Co("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let o=Ce({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t),this.zDragZoom=null,this.setState({cursorButton:"up"});return}this.handleIframeLikeCenterClick()||!this.maybeHandleElementLinkClick(t,o)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(ac=!1,yr?ac=!0:yr=window.setTimeout(()=>{yr=0,ac||this.handleCanvasContextMenu(t)},TV))});I(this,"resetContextMenuTimer",()=>{clearTimeout(yr),yr=0,ac=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{Ja?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(le.pointers.size<=1&&((t.button===Dn.WHEEL||t.button===Dn.MAIN&&ko||os(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Mo=!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(Pe.GRABBING);let{clientX:i,clientY:a}=t,s=hm(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(J.PASTE,p),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(J.PASTE,p),window.removeEventListener(J.POINTER_UP,u)},100)};document.body.addEventListener(J.PASTE,p),window.addEventListener(J.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=Ye(Ja=()=>{Ja=null,Mo=!1,ko||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(J.POINTER_MOVE,s),window.removeEventListener(J.POINTER_UP,l),window.removeEventListener(J.BLUR,l),s.flush()});return window.addEventListener(J.BLUR,l),window.addEventListener(J.POINTER_MOVE,s,{passive:!0}),window.addEventListener(J.POINTER_UP,l),!0});I(this,"updateMultiTouchGesture",t=>{le.pointers.has(t.pointerId)&&le.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=le.initialScale;if(le.pointers.size===2&&le.lastCenter&&o&&le.initialDistance){let r=Hg(le.pointers),i=r.x-le.lastCenter.x,a=r.y-le.lastCenter.y;le.lastCenter=r;let s=Gg(Array.from(le.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/le.initialDistance,c=l?On(o*l):this.state.zoom.value;this.setState(d=>{let m=io({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 le.lastCenter=le.initialDistance=le.initialScale=null});I(this,"clearSelectionIfNotUsingSelection",()=>{zp(this.state.activeTool.type)||this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,o)=>{if(zp(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&&!Ut(a[0])&&!(Rt(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=pM(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($a(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=eb(UY(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Rt(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=WY(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=me.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=me.getElement(p.elementId,E);if(g&&no(g)){let{hitFocusPoint:b,pointerOffset:y,arrowOtherEndpointInitialBinding:w}=eX(g,o,E,this.state);if(b)return this.setState({selectedLinearElement:{...p,hoveredFocusPointBinding:b,draggedFocusPointBinding:b,pointerOffset:y,initialState:{...p.initialState,arrowOtherEndpointInitialBinding:w}}}),!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?ke({[p.selectedLinearElement.elementId]:!0},this.state):ke({},p)}));else if(d!=null){if(t[X.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(o.origin.x,o.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({...OY(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!lM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:ke({},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)}),vt(d))lb(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(y=>si(this.scene.getNonDeletedElements(),y)).filter(y=>vt(y)).map(y=>y.id));b.size>0&&E.forEach(y=>{y.frameId&&b.has(y.frameId)&&(delete u[y.id],y.groupIds.flatMap(w=>si(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(g=>p.selectedGroupIds[g])||(u={[d.id]:!0})),{...Rn({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||Po(d)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(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);Yk(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:$t(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});I(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=Ct(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=eY({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"?fV:gV},locked:!1,frameId:s?s.id:null,points:[ne(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:ke(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});I(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=Ct(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=nY({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});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=Ct(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=Up(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=Gk({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});I(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,s]=Ct(t,o,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:a,y:s}):null,c=100/this.state.zoom.value;return iY({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})});I(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(eo(a,"selectedLinearElement is expected to be set"),i.type==="line"&&jk(i.points,this.state.zoom.value)){Gt(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(dt);return}if(Ut(i)&&i.points.length>1){this.actionManager.executeAction(dt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:s,y:l}=i,{lastCommittedPoint:c}=a,d=Ce(t,this.state),{start:m,end:p}=no(i)&&Hp(this.state)?rX(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&&!wM(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&Jn(ne(r.origin.x-s,r.origin.y-l),c)<JE;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(dt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(y=>({selectedElementIds:ke({...y.selectedElementIds,[i.id]:!0},y)})),this.cursor.set(Pe.POINTER)}else{let[i,a]=Ct(r.origin.x,r.origin.y,t[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,m]=o==="arrow"?[l,c]:[null,null],p=o==="arrow"?oY({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===xr.round?{type:Np.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===xr.elbow,fixedSegments:this.state.currentItemArrowType===xr.elbow?[]:null}):aY({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:Np.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=ne(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=Hp(this.state)?wr(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[ne(0,0),ne(0,0)]}),this.insertNewElement(p),no(p)&&$Y(p,new Map([[0,{point:ne(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:Ck(t.nativeEvent)}),Gt(()=>{this.setState(b=>{let y=null,w=b.selectedElementIds;if(Rt(p)){y=new me(p,this.scene.getNonDeletedElementsMap());let x=p.points.length-1;y={...y,selectedPointsIndices:[x],initialState:{...y.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:ne(r.origin.x,r.origin.y)}}}return w=this.isToolLocked()?b.selectedElementIds:ke({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&no(p)?{element:g,midPoint:hb(u,g,E,this.state.zoom)}:null,selectedElementIds:w,selectedLinearElement:y}})}),no(p)&&Co("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});I(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=Ct(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),s={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},l;t==="embeddable"?l=Gk({type:"embeddable",...s}):l=rY({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});I(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=Ct(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...So},s=o===_n.magicframe?tY(a):QV(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(no(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);Wp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);Wp(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else rb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&Wp(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&Wp(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)||Xk(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,to(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});I(this,"initializeImage",async(t,o)=>{if(!yc(o))throw new Error(f("errors.unsupportedFileType"));let r=o.type;if(this.cursor.set("wait"),r===Xa.svg)try{o=mu(qk(await o.text()),o.name)}catch(l){throw console.warn(l),new Error(f("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(o)||tx(o));if(!i)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[i]?.dataURL){let{maxWidthOrHeight:l,maxFileSizeBytes:c}=this.props.imageOptions;try{o=await(this.props.compressImageFile??rx)(o,{maxWidthOrHeight:l})}catch(d){console.error("Error trying to resize image file on insertion",d)}if(o.size>c)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(c/1024/1024)}MB`}))}let s=this.files[i]?.dataURL||await vc(o);return new Promise(async(l,c)=>{try{let d=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:s,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:u}=await this.updateImageCache([d]);if(u.size)throw new Error("Image cache update resulted with an error.")}let m=await this.imageCache.get(i)?.image,p=m?uY(m):null;if(m&&this.state.newElement?.id!==d.id){d=this.getLatestInitializedImageElement(t,i);let u=this.getImageNaturalDimensions(d,m);Object.assign(d,u)}d=to(d,{fileName:o.name,thumbHash:p,status:"saved"}),this.files={...this.files,[i]:{...this.files[i],fileName:o.name,thumbHash:p??void 0}},l(d)}catch(d){console.error(d),c(new Error(f("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return to(r,{fileId:o})});I(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Ce({clientX:t,clientY:o},this.state),a=await Yb({description:"Image",extensions:Object.keys(xV),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:$t(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(dt)})}});I(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}});I(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 Jk({imageCache:this.imageCache,fileIds:t.map(s=>s.fileId),files:o});for(let[s,l]of r){let c=this.imageCache.get(s);!c||!i.has(s)||this.imageCache.set(s,{...c,placeholderImage:await l,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction(jt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(ja(s)){if(a.has(s.fileId))return to(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return to(s,{status:"saved"})}return s}))),{updatedFiles:i,erroredFiles:a}});I(this,"addNewImagesToImageCache",async(t=fY(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)&&qa.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",mV(()=>{this.addNewImagesToImageCache()},wV));I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),this.interactiveCanvas.addEventListener(J.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(J.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(J.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(J.TOUCH_END,this.onTouchEnd))});I(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,s=EM(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 ui(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),to(u,{isDeleted:!0})}})),c=Jl(l),d=EM(l.filter(u=>!u.isDeleted),o,r,a),m=Jl(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:ke(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:jt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(dt)})});I(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Ce(t,this.state),i=Rh(t),a=await Br(t),s=a.getFiles();if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===Xa.png||d.type===Xa.svg))try{let p=await ss(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}let l=s.map(d=>d.file).filter(d=>yc(d));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,o,r,Nh(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(Xa.text);if(c){let d=c.value;if(d&&ib(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||Up(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:Op(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,o)=>{t=await ui(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await ss(t,this.state,r,o)}catch(a){let s=a instanceof Vb;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;PM(r.concat(i.elements)),this.store.scheduleMicroAction({action:jt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({elements:i.elements,files:i.files,appState:{...i.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});I(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!==Dn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Ce(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.isLinksEnabled()?this.getElementLinkAtPositionForContextMenu({x:o,y:r},i):void 0,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;Ne("contextMenu","openContextMenu",m),this.setState({...d&&!this.state.selectedElementIds[d.id]?{...this.state,...Rn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Rt(d)?new me(d,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(m,d)}})})});I(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){hM({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Za(t.origin.x,a.x),height:Za(t.origin.y,a.y),shouldMaintainAspectRatio:Zl(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]=Ct(a.x,a.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=ja(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}=E2(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}),no(s)||hM({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:Za(t.originInGrid.x,l),height:Za(t.originInGrid.y,c),shouldMaintainAspectRatio:oo(s)?!Zl(o):Zl(o),shouldResizeFromCenter:Sk(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===_n.frame||this.state.activeTool.type===_n.magicframe)&&this.setState({elementsToHighlight:db(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=Ct(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&oo(l)){let c=t.originalElements.get(l.id),d=ja(l)&&this.imageCache.get(l.fileId)?.image;if(c&&oo(c)&&d&&!(d instanceof Promise)){let[m,p]=Ct(i.x,i.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:E,snapLines:g}=Yg([l],[c],this,o,u,r);this.scene.mutateElement(l,MY(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),Gp(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});I(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(vt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Ut(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=Ct(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{lb(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]=Ct(s.x,s.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y},E=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(o,r);let{snapOffset:g,snapLines:b}=Yg(r,se(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(VY(t.originalElements,a,r,this.scene,Ck(o),Sk(o),r.some(m=>oo(m))?!Zl(o):Zl(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=>{Yp(u)?m.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...m]}),!0}return!1});I(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=>oo(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&oo(t)?[...o([t.id])]:[]});I(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=Op(t.link),r=iM(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 ho(o),this.setState({toast:{message:f("toast.elementLinkCopied"),closable:!0}})}}]});I(this,"getContextMenuItems",(t,o)=>{let r=this.getImageContextMenuItems(o),i=this.getElementLinkContextMenuItems(o);if(t==="canvas")return this.state.viewModeEnabled?[Ys,ji,Zr,er]:[Zh,$e,Zu,iv,$e,ji,kt,Xs,Ks,Zr,er];if(this.state.viewModeEnabled)return[...i,i.length>0&&$e,Ys,$i,r.length>0&&$e,...r];let a=this.editorInterface.formFactor==="desktop"?[$e,Vu,Yu,Xu,Ku]:[];return[$e,Ys,$e,Zd,$i,Zh,r.length>0&&$e,...r,$e,jv,qv,Jv,$e,_g,$e,Wh,Fg,Jh,Qh,Uy,Vh,$e,...a,$e,Xh,Kh,$e,aa,$e,lg,i.length>0&&$e,...i,$e,$u,js,$e,Es]});I(this,"handleWheel",Ye(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(nb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[X.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Mo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=CV*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:PV;c=Math.max(c,d),this.viewport.translate(p=>({...io({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:On(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}))}));I(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=Ce({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let s={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:s,button:r,pointersMap:le.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",_k(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(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()}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});I(this,"watchState",()=>{});let o=Ro(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${Nk()}`,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=$t(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===$l.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=jp(this.editorInterface),this.id=uV(),this.actionManager=new dm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new gM,this.canvas=document.createElement("canvas"),this.rc=pV.canvas(this.canvas),this.renderer=new gl(this.scene),this.visibleElements=[],this.store=new KY(this),this.history=new ul(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new ao(this.scene),this.history=new ul(this.store),this.actionManager.registerAll(Fc),this.actionManager.registerAction(n2(this.history)),this.actionManager.registerAction(o2(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(Bp).includes(i)&&gb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){eo(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=wr(ne(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=me.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&o?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Gt(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:o}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;eo(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?me.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):me.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||Ut(t))return;let r=()=>{if(this.bindModeHandler=null,eo(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=wr(ne(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){eo(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let E=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Gt(()=>{eo(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;eo(g,"Last event must exist");let b=m-this.state.selectedLinearElement.pointerOffset.x,y=p-this.state.selectedLinearElement.pointerOffset.y,w=this.state.multiElement?me.handlePointerMove(g,this,b,y,this.state.selectedLinearElement):me.handlePointDragging(g,this,b,y,this.state.selectedLinearElement);w&&this.setState(w)}},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&&xM(E,m),y=g&&xM(g,m);i=!!(b&&y&&E.id!==g.id&&jY(b,y))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),s=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),l=a?"startBinding":s?"endBinding":null,c=a?"endBinding":s?"startBinding":null,d=c&&t[c]?.mode==="inside"&&t[c]?.elementId===o?.id||l&&t[l]?.mode==="inside"&&o?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&o?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!o||this.previousHoveredBindableElement&&o.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Gt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,WV)),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!==Dn.MAIN||ko||!Fk(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=ne(Ce({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=ne(Ce({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(Jn(t,o)>kk)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&le.pointers.size<2&&ec(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),ob(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=gb.get(s.id);switch(c||(gb.set(s.id,Bp.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case Bp.PLAYING:case Bp.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=>Po(a)&&this.embedsValidationStatus.get(a.id)===!0||ob(a));return Ie(lX,{children:i.map(a=>{let{x:s,y:l}=Fp({sceneX:a.x,sceneY:a.y},this.state),c=Zk(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=Up(DV(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=Kl(g?t:1,.75,aX);return Ie("div",{className:wk("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:BY(a,mb(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?AV:1),"--embeddable-radius":`${hY(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?Ka.enabled:Ka.disabled},children:[E&&Ie("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Ie("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:Ie("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(Po(a)?this.props.renderEmbeddable?.(a,this.state):null)??Ie("iframe",{ref:y=>this.cacheEmbeddableRef(a,y),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=gt.get($n)?.type==="panel";return Ie("div",{translate:"no",className:wk("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?Ka.disabled:Ka.enabled,"--right-sidebar-width":`${Bf}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:Ie(Qa.Provider,{value:this.api,children:Ie(kM.Provider,{value:this,children:Ie(MM.Provider,{value:this.props,children:Ie(wb.Provider,{value:this.excalidrawContainerValue,children:Ie(xb.Provider,{value:this.editorInterface,children:Ie(Ib.Provider,{value:this.setAppState,children:Ie(vb.Provider,{value:this.state,children:fb(yb.Provider,{value:this.scene.getNonDeletedElements(),children:[fb(Tb.Provider,{value:this.actionManager,children:[Ie(QP,{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:zn().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}),Ie("div",{className:"excalidraw-textEditorContainer"}),Ie("div",{className:"excalidraw-contextMenuContainer"}),Ie("div",{className:"excalidraw-eye-dropper-container"}),Ie(tk,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Ie(Ek,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Ie($y,{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&&Ie(PT,{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?.()})}}),Ie(ZE,{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,isExporting:!1,renderGrid:or(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&&Ie(mk,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,renderConfig:{imageCache:this.imageCache,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}}),Ie(KE,{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"&&Ie($m,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Ie(xk,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Ie(nT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{ja(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),qa.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,TM()||SM()){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(),kV&&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),XV()&&!LY()&&this.setState({errorMessage:Ie(xT,{})});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.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 gM,this.fonts=new ao(this.scene),this.renderer=new gl(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(),qa.destroy(),ln.destroy(),clearTimeout(yr),Me.clearCache(),Rn.clearCache(),yr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(be(window,J.MESSAGE,this.onWindowMessage,!1),be(document,J.POINTER_UP,this.removePointer,{passive:!1}),be(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),be(window,J.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),be(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.handleNavigationModeKeyDown,!1),be(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),be(document,J.GESTURE_START,this.onGestureStart,!1),be(document,J.GESTURE_CHANGE,this.onGestureChange,!1),be(document,J.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),be(this.excalidrawContainerRef.current,J.GESTURE_START,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.GESTURE_CHANGE,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(be(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,J.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(be(document,J.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),be(document,J.COPY,this.onCopy,{passive:!1}),be(document,J.KEYUP,this.onKeyUp,{passive:!0}),be(document,J.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),be(document,J.GESTURE_START,this.onGestureStart,!1),be(document,J.GESTURE_CHANGE,this.onGestureChange,!1),be(document,J.GESTURE_END,this.onGestureEnd,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(be(document,J.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),be(document,J.PASTE,this.pasteFromClipboard,{passive:!1}),be(document,J.CUT,this.onCut,{passive:!1}),be(window,J.RESIZE,this.onResize,!1),be(window,J.UNLOAD,this.onUnload,!1),be(window,J.BLUR,this.onBlur,!1),be(this.excalidrawContainerRef.current,J.WHEEL,this.handleWheel,{passive:!1}),be(this.excalidrawContainerRef.current,J.DRAG_OVER,this.disableEvent,!1),be(this.excalidrawContainerRef.current,J.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(be(_V(this.excalidrawContainerRef.current),J.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.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===$l.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&&qt(this.state)&&this.setState({activeTool:$t(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(),qt(o)&&!qt(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===$l.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(dt)});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:ke(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(){nc=!1,rc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Ce({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(o.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&t.text){let d=Am(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(mu(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?qY(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=FV(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>gY(d)).filter(d=>ib(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||Up(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:Op(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)}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(`
22
22
 
23
- `),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=Ce({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:DV,verticalAlign:Mk,locked:!1},s=ob({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=Rk(a.fontFamily),[c,,d]=LY(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,y,w)=>{let x=BY(y).trim();if(x.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=sM(x,s,l),C=T.width>m,P=C?_Y(x,s,m):x;T=C?sM(P,s,l):T;let A=r-T.width/2,L=u-T.height/2,_=Vk({...a,x:A,y:L,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:v?v.id:null});b.push(_),u+=_.height+p}else E[w-1]?.trim()&&(u+=lM(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:ke(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&TM===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),TM=!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&&Wt(c)?eo(c,{originalText:s,isDeleted:l??c.isDeleted,...dY(c,tM(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=B2({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=Hp({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Ye(s=>{a(s,!1),Kp(t)&&Wp(t,this.scene)}),onSubmit:Ye(({viaKeyboard:s,nextOriginalText:l})=>{this.textWysiwygSubmitHandler=null;let c=!l.trim();a(l,c);let d=s&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(c?null:t.id):null;d&&Gt(()=>{this.setState(m=>({selectedElementIds:ke({...m.selectedElementIds,[d]:!0},m)}))}),c&&tY(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Gt(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type==="autoshape")&&this.cursor.applyForTool(),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:r,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),a(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ke({},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 Wt(r)?r:t?db(r,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(t,o){let r=this.scene.getSelectedElements(this.state);if(r.length!==1||!t||t.id!==r[0].id)return null;let i=r[0];if(Wt(i))return null;if(!nM(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&&Wt(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 nc({point:ne(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:vt(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||!(Wt(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=gb(l,a);return c&&!Kp(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!tc(l)?rM({x:t,y:o},c,a):!0}).filter(l=>tc(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(_k/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&yY([r],this.state,this.editorInterface)&&JY(ne(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||MY(ne(t,o),r,this.scene.getNonDeletedElementsMap())?!0:nc({point:ne(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:vt(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 $k(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]=Gk(r[s],this.scene.getNonDeletedElementsMap());if(ec(r[s])&&nc({point:ne(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(vt(r[s]))continue;a=r[s];break}}return $k(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Wt(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=me.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let s=-1,l=null;nc({point:ne(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=me.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=me.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Ut(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Pe.POINTER):this.hitElement(o,r,a)&&(!Ut(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Pe.MOVE)):this.hitElement(o,r,a)&&(!Ut(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Pe.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),me.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=oX(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(Pe.POINTER)}else this.cursor.set(Pe.AUTO)}updateGestureOnPointerDown(t){le.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),le.pointers.size===2&&(le.lastCenter=Wg(le.pointers),le.initialScale=this.state.zoom.value,le.initialDistance=Vg(Array.from(le.pointers.values())))}initialPointerDownState(t){let o=Ce(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=$a(r),c=r.findIndex(Ut)===0;return{origin:o,withCmdOrCtrl:t[X.CTRL_OR_CMD],originInGrid:rb(Ct(o.x,o.y,t[X.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:nf(ac,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,Yk(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;$p=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=Em(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Ye(()=>{Ja=null,$p=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(J.POINTER_MOVE,r),window.removeEventListener(J.POINTER_UP,i),r.flush()});return Ja=i,window.addEventListener(J.POINTER_MOVE,r),window.addEventListener(J.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(_k/this.state.zoom.value,1),i=wV*2/this.state.zoom.value,[a,s,l,c]=$a(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:uY(t)?Fp.ADAPTIVE_RADIUS:Fp.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return QV(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){Eo({event:t,app:this,selectedElements:o})&&(r||!ln.getReferenceSnapPoints())&&ln.setReferenceSnapPoints(E2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){Eo({event:t,app:this,selectedElements:o})&&(r||!ln.getVisibleGaps())&&ln.setVisibleGaps(f2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ye(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Ye(o=>{o.key===X.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return Em(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Ce(o,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[p,u]=Ct(r.x,r.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=me.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?me.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=me.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=rb(jY(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(qt(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]=Ct(r.x,r.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,o)||this.maybeHandleResize(t,o)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){nX(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(me.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=me.addMidpoint(this.state.selectedLinearElement,r,this,!o[X.CTRL_OR_CMD],this.scene);if(!u)return;Gt(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(p.initialState.segmentMidpoint.value!==null&&!p.initialState.segmentMidpoint.added)return;if(p.initialState.lastClickedPoint>-1){let u=me.getElement(p.elementId,c);if(u?.isDeleted)return;if(to(u)){let g=wr(ne(r.x,r.y),this.scene.getNonDeletedElements(),c);Co("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Co("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),p.initialState.lastClickedPoint===-1)return;let E=me.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||!Fk(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=>vt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:oM(p),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(E),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let g={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},b=[...t.originalElements.values()],y=o.shiftKey;if(y){let v=Math.abs(g.x),T=Math.abs(g.y),C=y&&v<T,P=y&&v>T;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let v=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(v&&no(v)&&v.crop!==null&&t.hit.element===v){let T=v.crop,C=ja(v)&&this.imageCache.get(v.fileId)?.image;if(C&&!(C instanceof Promise)){let P=aX(v),A=Ik(r.x-i.x,r.y-i.y);A[0]*=C.naturalWidth/P.width,A[1]*=C.naturalHeight/P.height;let[L,_,k,D,F,Y]=Gk(v,c),z=QE(JE(ne(L,_),ne(F,Y),v.angle)),W=QE(JE(ne(k,_),ne(F,Y),v.angle)),Z=QE(JE(ne(L,D),ne(F,Y),v.angle)),H=Ck(Tk(W,z)),re=Ck(Tk(Z,z)),B=Ik(Sk(A,H),Sk(A,re)),U={...T,x:Zl(T.x-B[0]*Math.sign(v.scale[0]),0,C.naturalWidth-T.width),y:Zl(T.y-B[1]*Math.sign(v.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(v,{crop:U});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:w,snapLines:x}=b2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||$Y(t,p,g,this.scene,w,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),o.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let v=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:A,duplicateElementsMap:L,elementsWithDuplicates:_,origIdToDuplicateId:k}=Xk({type:"in-place",elements:v,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:W})=>({frameId:z.frameId??W.frameId,seed:VV()})});A.forEach(z=>{t.originalElements.set(z.id,Yk(z))});let D=_.map(z=>{if(P.has(z.id)){let W=t.originalElements.get(z.id);if(W)return eo(z,{x:W.x,y:W.y})}return z}),F=this.props.onDuplicate?.(D,v),Y=dM(F||D,Ql(A));Gt(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),W=z&&L.get(z);t.hit.element=W||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,W)=>{let Z=k.get(W.id),H=Z&&L.get(Z);return H&&z.push(H),z},[]),t.drag.origin=Ce(o,this.state),this.setState(z=>({...mM(A,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(Y),C.forEach(z=>{lb(z)&&z.boundElements?.some(W=>W.type==="arrow")&&Wp(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 w=p.simulatePressure?p.pressures:[...p.pressures,o.pressure];this.scene.mutateElement(p,{points:[...u,ne(E,g)],pressures:w},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Rt(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;Qn(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 me(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,...me.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)me.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&Me(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>_n({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?Vb(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(g=>{let b={...u&&g.selectedElementIds,...E.reduce((y,w)=>(y[w.id]=!0,y),{})};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},{..._n({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Rt(E[0])?new me(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Po(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*(ac.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*(ac.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ye(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===Dn.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:Jl(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,ln.setReferenceSnapPoints(null),ln.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=Ce({clientX:o.clientX,clientY:o.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(x=>this.state.selectedElementIds[x.id])){let x=this.getElementAtPosition(E.x,E.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),x?.locked?this.setState({activeLockedId:x.groupIds.length>0?x.groupIds.at(-1)||"":x.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(Co("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);lb(x)&&x.boundElements?.filter(v=>v.type==="arrow").map(v=>r.get(v.id)).filter(v=>Ut(v)).forEach(v=>{v&&this.scene.mutateElement(v,{})})}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(dt);else{let x=me.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(dt,"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=me.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(iX(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(dt,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Rt(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(J.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(J.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(J.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(J.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=Ce(o,this.state),v=i.points,T=x.x-i.x,C=x.y-i.y;T===v[0][0]&&C===v[0][1]&&(C+=1e-4,T+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...v,ne(T,C)],pressures:P}),this.actionManager.executeAction(dt);return}if(Rt(i)&&this.state.activeTool.type!=="autoshape"){let x=Ce(o,this.state),v=qn(ne(x.x,x.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||v<YV)&&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:[ne(0,0),ne(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(dt)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),Rt(i)&&this.actionManager.executeAction(dt,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:$t(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ke({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new me(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Wt(i)){let x=zY(ob({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&&qk(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:jt.NEVER});return}if(vt(i)){let x=SY(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(ub(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,hY(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Ce(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let v=this.scene.getElement(this.state.selectedLinearElement.elementId);if(v?.frameId){let T=gb(v,r);T&&v&&(CY(v,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(v,{groupIds:[]}),TY([v],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let v=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:oM(v),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=A=>{if(A.length>0){for(let L of A){let _=L.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(L,{groupIds:L.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(L=>{L.groupIds.length&&si(C,L.groupIds[L.groupIds.length-1]).length<2&&this.scene.mutateElement(L,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let A=v.filter(L=>aM(L,C,this.state));this.state.editingGroupId&&P(A),C=ub(C,A,T)}else if(!T&&this.state.editingGroupId){let A=v.filter(L=>L.frameId&&!aM(L,C,this.state));P(A)}C=iM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&qk(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:jt.NEVER}),t.resize.isResizing){let x=iM(this.scene.getElementsIncludingDeleted(),this.state,this),v=this.scene.getSelectedElements(this.state).filter(vt);for(let T of v)x=IY(x,hb(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Rt(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new me(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!p||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,y=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(qt(this.state)&&b&&y){if(this.eraserTrail.endPath(),qn(ne(b.clientX,b.clientY),ne(y.clientX,y.clientY))===0){let v=Ce({clientX:y.clientX,clientY:y.clientY},this.state);this.getElementsAtPosition(v.x,v.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]?VY(this.state,g)?this.setState(x=>{let v={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>si(this.scene.getNonDeletedElements(),C)))delete v[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:ke(v,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let v={...x.selectedElementIds};delete v[g.id];let T=ie(this.scene.getNonDeletedElements(),{selectedElementIds:v});return{..._n({editingGroupId:x.editingGroupId,selectedElementIds:v},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Rt(T[0])?new me(T[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let v={...x.selectedElementIds,[g.id]:!0};return delete v[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>si(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete v[T.id]}),{..._n({editingGroupId:x.editingGroupId,selectedElementIds:v},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Po(g)?"info":!1}}):this.setState(x=>({selectedElementIds:ke({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({..._n({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Rt(g)&&x.selectedLinearElement?.elementId!==g.id?new me(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Ut(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&AY({point:ne(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:vt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(aa):this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Pe.AUTO);return}let w=this.getSelectedTextEditingContainerAtPosition(g,E);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[X.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&(Wt(g)&&this.state.selectedElementIds[g.id]&&this.scene.getSelectedElements(this.state).length===1||w)){this.startTextEditing({sceneX:E.x,sceneY:E.y,container:w,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:E});return}if(!this.isToolLocked()&&c.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:ke({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Po(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||Me(this.scene.getNonDeletedElements(),this.state)||!Fk(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(ec);Uk(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(dt);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==Dn.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:$t(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:ke({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&cM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:ke({},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)<CV){let{x:m,y:p}=Hp({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=gi.find(o=>o.code===this.props.langCode)||On;await Cc(t),this.setAppState({})}},mX=()=>{(SM()||CM())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(kM(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};mX();var LM=vb;import{useEffect as uX,useState as hX}from"react";import{jsx as gX}from"react/jsx-runtime";var DM=e=>{let[n,t]=hX(!0);return uX(()=>{let o=async()=>{await Cc(r),t(!1)},r=gi.find(i=>i.code===e.langCode)||On;o()},[e.langCode]),n?gX(tp,{theme:e.theme}):e.children};import fX from"clsx";import{jsx as _M}from"react/jsx-runtime";var RM=({children:e})=>{let{FooterCenterTunnel:n}=et(),t=fe();return _M(n.In,{children:_M("div",{className:fX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},EX=RM;RM.displayName="FooterCenter";import bX from"clsx";import{MQ_MIN_WIDTH_DESKTOP as xX}from"@excalidraw/common";import{jsx as yX,jsxs as vX}from"react/jsx-runtime";var NM=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=fe(),i=t?.formFactor!=="desktop"||r.width<xX;return vX(fn,{...o,className:bX("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?zx:f("labels.share"),r.collaborators.size>0&&yX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},wX=NM;NM.displayName="LiveCollaborationTrigger";import{jsx as vr,jsxs as OM}from"react/jsx-runtime";var IX=()=>vr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:vr("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"})}),TX=()=>OM("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[vr("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)"}),vr("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)"}),vr("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)"}),vr("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)"})]}),BM=({style:e,size:n="small",withText:t})=>OM("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[vr(IX,{}),t&&vr(TX,{})]});import{Fragment as HM,jsx as it,jsxs as Mb}from"react/jsx-runtime";var Ab=({icon:e,shortcut:n,children:t})=>{let o=ge();return Mb(HM,{children:[it("div",{className:"welcome-screen-menu-item__icon",children:e}),it("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&it("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};Ab.displayName="WelcomeScreenMenuItemContent";var lc=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>it("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:it(Ab,{icon:t,shortcut:o,children:n})});lc.displayName="WelcomeScreenMenuItem";var FM=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>it("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:it(Ab,{icon:t,shortcut:o,children:e})});FM.displayName="WelcomeScreenMenuItemLink";var bn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=et();return it(n.In,{children:it("div",{className:"welcome-screen-center",children:e||Mb(HM,{children:[it(Lb,{}),it(Db,{children:f("welcomeScreen.defaults.center_heading")}),Mb(_b,{children:[it(Nb,{}),it(Rb,{})]})]})})})};bn.displayName="Center";var Lb=({children:e})=>it("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||it(BM,{withText:!0})});Lb.displayName="Logo";var Db=({children:e})=>it("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Db.displayName="Heading";var _b=({children:e})=>it("div",{className:"welcome-screen-menu",children:e});_b.displayName="Menu";var Rb=()=>{let e=tt();return it(lc,{onSelect:()=>e.executeAction(Hr),shortcut:"?",icon:wi,children:f("helpDialog.title")})};Rb.displayName="MenuItemHelp";var Nb=()=>{let e=fe(),n=tt();return e.viewModeEnabled?null:it(lc,{onSelect:()=>n.executeAction(Ui),shortcut:Ke("loadScene"),icon:Lc,children:f("buttons.load")})};Nb.displayName="MenuItemLoadScene";var zM=({onSelect:e})=>{let{t:n}=Ae();return it(lc,{shortcut:null,onSelect:e,icon:Dc,children:n("labels.liveCollaboration")})};zM.displayName="MenuItemLiveCollaborationTrigger";bn.Logo=Lb;bn.Heading=Db;bn.Menu=_b;bn.MenuItem=lc;bn.MenuItemLink=FM;bn.MenuItemHelp=Rb;bn.MenuItemLoadScene=Nb;bn.MenuItemLiveCollaborationTrigger=zM;import{jsx as es,jsxs as Bb}from"react/jsx-runtime";var eu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=et();return es(n.In,{children:Bb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[yx,es("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};eu.displayName="MenuHint";var tu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=et();return es(n.In,{children:Bb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[es("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),Ix]})})};tu.displayName="ToolbarHint";var nu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=et();return es(n.In,{children:Bb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[es("div",{children:e||f("welcomeScreen.defaults.helpHint")}),vx]})})};nu.displayName="HelpHint";import{Fragment as GM,jsx as cc,jsxs as CX}from"react/jsx-runtime";var ou=e=>cc(GM,{children:e.children||CX(GM,{children:[cc(bn,{}),cc(eu,{}),cc(tu,{}),cc(nu,{})]})});ou.displayName="WelcomeScreen";ou.Center=bn;ou.Hints={MenuHint:eu,ToolbarHint:tu,HelpHint:nu};var SX=ou;var PX=()=>{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)})},UM=PX;import{getSceneVersion as ZWe,hashElementsVersion as $We,hashString as jWe,getNonDeletedElements as qWe}from"@excalidraw/element";import{getTextFromElements as QWe}from"@excalidraw/element";import{isInvisiblySmallElement as tVe}from"@excalidraw/element";import kX from"lodash.throttle";import{arrayToMap as MX,isDevEnv as WM,isTestEnv as VM}from"@excalidraw/common";import{orderByFractionalIndex as AX,syncInvalidIndices as YM,validateFractionalIndices as LX}from"@excalidraw/element";var DX=(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)),_X=kX((e,n,t)=>{if(WM()||VM()||window?.DEBUG_FRACTIONAL_INDICES){let o=YM(e.map(r=>({...r})));LX(o,{shouldThrow:VM()||WM(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),RX=(e,n,t)=>{let o=MX(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=DX(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=AX(r);return _X(a,e,n),YM(a),a};import{isLinearElement as dVe}from"@excalidraw/element";import{FONT_FAMILY as pVe,THEME as uVe,MIME_TYPES as hVe,ROUNDNESS as gVe,DEFAULT_LASER_COLOR as fVe,UserIdleState as EVe,normalizeLink as bVe,sceneCoordsToViewportCoords as xVe,viewportCoordsToSceneCoords as wVe,getFormFactor as yVe,throttleRAF as vVe}from"@excalidraw/common";import{mutateElement as TVe,newElementWith as SVe,bumpVersion as CVe}from"@excalidraw/element";import{CaptureUpdateAction as kVe}from"@excalidraw/element";import{getCommonBounds as OVe,getVisibleSceneBounds as FVe,convertToExcalidrawElements as zVe}from"@excalidraw/element";import{elementsOverlappingBBox as GVe}from"@excalidraw/element";import{isElementLink as VVe}from"@excalidraw/element";import{setCustomTextMetricsProvider as KVe}from"@excalidraw/element";import{jsx as dc}from"react/jsx-runtime";UM();var WWe=({children:e})=>{let[n,t]=HX(null);return dc(Qa.Provider,{value:n,children:dc(Qp.Provider,{value:t,children:e})})},UX=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=On.code,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:v,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,onPaste:F,detectScroll:Y=!0,handleKeyboardGlobally:z=!1,autoFocus:W=!1,compressImageFile:Z,generateIdForFile:H,onLinkOpen:re,generateLinkForSelection:B,onPointerDown:U,onPointerUp:ue,onScrollChange:we,onUserFollow:pe,userToFollow:he,onDuplicate:ye,imageContextMenuItems:se,children:ve,validateEmbeddable:st,renderEmbeddable:$e,showDeprecatedFonts:Re,wheelZoomsOnDefault:Do,strokeColorTopPicks:li,backgroundColorTopPicks:mc,renderScrollbars:pc,viewportStatusFrame:uc,currentUserControls:ru,imageOptions:oo,showDropEventDebugAlert:Rn}=e,ts=e.UIOptions?.canvasActions,hc={...e.UIOptions,canvasActions:{...XM.canvasActions,...ts},tools:{image:e.UIOptions?.tools?.image??!0}};ts?.export&&(hc.canvasActions.export.saveFileToDisk=ts.export?.saveFileToDisk??XM.canvasActions.export.saveFileToDisk),hc.canvasActions.toggleTheme===null&&(P==null||r)&&(hc.canvasActions.toggleTheme=!0);let KM={maxFileSizeBytes:oo?.maxFileSizeBytes??Lo.maxFileSizeBytes,maxWidthOrHeight:oo?.maxWidthOrHeight??Lo.maxWidthOrHeight,placeholderTransitionDuration:oo?.placeholderTransitionDuration??Lo.placeholderTransitionDuration},Ob=OX(Qp),Fb=zX(l);Fb.current=l;let ZM=BX(iu=>{Ob?.(iu),Fb.current?.(iu)},[Ob]),zb=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return FX(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),zb)return;let Hb=au=>{typeof au.scale=="number"&&au.scale!==1&&au.preventDefault()};return document.addEventListener("touchmove",Hb,{passive:!1}),()=>{document.removeEventListener("touchmove",Hb)}},[zb]),dc(hx,{store:gt,children:dc(DM,{langCode:b,theme:P,children:dc(LM,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:ZM,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:v,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,UIOptions:hc,onPaste:F,detectScroll:Y,handleKeyboardGlobally:z,autoFocus:W,compressImageFile:Z,generateIdForFile:H,onLinkOpen:re,generateLinkForSelection:B,onPointerDown:U,onPointerUp:ue,onScrollChange:we,onUserFollow:pe,userToFollow:he,onDuplicate:ye,imageContextMenuItems:se,validateEmbeddable:st,renderEmbeddable:$e,showDeprecatedFonts:Re,wheelZoomsOnDefault:Do,strokeColorTopPicks:li,backgroundColorTopPicks:mc,renderScrollbars:pc,viewportStatusFrame:uc,currentUserControls:ru,imageOptions:KM,showDropEventDebugAlert:Rn,children:ve})})})},WX=(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),v=Object.keys(d);if(x.length!==v.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(L=>L==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[L]===d?.canvasActions?.[L]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Lo.maxWidthOrHeight)===(m?.maxWidthOrHeight??Lo.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Lo.maxFileSizeBytes)===(m?.maxFileSizeBytes??Lo.maxFileSizeBytes)&&(r?.placeholderTransitionDuration??Lo.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Lo.placeholderTransitionDuration);return T&&C&&GX(l,g)},VX=NX.memo(UX,WX);VX.displayName="Excalidraw";function VWe(e){return Ni(e,!1)}export{fn as Button,kVe as CaptureUpdateAction,fVe as DEFAULT_LASER_COLOR,lu as DEFAULT_OVERSCROLL,YE as DefaultSidebar,Cs as Ellipsify,VX as Excalidraw,Qa as ExcalidrawAPIContext,WWe as ExcalidrawAPIProvider,pVe as FONT_FAMILY,io as Fonts,EX as Footer,wX as LiveCollaborationTrigger,hVe as MIME_TYPES,_t as MainMenu,gVe as ROUNDNESS,Er as Sidebar,Gl as Stats,uVe as THEME,EVe as UserIdleState,SX as WelcomeScreen,kWe as applyDarkModeFilter,CVe as bumpVersion,Bh as captureDragEventData,zVe as convertToExcalidrawElements,On as defaultLang,GVe as elementsOverlappingBBox,YC as exportToBlob,wp as exportToCanvas,TH as exportToClipboard,XC as exportToSvg,OVe as getCommonBounds,Ic as getDataURL,yVe as getFormFactor,qWe as getNonDeletedElements,ZWe as getSceneVersion,MWe as getStrokeWidthByKey,QWe as getTextFromElements,FVe as getVisibleSceneBounds,$We as hashElementsVersion,jWe as hashString,VVe as isElementLink,tVe as isInvisiblySmallElement,dVe as isLinearElement,Ea as isSpreadsheetValidForChartType,gi as languages,ss as loadFromBlob,TVe as mutateElement,SVe as newElementWith,bVe as normalizeLink,Br as parseDataTransferEvent,Oh as parseDragImageMetadata,RX as reconcileElements,Ef as renderSpreadsheet,pi as restoreAppState,jM as restoreElement,Sr as restoreElements,xVe as sceneCoordsToViewportCoords,rs as serializeAsJSON,KVe as setCustomTextMetricsProvider,vVe as throttleRAF,_m as tryParseSpreadsheet,ge as useEditorInterface,wd as useExcalidrawAPI,VWe as useExcalidrawStateValue,Ae as useI18n,a6 as useOnExcalidrawStateChange,at as useStylesPanelMode,wVe as viewportCoordsToSceneCoords,Ir as zoomToFitBounds};
23
+ `),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=Ce({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:MV,verticalAlign:Pk,locked:!1},s=QE({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=Dk(a.fontFamily),[c,,d]=kY(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,y,w)=>{let x=DY(y).trim();if(x.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=aM(x,s,l),C=T.width>m,P=C?AY(x,s,m):x;T=C?aM(P,s,l):T;let A=r-T.width/2,L=u-T.height/2,_=Uk({...a,x:A,y:L,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:v?v.id:null});b.push(_),u+=_.height+p}else E[w-1]?.trim()&&(u+=sM(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:ke(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&IM===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),IM=!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&&Wt(c)?to(c,{originalText:s,isDeleted:l??c.isDeleted,...sY(c,Qk(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=R2({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=Fp({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Ye(s=>{a(s,!1),Yp(t)&&Gp(t,this.scene)}),onSubmit:Ye(({viaKeyboard:s,nextOriginalText:l})=>{this.textWysiwygSubmitHandler=null;let c=!l.trim();a(l,c);let d=s&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(c?null:t.id):null;d&&Gt(()=>{this.setState(m=>({selectedElementIds:ke({...m.selectedElementIds,[d]:!0},m)}))}),c&&JV(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Gt(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type==="autoshape")&&this.cursor.applyForTool(),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:r,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),a(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ke({},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 Wt(r)?r:t?ab(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(Wt(i))return null;if(!eM(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&&Wt(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 tc({point:ne(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:vt(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||!(Wt(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=mb(l,a);return c&&!Yp(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!ec(l)?nM({x:t,y:o},c,a):!0}).filter(l=>ec(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(Lk/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&bY([r],this.state,this.editorInterface)&&ZY(ne(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||CY(ne(t,o),r,this.scene.getNonDeletedElementsMap())?!0:tc({point:ne(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:vt(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 Kk(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]=zk(r[s],this.scene.getNonDeletedElementsMap());if(Ql(r[s])&&tc({point:ne(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(vt(r[s]))continue;a=r[s];break}}return Kk(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||Wt(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=me.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let s=-1,l=null;tc({point:ne(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=me.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=me.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Ut(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Pe.POINTER):this.hitElement(o,r,a)&&(!Ut(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Pe.MOVE)):this.hitElement(o,r,a)&&(!Ut(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Pe.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),me.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=QY(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(Pe.POINTER)}else this.cursor.set(Pe.AUTO)}updateGestureOnPointerDown(t){le.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),le.pointers.size===2&&(le.lastCenter=Hg(le.pointers),le.initialScale=this.state.zoom.value,le.initialDistance=Gg(Array.from(le.pointers.values())))}initialPointerDownState(t){let o=Ce(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=$a(r),c=r.findIndex(Ut)===0;return{origin:o,withCmdOrCtrl:t[X.CTRL_OR_CMD],originInGrid:eb(Ct(o.x,o.y,t[X.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:Qg(ic,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,Wk(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;Kp=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=hm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=Ye(()=>{Ja=null,Kp=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(J.POINTER_MOVE,r),window.removeEventListener(J.POINTER_UP,i),r.flush()});return Ja=i,window.addEventListener(J.POINTER_MOVE,r),window.addEventListener(J.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(Lk/this.state.zoom.value,1),i=EV*2/this.state.zoom.value,[a,s,l,c]=$a(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:dY(t)?Np.ADAPTIVE_RADIUS:Np.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return jV(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){bo({event:t,app:this,selectedElements:o})&&(r||!ln.getReferenceSnapPoints())&&ln.setReferenceSnapPoints(g2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){bo({event:t,app:this,selectedElements:o})&&(r||!ln.getVisibleGaps())&&ln.setVisibleGaps(h2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ye(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return Ye(o=>{o.key===X.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return hm(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Ce(o,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[p,u]=Ct(r.x,r.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=me.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?me.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=me.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=eb(XY(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(qt(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]=Ct(r.x,r.y,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,o)||this.maybeHandleResize(t,o)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){JY(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(me.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=me.addMidpoint(this.state.selectedLinearElement,r,this,!o[X.CTRL_OR_CMD],this.scene);if(!u)return;Gt(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(p.initialState.segmentMidpoint.value!==null&&!p.initialState.segmentMidpoint.added)return;if(p.initialState.lastClickedPoint>-1){let u=me.getElement(p.elementId,c);if(u?.isDeleted)return;if(no(u)){let g=wr(ne(r.x,r.y),this.scene.getNonDeletedElements(),c);Co("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Co("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),p.initialState.lastClickedPoint===-1)return;let E=me.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||!Bk(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=>vt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:tM(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()],y=o.shiftKey;if(y){let v=Math.abs(g.x),T=Math.abs(g.y),C=y&&v<T,P=y&&v>T;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let v=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(v&&oo(v)&&v.crop!==null&&t.hit.element===v){let T=v.crop,C=ja(v)&&this.imageCache.get(v.fileId)?.image;if(C&&!(C instanceof Promise)){let P=nX(v),A=yk(r.x-i.x,r.y-i.y);A[0]*=C.naturalWidth/P.width,A[1]*=C.naturalHeight/P.height;let[L,_,k,D,O,Y]=zk(v,c),z=jE($E(ne(L,_),ne(O,Y),v.angle)),W=jE($E(ne(k,_),ne(O,Y),v.angle)),Z=jE($E(ne(L,D),ne(O,Y),v.angle)),H=Tk(vk(W,z)),re=Tk(vk(Z,z)),B=yk(Ik(A,H),Ik(A,re)),U={...T,x:Kl(T.x-B[0]*Math.sign(v.scale[0]),0,C.naturalWidth-T.width),y:Kl(T.y-B[1]*Math.sign(v.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(v,{crop:U});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:w,snapLines:x}=f2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||YY(t,p,g,this.scene,w,o[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),o.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let v=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:A,duplicateElementsMap:L,elementsWithDuplicates:_,origIdToDuplicateId:k}=Vk({type:"in-place",elements:v,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:W})=>({frameId:z.frameId??W.frameId,seed:GV()})});A.forEach(z=>{t.originalElements.set(z.id,Wk(z))});let D=_.map(z=>{if(P.has(z.id)){let W=t.originalElements.get(z.id);if(W)return to(z,{x:W.x,y:W.y})}return z}),O=this.props.onDuplicate?.(D,v),Y=cM(O||D,Jl(A));Gt(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),W=z&&L.get(z);t.hit.element=W||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,W)=>{let Z=k.get(W.id),H=Z&&L.get(Z);return H&&z.push(H),z},[]),t.drag.origin=Ce(o,this.state),this.setState(z=>({...dM(A,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(Y),C.forEach(z=>{rb(z)&&z.boundElements?.some(W=>W.type==="arrow")&&Gp(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 w=p.simulatePressure?p.pressures:[...p.pressures,o.pressure];this.scene.mutateElement(p,{points:[...u,ne(E,g)],pressures:w},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Rt(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;eo(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 me(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,...me.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)me.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&Me(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Rn({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?Hb(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(g=>{let b={...u&&g.selectedElementIds,...E.reduce((y,w)=>(y[w.id]=!0,y),{})};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},{...Rn({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Rt(E[0])?new me(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Po(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*(ic.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*(ic.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ye(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===_n.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:ql(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,ln.setReferenceSnapPoints(null),ln.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=Ce({clientX:o.clientX,clientY:o.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(x=>this.state.selectedElementIds[x.id])){let x=this.getElementAtPosition(E.x,E.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),x?.locked?this.setState({activeLockedId:x.groupIds.length>0?x.groupIds.at(-1)||"":x.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(Co("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);rb(x)&&x.boundElements?.filter(v=>v.type==="arrow").map(v=>r.get(v.id)).filter(v=>Ut(v)).forEach(v=>{v&&this.scene.mutateElement(v,{})})}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(dt);else{let x=me.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(dt,"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=me.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(tX(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(dt,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Rt(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(J.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(J.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(J.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(J.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=Ce(o,this.state),v=i.points,T=x.x-i.x,C=x.y-i.y;T===v[0][0]&&C===v[0][1]&&(C+=1e-4,T+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...v,ne(T,C)],pressures:P}),this.actionManager.executeAction(dt);return}if(Rt(i)&&this.state.activeTool.type!=="autoshape"){let x=Ce(o,this.state),v=Jn(ne(x.x,x.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||v<UV)&&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:[ne(0,0),ne(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(dt)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),Rt(i)&&this.actionManager.executeAction(dt,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:$t(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ke({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new me(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if(Wt(i)){let x=NY(QE({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&&$k(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:jt.NEVER});return}if(vt(i)){let x=vY(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(cb(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,mY(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Ce(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let v=this.scene.getElement(this.state.selectedLinearElement.elementId);if(v?.frameId){let T=mb(v,r);T&&v&&(IY(v,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(v,{groupIds:[]}),yY([v],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let v=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:tM(v),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=A=>{if(A.length>0){for(let L of A){let _=L.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(L,{groupIds:L.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(L=>{L.groupIds.length&&si(C,L.groupIds[L.groupIds.length-1]).length<2&&this.scene.mutateElement(L,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let A=v.filter(L=>rM(L,C,this.state));this.state.editingGroupId&&P(A),C=cb(C,A,T)}else if(!T&&this.state.editingGroupId){let A=v.filter(L=>L.frameId&&!rM(L,C,this.state));P(A)}C=oM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&$k(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:jt.NEVER}),t.resize.isResizing){let x=oM(this.scene.getElementsIncludingDeleted(),this.state,this),v=this.scene.getSelectedElements(this.state).filter(vt);for(let T of v)x=wY(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&&Rt(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new me(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!p||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,y=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(qt(this.state)&&b&&y){if(this.eraserTrail.endPath(),Jn(ne(b.clientX,b.clientY),ne(y.clientX,y.clientY))===0){let v=Ce({clientX:y.clientX,clientY:y.clientY},this.state);this.getElementsAtPosition(v.x,v.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]?HY(this.state,g)?this.setState(x=>{let v={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>si(this.scene.getNonDeletedElements(),C)))delete v[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:ke(v,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let v={...x.selectedElementIds};delete v[g.id];let T=se(this.scene.getNonDeletedElements(),{selectedElementIds:v});return{...Rn({editingGroupId:x.editingGroupId,selectedElementIds:v},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Rt(T[0])?new me(T[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let v={...x.selectedElementIds,[g.id]:!0};return delete v[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>si(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete v[T.id]}),{...Rn({editingGroupId:x.editingGroupId,selectedElementIds:v},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Po(g)?"info":!1}}):this.setState(x=>({selectedElementIds:ke({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Rn({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Rt(g)&&x.selectedLinearElement?.elementId!==g.id?new me(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Ut(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&PY({point:ne(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:vt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(aa):this.setState({selectedElementIds:ke({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Pe.AUTO);return}let w=this.getSelectedTextEditingContainerAtPosition(g,E);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[X.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&(Wt(g)&&this.state.selectedElementIds[g.id]&&this.scene.getSelectedElements(this.state).length===1||w)){this.startTextEditing({sceneX:E.x,sceneY:E.y,container:w,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:E});return}if(!this.isToolLocked()&&c.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:ke({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Po(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||Me(this.scene.getNonDeletedElements(),this.state)||!Bk(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(Ql);Hk(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(dt);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==_n.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:$t(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:ke({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&lM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:ke({},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=sb(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<IV){let{x:m,y:p}=Fp({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=gi.find(o=>o.code===this.props.langCode)||Fn;await Sc(t),this.setAppState({})}},sX=()=>{(TM()||SM())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(PM(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};sX();var AM=bb;import{useEffect as cX,useState as dX}from"react";import{jsx as mX}from"react/jsx-runtime";var LM=e=>{let[n,t]=dX(!0);return cX(()=>{let o=async()=>{await Sc(r),t(!1)},r=gi.find(i=>i.code===e.langCode)||Fn;o()},[e.langCode]),n?mX(Jm,{theme:e.theme}):e.children};import pX from"clsx";import{jsx as DM}from"react/jsx-runtime";var _M=({children:e})=>{let{FooterCenterTunnel:n}=tt(),t=fe();return DM(n.In,{children:DM("div",{className:pX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},uX=_M;_M.displayName="FooterCenter";import hX from"clsx";import{MQ_MIN_WIDTH_DESKTOP as gX}from"@excalidraw/common";import{jsx as EX,jsxs as bX}from"react/jsx-runtime";var RM=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=fe(),i=t?.formFactor!=="desktop"||r.width<gX;return bX(fn,{...o,className:hX("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?Bx:f("labels.share"),r.collaborators.size>0&&EX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},fX=RM;RM.displayName="LiveCollaborationTrigger";import{jsx as vr,jsxs as BM}from"react/jsx-runtime";var xX=()=>vr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:vr("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"})}),wX=()=>BM("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[vr("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)"}),vr("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)"}),vr("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)"}),vr("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)"})]}),NM=({style:e,size:n="small",withText:t})=>BM("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[vr(xX,{}),t&&vr(wX,{})]});import{Fragment as zM,jsx as it,jsxs as Sb}from"react/jsx-runtime";var Cb=({icon:e,shortcut:n,children:t})=>{let o=ge();return Sb(zM,{children:[it("div",{className:"welcome-screen-menu-item__icon",children:e}),it("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&it("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};Cb.displayName="WelcomeScreenMenuItemContent";var sc=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>it("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:it(Cb,{icon:t,shortcut:o,children:n})});sc.displayName="WelcomeScreenMenuItem";var OM=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>it("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:it(Cb,{icon:t,shortcut:o,children:e})});OM.displayName="WelcomeScreenMenuItemLink";var bn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=tt();return it(n.In,{children:it("div",{className:"welcome-screen-center",children:e||Sb(zM,{children:[it(Pb,{}),it(kb,{children:f("welcomeScreen.defaults.center_heading")}),Sb(Mb,{children:[it(Lb,{}),it(Ab,{})]})]})})})};bn.displayName="Center";var Pb=({children:e})=>it("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||it(NM,{withText:!0})});Pb.displayName="Logo";var kb=({children:e})=>it("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});kb.displayName="Heading";var Mb=({children:e})=>it("div",{className:"welcome-screen-menu",children:e});Mb.displayName="Menu";var Ab=()=>{let e=nt();return it(sc,{onSelect:()=>e.executeAction(Hr),shortcut:"?",icon:wi,children:f("helpDialog.title")})};Ab.displayName="MenuItemHelp";var Lb=()=>{let e=fe(),n=nt();return e.viewModeEnabled?null:it(sc,{onSelect:()=>n.executeAction(Ui),shortcut:Ke("loadScene"),icon:Ac,children:f("buttons.load")})};Lb.displayName="MenuItemLoadScene";var FM=({onSelect:e})=>{let{t:n}=Ae();return it(sc,{shortcut:null,onSelect:e,icon:Lc,children:n("labels.liveCollaboration")})};FM.displayName="MenuItemLiveCollaborationTrigger";bn.Logo=Pb;bn.Heading=kb;bn.Menu=Mb;bn.MenuItem=sc;bn.MenuItemLink=OM;bn.MenuItemHelp=Ab;bn.MenuItemLoadScene=Lb;bn.MenuItemLiveCollaborationTrigger=FM;import{jsx as es,jsxs as Db}from"react/jsx-runtime";var Jp=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=tt();return es(n.In,{children:Db("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[bx,es("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};Jp.displayName="MenuHint";var Qp=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=tt();return es(n.In,{children:Db("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[es("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),wx]})})};Qp.displayName="ToolbarHint";var eu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=tt();return es(n.In,{children:Db("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[es("div",{children:e||f("welcomeScreen.defaults.helpHint")}),xx]})})};eu.displayName="HelpHint";import{Fragment as HM,jsx as lc,jsxs as vX}from"react/jsx-runtime";var tu=e=>lc(HM,{children:e.children||vX(HM,{children:[lc(bn,{}),lc(Jp,{}),lc(Qp,{}),lc(eu,{})]})});tu.displayName="WelcomeScreen";tu.Center=bn;tu.Hints={MenuHint:Jp,ToolbarHint:Qp,HelpHint:eu};var yX=tu;var IX=()=>{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)})},GM=IX;import{getSceneVersion as _We,hashElementsVersion as RWe,hashString as NWe,getNonDeletedElements as BWe}from"@excalidraw/element";import{getTextFromElements as FWe}from"@excalidraw/element";import{isInvisiblySmallElement as HWe}from"@excalidraw/element";import TX from"lodash.throttle";import{arrayToMap as SX,isDevEnv as UM,isTestEnv as WM}from"@excalidraw/common";import{orderByFractionalIndex as CX,syncInvalidIndices as VM,validateFractionalIndices as PX}from"@excalidraw/element";var kX=(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)),MX=TX((e,n,t)=>{if(UM()||WM()||window?.DEBUG_FRACTIONAL_INDICES){let o=VM(e.map(r=>({...r})));PX(o,{shouldThrow:WM()||UM(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),AX=(e,n,t)=>{let o=SX(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=kX(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=CX(r);return MX(a,e,n),VM(a),a};import{isLinearElement as $We}from"@excalidraw/element";import{FONT_FAMILY as qWe,THEME as JWe,MIME_TYPES as QWe,ROUNDNESS as eVe,DEFAULT_LASER_COLOR as tVe,UserIdleState as nVe,normalizeLink as oVe,sceneCoordsToViewportCoords as rVe,viewportCoordsToSceneCoords as iVe,getFormFactor as aVe,throttleRAF as sVe}from"@excalidraw/common";import{mutateElement as cVe,newElementWith as dVe,bumpVersion as mVe}from"@excalidraw/element";import{CaptureUpdateAction as uVe}from"@excalidraw/element";import{getCommonBounds as vVe,getVisibleSceneBounds as IVe,convertToExcalidrawElements as TVe}from"@excalidraw/element";import{elementsOverlappingBBox as CVe}from"@excalidraw/element";import{isElementLink as MVe}from"@excalidraw/element";import{setCustomTextMetricsProvider as DVe}from"@excalidraw/element";import{jsx as cc}from"react/jsx-runtime";GM();var kWe=({children:e})=>{let[n,t]=BX(null);return cc(Qa.Provider,{value:n,children:cc(qp.Provider,{value:t,children:e})})},FX=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=Fn.code,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:v,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,onPaste:O,detectScroll:Y=!0,handleKeyboardGlobally:z=!1,autoFocus:W=!1,compressImageFile:Z,generateIdForFile:H,onLinkOpen:re,generateLinkForSelection:B,onPointerDown:U,onPointerUp:ue,onScrollChange:we,onUserFollow:pe,userToFollow:he,onDuplicate:ye,imageContextMenuItems:ae,children:ve,validateEmbeddable:st,renderEmbeddable:je,showDeprecatedFonts:Re,wheelZoomsOnDefault:Do,strokeColorTopPicks:li,backgroundColorTopPicks:dc,renderScrollbars:mc,viewportStatusFrame:pc,currentUserControls:nu,imageOptions:ro,showDropEventDebugAlert:Nn}=e,ts=e.UIOptions?.canvasActions,uc={...e.UIOptions,canvasActions:{...YM.canvasActions,...ts},tools:{image:e.UIOptions?.tools?.image??!0}};ts?.export&&(uc.canvasActions.export.saveFileToDisk=ts.export?.saveFileToDisk??YM.canvasActions.export.saveFileToDisk),uc.canvasActions.toggleTheme===null&&(P==null||r)&&(uc.canvasActions.toggleTheme=!0);let XM={maxFileSizeBytes:ro?.maxFileSizeBytes??Lo.maxFileSizeBytes,maxWidthOrHeight:ro?.maxWidthOrHeight??Lo.maxWidthOrHeight,placeholderTransitionDuration:ro?.placeholderTransitionDuration??Lo.placeholderTransitionDuration},_b=_X(qp),Rb=NX(l);Rb.current=l;let KM=DX(ou=>{_b?.(ou),Rb.current?.(ou)},[_b]),Nb=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return RX(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),Nb)return;let Bb=ru=>{typeof ru.scale=="number"&&ru.scale!==1&&ru.preventDefault()};return document.addEventListener("touchmove",Bb,{passive:!1}),()=>{document.removeEventListener("touchmove",Bb)}},[Nb]),cc(mx,{store:gt,children:cc(LM,{langCode:b,theme:P,children:cc(AM,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:KM,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:y,viewModeOnly:w,interaction:x,ui:v,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:A,name:L,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:D,UIOptions:uc,onPaste:O,detectScroll:Y,handleKeyboardGlobally:z,autoFocus:W,compressImageFile:Z,generateIdForFile:H,onLinkOpen:re,generateLinkForSelection:B,onPointerDown:U,onPointerUp:ue,onScrollChange:we,onUserFollow:pe,userToFollow:he,onDuplicate:ye,imageContextMenuItems:ae,validateEmbeddable:st,renderEmbeddable:je,showDeprecatedFonts:Re,wheelZoomsOnDefault:Do,strokeColorTopPicks:li,backgroundColorTopPicks:dc,renderScrollbars:mc,viewportStatusFrame:pc,currentUserControls:nu,imageOptions:XM,showDropEventDebugAlert:Nn,children:ve})})})},zX=(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),v=Object.keys(d);if(x.length!==v.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(L=>L==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[L]===d?.canvasActions?.[L]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Lo.maxWidthOrHeight)===(m?.maxWidthOrHeight??Lo.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Lo.maxFileSizeBytes)===(m?.maxFileSizeBytes??Lo.maxFileSizeBytes)&&(r?.placeholderTransitionDuration??Lo.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Lo.placeholderTransitionDuration);return T&&C&&OX(l,g)},HX=LX.memo(FX,zX);HX.displayName="Excalidraw";function MWe(e){return Ni(e,!1)}export{fn as Button,uVe as CaptureUpdateAction,tVe as DEFAULT_LASER_COLOR,au as DEFAULT_OVERSCROLL,UE as DefaultSidebar,Cs as Ellipsify,HX as Excalidraw,Qa as ExcalidrawAPIContext,kWe as ExcalidrawAPIProvider,qWe as FONT_FAMILY,ao as Fonts,uX as Footer,fX as LiveCollaborationTrigger,QWe as MIME_TYPES,_t as MainMenu,eVe as ROUNDNESS,Er as Sidebar,Hl as Stats,JWe as THEME,nVe as UserIdleState,yX as WelcomeScreen,uWe as applyDarkModeFilter,mVe as bumpVersion,Rh as captureDragEventData,TVe as convertToExcalidrawElements,Fn as defaultLang,CVe as elementsOverlappingBBox,WC as exportToBlob,Ep as exportToCanvas,yH as exportToClipboard,VC as exportToSvg,vVe as getCommonBounds,vc as getDataURL,aVe as getFormFactor,BWe as getNonDeletedElements,_We as getSceneVersion,hWe as getStrokeWidthByKey,FWe as getTextFromElements,IVe as getVisibleSceneBounds,RWe as hashElementsVersion,NWe as hashString,MVe as isElementLink,HWe as isInvisiblySmallElement,$We as isLinearElement,Ea as isSpreadsheetValidForChartType,gi as languages,ss as loadFromBlob,cVe as mutateElement,dVe as newElementWith,oVe as normalizeLink,Br as parseDataTransferEvent,Nh as parseDragImageMetadata,AX as reconcileElements,hf as renderSpreadsheet,pi as restoreAppState,$M as restoreElement,Sr as restoreElements,rVe as sceneCoordsToViewportCoords,rs as serializeAsJSON,DVe as setCustomTextMetricsProvider,sVe as throttleRAF,Am as tryParseSpreadsheet,ge as useEditorInterface,Ed as useExcalidrawAPI,MWe as useExcalidrawStateValue,Ae as useI18n,i6 as useOnExcalidrawStateChange,at as useStylesPanelMode,iVe as viewportCoordsToSceneCoords,Ir as zoomToFitBounds};