@myoc/excalidraw 0.19.4 → 0.19.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/{chunk-ZCRRPXDS.js → chunk-LMSQM7RP.js} +3 -3
- package/dist/dev/{chunk-BVSQPBD5.js → chunk-O64KOXGX.js} +2 -2
- package/dist/dev/data/{image-BVTQCISX.js → image-Z4UWWRMA.js} +3 -3
- package/dist/dev/index.js +140 -222
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/{chunk-VE3EUABP.js → chunk-COCFTLLX.js} +1 -1
- package/dist/prod/{chunk-2E373UDT.js → chunk-DWIVCTY2.js} +2 -2
- package/dist/prod/data/image-UCRRORR6.js +1 -0
- package/dist/prod/index.js +15 -15
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/element/src/index.d.ts +1 -0
- package/dist/types/element/src/shapes.d.ts +149 -2
- package/package.json +1 -1
- package/dist/prod/data/image-UFCJS6AE.js +0 -1
- package/dist/types/excalidraw/components/shapes.d.ts +0 -190
- /package/dist/dev/{chunk-ZCRRPXDS.js.map → chunk-LMSQM7RP.js.map} +0 -0
- /package/dist/dev/{chunk-BVSQPBD5.js.map → chunk-O64KOXGX.js.map} +0 -0
- /package/dist/dev/data/{image-BVTQCISX.js.map → image-Z4UWWRMA.js.map} +0 -0
package/dist/prod/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import{$ as Lm,A as iS,B as s1,C as c1,D as d1,E as ds,F as ms,G as ps,H as us,I as va,J as m1,K as p1,L as u1,M as hs,N as Gr,O as h1,P as aS,Q as qn,R as Ur,S as Ia,U as g1,W as f1,X as b1,Y as gs,Z as E1,_ as Pm,a as r1,aa as fs,b as jn,ba as x1,c as yo,ca as Am,d as i1,da as Jn,e as ve,ea as y1,f as a1,fa as _m,g as q,ga as w1,h as Br,ha as v1,i as wo,ia as bs,j as Ea,ja as Dm,k as xa,ka as I1,l as Fr,la as T1,m as ya,ma as S1,n as Or,na as Ta,o as l1,p as Cm,q as un,r as zr,s as wt,t as lo,u as Hr,v as ss,w as km,x as wa,y as cs,z as Mm}from"./chunk-2E373UDT.js";import{a as T}from"./chunk-VE3EUABP.js";import{J as Sm}from"./chunk-SXXYW6U7.js";import{c as n1}from"./chunk-AJI3LATG.js";import{b as t1,c as o1,d as S}from"./chunk-SRAX5OIU.js";import PG,{useEffect as LG}from"react";import{DEFAULT_UI_OPTIONS as tS,isShallowEqual as AG}from"@excalidraw/common";import B5 from"clsx";import lz from"lodash.throttle";import Yo,{useContext as Zn}from"react";import{flushSync as no}from"react-dom";import sz from"roughjs/bin/rough";import{nanoid as cz}from"nanoid";import{clamp as F5,pointFrom as oe,pointDistance as Pr,vector as O5,pointRotateRads as cf,vectorScale as dz,vectorFromPoint as df,vectorSubtract as z5,vectorDot as H5,vectorNormalize as G5}from"@excalidraw/math";import{COLOR_PALETTE as mz,CODES as U5,shouldResizeFromCenter as W5,shouldMaintainAspectRatio as Xl,shouldRotateWithDiscreteAngle as Y5,isArrowKey as cm,KEYS as X,APP_NAME as pz,CURSOR_TYPE as Ne,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as uz,DEFAULT_VERTICAL_ALIGN as V5,DRAGGING_THRESHOLD as hz,ELEMENT_SHIFT_TRANSLATE_AMOUNT as gz,ELEMENT_TRANSLATE_AMOUNT as X5,EVENT as re,FRAME_STYLE as zo,IMAGE_MIME_TYPES as fz,IMAGE_RENDER_TIMEOUT as bz,LINE_CONFIRM_THRESHOLD as mf,MAX_ALLOWED_FILE_BYTES as K5,MIME_TYPES as Ho,MQ_RIGHT_SIDEBAR_MIN_WIDTH as Ez,POINTER_BUTTON as Lr,ROUNDNESS as dm,SCROLL_TIMEOUT as xz,TAP_TWICE_TIMEOUT as yz,TEXT_TO_CENTER_SNAP_THRESHOLD as wz,THEME as mm,TOUCH_CTX_MENU_TIMEOUT as vz,VERTICAL_ALIGN as Iz,YOUTUBE_STATES as pm,ZOOM_STEP as Tz,POINTER_EVENTS as ma,TOOL_TYPE as Go,supportsResizeObserver as Sz,DEFAULT_COLLISION_THRESHOLD as Z5,DEFAULT_TEXT_ALIGN as Cz,ARROW_TYPE as Yn,DEFAULT_REDUCED_GLOBAL_ALPHA as kz,isLocalLink as Mz,normalizeLink as pf,toValidURL as Pz,getGridPoint as pt,getLineHeight as $5,debounce as j5,distance as pa,getFontString as uf,getNearestScrollableContainer as Lz,isInputLike as q5,isToolIcon as Az,isWritableElement as Kl,sceneCoordsToViewportCoords as um,tupleToCoors as hf,viewportCoordsToSceneCoords as Be,wrapEvent as _z,updateObject as gf,updateActiveTool as Uo,isTransparent as Dz,easeToValuesRAF as Rz,muteFSAbortError as Nz,isTestEnv as RT,isDevEnv as NT,easeOut as Bz,updateStable as Zl,addEventListener as Fe,normalizeEOL as Fz,getDateTime as J5,isShallowEqual as Q5,arrayToMap as hm,applyDarkModeFilter as Oz,randomInteger as zz,CLASSES as ff,Emitter as Ar,MINIMUM_ARROW_SIZE as Hz,DOUBLE_TAP_POSITION_THRESHOLD as Gz,BIND_MODE_TIMEOUT as Uz,invariant as Wo,getFeatureFlag as dn,createUserAgentDescriptor as BT,getFormFactor as Wz,deriveStylesPanelMode as ym,isIOS as Yz,isBrave as Vz,isSafari as Xz,loadDesktopUIModePreference as Kz,setDesktopUIMode as Zz,isSelectionLikeTool as gm}from"@excalidraw/common";import{getObservedAppState as $z,getCommonBounds as ua,getElementAbsoluteCoords as eT,bindOrUnbindBindingElements as tT,fixBindingsAfterDeletion as jz,getHoveredElementForBinding as Eo,isBindingEnabled as $l,shouldEnableBindingForPointerEvent as qz,updateBoundElements as fm,LinearElementEditor as pe,newElementWith as Vn,newFrameElement as Jz,newFreeDrawElement as Qz,newEmbeddableElement as oT,newMagicFrameElement as nT,newIframeElement as eH,newArrowElement as tH,newElement as oH,newImageElement as nH,newLinearElement as rH,newTextElement as rT,refreshTextDimensions as iH,deepCopyElement as iT,duplicateElements as bf,hasBoundTextElement as aT,isArrowElement as ha,isBindingElement as Xn,isBindingElementType as aH,isBoundToContainer as Ef,isFrameLikeElement as Lt,isImageElement as _r,isEmbeddableElement as mn,isInitializedImageElement as jl,isLinearElement as Et,isLinearElementType as lH,isUsingAdaptiveRadius as sH,isIframeElement as ga,isIframeLikeElement as ql,isMagicFrameElement as lT,isTextBindableContainer as sT,isElbowArrow as At,isFlowchartNodeElement as cH,isBindableElement as xf,isTextElement as xo,getNormalizedDimensions as dH,isElementCompletelyInViewport as yf,isElementInViewport as cT,isInvisiblySmallElement as dT,getCornerRadius as mH,isPathALoop as mT,createSrcDoc as pT,embeddableURLValidator as wf,maybeParseEmbedSrc as pH,getEmbedLink as bm,getInitializedImageElements as uH,normalizeSVG as uT,updateImageCache as hH,getBoundTextElement as vf,getContainerCenter as If,getContainerElement as hT,isValidTextContainer as gH,redrawTextBoundingBox as fH,hasBoundingBox as bH,getFrameChildren as Tf,isCursorInFrame as gT,addElementsToFrame as Sf,replaceAllElementsInFrame as EH,removeElementsFromFrame as xH,getElementsInResizingFrame as Cf,getElementsInNewFrame as yH,getContainingFrame as kf,elementOverlapsWithFrame as wH,updateFrameMembershipOfSelectedElements as fT,isElementInFrame as bT,getFrameLikeTitle as vH,getElementsOverlappingFrame as IH,filterElementsEligibleAsFrameChildren as TH,hitElementBoundText as SH,hitElementBoundingBoxOnly as CH,hitElementItself as Jl,getVisibleSceneBounds as kH,FlowChartCreator as MH,FlowChartNavigator as PH,getLinkDirectionFromKey as ET,cropElement as LH,wrapText as AH,isElementLink as Mf,parseElementLinkFromURL as _H,isMeasureTextSupported as DH,normalizeText as RH,measureText as xT,getLineHeightInPx as NH,getApproxMinLineWidth as BH,getApproxMinLineHeight as FH,getMinTextElementWidth as OH,ShapeCache as Ql,getRenderOpacity as zH,editGroupForSelectedElement as HH,getElementsInGroup as Dr,getSelectedGroupIdForElement as GH,getSelectedGroupIds as UH,isElementInGroup as yT,isSelectedViaGroup as WH,selectGroupsForSelectedElements as ro,syncInvalidIndices as FT,syncMovedIndices as wT,excludeElementsInFramesFromSelection as YH,getSelectionStateForElements as VH,makeNextSelectedElementIds as ye,getResizeOffsetXY as XH,getResizeArrowDirection as KH,transformElements as ZH,getCursorForResizingElement as vT,getElementWithTransformHandleType as IT,getTransformHandleTypeFromCoords as TT,dragNewElement as ST,dragSelectedElements as $H,getDragOffsetXY as jH,isNonDeletedElement as CT,Scene as kT,Store as qH,CaptureUpdateAction as xt,hitElementBoundingBox as JH,isLineElement as Pf,isSimpleArrow as Lf,StoreDelta as MT,positionElementsOnGrid as PT,calculateFixedPointForNonElbowArrowBinding as LT,bindOrUnbindBindingElement as QH,mutateElement as Em,getElementBounds as AT,doBoundsIntersect as eG,isPointInElement as tG,maxBindingDistance_simple as Af,convertToExcalidrawElements as oG}from"@excalidraw/element";import{KEYS as ap,MOBILE_ACTION_BUTTON_BG as wS,updateActiveTool as vS}from"@excalidraw/common";import{getNonDeletedElements as lp}from"@excalidraw/element";import{fixBindingsAfterDeletion as IS}from"@excalidraw/element";import{LinearElementEditor as bb}from"@excalidraw/element";import{newElementWith as Os}from"@excalidraw/element";import{getContainerElement as Eb}from"@excalidraw/element";import{isBoundToContainer as Bs,isElbowArrow as TS,isFrameLikeElement as SS}from"@excalidraw/element";import{getFrameChildren as CS}from"@excalidraw/element";import{getElementsInGroup as sp,selectGroupsForSelectedElements as kS}from"@excalidraw/element";import{CaptureUpdateAction as Fs}from"@excalidraw/element";import{isDevEnv as dS}from"@excalidraw/common";import{atom as Se,createStore as lS}from"jotai";import{createIsolation as sS}from"jotai-scope";var C1=sS();var{useAtom:ue,useSetAtom:Wr,useAtomValue:Es,useStore:FG}=C1,k1=C1.Provider,$e=lS();var cS=t1({"./locales/ar-SA.json":()=>import("./locales/ar-SA-EYKRCXR6.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-ZNDJBVCS.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-O5I6U3AR.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-CXZY522G.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-HPUBVY4I.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-AREX5NEO.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-HXAZMFYH.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5X7ZLFU3.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-76ZNVSOF.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-G3JVZ4MQ.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-4AZTZGY6.js"),"./locales/en.json":()=>import("./locales/en-IT7EQLWB.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-ART7BI3G.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-BIF4XBMT.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-D4HHKAAI.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-O35ZY7UI.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-XEFNCM4I.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-U4NYM3X5.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-656ABAVQ.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-Z55GAFFR.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-UJ62DVIW.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-FLZFU3OO.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-GIGIGIBJ.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-43VXGDWI.js"),"./locales/kaa.json":()=>import("./locales/kaa-L3IMSDYL.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-XKPWJLNL.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-SXPDDY2H.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-DOS4CPGC.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-BGC6VCY4.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-J7IUITIA.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-AC3LV5KG.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-I6AY7QG2.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-5SP4HV5B.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-S7ECRBYZ.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-6PNHTF4R.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-R4C4SUIG.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-3TFXTM7Y.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-IK6GIE7H.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-YAKHYJET.js"),"./locales/percentages.json":()=>import("./locales/percentages-OL6W367U.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-BIY22ZWU.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-Q23NUPD6.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-LOPEJLPJ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-W3D2ZATV.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-DCTW7QSH.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-FYRRHO3C.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-MC7UOHQO.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-L6B6HFY5.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-KMY6L2BA.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-ZQCYE2JK.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-WS7ECBAV.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-S5FI7JRW.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-4EZUWUSQ.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-OKHL6AFA.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-K34TWHF7.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-JE4UZWNO.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-RM35YDXX.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-ONGLV6Y5.js")});var mS=85,vo={code:"en",label:"English"},Vr=[vo,...[{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=>n1[e.code]>=mS).sort((e,o)=>e.label>o.label?1:-1)],ys="__test__";dS()&&Vr.unshift({code:ys,label:"test language"},{code:`${ys}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Yr=vo,xs={},ws=async e=>{if(Yr=e,document.documentElement.dir=Yr.rtl?"rtl":"ltr",document.documentElement.lang=Yr.code,e.code.startsWith(ys))xs={};else try{xs=await cS(`./locales/${Yr.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),xs=Sm}$e.set(P1,e.code)},Xo=()=>Yr,M1=(e,o)=>{for(let t=0;t<o.length;++t){let n=o[t];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},g=(e,o,t)=>{if(Yr.code.startsWith(ys))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=M1(xs,n)||M1(Sm,n)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)r=r.replace(`{{${i}}}`,String(o[i]));return r},P1=Se(vo.code),Ue=()=>{let e=Es(P1);return{t:g,langCode:e}};import pS from"clsx";import it from"react";import{THEME as uS}from"@excalidraw/common";import{Fragment as Ie,jsx as u,jsxs as R}from"react/jsx-runtime";var so=e=>"var(--icon-fill-color)",L1=e=>e===uS.LIGHT?"#fff":"#1e1e1e",M=(e,o=512)=>{let{width:t=512,height:n=t,mirror:r,style:i,...a}=typeof o=="number"?{width:o}:o;return u("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${n}`,className:pS({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?u("path",{fill:"currentColor",d:e}):e})},z={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"},JG=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("rect",{x:3,y:8,width:18,height:4,rx:1}),u("line",{x1:12,y1:8,x2:12,y2:21}),u("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),u("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),z),vs=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),u("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),u("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),u("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),u("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),z),A1=M(R("svg",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),u("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),z),_1=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("circle",{cx:"12",cy:"12",r:"1"}),u("circle",{cx:"12",cy:"19",r:"1"}),u("circle",{cx:"12",cy:"5",r:"1"})]}),z),D1=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),u("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),u("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),z),R1=M(R("svg",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),u("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),u("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),z),Rm=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M6.5 9.5l3.5 -3"}),u("path",{d:"M14 5.5l3 1.5"}),u("path",{d:"M18.5 10l-2.5 7"}),u("path",{d:"M13.5 17.5l-7 -5"})]}),z),Ko=M(R("g",{children:[u("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"}),u("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"}),u("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:u("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"})}),u("g",{mask:"url(#UnlockedIcon)",children:u("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),hn=M(R("g",{strokeWidth:"1.25",children:[u("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"}),u("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),u("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),N1=M(u("g",{fill:"currentColor",children:u("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}),B1=M(R(Ie,{children:[u("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"}),u("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),u("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"}),F1=M(R(Ie,{children:[u("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"}),u("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),u("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"}),O1=M(R(Ie,{children:[u("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"}),u("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),u("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"}),QG=M(u("g",{fill:"currentColor",children:u("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"}),Qn=M(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),gn=M(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[u("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"}),u("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Xr=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),z),Kr=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),z),Zr=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("circle",{cx:"12",cy:"12",r:"9"})]}),z),Is=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),u("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),u("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),z),$r=M(u("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ie),z1=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),u("path",{d:"M16 7h4"}),u("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),z),Io=M(R("g",{strokeWidth:"1.25",children:[u("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"}),u("path",{d:"m11.25 5.417 3.333 3.333"})]}),ie),To=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),u("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),u("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),u("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),u("polyline",{points:"5 20 11 4 13 4 20 20"})]}),z),H1=M(R("g",{stroke:"currentColor",strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 7v-2h13v2"}),u("path",{d:"M10 5v14"}),u("path",{d:"M12 19h-4"}),u("path",{d:"M15 13v-1h6v1"}),u("path",{d:"M18 12v7"}),u("path",{d:"M17 19h2"})]}),z),jr=M(R("g",{strokeWidth:"1.25",children:[u("path",{d:"M12.5 6.667h.01"}),u("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"}),u("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),u("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),ie),Ts=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M18 13.3l-6.3 -6.3"})]}),z),Nm=M(u("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ie),Bm=M(u("path",{d:"M5 10h10",strokeWidth:"1.25"}),ie),G1=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M21 21l-6 -6"}),u("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"}),u("path",{d:"M3 4v4h4"})]}),z),Zo=M(u("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),Ss=M(R("g",{strokeWidth:"1.5",children:[u("polyline",{points:"12 16 18 10 12 4"}),u("polyline",{points:"8 4 2 10 8 16"})]}),ie),Sa=M(R("g",{strokeWidth:"1.25",children:[u("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"}),u("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),Ca=M(u("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),ka=M(u("g",{stroke:"currentColor",strokeLinejoin:"round",children:u("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}),U1=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),u("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),u("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),z),er=M(u("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),qr=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("circle",{cx:"12",cy:"12",r:"9"}),u("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),u("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),W1=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("circle",{cx:"12",cy:"12",r:"9"}),u("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),u("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),eU=M(u("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),Y1=M(u("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),V1=M(R("g",{strokeWidth:"1.25",children:[u("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"}),u("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),X1=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),u("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),z),K1=M(u("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Ma=M(R("g",{strokeWidth:"1.25",children:[u("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"}),u("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),Z1=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}),$1=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}),Jr=M(u("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),tU=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}),oU=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"),Cs=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),u("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),u("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),z),j1=M(u("g",{strokeWidth:1.5,children:u("path",{d:"M6 18l12 -12"})}),z),ks=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M15 8h.01"}),u("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),u("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),u("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),u("path",{d:"M19 16v6"}),u("path",{d:"M22 19l-3 3l-3 -3"})]}),z),q1=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}),nU=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}),rU=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}),J1=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"),iU=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"),Fm=M(u("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),Om=M(u("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),Q1=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}),e0=M(u("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),aU=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"),lU=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}),sU=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M12 14v-11"}),u("path",{d:"M9 6l3 -3l3 3"})]}),z),cU=M(R(Ie,{children:[u("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"}),u("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}),dU=M(u("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}),t0=R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 10l0 10"}),u("path",{d:"M12 10l4 4"}),u("path",{d:"M12 10l-4 4"}),u("path",{d:"M4 4l16 0"})]}),o0=R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 5l0 14"}),u("path",{d:"M16 9l-4 -4"}),u("path",{d:"M8 9l4 -4"})]}),zm=M(o0,z),Hm=M(o0,{...z,style:{transform:"rotate(180deg)"}}),Gm=M(t0,z),Um=M(t0,{...z,style:{transform:"rotate(180deg)"}}),Wm=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),Ym=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),Vm=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),Xm=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),n0=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),r0=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),Km=M(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),u("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),u("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),u("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),Zm=M(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),u("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),u("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),u("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),Ms=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("circle",{cx:"9",cy:"7",r:"4"}),u("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),u("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),u("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),z),mU=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"),pU=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"),Ut=M(R(Ie,{children:[u("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:u("path",{d:"M15 5 5 15M5 5l10 10"})}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),uU=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}),hU=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}),gU=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}),$m=it.memo(({theme:e})=>M(R(Ie,{children:[u("path",{d:"M25 26H111V111H25",fill:so(e)}),u("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:so(e),strokeWidth:"2"}),u("path",{d:"M100 100H160V160H100",fill:so(e)}),u("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:so(e),strokeWidth:"2"}),R("g",{fill:L1(e),stroke:so(e),strokeWidth:"6",children:[u("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),u("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),u("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),u("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),jm=it.memo(({theme:e})=>M(R(Ie,{children:[u("path",{d:"M25 26H111V111H25",fill:so(e)}),u("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:so(e),strokeWidth:"2"}),u("path",{d:"M100 100H160V160H100",fill:so(e)}),u("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:so(e),strokeWidth:"2"}),R("g",{fill:L1(e),stroke:so(e),strokeWidth:"6",children:[u("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),u("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),u("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),u("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),u("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),u("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),i0=M(u("g",{strokeWidth:1.25,children:u("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),a0=M(R(Ie,{children:[u("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"}),u("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:u("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"})}),u("g",{mask:"url(#FillHachureIcon)",children:u("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),l0=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",children:[u("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"}),u("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:u("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"})}),u("g",{mask:"url(#FillCrossHatchIcon)",children:u("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"})})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),s0=M(R(Ie,{children:[u("g",{clipPath:"url(#a)",children:u("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"})}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...ie,fill:"currentColor"}),qm=M(u(Ie,{children:u("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ie),c0=M(u("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ie),d0=M(u("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ie),fU=it.memo(({theme:e})=>M(u("path",{d:"M6 10H34",stroke:so(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),m0=M(R("g",{strokeWidth:"2",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 12h2"}),u("path",{d:"M17 12h2"}),u("path",{d:"M11 12h2"})]}),z),p0=M(R("g",{strokeWidth:"2",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 12v.01"}),u("path",{d:"M8 12v.01"}),u("path",{d:"M12 12v.01"}),u("path",{d:"M16 12v.01"}),u("path",{d:"M20 12v.01"})]}),z),u0=M(u("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),h0=M(u("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),g0=M(u("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),f0=M(R("svg",{strokeWidth:"1.5",children:[u("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"}),u("path",{d:"M13.3333 3.33331V3.34331"}),u("path",{d:"M16.6667 3.33331V3.34331"}),u("path",{d:"M16.6667 6.66669V6.67669"}),u("path",{d:"M16.6667 10V10.01"}),u("path",{d:"M3.33334 13.3333V13.3433"}),u("path",{d:"M16.6667 13.3333V13.3433"}),u("path",{d:"M3.33334 16.6667V16.6767"}),u("path",{d:"M6.66666 16.6667V16.6767"}),u("path",{d:"M10 16.6667V16.6767"}),u("path",{d:"M13.3333 16.6667V16.6767"}),u("path",{d:"M16.6667 16.6667V16.6767"})]}),ie),b0=M(R("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),u("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),u("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),u("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),u("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),u("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),u("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),u("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),u("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),u("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),u("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),u("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),z),E0=M(R("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[u("path",{d:"M12 12l9 0"}),u("path",{d:"M3 9l6 6"}),u("path",{d:"M3 15l6 -6"})]}),z),x0=it.memo(({flip:e=!1})=>M(R("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[u("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),u("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),y0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[u("path",{d:"M32 10L6 10",strokeWidth:2}),u("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),w0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[u("path",{d:"M26 10L6 10"}),u("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),v0=it.memo(({flip:e=!1})=>M(u("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:u("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),I0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[u("path",{d:"M32 10L6 10",strokeWidth:2}),u("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),T0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[u("path",{d:"M6,9.5H27"}),u("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),S0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[u("path",{d:"M6,9.5H20"}),u("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),C0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[u("path",{d:"M6,9.5H20"}),u("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),k0=it.memo(({flip:e=!1})=>M(u("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:u("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),M0=it.memo(({flip:e=!1})=>M(u("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:u("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),P0=it.memo(({flip:e=!1})=>M(u("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:u("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),L0=M(R(Ie,{children:[u("g",{clipPath:"url(#a)",children:u("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"})}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),A0=M(R(Ie,{children:[u("g",{clipPath:"url(#a)",children:u("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),_0=M(R(Ie,{children:[u("g",{clipPath:"url(#a)",children:u("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),D0=M(u(Ie,{children:u("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),tr=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 7v-2h13v2"}),u("path",{d:"M10 5v14"}),u("path",{d:"M12 19h-4"}),u("path",{d:"M15 13v-1h6v1"}),u("path",{d:"M18 12v7"}),u("path",{d:"M17 19h2"})]}),z),R0=M(u(Ie,{children:R("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M7 12h10"}),u("path",{d:"M7 5v14"}),u("path",{d:"M17 5v14"}),u("path",{d:"M15 19h4"}),u("path",{d:"M15 5h4"}),u("path",{d:"M5 19h4"}),u("path",{d:"M5 5h4"})]})}),z),Pa=M(u(Ie,{children:u("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:u("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),hS=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M7 8l-4 4l4 4"}),u("path",{d:"M17 8l4 4l-4 4"}),u("path",{d:"M14 4l-4 16"})]}),z),Ps=hS,N0=M(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),u("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),u("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),z),B0=M(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),u("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),u("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),z),F0=M(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),u("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),u("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),z),O0=it.memo(({theme:e})=>M(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),u("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),z)),z0=it.memo(({theme:e})=>M(R("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),u("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),z)),H0=it.memo(({theme:e})=>M(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),u("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),u("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),z)),Ls=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M21 19h-18l9 -15"}),u("path",{d:"M20.615 15.171h.015"}),u("path",{d:"M19.515 11.771h.015"}),u("path",{d:"M17.715 8.671h.015"}),u("path",{d:"M15.415 5.971h.015"})]}),z),G0=M(u("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}),bU=M(u("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"})),As=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),u("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),u("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),u("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),z),Jm=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),u("path",{d:"M7 11l5 5l5 -5"}),u("path",{d:"M12 4l0 12"})]}),z),Qr=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),z),U0=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),u("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),u("path",{d:"M9.15 14.85l8.85 -10.85"}),u("path",{d:"M6 4l8.85 10.85"})]}),z),W0=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),u("path",{d:"M12 17l0 .01"}),u("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),EU=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M7 4v16l13 -8z"})]}),z),xU=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),z),Y0=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 12l5 5l10 -10"})]}),z),V0=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M12 9v4"}),u("path",{d:"M12 17h.01"})]}),z),X0=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M11 7l6 6"}),u("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),z),ei=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 3l-4 7h8z"}),u("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),u("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),z),fn=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 7l16 0"}),u("path",{d:"M4 17l16 0"}),u("path",{d:"M7 4l0 16"}),u("path",{d:"M17 4l0 16"})]}),z),yU=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),u("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),z),wU=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),u("path",{d:"M4 15l8 4l8 -4"}),u("path",{d:"M12 4v7"}),u("path",{d:"M15 8l-3 3l-3 -3"})]}),z),vU=M(R("g",{strokeWidth:"1.25",children:[u("path",{d:"M4.16602 10H15.8327"}),u("path",{d:"M12.5 13.3333L15.8333 10"}),u("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),ie),ti=M(R("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[u("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"}),u("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),K0=M(R("g",{stroke:"currentColor",fill:"none",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z"}),u("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),u("path",{d:"M15 6l3 3"}),u("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"}),u("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),IU=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z"}),u("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),u("path",{d:"M15 6l3 3"}),u("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"}),u("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),TU=M(R("g",{stroke:"currentColor",fill:"none",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),u("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),u("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"}),u("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),u("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),u("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),z),Z0=M(R("g",{stroke:"currentColor",fill:"none",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),u("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),u("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),u("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),z),or=M(R("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),u("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),z),$0=M(R("g",{stroke:"currentColor",fill:"none",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),u("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"}),u("path",{d:"M3 3l18 18"})]}),z),SU=M(R("g",{stroke:"currentColor",fill:"none",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("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"}),u("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),u("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),u("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),u("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),CU=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("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"}),u("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),u("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),u("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),u("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),_t=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),u("path",{d:"M21 21l-6 -6"})]}),z),j0=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),u("path",{d:"M12 7v5l3 3"}),u("path",{d:"M19 16l-2 3h4l-2 3"})]}),z),kU=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 8l0 4l2 2"}),u("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),z),q0=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M5 10a7 7 0 0 0 14 0"}),u("path",{d:"M8 21l8 0"}),u("path",{d:"M12 17l0 4"})]}),z),J0=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 3l18 18"}),u("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"}),u("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),u("path",{d:"M8 21l8 0"}),u("path",{d:"M12 17l0 4"})]}),z),La=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),z),Q0=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M12 20v.01"}),u("path",{d:"M16 20v.01"}),u("path",{d:"M8 20v.01"}),u("path",{d:"M4 20v.01"}),u("path",{d:"M4 16v.01"}),u("path",{d:"M4 12v.01"}),u("path",{d:"M4 8v.01"}),u("path",{d:"M4 4v.01"}),u("path",{d:"M8 4v.01"}),u("path",{d:"M12 4v.01"}),u("path",{d:"M16 4v.01"}),u("path",{d:"M20 4v.01"}),u("path",{d:"M20 8v.01"}),u("path",{d:"M20 12v.01"}),u("path",{d:"M20 16v.01"}),u("path",{d:"M20 20v.01"})]}),z),eb=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 3v18"}),u("path",{d:"M19 21v-18"}),u("path",{d:"M5 7h14"}),u("path",{d:"M5 15h14"}),u("path",{d:"M8 13v4"}),u("path",{d:"M11 13v4"}),u("path",{d:"M16 13v4"}),u("path",{d:"M14 5v4"}),u("path",{d:"M11 5v4"}),u("path",{d:"M8 5v4"}),u("path",{d:"M3 21h18"})]}),z),tb=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 12l18 0"}),u("path",{d:"M7 16l10 0l-10 5l0 -5"}),u("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),z),ob=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 3l0 18"}),u("path",{d:"M16 7l0 10l5 0l-5 -10"}),u("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),z),Qm=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),u("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),z),_s=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),u("path",{d:"M22 22l-3 -3"}),u("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),u("path",{d:"M3 11v-1"}),u("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),u("path",{d:"M10 3h1"}),u("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),z),nb=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),u("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),u("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"}),u("path",{d:"M10 15l2 6l2 -6"}),u("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),z),rb=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),u("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),u("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),u("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),u("path",{d:"M11 21v-6l3 6v-6"})]}),z),ib=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M4 8l5 0"}),u("path",{d:"M15 8l4 0"})]}),z),ab=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),u("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),u("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),u("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),z),lb=M(R("g",{stroke:"currentColor",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...z,strokeWidth:1.5}),MU=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M21 12h-13l3 -3"}),u("path",{d:"M11 15l-3 -3"})]}),z),PU=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M10 9l5 3l-5 3z"})]}),z),sb=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 6h18"}),u("path",{d:"M3 12h18"}),u("path",{d:"M3 18h18"}),u("path",{d:"M6 3v18"}),u("path",{d:"M12 3v18"}),u("path",{d:"M18 3v18"})]}),z),cb=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("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"}),u("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),z),oi=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 18l12 -12"}),u("path",{d:"M18 10v-4h-4"})]}),z),ni=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),u("path",{d:"M18 4l3 3l-3 3"})]}),z),ri=M(R("g",{children:[u("path",{d:"M16,12L20,9L16,6"}),u("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),z),Ds=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 9l6 6l6 -6"})]}),z),db=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 15l6 -6l6 6"})]}),z),mb=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 15l6 -6l6 6"})]}),z),ep=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),u("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),z),Rs=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M5 7l0 10"}),u("path",{d:"M7 5l10 0"}),u("path",{d:"M7 19l10 0"}),u("path",{d:"M19 7l0 10"})]}),z),tp=M(R("g",{strokeWidth:"1.25",children:[u("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),u("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),u("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),u("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),u("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),u("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),u("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),u("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),u("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),z),op=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),u("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),u("polyline",{points:"2 8 3 6 4 8"}),u("polyline",{points:"2 12 3 14 4 12"}),u("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),u("polyline",{points:"9 17 7 18 9 19"}),u("polyline",{points:"15 17 17 18 15 19"})]}),z),LU=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),z),np=M(u("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:u("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"})})),pb=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M4 6l8 0"}),u("path",{d:"M16 6l4 0"}),u("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M4 12l2 0"}),u("path",{d:"M10 12l10 0"}),u("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M4 18l11 0"}),u("path",{d:"M19 18l1 0"})]}),z),ub=M(R("g",{strokeWidth:1,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),z),gS=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),u("path",{d:"M13.5 6.5l4 4"})]}),z),AU=M(R("g",{strokeWidth:1,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M11 7l-5 5l5 5"}),u("path",{d:"M17 7l-5 5l5 5"})]}),z),hb=M(R("g",{strokeWidth:"1.75",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M15 4l0 16"})]}),z),_U=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),z),DU=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 4l18 0"}),u("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),u("path",{d:"M12 16l0 4"}),u("path",{d:"M9 20l6 0"}),u("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),z);import gb from"clsx";import ip,{useEffect as ES,useRef as fb,useState as xS}from"react";import{isPromiseLike as yS}from"@excalidraw/common";import fS from"react";import{jsx as rp}from"react/jsx-runtime";var bS=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(fS.useRef(Date.now()).current%1600);return rp("div",{className:`Spinner ${n}`,children:rp("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:rp("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},Dt=bS;import{jsx as Aa,jsxs as _a}from"react/jsx-runtime";var V=ip.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=ke(),a=ip.useRef(null);ip.useImperativeHandle(r,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=xS(!1),m=fb(!0),p=async h=>{let f="onClick"in n&&n.onClick?.(h);if(yS(f))try{c(!0),await f}catch(b){if(b instanceof Or)console.warn(b);else throw b}finally{m.current&&c(!1)}};ES(()=>(m.current=!0,()=>{m.current=!1}),[]);let d=fb(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let h=n.type==="icon"?"button":n.type;return _a("button",{className:gb("ToolIcon_type_button",l,t,o&&!n.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!n.hidden,"ToolIcon--selected":n.selected,"ToolIcon--plain":n.type==="icon"}),style:n.style,"data-testid":n["data-testid"],hidden:n.hidden,title:n.title,"aria-label":n["aria-label"],type:h,onClick:p,ref:a,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&_a("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&Aa("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&Aa(Dt,{})]}),n.showAriaLabel&&_a("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&Aa(Dt,{})]}),n.children]})}return _a("label",{className:gb("ToolIcon",t),title:n.title,onPointerDown:h=>{d.current=h.pointerType||null,n.onPointerDown?.({pointerType:h.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{d.current=null})},children:[Aa("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:n.name,"aria-label":n["aria-label"],"aria-keyshortcuts":n["aria-keyshortcuts"],"data-testid":n["data-testid"],id:`${i}-${n.id}`,onChange:()=>{n.onChange?.({pointerType:d.current})},checked:n.checked,ref:a}),_a("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&Aa("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});V.displayName="ToolButton";var Ns=[],F=e=>(Ns=Ns.concat(e),e);import{jsx as PS}from"react/jsx-runtime";var MS=(e,o,t)=>{let n=new Set(q(e.filter(m=>SS(m)),o).map(m=>m.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of n){let p=CS(e,m);for(let d of p)if(!a.has(d.id)){if(Bs(d)){let h=Eb(d,i);h&&(r[h.id]=!0)}else r[d.id]=!0;a.add(d.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let p=Bs(m)?Eb(m,i):null;return m.frameId&&n.has(m.frameId)?(l=!1,r[m.id]=!0,m):p?.frameId&&n.has(p?.frameId)?m:(m.boundElements&&m.boundElements.forEach(d=>{let h=t.scene.getNonDeletedElementsMap().get(d.id);h&&TS(h)&&t.scene.mutateElement(h,{startBinding:m.id===h.startBinding?.elementId?null:h.startBinding,endBinding:m.id===h.endBinding?.elementId?null:h.endBinding})}),Os(m,{isDeleted:!0}))}return m.frameId&&n.has(m.frameId)?(l=!1,Bs(m)||(r[m.id]=!0),Os(m,{frameId:null})):Bs(m)&&o.selectedElementIds[m.containerId]?Os(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=sp(s,o.editingGroupId).filter(p=>!p.isDeleted);if(m.length>1)m[0]&&(r[m[0].id]=!0);else{c=null,m[0]&&(r[m[0].id]=!0);let p=m[0];if(p){let d=p.groupIds.findIndex(f=>f===o.editingGroupId),h=p.groupIds[d+1];if(h){let f=sp(s,h).filter(b=>!b.isDeleted);f.length>1&&(c=h,f.forEach(b=>{r[b.id]=!0}))}}}}return{elements:s,appState:{...o,...kS({selectedElementIds:r,editingGroupId:c},s,o,null)}}},xb=(e,o)=>{if(e.editingGroupId){let t=sp(lp(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Da=F({name:"deleteSelectedElements",label:"labels.delete",icon:Zo,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l}=o.selectedLinearElement,s=n.scene.getNonDeletedElementsMap(),c=bb.getElement(a,s);if(!c||l==null)return!1;if(l.length>=c.points.length){let m=e.map(d=>d.id===c.id?Os(d,{isDeleted:!0}):d),p=xb(o,m);return{elements:m,appState:{...p,selectedLinearElement:null},captureUpdate:Fs.IMMEDIATELY}}return bb.deletePoints(c,n,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:Fs.IMMEDIATELY}}let{elements:r,appState:i}=MS(e,o,n);return IS(r,r.filter(a=>a.isDeleted)),i=xb(i,r),{elements:r,appState:{...i,activeTool:vS(o,{type:n.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:ve(lp(e),o)?Fs.IMMEDIATELY:Fs.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===ap.BACKSPACE||e.key===ap.DELETE)&&!e[ap.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=je()==="mobile";return PS(V,{type:"button",icon:Zo,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),disabled:!ve(lp(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?wS:{}}})}});import{KEYS as ii,CODES as ai,isDarwin as zs}from"@excalidraw/common";import{moveOneLeft as LS,moveOneRight as AS,moveAllLeft as _S,moveAllRight as DS}from"@excalidraw/element";import{CaptureUpdateAction as Hs}from"@excalidraw/element";import{isDarwin as yb}from"@excalidraw/common";var A=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,yb?g("keys.option"):g("keys.alt")).replace(/\bShift\b/i,g("keys.shift")).replace(/\b(Enter|Return)\b/i,g("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,yb?g("keys.cmd"):g("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,g("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,g("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,g("keys.delete"));import{jsx as Gs}from"react/jsx-runtime";var cp=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Hm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:LS(e,o,n.scene),appState:o,captureUpdate:Hs.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ii.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ai.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Gs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${A("CtrlOrCmd+[")}`,children:Hm})}),dp=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:zm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:AS(e,o,n.scene),appState:o,captureUpdate:Hs.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ii.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ai.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Gs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${A("CtrlOrCmd+]")}`,children:zm})}),mp=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Um,trackEvent:{category:"element"},perform:(e,o)=>({elements:_S(e,o),appState:o,captureUpdate:Hs.IMMEDIATELY}),keyTest:e=>zs?e[ii.CTRL_OR_CMD]&&e.altKey&&e.code===ai.BRACKET_LEFT:e[ii.CTRL_OR_CMD]&&e.shiftKey&&e.code===ai.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Gs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${zs?A("CtrlOrCmd+Alt+["):A("CtrlOrCmd+Shift+[")}`,children:Um})}),pp=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Gm,trackEvent:{category:"element"},perform:(e,o)=>({elements:DS(e,o),appState:o,captureUpdate:Hs.IMMEDIATELY}),keyTest:e=>zs?e[ii.CTRL_OR_CMD]&&e.altKey&&e.code===ai.BRACKET_RIGHT:e[ii.CTRL_OR_CMD]&&e.shiftKey&&e.code===ai.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Gs("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${zs?A("CtrlOrCmd+Alt+]"):A("CtrlOrCmd+Shift+]")}`,children:Gm})});import{getNonDeletedElements as RS}from"@excalidraw/element";import{LinearElementEditor as NS}from"@excalidraw/element";import{isLinearElement as BS,isTextElement as FS}from"@excalidraw/element";import{arrayToMap as OS,KEYS as wb}from"@excalidraw/common";import{selectGroupsForSelectedElements as zS}from"@excalidraw/element";import{CaptureUpdateAction as HS}from"@excalidraw/element";var up=F({name:"selectAll",label:"labels.selectAll",icon:Q0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(FS(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...zS({editingGroupId:null,selectedElementIds:r},RS(e),o,n),selectedLinearElement:Object.keys(r).length===1&&BS(e[0])?new NS(e[0],OS(e)):null},captureUpdate:HS.IMMEDIATELY}},keyTest:e=>e[wb.CTRL_OR_CMD]&&e.key===wb.A});import{DEFAULT_GRID_SIZE as vb,KEYS as Ib,MOBILE_ACTION_BUTTON_BG as GS,arrayToMap as Tb}from"@excalidraw/common";import{getNonDeletedElements as Sb}from"@excalidraw/element";import{LinearElementEditor as US}from"@excalidraw/element";import{getSelectedElements as WS,getSelectionStateForElements as YS}from"@excalidraw/element";import{syncMovedIndices as VS}from"@excalidraw/element";import{duplicateElements as XS}from"@excalidraw/element";import{CaptureUpdateAction as Cb}from"@excalidraw/element";import{jsx as KS}from"react/jsx-runtime";var hp=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Sa,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=US.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:a,captureUpdate:Cb.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=XS({type:"in-place",elements:e,idsOfElementsToDuplicate:Tb(WS(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+vb/2,y:a.y+vb/2,frameId:s??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:VS(i,Tb(r)),appState:{...o,...YS(r,Sb(i),o)},captureUpdate:Cb.IMMEDIATELY}},keyTest:e=>e[Ib.CTRL_OR_CMD]&&e.key===Ib.D,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=je()==="mobile";return KS(V,{type:"button",icon:Sa,title:`${g("labels.duplicateSelection")} \u2014 ${A("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),disabled:!ve(Sb(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?GS:{}}})}});import{pointFrom as $4}from"@excalidraw/math";import{useEffect as Bp,useMemo as j4,useRef as Fp,useState as q4}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as J4,DEFAULT_ELEMENT_BACKGROUND_PICKS as Q4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as e6,DEFAULT_ELEMENT_STROKE_PICKS as t6,ARROW_TYPE as Xt,DEFAULT_FONT_FAMILY as o6,DEFAULT_FONT_SIZE as n6,FONT_FAMILY as r6,ROUNDNESS as ac,STROKE_WIDTH as Op,VERTICAL_ALIGN as rc,KEYS as Ei,randomInteger as i6,arrayToMap as Hp,getFontFamilyString as a6,getLineHeight as l6,isTransparent as s6,reduceToCommonValue as c6,invariant as Gp,FONT_SIZES as ic}from"@excalidraw/common";import{canBecomePolygon as d6,getNonDeletedElements as gE}from"@excalidraw/element";import{bindBindingElement as mE,calculateFixedPointForElbowArrowBinding as pE,updateBoundElements as m6}from"@excalidraw/element";import{LinearElementEditor as ir}from"@excalidraw/element";import{newElementWith as Xe}from"@excalidraw/element";import{getBoundTextElement as Tn,redrawTextBoundingBox as Va}from"@excalidraw/element";import{isArrowElement as lc,isBoundToContainer as p6,isElbowArrow as fE,isLinearElement as zp,isLineElement as uE,isTextElement as It,isUsingAdaptiveRadius as u6}from"@excalidraw/element";import{hasStrokeColor as h6}from"@excalidraw/element";import{updateElbowArrowPoints as g6,CaptureUpdateAction as Ke,toggleLinePolygonState as f6}from"@excalidraw/element";import{deriveStylesPanelMode as b6}from"@excalidraw/common";import{isDevEnv as ZS}from"@excalidraw/common";var $S=new Set(["command_palette","export"]),le=(e,o,t,n)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!$S.has(e)||ZS())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:n}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:n})}catch(r){console.error("error during analytics",r)}};import QS from"clsx";import jS from"clsx";import{forwardRef as qS}from"react";import{jsx as JS}from"react/jsx-runtime";var li=qS((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:a,icon:l,onClick:s}=e;return JS("button",{type:"button",ref:o,title:t,"data-testid":r,className:jS(n,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as tC,jsx as gp,jsxs as eC}from"react/jsx-runtime";var Wt=e=>gp(tC,{children:e.options.map(o=>e.type==="button"?gp(li,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):eC("label",{className:QS({active:e.value===o.value}),title:o.text,children:[gp("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as js from"@radix-ui/react-popover";import Xb from"clsx";import{useRef as Kb,useEffect as n4}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as Yb,COLOR_PALETTE as Zb,isColorDark as Vb,isWritableElement as r4}from"@excalidraw/common";import{jsx as oC}from"react/jsx-runtime";var Us=()=>oC("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as lC,useRef as sC}from"react";import{createPortal as cC}from"react-dom";import{EVENT as En,KEYS as dC,rgbToHex as mC}from"@excalidraw/common";import kb from"react";var fp=kb.createContext(null),Te=()=>kb.useContext(fp);import{useState as nC,useLayoutEffect as Mb}from"react";import{THEME as rC}from"@excalidraw/common";var Ws=e=>{let[o,t]=nC(null),n=de(),{theme:r}=Te(),{container:i}=ke();return Mb(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",n.formFactor==="phone"),o.classList.toggle("theme--dark",r===rC.DARK))},[o,r,n.formFactor,e?.className]),Mb(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as iC}from"react";import{EVENT as Ys}from"@excalidraw/common";function si(e,o,t){iC(()=>{function n(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(Ys.POINTER_DOWN,n),document.addEventListener(Ys.TOUCH_START,n),()=>{document.removeEventListener(Ys.POINTER_DOWN,n),document.removeEventListener(Ys.TOUCH_START,n)}},[e,o,t])}import{useRef as aC}from"react";var bn=e=>{let o=aC(e);return Object.assign(o.current,e),o.current};import{jsx as pC}from"react/jsx-runtime";var xn=Se(null),Pb=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=Ws({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Te(),a=yn(),l=qe(),s=q(a,i),c=bn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=ke();lC(()=>{let d=p.current;if(!d||!l.canvas||!r)return;let h=!1,f=l.canvas.getContext("2d"),b=({clientX:C,clientY:P})=>{let k=f.getImageData((C-i.offsetLeft)*window.devicePixelRatio,(P-i.offsetTop)*window.devicePixelRatio,1,1).data;return mC(k[0],k[1],k[2])},E=({clientX:C,clientY:P,altKey:k})=>{d.style.top=`${P+20}px`,d.style.left=`${C+20}px`;let N=b({clientX:C,clientY:P});h&&c.onChange(n,N,c.selectedElements,{altKey:k}),d.style.background=N},w=()=>{c.onCancel()},y=(C,P)=>{c.onSelect(C,P)},x=C=>{h=!0,C.stopImmediatePropagation()},v=C=>{h=!1,m?.focus(),C.stopImmediatePropagation(),C.preventDefault(),y(b(C),C)},I=C=>{C.key===dC.ESCAPE&&(C.preventDefault(),C.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),E({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(En.KEYDOWN,I),r.addEventListener(En.POINTER_DOWN,x),r.addEventListener(En.POINTER_UP,v),window.addEventListener("pointermove",E,{passive:!0}),window.addEventListener(En.BLUR,w),()=>{h=!1,r.removeEventListener(En.KEYDOWN,I),r.removeEventListener(En.POINTER_DOWN,x),r.removeEventListener(En.POINTER_UP,v),window.removeEventListener("pointermove",E),window.removeEventListener(En.BLUR,w)}},[c,l.canvas,r,n,m,i.offsetLeft,i.offsetTop]);let p=sC(null);return si(p,()=>{e()},d=>!!d.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?cC(pC("div",{ref:p,className:"excalidraw-eye-dropper-preview"}),r):null};import*as ci from"@radix-ui/react-popover";import fC from"clsx";import bC from"react";import{isInteractive as EC}from"@excalidraw/common";import uC from"react";import hC from"clsx";import{jsx as gC}from"react/jsx-runtime";var ze=uC.forwardRef(({children:e,padding:o,className:t,style:n},r)=>gC("div",{className:hC("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as bp,jsxs as xC}from"react/jsx-runtime";var $o=bC.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:c=!1},m)=>{let p=de(),d=p.formFactor==="phone"&&!p.isLandscape;return bp(ci.Portal,{container:o,children:xC(ci.Content,{ref:m,className:fC("focus-visible-none",e),"data-prevent-outside-click":!0,side:d?"bottom":"right",align:d?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:o??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:p.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onOpenAutoFocus:h=>{c&&p.isTouchScreen&&h.preventDefault()},onCloseAutoFocus:h=>{h.stopPropagation(),h.preventDefault(),o&&!EC(document.activeElement)&&o.focus(),r()},children:[bp(ze,{padding:3,style:n,children:t}),bp(ci.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 yC,useCallback as Ep}from"react";var Vs=()=>document.querySelector(".excalidraw-wysiwyg"),Xs=()=>{let e=Vs();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Ra=e=>{setTimeout(()=>{let o=Vs();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},Na=(e,o,t,n)=>{o&&n&&n();let r=o&&t?Xs():null;e(),o&&t&&Ra(r)},Lb=()=>{let[e,o]=yC(null),t=Ep(()=>{let i=Xs();o(i)},[]),n=Ep(()=>{setTimeout(()=>{let i=Vs();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),r=Ep(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},Ab=(e=100)=>{let o=Vs();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import vC from"clsx";import{useCallback as IC,useEffect as yp,useRef as Db,useState as TC}from"react";import{KEYS as wp,normalizeInputColor as SC}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as wC}from"@excalidraw/common";var wn=({palette:e,color:o})=>{if(!o)return null;for(let[t,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(o);if(r>-1)return{colorName:t,shade:r}}else if(n===o)return{colorName:t,shade:null};return null},Ba=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),xp=({color:e,palette:o})=>!Object.values(o).flat().includes(e),_b=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[n[o]];return xp({color:l,palette:t})}),i=new Map;return r.forEach(a=>{let l=a[n[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,wC)},Yt=Se(null);import{Fragment as CC,jsx as Ks,jsxs as Rb}from"react/jsx-runtime";var Nb=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=de(),[a,l]=TC(e),[s,c]=ue(Yt);yp(()=>{l(e)},[e]);let m=IC(b=>{let E=b.toLowerCase(),w=SC(E);w&&o(w),l(E)},[o]),p=Db(null),d=Db(null);yp(()=>{p.current&&p.current.focus()},[s]);let[h,f]=ue(xn);return yp(()=>()=>{f(null)},[f]),Rb("div",{className:"color-picker__input-label",children:[Ks("div",{className:"color-picker__input-hash",children:"#"}),Ks("input",{ref:s==="hex"?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{m(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:b=>{b.key!==wp.TAB&&(b.key===wp.ESCAPE&&d.current?.focus(),b.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&Rb(CC,{children:[Ks("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Ks("div",{ref:d,className:vC("excalidraw-eye-dropper-trigger",{selected:h}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:E=>o(E),colorPickerType:n}),title:`${g("labels.eyeDropper")} \u2014 ${wp.I.toLocaleUpperCase()} or ${A("Alt")} `,children:X0})]})]})};import Sp,{useEffect as Cp,useImperativeHandle as XC,useState as KC}from"react";import{EVENT as Gb}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as ZC,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as $C,KEYS as jC}from"@excalidraw/common";import LC from"clsx";import{useEffect as AC,useRef as _C}from"react";import{isColorDark as kC}from"@excalidraw/common";import{jsxs as PC}from"react/jsx-runtime";var MC=({color:e,keyLabel:o,isShade:t=!1})=>PC("div",{className:"color-picker__button__hotkey-label",style:{color:kC(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),di=MC;import{jsx as vp,jsxs as DC}from"react/jsx-runtime";var Bb=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=ue(Yt),a=_C(null);return AC(()=>{a.current&&a.current.focus()},[o,r]),vp("div",{className:"color-picker-content--default",children:e.map((l,s)=>DC("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:LC("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":n,style:{"--swatch-color":l},children:[vp("div",{className:"color-picker__button-outline"}),vp(di,{color:l,keyLabel:s+1})]},s))})};import RC from"clsx";import{useEffect as NC,useRef as BC}from"react";import{jsx as Ip,jsxs as OC}from"react/jsx-runtime";var FC=({palette:e,color:o,onChange:t,activeShade:n,showHotKey:r=!0})=>{let i=wn({color:o,palette:e}),[a,l]=ue(Yt),s=BC(null);return NC(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),Ip("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],p)=>{let d=(Array.isArray(m)?m[n]:m)||"transparent",h=Ba[p],f=g(`colors.${c.replace(/\d+/,"")}`,null,"");return OC("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:RC("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),l("baseColors")},title:`${f}${d.startsWith("#")?` ${d}`:""} \u2014 ${h}`,"aria-label":`${f} \u2014 ${h}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${c}`,children:[Ip("div",{className:"color-picker__button-outline"}),r&&Ip(di,{color:d,keyLabel:h})]},c)})})},Fb=FC;import{jsx as HC}from"react/jsx-runtime";var zC=({children:e})=>HC("div",{className:"color-picker__heading",children:e}),mi=zC;import GC from"clsx";import{useEffect as UC,useRef as WC}from"react";import{jsx as Fa,jsxs as Ob}from"react/jsx-runtime";var zb=({color:e,onChange:o,palette:t,showHotKey:n})=>{let r=wn({color:e||"transparent",palette:t}),[i,a]=ue(Yt),l=WC(null);if(UC(()=>{l.current&&i==="shades"&&l.current.focus()},[r,i]),r){let{colorName:s,shade:c}=r,m=t[s];if(Array.isArray(m))return Fa("div",{className:"color-picker-content--default shades",children:m.map((p,d)=>Ob("button",{ref:d===c&&i==="shades"?l:void 0,tabIndex:-1,type:"button",className:GC("color-picker__button color-picker__button--large has-outline",{active:d===c}),"aria-label":"Shade",title:`${s} - ${d+1}`,style:p?{"--swatch-color":p}:void 0,onClick:()=>{o(p),a("shades")},children:[Fa("div",{className:"color-picker__button-outline"}),n&&Fa(di,{color:p,keyLabel:d+1,isShade:!0})]},d))})}return Ob("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Fa("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Fa("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:g("colorPicker.noShades")})]})};import{COLORS_PER_ROW as pi,COLOR_PALETTE as YC,KEYS as Oa}from"@excalidraw/common";var Tp=(e,o,t)=>{let n=Math.ceil(t/pi);switch(o=o??-1,e){case"ArrowLeft":{let r=o-1;return r<0?t-1:r}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let r=o+pi;return r>=t?o%pi:r}case"ArrowUp":{let r=o-pi,i=r<0?pi*n+r:r;return i>=t?void 0:i}}},VC=({e,colorObj:o,onChange:t,palette:n,customColors:r,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(n[o.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(Ba.includes(e.key)){let l=Ba.indexOf(e.key),s=Object.keys(n)[l],c=n[s],m=Array.isArray(c)?c[a]:c;return t(m),i("baseColors"),!0}return!1},Hb=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[Oa.CTRL_OR_CMD])return!1;if(e.key===Oa.ESCAPE)return m(e),!0;if(e.key===Oa.ALT)return c(!0),!0;if(e.key===Oa.I)return c(),!0;let p=wn({color:n,palette:t});if(e.key===Oa.TAB){let d={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},h=Object.entries(d).reduce((y,[x,v])=>(v&&y.push(x),y),[]),f=h.indexOf(o),b=e.shiftKey?-1:1,E=f+b>h.length-1?0:f+b<0?h.length-1:f+b,w=h[E];return w&&a(w),w==="custom"?r(i[0]):w==="baseColors"&&(Object.entries(t).find(([x,v])=>Array.isArray(v)?v.includes(n):v===n?x:null)||r(YC.black)),e.preventDefault(),e.stopPropagation(),!0}if(VC({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&p){let{shade:d}=p,h=Tp(e.key,d,pi);if(h!==void 0)return r(t[p.colorName][h]),!0}if(o==="baseColors"&&p){let{colorName:d}=p,h=Object.keys(t),f=h.indexOf(d),b=Tp(e.key,f,h.length);if(b!==void 0){let E=h[b],w=t[E];return r(Array.isArray(w)?w[s]:w),!0}}if(o==="custom"){let d=n!=null?i.indexOf(n):0,h=Tp(e.key,d,i.length);if(h!==void 0){let f=i[h];return r(f),!0}}return!1};import{jsx as vn,jsxs as Zs}from"react/jsx-runtime";var Ub=Sp.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:a,showTitle:l,onEyeDropperToggle:s,onEscape:c,showHotKey:m=!0},p)=>{let d=l?t==="elementStroke"?g("labels.stroke"):t==="elementBackground"?g("labels.background"):null:null,[h]=Sp.useState(()=>t==="canvasBackground"?[]:_b(n,t,r)),[f,b]=ue(Yt),E=wn({color:e,palette:r});Cp(()=>{if(!f){let v=!!e&&xp({color:e,palette:r}),I=v&&!h.includes(e);b(I?null:v?"custom":E?.shade!=null?"shades":"baseColors")}},[f,e,r,b,E,h]);let[w,y]=KC(E?.shade??(t==="elementBackground"?ZC:$C));Cp(()=>{E?.shade!=null&&y(E.shade);let v=I=>{I.key===jC.ALT&&s(!1)};return document.addEventListener(Gb.KEYUP,v,{capture:!0}),()=>{document.removeEventListener(Gb.KEYUP,v,{capture:!0})}},[E,s]);let x=Sp.useRef(null);return XC(p,()=>x.current),Cp(()=>{x?.current?.focus()},[]),vn("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:Zs("div",{ref:x,onKeyDown:v=>{Hb({event:v,activeColorPickerSection:f,palette:r,color:e,onChange:o,onEyeDropperToggle:s,customColors:h,setActiveColorPickerSection:b,updateData:i,activeShade:w,onEscape:c})&&(v.preventDefault(),v.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[d&&vn("div",{className:"color-picker__title",children:d}),!!h.length&&Zs("div",{children:[vn(mi,{children:g("colorPicker.mostUsedCustomColors")}),vn(Bb,{colors:h,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),Zs("div",{children:[vn(mi,{children:g("colorPicker.colors")}),vn(Fb,{color:e,palette:r,onChange:o,activeShade:w,showHotKey:m})]}),Zs("div",{children:[vn(mi,{children:g("colorPicker.shades")}),vn(zb,{color:e,onChange:o,palette:r,showHotKey:m})]}),a]})})});import qC from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as JC,DEFAULT_CANVAS_BACKGROUND_PICKS as QC,DEFAULT_ELEMENT_BACKGROUND_PICKS as e4,DEFAULT_ELEMENT_STROKE_PICKS as t4,isColorDark as o4}from"@excalidraw/common";import{jsx as kp}from"react/jsx-runtime";var Wb=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=t4),o==="elementBackground"&&(r=e4),o==="canvasBackground"&&(r=QC),n&&(r=n),r?kp("div",{className:"color-picker__top-picks",children:r.map(i=>kp("button",{className:qC("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!o4(i,JC)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:kp("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Vt,jsxs as $s}from"react/jsx-runtime";var i4=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=Zb,updateData:a,getOpenPopup:l,appState:s})=>{let{container:c}=ke(),m=je(),p=m!=="full",d=m==="mobile",[,h]=ue(Yt),[f,b]=ue(xn),E=$s("div",{children:[Vt(mi,{children:g("colorPicker.hexCode")}),Vt(Nb,{color:o||"",label:n,onChange:x=>{t(x)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),w=Kb(null),y=()=>{w.current?.focus()};return Vt($o,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:x=>{r4(x.target)||y(),x.preventDefault()},onPointerDownOutside:x=>{f&&x.preventDefault()},onClose:()=>{l()===e&&a({openPopup:null}),h(null),s.editingTextElement&&setTimeout(()=>{let x=document.querySelector(".excalidraw-wysiwyg");x&&x.focus()},0)},children:i?Vt(Ub,{ref:w,palette:i,color:o,onChange:x=>{let v=s.editingTextElement?Xs():null;t(x),s.editingTextElement&&v&&Ra(v)},onEyeDropperToggle:x=>{b(v=>x?(v=v||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},v.keepOpenOnAlt=!0,v):x===!1||v?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:x=>{f?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!d,children:E}):E})},a4=({label:e,color:o,type:t,mode:n="background",onToggle:r,editingTextElement:i})=>{let a=je(),l=a!=="full",s=a==="mobile",c=m=>{m.preventDefault(),m.stopPropagation(),i&&Ab(),r()};return $s(js.Trigger,{type:"button",className:Xb("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!Vb(o,Yb),"compact-sizing":l,"mobile-border":s}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),"data-openpopup":t,onClick:c,children:[Vt("div",{className:"color-picker__button-outline",children:!o&&j1}),l&&o&&n==="stroke"&&Vt("div",{className:"color-picker__button-background",children:Vt("span",{style:{color:o&&Vb(o,Yb)?"#fff":"#111"},children:ub})})]})},za=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=Zb,topPicks:a,updateData:l,appState:s})=>{let c=Kb(s.openPopup);n4(()=>{c.current=s.openPopup},[s.openPopup]);let p=je()!=="full";return Vt("div",{children:$s("div",{role:"dialog","aria-modal":"true",className:Xb("color-picker-container",{"color-picker-container--no-top-picks":p}),children:[!p&&Vt(Wb,{activeColor:o,onChange:t,type:e,topPicks:a}),!p&&Vt(Us,{}),$s(js.Root,{open:s.openPopup===e,onOpenChange:d=>{d&&l({openPopup:e})},children:[Vt(a4,{color:o,label:n,type:e,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?l({openPopup:null}):s.openPopup?l({openPopup:e}):l({openPopup:e})}}),s.openPopup===e&&Vt(i4,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:l,getOpenPopup:()=>c.current,appState:s})]})]})})};import*as nE from"@radix-ui/react-popover";import B4 from"clsx";import F4,{useCallback as O4,useMemo as z4}from"react";import{FONT_FAMILY as _p}from"@excalidraw/common";import C4,{useMemo as In,useState as k4,useRef as M4,useEffect as P4,useCallback as Jb}from"react";import{arrayToList as L4,debounce as A4,FONT_FAMILY as nr,getFontFamilyString as _4}from"@excalidraw/common";import l4 from"clsx";import s4 from"react";import{jsx as c4,jsxs as d4}from"react/jsx-runtime";var qs=s4.forwardRef(({className:e,placeholder:o,onChange:t},n)=>d4("div",{className:l4("QuickSearch__wrapper",e),children:[_t,c4("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import m4 from"clsx";import{Children as p4}from"react";import{jsx as $b}from"react/jsx-runtime";var Js=({className:e,placeholder:o,children:t})=>{let n=!p4.count(t);return $b("div",{className:m4("ScrollableList__wrapper",e),role:"menu",children:n?$b("div",{className:"empty",children:o}):t})};import{jsx as u4,jsxs as h4}from"react/jsx-runtime";var jb=({children:e,className:o="",style:t,title:n})=>h4("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&u4("p",{className:"dropdown-menu-group-title",children:n}),e]}),Ha=jb;jb.displayName="DropdownMenuGroup";import{useEffect as I4,useRef as T4}from"react";import{THEME as S4}from"@excalidraw/common";import{jsx as g4}from"react/jsx-runtime";var Ga=({children:e,...o})=>g4("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as b4,jsx as Ua,jsxs as E4}from"react/jsx-runtime";var f4=({textStyle:e,icon:o,shortcut:t,children:n,badge:r})=>{let i=de();return E4(b4,{children:[o&&Ua("div",{className:"dropdown-menu-item__icon",children:o}),Ua("div",{style:e,className:"dropdown-menu-item__text",children:Ua(Ga,{children:n})}),r&&Ua("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Ua("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Qs=f4;import x4,{useContext as y4}from"react";import{EVENT as w4,composeEventHandlers as v4}from"@excalidraw/common";var Mp=x4.createContext({}),ec=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
|
|
2
|
-
${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),tc=(e,o)=>{let t=y4(Mp);return v4(e,n=>{let r=new CustomEvent(w4.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(r),r.defaultPrevented||t.onSelect?.(r)})};import{jsx as Pp}from"react/jsx-runtime";var Lp=({icon:e,value:o,order:t,children:n,shortcut:r,className:i,hovered:a,selected:l,textStyle:s,onSelect:c,onClick:m,badge:p,...d})=>{let h=tc(m,c),f=T4(null);return I4(()=>{a&&(t===0?f.current?.scrollIntoView({block:"end"}):f.current?.scrollIntoView({block:"nearest"}))},[a,t]),Pp("button",{...d,ref:f,value:o,onClick:h,className:ec(i,l,a),title:d.title??d["aria-label"],children:Pp(Qs,{textStyle:s,icon:e,shortcut:r,badge:p,children:n})})};Lp.displayName="DropdownMenuItem";var ui={GREEN:"green",RED:"red",BLUE:"blue"},oc=({type:e=ui.BLUE,children:o})=>{let{theme:t}=So(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===S4.LIGHT?"1.5px solid white":"none"};switch(e){case ui.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ui.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case ui.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Pp("div",{className:"DropDownMenuItemBadge",style:n,children:o})};oc.displayName="DropdownMenuItemBadge";Lp.Badge=oc;var vt=Lp;import{KEYS as hi}from"@excalidraw/common";var qb=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[hi.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===hi.F)return o.current?.focus(),!0;if(e.key===hi.ESCAPE)return r(),!0;if(e.key===hi.ENTER)return t?.value&&i(t.value),!0;if(e.key===hi.ARROW_DOWN)return t?.next?a(t.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===hi.ARROW_UP)return t?.prev?a(t.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as gi,jsxs as R4}from"react/jsx-runtime";var D4=e=>{switch(e){case nr.Excalifont:case nr.Virgil:return Io;case nr.Nunito:case nr.Helvetica:return Pa;case nr["Lilita One"]:return R0;case nr["Comic Shanns"]:case nr.Cascadia:return Ps;default:return Pa}},Qb=C4.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=ke(),s=qe(),{fonts:c}=s,{showDeprecatedFonts:m}=Co(),p=je(),[d,h]=k4(""),f=M4(null),b=In(()=>Array.from(un.registered.entries()).filter(([L,{metadata:B}])=>!B.private&&!B.fallback).map(([L,{metadata:B,fontFaces:G}])=>{let j={value:L,icon:D4(L),text:G[0]?.fontFace?.family??"Unknown"};return B.deprecated&&Object.assign(j,{deprecated:B.deprecated,badge:{type:ui.RED,placeholder:g("fontList.badge.old")}}),j}).sort((L,B)=>L.text.toLowerCase()>B.text.toLowerCase()?1:-1),[]),E=In(()=>new Set(c.getSceneFamilies()),[e]),w=In(()=>b.filter(L=>E.has(L.value)),[b,E]),y=In(()=>b.filter(L=>!E.has(L.value)&&(m||!L.deprecated)),[b,E,m]),x=In(()=>L4([...w,...y].filter(L=>L.text?.toLowerCase().includes(d))),[w,y,d]),v=In(()=>{let L;return o?L=x.find(B=>B.value===o):e&&(L=x.find(B=>B.value===e)),!L&&d&&(x[0]?.value?n(x[0].value):r()),L},[o,e,d,x,n,r]),I=Jb(L=>{let B=null;if(s.state.editingTextElement){let G=document.querySelector(".excalidraw-wysiwyg");G&&(B={start:G.selectionStart,end:G.selectionEnd})}t(L),s.state.editingTextElement&&B&&setTimeout(()=>{let G=document.querySelector(".excalidraw-wysiwyg");G&&B&&(G.focus(),G.selectionStart=B.start,G.selectionEnd=B.end)},0)},[t,s.state.editingTextElement]),C=Jb(L=>{qb({event:L,inputRef:f,hoveredFont:v,filteredFonts:x,onSelect:I,onHover:n,onClose:a})&&(L.preventDefault(),L.stopPropagation())},[v,x,I,n,a]);P4(()=>(i(),()=>{a()}),[]);let P=In(()=>x.filter(L=>E.has(L.value)),[x,E]),k=In(()=>x.filter(L=>!E.has(L.value)),[x,E]),N=(L,B)=>gi(vt,{icon:L.icon,value:L.value,order:B,textStyle:{fontFamily:_4({fontFamily:L.value})},hovered:L.value===v?.value,selected:L.value===e,tabIndex:L.value===e?0:-1,onClick:G=>{I(Number(G.currentTarget.value))},onMouseMove:()=>{v?.value!==L.value&&n(L.value)},badge:L.badge&&gi(oc,{type:L.badge.type,children:L.badge.placeholder}),children:L.text},L.value),_=[];return P.length&&_.push(gi(Ha,{title:g("fontList.sceneFonts"),children:P.map(N)},"group_1")),k.length&&_.push(gi(Ha,{title:g("fontList.availableFonts"),children:k.map((L,B)=>N(L,B+P.length))},"group_2")),R4($o,{className:"properties-content",container:l,style:{width:"15rem"},onClose:()=>{a(),s.state.editingTextElement&&setTimeout(()=>{let L=document.querySelector(".excalidraw-wysiwyg");L&&L.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[p==="full"&&gi(qs,{ref:f,placeholder:g("quickSearch.placeholder"),onChange:A4(h,20)}),gi(Js,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:_.length?_:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as eE from"@radix-ui/react-popover";import{MOBILE_ACTION_BUTTON_BG as N4}from"@excalidraw/common";import{jsx as Ap}from"react/jsx-runtime";var tE=({selectedFontFamily:e,isOpened:o=!1,compactMode:t=!1})=>{let n=he(),r=t?{...N4,width:"2rem",height:"2rem"}:{};return Ap(eE.Trigger,{asChild:!0,children:Ap("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Ap(li,{standalone:!0,icon:To,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{n(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as Wa,jsxs as oE}from"react/jsx-runtime";var rE=[{value:_p.Excalifont,icon:Io,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:_p.Nunito,icon:Pa,text:g("labels.normal"),testId:"font-family-normal"},{value:_p["Comic Shanns"],icon:Ps,text:g("labels.code"),testId:"font-family-code"}],OZ=new Set(rE.map(e=>e.value));var iE=F4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:a,compactMode:l=!1})=>{let s=z4(()=>rE,[]),c=O4(m=>{m&&n(m)},[n]);return oE("div",{role:"dialog","aria-modal":"true",className:B4("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&Wa("div",{className:"buttonList",children:Wa(Wt,{type:"button",options:s,value:o,onClick:c})}),!l&&Wa(Us,{}),oE(nE.Root,{open:e,onOpenChange:a,children:[Wa(tE,{selectedFontFamily:o,isOpened:e,compactMode:l}),e&&Wa(Qb,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as bi from"@radix-ui/react-popover";import W4 from"clsx";import nc,{useEffect as Y4}from"react";import{isArrowKey as V4,KEYS as jo}from"@excalidraw/common";import{jsx as H4}from"react/jsx-runtime";var fi=({className:e,icon:o,size:t="1em"})=>H4("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:o});import{Fragment as U4,jsx as aE,jsxs as lE}from"react/jsx-runtime";var G4=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>lE(U4,{children:[lE("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&aE(fi,{icon:o?db:Ds})]}),o&&aE("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),Ya=G4;import{jsx as rr,jsxs as Dp}from"react/jsx-runtime";var X4=Se(!1);function K4({options:e,value:o,label:t,onChange:n,onClose:r,numberOfOptionsToAlwaysShow:i=e.length}){let a=de(),{container:l}=ke(),s=b=>{let E=e.find(w=>w.keyBinding===b.key.toLowerCase());if(!(b.metaKey||b.altKey||b.ctrlKey)&&E)n(E.value),b.preventDefault();else if(b.key===jo.TAB){let w=e.findIndex(x=>x.value===o),y=b.shiftKey?(e.length+w-1)%e.length:(w+1)%e.length;n(e[y].value)}else if(V4(b.key)){let w=Xo().rtl,y=e.findIndex(x=>x.value===o);if(y!==-1){let x=e.length,v=y;switch(b.key){case(w?jo.ARROW_LEFT:jo.ARROW_RIGHT):v=(y+1)%x;break;case(w?jo.ARROW_RIGHT:jo.ARROW_LEFT):v=(x+y-1)%x;break;case jo.ARROW_DOWN:{v=(y+(i??1))%x;break}case jo.ARROW_UP:{v=(x+y-(i??1))%x;break}}n(e[v].value)}b.preventDefault()}else(b.key===jo.ESCAPE||b.key===jo.ENTER)&&(b.preventDefault(),r());b.nativeEvent.stopImmediatePropagation(),b.stopPropagation()},[c,m]=ue(X4),p=nc.useMemo(()=>e.slice(0,i),[e,i]),d=nc.useMemo(()=>e.slice(i),[e,i]);Y4(()=>{p.some(b=>b.value===o)||m(!0)},[o,p,m]);let h=b=>rr("div",{className:"picker-content",children:b.map((E,w)=>Dp("button",{type:"button",className:W4("picker-option",{active:o===E.value}),onClick:y=>{n(E.value)},title:`${E.text} ${E.keyBinding&&`\u2014 ${E.keyBinding.toUpperCase()}`}`,"aria-label":E.text||"none","aria-keyshortcuts":E.keyBinding||void 0,ref:y=>{o===E.value&&setTimeout(()=>{y?.focus()},0)},children:[E.icon,E.keyBinding&&rr("span",{className:"picker-keybinding",children:E.keyBinding})]},E.text))}),f=a.formFactor==="phone";return rr(bi.Content,{side:f?"right":"bottom",align:"start",sideOffset:f?8:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:s,collisionBoundary:l??void 0,children:Dp("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[h(p),d.length>0&&rr(Ya,{label:g("labels.more_options"),open:c,openTrigger:()=>{m(b=>!b)},className:"picker-collapsible",children:h(d)})]})})}function Rp({value:e,label:o,options:t,onChange:n,group:r="",numberOfOptionsToAlwaysShow:i}){let[a,l]=nc.useState(!1),s=nc.useRef(null);return rr("div",{children:Dp(bi.Root,{open:a,onOpenChange:c=>l(c),children:[rr(bi.Trigger,{name:r,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(c=>c.value===e)?.icon}),a&&rr(K4,{options:t,value:e,label:o,onChange:n,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import sE,{useEffect as Z4}from"react";import{jsx as Np,jsxs as cE}from"react/jsx-runtime";var dE=({updateData:e,app:o,testId:t})=>{let n=sE.useRef(null),r=sE.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),c=i.reduce((m,p)=>(m!=null&&m!==p.opacity&&(a=!1),m==null||m>p.opacity?p.opacity:m),l?.opacity??null)??o.state.currentItemOpacity;return Z4(()=>{if(n.current&&r.current){let m=n.current,p=r.current,d=m.offsetWidth,h=15,f=c/100*(d-h)+h/2;p.style.left=`${f}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${c}%, var(--button-bg) ${c}%, var(--button-bg) 100%)`}},[c]),cE("label",{className:"control-label",children:[g("labels.opacity"),cE("div",{className:"range-wrapper",children:[Np("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:n,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:c,className:"range-input","data-testid":t}),Np("div",{className:"value-bubble",ref:r,children:c!==0?c:null}),Np("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Vp,jsx as ne,jsxs as ht}from"react/jsx-runtime";var bE=.1,xi=e=>{let o=b6(e.editorInterface);return{stylesPanelMode:o,isCompact:o!=="full",isMobile:o==="mobile"}},ut=(e,o,t,n=!1)=>{let r=Hp(q(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},st=function(e,o,t,n,r){let i=o.state.editingTextElement,a=gE(e),l=null;if(i&&(l=t(i)),!l)if(ve(a,o.state)){let c=o.scene.getSelectedElements(o.state),m=n===!0?c:c.filter(p=>n(p));l=c6(m,t)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},E6=(e,o,t)=>p6(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),Up=(e,o,t,n,r)=>{let i=new Set,a=ut(e,o,l=>{if(It(l)){let s=n(l);i.add(s);let c=Xe(l,{fontSize:s});return Va(c,t.scene.getContainerElement(l),t.scene),c=E6(l,c,t.scene),c}return l},!0);return q(e,o,{includeBoundTextElement:!0}).forEach(l=>{It(l)&&m6(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:Ke.IMMEDIATELY}},x6=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t?.currentItemStrokeColor&&{elements:ut(e,o,n=>h6(n.type)?Xe(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t?.currentItemStrokeColor?Ke.IMMEDIATELY:Ke.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=xi(n);return ht(Vp,{children:[i==="full"&&ne("h3",{"aria-hidden":"true",children:g("labels.stroke")}),ne(za,{topPicks:t6,palette:e6,type:"elementStroke",label:g("labels.stroke"),color:st(e,n,a=>a.strokeColor,!0,a=>a?null:o.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:o,updateData:t})]})}}),y6=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t?.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:Ke.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!s6(t.currentItemBackgroundColor)&&i.every(l=>uE(l)&&d6(l.points))){let l=Hp(i);r=e.map(s=>l.has(s.id)&&uE(s)?Xe(s,{backgroundColor:t.currentItemBackgroundColor,...f6(s,!0)}):s)}else r=ut(e,o,l=>Xe(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:Ke.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=xi(n);return ht(Vp,{children:[i==="full"&&ne("h3",{"aria-hidden":"true",children:g("labels.background")}),ne(za,{topPicks:Q4,palette:J4,type:"elementBackground",label:g("labels.background"),color:st(e,n,a=>a.backgroundColor,!0,a=>a?null:o.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:o,updateData:t})]})}}),w6=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(le("element","changeFillStyle",`${t} (${n.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:ut(e,o,r=>Xe(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=q(e,o),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return ht("fieldset",{children:[ne("legend",{children:g("labels.fill")}),ne("div",{className:"buttonList",children:ne(Wt,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${A("Alt-Click")})`,icon:i?i0:a0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:l0,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:s0,testId:"fill-solid"}],value:st(e,n,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),v6=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Xe(n,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[ne("legend",{children:g("labels.strokeWidth")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"stroke-width",options:[{value:Op.thin,text:g("labels.thin"),icon:qm,testId:"strokeWidth-thin"},{value:Op.bold,text:g("labels.bold"),icon:c0,testId:"strokeWidth-bold"},{value:Op.extraBold,text:g("labels.extraBold"),icon:d0,testId:"strokeWidth-extraBold"}],value:st(e,n,i=>i.strokeWidth,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:o.currentItemStrokeWidth),onChange:i=>t(i)})})]})}),I6=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Xe(n,{seed:i6(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[ne("legend",{children:g("labels.sloppiness")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:u0},{value:1,text:g("labels.artist"),icon:h0},{value:2,text:g("labels.cartoonist"),icon:g0}],value:st(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),U$=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Xe(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[ne("legend",{children:g("labels.strokeStyle")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:qm},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:m0},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:p0}],value:st(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),T6=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Xe(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>ne(dE,{updateData:o,app:e,testId:"opacity"})}),S6=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>Up(e,o,n,()=>(Gp(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=xi(n);return ht("fieldset",{children:[ne("legend",{children:g("labels.fontSize")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"font-size",options:[{value:ic.sm,text:g("labels.small"),icon:L0,testId:"fontSize-small"},{value:ic.md,text:g("labels.medium"),icon:A0,testId:"fontSize-medium"},{value:ic.lg,text:g("labels.large"),icon:_0,testId:"fontSize-large"},{value:ic.xl,text:g("labels.veryLarge"),icon:D0,testId:"fontSize-veryLarge"}],value:st(e,n,a=>{if(It(a))return a.fontSize;let l=Tn(a,n.scene.getNonDeletedElementsMap());return l?l.fontSize:null},a=>It(a)||Tn(a,n.scene.getNonDeletedElementsMap())!==null,a=>a?null:o.currentItemFontSize||n6),onChange:a=>{Na(()=>t(a),i,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),Wp=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:tr,trackEvent:!1,perform:(e,o,t,n)=>Up(e,o,n,r=>Math.round(1/(1+bE)*r.fontSize)),keyTest:e=>e[Ei.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ei.CHEVRON_LEFT||e.key===Ei.COMMA)}),Yp=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:tr,trackEvent:!1,perform:(e,o,t,n)=>Up(e,o,n,r=>Math.round(r.fontSize*(1+bE))),keyTest:e=>e[Ei.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ei.CHEVRON_RIGHT||e.key===Ei.PERIOD)}),C6=F({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,n)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:ut(e,o,b=>{let E=r?.get(b.id);return E?Xe(b,{...E}):b},!0),appState:{...o,...l},captureUpdate:Ke.NEVER};Gp(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=Ke.EVENTUALLY,p,d=!1;if(s)p=s,m=Ke.IMMEDIATELY;else if(c){p=c,m=Ke.EVENTUALLY;let f=q(e,o,{includeBoundTextElement:!0}).filter(b=>It(b));if(f.length>200)d=!0;else{let b=0,E=0;for(;b<f.length&&E<5e3;){let w=f[b];E+=w?.originalText.length||0,b++}E>5e3&&(d=!0)}}let h={appState:{...o,...l},captureUpdate:m};if(p&&!d){let f=new Map,b=new Set,E=!1,w=Array.from(un.loadedFontsCache.values()),y=Object.entries(r6).find(([I,C])=>C===p)?.[0];c&&y&&w.some(I=>I.startsWith(y))&&(E=!0),Object.assign(h,{elements:ut(e,o,I=>{if(It(I)&&(I.fontFamily!==p||s)){let C=Xe(I,{fontFamily:p,lineHeight:l6(p)}),P=r?.get(I.containerId||"")||{},k=n.scene.getContainerElement(I);return a&&k&&P&&n.scene.mutateElement(k,{...P}),E||(b=new Set([...b,...Array.from(C.originalText)])),f.set(C,k),C}return I},!0)});let x=`10px ${a6({fontFamily:p})}`,v=Array.from(b.values()).join();if(E||window.document.fonts.check(x,v))for(let[I,C]of f)Va(I,C,n.scene);else window.document.fonts.load(x,v).then(I=>{for(let[C,P]of f){let k=n.scene.getElement(C.id),N=P?n.scene.getElement(P.id):null;k&&Va(k,N,n.scene)}n.fonts.onLoaded(I)})}return h},PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=Fp(new Map),i=Fp(null),[a,l]=q4({}),s=Fp(!0),{stylesPanelMode:c,isCompact:m}=xi(t),p=j4(()=>{let d=(h,f)=>st(h,t,b=>{if(It(b))return b.fontFamily;let E=Tn(b,f);return E?E.fontFamily:null},b=>It(b)||Tn(b,f)!==null,b=>b?null:o.currentItemFontFamily||o6);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?d(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&o.openPopup!=="fontFamily"?d(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return Bp(()=>{i.current=p},[p]),Bp(()=>{Object.keys(a).length&&(n(a),l({}))},[a]),Bp(()=>(s.current=!1,()=>{s.current=!0}),[]),ht(Vp,{children:[c==="full"&&ne("legend",{children:g("labels.fontFamily")}),ne(iE,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:c!=="full",onSelect:d=>{Na(()=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:d}),r.current.clear()},m,!!o.editingTextElement)},onHover:d=>{l({currentHoveredFontFamily:d,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:d=>{if(d){r.current.clear();let{editingTextElement:h}=o;if(h?.type==="text"){let f=t.scene.getElement(h.id);r.current.set(h.id,Xe(f||h,{},!0))}else{let f=q(e,o,{includeBoundTextElement:!0});for(let b of f)r.current.set(b.id,Xe(b,{},!0))}l({...a,openPopup:"fontFamily"})}else{let h={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};l({...h}),r.current.clear(),m&&o.editingTextElement&&Ra(null)}}})]})}}),k6=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:ut(e,o,r=>{if(It(r)){let i=Xe(r,{textAlign:t});return Va(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap(),{isCompact:a}=xi(n);return ht("fieldset",{children:[ne("legend",{children:g("labels.textAlign")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:N0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:B0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:F0,testId:"align-right"}],value:st(e,n,l=>{if(It(l))return l.textAlign;let s=Tn(l,i);return s?s.textAlign:null},l=>It(l)||Tn(l,i)!==null,l=>l?null:o.currentItemTextAlign),onChange:l=>{Na(()=>t(l),a,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),M6=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:ut(e,o,r=>{if(It(r)){let i=Xe(r,{verticalAlign:t});return Va(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=xi(n);return ne("fieldset",{children:ne("div",{className:"buttonList",children:ne(Wt,{group:"text-align",options:[{value:rc.TOP,text:g("labels.alignTop"),icon:ne(O0,{theme:o.theme}),testId:"align-top"},{value:rc.MIDDLE,text:g("labels.centerVertically"),icon:ne(H0,{theme:o.theme}),testId:"align-middle"},{value:rc.BOTTOM,text:g("labels.alignBottom"),icon:ne(z0,{theme:o.theme}),testId:"align-bottom"}],value:st(e,n,a=>{if(It(a)&&a.containerId)return a.verticalAlign;let l=Tn(a,n.scene.getNonDeletedElementsMap());return l?l.verticalAlign:null},a=>It(a)||Tn(a,n.scene.getNonDeletedElementsMap())!==null,a=>a?null:rc.MIDDLE),onChange:a=>{Na(()=>t(a),i,!!o.editingTextElement,r?.onPreventClose)}})})})}}),W$=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>fE(n)?n:Xe(n,{roundness:t==="round"?{type:u6(n.type)?ac.ADAPTIVE_RADIUS:ac.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let a=Br(gE(e),o).some(l=>l.roundness?.type===ac.LEGACY);return ht("fieldset",{children:[ne("legend",{children:g("labels.edges")}),ht("div",{className:"buttonList",children:[ne(Wt,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:f0},{value:"round",text:g("labels.round"),icon:b0}],value:st(e,n,l=>a?null:l.roundness?"round":"sharp",l=>!lc(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),r("togglePolygon")]})]})}}),hE=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:E0},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:ne(x0,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:ne(I0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:ne(T0,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:ne(y0,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ne(w0,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:ne(S0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:ne(C0,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:ne(v0,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:ne(M0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:ne(k0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:ne(P0,{flip:e}),keyBinding:"v"}],Y$=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>(Gp(t,"actionChangeArrowhead: value must be defined"),{elements:ut(e,o,n=>{if(zp(n)){let{position:r,type:i}=t;if(r==="start")return Xe(n,{startArrowhead:i});if(r==="end")return Xe(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=Xo().rtl;return ht("fieldset",{children:[ne("legend",{children:g("labels.arrowheads")}),ht("div",{className:"iconSelectList buttonList",children:[ne(Rp,{label:"arrowhead_start",options:hE(!r),value:st(e,n,i=>zp(i)&&Fr(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),ne(Rp,{label:"arrowhead_end",group:"arrowheads",options:hE(!!r),value:st(e,n,i=>zp(i)&&Fr(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),P6=F({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,o,t,n)=>!1,PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>ht("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),V$=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=ut(e,o,l=>{if(!lc(l))return l;let s=n.scene.getNonDeletedElementsMap(),c=ir.getPointAtIndexGlobalCoordinates(l,0,s),m=ir.getPointAtIndexGlobalCoordinates(l,-1,s),p=Xe(l,{x:t===Xt.elbow?c[0]:l.x,y:t===Xt.elbow?c[1]:l.y,roundness:t===Xt.round?{type:ac.PROPORTIONAL_RADIUS}:null,elbowed:t===Xt.elbow,angle:t===Xt.elbow?0:l.angle,points:t===Xt.elbow||l.elbowed?[ir.pointFromAbsoluteCoords({...l,x:c[0],y:c[1],angle:0},c,s),ir.pointFromAbsoluteCoords({...l,x:c[0],y:c[1],angle:0},m,s)]:l.points});if(fE(p)){p.fixedSegments=null;let d=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let h=ir.getPointAtIndexGlobalCoordinates(p,0,d),f=ir.getPointAtIndexGlobalCoordinates(p,-1,d),b=p.startBinding&&d.get(p.startBinding.elementId),E=p.endBinding&&d.get(p.endBinding.elementId),w=b&&p.startBinding?{...p.startBinding,...pE(p,b,"start",d)}:null,y=E&&p.endBinding?{...p.endBinding,...pE(p,E,"end",d)}:null;p={...p,startBinding:w,endBinding:y,...g6(p,d,{points:[h,f].map(x=>$4(x[0]-p.x,x[1]-p.y)),startBinding:w,endBinding:y,fixedSegments:null})}}else{let d=n.scene.getNonDeletedElementsMap();if(p.startBinding){let h=d.get(p.startBinding.elementId);h&&mE(p,h,o.bindMode==="inside"?"inside":"orbit","start",n.scene)}if(p.endBinding){let h=d.get(p.endBinding.elementId);h&&mE(p,h,o.bindMode==="inside"?"inside":"orbit","end",n.scene)}}return p}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new ir(l,Hp(e)))}return{elements:r,appState:i,captureUpdate:Ke.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ht("fieldset",{children:[ne("legend",{children:g("labels.arrowtypes")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"arrowtypes",options:[{value:Xt.sharp,text:g("labels.arrowtype_sharp"),icon:oi,testId:"sharp-arrow"},{value:Xt.round,text:g("labels.arrowtype_round"),icon:ri,testId:"round-arrow"},{value:Xt.elbow,text:g("labels.arrowtype_elbowed"),icon:ni,testId:"elbow-arrow"}],value:st(e,n,r=>lc(r)?r.elbowed?Xt.elbow:r.roundness?Xt.round:Xt.sharp:null,r=>lc(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})});import{clamp as jp,roundToStep as B6}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as F6,CURSOR_TYPE as vE,MAX_ZOOM as IE,MIN_ZOOM as TE,THEME as Xa,ZOOM_STEP as qp,updateActiveTool as wi,CODES as Mo,KEYS as Jo}from"@excalidraw/common";import{getNonDeletedElements as O6}from"@excalidraw/element";import{getCommonBounds as z6}from"@excalidraw/element";import{CaptureUpdateAction as Po}from"@excalidraw/element";import{useEffect as L6}from"react";import{jsx as _6}from"react/jsx-runtime";var yi=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},Xp=(e,o,t="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-n.width/2;l<0?l=a:l+n.width>=r&&(l=r-n.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+n.height>=i&&(s=o.top-n.height-a)):(s=o.top-n.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},A6=(e,o,t,n)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=n?"50ch":"10ch",o.style.maxWidth=n?"50ch":"15ch",o.textContent=t;let r=e.getBoundingClientRect();Xp(o,r)},ct=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(L6(()=>()=>yi().classList.remove("excalidraw-tooltip--visible"),[]),r?null:_6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>A6(i.currentTarget,yi(),o,t),onPointerLeave:()=>yi().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import{CURSOR_TYPE as Kp,MIME_TYPES as Zp,THEME as xE}from"@excalidraw/common";var yE='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',D6='<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"/>',wE='<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"/>',R6=`data:${Zp.svg},${encodeURIComponent(`${yE}${wE}</svg>`)}`,N6=`data:${Zp.svg},${encodeURIComponent(`${yE}${D6}${wE}</svg>`)}`,Rt=e=>{e&&(e.style.cursor="")},xe=(e,o)=>{e&&(e.style.cursor=o)},ko,EE,$p=(e,o)=>{let n=()=>{let r=o===xE.DARK;ko=document.createElement("canvas"),ko.theme=o,ko.height=20,ko.width=20;let i=ko.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(ko.width/2,ko.height/2,5,0,2*Math.PI),i.fillStyle=r?"#000":"#fff",i.fill(),i.strokeStyle=r?"#fff":"#000",i.stroke(),EE=ko.toDataURL(Zp.svg)};(!ko||ko.theme!==o)&&n(),xe(e,`url(${EE}) ${20/2} ${20/2}, auto`)},Nt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Rt(e);else if(lo(o))e.style.cursor=Kp.GRAB;else if(wt(o))$p(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===xE.LIGHT?R6:N6;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Kp.AUTO):e.style.cursor=Kp.CROSSHAIR};var qo=({viewportX:e,viewportY:o,nextZoom:t},n)=>{let r=e-n.offsetLeft,i=o-n.offsetTop,a=n.zoom.value,l=n.scrollX+(r-r/a),s=n.scrollY+(i-i/a),c=-(r-r/t),m=-(i-i/t);return{scrollX:l+c,scrollY:s+m,zoom:{value:t}}};import{jsx as mc,jsxs as W6}from"react/jsx-runtime";var H6=F({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t?.viewBackgroundColor?Po.IMMEDIATELY:Po.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n,data:r})=>mc(za,{palette:null,topPicks:F6,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),sc=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Nm,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...qo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:yo(o.zoom.value+qp)},o),userToFollow:null},captureUpdate:Po.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>mc(V,{type:"button",className:"zoom-in-button zoom-button",icon:Nm,title:`${g("buttons.zoomIn")} \u2014 ${A("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=IE,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Mo.EQUAL||e.code===Mo.NUM_ADD)&&(e[Jo.CTRL_OR_CMD]||e.shiftKey)}),cc=F({name:"zoomOut",label:"buttons.zoomOut",icon:Bm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...qo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:yo(o.zoom.value-qp)},o),userToFollow:null},captureUpdate:Po.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>mc(V,{type:"button",className:"zoom-out-button zoom-button",icon:Bm,title:`${g("buttons.zoomOut")} \u2014 ${A("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=TE,onClick:()=>{e(null)}}),keyTest:e=>(e.code===Mo.MINUS||e.code===Mo.NUM_SUBTRACT)&&(e[Jo.CTRL_OR_CMD]||e.shiftKey)}),dc=F({name:"resetZoom",label:"buttons.resetZoom",icon:G1,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...qo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:yo(1)},o),userToFollow:null},captureUpdate:Po.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>mc(ct,{label:g("buttons.resetZoom"),style:{height:"100%"},children:W6(V,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===Mo.ZERO||e.code===Mo.NUM_ZERO)&&(e[Jo.CTRL_OR_CMD]||e.shiftKey)}),G6=(e,o,t=1)=>{let[n,r,i,a]=e,l=i-n,s=o.width/l,c=a-r,m=o.height/c,d=Math.min(s,m)*jp(t,.1,1);return Math.min(d,1)},SE=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{r=jp(r,TE,IE);let[l,s,c,m]=e,p=(l+c)/2,d=(s+m)/2,h=t?.left??0,f=t?.top??0,b=t?.right??0,E=t?.bottom??0,w=o.width-h-b,y=o.height-f-E,x;if(n){let C=c-l,P=m-s;x=Math.min(w/C,y/P)*r}else x=G6(e,{width:w,height:y},r);let v=yo(jp(B6(x,qp,"floor"),i,a)),I=r1({scenePoint:{x:p,y:d},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:I.scrollX,scrollY:I.scrollY,zoom:{value:v}},captureUpdate:Po.EVENTUALLY}},Ka=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})=>{let l=z6(O6(o));return SE({canvasOffsets:e,bounds:l,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})},Cj=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:_s,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return Ka({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===Mo.TWO&&e.shiftKey&&!e.altKey&&!e[Jo.CTRL_OR_CMD]}),kj=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:_s,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return Ka({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===Mo.THREE&&e.shiftKey&&!e.altKey&&!e[Jo.CTRL_OR_CMD]}),U6=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:_s,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>Ka({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===Mo.ONE&&e.shiftKey&&!e.altKey&&!e[Jo.CTRL_OR_CMD]}),ar=F({name:"toggleTheme",label:(e,o)=>o.theme===Xa.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,o)=>e.theme===Xa.LIGHT?Ca:ka,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===Xa.LIGHT?Xa.DARK:Xa.LIGHT)},captureUpdate:Po.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===Mo.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),Mj=F({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return wt(o)?r=wi(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):r=wi(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Po.IMMEDIATELY}},keyTest:e=>e.key===Jo.E}),Pj=F({name:"toggleLassoTool",label:"toolBar.lasso",icon:gn,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.state.preferredSelectionTool.type!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=wi(o,{type:"lasso",fromSelection:!1}),xe(n.interactiveCanvas,vE.CROSSHAIR)):r=wi(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Po.NEVER}}}),CE=F({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:As,viewMode:!1,perform:(e,o,t,n)=>{let r;return lo(o)?r=wi(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=wi(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),xe(n.interactiveCanvas,vE.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Po.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Jo.CTRL_OR_CMD]&&e.key===Jo.H});import{updateActiveTool as kE}from"@excalidraw/common";import{CaptureUpdateAction as Y6}from"@excalidraw/element";var V6=F({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=kE(o,{type:"embeddable"});return Nt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:kE(o,{type:"embeddable"})},captureUpdate:Y6.EVENTUALLY}}});import{pointFrom as ME}from"@excalidraw/math";import{bindOrUnbindBindingElement as X6}from"@excalidraw/element/binding";import{isValidPolygon as PE,LinearElementEditor as pc,newElementWith as Jp}from"@excalidraw/element";import{isBindingElement as LE,isFreeDrawElement as AE,isLinearElement as _E,isLineElement as uc}from"@excalidraw/element";import{KEYS as Qp,arrayToMap as K6,invariant as DE,shouldRotateWithDiscreteAngle as Z6,updateActiveTool as RE}from"@excalidraw/common";import{isPathALoop as $6}from"@excalidraw/element";import{isInvisiblySmallElement as eu}from"@excalidraw/element";import{CaptureUpdateAction as NE}from"@excalidraw/element";import{jsx as j6}from"react/jsx-runtime";var gt=F({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=e,{interactiveCanvas:i,focusContainer:a,scene:l}=n,s=l.getNonDeletedElementsMap();if(t&&o.selectedLinearElement){let{event:d,sceneCoords:h}=t,f=pc.getElement(o.selectedLinearElement.elementId,s);DE(f,"Arrow element should exist if selectedLinearElement is set"),DE(h,"sceneCoords should be defined if actionFinalize is called with event");let b=pc.handlePointerUp(d,o.selectedLinearElement,o,n.scene);if(LE(f)&&!o.selectedLinearElement.segmentMidPointHoveredCoords){let E=!!o.newElement,y=(E||!o.selectedLinearElement.selectedPointsIndices?[f.points.length-1]:o.selectedLinearElement.selectedPointsIndices).reduce((x,v)=>(x.set(v,{point:pc.pointFromAbsoluteCoords(f,ME(h.x,h.y),s)}),x),new Map)??new Map;X6(f,y,h.x,h.y,l,o,{newArrow:E,altKey:d.altKey,angleLocked:Z6(d)})}else uc(f)&&o.selectedLinearElement?.isEditing&&!o.newElement&&!PE(f.points)&&l.mutateElement(f,{polygon:!1});if(b!==o.selectedLinearElement){f&&eu(f)&&(r=r.map(w=>w.id===f.id?Jp(w,{isDeleted:!0}):w));let E=o.activeTool?.locked;return{elements:f.points.length<2||eu(f)?e.map(w=>w.id===f.id?Jp(w,{isDeleted:!0}):w):r,appState:{...o,cursorButton:"up",selectedLinearElement:E?null:{...b,selectedPointsIndices:null,isEditing:!1,initialState:{...b.initialState,lastClickedPoint:-1}},selectionElement:null,suggestedBinding:null,newElement:null,multiElement:null},captureUpdate:NE.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||LE(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let d=s.get(Object.keys(o.selectedElementIds)[0]);d&&(c=d)}if(c){if(o.selectedLinearElement&&o.multiElement&&c.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:d}=c,{lastCommittedPoint:h}=o.selectedLinearElement;(!h||d[d.length-1]!==h)&&l.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&eu(c)&&(r=r.map(d=>d.id===c?.id?Jp(d,{isDeleted:!0}):d)),_E(c)||AE(c)){if($6(c.points,o.zoom.value)&&(uc(c)||AE(c))){let h=c.points,f=h[0],b=h.map((E,w)=>w===h.length-1?ME(f[0],f[1]):E);uc(c)?l.mutateElement(c,{points:b,polygon:!0}):l.mutateElement(c,{points:b})}uc(c)&&!PE(c.points)&&l.mutateElement(c,{polygon:!1})}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Rt(i);let m;o.activeTool.type==="eraser"?m=RE(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):m=RE(o,{type:n.state.preferredSelectionTool.type});let p=c&&_E(c)?new pc(c,K6(r)):o.selectedLinearElement;return p=p&&{...p,isEditing:o.newElement?!1:p.isEditing,initialState:{...p.initialState,lastClickedPoint:-1,origin:null}},{elements:r,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:m,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:p},captureUpdate:NE.IMMEDIATELY}},keyTest:(e,o)=>e.key===Qp.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===Qp.ESCAPE||e.key===Qp.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>j6(V,{type:"button",icon:J1,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as yc,DEFAULT_EXPORT_PADDING as Gk,EXPORT_SCALES as Uk,THEME as nu}from"@excalidraw/common";import{getNonDeletedElements as Wk}from"@excalidraw/element";import{CaptureUpdateAction as uo}from"@excalidraw/element";import q6 from"clsx";import{jsx as BE,jsxs as J6}from"react/jsx-runtime";var Za=({children:e,checked:o,onChange:t,className:n})=>J6("div",{className:q6("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[BE("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:K1}),BE("div",{className:"Checkbox-label",children:e})]});import{THEME as $a}from"@excalidraw/common";import{jsx as ja}from"react/jsx-runtime";var OE=e=>{let o=e.title||(e.value===$a.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return ja(V,{type:"icon",icon:e.value===$a.LIGHT?FE.MOON:FE.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===$a.DARK?$a.LIGHT:$a.DARK),"data-testid":"toggle-dark-mode"})},FE={SUN:ja("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ja("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:ja("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ja("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 Q6}from"react";import{focusNearestParent as ek,KEYS as tk}from"@excalidraw/common";import{jsx as zE,jsxs as ok}from"react/jsx-runtime";var HE=e=>{let{id:o}=ke(),[t,n]=Q6(e.value),r=a=>{e.ignoreFocus||ek(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===tk.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return ok("div",{className:"ProjectName",children:[zE("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),zE("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>n(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as _k,DEFAULT_FILENAME as Dk,IMAGE_MIME_TYPES as ox,isFirefox as Rk,MIME_TYPES as Nk,cloneJSON as Bk,SVG_DOCUMENT_PREAMBLE as Fk}from"@excalidraw/common";import{getNonDeletedElements as Ok}from"@excalidraw/element";import{isFrameLikeElement as zk}from"@excalidraw/element";import{getElementsOverlappingFrame as Hk}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as hk,EXPORT_DATA_TYPES as Qa,MIME_TYPES as mo,arrayToMap as gk,isMemberOf as fk,isPromiseLike as bk,EVENT as fc}from"@excalidraw/common";import{mutateElement as Ek}from"@excalidraw/element";import{deepCopyElement as xk}from"@excalidraw/element";import{isFrameLikeElement as yk,isInitializedImageElement as wk}from"@excalidraw/element";import{getContainingFrame as qE}from"@excalidraw/element";import{pointFrom as Sn}from"@excalidraw/math";import{COLOR_PALETTE as UE,DEFAULT_CHART_COLOR_INDEX as nk,getAllColorsSpecificShade as rk,DEFAULT_FONT_FAMILY as ik,DEFAULT_FONT_SIZE as WE,VERTICAL_ALIGN as ak,randomId as YE,isDevEnv as VE,FONT_SIZES as lk}from"@excalidraw/common";import{newTextElement as hc,newLinearElement as Ja,newElement as ou}from"@excalidraw/element";var co=32,Ce=12,Cn=256,XE=50,lr="NOT_SPREADSHEET",vi="VALID_SPREADSHEET",qa=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},tu=(e,o)=>e.slice(1).every(t=>qa(t[o])!==null),GE=e=>{let o=e[0].length;if(o>2)return{type:lr,reason:"More than 2 columns"};if(o===1){if(!tu(e,0))return{type:lr,reason:"Value is not numeric"};let s=qa(e[0][0])===null,c=(s?e.slice(1):e).map(m=>qa(m[0]));return c.length<2?{type:lr,reason:"Less than two rows"}:{type:vi,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let t=tu(e,0),n=tu(e,1);if(!t&&!n)return{type:lr,reason:"Value is not numeric"};let[r,i]=n?[0,1]:[1,0],a=qa(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:lr,reason:"Less than 2 rows"}:{type:vi,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[r]),values:l.map(s=>qa(s[i]))}}},sk=e=>{let o=[];for(let t=0;t<e[0].length;t++){let n=[];for(let r=0;r<e.length;r++)n.push(e[r][t]);o.push(n)}return o},KE=e=>{let o=e.trim().split(`
|
|
1
|
+
import{$ as Cm,A as tS,B as n1,C as r1,D as i1,E as os,F as ns,G as rs,H as is,I as ha,J as a1,K as l1,L as s1,M as as,N as Or,O as c1,P as oS,Q as $n,R as zr,S as ga,U as d1,W as m1,X as p1,Y as ls,Z as u1,_ as Sm,a as Qf,aa as ss,b as Zn,ba as h1,c as xo,ca as km,d as e1,da as jn,e as ve,ea as g1,f as t1,fa as Mm,g as q,ga as f1,h as Dr,ha as b1,i as yo,ia as cs,j as da,ja as Pm,k as ma,ka as E1,l as Rr,la as x1,m as pa,ma as y1,n as Nr,na as fa,o as o1,p as vm,q as cn,r as Br,s as wt,t as ao,u as Fr,v as es,w as Im,x as ua,y as ts,z as Tm}from"./chunk-DWIVCTY2.js";import{a as T}from"./chunk-COCFTLLX.js";import{J as wm}from"./chunk-SXXYW6U7.js";import{c as Jf}from"./chunk-AJI3LATG.js";import{b as jf,c as qf,d as S}from"./chunk-SRAX5OIU.js";import AG,{useEffect as _G}from"react";import{DEFAULT_UI_OPTIONS as qT,isShallowEqual as DG}from"@excalidraw/common";import _5 from"clsx";import sz from"lodash.throttle";import Ho,{useContext as Xn}from"react";import{flushSync as oo}from"react-dom";import cz from"roughjs/bin/rough";import{nanoid as dz}from"nanoid";import{clamp as D5,pointFrom as oe,pointDistance as Cr,vector as R5,pointRotateRads as nf,vectorScale as mz,vectorFromPoint as rf,vectorSubtract as N5,vectorDot as B5,vectorNormalize as F5}from"@excalidraw/math";import{COLOR_PALETTE as pz,CODES as O5,shouldResizeFromCenter as z5,shouldMaintainAspectRatio as Ol,shouldRotateWithDiscreteAngle as H5,isArrowKey as im,KEYS as X,APP_NAME as uz,CURSOR_TYPE as Ne,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as hz,DEFAULT_VERTICAL_ALIGN as G5,DRAGGING_THRESHOLD as gz,ELEMENT_SHIFT_TRANSLATE_AMOUNT as fz,ELEMENT_TRANSLATE_AMOUNT as U5,EVENT as re,FRAME_STYLE as No,IMAGE_MIME_TYPES as bz,IMAGE_RENDER_TIMEOUT as Ez,LINE_CONFIRM_THRESHOLD as af,MAX_ALLOWED_FILE_BYTES as W5,MIME_TYPES as Bo,MQ_RIGHT_SIDEBAR_MIN_WIDTH as xz,POINTER_BUTTON as kr,ROUNDNESS as am,SCROLL_TIMEOUT as yz,TAP_TWICE_TIMEOUT as wz,TEXT_TO_CENTER_SNAP_THRESHOLD as vz,THEME as lm,TOUCH_CTX_MENU_TIMEOUT as Iz,VERTICAL_ALIGN as Tz,YOUTUBE_STATES as sm,ZOOM_STEP as Sz,POINTER_EVENTS as na,TOOL_TYPE as Fo,supportsResizeObserver as Cz,DEFAULT_COLLISION_THRESHOLD as Y5,DEFAULT_TEXT_ALIGN as kz,ARROW_TYPE as Un,DEFAULT_REDUCED_GLOBAL_ALPHA as Mz,isLocalLink as Pz,normalizeLink as lf,toValidURL as Lz,getGridPoint as pt,getLineHeight as V5,debounce as X5,distance as ra,getFontString as sf,getNearestScrollableContainer as Az,isInputLike as K5,isToolIcon as _z,isWritableElement as zl,sceneCoordsToViewportCoords as cm,tupleToCoors as cf,viewportCoordsToSceneCoords as Be,wrapEvent as Dz,updateObject as df,updateActiveTool as Oo,isTransparent as Rz,easeToValuesRAF as Nz,muteFSAbortError as Bz,isTestEnv as LT,isDevEnv as AT,easeOut as Fz,updateStable as Hl,addEventListener as Fe,normalizeEOL as Oz,getDateTime as Z5,isShallowEqual as $5,arrayToMap as dm,applyDarkModeFilter as zz,randomInteger as Hz,CLASSES as mf,Emitter as Mr,MINIMUM_ARROW_SIZE as Gz,DOUBLE_TAP_POSITION_THRESHOLD as Uz,BIND_MODE_TIMEOUT as Wz,invariant as zo,getFeatureFlag as an,createUserAgentDescriptor as _T,getFormFactor as Yz,deriveStylesPanelMode as fm,isIOS as Vz,isBrave as Xz,isSafari as Kz,loadDesktopUIModePreference as Zz,setDesktopUIMode as $z,isSelectionLikeTool as mm}from"@excalidraw/common";import{getObservedAppState as jz,getCommonBounds as ia,getElementAbsoluteCoords as j5,bindOrUnbindBindingElements as q5,fixBindingsAfterDeletion as qz,getHoveredElementForBinding as bo,isBindingEnabled as Gl,shouldEnableBindingForPointerEvent as Jz,updateBoundElements as pm,LinearElementEditor as pe,newElementWith as Wn,newFrameElement as Qz,newFreeDrawElement as eH,newEmbeddableElement as J5,newMagicFrameElement as Q5,newIframeElement as tH,newArrowElement as oH,newElement as nH,newImageElement as rH,newLinearElement as iH,newTextElement as eT,refreshTextDimensions as aH,deepCopyElement as tT,duplicateElements as pf,hasBoundTextElement as oT,isArrowElement as aa,isBindingElement as Yn,isBindingElementType as lH,isBoundToContainer as uf,isFrameLikeElement as Lt,isImageElement as Pr,isEmbeddableElement as ln,isInitializedImageElement as Ul,isLinearElement as Et,isLinearElementType as sH,isUsingAdaptiveRadius as cH,isIframeElement as la,isIframeLikeElement as Wl,isMagicFrameElement as nT,isTextBindableContainer as rT,isElbowArrow as At,isFlowchartNodeElement as dH,isBindableElement as hf,isTextElement as Eo,getNormalizedDimensions as mH,isElementCompletelyInViewport as gf,isElementInViewport as iT,isInvisiblySmallElement as aT,getCornerRadius as pH,isPathALoop as lT,createSrcDoc as sT,embeddableURLValidator as ff,maybeParseEmbedSrc as uH,getEmbedLink as um,getInitializedImageElements as hH,normalizeSVG as cT,updateImageCache as gH,getBoundTextElement as bf,getContainerCenter as Ef,getContainerElement as dT,isValidTextContainer as fH,redrawTextBoundingBox as bH,hasBoundingBox as EH,getFrameChildren as xf,isCursorInFrame as mT,addElementsToFrame as yf,replaceAllElementsInFrame as xH,removeElementsFromFrame as yH,getElementsInResizingFrame as wf,getElementsInNewFrame as wH,getContainingFrame as vf,elementOverlapsWithFrame as vH,updateFrameMembershipOfSelectedElements as pT,isElementInFrame as uT,getFrameLikeTitle as IH,getElementsOverlappingFrame as TH,filterElementsEligibleAsFrameChildren as SH,hitElementBoundText as CH,hitElementBoundingBoxOnly as kH,hitElementItself as Yl,getVisibleSceneBounds as MH,FlowChartCreator as PH,FlowChartNavigator as LH,getLinkDirectionFromKey as hT,cropElement as AH,wrapText as _H,isElementLink as If,parseElementLinkFromURL as DH,isMeasureTextSupported as RH,normalizeText as NH,measureText as gT,getLineHeightInPx as BH,getApproxMinLineWidth as FH,getApproxMinLineHeight as OH,getMinTextElementWidth as zH,ShapeCache as Vl,getRenderOpacity as HH,editGroupForSelectedElement as GH,getElementsInGroup as Lr,getSelectedGroupIdForElement as UH,getSelectedGroupIds as WH,isElementInGroup as fT,isSelectedViaGroup as YH,selectGroupsForSelectedElements as no,syncInvalidIndices as DT,syncMovedIndices as bT,excludeElementsInFramesFromSelection as VH,getSelectionStateForElements as XH,makeNextSelectedElementIds as ye,getResizeOffsetXY as KH,getResizeArrowDirection as ZH,transformElements as $H,getCursorForResizingElement as ET,getElementWithTransformHandleType as xT,getTransformHandleTypeFromCoords as yT,dragNewElement as wT,dragSelectedElements as jH,getDragOffsetXY as qH,isNonDeletedElement as vT,Scene as IT,Store as JH,CaptureUpdateAction as xt,hitElementBoundingBox as QH,isLineElement as Tf,isSimpleArrow as Sf,StoreDelta as TT,positionElementsOnGrid as ST,calculateFixedPointForNonElbowArrowBinding as CT,bindOrUnbindBindingElement as eG,mutateElement as hm,getElementBounds as kT,doBoundsIntersect as tG,isPointInElement as oG,maxBindingDistance_simple as Cf,convertToExcalidrawElements as nG}from"@excalidraw/element";import{KEYS as op,MOBILE_ACTION_BUTTON_BG as bS,updateActiveTool as ES}from"@excalidraw/common";import{getNonDeletedElements as np}from"@excalidraw/element";import{fixBindingsAfterDeletion as xS}from"@excalidraw/element";import{LinearElementEditor as hb}from"@excalidraw/element";import{newElementWith as Rs}from"@excalidraw/element";import{getContainerElement as gb}from"@excalidraw/element";import{isBoundToContainer as _s,isElbowArrow as yS,isFrameLikeElement as wS}from"@excalidraw/element";import{getFrameChildren as vS}from"@excalidraw/element";import{getElementsInGroup as rp,selectGroupsForSelectedElements as IS}from"@excalidraw/element";import{CaptureUpdateAction as Ds}from"@excalidraw/element";import{isDevEnv as aS}from"@excalidraw/common";import{atom as Se,createStore as nS}from"jotai";import{createIsolation as rS}from"jotai-scope";var w1=rS();var{useAtom:ue,useSetAtom:Hr,useAtomValue:ds,useStore:zG}=w1,v1=w1.Provider,$e=nS();var iS=jf({"./locales/ar-SA.json":()=>import("./locales/ar-SA-EYKRCXR6.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-ZNDJBVCS.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-O5I6U3AR.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-CXZY522G.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-HPUBVY4I.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-AREX5NEO.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-HXAZMFYH.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5X7ZLFU3.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-76ZNVSOF.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-G3JVZ4MQ.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-4AZTZGY6.js"),"./locales/en.json":()=>import("./locales/en-IT7EQLWB.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-ART7BI3G.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-BIF4XBMT.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-D4HHKAAI.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-O35ZY7UI.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-XEFNCM4I.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-U4NYM3X5.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-656ABAVQ.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-Z55GAFFR.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-UJ62DVIW.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-FLZFU3OO.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-GIGIGIBJ.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-43VXGDWI.js"),"./locales/kaa.json":()=>import("./locales/kaa-L3IMSDYL.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-XKPWJLNL.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-SXPDDY2H.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-DOS4CPGC.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-BGC6VCY4.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-J7IUITIA.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-AC3LV5KG.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-I6AY7QG2.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-5SP4HV5B.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-S7ECRBYZ.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-6PNHTF4R.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-R4C4SUIG.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-3TFXTM7Y.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-IK6GIE7H.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-YAKHYJET.js"),"./locales/percentages.json":()=>import("./locales/percentages-OL6W367U.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-BIY22ZWU.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-Q23NUPD6.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-LOPEJLPJ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-W3D2ZATV.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-DCTW7QSH.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-FYRRHO3C.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-MC7UOHQO.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-L6B6HFY5.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-KMY6L2BA.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-ZQCYE2JK.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-WS7ECBAV.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-S5FI7JRW.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-4EZUWUSQ.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-OKHL6AFA.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-K34TWHF7.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-JE4UZWNO.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-RM35YDXX.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-ONGLV6Y5.js")});var lS=85,wo={code:"en",label:"English"},Ur=[wo,...[{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=>Jf[e.code]>=lS).sort((e,o)=>e.label>o.label?1:-1)],ps="__test__";aS()&&Ur.unshift({code:ps,label:"test language"},{code:`${ps}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Gr=wo,ms={},us=async e=>{if(Gr=e,document.documentElement.dir=Gr.rtl?"rtl":"ltr",document.documentElement.lang=Gr.code,e.code.startsWith(ps))ms={};else try{ms=await iS(`./locales/${Gr.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),ms=wm}$e.set(T1,e.code)},Uo=()=>Gr,I1=(e,o)=>{for(let t=0;t<o.length;++t){let n=o[t];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},g=(e,o,t)=>{if(Gr.code.startsWith(ps))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=I1(ms,n)||I1(wm,n)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)r=r.replace(`{{${i}}}`,String(o[i]));return r},T1=Se(wo.code),Ue=()=>{let e=ds(T1);return{t:g,langCode:e}};import sS from"clsx";import it from"react";import{THEME as cS}from"@excalidraw/common";import{Fragment as Ie,jsx as u,jsxs as R}from"react/jsx-runtime";var lo=e=>"var(--icon-fill-color)",S1=e=>e===cS.LIGHT?"#fff":"#1e1e1e",M=(e,o=512)=>{let{width:t=512,height:n=t,mirror:r,style:i,...a}=typeof o=="number"?{width:o}:o;return u("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${n}`,className:sS({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?u("path",{fill:"currentColor",d:e}):e})},z={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"},eU=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("rect",{x:3,y:8,width:18,height:4,rx:1}),u("line",{x1:12,y1:8,x2:12,y2:21}),u("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),u("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),z),hs=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),u("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),u("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),u("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),u("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),z),C1=M(R("svg",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),u("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),z),k1=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("circle",{cx:"12",cy:"12",r:"1"}),u("circle",{cx:"12",cy:"19",r:"1"}),u("circle",{cx:"12",cy:"5",r:"1"})]}),z),M1=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),u("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),u("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),z),P1=M(R("svg",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),u("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),u("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),z),Lm=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M6.5 9.5l3.5 -3"}),u("path",{d:"M14 5.5l3 1.5"}),u("path",{d:"M18.5 10l-2.5 7"}),u("path",{d:"M13.5 17.5l-7 -5"})]}),z),Wo=M(R("g",{children:[u("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"}),u("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"}),u("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:u("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"})}),u("g",{mask:"url(#UnlockedIcon)",children:u("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),dn=M(R("g",{strokeWidth:"1.25",children:[u("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"}),u("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),u("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),L1=M(u("g",{fill:"currentColor",children:u("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}),A1=M(R(Ie,{children:[u("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"}),u("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),u("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"}),_1=M(R(Ie,{children:[u("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"}),u("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),u("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"}),D1=M(R(Ie,{children:[u("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"}),u("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),u("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"}),tU=M(u("g",{fill:"currentColor",children:u("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"}),gs=M(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),mn=M(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[u("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"}),u("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),fs=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),z),bs=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),z),Es=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("circle",{cx:"12",cy:"12",r:"9"})]}),z),R1=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),u("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),u("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),z),xs=M(u("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ie),N1=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),u("path",{d:"M16 7h4"}),u("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),z),pn=M(R("g",{strokeWidth:"1.25",children:[u("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"}),u("path",{d:"m11.25 5.417 3.333 3.333"})]}),ie),un=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),u("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),u("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),u("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),u("polyline",{points:"5 20 11 4 13 4 20 20"})]}),z),B1=M(R("g",{stroke:"currentColor",strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 7v-2h13v2"}),u("path",{d:"M10 5v14"}),u("path",{d:"M12 19h-4"}),u("path",{d:"M15 13v-1h6v1"}),u("path",{d:"M18 12v7"}),u("path",{d:"M17 19h2"})]}),z),ys=M(R("g",{strokeWidth:"1.25",children:[u("path",{d:"M12.5 6.667h.01"}),u("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"}),u("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),u("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),ie),F1=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M18 13.3l-6.3 -6.3"})]}),z),Am=M(u("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ie),_m=M(u("path",{d:"M5 10h10",strokeWidth:"1.25"}),ie),O1=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M21 21l-6 -6"}),u("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"}),u("path",{d:"M3 4v4h4"})]}),z),Yo=M(u("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),ws=M(R("g",{strokeWidth:"1.5",children:[u("polyline",{points:"12 16 18 10 12 4"}),u("polyline",{points:"8 4 2 10 8 16"})]}),ie),ba=M(R("g",{strokeWidth:"1.25",children:[u("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"}),u("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),Ea=M(u("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),xa=M(u("g",{stroke:"currentColor",strokeLinejoin:"round",children:u("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}),z1=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),u("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),u("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),z),qn=M(u("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),Wr=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("circle",{cx:"12",cy:"12",r:"9"}),u("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),u("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),H1=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("circle",{cx:"12",cy:"12",r:"9"}),u("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),u("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),oU=M(u("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),G1=M(u("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),U1=M(R("g",{strokeWidth:"1.25",children:[u("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"}),u("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),W1=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),u("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),z),Y1=M(u("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),ya=M(R("g",{strokeWidth:"1.25",children:[u("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"}),u("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),V1=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}),X1=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}),Yr=M(u("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),nU=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}),rU=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"),vs=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),u("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),u("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),z),K1=M(u("g",{strokeWidth:1.5,children:u("path",{d:"M6 18l12 -12"})}),z),Is=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M15 8h.01"}),u("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),u("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),u("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),u("path",{d:"M19 16v6"}),u("path",{d:"M22 19l-3 3l-3 -3"})]}),z),Z1=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}),iU=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}),aU=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}),$1=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"),lU=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"),Dm=M(u("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),Rm=M(u("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),j1=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}),q1=M(u("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),sU=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"),cU=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}),dU=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M12 14v-11"}),u("path",{d:"M9 6l3 -3l3 3"})]}),z),mU=M(R(Ie,{children:[u("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"}),u("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}),pU=M(u("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}),J1=R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 10l0 10"}),u("path",{d:"M12 10l4 4"}),u("path",{d:"M12 10l-4 4"}),u("path",{d:"M4 4l16 0"})]}),Q1=R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 5l0 14"}),u("path",{d:"M16 9l-4 -4"}),u("path",{d:"M8 9l4 -4"})]}),Nm=M(Q1,z),Bm=M(Q1,{...z,style:{transform:"rotate(180deg)"}}),Fm=M(J1,z),Om=M(J1,{...z,style:{transform:"rotate(180deg)"}}),zm=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),Hm=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),Gm=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),Um=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),e0=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),t0=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),u("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"})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),Wm=M(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),u("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),u("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),u("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),Ym=M(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[u("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),u("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),u("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),u("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),Ts=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("circle",{cx:"9",cy:"7",r:"4"}),u("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),u("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),u("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),z),uU=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"),hU=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"),Ut=M(R(Ie,{children:[u("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:u("path",{d:"M15 5 5 15M5 5l10 10"})}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),gU=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}),fU=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}),bU=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}),Vm=it.memo(({theme:e})=>M(R(Ie,{children:[u("path",{d:"M25 26H111V111H25",fill:lo(e)}),u("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:lo(e),strokeWidth:"2"}),u("path",{d:"M100 100H160V160H100",fill:lo(e)}),u("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:lo(e),strokeWidth:"2"}),R("g",{fill:S1(e),stroke:lo(e),strokeWidth:"6",children:[u("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),u("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),u("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),u("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Xm=it.memo(({theme:e})=>M(R(Ie,{children:[u("path",{d:"M25 26H111V111H25",fill:lo(e)}),u("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:lo(e),strokeWidth:"2"}),u("path",{d:"M100 100H160V160H100",fill:lo(e)}),u("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:lo(e),strokeWidth:"2"}),R("g",{fill:S1(e),stroke:lo(e),strokeWidth:"6",children:[u("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),u("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),u("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),u("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),u("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),u("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),o0=M(u("g",{strokeWidth:1.25,children:u("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),n0=M(R(Ie,{children:[u("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"}),u("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:u("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"})}),u("g",{mask:"url(#FillHachureIcon)",children:u("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),r0=M(R(Ie,{children:[R("g",{clipPath:"url(#a)",children:[u("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"}),u("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:u("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"})}),u("g",{mask:"url(#FillCrossHatchIcon)",children:u("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"})})]}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),i0=M(R(Ie,{children:[u("g",{clipPath:"url(#a)",children:u("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"})}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...ie,fill:"currentColor"}),Km=M(u(Ie,{children:u("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ie),a0=M(u("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ie),l0=M(u("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ie),EU=it.memo(({theme:e})=>M(u("path",{d:"M6 10H34",stroke:lo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),s0=M(R("g",{strokeWidth:"2",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 12h2"}),u("path",{d:"M17 12h2"}),u("path",{d:"M11 12h2"})]}),z),c0=M(R("g",{strokeWidth:"2",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 12v.01"}),u("path",{d:"M8 12v.01"}),u("path",{d:"M12 12v.01"}),u("path",{d:"M16 12v.01"}),u("path",{d:"M20 12v.01"})]}),z),d0=M(u("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),m0=M(u("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),p0=M(u("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),u0=M(R("svg",{strokeWidth:"1.5",children:[u("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"}),u("path",{d:"M13.3333 3.33331V3.34331"}),u("path",{d:"M16.6667 3.33331V3.34331"}),u("path",{d:"M16.6667 6.66669V6.67669"}),u("path",{d:"M16.6667 10V10.01"}),u("path",{d:"M3.33334 13.3333V13.3433"}),u("path",{d:"M16.6667 13.3333V13.3433"}),u("path",{d:"M3.33334 16.6667V16.6767"}),u("path",{d:"M6.66666 16.6667V16.6767"}),u("path",{d:"M10 16.6667V16.6767"}),u("path",{d:"M13.3333 16.6667V16.6767"}),u("path",{d:"M16.6667 16.6667V16.6767"})]}),ie),h0=M(R("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),u("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),u("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),u("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),u("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),u("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),u("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),u("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),u("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),u("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),u("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),u("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),z),g0=M(R("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[u("path",{d:"M12 12l9 0"}),u("path",{d:"M3 9l6 6"}),u("path",{d:"M3 15l6 -6"})]}),z),f0=it.memo(({flip:e=!1})=>M(R("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[u("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),u("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),b0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[u("path",{d:"M32 10L6 10",strokeWidth:2}),u("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),E0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[u("path",{d:"M26 10L6 10"}),u("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),x0=it.memo(({flip:e=!1})=>M(u("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:u("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),y0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[u("path",{d:"M32 10L6 10",strokeWidth:2}),u("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),w0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[u("path",{d:"M6,9.5H27"}),u("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),v0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[u("path",{d:"M6,9.5H20"}),u("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),I0=it.memo(({flip:e=!1})=>M(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[u("path",{d:"M6,9.5H20"}),u("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),T0=it.memo(({flip:e=!1})=>M(u("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:u("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),S0=it.memo(({flip:e=!1})=>M(u("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:u("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),C0=it.memo(({flip:e=!1})=>M(u("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:u("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),k0=M(R(Ie,{children:[u("g",{clipPath:"url(#a)",children:u("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"})}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),M0=M(R(Ie,{children:[u("g",{clipPath:"url(#a)",children:u("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),P0=M(R(Ie,{children:[u("g",{clipPath:"url(#a)",children:u("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),u("defs",{children:u("clipPath",{id:"a",children:u("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),L0=M(u(Ie,{children:u("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),Jn=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 7v-2h13v2"}),u("path",{d:"M10 5v14"}),u("path",{d:"M12 19h-4"}),u("path",{d:"M15 13v-1h6v1"}),u("path",{d:"M18 12v7"}),u("path",{d:"M17 19h2"})]}),z),A0=M(u(Ie,{children:R("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M7 12h10"}),u("path",{d:"M7 5v14"}),u("path",{d:"M17 5v14"}),u("path",{d:"M15 19h4"}),u("path",{d:"M15 5h4"}),u("path",{d:"M5 19h4"}),u("path",{d:"M5 5h4"})]})}),z),wa=M(u(Ie,{children:u("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:u("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),dS=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M7 8l-4 4l4 4"}),u("path",{d:"M17 8l4 4l-4 4"}),u("path",{d:"M14 4l-4 16"})]}),z),Ss=dS,_0=M(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),u("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),u("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),z),D0=M(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),u("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),u("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),z),R0=M(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),u("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),u("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),z),N0=it.memo(({theme:e})=>M(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),u("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),z)),B0=it.memo(({theme:e})=>M(R("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),u("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),z)),F0=it.memo(({theme:e})=>M(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),u("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),u("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),z)),Cs=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M21 19h-18l9 -15"}),u("path",{d:"M20.615 15.171h.015"}),u("path",{d:"M19.515 11.771h.015"}),u("path",{d:"M17.715 8.671h.015"}),u("path",{d:"M15.415 5.971h.015"})]}),z),O0=M(u("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}),xU=M(u("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"})),ks=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),u("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),u("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),u("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),z),Zm=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),u("path",{d:"M7 11l5 5l5 -5"}),u("path",{d:"M12 4l0 12"})]}),z),Vr=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),z),z0=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),u("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),u("path",{d:"M9.15 14.85l8.85 -10.85"}),u("path",{d:"M6 4l8.85 10.85"})]}),z),H0=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),u("path",{d:"M12 17l0 .01"}),u("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),z),yU=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M7 4v16l13 -8z"})]}),z),wU=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),z),G0=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 12l5 5l10 -10"})]}),z),U0=M(R(Ie,{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M12 9v4"}),u("path",{d:"M12 17h.01"})]}),z),W0=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M11 7l6 6"}),u("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),z),Xr=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 3l-4 7h8z"}),u("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),u("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),z),hn=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 7l16 0"}),u("path",{d:"M4 17l16 0"}),u("path",{d:"M7 4l0 16"}),u("path",{d:"M17 4l0 16"})]}),z),vU=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),u("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),z),IU=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),u("path",{d:"M4 15l8 4l8 -4"}),u("path",{d:"M12 4v7"}),u("path",{d:"M15 8l-3 3l-3 -3"})]}),z),TU=M(R("g",{strokeWidth:"1.25",children:[u("path",{d:"M4.16602 10H15.8327"}),u("path",{d:"M12.5 13.3333L15.8333 10"}),u("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),ie),Kr=M(R("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[u("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"}),u("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),Y0=M(R("g",{stroke:"currentColor",fill:"none",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z"}),u("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),u("path",{d:"M15 6l3 3"}),u("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"}),u("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),SU=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z"}),u("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),u("path",{d:"M15 6l3 3"}),u("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"}),u("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),z),CU=M(R("g",{stroke:"currentColor",fill:"none",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),u("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),u("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"}),u("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),u("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),u("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),z),V0=M(R("g",{stroke:"currentColor",fill:"none",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),u("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),u("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),u("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),z),Qn=M(R("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),u("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),z),X0=M(R("g",{stroke:"currentColor",fill:"none",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),u("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"}),u("path",{d:"M3 3l18 18"})]}),z),kU=M(R("g",{stroke:"currentColor",fill:"none",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("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"}),u("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),u("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),u("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),u("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),MU=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("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"}),u("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),u("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),u("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),u("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),z),_t=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),u("path",{d:"M21 21l-6 -6"})]}),z),K0=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),u("path",{d:"M12 7v5l3 3"}),u("path",{d:"M19 16l-2 3h4l-2 3"})]}),z),PU=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 8l0 4l2 2"}),u("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),z),Z0=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M5 10a7 7 0 0 0 14 0"}),u("path",{d:"M8 21l8 0"}),u("path",{d:"M12 17l0 4"})]}),z),$0=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 3l18 18"}),u("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"}),u("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),u("path",{d:"M8 21l8 0"}),u("path",{d:"M12 17l0 4"})]}),z),va=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),z),j0=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M12 20v.01"}),u("path",{d:"M16 20v.01"}),u("path",{d:"M8 20v.01"}),u("path",{d:"M4 20v.01"}),u("path",{d:"M4 16v.01"}),u("path",{d:"M4 12v.01"}),u("path",{d:"M4 8v.01"}),u("path",{d:"M4 4v.01"}),u("path",{d:"M8 4v.01"}),u("path",{d:"M12 4v.01"}),u("path",{d:"M16 4v.01"}),u("path",{d:"M20 4v.01"}),u("path",{d:"M20 8v.01"}),u("path",{d:"M20 12v.01"}),u("path",{d:"M20 16v.01"}),u("path",{d:"M20 20v.01"})]}),z),q0=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 3v18"}),u("path",{d:"M19 21v-18"}),u("path",{d:"M5 7h14"}),u("path",{d:"M5 15h14"}),u("path",{d:"M8 13v4"}),u("path",{d:"M11 13v4"}),u("path",{d:"M16 13v4"}),u("path",{d:"M14 5v4"}),u("path",{d:"M11 5v4"}),u("path",{d:"M8 5v4"}),u("path",{d:"M3 21h18"})]}),z),J0=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 12l18 0"}),u("path",{d:"M7 16l10 0l-10 5l0 -5"}),u("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),z),Q0=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M12 3l0 18"}),u("path",{d:"M16 7l0 10l5 0l-5 -10"}),u("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),z),$m=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),u("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),z),Ms=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),u("path",{d:"M22 22l-3 -3"}),u("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),u("path",{d:"M3 11v-1"}),u("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),u("path",{d:"M10 3h1"}),u("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),z),eb=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),u("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),u("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"}),u("path",{d:"M10 15l2 6l2 -6"}),u("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),z),tb=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),u("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),u("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),u("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),u("path",{d:"M11 21v-6l3 6v-6"})]}),z),ob=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M4 8l5 0"}),u("path",{d:"M15 8l4 0"})]}),z),nb=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),u("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),u("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),u("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),z),rb=M(R("g",{stroke:"currentColor",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...z,strokeWidth:1.5}),LU=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M21 12h-13l3 -3"}),u("path",{d:"M11 15l-3 -3"})]}),z),AU=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M10 9l5 3l-5 3z"})]}),z),ib=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 6h18"}),u("path",{d:"M3 12h18"}),u("path",{d:"M3 18h18"}),u("path",{d:"M6 3v18"}),u("path",{d:"M12 3v18"}),u("path",{d:"M18 3v18"})]}),z),ab=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("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"}),u("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),z),Zr=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 18l12 -12"}),u("path",{d:"M18 10v-4h-4"})]}),z),$r=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),u("path",{d:"M18 4l3 3l-3 3"})]}),z),jr=M(R("g",{children:[u("path",{d:"M16,12L20,9L16,6"}),u("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),z),Ps=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 9l6 6l6 -6"})]}),z),lb=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 15l6 -6l6 6"})]}),z),sb=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 15l6 -6l6 6"})]}),z),jm=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),u("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),z),Ls=M(R("g",{children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M5 7l0 10"}),u("path",{d:"M7 5l10 0"}),u("path",{d:"M7 19l10 0"}),u("path",{d:"M19 7l0 10"})]}),z),qm=M(R("g",{strokeWidth:"1.25",children:[u("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),u("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),u("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),u("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),u("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),u("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),u("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),u("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),u("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),z),Jm=M(R("g",{strokeWidth:"1.5",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),u("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),u("polyline",{points:"2 8 3 6 4 8"}),u("polyline",{points:"2 12 3 14 4 12"}),u("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),u("polyline",{points:"9 17 7 18 9 19"}),u("polyline",{points:"15 17 17 18 15 19"})]}),z),_U=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),z),Qm=M(u("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:u("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"})})),cb=M(R("g",{strokeWidth:1.5,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M4 6l8 0"}),u("path",{d:"M16 6l4 0"}),u("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M4 12l2 0"}),u("path",{d:"M10 12l10 0"}),u("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),u("path",{d:"M4 18l11 0"}),u("path",{d:"M19 18l1 0"})]}),z),db=M(R("g",{strokeWidth:1,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),z),mS=M(R("g",{strokeWidth:1.25,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),u("path",{d:"M13.5 6.5l4 4"})]}),z),DU=M(R("g",{strokeWidth:1,children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M11 7l-5 5l5 5"}),u("path",{d:"M17 7l-5 5l5 5"})]}),z),mb=M(R("g",{strokeWidth:"1.75",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("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"}),u("path",{d:"M15 4l0 16"})]}),z),RU=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),z),NU=M(R("g",{strokeWidth:"1.25",children:[u("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),u("path",{d:"M3 4l18 0"}),u("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),u("path",{d:"M12 16l0 4"}),u("path",{d:"M9 20l6 0"}),u("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),z);import pb from"clsx";import tp,{useEffect as hS,useRef as ub,useState as gS}from"react";import{isPromiseLike as fS}from"@excalidraw/common";import pS from"react";import{jsx as ep}from"react/jsx-runtime";var uS=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(pS.useRef(Date.now()).current%1600);return ep("div",{className:`Spinner ${n}`,children:ep("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:ep("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},Dt=uS;import{jsx as Ia,jsxs as Ta}from"react/jsx-runtime";var V=tp.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=ke(),a=tp.useRef(null);tp.useImperativeHandle(r,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=gS(!1),m=ub(!0),p=async h=>{let f="onClick"in n&&n.onClick?.(h);if(fS(f))try{c(!0),await f}catch(b){if(b instanceof Nr)console.warn(b);else throw b}finally{m.current&&c(!1)}};hS(()=>(m.current=!0,()=>{m.current=!1}),[]);let d=ub(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let h=n.type==="icon"?"button":n.type;return Ta("button",{className:pb("ToolIcon_type_button",l,t,o&&!n.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!n.hidden,"ToolIcon--selected":n.selected,"ToolIcon--plain":n.type==="icon"}),style:n.style,"data-testid":n["data-testid"],hidden:n.hidden,title:n.title,"aria-label":n["aria-label"],type:h,onClick:p,ref:a,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&Ta("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&Ia("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&Ia(Dt,{})]}),n.showAriaLabel&&Ta("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&Ia(Dt,{})]}),n.children]})}return Ta("label",{className:pb("ToolIcon",t),title:n.title,onPointerDown:h=>{d.current=h.pointerType||null,n.onPointerDown?.({pointerType:h.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{d.current=null})},children:[Ia("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:n.name,"aria-label":n["aria-label"],"aria-keyshortcuts":n["aria-keyshortcuts"],"data-testid":n["data-testid"],id:`${i}-${n.id}`,onChange:()=>{n.onChange?.({pointerType:d.current})},checked:n.checked,ref:a}),Ta("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&Ia("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});V.displayName="ToolButton";var As=[],F=e=>(As=As.concat(e),e);import{jsx as SS}from"react/jsx-runtime";var TS=(e,o,t)=>{let n=new Set(q(e.filter(m=>wS(m)),o).map(m=>m.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of n){let p=vS(e,m);for(let d of p)if(!a.has(d.id)){if(_s(d)){let h=gb(d,i);h&&(r[h.id]=!0)}else r[d.id]=!0;a.add(d.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let p=_s(m)?gb(m,i):null;return m.frameId&&n.has(m.frameId)?(l=!1,r[m.id]=!0,m):p?.frameId&&n.has(p?.frameId)?m:(m.boundElements&&m.boundElements.forEach(d=>{let h=t.scene.getNonDeletedElementsMap().get(d.id);h&&yS(h)&&t.scene.mutateElement(h,{startBinding:m.id===h.startBinding?.elementId?null:h.startBinding,endBinding:m.id===h.endBinding?.elementId?null:h.endBinding})}),Rs(m,{isDeleted:!0}))}return m.frameId&&n.has(m.frameId)?(l=!1,_s(m)||(r[m.id]=!0),Rs(m,{frameId:null})):_s(m)&&o.selectedElementIds[m.containerId]?Rs(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=rp(s,o.editingGroupId).filter(p=>!p.isDeleted);if(m.length>1)m[0]&&(r[m[0].id]=!0);else{c=null,m[0]&&(r[m[0].id]=!0);let p=m[0];if(p){let d=p.groupIds.findIndex(f=>f===o.editingGroupId),h=p.groupIds[d+1];if(h){let f=rp(s,h).filter(b=>!b.isDeleted);f.length>1&&(c=h,f.forEach(b=>{r[b.id]=!0}))}}}}return{elements:s,appState:{...o,...IS({selectedElementIds:r,editingGroupId:c},s,o,null)}}},fb=(e,o)=>{if(e.editingGroupId){let t=rp(np(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Sa=F({name:"deleteSelectedElements",label:"labels.delete",icon:Yo,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l}=o.selectedLinearElement,s=n.scene.getNonDeletedElementsMap(),c=hb.getElement(a,s);if(!c||l==null)return!1;if(l.length>=c.points.length){let m=e.map(d=>d.id===c.id?Rs(d,{isDeleted:!0}):d),p=fb(o,m);return{elements:m,appState:{...p,selectedLinearElement:null},captureUpdate:Ds.IMMEDIATELY}}return hb.deletePoints(c,n,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:Ds.IMMEDIATELY}}let{elements:r,appState:i}=TS(e,o,n);return xS(r,r.filter(a=>a.isDeleted)),i=fb(i,r),{elements:r,appState:{...i,activeTool:ES(o,{type:n.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:ve(np(e),o)?Ds.IMMEDIATELY:Ds.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===op.BACKSPACE||e.key===op.DELETE)&&!e[op.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=je()==="mobile";return SS(V,{type:"button",icon:Yo,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),disabled:!ve(np(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?bS:{}}})}});import{KEYS as qr,CODES as Jr,isDarwin as Ns}from"@excalidraw/common";import{moveOneLeft as CS,moveOneRight as kS,moveAllLeft as MS,moveAllRight as PS}from"@excalidraw/element";import{CaptureUpdateAction as Bs}from"@excalidraw/element";import{isDarwin as bb}from"@excalidraw/common";var A=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,bb?g("keys.option"):g("keys.alt")).replace(/\bShift\b/i,g("keys.shift")).replace(/\b(Enter|Return)\b/i,g("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,bb?g("keys.cmd"):g("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,g("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,g("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,g("keys.delete"));import{jsx as Fs}from"react/jsx-runtime";var ip=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Bm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:CS(e,o,n.scene),appState:o,captureUpdate:Bs.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[qr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Jr.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Fs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${A("CtrlOrCmd+[")}`,children:Bm})}),ap=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Nm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:kS(e,o,n.scene),appState:o,captureUpdate:Bs.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[qr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Jr.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Fs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${A("CtrlOrCmd+]")}`,children:Nm})}),lp=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Om,trackEvent:{category:"element"},perform:(e,o)=>({elements:MS(e,o),appState:o,captureUpdate:Bs.IMMEDIATELY}),keyTest:e=>Ns?e[qr.CTRL_OR_CMD]&&e.altKey&&e.code===Jr.BRACKET_LEFT:e[qr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Jr.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Fs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${Ns?A("CtrlOrCmd+Alt+["):A("CtrlOrCmd+Shift+[")}`,children:Om})}),sp=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Fm,trackEvent:{category:"element"},perform:(e,o)=>({elements:PS(e,o),appState:o,captureUpdate:Bs.IMMEDIATELY}),keyTest:e=>Ns?e[qr.CTRL_OR_CMD]&&e.altKey&&e.code===Jr.BRACKET_RIGHT:e[qr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Jr.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Fs("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${Ns?A("CtrlOrCmd+Alt+]"):A("CtrlOrCmd+Shift+]")}`,children:Fm})});import{getNonDeletedElements as LS}from"@excalidraw/element";import{LinearElementEditor as AS}from"@excalidraw/element";import{isLinearElement as _S,isTextElement as DS}from"@excalidraw/element";import{arrayToMap as RS,KEYS as Eb}from"@excalidraw/common";import{selectGroupsForSelectedElements as NS}from"@excalidraw/element";import{CaptureUpdateAction as BS}from"@excalidraw/element";var cp=F({name:"selectAll",label:"labels.selectAll",icon:j0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(DS(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...NS({editingGroupId:null,selectedElementIds:r},LS(e),o,n),selectedLinearElement:Object.keys(r).length===1&&_S(e[0])?new AS(e[0],RS(e)):null},captureUpdate:BS.IMMEDIATELY}},keyTest:e=>e[Eb.CTRL_OR_CMD]&&e.key===Eb.A});import{DEFAULT_GRID_SIZE as xb,KEYS as yb,MOBILE_ACTION_BUTTON_BG as FS,arrayToMap as wb}from"@excalidraw/common";import{getNonDeletedElements as vb}from"@excalidraw/element";import{LinearElementEditor as OS}from"@excalidraw/element";import{getSelectedElements as zS,getSelectionStateForElements as HS}from"@excalidraw/element";import{syncMovedIndices as GS}from"@excalidraw/element";import{duplicateElements as US}from"@excalidraw/element";import{CaptureUpdateAction as Ib}from"@excalidraw/element";import{jsx as WS}from"react/jsx-runtime";var dp=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:ba,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=OS.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:a,captureUpdate:Ib.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=US({type:"in-place",elements:e,idsOfElementsToDuplicate:wb(zS(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+xb/2,y:a.y+xb/2,frameId:s??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:GS(i,wb(r)),appState:{...o,...HS(r,vb(i),o)},captureUpdate:Ib.IMMEDIATELY}},keyTest:e=>e[yb.CTRL_OR_CMD]&&e.key===yb.D,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=je()==="mobile";return WS(V,{type:"button",icon:ba,title:`${g("labels.duplicateSelection")} \u2014 ${A("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),disabled:!ve(vb(e),o),style:{...r&&o.openPopup!=="compactOtherProperties"?FS:{}}})}});import{pointFrom as V4}from"@excalidraw/math";import{useEffect as _p,useMemo as X4,useRef as Dp,useState as K4}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Z4,DEFAULT_ELEMENT_BACKGROUND_PICKS as $4,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as j4,DEFAULT_ELEMENT_STROKE_PICKS as q4,ARROW_TYPE as Xt,DEFAULT_FONT_FAMILY as J4,DEFAULT_FONT_SIZE as Q4,FONT_FAMILY as e6,ROUNDNESS as oc,STROKE_WIDTH as Rp,VERTICAL_ALIGN as ec,KEYS as di,randomInteger as t6,arrayToMap as Bp,getFontFamilyString as o6,getLineHeight as n6,isTransparent as r6,reduceToCommonValue as i6,invariant as Fp,FONT_SIZES as tc}from"@excalidraw/common";import{canBecomePolygon as a6,getNonDeletedElements as pE}from"@excalidraw/element";import{bindBindingElement as sE,calculateFixedPointForElbowArrowBinding as cE,updateBoundElements as l6}from"@excalidraw/element";import{LinearElementEditor as or}from"@excalidraw/element";import{newElementWith as Xe}from"@excalidraw/element";import{getBoundTextElement as vn,redrawTextBoundingBox as Fa}from"@excalidraw/element";import{isArrowElement as nc,isBoundToContainer as s6,isElbowArrow as uE,isLinearElement as Np,isLineElement as dE,isTextElement as It,isUsingAdaptiveRadius as c6}from"@excalidraw/element";import{hasStrokeColor as d6}from"@excalidraw/element";import{updateElbowArrowPoints as m6,CaptureUpdateAction as Ke,toggleLinePolygonState as p6}from"@excalidraw/element";import{deriveStylesPanelMode as u6}from"@excalidraw/common";import{isDevEnv as YS}from"@excalidraw/common";var VS=new Set(["command_palette","export"]),le=(e,o,t,n)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!VS.has(e)||YS())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:n}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:n})}catch(r){console.error("error during analytics",r)}};import $S from"clsx";import XS from"clsx";import{forwardRef as KS}from"react";import{jsx as ZS}from"react/jsx-runtime";var Qr=KS((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:a,icon:l,onClick:s}=e;return ZS("button",{type:"button",ref:o,title:t,"data-testid":r,className:XS(n,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as qS,jsx as mp,jsxs as jS}from"react/jsx-runtime";var Wt=e=>mp(qS,{children:e.options.map(o=>e.type==="button"?mp(Qr,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):jS("label",{className:$S({active:e.value===o.value}),title:o.text,children:[mp("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as Xs from"@radix-ui/react-popover";import Wb from"clsx";import{useRef as Yb,useEffect as QC}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as Gb,COLOR_PALETTE as Vb,isColorDark as Ub,isWritableElement as e4}from"@excalidraw/common";import{jsx as JS}from"react/jsx-runtime";var Os=()=>JS("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as nC,useRef as rC}from"react";import{createPortal as iC}from"react-dom";import{EVENT as fn,KEYS as aC,rgbToHex as lC}from"@excalidraw/common";import Tb from"react";var pp=Tb.createContext(null),Te=()=>Tb.useContext(pp);import{useState as QS,useLayoutEffect as Sb}from"react";import{THEME as eC}from"@excalidraw/common";var zs=e=>{let[o,t]=QS(null),n=de(),{theme:r}=Te(),{container:i}=ke();return Sb(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",n.formFactor==="phone"),o.classList.toggle("theme--dark",r===eC.DARK))},[o,r,n.formFactor,e?.className]),Sb(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as tC}from"react";import{EVENT as Hs}from"@excalidraw/common";function ei(e,o,t){tC(()=>{function n(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(Hs.POINTER_DOWN,n),document.addEventListener(Hs.TOUCH_START,n),()=>{document.removeEventListener(Hs.POINTER_DOWN,n),document.removeEventListener(Hs.TOUCH_START,n)}},[e,o,t])}import{useRef as oC}from"react";var gn=e=>{let o=oC(e);return Object.assign(o.current,e),o.current};import{jsx as sC}from"react/jsx-runtime";var bn=Se(null),Cb=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=zs({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Te(),a=En(),l=qe(),s=q(a,i),c=gn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=ke();nC(()=>{let d=p.current;if(!d||!l.canvas||!r)return;let h=!1,f=l.canvas.getContext("2d"),b=({clientX:C,clientY:P})=>{let k=f.getImageData((C-i.offsetLeft)*window.devicePixelRatio,(P-i.offsetTop)*window.devicePixelRatio,1,1).data;return lC(k[0],k[1],k[2])},E=({clientX:C,clientY:P,altKey:k})=>{d.style.top=`${P+20}px`,d.style.left=`${C+20}px`;let N=b({clientX:C,clientY:P});h&&c.onChange(n,N,c.selectedElements,{altKey:k}),d.style.background=N},w=()=>{c.onCancel()},y=(C,P)=>{c.onSelect(C,P)},x=C=>{h=!0,C.stopImmediatePropagation()},v=C=>{h=!1,m?.focus(),C.stopImmediatePropagation(),C.preventDefault(),y(b(C),C)},I=C=>{C.key===aC.ESCAPE&&(C.preventDefault(),C.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),E({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(fn.KEYDOWN,I),r.addEventListener(fn.POINTER_DOWN,x),r.addEventListener(fn.POINTER_UP,v),window.addEventListener("pointermove",E,{passive:!0}),window.addEventListener(fn.BLUR,w),()=>{h=!1,r.removeEventListener(fn.KEYDOWN,I),r.removeEventListener(fn.POINTER_DOWN,x),r.removeEventListener(fn.POINTER_UP,v),window.removeEventListener("pointermove",E),window.removeEventListener(fn.BLUR,w)}},[c,l.canvas,r,n,m,i.offsetLeft,i.offsetTop]);let p=rC(null);return ei(p,()=>{e()},d=>!!d.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?iC(sC("div",{ref:p,className:"excalidraw-eye-dropper-preview"}),r):null};import*as ti from"@radix-ui/react-popover";import pC from"clsx";import uC from"react";import{isInteractive as hC}from"@excalidraw/common";import cC from"react";import dC from"clsx";import{jsx as mC}from"react/jsx-runtime";var ze=cC.forwardRef(({children:e,padding:o,className:t,style:n},r)=>mC("div",{className:dC("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as up,jsxs as gC}from"react/jsx-runtime";var Vo=uC.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s,preventAutoFocusOnTouch:c=!1},m)=>{let p=de(),d=p.formFactor==="phone"&&!p.isLandscape;return up(ti.Portal,{container:o,children:gC(ti.Content,{ref:m,className:pC("focus-visible-none",e),"data-prevent-outside-click":!0,side:d?"bottom":"right",align:d?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:o??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:p.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onOpenAutoFocus:h=>{c&&p.isTouchScreen&&h.preventDefault()},onCloseAutoFocus:h=>{h.stopPropagation(),h.preventDefault(),o&&!hC(document.activeElement)&&o.focus(),r()},children:[up(ze,{padding:3,style:n,children:t}),up(ti.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 fC,useCallback as hp}from"react";var Gs=()=>document.querySelector(".excalidraw-wysiwyg"),Us=()=>{let e=Gs();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Ca=e=>{setTimeout(()=>{let o=Gs();o&&(o.focus(),e&&(o.selectionStart=e.start,o.selectionEnd=e.end))},0)},ka=(e,o,t,n)=>{o&&n&&n();let r=o&&t?Us():null;e(),o&&t&&Ca(r)},kb=()=>{let[e,o]=fC(null),t=hp(()=>{let i=Us();o(i)},[]),n=hp(()=>{setTimeout(()=>{let i=Gs();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,o(null)))},0)},[e]),r=hp(()=>{o(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:n,clearSavedPosition:r,hasSavedPosition:!!e}},Mb=(e=100)=>{let o=Gs();if(o){let t=o.onblur;o.onblur=null,setTimeout(()=>{o.onblur=t},e)}};import EC from"clsx";import{useCallback as xC,useEffect as fp,useRef as Lb,useState as yC}from"react";import{KEYS as bp,normalizeInputColor as wC}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as bC}from"@excalidraw/common";var xn=({palette:e,color:o})=>{if(!o)return null;for(let[t,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(o);if(r>-1)return{colorName:t,shade:r}}else if(n===o)return{colorName:t,shade:null};return null},Ma=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),gp=({color:e,palette:o})=>!Object.values(o).flat().includes(e),Pb=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[n[o]];return gp({color:l,palette:t})}),i=new Map;return r.forEach(a=>{let l=a[n[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,bC)},Yt=Se(null);import{Fragment as vC,jsx as Ws,jsxs as Ab}from"react/jsx-runtime";var _b=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=de(),[a,l]=yC(e),[s,c]=ue(Yt);fp(()=>{l(e)},[e]);let m=xC(b=>{let E=b.toLowerCase(),w=wC(E);w&&o(w),l(E)},[o]),p=Lb(null),d=Lb(null);fp(()=>{p.current&&p.current.focus()},[s]);let[h,f]=ue(bn);return fp(()=>()=>{f(null)},[f]),Ab("div",{className:"color-picker__input-label",children:[Ws("div",{className:"color-picker__input-hash",children:"#"}),Ws("input",{ref:s==="hex"?p:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{m(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:b=>{b.key!==bp.TAB&&(b.key===bp.ESCAPE&&d.current?.focus(),b.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&Ab(vC,{children:[Ws("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Ws("div",{ref:d,className:EC("excalidraw-eye-dropper-trigger",{selected:h}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:E=>o(E),colorPickerType:n}),title:`${g("labels.eyeDropper")} \u2014 ${bp.I.toLocaleUpperCase()} or ${A("Alt")} `,children:W0})]})]})};import wp,{useEffect as vp,useImperativeHandle as UC,useState as WC}from"react";import{EVENT as Ob}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as YC,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as VC,KEYS as XC}from"@excalidraw/common";import CC from"clsx";import{useEffect as kC,useRef as MC}from"react";import{isColorDark as IC}from"@excalidraw/common";import{jsxs as SC}from"react/jsx-runtime";var TC=({color:e,keyLabel:o,isShade:t=!1})=>SC("div",{className:"color-picker__button__hotkey-label",style:{color:IC(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),oi=TC;import{jsx as Ep,jsxs as PC}from"react/jsx-runtime";var Db=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=ue(Yt),a=MC(null);return kC(()=>{a.current&&a.current.focus()},[o,r]),Ep("div",{className:"color-picker-content--default",children:e.map((l,s)=>PC("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:CC("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":n,style:{"--swatch-color":l},children:[Ep("div",{className:"color-picker__button-outline"}),Ep(oi,{color:l,keyLabel:s+1})]},s))})};import LC from"clsx";import{useEffect as AC,useRef as _C}from"react";import{jsx as xp,jsxs as RC}from"react/jsx-runtime";var DC=({palette:e,color:o,onChange:t,activeShade:n,showHotKey:r=!0})=>{let i=xn({color:o,palette:e}),[a,l]=ue(Yt),s=_C(null);return AC(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),xp("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],p)=>{let d=(Array.isArray(m)?m[n]:m)||"transparent",h=Ma[p],f=g(`colors.${c.replace(/\d+/,"")}`,null,"");return RC("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:LC("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),l("baseColors")},title:`${f}${d.startsWith("#")?` ${d}`:""} \u2014 ${h}`,"aria-label":`${f} \u2014 ${h}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${c}`,children:[xp("div",{className:"color-picker__button-outline"}),r&&xp(oi,{color:d,keyLabel:h})]},c)})})},Rb=DC;import{jsx as BC}from"react/jsx-runtime";var NC=({children:e})=>BC("div",{className:"color-picker__heading",children:e}),ni=NC;import FC from"clsx";import{useEffect as OC,useRef as zC}from"react";import{jsx as Pa,jsxs as Nb}from"react/jsx-runtime";var Bb=({color:e,onChange:o,palette:t,showHotKey:n})=>{let r=xn({color:e||"transparent",palette:t}),[i,a]=ue(Yt),l=zC(null);if(OC(()=>{l.current&&i==="shades"&&l.current.focus()},[r,i]),r){let{colorName:s,shade:c}=r,m=t[s];if(Array.isArray(m))return Pa("div",{className:"color-picker-content--default shades",children:m.map((p,d)=>Nb("button",{ref:d===c&&i==="shades"?l:void 0,tabIndex:-1,type:"button",className:FC("color-picker__button color-picker__button--large has-outline",{active:d===c}),"aria-label":"Shade",title:`${s} - ${d+1}`,style:p?{"--swatch-color":p}:void 0,onClick:()=>{o(p),a("shades")},children:[Pa("div",{className:"color-picker__button-outline"}),n&&Pa(oi,{color:p,keyLabel:d+1,isShade:!0})]},d))})}return Nb("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Pa("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Pa("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:g("colorPicker.noShades")})]})};import{COLORS_PER_ROW as ri,COLOR_PALETTE as HC,KEYS as La}from"@excalidraw/common";var yp=(e,o,t)=>{let n=Math.ceil(t/ri);switch(o=o??-1,e){case"ArrowLeft":{let r=o-1;return r<0?t-1:r}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let r=o+ri;return r>=t?o%ri:r}case"ArrowUp":{let r=o-ri,i=r<0?ri*n+r:r;return i>=t?void 0:i}}},GC=({e,colorObj:o,onChange:t,palette:n,customColors:r,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(n[o.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(Ma.includes(e.key)){let l=Ma.indexOf(e.key),s=Object.keys(n)[l],c=n[s],m=Array.isArray(c)?c[a]:c;return t(m),i("baseColors"),!0}return!1},Fb=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[La.CTRL_OR_CMD])return!1;if(e.key===La.ESCAPE)return m(e),!0;if(e.key===La.ALT)return c(!0),!0;if(e.key===La.I)return c(),!0;let p=xn({color:n,palette:t});if(e.key===La.TAB){let d={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},h=Object.entries(d).reduce((y,[x,v])=>(v&&y.push(x),y),[]),f=h.indexOf(o),b=e.shiftKey?-1:1,E=f+b>h.length-1?0:f+b<0?h.length-1:f+b,w=h[E];return w&&a(w),w==="custom"?r(i[0]):w==="baseColors"&&(Object.entries(t).find(([x,v])=>Array.isArray(v)?v.includes(n):v===n?x:null)||r(HC.black)),e.preventDefault(),e.stopPropagation(),!0}if(GC({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&p){let{shade:d}=p,h=yp(e.key,d,ri);if(h!==void 0)return r(t[p.colorName][h]),!0}if(o==="baseColors"&&p){let{colorName:d}=p,h=Object.keys(t),f=h.indexOf(d),b=yp(e.key,f,h.length);if(b!==void 0){let E=h[b],w=t[E];return r(Array.isArray(w)?w[s]:w),!0}}if(o==="custom"){let d=n!=null?i.indexOf(n):0,h=yp(e.key,d,i.length);if(h!==void 0){let f=i[h];return r(f),!0}}return!1};import{jsx as yn,jsxs as Ys}from"react/jsx-runtime";var zb=wp.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:a,showTitle:l,onEyeDropperToggle:s,onEscape:c,showHotKey:m=!0},p)=>{let d=l?t==="elementStroke"?g("labels.stroke"):t==="elementBackground"?g("labels.background"):null:null,[h]=wp.useState(()=>t==="canvasBackground"?[]:Pb(n,t,r)),[f,b]=ue(Yt),E=xn({color:e,palette:r});vp(()=>{if(!f){let v=!!e&&gp({color:e,palette:r}),I=v&&!h.includes(e);b(I?null:v?"custom":E?.shade!=null?"shades":"baseColors")}},[f,e,r,b,E,h]);let[w,y]=WC(E?.shade??(t==="elementBackground"?YC:VC));vp(()=>{E?.shade!=null&&y(E.shade);let v=I=>{I.key===XC.ALT&&s(!1)};return document.addEventListener(Ob.KEYUP,v,{capture:!0}),()=>{document.removeEventListener(Ob.KEYUP,v,{capture:!0})}},[E,s]);let x=wp.useRef(null);return UC(p,()=>x.current),vp(()=>{x?.current?.focus()},[]),yn("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:Ys("div",{ref:x,onKeyDown:v=>{Fb({event:v,activeColorPickerSection:f,palette:r,color:e,onChange:o,onEyeDropperToggle:s,customColors:h,setActiveColorPickerSection:b,updateData:i,activeShade:w,onEscape:c})&&(v.preventDefault(),v.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[d&&yn("div",{className:"color-picker__title",children:d}),!!h.length&&Ys("div",{children:[yn(ni,{children:g("colorPicker.mostUsedCustomColors")}),yn(Db,{colors:h,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),Ys("div",{children:[yn(ni,{children:g("colorPicker.colors")}),yn(Rb,{color:e,palette:r,onChange:o,activeShade:w,showHotKey:m})]}),Ys("div",{children:[yn(ni,{children:g("colorPicker.shades")}),yn(Bb,{color:e,onChange:o,palette:r,showHotKey:m})]}),a]})})});import KC from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as ZC,DEFAULT_CANVAS_BACKGROUND_PICKS as $C,DEFAULT_ELEMENT_BACKGROUND_PICKS as jC,DEFAULT_ELEMENT_STROKE_PICKS as qC,isColorDark as JC}from"@excalidraw/common";import{jsx as Ip}from"react/jsx-runtime";var Hb=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=qC),o==="elementBackground"&&(r=jC),o==="canvasBackground"&&(r=$C),n&&(r=n),r?Ip("div",{className:"color-picker__top-picks",children:r.map(i=>Ip("button",{className:KC("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!JC(i,ZC)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Ip("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Vt,jsxs as Vs}from"react/jsx-runtime";var t4=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=Vb,updateData:a,getOpenPopup:l,appState:s})=>{let{container:c}=ke(),m=je(),p=m!=="full",d=m==="mobile",[,h]=ue(Yt),[f,b]=ue(bn),E=Vs("div",{children:[Vt(ni,{children:g("colorPicker.hexCode")}),Vt(_b,{color:o||"",label:n,onChange:x=>{t(x)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),w=Yb(null),y=()=>{w.current?.focus()};return Vt(Vo,{container:c,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!s.editingTextElement,onFocusOutside:x=>{e4(x.target)||y(),x.preventDefault()},onPointerDownOutside:x=>{f&&x.preventDefault()},onClose:()=>{l()===e&&a({openPopup:null}),h(null),s.editingTextElement&&setTimeout(()=>{let x=document.querySelector(".excalidraw-wysiwyg");x&&x.focus()},0)},children:i?Vt(zb,{ref:w,palette:i,color:o,onChange:x=>{let v=s.editingTextElement?Us():null;t(x),s.editingTextElement&&v&&Ca(v)},onEyeDropperToggle:x=>{b(v=>x?(v=v||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},v.keepOpenOnAlt=!0,v):x===!1||v?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:x=>{f?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!d,children:E}):E})},o4=({label:e,color:o,type:t,mode:n="background",onToggle:r,editingTextElement:i})=>{let a=je(),l=a!=="full",s=a==="mobile",c=m=>{m.preventDefault(),m.stopPropagation(),i&&Mb(),r()};return Vs(Xs.Trigger,{type:"button",className:Wb("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!Ub(o,Gb),"compact-sizing":l,"mobile-border":s}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),"data-openpopup":t,onClick:c,children:[Vt("div",{className:"color-picker__button-outline",children:!o&&K1}),l&&o&&n==="stroke"&&Vt("div",{className:"color-picker__button-background",children:Vt("span",{style:{color:o&&Ub(o,Gb)?"#fff":"#111"},children:db})})]})},Aa=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=Vb,topPicks:a,updateData:l,appState:s})=>{let c=Yb(s.openPopup);QC(()=>{c.current=s.openPopup},[s.openPopup]);let p=je()!=="full";return Vt("div",{children:Vs("div",{role:"dialog","aria-modal":"true",className:Wb("color-picker-container",{"color-picker-container--no-top-picks":p}),children:[!p&&Vt(Hb,{activeColor:o,onChange:t,type:e,topPicks:a}),!p&&Vt(Os,{}),Vs(Xs.Root,{open:s.openPopup===e,onOpenChange:d=>{d&&l({openPopup:e})},children:[Vt(o4,{color:o,label:n,type:e,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!s.editingTextElement,onToggle:()=>{s.openPopup===e?l({openPopup:null}):s.openPopup?l({openPopup:e}):l({openPopup:e})}}),s.openPopup===e&&Vt(t4,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:l,getOpenPopup:()=>c.current,appState:s})]})]})})};import*as eE from"@radix-ui/react-popover";import _4 from"clsx";import D4,{useCallback as R4,useMemo as N4}from"react";import{FONT_FAMILY as Mp}from"@excalidraw/common";import v4,{useMemo as wn,useState as I4,useRef as T4,useEffect as S4,useCallback as $b}from"react";import{arrayToList as C4,debounce as k4,FONT_FAMILY as er,getFontFamilyString as M4}from"@excalidraw/common";import n4 from"clsx";import r4 from"react";import{jsx as i4,jsxs as a4}from"react/jsx-runtime";var Ks=r4.forwardRef(({className:e,placeholder:o,onChange:t},n)=>a4("div",{className:n4("QuickSearch__wrapper",e),children:[_t,i4("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import l4 from"clsx";import{Children as s4}from"react";import{jsx as Xb}from"react/jsx-runtime";var Zs=({className:e,placeholder:o,children:t})=>{let n=!s4.count(t);return Xb("div",{className:l4("ScrollableList__wrapper",e),role:"menu",children:n?Xb("div",{className:"empty",children:o}):t})};import{jsx as c4,jsxs as d4}from"react/jsx-runtime";var Kb=({children:e,className:o="",style:t,title:n})=>d4("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&c4("p",{className:"dropdown-menu-group-title",children:n}),e]}),_a=Kb;Kb.displayName="DropdownMenuGroup";import{useEffect as x4,useRef as y4}from"react";import{THEME as w4}from"@excalidraw/common";import{jsx as m4}from"react/jsx-runtime";var Da=({children:e,...o})=>m4("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as u4,jsx as Ra,jsxs as h4}from"react/jsx-runtime";var p4=({textStyle:e,icon:o,shortcut:t,children:n,badge:r})=>{let i=de();return h4(u4,{children:[o&&Ra("div",{className:"dropdown-menu-item__icon",children:o}),Ra("div",{style:e,className:"dropdown-menu-item__text",children:Ra(Da,{children:n})}),r&&Ra("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&Ra("div",{className:"dropdown-menu-item__shortcut",children:t})]})},$s=p4;import g4,{useContext as f4}from"react";import{EVENT as b4,composeEventHandlers as E4}from"@excalidraw/common";var Tp=g4.createContext({}),js=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
|
|
2
|
+
${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),qs=(e,o)=>{let t=f4(Tp);return E4(e,n=>{let r=new CustomEvent(b4.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(r),r.defaultPrevented||t.onSelect?.(r)})};import{jsx as Sp}from"react/jsx-runtime";var Cp=({icon:e,value:o,order:t,children:n,shortcut:r,className:i,hovered:a,selected:l,textStyle:s,onSelect:c,onClick:m,badge:p,...d})=>{let h=qs(m,c),f=y4(null);return x4(()=>{a&&(t===0?f.current?.scrollIntoView({block:"end"}):f.current?.scrollIntoView({block:"nearest"}))},[a,t]),Sp("button",{...d,ref:f,value:o,onClick:h,className:js(i,l,a),title:d.title??d["aria-label"],children:Sp($s,{textStyle:s,icon:e,shortcut:r,badge:p,children:n})})};Cp.displayName="DropdownMenuItem";var ii={GREEN:"green",RED:"red",BLUE:"blue"},Js=({type:e=ii.BLUE,children:o})=>{let{theme:t}=vo(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===w4.LIGHT?"1.5px solid white":"none"};switch(e){case ii.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ii.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case ii.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Sp("div",{className:"DropDownMenuItemBadge",style:n,children:o})};Js.displayName="DropdownMenuItemBadge";Cp.Badge=Js;var vt=Cp;import{KEYS as ai}from"@excalidraw/common";var Zb=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[ai.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===ai.F)return o.current?.focus(),!0;if(e.key===ai.ESCAPE)return r(),!0;if(e.key===ai.ENTER)return t?.value&&i(t.value),!0;if(e.key===ai.ARROW_DOWN)return t?.next?a(t.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===ai.ARROW_UP)return t?.prev?a(t.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as li,jsxs as L4}from"react/jsx-runtime";var P4=e=>{switch(e){case er.Excalifont:case er.Virgil:return pn;case er.Nunito:case er.Helvetica:return wa;case er["Lilita One"]:return A0;case er["Comic Shanns"]:case er.Cascadia:return Ss;default:return wa}},jb=v4.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=ke(),s=qe(),{fonts:c}=s,{showDeprecatedFonts:m}=Io(),p=je(),[d,h]=I4(""),f=T4(null),b=wn(()=>Array.from(cn.registered.entries()).filter(([L,{metadata:B}])=>!B.private&&!B.fallback).map(([L,{metadata:B,fontFaces:G}])=>{let j={value:L,icon:P4(L),text:G[0]?.fontFace?.family??"Unknown"};return B.deprecated&&Object.assign(j,{deprecated:B.deprecated,badge:{type:ii.RED,placeholder:g("fontList.badge.old")}}),j}).sort((L,B)=>L.text.toLowerCase()>B.text.toLowerCase()?1:-1),[]),E=wn(()=>new Set(c.getSceneFamilies()),[e]),w=wn(()=>b.filter(L=>E.has(L.value)),[b,E]),y=wn(()=>b.filter(L=>!E.has(L.value)&&(m||!L.deprecated)),[b,E,m]),x=wn(()=>C4([...w,...y].filter(L=>L.text?.toLowerCase().includes(d))),[w,y,d]),v=wn(()=>{let L;return o?L=x.find(B=>B.value===o):e&&(L=x.find(B=>B.value===e)),!L&&d&&(x[0]?.value?n(x[0].value):r()),L},[o,e,d,x,n,r]),I=$b(L=>{let B=null;if(s.state.editingTextElement){let G=document.querySelector(".excalidraw-wysiwyg");G&&(B={start:G.selectionStart,end:G.selectionEnd})}t(L),s.state.editingTextElement&&B&&setTimeout(()=>{let G=document.querySelector(".excalidraw-wysiwyg");G&&B&&(G.focus(),G.selectionStart=B.start,G.selectionEnd=B.end)},0)},[t,s.state.editingTextElement]),C=$b(L=>{Zb({event:L,inputRef:f,hoveredFont:v,filteredFonts:x,onSelect:I,onHover:n,onClose:a})&&(L.preventDefault(),L.stopPropagation())},[v,x,I,n,a]);S4(()=>(i(),()=>{a()}),[]);let P=wn(()=>x.filter(L=>E.has(L.value)),[x,E]),k=wn(()=>x.filter(L=>!E.has(L.value)),[x,E]),N=(L,B)=>li(vt,{icon:L.icon,value:L.value,order:B,textStyle:{fontFamily:M4({fontFamily:L.value})},hovered:L.value===v?.value,selected:L.value===e,tabIndex:L.value===e?0:-1,onClick:G=>{I(Number(G.currentTarget.value))},onMouseMove:()=>{v?.value!==L.value&&n(L.value)},badge:L.badge&&li(Js,{type:L.badge.type,children:L.badge.placeholder}),children:L.text},L.value),_=[];return P.length&&_.push(li(_a,{title:g("fontList.sceneFonts"),children:P.map(N)},"group_1")),k.length&&_.push(li(_a,{title:g("fontList.availableFonts"),children:k.map((L,B)=>N(L,B+P.length))},"group_2")),L4(Vo,{className:"properties-content",container:l,style:{width:"15rem"},onClose:()=>{a(),s.state.editingTextElement&&setTimeout(()=>{let L=document.querySelector(".excalidraw-wysiwyg");L&&L.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!s.state.editingTextElement,children:[p==="full"&&li(Ks,{ref:f,placeholder:g("quickSearch.placeholder"),onChange:k4(h,20)}),li(Zs,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:_.length?_:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as qb from"@radix-ui/react-popover";import{MOBILE_ACTION_BUTTON_BG as A4}from"@excalidraw/common";import{jsx as kp}from"react/jsx-runtime";var Jb=({selectedFontFamily:e,isOpened:o=!1,compactMode:t=!1})=>{let n=he(),r=t?{...A4,width:"2rem",height:"2rem"}:{};return kp(qb.Trigger,{asChild:!0,children:kp("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:kp(Qr,{standalone:!0,icon:un,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{n(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as Na,jsxs as Qb}from"react/jsx-runtime";var tE=[{value:Mp.Excalifont,icon:pn,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Mp.Nunito,icon:wa,text:g("labels.normal"),testId:"font-family-normal"},{value:Mp["Comic Shanns"],icon:Ss,text:g("labels.code"),testId:"font-family-code"}],HZ=new Set(tE.map(e=>e.value));var oE=D4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:a,compactMode:l=!1})=>{let s=N4(()=>tE,[]),c=R4(m=>{m&&n(m)},[n]);return Qb("div",{role:"dialog","aria-modal":"true",className:_4("FontPicker__container",{"FontPicker__container--compact":l}),children:[!l&&Na("div",{className:"buttonList",children:Na(Wt,{type:"button",options:s,value:o,onClick:c})}),!l&&Na(Os,{}),Qb(eE.Root,{open:e,onOpenChange:a,children:[Na(Jb,{selectedFontFamily:o,isOpened:e,compactMode:l}),e&&Na(jb,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as ci from"@radix-ui/react-popover";import z4 from"clsx";import Qs,{useEffect as H4}from"react";import{isArrowKey as G4,KEYS as Xo}from"@excalidraw/common";import{jsx as B4}from"react/jsx-runtime";var si=({className:e,icon:o,size:t="1em"})=>B4("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:o});import{Fragment as O4,jsx as nE,jsxs as rE}from"react/jsx-runtime";var F4=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>rE(O4,{children:[rE("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&nE(si,{icon:o?lb:Ps})]}),o&&nE("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),Ba=F4;import{jsx as tr,jsxs as Pp}from"react/jsx-runtime";var U4=Se(!1);function W4({options:e,value:o,label:t,onChange:n,onClose:r,numberOfOptionsToAlwaysShow:i=e.length}){let a=de(),{container:l}=ke(),s=b=>{let E=e.find(w=>w.keyBinding===b.key.toLowerCase());if(!(b.metaKey||b.altKey||b.ctrlKey)&&E)n(E.value),b.preventDefault();else if(b.key===Xo.TAB){let w=e.findIndex(x=>x.value===o),y=b.shiftKey?(e.length+w-1)%e.length:(w+1)%e.length;n(e[y].value)}else if(G4(b.key)){let w=Uo().rtl,y=e.findIndex(x=>x.value===o);if(y!==-1){let x=e.length,v=y;switch(b.key){case(w?Xo.ARROW_LEFT:Xo.ARROW_RIGHT):v=(y+1)%x;break;case(w?Xo.ARROW_RIGHT:Xo.ARROW_LEFT):v=(x+y-1)%x;break;case Xo.ARROW_DOWN:{v=(y+(i??1))%x;break}case Xo.ARROW_UP:{v=(x+y-(i??1))%x;break}}n(e[v].value)}b.preventDefault()}else(b.key===Xo.ESCAPE||b.key===Xo.ENTER)&&(b.preventDefault(),r());b.nativeEvent.stopImmediatePropagation(),b.stopPropagation()},[c,m]=ue(U4),p=Qs.useMemo(()=>e.slice(0,i),[e,i]),d=Qs.useMemo(()=>e.slice(i),[e,i]);H4(()=>{p.some(b=>b.value===o)||m(!0)},[o,p,m]);let h=b=>tr("div",{className:"picker-content",children:b.map((E,w)=>Pp("button",{type:"button",className:z4("picker-option",{active:o===E.value}),onClick:y=>{n(E.value)},title:`${E.text} ${E.keyBinding&&`\u2014 ${E.keyBinding.toUpperCase()}`}`,"aria-label":E.text||"none","aria-keyshortcuts":E.keyBinding||void 0,ref:y=>{o===E.value&&setTimeout(()=>{y?.focus()},0)},children:[E.icon,E.keyBinding&&tr("span",{className:"picker-keybinding",children:E.keyBinding})]},E.text))}),f=a.formFactor==="phone";return tr(ci.Content,{side:f?"right":"bottom",align:"start",sideOffset:f?8:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:s,collisionBoundary:l??void 0,children:Pp("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[h(p),d.length>0&&tr(Ba,{label:g("labels.more_options"),open:c,openTrigger:()=>{m(b=>!b)},className:"picker-collapsible",children:h(d)})]})})}function Lp({value:e,label:o,options:t,onChange:n,group:r="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Qs.useState(!1),s=Qs.useRef(null);return tr("div",{children:Pp(ci.Root,{open:a,onOpenChange:c=>l(c),children:[tr(ci.Trigger,{name:r,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(c=>c.value===e)?.icon}),a&&tr(W4,{options:t,value:e,label:o,onChange:n,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import iE,{useEffect as Y4}from"react";import{jsx as Ap,jsxs as aE}from"react/jsx-runtime";var lE=({updateData:e,app:o,testId:t})=>{let n=iE.useRef(null),r=iE.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),c=i.reduce((m,p)=>(m!=null&&m!==p.opacity&&(a=!1),m==null||m>p.opacity?p.opacity:m),l?.opacity??null)??o.state.currentItemOpacity;return Y4(()=>{if(n.current&&r.current){let m=n.current,p=r.current,d=m.offsetWidth,h=15,f=c/100*(d-h)+h/2;p.style.left=`${f}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${c}%, var(--button-bg) ${c}%, var(--button-bg) 100%)`}},[c]),aE("label",{className:"control-label",children:[g("labels.opacity"),aE("div",{className:"range-wrapper",children:[Ap("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:n,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:c,className:"range-input","data-testid":t}),Ap("div",{className:"value-bubble",ref:r,children:c!==0?c:null}),Ap("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Gp,jsx as ne,jsxs as ht}from"react/jsx-runtime";var hE=.1,mi=e=>{let o=u6(e.editorInterface);return{stylesPanelMode:o,isCompact:o!=="full",isMobile:o==="mobile"}},ut=(e,o,t,n=!1)=>{let r=Bp(q(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},st=function(e,o,t,n,r){let i=o.state.editingTextElement,a=pE(e),l=null;if(i&&(l=t(i)),!l)if(ve(a,o.state)){let c=o.scene.getSelectedElements(o.state),m=n===!0?c:c.filter(p=>n(p));l=i6(m,t)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},h6=(e,o,t)=>s6(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),Op=(e,o,t,n,r)=>{let i=new Set,a=ut(e,o,l=>{if(It(l)){let s=n(l);i.add(s);let c=Xe(l,{fontSize:s});return Fa(c,t.scene.getContainerElement(l),t.scene),c=h6(l,c,t.scene),c}return l},!0);return q(e,o,{includeBoundTextElement:!0}).forEach(l=>{It(l)&&l6(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:Ke.IMMEDIATELY}},g6=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t?.currentItemStrokeColor&&{elements:ut(e,o,n=>d6(n.type)?Xe(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t?.currentItemStrokeColor?Ke.IMMEDIATELY:Ke.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=mi(n);return ht(Gp,{children:[i==="full"&&ne("h3",{"aria-hidden":"true",children:g("labels.stroke")}),ne(Aa,{topPicks:q4,palette:j4,type:"elementStroke",label:g("labels.stroke"),color:st(e,n,a=>a.strokeColor,!0,a=>a?null:o.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:o,updateData:t})]})}}),f6=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t?.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:Ke.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!r6(t.currentItemBackgroundColor)&&i.every(l=>dE(l)&&a6(l.points))){let l=Bp(i);r=e.map(s=>l.has(s.id)&&dE(s)?Xe(s,{backgroundColor:t.currentItemBackgroundColor,...p6(s,!0)}):s)}else r=ut(e,o,l=>Xe(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:Ke.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{stylesPanelMode:i}=mi(n);return ht(Gp,{children:[i==="full"&&ne("h3",{"aria-hidden":"true",children:g("labels.background")}),ne(Aa,{topPicks:$4,palette:Z4,type:"elementBackground",label:g("labels.background"),color:st(e,n,a=>a.backgroundColor,!0,a=>a?null:o.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:o,updateData:t})]})}}),b6=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(le("element","changeFillStyle",`${t} (${n.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:ut(e,o,r=>Xe(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=q(e,o),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return ht("fieldset",{children:[ne("legend",{children:g("labels.fill")}),ne("div",{className:"buttonList",children:ne(Wt,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${A("Alt-Click")})`,icon:i?o0:n0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:r0,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:i0,testId:"fill-solid"}],value:st(e,n,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),E6=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Xe(n,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[ne("legend",{children:g("labels.strokeWidth")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"stroke-width",options:[{value:Rp.thin,text:g("labels.thin"),icon:Km,testId:"strokeWidth-thin"},{value:Rp.bold,text:g("labels.bold"),icon:a0,testId:"strokeWidth-bold"},{value:Rp.extraBold,text:g("labels.extraBold"),icon:l0,testId:"strokeWidth-extraBold"}],value:st(e,n,i=>i.strokeWidth,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:o.currentItemStrokeWidth),onChange:i=>t(i)})})]})}),x6=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Xe(n,{seed:t6(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[ne("legend",{children:g("labels.sloppiness")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:d0},{value:1,text:g("labels.artist"),icon:m0},{value:2,text:g("labels.cartoonist"),icon:p0}],value:st(e,n,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:o.currentItemRoughness),onChange:i=>t(i)})})]})}),Y$=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Xe(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>ht("fieldset",{children:[ne("legend",{children:g("labels.strokeStyle")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:Km},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:s0},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:c0}],value:st(e,n,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:o.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),y6=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Xe(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>ne(lE,{updateData:o,app:e,testId:"opacity"})}),w6=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>Op(e,o,n,()=>(Fp(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=mi(n);return ht("fieldset",{children:[ne("legend",{children:g("labels.fontSize")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"font-size",options:[{value:tc.sm,text:g("labels.small"),icon:k0,testId:"fontSize-small"},{value:tc.md,text:g("labels.medium"),icon:M0,testId:"fontSize-medium"},{value:tc.lg,text:g("labels.large"),icon:P0,testId:"fontSize-large"},{value:tc.xl,text:g("labels.veryLarge"),icon:L0,testId:"fontSize-veryLarge"}],value:st(e,n,a=>{if(It(a))return a.fontSize;let l=vn(a,n.scene.getNonDeletedElementsMap());return l?l.fontSize:null},a=>It(a)||vn(a,n.scene.getNonDeletedElementsMap())!==null,a=>a?null:o.currentItemFontSize||Q4),onChange:a=>{ka(()=>t(a),i,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),zp=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Jn,trackEvent:!1,perform:(e,o,t,n)=>Op(e,o,n,r=>Math.round(1/(1+hE)*r.fontSize)),keyTest:e=>e[di.CTRL_OR_CMD]&&e.shiftKey&&(e.key===di.CHEVRON_LEFT||e.key===di.COMMA)}),Hp=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Jn,trackEvent:!1,perform:(e,o,t,n)=>Op(e,o,n,r=>Math.round(r.fontSize*(1+hE))),keyTest:e=>e[di.CTRL_OR_CMD]&&e.shiftKey&&(e.key===di.CHEVRON_RIGHT||e.key===di.PERIOD)}),v6=F({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,n)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:ut(e,o,b=>{let E=r?.get(b.id);return E?Xe(b,{...E}):b},!0),appState:{...o,...l},captureUpdate:Ke.NEVER};Fp(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=Ke.EVENTUALLY,p,d=!1;if(s)p=s,m=Ke.IMMEDIATELY;else if(c){p=c,m=Ke.EVENTUALLY;let f=q(e,o,{includeBoundTextElement:!0}).filter(b=>It(b));if(f.length>200)d=!0;else{let b=0,E=0;for(;b<f.length&&E<5e3;){let w=f[b];E+=w?.originalText.length||0,b++}E>5e3&&(d=!0)}}let h={appState:{...o,...l},captureUpdate:m};if(p&&!d){let f=new Map,b=new Set,E=!1,w=Array.from(cn.loadedFontsCache.values()),y=Object.entries(e6).find(([I,C])=>C===p)?.[0];c&&y&&w.some(I=>I.startsWith(y))&&(E=!0),Object.assign(h,{elements:ut(e,o,I=>{if(It(I)&&(I.fontFamily!==p||s)){let C=Xe(I,{fontFamily:p,lineHeight:n6(p)}),P=r?.get(I.containerId||"")||{},k=n.scene.getContainerElement(I);return a&&k&&P&&n.scene.mutateElement(k,{...P}),E||(b=new Set([...b,...Array.from(C.originalText)])),f.set(C,k),C}return I},!0)});let x=`10px ${o6({fontFamily:p})}`,v=Array.from(b.values()).join();if(E||window.document.fonts.check(x,v))for(let[I,C]of f)Fa(I,C,n.scene);else window.document.fonts.load(x,v).then(I=>{for(let[C,P]of f){let k=n.scene.getElement(C.id),N=P?n.scene.getElement(P.id):null;k&&Fa(k,N,n.scene)}n.fonts.onLoaded(I)})}return h},PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=Dp(new Map),i=Dp(null),[a,l]=K4({}),s=Dp(!0),{stylesPanelMode:c,isCompact:m}=mi(t),p=X4(()=>{let d=(h,f)=>st(h,t,b=>{if(It(b))return b.fontFamily;let E=vn(b,f);return E?E.fontFamily:null},b=>It(b)||vn(b,f)!==null,b=>b?null:o.currentItemFontFamily||J4);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?d(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&o.openPopup!=="fontFamily"?d(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return _p(()=>{i.current=p},[p]),_p(()=>{Object.keys(a).length&&(n(a),l({}))},[a]),_p(()=>(s.current=!1,()=>{s.current=!0}),[]),ht(Gp,{children:[c==="full"&&ne("legend",{children:g("labels.fontFamily")}),ne(oE,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:p,hoveredFontFamily:o.currentHoveredFontFamily,compactMode:c!=="full",onSelect:d=>{ka(()=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:d}),r.current.clear()},m,!!o.editingTextElement)},onHover:d=>{l({currentHoveredFontFamily:d,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:d=>{if(d){r.current.clear();let{editingTextElement:h}=o;if(h?.type==="text"){let f=t.scene.getElement(h.id);r.current.set(h.id,Xe(f||h,{},!0))}else{let f=q(e,o,{includeBoundTextElement:!0});for(let b of f)r.current.set(b.id,Xe(b,{},!0))}l({...a,openPopup:"fontFamily"})}else{let h={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};l({...h}),r.current.clear(),m&&o.editingTextElement&&Ca(null)}}})]})}}),I6=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:ut(e,o,r=>{if(It(r)){let i=Xe(r,{textAlign:t});return Fa(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let i=n.scene.getNonDeletedElementsMap(),{isCompact:a}=mi(n);return ht("fieldset",{children:[ne("legend",{children:g("labels.textAlign")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:_0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:D0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:R0,testId:"align-right"}],value:st(e,n,l=>{if(It(l))return l.textAlign;let s=vn(l,i);return s?s.textAlign:null},l=>It(l)||vn(l,i)!==null,l=>l?null:o.currentItemTextAlign),onChange:l=>{ka(()=>t(l),a,!!o.editingTextElement,r?.onPreventClose)}})})]})}}),T6=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:ut(e,o,r=>{if(It(r)){let i=Xe(r,{verticalAlign:t});return Fa(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,data:r})=>{let{isCompact:i}=mi(n);return ne("fieldset",{children:ne("div",{className:"buttonList",children:ne(Wt,{group:"text-align",options:[{value:ec.TOP,text:g("labels.alignTop"),icon:ne(N0,{theme:o.theme}),testId:"align-top"},{value:ec.MIDDLE,text:g("labels.centerVertically"),icon:ne(F0,{theme:o.theme}),testId:"align-middle"},{value:ec.BOTTOM,text:g("labels.alignBottom"),icon:ne(B0,{theme:o.theme}),testId:"align-bottom"}],value:st(e,n,a=>{if(It(a)&&a.containerId)return a.verticalAlign;let l=vn(a,n.scene.getNonDeletedElementsMap());return l?l.verticalAlign:null},a=>It(a)||vn(a,n.scene.getNonDeletedElementsMap())!==null,a=>a?null:ec.MIDDLE),onChange:a=>{ka(()=>t(a),i,!!o.editingTextElement,r?.onPreventClose)}})})})}}),V$=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>uE(n)?n:Xe(n,{roundness:t==="round"?{type:c6(n.type)?oc.ADAPTIVE_RADIUS:oc.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let a=Dr(pE(e),o).some(l=>l.roundness?.type===oc.LEGACY);return ht("fieldset",{children:[ne("legend",{children:g("labels.edges")}),ht("div",{className:"buttonList",children:[ne(Wt,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:u0},{value:"round",text:g("labels.round"),icon:h0}],value:st(e,n,l=>a?null:l.roundness?"round":"sharp",l=>!nc(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),r("togglePolygon")]})]})}}),mE=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:g0},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:ne(f0,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:ne(y0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:ne(w0,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:ne(b0,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ne(E0,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:ne(v0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:ne(I0,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:ne(x0,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:ne(S0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:ne(T0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:ne(C0,{flip:e}),keyBinding:"v"}],X$=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>(Fp(t,"actionChangeArrowhead: value must be defined"),{elements:ut(e,o,n=>{if(Np(n)){let{position:r,type:i}=t;if(r==="start")return Xe(n,{startArrowhead:i});if(r==="end")return Xe(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Ke.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=Uo().rtl;return ht("fieldset",{children:[ne("legend",{children:g("labels.arrowheads")}),ht("div",{className:"iconSelectList buttonList",children:[ne(Lp,{label:"arrowhead_start",options:mE(!r),value:st(e,n,i=>Np(i)&&Rr(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),ne(Lp,{label:"arrowhead_end",group:"arrowheads",options:mE(!!r),value:st(e,n,i=>Np(i)&&Rr(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),S6=F({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,o,t,n)=>!1,PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>ht("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),K$=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=ut(e,o,l=>{if(!nc(l))return l;let s=n.scene.getNonDeletedElementsMap(),c=or.getPointAtIndexGlobalCoordinates(l,0,s),m=or.getPointAtIndexGlobalCoordinates(l,-1,s),p=Xe(l,{x:t===Xt.elbow?c[0]:l.x,y:t===Xt.elbow?c[1]:l.y,roundness:t===Xt.round?{type:oc.PROPORTIONAL_RADIUS}:null,elbowed:t===Xt.elbow,angle:t===Xt.elbow?0:l.angle,points:t===Xt.elbow||l.elbowed?[or.pointFromAbsoluteCoords({...l,x:c[0],y:c[1],angle:0},c,s),or.pointFromAbsoluteCoords({...l,x:c[0],y:c[1],angle:0},m,s)]:l.points});if(uE(p)){p.fixedSegments=null;let d=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let h=or.getPointAtIndexGlobalCoordinates(p,0,d),f=or.getPointAtIndexGlobalCoordinates(p,-1,d),b=p.startBinding&&d.get(p.startBinding.elementId),E=p.endBinding&&d.get(p.endBinding.elementId),w=b&&p.startBinding?{...p.startBinding,...cE(p,b,"start",d)}:null,y=E&&p.endBinding?{...p.endBinding,...cE(p,E,"end",d)}:null;p={...p,startBinding:w,endBinding:y,...m6(p,d,{points:[h,f].map(x=>V4(x[0]-p.x,x[1]-p.y)),startBinding:w,endBinding:y,fixedSegments:null})}}else{let d=n.scene.getNonDeletedElementsMap();if(p.startBinding){let h=d.get(p.startBinding.elementId);h&&sE(p,h,o.bindMode==="inside"?"inside":"orbit","start",n.scene)}if(p.endBinding){let h=d.get(p.endBinding.elementId);h&&sE(p,h,o.bindMode==="inside"?"inside":"orbit","end",n.scene)}}return p}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new or(l,Bp(e)))}return{elements:r,appState:i,captureUpdate:Ke.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>ht("fieldset",{children:[ne("legend",{children:g("labels.arrowtypes")}),ne("div",{className:"buttonList",children:ne(Wt,{group:"arrowtypes",options:[{value:Xt.sharp,text:g("labels.arrowtype_sharp"),icon:Zr,testId:"sharp-arrow"},{value:Xt.round,text:g("labels.arrowtype_round"),icon:jr,testId:"round-arrow"},{value:Xt.elbow,text:g("labels.arrowtype_elbowed"),icon:$r,testId:"elbow-arrow"}],value:st(e,n,r=>nc(r)?r.elbowed?Xt.elbow:r.roundness?Xt.round:Xt.sharp:null,r=>nc(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})});import{clamp as Xp,roundToStep as _6}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as D6,CURSOR_TYPE as xE,MAX_ZOOM as yE,MIN_ZOOM as wE,THEME as Oa,ZOOM_STEP as Kp,updateActiveTool as ui,CODES as So,KEYS as Zo}from"@excalidraw/common";import{getNonDeletedElements as R6}from"@excalidraw/element";import{getCommonBounds as N6}from"@excalidraw/element";import{CaptureUpdateAction as Co}from"@excalidraw/element";import{useEffect as C6}from"react";import{jsx as M6}from"react/jsx-runtime";var pi=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},Up=(e,o,t="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-n.width/2;l<0?l=a:l+n.width>=r&&(l=r-n.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+n.height>=i&&(s=o.top-n.height-a)):(s=o.top-n.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},k6=(e,o,t,n)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=n?"50ch":"10ch",o.style.maxWidth=n?"50ch":"15ch",o.textContent=t;let r=e.getBoundingClientRect();Up(o,r)},ct=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(C6(()=>()=>pi().classList.remove("excalidraw-tooltip--visible"),[]),r?null:M6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>k6(i.currentTarget,pi(),o,t),onPointerLeave:()=>pi().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import{CURSOR_TYPE as Wp,MIME_TYPES as Yp,THEME as fE}from"@excalidraw/common";var bE='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',P6='<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"/>',EE='<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"/>',L6=`data:${Yp.svg},${encodeURIComponent(`${bE}${EE}</svg>`)}`,A6=`data:${Yp.svg},${encodeURIComponent(`${bE}${P6}${EE}</svg>`)}`,Rt=e=>{e&&(e.style.cursor="")},xe=(e,o)=>{e&&(e.style.cursor=o)},To,gE,Vp=(e,o)=>{let n=()=>{let r=o===fE.DARK;To=document.createElement("canvas"),To.theme=o,To.height=20,To.width=20;let i=To.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(To.width/2,To.height/2,5,0,2*Math.PI),i.fillStyle=r?"#000":"#fff",i.fill(),i.strokeStyle=r?"#fff":"#000",i.stroke(),gE=To.toDataURL(Yp.svg)};(!To||To.theme!==o)&&n(),xe(e,`url(${gE}) ${20/2} ${20/2}, auto`)},Nt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Rt(e);else if(ao(o))e.style.cursor=Wp.GRAB;else if(wt(o))Vp(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===fE.LIGHT?L6:A6;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Wp.AUTO):e.style.cursor=Wp.CROSSHAIR};var Ko=({viewportX:e,viewportY:o,nextZoom:t},n)=>{let r=e-n.offsetLeft,i=o-n.offsetTop,a=n.zoom.value,l=n.scrollX+(r-r/a),s=n.scrollY+(i-i/a),c=-(r-r/t),m=-(i-i/t);return{scrollX:l+c,scrollY:s+m,zoom:{value:t}}};import{jsx as lc,jsxs as z6}from"react/jsx-runtime";var B6=F({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t?.viewBackgroundColor?Co.IMMEDIATELY:Co.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n,data:r})=>lc(Aa,{palette:null,topPicks:D6,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),rc=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Am,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Ko({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:xo(o.zoom.value+Kp)},o),userToFollow:null},captureUpdate:Co.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>lc(V,{type:"button",className:"zoom-in-button zoom-button",icon:Am,title:`${g("buttons.zoomIn")} \u2014 ${A("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=yE,onClick:()=>{e(null)}}),keyTest:e=>(e.code===So.EQUAL||e.code===So.NUM_ADD)&&(e[Zo.CTRL_OR_CMD]||e.shiftKey)}),ic=F({name:"zoomOut",label:"buttons.zoomOut",icon:_m,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Ko({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:xo(o.zoom.value-Kp)},o),userToFollow:null},captureUpdate:Co.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>lc(V,{type:"button",className:"zoom-out-button zoom-button",icon:_m,title:`${g("buttons.zoomOut")} \u2014 ${A("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=wE,onClick:()=>{e(null)}}),keyTest:e=>(e.code===So.MINUS||e.code===So.NUM_SUBTRACT)&&(e[Zo.CTRL_OR_CMD]||e.shiftKey)}),ac=F({name:"resetZoom",label:"buttons.resetZoom",icon:O1,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Ko({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:xo(1)},o),userToFollow:null},captureUpdate:Co.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>lc(ct,{label:g("buttons.resetZoom"),style:{height:"100%"},children:z6(V,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===So.ZERO||e.code===So.NUM_ZERO)&&(e[Zo.CTRL_OR_CMD]||e.shiftKey)}),F6=(e,o,t=1)=>{let[n,r,i,a]=e,l=i-n,s=o.width/l,c=a-r,m=o.height/c,d=Math.min(s,m)*Xp(t,.1,1);return Math.min(d,1)},vE=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{r=Xp(r,wE,yE);let[l,s,c,m]=e,p=(l+c)/2,d=(s+m)/2,h=t?.left??0,f=t?.top??0,b=t?.right??0,E=t?.bottom??0,w=o.width-h-b,y=o.height-f-E,x;if(n){let C=c-l,P=m-s;x=Math.min(w/C,y/P)*r}else x=F6(e,{width:w,height:y},r);let v=xo(Xp(_6(x,Kp,"floor"),i,a)),I=Qf({scenePoint:{x:p,y:d},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:I.scrollX,scrollY:I.scrollY,zoom:{value:v}},captureUpdate:Co.EVENTUALLY}},za=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})=>{let l=N6(R6(o));return vE({canvasOffsets:e,bounds:l,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})},Mj=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Ms,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return za({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===So.TWO&&e.shiftKey&&!e.altKey&&!e[Zo.CTRL_OR_CMD]}),Pj=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Ms,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return za({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===So.THREE&&e.shiftKey&&!e.altKey&&!e[Zo.CTRL_OR_CMD]}),O6=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Ms,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>za({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===So.ONE&&e.shiftKey&&!e.altKey&&!e[Zo.CTRL_OR_CMD]}),nr=F({name:"toggleTheme",label:(e,o)=>o.theme===Oa.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,o)=>e.theme===Oa.LIGHT?Ea:xa,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===Oa.LIGHT?Oa.DARK:Oa.LIGHT)},captureUpdate:Co.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===So.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),Lj=F({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return wt(o)?r=ui(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):r=ui(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Co.IMMEDIATELY}},keyTest:e=>e.key===Zo.E}),Aj=F({name:"toggleLassoTool",label:"toolBar.lasso",icon:mn,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.state.preferredSelectionTool.type!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=ui(o,{type:"lasso",fromSelection:!1}),xe(n.interactiveCanvas,xE.CROSSHAIR)):r=ui(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Co.NEVER}}}),IE=F({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:ks,viewMode:!1,perform:(e,o,t,n)=>{let r;return ao(o)?r=ui(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=ui(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),xe(n.interactiveCanvas,xE.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:Co.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Zo.CTRL_OR_CMD]&&e.key===Zo.H});import{updateActiveTool as TE}from"@excalidraw/common";import{CaptureUpdateAction as H6}from"@excalidraw/element";var G6=F({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=TE(o,{type:"embeddable"});return Nt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:TE(o,{type:"embeddable"})},captureUpdate:H6.EVENTUALLY}}});import{pointFrom as SE}from"@excalidraw/math";import{bindOrUnbindBindingElement as U6}from"@excalidraw/element/binding";import{isValidPolygon as CE,LinearElementEditor as sc,newElementWith as Zp}from"@excalidraw/element";import{isBindingElement as kE,isFreeDrawElement as ME,isLinearElement as PE,isLineElement as cc}from"@excalidraw/element";import{KEYS as $p,arrayToMap as W6,invariant as LE,shouldRotateWithDiscreteAngle as Y6,updateActiveTool as AE}from"@excalidraw/common";import{isPathALoop as V6}from"@excalidraw/element";import{isInvisiblySmallElement as jp}from"@excalidraw/element";import{CaptureUpdateAction as _E}from"@excalidraw/element";import{jsx as X6}from"react/jsx-runtime";var gt=F({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let r=e,{interactiveCanvas:i,focusContainer:a,scene:l}=n,s=l.getNonDeletedElementsMap();if(t&&o.selectedLinearElement){let{event:d,sceneCoords:h}=t,f=sc.getElement(o.selectedLinearElement.elementId,s);LE(f,"Arrow element should exist if selectedLinearElement is set"),LE(h,"sceneCoords should be defined if actionFinalize is called with event");let b=sc.handlePointerUp(d,o.selectedLinearElement,o,n.scene);if(kE(f)&&!o.selectedLinearElement.segmentMidPointHoveredCoords){let E=!!o.newElement,y=(E||!o.selectedLinearElement.selectedPointsIndices?[f.points.length-1]:o.selectedLinearElement.selectedPointsIndices).reduce((x,v)=>(x.set(v,{point:sc.pointFromAbsoluteCoords(f,SE(h.x,h.y),s)}),x),new Map)??new Map;U6(f,y,h.x,h.y,l,o,{newArrow:E,altKey:d.altKey,angleLocked:Y6(d)})}else cc(f)&&o.selectedLinearElement?.isEditing&&!o.newElement&&!CE(f.points)&&l.mutateElement(f,{polygon:!1});if(b!==o.selectedLinearElement){f&&jp(f)&&(r=r.map(w=>w.id===f.id?Zp(w,{isDeleted:!0}):w));let E=o.activeTool?.locked;return{elements:f.points.length<2||jp(f)?e.map(w=>w.id===f.id?Zp(w,{isDeleted:!0}):w):r,appState:{...o,cursorButton:"up",selectedLinearElement:E?null:{...b,selectedPointsIndices:null,isEditing:!1,initialState:{...b.initialState,lastClickedPoint:-1}},selectionElement:null,suggestedBinding:null,newElement:null,multiElement:null},captureUpdate:_E.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||kE(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let d=s.get(Object.keys(o.selectedElementIds)[0]);d&&(c=d)}if(c){if(o.selectedLinearElement&&o.multiElement&&c.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:d}=c,{lastCommittedPoint:h}=o.selectedLinearElement;(!h||d[d.length-1]!==h)&&l.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&jp(c)&&(r=r.map(d=>d.id===c?.id?Zp(d,{isDeleted:!0}):d)),PE(c)||ME(c)){if(V6(c.points,o.zoom.value)&&(cc(c)||ME(c))){let h=c.points,f=h[0],b=h.map((E,w)=>w===h.length-1?SE(f[0],f[1]):E);cc(c)?l.mutateElement(c,{points:b,polygon:!0}):l.mutateElement(c,{points:b})}cc(c)&&!CE(c.points)&&l.mutateElement(c,{polygon:!1})}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Rt(i);let m;o.activeTool.type==="eraser"?m=AE(o,{...o.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveToolBeforeEraser:null}):m=AE(o,{type:n.state.preferredSelectionTool.type});let p=c&&PE(c)?new sc(c,W6(r)):o.selectedLinearElement;return p=p&&{...p,isEditing:o.newElement?!1:p.isEditing,initialState:{...p.initialState,lastClickedPoint:-1,origin:null}},{elements:r,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:m,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:p},captureUpdate:_E.IMMEDIATELY}},keyTest:(e,o)=>e.key===$p.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===$p.ESCAPE||e.key===$p.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>X6(V,{type:"button",icon:$1,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as fc,DEFAULT_EXPORT_PADDING as Fk,EXPORT_SCALES as Ok,THEME as Qp}from"@excalidraw/common";import{getNonDeletedElements as zk}from"@excalidraw/element";import{CaptureUpdateAction as po}from"@excalidraw/element";import K6 from"clsx";import{jsx as DE,jsxs as Z6}from"react/jsx-runtime";var Ha=({children:e,checked:o,onChange:t,className:n})=>Z6("div",{className:K6("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[DE("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:Y1}),DE("div",{className:"Checkbox-label",children:e})]});import{THEME as Ga}from"@excalidraw/common";import{jsx as Ua}from"react/jsx-runtime";var NE=e=>{let o=e.title||(e.value===Ga.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return Ua(V,{type:"icon",icon:e.value===Ga.LIGHT?RE.MOON:RE.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===Ga.DARK?Ga.LIGHT:Ga.DARK),"data-testid":"toggle-dark-mode"})},RE={SUN:Ua("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ua("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:Ua("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ua("path",{fill:"currentColor",d:"M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"})})};import{useState as $6}from"react";import{focusNearestParent as j6,KEYS as q6}from"@excalidraw/common";import{jsx as BE,jsxs as J6}from"react/jsx-runtime";var FE=e=>{let{id:o}=ke(),[t,n]=$6(e.value),r=a=>{e.ignoreFocus||j6(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===q6.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return J6("div",{className:"ProjectName",children:[BE("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),BE("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>n(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as Mk,DEFAULT_FILENAME as Pk,IMAGE_MIME_TYPES as QE,isFirefox as Lk,MIME_TYPES as Ak,cloneJSON as _k,SVG_DOCUMENT_PREAMBLE as Dk}from"@excalidraw/common";import{getNonDeletedElements as Rk}from"@excalidraw/element";import{isFrameLikeElement as Nk}from"@excalidraw/element";import{getElementsOverlappingFrame as Bk}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as dk,EXPORT_DATA_TYPES as Va,MIME_TYPES as co,arrayToMap as mk,isMemberOf as pk,isPromiseLike as uk,EVENT as pc}from"@excalidraw/common";import{mutateElement as hk}from"@excalidraw/element";import{deepCopyElement as gk}from"@excalidraw/element";import{isFrameLikeElement as fk,isInitializedImageElement as bk}from"@excalidraw/element";import{getContainingFrame as ZE}from"@excalidraw/element";import{pointFrom as In}from"@excalidraw/math";import{COLOR_PALETTE as zE,DEFAULT_CHART_COLOR_INDEX as Q6,getAllColorsSpecificShade as ek,DEFAULT_FONT_FAMILY as tk,DEFAULT_FONT_SIZE as HE,VERTICAL_ALIGN as ok,randomId as GE,isDevEnv as UE,FONT_SIZES as nk}from"@excalidraw/common";import{newTextElement as dc,newLinearElement as Ya,newElement as Jp}from"@excalidraw/element";var so=32,Ce=12,Tn=256,WE=50,rr="NOT_SPREADSHEET",hi="VALID_SPREADSHEET",Wa=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},qp=(e,o)=>e.slice(1).every(t=>Wa(t[o])!==null),OE=e=>{let o=e[0].length;if(o>2)return{type:rr,reason:"More than 2 columns"};if(o===1){if(!qp(e,0))return{type:rr,reason:"Value is not numeric"};let s=Wa(e[0][0])===null,c=(s?e.slice(1):e).map(m=>Wa(m[0]));return c.length<2?{type:rr,reason:"Less than two rows"}:{type:hi,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let t=qp(e,0),n=qp(e,1);if(!t&&!n)return{type:rr,reason:"Value is not numeric"};let[r,i]=n?[0,1]:[1,0],a=Wa(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:rr,reason:"Less than 2 rows"}:{type:hi,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[r]),values:l.map(s=>Wa(s[i]))}}},rk=e=>{let o=[];for(let t=0;t<e[0].length;t++){let n=[];for(let r=0;r<e.length;r++)n.push(e[r][t]);o.push(n)}return o},YE=e=>{let o=e.trim().split(`
|
|
3
3
|
`).map(i=>i.trim().split(" "));if(o.length&&o[0].length!==2&&(o=e.trim().split(`
|
|
4
|
-
`).map(i=>i.trim().split(","))),o.length===0)return{type:
|
|
5
|
-
`).trim()}:n:{type:"text",value:(e.getData(
|
|
4
|
+
`).map(i=>i.trim().split(","))),o.length===0)return{type:rr,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:rr,reason:"All rows don't have same number of columns"};let r=OE(o);if(r.type!==hi){let i=OE(rk(o));if(i.type===hi)return i}return r},mc=ek(Q6),Kt={fillStyle:"hachure",fontFamily:tk,fontSize:HE,opacity:100,roughness:1,strokeColor:zE.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:ok.MIDDLE,locked:!1},VE=e=>{let o=(so+Ce)*e.values.length+Ce,t=Tn+Ce*2;return{chartWidth:o,chartHeight:t}},ik=(e,o,t,n,r)=>e.labels?.map((i,a)=>dc({groupIds:[n],backgroundColor:r,...Kt,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(so+Ce)+Ce*2,y:t+Ce/2,width:so,angle:5.87,fontSize:nk.sm,textAlign:"center",verticalAlign:"top"}))||[],ak=(e,o,t,n,r)=>{let i=dc({groupIds:[n],backgroundColor:r,...Kt,x:o-Ce,y:t-Ce,text:"0",textAlign:"right"}),a=dc({groupIds:[n],backgroundColor:r,...Kt,x:o-Ce,y:t-Tn-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},lk=(e,o,t,n,r)=>{let{chartWidth:i,chartHeight:a}=VE(e),l=Ya({backgroundColor:r,groupIds:[n],...Kt,type:"line",x:o,y:t,width:i,points:[In(0,0),In(i,0)]}),s=Ya({backgroundColor:r,groupIds:[n],...Kt,type:"line",x:o,y:t,height:a,points:[In(0,0),In(0,-a)]}),c=Ya({backgroundColor:r,groupIds:[n],...Kt,type:"line",x:o,y:t-Tn-Ce,strokeStyle:"dotted",width:i,opacity:WE,points:[In(0,0),In(i,0)]});return[l,s,c]},XE=(e,o,t,n,r,i)=>{let{chartWidth:a,chartHeight:l}=VE(e),s=e.title?dc({backgroundColor:r,groupIds:[n],...Kt,text:e.title,x:o+a/2,y:t-Tn-Ce*2-HE,roundness:null,textAlign:"center"}):null,c=i?Jp({backgroundColor:r,groupIds:[n],...Kt,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:zE.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...s?[s]:[],...ik(e,o,t,n,r),...ak(e,o,t,n,r),...lk(e,o,t,n,r)]},sk=(e,o,t)=>{let n=Math.max(...e.values),r=GE(),i=mc[Math.floor(Math.random()*mc.length)];return[...e.values.map((l,s)=>{let c=l/n*Tn;return Jp({backgroundColor:i,groupIds:[r],...Kt,type:"rectangle",x:o+s*(so+Ce)+Ce,y:t-c-Ce,width:so,height:c})}),...XE(e,o,t,r,i,UE())]},ck=(e,o,t)=>{let n=Math.max(...e.values),r=GE(),i=mc[Math.floor(Math.random()*mc.length)],a=0,l=[];for(let b of e.values){let E=a*(so+Ce),w=-(b/n)*Tn;l.push([E,w]),a++}let s=Math.max(...l.map(b=>b[0])),c=Math.max(...l.map(b=>b[1])),m=Math.min(...l.map(b=>b[0])),p=Math.min(...l.map(b=>b[1])),d=Ya({backgroundColor:i,groupIds:[r],...Kt,type:"line",x:o+Ce+so/2,y:t-Ce,height:c-p,width:s-m,strokeWidth:2,points:l}),h=e.values.map((b,E)=>{let w=E*(so+Ce)+Ce/2,y=-(b/n)*Tn+Ce/2;return Jp({backgroundColor:i,groupIds:[r],...Kt,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+w+so/2,y:t+y-Ce*2,width:Ce,height:Ce})}),f=e.values.map((b,E)=>{let w=E*(so+Ce)+Ce/2,y=b/n*Tn+Ce/2+Ce;return Ya({backgroundColor:i,groupIds:[r],...Kt,type:"line",x:o+w+so/2+Ce/2,y:t-y,height:y,strokeStyle:"dotted",opacity:WE,points:[In(0,0),In(0,y)]})});return[...XE(e,o,t,r,i,UE()),d,...f,...h]},KE=(e,o,t,n)=>e==="line"?ck(o,t,n):sk(o,t,n);var Yq="clipboard"in navigator&&"readText"in navigator.clipboard,uc="clipboard"in navigator&&"writeText"in navigator.clipboard,Sn="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,Ek=e=>!!([Va.excalidraw,Va.excalidrawClipboard,Va.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),$E=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(pc.PASTE,{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){o=o||[],o.push(r);continue}try{if(t.clipboardData?.items.add(r,n),t.clipboardData?.getData(n)!==r)throw new Error(`Failed to set "${n}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let n=-1;for(let r of o){n++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[n]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},xk=({elements:e,files:o})=>{let t=mk(e),n=new Set(e.filter(l=>fk(l))),r=!1,i=e.reduce((l,s)=>(bk(s)&&(r=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});r&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Va.excalidrawClipboard,elements:e.map(l=>{if(ZE(l,t)&&!n.has(ZE(l,t))){let s=gk(l);return hk(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},hc=async(e,o,t)=>{await mo(xk({elements:e,files:o}),t)},yk=e=>{let o=YE(e);return o.type===hi?{spreadsheet:o.spreadsheet}:null};function jE(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let n=t.textContent?.trim();n&&o.push({type:"text",value:n})}else if(t instanceof HTMLImageElement){let n=t.getAttribute("src");n&&n.startsWith("http")&&o.push({type:"imageUrl",value:n})}else o=o.concat(jE(t));return o}var wk=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,co.html),n=jE(t.body);if(n.length)return{type:"mixedContent",value:n}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},qE=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let n=await navigator.clipboard?.readText();if(n)return{[co.text]:n}}}catch(n){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${n.message}). Failling back to navigator.clipboard.read()`);else{if(n.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${n.message}`),e;throw n}}throw t}for(let t of o)for(let n of t.types)if(pk(dk,n))try{if(n===co.text||n===co.html)e[n]=await(await t.getType(n)).text();else if(u1(n)){let r=await t.getType(n),i=y1(r,n,void 0);e[n]=i}else throw new vm(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof vm?r.message:`Cannot retrieve ${n} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},vk=async(e,o=!1)=>{try{let t=e.findByType(co.html),n=!o&&t&&wk(t);return n?n.value.every(r=>r.type==="text")?{type:"text",value:e.getData(co.text)??n.value.map(r=>r.value).join(`
|
|
5
|
+
`).trim()}:n:{type:"text",value:(e.getData(co.text)||"").trim()}}catch{return{type:"text",value:""}}},Ik=function(e){return this.find(o=>o.type===e)||null},Tk=function(e){return this.find(t=>t.type===e)?.value??null},Sk=function(){return this.filter(e=>e.kind==="file")},Xa=async e=>{let o;kk(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=(await Promise.all(Array.from(o||[]).map(async n=>{if(n.kind==="file"){let r=n.getAsFile();if(r){let i=await x1(n);return r=await fa(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(n.kind==="string"){let{type:r}=n,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{n.getAsString(l=>a(l))}),{type:r,kind:"string",value:i}}return null}))).filter(n=>n!=null);return Object.assign(t,{findByType:Ik,getData:Tk,getFiles:Sk})},JE=async(e,o=!1)=>{let t=await vk(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let n=!o&&yk(t.value);if(n)return n}catch(n){console.error(n)}try{let n=JSON.parse(t.value),r=n.type===Va.excalidrawClipboardWithAPI;if(Ek(n))return{elements:n.elements,files:n.files,text:o?JSON.stringify(n.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},gc=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[co.png]:e})])}catch(o){if(uk(e))await navigator.clipboard.write([new window.ClipboardItem({[co.png]:await e})]);else throw o}},mo=async(e,o)=>{if(uc)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(co.text,e||""),o.clipboardData?.getData(co.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!Ck(e))throw new Error("Error copying to clipboard.")},Ck=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let n=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${n}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let r=!1;try{t.select(),t.setSelectionRange(0,t.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),r},kk=e=>e.type===pc.PASTE||e.type===pc.COPY||e.type===pc.CUT;var ir=(e,{selectedElementIds:o},t)=>{e=Rk(e);let n=t&&ve(e,{selectedElementIds:o}),r=null,i=n?q(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return n&&(i.length===1&&Nk(i[0])?(r=i[0],i=Bk(e,r)):i.length>1&&(i=q(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:r,exportedElements:_k(i)}},ar=async(e,o,t,n,{exportBackground:r,exportPadding:i=Mk,viewBackgroundColor:a,name:l=t.name||Pk,fileHandle:s=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let p=Or(o,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},n,{exportingFrame:c});if(e==="svg")return Im(p.then(d=>new Blob([Dk+d.outerHTML],{type:Ak.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[QE.svg],fileHandle:s});if(e==="clipboard-svg"){let d=await p.then(h=>h.outerHTML);try{await mo(d)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let m=as(o,t,n,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let p=jn(m);return t.exportEmbedScene&&(p=p.then(d=>import("./data/image-UCRRORR6.js").then(({encodePngMetadata:h})=>h({blob:d,metadata:ua(o,t,n,"local")})))),Im(p,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[QE.png],fileHandle:s})}else if(e==="clipboard")try{let p=jn(m);await gc(p)}catch(p){throw console.warn(p),p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):Lk&&p.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
|
|
6
6
|
|
|
7
|
-
${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var nx=async(e,o,t,n)=>{let{exportBackground:r,viewBackgroundColor:i,fileHandle:a}=o,l=f1(a);if(!a||!b1(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=sr(e,o,!1);return await cr(l,s,o,t,{exportBackground:r,viewBackgroundColor:i,name:n,fileHandle:a,exportingFrame:c}),{fileHandle:a}};import{Fragment as Yk,jsx as Qo,jsxs as Vk}from"react/jsx-runtime";var ru=F({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:uo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:n,app:r})=>Qo(HE,{label:g("labels.fileTitle"),value:r.getName(),onChange:i=>o(i),ignoreFocus:n?.ignoreFocus??!1})}),rx=F({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:uo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=Wk(e),i=ve(n,o)?q(n,o):n;return Qo(Yk,{children:Uk.map(a=>{let[l,s]=h1(i,Gk,a),c=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Qo(V,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),iu=F({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:uo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Qo(Za,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),wc=F({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:uo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Vk(Za,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),Qo(ct,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:Qo("div",{className:"excalidraw-tooltip-icon",children:Q1})})]})}),dr=F({name:"saveToActiveFile",label:"buttons.save",icon:er,trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{let r=!!o.fileHandle;try{let{fileHandle:i}=gs(o.fileHandle)?await nx(e,o,n.files,n.getName()):await cs(e,o,n.files,n.getName());return{captureUpdate:uo.EVENTUALLY,appState:{...o,fileHandle:i,toast:r?{message:i?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):g("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:uo.EVENTUALLY}}},keyTest:e=>!1}),tl=F({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:er,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,n)=>{try{let{fileHandle:r}=await cs(e,{...o,fileHandle:null},n.files,n.getName());return{captureUpdate:uo.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:r,toast:{message:g("toast.fileSaved")}}}}catch(r){return r?.name!=="AbortError"?console.error(r):console.warn(r),{captureUpdate:uo.EVENTUALLY}}},keyTest:e=>e.key===yc.S&&e.shiftKey&&e[yc.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Qo(V,{type:"button",icon:$1,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:de().formFactor==="phone",hidden:!Hr,onClick:()=>e(null),"data-testid":"save-as-button"})}),Ii=F({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{try{let{elements:r,appState:i,files:a}=await Mm(o,e);return{elements:r,appState:i,files:a,captureUpdate:uo.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...o,errorMessage:r.message},files:n.files,captureUpdate:uo.EVENTUALLY}}},keyTest:e=>e[yc.CTRL_OR_CMD]&&e.key===yc.O}),ix=F({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:uo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Qo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Qo(OE,{value:e.exportWithDarkMode?nu.DARK:nu.LIGHT,onChange:t=>{o(t===nu.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as Xk,DEFAULT_FONT_FAMILY as Kk,DEFAULT_TEXT_ALIGN as Zk,CODES as ax,KEYS as lx,getLineHeight as $k}from"@excalidraw/common";import{newElementWith as vc}from"@excalidraw/element";import{hasBoundTextElement as jk,canApplyRoundnessTypeToElement as qk,getDefaultRoundnessTypeForElement as Jk,isFrameLikeElement as Qk,isArrowElement as eM,isExcalidrawElement as tM,isTextElement as au}from"@excalidraw/element";import{getBoundTextElement as oM,redrawTextBoundingBox as nM}from"@excalidraw/element";import{CaptureUpdateAction as lu}from"@excalidraw/element";var sx="{}",su=F({name:"copyStyles",label:"labels.copyStyles",icon:Qm,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=[],i=e.find(a=>o.selectedElementIds[a.id]);if(r.push(i),i&&jk(i)){let a=oM(i,n.scene.getNonDeletedElementsMap());r.push(a)}return i&&(sx=JSON.stringify(r)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:lu.EVENTUALLY}},keyTest:e=>e[lx.CTRL_OR_CMD]&&e.altKey&&e.code===ax.C}),cu=F({name:"pasteStyles",label:"labels.pasteStyles",icon:Qm,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=JSON.parse(sx),i=r[0],a=r[1];if(!tM(i))return{elements:e,captureUpdate:lu.EVENTUALLY};let l=q(e,o,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=i;if(au(c)&&c.containerId&&(m=a),!m)return c;let p=vc(c,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?qk(m.roundness.type,c)?m.roundness:Jk(c):null});if(au(p)){let d=m.fontSize||Xk,h=m.fontFamily||Kk;p=vc(p,{fontSize:d,fontFamily:h,textAlign:m.textAlign||Zk,lineHeight:m.lineHeight||$k(h)});let f=null;p.containerId&&(f=l.find(b=>au(p)&&b.id===p.containerId)||null),nM(p,f,n.scene)}return p.type==="arrow"&&eM(m)&&(p=vc(p,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),Qk(c)&&(p=vc(p,{roundness:null,backgroundColor:"transparent"})),p}return c}),captureUpdate:lu.IMMEDIATELY}},keyTest:e=>e[lx.CTRL_OR_CMD]&&e.altKey&&e.code===ax.V});import{KEYS as rM}from"@excalidraw/common";import{CaptureUpdateAction as iM}from"@excalidraw/element";var mr=F({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:W1,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:n})=>(o.openDialog?.name==="help"&&n(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:iM.EVENTUALLY}),keyTest:e=>e.key===rM.QUESTION_MARK});import{getNonDeletedElements as Tc}from"@excalidraw/element";import{newElementWith as mx}from"@excalidraw/element";import{isBoundToContainer as aM}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as lM,getElementsInResizingFrame as sM,getFrameLikeElements as cM,getRootElements as dM,groupByFrameLikes as mM,removeElementsFromFrame as pM,replaceAllElementsInFrame as uM}from"@excalidraw/element";import{KEYS as Sc,randomId as hM,arrayToMap as du}from"@excalidraw/common";import{getSelectedGroupIds as Ic,selectGroup as gM,selectGroupsForSelectedElements as fM,getElementsInGroup as cx,addToGroup as bM,removeFromSelectedGroups as EM,isElementInGroup as px}from"@excalidraw/element";import{syncMovedIndices as xM}from"@excalidraw/element";import{CaptureUpdateAction as ol}from"@excalidraw/element";import{jsx as Ti}from"react/jsx-runtime";var yM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((n,r)=>n&&px(r,t),!0))return!0}return!1},dx=(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!yM(n)&&!lM(n)},mu=F({name:"group",label:"labels.group",icon:e=>Ti($m,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=dM(n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:o,elements:e,captureUpdate:ol.EVENTUALLY};let i=Ic(o);if(i.length===1){let E=i[0],w=new Set(cx(e,E).map(v=>v.id)),y=new Set(r.map(v=>v.id));if(new Set([...Array.from(w),...Array.from(y)]).size===w.size)return{appState:o,elements:e,captureUpdate:ol.EVENTUALLY}}let a=[...e];new Set(r.map(E=>E.frameId)).size>1&&mM(r).forEach((w,y)=>{pM(w,n.scene.getNonDeletedElementsMap())});let s=hM(),c=du(r);a=a.map(E=>c.get(E.id)?mx(E,{groupIds:bM(E.groupIds,s,o.editingGroupId)}):E);let m=cx(a,s),p=m[m.length-1],d=a.lastIndexOf(p),h=a.slice(d+1),f=a.slice(0,d).filter(E=>!px(E,s)),b=xM([...f,...m,...h],du(m));return{appState:{...o,...gM(s,{...o,selectedGroupIds:{}},Tc(a))},elements:b,captureUpdate:ol.IMMEDIATELY}},predicate:(e,o,t,n)=>dx(e,o,n),keyTest:e=>!e.shiftKey&&e[Sc.CTRL_OR_CMD]&&e.key===Sc.G,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Ti(V,{hidden:!dx(e,o,n),type:"button",icon:Ti($m,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${A("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:ve(Tc(e),o)})}),pu=F({name:"ungroup",label:"labels.ungroup",icon:e=>Ti(jm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=Ic(o),i=du(e);if(r.length===0)return{appState:o,elements:e,captureUpdate:ol.EVENTUALLY};let a=[...e],l=[];a=a.map(d=>{aM(d)&&l.push(d.id);let h=EM(d.groupIds,o.selectedGroupIds);return h.length===d.groupIds.length?d:mx(d,{groupIds:h})});let s=fM(o,Tc(a),o,null),c=n.scene.getSelectedElements(o),m=new Set(c.filter(d=>d.frameId).map(d=>d.frameId));return cM(e).filter(d=>m.has(d.id)).forEach(d=>{d&&(a=uM(a,sM(a,d,o,i),d,n))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((d,[h,f])=>(f&&!l.includes(h)&&(d[h]=!0),d),{}),{appState:{...o,...s},elements:a,captureUpdate:ol.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Sc.CTRL_OR_CMD]&&e.key===Sc.G.toUpperCase(),predicate:(e,o)=>Ic(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>Ti(V,{type:"button",hidden:Ic(o).length===0,icon:Ti(jm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${A("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:ve(Tc(e),o)})});import kM from"clsx";import{CaptureUpdateAction as bx}from"@excalidraw/element";import{invariant as MM}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as wM,COLOR_VOICE_CALL as vM,COLOR_WHITE as kc,THEME as IM,UserIdleState as ux}from"@excalidraw/common";var Cc=(e,o,t,n,r,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+n-i,t),e.quadraticCurveTo(o+n,t,o+n,t+i),e.lineTo(o+n,t+r-i),e.quadraticCurveTo(o+n,t+r,o+n-i,t+r),e.lineTo(o+i,t+r),e.quadraticCurveTo(o,t+r,o,t+r-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function TM(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);o=(o<<5)-o+n}return o}var pr=(e,o)=>`hsl(${Math.abs(TM(o?.id||e))%37*10}, 100%, 83%)`,hx=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},gx=({context:e,renderConfig:o,appState:t,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,c=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let m=11,p=14,d=l<0||l>n-m||s<0||s>r-p;l=Math.max(l,0),l=Math.min(l,n-m),s=Math.max(s,0),s=Math.min(s,r-p);let h=pr(i,c);e.save(),e.strokeStyle=h,e.fillStyle=h;let f=o.remotePointerUserStates.get(i),b=d||f===ux.IDLE||f===ux.AWAY;b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=h,e.stroke(),e.closePath());let E=t.theme===IM.DARK?"#2f6330":vM,w=c?.isSpeaking;w&&(e.fillStyle=E,e.strokeStyle=E,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=kc,e.strokeStyle=kc,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=h,e.strokeStyle=h,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let y=o.remotePointerUsernames.get(i)||"";if(!d&&y){e.font="600 12px sans-serif";let x=(w?l+0:l)+m/2,v=(w?s+0:s)+p+2,I=5,C=3,P=e.measureText(y),k=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,N=Math.max(k,12),_=x-1,L=v-1,B=P.width+2+I*2+2,G=N+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,L,B,G,8),e.fillStyle=h,e.fill(),e.strokeStyle=kc,e.stroke(),w&&(e.beginPath(),e.roundRect(_-2,L-2,B+4,G+4,8),e.strokeStyle=E,e.stroke())):Cc(e,_,L,B,G,8,kc),e.fillStyle=wM,e.fillText(y,x+I+1,v+C+P.actualBoundingBoxAscent+Math.floor((N-k)/2)+2),w){e.fillStyle=E;let j=8,H=8,Y=5;e.fillRect(_+B+H,L+(G/2-j/2),2,j),e.fillRect(_+B+H+Y,L+(G/2-j*2/2),2,j*2),e.fillRect(_+B+H+Y*2,L+(G/2-j/2),2,j)}}e.restore(),e.closePath()}};import SM from"clsx";import{useState as CM}from"react";import{jsx as fx}from"react/jsx-runtime";var uu=({color:e,onClick:o,name:t,src:n,className:r})=>{let i=hx(t),[a,l]=CM(!1),s=!a&&n,c=s?void 0:{background:e};return fx("div",{className:SM("Avatar",r),style:c,onClick:o,children:s?fx("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as Lo,jsxs as Mc}from"react/jsx-runtime";var PM=F({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>(MM(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:bx.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:bx.EVENTUALLY}),PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:a}=o,l=pr(n,r),s=kM({"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?Mc("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[Lo("div",{}),Lo("div",{}),Lo("div",{})]}):r.isMuted?Lo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:J0}):Lo("div",{title:g("userList.hint.inCall"),children:q0}):null;return i?Mc("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[Lo(uu,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),Lo("div",{className:"UserList__collaborator-name",children:r.username}),Mc("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Lo("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:or}),c]})]}):Mc("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[Lo(uu,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),c&&Lo("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{LIBRARY_DISABLED_TYPES as LM,randomId as AM}from"@excalidraw/common";import{deepCopyElement as _M}from"@excalidraw/element";import{CaptureUpdateAction as hu}from"@excalidraw/element";var gu=F({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of LM)if(r.some(a=>a.type===i))return{captureUpdate:hu.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:AM(),status:"unpublished",elements:r.map(_M),created:Date.now()},...i])).then(()=>({captureUpdate:hu.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:hu.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as Si}from"@excalidraw/element";import{isFrameLikeElement as DM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as RM}from"@excalidraw/element";import{KEYS as Mn,arrayToMap as NM}from"@excalidraw/common";import{alignElements as BM}from"@excalidraw/element";import{CaptureUpdateAction as Ci}from"@excalidraw/element";import{getSelectedElementsByGroup as FM}from"@excalidraw/element";import{jsx as Mi}from"react/jsx-runtime";var Ze=(e,o)=>{let t=o.scene.getSelectedElements(e);return FM(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>DM(n))},ki=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=BM(r,n,t.scene,o),a=NM(i);return RM(e.map(l=>a.get(l.id)||l),o,t)},OM=F({name:"alignTop",label:"labels.alignTop",icon:Wm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:ki(e,o,n,{position:"start",axis:"y"}),captureUpdate:Ci.IMMEDIATELY}),keyTest:e=>e[Mn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mn.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Mi(V,{hidden:!Ze(o,n),type:"button",icon:Wm,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${A("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:ve(Si(e),o)})}),zM=F({name:"alignBottom",label:"labels.alignBottom",icon:Ym,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:ki(e,o,n,{position:"end",axis:"y"}),captureUpdate:Ci.IMMEDIATELY}),keyTest:e=>e[Mn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mn.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Mi(V,{hidden:!Ze(o,n),type:"button",icon:Ym,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${A("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:ve(Si(e),o)})}),HM=F({name:"alignLeft",label:"labels.alignLeft",icon:Vm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:ki(e,o,n,{position:"start",axis:"x"}),captureUpdate:Ci.IMMEDIATELY}),keyTest:e=>e[Mn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mn.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Mi(V,{hidden:!Ze(o,n),type:"button",icon:Vm,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${A("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:ve(Si(e),o)})}),GM=F({name:"alignRight",label:"labels.alignRight",icon:Xm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:ki(e,o,n,{position:"end",axis:"x"}),captureUpdate:Ci.IMMEDIATELY}),keyTest:e=>e[Mn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mn.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Mi(V,{hidden:!Ze(o,n),type:"button",icon:Xm,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${A("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:ve(Si(e),o)})}),UM=F({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Km,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:ki(e,o,n,{position:"center",axis:"y"}),captureUpdate:Ci.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Mi(V,{hidden:!Ze(o,n),type:"button",icon:Km,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:ve(Si(e),o)})}),WM=F({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Zm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:ki(e,o,n,{position:"center",axis:"x"}),captureUpdate:Ci.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Mi(V,{hidden:!Ze(o,n),type:"button",icon:Zm,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:ve(Si(e),o)})});import{getNonDeletedElements as Ex}from"@excalidraw/element";import{isFrameLikeElement as YM}from"@excalidraw/element";import{CODES as xx,KEYS as yx,arrayToMap as VM}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as XM}from"@excalidraw/element";import{distributeElements as KM}from"@excalidraw/element";import{CaptureUpdateAction as wx}from"@excalidraw/element";import{getSelectedElementsByGroup as ZM}from"@excalidraw/element";import{jsx as Tx}from"react/jsx-runtime";var vx=(e,o)=>{let t=o.scene.getSelectedElements(e);return ZM(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(n=>YM(n))},Ix=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=KM(r,t.scene.getNonDeletedElementsMap(),n,o),a=VM(i);return XM(e.map(l=>a.get(l.id)||l),o,t)},$M=F({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:Ix(e,o,n,{space:"between",axis:"x"}),captureUpdate:wx.IMMEDIATELY}),keyTest:e=>!e[yx.CTRL_OR_CMD]&&e.altKey&&e.code===xx.H,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Tx(V,{hidden:!vx(o,n),type:"button",icon:n0,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${A("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:ve(Ex(e),o)})}),jM=F({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:Ix(e,o,n,{space:"between",axis:"y"}),captureUpdate:wx.IMMEDIATELY}),keyTest:e=>!e[yx.CTRL_OR_CMD]&&e.altKey&&e.code===xx.V,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Tx(V,{hidden:!vx(o,n),type:"button",icon:r0,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${A("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:ve(Ex(e),o)})});import{arrayToMap as Sx,KEYS as qM,matchKey as JM}from"@excalidraw/common";import{CaptureUpdateAction as QM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as eP}from"@excalidraw/element/frame";import{arrangeElements as tP}from"@excalidraw/element/arrange";import{jsx as iP}from"react/jsx-runtime";var oP=(e,o,t)=>{let n=t.scene.getSelectedElements(o),r=Sx(e),i=tP(t.scene,n,r,o.arrangeConfiguration.algorithm,o.arrangeConfiguration.gap),a=Sx(i);return eP(e.map(l=>a.get(l.id)||l),o,t)},nP=Ze,rP=F({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:tp,trackEvent:{category:"element"},viewMode:!1,predicate:(e,o,t,n)=>nP(o,n),perform:(e,o,t,n)=>({appState:o,elements:oP(e,o,n),captureUpdate:QM.IMMEDIATELY}),keyTest:e=>e.shiftKey&&JM(e,qM.R),PanelComponent:({updateData:e})=>iP("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${g("labels.arrangeElements")} \u2014 ${A("Shift+R")}`,children:tp})});import{arrayToMap as Cx}from"@excalidraw/common";import{CaptureUpdateAction as aP}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as lP}from"@excalidraw/element/frame";import{normaliseElements as sP}from"@excalidraw/element/normalise";import{jsx as mP}from"react/jsx-runtime";var cP=(e,o,t)=>{let n=t.scene.getSelectedElements(o),r=Cx(e),i=sP(t.scene,n,r,o.normaliseConfiguration.mode,o.normaliseConfiguration.metric),a=Cx(i);return lP(e.map(l=>a.get(l.id)||l),o,t)},dP=Ze,fu=F({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:op,trackEvent:{category:"element"},viewMode:!1,predicate:(e,o,t,n)=>dP(o,n),perform:(e,o,t,n)=>({appState:o,elements:cP(e,o,n),captureUpdate:aP.IMMEDIATELY}),PanelComponent:({updateData:e})=>mP("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:g("labels.normaliseElements"),children:op})});import{getNonDeletedElements as pP}from"@excalidraw/element";import{bindOrUnbindBindingElements as uP}from"@excalidraw/element";import{getCommonBoundingBox as kx}from"@excalidraw/element";import{newElementWith as hP}from"@excalidraw/element";import{deepCopyElement as gP}from"@excalidraw/element";import{resizeMultipleElements as fP}from"@excalidraw/element";import{isArrowElement as Mx,isElbowArrow as bP}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Px}from"@excalidraw/element";import{CODES as Lx,KEYS as EP,arrayToMap as xP}from"@excalidraw/common";import{CaptureUpdateAction as Ax}from"@excalidraw/element";var bu=F({name:"flipHorizontal",label:"labels.flipHorizontal",icon:ob,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:Px(_x(e,n.scene.getNonDeletedElementsMap(),o,"horizontal",n),o,n),appState:o,captureUpdate:Ax.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Lx.H}),Eu=F({name:"flipVertical",label:"labels.flipVertical",icon:tb,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:Px(_x(e,n.scene.getNonDeletedElementsMap(),o,"vertical",n),o,n),appState:o,captureUpdate:Ax.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===Lx.V&&!e[EP.CTRL_OR_CMD]}),_x=(e,o,t,n,r)=>{let i=q(pP(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=yP(i,o,n,r),l=xP(a);return e.map(s=>l.get(s.id)||s)},yP=(e,o,t,n)=>{if(e.every(d=>Mx(d)&&(d.startBinding||d.endBinding)))return e.map(d=>{let h=d;return hP(h,{startArrowhead:h.endArrowhead,endArrowhead:h.startArrowhead})});let{midX:r,midY:i}=kx(e);fP(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(d=>[d.id,gP(d)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),uP(e.filter(Mx),n.scene,n.state);let{elbowArrows:a,otherElements:l}=e.reduce((d,h)=>bP(h)?{...d,elbowArrows:d.elbowArrows.concat(h)}:{...d,otherElements:d.otherElements.concat(h)},{elbowArrows:[],otherElements:[]}),{midX:s,midY:c}=kx(e),[m,p]=[r-s,i-c];return l.forEach(d=>n.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),a.forEach(d=>n.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),e};import{isTextElement as wP}from"@excalidraw/element";import{getTextFromElements as vP}from"@excalidraw/element";import{CODES as IP,KEYS as Dx,isFirefox as TP}from"@excalidraw/common";import{CaptureUpdateAction as Bt}from"@excalidraw/element";var Pi=F({name:"copy",label:"labels.copy",icon:Sa,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Ec(r,n.files,t)}catch(i){return{captureUpdate:Bt.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Bt.EVENTUALLY}},keyTest:void 0}),xu=F({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r;try{r=await ex()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),TP?{captureUpdate:Bt.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:Bt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(JE({types:r}))}catch(i){return console.error(i),{captureUpdate:Bt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Bt.EVENTUALLY}},keyTest:void 0}),Pc=F({name:"cut",label:"labels.cut",icon:U0,trackEvent:{category:"element"},perform:(e,o,t,n)=>(Pi.perform(e,o,t,n),Da.perform(e,o,null,n)),keyTest:e=>e[Dx.CTRL_OR_CMD]&&e.key===Dx.X}),Lc=F({name:"copyAsSvg",label:"labels.copyAsSvg",icon:nb,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Bt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=sr(e,o,!0);try{await cr("clipboard-svg",r,o,n.files,{...o,exportingFrame:i,name:n.getName()});let a=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Bt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Bt.EVENTUALLY}}},predicate:e=>bc&&e.length>0,keywords:["svg","clipboard","copy"]}),Ac=F({name:"copyAsPng",label:"labels.copyAsPng",icon:rb,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Bt.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=sr(e,o,!0);try{return await cr("clipboard",i,o,n.files,{...o,exportingFrame:a,name:n.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:r.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Bt.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Bt.EVENTUALLY}}},predicate:e=>kn&&e.length>0,keyTest:e=>e.code===IP.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),_c=F({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{po(vP(r))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Bt.EVENTUALLY}},predicate:(e,o,t,n)=>bc&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(wP),keywords:["text","clipboard","copy"]});import{CODES as SP,KEYS as CP}from"@excalidraw/common";import{CaptureUpdateAction as kP}from"@excalidraw/element";var Dc=F({name:"gridMode",icon:sb,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:kP.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[CP.CTRL_OR_CMD]&&e.code===SP.QUOTE});import{CODES as MP,KEYS as PP}from"@excalidraw/common";import{CaptureUpdateAction as LP}from"@excalidraw/element";var Li=F({name:"zenMode",label:"buttons.zenMode",icon:ab,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:LP.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t,n)=>n.editorInterface.formFactor!=="phone"&&typeof t.zenModeEnabled>"u",keyTest:e=>!e[PP.CTRL_OR_CMD]&&e.altKey&&e.code===MP.Z});import{CODES as AP,KEYS as _P}from"@excalidraw/common";import{CaptureUpdateAction as DP}from"@excalidraw/element";var yu=F({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:ib,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:DP.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[_P.CTRL_OR_CMD]&&e.altKey&&e.code===AP.S});import{CODES as RP,KEYS as NP}from"@excalidraw/common";import{CaptureUpdateAction as BP}from"@excalidraw/element";var Ai=F({name:"stats",label:"stats.fullTitle",icon:eb,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:BP.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[NP.CTRL_OR_CMD]&&e.altKey&&e.code===RP.SLASH});import{BOUND_TEXT_PADDING as Rx,ROUNDNESS as Nx,TEXT_ALIGN as Ox,VERTICAL_ALIGN as zx,arrayToMap as Hx,getFontString as FP}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as OP,isBoundToContainer as Bx,resetOriginalContainerCache as zP,updateOriginalContainerCache as HP}from"@excalidraw/element";import{computeBoundTextPosition as GP,computeContainerDimensionForBoundText as Fx,getBoundTextElement as Gx,redrawTextBoundingBox as Ux}from"@excalidraw/element";import{hasBoundTextElement as UP,isArrowElement as WP,isTextBindableContainer as wu,isTextElement as nl,isUsingAdaptiveRadius as YP}from"@excalidraw/element";import{measureText as VP}from"@excalidraw/element";import{syncMovedIndices as Wx}from"@excalidraw/element";import{newElement as XP}from"@excalidraw/element";import{CaptureUpdateAction as vu}from"@excalidraw/element";var Iu=F({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>n.scene.getSelectedElements(o).some(i=>UP(i)),perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=n.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=Gx(a,i);if(l){let{width:s,height:c}=VP(l.originalText,FP(l),l.lineHeight),m=OP(a.id);zP(a.id);let{x:p,y:d}=GP(a,l,i);n.scene.mutateElement(l,{containerId:null,width:s,height:c,text:l.originalText,x:p,y:d}),n.scene.mutateElement(a,{boundElements:a.boundElements?.filter(h=>h.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:vu.IMMEDIATELY}}}),Tu=F({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);if(r.length===2){let i=nl(r[0])||nl(r[1]),a;if(wu(r[0])?a=r[0]:wu(r[1])&&(a=r[1]),i&&a&&Gx(a,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i,a;nl(r[0])&&wu(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),n.scene.mutateElement(i,{containerId:a.id,verticalAlign:zx.MIDDLE,textAlign:Ox.CENTER,autoResize:!0,angle:WP(a)?0:a?.angle??0}),n.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Ux(i,a,n.scene),HP(a.id,l),{elements:KP(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:vu.IMMEDIATELY}}}),KP=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===t.id);n.splice(r,1);let i=n.findIndex(a=>a.id===o.id);return n.splice(i+1,0,t),Wx(n,Hx([o,t])),n},ZP=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===o.id);n.splice(r,1);let i=n.findIndex(a=>a.id===t.id);return n.splice(i,0,o),Wx(n,Hx([o,t])),n},Yx=F({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=r.some(a=>nl(a)&&!Bx(a));return r.length>0&&i},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of r)if(nl(l)&&!Bx(l)){let s=XP({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:YP("rectangle")?Nx.ADAPTIVE_RADIUS:Nx.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-Rx,y:l.y-Rx,width:Fx(l.width,"rectangle"),height:Fx(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(p=>p.type==="arrow").map(p=>p.id);i.filter(p=>c.includes(p.id)).forEach(p=>{let d=p.startBinding,h=p.endBinding;d?.elementId===l.id&&(d={...d,elementId:s.id}),h?.elementId===l.id&&(h={...h,elementId:s.id}),(d||h)&&n.scene.mutateElement(p,{startBinding:d,endBinding:h})})}n.scene.mutateElement(l,{containerId:s.id,verticalAlign:zx.MIDDLE,boundElements:null,textAlign:Ox.CENTER,autoResize:!0}),Ux(l,s,n.scene),i=ZP([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:vu.IMMEDIATELY}}});import{isEmbeddableElement as mL}from"@excalidraw/element";import{KEYS as ey}from"@excalidraw/common";import{CaptureUpdateAction as pL}from"@excalidraw/element";import{pointFrom as Zx}from"@excalidraw/math";import $P from"clsx";import{useCallback as Vx,useEffect as Xx,useLayoutEffect as jP,useRef as qP,useState as JP}from"react";import{EVENT as Su,HYPERLINK_TOOLTIP_DELAY as QP,KEYS as Rc}from"@excalidraw/common";import{getElementAbsoluteCoords as Lu}from"@excalidraw/element";import{hitElementBoundingBox as eL}from"@excalidraw/element";import{isElementLink as tL}from"@excalidraw/element";import{getEmbedLink as oL,embeddableURLValidator as nL}from"@excalidraw/element";import{sceneCoordsToViewportCoords as $x,viewportCoordsToSceneCoords as rL,wrapEvent as iL,isLocalLink as aL,normalizeLink as Cu}from"@excalidraw/common";import{isEmbeddableElement as ku}from"@excalidraw/element";import{jsx as _i,jsxs as Kx}from"react/jsx-runtime";var Au=380,lL=42,Mu=5,jx=85,sL=500,Pu=!1,Nc=new Map,qx=({element:e,scene:o,setAppState:t,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=So(),s=Co(),c=de(),m=e.link||"",[p,d]=JP(m),h=qP(null),f=l.showHyperlinkPopup==="editor",b=Vx(()=>{if(!h.current)return;let v=Cu(h.current.value)||null;if(!e.link&&v&&le("hyperlink","create"),ku(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!nL(v,s.validateEmbeddable))v&&r({message:g("toast.unableToEmbed"),closable:!0}),e.link&&Nc.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:I,height:C}=e,P=oL(v);P?.error instanceof URIError&&r({message:g("toast.unrecognizedLinkFormat"),closable:!0});let k=P?P.intrinsicSize.w/P.intrinsicSize.h:1,N=Nc.get(e.id)!==e.link;o.mutateElement(e,{...N?{width:P?.type==="video"?I>C?I:C*k:I,height:P?.type==="video"&&I>C?I/k:C}:{},link:v}),i(e,!0),Nc.has(e.id)&&Nc.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,r,s.validateEmbeddable,l.activeEmbeddable,t,i]);jP(()=>()=>{b()},[b]),Xx(()=>{f&&h?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&h.current.select()},[f,c.formFactor,c.isTouchScreen]),Xx(()=>{let v=null,I=C=>{if(f)return;v&&clearTimeout(v),dL(e,a,l,Zx(C.clientX,C.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},sL))};return window.addEventListener(Su.POINTER_MOVE,I,!1),()=>{window.removeEventListener(Su.POINTER_MOVE,I,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let E=Vx(()=>{le("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),w=()=>{le("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:x}=Jx(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:Kx("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${y}px`,width:Au,padding:Mu},children:[f?_i("input",{className:$P("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:h,value:p,onChange:v=>d(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[Rc.CTRL_OR_CMD]&&v.key===Rc.K&&v.preventDefault(),(v.key===Rc.ENTER||v.key===Rc.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?_i("a",{href:Cu(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:aL(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&n){let I=iL(Su.EXCALIDRAW_LINK,v.nativeEvent);n({...e,link:Cu(e.link)},I),I.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):_i("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),Kx("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&_i(V,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:Io}),_i(V,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Rs}),m&&!ku(e)&&_i(V,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:E,className:"excalidraw-hyperlinkContainer--remove",icon:Zo})]})]})},Jx=(e,o,t)=>{let[n,r]=Lu(e,t),{x:i,y:a}=$x({sceneX:n+e.width/2,sceneY:r},o),l=i-o.offsetLeft-Au/2,s=a-o.offsetTop-jx;return{x:l,y:s}},_u=(e,o)=>{let t=q(e,o);return ku(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},rl=null,Qx=(e,o,t)=>{rl&&clearTimeout(rl),rl=window.setTimeout(()=>cL(e,o,t),QP)},cL=(e,o,t)=>{if(!e.link)return;let n=yi();n.classList.add("excalidraw-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=tL(e.link)?g("labels.link.goToElement"):e.link;let[r,i,a,l]=Lu(e,t),[s,c,m,p]=c1([r,i,a,l],e.angle,o),d=$x({sceneX:s,sceneY:c},o);Xp(n,{left:d.x,top:d.y,width:m,height:p},"top"),le("hyperlink","tooltip","link-icon"),Pu=!0},Du=()=>{rl&&clearTimeout(rl),Pu&&(Pu=!1,yi().classList.remove("excalidraw-tooltip--visible"))},dL=(e,o,t,[n,r])=>{let{x:i,y:a}=rL({clientX:n,clientY:r},t),l=15/t.zoom.value;if(eL(Zx(i,a),e,o))return!1;let[s,c,m]=Lu(e,o);if(i>=s&&i<=m&&a>=c-jx&&a<=c)return!1;let{x:p,y:d}=Jx(e,t,o);return!(n>=p-l&&n<=p+Au+Mu*2+l&&r>=d-l&&r<=d+l+Mu*2+lL)};import{jsx as uL}from"react/jsx-runtime";var il=F({name:"hyperlink",label:(e,o)=>_u(e,o),icon:Ma,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:pL.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[ey.CTRL_OR_CMD]&&e.key===ey.K,predicate:(e,o)=>q(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=q(e,o);return uL(V,{type:"button",icon:Ma,"aria-label":g(_u(e,o)),title:`${mL(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${A("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as ty,arrayToMap as Nu,randomId as hL}from"@excalidraw/common";import{elementsAreInSameGroup as gL,newElementWith as oy,selectGroupsFromGivenElements as ny}from"@excalidraw/element";import{CaptureUpdateAction as ry}from"@excalidraw/element";var Ru=e=>e.every(o=>!o.locked),al=F({name:"toggleElementLock",label:(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Ru(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=q(o,e);return Ru(t)?hn:Ko},trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=Ru(r),a=Nu(r),l=r.length>1&&gL(r),c=r.length===1||l?null:hL(),m={...o.lockedMultiSelections};if(i)m={...o.lockedMultiSelections,...c?{[c]:!0}:{}};else if(l){let w=r[0].groupIds.at(-1);delete m[w]}let p=e.map(w=>{if(!a.has(w.id))return w;let y=w.groupIds;return i?c&&(y=[...y,c]):y=y.filter(x=>!o.lockedMultiSelections[x]),oy(w,{locked:i,groupIds:y.length!==w.groupIds.length?y:w.groupIds})}),d=Nu(p),h=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),f=r.map(w=>d.get(w.id)||w),b=i?{}:ny(f,o),E=i?c||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:p,appState:{...o,selectedElementIds:h,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:E},captureUpdate:ry.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key.toLocaleLowerCase()===ty.L&&e[ty.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),iy=F({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Ko,predicate:(e,o)=>q(e,o).length===0&&e.some(n=>n.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),n=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return oy(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),r=Nu(n),i=t.map(a=>r.get(a.id)||a);return{elements:n,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:ny(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:ry.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as A_,isLinearElement as __,isLineElement as Ji}from"@excalidraw/element";import{arrayToMap as D_,invariant as Bh}from"@excalidraw/common";import{toggleLinePolygonState as R_,CaptureUpdateAction as Ew}from"@excalidraw/element";import X2 from"clsx";import S8 from"fuzzy";import{useEffect as dd,useRef as K2,useMemo as C8,useState as cd}from"react";import{DEFAULT_SIDEBAR as W2,EVENT as pd,KEYS as go,capitalizeString as k8,isWritableElement as M8}from"@excalidraw/common";import{CaptureUpdateAction as qL}from"@excalidraw/element";import{useEffect as cl,useMemo as ay,useRef as zu,useState as fL}from"react";import{getLinearElementSubType as Ni,updateElbowArrowPoints as bL}from"@excalidraw/element";import{pointFrom as Fc,pointRotateRads as EL}from"@excalidraw/math";import{hasBoundTextElement as xL,isArrowBoundToElement as yL,isArrowElement as wL,isElbowArrow as vL,isLinearElement as Wu,isUsingAdaptiveRadius as IL}from"@excalidraw/element";import{getCommonBoundingBox as TL,getElementAbsoluteCoords as SL}from"@excalidraw/element";import{getBoundTextElement as my,getBoundTextMaxHeight as CL,getBoundTextMaxWidth as kL,redrawTextBoundingBox as ML}from"@excalidraw/element";import{wrapText as PL}from"@excalidraw/element";import{assertNever as LL,CLASSES as AL,getFontString as Bu,isProdEnv as _L,mapFind as DL,reduceToCommonValue as RL,updateActiveTool as ly}from"@excalidraw/common";import{measureText as sy}from"@excalidraw/element";import{LinearElementEditor as NL}from"@excalidraw/element";import{newArrowElement as Fu,newElement as BL,newLinearElement as FL}from"@excalidraw/element";import{ShapeCache as OL}from"@excalidraw/element";import{updateBindings as zL}from"@excalidraw/element";import{jsx as Uu}from"react/jsx-runtime";var HL=8,GL=10,ll=["rectangle","diamond","ellipse"],sl=["line","sharpArrow","curvedArrow","elbowArrow"],UL=new Set(ll),WL=new Set(sl),Bi=e=>UL.has(e),zc=e=>e==="arrow"||WL.has(e),ho=Se(null),dl=new Map,ml=new Map,YL=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=zu(null);return cl(()=>{if(o.length===0){e.updateEditorAtom(ho,null);return}let n=Fi(o);n&&!t.current?t.current=n:(t.current&&!n||t.current&&n!==t.current)&&(e.updateEditorAtom(ho,null),t.current=null)},[o,e]),cl(()=>()=>{dl.clear(),ml.clear()},[]),Uu(VL,{app:e,elements:o})},VL=({app:e,elements:o})=>{let t=Fi(o),n=ay(()=>t==="generic"?uy(o):[],[t,o]),r=ay(()=>t==="linear"?Gu(o):[],[t,o]),i=t==="generic"?n.every(p=>p.type===n[0].type):t==="linear"?r.every(p=>Ni(p)===Ni(r[0])):!1,[a,l]=fL({x:0,y:0}),s=zu(""),c=zu(null);cl(()=>{let p=[...n,...r].sort((E,w)=>E.id.localeCompare(w.id)),d=`
|
|
8
|
-
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${p.map(E=>E.id).join(",")}`;if(d===s.current)return;s.current=d;let h;if(p.length===1){let[E,,,w,y,x]=SL(p[0],e.scene.getNonDeletedElementsMap());h=EL(Fc(E,w),Fc(y,x),p[0].angle)}else{let{minX:E,maxY:w}=TL(p);h=Fc(E,w)}let{x:f,y:b}=gy({sceneX:h[0],sceneY:h[1]},e.state);l({x:f,y:b})},[n,r,e.scene,e.state]),cl(()=>{for(let p of r){let d=Hu(p.id,jL(p));ml.has(d)||ml.set(d,p)}},[r]),cl(()=>{for(let p of n)if(!dl.has(p.id)){let d=my(p,e.scene.getNonDeletedElementsMap());d&&dl.set(p.id,{fontSize:d.fontSize})}},[n,e.scene]);let m=t==="linear"?[["line",$r],["sharpArrow",oi],["curvedArrow",ri],["elbowArrow",ni]]:t==="generic"?[["rectangle",Xr],["diamond",Kr],["ellipse",Zr]]:[];return Uu("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(GL+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-HL}px`,zIndex:2},className:AL.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([p,d])=>{let h=i&&(t==="generic"&&n[0].type===p||t==="linear"&&Ni(r[0])===p);return Uu(V,{className:"Shape",type:"radio",icon:d,checked:h,name:"convertElementType-option",title:p,keyBindingLabel:"","aria-label":p,"data-testid":`toolbar-${p}`,onChange:()=>{e.state.activeTool.type!==p&&le("convertElementType",p,"ui"),Yu(e,{conversionType:t,nextType:p}),c.current?.focus()}},`${o[0].id}${o[0].version}_${p}`)})})},XL=(e,o,t)=>{let n=kL(e,o),r=CL(e,o),i=PL(o.text,Bu(o),n),a=sy(i,Bu(o),o.lineHeight),l=o.fontSize;for(;(a.width>n||a.height>r)&&l>0;){l-=1;let s={...o,fontSize:l};a=sy(o.text,Bu(s),o.lineHeight)}Hc(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),ML(o,e,t)},Yu=(e,{conversionType:o,nextType:t,direction:n="right"})=>{if(!o)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=n==="right"?1:-1;if(o==="generic"){let l=uy(r),c=l.every(m=>m.type===l[0].type)?ll.indexOf(l[0].type):-1;if(t=t??ll[(c+ll.length+a)%ll.length],t&&Bi(t)){let m={};for(let d of l){let h=dy(d,t,e);m[h.id]=h}let p=[];for(let d of e.scene.getElementsIncludingDeleted())m[d.id]?p.push(m[d.id]):p.push(d);e.scene.replaceAllElements(p);for(let d of Object.values(m)){let h=my(d,e.scene.getNonDeletedElementsMap());h&&(dl.get(d.id)&&Hc(h,e.scene.getNonDeletedElementsMap(),{fontSize:dl.get(d.id)?.fontSize??h.fontSize}),XL(d,h,e.scene))}e.setState(d=>({selectedElementIds:i,activeTool:ly(d,{type:"selection"})}))}}if(o==="linear"){let l=Gu(r);if(!t){let c=RL(l,Ni),m=c?sl.indexOf(c):-1;t=sl[(m+sl.length+a)%sl.length]}if(zc(t)){let c=[],m=e.scene.getElementsMapIncludingDeleted();for(let p of l){let d=ml.get(Hu(p.id,t));if(d&&Ni(d)===t)m.set(d.id,d),c.push(d);else{let h=dy(p,t,e);m.set(h.id,h),c.push(h)}}e.scene.replaceAllElements(m);for(let p of c)if(Wu(p))if(vL(p)){let d=KL(p);if(d.length<2)continue;let h=[];for(let b=1;b<d.length-2;b++)h.push({start:d[b],end:d[b+1],index:b+1});let f=bL(p,e.scene.getNonDeletedElementsMap(),{points:d,fixedSegments:h});Hc(p,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let d=DL(["line","sharpArrow","curvedArrow"],h=>ml.get(Hu(p.id,h)));if(d){let h=d.points;e.scene.mutateElement(p,{points:h})}}}let s=Gu(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:s.length===1?new NL(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:ly(c,{type:"selection"})}))}return!0},Fi=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(Bi(t.type))return"generic";py(t)&&(o=!0)}return o?"linear":null},py=e=>Wu(e)&&(!wL(e)||!yL(e)&&!xL(e)),Hu=(e,o)=>`${e}:${o}`,uy=e=>e.filter(o=>Bi(o.type)),Gu=e=>e.filter(o=>py(o)),Bc=20,Di=(e,o)=>e[0]===o[0],Ou=(e,o)=>e[1]===o[1],cy=(e,o)=>Di(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),KL=e=>{let o=[e.points[0]],t=ZL(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<Bc?l[0]=a[0]:Math.abs(l[1]-a[1])<Bc&&(l[1]=a[1]),Di(a,l)||Ou(a,l)||o.push(Fc(a[0],l[1])),o.push(l)}let n=[o[0]];for(let i=1;i<o.length-1;++i)Di(o[i-1],o[i])&&Di(o[i],o[i+1])||Ou(o[i-1],o[i])&&Ou(o[i],o[i+1])||n.push(o[i]);n.push(o[o.length-1]);let r=[n[0]];for(let i=1;i<n.length-1;++i){let a=r[r.length-1],l=n[i],s=n[i+1],c=Di(a,l),m=Di(l,s);if(c!==m){let p=cy(a,l),d=cy(l,s);if(p<Bc||d<Bc){if(d<p)c?s[0]=a[0]:s[1]=a[1];else if(m)for(let h=r.length-1;h>=0&&r[h][0]===a[0];--h)r[h][0]=l[0];else for(let h=r.length-1;h>=0&&r[h][1]===a[1];--h)r[h][1]=l[1];continue}}r.push(l)}return r.push(n[n.length-1]),r},ZL=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[n,r]=o[o.length-1],[i,a]=e[t];(n!==i||r!==a)&&o.push(e[t])}return o},dy=(e,o,t)=>{if(!$L(e.type,o)){if(!_L())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(OL.delete(e),Bi(o)){let n=Ri(BL({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:IL(o)?Oc.ADAPTIVE_RADIUS:Oc.PROPORTIONAL_RADIUS}:e.roundness}));return zL(n,t.scene,t.state),n}if(zc(o))switch(o){case"line":return Ri(FL({...e,type:"line"}));case"sharpArrow":return Ri(Fu({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Ri(Fu({...e,type:"arrow",elbowed:!1,roundness:{type:Oc.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Ri(Fu({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return LL(o,`unhandled conversion type: ${o}`),e},$L=(e,o)=>!!(Bi(e)&&Bi(o)||zc(e)&&zc(o)),jL=e=>Wu(e)?Ni(e):e.type,hy=YL;var fy=F({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,n){return $e.set(ho,{type:"panel"}),{captureUpdate:qL.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>Fi(e)!==null});import{canCreateLinkFromElements as Vu,defaultGetElementLinkFromSelection as JL,getLinkIdAndTypeFromSelection as QL}from"@excalidraw/element";import{CaptureUpdateAction as pl}from"@excalidraw/element";var Gc=F({name:"copyElementLink",label:"labels.copyElementLink",icon:Qr,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=q(e,o);try{if(window.location){let i=QL(r,o);return i?(await po(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):JL(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:pl.EVENTUALLY}):{appState:o,elements:e,app:n,captureUpdate:pl.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:n,captureUpdate:pl.EVENTUALLY}},predicate:(e,o)=>Vu(q(e,o))}),by=F({name:"linkToElement",label:"labels.linkToElement",icon:Rs,perform:(e,o,t,n)=>{let r=q(e,o);return r.length!==1||!Vu(r)?{elements:e,appState:o,app:n,captureUpdate:pl.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:q(e,o)[0].id}},captureUpdate:pl.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=q(e,o);return o.openDialog?.name!=="elementLinkSelector"&&r.length===1&&Vu(r)},trackEvent:!1});import{isDarwin as Ey}from"@excalidraw/common";var eA={toggleTheme:[A("Shift+Alt+D")],saveScene:[A("CtrlOrCmd+S")],loadScene:[A("CtrlOrCmd+O")],imageExport:[A("CtrlOrCmd+Shift+E")],commandPalette:[A("CtrlOrCmd+/"),A("CtrlOrCmd+Shift+P")],cut:[A("CtrlOrCmd+X")],copy:[A("CtrlOrCmd+C")],paste:[A("CtrlOrCmd+V")],copyStyles:[A("CtrlOrCmd+Alt+C")],pasteStyles:[A("CtrlOrCmd+Alt+V")],selectAll:[A("CtrlOrCmd+A")],deleteSelectedElements:[A("Delete")],duplicateSelection:[A("CtrlOrCmd+D"),A(`Alt+${g("helpDialog.drag")}`)],sendBackward:[A("CtrlOrCmd+[")],bringForward:[A("CtrlOrCmd+]")],sendToBack:[Ey?A("CtrlOrCmd+Alt+["):A("CtrlOrCmd+Shift+[")],bringToFront:[Ey?A("CtrlOrCmd+Alt+]"):A("CtrlOrCmd+Shift+]")],copyAsPng:[A("Shift+Alt+C")],group:[A("CtrlOrCmd+G")],ungroup:[A("CtrlOrCmd+Shift+G")],gridMode:[A("CtrlOrCmd+'")],zenMode:[A("Alt+Z")],objectsSnapMode:[A("Alt+S")],stats:[A("Alt+/")],addToLibrary:[],flipHorizontal:[A("Shift+H")],flipVertical:[A("Shift+V")],viewMode:[A("Alt+R")],hyperlink:[A("CtrlOrCmd+K")],toggleElementLock:[A("CtrlOrCmd+Shift+L")],resetZoom:[A("CtrlOrCmd+0")],zoomOut:[A("CtrlOrCmd+-")],zoomIn:[A("CtrlOrCmd++")],zoomToFitSelection:[A("Shift+3")],zoomToFit:[A("Shift+1")],zoomToFitSelectionInViewport:[A("Shift+2")],toggleEraserTool:[A("E")],toggleHandTool:[A("H")],setFrameAsActiveTool:[A("F")],saveFileToDisk:[A("CtrlOrCmd+S")],saveToActiveFile:[A("CtrlOrCmd+S")],toggleShortcuts:[A("?")],searchMenu:[A("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[A("Shift+R")]},Ae=(e,o=0)=>{let t=eA[e];return t&&t.length>0?t[o]||t[0]:""};var tA="\\u0300-\\u036f",oA="\\ufe20-\\ufe2f",nA="\\u20d0-\\u20ff",rA=tA+oA+nA,iA=`[${rA}]`,aA=RegExp(iA,"g"),lA=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,sA={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},ur=e=>e.replace(lA,o=>sA[o]||o).replace(aA,"");import i8 from"clsx";import{useEffect as a8,useState as l8}from"react";import{KEYS as s8,queryFocusableElements as w2}from"@excalidraw/common";import{useCallback as cA,useState as dA}from"react";var xy=()=>{let[e,o]=dA(null),t=cA(n=>o(n),[]);return[e,t]};import{useState as g2,useCallback as dh,useMemo as f2,useEffect as mh,memo as b2,useRef as Y7}from"react";import{LIBRARY_DISABLED_TYPES as V7,randomId as X7,isShallowEqual as K7,KEYS as Z7,isWritableElement as $7,addEventListener as j7,EVENT as q7,CLASSES as p2}from"@excalidraw/common";import{useEffect as Iy,useRef as Ty}from"react";import{URL_HASH_KEYS as Zu,URL_QUERY_KEYS as $u,APP_NAME as Sy,EVENT as Wc,DEFAULT_SIDEBAR as hA,LIBRARY_SIDEBAR_TAB as gA,arrayToMap as ju,cloneJSON as fA,preventUnload as bA,promiseTry as Cy,resolvablePromise as EA,toValidURL as xA,Queue as yA,Emitter as wA}from"@excalidraw/common";import{hashElementsVersion as vA,hashString as IA}from"@excalidraw/element";import{getCommonBoundingBox as Ku}from"@excalidraw/element";import{MIME_TYPES as hr}from"@excalidraw/common";var Oi=({elements:e,appState:o,files:t,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let l=qn(e,null,{deleteInvisibleElements:!0}),s=Ur(o,null),{exportBackground:c,viewBackgroundColor:m}=s;return hs(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(p,d)=>{let h=document.createElement("canvas");if(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(p,d),E=n<b?n/b:o?.exportScale??1;return h.width=p*E,h.height=d*E,{canvas:h,scale:E}}let f=r?.(p,d)||{width:p,height:d};return h.width=f.width,h.height=f.height,{canvas:h,scale:f.scale??1}})},yy=async e=>{let{mimeType:o=hr.png,quality:t}=e;o===hr.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${hr.png}" mimeType`),o==="image/jpg"&&(o=hr.jpg),o===hr.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${hr.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await Oi(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((r,i)=>{n.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===hr.png&&e.appState?.exportEmbedScene&&(a=await g1({blob:a,metadata:wa(e.elements,e.appState,e.files||{},"local")})),r(a)},o,t)})},zi=async({elements:e,appState:o=zr(),files:t={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let s=qn(e,null,{deleteInvisibleElements:!0}),m={...Ur(o,null),exportPadding:n};return Gr(s,m,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:l})},mA=async e=>{if(e.type==="svg"){let o=await zi(e);await po(o.outerHTML)}else if(e.type==="png")await xc(yy(e));else if(e.type==="json")await Ec(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as wy,useState as pA}from"react";import{COLOR_PALETTE as uA}from"@excalidraw/common";var Xu=Se(new Map),vy=async e=>await zi({elements:e,appState:{exportBackground:!1,viewBackgroundColor:uA.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),Uc=(e,o,t,n)=>{let[r,i]=pA();return wy(()=>{if(o)if(e){let a=t.get(e);a?i(a):(async()=>{let l=await vy(o);l.querySelector(".style-fonts")?.remove(),l&&(t.set(e,l),i(l))})()}else(async()=>{let a=await vy(o);i(a)})()},[e,o,t,i]),wy(()=>{let a=n.current;if(a)return r&&(a.innerHTML=r.outerHTML),()=>{a.innerHTML=""}},[r,n]),r},Hi=()=>{let[e]=ue(Xu);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var TA=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],My=new wA,en=Se({status:"loaded",isInitialized:!1,libraryItems:[]}),ul=e=>fA(e),SA=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((n,r)=>n.id===o.elements[r].id&&n.versionNonce===o.elements[r].versionNonce)),Py=(e,o)=>{let t=[];for(let n of o)SA(e,n)&&t.push(n);return[...t,...e]},Ly=(e,o)=>{let t=ju(o),n={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let i of e)t.has(i.id)||n.deletedItems.set(i.id,i);let r=ju(e);for(let i of o){let a=r.get(i.id);a?Qu(a)!==Qu(i)&&n.updatedItems.set(i.id,i):n.addedItems.set(i.id,i)}return n},qu=class{constructor(o){S(this,"currLibraryItems",[]);S(this,"prevLibraryItems",ul(this.currLibraryItems));S(this,"app");S(this,"updateQueue",[]);S(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);S(this,"notifyListeners",()=>{if(this.updateQueue.length>0)$e.set(en,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{$e.set(en,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=ul(this.currLibraryItems);let t=ul(this.currLibraryItems);this.app.props.onLibraryChange?.(t),My.trigger(Ly(o,t),t)}catch(o){console.error(o)}}});S(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],$e.set(Xu,new Map)});S(this,"resetLibrary",()=>this.setLibrary([]));S(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(ul(t))}catch{return o(this.currLibraryItems)}}));S(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:hA.name,tab:gA}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await Am(s,i):c=Ia(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),a(n?Py(this.currLibraryItems,c):c)):l(new Or)}catch(s){l(s)}}))));S(this,"setLibrary",o=>{let t=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=ul(await o),n(this.currLibraryItems)}catch(i){r(i)}}).catch(n=>{if(n.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw n}).finally(()=>{this.updateQueue=this.updateQueue.filter(n=>n!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},Ay=qu,Ui=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=h=>e.slice(h*t,h*t+t).reduce((b,E)=>{let{height:w}=Ku(E.elements);return Math.max(b,w)},0),i=h=>{let f=0,b=0,E=0;for(let w of e){if(f%t===0&&(b=0),b===h){let{width:y}=Ku(w.elements);E=Math.max(E,y)}f++,b++}return E},a=0,l=0,s=0,c=0,m=0,p=0,d=0;for(let h of e){m&&m%t===0&&(l+=s+50,a=0,p=0,d++),p===0&&(s=r(d)),c=i(p);let{minX:f,minY:b,width:E,height:w}=Ku(h.elements),y=(c-E)/2,x=(s-w)/2;n.push(...h.elements.map(v=>({...v,x:v.x+a+y-f,y:v.y+l+x-b}))),a+=c+50,m++,p++}return n},CA=(e,o=TA)=>{if(typeof o=="function"?o(e):o.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:r,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${n.hostname}$`).test(r)&&new RegExp(`^${n.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},Ju=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Zu.addLibrary)||new URLSearchParams(window.location.search).get($u.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},Pn=class Pn{constructor(o){S(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,n=!0){let r=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(Ia(l?.libraryItems||[],"published"))}catch(l){a(l)}});return n?Pn.queue.push(r):r()}getLibraryItems(o){return Pn.getLibraryItems(this.adapter,o,!1)}};S(Pn,"queue",new yA),S(Pn,"run",async(o,t)=>{let n=new Pn(o);return Pn.queue.push(()=>t(n))});var Gi=Pn,hl=0,Yc=0,Qu=e=>`${e.id}:${e.name||""}:${vA(e.elements)}`,Vc=e=>IA(e.map(o=>Qu(o)).sort().join()),ky=async(e,o)=>{try{return Yc++,await Gi.run(e,async t=>{let n=ju(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)n.delete(l);let r=[];for(let[l,s]of o.addedItems)n.has(l)?n.set(l,s):r.push(s);if(o.updatedItems)for(let[l,s]of o.updatedItems)n.set(l,s);let i=r.concat(Array.from(n.values())),a=Vc(i);return a!==hl&&await e.save({libraryItems:i}),hl=a,i})}finally{Yc--}},kA=e=>{let{excalidrawAPI:o}=e,t=Ty(e);t.current=e;let n=Ty(!1);Iy(()=>{if(!o)return;n.current=!1;let r=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(p,d)=>{try{l=decodeURIComponent(l),l=xA(l),CA(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();p(f)}catch(h){d(h)}}),m=s!==o.id;await(m&&document.hidden?new Promise(p=>{window.addEventListener("focus",()=>p(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(p){throw o.updateScene({appState:{errorMessage:p.message}}),p}finally{if(window.location.hash.includes(Zu.addLibrary)){let p=new URLSearchParams(window.location.hash.slice(1));p.delete(Zu.addLibrary),window.history.replaceState({},Sy,`#${p.toString()}`)}else if(window.location.search.includes($u.addLibrary)){let p=new URLSearchParams(window.location.search);p.delete($u.addLibrary),window.history.replaceState({},Sy,`?${p.toString()}`)}}},i=l=>{l.preventDefault();let s=Ju();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),r(s))},a=Ju();if(a&&r(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,c=EA();s?c.resolve(Cy(s.load).then(async m=>{let p=null;try{if(!m)return Gi.getLibraryItems(l,"load");p=Ia(m.libraryItems||[],"published");let d=await ky(l,Ly([],p));try{await s.clear()}catch(h){console.error(`couldn't delete legacy library data: ${h.message}`)}return d}catch(d){return console.error(`couldn't migrate legacy library data: ${d.message}`),p}}).catch(m=>(console.error(`error during library migration: ${m.message}`),Gi.getLibraryItems(l,"load")))):c.resolve(Cy(Gi.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:c.then(m=>{let p=m||[];return hl=Vc(p),p}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(Wc.HASHCHANGE,i),()=>{window.removeEventListener(Wc.HASHCHANGE,i)}},[o]),Iy(()=>{let r=My.on(async(a,l)=>{let s=n.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&hl!==Vc(l)&&await ky(c,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{Yc&&bA(a)};return window.addEventListener(Wc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(Wc.BEFORE_UNLOAD,i),r(),hl=0,Yc=0}},[])};import AA from"clsx";import{VERSIONS as MA}from"@excalidraw/common";import{jsx as LA}from"react/jsx-runtime";var PA=({theme:e,id:o,libraryReturnUrl:t})=>{let n=t||window.location.origin+window.location.pathname;return LA("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${n}&useHash=true&token=${o}&theme=${e}&version=${MA.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},_y=PA;import{jsx as _A,jsxs as DA}from"react/jsx-runtime";var Xc=({libraryReturnUrl:e,theme:o,id:t,style:n,children:r,className:i})=>DA("div",{className:AA("library-menu-control-buttons",i),style:n,children:[_A(_y,{id:t,libraryReturnUrl:e,theme:o}),r]});import{useCallback as Vi,useEffect as ah,useMemo as lh,useRef as c2,useState as d2}from"react";import{MIME_TYPES as F7,arrayToMap as O7,nextAnimationFrame as z7}from"@excalidraw/common";import{duplicateElements as H7}from"@excalidraw/element";import G7 from"clsx";import RA from"lodash.throttle";import{useEffect as NA}from"react";var BA=Se(0),Dy=e=>{let[o,t]=ue(BA);return NA(()=>{let{current:n}=e;if(!n)return;let r=RA(()=>{let{scrollTop:i}=n;t(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,t]),o};import u7 from"clsx";import{useCallback as h7,useState as nh}from"react";import{muteFSAbortError as g7}from"@excalidraw/common";import{flushSync as Ry}from"react-dom";import FA from"clsx";import{jsx as Kc,jsxs as zA}from"react/jsx-runtime";var OA=({label:e,onClick:o,className:t,children:n,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return zA("button",{className:FA("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[n&&Kc("div",{style:a?{visibility:"hidden"}:{},children:n}),Kc("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Kc("div",{style:{position:"absolute",inset:0},children:Kc(Dt,{})})]})},tn=OA;import{jsx as Ny,jsxs as By}from"react/jsx-runtime";var HA=e=>{let{onConfirm:o,onCancel:t,children:n,confirmText:r=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=he(),c=Wr(Wi),{container:m}=ke();return By(We,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[n,By("div",{className:"confirm-dialog-buttons",children:[Ny(tn,{label:i,onClick:()=>{s({openMenu:null}),c(!1),Ry(()=>{t()}),m?.focus()}}),Ny(tn,{label:r,onClick:()=>{s({openMenu:null}),c(!1),Ry(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},Fy=HA;import{useCallback as KA,useEffect as oh,useRef as Oy,useState as eh}from"react";import{EDITOR_LS_KEYS as th,EXPORT_DATA_TYPES as ZA,MIME_TYPES as zy,VERSIONS as $A,chunk as jA,getExportSource as qA}from"@excalidraw/common";var Ln=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};S(Ln,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),S(Ln,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Zc from"react";var GA=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,UA=/{{([\w-]+)}}/,WA=/<([\w-]+)>/,YA=/<\/([\w-]+)>/,VA=(e,o)=>{let t=[{name:"",children:[]}];return e.split(GA).filter(Boolean).forEach(n=>{let r=n.match(WA),i=n.match(YA),a=n.match(UA);if(r!==null){let l=r[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),c=Zc.createElement(Zc.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(c))}else console.warn(`Trans: unexpected end tag ${n} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(n)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},XA=({i18nKey:e,children:o,...t})=>{let{t:n}=Ue();return Zc.createElement(Zc.Fragment,{},...VA(n(e),t))},Ft=XA;import{jsx as me,jsxs as dt}from"react/jsx-runtime";var JA=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=jA(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(n*2)-n*2,a.height=i.length*128+(i.length+1)*(n*2)-n*2;let l=a.getContext("2d");l.fillStyle="#fff",l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let m=await Oi({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:p,height:d}=m,h=Math.floor(s/6)*(128+n*2),f=s%6*(128+n*2);l.drawImage(m,f+(128-p)/2+n,h+(128-d)/2+n),l.lineWidth=r,l.strokeStyle="#ced4da",l.strokeRect(f+n/2,h+n/2,128+n,128+n)}return await bs(new File([await Jn(a)],"preview",{type:zy.png}),{outputType:zy.jpg,maxWidthOrHeight:5e3})},QA=({libItem:e,appState:o,index:t,onChange:n,onRemove:r})=>{let i=Oy(null),a=Oy(null);return oh(()=>{let l=i.current;l&&(async()=>{let s=await zi({elements:e.elements,appState:{...o,viewBackgroundColor:"#fff",exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),dt("div",{className:"single-library-item",children:[e.status==="published"&&me("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),me("div",{ref:i,className:"single-library-item__svg"}),me(V,{"aria-label":g("buttons.remove"),type:"button",icon:Ut,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:g("buttons.remove")}),dt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[dt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[dt("div",{style:{padding:"0.5em 0"},children:[me("span",{style:{fontWeight:500,color:"#868e96"},children:g("publishDialog.itemName")}),me("span",{"aria-hidden":"true",className:"required",children:"*"})]}),me("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{n(l.target.value,t)}})]}),me("span",{className:"error",children:e.error})]})]})},e7=({onClose:e,libraryItems:o,appState:t,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=eh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=eh(!1);oh(()=>{let x=Ln.get(th.PUBLISH_LIBRARY);x&&s(x)},[]);let[p,d]=eh(o.slice());oh(()=>{d(o.slice())},[o]);let h=x=>{s({...l,[x.target.name]:x.target.value})},f=async x=>{x.preventDefault(),m(!0);let v=[],I=!1;if(p.forEach(L=>{let B="";L.name||(B=g("publishDialog.errors.required"),I=!0),v.push({...L,error:B})}),I){d(v),m(!1);return}let C=await JA(p),P={type:ZA.excalidrawLibrary,version:$A.excalidrawLibrary,source:qA(),libraryItems:p},k=JSON.stringify(P,null,2),N=new Blob([k],{type:"application/json"}),_=new FormData;_.append("excalidrawLib",N),_.append("previewImage",C),_.append("previewImageType",C.type),_.append("title",l.name),_.append("authorName",l.authorName),_.append("githubHandle",l.githubHandle),_.append("name",l.name),_.append("description",l.description),_.append("twitterHandle",l.twitterHandle),_.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:_}).then(L=>L.ok?L.json().then(({url:B})=>{Ln.delete(th.PUBLISH_LIBRARY),n({url:B,authorName:l.authorName,items:p})}):L.json().catch(()=>{throw new Error(L.statusText||"something went wrong")}).then(B=>{throw new Error(B.message||L.statusText||"something went wrong")}),L=>{console.error(L),r(L),m(!1)}).catch(L=>{console.error(L),r(L),m(!1)})},b=()=>{let x=[];return p.forEach((v,I)=>{x.push(me("div",{className:"single-library-item-wrapper",children:me(QA,{libItem:v,appState:t,index:I,onChange:(C,P)=>{let k=p.slice();k[P].name=C,d(k)},onRemove:a})},I))}),me("div",{className:"selected-library-items",children:x})},E=KA(()=>{i(p),Ln.set(th.PUBLISH_LIBRARY,l),e()},[p,e,i,l]),w=!!o.length,y=o.some(x=>x.status==="published");return me(We,{onCloseRequest:E,title:g("publishDialog.title"),className:"publish-library",children:w?dt("form",{onSubmit:f,children:[me("div",{className:"publish-library-note",children:me(Ft,{i18nKey:"publishDialog.noteDescription",link:x=>me("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:x})})}),me("span",{className:"publish-library-note",children:me(Ft,{i18nKey:"publishDialog.noteGuidelines",link:x=>me("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:x})})}),me("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),y&&me("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),dt("div",{className:"publish-library__fields",children:[dt("label",{children:[dt("div",{children:[me("span",{children:g("publishDialog.libraryName")}),me("span",{"aria-hidden":"true",className:"required",children:"*"})]}),me("input",{type:"text",name:"name",required:!0,value:l.name,onChange:h,placeholder:g("publishDialog.placeholder.libraryName")})]}),dt("label",{style:{alignItems:"flex-start"},children:[dt("div",{children:[me("span",{children:g("publishDialog.libraryDesc")}),me("span",{"aria-hidden":"true",className:"required",children:"*"})]}),me("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:h,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),dt("label",{children:[dt("div",{children:[me("span",{children:g("publishDialog.authorName")}),me("span",{"aria-hidden":"true",className:"required",children:"*"})]}),me("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:h,placeholder:g("publishDialog.placeholder.authorName")})]}),dt("label",{children:[me("span",{children:g("publishDialog.githubUsername")}),me("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:h,placeholder:g("publishDialog.placeholder.githubHandle")})]}),dt("label",{children:[me("span",{children:g("publishDialog.twitterUsername")}),me("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:h,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),dt("label",{children:[me("span",{children:g("publishDialog.website")}),me("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:h,placeholder:g("publishDialog.placeholder.website")})]}),me("span",{className:"publish-library-note",children:me(Ft,{i18nKey:"publishDialog.noteLicense",link:x=>me("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:x})})})]}),dt("div",{className:"publish-library__buttons",children:[me(tn,{label:g("buttons.saveLibNames"),onClick:E,"data-testid":"cancel-clear-canvas-button"}),me(tn,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:c})]})]}):me("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},Hy=e7;import o2 from"react";import n7 from"clsx";import{useEffect as r7,useRef as i7}from"react";import{EVENT as Yy,KEYS as a7}from"@excalidraw/common";import{forwardRef as Gy}from"react";import Uy from"clsx";import{jsx as Wy}from"react/jsx-runtime";var t7=Gy(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>Wy("div",{className:Uy("Stack Stack_horizontal",r),style:{"--gap":o,alignItems:t,justifyContent:n,...i},ref:a,children:e})),o7=Gy(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>Wy("div",{className:Uy("Stack Stack_vertical",r),style:{"--gap":o,justifyItems:t,justifyContent:n,...i},ref:a,children:e})),Tt={Row:t7,Col:o7};import{jsx as $c}from"react/jsx-runtime";var Vy=({children:e,onClickOutside:o,className:t="",onSelect:n,style:r,placement:i="bottom"})=>{let a=de(),l=i7(null),s=bn({onClickOutside:o});si(l,m=>{l.current?.closest(".dropdown-menu-container")?.contains(m.target)||s.onClickOutside?.()}),r7(()=>{let m=d=>{d.key===a7.ESCAPE&&(d.stopImmediatePropagation(),s.onClickOutside?.())},p={capture:!0};return document.addEventListener(Yy.KEYDOWN,m,p),()=>{document.removeEventListener(Yy.KEYDOWN,m,p)}},[s]);let c=n7(`dropdown-menu ${t}`,{"dropdown-menu--mobile":a.formFactor==="phone","dropdown-menu--placement-top":i==="top"}).trim();return $c(Mp.Provider,{value:{onSelect:n},children:$c("div",{ref:l,className:c,style:r,"data-testid":"dropdown-menu",children:a.formFactor==="phone"?$c(Tt.Col,{className:"dropdown-menu-container",children:e}):$c(ze,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};Vy.displayName="DropdownMenuContent";var Xy=Vy;import{jsx as s7}from"react/jsx-runtime";var l7=({children:e,className:o="",selected:t,...n})=>s7("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),Ky=l7;import{jsx as Zy}from"react/jsx-runtime";var $y=({icon:e,shortcut:o,href:t,children:n,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let c=tc(s.onClick,r);return Zy("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:ec(i,a),title:s.title??s["aria-label"],onClick:c,children:Zy(Qs,{icon:e,shortcut:o,children:n})})},Yi=$y;$y.displayName="DropdownMenuItemLink";import{jsx as c7}from"react/jsx-runtime";var jy=()=>c7("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0",flex:"0 0 auto"}}),qy=jy;jy.displayName="DropdownMenuSeparator";import d7 from"clsx";import{jsx as m7}from"react/jsx-runtime";var Jy=({className:e="",children:o,onToggle:t,title:n,...r})=>{let i=de(),a=d7(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return m7("button",{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:o})},Qy=Jy;Jy.displayName="DropdownMenuTrigger";import jc from"react";var e2=e=>{let o=jc.Children.toArray(e).find(t=>jc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},t2=e=>{let o=jc.Children.toArray(e).find(t=>jc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{jsxs as p7}from"react/jsx-runtime";var on=({children:e,open:o,placement:t})=>{let n=e2(e),r=t2(e),i=r&&o2.isValidElement(r)?o2.cloneElement(r,{placement:t}):r;return p7("div",{className:"dropdown-menu-container",style:{display:"contents"},children:[n,o&&i]})};on.Trigger=Qy;on.Content=Xy;on.Item=vt;on.ItemLink=Yi;on.ItemCustom=Ky;on.Group=Ha;on.Separator=qy;var ge=on;on.displayName="DropdownMenu";import{jsx as St,jsxs as qc}from"react/jsx-runtime";var f7=(e,o)=>e.filter(t=>o.includes(t.id)),b7=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:a,className:l})=>{let[s]=ue(en),[c,m]=ue(Wi),p=()=>{let _=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),L=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return St(Fy,{onConfirm:()=>{o.length?n():r(),h(!1)},onCancel:()=>{h(!1)},title:L,children:St("p",{children:_})})},[d,h]=nh(!1),f=!!o.length,b=f?s.libraryItems.filter(_=>o.includes(_.id)):s.libraryItems,E=f?g("buttons.remove"):g("buttons.resetLibrary"),[w,y]=nh(!1),[x,v]=nh(null),I=h7(()=>qc(We,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[St("p",{children:St(Ft,{i18nKey:"publishSuccessDialog.content",authorName:x.authorName,link:_=>St("a",{href:x?.url,target:"_blank",rel:"noopener noreferrer",children:_})})}),St(V,{type:"button",title:g("buttons.close"),"aria-label":g("buttons.close"),label:g("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,x]),C=(_,L)=>{y(!1),v({url:_.url,authorName:_.authorName});let B=L.slice();B.forEach(G=>{o.includes(G.id)&&(G.status="published")}),t.setLibrary(B)},P=async()=>{try{await t.updateLibrary({libraryItems:ss({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(_){if(_?.name==="AbortError"){console.warn(_);return}e({errorMessage:g("errors.importLibraryError")})}},k=async()=>{let _=f?b:await t.getLatestLibrary();s1(_).catch(g7).catch(L=>{e({errorMessage:L.message})})},N=()=>qc(ge,{open:c,children:[St(ge.Trigger,{onToggle:()=>m(!c),children:_1}),qc(ge.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!f&&St(ge.Item,{onSelect:P,icon:Jr,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&St(ge.Item,{onSelect:k,icon:er,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),f&&St(ge.Item,{icon:G0,onSelect:()=>y(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")}),!!b.length&&St(ge.Item,{onSelect:()=>h(!0),icon:Zo,children:E})]})]});return qc("div",{className:u7("library-menu-dropdown-container",l),children:[N(),o.length>0&&St("div",{className:"library-actions-counter",children:o.length}),d&&p(),w&&St(Hy,{onClose:()=>y(!1),libraryItems:f7(s.libraryItems,o),appState:a,onSuccess:_=>C(_,s.libraryItems),onError:_=>window.alert(_),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:_=>i(o.filter(L=>L!==_))}),x&&I()]})},n2=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:n}=qe(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=Hi(),a=Te(),l=he(),[s]=ue(en),c=async p=>{let d=p.filter(h=>!e.includes(h.id));n.setLibrary(d).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return St(b7,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:n,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:t})};import{memo as S7,useEffect as C7,useState as k7}from"react";import E7,{useCallback as x7}from"react";function y7(){return[!1,x7(o=>o(),[])]}var r2=E7.useTransition||y7;import i2 from"clsx";import{memo as w7,useRef as v7,useState as I7}from"react";import{jsx as Jc,jsxs as T7}from"react/jsx-runtime";var a2=w7(({id:e,elements:o,isPending:t,onClick:n,selected:r,onToggle:i,onDrag:a,svgCache:l})=>{let s=v7(null),c=Uc(e,o,l,s),[m,p]=I7(!1),d=de().formFactor==="phone",h=t&&Jc("div",{className:"library-unit__adder",children:A1});return T7("div",{className:i2("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":r,"library-unit--skeleton":!c}),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[Jc("div",{className:i2("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):n(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}p(!1),a(e,f)}}),h,e&&o&&(m||d||r)&&Jc(Za,{checked:r,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),l2=()=>Jc("div",{className:"library-unit library-unit--skeleton"});import{Fragment as M7,jsx as Qc}from"react/jsx-runtime";var ed=({children:e})=>Qc("div",{className:"library-menu-items-container__grid",children:e}),gl=S7(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=r2(),[s,c]=k7(0);return C7(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),Qc(M7,{children:e.map((m,p)=>p<s?Qc(a2,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:r,svgCache:i,id:m?.id,selected:n(m.id),onToggle:o,onDrag:t},m?.id??p):Qc(l2,{},p))})});import rh from"clsx";import{forwardRef as _7,useRef as D7,useImperativeHandle as R7,useLayoutEffect as N7,useState as B7}from"react";import P7 from"clsx";import{composeEventHandlers as L7}from"@excalidraw/common";import{jsx as A7}from"react/jsx-runtime";var Ot=({type:e="button",onSelect:o,selected:t,children:n,className:r="",...i})=>A7("button",{onClick:L7(i.onClick,a=>{o()}),type:e,className:P7("excalidraw-button",r,{selected:t}),...i,children:n});import{jsx as ih,jsxs as s2}from"react/jsx-runtime";var An=_7(({onChange:e,label:o,fullWidth:t,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:c,type:m,...p},d)=>{let h=D7(null);R7(d,()=>h.current),N7(()=>{i&&(h.current?.focus(),h.current?.select())},[i]);let[f,b]=B7(!1);return s2("div",{className:rh("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{h.current?.focus()},children:[s,o&&ih("div",{className:"ExcTextField__label",children:o}),s2("div",{className:rh("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[ih("input",{className:rh({"is-redacted":"value"in p&&p.value&&l&&!f}),readOnly:r,value:"value"in p?p.value:void 0,defaultValue:"defaultValue"in p?p.defaultValue:void 0,placeholder:n,ref:h,onChange:E=>e?.(E.target.value),onKeyDown:a,type:m}),l&&ih(Ot,{onSelect:()=>b(!f),style:{border:0,userSelect:"none"},children:f?$0:or})]})]})});import{Fragment as m2,jsx as Je,jsxs as Ao}from"react/jsx-runtime";var U7=17,W7=64;function sh({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:n,pendingElements:r,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let m=de(),p=c2(null),d=Dy(p);ah(()=>{d>0&&p.current?.scrollTo(0,d)},[]);let{svgCache:h}=Hi(),[f,b]=d2(null),[E,w]=d2(""),y=!o.length&&!r.length,x=!y&&!!E.trim(),v=lh(()=>{let D=ur(E.trim().toLowerCase());return D?o.filter(O=>{let Q=O.name||"";return Q.trim()&&ur(Q.toLowerCase()).includes(D)}):[]},[o,E]),I=lh(()=>o.filter(D=>D.status!=="published"),[o]),C=lh(()=>o.filter(D=>D.status==="published"),[o]),P=Vi((D,O)=>{let Q=!c.includes(D),ee=[...I,...C];if(Q){if(O.shiftKey&&f){let K=ee.findIndex(yt=>yt.id===f),ae=ee.findIndex(yt=>yt.id===D);if(K===-1||ae===-1){s([...c,D]);return}let be=O7(c),ce=Math.min(K,ae),Oe=Math.max(K,ae),ao=ee.reduce((yt,Vo,Nr)=>((Nr>=ce&&Nr<=Oe||be.has(Vo.id))&&yt.push(Vo.id),yt),[]);s(ao)}else s([...c,D]);b(D)}else b(null),s(c.filter(K=>K!==D))},[f,s,C,c,I]);ah(()=>{c.length||b(null)},[c]);let k=Vi(D=>{let O;return c.includes(D)?O=o.filter(Q=>c.includes(Q.id)):O=o.filter(Q=>Q.id===D),O.map(Q=>({...Q,elements:H7({type:"everything",elements:Q.elements,randomizeSeed:!0}).duplicatedElements}))},[o,c]),N=Vi((D,O)=>{let Q={itemIds:c.includes(D)?c:[D]};O.dataTransfer.setData(F7.excalidrawlibIds,JSON.stringify(Q))},[c]),_=Vi(D=>D?c.includes(D):!1,[c]),L=Vi(()=>{t(r)},[r,t]),B=Vi(D=>{D&&n(k(D))},[k,n]),G=h.size>=(v.length?v:o).length?W7:U7,j=c2(null);ah(()=>{z7(()=>{j.current?.focus()})},[]);let H=!x&&Ao(m2,{children:[!y&&Je("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),!r.length&&!I.length?Ao("div",{className:"library-menu-items__no-items",children:[!C.length&&Je("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),Je("div",{className:"library-menu-items__no-items__hint",children:C.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):Ao(ed,{children:[r.length>0&&Je(gl,{itemsRenderedPerBatch:G,items:[{id:null,elements:r}],onItemSelectToggle:P,onItemDrag:N,onClick:L,isItemSelected:_,svgCache:h}),Je(gl,{itemsRenderedPerBatch:G,items:I,onItemSelectToggle:P,onItemDrag:N,onClick:B,isItemSelected:_,svgCache:h})]}),C.length>0&&Je("div",{className:"library-menu-items-container__header",style:{marginTop:"0.75rem"},children:g("labels.excalidrawLib")}),C.length>0&&Je(ed,{children:Je(gl,{itemsRenderedPerBatch:G,items:C,onItemSelectToggle:P,onItemDrag:N,onClick:B,isItemSelected:_,svgCache:h})})]}),Y=x&&Ao(m2,{children:[Ao("div",{className:"library-menu-items-container__header",children:[g("library.search.heading"),!e&&Ao("div",{className:"library-menu-items-container__header__hint",style:{cursor:"pointer"},onPointerDown:D=>D.preventDefault(),onClick:D=>{w("")},children:[Je("kbd",{children:"esc"})," to clear"]})]}),v.length>0?Je(ed,{children:Je(gl,{itemsRenderedPerBatch:G,items:v,onItemSelectToggle:P,onItemDrag:N,onClick:B,isItemSelected:_,svgCache:h})}):Ao("div",{className:"library-menu-items__no-items",children:[Je("div",{className:"library-menu-items__no-items__hint",children:g("library.search.noResults")}),Je(Ot,{onPointerDown:D=>D.preventDefault(),onSelect:()=>{w("")},style:{width:"auto",marginTop:"1rem"},children:g("library.search.clearSearch")})]})]});return Ao("div",{className:"library-menu-items-container",style:r.length||I.length||C.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[Ao("div",{className:"library-menu-items-header",children:[!y&&Je(An,{ref:j,type:"search",className:G7("library-menu-items-container__search",{hideCancelButton:m.formFactor!=="phone"}),placeholder:g("library.search.inputPlaceholder"),value:E,onChange:D=>w(D)}),Je(n2,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"})]}),Ao(Tt.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:C.length>0?1:"0 1 auto",margin:y?"auto":0},ref:p,children:[e&&Je("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:Je(Dt,{})}),H,Y,y&&Je(Xc,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i})]})]})}import{jsx as _n,jsxs as h2}from"react/jsx-runtime";var Wi=Se(!1),u2=({children:e})=>_n("div",{className:"layer-ui__library",children:e}),J7=b2(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:n,libraryReturnUrl:r,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=ue(en),p=dh(f=>{(async(E,w)=>{le("element","addToLibrary","ui");for(let x of V7)if(E.some(v=>v.type===x))return n({errorMessage:g(`errors.libraryElementTypeError.${x}`)});let y=[{status:"unpublished",elements:E,id:X7(),created:Date.now()},...w];t(),i.setLibrary(y).catch(()=>{n({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,m.libraryItems)},[t,i,n,m.libraryItems]),d=f2(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return _n(u2,{children:_n("div",{className:"layer-ui__library-message",children:h2("div",{children:[_n(Dt,{size:"2em"}),_n("span",{children:g("labels.libraryLoadingMessage")})]})})});let h=m.libraryItems.length>0||o.length>0;return h2(u2,{children:[_n(sh,{isLoading:m.status==="loading",libraryItems:d,onAddToLibrary:p,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:r,theme:l,onSelectItems:c,selectedItems:s}),h&&_n(Xc,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:r,theme:l})]})}),ch=(e,o)=>({elements:e,pending:q(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),Q7=(e,o)=>{let t=yn(),[n,r]=g2(()=>ch(t,e.selectedElementIds)),i=Y7(new Map);return mh(()=>{for(let a of n.pending)i.current.set(a.id,a.version)},[n.pending]),mh(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&r(a=>{if(!K7(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),ch(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=l.get(s)?.version;if(c&&c!==i.current.get(s))return ch(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),n.pending},E2=b2(()=>{let e=qe(),{onInsertElements:o}=e,t=Co(),n=Te(),r=he(),[i,a]=g2([]),l=f2(()=>e.library,[e.library]),s=Q7(n,e);mh(()=>j7(document,q7.KEYDOWN,p=>{if(p.key===Z7.ESCAPE&&p.target instanceof HTMLElement){let d=p.target;if(d.closest(`.${p2.SIDEBAR}`))i.length>0?(p.stopPropagation(),a([])):$7(d)&&d instanceof HTMLInputElement&&!d.value&&(p.stopPropagation(),r({openSidebar:null}),e.focusContainer());else if(i.length>0){let{x:h,y:f}=e.lastViewportPosition;document.elementFromPoint(h,f)?.closest(`.${p2.SIDEBAR}`)&&(p.stopPropagation(),a([]))}}},{capture:!0}),[i,r,e]);let c=dh(p=>{o(Ui(p)),e.focusContainer()},[o,e]),m=dh(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return _n(J7,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:r,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:a})});import e8 from"clsx";import{useRef as t8}from"react";import{createPortal as o8}from"react-dom";import{KEYS as n8}from"@excalidraw/common";import{jsx as x2,jsxs as r8}from"react/jsx-runtime";var y2=e=>{let{closeOnClickOutside:o=!0}=e,t=Ws({className:"excalidraw-modal-container"}),n=t8(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===n8.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return o8(r8("div",{className:e8("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[x2("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),x2("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as td,jsxs as v2}from"react/jsx-runtime";function c8(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var We=e=>{let[o,t]=xy(),[n]=l8(document.activeElement),{id:r}=ke(),i=de().formFactor==="phone";a8(()=>{if(!o)return;let c=w2(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=p=>{if(p.key===s8.TAB){let d=w2(o),{activeElement:h}=document,f=d.findIndex(b=>b===h);f===0&&p.shiftKey?(d[d.length-1].focus(),p.preventDefault()):f===d.length-1&&!p.shiftKey&&(d[0].focus(),p.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=he(),l=Wr(Wi),s=()=>{a({openMenu:null}),l(!1),n.focus(),e.onCloseRequest()};return td(y2,{className:i8("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:c8(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:v2(ze,{ref:t,children:[e.title&&v2("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[td("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&td("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:Ut}),td("div",{className:"Dialog__content",children:e.children})]})})};import{KEYS as Zt}from"@excalidraw/common";var _o=[{icon:Qn,value:"selection",key:Zt.V,fillable:!0,myocSimplifiedMode:!0},{icon:Xr,value:"rectangle",key:Zt.R,fillable:!0,myocSimplifiedMode:!1},{icon:Kr,value:"diamond",key:Zt.D,fillable:!0,myocSimplifiedMode:!1},{icon:Zr,value:"ellipse",key:Zt.O,fillable:!0,myocSimplifiedMode:!1},{icon:Is,value:"arrow",key:Zt.A,fillable:!0,myocSimplifiedMode:!1},{icon:$r,value:"line",key:Zt.L,fillable:!0,myocSimplifiedMode:!1},{icon:Io,value:"freedraw",key:[Zt.P,Zt.X],fillable:!1,myocSimplifiedMode:!0},{icon:To,value:"text",key:Zt.T,fillable:!1,myocSimplifiedMode:!0},{icon:jr,value:"image",key:[Zt.I],fillable:!1,myocSimplifiedMode:!0},{icon:Ts,value:"eraser",key:Zt.E,fillable:!1,myocSimplifiedMode:!0}],ph=e=>e.state.preferredSelectionTool.type==="lasso"?[{value:"lasso",icon:Qn,key:Zt.V,fillable:!0,myocSimplifiedMode:!0},..._o.slice(1)]:_o,I2=(e,o)=>ph(o).find((n,r)=>n.key&&(typeof n.key=="string"?n.key===e:n.key.includes(e)))?.value||null;import Do from"clsx";import{useMemo as E8,useRef as x8,useState as y8}from"react";import*as Ro from"@radix-ui/react-popover";import{CLASSES as M2,KEYS as w8,capitalizeString as nn,isTransparent as id}from"@excalidraw/common";import{shouldAllowVerticalAlign as P2,suppportsHorizontalAlign as L2,hasBoundTextElement as ad,isElbowArrow as uh,isImageElement as A2,isLinearElement as hh,isTextElement as sd,isArrowElement as C2,hasStrokeColor as k2,toolIsArrow as ld}from"@excalidraw/element";import{CODES as d8,KEYS as m8}from"@excalidraw/common";import p8 from"clsx";import{CaptureUpdateAction as u8}from"@excalidraw/element";import{jsx as h8}from"react/jsx-runtime";var od=F({name:"viewMode",label:"labels.viewMode",icon:or,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:u8.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[m8.CTRL_OR_CMD]&&e.altKey&&e.code===d8.R,PanelComponent:({data:e,updateData:o,appState:t})=>h8(V,{type:"button",icon:or,"aria-label":g("labels.viewMode"),onClick:()=>o(null),size:e?.size||"medium","data-testid":"button-view-mode",className:p8({enabled:t.viewModeEnabled})})});import{useEffect as g8,useState as f8}from"react";import T2 from"clsx";import{capitalizeString as S2}from"@excalidraw/common";import*as Xi from"@radix-ui/react-popover";import{jsx as nd,jsxs as b8}from"react/jsx-runtime";var rd=({app:e,options:o,activeTool:t,defaultOption:n,className:r="Shape",namePrefix:i,title:a,"data-testid":l,onToolChange:s,displayedOption:c,fillable:m=!1})=>{let[p,d]=f8(!1),h=t.type,f=c.type===h,b=32/2+10,{container:E}=ke();return!o.some(w=>w.type===h)&&p&&d(!1),g8(()=>{let w=e.onPointerDownEmitter.on(()=>{d(!1)});return()=>w?.()},[e]),b8(Xi.Root,{open:p,children:[nd(Xi.Trigger,{asChild:!0,children:nd(V,{className:T2(r,{fillable:m,active:o.some(w=>w.type===t.type)}),type:"radio",icon:c.icon,checked:f,name:"editor-current-shape",title:a,"aria-label":a,"data-testid":l,onPointerDown:()=>{d(w=>!w),s(n)}})}),nd(Xi.Content,{className:"tool-popover-content",sideOffset:b,collisionBoundary:E??void 0,children:o.map(({type:w,icon:y,title:x})=>nd(V,{className:T2(r,{active:h===w}),type:"radio",icon:y,checked:h===w,name:`${i}-option`,title:x||S2(w),keyBindingLabel:"","aria-label":x||S2(w),"data-testid":`toolbar-${w}`,onChange:()=>{e.state.activeTool.type!==w&&le("toolbar",w,"ui"),e.setActiveTool({type:w}),s?.(w)}},w))})]})};import{Fragment as zt,jsx as Z,jsxs as se}from"react/jsx-runtime";var gh=Do([M2.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),fl=(e,o)=>{let t=o[0]?.type||null;for(let n of o)if(n.type!==t){t=null;break}return k2(e.activeTool.type)&&e.activeTool.type!=="image"&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(n=>k2(n.type))},bl=(e,o)=>wo(e.activeTool.type)||o.some(t=>wo(t.type)),_2=({appState:e,elementsMap:o,renderAction:t,app:n})=>{let r=Br(o,e),i=!1;r.length===2&&(ad(r[0])||ad(r[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=de(),s=document.documentElement.getAttribute("dir")==="rtl",c=wo(e.activeTool.type)&&!id(e.currentItemBackgroundColor)||r.some(f=>wo(f.type)&&!id(f.backgroundColor)),m=r.length===1||i,p=!e.selectedLinearElement?.isEditing&&r.length===1&&hh(r[0])&&!uh(r[0]),d=!e.croppingElementId&&r.length===1&&A2(r[0]),h=!i&&Ze(e,n);return se("div",{className:"selected-shape-actions",children:[Z("div",{children:fl(e,r)&&t("changeStrokeColor")}),bl(e,r)&&Z("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(Ea(e.activeTool.type)||r.some(f=>Ea(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(xa(e.activeTool.type)||r.some(f=>xa(f.type)))&&se(zt,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(ya(e.activeTool.type)||r.some(f=>ya(f.type)))&&Z(zt,{children:t("changeRoundness")}),(ld(e.activeTool.type)||r.some(f=>ld(f.type)))&&Z(zt,{children:t("changeArrowType")}),(e.activeTool.type==="text"||r.some(sd))&&se(zt,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||L2(r,o))&&t("changeTextAlign")]}),P2(r,o)&&t("changeVerticalAlign"),(Fr(e.activeTool.type)||r.some(f=>Fr(f.type)))&&Z(zt,{children:t("changeArrowhead")}),t("changeOpacity"),se("fieldset",{children:[Z("legend",{children:g("labels.layers")}),se("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),h&&!i&&se("fieldset",{children:[Z("legend",{children:g("labels.align")}),se("div",{className:"buttonList",children:[s?se(zt,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):se(zt,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),r.length>2&&t("distributeHorizontally"),Z("div",{style:{flexBasis:"100%",height:0}}),se("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),r.length>2&&t("distributeVertically"),Z("div",{style:{flexBasis:"100%",height:0}}),t("arrangeElements"),t("normaliseElements")]})]})]}),!a&&r.length>0&&se("fieldset",{children:[Z("legend",{children:g("labels.actions")}),se("div",{className:"buttonList",children:[l.formFactor!=="phone"&&t("duplicateSelection"),l.formFactor!=="phone"&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),d&&t("cropEditor"),p&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},D2=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r})=>{let i=wo(e.activeTool.type)&&!id(e.currentItemBackgroundColor)||n.some(s=>wo(s.type)&&!id(s.backgroundColor)),a=n.length>0||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",l=e.openPopup==="compactStrokeStyles";return a?Z("div",{className:"compact-action-item",children:se(Ro.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[Z(Ro.Trigger,{asChild:!0,children:Z("button",{type:"button",className:Do("compact-action-button properties-trigger",{active:l}),title:g("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactStrokeStyles"})},children:pb})}),l&&Z($o,{className:gh,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:se("div",{className:"selected-shape-actions",children:[i&&o("changeFillStyle"),(Ea(e.activeTool.type)||n.some(s=>Ea(s.type)))&&o("changeStrokeWidth"),(xa(e.activeTool.type)||n.some(s=>xa(s.type)))&&se(zt,{children:[o("changeStrokeStyle"),o("changeSloppiness")]}),(ya(e.activeTool.type)||n.some(s=>ya(s.type)))&&o("changeRoundness"),o("changeOpacity")]})})]})}):null},R2=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,app:i})=>{let a=ld(e.activeTool.type)||n.some(s=>ld(s.type)),l=e.openPopup==="compactArrowProperties";return a?Z("div",{className:"compact-action-item",children:se(Ro.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[Z(Ro.Trigger,{asChild:!0,children:Z("button",{type:"button",className:Do("compact-action-button properties-trigger",{active:l}),title:g("labels.arrowtypes"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactArrowProperties"})},children:(()=>{let s=st(n,i,c=>C2(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>C2(c),c=>c?null:e.currentItemArrowType);return s==="elbow"?ni:s==="round"?ri:oi})()})}),l&&Z($o,{container:r,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:o("changeArrowProperties")})]})}):null},N2=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,elementsMap:i})=>{let{saveCaretPosition:a,restoreCaretPosition:l}=Lb(),s=e.openPopup==="compactTextProperties";return Z("div",{className:"compact-action-item",children:se(Ro.Root,{open:s,onOpenChange:c=>{c?(e.editingTextElement&&a(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&l())},children:[Z(Ro.Trigger,{asChild:!0,children:Z("button",{type:"button",className:Do("compact-action-button properties-trigger",{active:s}),title:g("labels.textAlign"),onClick:c=>{c.preventDefault(),c.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&a(),t({openPopup:"compactTextProperties"}))},children:H1})}),e.openPopup==="compactTextProperties"&&Z($o,{className:gh,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&l()},children:se("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||n.some(sd))&&o("changeFontSize"),(e.activeTool.type==="text"||L2(n,i))&&o("changeTextAlign"),P2(n,i)&&o("changeVerticalAlign")]})})]})})},B2=({appState:e,renderAction:o,targetElements:t,setAppState:n,container:r,app:i,showDuplicate:a,showDelete:l})=>{let s=!!(e.editingTextElement||e.newElement),c=!e.croppingElementId&&t.length===1&&A2(t[0]),m=t.length===1,p=Ze(e,i),d=!1;t.length===2&&(ad(t[0])||ad(t[1]))&&(d=!0);let h=document.documentElement.getAttribute("dir")==="rtl",f=e.openPopup==="compactOtherProperties";return s||t.length===0?null:Z("div",{className:"compact-action-item",children:se(Ro.Root,{open:f,onOpenChange:b=>{n(b?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[Z(Ro.Trigger,{asChild:!0,children:Z("button",{type:"button",className:Do("compact-action-button properties-trigger",{active:f}),title:g("labels.actions"),onClick:b=>{b.preventDefault(),b.stopPropagation(),n({openPopup:f?null:"compactOtherProperties"})},children:D1})}),f&&Z($o,{className:gh,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:se("div",{className:"selected-shape-actions",children:[se("fieldset",{children:[Z("legend",{children:g("labels.layers")}),se("div",{className:"buttonList",children:[o("sendToBack"),o("sendBackward"),o("bringForward"),o("bringToFront")]})]}),p&&!d&&se("fieldset",{children:[Z("legend",{children:g("labels.align")}),se("div",{className:"buttonList",children:[h?se(zt,{children:[o("alignRight"),o("alignHorizontallyCentered"),o("alignLeft")]}):se(zt,{children:[o("alignLeft"),o("alignHorizontallyCentered"),o("alignRight")]}),t.length>2&&o("distributeHorizontally"),Z("div",{style:{flexBasis:"100%",height:0}}),se("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[o("alignTop"),o("alignVerticallyCentered"),o("alignBottom"),t.length>2&&o("distributeVertically"),Z("div",{style:{flexBasis:"100%",height:0}}),o("arrangeElements"),o("normaliseElements")]})]})]}),se("fieldset",{children:[Z("legend",{children:g("labels.actions")}),se("div",{className:"buttonList",children:[o("group"),o("ungroup"),m&&o("hyperlink"),c&&o("cropEditor"),a&&o("duplicateSelection"),l&&o("deleteSelectedElements")]})]})]})})]})})},v8=({appState:e,renderAction:o,targetElements:t})=>!e.selectedLinearElement?.isEditing&&t.length===1&&hh(t[0])&&!uh(t[0])?Z("div",{className:"compact-action-item",children:o("toggleLinearEditor")}):null,F2=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=Br(o,e),{container:a}=ke(),l=!!(e.editingTextElement||e.newElement),s=!e.selectedLinearElement?.isEditing&&i.length===1&&hh(i[0])&&!uh(i[0]);return se("div",{className:"compact-shape-actions",children:[fl(e,i)&&Z("div",{className:Do("compact-action-item"),children:t("changeStrokeColor")}),bl(e,i)&&Z("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),Z(D2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a}),Z(R2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,app:n}),s&&Z("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),(e.activeTool.type==="text"||i.some(sd))&&se(zt,{children:[Z("div",{className:"compact-action-item",children:t("changeFontFamily")}),Z(N2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,elementsMap:o})]}),!l&&i.length>0&&Z("div",{className:"compact-action-item",children:t("duplicateSelection")}),!l&&i.length>0&&Z("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),Z(B2,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:a,app:n})]})},O2=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=Br(o,e),{container:a}=ke(),l=x8(null),s=l.current?.getBoundingClientRect()?.width??0,c=9,m=6,p=32,d=c*p+(c-1)*m,h=p+m,f=s>=d+h,b=s>=d+2*h;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:[fl(e,i)&&Z("div",{className:Do("compact-action-item"),children:t("changeStrokeColor")}),bl(e,i)&&Z("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),Z(D2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a}),Z(R2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,app:n}),Z(v8,{appState:e,renderAction:t,targetElements:i}),(e.activeTool.type==="text"||i.some(sd))&&se(zt,{children:[Z("div",{className:"compact-action-item",children:t("changeFontFamily")}),Z(N2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,elementsMap:o})]}),Z(B2,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:a,app:n,showDuplicate:!b,showDelete:!f})]}),se("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[Z("div",{className:"compact-action-item",children:t("undo")}),Z("div",{className:"compact-action-item",children:t("redo")}),b&&Z("div",{className:"compact-action-item",children:t("duplicateSelection")}),f&&Z("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},z2=({activeTool:e,setAppState:o,app:t,UIOptions:n})=>{let[r,i]=y8(!1),a=je(),l=a==="full",s=a==="compact",c=[{type:"selection",icon:Qn,title:nn(g("toolBar.selection"))},{type:"lasso",icon:gn,title:nn(g("toolBar.lasso"))}],m=e.type==="frame",p=e.type==="laser",d=l&&e.type==="lasso"&&t.state.preferredSelectionTool.type!=="lasso",h=e.type==="embeddable",f=_o.filter(E=>E.myocSimplifiedMode===!1),b=E8(()=>{switch(e.type){case"frame":return{icon:fn,highlight:!1};case"lasso":return{icon:gn,highlight:!0};case"embeddable":return{icon:Ss,highlight:!0};case"laser":return t.props.isCollaborating?{icon:ei,highlight:!0}:{icon:ti,highlight:!0};case"diamond":return{icon:Kr,highlight:!0};case"rectangle":return{icon:Xr,highlight:!0};case"ellipse":return{icon:Zr,highlight:!0};case"arrow":return{icon:Is,highlight:!0};case"line":return{icon:$r,highlight:!0};default:return{icon:ei,highlight:!1}}},[e.type,t.props.isCollaborating]);return se(zt,{children:[ph(t).filter(E=>!t.state.myocSimplifiedMode||E.myocSimplifiedMode).map(({value:E,icon:w,key:y,fillable:x},v)=>{if(n.tools?.[E]===!1)return null;let I=g(`toolBar.${E}`),C=y&&nn(typeof y=="string"?y:y[0]),P=C;return(E==="selection"||E==="lasso")&&s?Z(rd,{app:t,options:c,activeTool:e,defaultOption:t.state.preferredSelectionTool.type,namePrefix:"selectionType",title:nn(g("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:k=>{(k==="selection"||k==="lasso")&&(t.setActiveTool({type:k}),o({preferredSelectionTool:{type:k,initialized:!0}}))},displayedOption:c.find(k=>k.type===t.state.preferredSelectionTool.type)||c[0],fillable:e.type==="selection"},"selection-popover"):Z(V,{className:Do("Shape",{fillable:x}),type:"radio",icon:w,checked:e.type===E,name:"editor-current-shape",title:`${nn(I)} \u2014 ${P}`,keyBindingLabel:C,"aria-label":nn(I),"aria-keyshortcuts":P,"data-testid":`toolbar-${E}`,onPointerDown:({pointerType:k})=>{!t.state.penDetected&&k==="pen"&&t.togglePenMode(!0),E==="selection"&&(t.state.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:k})=>{t.state.activeTool.type!==E&&le("toolbar",E,"ui"),E==="image"?t.setActiveTool({type:E}):t.setActiveTool({type:E})}},E)}),Z("div",{className:"App-toolbar__divider"}),se(ge,{open:r,children:[Z(ge.Trigger,{className:Do("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":b.highlight}),onToggle:()=>{i(!r),o({openMenu:null,openPopup:null})},title:g("toolBar.extraTools"),children:b.icon}),se(ge.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Z(ge.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:gn,"data-testid":"toolbar-lasso",selected:d,children:g("toolBar.lasso")}),f.map(({value:E,icon:w,key:y,fillable:x})=>{let v=g(`toolBar.${E}`),I=y&&nn(typeof y=="string"?y:y[0]);return Z(ge.Item,{onSelect:()=>t.setActiveTool({type:E}),icon:w,"data-testid":`toolbar-${E}`,selected:e.type===E,shortcut:I??void 0,children:nn(v)},E)}),Z("div",{className:"App-toolbar__dropdown-divider"}),Z(ge.Item,{onSelect:()=>t.toggleLock(),icon:t.state.activeTool.locked?hn:Ko,"data-testid":"toolbar-lock",selected:t.state.activeTool.locked,shortcut:w8.Q,children:nn(g("toolBar.lock-short"))})]})]})]})},H2=({renderAction:e,zoom:o})=>Z(Tt.Col,{gap:1,className:M2.ZOOM_ACTIONS,children:se(Tt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),G2=({renderAction:e,className:o})=>se("div",{className:`undo-redo-buttons ${o}`,children:[Z("div",{className:"undo-button-container",children:Z(ct,{label:g("buttons.undo"),children:e("undo")})}),Z("div",{className:"redo-button-container",children:se(ct,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),U2=({actionManager:e,showExitZenModeBtn:o})=>Z("button",{type:"button",className:Do("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(Li),children:g("buttons.exitZenMode")});import{useRef as I8}from"react";var fh=e=>{let o=I8({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};var bh={};o1(bh,{toggleTheme:()=>T8});var T8={...ar,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(ar,"commandPalette")}};import{jsx as Qe,jsxs as No}from"react/jsx-runtime";var P8=Se(null),He={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links",library:"Library"},Y2=e=>{switch(e){case He.app:return 1;case He.export:return 2;case He.editor:return 3;case He.tools:return 4;case He.elements:return 5;case He.links:return 6;default:return 10}},md=({shortcut:e,className:o,children:t})=>{let n=e.replace("++","+$").split("+");return No("div",{className:X2("shortcut",o),children:[n.map((r,i)=>Qe("div",{className:"shortcut-wrapper",children:Qe("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),Qe("div",{className:"shortcut-desc",children:t})]})},Z2=e=>!e.altKey&&e[go.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===go.P||e.key===go.SLASH),Lde=Object.assign(e=>{let o=Te(),t=he();return dd(()=>{let n=r=>{Z2(r)&&(r.preventDefault(),r.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&le("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(pd.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(pd.KEYDOWN,n,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:Qe(L8,{...e})},{defaultItems:bh});function L8({customCommandPaletteItems:e}){let o=qe(),t=Te(),n=he(),r=Co(),i=at(),[a,l]=ue(P8),[s,c]=cd(null),m=K2(null),p=bn({uiAppState:t,customCommandPaletteItems:e,appProps:r}),[d]=ue(en),h=C8(()=>d.libraryItems?.filter(k=>!!k.name).map(k=>({label:k.name,icon:Qe(A8,{id:k.id,elements:k.elements}),category:"Library",order:Y2("Library"),haystack:ur(k.name),perform:()=>{o.onInsertElements(Ui([k]))}}))||[],[o,d.libraryItems]);dd(()=>{let{uiAppState:k,customCommandPaletteItems:N,appProps:_}=p,L=H=>{let Y="";return H.label&&(typeof H.label=="function"?Y=g(H.label(o.scene.getNonDeletedElements(),k,o)):Y=g(H.label)),Y},B=H=>typeof H.icon=="function"?H.icon(k,o.scene.getNonDeletedElements()):H.icon,G=[],j=(H,Y,D)=>{let O={label:L(H),icon:B(H),category:Y,shortcut:Ae(H.name),keywords:H.keywords,predicate:H.predicate,viewMode:H.viewMode,perform:()=>{i.executeAction(H,"commandPalette")}};return D?D(O,H):O};if(k&&o.scene&&i){let H=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.arrangeElements,i.actions.normaliseElements,i.actions.duplicateSelection,i.actions.smartZoom,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,il,Gc,by].map(K=>j(K,He.elements,(ae,be)=>({...ae,predicate:be.predicate?be.predicate:(ce,Oe,ao,yt)=>q(ce,Oe).length>0}))),Y=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(K=>j(K,He.tools)),D=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.smartZoom,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(K=>j(K,He.editor)),O=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(K=>j(K,He.export));G=[...H,...D,{label:g("buttons.exportImage"),category:He.export,icon:ks,shortcut:Ae("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...O];let Q=[{label:g("toolBar.library"),category:He.app,icon:vs,viewMode:!1,perform:()=>{k.openSidebar?n({openSidebar:null}):n({openSidebar:{name:W2.name,tab:W2.defaultTab}})}},{label:g("search.title"),category:He.app,icon:_t,viewMode:!0,perform:()=>{i.executeAction(El)}},{label:g("labels.shapeSwitch"),category:He.elements,icon:La,perform:()=>{i.executeAction(fy)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:He.elements,icon:Cs,viewMode:!1,predicate:(K,ae)=>{let be=q(K,ae);return be.length>0&&fl(ae,be)},perform:()=>{n(K=>({openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:Cs,category:He.elements,viewMode:!1,predicate:(K,ae)=>{let be=q(K,ae);return be.length>0&&bl(ae,be)},perform:()=>{n(K=>({openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:Cs,category:He.editor,viewMode:!1,perform:()=>{n(K=>({openMenu:K.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},..._o.reduce((K,ae)=>{let{value:be,icon:ce,key:Oe}=ae;if(_.UIOptions.tools?.[be]===!1)return K;let yt=Oe&&k8(typeof Oe=="string"?Oe:Oe[0]),Vo={label:g(`toolBar.${be}`),category:He.tools,shortcut:yt,icon:ce,keywords:["toolbar"],viewMode:!1,perform:({event:Nr})=>{be==="image"?o.setActiveTool({type:be}):o.setActiveTool({type:be})}};return K.push(Vo),K},[]),...Y,{label:g("toolBar.lock"),category:He.tools,icon:k.activeTool.locked?hn:Ko,shortcut:go.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}}],ee=[...G,...Q,...N||[]].map(K=>({...K,icon:K.icon||La,order:K.order??Y2(K.category),haystack:`${ur(K.label.toLocaleLowerCase())} ${K.keywords?.join(" ")||""}`}));c(ee),l([...ee,...h].find(K=>K.label===a?.label)??null)}},[p,o,i,c,a?.label,l,n,h]);let[f,b]=cd(""),[E,w]=cd(null),[y,x]=cd({}),v=k=>{n({openDialog:null},k),b("")},I=(k,N)=>{t.openDialog?.name==="commandPalette"&&(N.stopPropagation(),N.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),v(()=>{k.perform({actionManager:i,event:N}),l(k),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},C=fh(k=>k.viewMode===!1&&t.viewModeEnabled?!1:typeof k.predicate=="function"?k.predicate(o.scene.getNonDeletedElements(),t,r,o):k.predicate===void 0||k.predicate),P=fh(k=>{let N=M8(k.target)||Z2(k)||k.key===go.ESCAPE;if(N&&k.key!==go.ARROW_UP&&k.key!==go.ARROW_DOWN&&k.key!==go.ENTER)return;let _=Object.values(y).flat(),L=a&&!f&&C(a);if(k.key===go.ARROW_UP){k.preventDefault();let B=_.findIndex(H=>H.label===E?.label);if(L){if(B===0){w(a);return}if(E===a){let H=_[_.length-1];H&&w(H);return}}let G;B===-1?G=_.length-1:G=B===0?_.length-1:(B-1)%_.length;let j=_[G];j&&w(j);return}if(k.key===go.ARROW_DOWN){k.preventDefault();let B=_.findIndex(H=>H.label===E?.label);if(L){if(!E||B===_.length-1){w(a);return}if(E===a){let H=_[0];H&&w(H);return}}let G=(B+1)%_.length,j=_[G];j&&w(j);return}if(k.key===go.ENTER&&E&&setTimeout(()=>{I(E,k)}),!N){if(k.stopPropagation(),/^[a-zA-Z0-9]$/.test(k.key)){m?.current?.focus();return}k.preventDefault()}});return dd(()=>(window.addEventListener(pd.KEYDOWN,P,{capture:!0}),()=>window.removeEventListener(pd.KEYDOWN,P,{capture:!0})),[P]),dd(()=>{if(!s)return;let k=B=>{let G={};for(let j of B)G[j.category]?G[j.category].push(j):G[j.category]=[j];return G},N=f?.length>1?[...s.filter(C).sort((B,G)=>B.order-G.order),...h]:s.filter(C).sort((B,G)=>B.order-G.order),_=!f&&a&&C(a);if(!f){x(k(_?N.filter(B=>B.label!==a?.label):N)),w(_?a:N[0]||null);return}let L=ur(f.toLocaleLowerCase().replace(/[<>_| -]/g,""));N=S8.filter(L,N,{extract:B=>B.haystack??""}).sort((B,G)=>G.score-B.score).map(B=>B.original),x(k(N)),w(N[0]??null)},[f,s,C,a,h]),No(We,{onCloseRequest:()=>v(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Qe(An,{value:f,placeholder:g("commandPalette.search.placeholder"),onChange:k=>{b(k)},selectOnRender:!0,ref:m}),o.editorInterface.formFactor!=="phone"&&No("div",{className:"shortcuts-wrapper",children:[Qe(md,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),Qe(md,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),Qe(md,{shortcut:A("Esc"),children:g("commandPalette.shortcuts.close")})]}),No("div",{className:"commands",children:[a&&!f&&No("div",{className:"command-category",children:[No("div",{className:"command-category-title",children:[g("commandPalette.recents"),Qe("div",{className:"icon",style:{marginLeft:"6px"},children:j0})]}),Qe(V2,{command:a,isSelected:a.label===E?.label,onClick:k=>I(a,k),disabled:!C(a),onMouseMove:()=>w(a),showShortcut:o.editorInterface.formFactor!=="phone",appState:t})]}),Object.keys(y).length>0?Object.keys(y).map((k,N)=>No("div",{className:"command-category",children:[Qe("div",{className:"command-category-title",children:k}),y[k].map(_=>Qe(V2,{command:_,isSelected:_.label===E?.label,onClick:L=>I(_,L),onMouseMove:()=>w(_),showShortcut:o.editorInterface.formFactor!=="phone",appState:t,size:k==="Library"?"large":"small"},_.label))]},k)):s?No("div",{className:"no-match",children:[Qe("div",{className:"icon",children:_t})," ",g("commandPalette.search.noMatch")]}):null]})]})}var A8=({id:e,elements:o})=>{let t=K2(null),{svgCache:n}=Hi();return Uc(e,o,n,t),Qe("div",{className:"library-item-icon",ref:t})},V2=({command:e,isSelected:o,disabled:t,onMouseMove:n,onClick:r,showShortcut:i,appState:a,size:l="small"})=>{let s=()=>{};return No("div",{className:X2("command-item",{"item-selected":o,"item-disabled":t,"command-item-large":l==="large"}),ref:c=>{o&&!t&&c?.scrollIntoView?.({block:"nearest"})},onClick:t?s:r,onMouseMove:t?s:n,title:t?g("commandPalette.itemNotAvailable"):"",children:[No("div",{className:"name",children:[e.icon&&Qe(fi,{className:"icon",size:"var(--icon-size, 1rem)",icon:typeof e.icon=="function"?e.icon(a,[]):e.icon}),Qe(Ga,{children:e.label})]}),i&&e.shortcut&&Qe(md,{shortcut:e.shortcut})]})};import{getSizeFromPoints as W0e,randomInteger as P_,getUpdatedTimestamp as L_}from"@excalidraw/common";import{simplify as h_}from"points-on-curve";import{getStroke as g_}from"perfect-freehand";import{pointsOnBezierCurves as Nde}from"points-on-curve";import{invariant as Fde}from"@excalidraw/common";import{curve as zde,lineSegment as Hde,pointFrom as Gde,pointDistance as Ude,pointFromArray as Wde,pointFromVector as Yde,pointRotateRads as Vde,polygon as Xde,polygonFromPoints as Kde,PRECISION as Zde,segmentsIntersectAt as $de,vector as jde,vectorAdd as qde,vectorFromPoint as Jde,vectorScale as Qde}from"@excalidraw/math";import{getElementAbsoluteCoords as tme}from"@excalidraw/element";var Eh=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as f_,pointDistance as pw,pointRotateRads as M0e}from"@excalidraw/math";import{ROUGHNESS as b_,THEME as Nh,isTransparent as vl,assertNever as E_,COLOR_PALETTE as x_,LINE_POLYGON_POINT_MERGE_DISTANCE as L0e,applyDarkModeFilter as Id}from"@excalidraw/common";import{RoughGenerator as y_}from"roughjs/bin/generator";import z1e from"roughjs/bin/rough";import{isRightAngleRads as G1e,lineSegment as U1e,pointFrom as W1e,pointRotateRads as Y1e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as X1e,DEFAULT_REDUCED_GLOBAL_ALPHA as K1e,ELEMENT_READY_TO_ERASE_OPACITY as Z1e,FRAME_STYLE as $1e,DARK_THEME_FILTER as j1e,MIME_TYPES as dw,THEME as q1e,distance as J1e,getFontString as Q1e,isRTL as e0e,getVerticalOffset as t0e,invariant as o0e,applyDarkModeFilter as n0e}from"@excalidraw/common";import qge from"roughjs/bin/rough";import{arrayToMap as Qge,invariant as nw,rescalePoints as efe,sizeOf as tfe}from"@excalidraw/common";import{degreesToRadians as Ph,lineSegment as nfe,pointDistance as rfe,pointFrom as lt,pointFromArray as j8,pointRotateRads as qi}from"@excalidraw/math";import{pointsOnBezierCurves as lfe}from"points-on-curve";import{pointCenter as pge,pointFrom as uge,pointRotateRads as hge,pointsEqual as gge,pointDistance as fge,vectorFromPoint as bge,curveLength as Ege,curvePointAtLength as xge,lineSegment as yge}from"@excalidraw/math";import{DRAGGING_THRESHOLD as Ige,KEYS as Tge,shouldRotateWithDiscreteAngle as Sge,getGridPoint as Cge,invariant as kge,isShallowEqual as Mge,getFeatureFlag as Pge}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as Age,isPathALoop as _ge,moveArrowAboveBindable as Dge,projectFixedPointOntoDiagonal as Rge}from"@excalidraw/element";import{KEYS as hhe,arrayToMap as ghe,getFeatureFlag as fhe,invariant as bhe,isTransparent as Ehe}from"@excalidraw/common";import{PRECISION as yhe,clamp as whe,lineSegment as vhe,pointDistance as Ihe,pointDistanceSq as The,pointFrom as She,pointFromVector as Che,pointRotateRads as khe,pointsEqual as Mhe,vectorFromPoint as Phe,vectorNormalize as Lhe,vectorScale as Ahe}from"@excalidraw/math";import{invariant as zpe,isTransparent as Hpe}from"@excalidraw/common";import{curveIntersectLineSegment as Upe,isPointWithinBounds as Wpe,lineSegment as Ype,lineSegmentIntersectionPoints as Vpe,pointFrom as Xpe,pointFromVector as Kpe,pointRotateRads as Zpe,pointsEqual as $pe,vectorFromPoint as jpe,vectorNormalize as qpe,vectorScale as Jpe}from"@excalidraw/math";import{ellipse as eue,ellipseSegmentInterceptPoints as tue}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as R8,DEFAULT_PROPORTIONAL_RADIUS as yh,invariant as pme,LINE_CONFIRM_THRESHOLD as N8,ROUNDNESS as wh}from"@excalidraw/common";import{curve as hme,curveCatmullRomCubicApproxPoints as gme,curveOffsetPoints as fme,lineSegment as bme,lineSegmentIntersectionPoints as Eme,pointDistance as B8,pointFrom as xme,pointFromArray as yme,pointFromVector as wme,pointRotateRads as vme,pointTranslate as Ime,rectangle as Tme,vectorFromPoint as Sme,vectorNormalize as Cme,vectorScale as kme}from"@excalidraw/math";import{ROUNDNESS as ime,assertNever as ame}from"@excalidraw/common";import{pointsEqual as sme}from"@excalidraw/math";var $2=e=>!!e&&e.type==="embeddable",j2=e=>!!e&&e.type==="iframe",xh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),gr=e=>e!=null&&e.type==="text";var ud=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var fr=e=>e!=null&&_8(e.type);var br=e=>e!=null&&e.type==="arrow",xl=e=>br(e)&&e.elbowed;var _8=e=>e==="arrow"||e==="line";var Ki=e=>e!==null&&"containerId"in e&&e.containerId!==null&&gr(e);var hd=(e,o=1)=>{if(e.length>=3){let[t,n]=[e[0],e[e.length-1]];return B8(t,n)<=N8/o}return!1},yl=(e,o)=>{if(o.roundness?.type===wh.PROPORTIONAL_RADIUS||o.roundness?.type===wh.LEGACY)return e*yh;if(o.roundness?.type===wh.ADAPTIVE_RADIUS){let t=o.roundness?.value??R8,n=t/yh;return e<=n?e*yh:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as spe,ARROW_LABEL_WIDTH_FRACTION as cpe,BOUND_TEXT_PADDING as dpe,DEFAULT_FONT_SIZE as mpe,TEXT_ALIGN as ppe,VERTICAL_ALIGN as upe,getFontString as hpe,isProdEnv as gpe,invariant as fpe}from"@excalidraw/common";import{pointFrom as Epe,pointRotateRads as xpe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as zme,DEFAULT_FONT_SIZE as Hme,DEFAULT_FONT_FAMILY as Gme,getFontString as Ume,isTestEnv as Wme,normalizeEOL as Yme}from"@excalidraw/common";var Vme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Jme,isTestEnv as Qme}from"@excalidraw/common";import{curvePointDistance as Mpe,distanceToLineSegment as Ppe,pointRotateRads as Lpe}from"@excalidraw/math";import{ellipse as _pe,ellipseDistanceFromPoint as Dpe}from"@excalidraw/math/ellipse";import{invariant as uue,isDevEnv as hue,isTestEnv as gue}from"@excalidraw/common";import{pointFrom as bue,pointFromVector as Eue,pointRotateRads as xue,pointScaleFromOrigin as yue,pointsEqual as wue,triangleIncludesPoint as vue,vectorCross as Iue,vectorFromPoint as W8,vectorScale as Tue}from"@excalidraw/math";var kh=[1,0],Q2=[0,1],Mh=[-1,0],ew=[0,-1],Ed=e=>{let[o,t]=e,n=Math.abs(o),r=Math.abs(t);return o>r?kh:o<=-r?Mh:t>n?Q2:ew},tw=(e,o)=>Ed(W8(e,o)),xd=(e,o)=>yd(tw(e,o)),Ch=(e,o)=>e[0]===o[0]&&e[1]===o[1],yd=e=>Ch(e,kh)||Ch(e,Mh);import{clamp as Lue,pointDistance as Aue,pointFrom as _ue,pointScaleFromOrigin as Due,pointsEqual as Rue,pointTranslate as Nue,vector as Bue,vectorCross as Fue,vectorFromPoint as Oue,vectorScale as zue}from"@excalidraw/math";import{BinaryHeap as Gue,invariant as Uue,isAnyTrue as Wue,getSizeFromPoints as Yue,isDevEnv as Vue,arrayToMap as Xue}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Khe,viewportCoordsToSceneCoords as Zhe}from"@excalidraw/common";import{normalizeRadians as jhe,radiansBetweenAngles as qhe,radiansDifference as Jhe}from"@excalidraw/math";import{pointsEqual as ege}from"@excalidraw/math";var gd=e=>{let o=Math.floor(e.width/2)+1,t=0,n=e.width,r=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,n,r,i,a,0,r]};var q8=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"crowfoot_many":case"crowfoot_one":case"crowfoot_one_or_many":return 20;default:return 15}},J8=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Lh=(e,o,t,n)=>{if(o.length<1)return null;let r=Eh(o[0]);if(r.length<1)return null;let i=t==="start"?1:r.length-1,a=r[i].data;nw(a.length===6,"Op data length is not 6");let l=lt(a[4],a[5]),s=lt(a[2],a[3]),c=lt(a[0],a[1]),m=r[i-1],p=lt(0,0);if(m.op==="move"){let H=j8(m.data);nw(H!=null,"Op data is not a point"),p=H}else m.op==="bcurveTo"&&(p=lt(m.data[4],m.data[5]));let d=(H,Y)=>Math.pow(1-H,3)*l[Y]+3*H*Math.pow(1-H,2)*s[Y]+3*Math.pow(H,2)*(1-H)*c[Y]+p[Y]*Math.pow(H,3),[h,f]=t==="start"?p:l,[b,E]=[d(.3,0),d(.3,1)],w=Math.hypot(h-b,f-E),y=(h-b)/w,x=(f-E)/w,v=q8(n),I=0;{let[H,Y]=t==="end"?e.points[e.points.length-1]:e.points[0],[D,O]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];I=Math.hypot(H-D,Y-O)}let P=Math.min(v,I*(n==="diamond"||n==="diamond_outline"?.25:.5)),k=h-y*P,N=f-x*P;if(n==="dot"||n==="circle"||n==="circle_outline"){let H=Math.hypot(N-f,k-h)+e.strokeWidth-2;return[h,f,H]}let _=J8(n);if(n==="crowfoot_many"||n==="crowfoot_one_or_many"){let[H,Y]=qi(lt(h,f),lt(k,N),Ph(-_)),[D,O]=qi(lt(h,f),lt(k,N),Ph(_));return[k,N,H,Y,D,O]}let[L,B]=qi(lt(k,N),lt(h,f),-_*Math.PI/180),[G,j]=qi(lt(k,N),lt(h,f),Ph(_));if(n==="diamond"||n==="diamond_outline"){let H,Y;if(t==="start"){let[D,O]=e.points.length>1?e.points[1]:[0,0];[H,Y]=qi(lt(h+P*2,f),lt(h,f),Math.atan2(O-f,D-h))}else{let[D,O]=e.points.length>1?e.points[e.points.length-2]:[0,0];[H,Y]=qi(lt(h-P*2,f),lt(h,f),Math.atan2(f-O,h-D))}return[h,f,L,B,H,Y,G,j]}return[h,f,L,B,G,j]};import{pointFrom as wfe,pointCenter as vfe,pointRotateRads as Ife,vectorFromPoint as Tfe,vectorNormalize as Sfe,vectorSubtract as Cfe,vectorAdd as kfe,vectorScale as Mfe,pointFromVector as Pfe,clamp as Lfe,isCloseTo as Afe}from"@excalidraw/math";import{arrayToMap as b1e}from"@excalidraw/common";import{isPointWithinBounds as x1e,pointFrom as y1e}from"@excalidraw/math";import{vectorCross as Bfe,vectorFromPoint as Ffe}from"@excalidraw/math";import{arrayToMap as Q8}from"@excalidraw/common";import{getElementBounds as e_}from"@excalidraw/element";import{isArrowElement as t_,isExcalidrawElement as o_,isFreeDrawElement as n_,isLinearElement as r_,isTextElement as i_}from"@excalidraw/element";import{rangeIncludesValue as wd,pointFrom as an,pointRotateRads as a_,rangeInclusive as vd}from"@excalidraw/math";var l_=e=>e.type==="diamond"?[an(e.width/2,0),an(e.width,e.height/2),an(e.width/2,e.height),an(0,e.height/2)]:[an(0,0),an(0+e.width,0),an(0+e.width,e.height),an(0,e.height)],s_=e=>r_(e)||n_(e)?e.points:l_(e),iw=e=>{let o=e.reduce((t,[n,r])=>(t.minY=Math.min(t.minY,r),t.minX=Math.min(t.minX,n),t.maxX=Math.max(t.maxX,n),t.maxY=Math.max(t.maxY,r),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},aw=e=>{let o=s_(e),{cx:t,cy:n}=iw(o),r=an(t,n),i=o.map(m=>a_(m,r,e.angle)),{minX:a,minY:l,maxX:s,maxY:c}=iw(i);return[a+e.x,l+e.y,s+e.x,c+e.y]},Ah=(e,o,t=!1)=>{let n=aw(e),r=o[0]<=n[0]&&o[2]>=n[2]&&o[1]<=n[1]&&o[3]>=n[3];return t?r?!0:n[0]<=o[0]&&n[2]>=o[2]&&n[1]<=o[1]&&n[3]>=o[3]:r},lw=(e,o)=>{let t=aw(e);return(wd(t[0],vd(o[0],o[2]))||wd(o[0],vd(t[0],t[2])))&&(wd(t[1],vd(o[1],o[3]))||wd(o[1],vd(t[1],t[3])))},sw=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{o_(o)&&(o=e_(o,Q8(e)));let r=[o[0]-n,o[1]-n,o[2]+n,o[3]+n],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?lw(a,r):t==="inside"?Ah(a,r):Ah(a,r,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);i_(a)&&a.containerId&&i.add(a.containerId),t_(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{arrayToMap as Qfe,isShallowEqual as d_}from"@excalidraw/common";var c_=function(){let e=null,o=null,t=null,n=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let c={};for(let d of i){let h=d.groupIds;if(l.editingGroupId){let f=h.indexOf(l.editingGroupId);f>-1&&(h=h.slice(0,f))}if(h.length>0){let f=h[h.length-1];c[f]=!0}}let m={},p=a.reduce((d,h)=>{if(h.isDeleted)return d;let f=h.groupIds.find(b=>c[b]);return f&&(d[h.id]=!0,Array.isArray(m[f])?m[f].push(h.id):m[f]=[h.id]),d},{});for(let d of Object.keys(m))m[d].length<2&&c[d]&&(c[d]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:c,selectedElementIds:_h({...l.selectedElementIds,...p},s)},t},r=(i,a,l,s)=>{let c=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Dh(a,i);return c.length?n(c,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:_h(i.selectedElementIds,l)}};return r.clearCache=()=>{o=null,e=null,t=null},r}();var a1e=function(){let e=null,o=null,t=null,n=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===o||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,o=i.selectedElementIds),t);return n.clearCache=()=>{e=null,o=null,t=null},n}(),Dh=(e,o,t)=>{let n=new Set,r=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){r.push(i),n.add(i.id);continue}if(t?.includeBoundTextElement&&Ki(i)&&o.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{ud(a)&&cw(e,a.id).forEach(l=>!n.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var _h=(e,o)=>d_(o.selectedElementIds,e)?o.selectedElementIds:e;var cw=(e,o)=>{let t=[];for(let n of e.values())n.frameId===o&&t.push(n);return t};var p_=typeof document<"u"?document.createElement("img"):{src:""};p_.src=`data:${dw.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 u_=typeof document<"u"?document.createElement("img"):{src:""};u_.src=`data:${dw.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 Rh=new WeakMap;var mw=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var Ct=class Ct{};S(Ct,"rg",new y_),S(Ct,"cache",new WeakMap),S(Ct,"get",(o,t)=>{let n=Ct.cache.get(o);if(n&&(t===null||n.theme===t))return n.shape}),S(Ct,"delete",o=>{Ct.cache.delete(o),Rh.delete(o)}),S(Ct,"destroy",()=>{Ct.cache=new WeakMap}),S(Ct,"generateElementShape",(o,t)=>{let n=t?.isExporting?void 0:Ct.get(o,t?t.theme:null);if(n!==void 0)return n;Rh.delete(o);let r=I_(o,Ct.rg,t||{isExporting:!1,canvasBackgroundColor:x_.white,embedsValidationStatus:null,theme:Nh.LIGHT});return t?.isExporting||Ct.cache.set(o,{shape:r,theme:t?.theme||Nh.LIGHT}),r});var ji=Ct,w_=e=>[8,8+e],fw=e=>[1.5,6+e];function v_(e){let o=e.roughness,t=Math.max(e.width,e.height),n=Math.min(e.width,e.height);return n>=20&&t>=50||n>=15&&e.roundness&&mw(e.type)||fr(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var rn=(e,o=!1,t=!1)=>{let n={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?w_(e.strokeWidth):e.strokeStyle==="dotted"?fw(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:v_(e),stroke:t?Id(e.strokeColor):e.strokeColor,preserveVertices:o||e.roughness<b_.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return n.fillStyle=e.fillStyle,n.fill=vl(e.backgroundColor)?void 0:t?Id(e.backgroundColor):e.backgroundColor,e.type==="ellipse"&&(n.curveFitting=1),n;case"line":case"freedraw":return hd(e.points)&&(n.fillStyle=e.fillStyle,n.fill=e.backgroundColor==="transparent"?void 0:t?Id(e.backgroundColor):e.backgroundColor),n;case"arrow":return n;default:throw new Error(`Unimplemented type ${e.type}`)}},uw=(e,o,t)=>xh(e)&&(o||$2(e)&&t?.get(e.id)!==!0)&&vl(e.backgroundColor)&&vl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:j2(e)?{...e,strokeColor:vl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:vl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,hw=(e,o,t,n,r,i,a,l)=>{let s=Lh(e,o,t,n);if(s===null)return[];let c=(p,d)=>{if(p===null)return[];let[,,h,f,b,E]=p;return[r.line(h,f,b,E,d)]},m=l?Id(e.strokeColor):e.strokeColor;switch(n){case"dot":case"circle":case"circle_outline":{let[p,d,h]=s;return delete i.strokeLineDash,[r.circle(p,d,h,{...i,fill:n==="circle_outline"?a:m,fillStyle:"solid",stroke:m,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[p,d,h,f,b,E]=s;return delete i.strokeLineDash,[r.polygon([[p,d],[h,f],[b,E],[p,d]],{...i,fill:n==="triangle_outline"?a:m,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[p,d,h,f,b,E,w,y]=s;return delete i.strokeLineDash,[r.polygon([[p,d],[h,f],[b,E],[w,y],[p,d]],{...i,fill:n==="diamond_outline"?a:m,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"crowfoot_one":return c(s,i);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[p,d,h,f,b,E]=s;if(e.strokeStyle==="dotted"){let w=fw(e.strokeWidth-1);i.strokeLineDash=[w[0],w[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[r.line(h,f,p,d,i),r.line(b,E,p,d,i),...n==="crowfoot_one_or_many"?c(Lh(e,o,t,"crowfoot_one"),i):[]]}}};var I_=(e,o,{isExporting:t,canvasBackgroundColor:n,embedsValidationStatus:r,theme:i})=>{let a=i===Nh.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let l;if(e.roundness){let s=e.width,c=e.height,m=yl(Math.min(s,c),e);l=o.path(`M ${m} 0 L ${s-m} 0 Q ${s} 0, ${s} ${m} L ${s} ${c-m} Q ${s} ${c}, ${s-m} ${c} L ${m} ${c} Q 0 ${c}, 0 ${c-m} L 0 ${m} Q 0 0, ${m} 0`,rn(uw(e,t,r),!0,a))}else l=o.rectangle(0,0,e.width,e.height,rn(uw(e,t,r),!1,a));return l}case"diamond":{let l,[s,c,m,p,d,h,f,b]=gd(e);if(e.roundness){let E=yl(Math.abs(s-f),e),w=yl(Math.abs(p-c),e);l=o.path(`M ${s+E} ${c+w} L ${m-E} ${p-w}
|
|
7
|
+
${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var ex=async(e,o,t,n)=>{let{exportBackground:r,viewBackgroundColor:i,fileHandle:a}=o,l=m1(a);if(!a||!p1(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=ir(e,o,!1);return await ar(l,s,o,t,{exportBackground:r,viewBackgroundColor:i,name:n,fileHandle:a,exportingFrame:c}),{fileHandle:a}};import{Fragment as Hk,jsx as $o,jsxs as Gk}from"react/jsx-runtime";var eu=F({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:po.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:n,app:r})=>$o(FE,{label:g("labels.fileTitle"),value:r.getName(),onChange:i=>o(i),ignoreFocus:n?.ignoreFocus??!1})}),tx=F({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:po.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=zk(e),i=ve(n,o)?q(n,o):n;return $o(Hk,{children:Ok.map(a=>{let[l,s]=c1(i,Fk,a),c=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return $o(V,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),tu=F({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:po.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>$o(Ha,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),bc=F({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:po.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Gk(Ha,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),$o(ct,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:$o("div",{className:"excalidraw-tooltip-icon",children:j1})})]})}),lr=F({name:"saveToActiveFile",label:"buttons.save",icon:qn,trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{let r=!!o.fileHandle;try{let{fileHandle:i}=ls(o.fileHandle)?await ex(e,o,n.files,n.getName()):await ts(e,o,n.files,n.getName());return{captureUpdate:po.EVENTUALLY,appState:{...o,fileHandle:i,toast:r?{message:i?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):g("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:po.EVENTUALLY}}},keyTest:e=>!1}),Ka=F({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:qn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,n)=>{try{let{fileHandle:r}=await ts(e,{...o,fileHandle:null},n.files,n.getName());return{captureUpdate:po.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:r,toast:{message:g("toast.fileSaved")}}}}catch(r){return r?.name!=="AbortError"?console.error(r):console.warn(r),{captureUpdate:po.EVENTUALLY}}},keyTest:e=>e.key===fc.S&&e.shiftKey&&e[fc.CTRL_OR_CMD],PanelComponent:({updateData:e})=>$o(V,{type:"button",icon:X1,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:de().formFactor==="phone",hidden:!Fr,onClick:()=>e(null),"data-testid":"save-as-button"})}),gi=F({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{try{let{elements:r,appState:i,files:a}=await Tm(o,e);return{elements:r,appState:i,files:a,captureUpdate:po.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...o,errorMessage:r.message},files:n.files,captureUpdate:po.EVENTUALLY}}},keyTest:e=>e[fc.CTRL_OR_CMD]&&e.key===fc.O}),ox=F({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:po.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>$o("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:$o(NE,{value:e.exportWithDarkMode?Qp.DARK:Qp.LIGHT,onChange:t=>{o(t===Qp.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as Uk,DEFAULT_FONT_FAMILY as Wk,DEFAULT_TEXT_ALIGN as Yk,CODES as nx,KEYS as rx,getLineHeight as Vk}from"@excalidraw/common";import{newElementWith as Ec}from"@excalidraw/element";import{hasBoundTextElement as Xk,canApplyRoundnessTypeToElement as Kk,getDefaultRoundnessTypeForElement as Zk,isFrameLikeElement as $k,isArrowElement as jk,isExcalidrawElement as qk,isTextElement as ou}from"@excalidraw/element";import{getBoundTextElement as Jk,redrawTextBoundingBox as Qk}from"@excalidraw/element";import{CaptureUpdateAction as nu}from"@excalidraw/element";var ix="{}",ru=F({name:"copyStyles",label:"labels.copyStyles",icon:$m,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=[],i=e.find(a=>o.selectedElementIds[a.id]);if(r.push(i),i&&Xk(i)){let a=Jk(i,n.scene.getNonDeletedElementsMap());r.push(a)}return i&&(ix=JSON.stringify(r)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:nu.EVENTUALLY}},keyTest:e=>e[rx.CTRL_OR_CMD]&&e.altKey&&e.code===nx.C}),iu=F({name:"pasteStyles",label:"labels.pasteStyles",icon:$m,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=JSON.parse(ix),i=r[0],a=r[1];if(!qk(i))return{elements:e,captureUpdate:nu.EVENTUALLY};let l=q(e,o,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=i;if(ou(c)&&c.containerId&&(m=a),!m)return c;let p=Ec(c,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?Kk(m.roundness.type,c)?m.roundness:Zk(c):null});if(ou(p)){let d=m.fontSize||Uk,h=m.fontFamily||Wk;p=Ec(p,{fontSize:d,fontFamily:h,textAlign:m.textAlign||Yk,lineHeight:m.lineHeight||Vk(h)});let f=null;p.containerId&&(f=l.find(b=>ou(p)&&b.id===p.containerId)||null),Qk(p,f,n.scene)}return p.type==="arrow"&&jk(m)&&(p=Ec(p,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),$k(c)&&(p=Ec(p,{roundness:null,backgroundColor:"transparent"})),p}return c}),captureUpdate:nu.IMMEDIATELY}},keyTest:e=>e[rx.CTRL_OR_CMD]&&e.altKey&&e.code===nx.V});import{KEYS as eM}from"@excalidraw/common";import{CaptureUpdateAction as tM}from"@excalidraw/element";var sr=F({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:H1,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:n})=>(o.openDialog?.name==="help"&&n(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:tM.EVENTUALLY}),keyTest:e=>e.key===eM.QUESTION_MARK});import{getNonDeletedElements as yc}from"@excalidraw/element";import{newElementWith as sx}from"@excalidraw/element";import{isBoundToContainer as oM}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as nM,getElementsInResizingFrame as rM,getFrameLikeElements as iM,getRootElements as aM,groupByFrameLikes as lM,removeElementsFromFrame as sM,replaceAllElementsInFrame as cM}from"@excalidraw/element";import{KEYS as wc,randomId as dM,arrayToMap as au}from"@excalidraw/common";import{getSelectedGroupIds as xc,selectGroup as mM,selectGroupsForSelectedElements as pM,getElementsInGroup as ax,addToGroup as uM,removeFromSelectedGroups as hM,isElementInGroup as cx}from"@excalidraw/element";import{syncMovedIndices as gM}from"@excalidraw/element";import{CaptureUpdateAction as Za}from"@excalidraw/element";import{jsx as fi}from"react/jsx-runtime";var fM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((n,r)=>n&&cx(r,t),!0))return!0}return!1},lx=(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!fM(n)&&!nM(n)},lu=F({name:"group",label:"labels.group",icon:e=>fi(Vm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=aM(n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:o,elements:e,captureUpdate:Za.EVENTUALLY};let i=xc(o);if(i.length===1){let E=i[0],w=new Set(ax(e,E).map(v=>v.id)),y=new Set(r.map(v=>v.id));if(new Set([...Array.from(w),...Array.from(y)]).size===w.size)return{appState:o,elements:e,captureUpdate:Za.EVENTUALLY}}let a=[...e];new Set(r.map(E=>E.frameId)).size>1&&lM(r).forEach((w,y)=>{sM(w,n.scene.getNonDeletedElementsMap())});let s=dM(),c=au(r);a=a.map(E=>c.get(E.id)?sx(E,{groupIds:uM(E.groupIds,s,o.editingGroupId)}):E);let m=ax(a,s),p=m[m.length-1],d=a.lastIndexOf(p),h=a.slice(d+1),f=a.slice(0,d).filter(E=>!cx(E,s)),b=gM([...f,...m,...h],au(m));return{appState:{...o,...mM(s,{...o,selectedGroupIds:{}},yc(a))},elements:b,captureUpdate:Za.IMMEDIATELY}},predicate:(e,o,t,n)=>lx(e,o,n),keyTest:e=>!e.shiftKey&&e[wc.CTRL_OR_CMD]&&e.key===wc.G,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>fi(V,{hidden:!lx(e,o,n),type:"button",icon:fi(Vm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${A("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:ve(yc(e),o)})}),su=F({name:"ungroup",label:"labels.ungroup",icon:e=>fi(Xm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=xc(o),i=au(e);if(r.length===0)return{appState:o,elements:e,captureUpdate:Za.EVENTUALLY};let a=[...e],l=[];a=a.map(d=>{oM(d)&&l.push(d.id);let h=hM(d.groupIds,o.selectedGroupIds);return h.length===d.groupIds.length?d:sx(d,{groupIds:h})});let s=pM(o,yc(a),o,null),c=n.scene.getSelectedElements(o),m=new Set(c.filter(d=>d.frameId).map(d=>d.frameId));return iM(e).filter(d=>m.has(d.id)).forEach(d=>{d&&(a=cM(a,rM(a,d,o,i),d,n))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((d,[h,f])=>(f&&!l.includes(h)&&(d[h]=!0),d),{}),{appState:{...o,...s},elements:a,captureUpdate:Za.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[wc.CTRL_OR_CMD]&&e.key===wc.G.toUpperCase(),predicate:(e,o)=>xc(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>fi(V,{type:"button",hidden:xc(o).length===0,icon:fi(Xm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${A("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:ve(yc(e),o)})});import IM from"clsx";import{CaptureUpdateAction as hx}from"@excalidraw/element";import{invariant as TM}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as bM,COLOR_VOICE_CALL as EM,COLOR_WHITE as Ic,THEME as xM,UserIdleState as dx}from"@excalidraw/common";var vc=(e,o,t,n,r,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+n-i,t),e.quadraticCurveTo(o+n,t,o+n,t+i),e.lineTo(o+n,t+r-i),e.quadraticCurveTo(o+n,t+r,o+n-i,t+r),e.lineTo(o+i,t+r),e.quadraticCurveTo(o,t+r,o,t+r-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function yM(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);o=(o<<5)-o+n}return o}var cr=(e,o)=>`hsl(${Math.abs(yM(o?.id||e))%37*10}, 100%, 83%)`,mx=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},px=({context:e,renderConfig:o,appState:t,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,c=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let m=11,p=14,d=l<0||l>n-m||s<0||s>r-p;l=Math.max(l,0),l=Math.min(l,n-m),s=Math.max(s,0),s=Math.min(s,r-p);let h=cr(i,c);e.save(),e.strokeStyle=h,e.fillStyle=h;let f=o.remotePointerUserStates.get(i),b=d||f===dx.IDLE||f===dx.AWAY;b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=h,e.stroke(),e.closePath());let E=t.theme===xM.DARK?"#2f6330":EM,w=c?.isSpeaking;w&&(e.fillStyle=E,e.strokeStyle=E,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Ic,e.strokeStyle=Ic,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=h,e.strokeStyle=h,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let y=o.remotePointerUsernames.get(i)||"";if(!d&&y){e.font="600 12px sans-serif";let x=(w?l+0:l)+m/2,v=(w?s+0:s)+p+2,I=5,C=3,P=e.measureText(y),k=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,N=Math.max(k,12),_=x-1,L=v-1,B=P.width+2+I*2+2,G=N+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,L,B,G,8),e.fillStyle=h,e.fill(),e.strokeStyle=Ic,e.stroke(),w&&(e.beginPath(),e.roundRect(_-2,L-2,B+4,G+4,8),e.strokeStyle=E,e.stroke())):vc(e,_,L,B,G,8,Ic),e.fillStyle=bM,e.fillText(y,x+I+1,v+C+P.actualBoundingBoxAscent+Math.floor((N-k)/2)+2),w){e.fillStyle=E;let j=8,H=8,Y=5;e.fillRect(_+B+H,L+(G/2-j/2),2,j),e.fillRect(_+B+H+Y,L+(G/2-j*2/2),2,j*2),e.fillRect(_+B+H+Y*2,L+(G/2-j/2),2,j)}}e.restore(),e.closePath()}};import wM from"clsx";import{useState as vM}from"react";import{jsx as ux}from"react/jsx-runtime";var cu=({color:e,onClick:o,name:t,src:n,className:r})=>{let i=mx(t),[a,l]=vM(!1),s=!a&&n,c=s?void 0:{background:e};return ux("div",{className:wM("Avatar",r),style:c,onClick:o,children:s?ux("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as ko,jsxs as Tc}from"react/jsx-runtime";var SM=F({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>(TM(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:hx.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:hx.EVENTUALLY}),PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:a}=o,l=cr(n,r),s=IM({"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?Tc("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[ko("div",{}),ko("div",{}),ko("div",{})]}):r.isMuted?ko("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:$0}):ko("div",{title:g("userList.hint.inCall"),children:Z0}):null;return i?Tc("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[ko(cu,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),ko("div",{className:"UserList__collaborator-name",children:r.username}),Tc("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&ko("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:Qn}),c]})]}):Tc("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[ko(cu,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),c&&ko("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{LIBRARY_DISABLED_TYPES as CM,randomId as kM}from"@excalidraw/common";import{deepCopyElement as MM}from"@excalidraw/element";import{CaptureUpdateAction as du}from"@excalidraw/element";var mu=F({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of CM)if(r.some(a=>a.type===i))return{captureUpdate:du.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:kM(),status:"unpublished",elements:r.map(MM),created:Date.now()},...i])).then(()=>({captureUpdate:du.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:du.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as bi}from"@excalidraw/element";import{isFrameLikeElement as PM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as LM}from"@excalidraw/element";import{KEYS as Cn,arrayToMap as AM}from"@excalidraw/common";import{alignElements as _M}from"@excalidraw/element";import{CaptureUpdateAction as Ei}from"@excalidraw/element";import{getSelectedElementsByGroup as DM}from"@excalidraw/element";import{jsx as yi}from"react/jsx-runtime";var Ze=(e,o)=>{let t=o.scene.getSelectedElements(e);return DM(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>PM(n))},xi=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=_M(r,n,t.scene,o),a=AM(i);return LM(e.map(l=>a.get(l.id)||l),o,t)},RM=F({name:"alignTop",label:"labels.alignTop",icon:zm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:xi(e,o,n,{position:"start",axis:"y"}),captureUpdate:Ei.IMMEDIATELY}),keyTest:e=>e[Cn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Cn.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yi(V,{hidden:!Ze(o,n),type:"button",icon:zm,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${A("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:ve(bi(e),o)})}),NM=F({name:"alignBottom",label:"labels.alignBottom",icon:Hm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:xi(e,o,n,{position:"end",axis:"y"}),captureUpdate:Ei.IMMEDIATELY}),keyTest:e=>e[Cn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Cn.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yi(V,{hidden:!Ze(o,n),type:"button",icon:Hm,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${A("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:ve(bi(e),o)})}),BM=F({name:"alignLeft",label:"labels.alignLeft",icon:Gm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:xi(e,o,n,{position:"start",axis:"x"}),captureUpdate:Ei.IMMEDIATELY}),keyTest:e=>e[Cn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Cn.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yi(V,{hidden:!Ze(o,n),type:"button",icon:Gm,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${A("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:ve(bi(e),o)})}),FM=F({name:"alignRight",label:"labels.alignRight",icon:Um,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:xi(e,o,n,{position:"end",axis:"x"}),captureUpdate:Ei.IMMEDIATELY}),keyTest:e=>e[Cn.CTRL_OR_CMD]&&e.shiftKey&&e.key===Cn.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yi(V,{hidden:!Ze(o,n),type:"button",icon:Um,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${A("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:ve(bi(e),o)})}),OM=F({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Wm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:xi(e,o,n,{position:"center",axis:"y"}),captureUpdate:Ei.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yi(V,{hidden:!Ze(o,n),type:"button",icon:Wm,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:ve(bi(e),o)})}),zM=F({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Ym,trackEvent:{category:"element"},predicate:(e,o,t,n)=>Ze(o,n),perform:(e,o,t,n)=>({appState:o,elements:xi(e,o,n,{position:"center",axis:"x"}),captureUpdate:Ei.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yi(V,{hidden:!Ze(o,n),type:"button",icon:Ym,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:ve(bi(e),o)})});import{getNonDeletedElements as gx}from"@excalidraw/element";import{isFrameLikeElement as HM}from"@excalidraw/element";import{CODES as fx,KEYS as bx,arrayToMap as GM}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as UM}from"@excalidraw/element";import{distributeElements as WM}from"@excalidraw/element";import{CaptureUpdateAction as Ex}from"@excalidraw/element";import{getSelectedElementsByGroup as YM}from"@excalidraw/element";import{jsx as wx}from"react/jsx-runtime";var xx=(e,o)=>{let t=o.scene.getSelectedElements(e);return YM(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(n=>HM(n))},yx=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=WM(r,t.scene.getNonDeletedElementsMap(),n,o),a=GM(i);return UM(e.map(l=>a.get(l.id)||l),o,t)},VM=F({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:yx(e,o,n,{space:"between",axis:"x"}),captureUpdate:Ex.IMMEDIATELY}),keyTest:e=>!e[bx.CTRL_OR_CMD]&&e.altKey&&e.code===fx.H,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>wx(V,{hidden:!xx(o,n),type:"button",icon:e0,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${A("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:ve(gx(e),o)})}),XM=F({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:yx(e,o,n,{space:"between",axis:"y"}),captureUpdate:Ex.IMMEDIATELY}),keyTest:e=>!e[bx.CTRL_OR_CMD]&&e.altKey&&e.code===fx.V,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>wx(V,{hidden:!xx(o,n),type:"button",icon:t0,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${A("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:ve(gx(e),o)})});import{arrayToMap as vx,KEYS as KM,matchKey as ZM}from"@excalidraw/common";import{CaptureUpdateAction as $M}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as jM}from"@excalidraw/element/frame";import{arrangeElements as qM}from"@excalidraw/element/arrange";import{jsx as tP}from"react/jsx-runtime";var JM=(e,o,t)=>{let n=t.scene.getSelectedElements(o),r=vx(e),i=qM(t.scene,n,r,o.arrangeConfiguration.algorithm,o.arrangeConfiguration.gap),a=vx(i);return jM(e.map(l=>a.get(l.id)||l),o,t)},QM=Ze,eP=F({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:qm,trackEvent:{category:"element"},viewMode:!1,predicate:(e,o,t,n)=>QM(o,n),perform:(e,o,t,n)=>({appState:o,elements:JM(e,o,n),captureUpdate:$M.IMMEDIATELY}),keyTest:e=>e.shiftKey&&ZM(e,KM.R),PanelComponent:({updateData:e})=>tP("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${g("labels.arrangeElements")} \u2014 ${A("Shift+R")}`,children:qm})});import{arrayToMap as Ix}from"@excalidraw/common";import{CaptureUpdateAction as oP}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as nP}from"@excalidraw/element/frame";import{normaliseElements as rP}from"@excalidraw/element/normalise";import{jsx as lP}from"react/jsx-runtime";var iP=(e,o,t)=>{let n=t.scene.getSelectedElements(o),r=Ix(e),i=rP(t.scene,n,r,o.normaliseConfiguration.mode,o.normaliseConfiguration.metric),a=Ix(i);return nP(e.map(l=>a.get(l.id)||l),o,t)},aP=Ze,pu=F({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:Jm,trackEvent:{category:"element"},viewMode:!1,predicate:(e,o,t,n)=>aP(o,n),perform:(e,o,t,n)=>({appState:o,elements:iP(e,o,n),captureUpdate:oP.IMMEDIATELY}),PanelComponent:({updateData:e})=>lP("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:g("labels.normaliseElements"),children:Jm})});import{getNonDeletedElements as sP}from"@excalidraw/element";import{bindOrUnbindBindingElements as cP}from"@excalidraw/element";import{getCommonBoundingBox as Tx}from"@excalidraw/element";import{newElementWith as dP}from"@excalidraw/element";import{deepCopyElement as mP}from"@excalidraw/element";import{resizeMultipleElements as pP}from"@excalidraw/element";import{isArrowElement as Sx,isElbowArrow as uP}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as Cx}from"@excalidraw/element";import{CODES as kx,KEYS as hP,arrayToMap as gP}from"@excalidraw/common";import{CaptureUpdateAction as Mx}from"@excalidraw/element";var uu=F({name:"flipHorizontal",label:"labels.flipHorizontal",icon:Q0,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:Cx(Px(e,n.scene.getNonDeletedElementsMap(),o,"horizontal",n),o,n),appState:o,captureUpdate:Mx.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===kx.H}),hu=F({name:"flipVertical",label:"labels.flipVertical",icon:J0,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:Cx(Px(e,n.scene.getNonDeletedElementsMap(),o,"vertical",n),o,n),appState:o,captureUpdate:Mx.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===kx.V&&!e[hP.CTRL_OR_CMD]}),Px=(e,o,t,n,r)=>{let i=q(sP(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=fP(i,o,n,r),l=gP(a);return e.map(s=>l.get(s.id)||s)},fP=(e,o,t,n)=>{if(e.every(d=>Sx(d)&&(d.startBinding||d.endBinding)))return e.map(d=>{let h=d;return dP(h,{startArrowhead:h.endArrowhead,endArrowhead:h.startArrowhead})});let{midX:r,midY:i}=Tx(e);pP(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(d=>[d.id,mP(d)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),cP(e.filter(Sx),n.scene,n.state);let{elbowArrows:a,otherElements:l}=e.reduce((d,h)=>uP(h)?{...d,elbowArrows:d.elbowArrows.concat(h)}:{...d,otherElements:d.otherElements.concat(h)},{elbowArrows:[],otherElements:[]}),{midX:s,midY:c}=Tx(e),[m,p]=[r-s,i-c];return l.forEach(d=>n.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),a.forEach(d=>n.scene.mutateElement(d,{x:d.x+m,y:d.y+p})),e};import{isTextElement as bP}from"@excalidraw/element";import{getTextFromElements as EP}from"@excalidraw/element";import{CODES as xP,KEYS as Lx,isFirefox as yP}from"@excalidraw/common";import{CaptureUpdateAction as Bt}from"@excalidraw/element";var wi=F({name:"copy",label:"labels.copy",icon:ba,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await hc(r,n.files,t)}catch(i){return{captureUpdate:Bt.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Bt.EVENTUALLY}},keyTest:void 0}),gu=F({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r;try{r=await qE()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),yP?{captureUpdate:Bt.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:Bt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard($E({types:r}))}catch(i){return console.error(i),{captureUpdate:Bt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Bt.EVENTUALLY}},keyTest:void 0}),Sc=F({name:"cut",label:"labels.cut",icon:z0,trackEvent:{category:"element"},perform:(e,o,t,n)=>(wi.perform(e,o,t,n),Sa.perform(e,o,null,n)),keyTest:e=>e[Lx.CTRL_OR_CMD]&&e.key===Lx.X}),Cc=F({name:"copyAsSvg",label:"labels.copyAsSvg",icon:eb,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Bt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=ir(e,o,!0);try{await ar("clipboard-svg",r,o,n.files,{...o,exportingFrame:i,name:n.getName()});let a=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Bt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Bt.EVENTUALLY}}},predicate:e=>uc&&e.length>0,keywords:["svg","clipboard","copy"]}),kc=F({name:"copyAsPng",label:"labels.copyAsPng",icon:tb,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:Bt.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=ir(e,o,!0);try{return await ar("clipboard",i,o,n.files,{...o,exportingFrame:a,name:n.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:r.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:Bt.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Bt.EVENTUALLY}}},predicate:e=>Sn&&e.length>0,keyTest:e=>e.code===xP.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Mc=F({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{mo(EP(r))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Bt.EVENTUALLY}},predicate:(e,o,t,n)=>uc&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(bP),keywords:["text","clipboard","copy"]});import{CODES as wP,KEYS as vP}from"@excalidraw/common";import{CaptureUpdateAction as IP}from"@excalidraw/element";var Pc=F({name:"gridMode",icon:ib,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:IP.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[vP.CTRL_OR_CMD]&&e.code===wP.QUOTE});import{CODES as TP,KEYS as SP}from"@excalidraw/common";import{CaptureUpdateAction as CP}from"@excalidraw/element";var vi=F({name:"zenMode",label:"buttons.zenMode",icon:nb,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:CP.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t,n)=>n.editorInterface.formFactor!=="phone"&&typeof t.zenModeEnabled>"u",keyTest:e=>!e[SP.CTRL_OR_CMD]&&e.altKey&&e.code===TP.Z});import{CODES as kP,KEYS as MP}from"@excalidraw/common";import{CaptureUpdateAction as PP}from"@excalidraw/element";var fu=F({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:ob,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:PP.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[MP.CTRL_OR_CMD]&&e.altKey&&e.code===kP.S});import{CODES as LP,KEYS as AP}from"@excalidraw/common";import{CaptureUpdateAction as _P}from"@excalidraw/element";var Ii=F({name:"stats",label:"stats.fullTitle",icon:q0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:_P.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[AP.CTRL_OR_CMD]&&e.altKey&&e.code===LP.SLASH});import{BOUND_TEXT_PADDING as Ax,ROUNDNESS as _x,TEXT_ALIGN as Nx,VERTICAL_ALIGN as Bx,arrayToMap as Fx,getFontString as DP}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as RP,isBoundToContainer as Dx,resetOriginalContainerCache as NP,updateOriginalContainerCache as BP}from"@excalidraw/element";import{computeBoundTextPosition as FP,computeContainerDimensionForBoundText as Rx,getBoundTextElement as Ox,redrawTextBoundingBox as zx}from"@excalidraw/element";import{hasBoundTextElement as OP,isArrowElement as zP,isTextBindableContainer as bu,isTextElement as $a,isUsingAdaptiveRadius as HP}from"@excalidraw/element";import{measureText as GP}from"@excalidraw/element";import{syncMovedIndices as Hx}from"@excalidraw/element";import{newElement as UP}from"@excalidraw/element";import{CaptureUpdateAction as Eu}from"@excalidraw/element";var xu=F({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>n.scene.getSelectedElements(o).some(i=>OP(i)),perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=n.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=Ox(a,i);if(l){let{width:s,height:c}=GP(l.originalText,DP(l),l.lineHeight),m=RP(a.id);NP(a.id);let{x:p,y:d}=FP(a,l,i);n.scene.mutateElement(l,{containerId:null,width:s,height:c,text:l.originalText,x:p,y:d}),n.scene.mutateElement(a,{boundElements:a.boundElements?.filter(h=>h.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:Eu.IMMEDIATELY}}}),yu=F({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);if(r.length===2){let i=$a(r[0])||$a(r[1]),a;if(bu(r[0])?a=r[0]:bu(r[1])&&(a=r[1]),i&&a&&Ox(a,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i,a;$a(r[0])&&bu(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),n.scene.mutateElement(i,{containerId:a.id,verticalAlign:Bx.MIDDLE,textAlign:Nx.CENTER,autoResize:!0,angle:zP(a)?0:a?.angle??0}),n.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return zx(i,a,n.scene),BP(a.id,l),{elements:WP(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:Eu.IMMEDIATELY}}}),WP=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===t.id);n.splice(r,1);let i=n.findIndex(a=>a.id===o.id);return n.splice(i+1,0,t),Hx(n,Fx([o,t])),n},YP=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===o.id);n.splice(r,1);let i=n.findIndex(a=>a.id===t.id);return n.splice(i,0,o),Hx(n,Fx([o,t])),n},Gx=F({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=r.some(a=>$a(a)&&!Dx(a));return r.length>0&&i},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of r)if($a(l)&&!Dx(l)){let s=UP({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:HP("rectangle")?_x.ADAPTIVE_RADIUS:_x.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-Ax,y:l.y-Ax,width:Rx(l.width,"rectangle"),height:Rx(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(p=>p.type==="arrow").map(p=>p.id);i.filter(p=>c.includes(p.id)).forEach(p=>{let d=p.startBinding,h=p.endBinding;d?.elementId===l.id&&(d={...d,elementId:s.id}),h?.elementId===l.id&&(h={...h,elementId:s.id}),(d||h)&&n.scene.mutateElement(p,{startBinding:d,endBinding:h})})}n.scene.mutateElement(l,{containerId:s.id,verticalAlign:Bx.MIDDLE,boundElements:null,textAlign:Nx.CENTER,autoResize:!0}),zx(l,s,n.scene),i=YP([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:Eu.IMMEDIATELY}}});import{isEmbeddableElement as lL}from"@excalidraw/element";import{KEYS as qx}from"@excalidraw/common";import{CaptureUpdateAction as sL}from"@excalidraw/element";import{pointFrom as Vx}from"@excalidraw/math";import VP from"clsx";import{useCallback as Ux,useEffect as Wx,useLayoutEffect as XP,useRef as KP,useState as ZP}from"react";import{EVENT as wu,HYPERLINK_TOOLTIP_DELAY as $P,KEYS as Lc}from"@excalidraw/common";import{getElementAbsoluteCoords as Cu}from"@excalidraw/element";import{hitElementBoundingBox as jP}from"@excalidraw/element";import{isElementLink as qP}from"@excalidraw/element";import{getEmbedLink as JP,embeddableURLValidator as QP}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Xx,viewportCoordsToSceneCoords as eL,wrapEvent as tL,isLocalLink as oL,normalizeLink as vu}from"@excalidraw/common";import{isEmbeddableElement as Iu}from"@excalidraw/element";import{jsx as Ti,jsxs as Yx}from"react/jsx-runtime";var ku=380,nL=42,Tu=5,Kx=85,rL=500,Su=!1,Ac=new Map,Zx=({element:e,scene:o,setAppState:t,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=vo(),s=Io(),c=de(),m=e.link||"",[p,d]=ZP(m),h=KP(null),f=l.showHyperlinkPopup==="editor",b=Ux(()=>{if(!h.current)return;let v=vu(h.current.value)||null;if(!e.link&&v&&le("hyperlink","create"),Iu(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!QP(v,s.validateEmbeddable))v&&r({message:g("toast.unableToEmbed"),closable:!0}),e.link&&Ac.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:I,height:C}=e,P=JP(v);P?.error instanceof URIError&&r({message:g("toast.unrecognizedLinkFormat"),closable:!0});let k=P?P.intrinsicSize.w/P.intrinsicSize.h:1,N=Ac.get(e.id)!==e.link;o.mutateElement(e,{...N?{width:P?.type==="video"?I>C?I:C*k:I,height:P?.type==="video"&&I>C?I/k:C}:{},link:v}),i(e,!0),Ac.has(e.id)&&Ac.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,r,s.validateEmbeddable,l.activeEmbeddable,t,i]);XP(()=>()=>{b()},[b]),Wx(()=>{f&&h?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&h.current.select()},[f,c.formFactor,c.isTouchScreen]),Wx(()=>{let v=null,I=C=>{if(f)return;v&&clearTimeout(v),aL(e,a,l,Vx(C.clientX,C.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},rL))};return window.addEventListener(wu.POINTER_MOVE,I,!1),()=>{window.removeEventListener(wu.POINTER_MOVE,I,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let E=Ux(()=>{le("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),w=()=>{le("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:x}=$x(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:Yx("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${y}px`,width:ku,padding:Tu},children:[f?Ti("input",{className:VP("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:h,value:p,onChange:v=>d(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[Lc.CTRL_OR_CMD]&&v.key===Lc.K&&v.preventDefault(),(v.key===Lc.ENTER||v.key===Lc.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?Ti("a",{href:vu(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:oL(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&n){let I=tL(wu.EXCALIDRAW_LINK,v.nativeEvent);n({...e,link:vu(e.link)},I),I.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Ti("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),Yx("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&Ti(V,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:pn}),Ti(V,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Ls}),m&&!Iu(e)&&Ti(V,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:E,className:"excalidraw-hyperlinkContainer--remove",icon:Yo})]})]})},$x=(e,o,t)=>{let[n,r]=Cu(e,t),{x:i,y:a}=Xx({sceneX:n+e.width/2,sceneY:r},o),l=i-o.offsetLeft-ku/2,s=a-o.offsetTop-Kx;return{x:l,y:s}},Mu=(e,o)=>{let t=q(e,o);return Iu(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},ja=null,jx=(e,o,t)=>{ja&&clearTimeout(ja),ja=window.setTimeout(()=>iL(e,o,t),$P)},iL=(e,o,t)=>{if(!e.link)return;let n=pi();n.classList.add("excalidraw-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=qP(e.link)?g("labels.link.goToElement"):e.link;let[r,i,a,l]=Cu(e,t),[s,c,m,p]=r1([r,i,a,l],e.angle,o),d=Xx({sceneX:s,sceneY:c},o);Up(n,{left:d.x,top:d.y,width:m,height:p},"top"),le("hyperlink","tooltip","link-icon"),Su=!0},Pu=()=>{ja&&clearTimeout(ja),Su&&(Su=!1,pi().classList.remove("excalidraw-tooltip--visible"))},aL=(e,o,t,[n,r])=>{let{x:i,y:a}=eL({clientX:n,clientY:r},t),l=15/t.zoom.value;if(jP(Vx(i,a),e,o))return!1;let[s,c,m]=Cu(e,o);if(i>=s&&i<=m&&a>=c-Kx&&a<=c)return!1;let{x:p,y:d}=$x(e,t,o);return!(n>=p-l&&n<=p+ku+Tu*2+l&&r>=d-l&&r<=d+l+Tu*2+nL)};import{jsx as cL}from"react/jsx-runtime";var qa=F({name:"hyperlink",label:(e,o)=>Mu(e,o),icon:ya,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:sL.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[qx.CTRL_OR_CMD]&&e.key===qx.K,predicate:(e,o)=>q(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=q(e,o);return cL(V,{type:"button",icon:ya,"aria-label":g(Mu(e,o)),title:`${lL(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${A("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as Jx,arrayToMap as Au,randomId as dL}from"@excalidraw/common";import{elementsAreInSameGroup as mL,newElementWith as Qx,selectGroupsFromGivenElements as ey}from"@excalidraw/element";import{CaptureUpdateAction as ty}from"@excalidraw/element";var Lu=e=>e.every(o=>!o.locked),Ja=F({name:"toggleElementLock",label:(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Lu(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=q(o,e);return Lu(t)?dn:Wo},trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=Lu(r),a=Au(r),l=r.length>1&&mL(r),c=r.length===1||l?null:dL(),m={...o.lockedMultiSelections};if(i)m={...o.lockedMultiSelections,...c?{[c]:!0}:{}};else if(l){let w=r[0].groupIds.at(-1);delete m[w]}let p=e.map(w=>{if(!a.has(w.id))return w;let y=w.groupIds;return i?c&&(y=[...y,c]):y=y.filter(x=>!o.lockedMultiSelections[x]),Qx(w,{locked:i,groupIds:y.length!==w.groupIds.length?y:w.groupIds})}),d=Au(p),h=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),f=r.map(w=>d.get(w.id)||w),b=i?{}:ey(f,o),E=i?c||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:p,appState:{...o,selectedElementIds:h,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:E},captureUpdate:ty.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key.toLocaleLowerCase()===Jx.L&&e[Jx.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),oy=F({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Wo,predicate:(e,o)=>q(e,o).length===0&&e.some(n=>n.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),n=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return Qx(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),r=Au(n),i=t.map(a=>r.get(a.id)||a);return{elements:n,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:ey(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:ty.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as L_,isLinearElement as A_,isLineElement as Yi}from"@excalidraw/element";import{arrayToMap as __,invariant as Ah}from"@excalidraw/common";import{toggleLinePolygonState as D_,CaptureUpdateAction as hw}from"@excalidraw/element";import U2 from"clsx";import I8 from"fuzzy";import{useEffect as ad,useRef as W2,useMemo as T8,useState as id}from"react";import{DEFAULT_SIDEBAR as z2,EVENT as sd,KEYS as ho,capitalizeString as S8,isWritableElement as C8}from"@excalidraw/common";import{CaptureUpdateAction as KL}from"@excalidraw/element";import{useEffect as tl,useMemo as ny,useRef as Nu,useState as pL}from"react";import{getLinearElementSubType as ki,updateElbowArrowPoints as uL}from"@excalidraw/element";import{pointFrom as Dc,pointRotateRads as hL}from"@excalidraw/math";import{hasBoundTextElement as gL,isArrowBoundToElement as fL,isArrowElement as bL,isElbowArrow as EL,isLinearElement as zu,isUsingAdaptiveRadius as xL}from"@excalidraw/element";import{getCommonBoundingBox as yL,getElementAbsoluteCoords as wL}from"@excalidraw/element";import{getBoundTextElement as sy,getBoundTextMaxHeight as vL,getBoundTextMaxWidth as IL,redrawTextBoundingBox as TL}from"@excalidraw/element";import{wrapText as SL}from"@excalidraw/element";import{assertNever as CL,CLASSES as kL,getFontString as _u,isProdEnv as ML,mapFind as PL,reduceToCommonValue as LL,updateActiveTool as ry}from"@excalidraw/common";import{measureText as iy}from"@excalidraw/element";import{LinearElementEditor as AL}from"@excalidraw/element";import{newArrowElement as Du,newElement as _L,newLinearElement as DL}from"@excalidraw/element";import{ShapeCache as RL}from"@excalidraw/element";import{updateBindings as NL}from"@excalidraw/element";import{jsx as Ou}from"react/jsx-runtime";var BL=8,FL=10,Qa=["rectangle","diamond","ellipse"],el=["line","sharpArrow","curvedArrow","elbowArrow"],OL=new Set(Qa),zL=new Set(el),Mi=e=>OL.has(e),Nc=e=>e==="arrow"||zL.has(e),uo=Se(null),ol=new Map,nl=new Map,HL=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Nu(null);return tl(()=>{if(o.length===0){e.updateEditorAtom(uo,null);return}let n=Pi(o);n&&!t.current?t.current=n:(t.current&&!n||t.current&&n!==t.current)&&(e.updateEditorAtom(uo,null),t.current=null)},[o,e]),tl(()=>()=>{ol.clear(),nl.clear()},[]),Ou(GL,{app:e,elements:o})},GL=({app:e,elements:o})=>{let t=Pi(o),n=ny(()=>t==="generic"?dy(o):[],[t,o]),r=ny(()=>t==="linear"?Fu(o):[],[t,o]),i=t==="generic"?n.every(p=>p.type===n[0].type):t==="linear"?r.every(p=>ki(p)===ki(r[0])):!1,[a,l]=pL({x:0,y:0}),s=Nu(""),c=Nu(null);tl(()=>{let p=[...n,...r].sort((E,w)=>E.id.localeCompare(w.id)),d=`
|
|
8
|
+
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${p.map(E=>E.id).join(",")}`;if(d===s.current)return;s.current=d;let h;if(p.length===1){let[E,,,w,y,x]=wL(p[0],e.scene.getNonDeletedElementsMap());h=hL(Dc(E,w),Dc(y,x),p[0].angle)}else{let{minX:E,maxY:w}=yL(p);h=Dc(E,w)}let{x:f,y:b}=py({sceneX:h[0],sceneY:h[1]},e.state);l({x:f,y:b})},[n,r,e.scene,e.state]),tl(()=>{for(let p of r){let d=Bu(p.id,XL(p));nl.has(d)||nl.set(d,p)}},[r]),tl(()=>{for(let p of n)if(!ol.has(p.id)){let d=sy(p,e.scene.getNonDeletedElementsMap());d&&ol.set(p.id,{fontSize:d.fontSize})}},[n,e.scene]);let m=t==="linear"?[["line",xs],["sharpArrow",Zr],["curvedArrow",jr],["elbowArrow",$r]]:t==="generic"?[["rectangle",fs],["diamond",bs],["ellipse",Es]]:[];return Ou("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(FL+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-BL}px`,zIndex:2},className:kL.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([p,d])=>{let h=i&&(t==="generic"&&n[0].type===p||t==="linear"&&ki(r[0])===p);return Ou(V,{className:"Shape",type:"radio",icon:d,checked:h,name:"convertElementType-option",title:p,keyBindingLabel:"","aria-label":p,"data-testid":`toolbar-${p}`,onChange:()=>{e.state.activeTool.type!==p&&le("convertElementType",p,"ui"),Hu(e,{conversionType:t,nextType:p}),c.current?.focus()}},`${o[0].id}${o[0].version}_${p}`)})})},UL=(e,o,t)=>{let n=IL(e,o),r=vL(e,o),i=SL(o.text,_u(o),n),a=iy(i,_u(o),o.lineHeight),l=o.fontSize;for(;(a.width>n||a.height>r)&&l>0;){l-=1;let s={...o,fontSize:l};a=iy(o.text,_u(s),o.lineHeight)}Bc(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),TL(o,e,t)},Hu=(e,{conversionType:o,nextType:t,direction:n="right"})=>{if(!o)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=n==="right"?1:-1;if(o==="generic"){let l=dy(r),c=l.every(m=>m.type===l[0].type)?Qa.indexOf(l[0].type):-1;if(t=t??Qa[(c+Qa.length+a)%Qa.length],t&&Mi(t)){let m={};for(let d of l){let h=ly(d,t,e);m[h.id]=h}let p=[];for(let d of e.scene.getElementsIncludingDeleted())m[d.id]?p.push(m[d.id]):p.push(d);e.scene.replaceAllElements(p);for(let d of Object.values(m)){let h=sy(d,e.scene.getNonDeletedElementsMap());h&&(ol.get(d.id)&&Bc(h,e.scene.getNonDeletedElementsMap(),{fontSize:ol.get(d.id)?.fontSize??h.fontSize}),UL(d,h,e.scene))}e.setState(d=>({selectedElementIds:i,activeTool:ry(d,{type:"selection"})}))}}if(o==="linear"){let l=Fu(r);if(!t){let c=LL(l,ki),m=c?el.indexOf(c):-1;t=el[(m+el.length+a)%el.length]}if(Nc(t)){let c=[],m=e.scene.getElementsMapIncludingDeleted();for(let p of l){let d=nl.get(Bu(p.id,t));if(d&&ki(d)===t)m.set(d.id,d),c.push(d);else{let h=ly(p,t,e);m.set(h.id,h),c.push(h)}}e.scene.replaceAllElements(m);for(let p of c)if(zu(p))if(EL(p)){let d=WL(p);if(d.length<2)continue;let h=[];for(let b=1;b<d.length-2;b++)h.push({start:d[b],end:d[b+1],index:b+1});let f=uL(p,e.scene.getNonDeletedElementsMap(),{points:d,fixedSegments:h});Bc(p,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let d=PL(["line","sharpArrow","curvedArrow"],h=>nl.get(Bu(p.id,h)));if(d){let h=d.points;e.scene.mutateElement(p,{points:h})}}}let s=Fu(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:s.length===1?new AL(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:ry(c,{type:"selection"})}))}return!0},Pi=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(Mi(t.type))return"generic";cy(t)&&(o=!0)}return o?"linear":null},cy=e=>zu(e)&&(!bL(e)||!fL(e)&&!gL(e)),Bu=(e,o)=>`${e}:${o}`,dy=e=>e.filter(o=>Mi(o.type)),Fu=e=>e.filter(o=>cy(o)),_c=20,Si=(e,o)=>e[0]===o[0],Ru=(e,o)=>e[1]===o[1],ay=(e,o)=>Si(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),WL=e=>{let o=[e.points[0]],t=YL(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<_c?l[0]=a[0]:Math.abs(l[1]-a[1])<_c&&(l[1]=a[1]),Si(a,l)||Ru(a,l)||o.push(Dc(a[0],l[1])),o.push(l)}let n=[o[0]];for(let i=1;i<o.length-1;++i)Si(o[i-1],o[i])&&Si(o[i],o[i+1])||Ru(o[i-1],o[i])&&Ru(o[i],o[i+1])||n.push(o[i]);n.push(o[o.length-1]);let r=[n[0]];for(let i=1;i<n.length-1;++i){let a=r[r.length-1],l=n[i],s=n[i+1],c=Si(a,l),m=Si(l,s);if(c!==m){let p=ay(a,l),d=ay(l,s);if(p<_c||d<_c){if(d<p)c?s[0]=a[0]:s[1]=a[1];else if(m)for(let h=r.length-1;h>=0&&r[h][0]===a[0];--h)r[h][0]=l[0];else for(let h=r.length-1;h>=0&&r[h][1]===a[1];--h)r[h][1]=l[1];continue}}r.push(l)}return r.push(n[n.length-1]),r},YL=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[n,r]=o[o.length-1],[i,a]=e[t];(n!==i||r!==a)&&o.push(e[t])}return o},ly=(e,o,t)=>{if(!VL(e.type,o)){if(!ML())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(RL.delete(e),Mi(o)){let n=Ci(_L({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:xL(o)?Rc.ADAPTIVE_RADIUS:Rc.PROPORTIONAL_RADIUS}:e.roundness}));return NL(n,t.scene,t.state),n}if(Nc(o))switch(o){case"line":return Ci(DL({...e,type:"line"}));case"sharpArrow":return Ci(Du({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Ci(Du({...e,type:"arrow",elbowed:!1,roundness:{type:Rc.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Ci(Du({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return CL(o,`unhandled conversion type: ${o}`),e},VL=(e,o)=>!!(Mi(e)&&Mi(o)||Nc(e)&&Nc(o)),XL=e=>zu(e)?ki(e):e.type,my=HL;var uy=F({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,n){return $e.set(uo,{type:"panel"}),{captureUpdate:KL.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>Pi(e)!==null});import{canCreateLinkFromElements as Gu,defaultGetElementLinkFromSelection as ZL,getLinkIdAndTypeFromSelection as $L}from"@excalidraw/element";import{CaptureUpdateAction as rl}from"@excalidraw/element";var Fc=F({name:"copyElementLink",label:"labels.copyElementLink",icon:Vr,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=q(e,o);try{if(window.location){let i=$L(r,o);return i?(await mo(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):ZL(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:rl.EVENTUALLY}):{appState:o,elements:e,app:n,captureUpdate:rl.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:n,captureUpdate:rl.EVENTUALLY}},predicate:(e,o)=>Gu(q(e,o))}),hy=F({name:"linkToElement",label:"labels.linkToElement",icon:Ls,perform:(e,o,t,n)=>{let r=q(e,o);return r.length!==1||!Gu(r)?{elements:e,appState:o,app:n,captureUpdate:rl.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:q(e,o)[0].id}},captureUpdate:rl.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=q(e,o);return o.openDialog?.name!=="elementLinkSelector"&&r.length===1&&Gu(r)},trackEvent:!1});import{isDarwin as gy}from"@excalidraw/common";var jL={toggleTheme:[A("Shift+Alt+D")],saveScene:[A("CtrlOrCmd+S")],loadScene:[A("CtrlOrCmd+O")],imageExport:[A("CtrlOrCmd+Shift+E")],commandPalette:[A("CtrlOrCmd+/"),A("CtrlOrCmd+Shift+P")],cut:[A("CtrlOrCmd+X")],copy:[A("CtrlOrCmd+C")],paste:[A("CtrlOrCmd+V")],copyStyles:[A("CtrlOrCmd+Alt+C")],pasteStyles:[A("CtrlOrCmd+Alt+V")],selectAll:[A("CtrlOrCmd+A")],deleteSelectedElements:[A("Delete")],duplicateSelection:[A("CtrlOrCmd+D"),A(`Alt+${g("helpDialog.drag")}`)],sendBackward:[A("CtrlOrCmd+[")],bringForward:[A("CtrlOrCmd+]")],sendToBack:[gy?A("CtrlOrCmd+Alt+["):A("CtrlOrCmd+Shift+[")],bringToFront:[gy?A("CtrlOrCmd+Alt+]"):A("CtrlOrCmd+Shift+]")],copyAsPng:[A("Shift+Alt+C")],group:[A("CtrlOrCmd+G")],ungroup:[A("CtrlOrCmd+Shift+G")],gridMode:[A("CtrlOrCmd+'")],zenMode:[A("Alt+Z")],objectsSnapMode:[A("Alt+S")],stats:[A("Alt+/")],addToLibrary:[],flipHorizontal:[A("Shift+H")],flipVertical:[A("Shift+V")],viewMode:[A("Alt+R")],hyperlink:[A("CtrlOrCmd+K")],toggleElementLock:[A("CtrlOrCmd+Shift+L")],resetZoom:[A("CtrlOrCmd+0")],zoomOut:[A("CtrlOrCmd+-")],zoomIn:[A("CtrlOrCmd++")],zoomToFitSelection:[A("Shift+3")],zoomToFit:[A("Shift+1")],zoomToFitSelectionInViewport:[A("Shift+2")],toggleEraserTool:[A("E")],toggleHandTool:[A("H")],setFrameAsActiveTool:[A("F")],saveFileToDisk:[A("CtrlOrCmd+S")],saveToActiveFile:[A("CtrlOrCmd+S")],toggleShortcuts:[A("?")],searchMenu:[A("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[A("Shift+R")]},Ae=(e,o=0)=>{let t=jL[e];return t&&t.length>0?t[o]||t[0]:""};var qL="\\u0300-\\u036f",JL="\\ufe20-\\ufe2f",QL="\\u20d0-\\u20ff",eA=qL+JL+QL,tA=`[${eA}]`,oA=RegExp(tA,"g"),nA=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,rA={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},dr=e=>e.replace(nA,o=>rA[o]||o).replace(oA,"");import t8 from"clsx";import{useEffect as o8,useState as n8}from"react";import{KEYS as r8,queryFocusableElements as E2}from"@excalidraw/common";import{useCallback as iA,useState as aA}from"react";var fy=()=>{let[e,o]=aA(null),t=iA(n=>o(n),[]);return[e,t]};import{useState as p2,useCallback as ah,useMemo as u2,useEffect as lh,memo as h2,useRef as H7}from"react";import{LIBRARY_DISABLED_TYPES as G7,randomId as U7,isShallowEqual as W7,KEYS as Y7,isWritableElement as V7,addEventListener as X7,EVENT as K7,CLASSES as c2}from"@excalidraw/common";import{useEffect as yy,useRef as wy}from"react";import{URL_HASH_KEYS as Yu,URL_QUERY_KEYS as Vu,APP_NAME as vy,EVENT as zc,DEFAULT_SIDEBAR as dA,LIBRARY_SIDEBAR_TAB as mA,arrayToMap as Xu,cloneJSON as pA,preventUnload as uA,promiseTry as Iy,resolvablePromise as hA,toValidURL as gA,Queue as fA,Emitter as bA}from"@excalidraw/common";import{hashElementsVersion as EA,hashString as xA}from"@excalidraw/element";import{getCommonBoundingBox as Wu}from"@excalidraw/element";import{MIME_TYPES as mr}from"@excalidraw/common";var Li=({elements:e,appState:o,files:t,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let l=$n(e,null,{deleteInvisibleElements:!0}),s=zr(o,null),{exportBackground:c,viewBackgroundColor:m}=s;return as(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(p,d)=>{let h=document.createElement("canvas");if(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(p,d),E=n<b?n/b:o?.exportScale??1;return h.width=p*E,h.height=d*E,{canvas:h,scale:E}}let f=r?.(p,d)||{width:p,height:d};return h.width=f.width,h.height=f.height,{canvas:h,scale:f.scale??1}})},by=async e=>{let{mimeType:o=mr.png,quality:t}=e;o===mr.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${mr.png}" mimeType`),o==="image/jpg"&&(o=mr.jpg),o===mr.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${mr.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await Li(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((r,i)=>{n.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===mr.png&&e.appState?.exportEmbedScene&&(a=await d1({blob:a,metadata:ua(e.elements,e.appState,e.files||{},"local")})),r(a)},o,t)})},Ai=async({elements:e,appState:o=Br(),files:t={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let s=$n(e,null,{deleteInvisibleElements:!0}),m={...zr(o,null),exportPadding:n};return Or(s,m,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:l})},lA=async e=>{if(e.type==="svg"){let o=await Ai(e);await mo(o.outerHTML)}else if(e.type==="png")await gc(by(e));else if(e.type==="json")await hc(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as Ey,useState as sA}from"react";import{COLOR_PALETTE as cA}from"@excalidraw/common";var Uu=Se(new Map),xy=async e=>await Ai({elements:e,appState:{exportBackground:!1,viewBackgroundColor:cA.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),Oc=(e,o,t,n)=>{let[r,i]=sA();return Ey(()=>{if(o)if(e){let a=t.get(e);a?i(a):(async()=>{let l=await xy(o);l.querySelector(".style-fonts")?.remove(),l&&(t.set(e,l),i(l))})()}else(async()=>{let a=await xy(o);i(a)})()},[e,o,t,i]),Ey(()=>{let a=n.current;if(a)return r&&(a.innerHTML=r.outerHTML),()=>{a.innerHTML=""}},[r,n]),r},_i=()=>{let[e]=ue(Uu);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var yA=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],Sy=new bA,jo=Se({status:"loaded",isInitialized:!1,libraryItems:[]}),il=e=>pA(e),wA=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((n,r)=>n.id===o.elements[r].id&&n.versionNonce===o.elements[r].versionNonce)),Cy=(e,o)=>{let t=[];for(let n of o)wA(e,n)&&t.push(n);return[...t,...e]},ky=(e,o)=>{let t=Xu(o),n={deletedItems:new Map,addedItems:new Map,updatedItems:new Map};for(let i of e)t.has(i.id)||n.deletedItems.set(i.id,i);let r=Xu(e);for(let i of o){let a=r.get(i.id);a?$u(a)!==$u(i)&&n.updatedItems.set(i.id,i):n.addedItems.set(i.id,i)}return n},Ku=class{constructor(o){S(this,"currLibraryItems",[]);S(this,"prevLibraryItems",il(this.currLibraryItems));S(this,"app");S(this,"updateQueue",[]);S(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);S(this,"notifyListeners",()=>{if(this.updateQueue.length>0)$e.set(jo,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{$e.set(jo,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=il(this.currLibraryItems);let t=il(this.currLibraryItems);this.app.props.onLibraryChange?.(t),Sy.trigger(ky(o,t),t)}catch(o){console.error(o)}}});S(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],$e.set(Uu,new Map)});S(this,"resetLibrary",()=>this.setLibrary([]));S(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(il(t))}catch{return o(this.currLibraryItems)}}));S(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:dA.name,tab:mA}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await km(s,i):c=ga(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),a(n?Cy(this.currLibraryItems,c):c)):l(new Nr)}catch(s){l(s)}}))));S(this,"setLibrary",o=>{let t=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=il(await o),n(this.currLibraryItems)}catch(i){r(i)}}).catch(n=>{if(n.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw n}).finally(()=>{this.updateQueue=this.updateQueue.filter(n=>n!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},My=Ku,Ri=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=h=>e.slice(h*t,h*t+t).reduce((b,E)=>{let{height:w}=Wu(E.elements);return Math.max(b,w)},0),i=h=>{let f=0,b=0,E=0;for(let w of e){if(f%t===0&&(b=0),b===h){let{width:y}=Wu(w.elements);E=Math.max(E,y)}f++,b++}return E},a=0,l=0,s=0,c=0,m=0,p=0,d=0;for(let h of e){m&&m%t===0&&(l+=s+50,a=0,p=0,d++),p===0&&(s=r(d)),c=i(p);let{minX:f,minY:b,width:E,height:w}=Wu(h.elements),y=(c-E)/2,x=(s-w)/2;n.push(...h.elements.map(v=>({...v,x:v.x+a+y-f,y:v.y+l+x-b}))),a+=c+50,m++,p++}return n},vA=(e,o=yA)=>{if(typeof o=="function"?o(e):o.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:r,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${n.hostname}$`).test(r)&&new RegExp(`^${n.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},Zu=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Yu.addLibrary)||new URLSearchParams(window.location.search).get(Vu.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},kn=class kn{constructor(o){S(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,n=!0){let r=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(ga(l?.libraryItems||[],"published"))}catch(l){a(l)}});return n?kn.queue.push(r):r()}getLibraryItems(o){return kn.getLibraryItems(this.adapter,o,!1)}};S(kn,"queue",new fA),S(kn,"run",async(o,t)=>{let n=new kn(o);return kn.queue.push(()=>t(n))});var Di=kn,al=0,Hc=0,$u=e=>`${e.id}:${e.name||""}:${EA(e.elements)}`,Gc=e=>xA(e.map(o=>$u(o)).sort().join()),Ty=async(e,o)=>{try{return Hc++,await Di.run(e,async t=>{let n=Xu(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)n.delete(l);let r=[];for(let[l,s]of o.addedItems)n.has(l)?n.set(l,s):r.push(s);if(o.updatedItems)for(let[l,s]of o.updatedItems)n.set(l,s);let i=r.concat(Array.from(n.values())),a=Gc(i);return a!==al&&await e.save({libraryItems:i}),al=a,i})}finally{Hc--}},IA=e=>{let{excalidrawAPI:o}=e,t=wy(e);t.current=e;let n=wy(!1);yy(()=>{if(!o)return;n.current=!1;let r=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(p,d)=>{try{l=decodeURIComponent(l),l=gA(l),vA(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();p(f)}catch(h){d(h)}}),m=s!==o.id;await(m&&document.hidden?new Promise(p=>{window.addEventListener("focus",()=>p(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(p){throw o.updateScene({appState:{errorMessage:p.message}}),p}finally{if(window.location.hash.includes(Yu.addLibrary)){let p=new URLSearchParams(window.location.hash.slice(1));p.delete(Yu.addLibrary),window.history.replaceState({},vy,`#${p.toString()}`)}else if(window.location.search.includes(Vu.addLibrary)){let p=new URLSearchParams(window.location.search);p.delete(Vu.addLibrary),window.history.replaceState({},vy,`?${p.toString()}`)}}},i=l=>{l.preventDefault();let s=Zu();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),r(s))},a=Zu();if(a&&r(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,c=hA();s?c.resolve(Iy(s.load).then(async m=>{let p=null;try{if(!m)return Di.getLibraryItems(l,"load");p=ga(m.libraryItems||[],"published");let d=await Ty(l,ky([],p));try{await s.clear()}catch(h){console.error(`couldn't delete legacy library data: ${h.message}`)}return d}catch(d){return console.error(`couldn't migrate legacy library data: ${d.message}`),p}}).catch(m=>(console.error(`error during library migration: ${m.message}`),Di.getLibraryItems(l,"load")))):c.resolve(Iy(Di.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:c.then(m=>{let p=m||[];return al=Gc(p),p}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(zc.HASHCHANGE,i),()=>{window.removeEventListener(zc.HASHCHANGE,i)}},[o]),yy(()=>{let r=Sy.on(async(a,l)=>{let s=n.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&al!==Gc(l)&&await Ty(c,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{Hc&&uA(a)};return window.addEventListener(zc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(zc.BEFORE_UNLOAD,i),r(),al=0,Hc=0}},[])};import kA from"clsx";import{VERSIONS as TA}from"@excalidraw/common";import{jsx as CA}from"react/jsx-runtime";var SA=({theme:e,id:o,libraryReturnUrl:t})=>{let n=t||window.location.origin+window.location.pathname;return CA("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${n}&useHash=true&token=${o}&theme=${e}&version=${TA.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},Py=SA;import{jsx as MA,jsxs as PA}from"react/jsx-runtime";var Uc=({libraryReturnUrl:e,theme:o,id:t,style:n,children:r,className:i})=>PA("div",{className:kA("library-menu-control-buttons",i),style:n,children:[MA(Py,{id:t,libraryReturnUrl:e,theme:o}),r]});import{useCallback as Fi,useEffect as oh,useMemo as nh,useRef as a2,useState as l2}from"react";import{MIME_TYPES as D7,arrayToMap as R7,nextAnimationFrame as N7}from"@excalidraw/common";import{duplicateElements as B7}from"@excalidraw/element";import F7 from"clsx";import LA from"lodash.throttle";import{useEffect as AA}from"react";var _A=Se(0),Ly=e=>{let[o,t]=ue(_A);return AA(()=>{let{current:n}=e;if(!n)return;let r=LA(()=>{let{scrollTop:i}=n;t(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,t]),o};import c7 from"clsx";import{useCallback as d7,useState as Qu}from"react";import{muteFSAbortError as m7}from"@excalidraw/common";import{flushSync as Ay}from"react-dom";import DA from"clsx";import{jsx as Wc,jsxs as NA}from"react/jsx-runtime";var RA=({label:e,onClick:o,className:t,children:n,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return NA("button",{className:DA("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[n&&Wc("div",{style:a?{visibility:"hidden"}:{},children:n}),Wc("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Wc("div",{style:{position:"absolute",inset:0},children:Wc(Dt,{})})]})},qo=RA;import{jsx as _y,jsxs as Dy}from"react/jsx-runtime";var BA=e=>{let{onConfirm:o,onCancel:t,children:n,confirmText:r=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=he(),c=Hr(Ni),{container:m}=ke();return Dy(We,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[n,Dy("div",{className:"confirm-dialog-buttons",children:[_y(qo,{label:i,onClick:()=>{s({openMenu:null}),c(!1),Ay(()=>{t()}),m?.focus()}}),_y(qo,{label:r,onClick:()=>{s({openMenu:null}),c(!1),Ay(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},Ry=BA;import{useCallback as WA,useEffect as Ju,useRef as Ny,useState as ju}from"react";import{EDITOR_LS_KEYS as qu,EXPORT_DATA_TYPES as YA,MIME_TYPES as By,VERSIONS as VA,chunk as XA,getExportSource as KA}from"@excalidraw/common";var Mn=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};S(Mn,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),S(Mn,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Yc from"react";var FA=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,OA=/{{([\w-]+)}}/,zA=/<([\w-]+)>/,HA=/<\/([\w-]+)>/,GA=(e,o)=>{let t=[{name:"",children:[]}];return e.split(FA).filter(Boolean).forEach(n=>{let r=n.match(zA),i=n.match(HA),a=n.match(OA);if(r!==null){let l=r[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),c=Yc.createElement(Yc.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(c))}else console.warn(`Trans: unexpected end tag ${n} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(n)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},UA=({i18nKey:e,children:o,...t})=>{let{t:n}=Ue();return Yc.createElement(Yc.Fragment,{},...GA(n(e),t))},Ft=UA;import{jsx as me,jsxs as dt}from"react/jsx-runtime";var ZA=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=XA(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(n*2)-n*2,a.height=i.length*128+(i.length+1)*(n*2)-n*2;let l=a.getContext("2d");l.fillStyle="#fff",l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let m=await Li({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:p,height:d}=m,h=Math.floor(s/6)*(128+n*2),f=s%6*(128+n*2);l.drawImage(m,f+(128-p)/2+n,h+(128-d)/2+n),l.lineWidth=r,l.strokeStyle="#ced4da",l.strokeRect(f+n/2,h+n/2,128+n,128+n)}return await cs(new File([await jn(a)],"preview",{type:By.png}),{outputType:By.jpg,maxWidthOrHeight:5e3})},$A=({libItem:e,appState:o,index:t,onChange:n,onRemove:r})=>{let i=Ny(null),a=Ny(null);return Ju(()=>{let l=i.current;l&&(async()=>{let s=await Ai({elements:e.elements,appState:{...o,viewBackgroundColor:"#fff",exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),dt("div",{className:"single-library-item",children:[e.status==="published"&&me("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),me("div",{ref:i,className:"single-library-item__svg"}),me(V,{"aria-label":g("buttons.remove"),type:"button",icon:Ut,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:g("buttons.remove")}),dt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[dt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[dt("div",{style:{padding:"0.5em 0"},children:[me("span",{style:{fontWeight:500,color:"#868e96"},children:g("publishDialog.itemName")}),me("span",{"aria-hidden":"true",className:"required",children:"*"})]}),me("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{n(l.target.value,t)}})]}),me("span",{className:"error",children:e.error})]})]})},jA=({onClose:e,libraryItems:o,appState:t,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=ju({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=ju(!1);Ju(()=>{let x=Mn.get(qu.PUBLISH_LIBRARY);x&&s(x)},[]);let[p,d]=ju(o.slice());Ju(()=>{d(o.slice())},[o]);let h=x=>{s({...l,[x.target.name]:x.target.value})},f=async x=>{x.preventDefault(),m(!0);let v=[],I=!1;if(p.forEach(L=>{let B="";L.name||(B=g("publishDialog.errors.required"),I=!0),v.push({...L,error:B})}),I){d(v),m(!1);return}let C=await ZA(p),P={type:YA.excalidrawLibrary,version:VA.excalidrawLibrary,source:KA(),libraryItems:p},k=JSON.stringify(P,null,2),N=new Blob([k],{type:"application/json"}),_=new FormData;_.append("excalidrawLib",N),_.append("previewImage",C),_.append("previewImageType",C.type),_.append("title",l.name),_.append("authorName",l.authorName),_.append("githubHandle",l.githubHandle),_.append("name",l.name),_.append("description",l.description),_.append("twitterHandle",l.twitterHandle),_.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:_}).then(L=>L.ok?L.json().then(({url:B})=>{Mn.delete(qu.PUBLISH_LIBRARY),n({url:B,authorName:l.authorName,items:p})}):L.json().catch(()=>{throw new Error(L.statusText||"something went wrong")}).then(B=>{throw new Error(B.message||L.statusText||"something went wrong")}),L=>{console.error(L),r(L),m(!1)}).catch(L=>{console.error(L),r(L),m(!1)})},b=()=>{let x=[];return p.forEach((v,I)=>{x.push(me("div",{className:"single-library-item-wrapper",children:me($A,{libItem:v,appState:t,index:I,onChange:(C,P)=>{let k=p.slice();k[P].name=C,d(k)},onRemove:a})},I))}),me("div",{className:"selected-library-items",children:x})},E=WA(()=>{i(p),Mn.set(qu.PUBLISH_LIBRARY,l),e()},[p,e,i,l]),w=!!o.length,y=o.some(x=>x.status==="published");return me(We,{onCloseRequest:E,title:g("publishDialog.title"),className:"publish-library",children:w?dt("form",{onSubmit:f,children:[me("div",{className:"publish-library-note",children:me(Ft,{i18nKey:"publishDialog.noteDescription",link:x=>me("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:x})})}),me("span",{className:"publish-library-note",children:me(Ft,{i18nKey:"publishDialog.noteGuidelines",link:x=>me("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:x})})}),me("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),y&&me("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),dt("div",{className:"publish-library__fields",children:[dt("label",{children:[dt("div",{children:[me("span",{children:g("publishDialog.libraryName")}),me("span",{"aria-hidden":"true",className:"required",children:"*"})]}),me("input",{type:"text",name:"name",required:!0,value:l.name,onChange:h,placeholder:g("publishDialog.placeholder.libraryName")})]}),dt("label",{style:{alignItems:"flex-start"},children:[dt("div",{children:[me("span",{children:g("publishDialog.libraryDesc")}),me("span",{"aria-hidden":"true",className:"required",children:"*"})]}),me("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:h,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),dt("label",{children:[dt("div",{children:[me("span",{children:g("publishDialog.authorName")}),me("span",{"aria-hidden":"true",className:"required",children:"*"})]}),me("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:h,placeholder:g("publishDialog.placeholder.authorName")})]}),dt("label",{children:[me("span",{children:g("publishDialog.githubUsername")}),me("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:h,placeholder:g("publishDialog.placeholder.githubHandle")})]}),dt("label",{children:[me("span",{children:g("publishDialog.twitterUsername")}),me("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:h,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),dt("label",{children:[me("span",{children:g("publishDialog.website")}),me("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:h,placeholder:g("publishDialog.placeholder.website")})]}),me("span",{className:"publish-library-note",children:me(Ft,{i18nKey:"publishDialog.noteLicense",link:x=>me("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:x})})})]}),dt("div",{className:"publish-library__buttons",children:[me(qo,{label:g("buttons.saveLibNames"),onClick:E,"data-testid":"cancel-clear-canvas-button"}),me(qo,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:c})]})]}):me("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},Fy=jA;import Qy from"react";import QA from"clsx";import{useEffect as e7,useRef as t7}from"react";import{EVENT as Gy,KEYS as o7}from"@excalidraw/common";import{forwardRef as Oy}from"react";import zy from"clsx";import{jsx as Hy}from"react/jsx-runtime";var qA=Oy(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>Hy("div",{className:zy("Stack Stack_horizontal",r),style:{"--gap":o,alignItems:t,justifyContent:n,...i},ref:a,children:e})),JA=Oy(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>Hy("div",{className:zy("Stack Stack_vertical",r),style:{"--gap":o,justifyItems:t,justifyContent:n,...i},ref:a,children:e})),Tt={Row:qA,Col:JA};import{jsx as Vc}from"react/jsx-runtime";var Uy=({children:e,onClickOutside:o,className:t="",onSelect:n,style:r,placement:i="bottom"})=>{let a=de(),l=t7(null),s=gn({onClickOutside:o});ei(l,m=>{l.current?.closest(".dropdown-menu-container")?.contains(m.target)||s.onClickOutside?.()}),e7(()=>{let m=d=>{d.key===o7.ESCAPE&&(d.stopImmediatePropagation(),s.onClickOutside?.())},p={capture:!0};return document.addEventListener(Gy.KEYDOWN,m,p),()=>{document.removeEventListener(Gy.KEYDOWN,m,p)}},[s]);let c=QA(`dropdown-menu ${t}`,{"dropdown-menu--mobile":a.formFactor==="phone","dropdown-menu--placement-top":i==="top"}).trim();return Vc(Tp.Provider,{value:{onSelect:n},children:Vc("div",{ref:l,className:c,style:r,"data-testid":"dropdown-menu",children:a.formFactor==="phone"?Vc(Tt.Col,{className:"dropdown-menu-container",children:e}):Vc(ze,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};Uy.displayName="DropdownMenuContent";var Wy=Uy;import{jsx as r7}from"react/jsx-runtime";var n7=({children:e,className:o="",selected:t,...n})=>r7("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),Yy=n7;import{jsx as Vy}from"react/jsx-runtime";var Xy=({icon:e,shortcut:o,href:t,children:n,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let c=qs(s.onClick,r);return Vy("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:js(i,a),title:s.title??s["aria-label"],onClick:c,children:Vy($s,{icon:e,shortcut:o,children:n})})},Bi=Xy;Xy.displayName="DropdownMenuItemLink";import{jsx as i7}from"react/jsx-runtime";var Ky=()=>i7("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0",flex:"0 0 auto"}}),Zy=Ky;Ky.displayName="DropdownMenuSeparator";import a7 from"clsx";import{jsx as l7}from"react/jsx-runtime";var $y=({className:e="",children:o,onToggle:t,title:n,...r})=>{let i=de(),a=a7(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return l7("button",{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:o})},jy=$y;$y.displayName="DropdownMenuTrigger";import Xc from"react";var qy=e=>{let o=Xc.Children.toArray(e).find(t=>Xc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},Jy=e=>{let o=Xc.Children.toArray(e).find(t=>Xc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{jsxs as s7}from"react/jsx-runtime";var Jo=({children:e,open:o,placement:t})=>{let n=qy(e),r=Jy(e),i=r&&Qy.isValidElement(r)?Qy.cloneElement(r,{placement:t}):r;return s7("div",{className:"dropdown-menu-container",style:{display:"contents"},children:[n,o&&i]})};Jo.Trigger=jy;Jo.Content=Wy;Jo.Item=vt;Jo.ItemLink=Bi;Jo.ItemCustom=Yy;Jo.Group=_a;Jo.Separator=Zy;var ge=Jo;Jo.displayName="DropdownMenu";import{jsx as St,jsxs as Kc}from"react/jsx-runtime";var p7=(e,o)=>e.filter(t=>o.includes(t.id)),u7=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:a,className:l})=>{let[s]=ue(jo),[c,m]=ue(Ni),p=()=>{let _=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),L=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return St(Ry,{onConfirm:()=>{o.length?n():r(),h(!1)},onCancel:()=>{h(!1)},title:L,children:St("p",{children:_})})},[d,h]=Qu(!1),f=!!o.length,b=f?s.libraryItems.filter(_=>o.includes(_.id)):s.libraryItems,E=f?g("buttons.remove"):g("buttons.resetLibrary"),[w,y]=Qu(!1),[x,v]=Qu(null),I=d7(()=>Kc(We,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[St("p",{children:St(Ft,{i18nKey:"publishSuccessDialog.content",authorName:x.authorName,link:_=>St("a",{href:x?.url,target:"_blank",rel:"noopener noreferrer",children:_})})}),St(V,{type:"button",title:g("buttons.close"),"aria-label":g("buttons.close"),label:g("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,x]),C=(_,L)=>{y(!1),v({url:_.url,authorName:_.authorName});let B=L.slice();B.forEach(G=>{o.includes(G.id)&&(G.status="published")}),t.setLibrary(B)},P=async()=>{try{await t.updateLibrary({libraryItems:es({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(_){if(_?.name==="AbortError"){console.warn(_);return}e({errorMessage:g("errors.importLibraryError")})}},k=async()=>{let _=f?b:await t.getLatestLibrary();n1(_).catch(m7).catch(L=>{e({errorMessage:L.message})})},N=()=>Kc(ge,{open:c,children:[St(ge.Trigger,{onToggle:()=>m(!c),children:k1}),Kc(ge.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!f&&St(ge.Item,{onSelect:P,icon:Yr,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&St(ge.Item,{onSelect:k,icon:qn,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),f&&St(ge.Item,{icon:O0,onSelect:()=>y(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")}),!!b.length&&St(ge.Item,{onSelect:()=>h(!0),icon:Yo,children:E})]})]});return Kc("div",{className:c7("library-menu-dropdown-container",l),children:[N(),o.length>0&&St("div",{className:"library-actions-counter",children:o.length}),d&&p(),w&&St(Fy,{onClose:()=>y(!1),libraryItems:p7(s.libraryItems,o),appState:a,onSuccess:_=>C(_,s.libraryItems),onError:_=>window.alert(_),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:_=>i(o.filter(L=>L!==_))}),x&&I()]})},e2=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:n}=qe(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=_i(),a=Te(),l=he(),[s]=ue(jo),c=async p=>{let d=p.filter(h=>!e.includes(h.id));n.setLibrary(d).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return St(u7,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:n,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:t})};import{memo as w7,useEffect as v7,useState as I7}from"react";import h7,{useCallback as g7}from"react";function f7(){return[!1,g7(o=>o(),[])]}var t2=h7.useTransition||f7;import o2 from"clsx";import{memo as b7,useRef as E7,useState as x7}from"react";import{jsx as Zc,jsxs as y7}from"react/jsx-runtime";var n2=b7(({id:e,elements:o,isPending:t,onClick:n,selected:r,onToggle:i,onDrag:a,svgCache:l})=>{let s=E7(null),c=Oc(e,o,l,s),[m,p]=x7(!1),d=de().formFactor==="phone",h=t&&Zc("div",{className:"library-unit__adder",children:C1});return y7("div",{className:o2("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":r,"library-unit--skeleton":!c}),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[Zc("div",{className:o2("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):n(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}p(!1),a(e,f)}}),h,e&&o&&(m||d||r)&&Zc(Ha,{checked:r,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),r2=()=>Zc("div",{className:"library-unit library-unit--skeleton"});import{Fragment as T7,jsx as $c}from"react/jsx-runtime";var jc=({children:e})=>$c("div",{className:"library-menu-items-container__grid",children:e}),ll=w7(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=t2(),[s,c]=I7(0);return v7(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),$c(T7,{children:e.map((m,p)=>p<s?$c(n2,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:r,svgCache:i,id:m?.id,selected:n(m.id),onToggle:o,onDrag:t},m?.id??p):$c(r2,{},p))})});import eh from"clsx";import{forwardRef as M7,useRef as P7,useImperativeHandle as L7,useLayoutEffect as A7,useState as _7}from"react";import S7 from"clsx";import{composeEventHandlers as C7}from"@excalidraw/common";import{jsx as k7}from"react/jsx-runtime";var Ot=({type:e="button",onSelect:o,selected:t,children:n,className:r="",...i})=>k7("button",{onClick:C7(i.onClick,a=>{o()}),type:e,className:S7("excalidraw-button",r,{selected:t}),...i,children:n});import{jsx as th,jsxs as i2}from"react/jsx-runtime";var Pn=M7(({onChange:e,label:o,fullWidth:t,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:c,type:m,...p},d)=>{let h=P7(null);L7(d,()=>h.current),A7(()=>{i&&(h.current?.focus(),h.current?.select())},[i]);let[f,b]=_7(!1);return i2("div",{className:eh("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{h.current?.focus()},children:[s,o&&th("div",{className:"ExcTextField__label",children:o}),i2("div",{className:eh("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[th("input",{className:eh({"is-redacted":"value"in p&&p.value&&l&&!f}),readOnly:r,value:"value"in p?p.value:void 0,defaultValue:"defaultValue"in p?p.defaultValue:void 0,placeholder:n,ref:h,onChange:E=>e?.(E.target.value),onKeyDown:a,type:m}),l&&th(Ot,{onSelect:()=>b(!f),style:{border:0,userSelect:"none"},children:f?X0:Qn})]})]})});import{Fragment as s2,jsx as Je,jsxs as Mo}from"react/jsx-runtime";var O7=17,z7=64;function rh({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:n,pendingElements:r,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let m=de(),p=a2(null),d=Ly(p);oh(()=>{d>0&&p.current?.scrollTo(0,d)},[]);let{svgCache:h}=_i(),[f,b]=l2(null),[E,w]=l2(""),y=!o.length&&!r.length,x=!y&&!!E.trim(),v=nh(()=>{let D=dr(E.trim().toLowerCase());return D?o.filter(O=>{let Q=O.name||"";return Q.trim()&&dr(Q.toLowerCase()).includes(D)}):[]},[o,E]),I=nh(()=>o.filter(D=>D.status!=="published"),[o]),C=nh(()=>o.filter(D=>D.status==="published"),[o]),P=Fi((D,O)=>{let Q=!c.includes(D),ee=[...I,...C];if(Q){if(O.shiftKey&&f){let K=ee.findIndex(yt=>yt.id===f),ae=ee.findIndex(yt=>yt.id===D);if(K===-1||ae===-1){s([...c,D]);return}let be=R7(c),ce=Math.min(K,ae),Oe=Math.max(K,ae),io=ee.reduce((yt,Go,_r)=>((_r>=ce&&_r<=Oe||be.has(Go.id))&&yt.push(Go.id),yt),[]);s(io)}else s([...c,D]);b(D)}else b(null),s(c.filter(K=>K!==D))},[f,s,C,c,I]);oh(()=>{c.length||b(null)},[c]);let k=Fi(D=>{let O;return c.includes(D)?O=o.filter(Q=>c.includes(Q.id)):O=o.filter(Q=>Q.id===D),O.map(Q=>({...Q,elements:B7({type:"everything",elements:Q.elements,randomizeSeed:!0}).duplicatedElements}))},[o,c]),N=Fi((D,O)=>{let Q={itemIds:c.includes(D)?c:[D]};O.dataTransfer.setData(D7.excalidrawlibIds,JSON.stringify(Q))},[c]),_=Fi(D=>D?c.includes(D):!1,[c]),L=Fi(()=>{t(r)},[r,t]),B=Fi(D=>{D&&n(k(D))},[k,n]),G=h.size>=(v.length?v:o).length?z7:O7,j=a2(null);oh(()=>{N7(()=>{j.current?.focus()})},[]);let H=!x&&Mo(s2,{children:[!y&&Je("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),!r.length&&!I.length?Mo("div",{className:"library-menu-items__no-items",children:[!C.length&&Je("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),Je("div",{className:"library-menu-items__no-items__hint",children:C.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):Mo(jc,{children:[r.length>0&&Je(ll,{itemsRenderedPerBatch:G,items:[{id:null,elements:r}],onItemSelectToggle:P,onItemDrag:N,onClick:L,isItemSelected:_,svgCache:h}),Je(ll,{itemsRenderedPerBatch:G,items:I,onItemSelectToggle:P,onItemDrag:N,onClick:B,isItemSelected:_,svgCache:h})]}),C.length>0&&Je("div",{className:"library-menu-items-container__header",style:{marginTop:"0.75rem"},children:g("labels.excalidrawLib")}),C.length>0&&Je(jc,{children:Je(ll,{itemsRenderedPerBatch:G,items:C,onItemSelectToggle:P,onItemDrag:N,onClick:B,isItemSelected:_,svgCache:h})})]}),Y=x&&Mo(s2,{children:[Mo("div",{className:"library-menu-items-container__header",children:[g("library.search.heading"),!e&&Mo("div",{className:"library-menu-items-container__header__hint",style:{cursor:"pointer"},onPointerDown:D=>D.preventDefault(),onClick:D=>{w("")},children:[Je("kbd",{children:"esc"})," to clear"]})]}),v.length>0?Je(jc,{children:Je(ll,{itemsRenderedPerBatch:G,items:v,onItemSelectToggle:P,onItemDrag:N,onClick:B,isItemSelected:_,svgCache:h})}):Mo("div",{className:"library-menu-items__no-items",children:[Je("div",{className:"library-menu-items__no-items__hint",children:g("library.search.noResults")}),Je(Ot,{onPointerDown:D=>D.preventDefault(),onSelect:()=>{w("")},style:{width:"auto",marginTop:"1rem"},children:g("library.search.clearSearch")})]})]});return Mo("div",{className:"library-menu-items-container",style:r.length||I.length||C.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[Mo("div",{className:"library-menu-items-header",children:[!y&&Je(Pn,{ref:j,type:"search",className:F7("library-menu-items-container__search",{hideCancelButton:m.formFactor!=="phone"}),placeholder:g("library.search.inputPlaceholder"),value:E,onChange:D=>w(D)}),Je(e2,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"})]}),Mo(Tt.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:C.length>0?1:"0 1 auto",margin:y?"auto":0},ref:p,children:[e&&Je("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:Je(Dt,{})}),H,Y,y&&Je(Uc,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i})]})]})}import{jsx as Ln,jsxs as m2}from"react/jsx-runtime";var Ni=Se(!1),d2=({children:e})=>Ln("div",{className:"layer-ui__library",children:e}),Z7=h2(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:n,libraryReturnUrl:r,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=ue(jo),p=ah(f=>{(async(E,w)=>{le("element","addToLibrary","ui");for(let x of G7)if(E.some(v=>v.type===x))return n({errorMessage:g(`errors.libraryElementTypeError.${x}`)});let y=[{status:"unpublished",elements:E,id:U7(),created:Date.now()},...w];t(),i.setLibrary(y).catch(()=>{n({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,m.libraryItems)},[t,i,n,m.libraryItems]),d=u2(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return Ln(d2,{children:Ln("div",{className:"layer-ui__library-message",children:m2("div",{children:[Ln(Dt,{size:"2em"}),Ln("span",{children:g("labels.libraryLoadingMessage")})]})})});let h=m.libraryItems.length>0||o.length>0;return m2(d2,{children:[Ln(rh,{isLoading:m.status==="loading",libraryItems:d,onAddToLibrary:p,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:r,theme:l,onSelectItems:c,selectedItems:s}),h&&Ln(Uc,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:r,theme:l})]})}),ih=(e,o)=>({elements:e,pending:q(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),$7=(e,o)=>{let t=En(),[n,r]=p2(()=>ih(t,e.selectedElementIds)),i=H7(new Map);return lh(()=>{for(let a of n.pending)i.current.set(a.id,a.version)},[n.pending]),lh(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&r(a=>{if(!W7(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),ih(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=l.get(s)?.version;if(c&&c!==i.current.get(s))return ih(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),n.pending},g2=h2(()=>{let e=qe(),{onInsertElements:o}=e,t=Io(),n=Te(),r=he(),[i,a]=p2([]),l=u2(()=>e.library,[e.library]),s=$7(n,e);lh(()=>X7(document,K7.KEYDOWN,p=>{if(p.key===Y7.ESCAPE&&p.target instanceof HTMLElement){let d=p.target;if(d.closest(`.${c2.SIDEBAR}`))i.length>0?(p.stopPropagation(),a([])):V7(d)&&d instanceof HTMLInputElement&&!d.value&&(p.stopPropagation(),r({openSidebar:null}),e.focusContainer());else if(i.length>0){let{x:h,y:f}=e.lastViewportPosition;document.elementFromPoint(h,f)?.closest(`.${c2.SIDEBAR}`)&&(p.stopPropagation(),a([]))}}},{capture:!0}),[i,r,e]);let c=ah(p=>{o(Ri(p)),e.focusContainer()},[o,e]),m=ah(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return Ln(Z7,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:r,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:a})});import j7 from"clsx";import{useRef as q7}from"react";import{createPortal as J7}from"react-dom";import{KEYS as Q7}from"@excalidraw/common";import{jsx as f2,jsxs as e8}from"react/jsx-runtime";var b2=e=>{let{closeOnClickOutside:o=!0}=e,t=zs({className:"excalidraw-modal-container"}),n=q7(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===Q7.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return J7(e8("div",{className:j7("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[f2("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),f2("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as qc,jsxs as x2}from"react/jsx-runtime";function i8(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var We=e=>{let[o,t]=fy(),[n]=n8(document.activeElement),{id:r}=ke(),i=de().formFactor==="phone";o8(()=>{if(!o)return;let c=E2(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=p=>{if(p.key===r8.TAB){let d=E2(o),{activeElement:h}=document,f=d.findIndex(b=>b===h);f===0&&p.shiftKey?(d[d.length-1].focus(),p.preventDefault()):f===d.length-1&&!p.shiftKey&&(d[0].focus(),p.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=he(),l=Hr(Ni),s=()=>{a({openMenu:null}),l(!1),n.focus(),e.onCloseRequest()};return qc(b2,{className:t8("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:i8(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:x2(ze,{ref:t,children:[e.title&&x2("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[qc("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&qc("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:Ut}),qc("div",{className:"Dialog__content",children:e.children})]})})};import{SHAPES as k8}from"@excalidraw/element/shapes";import Po from"clsx";import{useMemo as h8,useRef as g8,useState as f8}from"react";import*as Lo from"@radix-ui/react-popover";import{CLASSES as T2,KEYS as b8,capitalizeString as Qo,isTransparent as td}from"@excalidraw/common";import{shouldAllowVerticalAlign as S2,suppportsHorizontalAlign as C2,hasBoundTextElement as od,isElbowArrow as sh,isImageElement as k2,isLinearElement as ch,isTextElement as rd,isArrowElement as v2,hasStrokeColor as I2,toolIsArrow as nd}from"@excalidraw/element";import{CODES as a8,KEYS as l8}from"@excalidraw/common";import s8 from"clsx";import{CaptureUpdateAction as c8}from"@excalidraw/element";import{jsx as d8}from"react/jsx-runtime";var Jc=F({name:"viewMode",label:"labels.viewMode",icon:Qn,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:c8.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[l8.CTRL_OR_CMD]&&e.altKey&&e.code===a8.R,PanelComponent:({data:e,updateData:o,appState:t})=>d8(V,{type:"button",icon:Qn,"aria-label":g("labels.viewMode"),onClick:()=>o(null),size:e?.size||"medium","data-testid":"button-view-mode",className:s8({enabled:t.viewModeEnabled})})});import{getToolbarTools as E8,SHAPES as x8}from"@excalidraw/element/shapes";import{useEffect as m8,useState as p8}from"react";import y2 from"clsx";import{capitalizeString as w2}from"@excalidraw/common";import*as Oi from"@radix-ui/react-popover";import{jsx as Qc,jsxs as u8}from"react/jsx-runtime";var ed=({app:e,options:o,activeTool:t,defaultOption:n,className:r="Shape",namePrefix:i,title:a,"data-testid":l,onToolChange:s,displayedOption:c,fillable:m=!1})=>{let[p,d]=p8(!1),h=t.type,f=c.type===h,b=32/2+10,{container:E}=ke();return!o.some(w=>w.type===h)&&p&&d(!1),m8(()=>{let w=e.onPointerDownEmitter.on(()=>{d(!1)});return()=>w?.()},[e]),u8(Oi.Root,{open:p,children:[Qc(Oi.Trigger,{asChild:!0,children:Qc(V,{className:y2(r,{fillable:m,active:o.some(w=>w.type===t.type)}),type:"radio",icon:c.icon,checked:f,name:"editor-current-shape",title:a,"aria-label":a,"data-testid":l,onPointerDown:()=>{d(w=>!w),s(n)}})}),Qc(Oi.Content,{className:"tool-popover-content",sideOffset:b,collisionBoundary:E??void 0,children:o.map(({type:w,icon:y,title:x})=>Qc(V,{className:y2(r,{active:h===w}),type:"radio",icon:y,checked:h===w,name:`${i}-option`,title:x||w2(w),keyBindingLabel:"","aria-label":x||w2(w),"data-testid":`toolbar-${w}`,onChange:()=>{e.state.activeTool.type!==w&&le("toolbar",w,"ui"),e.setActiveTool({type:w}),s?.(w)}},w))})]})};import{Fragment as zt,jsx as Z,jsxs as se}from"react/jsx-runtime";var dh=Po([T2.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),sl=(e,o)=>{let t=o[0]?.type||null;for(let n of o)if(n.type!==t){t=null;break}return I2(e.activeTool.type)&&e.activeTool.type!=="image"&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(n=>I2(n.type))},cl=(e,o)=>yo(e.activeTool.type)||o.some(t=>yo(t.type)),M2=({appState:e,elementsMap:o,renderAction:t,app:n})=>{let r=Dr(o,e),i=!1;r.length===2&&(od(r[0])||od(r[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=de(),s=document.documentElement.getAttribute("dir")==="rtl",c=yo(e.activeTool.type)&&!td(e.currentItemBackgroundColor)||r.some(f=>yo(f.type)&&!td(f.backgroundColor)),m=r.length===1||i,p=!e.selectedLinearElement?.isEditing&&r.length===1&&ch(r[0])&&!sh(r[0]),d=!e.croppingElementId&&r.length===1&&k2(r[0]),h=!i&&Ze(e,n);return se("div",{className:"selected-shape-actions",children:[Z("div",{children:sl(e,r)&&t("changeStrokeColor")}),cl(e,r)&&Z("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(da(e.activeTool.type)||r.some(f=>da(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(ma(e.activeTool.type)||r.some(f=>ma(f.type)))&&se(zt,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(pa(e.activeTool.type)||r.some(f=>pa(f.type)))&&Z(zt,{children:t("changeRoundness")}),(nd(e.activeTool.type)||r.some(f=>nd(f.type)))&&Z(zt,{children:t("changeArrowType")}),(e.activeTool.type==="text"||r.some(rd))&&se(zt,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||C2(r,o))&&t("changeTextAlign")]}),S2(r,o)&&t("changeVerticalAlign"),(Rr(e.activeTool.type)||r.some(f=>Rr(f.type)))&&Z(zt,{children:t("changeArrowhead")}),t("changeOpacity"),se("fieldset",{children:[Z("legend",{children:g("labels.layers")}),se("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),h&&!i&&se("fieldset",{children:[Z("legend",{children:g("labels.align")}),se("div",{className:"buttonList",children:[s?se(zt,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):se(zt,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),r.length>2&&t("distributeHorizontally"),Z("div",{style:{flexBasis:"100%",height:0}}),se("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),r.length>2&&t("distributeVertically"),Z("div",{style:{flexBasis:"100%",height:0}}),t("arrangeElements"),t("normaliseElements")]})]})]}),!a&&r.length>0&&se("fieldset",{children:[Z("legend",{children:g("labels.actions")}),se("div",{className:"buttonList",children:[l.formFactor!=="phone"&&t("duplicateSelection"),l.formFactor!=="phone"&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),d&&t("cropEditor"),p&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},P2=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r})=>{let i=yo(e.activeTool.type)&&!td(e.currentItemBackgroundColor)||n.some(s=>yo(s.type)&&!td(s.backgroundColor)),a=n.length>0||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",l=e.openPopup==="compactStrokeStyles";return a?Z("div",{className:"compact-action-item",children:se(Lo.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[Z(Lo.Trigger,{asChild:!0,children:Z("button",{type:"button",className:Po("compact-action-button properties-trigger",{active:l}),title:g("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactStrokeStyles"})},children:cb})}),l&&Z(Vo,{className:dh,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:se("div",{className:"selected-shape-actions",children:[i&&o("changeFillStyle"),(da(e.activeTool.type)||n.some(s=>da(s.type)))&&o("changeStrokeWidth"),(ma(e.activeTool.type)||n.some(s=>ma(s.type)))&&se(zt,{children:[o("changeStrokeStyle"),o("changeSloppiness")]}),(pa(e.activeTool.type)||n.some(s=>pa(s.type)))&&o("changeRoundness"),o("changeOpacity")]})})]})}):null},L2=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,app:i})=>{let a=nd(e.activeTool.type)||n.some(s=>nd(s.type)),l=e.openPopup==="compactArrowProperties";return a?Z("div",{className:"compact-action-item",children:se(Lo.Root,{open:l,onOpenChange:s=>{t(s?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[Z(Lo.Trigger,{asChild:!0,children:Z("button",{type:"button",className:Po("compact-action-button properties-trigger",{active:l}),title:g("labels.arrowtypes"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:l?null:"compactArrowProperties"})},children:(()=>{let s=st(n,i,c=>v2(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>v2(c),c=>c?null:e.currentItemArrowType);return s==="elbow"?$r:s==="round"?jr:Zr})()})}),l&&Z(Vo,{container:r,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:o("changeArrowProperties")})]})}):null},A2=({appState:e,renderAction:o,setAppState:t,targetElements:n,container:r,elementsMap:i})=>{let{saveCaretPosition:a,restoreCaretPosition:l}=kb(),s=e.openPopup==="compactTextProperties";return Z("div",{className:"compact-action-item",children:se(Lo.Root,{open:s,onOpenChange:c=>{c?(e.editingTextElement&&a(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&l())},children:[Z(Lo.Trigger,{asChild:!0,children:Z("button",{type:"button",className:Po("compact-action-button properties-trigger",{active:s}),title:g("labels.textAlign"),onClick:c=>{c.preventDefault(),c.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&a(),t({openPopup:"compactTextProperties"}))},children:B1})}),e.openPopup==="compactTextProperties"&&Z(Vo,{className:dh,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&l()},children:se("div",{className:"selected-shape-actions",children:[(e.activeTool.type==="text"||n.some(rd))&&o("changeFontSize"),(e.activeTool.type==="text"||C2(n,i))&&o("changeTextAlign"),S2(n,i)&&o("changeVerticalAlign")]})})]})})},_2=({appState:e,renderAction:o,targetElements:t,setAppState:n,container:r,app:i,showDuplicate:a,showDelete:l})=>{let s=!!(e.editingTextElement||e.newElement),c=!e.croppingElementId&&t.length===1&&k2(t[0]),m=t.length===1,p=Ze(e,i),d=!1;t.length===2&&(od(t[0])||od(t[1]))&&(d=!0);let h=document.documentElement.getAttribute("dir")==="rtl",f=e.openPopup==="compactOtherProperties";return s||t.length===0?null:Z("div",{className:"compact-action-item",children:se(Lo.Root,{open:f,onOpenChange:b=>{n(b?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[Z(Lo.Trigger,{asChild:!0,children:Z("button",{type:"button",className:Po("compact-action-button properties-trigger",{active:f}),title:g("labels.actions"),onClick:b=>{b.preventDefault(),b.stopPropagation(),n({openPopup:f?null:"compactOtherProperties"})},children:M1})}),f&&Z(Vo,{className:dh,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:se("div",{className:"selected-shape-actions",children:[se("fieldset",{children:[Z("legend",{children:g("labels.layers")}),se("div",{className:"buttonList",children:[o("sendToBack"),o("sendBackward"),o("bringForward"),o("bringToFront")]})]}),p&&!d&&se("fieldset",{children:[Z("legend",{children:g("labels.align")}),se("div",{className:"buttonList",children:[h?se(zt,{children:[o("alignRight"),o("alignHorizontallyCentered"),o("alignLeft")]}):se(zt,{children:[o("alignLeft"),o("alignHorizontallyCentered"),o("alignRight")]}),t.length>2&&o("distributeHorizontally"),Z("div",{style:{flexBasis:"100%",height:0}}),se("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[o("alignTop"),o("alignVerticallyCentered"),o("alignBottom"),t.length>2&&o("distributeVertically"),Z("div",{style:{flexBasis:"100%",height:0}}),o("arrangeElements"),o("normaliseElements")]})]})]}),se("fieldset",{children:[Z("legend",{children:g("labels.actions")}),se("div",{className:"buttonList",children:[o("group"),o("ungroup"),m&&o("hyperlink"),c&&o("cropEditor"),a&&o("duplicateSelection"),l&&o("deleteSelectedElements")]})]})]})})]})})},y8=({appState:e,renderAction:o,targetElements:t})=>!e.selectedLinearElement?.isEditing&&t.length===1&&ch(t[0])&&!sh(t[0])?Z("div",{className:"compact-action-item",children:o("toggleLinearEditor")}):null,D2=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=Dr(o,e),{container:a}=ke(),l=!!(e.editingTextElement||e.newElement),s=!e.selectedLinearElement?.isEditing&&i.length===1&&ch(i[0])&&!sh(i[0]);return se("div",{className:"compact-shape-actions",children:[sl(e,i)&&Z("div",{className:Po("compact-action-item"),children:t("changeStrokeColor")}),cl(e,i)&&Z("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),Z(P2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a}),Z(L2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,app:n}),s&&Z("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),(e.activeTool.type==="text"||i.some(rd))&&se(zt,{children:[Z("div",{className:"compact-action-item",children:t("changeFontFamily")}),Z(A2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,elementsMap:o})]}),!l&&i.length>0&&Z("div",{className:"compact-action-item",children:t("duplicateSelection")}),!l&&i.length>0&&Z("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),Z(_2,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:a,app:n})]})},R2=({appState:e,elementsMap:o,renderAction:t,app:n,setAppState:r})=>{let i=Dr(o,e),{container:a}=ke(),l=g8(null),s=l.current?.getBoundingClientRect()?.width??0,c=9,m=6,p=32,d=c*p+(c-1)*m,h=p+m,f=s>=d+h,b=s>=d+2*h;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:[sl(e,i)&&Z("div",{className:Po("compact-action-item"),children:t("changeStrokeColor")}),cl(e,i)&&Z("div",{className:"compact-action-item",children:t("changeBackgroundColor")}),Z(P2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a}),Z(L2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,app:n}),Z(y8,{appState:e,renderAction:t,targetElements:i}),(e.activeTool.type==="text"||i.some(rd))&&se(zt,{children:[Z("div",{className:"compact-action-item",children:t("changeFontFamily")}),Z(A2,{appState:e,renderAction:t,setAppState:r,targetElements:i,container:a,elementsMap:o})]}),Z(_2,{appState:e,renderAction:t,targetElements:i,setAppState:r,container:a,app:n,showDuplicate:!b,showDelete:!f})]}),se("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[Z("div",{className:"compact-action-item",children:t("undo")}),Z("div",{className:"compact-action-item",children:t("redo")}),b&&Z("div",{className:"compact-action-item",children:t("duplicateSelection")}),f&&Z("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},N2=({activeTool:e,setAppState:o,app:t,UIOptions:n})=>{let[r,i]=f8(!1),a=je(),l=a==="full",s=a==="compact",c=[{type:"selection",icon:gs,title:Qo(g("toolBar.selection"))},{type:"lasso",icon:mn,title:Qo(g("toolBar.lasso"))}],m=e.type==="frame",p=e.type==="laser",d=l&&e.type==="lasso"&&t.state.preferredSelectionTool.type!=="lasso",h=e.type==="embeddable",f=x8.filter(E=>E.myocSimplifiedMode===!1),b=h8(()=>{switch(e.type){case"frame":return{icon:hn,highlight:!1};case"lasso":return{icon:mn,highlight:!0};case"embeddable":return{icon:ws,highlight:!0};case"laser":return t.props.isCollaborating?{icon:Xr,highlight:!0}:{icon:Kr,highlight:!0};case"diamond":return{icon:bs,highlight:!0};case"rectangle":return{icon:fs,highlight:!0};case"ellipse":return{icon:Es,highlight:!0};case"arrow":return{icon:R1,highlight:!0};case"line":return{icon:xs,highlight:!0};default:return{icon:Xr,highlight:!1}}},[e.type,t.props.isCollaborating]);return se(zt,{children:[E8(t).filter(E=>!t.state.myocSimplifiedMode||E.myocSimplifiedMode).map(({value:E,icon:w,key:y,fillable:x},v)=>{if(n.tools?.[E]===!1)return null;let I=g(`toolBar.${E}`),C=y&&Qo(typeof y=="string"?y:y[0]),P=C;return(E==="selection"||E==="lasso")&&s?Z(ed,{app:t,options:c,activeTool:e,defaultOption:t.state.preferredSelectionTool.type,namePrefix:"selectionType",title:Qo(g("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:k=>{(k==="selection"||k==="lasso")&&(t.setActiveTool({type:k}),o({preferredSelectionTool:{type:k,initialized:!0}}))},displayedOption:c.find(k=>k.type===t.state.preferredSelectionTool.type)||c[0],fillable:e.type==="selection"},"selection-popover"):Z(V,{className:Po("Shape",{fillable:x}),type:"radio",icon:w,checked:e.type===E,name:"editor-current-shape",title:`${Qo(I)} \u2014 ${P}`,keyBindingLabel:C,"aria-label":Qo(I),"aria-keyshortcuts":P,"data-testid":`toolbar-${E}`,onPointerDown:({pointerType:k})=>{!t.state.penDetected&&k==="pen"&&t.togglePenMode(!0),E==="selection"&&(t.state.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:k})=>{t.state.activeTool.type!==E&&le("toolbar",E,"ui"),E==="image"?t.setActiveTool({type:E}):t.setActiveTool({type:E})}},E)}),Z("div",{className:"App-toolbar__divider"}),se(ge,{open:r,children:[Z(ge.Trigger,{className:Po("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":b.highlight}),onToggle:()=>{i(!r),o({openMenu:null,openPopup:null})},title:g("toolBar.extraTools"),children:b.icon}),se(ge.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Z(ge.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:mn,"data-testid":"toolbar-lasso",selected:d,children:g("toolBar.lasso")}),f.map(({value:E,icon:w,key:y,fillable:x})=>{let v=g(`toolBar.${E}`),I=y&&Qo(typeof y=="string"?y:y[0]);return Z(ge.Item,{onSelect:()=>t.setActiveTool({type:E}),icon:w,"data-testid":`toolbar-${E}`,selected:e.type===E,shortcut:I??void 0,children:Qo(v)},E)}),Z("div",{className:"App-toolbar__dropdown-divider"}),Z(ge.Item,{onSelect:()=>t.toggleLock(),icon:t.state.activeTool.locked?dn:Wo,"data-testid":"toolbar-lock",selected:t.state.activeTool.locked,shortcut:b8.Q,children:Qo(g("toolBar.lock-short"))})]})]})]})},B2=({renderAction:e,zoom:o})=>Z(Tt.Col,{gap:1,className:T2.ZOOM_ACTIONS,children:se(Tt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),F2=({renderAction:e,className:o})=>se("div",{className:`undo-redo-buttons ${o}`,children:[Z("div",{className:"undo-button-container",children:Z(ct,{label:g("buttons.undo"),children:e("undo")})}),Z("div",{className:"redo-button-container",children:se(ct,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),O2=({actionManager:e,showExitZenModeBtn:o})=>Z("button",{type:"button",className:Po("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(vi),children:g("buttons.exitZenMode")});import{useRef as w8}from"react";var mh=e=>{let o=w8({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};var ph={};qf(ph,{toggleTheme:()=>v8});var v8={...nr,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(nr,"commandPalette")}};import{jsx as Qe,jsxs as Ao}from"react/jsx-runtime";var M8=Se(null),He={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links",library:"Library"},H2=e=>{switch(e){case He.app:return 1;case He.export:return 2;case He.editor:return 3;case He.tools:return 4;case He.elements:return 5;case He.links:return 6;default:return 10}},ld=({shortcut:e,className:o,children:t})=>{let n=e.replace("++","+$").split("+");return Ao("div",{className:U2("shortcut",o),children:[n.map((r,i)=>Qe("div",{className:"shortcut-wrapper",children:Qe("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),Qe("div",{className:"shortcut-desc",children:t})]})},Y2=e=>!e.altKey&&e[ho.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===ho.P||e.key===ho.SLASH),Mde=Object.assign(e=>{let o=Te(),t=he();return ad(()=>{let n=r=>{Y2(r)&&(r.preventDefault(),r.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&le("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(sd.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(sd.KEYDOWN,n,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:Qe(P8,{...e})},{defaultItems:ph});function P8({customCommandPaletteItems:e}){let o=qe(),t=Te(),n=he(),r=Io(),i=at(),[a,l]=ue(M8),[s,c]=id(null),m=W2(null),p=gn({uiAppState:t,customCommandPaletteItems:e,appProps:r}),[d]=ue(jo),h=T8(()=>d.libraryItems?.filter(k=>!!k.name).map(k=>({label:k.name,icon:Qe(L8,{id:k.id,elements:k.elements}),category:"Library",order:H2("Library"),haystack:dr(k.name),perform:()=>{o.onInsertElements(Ri([k]))}}))||[],[o,d.libraryItems]);ad(()=>{let{uiAppState:k,customCommandPaletteItems:N,appProps:_}=p,L=H=>{let Y="";return H.label&&(typeof H.label=="function"?Y=g(H.label(o.scene.getNonDeletedElements(),k,o)):Y=g(H.label)),Y},B=H=>typeof H.icon=="function"?H.icon(k,o.scene.getNonDeletedElements()):H.icon,G=[],j=(H,Y,D)=>{let O={label:L(H),icon:B(H),category:Y,shortcut:Ae(H.name),keywords:H.keywords,predicate:H.predicate,viewMode:H.viewMode,perform:()=>{i.executeAction(H,"commandPalette")}};return D?D(O,H):O};if(k&&o.scene&&i){let H=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.arrangeElements,i.actions.normaliseElements,i.actions.duplicateSelection,i.actions.smartZoom,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,qa,Fc,hy].map(K=>j(K,He.elements,(ae,be)=>({...ae,predicate:be.predicate?be.predicate:(ce,Oe,io,yt)=>q(ce,Oe).length>0}))),Y=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(K=>j(K,He.tools)),D=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.smartZoom,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(K=>j(K,He.editor)),O=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(K=>j(K,He.export));G=[...H,...D,{label:g("buttons.exportImage"),category:He.export,icon:Is,shortcut:Ae("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...O];let Q=[{label:g("toolBar.library"),category:He.app,icon:hs,viewMode:!1,perform:()=>{k.openSidebar?n({openSidebar:null}):n({openSidebar:{name:z2.name,tab:z2.defaultTab}})}},{label:g("search.title"),category:He.app,icon:_t,viewMode:!0,perform:()=>{i.executeAction(dl)}},{label:g("labels.shapeSwitch"),category:He.elements,icon:va,perform:()=>{i.executeAction(uy)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:He.elements,icon:vs,viewMode:!1,predicate:(K,ae)=>{let be=q(K,ae);return be.length>0&&sl(ae,be)},perform:()=>{n(K=>({openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:vs,category:He.elements,viewMode:!1,predicate:(K,ae)=>{let be=q(K,ae);return be.length>0&&cl(ae,be)},perform:()=>{n(K=>({openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:vs,category:He.editor,viewMode:!1,perform:()=>{n(K=>({openMenu:K.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...k8.reduce((K,ae)=>{let{value:be,icon:ce,key:Oe}=ae;if(_.UIOptions.tools?.[be]===!1)return K;let yt=Oe&&S8(typeof Oe=="string"?Oe:Oe[0]),Go={label:g(`toolBar.${be}`),category:He.tools,shortcut:yt,icon:ce,keywords:["toolbar"],viewMode:!1,perform:({event:_r})=>{be==="image"?o.setActiveTool({type:be}):o.setActiveTool({type:be})}};return K.push(Go),K},[]),...Y,{label:g("toolBar.lock"),category:He.tools,icon:k.activeTool.locked?dn:Wo,shortcut:ho.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}}],ee=[...G,...Q,...N||[]].map(K=>({...K,icon:K.icon||va,order:K.order??H2(K.category),haystack:`${dr(K.label.toLocaleLowerCase())} ${K.keywords?.join(" ")||""}`}));c(ee),l([...ee,...h].find(K=>K.label===a?.label)??null)}},[p,o,i,c,a?.label,l,n,h]);let[f,b]=id(""),[E,w]=id(null),[y,x]=id({}),v=k=>{n({openDialog:null},k),b("")},I=(k,N)=>{t.openDialog?.name==="commandPalette"&&(N.stopPropagation(),N.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),v(()=>{k.perform({actionManager:i,event:N}),l(k),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},C=mh(k=>k.viewMode===!1&&t.viewModeEnabled?!1:typeof k.predicate=="function"?k.predicate(o.scene.getNonDeletedElements(),t,r,o):k.predicate===void 0||k.predicate),P=mh(k=>{let N=C8(k.target)||Y2(k)||k.key===ho.ESCAPE;if(N&&k.key!==ho.ARROW_UP&&k.key!==ho.ARROW_DOWN&&k.key!==ho.ENTER)return;let _=Object.values(y).flat(),L=a&&!f&&C(a);if(k.key===ho.ARROW_UP){k.preventDefault();let B=_.findIndex(H=>H.label===E?.label);if(L){if(B===0){w(a);return}if(E===a){let H=_[_.length-1];H&&w(H);return}}let G;B===-1?G=_.length-1:G=B===0?_.length-1:(B-1)%_.length;let j=_[G];j&&w(j);return}if(k.key===ho.ARROW_DOWN){k.preventDefault();let B=_.findIndex(H=>H.label===E?.label);if(L){if(!E||B===_.length-1){w(a);return}if(E===a){let H=_[0];H&&w(H);return}}let G=(B+1)%_.length,j=_[G];j&&w(j);return}if(k.key===ho.ENTER&&E&&setTimeout(()=>{I(E,k)}),!N){if(k.stopPropagation(),/^[a-zA-Z0-9]$/.test(k.key)){m?.current?.focus();return}k.preventDefault()}});return ad(()=>(window.addEventListener(sd.KEYDOWN,P,{capture:!0}),()=>window.removeEventListener(sd.KEYDOWN,P,{capture:!0})),[P]),ad(()=>{if(!s)return;let k=B=>{let G={};for(let j of B)G[j.category]?G[j.category].push(j):G[j.category]=[j];return G},N=f?.length>1?[...s.filter(C).sort((B,G)=>B.order-G.order),...h]:s.filter(C).sort((B,G)=>B.order-G.order),_=!f&&a&&C(a);if(!f){x(k(_?N.filter(B=>B.label!==a?.label):N)),w(_?a:N[0]||null);return}let L=dr(f.toLocaleLowerCase().replace(/[<>_| -]/g,""));N=I8.filter(L,N,{extract:B=>B.haystack??""}).sort((B,G)=>G.score-B.score).map(B=>B.original),x(k(N)),w(N[0]??null)},[f,s,C,a,h]),Ao(We,{onCloseRequest:()=>v(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Qe(Pn,{value:f,placeholder:g("commandPalette.search.placeholder"),onChange:k=>{b(k)},selectOnRender:!0,ref:m}),o.editorInterface.formFactor!=="phone"&&Ao("div",{className:"shortcuts-wrapper",children:[Qe(ld,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),Qe(ld,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),Qe(ld,{shortcut:A("Esc"),children:g("commandPalette.shortcuts.close")})]}),Ao("div",{className:"commands",children:[a&&!f&&Ao("div",{className:"command-category",children:[Ao("div",{className:"command-category-title",children:[g("commandPalette.recents"),Qe("div",{className:"icon",style:{marginLeft:"6px"},children:K0})]}),Qe(G2,{command:a,isSelected:a.label===E?.label,onClick:k=>I(a,k),disabled:!C(a),onMouseMove:()=>w(a),showShortcut:o.editorInterface.formFactor!=="phone",appState:t})]}),Object.keys(y).length>0?Object.keys(y).map((k,N)=>Ao("div",{className:"command-category",children:[Qe("div",{className:"command-category-title",children:k}),y[k].map(_=>Qe(G2,{command:_,isSelected:_.label===E?.label,onClick:L=>I(_,L),onMouseMove:()=>w(_),showShortcut:o.editorInterface.formFactor!=="phone",appState:t,size:k==="Library"?"large":"small"},_.label))]},k)):s?Ao("div",{className:"no-match",children:[Qe("div",{className:"icon",children:_t})," ",g("commandPalette.search.noMatch")]}):null]})]})}var L8=({id:e,elements:o})=>{let t=W2(null),{svgCache:n}=_i();return Oc(e,o,n,t),Qe("div",{className:"library-item-icon",ref:t})},G2=({command:e,isSelected:o,disabled:t,onMouseMove:n,onClick:r,showShortcut:i,appState:a,size:l="small"})=>{let s=()=>{};return Ao("div",{className:U2("command-item",{"item-selected":o,"item-disabled":t,"command-item-large":l==="large"}),ref:c=>{o&&!t&&c?.scrollIntoView?.({block:"nearest"})},onClick:t?s:r,onMouseMove:t?s:n,title:t?g("commandPalette.itemNotAvailable"):"",children:[Ao("div",{className:"name",children:[e.icon&&Qe(si,{className:"icon",size:"var(--icon-size, 1rem)",icon:typeof e.icon=="function"?e.icon(a,[]):e.icon}),Qe(Da,{children:e.label})]}),i&&e.shortcut&&Qe(ld,{shortcut:e.shortcut})]})};import{getSizeFromPoints as G0e,randomInteger as M_,getUpdatedTimestamp as P_}from"@excalidraw/common";import{simplify as u_}from"points-on-curve";import{getStroke as h_}from"perfect-freehand";import{pointsOnBezierCurves as Dde}from"points-on-curve";import{invariant as Nde}from"@excalidraw/common";import{curve as Fde,lineSegment as Ode,pointFrom as zde,pointDistance as Hde,pointFromArray as Gde,pointFromVector as Ude,pointRotateRads as Wde,polygon as Yde,polygonFromPoints as Vde,PRECISION as Xde,segmentsIntersectAt as Kde,vector as Zde,vectorAdd as $de,vectorFromPoint as jde,vectorScale as qde}from"@excalidraw/math";import{getElementAbsoluteCoords as Qde}from"@excalidraw/element";var uh=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as g_,pointDistance as sw,pointRotateRads as C0e}from"@excalidraw/math";import{ROUGHNESS as f_,THEME as Lh,isTransparent as hl,assertNever as b_,COLOR_PALETTE as E_,LINE_POLYGON_POINT_MERGE_DISTANCE as M0e,applyDarkModeFilter as xd}from"@excalidraw/common";import{RoughGenerator as x_}from"roughjs/bin/generator";import F1e from"roughjs/bin/rough";import{isRightAngleRads as z1e,lineSegment as H1e,pointFrom as G1e,pointRotateRads as U1e}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Y1e,DEFAULT_REDUCED_GLOBAL_ALPHA as V1e,ELEMENT_READY_TO_ERASE_OPACITY as X1e,FRAME_STYLE as K1e,DARK_THEME_FILTER as Z1e,MIME_TYPES as aw,THEME as $1e,distance as j1e,getFontString as q1e,isRTL as J1e,getVerticalOffset as Q1e,invariant as e0e,applyDarkModeFilter as t0e}from"@excalidraw/common";import $ge from"roughjs/bin/rough";import{arrayToMap as qge,invariant as Q2,rescalePoints as Jge,sizeOf as Qge}from"@excalidraw/common";import{degreesToRadians as Th,lineSegment as tfe,pointDistance as ofe,pointFrom as lt,pointFromArray as $8,pointRotateRads as Wi}from"@excalidraw/math";import{pointsOnBezierCurves as ife}from"points-on-curve";import{pointCenter as dge,pointFrom as mge,pointRotateRads as pge,pointsEqual as uge,pointDistance as hge,vectorFromPoint as gge,curveLength as fge,curvePointAtLength as bge,lineSegment as Ege}from"@excalidraw/math";import{DRAGGING_THRESHOLD as wge,KEYS as vge,shouldRotateWithDiscreteAngle as Ige,getGridPoint as Tge,invariant as Sge,isShallowEqual as Cge,getFeatureFlag as kge}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as Pge,isPathALoop as Lge,moveArrowAboveBindable as Age,projectFixedPointOntoDiagonal as _ge}from"@excalidraw/element";import{KEYS as phe,arrayToMap as uhe,getFeatureFlag as hhe,invariant as ghe,isTransparent as fhe}from"@excalidraw/common";import{PRECISION as Ehe,clamp as xhe,lineSegment as yhe,pointDistance as whe,pointDistanceSq as vhe,pointFrom as Ihe,pointFromVector as The,pointRotateRads as She,pointsEqual as Che,vectorFromPoint as khe,vectorNormalize as Mhe,vectorScale as Phe}from"@excalidraw/math";import{invariant as Fpe,isTransparent as Ope}from"@excalidraw/common";import{curveIntersectLineSegment as Hpe,isPointWithinBounds as Gpe,lineSegment as Upe,lineSegmentIntersectionPoints as Wpe,pointFrom as Ype,pointFromVector as Vpe,pointRotateRads as Xpe,pointsEqual as Kpe,vectorFromPoint as Zpe,vectorNormalize as $pe,vectorScale as jpe}from"@excalidraw/math";import{ellipse as Jpe,ellipseSegmentInterceptPoints as Qpe}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as D8,DEFAULT_PROPORTIONAL_RADIUS as gh,invariant as dme,LINE_CONFIRM_THRESHOLD as R8,ROUNDNESS as fh}from"@excalidraw/common";import{curve as pme,curveCatmullRomCubicApproxPoints as ume,curveOffsetPoints as hme,lineSegment as gme,lineSegmentIntersectionPoints as fme,pointDistance as N8,pointFrom as bme,pointFromArray as Eme,pointFromVector as xme,pointRotateRads as yme,pointTranslate as wme,rectangle as vme,vectorFromPoint as Ime,vectorNormalize as Tme,vectorScale as Sme}from"@excalidraw/math";import{ROUNDNESS as nme,assertNever as rme}from"@excalidraw/common";import{pointsEqual as ame}from"@excalidraw/math";var V2=e=>!!e&&e.type==="embeddable",X2=e=>!!e&&e.type==="iframe",hh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),pr=e=>e!=null&&e.type==="text";var cd=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var ur=e=>e!=null&&A8(e.type);var hr=e=>e!=null&&e.type==="arrow",ml=e=>hr(e)&&e.elbowed;var A8=e=>e==="arrow"||e==="line";var zi=e=>e!==null&&"containerId"in e&&e.containerId!==null&&pr(e);var dd=(e,o=1)=>{if(e.length>=3){let[t,n]=[e[0],e[e.length-1]];return N8(t,n)<=R8/o}return!1},pl=(e,o)=>{if(o.roundness?.type===fh.PROPORTIONAL_RADIUS||o.roundness?.type===fh.LEGACY)return e*gh;if(o.roundness?.type===fh.ADAPTIVE_RADIUS){let t=o.roundness?.value??D8,n=t/gh;return e<=n?e*gh:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as ape,ARROW_LABEL_WIDTH_FRACTION as lpe,BOUND_TEXT_PADDING as spe,DEFAULT_FONT_SIZE as cpe,TEXT_ALIGN as dpe,VERTICAL_ALIGN as mpe,getFontString as ppe,isProdEnv as upe,invariant as hpe}from"@excalidraw/common";import{pointFrom as fpe,pointRotateRads as bpe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as Fme,DEFAULT_FONT_SIZE as Ome,DEFAULT_FONT_FAMILY as zme,getFontString as Hme,isTestEnv as Gme,normalizeEOL as Ume}from"@excalidraw/common";var Wme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as jme,isTestEnv as qme}from"@excalidraw/common";import{curvePointDistance as Cpe,distanceToLineSegment as kpe,pointRotateRads as Mpe}from"@excalidraw/math";import{ellipse as Lpe,ellipseDistanceFromPoint as Ape}from"@excalidraw/math/ellipse";import{invariant as mue,isDevEnv as pue,isTestEnv as uue}from"@excalidraw/common";import{pointFrom as gue,pointFromVector as fue,pointRotateRads as bue,pointScaleFromOrigin as Eue,pointsEqual as xue,triangleIncludesPoint as yue,vectorCross as wue,vectorFromPoint as U8,vectorScale as vue}from"@excalidraw/math";var vh=[1,0],$2=[0,1],Ih=[-1,0],j2=[0,-1],hd=e=>{let[o,t]=e,n=Math.abs(o),r=Math.abs(t);return o>r?vh:o<=-r?Ih:t>n?$2:j2},q2=(e,o)=>hd(U8(e,o)),gd=(e,o)=>fd(q2(e,o)),wh=(e,o)=>e[0]===o[0]&&e[1]===o[1],fd=e=>wh(e,vh)||wh(e,Ih);import{clamp as Mue,pointDistance as Pue,pointFrom as Lue,pointScaleFromOrigin as Aue,pointsEqual as _ue,pointTranslate as Due,vector as Rue,vectorCross as Nue,vectorFromPoint as Bue,vectorScale as Fue}from"@excalidraw/math";import{BinaryHeap as zue,invariant as Hue,isAnyTrue as Gue,getSizeFromPoints as Uue,isDevEnv as Wue,arrayToMap as Yue}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Vhe,viewportCoordsToSceneCoords as Xhe}from"@excalidraw/common";import{normalizeRadians as Zhe,radiansBetweenAngles as $he,radiansDifference as jhe}from"@excalidraw/math";import{pointsEqual as Jhe}from"@excalidraw/math";var md=e=>{let o=Math.floor(e.width/2)+1,t=0,n=e.width,r=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,n,r,i,a,0,r]};var j8=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"crowfoot_many":case"crowfoot_one":case"crowfoot_one_or_many":return 20;default:return 15}},q8=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Sh=(e,o,t,n)=>{if(o.length<1)return null;let r=uh(o[0]);if(r.length<1)return null;let i=t==="start"?1:r.length-1,a=r[i].data;Q2(a.length===6,"Op data length is not 6");let l=lt(a[4],a[5]),s=lt(a[2],a[3]),c=lt(a[0],a[1]),m=r[i-1],p=lt(0,0);if(m.op==="move"){let H=$8(m.data);Q2(H!=null,"Op data is not a point"),p=H}else m.op==="bcurveTo"&&(p=lt(m.data[4],m.data[5]));let d=(H,Y)=>Math.pow(1-H,3)*l[Y]+3*H*Math.pow(1-H,2)*s[Y]+3*Math.pow(H,2)*(1-H)*c[Y]+p[Y]*Math.pow(H,3),[h,f]=t==="start"?p:l,[b,E]=[d(.3,0),d(.3,1)],w=Math.hypot(h-b,f-E),y=(h-b)/w,x=(f-E)/w,v=j8(n),I=0;{let[H,Y]=t==="end"?e.points[e.points.length-1]:e.points[0],[D,O]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];I=Math.hypot(H-D,Y-O)}let P=Math.min(v,I*(n==="diamond"||n==="diamond_outline"?.25:.5)),k=h-y*P,N=f-x*P;if(n==="dot"||n==="circle"||n==="circle_outline"){let H=Math.hypot(N-f,k-h)+e.strokeWidth-2;return[h,f,H]}let _=q8(n);if(n==="crowfoot_many"||n==="crowfoot_one_or_many"){let[H,Y]=Wi(lt(h,f),lt(k,N),Th(-_)),[D,O]=Wi(lt(h,f),lt(k,N),Th(_));return[k,N,H,Y,D,O]}let[L,B]=Wi(lt(k,N),lt(h,f),-_*Math.PI/180),[G,j]=Wi(lt(k,N),lt(h,f),Th(_));if(n==="diamond"||n==="diamond_outline"){let H,Y;if(t==="start"){let[D,O]=e.points.length>1?e.points[1]:[0,0];[H,Y]=Wi(lt(h+P*2,f),lt(h,f),Math.atan2(O-f,D-h))}else{let[D,O]=e.points.length>1?e.points[e.points.length-2]:[0,0];[H,Y]=Wi(lt(h-P*2,f),lt(h,f),Math.atan2(f-O,h-D))}return[h,f,L,B,H,Y,G,j]}return[h,f,L,B,G,j]};import{pointFrom as xfe,pointCenter as yfe,pointRotateRads as wfe,vectorFromPoint as vfe,vectorNormalize as Ife,vectorSubtract as Tfe,vectorAdd as Sfe,vectorScale as Cfe,pointFromVector as kfe,clamp as Mfe,isCloseTo as Pfe}from"@excalidraw/math";import{arrayToMap as g1e}from"@excalidraw/common";import{isPointWithinBounds as b1e,pointFrom as E1e}from"@excalidraw/math";import{vectorCross as Rfe,vectorFromPoint as Nfe}from"@excalidraw/math";import{arrayToMap as J8}from"@excalidraw/common";import{getElementBounds as Q8}from"@excalidraw/element";import{isArrowElement as e_,isExcalidrawElement as t_,isFreeDrawElement as o_,isLinearElement as n_,isTextElement as r_}from"@excalidraw/element";import{rangeIncludesValue as bd,pointFrom as tn,pointRotateRads as i_,rangeInclusive as Ed}from"@excalidraw/math";var a_=e=>e.type==="diamond"?[tn(e.width/2,0),tn(e.width,e.height/2),tn(e.width/2,e.height),tn(0,e.height/2)]:[tn(0,0),tn(0+e.width,0),tn(0+e.width,e.height),tn(0,e.height)],l_=e=>n_(e)||o_(e)?e.points:a_(e),tw=e=>{let o=e.reduce((t,[n,r])=>(t.minY=Math.min(t.minY,r),t.minX=Math.min(t.minX,n),t.maxX=Math.max(t.maxX,n),t.maxY=Math.max(t.maxY,r),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},ow=e=>{let o=l_(e),{cx:t,cy:n}=tw(o),r=tn(t,n),i=o.map(m=>i_(m,r,e.angle)),{minX:a,minY:l,maxX:s,maxY:c}=tw(i);return[a+e.x,l+e.y,s+e.x,c+e.y]},Ch=(e,o,t=!1)=>{let n=ow(e),r=o[0]<=n[0]&&o[2]>=n[2]&&o[1]<=n[1]&&o[3]>=n[3];return t?r?!0:n[0]<=o[0]&&n[2]>=o[2]&&n[1]<=o[1]&&n[3]>=o[3]:r},nw=(e,o)=>{let t=ow(e);return(bd(t[0],Ed(o[0],o[2]))||bd(o[0],Ed(t[0],t[2])))&&(bd(t[1],Ed(o[1],o[3]))||bd(o[1],Ed(t[1],t[3])))},rw=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{t_(o)&&(o=Q8(o,J8(e)));let r=[o[0]-n,o[1]-n,o[2]+n,o[3]+n],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?nw(a,r):t==="inside"?Ch(a,r):Ch(a,r,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);r_(a)&&a.containerId&&i.add(a.containerId),e_(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{arrayToMap as qfe,isShallowEqual as c_}from"@excalidraw/common";var s_=function(){let e=null,o=null,t=null,n=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let c={};for(let d of i){let h=d.groupIds;if(l.editingGroupId){let f=h.indexOf(l.editingGroupId);f>-1&&(h=h.slice(0,f))}if(h.length>0){let f=h[h.length-1];c[f]=!0}}let m={},p=a.reduce((d,h)=>{if(h.isDeleted)return d;let f=h.groupIds.find(b=>c[b]);return f&&(d[h.id]=!0,Array.isArray(m[f])?m[f].push(h.id):m[f]=[h.id]),d},{});for(let d of Object.keys(m))m[d].length<2&&c[d]&&(c[d]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:c,selectedElementIds:kh({...l.selectedElementIds,...p},s)},t},r=(i,a,l,s)=>{let c=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Mh(a,i);return c.length?n(c,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:kh(i.selectedElementIds,l)}};return r.clearCache=()=>{o=null,e=null,t=null},r}();var r1e=function(){let e=null,o=null,t=null,n=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===o||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,o=i.selectedElementIds),t);return n.clearCache=()=>{e=null,o=null,t=null},n}(),Mh=(e,o,t)=>{let n=new Set,r=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){r.push(i),n.add(i.id);continue}if(t?.includeBoundTextElement&&zi(i)&&o.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{cd(a)&&iw(e,a.id).forEach(l=>!n.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var kh=(e,o)=>c_(o.selectedElementIds,e)?o.selectedElementIds:e;var iw=(e,o)=>{let t=[];for(let n of e.values())n.frameId===o&&t.push(n);return t};var m_=typeof document<"u"?document.createElement("img"):{src:""};m_.src=`data:${aw.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 p_=typeof document<"u"?document.createElement("img"):{src:""};p_.src=`data:${aw.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 Ph=new WeakMap;var lw=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var Ct=class Ct{};S(Ct,"rg",new x_),S(Ct,"cache",new WeakMap),S(Ct,"get",(o,t)=>{let n=Ct.cache.get(o);if(n&&(t===null||n.theme===t))return n.shape}),S(Ct,"delete",o=>{Ct.cache.delete(o),Ph.delete(o)}),S(Ct,"destroy",()=>{Ct.cache=new WeakMap}),S(Ct,"generateElementShape",(o,t)=>{let n=t?.isExporting?void 0:Ct.get(o,t?t.theme:null);if(n!==void 0)return n;Ph.delete(o);let r=v_(o,Ct.rg,t||{isExporting:!1,canvasBackgroundColor:E_.white,embedsValidationStatus:null,theme:Lh.LIGHT});return t?.isExporting||Ct.cache.set(o,{shape:r,theme:t?.theme||Lh.LIGHT}),r});var Ui=Ct,y_=e=>[8,8+e],pw=e=>[1.5,6+e];function w_(e){let o=e.roughness,t=Math.max(e.width,e.height),n=Math.min(e.width,e.height);return n>=20&&t>=50||n>=15&&e.roundness&&lw(e.type)||ur(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var en=(e,o=!1,t=!1)=>{let n={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?y_(e.strokeWidth):e.strokeStyle==="dotted"?pw(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:w_(e),stroke:t?xd(e.strokeColor):e.strokeColor,preserveVertices:o||e.roughness<f_.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return n.fillStyle=e.fillStyle,n.fill=hl(e.backgroundColor)?void 0:t?xd(e.backgroundColor):e.backgroundColor,e.type==="ellipse"&&(n.curveFitting=1),n;case"line":case"freedraw":return dd(e.points)&&(n.fillStyle=e.fillStyle,n.fill=e.backgroundColor==="transparent"?void 0:t?xd(e.backgroundColor):e.backgroundColor),n;case"arrow":return n;default:throw new Error(`Unimplemented type ${e.type}`)}},cw=(e,o,t)=>hh(e)&&(o||V2(e)&&t?.get(e.id)!==!0)&&hl(e.backgroundColor)&&hl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:X2(e)?{...e,strokeColor:hl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:hl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,dw=(e,o,t,n,r,i,a,l)=>{let s=Sh(e,o,t,n);if(s===null)return[];let c=(p,d)=>{if(p===null)return[];let[,,h,f,b,E]=p;return[r.line(h,f,b,E,d)]},m=l?xd(e.strokeColor):e.strokeColor;switch(n){case"dot":case"circle":case"circle_outline":{let[p,d,h]=s;return delete i.strokeLineDash,[r.circle(p,d,h,{...i,fill:n==="circle_outline"?a:m,fillStyle:"solid",stroke:m,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[p,d,h,f,b,E]=s;return delete i.strokeLineDash,[r.polygon([[p,d],[h,f],[b,E],[p,d]],{...i,fill:n==="triangle_outline"?a:m,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[p,d,h,f,b,E,w,y]=s;return delete i.strokeLineDash,[r.polygon([[p,d],[h,f],[b,E],[w,y],[p,d]],{...i,fill:n==="diamond_outline"?a:m,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"crowfoot_one":return c(s,i);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[p,d,h,f,b,E]=s;if(e.strokeStyle==="dotted"){let w=pw(e.strokeWidth-1);i.strokeLineDash=[w[0],w[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[r.line(h,f,p,d,i),r.line(b,E,p,d,i),...n==="crowfoot_one_or_many"?c(Sh(e,o,t,"crowfoot_one"),i):[]]}}};var v_=(e,o,{isExporting:t,canvasBackgroundColor:n,embedsValidationStatus:r,theme:i})=>{let a=i===Lh.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let l;if(e.roundness){let s=e.width,c=e.height,m=pl(Math.min(s,c),e);l=o.path(`M ${m} 0 L ${s-m} 0 Q ${s} 0, ${s} ${m} L ${s} ${c-m} Q ${s} ${c}, ${s-m} ${c} L ${m} ${c} Q 0 ${c}, 0 ${c-m} L 0 ${m} Q 0 0, ${m} 0`,en(cw(e,t,r),!0,a))}else l=o.rectangle(0,0,e.width,e.height,en(cw(e,t,r),!1,a));return l}case"diamond":{let l,[s,c,m,p,d,h,f,b]=md(e);if(e.roundness){let E=pl(Math.abs(s-f),e),w=pl(Math.abs(p-c),e);l=o.path(`M ${s+E} ${c+w} L ${m-E} ${p-w}
|
|
9
9
|
C ${m} ${p}, ${m} ${p}, ${m-E} ${p+w}
|
|
10
10
|
L ${d+E} ${h-w}
|
|
11
11
|
C ${d} ${h}, ${d} ${h}, ${d-E} ${h-w}
|
|
12
12
|
L ${f+E} ${b+w}
|
|
13
13
|
C ${f} ${b}, ${f} ${b}, ${f+E} ${b-w}
|
|
14
14
|
L ${s-E} ${c+w}
|
|
15
|
-
C ${s} ${c}, ${s} ${c}, ${s+E} ${c+w}`,rn(e,!0,a))}else l=o.polygon([[s,c],[m,p],[d,h],[f,b]],rn(e,!1,a));return l}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,rn(e,!1,a));case"line":case"arrow":{let l,s=rn(e,!1,a),c=e.points.length?e.points:[f_(0,0)];if(xl(e)?c.every(m=>Math.abs(m[0])<=1e6&&Math.abs(m[1])<=1e6)?l=[o.path(T_(c,16),rn(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),l=[]):e.roundness?l=[o.curve(c,s)]:s.fill?l=[o.polygon(c,s)]:l=[o.linearPath(c,s)],e.type==="arrow"){let{startArrowhead:m=null,endArrowhead:p="arrow"}=e;if(m!==null){let d=hw(e,l,"start",m,o,s,n,a);l.push(...d)}if(p!==null){let d=hw(e,l,"end",p,o,s,n,a);l.push(...d)}}return l}case"freedraw":{let l=[];if(hd(e.points)){let s=h_(e.points,.75);l.push(o.curve(s,{...rn(e,!1,a),stroke:"none"}))}return l.push(S_(e)),l}case"frame":case"magicframe":case"text":case"image":return null;default:return E_(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},T_=(e,o)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],l=e[r],s=xd(l,i),c=xd(a,l),m=Math.min(o,pw(e[r],a)/2,pw(e[r],i)/2);s?i[0]<l[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):i[1]<l[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m]),t.push(e[r]),c?a[0]<l[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):a[1]<l[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m])}let n=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)n.push(`L ${t[r][0]} ${t[r][1]}`),n.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return n.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),n.join(" ")};var S_=e=>M_(C_(e)),C_=e=>{let o=e.simulatePressure?e.points:e.points.length?e.points.map(([t,n],r)=>[t,n,e.pressures[r]]):[[0,0,.5]];return g_(o,{simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:t=>Math.sin(t*Math.PI/2),last:!0})},gw=(e,o)=>[(e[0]+o[0])/2,(e[1]+o[1])/2],k_=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,M_=e=>{if(!e.length)return"";let o=e.length-1;return e.reduce((t,n,r,i)=>(r===o?t.push(n,gw(n,i[0]),"L",i[0],"Z"):t.push(n,gw(n,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(k_,"$1")};var bw=(e,o,t=!1)=>{let n=!1;for(let r in o){let i=o[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return!n&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??P_(),updated:L_()}};import{jsx as xw}from"react/jsx-runtime";var Qi=F({name:"toggleLinearEditor",category:He.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&r.length===1&&__(r[0])&&!A_(r[0]))},perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];Bh(r,"No selected element found"),Bh(o.selectedLinearElement,"No selected linear element found"),Bh(r.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:Ew.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!n)return null;let r=g(n.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return xw(V,{type:"button",icon:cb,title:r,"aria-label":r,onClick:()=>o(null)})}}),ibe=F({name:"togglePolygon",category:He.elements,icon:Rm,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!Ji(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return r.length>0&&r.every(i=>Ji(i)&&i.points.length>=4)},perform(e,o,t,n){let r=n.scene.getSelectedElements(o);if(r.some(s=>!Ji(s)))return!1;let i=r,a=i.some(s=>!s.polygon),l=D_(i);return{elements:e.map(s=>!l.has(s.id)||!Ji(s)?s:bw(s,{backgroundColor:a?s.backgroundColor:"transparent",...R_(s,a)})),appState:o,captureUpdate:Ew.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(n.length===0||n.some(a=>!Ji(a)||!a.polygon||a.points.length<3))return null;let r=n.every(a=>Ji(a)&&a.polygon),i=g(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return xw(li,{icon:Rm,title:i,"aria-label":i,active:r,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as yw,CANVAS_SEARCH_TAB as ww,CLASSES as N_,DEFAULT_SIDEBAR as vw}from"@excalidraw/common";import{CaptureUpdateAction as B_}from"@excalidraw/element";var El=F({name:"searchMenu",icon:_t,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,n){if(o.openDialog)return!1;if(o.openSidebar?.name===vw.name&&o.openSidebar.tab===ww){let r=n.excalidrawContainerValue.container?.querySelector(`.${N_.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...o,openSidebar:{name:vw.name,tab:ww},openDialog:null},captureUpdate:B_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[yw.CTRL_OR_CMD]&&e.key===yw.F});import{isImageElement as F_}from"@excalidraw/element";import{CaptureUpdateAction as O_}from"@excalidraw/element";import{jsx as z_}from"react/jsx-runtime";var Fh=F({name:"cropEditor",label:"helpDialog.cropStart",icon:ep,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:r.id},captureUpdate:O_.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.croppingElementId&&r.length===1&&F_(r[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=g("helpDialog.cropStart");return z_(V,{type:"button",icon:ep,title:n,"aria-label":n,onClick:()=>o(null)})}});import{getNonDeletedElements as H_}from"@excalidraw/element";import{mutateElement as G_}from"@excalidraw/element";import{newFrameElement as U_}from"@excalidraw/element";import{isFrameLikeElement as Td}from"@excalidraw/element";import{addElementsToFrame as W_,removeAllElementsFromFrame as Y_}from"@excalidraw/element";import{getFrameChildren as V_}from"@excalidraw/element";import{updateActiveTool as Iw}from"@excalidraw/common";import{getElementsInGroup as X_}from"@excalidraw/element";import{getCommonBounds as K_}from"@excalidraw/element";import{CaptureUpdateAction as Er}from"@excalidraw/element";var Tw=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&Td(t[0])},Sw=F({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;if(Td(r)){let i=V_(H_(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:Er.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:Er.EVENTUALLY}},predicate:(e,o,t,n)=>Tw(o,n)}),Cw=F({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;return Td(r)?{elements:Y_(e,r),appState:{...o,selectedElementIds:{[r.id]:!0}},captureUpdate:Er.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:Er.EVENTUALLY}},predicate:(e,o,t,n)=>Tw(o,n)}),fEe=F({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:Er.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),bEe=F({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:fn,viewMode:!1,perform:(e,o,t,n)=>{let r=Iw(o,{type:"frame"});return Nt(n.interactiveCanvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:Iw(o,{type:"frame"})},captureUpdate:Er.EVENTUALLY}},keyTest:e=>!1}),kw=F({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=q(e,o);return r.length>0&&!r.some(i=>Td(i))},perform:(e,o,t,n)=>{let r=q(e,o),i=n.scene.getNonDeletedElementsMap(),[a,l,s,c]=K_(r,i),m=16,p=U_({x:a-m,y:l-m,width:s-a+m*2,height:c-l+m*2});if(o.editingGroupId){let h=X_(r,o.editingGroupId);for(let f of h){let b=f.groupIds.indexOf(o.editingGroupId);G_(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:W_([...n.scene.getElementsIncludingDeleted(),p],r,p,o),appState:{selectedElementIds:{[p.id]:!0}},captureUpdate:Er.IMMEDIATELY}}});import{isWindows as eD,KEYS as Tl,matchKey as Hh,arrayToMap as Mw,MOBILE_ACTION_BUTTON_BG as Pw}from"@excalidraw/common";import{CaptureUpdateAction as zh}from"@excalidraw/element";import{orderByFractionalIndex as tD}from"@excalidraw/element";import{Emitter as Z_}from"@excalidraw/common";import{CaptureUpdateAction as $_,StoreChange as j_,StoreDelta as q_}from"@excalidraw/element";var ea=class extends q_{applyTo(o,t,n){let[r,i]=this.elements.applyTo(o,n.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,r);return[r,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,n,r){return super.applyLatestChanges(o,t,n,r)}},xr=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},Il=class e{constructor(o){this.store=o;S(this,"onHistoryChangedEmitter",new Z_);S(this,"undoStack",[]);S(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof ea)return;let t=ea.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new xr(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n))}perform(o,t,n,r){try{let i=n();if(i===null)return;let a=$_.IMMEDIATELY,l=this.store.snapshot,s=o,c=t,m=!1;for(;i;){try{[s,c,m]=i.applyTo(s,c,l);let p=l.elements,d=l.maybeClone(a,s,c),h=j_.create(l,d),f=ea.applyLatestChanges(i,p,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:h,delta:f}),i=f),l=d}finally{r(i)}if(m)break;i=n()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new xr(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let n=ea.inverse(t);return o.push(n)}};import{useEffect as J_,useState as Q_}from"react";var Oh=(e,o)=>{let[t,n]=Q_(o);return J_(()=>{let r=e.on(i=>{n(i)});return()=>{r()}},[e]),t};import{jsx as Dw}from"react/jsx-runtime";var Lw=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let n=t();if(!n)return{captureUpdate:zh.EVENTUALLY};let[r,i]=n,a=tD(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:zh.NEVER}}return{captureUpdate:zh.EVENTUALLY}},Aw=e=>({name:"undo",label:"buttons.undo",icon:Fm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>Lw(r,t,()=>e.undo(Mw(o),t)),keyTest:o=>o[Tl.CTRL_OR_CMD]&&Hh(o,Tl.Z)&&!o.shiftKey,PanelComponent:({appState:o,updateData:t,data:n,app:r})=>{let{isUndoStackEmpty:i}=Oh(e.onHistoryChangedEmitter,new xr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=je()==="mobile";return Dw(V,{type:"button",icon:Fm,"aria-label":g("buttons.undo"),onClick:t,size:n?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?Pw:{}}})}}),_w=e=>({name:"redo",label:"buttons.redo",icon:Om,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>Lw(r,t,()=>e.redo(Mw(o),t)),keyTest:o=>o[Tl.CTRL_OR_CMD]&&o.shiftKey&&Hh(o,Tl.Z)||eD&&o.ctrlKey&&!o.shiftKey&&Hh(o,Tl.Y),PanelComponent:({appState:o,updateData:t,data:n,app:r})=>{let{isRedoStackEmpty:i}=Oh(e.onHistoryChangedEmitter,new xr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=je()==="mobile";return Dw(V,{type:"button",icon:Om,"aria-label":g("buttons.redo"),onClick:t,size:n?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?Pw:{}}})}});import{getFontString as oD}from"@excalidraw/common";import{newElementWith as nD}from"@excalidraw/element";import{measureText as rD}from"@excalidraw/element";import{isTextElement as Rw}from"@excalidraw/element";import{CaptureUpdateAction as iD}from"@excalidraw/element";var Nw=F({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=q(e,o);return r.length===1&&Rw(r[0])&&!r[0].autoResize},perform:(e,o,t,n)=>{let r=q(e,o);return{appState:o,elements:e.map(i=>{if(i.id===r[0].id&&Rw(i)){let a=rD(i.originalText,oD(i),i.lineHeight);return nD(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:iD.IMMEDIATELY}}});import{isPromiseLike as aD}from"@excalidraw/common";import{jsx as lD}from"react/jsx-runtime";var Gh=(e,o,t,n,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,n,i))&&le(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Sd=class{constructor(o,t,n,r){S(this,"actions",{});S(this,"updater");S(this,"getAppState");S(this,"getElementsIncludingDeleted");S(this,"app");S(this,"renderAction",(o,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in n)||n[o])){let r=this.actions[o],i=r.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{Gh(r,"ui",l,a,this.app,c),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return lD(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});S(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!o.predicate||o.predicate(t,n,this.app.props,this.app)});this.updater=i=>{if(aD(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn("Canceling as multiple actions match this shortcut",n),!1;let r=n[0];if(this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return Gh(r,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(n[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",n=null){let r=this.getElementsIncludingDeleted(),i=this.getAppState();Gh(o,t,i,r,this.app,n),this.updater(o.perform(r,i,n,this.app))}};var Cd=class{constructor(){S(this,"targets",new WeakMap);S(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let n=this.targets.get(o);if(!n)return;let r=this.onFrame(n,t);!n.stopped&&!r?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var Uh=e=>{let o=Array.from(e.values());return{x:Bw(o,t=>t.x)/o.length,y:Bw(o,t=>t.y)/o.length}},Wh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),Bw=(e,o)=>e.reduce((t,n)=>t+o(n),0);import{pointFrom as U,pointRotateRads as Dn,rangeInclusive as $t,rangeIntersection as kd,rangesOverlap as Md}from"@excalidraw/math";import{TOOL_TYPE as yr,KEYS as Fw}from"@excalidraw/common";import{getCommonBounds as Yh,getDraggedElementsBounds as Vh,getElementAbsoluteCoords as sD}from"@excalidraw/element";import{isBoundToContainer as Gw}from"@excalidraw/element";import{getMaximumGroups as Uw}from"@excalidraw/element";import{getSelectedElements as cD,getVisibleAndNonSelectedElements as Ww}from"@excalidraw/element";var dD=8,Ow=99999,Pd=e=>dD/e,ft=class ft{};S(ft,"referenceSnapPoints",null),S(ft,"visibleGaps",null),S(ft,"setReferenceSnapPoints",o=>{ft.referenceSnapPoints=o}),S(ft,"getReferenceSnapPoints",()=>ft.referenceSnapPoints),S(ft,"setVisibleGaps",o=>{ft.visibleGaps=o}),S(ft,"getVisibleGaps",()=>ft.visibleGaps),S(ft,"destroy",()=>{ft.referenceSnapPoints=null,ft.visibleGaps=null});var jt=ft,Rn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,ln=({event:e,app:o,selectedElements:t})=>{if(e){let n=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||n)&&(o.state.objectsSnapModeEnabled&&!e[Fw.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[Fw.CTRL_OR_CMD]&&!Rn(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},mD=(e,o,t=.01)=>Math.abs(e-o)<=t,Sl=(e,o,{omitCenter:t,boundingBoxCorners:n,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,m,p,d]=sD(a,o);r&&(l+=r.x,c+=r.x,p+=r.x,s+=r.y,m+=r.y,d+=r.y);let h=(c-l)/2,f=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!n){let b=Dn(U(l,s+f),U(p,d),a.angle),E=Dn(U(l+h,s),U(p,d),a.angle),w=Dn(U(c,s+f),U(p,d),a.angle),y=Dn(U(l+h,m),U(p,d),a.angle),x=U(p,d);i=t?[b,E,w,y]:[b,E,w,y,x]}else{let b=Dn(U(l,s),U(p,d),a.angle),E=Dn(U(c,s),U(p,d),a.angle),w=Dn(U(l,m),U(p,d),a.angle),y=Dn(U(c,m),U(p,d),a.angle),x=U(p,d);i=t?[b,E,w,y]:[b,E,w,y,x]}}else if(e.length>1){let[a,l,s,c]=Vh(e,r??{x:0,y:0}),m=s-a,p=c-l,d=U(a,l),h=U(s,l),f=U(a,c),b=U(s,c),E=U(a+m/2,l+p/2);i=t?[d,h,f,b]:[d,h,f,b,E]}return i.map(a=>U(De(a[0]),De(a[1])))},Yw=(e,o,t,n)=>Ww(e,o,t,n),Vw=(e,o,t,n)=>{let r=Yw(e,o,t,n),i=Uw(r,n).filter(p=>!(p.length===1&&Gw(p[0]))).map(p=>Yh(p).map(d=>De(d))),a=i.sort((p,d)=>p[0]-d[0]),l=[],s=0;e:for(let p=0;p<a.length;p++){let d=a[p];for(let h=p+1;h<a.length;h++){if(++s>Ow)break e;let f=a[h],[,b,E,w]=d,[y,x,,v]=f;E<y&&Md($t(b,w),$t(x,v))&&l.push({startBounds:d,endBounds:f,startSide:[U(E,b),U(E,w)],endSide:[U(y,x),U(y,v)],length:y-E,overlap:kd($t(b,w),$t(x,v))})}}let c=i.sort((p,d)=>p[1]-d[1]),m=[];s=0;e:for(let p=0;p<c.length;p++){let d=c[p];for(let h=p+1;h<c.length;h++){if(++s>Ow)break e;let f=c[h],[b,,E,w]=d,[y,x,v]=f;w<x&&Md($t(b,E),$t(y,v))&&m.push({startBounds:d,endBounds:f,startSide:[U(b,w),U(E,w)],endSide:[U(y,x),U(v,x)],length:x-w,overlap:kd($t(b,E),$t(y,v))})}}return{horizontalGaps:l,verticalGaps:m}},zw=(e,o,t,n,r,i,a)=>{if(!ln({app:t,event:n,selectedElements:e}))return[];if(e.length===0)return[];let l=jt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[m,p,d,h]=Vh(e,o).map(E=>De(E)),f=(m+d)/2,b=(p+h)/2;for(let E of s){if(!Md($t(p,h),E.overlap))continue;let w=E.startSide[0][0]+E.length/2,y=De(w-f);if(E.length>d-m&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(r.length=0),a.x=Math.abs(y);let _={type:"gap",direction:"center_horizontal",gap:E,offset:y};r.push(_);continue}let[,,v]=E.endBounds,I=m-v,C=De(E.length-I);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:E,offset:C};r.push(_);continue}let[P,,,]=E.startBounds,k=P-d,N=De(k-E.length);if(Math.abs(N)<=a.x){Math.abs(N)<a.x&&(r.length=0),a.x=Math.abs(N);let _={type:"gap",direction:"side_left",gap:E,offset:N};r.push(_);continue}}for(let E of c){if(!Md($t(m,d),E.overlap))continue;let w=E.startSide[0][1]+E.length/2,y=De(w-b);if(E.length>h-p&&Math.abs(y)<=a.y){Math.abs(y)<a.y&&(i.length=0),a.y=Math.abs(y);let _={type:"gap",direction:"center_vertical",gap:E,offset:y};i.push(_);continue}let[,v,,]=E.startBounds,I=v-h,C=De(I-E.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:E,offset:C};i.push(_);continue}let[,,,P]=E.endBounds,k=De(p-P),N=E.length-k;if(Math.abs(N)<=a.y){Math.abs(N)<a.y&&(i.length=0),a.y=Math.abs(N);let _={type:"gap",direction:"side_bottom",gap:E,offset:N};i.push(_);continue}}}},Xw=(e,o,t,n)=>{let r=Yw(e,o,t,n);return Uw(r,n).filter(i=>!(i.length===1&&Gw(i[0]))).flatMap(i=>Sl(i,n))},ta=(e,o,t,n,r,i,a)=>{if(!ln({app:t,event:n,selectedElements:e})||e.length===0&&o.length===0)return[];let l=jt.getReferenceSnapPoints();if(l)for(let s of o)for(let c of l){let m=c[0]-s[0],p=c[1]-s[1];Math.abs(m)<=a.x&&(Math.abs(m)<a.x&&(r.length=0),r.push({type:"point",points:[s,c],offset:m}),a.x=Math.abs(m)),Math.abs(p)<=a.y&&(Math.abs(p)<a.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:p}),a.y=Math.abs(p))}},Kw=(e,o,t,n,r)=>{let i=t.state,a=cD(e,i);if(!ln({app:t,event:n,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=De(o.x),o.y=De(o.y);let l=[],s=[],c=Pd(i.zoom.value),m={x:c,y:c},p=Sl(a,r,{dragOffset:o});ta(a,p,t,n,l,s,m),zw(a,o,t,n,l,s,m);let d={x:l[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,l.length=0,s.length=0;let h={x:De(o.x+d.x),y:De(o.y+d.y)};ta(a,Sl(a,r,{dragOffset:h}),t,n,l,s,m),zw(a,h,t,n,l,s,m);let f=Xh(l,s),b=uD(a,h,[...l,...s].filter(E=>E.type==="gap"));return{snapOffset:d,snapLines:[...f,...b]}},De=e=>Math.round(e*10**6)/10**6,Hw=e=>{let o=new Map;for(let t of e){let n=t.join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},Xh=(e,o)=>{let t={},n={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=De(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>U(De(a[0]),De(a[1]))))}}if(o.length>0){for(let r of o)if(r.type==="point"){let i=De(r.points[0][1]);n[i]||(n[i]=[]),n[i].push(...r.points.map(a=>U(De(a[0]),De(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:Hw(i.map(a=>U(Number(r),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(n).map(([r,i])=>({type:"points",points:Hw(i.map(a=>U(a[0],Number(r))).sort((a,l)=>a[0]-l[0]))})))},pD=e=>{let o=new Map;for(let t of e){let n=t.points.flat().map(r=>[De(r)]).join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},uD=(e,o,t)=>{let[n,r,i,a]=Vh(e,o),l=[];for(let s of t){let[c,m,p,d]=s.gap.startBounds,[h,f,b,E]=s.gap.endBounds,w=kd($t(r,a),s.gap.overlap),y=kd($t(n,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[U(s.gap.startSide[0][0],x),U(n,x)]},{type:"gap",direction:"horizontal",points:[U(i,x),U(s.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[U(x,s.gap.startSide[0][1]),U(x,r)]},{type:"gap",direction:"vertical",points:[U(x,a),U(x,s.gap.endSide[0][1])]})}break}case"side_right":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[U(p,x),U(h,x)]},{type:"gap",direction:"horizontal",points:[U(b,x),U(n,x)]})}break}case"side_left":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[U(i,x),U(c,x)]},{type:"gap",direction:"horizontal",points:[U(p,x),U(h,x)]})}break}case"side_top":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[U(x,a),U(x,m)]},{type:"gap",direction:"vertical",points:[U(x,d),U(x,f)]})}break}case"side_bottom":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[U(x,d),U(x,f)]},{type:"gap",direction:"vertical",points:[U(x,E),U(x,r)]})}break}}}return pD(l.map(s=>({...s,points:s.points.map(c=>U(De(c[0]),De(c[1])))})))},Kh=(e,o,t,n,r,i)=>{if(!ln({event:n,selectedElements:e,app:t})||e.length===0||e.length===1&&!mD(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=Yh(o);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?l+=r.y:i.includes("s")&&(c+=r.y));let m=[];if(i)switch(i){case"e":{m.push(U(s,l),U(s,c));break}case"w":{m.push(U(a,l),U(a,c));break}case"n":{m.push(U(a,l),U(s,l));break}case"s":{m.push(U(a,c),U(s,c));break}case"ne":{m.push(U(s,l));break}case"nw":{m.push(U(a,l));break}case"se":{m.push(U(s,c));break}case"sw":{m.push(U(a,c));break}}let p=Pd(t.state.zoom.value),d={x:p,y:p},h=[],f=[];ta(o,m,t,n,h,f,d);let b={x:h[0]?.offset??0,y:f[0]?.offset??0};d.x=0,d.y=0,h.length=0,f.length=0;let[E,w,y,x]=Yh(e).map(C=>De(C)),v=[U(E,w),U(E,x),U(y,w),U(y,x)];ta(e,v,t,n,h,f,d);let I=Xh(h,f);return{snapOffset:b,snapLines:I}},Zw=(e,o,t,n,r,i)=>{if(!ln({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[U(n.x+r.x,n.y+r.y)],l=Pd(o.state.zoom.value),s={x:l,y:l},c=[],m=[];ta([e],a,o,t,c,m,s);let p={x:c[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,c.length=0,m.length=0;let d=Sl([e],i,{boundingBoxCorners:!0,omitCenter:!0});ta([e],d,o,t,c,m,s);let h=Xh(c,m);return{snapOffset:p,snapLines:h}},$w=(e,o,t,n,r)=>{if(!ln({event:n,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Ww(e,[],o.state,r),a=Pd(o.state.zoom.value),l={x:a,y:a},s=[],c=[];for(let m of i){let p=Sl([m],r);for(let d of p){let h=d[0]-t.x;Math.abs(h)<=Math.abs(l.x)&&(Math.abs(h)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[d,U(d[0],t.y)],direction:"vertical"}),l.x=h);let f=d[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[d,U(t.x,d[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},jw=e=>e===yr.rectangle||e===yr.ellipse||e===yr.diamond||e===yr.frame||e===yr.magicframe||e===yr.image||e===yr.text;import{isElementInViewport as hD}from"@excalidraw/element";import{memoize as gD,toBrandedType as fD}from"@excalidraw/common";var Cl=class{constructor(o){S(this,"scene");S(this,"getRenderableElements",(()=>{let o=({elementsMap:n,zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:m})=>{let p=[];for(let d of n.values())hD(d,m,c,{zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},n)&&p.push(d);return p},t=({elements:n,editingTextElement:r,newElementId:i})=>{let a=fD(new Map);for(let l of n)i!==l.id&&(!r||r.type!=="text"||l.id!==r.id)&&a.set(l.id,l);return a};return gD(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingTextElement:m,newElementId:p,sceneNonce:d})=>{let h=this.scene.getNonDeletedElements(),f=t({elements:h,editingTextElement:m,newElementId:p}),b=o({elementsMap:f,zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){p1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as bD}from"@excalidraw/common";import{getElementAbsoluteCoords as ED}from"@excalidraw/element";import{jsx as wD}from"react/jsx-runtime";var xD=5,yD=(e,o,t)=>{let[n,r]=ED(e,t),{x:i,y:a}=bD({sceneX:n+e.width,sceneY:r},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},qw=({children:e,element:o,elementsMap:t})=>{let n=So();if(n.contextMenu||n.newElement||n.resizingElement||n.isRotating||n.openMenu||n.viewModeEnabled)return null;let{x:r,y:i}=yD(o,n,t);return wD("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${r}px`,padding:xD},children:e})};import{DEFAULT_LASER_COLOR as SD,easeOut as Qw}from"@excalidraw/common";import{LaserPointer as vD}from"@excalidraw/laser-pointer";import{SVG_NS as Jw,getSvgPathFromStroke as ID,sceneCoordsToViewportCoords as TD}from"@excalidraw/common";var sn=class{constructor(o,t,n){this.animationFrameHandler=o;this.app=t;this.options=n;S(this,"currentTrail");S(this,"pastTrails",[]);S(this,"container");S(this,"trailElement");S(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Jw,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Jw,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===o&&this.currentTrail.originalPoints[n-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new vD(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let n of this.pastTrails)o.push(this.drawTrail(n,this.app.state));if(this.currentTrail){let n=this.drawTrail(this.currentTrail,this.app.state);o.push(n)}this.pastTrails=this.pastTrails.filter(n=>n.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let n=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=TD({sceneX:i,sceneY:a},t);return[l.x,l.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return ID(r,!0)}};var Ld=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;S(this,"localTrail");S(this,"collabTrails",new Map);S(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new sn(o,t,{...this.getTrailOptions(),fill:()=>SD})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let r=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(Qw(i),Qw(r))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(o)?n=this.collabTrails.get(o):(n=new sn(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||pr(o,t)}),n.start(this.container),this.collabTrails.set(o,n)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!n.hasCurrentTrail&&n.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&n.hasCurrentTrail&&!n.hasLastPoint(t.pointer.x,t.pointer.y)&&n.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&n.hasCurrentTrail&&(n.addPointToPath(t.pointer.x,t.pointer.y),n.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as CD}from"react";import{unstable_batchedUpdates as ev}from"react-dom";import{throttleRAF as kD}from"@excalidraw/common";var Re=e=>o=>{ev(e,o)},Ad=e=>kD(o=>{ev(e,o)}),wr=(()=>{let e;try{let t=CD.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as Zh,KEYS as kl,CLASSES as $h,POINTER_BUTTON as MD,THEME as PD,isWritableElement as LD,getFontString as tv,getFontFamilyString as ov,isTestEnv as nv,MIME_TYPES as AD,applyDarkModeFilter as _D}from"@excalidraw/common";import{originalContainerCache as DD,updateOriginalContainerCache as rv}from"@excalidraw/element";import{LinearElementEditor as RD}from"@excalidraw/element";import{bumpVersion as ND}from"@excalidraw/element";import{getBoundTextElementId as BD,getContainerElement as jh,getTextElementAngle as FD,redrawTextBoundingBox as OD,getBoundTextMaxHeight as zD,getBoundTextMaxWidth as iv,computeContainerDimensionForBoundText as av,computeBoundTextPosition as HD,getBoundTextElement as GD}from"@excalidraw/element";import{getTextWidth as UD}from"@excalidraw/element";import{normalizeText as lv}from"@excalidraw/element";import{wrapText as WD}from"@excalidraw/element";import{isArrowElement as _d,isBoundToContainer as YD,isTextElement as sv}from"@excalidraw/element";var VD=(e,o,t,n,r,i)=>{let{zoom:a}=n,l=180*t/Math.PI,s=e*(a.value-1)/2,c=o*(a.value-1)/2;return e>r&&a.value!==1&&(s=r*(a.value-1)/2),o>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},cv=({id:e,onChange:o,onSubmit:t,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let c=(D,O)=>{if(!O.style.fontFamily||!O.style.fontSize)return!1;let Q=O.style.fontFamily.replace(/"/g,"");return ov({fontFamily:D.fontFamily})!==Q||`${D.fontSize}px`!==O.style.fontSize},m=l.state.theme,p=()=>{m=l.state.theme;let D=l.state,O=l.scene.getElement(e);if(!O)return;let{textAlign:Q,verticalAlign:ee}=O,K=l.scene.getNonDeletedElementsMap();if(O&&sv(O)){let ae=O.x,be=O.y,ce=jh(O,l.scene.getNonDeletedElementsMap()),Oe=O.width,ao=O.height,yt=O.width,Vo=O.height;if(ce&&O.containerId){if(_d(ce)){let pn=RD.getBoundTextElementPosition(ce,O,K);ae=pn.x,be=pn.y}let nS=c(O,d),ba;if(nS?ba=rv(ce.id,ce.height):(ba=DD[ce.id],ba||(ba=rv(ce.id,ce.height))),yt=iv(ce,O),Vo=zD(ce,O),!_d(ce)&&ao>Vo){let pn=av(ao,ce.type);l.scene.mutateElement(ce,{height:pn});return}else if(!_d(ce)&&ce.height>ba.height&&ao<Vo){let pn=av(ao,ce.type);l.scene.mutateElement(ce,{height:pn})}else{let{x:pn,y:rS}=HD(ce,O,K);ae=pn,be=rS}}let[Nr,Qf]=n(ae,be);ce?Oe+=.5:(yt=(D.width-8-Nr)/D.zoom.value,Oe=Math.min(Oe,yt)),ao*=1.05;let oS=tv(O),e1=(D.height-Qf)/D.zoom.value;Object.assign(d.style,{font:oS,lineHeight:O.lineHeight,width:`${Oe}px`,height:`${ao}px`,left:`${Nr}px`,top:`${Qf}px`,transform:VD(Oe,ao,FD(O,ce),D,yt,e1),textAlign:Q,verticalAlign:ee,color:D.theme===PD.DARK?_D(O.strokeColor):O.strokeColor,opacity:O.opacity/100,maxHeight:`${e1}px`}),d.scrollTop=0,nv()&&(d.style.fontFamily=ov(O)),l.scene.mutateElement(O,{x:ae,y:be})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let h="pre",f="normal";(YD(r)||!r.autoResize)&&(h="pre-wrap",f="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:f,whiteSpace:h,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=r.originalText,p(),o&&(d.onpaste=async D=>{let O=(await el(D)).findByType(AD.text);if(!O)return;let Q=lv(O.value);if(!Q)return;let ee=jh(r,l.scene.getNonDeletedElementsMap()),K=tv({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(ee){let ae=GD(ee,l.scene.getNonDeletedElementsMap()),be=WD(`${d.value}${Q}`,K,iv(ee,ae)),ce=UD(be,K);d.style.width=`${ce}px`}},d.oninput=()=>{let D=lv(d.value);if(d.value!==D){let O=d.selectionStart;d.value=D,d.selectionStart=O,d.selectionEnd=O}o(d.value)}),d.onkeydown=D=>{if(!D.shiftKey&&sc.keyTest(D))D.preventDefault(),l.actionManager.executeAction(sc),p();else if(!D.shiftKey&&cc.keyTest(D))D.preventDefault(),l.actionManager.executeAction(cc),p();else if(!D.shiftKey&&dc.keyTest(D))D.preventDefault(),l.actionManager.executeAction(dc),p();else if(Wp.keyTest(D))l.actionManager.executeAction(Wp);else if(Yp.keyTest(D))l.actionManager.executeAction(Yp);else if(D.key===kl.ESCAPE)D.preventDefault(),C=!0,P();else if(dr.keyTest(D))D.preventDefault(),P(),l.actionManager.executeAction(dr);else if(D.key===kl.ENTER&&D[kl.CTRL_OR_CMD]){if(D.preventDefault(),D.isComposing||D.keyCode===229)return;C=!0,P()}else if(D.key===kl.TAB||D[kl.CTRL_OR_CMD]&&(D.code===Zh.BRACKET_LEFT||D.code===Zh.BRACKET_RIGHT)){if(D.preventDefault(),D.isComposing)return;D.shiftKey||D.code===Zh.BRACKET_LEFT?x():y(),d.dispatchEvent(new Event("input"))}};let b=4,E=" ".repeat(b),w=new RegExp(`^ {1,${b}}`),y=()=>{let{selectionStart:D,selectionEnd:O}=d,Q=v(),ee=d.value;Q.forEach(K=>{let ae=ee.slice(0,K),be=ee.slice(K);ee=`${ae}${E}${be}`}),d.value=ee,d.selectionStart=D+b,d.selectionEnd=O+b*Q.length},x=()=>{let{selectionStart:D,selectionEnd:O}=d,Q=v(),ee=[],K=d.value;Q.forEach(ae=>{let be=K.slice(ae,ae+b).match(w);if(be){let ce=K.slice(0,ae),Oe=K.slice(ae+be[0].length);K=`${ce}${Oe}`,ee.push(ae)}}),d.value=K,ee.length&&(D>ee[ee.length-1]?d.selectionStart=Math.max(D-b,ee[ee.length-1]):d.selectionStart=D,d.selectionEnd=Math.max(d.selectionStart,O-b*ee.length))},v=()=>{let{selectionStart:D,selectionEnd:O,value:Q}=d,ee=Q.slice(0,D).match(/[^\n]*$/)[0].length;return D=D-ee,Q.slice(D,O).split(`
|
|
16
|
-
`).reduce((ae,be,ce,Oe)=>ae.concat(ce?ae[ce-1]+Oe[ce-1].length+1:D),[]).reverse()},I=D=>{D.target instanceof HTMLCanvasElement&&(D.preventDefault(),D.stopPropagation())},C=!1,P=()=>{if(H)return;H=!0,k();let D=l.scene.getElement(r.id);if(!D)return;let O=jh(D,l.scene.getNonDeletedElementsMap());if(O){if(d.value.trim()){let Q=BD(O);!Q||Q!==r.id?l.scene.mutateElement(O,{boundElements:(O.boundElements||[]).concat({type:"text",id:r.id})}):_d(O)&&ND(O)}else l.scene.mutateElement(O,{boundElements:O.boundElements?.filter(Q=>!sv(Q))});OD(D,O,l.scene)}t({viaKeyboard:C,nextOriginalText:d.value})},k=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,Y&&Y.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",I,!0),window.removeEventListener("pointerdown",L),window.removeEventListener("pointerup",N),window.removeEventListener("blur",P),window.removeEventListener("beforeunload",P),G(),B(),j(),d.remove()},N=D=>{window.removeEventListener("pointerup",N);let O=D?.target,Q=O instanceof HTMLElement&&O.classList.contains("properties-trigger"),ee=(O instanceof HTMLElement||O instanceof SVGElement)&&!!O.closest(".properties-content"),K=(O instanceof HTMLElement||O instanceof SVGElement)&&(!!O.closest(`.${$h.SHAPE_ACTIONS_MENU}`)||!!O.closest(".compact-shape-actions-island"));setTimeout(()=>{K||Q||ee||(d.onblur=P,d.focus())})},_=()=>{d.onblur=null,window.addEventListener("pointerup",N),window.addEventListener("blur",P)},L=D=>{let O=D?.target;if(D.button===MD.WHEEL){O instanceof HTMLTextAreaElement&&(D.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(D)),_();return}let Q=O instanceof HTMLElement&&O.classList.contains("properties-trigger"),ee=(O instanceof HTMLElement||O instanceof SVGElement)&&!!O.closest(".properties-content");(D.target instanceof HTMLElement||D.target instanceof SVGElement)&&(D.target.closest(`.${$h.SHAPE_ACTIONS_MENU}, .${$h.ZOOM_ACTIONS}`)||D.target.closest(".compact-shape-actions-island"))&&!LD(D.target)||Q||ee?_():D.target instanceof HTMLCanvasElement&&!nv()&&requestAnimationFrame(()=>{P()})},B=l.onChangeEmitter.on(D=>{l.state.theme!==m&&p()}),G=l.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||d.focus()}),j=l.onScrollChangeEmitter.on(()=>{p()}),H=!1;s&&d.select(),N();let Y=null;return i&&"ResizeObserver"in window?(Y=new window.ResizeObserver(()=>{p()}),Y.observe(i)):window.addEventListener("resize",p),d.onpointerdown=D=>D.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",L,{capture:!0})}),window.addEventListener("beforeunload",P),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d),P};import{getGlobalCSSVariable as Dd}from"@excalidraw/common";import{getCommonBounds as XD}from"@excalidraw/element";var cn=4,qt=6,dv="rgba(0,0,0,0.3)",mv=(e,o,t,n)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,l]=XD(e),s=o/n.zoom.value,c=t/n.zoom.value,m={top:parseInt(Dd("sat"))||0,bottom:parseInt(Dd("sab"))||0,left:parseInt(Dd("sal"))||0,right:parseInt(Dd("sar"))||0},p=Xo().rtl,d=-n.scrollX+m.left,h=-n.scrollY+m.top,f=d+s-m.right,b=h+c-m.bottom,E=Math.min(r,d),w=Math.min(i,h),y=Math.max(a,f),x=Math.max(l,b),v=a-r,I=l-i,C=y-E,P=x-w,k=Math.max(cn*2,m.left+m.right)+qt*2,N=o*(s/C)-k,_=Math.max(cn*2,m.top+m.bottom)+qt*2,L=t*(c/P)-_,B=C>v?C*n.zoom.value/(N+k):o/(N+k),G=P>I?P*n.zoom.value/(L+_):t/(L+_);return{horizontal:d===E&&f===y?null:{x:Math.max(m.left,cn)+qt+(d-E)/C*o,y:t-qt-Math.max(cn,m.bottom),width:N,height:qt,deltaMultiplier:B},vertical:h===w&&b===x?null:{x:p?Math.max(m.left,cn):o-qt-Math.max(m.right,cn),y:Math.max(m.top,cn)+qt+(h-w)/P*t,width:qt,height:L,deltaMultiplier:G}}},qh=(e,o,t)=>{let[n,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:n||r,isOverHorizontal:n,isOverVertical:r}};import{pointFrom as oR}from"@excalidraw/math";import{getElementLineSegments as nR}from"@excalidraw/element";import{LinearElementEditor as rR}from"@excalidraw/element";import{isFrameLikeElement as iR,isLinearElement as aR,isTextElement as lR}from"@excalidraw/element";import{getFrameChildren as sR}from"@excalidraw/element";import{selectGroupsForSelectedElements as cR}from"@excalidraw/element";import{getContainerElement as dR}from"@excalidraw/element";import{arrayToMap as mR,easeOut as gv,isShallowEqual as pR}from"@excalidraw/common";import{simplify as KD}from"points-on-curve";import{polygonFromPoints as ZD,lineSegment as pv,polygonIncludesPointNonZero as $D}from"@excalidraw/math";import{computeBoundTextPosition as jD,doBoundsIntersect as qD,getBoundTextElement as JD,getElementBounds as QD,intersectElementWithLineSegment as uv}from"@excalidraw/element";var hv=e=>{let{lassoPath:o,elements:t,elementsMap:n,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=KD(o,l));let c=t.filter(d=>!d.locked);a.clear(),i.clear();let m=o.reduce((d,h)=>[Math.min(d[0],h[0]),Math.min(d[1],h[1]),Math.max(d[2],h[0]),Math.max(d[3],h[1])],[1/0,1/0,-1/0,-1/0]);for(let d of c){let h=QD(d,n);qD(m,h)&&!i.has(d.id)&&!a.has(d.id)&&(eR(s,d,r)?a.add(d.id):tR(s,d,n)&&i.add(d.id))}return{selectedElementIds:[...i,...a]}},eR=(e,o,t)=>{let n=ZD(e),r=t.get(o.id);return r?r.some(i=>i.some(a=>$D(a,n))):!1},tR=(e,o,t)=>{let n=e.slice(1).map((i,a)=>pv(e[a],i)).concat([pv(e[e.length-1],e[0])]),r=JD(o,t);return n.some(i=>uv(o,t,i,0,!0).length>0||!!r&&uv({...r,...jD(o,r,t)},t,i,0,!0).length>0)};var Rd=class extends sn{constructor(t,n){super(t,n,{animateTrail:!0,streamline:.4,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/(1/0)),s=(5e3-Math.min(5e3,r.totalLength-r.currentIndex))/5e3;return Math.min(gv(s),gv(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});S(this,"intersectedElements",new Set);S(this,"enclosedElements",new Set);S(this,"elementsSegments",null);S(this,"canvasTranslate",null);S(this,"keepPreviousSelection",!1);S(this,"selectElementsFromIds",t=>{this.app.setState(n=>{let r=t.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(n.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(s);if(c&&lR(c)){let m=dR(c,this.app.scene.getNonDeletedElementsMap());m&&(r[m.id]=!0,delete r[c.id])}}for(let[s]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(s);if(c&&iR(c)){let m=sR(this.app.scene.getNonDeletedElementsMap(),c.id);for(let p of m)delete r[p.id]}}let i=cR({editingGroupId:n.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),n,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&aR(this.app.scene.getNonDeletedElement(a[0]))?new rR(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});S(this,"addPointToPath",(t,n,r=!1)=>{super.addPointToPath(t,n),this.keepPreviousSelection=r,this.updateSelection()});S(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>oR(r[0],r[1])),n={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!pR(n,this.canvasTranslate??{})){this.canvasTranslate=n,this.elementsSegments=new Map;let r=mR(this.app.visibleElements);for(let i of this.app.visibleElements){let a=nR(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=hv({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}startPath(t,n,r=!1){this.endPath(),super.startPath(t,n),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{KEYS as Jh}from"@excalidraw/common";import{jsx as uR}from"react/jsx-runtime";var fv=F({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:np,viewMode:!0,perform:(e,o,t,n)=>{let r={fitToViewport:!0,animate:!0,duration:200,viewportZoomFactor:.8},i=q(e,o);return i.length<1?n.scrollToContent(e,r):n.scrollToContent(i,r),{captureUpdate:bv.NEVER}},keyTest:e=>!e[Jh.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===Jh.F,PanelComponent:({data:e,updateData:o})=>uR(V,{type:"button",icon:np,"aria-label":g("labels.smartZoom"),onClick:()=>o(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:Jh.F.toLocaleUpperCase()})});import{arrayToMap as hR,easeOut as Ev,THEME as gR}from"@excalidraw/common";import{computeBoundTextPosition as fR,doBoundsIntersect as bR,getBoundTextElement as ER,getElementBounds as xR,getElementLineSegments as yR,getFreedrawOutlineAsSegments as wR,getFreedrawOutlinePoints as vR,intersectElementWithLineSegment as xv,isArrowElement as IR,isFreeDrawElement as yv,isLineElement as TR,isPointInElement as SR}from"@excalidraw/element";import{lineSegment as CR,lineSegmentsDistance as wv,pointFrom as kv,polygon as kR,polygonIncludesPointNonZero as MR}from"@excalidraw/math";import{getElementsInGroup as vv}from"@excalidraw/element";import{shouldTestInside as PR}from"@excalidraw/element";import{hasBoundTextElement as Iv,isBoundToContainer as Tv}from"@excalidraw/element";import{getBoundTextElementId as Sv}from"@excalidraw/element";var Nd=class extends sn{constructor(t,n){super(t,n,{streamline:.2,size:5,keepHead:!0,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/200),s=(10-Math.min(10,r.totalLength-r.currentIndex))/10;return Math.min(Ev(s),Ev(l))},fill:()=>n.state.theme===gR.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});S(this,"elementsToErase",new Set);S(this,"groupsToErase",new Set)}startPath(t,n){this.endPath(),super.startPath(t,n),this.elementsToErase.clear()}addPointToPath(t,n,r=!1){return super.addPointToPath(t,n),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let n=super.getCurrentTrail()?.originalPoints?.map(l=>kv(l[0],l[1]))||[];if(n.length<2)return[];let r=CR(n[n.length-1],n[n.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=hR(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(Cv(r,l,a,this.app.state.zoom.value)){let c=l.groupIds.at(-1);if(this.groupsToErase.has(c)){let m=vv(this.app.scene.getNonDeletedElementsMap(),c);for(let p of m)this.elementsToErase.delete(p.id);this.groupsToErase.delete(c)}if(Tv(l)&&this.elementsToErase.delete(l.containerId),Iv(l)){let m=Sv(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&Cv(r,l,a,this.app.state.zoom.value)){let c=l.groupIds.at(-1);if(!this.groupsToErase.has(c)){let m=vv(this.app.scene.getNonDeletedElementsMap(),c);for(let p of m)this.elementsToErase.add(p.id);this.groupsToErase.add(c)}if(Iv(l)){let m=Sv(l);m&&this.elementsToErase.add(m)}Tv(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},Cv=(e,o,t,n)=>{let r=e[1],i=yv(o)?15:o.strokeWidth/2,a=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],l=xR(o,t),s=[l[0]-i,l[1]-i,l[2]+i,l[3]+i];if(!bR(a,s))return!1;if(PR(o)&&SR(r,o,t))return!0;if(yv(o)){let m=vR(o),p=wR(o,m,t),d=Math.max(2.25,5/n);for(let f of p)if(wv(f,e)<=d)return!0;let h=kR(...m.map(([f,b])=>kv(o.x+f,o.y+b)));return!!MR(e[0],h)}let c=ER(o,t);if(IR(o)||TR(o)&&!o.polygon){let m=Math.max(o.strokeWidth,o.strokeWidth*2/n),p=yR(o,t);for(let d of p)if(wv(d,e)<=m)return!0;return!1}return xv(o,t,e,0,!0).length>0||!!c&&xv({...c,...fR(o,c,t)},t,e,0,!0).length>0};import{jsx as Jt,jsxs as Mv}from"react/jsx-runtime";var LR=()=>Mv("div",{"data-testid":"brave-measure-text-error",children:[Jt("p",{children:Jt(Ft,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Jt("span",{style:{fontWeight:600},children:e})})}),Jt("p",{children:Jt(Ft,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Jt("span",{style:{fontWeight:600},children:e})})}),Jt("p",{children:Jt(Ft,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Jt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Jt("p",{children:Jt(Ft,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Jt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>Mv("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Pv=LR;import FR from"clsx";import OR from"react";import{useLayoutEffect as AR,useRef as Lv,useEffect as Av}from"react";import{unstable_batchedUpdates as _R}from"react-dom";import{KEYS as DR,queryFocusableElements as RR}from"@excalidraw/common";import NR from"clsx";import{jsx as BR}from"react/jsx-runtime";var _v=({children:e,left:o,top:t,onCloseRequest:n,fitInViewport:r=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight,className:c})=>{let m=Lv(null);Av(()=>{let d=m.current;if(!d)return;d.contains(document.activeElement)||d.focus();let h=f=>{if(f.key===DR.TAB){let b=RR(d),{activeElement:E}=document,w=b.findIndex(y=>y===E);E===d?(f.shiftKey?b[b.length-1]?.focus():b[0].focus(),f.preventDefault(),f.stopImmediatePropagation()):w===0&&f.shiftKey?(b[b.length-1]?.focus(),f.preventDefault(),f.stopImmediatePropagation()):w===b.length-1&&!f.shiftKey&&(b[0]?.focus(),f.preventDefault(),f.stopImmediatePropagation())}};return d.addEventListener("keydown",h),()=>d.removeEventListener("keydown",h)},[]);let p=Lv(null);return AR(()=>{if(r&&m.current&&t!=null&&o!=null){let d=m.current,{width:h,height:f}=d.getBoundingClientRect();if(p.current?.top===t&&p.current?.left===o)return;p.current={top:t,left:o},h>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):o+h-i>l?d.style.left=`${l-h-10}px`:d.style.left=`${o}px`,f>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+f-a>s?d.style.top=`${s-f}px`:d.style.top=`${t}px`}},[t,o,r,l,s,i,a]),Av(()=>{if(n){let d=h=>{m.current?.contains(h.target)||_R(()=>n(h))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[n]),BR("div",{className:NR("popover",c),ref:m,tabIndex:-1,children:e})};import{jsx as oa,jsxs as zR}from"react/jsx-runtime";var Ye="separator",Dv=OR.memo(({actionManager:e,items:o,top:t,left:n,onClose:r})=>{let i=So(),a=yn(),l=o.reduce((s,c)=>(c&&(c===Ye||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return oa(_v,{onCloseRequest:()=>{r()},top:t,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:oa("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===Ye)return!l[c-1]||l[c-1]===Ye?null:oa("hr",{className:"context-menu-item-separator"},c);let m=s.name,p="";return s.label&&(typeof s.label=="function"?p=g(s.label(a,i,e.app)):p=g(s.label)),oa("li",{"data-testid":m,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:zR("button",{type:"button",className:FR("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[oa("div",{className:"context-menu-item__label",children:p}),oa("kbd",{className:"context-menu-item__shortcut",children:m?Ae(m):""})]})},c)})})})});import{jsx as Qh,jsxs as Rv}from"react/jsx-runtime";var HR=({height:e,width:o,userToFollow:t,onDisconnect:n})=>Qh("div",{className:"follow-mode",style:{width:o,height:e},children:Rv("div",{className:"follow-mode__badge",children:[Rv("div",{className:"follow-mode__badge__label",children:["Following"," ",Qh("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),Qh("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:Ut})]})}),Nv=HR;import kr from"clsx";import OF from"react";import{CLASSES as zF,DEFAULT_SIDEBAR as qg,TOOL_TYPE as e5,arrayToMap as HF,capitalizeString as GF,isShallowEqual as lm}from"@excalidraw/common";import{mutateElement as UF}from"@excalidraw/element";import{showSelectedShapeActions as WF}from"@excalidraw/element";import{ShapeCache as YF}from"@excalidraw/element";import{createIsolation as GR}from"jotai-scope";import eg from"react";import Bo from"tunnel-rat";var tg=eg.createContext(null),Ge=()=>eg.useContext(tg),UR=GR(),Bv=()=>eg.useMemo(()=>({MainMenuTunnel:Bo(),WelcomeScreenMenuHintTunnel:Bo(),WelcomeScreenToolbarHintTunnel:Bo(),WelcomeScreenHelpHintTunnel:Bo(),WelcomeScreenCenterTunnel:Bo(),FooterCenterTunnel:Bo(),DefaultSidebarTriggerTunnel:Bo(),DefaultSidebarTabTriggersTunnel:Bo(),OverwriteConfirmDialogTunnel:Bo(),TTDDialogTriggerTunnel:Bo(),tunnelsJotai:UR}),[]);import WR from"clsx";import{useState as YR,useEffect as VR}from"react";import{THEME as XR}from"@excalidraw/common";import{jsx as og,jsxs as KR}from"react/jsx-runtime";var Bd=({delay:e,theme:o})=>{let[t,n]=YR(!!e);return VR(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),t?null:KR("div",{className:WR("LoadingMessage",{"LoadingMessage--dark":o===XR.DARK}),children:[og("div",{children:og(Dt,{})}),og("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import{useState as Ov}from"react";import Ml from"clsx";import{KEYS as zv,capitalizeString as kt}from"@excalidraw/common";import ZR from"clsx";import{KEYS as Fv}from"@excalidraw/common";import{jsx as $R}from"react/jsx-runtime";var Fd=e=>$R(V,{className:ZR("Shape",{fillable:!1,active:e.checked}),type:"radio",icon:As,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:Fv.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":Fv.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{jsx as Qt,jsxs as rg}from"react/jsx-runtime";var ng=[{type:"selection",icon:Qn,title:kt(g("toolBar.selection"))},{type:"lasso",icon:gn,title:kt(g("toolBar.lasso"))}],Hv=({app:e,onHandToolToggle:o,setAppState:t})=>{let n=e.state.activeTool,[r,i]=Ov(!1),a=(I,C)=>{e.state.activeTool.type!==I&&le("toolbar",I,"ui"),I==="selection"?e.state.activeTool.type==="selection"||e.setActiveTool({type:"selection"}):e.setActiveTool({type:I})},[l,s]=Ov(0),c=36,m=4,p=7,d=p*c+(p-1)*m,h=c+m,f=l>=d+1*h,b=l>=d+2*h,E=l>=d+3*h,w=_o.filter(I=>I.myocSimplifiedMode===!1),x=["text","frame","embeddable","laser","magicframe"].filter(I=>!(f&&I==="text"||b&&I==="image"||E&&I==="frame")).includes(n.type),v=x?n.type==="text"?To:n.type==="image"?jr:n.type==="frame"?fn:n.type==="embeddable"?Ss:n.type==="laser"?ti:n.type==="magicframe"?K0:ei:ei;return rg("div",{className:"mobile-toolbar",ref:I=>{I&&s(I.getBoundingClientRect().width)},children:[Qt(Fd,{checked:lo(e.state),onChange:o,title:g("toolBar.hand"),isMobile:!0}),Qt(rd,{app:e,options:ng,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,namePrefix:"selectionType",title:kt(g("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:I=>{(I==="selection"||I==="lasso")&&(e.setActiveTool({type:I}),t({preferredSelectionTool:{type:I,initialized:!0}}))},displayedOption:ng.find(I=>I.type===e.state.preferredSelectionTool.type)||ng[0]}),Qt(V,{className:Ml({active:n.type==="freedraw"}),type:"radio",icon:Io,checked:n.type==="freedraw",name:"editor-current-shape",title:`${kt(g("toolBar.freedraw"))}`,"aria-label":kt(g("toolBar.freedraw")),"data-testid":"toolbar-freedraw",onChange:()=>a("freedraw")}),f&&Qt(V,{className:Ml({active:n.type==="text"}),type:"radio",icon:To,checked:n.type==="text",name:"editor-current-shape",title:`${kt(g("toolBar.text"))}`,"aria-label":kt(g("toolBar.text")),"data-testid":"toolbar-text",onChange:()=>a("text")}),b&&Qt(V,{className:Ml({active:n.type==="image"}),type:"radio",icon:jr,checked:n.type==="image",name:"editor-current-shape",title:`${kt(g("toolBar.image"))}`,"aria-label":kt(g("toolBar.image")),"data-testid":"toolbar-image",onChange:()=>a("image")}),Qt(V,{className:Ml({active:n.type==="eraser"}),type:"radio",icon:Ts,checked:n.type==="eraser",name:"editor-current-shape",title:`${kt(g("toolBar.eraser"))}`,"aria-label":kt(g("toolBar.eraser")),"data-testid":"toolbar-eraser",onChange:()=>a("eraser")}),rg(ge,{open:r,placement:"top",children:[Qt(ge.Trigger,{className:Ml("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":x||r}),onToggle:()=>{i(!r),t({openMenu:null,openPopup:null})},title:g("toolBar.extraTools"),style:{width:c,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:v}),rg(ge.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[w.map(({value:I,icon:C,key:P,fillable:k})=>{let N=g(`toolBar.${I}`),_=P&&kt(typeof P=="string"?P:P[0]);return Qt(ge.Item,{onSelect:()=>e.setActiveTool({type:I}),icon:C,"data-testid":`toolbar-${I}`,selected:n.type===I,shortcut:_??void 0,children:kt(N)},I)}),Qt("div",{className:"App-toolbar__dropdown-divider"}),Qt(ge.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?hn:Ko,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:zv.Q,children:kt(g("toolBar.lock-short"))}),!f&&Qt(ge.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:To,shortcut:zv.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:n.type==="text",children:g("toolBar.text")}),!b&&Qt(ge.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:jr,"data-testid":"toolbar-image",selected:n.type==="image",children:g("toolBar.image")})]})]})]})};import{Fragment as jR,jsx as vr,jsxs as Pl}from"react/jsx-runtime";var Gv=({appState:e,elements:o,actionManager:t,setAppState:n,onHandToolToggle:r,renderTopLeftUI:i,renderTopRightUI:a,renderSidebars:l,renderWelcomeScreen:s,UIOptions:c,app:m,onPenModeToggle:p})=>{let{WelcomeScreenCenterTunnel:d}=Ge(),h=()=>vr(Hv,{app:m,onHandToolToggle:r,setAppState:n});return Pl(jR,{children:[l(),vr("div",{className:"App-welcome-screen",children:s&&vr(d.Out,{})}),Pl("div",{className:"App-bottom-bar-container",style:{marginBottom:qt+cn},children:[vr("div",{className:"App-bottom-bar-item",children:vr(ze,{children:Pl("div",{className:"mobile-toolbar",children:[t.renderAction("viewMode"),t.renderAction("smartZoom")]})})}),!e.viewModeEnabled&&Pl("div",{className:"App-bottom-bar-item",children:[vr(O2,{appState:e,elementsMap:m.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:m,setAppState:n}),Pl(ze,{className:"App-toolbar",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&h(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&vr("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(f=>({...jn(o,f)}))},children:g("buttons.scrollBackToContent")})]})]})]})]})};import qR,{useLayoutEffect as JR,useRef as QR,useState as e9}from"react";import{jsx as Ll,jsxs as t9}from"react/jsx-runtime";var Uv=e=>{let o=QR(null),[t,n]=e9(null);return JR(()=>{if(!e.spreadsheet)return;let r=jE(e.chartType,e.spreadsheet,0,0);n(r);let i,a=o.current;return(async()=>(i=await Gr(r,{exportBackground:!1,viewBackgroundColor:"#fff"},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),Ll("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:Ll("div",{ref:o})})},Wv=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:n}=qe(),r=qR.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{n(l),le("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Ll(We,{size:"small",onCloseRequest:r,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:t9("div",{className:"container",children:[Ll(Uv,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),Ll(Uv,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import{Fragment as o9,jsx as Yv,jsxs as n9}from"react/jsx-runtime";var Al=({heading:e,children:o,...t})=>{let{id:n}=ke(),r=Yv("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:g(`headings.${e}`)});return Yv("section",{...t,"aria-labelledby":`${n}-${e}-title`,children:typeof o=="function"?o(r):n9(o9,{children:[r,o]})})};import*as Nn from"@radix-ui/react-popover";import Vv from"clsx";import Od,{useLayoutEffect as r9}from"react";import{supportsResizeObserver as i9,isShallowEqual as a9}from"@excalidraw/common";import{Fragment as m9,jsx as Fo,jsxs as zd}from"react/jsx-runtime";var l9=4,s9=8,c9=({shouldWrap:e,children:o,username:t})=>e?Fo(ct,{label:t||"Unknown user",children:o}):Fo(m9,{children:o}),ig=({actionManager:e,collaborator:o,socketId:t,withName:n=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:n,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Fo(c9,{username:o.username,shouldWrap:r,children:l},t)},d9=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Hd=Od.memo(({className:e,mobile:o,collaborators:t,userToFollow:n})=>{let r=at(),i=new Map;t.forEach((b,E)=>{let w=b.id||E;i.set(w,{...b,socketId:E})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=Od.useState(""),c=a.filter(b=>b.username?.toLowerCase().includes(l)),m=Od.useRef(null);r9(()=>{if(m.current){let b=w=>{let y=Math.max(1,Math.min(8,Math.floor(w/38)));d(y)};if(b(m.current.clientWidth),!i9)return;let E=new ResizeObserver(w=>{for(let y of w){let{width:x}=y.contentRect;b(x)}});return E.observe(m.current),()=>{E.disconnect()}}},[]);let[p,d]=Od.useState(l9),f=a.slice(0,p-1).map(b=>ig({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}));return o?Fo("div",{className:Vv("UserList UserList_mobile",e),children:a.map(b=>ig({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}))}):Fo("div",{className:"UserList__wrapper",ref:m,children:zd("div",{className:Vv("UserList",e),style:{"--max-avatars":p},children:[f,a.length>p-1&&zd(Nn.Root,{children:[zd(Nn.Trigger,{className:"UserList__more",children:["+",a.length-p+1]}),Fo(Nn.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:zd(ze,{padding:2,children:[a.length>=s9&&Fo(qs,{placeholder:g("quickSearch.placeholder"),onChange:s}),Fo(Js,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:c.length>0?[Fo("div",{className:"hint",children:g("userList.hint.text")}),c.map(b=>ig({actionManager:r,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===n}))]:[]}),Fo(Nn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[n,r]of e.collaborators){let i=o.collaborators.get(n);if(!i||n!==t.next().value||!a9(r,i,d9))return!1}return!0});import p9 from"clsx";import{jsx as Xv,jsxs as h9}from"react/jsx-runtime";var u9="medium",Kv=e=>e.penDetected?h9("label",{className:p9("ToolIcon ToolIcon__penMode",`ToolIcon_size_${u9}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Xv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Xv("div",{className:"ToolIcon__icon",children:z1})]}):null;import _l from"clsx";import{jsx as g9}from"react/jsx-runtime";var Zv=e=>g9("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:qr});import{jsx as Ht,jsxs as ag}from"react/jsx-runtime";var $v=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i}=Ge();return ag("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Ht("div",{className:_l("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Ht(Tt.Col,{gap:2,children:ag(Al,{heading:"canvasActions",children:[Ht(ct,{label:g("labels.viewMode"),children:Ht("div",{className:_l("view-mode-button"),children:o.renderAction("viewMode")})}),Ht(ct,{label:g("buttons.smartZoom"),children:Ht("div",{className:_l("smart-zoom-button"),children:o.renderAction("smartZoom")})}),Ht(H2,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Ht(G2,{renderAction:o.renderAction,className:_l("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Ht(r.Out,{}),Ht("div",{className:_l("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:ag("div",{style:{position:"relative"},children:[n&&Ht(i.Out,{}),Ht(Zv,{onClick:()=>o.executeAction(mr)})]})}),Ht(U2,{actionManager:o,showExitZenModeBtn:t})]})},jv=$v;$v.displayName="Footer";import I9 from"clsx";import{useEffect as l3,useLayoutEffect as s3,useRef as gg,useState as T9,forwardRef as c3,useImperativeHandle as S9,useCallback as r3}from"react";import{CLASSES as C9,EVENT as i3,isDevEnv as k9,KEYS as M9,updateObject as P9}from"@excalidraw/common";import b9 from"clsx";import{useContext as E9}from"react";import f9 from"react";var Gd=f9.createContext({});import{jsx as lg,jsxs as qv}from"react/jsx-runtime";var sg=({children:e,className:o})=>{let t=de(),n=E9(Gd),r=!!(t.canFitSidebar&&n.shouldRenderDockButton);return qv("div",{className:b9("sidebar__header",o),"data-testid":"sidebar-header",children:[e,qv("div",{className:"sidebar__header__buttons",children:[r&&lg(ct,{label:g("labels.sidebarLock"),children:lg(Ot,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:R1})}),lg(Ot,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":g("buttons.close"),children:Ut})]})]})};sg.displayName="SidebarHeader";import*as Qv from"@radix-ui/react-tabs";import{jsx as Jv}from"react/jsx-runtime";var cg=({children:e,tab:o,onSelect:t,...n})=>Jv(Qv.Trigger,{value:o,asChild:!0,onSelect:t,children:Jv("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...n,children:e})});cg.displayName="SidebarTabTrigger";import*as e3 from"@radix-ui/react-tabs";import{jsx as x9}from"react/jsx-runtime";var dg=({children:e,...o})=>x9(e3.List,{className:"sidebar-triggers",...o,children:e});dg.displayName="SidebarTabTriggers";import y9 from"clsx";import{jsx as mg,jsxs as t3}from"react/jsx-runtime";var pg=({name:e,tab:o,icon:t,title:n,children:r,onToggle:i,className:a,style:l})=>{let s=he(),c=Te();return t3("label",{title:n,className:"sidebar-trigger__label-element",children:[mg("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let p=m.target.checked;s({openSidebar:p?{name:e,tab:o}:null,openMenu:null,openPopup:null}),i?.(p)},checked:c.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),t3("div",{className:y9("sidebar-trigger",a),style:l,children:[t&&mg("div",{children:t}),r&&mg("div",{className:"sidebar-trigger__label",children:r})]})]})};pg.displayName="SidebarTrigger";import*as o3 from"@radix-ui/react-tabs";import{jsx as w9}from"react/jsx-runtime";var ug=({children:e,...o})=>{let t=Te(),n=he();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return w9(o3.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>n(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...o,children:e})};ug.displayName="SidebarTabs";import*as n3 from"@radix-ui/react-tabs";import{jsx as v9}from"react/jsx-runtime";var hg=({tab:e,children:o,...t})=>v9(n3.Content,{...t,value:e,"data-testid":e,children:o});hg.displayName="SidebarTab";import{jsx as a3}from"react/jsx-runtime";import{createElement as L9}from"react";var Dl=Se(!1),d3=c3(({name:e,children:o,onDock:t,docked:n,className:r,...i},a)=>{k9()&&t&&n==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=he(),s=Wr(Dl);s3(()=>(s(!!n),()=>{s(!1)}),[s,n]);let c=gg({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=h=>t?.(h),c.current=P9(c.current,{docked:n,shouldRenderDockButton:!!t&&n!=null});let m=gg(null);S9(a,()=>m.current);let p=de(),d=r3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return si(m,r3(h=>{h.target.closest(".sidebar-trigger")||(!n||!p.canFitSidebar)&&d()},[d,n,p.canFitSidebar])),l3(()=>{let h=f=>{f.key===M9.ESCAPE&&(!n||!p.canFitSidebar)&&d()};return document.addEventListener(i3.KEYDOWN,h),()=>{document.removeEventListener(i3.KEYDOWN,h)}},[d,n,p.canFitSidebar]),a3(ze,{...i,className:I9(C9.SIDEBAR,{"sidebar--docked":n},r),ref:m,children:a3(Gd.Provider,{value:c.current,children:o})})});d3.displayName="SidebarInner";var eo=Object.assign(c3((e,o)=>{let t=Te(),{onStateChange:n}=e,r=gg(t.openSidebar);l3(()=>{(!t.openSidebar&&r?.current?.name===e.name||t.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&t.openSidebar!==r.current&&n?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,n,e.name]);let[i,a]=T9(!1);return s3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?L9(d3,{...e,ref:o,key:e.name}):null}),{Header:sg,TabTriggers:dg,TabTrigger:cg,Tabs:ug,Tab:hg,Trigger:pg});eo.displayName="Sidebar";import{composeEventHandlers as z9}from"@excalidraw/common";import{useLayoutEffect as A9,useRef as _9}from"react";import{jsx as D9}from"react/jsx-runtime";var Ir=(e,o)=>{let t=Se(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=Ge(),[,a]=i(t),l=_9({preferHost:!1,counter:0});return A9(()=>{let s=l.current;return a(c=>{let m=c+1;return s.counter=m,m}),()=>{a(c=>{let m=c-1;return s.counter=m,m||(s.preferHost=!1),m})}},[a]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:D9(o,{...r})};return n.displayName=e,n};var Eg={};o1(Eg,{ChangeCanvasBackground:()=>I3,CommandPalette:()=>x3,Export:()=>T3,Help:()=>w3,LiveCollaborationTrigger:()=>C3,LoadScene:()=>f3,SaveAsImage:()=>E3,SaveToActiveFile:()=>b3,SearchMenu:()=>y3,Socials:()=>S3,ToggleTheme:()=>v3});import F9 from"clsx";import{THEME as Bn}from"@excalidraw/common";var fg=Se({active:!1});async function m3({title:e,description:o,actionLabel:t,color:n}){return new Promise(r=>{$e.set(fg,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:o,actionLabel:t,color:n})})}import R9 from"clsx";import{jsx as p3,jsxs as N9}from"react/jsx-runtime";var Ud=function({onChange:e,value:o,choices:t,name:n}){return p3("div",{className:"RadioGroup",children:t.map(r=>N9("div",{className:R9("RadioGroup__choice",{active:r.value===o}),title:r.ariaLabel,children:[p3("input",{name:n,type:"radio",checked:r.value===o,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as B9,jsx as bg,jsxs as u3}from"react/jsx-runtime";var h3=({value:e,shortcut:o,onChange:t,choices:n,children:r,name:i})=>{let a=de();return u3(B9,{children:[u3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[bg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:r}),bg(Ud,{name:i,value:e,onChange:t,choices:n})]}),o&&a.formFactor!=="phone"&&bg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};h3.displayName="DropdownMenuItemContentRadio";var g3=h3;import{Fragment as O9,jsx as et,jsxs as k3}from"react/jsx-runtime";var f3=()=>{let{t:e}=Ue(),o=at(),t=yn();return o.isActionEnabled(Ii)?et(vt,{icon:Jr,onSelect:async()=>{(!t.length||await m3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:et(Ft,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>et("strong",{children:r}),br:()=>et("br",{})})}))&&o.executeAction(Ii)},"data-testid":"load-button",shortcut:Ae("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};f3.displayName="LoadScene";var b3=()=>{let{t:e}=Ue(),o=at();return o.isActionEnabled(dr)?et(vt,{shortcut:Ae("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(dr),icon:Z1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};b3.displayName="SaveToActiveFile";var E3=()=>{let e=he(),{t:o}=Ue();return et(vt,{icon:ks,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Ae("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};E3.displayName="SaveAsImage";var x3=e=>{let o=he(),{t}=Ue();return et(vt,{icon:La,"data-testid":"command-palette-button",onSelect:()=>{le("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Ae("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};x3.displayName="CommandPalette";var y3=e=>{let{t:o}=Ue(),t=at();return et(vt,{icon:_t,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(El)},shortcut:Ae("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};y3.displayName="SearchMenu";var w3=()=>{let{t:e}=Ue(),o=at();return et(vt,{"data-testid":"help-menu-item",icon:qr,onSelect:()=>o.executeAction(mr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};w3.displayName="Help";var v3=e=>{let{t:o}=Ue(),t=Te(),n=at(),r=Ae("toggleTheme");return n.isActionEnabled(ar)?e?.allowSystemTheme?et(g3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:Bn.LIGHT,label:ka,ariaLabel:`${o("buttons.lightMode")} - ${r}`},{value:Bn.DARK,label:Ca,ariaLabel:`${o("buttons.darkMode")} - ${r}`},{value:"system",label:lb,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):et(vt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===Bn.DARK?Bn.LIGHT:Bn.DARK);else return n.executeAction(ar)},icon:t.theme===Bn.DARK?ka:Ca,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Bn.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===Bn.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};v3.displayName="ToggleTheme";var I3=()=>{let{t:e}=Ue(),o=Te(),t=at(),n=Co();return o.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:k3("div",{style:{marginTop:"0.5rem"},children:[et("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),et("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};I3.displayName="ChangeCanvasBackground";var T3=()=>{let{t:e}=Ue(),o=he();return et(vt,{icon:er,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};T3.displayName="Export";var S3=()=>{let{t:e}=Ue();return k3(O9,{children:[et(Yi,{icon:Y1,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),et(Yi,{icon:X1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),et(Yi,{icon:V1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};S3.displayName="Socials";var C3=({onSelect:e,isCollaborating:o})=>{let{t}=Ue();return et(vt,{"data-testid":"collab-button",icon:Ms,className:F9({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};C3.displayName="LiveCollaborationTrigger";import{jsx as Wd,jsxs as xg}from"react/jsx-runtime";var H9=Object.assign(Ir("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ge(),n=de(),r=Te(),i=he();return Wd(t.In,{children:xg(ge,{open:r.openMenu==="canvas",children:[Wd(ge.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:U1}),xg(ge.Content,{onClickOutside:()=>i({openMenu:null}),onSelect:z9(o,()=>{i({openMenu:null})}),placement:"bottom",className:n.formFactor==="phone"?"main-menu-dropdown":"",children:[e,n.formFactor==="phone"&&r.collaborators.size>0&&xg("fieldset",{className:"UserList-Wrapper",children:[Wd("legend",{children:g("labels.collaborators")}),Wd(Hd,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:ge.Trigger,Item:ge.Item,ItemLink:ge.ItemLink,ItemCustom:ge.ItemCustom,Group:ge.Group,Separator:ge.Separator,DefaultItems:Eg}),bt=H9;import G9 from"clsx";import{forwardRef as U9,useState as W9}from"react";import{isPromiseLike as Y9}from"@excalidraw/common";import{jsx as Yd,jsxs as V9}from"react/jsx-runtime";var Fn=U9(({children:e,icon:o,onClick:t,label:n,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:c,disabled:m},p)=>{let[d,h]=W9(!1),f=async E=>{let w=t?.(E);if(Y9(w)){let y=window.setTimeout(()=>{h(!0)},50);try{await w}catch(x){if(x instanceof Or)console.warn(x);else throw x}finally{clearTimeout(y),h(!1)}}},b=d?"loading":c;return i=b==="success"?"success":i,Yd("button",{className:G9("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${b}`,{"ExcButton--fullWidth":l},s),onClick:f,type:"button","aria-label":n,ref:p,disabled:m||b==="loading"||b==="success",children:V9("div",{className:"ExcButton__contents",children:[b==="loading"?Yd(Dt,{className:"ExcButton__statusIcon"}):b==="success"&&Yd("div",{className:"ExcButton__statusIcon",children:Y0}),o&&Yd("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),r!=="icon"&&(e??n)]})})});import{jsx as na,jsxs as Z9}from"react/jsx-runtime";var Vd=({title:e,children:o,actionLabel:t,onClick:n})=>Z9("div",{className:"OverwriteConfirm__Actions__Action",children:[na("h4",{children:e}),na("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),na(Fn,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:n})]}),X9=()=>{let{t:e}=Ue(),o=at(),t=he();return na(Vd,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(wc,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},K9=()=>{let{t:e}=Ue(),o=at();return na(Vd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(tl,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},yg=Object.assign(({children:e})=>na("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:X9,SaveToDisk:K9});import{jsx as On,jsxs as M3}from"react/jsx-runtime";var Xd=Object.assign(Ir("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ge(),[t,n]=ue(fg);if(!t.active)return null;let r=()=>{t.onClose(),n(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),n(a=>({...a,active:!1}))};return On(o.In,{children:On(We,{onCloseRequest:r,title:!1,size:916,children:M3("div",{className:"OverwriteConfirm",children:[On("h3",{children:t.title}),M3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[On("div",{className:"OverwriteConfirm__Description__icon",children:V0}),On("div",{children:t.description}),On("div",{className:"OverwriteConfirm__Description__spacer"}),On(Fn,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),On(yg,{children:e})]})})})}),{Actions:yg,Action:Vd});import fN from"clsx";import{CANVAS_SEARCH_TAB as Sg,DEFAULT_SIDEBAR as bN,LIBRARY_SIDEBAR_TAB as O3,composeEventHandlers as EN}from"@excalidraw/common";import{round as $9}from"@excalidraw/math";import j9 from"clsx";import q9 from"lodash.debounce";import{Fragment as J9,memo as Q9,useEffect as Rl,useMemo as P3,useRef as wg,useState as L3}from"react";import{CLASSES as eN,EVENT as tN,FONT_FAMILY as vg,FRAME_STYLE as Ig,getLineHeight as oN}from"@excalidraw/common";import{isElementCompletelyInViewport as nN}from"@excalidraw/element";import{measureText as Nl}from"@excalidraw/element";import{KEYS as ra,randomInteger as A3,addEventListener as rN,getFontString as Kd}from"@excalidraw/common";import{newTextElement as iN}from"@excalidraw/element";import{isTextElement as N3,isFrameLikeElement as Zd}from"@excalidraw/element";import{getDefaultFrameName as B3}from"@excalidraw/element/frame";import{Fragment as gN,jsx as tt,jsxs as Oo}from"react/jsx-runtime";var aN=Se(""),Tg=Se(null),lN=350,F3=()=>{let e=qe(),o=he(),t=wg(null),[n,r]=ue(aN),i=n.trim(),[a,l]=L3(!1),[s,c]=L3({nonce:null,items:[]}),m=wg(null),p=wg(void 0),[d,h]=ue(Tg),f=e.scene.getNonDeletedElementsMap();Rl(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==p.current)&&(m.current=null,R3(i,e,(x,v)=>{c({nonce:A3(),items:x}),m.current=i,p.current=e.scene.getSceneNonce(),o({searchMatches:x.length?{focusedId:null,matches:x.map(I=>({id:I.element.id,focus:!1,matchedLines:I.matchedLines}))}:null})}))},[a,i,f,e,o,h,p]);let b=()=>{s.items.length>0&&h(x=>x===null?0:(x+1)%s.items.length)},E=()=>{s.items.length>0&&h(x=>x===null?0:x-1<0?s.items.length-1:x-1)};Rl(()=>{o(x=>x.searchMatches?{searchMatches:{focusedId:d!==null&&x.searchMatches?.matches[d]?.id||null,matches:x.searchMatches.matches.map((I,C)=>C===d?{...I,focus:!0}:{...I,focus:!1})}}:null)},[d,o]),Rl(()=>{if(s.items.length>0&&d!==null){let x=s.items[d];if(x){let v=e.state.zoom.value,I=iN({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:Zd(x.element)?Ig.nameFontSize:x.element.fontSize,fontFamily:Zd(x.element)?vg.Assistant:x.element.fontFamily}),C=14,P=I.fontSize,k=P*v<C;if(!nN([I],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||k){let N;k?P>=C?N={fitToContent:!0}:N={fitToViewport:!0,maxZoom:$9(C/P,1)}:N={fitToContent:!0},e.scrollToContent(I,{animate:!0,duration:300,...N,canvasOffsets:e.getEditorUIOffsets()})}}}},[d,s,e]),Rl(()=>()=>{h(null),m.current=null,p.current=void 0,o({searchMatches:null}),l(!1)},[o,h]);let w=bn({goToNextItem:b,goToPreviousItem:E,searchMatches:s});Rl(()=>{let x=v=>{if(v.key===ra.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[ra.CTRL_OR_CMD]&&v.key===ra.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(v.key===ra.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===ra.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===ra.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return rN(window,tN.KEYDOWN,x,{capture:!0,passive:!1})},[o,w,e]);let y=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return Oo("div",{className:"layer-ui__search",children:[tt("div",{className:"layer-ui__search-header",children:tt(An,{className:eN.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:t,placeholder:g("search.placeholder"),icon:_t,onChange:x=>{r(x),l(!0);let v=x.trim();R3(v,e,(I,C)=>{c({nonce:A3(),items:I}),h(C),m.current=v,p.current=e.scene.getSceneNonce(),o({searchMatches:I.length?{focusedId:null,matches:I.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),Oo("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Oo(gN,{children:[d!==null&&d>-1?Oo("div",{children:[d+1," / ",y]}):tt("div",{children:y}),Oo("div",{className:"result-nav",children:[tt(Ot,{onSelect:()=>{b()},className:"result-nav-btn",children:Ds}),tt(Ot,{onSelect:()=>{E()},className:"result-nav-btn",children:mb})]})]}),s.items.length===0&&i&&m.current&&tt("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),tt(dN,{matches:s,onItemClick:h,focusIndex:d,searchQuery:i})]})},_3=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return tt("div",{tabIndex:-1,className:j9("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:tt("div",{className:"preview-text",children:o.flatMap((t,n)=>tt(J9,{children:n===2?tt("b",{children:t}):t},n))})})},sN=e=>{let o=P3(()=>e.matches.items.filter(n=>Zd(n.element)),[e.matches]),t=P3(()=>e.matches.items.filter(n=>N3(n.element)),[e.matches]);return Oo("div",{children:[o.length>0&&Oo("div",{className:"layer-ui__search-result-container",children:[Oo("div",{className:"layer-ui__search-result-title",children:[tt("div",{className:"title-icon",children:fn}),tt("div",{children:g("search.frames")})]}),o.map((n,r)=>tt(_3,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),t.length>0&&tt("div",{className:"layer-ui__divider"})]}),t.length>0&&Oo("div",{className:"layer-ui__search-result-container",children:[Oo("div",{className:"layer-ui__search-result-title",children:[tt("div",{className:"title-icon",children:To}),tt("div",{children:g("search.texts")})]}),t.map((n,r)=>tt(_3,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+o.length===e.focusIndex,onClick:()=>e.onItemClick(r+o.length)},n.element.id+n.index))]})]})},cN=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,dN=Q9(sN,cN),D3=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),c=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;c=c.length>m?c.slice(-m):c;let p=e.slice(o+t.length),d=p.split(/\s+/),h=!p.startsWith(" "),f=h?6:5,b=(h?"":" ")+d.slice(0,f).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+b,moreBefore:s>0,moreAfter:d.length>f}},mN=(e,o)=>{let t=e.split(`
|
|
15
|
+
C ${s} ${c}, ${s} ${c}, ${s+E} ${c+w}`,en(e,!0,a))}else l=o.polygon([[s,c],[m,p],[d,h],[f,b]],en(e,!1,a));return l}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,en(e,!1,a));case"line":case"arrow":{let l,s=en(e,!1,a),c=e.points.length?e.points:[g_(0,0)];if(ml(e)?c.every(m=>Math.abs(m[0])<=1e6&&Math.abs(m[1])<=1e6)?l=[o.path(I_(c,16),en(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),l=[]):e.roundness?l=[o.curve(c,s)]:s.fill?l=[o.polygon(c,s)]:l=[o.linearPath(c,s)],e.type==="arrow"){let{startArrowhead:m=null,endArrowhead:p="arrow"}=e;if(m!==null){let d=dw(e,l,"start",m,o,s,n,a);l.push(...d)}if(p!==null){let d=dw(e,l,"end",p,o,s,n,a);l.push(...d)}}return l}case"freedraw":{let l=[];if(dd(e.points)){let s=u_(e.points,.75);l.push(o.curve(s,{...en(e,!1,a),stroke:"none"}))}return l.push(T_(e)),l}case"frame":case"magicframe":case"text":case"image":return null;default:return b_(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},I_=(e,o)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],l=e[r],s=gd(l,i),c=gd(a,l),m=Math.min(o,sw(e[r],a)/2,sw(e[r],i)/2);s?i[0]<l[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):i[1]<l[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m]),t.push(e[r]),c?a[0]<l[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):a[1]<l[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m])}let n=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)n.push(`L ${t[r][0]} ${t[r][1]}`),n.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return n.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),n.join(" ")};var T_=e=>k_(S_(e)),S_=e=>{let o=e.simulatePressure?e.points:e.points.length?e.points.map(([t,n],r)=>[t,n,e.pressures[r]]):[[0,0,.5]];return h_(o,{simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:t=>Math.sin(t*Math.PI/2),last:!0})},mw=(e,o)=>[(e[0]+o[0])/2,(e[1]+o[1])/2],C_=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,k_=e=>{if(!e.length)return"";let o=e.length-1;return e.reduce((t,n,r,i)=>(r===o?t.push(n,mw(n,i[0]),"L",i[0],"Z"):t.push(n,mw(n,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(C_,"$1")};var uw=(e,o,t=!1)=>{let n=!1;for(let r in o){let i=o[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return!n&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??M_(),updated:P_()}};import{jsx as gw}from"react/jsx-runtime";var Vi=F({name:"toggleLinearEditor",category:He.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&r.length===1&&A_(r[0])&&!L_(r[0]))},perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];Ah(r,"No selected element found"),Ah(o.selectedLinearElement,"No selected linear element found"),Ah(r.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:hw.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!n)return null;let r=g(n.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return gw(V,{type:"button",icon:ab,title:r,"aria-label":r,onClick:()=>o(null)})}}),nbe=F({name:"togglePolygon",category:He.elements,icon:Lm,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!Yi(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return r.length>0&&r.every(i=>Yi(i)&&i.points.length>=4)},perform(e,o,t,n){let r=n.scene.getSelectedElements(o);if(r.some(s=>!Yi(s)))return!1;let i=r,a=i.some(s=>!s.polygon),l=__(i);return{elements:e.map(s=>!l.has(s.id)||!Yi(s)?s:uw(s,{backgroundColor:a?s.backgroundColor:"transparent",...D_(s,a)})),appState:o,captureUpdate:hw.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(n.length===0||n.some(a=>!Yi(a)||!a.polygon||a.points.length<3))return null;let r=n.every(a=>Yi(a)&&a.polygon),i=g(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return gw(Qr,{icon:Lm,title:i,"aria-label":i,active:r,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as fw,CANVAS_SEARCH_TAB as bw,CLASSES as R_,DEFAULT_SIDEBAR as Ew}from"@excalidraw/common";import{CaptureUpdateAction as N_}from"@excalidraw/element";var dl=F({name:"searchMenu",icon:_t,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,n){if(o.openDialog)return!1;if(o.openSidebar?.name===Ew.name&&o.openSidebar.tab===bw){let r=n.excalidrawContainerValue.container?.querySelector(`.${R_.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...o,openSidebar:{name:Ew.name,tab:bw},openDialog:null},captureUpdate:N_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[fw.CTRL_OR_CMD]&&e.key===fw.F});import{isImageElement as B_}from"@excalidraw/element";import{CaptureUpdateAction as F_}from"@excalidraw/element";import{jsx as O_}from"react/jsx-runtime";var _h=F({name:"cropEditor",label:"helpDialog.cropStart",icon:jm,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:r.id},captureUpdate:F_.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.croppingElementId&&r.length===1&&B_(r[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=g("helpDialog.cropStart");return O_(V,{type:"button",icon:jm,title:n,"aria-label":n,onClick:()=>o(null)})}});import{getNonDeletedElements as z_}from"@excalidraw/element";import{mutateElement as H_}from"@excalidraw/element";import{newFrameElement as G_}from"@excalidraw/element";import{isFrameLikeElement as yd}from"@excalidraw/element";import{addElementsToFrame as U_,removeAllElementsFromFrame as W_}from"@excalidraw/element";import{getFrameChildren as Y_}from"@excalidraw/element";import{updateActiveTool as xw}from"@excalidraw/common";import{getElementsInGroup as V_}from"@excalidraw/element";import{getCommonBounds as X_}from"@excalidraw/element";import{CaptureUpdateAction as gr}from"@excalidraw/element";var yw=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&yd(t[0])},ww=F({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;if(yd(r)){let i=Y_(z_(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:gr.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:gr.EVENTUALLY}},predicate:(e,o,t,n)=>yw(o,n)}),vw=F({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;return yd(r)?{elements:W_(e,r),appState:{...o,selectedElementIds:{[r.id]:!0}},captureUpdate:gr.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:gr.EVENTUALLY}},predicate:(e,o,t,n)=>yw(o,n)}),hEe=F({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:gr.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),gEe=F({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:hn,viewMode:!1,perform:(e,o,t,n)=>{let r=xw(o,{type:"frame"});return Nt(n.interactiveCanvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:xw(o,{type:"frame"})},captureUpdate:gr.EVENTUALLY}},keyTest:e=>!1}),Iw=F({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=q(e,o);return r.length>0&&!r.some(i=>yd(i))},perform:(e,o,t,n)=>{let r=q(e,o),i=n.scene.getNonDeletedElementsMap(),[a,l,s,c]=X_(r,i),m=16,p=G_({x:a-m,y:l-m,width:s-a+m*2,height:c-l+m*2});if(o.editingGroupId){let h=V_(r,o.editingGroupId);for(let f of h){let b=f.groupIds.indexOf(o.editingGroupId);H_(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:U_([...n.scene.getElementsIncludingDeleted(),p],r,p,o),appState:{selectedElementIds:{[p.id]:!0}},captureUpdate:gr.IMMEDIATELY}}});import{isWindows as Q_,KEYS as fl,matchKey as Nh,arrayToMap as Tw,MOBILE_ACTION_BUTTON_BG as Sw}from"@excalidraw/common";import{CaptureUpdateAction as Rh}from"@excalidraw/element";import{orderByFractionalIndex as eD}from"@excalidraw/element";import{Emitter as K_}from"@excalidraw/common";import{CaptureUpdateAction as Z_,StoreChange as $_,StoreDelta as j_}from"@excalidraw/element";var Xi=class extends j_{applyTo(o,t,n){let[r,i]=this.elements.applyTo(o,n.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,r);return[r,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,n,r){return super.applyLatestChanges(o,t,n,r)}},fr=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},gl=class e{constructor(o){this.store=o;S(this,"onHistoryChangedEmitter",new K_);S(this,"undoStack",[]);S(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof Xi)return;let t=Xi.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new fr(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n))}perform(o,t,n,r){try{let i=n();if(i===null)return;let a=Z_.IMMEDIATELY,l=this.store.snapshot,s=o,c=t,m=!1;for(;i;){try{[s,c,m]=i.applyTo(s,c,l);let p=l.elements,d=l.maybeClone(a,s,c),h=$_.create(l,d),f=Xi.applyLatestChanges(i,p,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:h,delta:f}),i=f),l=d}finally{r(i)}if(m)break;i=n()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new fr(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let n=Xi.inverse(t);return o.push(n)}};import{useEffect as q_,useState as J_}from"react";var Dh=(e,o)=>{let[t,n]=J_(o);return q_(()=>{let r=e.on(i=>{n(i)});return()=>{r()}},[e]),t};import{jsx as Pw}from"react/jsx-runtime";var Cw=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let n=t();if(!n)return{captureUpdate:Rh.EVENTUALLY};let[r,i]=n,a=eD(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:Rh.NEVER}}return{captureUpdate:Rh.EVENTUALLY}},kw=e=>({name:"undo",label:"buttons.undo",icon:Dm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>Cw(r,t,()=>e.undo(Tw(o),t)),keyTest:o=>o[fl.CTRL_OR_CMD]&&Nh(o,fl.Z)&&!o.shiftKey,PanelComponent:({appState:o,updateData:t,data:n,app:r})=>{let{isUndoStackEmpty:i}=Dh(e.onHistoryChangedEmitter,new fr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=je()==="mobile";return Pw(V,{type:"button",icon:Dm,"aria-label":g("buttons.undo"),onClick:t,size:n?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?Sw:{}}})}}),Mw=e=>({name:"redo",label:"buttons.redo",icon:Rm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>Cw(r,t,()=>e.redo(Tw(o),t)),keyTest:o=>o[fl.CTRL_OR_CMD]&&o.shiftKey&&Nh(o,fl.Z)||Q_&&o.ctrlKey&&!o.shiftKey&&Nh(o,fl.Y),PanelComponent:({appState:o,updateData:t,data:n,app:r})=>{let{isRedoStackEmpty:i}=Dh(e.onHistoryChangedEmitter,new fr(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=je()==="mobile";return Pw(V,{type:"button",icon:Rm,"aria-label":g("buttons.redo"),onClick:t,size:n?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?Sw:{}}})}});import{getFontString as tD}from"@excalidraw/common";import{newElementWith as oD}from"@excalidraw/element";import{measureText as nD}from"@excalidraw/element";import{isTextElement as Lw}from"@excalidraw/element";import{CaptureUpdateAction as rD}from"@excalidraw/element";var Aw=F({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=q(e,o);return r.length===1&&Lw(r[0])&&!r[0].autoResize},perform:(e,o,t,n)=>{let r=q(e,o);return{appState:o,elements:e.map(i=>{if(i.id===r[0].id&&Lw(i)){let a=nD(i.originalText,tD(i),i.lineHeight);return oD(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:rD.IMMEDIATELY}}});import{isPromiseLike as iD}from"@excalidraw/common";import{jsx as aD}from"react/jsx-runtime";var Bh=(e,o,t,n,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,n,i))&&le(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},wd=class{constructor(o,t,n,r){S(this,"actions",{});S(this,"updater");S(this,"getAppState");S(this,"getElementsIncludingDeleted");S(this,"app");S(this,"renderAction",(o,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in n)||n[o])){let r=this.actions[o],i=r.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{Bh(r,"ui",l,a,this.app,c),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return aD(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});S(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!o.predicate||o.predicate(t,n,this.app.props,this.app)});this.updater=i=>{if(iD(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn("Canceling as multiple actions match this shortcut",n),!1;let r=n[0];if(this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return Bh(r,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(n[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",n=null){let r=this.getElementsIncludingDeleted(),i=this.getAppState();Bh(o,t,i,r,this.app,n),this.updater(o.perform(r,i,n,this.app))}};var vd=class{constructor(){S(this,"targets",new WeakMap);S(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let n=this.targets.get(o);if(!n)return;let r=this.onFrame(n,t);!n.stopped&&!r?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var Fh=e=>{let o=Array.from(e.values());return{x:_w(o,t=>t.x)/o.length,y:_w(o,t=>t.y)/o.length}},Oh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),_w=(e,o)=>e.reduce((t,n)=>t+o(n),0);import{pointFrom as U,pointRotateRads as An,rangeInclusive as Zt,rangeIntersection as Id,rangesOverlap as Td}from"@excalidraw/math";import{TOOL_TYPE as br,KEYS as Dw}from"@excalidraw/common";import{getCommonBounds as zh,getDraggedElementsBounds as Hh,getElementAbsoluteCoords as lD}from"@excalidraw/element";import{isBoundToContainer as Fw}from"@excalidraw/element";import{getMaximumGroups as Ow}from"@excalidraw/element";import{getSelectedElements as sD,getVisibleAndNonSelectedElements as zw}from"@excalidraw/element";var cD=8,Rw=99999,Sd=e=>cD/e,ft=class ft{};S(ft,"referenceSnapPoints",null),S(ft,"visibleGaps",null),S(ft,"setReferenceSnapPoints",o=>{ft.referenceSnapPoints=o}),S(ft,"getReferenceSnapPoints",()=>ft.referenceSnapPoints),S(ft,"setVisibleGaps",o=>{ft.visibleGaps=o}),S(ft,"getVisibleGaps",()=>ft.visibleGaps),S(ft,"destroy",()=>{ft.referenceSnapPoints=null,ft.visibleGaps=null});var $t=ft,_n=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,on=({event:e,app:o,selectedElements:t})=>{if(e){let n=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||n)&&(o.state.objectsSnapModeEnabled&&!e[Dw.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[Dw.CTRL_OR_CMD]&&!_n(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},dD=(e,o,t=.01)=>Math.abs(e-o)<=t,bl=(e,o,{omitCenter:t,boundingBoxCorners:n,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,m,p,d]=lD(a,o);r&&(l+=r.x,c+=r.x,p+=r.x,s+=r.y,m+=r.y,d+=r.y);let h=(c-l)/2,f=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!n){let b=An(U(l,s+f),U(p,d),a.angle),E=An(U(l+h,s),U(p,d),a.angle),w=An(U(c,s+f),U(p,d),a.angle),y=An(U(l+h,m),U(p,d),a.angle),x=U(p,d);i=t?[b,E,w,y]:[b,E,w,y,x]}else{let b=An(U(l,s),U(p,d),a.angle),E=An(U(c,s),U(p,d),a.angle),w=An(U(l,m),U(p,d),a.angle),y=An(U(c,m),U(p,d),a.angle),x=U(p,d);i=t?[b,E,w,y]:[b,E,w,y,x]}}else if(e.length>1){let[a,l,s,c]=Hh(e,r??{x:0,y:0}),m=s-a,p=c-l,d=U(a,l),h=U(s,l),f=U(a,c),b=U(s,c),E=U(a+m/2,l+p/2);i=t?[d,h,f,b]:[d,h,f,b,E]}return i.map(a=>U(De(a[0]),De(a[1])))},Hw=(e,o,t,n)=>zw(e,o,t,n),Gw=(e,o,t,n)=>{let r=Hw(e,o,t,n),i=Ow(r,n).filter(p=>!(p.length===1&&Fw(p[0]))).map(p=>zh(p).map(d=>De(d))),a=i.sort((p,d)=>p[0]-d[0]),l=[],s=0;e:for(let p=0;p<a.length;p++){let d=a[p];for(let h=p+1;h<a.length;h++){if(++s>Rw)break e;let f=a[h],[,b,E,w]=d,[y,x,,v]=f;E<y&&Td(Zt(b,w),Zt(x,v))&&l.push({startBounds:d,endBounds:f,startSide:[U(E,b),U(E,w)],endSide:[U(y,x),U(y,v)],length:y-E,overlap:Id(Zt(b,w),Zt(x,v))})}}let c=i.sort((p,d)=>p[1]-d[1]),m=[];s=0;e:for(let p=0;p<c.length;p++){let d=c[p];for(let h=p+1;h<c.length;h++){if(++s>Rw)break e;let f=c[h],[b,,E,w]=d,[y,x,v]=f;w<x&&Td(Zt(b,E),Zt(y,v))&&m.push({startBounds:d,endBounds:f,startSide:[U(b,w),U(E,w)],endSide:[U(y,x),U(v,x)],length:x-w,overlap:Id(Zt(b,E),Zt(y,v))})}}return{horizontalGaps:l,verticalGaps:m}},Nw=(e,o,t,n,r,i,a)=>{if(!on({app:t,event:n,selectedElements:e}))return[];if(e.length===0)return[];let l=$t.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[m,p,d,h]=Hh(e,o).map(E=>De(E)),f=(m+d)/2,b=(p+h)/2;for(let E of s){if(!Td(Zt(p,h),E.overlap))continue;let w=E.startSide[0][0]+E.length/2,y=De(w-f);if(E.length>d-m&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(r.length=0),a.x=Math.abs(y);let _={type:"gap",direction:"center_horizontal",gap:E,offset:y};r.push(_);continue}let[,,v]=E.endBounds,I=m-v,C=De(E.length-I);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:E,offset:C};r.push(_);continue}let[P,,,]=E.startBounds,k=P-d,N=De(k-E.length);if(Math.abs(N)<=a.x){Math.abs(N)<a.x&&(r.length=0),a.x=Math.abs(N);let _={type:"gap",direction:"side_left",gap:E,offset:N};r.push(_);continue}}for(let E of c){if(!Td(Zt(m,d),E.overlap))continue;let w=E.startSide[0][1]+E.length/2,y=De(w-b);if(E.length>h-p&&Math.abs(y)<=a.y){Math.abs(y)<a.y&&(i.length=0),a.y=Math.abs(y);let _={type:"gap",direction:"center_vertical",gap:E,offset:y};i.push(_);continue}let[,v,,]=E.startBounds,I=v-h,C=De(I-E.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:E,offset:C};i.push(_);continue}let[,,,P]=E.endBounds,k=De(p-P),N=E.length-k;if(Math.abs(N)<=a.y){Math.abs(N)<a.y&&(i.length=0),a.y=Math.abs(N);let _={type:"gap",direction:"side_bottom",gap:E,offset:N};i.push(_);continue}}}},Uw=(e,o,t,n)=>{let r=Hw(e,o,t,n);return Ow(r,n).filter(i=>!(i.length===1&&Fw(i[0]))).flatMap(i=>bl(i,n))},Ki=(e,o,t,n,r,i,a)=>{if(!on({app:t,event:n,selectedElements:e})||e.length===0&&o.length===0)return[];let l=$t.getReferenceSnapPoints();if(l)for(let s of o)for(let c of l){let m=c[0]-s[0],p=c[1]-s[1];Math.abs(m)<=a.x&&(Math.abs(m)<a.x&&(r.length=0),r.push({type:"point",points:[s,c],offset:m}),a.x=Math.abs(m)),Math.abs(p)<=a.y&&(Math.abs(p)<a.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:p}),a.y=Math.abs(p))}},Ww=(e,o,t,n,r)=>{let i=t.state,a=sD(e,i);if(!on({app:t,event:n,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=De(o.x),o.y=De(o.y);let l=[],s=[],c=Sd(i.zoom.value),m={x:c,y:c},p=bl(a,r,{dragOffset:o});Ki(a,p,t,n,l,s,m),Nw(a,o,t,n,l,s,m);let d={x:l[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,l.length=0,s.length=0;let h={x:De(o.x+d.x),y:De(o.y+d.y)};Ki(a,bl(a,r,{dragOffset:h}),t,n,l,s,m),Nw(a,h,t,n,l,s,m);let f=Gh(l,s),b=pD(a,h,[...l,...s].filter(E=>E.type==="gap"));return{snapOffset:d,snapLines:[...f,...b]}},De=e=>Math.round(e*10**6)/10**6,Bw=e=>{let o=new Map;for(let t of e){let n=t.join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},Gh=(e,o)=>{let t={},n={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=De(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>U(De(a[0]),De(a[1]))))}}if(o.length>0){for(let r of o)if(r.type==="point"){let i=De(r.points[0][1]);n[i]||(n[i]=[]),n[i].push(...r.points.map(a=>U(De(a[0]),De(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:Bw(i.map(a=>U(Number(r),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(n).map(([r,i])=>({type:"points",points:Bw(i.map(a=>U(a[0],Number(r))).sort((a,l)=>a[0]-l[0]))})))},mD=e=>{let o=new Map;for(let t of e){let n=t.points.flat().map(r=>[De(r)]).join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},pD=(e,o,t)=>{let[n,r,i,a]=Hh(e,o),l=[];for(let s of t){let[c,m,p,d]=s.gap.startBounds,[h,f,b,E]=s.gap.endBounds,w=Id(Zt(r,a),s.gap.overlap),y=Id(Zt(n,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[U(s.gap.startSide[0][0],x),U(n,x)]},{type:"gap",direction:"horizontal",points:[U(i,x),U(s.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[U(x,s.gap.startSide[0][1]),U(x,r)]},{type:"gap",direction:"vertical",points:[U(x,a),U(x,s.gap.endSide[0][1])]})}break}case"side_right":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[U(p,x),U(h,x)]},{type:"gap",direction:"horizontal",points:[U(b,x),U(n,x)]})}break}case"side_left":{if(w){let x=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[U(i,x),U(c,x)]},{type:"gap",direction:"horizontal",points:[U(p,x),U(h,x)]})}break}case"side_top":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[U(x,a),U(x,m)]},{type:"gap",direction:"vertical",points:[U(x,d),U(x,f)]})}break}case"side_bottom":{if(y){let x=(y[0]+y[1])/2;l.push({type:"gap",direction:"vertical",points:[U(x,d),U(x,f)]},{type:"gap",direction:"vertical",points:[U(x,E),U(x,r)]})}break}}}return mD(l.map(s=>({...s,points:s.points.map(c=>U(De(c[0]),De(c[1])))})))},Uh=(e,o,t,n,r,i)=>{if(!on({event:n,selectedElements:e,app:t})||e.length===0||e.length===1&&!dD(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=zh(o);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?l+=r.y:i.includes("s")&&(c+=r.y));let m=[];if(i)switch(i){case"e":{m.push(U(s,l),U(s,c));break}case"w":{m.push(U(a,l),U(a,c));break}case"n":{m.push(U(a,l),U(s,l));break}case"s":{m.push(U(a,c),U(s,c));break}case"ne":{m.push(U(s,l));break}case"nw":{m.push(U(a,l));break}case"se":{m.push(U(s,c));break}case"sw":{m.push(U(a,c));break}}let p=Sd(t.state.zoom.value),d={x:p,y:p},h=[],f=[];Ki(o,m,t,n,h,f,d);let b={x:h[0]?.offset??0,y:f[0]?.offset??0};d.x=0,d.y=0,h.length=0,f.length=0;let[E,w,y,x]=zh(e).map(C=>De(C)),v=[U(E,w),U(E,x),U(y,w),U(y,x)];Ki(e,v,t,n,h,f,d);let I=Gh(h,f);return{snapOffset:b,snapLines:I}},Yw=(e,o,t,n,r,i)=>{if(!on({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[U(n.x+r.x,n.y+r.y)],l=Sd(o.state.zoom.value),s={x:l,y:l},c=[],m=[];Ki([e],a,o,t,c,m,s);let p={x:c[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,c.length=0,m.length=0;let d=bl([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ki([e],d,o,t,c,m,s);let h=Gh(c,m);return{snapOffset:p,snapLines:h}},Vw=(e,o,t,n,r)=>{if(!on({event:n,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=zw(e,[],o.state,r),a=Sd(o.state.zoom.value),l={x:a,y:a},s=[],c=[];for(let m of i){let p=bl([m],r);for(let d of p){let h=d[0]-t.x;Math.abs(h)<=Math.abs(l.x)&&(Math.abs(h)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[d,U(d[0],t.y)],direction:"vertical"}),l.x=h);let f=d[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[d,U(t.x,d[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},Xw=e=>e===br.rectangle||e===br.ellipse||e===br.diamond||e===br.frame||e===br.magicframe||e===br.image||e===br.text;import{isElementInViewport as uD}from"@excalidraw/element";import{memoize as hD,toBrandedType as gD}from"@excalidraw/common";var El=class{constructor(o){S(this,"scene");S(this,"getRenderableElements",(()=>{let o=({elementsMap:n,zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:m})=>{let p=[];for(let d of n.values())uD(d,m,c,{zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},n)&&p.push(d);return p},t=({elements:n,editingTextElement:r,newElementId:i})=>{let a=gD(new Map);for(let l of n)i!==l.id&&(!r||r.type!=="text"||l.id!==r.id)&&a.set(l.id,l);return a};return hD(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingTextElement:m,newElementId:p,sceneNonce:d})=>{let h=this.scene.getNonDeletedElements(),f=t({elements:h,editingTextElement:m,newElementId:p}),b=o({elementsMap:f,zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){l1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as fD}from"@excalidraw/common";import{getElementAbsoluteCoords as bD}from"@excalidraw/element";import{jsx as yD}from"react/jsx-runtime";var ED=5,xD=(e,o,t)=>{let[n,r]=bD(e,t),{x:i,y:a}=fD({sceneX:n+e.width,sceneY:r},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},Kw=({children:e,element:o,elementsMap:t})=>{let n=vo();if(n.contextMenu||n.newElement||n.resizingElement||n.isRotating||n.openMenu||n.viewModeEnabled)return null;let{x:r,y:i}=xD(o,n,t);return yD("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${r}px`,padding:ED},children:e})};import{DEFAULT_LASER_COLOR as TD,easeOut as $w}from"@excalidraw/common";import{LaserPointer as wD}from"@excalidraw/laser-pointer";import{SVG_NS as Zw,getSvgPathFromStroke as vD,sceneCoordsToViewportCoords as ID}from"@excalidraw/common";var nn=class{constructor(o,t,n){this.animationFrameHandler=o;this.app=t;this.options=n;S(this,"currentTrail");S(this,"pastTrails",[]);S(this,"container");S(this,"trailElement");S(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Zw,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Zw,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===o&&this.currentTrail.originalPoints[n-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new wD(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let n of this.pastTrails)o.push(this.drawTrail(n,this.app.state));if(this.currentTrail){let n=this.drawTrail(this.currentTrail,this.app.state);o.push(n)}this.pastTrails=this.pastTrails.filter(n=>n.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let n=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=ID({sceneX:i,sceneY:a},t);return[l.x,l.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return vD(r,!0)}};var Cd=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;S(this,"localTrail");S(this,"collabTrails",new Map);S(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new nn(o,t,{...this.getTrailOptions(),fill:()=>TD})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let r=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min($w(i),$w(r))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(o)?n=this.collabTrails.get(o):(n=new nn(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||cr(o,t)}),n.start(this.container),this.collabTrails.set(o,n)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!n.hasCurrentTrail&&n.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&n.hasCurrentTrail&&!n.hasLastPoint(t.pointer.x,t.pointer.y)&&n.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&n.hasCurrentTrail&&(n.addPointToPath(t.pointer.x,t.pointer.y),n.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as SD}from"react";import{unstable_batchedUpdates as jw}from"react-dom";import{throttleRAF as CD}from"@excalidraw/common";var Re=e=>o=>{jw(e,o)},kd=e=>CD(o=>{jw(e,o)}),Er=(()=>{let e;try{let t=SD.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as Wh,KEYS as xl,CLASSES as Yh,POINTER_BUTTON as kD,THEME as MD,isWritableElement as PD,getFontString as qw,getFontFamilyString as Jw,isTestEnv as Qw,MIME_TYPES as LD,applyDarkModeFilter as AD}from"@excalidraw/common";import{originalContainerCache as _D,updateOriginalContainerCache as ev}from"@excalidraw/element";import{LinearElementEditor as DD}from"@excalidraw/element";import{bumpVersion as RD}from"@excalidraw/element";import{getBoundTextElementId as ND,getContainerElement as Vh,getTextElementAngle as BD,redrawTextBoundingBox as FD,getBoundTextMaxHeight as OD,getBoundTextMaxWidth as tv,computeContainerDimensionForBoundText as ov,computeBoundTextPosition as zD,getBoundTextElement as HD}from"@excalidraw/element";import{getTextWidth as GD}from"@excalidraw/element";import{normalizeText as nv}from"@excalidraw/element";import{wrapText as UD}from"@excalidraw/element";import{isArrowElement as Md,isBoundToContainer as WD,isTextElement as rv}from"@excalidraw/element";var YD=(e,o,t,n,r,i)=>{let{zoom:a}=n,l=180*t/Math.PI,s=e*(a.value-1)/2,c=o*(a.value-1)/2;return e>r&&a.value!==1&&(s=r*(a.value-1)/2),o>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},iv=({id:e,onChange:o,onSubmit:t,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let c=(D,O)=>{if(!O.style.fontFamily||!O.style.fontSize)return!1;let Q=O.style.fontFamily.replace(/"/g,"");return Jw({fontFamily:D.fontFamily})!==Q||`${D.fontSize}px`!==O.style.fontSize},m=l.state.theme,p=()=>{m=l.state.theme;let D=l.state,O=l.scene.getElement(e);if(!O)return;let{textAlign:Q,verticalAlign:ee}=O,K=l.scene.getNonDeletedElementsMap();if(O&&rv(O)){let ae=O.x,be=O.y,ce=Vh(O,l.scene.getNonDeletedElementsMap()),Oe=O.width,io=O.height,yt=O.width,Go=O.height;if(ce&&O.containerId){if(Md(ce)){let sn=DD.getBoundTextElementPosition(ce,O,K);ae=sn.x,be=sn.y}let QT=c(O,d),ca;if(QT?ca=ev(ce.id,ce.height):(ca=_D[ce.id],ca||(ca=ev(ce.id,ce.height))),yt=tv(ce,O),Go=OD(ce,O),!Md(ce)&&io>Go){let sn=ov(io,ce.type);l.scene.mutateElement(ce,{height:sn});return}else if(!Md(ce)&&ce.height>ca.height&&io<Go){let sn=ov(io,ce.type);l.scene.mutateElement(ce,{height:sn})}else{let{x:sn,y:eS}=zD(ce,O,K);ae=sn,be=eS}}let[_r,Zf]=n(ae,be);ce?Oe+=.5:(yt=(D.width-8-_r)/D.zoom.value,Oe=Math.min(Oe,yt)),io*=1.05;let JT=qw(O),$f=(D.height-Zf)/D.zoom.value;Object.assign(d.style,{font:JT,lineHeight:O.lineHeight,width:`${Oe}px`,height:`${io}px`,left:`${_r}px`,top:`${Zf}px`,transform:YD(Oe,io,BD(O,ce),D,yt,$f),textAlign:Q,verticalAlign:ee,color:D.theme===MD.DARK?AD(O.strokeColor):O.strokeColor,opacity:O.opacity/100,maxHeight:`${$f}px`}),d.scrollTop=0,Qw()&&(d.style.fontFamily=Jw(O)),l.scene.mutateElement(O,{x:ae,y:be})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let h="pre",f="normal";(WD(r)||!r.autoResize)&&(h="pre-wrap",f="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:f,whiteSpace:h,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=r.originalText,p(),o&&(d.onpaste=async D=>{let O=(await Xa(D)).findByType(LD.text);if(!O)return;let Q=nv(O.value);if(!Q)return;let ee=Vh(r,l.scene.getNonDeletedElementsMap()),K=qw({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(ee){let ae=HD(ee,l.scene.getNonDeletedElementsMap()),be=UD(`${d.value}${Q}`,K,tv(ee,ae)),ce=GD(be,K);d.style.width=`${ce}px`}},d.oninput=()=>{let D=nv(d.value);if(d.value!==D){let O=d.selectionStart;d.value=D,d.selectionStart=O,d.selectionEnd=O}o(d.value)}),d.onkeydown=D=>{if(!D.shiftKey&&rc.keyTest(D))D.preventDefault(),l.actionManager.executeAction(rc),p();else if(!D.shiftKey&&ic.keyTest(D))D.preventDefault(),l.actionManager.executeAction(ic),p();else if(!D.shiftKey&&ac.keyTest(D))D.preventDefault(),l.actionManager.executeAction(ac),p();else if(zp.keyTest(D))l.actionManager.executeAction(zp);else if(Hp.keyTest(D))l.actionManager.executeAction(Hp);else if(D.key===xl.ESCAPE)D.preventDefault(),C=!0,P();else if(lr.keyTest(D))D.preventDefault(),P(),l.actionManager.executeAction(lr);else if(D.key===xl.ENTER&&D[xl.CTRL_OR_CMD]){if(D.preventDefault(),D.isComposing||D.keyCode===229)return;C=!0,P()}else if(D.key===xl.TAB||D[xl.CTRL_OR_CMD]&&(D.code===Wh.BRACKET_LEFT||D.code===Wh.BRACKET_RIGHT)){if(D.preventDefault(),D.isComposing)return;D.shiftKey||D.code===Wh.BRACKET_LEFT?x():y(),d.dispatchEvent(new Event("input"))}};let b=4,E=" ".repeat(b),w=new RegExp(`^ {1,${b}}`),y=()=>{let{selectionStart:D,selectionEnd:O}=d,Q=v(),ee=d.value;Q.forEach(K=>{let ae=ee.slice(0,K),be=ee.slice(K);ee=`${ae}${E}${be}`}),d.value=ee,d.selectionStart=D+b,d.selectionEnd=O+b*Q.length},x=()=>{let{selectionStart:D,selectionEnd:O}=d,Q=v(),ee=[],K=d.value;Q.forEach(ae=>{let be=K.slice(ae,ae+b).match(w);if(be){let ce=K.slice(0,ae),Oe=K.slice(ae+be[0].length);K=`${ce}${Oe}`,ee.push(ae)}}),d.value=K,ee.length&&(D>ee[ee.length-1]?d.selectionStart=Math.max(D-b,ee[ee.length-1]):d.selectionStart=D,d.selectionEnd=Math.max(d.selectionStart,O-b*ee.length))},v=()=>{let{selectionStart:D,selectionEnd:O,value:Q}=d,ee=Q.slice(0,D).match(/[^\n]*$/)[0].length;return D=D-ee,Q.slice(D,O).split(`
|
|
16
|
+
`).reduce((ae,be,ce,Oe)=>ae.concat(ce?ae[ce-1]+Oe[ce-1].length+1:D),[]).reverse()},I=D=>{D.target instanceof HTMLCanvasElement&&(D.preventDefault(),D.stopPropagation())},C=!1,P=()=>{if(H)return;H=!0,k();let D=l.scene.getElement(r.id);if(!D)return;let O=Vh(D,l.scene.getNonDeletedElementsMap());if(O){if(d.value.trim()){let Q=ND(O);!Q||Q!==r.id?l.scene.mutateElement(O,{boundElements:(O.boundElements||[]).concat({type:"text",id:r.id})}):Md(O)&&RD(O)}else l.scene.mutateElement(O,{boundElements:O.boundElements?.filter(Q=>!rv(Q))});FD(D,O,l.scene)}t({viaKeyboard:C,nextOriginalText:d.value})},k=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,Y&&Y.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",I,!0),window.removeEventListener("pointerdown",L),window.removeEventListener("pointerup",N),window.removeEventListener("blur",P),window.removeEventListener("beforeunload",P),G(),B(),j(),d.remove()},N=D=>{window.removeEventListener("pointerup",N);let O=D?.target,Q=O instanceof HTMLElement&&O.classList.contains("properties-trigger"),ee=(O instanceof HTMLElement||O instanceof SVGElement)&&!!O.closest(".properties-content"),K=(O instanceof HTMLElement||O instanceof SVGElement)&&(!!O.closest(`.${Yh.SHAPE_ACTIONS_MENU}`)||!!O.closest(".compact-shape-actions-island"));setTimeout(()=>{K||Q||ee||(d.onblur=P,d.focus())})},_=()=>{d.onblur=null,window.addEventListener("pointerup",N),window.addEventListener("blur",P)},L=D=>{let O=D?.target;if(D.button===kD.WHEEL){O instanceof HTMLTextAreaElement&&(D.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(D)),_();return}let Q=O instanceof HTMLElement&&O.classList.contains("properties-trigger"),ee=(O instanceof HTMLElement||O instanceof SVGElement)&&!!O.closest(".properties-content");(D.target instanceof HTMLElement||D.target instanceof SVGElement)&&(D.target.closest(`.${Yh.SHAPE_ACTIONS_MENU}, .${Yh.ZOOM_ACTIONS}`)||D.target.closest(".compact-shape-actions-island"))&&!PD(D.target)||Q||ee?_():D.target instanceof HTMLCanvasElement&&!Qw()&&requestAnimationFrame(()=>{P()})},B=l.onChangeEmitter.on(D=>{l.state.theme!==m&&p()}),G=l.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||d.focus()}),j=l.onScrollChangeEmitter.on(()=>{p()}),H=!1;s&&d.select(),N();let Y=null;return i&&"ResizeObserver"in window?(Y=new window.ResizeObserver(()=>{p()}),Y.observe(i)):window.addEventListener("resize",p),d.onpointerdown=D=>D.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",L,{capture:!0})}),window.addEventListener("beforeunload",P),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d),P};import{getGlobalCSSVariable as Pd}from"@excalidraw/common";import{getCommonBounds as VD}from"@excalidraw/element";var rn=4,jt=6,av="rgba(0,0,0,0.3)",lv=(e,o,t,n)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,l]=VD(e),s=o/n.zoom.value,c=t/n.zoom.value,m={top:parseInt(Pd("sat"))||0,bottom:parseInt(Pd("sab"))||0,left:parseInt(Pd("sal"))||0,right:parseInt(Pd("sar"))||0},p=Uo().rtl,d=-n.scrollX+m.left,h=-n.scrollY+m.top,f=d+s-m.right,b=h+c-m.bottom,E=Math.min(r,d),w=Math.min(i,h),y=Math.max(a,f),x=Math.max(l,b),v=a-r,I=l-i,C=y-E,P=x-w,k=Math.max(rn*2,m.left+m.right)+jt*2,N=o*(s/C)-k,_=Math.max(rn*2,m.top+m.bottom)+jt*2,L=t*(c/P)-_,B=C>v?C*n.zoom.value/(N+k):o/(N+k),G=P>I?P*n.zoom.value/(L+_):t/(L+_);return{horizontal:d===E&&f===y?null:{x:Math.max(m.left,rn)+jt+(d-E)/C*o,y:t-jt-Math.max(rn,m.bottom),width:N,height:jt,deltaMultiplier:B},vertical:h===w&&b===x?null:{x:p?Math.max(m.left,rn):o-jt-Math.max(m.right,rn),y:Math.max(m.top,rn)+jt+(h-w)/P*t,width:jt,height:L,deltaMultiplier:G}}},Xh=(e,o,t)=>{let[n,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:n||r,isOverHorizontal:n,isOverVertical:r}};import{pointFrom as tR}from"@excalidraw/math";import{getElementLineSegments as oR}from"@excalidraw/element";import{LinearElementEditor as nR}from"@excalidraw/element";import{isFrameLikeElement as rR,isLinearElement as iR,isTextElement as aR}from"@excalidraw/element";import{getFrameChildren as lR}from"@excalidraw/element";import{selectGroupsForSelectedElements as sR}from"@excalidraw/element";import{getContainerElement as cR}from"@excalidraw/element";import{arrayToMap as dR,easeOut as mv,isShallowEqual as mR}from"@excalidraw/common";import{simplify as XD}from"points-on-curve";import{polygonFromPoints as KD,lineSegment as sv,polygonIncludesPointNonZero as ZD}from"@excalidraw/math";import{computeBoundTextPosition as $D,doBoundsIntersect as jD,getBoundTextElement as qD,getElementBounds as JD,intersectElementWithLineSegment as cv}from"@excalidraw/element";var dv=e=>{let{lassoPath:o,elements:t,elementsMap:n,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=XD(o,l));let c=t.filter(d=>!d.locked);a.clear(),i.clear();let m=o.reduce((d,h)=>[Math.min(d[0],h[0]),Math.min(d[1],h[1]),Math.max(d[2],h[0]),Math.max(d[3],h[1])],[1/0,1/0,-1/0,-1/0]);for(let d of c){let h=JD(d,n);jD(m,h)&&!i.has(d.id)&&!a.has(d.id)&&(QD(s,d,r)?a.add(d.id):eR(s,d,n)&&i.add(d.id))}return{selectedElementIds:[...i,...a]}},QD=(e,o,t)=>{let n=KD(e),r=t.get(o.id);return r?r.some(i=>i.some(a=>ZD(a,n))):!1},eR=(e,o,t)=>{let n=e.slice(1).map((i,a)=>sv(e[a],i)).concat([sv(e[e.length-1],e[0])]),r=qD(o,t);return n.some(i=>cv(o,t,i,0,!0).length>0||!!r&&cv({...r,...$D(o,r,t)},t,i,0,!0).length>0)};var Ld=class extends nn{constructor(t,n){super(t,n,{animateTrail:!0,streamline:.4,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/(1/0)),s=(5e3-Math.min(5e3,r.totalLength-r.currentIndex))/5e3;return Math.min(mv(s),mv(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});S(this,"intersectedElements",new Set);S(this,"enclosedElements",new Set);S(this,"elementsSegments",null);S(this,"canvasTranslate",null);S(this,"keepPreviousSelection",!1);S(this,"selectElementsFromIds",t=>{this.app.setState(n=>{let r=t.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(n.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(s);if(c&&aR(c)){let m=cR(c,this.app.scene.getNonDeletedElementsMap());m&&(r[m.id]=!0,delete r[c.id])}}for(let[s]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(s);if(c&&rR(c)){let m=lR(this.app.scene.getNonDeletedElementsMap(),c.id);for(let p of m)delete r[p.id]}}let i=sR({editingGroupId:n.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),n,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&iR(this.app.scene.getNonDeletedElement(a[0]))?new nR(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});S(this,"addPointToPath",(t,n,r=!1)=>{super.addPointToPath(t,n),this.keepPreviousSelection=r,this.updateSelection()});S(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>tR(r[0],r[1])),n={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!mR(n,this.canvasTranslate??{})){this.canvasTranslate=n,this.elementsSegments=new Map;let r=dR(this.app.visibleElements);for(let i of this.app.visibleElements){let a=oR(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=dv({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}startPath(t,n,r=!1){this.endPath(),super.startPath(t,n),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{KEYS as Kh}from"@excalidraw/common";import{jsx as pR}from"react/jsx-runtime";var pv=F({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:Qm,viewMode:!0,perform:(e,o,t,n)=>{let r={fitToViewport:!0,animate:!0,duration:200,viewportZoomFactor:.8},i=q(e,o);return i.length<1?n.scrollToContent(e,r):n.scrollToContent(i,r),{captureUpdate:uv.NEVER}},keyTest:e=>!e[Kh.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===Kh.F,PanelComponent:({data:e,updateData:o})=>pR(V,{type:"button",icon:Qm,"aria-label":g("labels.smartZoom"),onClick:()=>o(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:Kh.F.toLocaleUpperCase()})});import{arrayToMap as uR,easeOut as hv,THEME as hR}from"@excalidraw/common";import{computeBoundTextPosition as gR,doBoundsIntersect as fR,getBoundTextElement as bR,getElementBounds as ER,getElementLineSegments as xR,getFreedrawOutlineAsSegments as yR,getFreedrawOutlinePoints as wR,intersectElementWithLineSegment as gv,isArrowElement as vR,isFreeDrawElement as fv,isLineElement as IR,isPointInElement as TR}from"@excalidraw/element";import{lineSegment as SR,lineSegmentsDistance as bv,pointFrom as Iv,polygon as CR,polygonIncludesPointNonZero as kR}from"@excalidraw/math";import{getElementsInGroup as Ev}from"@excalidraw/element";import{shouldTestInside as MR}from"@excalidraw/element";import{hasBoundTextElement as xv,isBoundToContainer as yv}from"@excalidraw/element";import{getBoundTextElementId as wv}from"@excalidraw/element";var Ad=class extends nn{constructor(t,n){super(t,n,{streamline:.2,size:5,keepHead:!0,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/200),s=(10-Math.min(10,r.totalLength-r.currentIndex))/10;return Math.min(hv(s),hv(l))},fill:()=>n.state.theme===hR.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});S(this,"elementsToErase",new Set);S(this,"groupsToErase",new Set)}startPath(t,n){this.endPath(),super.startPath(t,n),this.elementsToErase.clear()}addPointToPath(t,n,r=!1){return super.addPointToPath(t,n),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let n=super.getCurrentTrail()?.originalPoints?.map(l=>Iv(l[0],l[1]))||[];if(n.length<2)return[];let r=SR(n[n.length-1],n[n.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=uR(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(vv(r,l,a,this.app.state.zoom.value)){let c=l.groupIds.at(-1);if(this.groupsToErase.has(c)){let m=Ev(this.app.scene.getNonDeletedElementsMap(),c);for(let p of m)this.elementsToErase.delete(p.id);this.groupsToErase.delete(c)}if(yv(l)&&this.elementsToErase.delete(l.containerId),xv(l)){let m=wv(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&vv(r,l,a,this.app.state.zoom.value)){let c=l.groupIds.at(-1);if(!this.groupsToErase.has(c)){let m=Ev(this.app.scene.getNonDeletedElementsMap(),c);for(let p of m)this.elementsToErase.add(p.id);this.groupsToErase.add(c)}if(xv(l)){let m=wv(l);m&&this.elementsToErase.add(m)}yv(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},vv=(e,o,t,n)=>{let r=e[1],i=fv(o)?15:o.strokeWidth/2,a=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],l=ER(o,t),s=[l[0]-i,l[1]-i,l[2]+i,l[3]+i];if(!fR(a,s))return!1;if(MR(o)&&TR(r,o,t))return!0;if(fv(o)){let m=wR(o),p=yR(o,m,t),d=Math.max(2.25,5/n);for(let f of p)if(bv(f,e)<=d)return!0;let h=CR(...m.map(([f,b])=>Iv(o.x+f,o.y+b)));return!!kR(e[0],h)}let c=bR(o,t);if(vR(o)||IR(o)&&!o.polygon){let m=Math.max(o.strokeWidth,o.strokeWidth*2/n),p=xR(o,t);for(let d of p)if(bv(d,e)<=m)return!0;return!1}return gv(o,t,e,0,!0).length>0||!!c&&gv({...c,...gR(o,c,t)},t,e,0,!0).length>0};import{jsx as qt,jsxs as Tv}from"react/jsx-runtime";var PR=()=>Tv("div",{"data-testid":"brave-measure-text-error",children:[qt("p",{children:qt(Ft,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>qt("span",{style:{fontWeight:600},children:e})})}),qt("p",{children:qt(Ft,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>qt("span",{style:{fontWeight:600},children:e})})}),qt("p",{children:qt(Ft,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>qt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),qt("p",{children:qt(Ft,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>qt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>Tv("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Sv=PR;import BR from"clsx";import FR from"react";import{useLayoutEffect as LR,useRef as Cv,useEffect as kv}from"react";import{unstable_batchedUpdates as AR}from"react-dom";import{KEYS as _R,queryFocusableElements as DR}from"@excalidraw/common";import RR from"clsx";import{jsx as NR}from"react/jsx-runtime";var Mv=({children:e,left:o,top:t,onCloseRequest:n,fitInViewport:r=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight,className:c})=>{let m=Cv(null);kv(()=>{let d=m.current;if(!d)return;d.contains(document.activeElement)||d.focus();let h=f=>{if(f.key===_R.TAB){let b=DR(d),{activeElement:E}=document,w=b.findIndex(y=>y===E);E===d?(f.shiftKey?b[b.length-1]?.focus():b[0].focus(),f.preventDefault(),f.stopImmediatePropagation()):w===0&&f.shiftKey?(b[b.length-1]?.focus(),f.preventDefault(),f.stopImmediatePropagation()):w===b.length-1&&!f.shiftKey&&(b[0]?.focus(),f.preventDefault(),f.stopImmediatePropagation())}};return d.addEventListener("keydown",h),()=>d.removeEventListener("keydown",h)},[]);let p=Cv(null);return LR(()=>{if(r&&m.current&&t!=null&&o!=null){let d=m.current,{width:h,height:f}=d.getBoundingClientRect();if(p.current?.top===t&&p.current?.left===o)return;p.current={top:t,left:o},h>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):o+h-i>l?d.style.left=`${l-h-10}px`:d.style.left=`${o}px`,f>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+f-a>s?d.style.top=`${s-f}px`:d.style.top=`${t}px`}},[t,o,r,l,s,i,a]),kv(()=>{if(n){let d=h=>{m.current?.contains(h.target)||AR(()=>n(h))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[n]),NR("div",{className:RR("popover",c),ref:m,tabIndex:-1,children:e})};import{jsx as Zi,jsxs as OR}from"react/jsx-runtime";var Ye="separator",Pv=FR.memo(({actionManager:e,items:o,top:t,left:n,onClose:r})=>{let i=vo(),a=En(),l=o.reduce((s,c)=>(c&&(c===Ye||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return Zi(Mv,{onCloseRequest:()=>{r()},top:t,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:Zi("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===Ye)return!l[c-1]||l[c-1]===Ye?null:Zi("hr",{className:"context-menu-item-separator"},c);let m=s.name,p="";return s.label&&(typeof s.label=="function"?p=g(s.label(a,i,e.app)):p=g(s.label)),Zi("li",{"data-testid":m,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:OR("button",{type:"button",className:BR("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Zi("div",{className:"context-menu-item__label",children:p}),Zi("kbd",{className:"context-menu-item__shortcut",children:m?Ae(m):""})]})},c)})})})});import{jsx as Zh,jsxs as Lv}from"react/jsx-runtime";var zR=({height:e,width:o,userToFollow:t,onDisconnect:n})=>Zh("div",{className:"follow-mode",style:{width:o,height:e},children:Lv("div",{className:"follow-mode__badge",children:[Lv("div",{className:"follow-mode__badge__label",children:["Following"," ",Zh("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),Zh("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:Ut})]})}),Av=zR;import Tr from"clsx";import zF from"react";import{CLASSES as HF,DEFAULT_SIDEBAR as Xg,TOOL_TYPE as jI,arrayToMap as GF,capitalizeString as UF,isShallowEqual as nm}from"@excalidraw/common";import{mutateElement as WF}from"@excalidraw/element";import{showSelectedShapeActions as YF}from"@excalidraw/element";import{ShapeCache as VF}from"@excalidraw/element";import{createIsolation as HR}from"jotai-scope";import $h from"react";import _o from"tunnel-rat";var jh=$h.createContext(null),Ge=()=>$h.useContext(jh),GR=HR(),_v=()=>$h.useMemo(()=>({MainMenuTunnel:_o(),WelcomeScreenMenuHintTunnel:_o(),WelcomeScreenToolbarHintTunnel:_o(),WelcomeScreenHelpHintTunnel:_o(),WelcomeScreenCenterTunnel:_o(),FooterCenterTunnel:_o(),DefaultSidebarTriggerTunnel:_o(),DefaultSidebarTabTriggersTunnel:_o(),OverwriteConfirmDialogTunnel:_o(),TTDDialogTriggerTunnel:_o(),tunnelsJotai:GR}),[]);import UR from"clsx";import{useState as WR,useEffect as YR}from"react";import{THEME as VR}from"@excalidraw/common";import{jsx as qh,jsxs as XR}from"react/jsx-runtime";var _d=({delay:e,theme:o})=>{let[t,n]=WR(!!e);return YR(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),t?null:XR("div",{className:UR("LoadingMessage",{"LoadingMessage--dark":o===VR.DARK}),children:[qh("div",{children:qh(Dt,{})}),qh("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import{useState as Rv}from"react";import yl from"clsx";import{KEYS as Nv,capitalizeString as kt}from"@excalidraw/common";import KR from"clsx";import{KEYS as Dv}from"@excalidraw/common";import{jsx as ZR}from"react/jsx-runtime";var Dd=e=>ZR(V,{className:KR("Shape",{fillable:!1,active:e.checked}),type:"radio",icon:ks,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:Dv.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":Dv.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{SHAPES as $R}from"@excalidraw/element/shapes";import{jsx as Jt,jsxs as Qh}from"react/jsx-runtime";var Jh=[{type:"selection",icon:gs,title:kt(g("toolBar.selection"))},{type:"lasso",icon:mn,title:kt(g("toolBar.lasso"))}],Bv=({app:e,onHandToolToggle:o,setAppState:t})=>{let n=e.state.activeTool,[r,i]=Rv(!1),a=(I,C)=>{e.state.activeTool.type!==I&&le("toolbar",I,"ui"),I==="selection"?e.state.activeTool.type==="selection"||e.setActiveTool({type:"selection"}):e.setActiveTool({type:I})},[l,s]=Rv(0),c=36,m=4,p=7,d=p*c+(p-1)*m,h=c+m,f=l>=d+1*h,b=l>=d+2*h,E=l>=d+3*h,w=$R.filter(I=>I.myocSimplifiedMode===!1),x=["text","frame","embeddable","laser","magicframe"].filter(I=>!(f&&I==="text"||b&&I==="image"||E&&I==="frame")).includes(n.type),v=x?n.type==="text"?un:n.type==="image"?ys:n.type==="frame"?hn:n.type==="embeddable"?ws:n.type==="laser"?Kr:n.type==="magicframe"?Y0:Xr:Xr;return Qh("div",{className:"mobile-toolbar",ref:I=>{I&&s(I.getBoundingClientRect().width)},children:[Jt(Dd,{checked:ao(e.state),onChange:o,title:g("toolBar.hand"),isMobile:!0}),Jt(ed,{app:e,options:Jh,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,namePrefix:"selectionType",title:kt(g("toolBar.selection")),"data-testid":"toolbar-selection",onToolChange:I=>{(I==="selection"||I==="lasso")&&(e.setActiveTool({type:I}),t({preferredSelectionTool:{type:I,initialized:!0}}))},displayedOption:Jh.find(I=>I.type===e.state.preferredSelectionTool.type)||Jh[0]}),Jt(V,{className:yl({active:n.type==="freedraw"}),type:"radio",icon:pn,checked:n.type==="freedraw",name:"editor-current-shape",title:`${kt(g("toolBar.freedraw"))}`,"aria-label":kt(g("toolBar.freedraw")),"data-testid":"toolbar-freedraw",onChange:()=>a("freedraw")}),f&&Jt(V,{className:yl({active:n.type==="text"}),type:"radio",icon:un,checked:n.type==="text",name:"editor-current-shape",title:`${kt(g("toolBar.text"))}`,"aria-label":kt(g("toolBar.text")),"data-testid":"toolbar-text",onChange:()=>a("text")}),b&&Jt(V,{className:yl({active:n.type==="image"}),type:"radio",icon:ys,checked:n.type==="image",name:"editor-current-shape",title:`${kt(g("toolBar.image"))}`,"aria-label":kt(g("toolBar.image")),"data-testid":"toolbar-image",onChange:()=>a("image")}),Jt(V,{className:yl({active:n.type==="eraser"}),type:"radio",icon:F1,checked:n.type==="eraser",name:"editor-current-shape",title:`${kt(g("toolBar.eraser"))}`,"aria-label":kt(g("toolBar.eraser")),"data-testid":"toolbar-eraser",onChange:()=>a("eraser")}),Qh(ge,{open:r,placement:"top",children:[Jt(ge.Trigger,{className:yl("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":x||r}),onToggle:()=>{i(!r),t({openMenu:null,openPopup:null})},title:g("toolBar.extraTools"),style:{width:c,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:v}),Qh(ge.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[w.map(({value:I,icon:C,key:P,fillable:k})=>{let N=g(`toolBar.${I}`),_=P&&kt(typeof P=="string"?P:P[0]);return Jt(ge.Item,{onSelect:()=>e.setActiveTool({type:I}),icon:C,"data-testid":`toolbar-${I}`,selected:n.type===I,shortcut:_??void 0,children:kt(N)},I)}),Jt("div",{className:"App-toolbar__dropdown-divider"}),Jt(ge.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?dn:Wo,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:Nv.Q,children:kt(g("toolBar.lock-short"))}),!f&&Jt(ge.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:un,shortcut:Nv.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:n.type==="text",children:g("toolBar.text")}),!b&&Jt(ge.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:ys,"data-testid":"toolbar-image",selected:n.type==="image",children:g("toolBar.image")})]})]})]})};import{Fragment as jR,jsx as xr,jsxs as wl}from"react/jsx-runtime";var Fv=({appState:e,elements:o,actionManager:t,setAppState:n,onHandToolToggle:r,renderTopLeftUI:i,renderTopRightUI:a,renderSidebars:l,renderWelcomeScreen:s,UIOptions:c,app:m,onPenModeToggle:p})=>{let{WelcomeScreenCenterTunnel:d}=Ge(),h=()=>xr(Bv,{app:m,onHandToolToggle:r,setAppState:n});return wl(jR,{children:[l(),xr("div",{className:"App-welcome-screen",children:s&&xr(d.Out,{})}),wl("div",{className:"App-bottom-bar-container",style:{marginBottom:jt+rn},children:[xr("div",{className:"App-bottom-bar-item",children:xr(ze,{children:wl("div",{className:"mobile-toolbar",children:[t.renderAction("viewMode"),t.renderAction("smartZoom")]})})}),!e.viewModeEnabled&&wl("div",{className:"App-bottom-bar-item",children:[xr(R2,{appState:e,elementsMap:m.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:m,setAppState:n}),wl(ze,{className:"App-toolbar",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&h(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&xr("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(f=>({...Zn(o,f)}))},children:g("buttons.scrollBackToContent")})]})]})]})]})};import qR,{useLayoutEffect as JR,useRef as QR,useState as e9}from"react";import{jsx as vl,jsxs as t9}from"react/jsx-runtime";var Ov=e=>{let o=QR(null),[t,n]=e9(null);return JR(()=>{if(!e.spreadsheet)return;let r=KE(e.chartType,e.spreadsheet,0,0);n(r);let i,a=o.current;return(async()=>(i=await Or(r,{exportBackground:!1,viewBackgroundColor:"#fff"},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),vl("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:vl("div",{ref:o})})},zv=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:n}=qe(),r=qR.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{n(l),le("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return vl(We,{size:"small",onCloseRequest:r,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:t9("div",{className:"container",children:[vl(Ov,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),vl(Ov,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import{Fragment as o9,jsx as Hv,jsxs as n9}from"react/jsx-runtime";var Il=({heading:e,children:o,...t})=>{let{id:n}=ke(),r=Hv("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:g(`headings.${e}`)});return Hv("section",{...t,"aria-labelledby":`${n}-${e}-title`,children:typeof o=="function"?o(r):n9(o9,{children:[r,o]})})};import*as Dn from"@radix-ui/react-popover";import Gv from"clsx";import Rd,{useLayoutEffect as r9}from"react";import{supportsResizeObserver as i9,isShallowEqual as a9}from"@excalidraw/common";import{Fragment as m9,jsx as Do,jsxs as Nd}from"react/jsx-runtime";var l9=4,s9=8,c9=({shouldWrap:e,children:o,username:t})=>e?Do(ct,{label:t||"Unknown user",children:o}):Do(m9,{children:o}),eg=({actionManager:e,collaborator:o,socketId:t,withName:n=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:n,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Do(c9,{username:o.username,shouldWrap:r,children:l},t)},d9=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Bd=Rd.memo(({className:e,mobile:o,collaborators:t,userToFollow:n})=>{let r=at(),i=new Map;t.forEach((b,E)=>{let w=b.id||E;i.set(w,{...b,socketId:E})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=Rd.useState(""),c=a.filter(b=>b.username?.toLowerCase().includes(l)),m=Rd.useRef(null);r9(()=>{if(m.current){let b=w=>{let y=Math.max(1,Math.min(8,Math.floor(w/38)));d(y)};if(b(m.current.clientWidth),!i9)return;let E=new ResizeObserver(w=>{for(let y of w){let{width:x}=y.contentRect;b(x)}});return E.observe(m.current),()=>{E.disconnect()}}},[]);let[p,d]=Rd.useState(l9),f=a.slice(0,p-1).map(b=>eg({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}));return o?Do("div",{className:Gv("UserList UserList_mobile",e),children:a.map(b=>eg({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}))}):Do("div",{className:"UserList__wrapper",ref:m,children:Nd("div",{className:Gv("UserList",e),style:{"--max-avatars":p},children:[f,a.length>p-1&&Nd(Dn.Root,{children:[Nd(Dn.Trigger,{className:"UserList__more",children:["+",a.length-p+1]}),Do(Dn.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Nd(ze,{padding:2,children:[a.length>=s9&&Do(Ks,{placeholder:g("quickSearch.placeholder"),onChange:s}),Do(Zs,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:c.length>0?[Do("div",{className:"hint",children:g("userList.hint.text")}),c.map(b=>eg({actionManager:r,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===n}))]:[]}),Do(Dn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[n,r]of e.collaborators){let i=o.collaborators.get(n);if(!i||n!==t.next().value||!a9(r,i,d9))return!1}return!0});import p9 from"clsx";import{jsx as Uv,jsxs as h9}from"react/jsx-runtime";var u9="medium",Wv=e=>e.penDetected?h9("label",{className:p9("ToolIcon ToolIcon__penMode",`ToolIcon_size_${u9}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Uv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Uv("div",{className:"ToolIcon__icon",children:N1})]}):null;import Tl from"clsx";import{jsx as g9}from"react/jsx-runtime";var Yv=e=>g9("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Wr});import{jsx as Ht,jsxs as tg}from"react/jsx-runtime";var Vv=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i}=Ge();return tg("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Ht("div",{className:Tl("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Ht(Tt.Col,{gap:2,children:tg(Il,{heading:"canvasActions",children:[Ht(ct,{label:g("labels.viewMode"),children:Ht("div",{className:Tl("view-mode-button"),children:o.renderAction("viewMode")})}),Ht(ct,{label:g("buttons.smartZoom"),children:Ht("div",{className:Tl("smart-zoom-button"),children:o.renderAction("smartZoom")})}),Ht(B2,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Ht(F2,{renderAction:o.renderAction,className:Tl("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Ht(r.Out,{}),Ht("div",{className:Tl("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:tg("div",{style:{position:"relative"},children:[n&&Ht(i.Out,{}),Ht(Yv,{onClick:()=>o.executeAction(sr)})]})}),Ht(O2,{actionManager:o,showExitZenModeBtn:t})]})},Xv=Vv;Vv.displayName="Footer";import I9 from"clsx";import{useEffect as n3,useLayoutEffect as r3,useRef as dg,useState as T9,forwardRef as i3,useImperativeHandle as S9,useCallback as e3}from"react";import{CLASSES as C9,EVENT as t3,isDevEnv as k9,KEYS as M9,updateObject as P9}from"@excalidraw/common";import b9 from"clsx";import{useContext as E9}from"react";import f9 from"react";var Fd=f9.createContext({});import{jsx as og,jsxs as Kv}from"react/jsx-runtime";var ng=({children:e,className:o})=>{let t=de(),n=E9(Fd),r=!!(t.canFitSidebar&&n.shouldRenderDockButton);return Kv("div",{className:b9("sidebar__header",o),"data-testid":"sidebar-header",children:[e,Kv("div",{className:"sidebar__header__buttons",children:[r&&og(ct,{label:g("labels.sidebarLock"),children:og(Ot,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:P1})}),og(Ot,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":g("buttons.close"),children:Ut})]})]})};ng.displayName="SidebarHeader";import*as $v from"@radix-ui/react-tabs";import{jsx as Zv}from"react/jsx-runtime";var rg=({children:e,tab:o,onSelect:t,...n})=>Zv($v.Trigger,{value:o,asChild:!0,onSelect:t,children:Zv("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...n,children:e})});rg.displayName="SidebarTabTrigger";import*as jv from"@radix-ui/react-tabs";import{jsx as x9}from"react/jsx-runtime";var ig=({children:e,...o})=>x9(jv.List,{className:"sidebar-triggers",...o,children:e});ig.displayName="SidebarTabTriggers";import y9 from"clsx";import{jsx as ag,jsxs as qv}from"react/jsx-runtime";var lg=({name:e,tab:o,icon:t,title:n,children:r,onToggle:i,className:a,style:l})=>{let s=he(),c=Te();return qv("label",{title:n,className:"sidebar-trigger__label-element",children:[ag("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let p=m.target.checked;s({openSidebar:p?{name:e,tab:o}:null,openMenu:null,openPopup:null}),i?.(p)},checked:c.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),qv("div",{className:y9("sidebar-trigger",a),style:l,children:[t&&ag("div",{children:t}),r&&ag("div",{className:"sidebar-trigger__label",children:r})]})]})};lg.displayName="SidebarTrigger";import*as Jv from"@radix-ui/react-tabs";import{jsx as w9}from"react/jsx-runtime";var sg=({children:e,...o})=>{let t=Te(),n=he();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return w9(Jv.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>n(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...o,children:e})};sg.displayName="SidebarTabs";import*as Qv from"@radix-ui/react-tabs";import{jsx as v9}from"react/jsx-runtime";var cg=({tab:e,children:o,...t})=>v9(Qv.Content,{...t,value:e,"data-testid":e,children:o});cg.displayName="SidebarTab";import{jsx as o3}from"react/jsx-runtime";import{createElement as L9}from"react";var Sl=Se(!1),a3=i3(({name:e,children:o,onDock:t,docked:n,className:r,...i},a)=>{k9()&&t&&n==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=he(),s=Hr(Sl);r3(()=>(s(!!n),()=>{s(!1)}),[s,n]);let c=dg({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=h=>t?.(h),c.current=P9(c.current,{docked:n,shouldRenderDockButton:!!t&&n!=null});let m=dg(null);S9(a,()=>m.current);let p=de(),d=e3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return ei(m,e3(h=>{h.target.closest(".sidebar-trigger")||(!n||!p.canFitSidebar)&&d()},[d,n,p.canFitSidebar])),n3(()=>{let h=f=>{f.key===M9.ESCAPE&&(!n||!p.canFitSidebar)&&d()};return document.addEventListener(t3.KEYDOWN,h),()=>{document.removeEventListener(t3.KEYDOWN,h)}},[d,n,p.canFitSidebar]),o3(ze,{...i,className:I9(C9.SIDEBAR,{"sidebar--docked":n},r),ref:m,children:o3(Fd.Provider,{value:c.current,children:o})})});a3.displayName="SidebarInner";var Qt=Object.assign(i3((e,o)=>{let t=Te(),{onStateChange:n}=e,r=dg(t.openSidebar);n3(()=>{(!t.openSidebar&&r?.current?.name===e.name||t.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&t.openSidebar!==r.current&&n?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,n,e.name]);let[i,a]=T9(!1);return r3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?L9(a3,{...e,ref:o,key:e.name}):null}),{Header:ng,TabTriggers:ig,TabTrigger:rg,Tabs:sg,Tab:cg,Trigger:lg});Qt.displayName="Sidebar";import{composeEventHandlers as z9}from"@excalidraw/common";import{useLayoutEffect as A9,useRef as _9}from"react";import{jsx as D9}from"react/jsx-runtime";var yr=(e,o)=>{let t=Se(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=Ge(),[,a]=i(t),l=_9({preferHost:!1,counter:0});return A9(()=>{let s=l.current;return a(c=>{let m=c+1;return s.counter=m,m}),()=>{a(c=>{let m=c-1;return s.counter=m,m||(s.preferHost=!1),m})}},[a]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:D9(o,{...r})};return n.displayName=e,n};var ug={};qf(ug,{ChangeCanvasBackground:()=>x3,CommandPalette:()=>g3,Export:()=>y3,Help:()=>b3,LiveCollaborationTrigger:()=>v3,LoadScene:()=>p3,SaveAsImage:()=>h3,SaveToActiveFile:()=>u3,SearchMenu:()=>f3,Socials:()=>w3,ToggleTheme:()=>E3});import F9 from"clsx";import{THEME as Rn}from"@excalidraw/common";var mg=Se({active:!1});async function l3({title:e,description:o,actionLabel:t,color:n}){return new Promise(r=>{$e.set(mg,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:o,actionLabel:t,color:n})})}import R9 from"clsx";import{jsx as s3,jsxs as N9}from"react/jsx-runtime";var Od=function({onChange:e,value:o,choices:t,name:n}){return s3("div",{className:"RadioGroup",children:t.map(r=>N9("div",{className:R9("RadioGroup__choice",{active:r.value===o}),title:r.ariaLabel,children:[s3("input",{name:n,type:"radio",checked:r.value===o,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as B9,jsx as pg,jsxs as c3}from"react/jsx-runtime";var d3=({value:e,shortcut:o,onChange:t,choices:n,children:r,name:i})=>{let a=de();return c3(B9,{children:[c3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[pg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:r}),pg(Od,{name:i,value:e,onChange:t,choices:n})]}),o&&a.formFactor!=="phone"&&pg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};d3.displayName="DropdownMenuItemContentRadio";var m3=d3;import{Fragment as O9,jsx as et,jsxs as I3}from"react/jsx-runtime";var p3=()=>{let{t:e}=Ue(),o=at(),t=En();return o.isActionEnabled(gi)?et(vt,{icon:Yr,onSelect:async()=>{(!t.length||await l3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:et(Ft,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>et("strong",{children:r}),br:()=>et("br",{})})}))&&o.executeAction(gi)},"data-testid":"load-button",shortcut:Ae("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};p3.displayName="LoadScene";var u3=()=>{let{t:e}=Ue(),o=at();return o.isActionEnabled(lr)?et(vt,{shortcut:Ae("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(lr),icon:V1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};u3.displayName="SaveToActiveFile";var h3=()=>{let e=he(),{t:o}=Ue();return et(vt,{icon:Is,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Ae("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};h3.displayName="SaveAsImage";var g3=e=>{let o=he(),{t}=Ue();return et(vt,{icon:va,"data-testid":"command-palette-button",onSelect:()=>{le("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Ae("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};g3.displayName="CommandPalette";var f3=e=>{let{t:o}=Ue(),t=at();return et(vt,{icon:_t,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(dl)},shortcut:Ae("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};f3.displayName="SearchMenu";var b3=()=>{let{t:e}=Ue(),o=at();return et(vt,{"data-testid":"help-menu-item",icon:Wr,onSelect:()=>o.executeAction(sr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};b3.displayName="Help";var E3=e=>{let{t:o}=Ue(),t=Te(),n=at(),r=Ae("toggleTheme");return n.isActionEnabled(nr)?e?.allowSystemTheme?et(m3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:Rn.LIGHT,label:xa,ariaLabel:`${o("buttons.lightMode")} - ${r}`},{value:Rn.DARK,label:Ea,ariaLabel:`${o("buttons.darkMode")} - ${r}`},{value:"system",label:rb,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):et(vt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===Rn.DARK?Rn.LIGHT:Rn.DARK);else return n.executeAction(nr)},icon:t.theme===Rn.DARK?xa:Ea,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===Rn.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===Rn.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};E3.displayName="ToggleTheme";var x3=()=>{let{t:e}=Ue(),o=Te(),t=at(),n=Io();return o.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:I3("div",{style:{marginTop:"0.5rem"},children:[et("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),et("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};x3.displayName="ChangeCanvasBackground";var y3=()=>{let{t:e}=Ue(),o=he();return et(vt,{icon:qn,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};y3.displayName="Export";var w3=()=>{let{t:e}=Ue();return I3(O9,{children:[et(Bi,{icon:G1,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),et(Bi,{icon:W1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),et(Bi,{icon:U1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};w3.displayName="Socials";var v3=({onSelect:e,isCollaborating:o})=>{let{t}=Ue();return et(vt,{"data-testid":"collab-button",icon:Ts,className:F9({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};v3.displayName="LiveCollaborationTrigger";import{jsx as zd,jsxs as hg}from"react/jsx-runtime";var H9=Object.assign(yr("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ge(),n=de(),r=Te(),i=he();return zd(t.In,{children:hg(ge,{open:r.openMenu==="canvas",children:[zd(ge.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:z1}),hg(ge.Content,{onClickOutside:()=>i({openMenu:null}),onSelect:z9(o,()=>{i({openMenu:null})}),placement:"bottom",className:n.formFactor==="phone"?"main-menu-dropdown":"",children:[e,n.formFactor==="phone"&&r.collaborators.size>0&&hg("fieldset",{className:"UserList-Wrapper",children:[zd("legend",{children:g("labels.collaborators")}),zd(Bd,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:ge.Trigger,Item:ge.Item,ItemLink:ge.ItemLink,ItemCustom:ge.ItemCustom,Group:ge.Group,Separator:ge.Separator,DefaultItems:ug}),bt=H9;import G9 from"clsx";import{forwardRef as U9,useState as W9}from"react";import{isPromiseLike as Y9}from"@excalidraw/common";import{jsx as Hd,jsxs as V9}from"react/jsx-runtime";var Nn=U9(({children:e,icon:o,onClick:t,label:n,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:c,disabled:m},p)=>{let[d,h]=W9(!1),f=async E=>{let w=t?.(E);if(Y9(w)){let y=window.setTimeout(()=>{h(!0)},50);try{await w}catch(x){if(x instanceof Nr)console.warn(x);else throw x}finally{clearTimeout(y),h(!1)}}},b=d?"loading":c;return i=b==="success"?"success":i,Hd("button",{className:G9("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${b}`,{"ExcButton--fullWidth":l},s),onClick:f,type:"button","aria-label":n,ref:p,disabled:m||b==="loading"||b==="success",children:V9("div",{className:"ExcButton__contents",children:[b==="loading"?Hd(Dt,{className:"ExcButton__statusIcon"}):b==="success"&&Hd("div",{className:"ExcButton__statusIcon",children:G0}),o&&Hd("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),r!=="icon"&&(e??n)]})})});import{jsx as $i,jsxs as Z9}from"react/jsx-runtime";var Gd=({title:e,children:o,actionLabel:t,onClick:n})=>Z9("div",{className:"OverwriteConfirm__Actions__Action",children:[$i("h4",{children:e}),$i("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),$i(Nn,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:n})]}),X9=()=>{let{t:e}=Ue(),o=at(),t=he();return $i(Gd,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(bc,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},K9=()=>{let{t:e}=Ue(),o=at();return $i(Gd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Ka,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},gg=Object.assign(({children:e})=>$i("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:X9,SaveToDisk:K9});import{jsx as Bn,jsxs as T3}from"react/jsx-runtime";var Ud=Object.assign(yr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ge(),[t,n]=ue(mg);if(!t.active)return null;let r=()=>{t.onClose(),n(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),n(a=>({...a,active:!1}))};return Bn(o.In,{children:Bn(We,{onCloseRequest:r,title:!1,size:916,children:T3("div",{className:"OverwriteConfirm",children:[Bn("h3",{children:t.title}),T3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Bn("div",{className:"OverwriteConfirm__Description__icon",children:U0}),Bn("div",{children:t.description}),Bn("div",{className:"OverwriteConfirm__Description__spacer"}),Bn(Nn,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Bn(gg,{children:e})]})})})}),{Actions:gg,Action:Gd});import fN from"clsx";import{CANVAS_SEARCH_TAB as yg,DEFAULT_SIDEBAR as bN,LIBRARY_SIDEBAR_TAB as R3,composeEventHandlers as EN}from"@excalidraw/common";import{round as $9}from"@excalidraw/math";import j9 from"clsx";import q9 from"lodash.debounce";import{Fragment as J9,memo as Q9,useEffect as Cl,useMemo as S3,useRef as fg,useState as C3}from"react";import{CLASSES as eN,EVENT as tN,FONT_FAMILY as bg,FRAME_STYLE as Eg,getLineHeight as oN}from"@excalidraw/common";import{isElementCompletelyInViewport as nN}from"@excalidraw/element";import{measureText as kl}from"@excalidraw/element";import{KEYS as ji,randomInteger as k3,addEventListener as rN,getFontString as Wd}from"@excalidraw/common";import{newTextElement as iN}from"@excalidraw/element";import{isTextElement as A3,isFrameLikeElement as Yd}from"@excalidraw/element";import{getDefaultFrameName as _3}from"@excalidraw/element/frame";import{Fragment as gN,jsx as tt,jsxs as Ro}from"react/jsx-runtime";var aN=Se(""),xg=Se(null),lN=350,D3=()=>{let e=qe(),o=he(),t=fg(null),[n,r]=ue(aN),i=n.trim(),[a,l]=C3(!1),[s,c]=C3({nonce:null,items:[]}),m=fg(null),p=fg(void 0),[d,h]=ue(xg),f=e.scene.getNonDeletedElementsMap();Cl(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==p.current)&&(m.current=null,L3(i,e,(x,v)=>{c({nonce:k3(),items:x}),m.current=i,p.current=e.scene.getSceneNonce(),o({searchMatches:x.length?{focusedId:null,matches:x.map(I=>({id:I.element.id,focus:!1,matchedLines:I.matchedLines}))}:null})}))},[a,i,f,e,o,h,p]);let b=()=>{s.items.length>0&&h(x=>x===null?0:(x+1)%s.items.length)},E=()=>{s.items.length>0&&h(x=>x===null?0:x-1<0?s.items.length-1:x-1)};Cl(()=>{o(x=>x.searchMatches?{searchMatches:{focusedId:d!==null&&x.searchMatches?.matches[d]?.id||null,matches:x.searchMatches.matches.map((I,C)=>C===d?{...I,focus:!0}:{...I,focus:!1})}}:null)},[d,o]),Cl(()=>{if(s.items.length>0&&d!==null){let x=s.items[d];if(x){let v=e.state.zoom.value,I=iN({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:Yd(x.element)?Eg.nameFontSize:x.element.fontSize,fontFamily:Yd(x.element)?bg.Assistant:x.element.fontFamily}),C=14,P=I.fontSize,k=P*v<C;if(!nN([I],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||k){let N;k?P>=C?N={fitToContent:!0}:N={fitToViewport:!0,maxZoom:$9(C/P,1)}:N={fitToContent:!0},e.scrollToContent(I,{animate:!0,duration:300,...N,canvasOffsets:e.getEditorUIOffsets()})}}}},[d,s,e]),Cl(()=>()=>{h(null),m.current=null,p.current=void 0,o({searchMatches:null}),l(!1)},[o,h]);let w=gn({goToNextItem:b,goToPreviousItem:E,searchMatches:s});Cl(()=>{let x=v=>{if(v.key===ji.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[ji.CTRL_OR_CMD]&&v.key===ji.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(v.key===ji.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===ji.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===ji.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return rN(window,tN.KEYDOWN,x,{capture:!0,passive:!1})},[o,w,e]);let y=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return Ro("div",{className:"layer-ui__search",children:[tt("div",{className:"layer-ui__search-header",children:tt(Pn,{className:eN.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:t,placeholder:g("search.placeholder"),icon:_t,onChange:x=>{r(x),l(!0);let v=x.trim();L3(v,e,(I,C)=>{c({nonce:k3(),items:I}),h(C),m.current=v,p.current=e.scene.getSceneNonce(),o({searchMatches:I.length?{focusedId:null,matches:I.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),Ro("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Ro(gN,{children:[d!==null&&d>-1?Ro("div",{children:[d+1," / ",y]}):tt("div",{children:y}),Ro("div",{className:"result-nav",children:[tt(Ot,{onSelect:()=>{b()},className:"result-nav-btn",children:Ps}),tt(Ot,{onSelect:()=>{E()},className:"result-nav-btn",children:sb})]})]}),s.items.length===0&&i&&m.current&&tt("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),tt(dN,{matches:s,onItemClick:h,focusIndex:d,searchQuery:i})]})},M3=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return tt("div",{tabIndex:-1,className:j9("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:tt("div",{className:"preview-text",children:o.flatMap((t,n)=>tt(J9,{children:n===2?tt("b",{children:t}):t},n))})})},sN=e=>{let o=S3(()=>e.matches.items.filter(n=>Yd(n.element)),[e.matches]),t=S3(()=>e.matches.items.filter(n=>A3(n.element)),[e.matches]);return Ro("div",{children:[o.length>0&&Ro("div",{className:"layer-ui__search-result-container",children:[Ro("div",{className:"layer-ui__search-result-title",children:[tt("div",{className:"title-icon",children:hn}),tt("div",{children:g("search.frames")})]}),o.map((n,r)=>tt(M3,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),t.length>0&&tt("div",{className:"layer-ui__divider"})]}),t.length>0&&Ro("div",{className:"layer-ui__search-result-container",children:[Ro("div",{className:"layer-ui__search-result-title",children:[tt("div",{className:"title-icon",children:un}),tt("div",{children:g("search.texts")})]}),t.map((n,r)=>tt(M3,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+o.length===e.focusIndex,onClick:()=>e.onItemClick(r+o.length)},n.element.id+n.index))]})]})},cN=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,dN=Q9(sN,cN),P3=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),c=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;c=c.length>m?c.slice(-m):c;let p=e.slice(o+t.length),d=p.split(/\s+/),h=!p.startsWith(" "),f=h?6:5,b=(h?"":" ")+d.slice(0,f).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+b,moreBefore:s>0,moreAfter:d.length>f}},mN=(e,o)=>{let t=e.split(`
|
|
17
17
|
`),n=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=o.indexOf(l,r);if(s>a.length+r){let c=s-(a.length+r);for(;c>0;)a+=" ",c--}}n.push(a),r=r+a.length}return n.join(`
|
|
18
18
|
`)},pN=(e,o,t)=>{let r=mN(e.text,e.originalText).split(`
|
|
19
|
-
`),i=[],a=0,l=0;for(let p of r){let d=a,h=d+p.length-1;i.push({line:p,startIndex:d,endIndex:h,lineNumber:l}),a=h+1,l++}let s=t,c=e.originalText.slice(t,t+o.length),m=[];for(let p of i){if(c==="")break;if(s>=p.startIndex&&s<=p.endIndex){let d=p.endIndex+1-s,h=p.line.slice(0,s-p.startIndex),f=c.slice(0,d);c=c.slice(d);let b=Nl(h,Kd(e),e.lineHeight);if(h===""&&(b.width=0),e.textAlign!=="left"&&p.line.length>0){let v=Nl(p.line,Kd(e),e.lineHeight),I=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=I}let{width:E,height:w}=Nl(f,Kd(e),e.lineHeight),y=b.width,x=p.lineNumber*b.height;m.push({offsetX:y,offsetY:x,width:E,height:w,showOnCanvas:!0}),s+=d}}return m},uN=(e,o,t,n)=>{let r=e.name??B3(e),i=r.slice(t,t+o.length),a=r.slice(0,t),l=Kd({fontSize:Ig.nameFontSize,fontFamily:vg.Assistant}),s=oN(vg.Assistant),c=Nl(a,l,s);a===""&&(c.width=0);let m=Nl(i,l,s),p=c.width,d=-c.height-Ig.strokeWidth,h=m.width;return[{offsetX:p,offsetY:d,width:h,height:m.height,showOnCanvas:p+h<=e.width*n}]},hN=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),R3=q9((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(d=>N3(d)),i=n.filter(d=>Zd(d));r.sort((d,h)=>d.y-h.y),i.sort((d,h)=>d.y-h.y);let a=[],l=new RegExp(hN(e),"gi");for(let d of r){let h=null,f=d.originalText;for(;(h=l.exec(f))!==null;){let b=D3(f,h.index,e),E=pN(d,e,h.index);E.length>0&&a.push({element:d,searchQuery:e,preview:b,index:h.index,matchedLines:E})}}let s=[];for(let d of i){let h=null,f=d.name??B3(d);for(;(h=l.exec(f))!==null;){let b=D3(f,h.index,e),E=uN(d,e,h.index,o.state.zoom.value);E.length>0&&s.push({element:d,searchQuery:e,preview:b,index:h.index,matchedLines:E})}}let c=new Set(o.visibleElements.map(d=>d.id)),m=[...s,...a],p=m.findIndex(d=>c.has(d.element.id))??null;t(m,p)},lN);import{jsx as fo,jsxs as z3}from"react/jsx-runtime";import{createElement as xN}from"react";var H3=Ir("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ge();return fo(o.In,{children:fo(eo.Trigger,{...e,className:"default-sidebar-trigger",name:bN.name})})});H3.displayName="DefaultSidebarTrigger";var G3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Ge();return fo(o.In,{children:e})};G3.displayName="DefaultTabTriggers";var $d=Object.assign(Ir("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=Te(),a=he(),{DefaultSidebarTabTriggersTunnel:l}=Ge(),s=i.openSidebar?.tab===Sg;return xN(eo,{...r,name:"default",key:"default",className:fN("default-sidebar",o),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&n!=null?void 0:EN(t,c=>{a({defaultSidebarDockedPreference:c})})},z3(eo.Tabs,{children:[fo(eo.Header,{children:z3(eo.TabTriggers,{children:[fo(eo.TabTrigger,{tab:Sg,children:_t}),fo(eo.TabTrigger,{tab:O3,children:vs}),fo(l.Out,{})]})}),fo(eo.Tab,{tab:O3,children:fo(E2,{})}),fo(eo.Tab,{tab:Sg,children:fo(F3,{})}),e]}))}),{Trigger:H3,TabTriggers:G3});import{round as MI}from"@excalidraw/math";import DB from"clsx";import RB from"lodash.throttle";import{useEffect as PI,useMemo as zg,useState as NB,memo as BB}from"react";import{STATS_PANELS as nm}from"@excalidraw/common";import{getCommonBounds as FB}from"@excalidraw/element";import{getUncroppedWidthAndHeight as OB}from"@excalidraw/element";import{isImageElement as Hg}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as zB}from"@excalidraw/element";import{elementsAreInSameGroup as HB}from"@excalidraw/element";import{degreesToRadians as $3,radiansToDegrees as Q3}from"@excalidraw/math";import{getBoundTextElement as j3}from"@excalidraw/element";import{isArrowElement as q3,isElbowArrow as _N}from"@excalidraw/element";import{updateBindings as J3}from"@excalidraw/element";import CN from"clsx";import{useEffect as K3,useRef as qd,useState as kN}from"react";import{EVENT as la,KEYS as MN,cloneJSON as Cg}from"@excalidraw/common";import{deepCopyElement as PN}from"@excalidraw/element";import{CaptureUpdateAction as Z3}from"@excalidraw/element";import{pointFrom as zn,pointRotateRads as jd}from"@excalidraw/math";import{getBoundTextElement as yN,isBindingElement as wN,unbindBindingElement as U3}from"@excalidraw/element";import{isFrameLikeElement as V3}from"@excalidraw/element";import{getSelectedGroupIds as vN,getElementsInGroup as IN,isInGroup as TN}from"@excalidraw/element";import{getFrameChildren as SN}from"@excalidraw/element";import{updateBindings as W3}from"@excalidraw/element";import{DRAGGING_THRESHOLD as Y3}from"@excalidraw/common";var X3=.01,Bl=10,Mt=(e,o)=>!(o==="angle"&&V3(e)),_e=(e,o)=>{let t=e+o/2;return t-t%o},ia=(e,o,t)=>Object.keys(e).map(n=>({original:(t??o).get(n),latest:o.get(n)})).filter(n=>n.original!==void 0&&n.latest!==void 0);var Tr=(e,o,t,n,r,i,a=!0)=>{if(wN(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<Y3&&Math.abs(o-t.y)<Y3)return;U3(t,"start",n),U3(t,"end",n)}let l=n.getNonDeletedElementsMap(),s=l.get(t.id);if(!s)return;let[c,m]=[t.x+t.width/2,t.y+t.height/2],[p,d]=jd(zn(t.x,t.y),zn(c,m),t.angle),h=e-p,f=o-d,[b,E]=jd(zn(e,o),zn(c+h,m+f),-t.angle);n.mutateElement(s,{x:b,y:E},{informMutation:a,isDragging:!1}),W3(s,n,r);let w=yN(t,i);if(w){let y=l.get(w.id);y&&n.mutateElement(y,{x:w.x+h,y:w.y+f},{informMutation:a,isDragging:!1})}if(V3(t)){let y=SN(i,t.id);y.forEach(x=>{let v=l.get(x.id);if(!v)return;let[I,C]=[x.x+x.width/2,x.y+x.height/2],[P,k]=jd(zn(x.x,x.y),zn(I,C),x.angle),N=Math.round(P+h),_=Math.round(k+f),[L,B]=jd(zn(N,_),zn(I+h,C+f),-x.angle);n.mutateElement(v,{x:L,y:B},{informMutation:a,isDragging:!1}),W3(v,n,r,{simultaneouslyUpdated:y})})}},aa=(e,o)=>{let n=vN(o).map(r=>IN(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!TN(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as kg,jsxs as AN}from"react/jsx-runtime";var LN=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:m=1,dragFinishedCallback:p})=>{let d=qe(),h=he(),f=qd(null),b=qd(null),[E,w]=kN(n.toString()),y=qd(null);y.current||(y.current={originalAppState:Cg(c),originalElements:r,lastUpdatedValue:E,updatePending:!1}),K3(()=>{let I=n.toString();w(I),y.current.lastUpdatedValue=I},[n]);let x=(I,C,P)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let k=Number(I);if(isNaN(k)){w(n.toString());return}let N=Number(k.toFixed(2)),_=Number(n);(isNaN(_)||Math.abs(N-_)>=X3)&&(y.current.lastUpdatedValue=I,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:N,property:l,originalAppState:P,setInputValue:L=>w(String(L)),app:d,setAppState:h}),d.syncActionResult({captureUpdate:Z3.IMMEDIATELY}))},v=qd({});return v.current.handleInputValue=x,K3(()=>{let I=f.current,C=v.current;return()=>{let P=I?.value;P&&C.handleInputValue?.(P,y.current.originalElements,y.current.originalAppState),window.removeEventListener(la.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(la.POINTER_UP,C.onPointerUp,!1)}},[i]),i?AN("div",{className:CN("drag-input-container",!i&&"disabled"),"data-testid":e,children:[kg("div",{className:"drag-input-label",ref:b,onPointerDown:I=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(f.current.value);isNaN(C)&&(C=0);let P=null,k=d.scene.getNonDeletedElements().reduce((H,Y)=>(H.set(Y.id,PN(Y)),H),new Map),N=r.map(H=>k.get(H.id)),_=Cg(c),L=0,B=0,G=H=>{if(P&&k!==null&&N!==null){let Y=H.clientX-P.x;Y!==0&&(B+=Y,Math.abs(B)>=m&&(B=Math.sign(B)*Math.floor(Math.abs(B)/m),L+=B,t({accumulatedChange:L,instantChange:B,originalElements:N,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:H.shiftKey,property:l,scene:s,originalAppState:_,setInputValue:D=>w(String(D)),app:d,setAppState:h}),B=0))}P={x:H.clientX,y:H.clientY}},j=()=>{window.removeEventListener(la.POINTER_MOVE,G,!1),d.syncActionResult({captureUpdate:Z3.IMMEDIATELY}),p?.({app:d,setAppState:h,originalElements:N,originalAppState:_}),P=null,L=0,B=0,N=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(la.POINTER_UP,j,!1)};v.current.onPointerMove=G,v.current.onPointerUp=j,window.addEventListener(la.POINTER_MOVE,G,!1),window.addEventListener(la.POINTER_UP,j,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?kg(fi,{icon:o}):e}),kg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:I=>{if(i){let C=I.target;C instanceof HTMLInputElement&&I.key===MN.ENTER&&(x(C.value,r,c),d.focusContainer())}},ref:f,value:E,onChange:I=>{y.current.updatePending=!0,w(I.target.value)},onFocus:I=>{I.target.select(),y.current.originalElements=r,y.current.originalAppState=Cg(c)},onBlur:I=>{E?i&&x(I.target.value,y.current.originalElements,y.current.originalAppState):w(n.toString())},disabled:!i})]}):null},ot=LN;import{jsx as BN}from"react/jsx-runtime";var DN=15,RN=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),l=o[0];if(l&&!_N(l)){let s=a.get(l.id);if(!s)return;if(n!==void 0){let f=$3(n);r.mutateElement(s,{angle:f}),J3(s,r,i.state);let b=j3(s,a);b&&!q3(s)&&r.mutateElement(b,{angle:f});return}let c=Math.round(Q3(l.angle)*100)/100,m=Math.round(e),p=(c+m)%360;t&&(p=_e(p,DN)),p=p<0?p+360:p;let d=$3(p);r.mutateElement(s,{angle:d}),J3(s,r,i.state);let h=j3(s,a);h&&!q3(s)&&r.mutateElement(h,{angle:d})}},NN=({element:e,scene:o,appState:t,property:n})=>BN(ot,{label:"A",icon:Ls,value:Math.round(Q3(e.angle)%360*100)/100,elements:[e],dragInputCallback:RN,editable:Mt(e,"angle"),scene:o,appState:t,property:n}),eI=NN;import{jsx as ON}from"react/jsx-runtime";var tI=5,FN=({property:e,scene:o,appState:t,setAppState:n})=>ON(ot,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{n(s=>{let c;return r?c=r:i&&(c=a?_e(s.gridStep+tI*Math.sign(i),tI):s.gridStep+i),c?(c=i1(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),oI=FN;import{clamp as Jd,round as Mg}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Qd}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as nI,getUncroppedWidthAndHeight as aI}from"@excalidraw/element";import{resizeSingleElement as rI}from"@excalidraw/element";import{isImageElement as lI}from"@excalidraw/element";import{isFrameLikeElement as Pg}from"@excalidraw/element";import{getElementsInResizingFrame as Lg}from"@excalidraw/element";import{replaceAllElementsInFrame as sI}from"@excalidraw/element";import{jsx as WN}from"react/jsx-runtime";var iI=10,zN=e=>e.type==="image",HN=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:c,app:m,setAppState:p})=>{let d=c.getNonDeletedElementsMap(),h=o[0],f=d.get(h.id);if(h&&f){let b=n||zN(h),E=h.width/h.height;if(l.croppingElementId===h.id){let w=d.get(h.id);if(!w||!lI(w)||!w.crop)return;let y=w.crop,x={...y},v=w.scale[0]===-1,I=w.scale[1]===-1,{width:C,height:P}=aI(w),k=y.naturalWidth/C,N=y.naturalHeight/P,_=v?y.width+y.x:y.naturalWidth-y.x,L=I?y.height+y.y:y.naturalHeight-y.y,B=nI*k,G=nI*N;if(i!==void 0){if(a==="width"){let O=i*k,Q=Jd(O,B,_);x={...x,width:Q,x:v?y.x+y.width-Q:y.x}}else if(a==="height"){let O=i*N,Q=Jd(O,G,L);x={...x,height:Q,y:I?y.y+y.height-Q:y.y}}c.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}let j=a==="width"?s:0,H=a==="height"?s:0,Y=Jd(y.width+j,B,_),D=Jd(y.height+H,B,L);x={...y,x:v?y.x+y.width-Y:y.x,y:I?y.y+y.height-D:y.y,width:Y,height:D},c.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}if(i!==void 0){let w=Math.max(a==="width"?i:b?i*E:h.width,Qd),y=Math.max(a==="height"?i:b?i/E:h.height,Qd);if(rI(w,y,f,h,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Pg(f)){let x=Lg(c.getElementsIncludingDeleted(),f,l,c.getNonDeletedElementsMap()),v=sI(c.getElementsIncludingDeleted(),x,f,m);c.replaceAllElements(v)}return}{let w=a==="width"?e:0,y=a==="height"?e:0,x=Math.max(0,h.width+w);a==="width"&&(r?x=_e(x,iI):x=Math.round(x));let v=Math.max(0,h.height+y);if(a==="height"&&(r?v=_e(v,iI):v=Math.round(v)),b&&(a==="width"?v=Math.round(x/E*100)/100:x=Math.round(v*E*100)/100),v=Math.max(Qd,v),x=Math.max(Qd,x),rI(x,v,f,h,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Pg(f)){let I=Lg(c.getElementsIncludingDeleted(),f,l,c.getNonDeletedElementsMap());p({elementsToHighlight:I})}}}},GN=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Pg(a)){let l=Lg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=sI(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},UN=({property:e,element:o,scene:t,appState:n})=>{let r=Mg(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&lI(o)&&o.crop){let{width:i,height:a}=aI(o);if(e==="width"){let l=i/o.crop.naturalWidth;r=Mg(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;r=Mg(o.crop.height*l,2)}}return WN(ot,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:HN,value:r,editable:Mt(o,e),scene:t,appState:n,property:e,dragFinishedCallback:GN})},Ag=UN;import{getBoundTextElement as YN,redrawTextBoundingBox as VN}from"@excalidraw/element";import{hasBoundTextElement as XN,isTextElement as dI}from"@excalidraw/element";import{jsx as jN}from"react/jsx-runtime";var cI=4,KN=4,ZN=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!dI(l))return;let s;if(n!==void 0)s=Math.max(Math.round(n),cI);else if(a.type==="text"){let c=Math.round(a.fontSize),m=Math.round(e);s=Math.max(c+m,cI),t&&(s=_e(s,KN))}s&&(r.mutateElement(l,{fontSize:s}),VN(l,r.getContainerElement(l),r))}},$N=({element:e,scene:o,appState:t,property:n})=>{let r=dI(e)?e:XN(e)?YN(e,o.getNonDeletedElementsMap()):null;return r?jN(ot,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:ZN,icon:tr,appState:t,scene:o,property:n}):null},mI=$N;import{degreesToRadians as pI,radiansToDegrees as gI}from"@excalidraw/math";import{getBoundTextElement as uI}from"@excalidraw/element";import{isArrowElement as hI}from"@excalidraw/element";import{isInGroup as _g}from"@excalidraw/element";import{jsx as eB}from"react/jsx-runtime";var qN=15,JN=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(c=>a.get(c.id)).filter(c=>c&&!_g(c)&&Mt(c,r)),s=o.filter(c=>!_g(c)&&Mt(c,r));if(n!==void 0){let c=pI(n);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:c});let p=uI(m,a);p&&!hI(m)&&i.mutateElement(p,{angle:c})}i.triggerUpdate();return}for(let c=0;c<l.length;c++){let m=l[c];if(!m)continue;let p=s[c],d=Math.round(gI(p.angle)*100)/100,h=Math.round(e),f=(d+h)%360;t&&(f=_e(f,qN)),f=f<0?f+360:f;let b=pI(f);i.mutateElement(m,{angle:b});let E=uI(m,a);E&&!hI(m)&&i.mutateElement(E,{angle:b})}i.triggerUpdate()},QN=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(s=>!_g(s)&&Mt(s,"angle")),i=r.map(s=>Math.round(gI(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>Mt(s,"angle"));return eB(ot,{label:"A",icon:Ls,value:a,elements:e,dragInputCallback:JN,editable:l,appState:t,scene:o,property:n})},fI=QN;import{pointFrom as bI}from"@excalidraw/math";import{useMemo as tB}from"react";import{MIN_WIDTH_OR_HEIGHT as Hn}from"@excalidraw/common";import{getElementsInResizingFrame as Dg,isFrameLikeElement as Rg,replaceAllElementsInFrame as yI,updateBoundElements as oB}from"@excalidraw/element";import{rescalePointsInElement as nB,resizeSingleElement as EI}from"@excalidraw/element";import{getBoundTextElement as rB,handleBindTextResize as iB}from"@excalidraw/element";import{isTextElement as wI}from"@excalidraw/element";import{getCommonBounds as em}from"@excalidraw/element";import{jsx as mB}from"react/jsx-runtime";var sa=10,aB=(e,o,t,n)=>{let r=n.x-e,i=n.y-o,a=n.width*t,l=n.height*t,s=e+r*t,c=o+i*t;return{width:a,height:l,x:s,y:c,...nB(n,a,l,!1),...wI(n)?{fontSize:n.fontSize*t}:{}}},lB=(e,o,t,n,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),c=aB(e,o,n,i);l.mutateElement(r,c);let m=rB(i,a);if(m){let p=m.fontSize*n;oB(r,l);let d=s.get(m.id);d&&wI(d)&&(l.mutateElement(d,{fontSize:p}),iB(r,l,t==="width"?"e":"s",!0))}},xI=(e,o,t,n,r,i,a,l,s,c)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let m=o/t;for(let p=0;p<l.length;p++){let d=l[p],h=a[p];lB(r[0],r[1],i,m,h,d,s,c)}},sB=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:c})=>{let m=a.getNonDeletedElementsMap(),p=aa(o,n);if(i!==void 0){for(let b of p){let E=ia(b,m,t);if(E.length>1){let w=E.map(B=>B.latest),y=E.map(B=>B.original),[x,v,I,C]=em(y),P=I-x,k=C-v,N=P/k,_=Math.max(Hn,l==="width"?Math.max(0,i):P),L=Math.max(Hn,l==="height"?Math.max(0,i):k);xI(_,L,k,N,bI(x,v),l,w,y,t,a)}else{let[w]=E,y=w?.latest,x=w?.original;if(y&&x&&Mt(y,l)){let v=l==="width"?Math.max(0,i):y.width;l==="width"&&(r?v=_e(v,sa):v=Math.round(v));let I=l==="height"?Math.max(0,i):y.height;if(l==="height"&&(r?I=_e(I,sa):I=Math.round(I)),v=Math.max(Hn,v),I=Math.max(Hn,I),EI(v,I,y,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Rg(y)){let C=Dg(a.getElementsIncludingDeleted(),y,n,a.getNonDeletedElementsMap()),P=yI(a.getElementsIncludingDeleted(),C,y,c);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let d=l==="width"?e:0,h=l==="height"?e:0,f=[];for(let b of p){let E=ia(b,m,t);if(E.length>1){let w=E.map(B=>B.latest),y=E.map(B=>B.original),[x,v,I,C]=em(y),P=I-x,k=C-v,N=P/k,_=Math.max(0,P+d);l==="width"&&(r?_=_e(_,sa):_=Math.round(_));let L=Math.max(0,k+h);l==="height"&&(r?L=_e(L,sa):L=Math.round(L)),_=Math.max(Hn,_),L=Math.max(Hn,L),xI(_,L,k,N,bI(x,v),l,w,y,t,a)}else{let[w]=E,y=w?.latest,x=w?.original;if(y&&x&&Mt(y,l)){let v=Math.max(0,x.width+d);l==="width"&&(r?v=_e(v,sa):v=Math.round(v));let I=Math.max(0,x.height+h);if(l==="height"&&(r?I=_e(I,sa):I=Math.round(I)),v=Math.max(Hn,v),I=Math.max(Hn,I),EI(v,I,y,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Rg(y)){let C=Dg(a.getElementsIncludingDeleted(),y,n,a.getNonDeletedElementsMap());f.push(...C)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},cB=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Rg(a)){let l=Dg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=yI(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},dB=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=tB(()=>n.map(c=>{let m=ia(c,t);if(m.length>1){let[d,h,f,b]=em(m.map(E=>E.latest));return Math.round((e==="width"?f-d:b-h)*100)/100}let[p]=m;return Math.round((e==="width"?p.latest.width:p.latest.height)*100)/100}),[t,n,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return mB(ot,{label:e==="width"?"W":"H",elements:o,dragInputCallback:sB,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:cB})},Ng=dB;import{getBoundTextElement as pB,redrawTextBoundingBox as vI}from"@excalidraw/element";import{hasBoundTextElement as uB,isTextElement as hB}from"@excalidraw/element";import{isInGroup as gB}from"@excalidraw/element";import{jsx as yB}from"react/jsx-runtime";var II=4,fB=4,bB=(e,o)=>e.reduce((t,n)=>{if(!n||gB(n))return t;if(hB(n))return t.push(n),t;if(uB(n)){let r=pB(n,o);if(r)return t.push(r),t}return t},[]),EB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(n){l=Math.max(Math.round(n),II);for(let s of a)r.mutateElement(s,{fontSize:l}),vI(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=o;for(let c=0;c<a.length;c++){let m=a[c],p=s[c],d=Math.round(p.fontSize),h=Math.round(e),f=Math.max(d+h,II);t&&(f=_e(f,fB)),r.mutateElement(m,{fontSize:f}),vI(m,r.getContainerElement(m),r)}r.triggerUpdate()}},xB=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=bB(e,r);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return yB(ot,{label:"F",icon:tr,elements:i,dragInputCallback:EB,value:l,editable:s,scene:o,property:n,appState:t})},TI=xB;import{pointFrom as Gn,pointRotateRads as tm}from"@excalidraw/math";import{useMemo as wB}from"react";import{isTextElement as vB}from"@excalidraw/element";import{getCommonBounds as Bg}from"@excalidraw/element";import{jsx as kB}from"react/jsx-runtime";var IB=(e,o,t,n,r,i,a)=>{for(let l=0;l<n.length;l++){let s=n[l],[c,m]=[s.x+s.width/2,s.y+s.height/2],[p,d]=tm(Gn(s.x,s.y),Gn(c,m),s.angle),h=e==="x"?Math.round(p+o):p,f=e==="y"?Math.round(d+t):d;Tr(h,f,s,i,a,r,!1)}},TB=(e,o,t,n,r,i)=>{let a=r.getNonDeletedElementsMap(),[l,s,,]=Bg(t),c=e-l,m=o-s;for(let p=0;p<t.length;p++){let d=t[p],h=a.get(d.id);if(h&&(!vB(h)||!h.containerId)){let[f,b]=[h.x+h.width/2,h.y+h.height/2],[E,w]=tm(Gn(h.x,h.y),Gn(f,b),h.angle);Tr(E+c,w+m,d,r,i,n,!1)}}},SB=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a,originalAppState:l,app:s})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let h of aa(o,l)){let f=ia(h,c,t);if(f.length>1){let[b,E,,]=Bg(f.map(x=>x.latest));TB(i==="x"?r:b,i==="y"?r:E,f.map(x=>x.original),t,a,s.state)}else{let b=f[0]?.original,E=f[0]?.latest;if(b&&E&&Mt(E,i)){let[w,y]=[b.x+b.width/2,b.y+b.height/2],[x,v]=tm(Gn(b.x,b.y),Gn(w,y),b.angle);Tr(i==="x"?r:x,i==="y"?r:v,b,a,s.state,t,!1)}}}a.triggerUpdate();return}let m=n?_e(e,Bl):e;IB(i,i==="x"?m:0,i==="y"?m:0,o,t,a,s.state),a.triggerUpdate()},CB=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=wB(()=>n.map(s=>{let c=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(c.length>1){let[b,E]=Bg(c);return Math.round((e==="x"?b:E)*100)/100}let[m]=c,[p,d]=[m.x+m.width/2,m.y+m.height/2],[h,f]=tm(Gn(m.x,m.y),Gn(p,d),m.angle);return Math.round((e==="x"?h:f)*100)/100}),[n,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return kB(ot,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:SB,value:l,property:e,scene:r,appState:i})},Fg=CB;import{clamp as Fl,pointFrom as om,pointRotateRads as CI,round as SI}from"@excalidraw/math";import{getFlipAdjustedCropPosition as MB,getUncroppedWidthAndHeight as PB}from"@excalidraw/element";import{isImageElement as kI}from"@excalidraw/element";import{jsx as _B}from"react/jsx-runtime";var LB=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s,app:c})=>{let m=l.getNonDeletedElementsMap(),p=t[0],[d,h]=[p.x+p.width/2,p.y+p.height/2],[f,b]=CI(om(p.x,p.y),om(d,h),p.angle);if(s.croppingElementId===p.id){let v=m.get(p.id);if(!v||!kI(v)||!v.crop)return;let I=v.crop,C=I,P=v.scale[0]===-1,k=v.scale[1]===-1,{width:N,height:_}=PB(v);if(i!==void 0){if(a==="x"){let G=i*(I.naturalWidth/N);P?C={...I,x:Fl(I.naturalWidth-G-I.width,0,I.naturalWidth-I.width)}:C={...I,x:Fl(i*(I.naturalWidth/N),0,I.naturalWidth-I.width)}}a==="y"&&(C={...I,y:Fl(i*(I.naturalHeight/_),0,I.naturalHeight-I.height)}),l.mutateElement(v,{crop:C});return}let L=(a==="x"?o:0)*(P?-1:1),B=(a==="y"?o:0)*(k?-1:1);C={...I,x:Fl(I.x+L,0,I.naturalWidth-I.width),y:Fl(I.y+B,0,I.naturalHeight-I.height)},l.mutateElement(v,{crop:C});return}if(i!==void 0){Tr(a==="x"?i:f,a==="y"?i:b,p,l,c.state,n);return}let E=a==="x"?e:0,w=a==="y"?e:0,y=a==="x"?Math.round(r?_e(p.x+E,Bl):f+E):f,x=a==="y"?Math.round(r?_e(p.y+w,Bl):b+w):b;Tr(y,x,p,l,c.state,n)},AB=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,a]=CI(om(o.x,o.y),om(o.x+o.width/2,o.y+o.height/2),o.angle),l=SI(e==="x"?i:a,2);if(r.croppingElementId===o.id&&kI(o)&&o.crop){let s=MB(o);s&&(l=SI(e==="x"?s.x:s.y,2))}return _B(ot,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:LB,scene:n,value:l,property:e,appState:r})},Og=AB;import{Fragment as Gg,jsx as te,jsxs as Pt}from"react/jsx-runtime";var GB=50,Ol=e=>{let o=So(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=Rn(e.app);return te(UB,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},Me=({children:e,columns:o=1,heading:t,style:n,...r})=>te("div",{className:DB("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});Me.displayName="StatsRow";var rm=({children:e,order:o,style:t,...n})=>te("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});rm.displayName="StatsRows";Ol.StatsRow=Me;Ol.StatsRows=rm;var UB=BB(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),m=he(),p=n.length===1?n[0]:null,d=n.length>1?n:null,h=r.croppingElementId&&Hg(p),f=h?OB(p):null,[b,E]=NB({width:0,height:0}),w=zg(()=>RB(v=>{let I=FB(v);E({width:Math.round(I[2])-Math.round(I[0]),height:Math.round(I[3])-Math.round(I[1])})},GB),[]);PI(()=>{w(s)},[i,s,w]),PI(()=>()=>w.cancel(),[w]);let y=zg(()=>aa(n,r),[n,r]),x=zg(()=>zB(n),[n]);return te("div",{className:"exc-stats",children:Pt(ze,{padding:3,children:[Pt("div",{className:"title",children:[te("h2",{children:g("stats.title")}),te("div",{className:"close",onClick:o,children:Ut})]}),Pt(Ya,{label:te("h3",{children:g("stats.generalStats")}),open:!!(r.stats.panels&nm.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^nm.generalStats}})),children:[Pt(rm,{children:[te(Me,{heading:!0,children:g("stats.scene")}),Pt(Me,{columns:2,children:[te("div",{children:g("stats.shapes")}),te("div",{children:s.length})]}),Pt(Me,{columns:2,children:[te("div",{children:g("stats.width")}),te("div",{children:b.width})]}),Pt(Me,{columns:2,children:[te("div",{children:g("stats.height")}),te("div",{children:b.height})]}),a&&Pt(Gg,{children:[te(Me,{heading:!0,children:"Canvas"}),te(Me,{children:te(oI,{property:"gridStep",scene:l,appState:r,setAppState:m})})]})]}),t?.(s,r)]}),!x&&n.length>0&&te("div",{id:"elementStats",style:{marginTop:12},children:te(Ya,{label:te("h3",{children:g("stats.elementProperties")}),open:!!(r.stats.panels&nm.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^nm.elementProperties}})),children:Pt(rm,{children:[p&&Pt(Gg,{children:[h&&te(Me,{heading:!0,children:g("labels.unCroppedDimension")}),r.croppingElementId&&Hg(p)&&f&&Pt(Me,{columns:2,children:[te("div",{children:g("stats.width")}),te("div",{children:MI(f.width,2)})]}),r.croppingElementId&&Hg(p)&&f&&Pt(Me,{columns:2,children:[te("div",{children:g("stats.height")}),te("div",{children:MI(f.height,2)})]}),te(Me,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?g("labels.imageCropping"):g(`element.${p.type}`)}),te(Me,{children:te(Og,{element:p,property:"x",elementsMap:c,scene:l,appState:r})}),te(Me,{children:te(Og,{element:p,property:"y",elementsMap:c,scene:l,appState:r})}),te(Me,{children:te(Ag,{property:"width",element:p,scene:l,appState:r})}),te(Me,{children:te(Ag,{property:"height",element:p,scene:l,appState:r})}),te(Me,{children:te(eI,{property:"angle",element:p,scene:l,appState:r})}),te(Me,{children:te(mI,{property:"fontSize",element:p,scene:l,appState:r})})]}),d&&Pt(Gg,{children:[HB(d)&&te(Me,{heading:!0,children:g("element.group")}),Pt(Me,{columns:2,style:{margin:"0.3125rem 0"},children:[te("div",{children:g("stats.shapes")}),te("div",{children:n.length})]}),te(Me,{children:te(Fg,{property:"x",elements:d,elementsMap:c,atomicUnits:y,scene:l,appState:r})}),te(Me,{children:te(Fg,{property:"y",elements:d,elementsMap:c,atomicUnits:y,scene:l,appState:r})}),te(Me,{children:te(Ng,{property:"width",elements:d,elementsMap:c,atomicUnits:y,scene:l,appState:r})}),te(Me,{children:te(Ng,{property:"height",elements:d,elementsMap:c,atomicUnits:y,scene:l,appState:r})}),te(Me,{children:te(fI,{property:"angle",elements:d,scene:l,appState:r})}),te(Me,{children:te(TI,{property:"fontSize",elements:d,scene:l,appState:r,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as WB,useEffect as LI,useState as AI}from"react";import{normalizeLink as YB,KEYS as Ug}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as VB,getLinkIdAndTypeFromSelection as XB}from"@excalidraw/element";import{jsx as ca,jsxs as im}from"react/jsx-runtime";var KB=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=VB})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=AI(a),[c,m]=AI(!1);LI(()=>{let d=q(i,t),h=a;if(d.length>0&&r){let f=XB(d,t);f&&(h=YB(r(f.id,f.type)))}s(h)},[i,t,t.selectedElementIds,a,r]);let p=WB(()=>{if(l&&l!==i.get(e)?.link){let d=i.get(e);d&&n.mutateElement(d,{link:l})}if(!l&&c&&e){let d=i.get(e);d&&n.mutateElement(d,{link:null})}o?.()},[e,l,i,c,n,o]);return LI(()=>{let d=h=>{t.openDialog?.name==="elementLinkSelector"&&h.key===Ug.ENTER&&p(),t.openDialog?.name==="elementLinkSelector"&&h.key===Ug.ESCAPE&&o?.()};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[t,o,p]),im("div",{className:"ElementLinkDialog",children:[im("div",{className:"ElementLinkDialog__header",children:[ca("h2",{children:g("elementLink.title")}),ca("p",{children:g("elementLink.desc")})]}),im("div",{className:"ElementLinkDialog__input",children:[ca(An,{value:l??"",onChange:d=>{c||m(!0),s(d)},onKeyDown:d=>{d.key===Ug.ENTER&&p()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&ca(V,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:Zo})]}),im("div",{className:"ElementLinkDialog__actions",children:[ca(tn,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),ca(tn,{label:g("buttons.confirm"),onClick:p,actionType:"primary"})]})]})},_I=KB;import ZB,{useState as $B}from"react";import{Fragment as jB,jsx as Wg}from"react/jsx-runtime";var DI=({children:e,onClose:o})=>{let[t,n]=$B(!!e),{container:r}=ke(),i=ZB.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return Wg(jB,{children:t&&Wg(We,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:Wg("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import qB from"clsx";import{jsx as JB}from"react/jsx-runtime";var RI=({children:e,side:o,className:t})=>JB("div",{className:qB("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import FI,{useMemo as rF}from"react";import OI from"clsx";import{isDarwin as zI,isFirefox as HI,isWindows as iF}from"@excalidraw/common";import{KEYS as da}from"@excalidraw/common";import{SHAPES as aF}from"@excalidraw/element/shapes";import{isFirefox as NI,KEYS as BI}from"@excalidraw/common";import{Fragment as nF,jsx as Pe,jsxs as Sr}from"react/jsx-runtime";var QB=e=>Sr(nF,{children:[Pe("h3",{children:e.title}),Pe("div",{className:"HelpDialog__islands-container",children:e.children})]}),Yg=e=>Sr("div",{className:`HelpDialog__island ${e.className}`,children:[Pe("h4",{className:"HelpDialog__island-title",children:e.caption}),Pe("div",{className:"HelpDialog__island-content",children:e.children})]});function*eF(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var tF=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),nt=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Pe(oF,{children:tF(a)},a)));return Sr("div",{className:"HelpDialog__shortcut",children:[Pe("div",{children:e}),Pe("div",{className:"HelpDialog__key-container",children:[...eF(n,t?g("helpDialog.or"):null)]})]})},oF=e=>Pe("kbd",{className:"HelpDialog__key",...e});function Vg(){return Sr(QB,{title:g("helpDialog.shortcuts"),children:[Sr(Yg,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[Pe(nt,{label:g("toolBar.hand"),shortcuts:[BI.H]}),_o.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:o})=>Pe(nt,{label:g(`toolBar.${e}`),shortcuts:[...o]},e)),Pe(nt,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),A("Enter")],isOr:!0}),Pe(nt,{label:g("helpDialog.cropFinish"),shortcuts:[A("Enter"),A("Escape")],isOr:!0})]}),Sr(Yg,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[Pe(nt,{label:g("helpDialog.smartZoom"),shortcuts:[BI.F]}),Pe(nt,{label:g("buttons.zenMode"),shortcuts:[A("Alt+Z")]}),Pe(nt,{label:g("buttons.objectsSnapMode"),shortcuts:[A("Alt+S")]}),Pe(nt,{label:g("commandPalette.title"),shortcuts:NI?[Ae("commandPalette")]:[Ae("commandPalette"),Ae("commandPalette",1)]})]}),Sr(Yg,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[Pe(nt,{label:g("labels.pasteAsPlaintext"),shortcuts:[A("CtrlOrCmd+Shift+V")]}),Pe(nt,{label:g("labels.multiSelect"),shortcuts:[A(`Shift+${g("helpDialog.click")}`)]}),Pe(nt,{label:g("helpDialog.deepSelect"),shortcuts:[A(`CtrlOrCmd+${g("helpDialog.click")}`)]}),Pe(nt,{label:g("helpDialog.deepBoxSelect"),shortcuts:[A(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(kn||NI)&&Pe(nt,{label:g("labels.copyAsPng"),shortcuts:[A("Shift+Alt+C")]}),Pe(nt,{label:g("helpDialog.toggleElementLock"),shortcuts:[A("CtrlOrCmd+Shift+L")]}),Pe(nt,{label:g("labels.group"),shortcuts:[A("CtrlOrCmd+G")]}),Pe(nt,{label:g("labels.ungroup"),shortcuts:[A("CtrlOrCmd+Shift+G")]}),Pe(nt,{label:g("labels.flipHorizontal"),shortcuts:[A("Shift+H")]}),Pe(nt,{label:g("labels.flipVertical"),shortcuts:[A("Shift+V")]})]})]})}import{Fragment as UI,jsx as W,jsxs as Cr}from"react/jsx-runtime";var lF=e=>Cr(UI,{children:[W("h3",{children:e.title}),W("div",{className:"HelpDialog__islands-container",children:e.children})]}),Xg=e=>Cr("div",{className:`HelpDialog__island ${e.className}`,children:[W("h4",{className:"HelpDialog__island-title",children:e.caption}),W("div",{className:"HelpDialog__island-content",children:e.children})]});function*sF(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var cF=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),$=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>W(dF,{children:cF(a)},a)));return Cr("div",{className:"HelpDialog__shortcut",children:[W("div",{children:e}),W("div",{className:"HelpDialog__key-container",children:[...sF(n,t?g("helpDialog.or"):null)]})]})},dF=e=>W("kbd",{className:"HelpDialog__key",...e}),GI=({onClose:e})=>{let[o,t]=FI.useState(!1),n=FI.useCallback(()=>{e&&e()},[e]),r=rF(()=>o?W("button",{className:OI("toggle-button",{}),onClick:()=>t(!1),children:g("helpDialog.myoc.showingAll")}):W("button",{className:OI("toggle-button",{}),onClick:()=>t(!0),children:g("helpDialog.myoc.showingBasic")}),[o]);return W(UI,{children:W(We,{onCloseRequest:n,title:g("helpDialog.title"),className:"HelpDialog",titleButton:r,children:o?Cr(lF,{title:g("helpDialog.shortcuts"),children:[Cr(Xg,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[W($,{label:g("toolBar.hand"),shortcuts:[da.H]}),aF.map(({value:i,key:a})=>W($,{label:g(`toolBar.${i}`),shortcuts:[...a]},i)),W($,{label:g("toolBar.frame"),shortcuts:[da.F]}),W($,{label:g("toolBar.laser"),shortcuts:[da.K]}),W($,{label:g("labels.eyeDropper"),shortcuts:[da.I,"Shift+S","Shift+G"]}),W($,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[A("CtrlOrCmd+Enter")]}),W($,{label:g("helpDialog.editText"),shortcuts:[A("Enter")]}),W($,{label:g("helpDialog.textNewLine"),shortcuts:[A("Enter"),A("Shift+Enter")]}),W($,{label:g("helpDialog.textFinish"),shortcuts:[A("Esc"),A("CtrlOrCmd+Enter")]}),W($,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),W($,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),W($,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),A("Enter")],isOr:!0}),W($,{label:g("helpDialog.cropFinish"),shortcuts:[A("Enter"),A("Escape")],isOr:!0}),W($,{label:g("toolBar.lock"),shortcuts:[da.Q]}),W($,{label:g("helpDialog.preventBinding"),shortcuts:[A("CtrlOrCmd")]}),W($,{label:g("toolBar.link"),shortcuts:[A("CtrlOrCmd+K")]}),W($,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Cr(Xg,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[W($,{label:g("helpDialog.smartZoom"),shortcuts:[da.F]}),W($,{label:g("buttons.zoomIn"),shortcuts:[A("CtrlOrCmd++")]}),W($,{label:g("buttons.zoomOut"),shortcuts:[A("CtrlOrCmd+-")]}),W($,{label:g("buttons.resetZoom"),shortcuts:[A("CtrlOrCmd+0")]}),W($,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),W($,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),W($,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),W($,{label:g("buttons.zenMode"),shortcuts:[A("Alt+Z")]}),W($,{label:g("buttons.objectsSnapMode"),shortcuts:[A("Alt+S")]}),W($,{label:g("labels.toggleGrid"),shortcuts:[A("CtrlOrCmd+'")]}),W($,{label:g("labels.viewMode"),shortcuts:[A("Alt+R")]}),W($,{label:g("stats.fullTitle"),shortcuts:[A("Alt+/")]}),W($,{label:g("search.title"),shortcuts:[Ae("searchMenu")]}),W($,{label:g("commandPalette.title"),shortcuts:HI?[Ae("commandPalette")]:[Ae("commandPalette"),Ae("commandPalette",1)]})]}),Cr(Xg,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[W($,{label:g("labels.moveCanvas"),shortcuts:[A(`Space+${g("helpDialog.drag")}`),A(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),W($,{label:g("labels.delete"),shortcuts:[A("Delete")]}),W($,{label:g("labels.cut"),shortcuts:[A("CtrlOrCmd+X")]}),W($,{label:g("labels.copy"),shortcuts:[A("CtrlOrCmd+C")]}),W($,{label:g("labels.paste"),shortcuts:[A("CtrlOrCmd+V")]}),W($,{label:g("labels.pasteAsPlaintext"),shortcuts:[A("CtrlOrCmd+Shift+V")]}),W($,{label:g("labels.selectAll"),shortcuts:[A("CtrlOrCmd+A")]}),W($,{label:g("labels.multiSelect"),shortcuts:[A(`Shift+${g("helpDialog.click")}`)]}),W($,{label:g("helpDialog.deepSelect"),shortcuts:[A(`CtrlOrCmd+${g("helpDialog.click")}`)]}),W($,{label:g("helpDialog.deepBoxSelect"),shortcuts:[A(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(kn||HI)&&W($,{label:g("labels.copyAsPng"),shortcuts:[A("Shift+Alt+C")]}),W($,{label:g("labels.copyStyles"),shortcuts:[A("CtrlOrCmd+Alt+C")]}),W($,{label:g("labels.pasteStyles"),shortcuts:[A("CtrlOrCmd+Alt+V")]}),W($,{label:g("labels.sendToBack"),shortcuts:[zI?A("CtrlOrCmd+Alt+["):A("CtrlOrCmd+Shift+[")]}),W($,{label:g("labels.bringToFront"),shortcuts:[zI?A("CtrlOrCmd+Alt+]"):A("CtrlOrCmd+Shift+]")]}),W($,{label:g("labels.sendBackward"),shortcuts:[A("CtrlOrCmd+[")]}),W($,{label:g("labels.bringForward"),shortcuts:[A("CtrlOrCmd+]")]}),W($,{label:g("labels.alignTop"),shortcuts:[A("CtrlOrCmd+Shift+Up")]}),W($,{label:g("labels.alignBottom"),shortcuts:[A("CtrlOrCmd+Shift+Down")]}),W($,{label:g("labels.alignLeft"),shortcuts:[A("CtrlOrCmd+Shift+Left")]}),W($,{label:g("labels.alignRight"),shortcuts:[A("CtrlOrCmd+Shift+Right")]}),W($,{label:g("labels.arrangeElements"),shortcuts:[A("Shift+R")]}),W($,{label:g("labels.duplicateSelection"),shortcuts:[A("CtrlOrCmd+D"),A(`Alt+${g("helpDialog.drag")}`)]}),W($,{label:g("helpDialog.toggleElementLock"),shortcuts:[A("CtrlOrCmd+Shift+L")]}),W($,{label:g("buttons.undo"),shortcuts:[A("CtrlOrCmd+Z")]}),W($,{label:g("buttons.redo"),shortcuts:iF?[A("CtrlOrCmd+Y"),A("CtrlOrCmd+Shift+Z")]:[A("CtrlOrCmd+Shift+Z")]}),W($,{label:g("labels.group"),shortcuts:[A("CtrlOrCmd+G")]}),W($,{label:g("labels.ungroup"),shortcuts:[A("CtrlOrCmd+Shift+G")]}),W($,{label:g("labels.flipHorizontal"),shortcuts:[A("Shift+H")]}),W($,{label:g("labels.flipVertical"),shortcuts:[A("Shift+V")]}),W($,{label:g("labels.showStroke"),shortcuts:[A("S")]}),W($,{label:g("labels.showBackground"),shortcuts:[A("G")]}),W($,{label:g("labels.showFonts"),shortcuts:[A("Shift+F")]}),W($,{label:g("labels.decreaseFontSize"),shortcuts:[A("CtrlOrCmd+Shift+<")]}),W($,{label:g("labels.increaseFontSize"),shortcuts:[A("CtrlOrCmd+Shift+>")]})]})]}):W(Vg,{})})})};import{CANVAS_SEARCH_TAB as mF,DEFAULT_SIDEBAR as pF}from"@excalidraw/common";import{isFlowchartNodeElement as uF,isImageElement as WI,isLinearElement as YI,isLineElement as hF,isTextBindableContainer as gF,isTextElement as fF}from"@excalidraw/element";import{isNodeInFlowchart as bF}from"@excalidraw/element";import{jsx as Kg}from"react/jsx-runtime";var Ee=e=>Array.isArray(e)?`<kbd>${e.map(A).join(" + ")}</kbd>`:`<kbd>${A(e)}</kbd>`,EF=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===pF.name&&e.openSidebar.tab===mF&&e.searchMatches?.matches.length)return g("hints.dismissSearch",{shortcut:Ee("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(wt(e))return g("hints.eraserRevert",{shortcut:Ee("Alt")});let c=n.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return g("hints.arrowBindModifiers",{shortcut_1:Ee("Ctrl"),shortcut_2:Ee("Alt")});if(r.type==="arrow"||r.type==="line")return s?g("hints.linearElementMulti",{shortcut_1:Ee("Escape"),shortcut_2:Ee("Enter")}):r.type==="arrow"?g("hints.arrowTool",{shortcut:Ee("A")}):g("hints.linearElement");if(r.type==="freedraw")return g("hints.freeDraw");if(r.type==="text")return g("hints.text");if(r.type==="embeddable")return g("hints.embeddable");if(i&&l==="mouse"&&c.length===1){let m=c[0];return YI(m)&&m.points.length===2?g("hints.lockAngle",{shortcut:Ee("Shift")}):WI(m)?g("hints.resizeImage",{shortcut_1:Ee("Shift"),shortcut_2:Ee("Alt")}):g("hints.resize",{shortcut_1:Ee("Shift"),shortcut_2:Ee("Alt")})}if(a&&l==="mouse")return g("hints.rotate",{shortcut:Ee("Shift")});if(c.length===1&&fF(c[0]))return g("hints.text_selected",{shortcut:Ee("Enter")});if(e.editingTextElement)return g("hints.text_editing",{shortcut_1:Ee("Escape"),shortcut_2:Ee(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return g("hints.leaveCropEditor",{shortcut_1:Ee("Enter"),shortcut_2:Ee("Escape")});if(c.length===1&&WI(c[0]))return g("hints.enterCropEditor",{shortcut:Ee("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return g("hints.deepBoxSelect",{shortcut:Ee("CtrlOrCmd")});if(Rn(n)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping",{shortcut:Ee("CtrlOrCmd")});if(!c.length&&!o)return g("hints.canvasPanning",{shortcut_1:Ee(g("keys.mmb")),shortcut_2:Ee("Space")});if(c.length===1){if(YI(c[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected",{shortcut_1:Ee("Delete"),shortcut_2:Ee(["CtrlOrCmd","D"])}):g("hints.lineEditor_nothingSelected",{shortcut_1:Ee("Shift"),shortcut_2:Ee("Alt")}):hF(c[0])?g("hints.lineEditor_line_info",{shortcut:Ee("Enter")}):g("hints.lineEditor_info",{shortcut_1:Ee("CtrlOrCmd"),shortcut_2:Ee(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&gF(c[0])){let m=g("hints.bindTextToElement",{shortcut:Ee("Enter")}),p=g("hints.createFlowchart",{shortcut:Ee(["CtrlOrCmd","\u2191\u2193"])});return uF(c[0])?bF(c[0],n.scene.getNonDeletedElementsMap())?[m,p]:[m,p]:m}}}return null},VI=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let r=EF({appState:e,isMobile:o,editorInterface:t,app:n});if(!r)return null;let a=(Array.isArray(r)?r.map(l=>l.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((l,s)=>{if(s%2===1){let c=l[0]==="<"&&l.match(/^<kbd>([^<]+)<\/kbd>$/);return Kg("kbd",{children:c?c[1]:l},s)}return l});return Kg("div",{className:"HintViewer",children:Kg("span",{children:a})})};import{useEffect as ZI,useRef as TF,useState as Un}from"react";import{DEFAULT_EXPORT_PADDING as SF,EXPORT_IMAGE_TYPES as Zg,isFirefox as CF,EXPORT_SCALES as kF,cloneJSON as $I}from"@excalidraw/common";import{useCallback as xF,useRef as yF,useState as wF}from"react";var vF=2e3,XI=()=>{let[e,o]=wF(null),t=yF(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},vF)},r=xF(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import IF from"clsx";import{jsx as KI}from"react/jsx-runtime";var zl=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>KI("div",{className:IF("Switch",{toggled:t,disabled:r}),children:KI("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>n(!t),onKeyDown:i=>{i.key===" "&&n(!t)}})});import{jsx as Le,jsxs as Wn}from"react/jsx-runtime";var MF=()=>Wn("div",{children:[Le("h3",{children:g("canvasError.cannotShowPreview")}),Le("p",{children:Le("span",{children:g("canvasError.canvasTooBig")})}),Wn("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),PF=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i})=>{let a=ve(o,e),[l,s]=Un(i),[c,m]=Un(a),[p,d]=Un(e.exportBackground),[h,f]=Un(e.exportWithDarkMode),[b,E]=Un(e.exportEmbedScene),[w,y]=Un(e.exportScale),x=TF(null),[v,I]=Un(null),{onCopy:C,copyStatus:P,resetCopyStatus:k}=XI();ZI(()=>{k()},[l,p,h,w,b,k]);let{exportedElements:N,exportingFrame:_}=sr(o,e,c);return ZI(()=>{let L=x.current;if(!L)return;let B=L.offsetWidth,G=L.offsetHeight;B&&Oi({elements:N,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:h,exportScale:w,exportEmbedScene:b},files:t,exportPadding:SF,maxWidthOrHeight:Math.max(B,G),exportingFrame:_}).then(j=>(I(null),Jn(j).then(()=>{L.replaceChildren(j)}).catch(H=>{throw H.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):H}))).catch(j=>{console.error(j),I(j)})},[e,t,N,_,l,p,h,w,b]),Wn("div",{className:"ImageExportModal",children:[Le("h3",{children:g("imageExportDialog.header")}),Wn("div",{className:"ImageExportModal__preview",children:[Le("div",{className:"ImageExportModal__preview__canvas",ref:x,children:v&&Le(MF,{})}),Le("div",{className:"ImageExportModal__preview__filename",children:!Hr&&Le("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:L=>{s(L.target.value),n.executeAction(ru,"ui",L.target.value)}})})]}),Wn("div",{className:"ImageExportModal__settings",children:[Le("h3",{children:g("imageExportDialog.header")}),a&&Le(Hl,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Le(zl,{name:"exportOnlySelected",checked:c,onChange:L=>{m(L)}})}),Le(Hl,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Le(zl,{name:"exportBackgroundSwitch",checked:p,onChange:L=>{d(L),n.executeAction(iu,"ui",L)}})}),Le(Hl,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Le(zl,{name:"exportDarkModeSwitch",checked:h,onChange:L=>{f(L),n.executeAction(ix,"ui",L)}})}),Le(Hl,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Le(zl,{name:"exportEmbedSwitch",checked:b,onChange:L=>{E(L),n.executeAction(wc,"ui",L)}})}),Le(Hl,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Le(Ud,{name:"exportScale",value:w,onChange:L=>{y(L),n.executeAction(rx,"ui",L)},choices:kF.map(L=>({value:L,label:`${L}\xD7`}))})}),Wn("div",{className:"ImageExportModal__settings__buttons",children:[Le(Fn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>r(Zg.png,N,{exportingFrame:_}),icon:Jm,children:g("imageExportDialog.button.exportToPng")}),Le(Fn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>r(Zg.svg,N,{exportingFrame:_}),icon:Jm,children:g("imageExportDialog.button.exportToSvg")}),(kn||CF)&&Le(Fn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(Zg.clipboard,N,{exportingFrame:_}),C()},icon:Qr,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Hl=({label:e,children:o,tooltip:t,name:n})=>Wn("div",{className:"ImageExportModal__settings__setting",title:e,children:[Wn("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&Le(ct,{label:t,long:!0,children:W0})]}),Le("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),jI=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Un(()=>({appStateSnapshot:$I(o),elementsSnapshot:$I(e)}));return Le(We,{onCloseRequest:i,size:"wide",title:!1,children:Le(PF,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:n,onExportImage:r,name:a})})};import AF from"react";import{getFrame as _F}from"@excalidraw/common";import{jsx as LF}from"react/jsx-runtime";var $g={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"}},jg=({children:e,color:o})=>LF("div",{className:"Card",style:{"--card-color":$g[o].base,"--card-color-darker":$g[o].darker,"--card-color-darkest":$g[o].darkest},children:e});import{Fragment as RF,jsx as bo,jsxs as am}from"react/jsx-runtime";var DF=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return bo("div",{className:"ExportDialog ExportDialog--json",children:am("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&am(jg,{color:"lime",children:[bo("div",{className:"Card-icon",children:q1}),bo("h2",{children:g("exportDialog.disk_title")}),am("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!Hr&&r.renderAction("changeProjectName")]}),bo(V,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(tl,"ui")}})]}),s&&am(jg,{color:"pink",children:[bo("div",{className:"Card-icon",children:Ma}),bo("h2",{children:g("exportDialog.link_title")}),bo("div",{className:"Card-details",children:g("exportDialog.link_details")}),bo(V,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{le("export","link",`ui (${_F()})`),await s(e,o,n),l()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,a)]})})},qI=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let l=AF.useCallback(()=>{a({openDialog:null})},[a]);return bo(RF,{children:o.openDialog?.name==="jsonExport"&&bo(We,{onCloseRequest:l,title:g("buttons.export"),children:bo(DF,{elements:e,appState:o,setAppState:a,files:t,actionManager:n,onCloseRequest:l,exportOpts:r,canvas:i})})})};import NF from"clsx";import{jsx as JI,jsxs as FF}from"react/jsx-runtime";var BF="small",QI=e=>FF("label",{className:NF("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${BF}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[JI("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),JI("div",{className:"ToolIcon__icon",children:ti})]});import{Fragment as o5,jsx as J,jsxs as Gt}from"react/jsx-runtime";var VF=({UIOptions:e})=>Gt(bt,{__fallback:!0,children:[J(bt.DefaultItems.LoadScene,{}),J(bt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&J(bt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&J(bt.DefaultItems.SaveAsImage,{}),J(bt.DefaultItems.SearchMenu,{}),J(bt.DefaultItems.Help,{}),J(bt.Separator,{}),J(bt.Group,{title:"Excalidraw links",children:J(bt.DefaultItems.Socials,{})}),J(bt.Separator,{}),J(bt.DefaultItems.ToggleTheme,{}),J(bt.DefaultItems.ChangeCanvasBackground,{})]}),XF=()=>Gt(Xd,{__fallback:!0,children:[J(Xd.Actions.SaveToDisk,{}),J(Xd.Actions.ExportToImage,{})]}),KF=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopLeftUI:m,renderTopRightUI:p,renderCustomStats:d,UIOptions:h,onExportImage:f,renderWelcomeScreen:b,children:E,app:w,isCollaborating:y,generateLinkForSelection:x})=>{let v=de(),C=je()==="compact",P=Bv(),k=C?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},N=P.tunnelsJotai.Provider,[_,L]=ue(xn),B=()=>h.canvasActions.export?J(qI,{elements:r,appState:o,files:t,actionManager:e,exportOpts:h.canvasActions.export,canvas:i,setAppState:n}):null,G=()=>!h.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:J(jI,{elements:r,appState:o,files:t,actionManager:e,onExportImage:f,onCloseRequest:()=>n({openDialog:null}),name:w.getName()}),j=()=>Gt("div",{style:{position:"relative"},children:[J(P.MainMenuTunnel.Out,{}),b&&J(P.WelcomeScreenMenuHintTunnel.Out,{})]}),H=()=>{let ee=C;return J(Al,{heading:"selectedShapeActions",className:kr("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:ee?J(ze,{className:kr("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:J(F2,{appState:o,elementsMap:w.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:w,setAppState:n})}):J(ze,{className:zF.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:J(_2,{appState:o,elementsMap:w.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:w})})})},Y=()=>{let ee=WF(o,r),K=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return J(RI,{side:"top",children:Gt("div",{className:"App-menu App-menu_top",children:[Gt(Tt.Col,{gap:k.menuTopGap,className:kr("App-menu_top__left"),children:[j(),J("div",{className:kr("selected-shape-actions-container",{"selected-shape-actions-container--compact":C}),children:ee&&H()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&J(Al,{heading:"shapes",className:"shapes-section",children:ae=>Gt("div",{style:{position:"relative"},children:[b&&J(P.WelcomeScreenToolbarHintTunnel.Out,{}),J(Tt.Col,{gap:k.toolbarColGap,align:"start",children:Gt(Tt.Row,{gap:k.toolbarRowGap,className:kr("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Gt(ze,{padding:k.islandPadding,className:kr("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":C}),children:[J(VI,{appState:o,isMobile:v.formFactor==="phone",editorInterface:v,app:w}),ae,Gt(Tt.Row,{gap:k.toolbarInnerRowGap,children:[J(Kv,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),J(Fd,{checked:lo(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),J(z2,{setAppState:n,activeTool:o.activeTool,UIOptions:h,app:w})]})]}),y&&J(ze,{style:{marginLeft:k.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:J(QI,{title:g("toolBar.laser"),checked:o.activeTool.type===e5.laser,onChange:()=>w.setActiveTool({type:e5.laser}),isMobile:!0})})]})})]})}),Gt("div",{className:kr("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":C}),children:[o.collaborators.size>0&&J(Hd,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),p?.(v.formFactor==="phone",o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!O||o.openSidebar?.name!==qg.name)&&J(P.DefaultSidebarTriggerTunnel.Out,{}),K&&J(Ol,{app:w,onClose:()=>{e.executeAction(Ai)},renderCustomStats:d})]})]})})},D=()=>J($d,{__fallback:!0,onDock:ee=>{le("sidebar",`toggleDock (${ee?"dock":"undock"})`,`(${v.formFactor==="phone"?"mobile":"desktop"})`)}}),O=Es(Dl),Q=Gt(o5,{children:[E,J(VF,{UIOptions:h}),J($d.Trigger,{__fallback:!0,icon:hb,title:GF(g("toolBar.library")),onToggle:ee=>{ee&&le("sidebar",`${qg.name} (open)`,`button (${v.formFactor==="phone"?"mobile":"desktop"})`)},tab:qg.defaultTab}),J(XF,{}),o.isLoading&&J(Bd,{delay:250}),o.errorMessage&&J(DI,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),_&&v.formFactor!=="phone"&&J(Pb,{colorPickerType:_.colorPickerType,onCancel:()=>{L(null)},onChange:(ee,K,ae,{altKey:be})=>{if(!(ee!=="elementBackground"&&ee!=="elementStroke"))if(ae.length){for(let ce of ae)UF(ce,HF(r),{[be&&_.swapPreviewOnAlt?ee==="elementBackground"?"strokeColor":"backgroundColor":ee==="elementBackground"?"backgroundColor":"strokeColor"]:K}),YF.delete(ce);w.scene.triggerUpdate()}else n(ee==="elementBackground"?{currentItemBackgroundColor:K}:{currentItemStrokeColor:K})},onSelect:(ee,K)=>{L(ae=>ae?.keepOpenOnAlt&&K.altKey?ae:null),_?.onSelect?.(ee,K)}}),o.openDialog?.name==="help"&&J(GI,{onClose:()=>{n({openDialog:null})}}),o.openDialog?.name==="elementLinkSelector"&&J(_I,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:w.scene,appState:o,generateLinkForSelection:x}),J(P.OverwriteConfirmDialogTunnel.Out,{}),G(),B(),o.pasteDialog.shown&&J(Wv,{setAppState:n,appState:o,onClose:()=>n({pasteDialog:{shown:!1,data:null}})}),v.formFactor==="phone"&&J(Gv,{app:w,appState:o,elements:r,actionManager:e,renderJSONExportDialog:B,renderImageExportDialog:G,setAppState:n,onHandToolToggle:l,onPenModeToggle:s,renderTopLeftUI:m,renderTopRightUI:p,renderSidebars:D,renderWelcomeScreen:b,UIOptions:h}),v.formFactor!=="phone"&&Gt(o5,{children:[Gt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&O&&v.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[b&&J(P.WelcomeScreenCenterTunnel.Out,{}),Y(),J(jv,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:b}),o.scrolledOutside&&J("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(ee=>({...jn(r,ee)}))},children:g("buttons.scrollBackToContent")})]}),D()]})]});return J(fp.Provider,{value:o,children:J(N,{children:J(tg.Provider,{value:P,children:Q})})})},t5=e=>{let{startBoundElement:o,cursorButton:t,scrollX:n,scrollY:r,...i}=e;return i},ZF=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:a,...l}=o;return lm(t5(n),t5(a),{selectedElementIds:lm,selectedGroupIds:lm})&&lm(r,l)},n5=OF.memo(KF,ZF);import $F from"clsx";import{jsx as r5,jsxs as qF}from"react/jsx-runtime";var jF="small",Jg=e=>qF("label",{className:$F("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${jF}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[r5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),r5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as JF,useRef as QF}from"react";import{jsx as i5}from"react/jsx-runtime";var a5=({trails:e})=>{let o=QF(null);return JF(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),i5("div",{className:"SVGLayer",children:i5("svg",{ref:o})})};import MO,{useEffect as PO,useRef as v5}from"react";import{CURSOR_TYPE as I5,isShallowEqual as LO,sceneCoordsToViewportCoords as AO}from"@excalidraw/common";var rt=class rt{static start(o,t){let n=t({deltaTime:0,state:void 0});n&&(rt.animations.set(o,{animation:t,lastTime:0,state:n}),rt.isRunning||(rt.isRunning=!0,wr()?requestAnimationFrame(rt.tick):setTimeout(rt.tick,0)))}static tick(){if(rt.animations.size>0){for(let[o,t]of rt.animations){let n=performance.now(),r=t.lastTime===0?0:n-t.lastTime,i=t.animation({deltaTime:r,state:t.state});if(i)t.lastTime=n,t.state=i;else if(rt.animations.delete(o),rt.animations.size===0){rt.isRunning=!1;return}}wr()?requestAnimationFrame(rt.tick):setTimeout(rt.tick,0)}}static running(o){return rt.animations.has(o)}static cancel(o){rt.animations.delete(o)}};S(rt,"isRunning",!1),S(rt,"animations",new Map);var Gl=rt;import{clamp as of,pointFrom as aO,pointsEqual as lO}from"@excalidraw/math";import{arrayToMap as sO,BIND_MODE_TIMEOUT as Ul,DEFAULT_TRANSFORM_HANDLE_SPACING as af,FRAME_STYLE as oo,getFeatureFlag as cO,invariant as m5,THEME as Yl}from"@excalidraw/common";import{deconstructDiamondElement as f5,deconstructRectanguloidElement as b5,elementCenterPoint as E5,getOmitSidesForEditorInterface as Qg,getTransformHandles as dO,getTransformHandlesFromCoords as mO,hasBoundingBox as pO,isElbowArrow as Wl,isFrameLikeElement as Vl,isImageElement as p5,isLinearElement as uO,isLineElement as hO,isTextElement as u5,LinearElementEditor as Mr}from"@excalidraw/element";import{renderSelectionElement as gO}from"@excalidraw/element";import{getElementsInGroup as nf,getSelectedGroupIds as fO,isSelectedViaGroup as bO,selectGroupsFromGivenElements as EO}from"@excalidraw/element";import{getCommonBounds as rf,getElementAbsoluteCoords as sm}from"@excalidraw/element";import{pointFrom as mt}from"@excalidraw/math";import{THEME as eO}from"@excalidraw/common";var tO="#ff6b6b",oO="#ff0000",l5=1,s5=2,c5=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===eO.LIGHT||o.zenModeEnabled?tO:oO,n=(o.zenModeEnabled?l5*1.5:l5)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let r of o.snapLines)r.type==="pointer"?(e.lineWidth=n,e.strokeStyle=t,rO(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,iO(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,nO(r,e,o));e.restore()},nO=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];to(n,r,o)}for(let n of e.points)d5(n,t,o)},rO=(e,o,t)=>{d5(e.points[0],t,o),t.zenModeEnabled||to(e.points[0],e.points[1],o)},d5=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?s5*1.5:s5)/t.zoom.value;n.beginPath(),n.moveTo(e-r,o-r),n.lineTo(e+r,o+r),n.moveTo(e+r,o-r),n.lineTo(e-r,o+r),n.stroke(),n.restore()},to=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},iO=(e,o,t,n,r)=>{let i=8/n.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];n.zenModeEnabled||to(mt(e[0],e[1]-i),mt(e[0],e[1]+i),r),to(mt(s[0]-l,s[1]-a),mt(s[0]-l,s[1]+a),r),to(mt(s[0]+l,s[1]-a),mt(s[0]+l,s[1]+a),r),n.zenModeEnabled||(to(mt(o[0],o[1]-i),mt(o[0],o[1]+i),r),to(e,o,r))}else{let s=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||to(mt(e[0]-i,e[1]),mt(e[0]+i,e[1]),r),to(mt(s[0]-a,s[1]-l),mt(s[0]+a,s[1]-l),r),to(mt(s[0]-a,s[1]+l),mt(s[0]+a,s[1]+l),r),n.zenModeEnabled||(to(mt(o[0]-i,o[1]),mt(o[0]+i,o[1]),r),to(e,o,r))}};var xO=(e,o)=>{m5(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;m5(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),x5(t,e,o),e.restore()},yO=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r))return;let i=Mr.getElement(n,t);if(!i)return;let a=Mr.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),x5(a,e,o),e.restore()},x5=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",ms(o,e[0],e[1],Mr.POINT_HANDLE_SIZE/t.zoom.value,!1)},ef=(e,o,t,n,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)"),ms(e,t[0],t[1],(a?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!a||r)},wO=(e,o,t,n)=>{let r=o.frameId&&t.get(o.frameId);switch(r&&Vl(r)&&(e.translate(r.x,r.y),e.beginPath(),oo.radius&&e.roundRect?e.roundRect(-1,-1,r.width+1,r.height+1,oo.radius/n.zoom.value):e.rect(-1,-1,r.width+1,r.height+1),e.clip(),e.translate(-r.x,-r.y)),o.type){case"magicframe":case"frame":e.save(),e.translate(o.x,o.y),e.lineWidth=oo.strokeWidth/n.zoom.value,e.strokeStyle=n.theme===Yl.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",oo.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,o.width,o.height,oo.radius/n.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,o.width,o.height),e.restore();break;default:e.save();let i=E5(o,t);switch(e.translate(i[0],i[1]),e.rotate(o.angle),e.translate(-i[0],-i[1]),e.translate(o.x,o.y),e.lineWidth=of(1.75,o.strokeWidth,4)/Math.max(.25,n.zoom.value),e.strokeStyle=n.theme===Yl.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",o.type){case"ellipse":e.beginPath(),e.ellipse(o.width/2,o.height/2,o.width/2,o.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[a,l]=f5(o);a.forEach(s=>{e.beginPath(),e.moveTo(s[0][0]-o.x,s[0][1]-o.y),e.lineTo(s[1][0]-o.x,s[1][1]-o.y),e.stroke()}),l.forEach(s=>{let[c,m,p,d]=s;e.beginPath(),e.moveTo(c[0]-o.x,c[1]-o.y),e.bezierCurveTo(m[0]-o.x,m[1]-o.y,p[0]-o.x,p[1]-o.y,d[0]-o.x,d[1]-o.y),e.stroke()})}break;default:{let[a,l]=b5(o);a.forEach(s=>{e.beginPath(),e.moveTo(s[0][0]-o.x,s[0][1]-o.y),e.lineTo(s[1][0]-o.x,s[1][1]-o.y),e.stroke()}),l.forEach(s=>{let[c,m,p,d]=s;e.beginPath(),e.moveTo(c[0]-o.x,c[1]-o.y),e.bezierCurveTo(m[0]-o.x,m[1]-o.y,p[0]-o.x,p[1]-o.y,d[0]-o.x,d[1]-o.y),e.stroke()})}break}e.restore();break}},vO=(e,o,t,n,r,i,a)=>{let l=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,s=Ul-(a?.runtime??(l?0:Ul)),c=of(1/Ul*s,1e-4,1),m=t.strokeWidth/2,p=t.frameId&&n.get(t.frameId);switch(p&&Vl(p)&&(o.translate(p.x,p.y),o.beginPath(),oo.radius&&o.roundRect?o.roundRect(-1,-1,p.width+1,p.height+1,oo.radius/r.zoom.value):o.rect(-1,-1,p.width+1,p.height+1),o.clip(),o.translate(-p.x,-p.y)),t.type){case"magicframe":case"frame":o.save(),o.translate(t.x,t.y),o.lineWidth=oo.strokeWidth/r.zoom.value,o.strokeStyle=r.theme===Yl.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,oo.radius&&o.roundRect?(o.beginPath(),o.roundRect(0,0,t.width,t.height,oo.radius/r.zoom.value),o.stroke(),o.closePath()):o.strokeRect(0,0,t.width,t.height),o.restore();break;default:o.save();let h=E5(t,n),f=h[0]+r.scrollX,b=h[1]+r.scrollY;switch(o.translate(f,b),o.rotate(t.angle),o.translate(-f,-b),o.translate(t.x+r.scrollX-m,t.y+r.scrollY-m),o.lineWidth=of(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),o.strokeStyle=r.theme===Yl.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":o.beginPath(),o.ellipse((t.width+m*2)/2,(t.height+m*2)/2,(t.width+m*2)/2,(t.height+m*2)/2,0,0,2*Math.PI),o.closePath(),o.stroke();break;case"diamond":{let[E,w]=f5(t,m);E.forEach(y=>{o.beginPath(),o.moveTo(y[0][0]-t.x+m,y[0][1]-t.y+m),o.lineTo(y[1][0]-t.x+m,y[1][1]-t.y+m),o.stroke()}),w.forEach(y=>{let[x,v,I,C]=y;o.beginPath(),o.moveTo(x[0]-t.x+m,x[1]-t.y+m),o.bezierCurveTo(v[0]-t.x+m,v[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m),o.stroke()})}break;default:{let[E,w]=b5(t,m);E.forEach(y=>{o.beginPath(),o.moveTo(y[0][0]-t.x+m,y[0][1]-t.y+m),o.lineTo(y[1][0]-t.x+m,y[1][1]-t.y+m),o.stroke()}),w.forEach(y=>{let[x,v,I,C]=y;o.beginPath(),o.moveTo(x[0]-t.x+m,x[1]-t.y+m),o.bezierCurveTo(v[0]-t.x+m,v[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m),o.stroke()})}break}o.restore();break}if(!l||(a?.runtime??0)>Ul)return;let d=.5*(Math.min(t.width,t.height)/2);if(!Vl(t)){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let h=1/Ul*s;o.strokeStyle="rgba(0, 0, 0, 0.2)",o.lineWidth=1/r.zoom.value,o.setLineDash([4/r.zoom.value,4/r.zoom.value]),o.lineDashOffset=-h*10/r.zoom.value,o.beginPath(),o.ellipse(t.width/2,t.height/2,d,d,0,0,2*Math.PI),o.stroke(),o.fillStyle="rgba(0, 0, 0, 0.04)",o.beginPath(),o.ellipse(t.width/2,t.height/2,d*(1-c),d*(1-c),0,0,2*Math.PI),o.fill(),o.restore()}return{runtime:(a?.runtime??0)+i}},IO=(e,o,t,n,r,i,a)=>{if(cO("COMPLEX_BINDINGS"))return vO(e,o,t,n,r,i,a);o.save(),o.translate(r.scrollX,r.scrollY),wO(o,t,n,r),o.restore()},y5=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:m,dashed:p,activeEmbeddable:d}=t,h=a-r,f=l-i,E=(t.padding??af*2)/o.zoom.value,w=8/o.zoom.value,y=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(d?4:1)/o.zoom.value;let x=s.length;for(let v=0;v<x;++v)e.strokeStyle=s[v],p&&e.setLineDash([w,y+(w+y)*(x-1)]),e.lineDashOffset=(w+y)*v,va(e,r-E,i-E,h+E*2,f+E*2,c,m,n);e.restore()},TO=(e,o,t,n)=>{let[r,i,a,l]=sm(t,n),s=a-r,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=oo.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),va(e,r,i,s,c,r+s/2,i+c/2,t.angle,!1,oo.radius/o.zoom.value),e.restore()},h5=(e,o,t,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},a=t.filter(m=>m.groupIds.length===0),l=t.filter(m=>m.groupIds.length>0),s=m=>{let[p,d,h,f]=rf(m);return{angle:0,x1:p,x2:h,y1:d,y2:f,selectionColors:r,dashed:i,cx:p+(h-p)/2,cy:d+(f-d)/2,activeEmbeddable:!1}},c=m=>{let p=nf(t,m);return s(p)};Object.entries(EO(l,o)).filter(([m,p])=>p).map(([m,p])=>m).map(m=>c(m)).concat(a.map(m=>s([m]))).forEach(m=>y5(e,o,m))},tf=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=Mr.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=Mr,a=o.selectedLinearElement?.isEditing?i:i/2,l=Wl(t),s=hO(t);if(r.forEach((c,m)=>{if(l&&m!==0&&m!==r.length-1)return;let p=m>0&&(m!==r.length-1||!s||!t.polygon)&&lO(c,m===r.length-1?r[0]:r[m-1],2/o.zoom.value),d=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!d&&m===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(d=!0),ef(e,o,c,a,d,!1,p)}),Wl(t)){let c=t.fixedSegments?.map(m=>m.index)||[];r.slice(0,-1).forEach((m,p)=>{Mr.isSegmentTooShort(t,r[p+1],r[p],p,o.zoom)||ef(e,o,aO((m[0]+r[p+1][0])/2,(m[1]+r[p+1][1])/2),i/2,!1,!c.includes(p+1),!1)})}else Mr.getEditorMidPoints(t,n,o).filter((m,p,d)=>m!==null&&!(Wl(t)&&(p===0||p===d.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||r.length===2)&&ef(e,o,m,i/2,!1,!0,!1)});e.restore()},g5=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[l,s,c,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?ms(e,l+c/2,s+m/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,m,2/t.zoom.value),e.fill(),e.stroke()):va(e,l,s,c,m,l+c/2,s+m/2,r,!0),e.restore()}})},SO=(e,o,t,n,r)=>{let[i,a,,,l,s]=sm(n,r),c=3,m=20,p=c/t.zoom.value,d=p/2,h=l-i+p,f=s-a+p,b=Math.min(m/t.zoom.value,h),E=Math.min(m/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=p,[[[-h,-f],[0,d],[b,d],[d,0],[d,E]],[[h-d,-f],[d,d],[-b+d,d],[0,0],[0,E]],[[-h,f],[0,-d],[b,-d],[d,0],[d,-E]],[[h-d,f],[d,-d],[-b+d,-d],[0,0],[0,-E]]].forEach(y=>{let[[x,v],[I,C],[P,k],[N,_],[L,B]]=y;e.save(),e.translate(l,s),e.rotate(n.angle),e.beginPath(),e.moveTo(x+I,v+C),e.lineTo(x+P,v+k),e.stroke(),e.beginPath(),e.moveTo(x+N,v+_),e.lineTo(x+L,v+B),e.stroke(),e.restore()}),e.restore()},CO=(e,o,t,n)=>{o.save();let r=af*2/t.zoom.value,i=e.width+r*2,a=e.height+r*2,l=e.x+i/2,s=e.y+a/2,c=-(i/2+r),m=-(a/2+r);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.strokeRect(c,m,i,a),o.restore()},kO=({app:e,canvas:o,elementsMap:t,visibleElements:n,selectedElements:r,allElementsMap:i,scale:a,appState:l,renderConfig:s,editorInterface:c,animationState:m,deltaTime:p})=>{if(o===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[d,h]=ps(o,a),f=m,b=us({canvas:o,scale:a,normalizedWidth:d,normalizedHeight:h});b.save(),b.scale(l.zoom.value,l.zoom.value);let E;if(n.forEach(x=>{l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===x.id&&x&&(E=x)}),E&&tf(b,l,E,t),l.selectionElement&&!l.isCropping)try{gO(l.selectionElement,b,l,s.selectionColor)}catch(x){console.error(x)}if(l.editingTextElement&&u5(l.editingTextElement)){let x=i.get(l.editingTextElement.id);x&&!x.autoResize&&CO(x,b,l,s.selectionColor)}if(l.isBindingEnabled&&l.suggestedBinding?f={...m,bindingHighlight:IO(e,b,l.suggestedBinding,i,l,p,m?.bindingHighlight)}:f={...m,bindingHighlight:void 0},l.frameToHighlight&&TO(b,l,l.frameToHighlight,t),l.elementsToHighlight&&h5(b,l,l.elementsToHighlight),l.activeLockedId){let x=i.get(l.activeLockedId),v=x?[x]:nf(i,l.activeLockedId);h5(b,l,v,{colors:["#ced4da"],dashed:!0})}let w=r.some(x=>Vl(x));if(r.length===1&&l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===r[0].id&&tf(b,l,r[0],t),l.selectedLinearElement){let x=l.selectedLinearElement,v=r.find(I=>I.id===x.elementId);l.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?xO(b,l):(Wl(v)?x.hoverPointIndex===0||x.hoverPointIndex===v.points.length-1:x.hoverPointIndex>=0)&&yO(b,l,t))}if(!l.multiElement&&!l.newElement&&!l.selectedLinearElement?.isEditing){let x=pO(r,l,c),v=r.length===1&&uO(r[0]);v&&l.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&tf(b,l,r[0],t);let I=s.selectionColor||"#000";if(x){let C=sO(r),P=[];for(let N of t.values()){let _=[],L=s.remoteSelectedElementIds.get(N.id);if(v&&Wl(N)&&(N.startBinding||N.endBinding)||(C.has(N.id)&&!bO(l,N)&&_.push(I),L&&_.push(...L.map(B=>pr(B,l.collaborators.get(B))))),_.length){let[B,G,j,H,Y,D]=sm(N,t,!0);P.push({angle:N.angle,x1:B,y1:G,x2:j,y2:H,selectionColors:N.locked?["#ced4da"]:_,dashed:!!L||N.locked,cx:Y,cy:D,activeEmbeddable:l.activeEmbeddable?.element===N&&l.activeEmbeddable.state==="active",padding:N.id===l.croppingElementId||p5(N)?0:void 0})}}let k=N=>{let _=nf(t,N),[L,B,G,j]=rf(_);P.push({angle:0,x1:L,x2:G,y1:B,y2:j,selectionColors:_.some(H=>H.locked)?["#ced4da"]:["#000"],dashed:!0,cx:L+(G-L)/2,cy:B+(j-B)/2,activeEmbeddable:!1})};for(let N of fO(l))k(N);l.editingGroupId&&k(l.editingGroupId),P.forEach(N=>y5(b,l,N))}if(b.save(),b.translate(l.scrollX,l.scrollY),r.length===1){b.fillStyle="#fff";let C=dO(r[0],l.zoom,t,"mouse",Qg(c));if(!l.viewModeEnabled&&x&&!u5(l.editingTextElement)&&!l.croppingElementId&&g5(b,s,l,C,r[0].angle),l.croppingElementId&&!l.isCropping){let P=t.get(l.croppingElementId);P&&p5(P)&&SO(b,s,l,P,t)}}else if(r.length>1&&!l.isRotating&&!r.some(C=>C.locked)){let C=af*2/l.zoom.value;b.fillStyle="#fff";let[P,k,N,_]=rf(r,t),L=b.getLineDash();b.setLineDash([2/l.zoom.value]);let B=b.lineWidth;b.lineWidth=1/l.zoom.value,b.strokeStyle=I,va(b,P-C,k-C,N-P+C*2,_-k+C*2,(P+N)/2,(k+_)/2,0),b.lineWidth=B,b.setLineDash(L);let G=mO([P,k,N,_,(P+N)/2,(k+_)/2],0,l.zoom,"mouse",w?{...Qg(c),rotation:!0}:Qg(c));r.some(j=>!j.locked)&&g5(b,s,l,G,0)}b.restore()}l.searchMatches?.matches.forEach(({id:x,focus:v,matchedLines:I})=>{let C=t.get(x);if(C){let[P,k,,,N,_]=sm(C,t,!0);b.save(),l.theme===Yl.LIGHT?v?b.fillStyle="rgba(255, 124, 0, 0.4)":b.fillStyle="rgba(255, 226, 0, 0.4)":v?b.fillStyle="rgba(229, 82, 0, 0.4)":b.fillStyle="rgba(99, 52, 0, 0.4)";let L=Vl(C)?l.zoom.value:1;b.translate(l.scrollX,l.scrollY),b.translate(N,_),b.rotate(C.angle),I.forEach(B=>{(B.showOnCanvas||v)&&b.fillRect(P+B.offsetX/L-N,k+B.offsetY/L-_,B.width/L,B.height/L)}),b.restore()}}),c5(b,l),b.restore(),gx({context:b,renderConfig:s,appState:l,normalizedWidth:d,normalizedHeight:h});let y;return s.renderScrollbars&&(y=mv(t,d,h,l),b.save(),b.fillStyle=dv,b.strokeStyle="rgba(255,255,255,0.8)",[y.horizontal,y.vertical].forEach(x=>{x&&Cc(b,x.x,x.y,x.width,x.height,qt/2)}),b.restore()),{scrollBars:y,atLeastOneVisibleElement:n.length>0,elementsMap:t,animationState:f}},w5=e=>{let o=kO(e);return e.callback(o),o};import{jsx as RO}from"react/jsx-runtime";var T5="animateInteractiveScene",_O=e=>{let o=v5(!1),t=v5(null);return PO(()=>{if(!o.current){o.current=!0;return}let n=new Map,r=new Map,i=new Map,a=new Map,l=new Map;e.appState.collaborators.forEach((c,m)=>{if(c.selectedElementIds)for(let p of Object.keys(c.selectedElementIds))i.has(p)||i.set(p,[]),i.get(p).push(m);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(m,c.username),c.userState&&l.set(m,c.userState),r.set(m,AO({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),n.set(m,c.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";t.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:n,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:l,selectionColor:s,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.lastViewportPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},Gl.running(T5)||Gl.start(T5,({deltaTime:c,state:m})=>{let p=w5({...t.current,deltaTime:c,animationState:m}).animationState;if(p){for(let d in p)if(p[d]!==void 0)return p}})}),RO("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?I5.GRAB:I5.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:g("labels.drawingCanvas")})},S5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,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,suggestedBinding:e.suggestedBinding,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale}),DO=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:LO(S5(e.appState),S5(o.appState)),lf=MO.memo(_O,DO);import NO,{useEffect as C5,useRef as k5}from"react";import{isShallowEqual as M5}from"@excalidraw/common";import{jsx as OO}from"react/jsx-runtime";var BO=e=>{let o=k5(null),t=k5(!1);return C5(()=>{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]),C5(()=>{let n=o.current;if(!n)return;let r=e.canvas;t.current||(t.current=!0,n.replaceChildren(r),r.classList.add("excalidraw__canvas","static")),u1({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},wr())}),OO("div",{className:"excalidraw__canvas-wrapper",ref:o})},P5=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}),FO=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:M5(P5(e.appState),P5(o.appState))&&M5(e.renderConfig,o.renderConfig),sf=NO.memo(BO,FO);import{useEffect as VO,useRef as XO}from"react";import{throttleRAF as zO}from"@excalidraw/common";import{getTargetFrame as HO,isInvisiblySmallElement as GO,renderElement as UO,shouldApplyFrameClip as WO}from"@excalidraw/element";var L5=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=ps(e,i),m=us({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});if(m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(GO(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let d=HO(t,n,a);d&&WO(t,d,a,n)&&m1(d,m,l,a)}UO(t,n,r,o,m,l,a)}else m.clearRect(0,0,s,c);m.restore()}},YO=zO(e=>{L5(e)},{trailing:!0}),A5=(e,o)=>{if(o){YO(e);return}L5(e)};import{jsx as ZO}from"react/jsx-runtime";var KO=e=>{let o=XO(null);return VO(()=>{o.current&&A5({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},wr())}),ZO("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:o})},_5=KO;import{useCallback as $O,useEffect as jO,useRef as qO}from"react";import{jsx as D5,jsxs as QO}from"react/jsx-runtime";var JO=5e3,R5=({message:e,onClose:o,closable:t=!1,duration:n=JO,style:r})=>{let i=qO(0),a=n!==1/0,l=$O(()=>{a&&(i.current=window.setTimeout(()=>o(),n))},[o,n,a]);return jO(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,n,a]),QO("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[D5("p",{className:"Toast__message",children:e}),t&&D5(V,{icon:Ut,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as ez,getElementsInGroup as tz,selectGroupsFromGivenElements as oz}from"@excalidraw/element";import{sceneCoordsToViewportCoords as nz}from"@excalidraw/common";import{flushSync as rz}from"react-dom";import{jsx as az}from"react/jsx-runtime";var iz=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:tz(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=ez(n),{x:a,y:l}=nz({sceneX:r,sceneY:i},e.state);return az("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{rz(()=>{let s=oz(n,e.state);e.setState({selectedElementIds:n.reduce((c,m)=>({...c,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(al)},title:g("labels.elementLock.unlock"),children:N1})},N5=iz;import{Fragment as rG,jsx as we,jsxs as xm}from"react/jsx-runtime";var OT=Yo.createContext(null),zT=Yo.createContext(null),Bf={formFactor:"desktop",desktopUIMode:"full",userAgent:BT(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},Of=Yo.createContext(Bf);Of.displayName="EditorInterfaceContext";var zf=Yo.createContext({container:null,id:null});zf.displayName="ExcalidrawContainerContext";var Hf=Yo.createContext([]);Hf.displayName="ExcalidrawElementsContext";var Gf=Yo.createContext({...zr(),width:0,height:0,offsetLeft:0,offsetTop:0});Gf.displayName="ExcalidrawAppStateContext";var Uf=Yo.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Uf.displayName="ExcalidrawSetAppStateContext";var Wf=Yo.createContext(null);Wf.displayName="ExcalidrawActionManagerContext";var qe=()=>Zn(OT),Co=()=>Zn(zT),de=()=>Zn(Of),je=()=>ym(de()),ke=()=>Zn(zf),yn=()=>Zn(Hf),So=()=>Zn(Gf),he=()=>Zn(Uf),at=()=>Zn(Wf),es=!1,_f=0,ts=null,Rr=!1,os=!1,Df=!1,ns={horizontal:null,vertical:null},Kn=0,rs=!1,Rf=new Map,Nf=!1,_T=0,DT=!1,is=null,fe={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Ff=class e extends Yo.Component{constructor(t){super(t);S(this,"canvas");S(this,"interactiveCanvas",null);S(this,"rc");S(this,"unmounted",!1);S(this,"actionManager");S(this,"editorInterface",Bf);S(this,"stylesPanelMode",ym(Bf));S(this,"excalidrawContainerRef",Yo.createRef());S(this,"scene");S(this,"fonts");S(this,"renderer");S(this,"visibleElements");S(this,"resizeObserver");S(this,"library");S(this,"libraryItemsFromStorage");S(this,"id");S(this,"store");S(this,"history");S(this,"excalidrawContainerValue");S(this,"files",{});S(this,"imageCache",new Map);S(this,"iFrameRefs",new Map);S(this,"embedsValidationStatus",new Map);S(this,"initializedEmbeds",new Set);S(this,"handleToastClose",()=>{this.setToast(null)});S(this,"elementsPendingErasure",new Set);S(this,"flowChartCreator",new MH);S(this,"flowChartNavigator",new PH);S(this,"bindModeHandler",null);S(this,"hitLinkElement");S(this,"lastPointerDownEvent",null);S(this,"lastPointerUpEvent",null);S(this,"lastPointerMoveEvent",null);S(this,"lastPointerMoveCoords",null);S(this,"lastViewportPosition",{x:0,y:0});S(this,"animationFrameHandler",new Cd);S(this,"laserTrails",new Ld(this.animationFrameHandler,this));S(this,"eraserTrail",new Nd(this.animationFrameHandler,this));S(this,"lassoTrail",new Rd(this.animationFrameHandler,this));S(this,"onChangeEmitter",new Ar);S(this,"onPointerDownEmitter",new Ar);S(this,"onPointerUpEmitter",new Ar);S(this,"onUserFollowEmitter",new Ar);S(this,"onScrollChangeEmitter",new Ar);S(this,"missingPointerEventCleanupEmitter",new Ar);S(this,"onRemoveEventListenersEmitter",new Ar);S(this,"updateEditorAtom",(t,...n)=>{let r=$e.set(t,...n);return this.triggerRender(),r});S(this,"previousHoveredBindableElement",null);S(this,"getEffectiveGridSize",()=>Rn(this)?this.state.gridSize:null);S(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),Ql.delete(t)});S(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(mn(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=wf(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else ga(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});S(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);S(this,"frameNameBoundsCache",{get:t=>{let n=this.frameNameBoundsCache._cache.get(t.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Be({clientX:i.x,clientY:i.y},this.state),l=Be({clientX:i.right,clientY:i.bottom},this.state);return n={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,n),n}return null}return n},_cache:new Map});S(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});S(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===mm.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&Lt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!cT(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:a,y:l}=um({sceneX:i.x,sceneY:i.y},this.state),s=6,c,m=vH(i);if(i.id===this.state.editingFrame){let p=m;c=we("input",{autoFocus:!0,value:p,onChange:d=>{this.scene.mutateElement(i,{name:d.target.value})},onFocus:d=>d.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:d=>{(d.key===X.ESCAPE||d.key===X.ENTER)&&this.resetEditingFrame(i)},style:{background:t?Oz(this.state.viewBackgroundColor):this.state.viewBackgroundColor,zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${zo.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:t?zo.nameColorDarkTheme:zo.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:p.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=m;return we("div",{id:this.getFrameNameDOMId(i),className:ff.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+zo.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:zo.nameFontSize,color:t?zo.nameColorDarkTheme:zo.nameColorLightTheme,lineHeight:zo.nameLineHeight,width:"max-content",maxWidth:r?.id===i.id&&r?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Ne.MOVE,pointerEvents:this.state.viewModeEnabled?ma.disabled:ma.enabled},onPointerDown:p=>this.handleCanvasPointerDown(p),onWheel:p=>this.handleWheel(p),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});S(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});S(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());S(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());S(this,"getSceneElements",()=>this.scene.getNonDeletedElements());S(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});S(this,"onExportImage",async(t,n,r)=>{le("export",t,"ui");let i=await cr(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(Nz).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&gs(i)&&this.setState({fileHandle:i})});S(this,"magicGenerations",new Map);S(this,"updateMagicGeneration",({frameElement:t,data:n})=>{n.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,n),this.triggerRender()});S(this,"plugins",{});S(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:Go.magicframe}),le("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&lT(t[0])&&t[0];if(!n&&t.some(i=>Lt(i)||i.frameId)){this.setActiveTool({type:Go.magicframe});return}le("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,l,s]=ua(t),c=50;r=nT({...zo,x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let m of t)this.scene.mutateElement(m,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});S(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(xn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=t==="background"&&r.altKey||t==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:xt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:xt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?Vn(l,{[i?"strokeColor":"backgroundColor"]:n}):l),captureUpdate:xt.IMMEDIATELY})},keepOpenOnAlt:!1})});S(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});S(this,"syncActionResult",Re(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let n=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),n=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||mm.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(m=>{r?.id===m.id&&r!==m&&CT(m)&&xo(m)&&(r=m)}),r?.isDeleted&&(r=null),this.setState(m=>{let p=t.appState||{};return{...m,...p,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),n=!0}n||this.scene.triggerUpdate()}));S(this,"onBlur",Re(()=>{Rr=!1,this.setState({isBindingEnabled:!0})}));S(this,"onUnload",()=>{this.onBlur()});S(this,"disableEvent",t=>{t.preventDefault()});S(this,"resetHistory",()=>{this.history.clear()});S(this,"resetStore",()=>{this.store.clear()});S(this,"resetScene",Re(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...zr(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));S(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async a=>{if(!a.files.length)return;let l=a.files[0],s=await l.getFile();this.loadFileToCanvas(new File([s],s.name||"",{type:s.type}),l)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(a=>{console.error(a)})}catch(a){console.error(a),t={appState:{errorMessage:a.message||"Encountered an error during importing or restoring scene data"}}}let n=qn(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=Ur(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r={...r,...jn(n,{...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({elements:n,appState:r,files:t?.files,captureUpdate:xt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(a=>{this.fonts.onLoaded(a)}),Mf(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});S(this,"getFormFactor",(t,n)=>this.props.UIOptions.getFormFactor?.(t,n)??Wz(t,n));S(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=Kz(),a=BT(typeof navigator<"u"?navigator.userAgent:""),l=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:Ez,s=gf(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(n,r),userAgent:a,canFitSidebar:n>l,isLandscape:n>r});this.editorInterface=s,this.reconcileStylesPanelMode(s)});S(this,"reconcileStylesPanelMode",t=>{let n=ym(t);if(n===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=n,r!=="full"&&n==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});S(this,"setDesktopUIMode",t=>{let n=Zz(t);this.editorInterface=gf(this.editorInterface,{desktopUIMode:n}),this.reconcileStylesPanelMode(this.editorInterface)});S(this,"onResize",Re(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Ql.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));S(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});S(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&(ns=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});S(this,"onScroll",j5(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},xz));S(this,"onCut",Re(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Kl(t.target)||(this.actionManager.executeAction(Pc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));S(this,"onCopy",Re(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||Kl(t.target)||(this.actionManager.executeAction(Pi,"keyboard",t),t.preventDefault(),t.stopPropagation())}));S(this,"onTouchStart",t=>{if(Yz&&t.preventDefault(),!es){es=!0,t.touches.length===1&&(ts={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(_f),_f=window.setTimeout(e.resetTapTwice,yz);return}if(es&&t.touches.length===1&&ts){let n=t.touches[0];Pr(oe(n.clientX,n.clientY),oe(ts.x,ts.y))<=Gz&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY})),es=!1,clearTimeout(_f)}t.touches.length===2&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null})});S(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}):fe.pointers.clear()});S(this,"pasteFromClipboard",Re(async t=>{let n=!!Nf,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||Kl(r)))return;let l=await el(t),s=l.getFiles(),c=await tx(l,n);if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(m){console.error(m)}await this.insertClipboardContent(c,s,n),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t?.preventDefault()}));S(this,"addElementsFromPasteOrLibrary",t=>{let n=qn(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=ua(n),s=pa(r,a)/2,c=pa(i,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,p=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:d,y:h}=Be({clientX:m,clientY:p},this.state),f=d-s,b=h-c,[E,w]=pt(f,b,this.getEffectiveGridSize()),{duplicatedElements:y}=bf({type:"everything",elements:n.map(k=>Vn(k,{x:k.x+E-r,y:k.y+w-i})),randomizeSeed:!t.retainSeed}),x=this.scene.getElementsIncludingDeleted(),v=[...x,...y];v=this.props.onDuplicate?.(v,x)||v,wT(v,hm(y));let C=this.getTopLayerFrameAtSceneCoords({x:d,y:h});if(C){let k=TH(y,C);Sf(v,k,C,this.state)}this.scene.replaceAllElements(v),y.forEach(k=>{if(xo(k)&&Ef(k)){let N=hT(k,this.scene.getElementsMapIncludingDeleted());fH(k,N,this.scene)}}),Xz&&un.loadElementsFonts(y).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let P=YH(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&$e.get(Dl)?this.state.openSidebar:null,...ro({editingGroupId:null,selectedElementIds:P.reduce((k,N)=>(Ef(N)||(k[N.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t.fitToContent&&this.scrollToContent(y,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});S(this,"setAppState",(t,n)=>{this.setState(t,n)});S(this,"removePointer",t=>{Kn&&this.resetContextMenuTimer(),fe.pointers.delete(t.pointerId)});S(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||le("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...Uo(this.state,n.activeTool.locked?{type:this.state.preferredSelectionTool.type}:n.activeTool),locked:!n.activeTool.locked}}))});S(this,"updateFrameRendering",t=>{this.setState(n=>{let r=typeof t=="function"?t(n.frameRendering):t;return{frameRendering:{enabled:r?.enabled??n.frameRendering.enabled,clip:r?.clip??n.frameRendering.clip,name:r?.name??n.frameRendering.name,outline:r?.outline??n.frameRendering.outline}}})});S(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});S(this,"onHandToolToggle",()=>{this.actionManager.executeAction(CE)});S(this,"zoomCanvas",t=>{this.setState({...qo({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:yo(t)},this.state)})});S(this,"cancelInProgressAnimation",null);S(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let s;if(Mf(t)?s=_H(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):Mf(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:s}=Ka({canvasOffsets:n.canvasOffsets,targetElements:r,appState:this.state,fitToViewport:!!n?.fitToViewport,viewportZoomFactor:n?.viewportZoomFactor,minZoom:n?.minZoom,maxZoom:n?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=jn(r,this.state);a=s.scrollX,l=s.scrollY}if(n?.animate){let s=this.state.scrollX,c=this.state.scrollY,m=this.state.zoom.value,p=Rz({fromValues:{scrollX:s,scrollY:c,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(d,h,f,b)=>{if(b==="zoom")return d*Math.pow(h/d,Bz(f))},onStep:({scrollX:d,scrollY:h,zoom:f})=>{this.setState({scrollX:d,scrollY:h,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:n?.duration??500});this.cancelInProgressAnimation=()=>{p(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});S(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});S(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});S(this,"setToast",t=>{this.setState({toast:t})});S(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),n=await t.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,pz,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});S(this,"addFiles",Re(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));S(this,"addMissingFiles",(t,n=!1)=>{let r=n?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!r[l.id]&&(i[l.id]=l,r[l.id]=l,l.mimeType===Ho.svg))try{let s=w1(uT(v1(l.dataURL)),Ho.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});S(this,"updateScene",Re(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let l=n||void 0,s=r?$z({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}r&&this.setState(r),n&&this.scene.replaceAllElements(n),i&&this.setState({collaborators:i})}));S(this,"applyDeltas",(t,n)=>{let r=MT.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return MT.applyTo(r,a,i,n)});S(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));S(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});S(this,"toggleSidebar",({name:t,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===n?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&n&&(a.tab=n),this.setState({openSidebar:a}),!!i});S(this,"updateCurrentCursorPosition",Re(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));S(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,n=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),r=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Xo().rtl?{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width),0)+i,bottom:i,left:Math.max(n?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width)+i,0),bottom:i,left:Math.max(r?.right??0,0)+i}});S(this,"onKeyDown",Re(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!q5(t.target)){if((t.key===X.ESCAPE||t.key===X.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=q(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&_r(a[0])&&t.key===X.ENTER){this.startImageCropping(a[0]);return}if(t.key===X.ESCAPE)this.updateEditorAtom(ho,null);else if(t.key===X.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(ff.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=Fi(a);$e.get(ho)?.type==="panel"&&Yu(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(ho,{type:"panel"})}if(t.key===X.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=cm(t.key);if(t[X.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=q(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&cH(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,ET(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!yf(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let s=q(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let c=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),ET(t.key));if(c){this.setState(p=>({selectedElementIds:ye({[c]:!0},p)}));let m=this.scene.getNonDeletedElementsMap().get(c);m&&!yf([m],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(m,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[X.CTRL_OR_CMD]&&t.key===X.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:Ae("commandPalette")})}),t.preventDefault();return}if(t[X.CTRL_OR_CMD]&&t.key.toLowerCase()===X.V&&(Nf=t.shiftKey,clearTimeout(_T),_T=window.setTimeout(()=>{Nf=!1},100)),t[X.CTRL_OR_CMD]&&Kl(t.target)&&(t.code===U5.MINUS||t.code===U5.EQUAL)){t.preventDefault();return}if(Kl(t.target)&&t.key!==X.ESCAPE||cm(t.key)&&q5(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(t.key===X.PAGE_UP||t.key===X.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===X.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||(t.key===X.ALT&&dn("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),this.actionManager.handleKeyDown(t))||this.state.viewModeEnabled)return;if(t[X.CTRL_OR_CMD]&&this.state.isBindingEnabled&&(dn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({isBindingEnabled:!1})),cm(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=new Set;a.filter(p=>Xn(p)).filter(p=>{let d=p.startBinding&&!a.some(f=>f.id===p.startBinding?.elementId),h=p.endBinding&&!a.some(f=>f.id===p.endBinding?.elementId);return d||h}).forEach(p=>l.add(p.id)),a=a.filter(p=>!l.has(p.id));let s=this.getEffectiveGridSize()&&(t.shiftKey?X5:this.getEffectiveGridSize())||(t.shiftKey?gz:X5),c=0,m=0;t.key===X.ARROW_LEFT?c=-s:t.key===X.ARROW_RIGHT?c=s:t.key===X.ARROW_UP?m=-s:t.key===X.ARROW_DOWN&&(m=s),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+c,y:p.y+m},{informMutation:!1,isDragging:!1}),fm(p,this.scene,{simultaneouslyUpdated:a})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===X.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[X.CTRL_OR_CMD]||Pf(l))Et(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),At(l)||this.actionManager.executeAction(Qi));else if(xo(l)||gH(l)){let s;xo(l)||(s=l);let c=If(l,this.state,this.scene.getNonDeletedElementsMap()),m=c.x,p=c.y;this.startTextEditing({sceneX:m,sceneY:p,container:s}),t.preventDefault();return}else Lt(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=I2(t.key,this);a?(this.state.activeTool.type!==a&&le("toolbar",a,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Yn.sharp?Yn.round:l.currentItemArrowType===Yn.round?Yn.elbow:Yn.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===X.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===X.SPACE&&fe.pointers.size===0&&(Rr=!0,xe(this.interactiveCanvas,Ne.GRAB),t.preventDefault()),(t.key===X.G||t.key===X.S)&&!t.altKey&&!t[X.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===X.G&&(wo(this.state.activeTool.type)||a.some(l=>wo(l.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 a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>xo(l)||vf(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===X.K&&!t.altKey&&!t[X.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:"laser"});return}let n=t.key.toLocaleLowerCase(),r=n===X.S&&t.shiftKey,i=t.key===X.I||n===X.G&&t.shiftKey;(r||i)&&this.openEyeDropper({type:r?"stroke":"background"})}));S(this,"onKeyUp",Re(t=>{if(t.key===X.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,Ne.GRAB):gm(this.state.activeTool.type)?Rt(this.interactiveCanvas):(Nt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Rr=!1),(t.key===X.ALT&&this.state.bindMode==="skip"||!t[X.CTRL_OR_CMD]&&!$l(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent)){let n=Be({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Eo(oe(n.x,n.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=pe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());Xn(i)&&dn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(i,r)}}if(!t[X.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),cm(t.key)){tT(this.scene.getSelectedElements(this.state).filter(ha),this.scene,this.state);let n=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Lf).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...LT(r,n.get(r.startBinding.elementId),"start",n)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...LT(r,n.get(r.endBinding.elementId),"end",n)}})}),this.setState({suggestedBinding:null})}if(t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:xt.IMMEDIATELY})),!t[X.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:ye({[n.id]:!0},r)})),yf([n],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(n,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:xt.IMMEDIATELY})}}));S(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);S(this,"setActiveTool",(t,n=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=Uo(this.state,t);r.type==="hand"?xe(this.interactiveCanvas,Ne.GRAB):Rr||Nt(this.interactiveCanvas,{...this.state,activeTool:r}),Az(document.activeElement)&&this.focusContainer(),lH(r.type)||this.setState({suggestedBinding:null}),r.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:gm(r.type)?i.selectedLinearElement:null};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,...a,activeTool:r,...n?{}:{selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null}}:r.type!=="selection"?{...i,...a,activeTool:r,selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null}:{...i,...a,activeTool:r}})});S(this,"setOpenDialog",t=>{this.setState({openDialog:t})});S(this,"setCursor",t=>{xe(this.interactiveCanvas,t)});S(this,"resetCursor",()=>{Rt(this.interactiveCanvas)});S(this,"isTouchScreenMultiTouchGesture",()=>fe.pointers.size>=2);S(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${J5()}`);S(this,"onGestureStart",Re(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null}),fe.initialScale=this.state.zoom.value}));S(this,"onGestureChange",Re(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=fe.initialScale;n&&this.setState(r=>({...qo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:yo(n*t.scale)},r)}))}));S(this,"onGestureEnd",Re(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}),fe.initialScale=null}));S(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&s&&(vf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let c=null,m=this.scene.getSelectedElements(this.state);m.length===1?xo(m[0])?c=m[0]:i?c=vf(m[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(t,n):c=this.getTextElementAtPosition(t,n);let p=c?.fontFamily||this.state.currentItemFontFamily,d=c?.lineHeight||$5(p),h=this.state.currentItemFontSize;if(!c&&l&&i&&!ha(i)){let w=BH(uf({fontSize:h,fontFamily:p}),d),y=FH(h,d),x=Math.max(i.height,y),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:x,width:v}),t=i.x+v/2,n=i.y+x/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:n}),b=c||rT({x:s?s.elementCenterX:t,y:s?s.elementCenterY:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:h,fontFamily:p,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?Iz.MIDDLE:V5,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:d,angle:i?ha(i)?0:i.angle:0,frameId:f?f.id:null});if(!c&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!c)if(i&&l){let E=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,E+1)}else this.scene.insertElement(b);a||c||i?this.handleTextWysiwyg(b,{isExistingElement:!!c}):this.setState({newElement:b,multiElement:null})});S(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});S(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});S(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=Be(t,this.state);if(n.length===1&&Et(n[0])){let l=n[0];if((t[X.CTRL_OR_CMD]&&Lf(l)||Pf(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(Qi);return}else if(this.state.selectedLinearElement&&At(n[0])){let s=pe.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=s?pe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),pe.deleteFixedSegment(n[0],this.scene,c);let m=pe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),p=m?pe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:p,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&Pf(l))return}if(n.length===1&&_r(n[0])){this.startImageCropping(n[0]);return}if(Rt(this.interactiveCanvas),UH(this.state).length>0){let l=this.getElementAtPosition(r,i),s=l&&GH(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...ro({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(Rt(this.interactiveCanvas),!t[X.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(ql(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(aT(s)||!Dz(s.backgroundColor)||Jl({point:oe(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let c=If(s,this.state,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});S(this,"getElementLinkAtPosition",(t,n)=>{if(n&&n.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let l=r[a];if(n&&l.id===n.id&&(i=a),l.link&&a>=i&&ds(l,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return l}});S(this,"redirectToLink",(t,n)=>{let r=Pr(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>hz)return;let i=Be(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=ds(this.hitLinkElement,a,this.state,oe(i.x,i.y),this.editorInterface.formFactor==="phone"),s=Be(this.lastPointerUpEvent,this.state),c=ds(this.hitLinkElement,a,this.state,oe(s.x,s.y),this.editorInterface.formFactor==="phone");if(l&&c){Du();let m=this.hitLinkElement.link;if(m){m=pf(m);let p;if(this.props.onLinkOpen&&(p=_z(re.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},p)),!p?.defaultPrevented){let d=Mz(m)?"_self":"_blank",h=window.open(void 0,d);h&&(h.opener=null,h.location=m)}}}});S(this,"getTopLayerFrameAtSceneCoords",t=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&gT(t,i,n));return r.length?r[r.length-1]:null});S(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let n=Be(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i},fe.pointers.has(t.pointerId)&&fe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let a=fe.initialScale;if(fe.pointers.size===2&&fe.lastCenter&&a&&fe.initialDistance){let f=Uh(fe.pointers),b=f.x-fe.lastCenter.x,E=f.y-fe.lastCenter.y;fe.lastCenter=f;let w=Wh(Array.from(fe.pointers.values())),y=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/fe.initialDistance,x=y?yo(a*y):this.state.zoom.value;this.setState(v=>{let I=qo({viewportX:f.x,viewportY:f.y,nextZoom:x},v);return this.translateCanvas({zoom:I.zoom,scrollX:I.scrollX+2*(b/x),scrollY:I.scrollY+2*(E/x),shouldCacheIgnoreZoom:!0}),null}),this.resetShouldCacheIgnoreZoomDebounced()}else fe.lastCenter=fe.initialDistance=fe.initialScale=null;if(Rr||os||Df||lo(this.state))return;let s=qh(ns,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?Rt(this.interactiveCanvas):Nt(this.interactiveCanvas,this.state)),!this.state.newElement&&jw(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=$w(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(E=>{let w=Zl(E.snapLines,b),y=E.originSnapOffset?Zl(E.originSnapOffset,f):f;return E.snapLines===w&&E.originSnapOffset===y?null:{snapLines:w,originSnapOffset:y}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let f=this.state.newElement?null:pe.handlePointerMoveInEditMode(t,r,i,this);f&&f!==this.state.selectedLinearElement&&no(()=>{this.setState({selectedLinearElement:f})})}if(aH(this.state.activeTool.type)){let{newElement:f}=this.state;if(!f&&$l(this.state)){let b=Eo(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),E=>Af(this.state.zoom));b?this.setState({suggestedBinding:b}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:f,selectedLinearElement:b}=this.state,{x:E,y:w,points:y}=f,x=y[y.length-1],{lastCommittedPoint:v}=b;if(Nt(this.interactiveCanvas,this.state),x===v)ha(this.state.newElement)&&$l(this.state)&&Eo(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),C=>Af(this.state.zoom))?(this.actionManager.executeAction(gt,"ui",{event:t.nativeEvent,sceneCoords:{x:r,y:i}}),this.setState({suggestedBinding:null,startBoundElement:null}),this.state.activeTool.locked||(Rt(this.interactiveCanvas),this.setState(C=>({newElement:null,activeTool:Uo(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ye({...C.selectedElementIds,[f.id]:!0},C),selectedLinearElement:new pe(f,this.scene.getNonDeletedElementsMap())})))):Pr(oe(r-E,i-w),x)>=mf?(this.scene.mutateElement(f,{points:[...y,oe(r-E,i-w)]},{informMutation:!1,isDragging:!1}),Wo(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:y[y.length-1],selectedPointsIndices:[f.points.length-1],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:f.points.length-1}}})):xe(this.interactiveCanvas,Ne.POINTER);else if(y.length>2&&v&&Pr(oe(r-E,i-w),v)<mf)xe(this.interactiveCanvas,Ne.POINTER),this.scene.mutateElement(f,{points:y.slice(0,-1)},{informMutation:!1,isDragging:!1}),this.setState({selectedLinearElement:{...b,selectedPointsIndices:b.selectedPointsIndices?.includes(f.points.length)?[...b.selectedPointsIndices.filter(I=>I!==f.points.length&&I!==f.points.length-1),f.points.length-1]:b.selectedPointsIndices,lastCommittedPoint:f.points[f.points.length-1],initialState:{...b.initialState,lastClickedPoint:f.points.length-1}}});else{mT(y,this.state.zoom.value)&&xe(this.interactiveCanvas,Ne.POINTER);let I=this.scene.getNonDeletedElementsMap();if(Lf(f)){let P=Eo(oe(r,i),this.scene.getNonDeletedElements(),I);dn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(f,P)}Wo(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let C=pe.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);C&&this.setState(C)}return}if(this.state.activeTool.type==="arrow"){let f=Eo(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),b=>Af(this.state.zoom));f&&!tG(oe(r,i),f,this.scene.getNonDeletedElementsMap())&&this.setState({suggestedBinding:f})}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),p=this.scene.getSelectedElements(this.state);if(p.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"&&!(p.length===1&&At(p[0]))&&!(Et(p[0])&&(this.editorInterface.userAgent.isMobileDevice||p[0].points.length===2))){let f=IT(m,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(f&&f.transformHandleType){xe(this.interactiveCanvas,vT(f));return}}}else if(p.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let f=TT(ua(p),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(f){xe(this.interactiveCanvas,vT({transformHandleType:f}));return}}let d=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),h=null;d&&d.locked?h=null:h=d,this.hitLinkElement=this.getElementLinkAtPosition(n,d),!wt(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(xe(this.interactiveCanvas,Ne.POINTER),Qx(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Du(),h&&(h.link||mn(h))&&this.state.selectedElementIds[h.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?xe(this.interactiveCanvas,xo(h)?Ne.TEXT:Ne.CROSSHAIR):this.state.viewModeEnabled?xe(this.interactiveCanvas,Ne.GRAB):this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,Ne.AUTO):s?xe(this.interactiveCanvas,Ne.AUTO):t[X.CTRL_OR_CMD]?xe(this.interactiveCanvas,Ne.AUTO):(h||this.isHittingCommonBoundingBoxOfSelectedElements(n,p))&&!h?.locked&&(h&&ql(h)&&this.isIframeLikeElementCenter(h,t,r,i)?(xe(this.interactiveCanvas,Ne.POINTER),this.setState({activeEmbeddable:{element:h,state:"hover"}})):(!h||!At(h)||!(h.startBinding||h.endBinding))&&((this.state.activeTool.type!=="lasso"||p.length>0)&&xe(this.interactiveCanvas,Ne.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}))),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)),this.state.openDialog?.name==="elementLinkSelector"&&h?this.setState(f=>({hoveredElementIds:Zl(f.hoveredElementIds,ro({editingGroupId:f.editingGroupId,selectedElementIds:{[h.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!h&&this.setState(f=>({hoveredElementIds:Zl(f.hoveredElementIds,{})})))});S(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});S(this,"handleTouchMove",t=>{rs=!0});S(this,"handleCanvasPointerDown",t=>{let n=Be(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i};let a=t.target;if(a.setPointerCapture&&a.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(f=>({searchMatches:f.searchMatches&&{focusedId:null,matches:f.searchMatches.matches.map(b=>({...b,focus:!1}))}})),this.updateEditorAtom(Tg,null)),$e.get(ho)&&this.updateEditorAtom(ho,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let f=this.state.newElement;this.updateScene({...f.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(b=>b.id!==f.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:ye(Object.keys(this.state.selectedElementIds).filter(b=>b!==f.id).reduce((b,E)=>(b[E]=this.state.selectedElementIds[E],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?xt.EVENTUALLY:xt.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(f=>({penMode:!0,penDetected:!0})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=gf(this.editorInterface,{isTouchScreen:!0})),os||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Lr.ERASER&&this.state.activeTool.type!==Go.eraser){this.setState({activeTool:Uo(this.state,{type:Go.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let f=()=>{b(),E?.(),wt(this.state)&&this.setState({activeTool:Uo(this.state,{...this.state.activeTool.lastActiveTool||{type:Go.selection},lastActiveToolBeforeEraser:null})})},b=Fe(window,re.POINTER_UP,f,{once:!0}),E;requestAnimationFrame(()=>{E=this.missingPointerEventCleanupEmitter.once(f)})});return}if(t.button!==Lr.MAIN&&t.button!==Lr.TOUCH&&t.button!==Lr.ERASER||fe.pointers.size>1)return;let s=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,s)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,s))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let f=s.hit.element&&this.isASelectedElement(s.hit.element);!s.hit.hasHitCommonBoundingBoxOfSelectedElements&&!s.resize.handleType&&!f&&(this.lassoTrail.startPath(s.origin.x,s.origin.y,t.shiftKey),s.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&s.hit.element&&!f&&(this.setState(b=>{let E={...b.selectedElementIds,[s.hit.element.id]:!0},w=[];Object.keys(b.selectedElementIds).forEach(x=>{let v=this.scene.getElement(x);v&&w.push(v)});let y=s.hit.element;if(Lt(y))Tf(w,y.id).forEach(x=>{delete E[x.id]});else if(y.frameId)E[y.frameId]&&delete E[y.id];else{let x=y.groupIds,v=new Set(x.flatMap(I=>Dr(this.scene.getNonDeletedElements(),I)).filter(I=>Lt(I)).map(I=>I.id));v.size>0&&w.forEach(I=>{I.frameId&&v.has(I.frameId)&&(delete E[I.id],I.groupIds.flatMap(C=>Dr(this.scene.getNonDeletedElements(),C)).forEach(C=>{delete E[C.id]}))})}return{...ro({editingGroupId:b.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),b,this),showHyperlinkPopup:y.link||mn(y)?"info":!1}}),s.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,s):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,s):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,s):this.state.activeTool.type==="custom"?Nt(this.interactiveCanvas,this.state):this.state.activeTool.type===Go.frame||this.state.activeTool.type===Go.magicframe?this.createFrameElementOnPointerDown(s,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(s.lastCoords.x,s.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,s);this.props?.onPointerDown?.(this.state.activeTool,s),this.onPointerDownEmitter.trigger(this.state.activeTool,s,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(s.lastCoords.x,s.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(s),p=this.onPointerUpFromPointerDownHandler(s),d=this.onKeyDownFromPointerDownHandler(s),h=this.onKeyUpFromPointerDownHandler(s);this.missingPointerEventCleanupEmitter.once(f=>p(f||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(re.POINTER_MOVE,m),window.addEventListener(re.POINTER_UP,p),window.addEventListener(re.KEYDOWN,d),window.addEventListener(re.KEYUP,h),s.eventListeners.onMove=m,s.eventListeners.onUp=p,s.eventListeners.onKeyUp=h,s.eventListeners.onKeyDown=d)});S(this,"handleCanvasPointerUp",t=>{dn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpEvent=t;let n=Be({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i};let a=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.editorInterface.formFactor==="phone"&&a<300){let l=this.getElementAtPosition(n.x,n.y);if(ql(l)&&this.isIframeLikeElementCenter(l,t,n.x,n.y)){this.handleEmbeddableCenterClick(l);return}}if(this.editorInterface.isTouchScreen){let l=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,l)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?a<300&&ql(this.hitLinkElement)&&!d1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,oe(n.x,n.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.editorInterface.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});S(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(rs=!1,Kn?rs=!0:Kn=window.setTimeout(()=>{Kn=0,rs||this.handleCanvasContextMenu(t)},vz))});S(this,"resetContextMenuTimer",()=>{clearTimeout(Kn),Kn=0,rs=!1});S(this,"maybeCleanupAfterMissingPointerUp",t=>{is?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});S(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(fe.pointers.size<=1&&(t.button===Lr.WHEEL||t.button===Lr.MAIN&&Rr||lo(this.state)||this.state.viewModeEnabled)))return!1;os=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);xe(this.interactiveCanvas,Ne.GRABBING);let{clientX:i,clientY:a}=t,l=Ad(c=>{let m=i-c.clientX,p=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!n&&(Math.abs(m)>1||Math.abs(p)>1)){n=!0;let d=f=>{document.body.removeEventListener(re.PASTE,d),f.stopPropagation()},h=()=>{setTimeout(()=>{document.body.removeEventListener(re.PASTE,d),window.removeEventListener(re.POINTER_UP,h)},100)};document.body.addEventListener(re.PASTE,d),window.addEventListener(re.POINTER_UP,h)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-p/this.state.zoom.value})}),s=Re(is=()=>{is=null,os=!1,Rr||(this.state.viewModeEnabled?xe(this.interactiveCanvas,Ne.GRAB):Nt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(re.POINTER_MOVE,l),window.removeEventListener(re.POINTER_UP,s),window.removeEventListener(re.BLUR,s),l.flush()});return window.addEventListener(re.BLUR,s),window.addEventListener(re.POINTER_MOVE,l,{passive:!0}),window.addEventListener(re.POINTER_UP,s),!0});S(this,"clearSelectionIfNotUsingSelection",()=>{gm(this.state.activeTool.type)||this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});S(this,"handleSelectionOnPointerDown",(t,n)=>{if(gm(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&&!At(a[0])&&!(Et(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=IT(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType))}else a.length>1&&(n.resize.handleType=TT(ua(a),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=hf(XH(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&Et(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=KH(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement,h=pe.handlePointerDown(t,this,this.store,n.origin,d,this.scene);if(h.hitElement&&(n.hit.element=h.hitElement),h.linearElementEditor&&this.setState({selectedLinearElement:h.linearElementEditor}),h.didAddPoint)return!0}let l=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),s=l.filter(d=>!d.locked),c=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:l});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!s.some(d=>this.state.selectedElementIds[d.id])?n.hit.element=null:n.hit.element=n.hit.element??this.getElementAtPosition(n.origin.x,n.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(n.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&n.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),n.hit.element&&this.getElementLinkAtPosition({x:n.origin.x,y:n.origin.y},n.hit.element))return!1;n.hit.allHitElements=s;let m=n.hit.element,p=n.hit.allHitElements.some(d=>this.isASelectedElement(d));if((m===null||!p)&&!t.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||m&&m?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState(d=>({selectedLinearElement:d.selectedLinearElement?{...d.selectedLinearElement,isEditing:!!m&&m.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:d.selectedLinearElement?ye({[d.selectedLinearElement.elementId]:!0},this.state):ye({},d)}));else if(m!=null){if(t[X.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(n.origin.x,n.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[m.id]||(n.hit.wasAddedToSelection=!0),this.setState(d=>({...HH(d,m),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!yT(m,this.state.editingGroupId)&&this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!p&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(d=>{let h={...d.selectedElementIds,[m.id]:!0},f=[];if(Object.keys(d.selectedElementIds).forEach(b=>{let E=this.scene.getElement(b);E&&f.push(E)}),Lt(m))Tf(f,m.id).forEach(b=>{delete h[b.id]});else if(m.frameId)h[m.frameId]&&delete h[m.id];else{let b=m.groupIds,E=new Set(b.flatMap(w=>Dr(this.scene.getNonDeletedElements(),w)).filter(w=>Lt(w)).map(w=>w.id));E.size>0&&f.forEach(w=>{w.frameId&&E.has(w.frameId)&&(delete h[w.id],w.groupIds.flatMap(y=>Dr(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete h[y.id]}))})}return d.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(b=>d.selectedGroupIds[b])||(h={[m.id]:!0})),{...ro({editingGroupId:d.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),d,this),showHyperlinkPopup:m.link||mn(m)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});S(this,"handleTextOnPointerDown",(t,n)=>{if(this.state.editingTextElement)return;let r=n.origin.x,i=n.origin.y,a=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);aT(a)&&(l=a,r=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Rt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Uo(this.state,{type:this.state.preferredSelectionTool.type})})});S(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,a]=pt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,c=Qz({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[oe(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(p=>{let d={...p.selectedElementIds};return delete d[c.id],{selectedElementIds:ye(d,p)}});let m=Eo(oe(r.origin.x,r.origin.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.setState({newElement:c,startBoundElement:m,suggestedBinding:null})});S(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[a,l]=pt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=eH({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.scene.insertElement(s),s});S(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,a]=pt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=bm(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=oT({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:r});return this.scene.insertElement(s),s});S(this,"newImagePlaceholder",({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,a]=pt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return nH({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,x:i-s/2,y:a-s/2,width:s,height:s})});S(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(t.ctrlKey&&no(()=>{this.setState({isBindingEnabled:!1})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(Wo(a,"selectedLinearElement is expected to be set"),i.type==="line"&&mT(i.points,this.state.zoom.value)){no(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(gt);return}if(At(i)&&i.points.length>1){this.actionManager.executeAction(gt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:l,y:s}=i,{lastCommittedPoint:c}=a,m=$l(this.state)&&Eo(oe(this.lastPointerMoveCoords?.x??l+i.points[i.points.length-1][0],this.lastPointerMoveCoords?.y??s+i.points[i.points.length-1][1]),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(Xn(i)&&m||i.points.length>1&&c&&Pr(oe(r.origin.x-l,r.origin.y-s),c)<mf){this.actionManager.executeAction(gt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(p=>({selectedElementIds:ye({...p.selectedElementIds,[i.id]:!0},p)})),xe(this.interactiveCanvas,Ne.POINTER)}else{let[i,a]=pt(r.origin.x,r.origin.y,t[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,p]=n==="arrow"?[s,c]:[null,null],d=n==="arrow"?tH({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Yn.round?{type:dm.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:p,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Yn.elbow,fixedSegments:this.state.currentItemArrowType===Yn.elbow?[]:null}):rH({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:dm.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null}),h=oe(r.origin.x,r.origin.y),f=this.scene.getNonDeletedElementsMap(),b=$l(this.state)?Eo(h,this.scene.getNonDeletedElements(),f):null;this.scene.mutateElement(d,{points:[oe(0,0),oe(0,0)]}),this.scene.insertElement(d),Xn(d)&&QH(d,new Map([[0,{point:oe(0,0),isDragging:!1}]]),h[0],h[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:Y5(t.nativeEvent)}),no(()=>{this.setState(E=>{let w=null,y=E.selectedElementIds;if(Et(d)){w=new pe(d,this.scene.getNonDeletedElementsMap());let x=d.points.length-1;w={...w,selectedPointsIndices:[x],initialState:{...w.initialState,lastClickedPoint:x,origin:oe(r.origin.x,r.origin.y)}}}return y=this.state.activeTool.locked?E.selectedElementIds:ye({[d.id]:!0},E),{...E,bindMode:"orbit",newElement:d,startBoundElement:b,suggestedBinding:b||null,selectedElementIds:y,selectedLinearElement:w}})}),Xn(d)&&dn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(d,b)}});S(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=pt(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),l={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=oT({type:"embeddable",...l}):s=oH({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});S(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=pt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...zo},l=n===Go.magicframe?nT(a):Jz(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});S(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});S(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(Xn(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);Em(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);Em(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}}else xf(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let l=this.scene.getElement(a.id);l?.startBinding?.elementId===i.id&&Em(l,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),l?.endBinding?.elementId===i.id&&Em(l,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||Ef(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,Vn(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});S(this,"initializeImage",async(t,n)=>{if(!Pm(n))throw new Error(g("errors.unsupportedFileType"));let r=n.type,i=n.size>=this.state.dontResizeLimitMBs*1024*1024;if(xe(this.interactiveCanvas,"wait"),r===Ho.svg)try{n=Dm(uT(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}else if(i)try{n=await bs(n,{maxWidthOrHeight:uz}),console.info("Excalidraw: image resized")}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>K5)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(K5/1024/1024)}MB`}));let a=await(this.props.generateIdForFile?.(n)||y1(n));if(console.info("Excalidraw File ID:",a),!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));let l=this.files[a]?.dataURL||await _m(n);return new Promise(async(s,c)=>{try{let m=this.getLatestInitializedImageElement(t,a);if(this.addMissingFiles([{mimeType:r,id:a,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(a)){this.addNewImagesToImageCache();let{erroredFiles:d}=await this.updateImageCache([m]);if(d.size)throw new Error("Image cache update resulted with an error.")}let p=await this.imageCache.get(a)?.image;if(p&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,a);let d=this.getImageNaturalDimensions(m,p);Object.assign(m,d)}s(m)}catch(m){console.error(m),c(new Error(g("errors.imageInsertError")))}})});S(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return Vn(r,{fileId:n})});S(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Be({clientX:t,clientY:n},this.state),a=await ss({description:"Image",extensions:Object.keys(fz),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Uo(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(gt)})}});S(this,"getImageNaturalDimensions",(t,n)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(n.naturalHeight,i),l=a*(n.naturalWidth/n.naturalHeight),s=t.x+t.width/2-l/2,c=t.y+t.height/2-a/2;return{x:s,y:c,width:l,height:a,crop:null}});S(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await hH({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(xt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>jl(a)&&i.has(a.fileId)?Vn(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});S(this,"addNewImagesToImageCache",async(t=uH(this.scene.getNonDeletedElements()),n=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,n);if(i.size)for(let a of r)i.has(a.fileId)&&Ql.delete(a);i.size&&this.scene.triggerUpdate()}});S(this,"scheduleImageRefresh",lz(()=>{this.addNewImagesToImageCache()},bz));S(this,"updateBindingEnabledOnPointerMove",t=>{let n=qz(t);this.state.isBindingEnabled!==n&&this.setState({isBindingEnabled:n})});S(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(re.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(re.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(re.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(re.TOUCH_END,this.onTouchEnd))});S(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,a=PT(t.map(()=>this.newImagePlaceholder({sceneX:n,sceneY:r})),n,r,i);a.forEach(d=>this.scene.insertElement(d));let l=await Promise.all(a.map(async(d,h)=>{try{return await this.initializeImage(d,await Ta(t[h]))}catch(f){return this.setState({errorMessage:f.message||g("errors.imageInsertError")}),Vn(d,{isDeleted:!0})}})),s=hm(l),c=PT(l.filter(d=>!d.isDeleted),n,r,i),m=hm(c),p=this.scene.getElementsIncludingDeleted().map(d=>m.get(d.id)??s.get(d.id)??d);this.updateScene({appState:{selectedElementIds:ye(Object.fromEntries(c.map(d=>[d.id,!0])),this.state)},elements:p,captureUpdate:xt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(gt)})});S(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=Be(t,this.state),i=await el(t),a=i.getFiles();if(a.length===1){let{file:p,fileHandle:d}=a[0];if(p&&(p.type===Ho.png||p.type===Ho.svg))try{let h=await fs(p,this.state,this.scene.getElementsIncludingDeleted(),d);this.syncActionResult({...h,appState:{...h.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:xt.IMMEDIATELY});return}catch(h){if(h.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}}let l=a.map(p=>p.file).filter(p=>Pm(p));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,n,r);let s=i.getData(Ho.excalidrawlibIds),c=i.getData(Ho.excalidrawlib);if(s||c){try{let p=null;if(s){let{itemIds:d}=JSON.parse(s);p=(await this.library.getLatestLibrary()).filter(f=>d.includes(f.id))}else c&&(p=x1(c));p?.length&&(p=p.map(d=>({...d,elements:bf({type:"everything",elements:d.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Ui(p),position:t,files:null}))}catch(p){this.setState({errorMessage:p.message})}return}if(a.length>0){let{file:p,fileHandle:d}=a[0];p&&await this.loadFileToCanvas(p,d)}let m=i.findByType(Ho.text);if(m){let p=m.value;if(p&&wf(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||bm(p)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:pf(p)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});S(this,"loadFileToCanvas",async(t,n)=>{t=await Ta(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Lm(t,this.state,r,n)}catch(a){let l=a instanceof l1;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let s=l?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===Ho.excalidraw?(FT(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:xt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:xt.IMMEDIATELY})):i.type===Ho.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});S(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Lr.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let{x:n,y:r}=Be(t,this.state),i=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:n,y:r},a),s=i||l?"element":"canvas",c=this.excalidrawContainerRef.current,{top:m,left:p}=c.getBoundingClientRect(),d=t.clientX-p,h=t.clientY-m;le("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...ro({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Et(i)?new pe(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:h,left:d,items:this.getContextMenuItems(s)}})})});S(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){ST({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:pa(t.origin.x,a.x),height:pa(t.origin.y,a.y),shouldMaintainAspectRatio:Xl(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,c]=pt(a.x,a.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=jl(l)&&this.imageCache.get(l.fileId)?.image,p=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:d,snapLines:h}=Zw(l,this,n,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=d.x,c+=d.y,this.setState({snapLines:h}),Xn(l)||ST({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:pa(t.originInGrid.x,s),height:pa(t.originInGrid.y,c),shouldMaintainAspectRatio:_r(l)?!Xl(n):Xl(n),shouldResizeFromCenter:W5(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:p,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===Go.frame||this.state.activeTool.type===Go.magicframe)&&this.setState({elementsToHighlight:Cf(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});S(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,l]=pt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&_r(s)){let c=t.originalElements.get(s.id),m=jl(s)&&this.imageCache.get(s.fileId)?.image;if(c&&_r(c)&&m&&!(m instanceof Promise)){let[p,d]=pt(i.x,i.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),h={x:p-t.originInGrid.x,y:d-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:f,snapLines:b}=Kh([s],[c],this,n,h,r);this.scene.mutateElement(s,LH(s,this.scene.getNonDeletedElementsMap(),r,m.naturalWidth,m.naturalHeight,a+f.x,l+f.y,n.shiftKey?c.width/c.height:void 0)),fm(s,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:b})}return!0}return!1});S(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(p=>Lt(p)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&At(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=pt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(p=>{Tf(this.scene.getNonDeletedElements(),p.id).forEach(h=>{m.set(p.id+h.id,{x:h.x-p.x,y:h.y-p.y})})}),!this.state.selectedElementsAreBeingDragged){let[p,d]=pt(l.x,l.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),h={x:p-t.originInGrid.x,y:d-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:b,snapLines:E}=Kh(r,q(f,this.state),this,n,h,a);s+=b.x,c+=b.y,this.setState({snapLines:E})}if(ZH(t.originalElements,a,r,this.scene,Y5(n),W5(n),r.some(p=>_r(p))?!Xl(n):Xl(n),s,c,t.resize.center.x,t.resize.center.y)){let p=new Set;return i.forEach(d=>{Cf(this.scene.getNonDeletedElements(),d,this.state,this.scene.getNonDeletedElementsMap()).forEach(h=>p.add(h))}),this.setState({elementsToHighlight:[...p]}),!0}return!1});S(this,"getContextMenuItems",t=>{let n=[];if(n.push(Ac,Lc),t==="canvas")return this.state.viewModeEnabled?[...n,Dc,Li,od,Ai]:[xu,Ye,Ac,Lc,_c,Ye,up,iy,Ye,Dc,yu,Li,od,Ai];if(n.push(_c),this.state.viewModeEnabled)return[Pi,...n];let r=this.editorInterface.formFactor==="desktop"?[Ye,cp,dp,mp,pp]:[];return[Ye,Pc,Pi,xu,Ye,Sw,Cw,kw,Ye,Fh,fu,Ye,...n,Ye,su,cu,Ye,mu,Nw,Iu,Tu,Yx,pu,Ye,gu,...r,Ye,bu,Eu,Ye,Qi,Ye,il,Gc,Ye,fv,hp,al,Ye,Da]});S(this,"handleWheel",Re(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&t.target.classList.contains(ff.FRAME_NAME))){t[X.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),os)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=Tz*100,l=Math.abs(r),s=r;l>a&&(s=a*i);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(m=>({...qo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:yo(c)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(r||n)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-n/i.value,scrollY:l-r/i.value}))}));S(this,"savePointer",(t,n,r)=>{if(!t||!n)return;let{x:i,y:a}=Be({clientX:t,clientY:n},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:r,pointersMap:fe.pointers})});S(this,"resetShouldCacheIgnoreZoomDebounced",j5(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));S(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let n=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:l}=n.getBoundingClientRect(),{width:s,height:c,offsetTop:m,offsetLeft:p}=this.state;if(r===s&&i===c&&a===p&&l===m){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});S(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});S(this,"watchState",()=>{});let n=zr(),{excalidrawAPI:r,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=n.theme,name:m=`${g("labels.untitled")}-${J5()}`,wheelZoomsOnDefault:p=!1}=t;if(this.state={...n,theme:c,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??n.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:p},this.refreshEditorInterface(),this.stylesPanelMode=ym(this.editorInterface),this.id=cz(),this.library=new Ay(this),this.actionManager=new Sd(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new kT,this.canvas=document.createElement("canvas"),this.rc=sz.canvas(this.canvas),this.renderer=new Cl(this.scene),this.visibleElements=[],this.store=new qH(this),this.history=new Il(this.store),r){let d={updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,addImageElementsToScene:this.insertImages,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:h=>{this.actionManager.registerAction(h)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:h=>this.onChangeEmitter.on(h),onIncrement:h=>this.store.onStoreIncrementEmitter.on(h),onPointerDown:h=>this.onPointerDownEmitter.on(h),onPointerUp:h=>this.onPointerUpEmitter.on(h),onScrollChange:h=>this.onScrollChangeEmitter.on(h),onUserFollow:h=>this.onUserFollowEmitter.on(h)};typeof r=="function"?r(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new un(this.scene),this.history=new Il(this.store),this.actionManager.registerAll(Ns),this.actionManager.registerAction(Aw(this.history)),this.actionManager.registerAction(_w(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(t.data)}catch{}if(n)switch(t.origin){case"https://player.vimeo.com":if(n.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:n.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(n.event==="infoDelivery"&&n.info&&n.id&&typeof n.info.playerState=="number"){let r=n.id,i=n.info.playerState;Object.values(pm).includes(i)&&Rf.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){Wo(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),n=Eo(oe(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=pe.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&n?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),no(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:n}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;Wo(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=n-this.state.selectedLinearElement.pointerOffset.y,l=this.state.multiElement?pe.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):pe.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);l&&this.setState(l)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,n){if(t.isDeleted||At(t))return;let r=()=>{if(this.bindModeHandler=null,Wo(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 f=this.state.selectedLinearElement.selectedPointsIndices.includes(0),b=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!f&&!b||f&&b)return}let{x:p,y:d}=this.lastPointerMoveCoords,h=Eo(oe(p,d),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(h&&this.state.bindMode!=="skip"){Wo(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let f=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===h.id;no(()=>{Wo(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:f}}})});let b=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;Wo(b,"Last event must exist");let E=p-this.state.selectedLinearElement.pointerOffset.x,w=d-this.state.selectedLinearElement.pointerOffset.y,y=this.state.multiElement?pe.handlePointerMove(b,this,E,w,this.state.selectedLinearElement):pe.handlePointDragging(b,this,E,w,this.state.selectedLinearElement);y&&this.setState(y)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let p=this.scene.getNonDeletedElementsMap(),d=this.state.selectedLinearElement.selectedPointsIndices.includes(0),h=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),f=d?n:t.startBinding&&p.get(t.startBinding.elementId),b=h?n:t.endBinding&&p.get(t.endBinding.elementId),E=f&&AT(f,p),w=b&&AT(b,p);i=!!(E&&w&&f.id!==b.id&&eG(E,w))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),l=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),s=a?"startBinding":l?"endBinding":null,c=a?"endBinding":l?"startBinding":null,m=c&&t[c]?.mode==="inside"&&t[c]?.elementId===n?.id||s&&t[s]?.mode==="inside"&&n?.id===t[s]?.elementId;s&&c&&t[s]?.mode==="inside"&&n?.id!==t[s]?.elementId&&t[c]?.elementId!==t[s]?.elementId&&this.scene.mutateElement(t,{[s]:{...t[s],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!n||this.previousHoveredBindableElement&&n.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&no(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!m&&(this.bindModeHandler=setTimeout(r,Uz)),this.previousHoveredBindableElement=n}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),ga(t)))return;let n=this.getHTMLIFrameElement(t);if(n?.contentWindow){if(n.src.includes("youtube")){let r=Rf.get(t.id);switch(r||(Rf.set(t.id,pm.UNSTARTED),n.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),r){case pm.PLAYING:case pm.BUFFERING:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}n.src.includes("player.vimeo.com")&&n.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,n,r,i){return t&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>mn(a)&&this.embedsValidationStatus.get(a.id)===!0||ga(a));return we(rG,{children:i.map(a=>{let{x:l,y:s}=um({sceneX:a.x,sceneY:a.y},this.state),c=cT(a,n,r,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(c&&!m&&this.initializedEmbeds.add(a.id),!(c||m))return null;let d;if(ga(a)){d=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let E=b.html;d={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>E}}else if(b.status==="pending")d={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>pT(`
|
|
19
|
+
`),i=[],a=0,l=0;for(let p of r){let d=a,h=d+p.length-1;i.push({line:p,startIndex:d,endIndex:h,lineNumber:l}),a=h+1,l++}let s=t,c=e.originalText.slice(t,t+o.length),m=[];for(let p of i){if(c==="")break;if(s>=p.startIndex&&s<=p.endIndex){let d=p.endIndex+1-s,h=p.line.slice(0,s-p.startIndex),f=c.slice(0,d);c=c.slice(d);let b=kl(h,Wd(e),e.lineHeight);if(h===""&&(b.width=0),e.textAlign!=="left"&&p.line.length>0){let v=kl(p.line,Wd(e),e.lineHeight),I=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=I}let{width:E,height:w}=kl(f,Wd(e),e.lineHeight),y=b.width,x=p.lineNumber*b.height;m.push({offsetX:y,offsetY:x,width:E,height:w,showOnCanvas:!0}),s+=d}}return m},uN=(e,o,t,n)=>{let r=e.name??_3(e),i=r.slice(t,t+o.length),a=r.slice(0,t),l=Wd({fontSize:Eg.nameFontSize,fontFamily:bg.Assistant}),s=oN(bg.Assistant),c=kl(a,l,s);a===""&&(c.width=0);let m=kl(i,l,s),p=c.width,d=-c.height-Eg.strokeWidth,h=m.width;return[{offsetX:p,offsetY:d,width:h,height:m.height,showOnCanvas:p+h<=e.width*n}]},hN=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),L3=q9((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(d=>A3(d)),i=n.filter(d=>Yd(d));r.sort((d,h)=>d.y-h.y),i.sort((d,h)=>d.y-h.y);let a=[],l=new RegExp(hN(e),"gi");for(let d of r){let h=null,f=d.originalText;for(;(h=l.exec(f))!==null;){let b=P3(f,h.index,e),E=pN(d,e,h.index);E.length>0&&a.push({element:d,searchQuery:e,preview:b,index:h.index,matchedLines:E})}}let s=[];for(let d of i){let h=null,f=d.name??_3(d);for(;(h=l.exec(f))!==null;){let b=P3(f,h.index,e),E=uN(d,e,h.index,o.state.zoom.value);E.length>0&&s.push({element:d,searchQuery:e,preview:b,index:h.index,matchedLines:E})}}let c=new Set(o.visibleElements.map(d=>d.id)),m=[...s,...a],p=m.findIndex(d=>c.has(d.element.id))??null;t(m,p)},lN);import{jsx as go,jsxs as N3}from"react/jsx-runtime";import{createElement as xN}from"react";var B3=yr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ge();return go(o.In,{children:go(Qt.Trigger,{...e,className:"default-sidebar-trigger",name:bN.name})})});B3.displayName="DefaultSidebarTrigger";var F3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Ge();return go(o.In,{children:e})};F3.displayName="DefaultTabTriggers";var Vd=Object.assign(yr("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=Te(),a=he(),{DefaultSidebarTabTriggersTunnel:l}=Ge(),s=i.openSidebar?.tab===yg;return xN(Qt,{...r,name:"default",key:"default",className:fN("default-sidebar",o),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&n!=null?void 0:EN(t,c=>{a({defaultSidebarDockedPreference:c})})},N3(Qt.Tabs,{children:[go(Qt.Header,{children:N3(Qt.TabTriggers,{children:[go(Qt.TabTrigger,{tab:yg,children:_t}),go(Qt.TabTrigger,{tab:R3,children:hs}),go(l.Out,{})]})}),go(Qt.Tab,{tab:R3,children:go(g2,{})}),go(Qt.Tab,{tab:yg,children:go(D3,{})}),e]}))}),{Trigger:B3,TabTriggers:F3});import{round as TI}from"@excalidraw/math";import DB from"clsx";import RB from"lodash.throttle";import{useEffect as SI,useMemo as Rg,useState as NB,memo as BB}from"react";import{STATS_PANELS as Qd}from"@excalidraw/common";import{getCommonBounds as FB}from"@excalidraw/element";import{getUncroppedWidthAndHeight as OB}from"@excalidraw/element";import{isImageElement as Ng}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as zB}from"@excalidraw/element";import{elementsAreInSameGroup as HB}from"@excalidraw/element";import{degreesToRadians as V3,radiansToDegrees as $3}from"@excalidraw/math";import{getBoundTextElement as X3}from"@excalidraw/element";import{isArrowElement as K3,isElbowArrow as _N}from"@excalidraw/element";import{updateBindings as Z3}from"@excalidraw/element";import CN from"clsx";import{useEffect as W3,useRef as Kd,useState as kN}from"react";import{EVENT as Qi,KEYS as MN,cloneJSON as wg}from"@excalidraw/common";import{deepCopyElement as PN}from"@excalidraw/element";import{CaptureUpdateAction as Y3}from"@excalidraw/element";import{pointFrom as Fn,pointRotateRads as Xd}from"@excalidraw/math";import{getBoundTextElement as yN,isBindingElement as wN,unbindBindingElement as O3}from"@excalidraw/element";import{isFrameLikeElement as G3}from"@excalidraw/element";import{getSelectedGroupIds as vN,getElementsInGroup as IN,isInGroup as TN}from"@excalidraw/element";import{getFrameChildren as SN}from"@excalidraw/element";import{updateBindings as z3}from"@excalidraw/element";import{DRAGGING_THRESHOLD as H3}from"@excalidraw/common";var U3=.01,Ml=10,Mt=(e,o)=>!(o==="angle"&&G3(e)),_e=(e,o)=>{let t=e+o/2;return t-t%o},qi=(e,o,t)=>Object.keys(e).map(n=>({original:(t??o).get(n),latest:o.get(n)})).filter(n=>n.original!==void 0&&n.latest!==void 0);var wr=(e,o,t,n,r,i,a=!0)=>{if(wN(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<H3&&Math.abs(o-t.y)<H3)return;O3(t,"start",n),O3(t,"end",n)}let l=n.getNonDeletedElementsMap(),s=l.get(t.id);if(!s)return;let[c,m]=[t.x+t.width/2,t.y+t.height/2],[p,d]=Xd(Fn(t.x,t.y),Fn(c,m),t.angle),h=e-p,f=o-d,[b,E]=Xd(Fn(e,o),Fn(c+h,m+f),-t.angle);n.mutateElement(s,{x:b,y:E},{informMutation:a,isDragging:!1}),z3(s,n,r);let w=yN(t,i);if(w){let y=l.get(w.id);y&&n.mutateElement(y,{x:w.x+h,y:w.y+f},{informMutation:a,isDragging:!1})}if(G3(t)){let y=SN(i,t.id);y.forEach(x=>{let v=l.get(x.id);if(!v)return;let[I,C]=[x.x+x.width/2,x.y+x.height/2],[P,k]=Xd(Fn(x.x,x.y),Fn(I,C),x.angle),N=Math.round(P+h),_=Math.round(k+f),[L,B]=Xd(Fn(N,_),Fn(I+h,C+f),-x.angle);n.mutateElement(v,{x:L,y:B},{informMutation:a,isDragging:!1}),z3(v,n,r,{simultaneouslyUpdated:y})})}},Ji=(e,o)=>{let n=vN(o).map(r=>IN(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!TN(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as vg,jsxs as AN}from"react/jsx-runtime";var LN=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:m=1,dragFinishedCallback:p})=>{let d=qe(),h=he(),f=Kd(null),b=Kd(null),[E,w]=kN(n.toString()),y=Kd(null);y.current||(y.current={originalAppState:wg(c),originalElements:r,lastUpdatedValue:E,updatePending:!1}),W3(()=>{let I=n.toString();w(I),y.current.lastUpdatedValue=I},[n]);let x=(I,C,P)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let k=Number(I);if(isNaN(k)){w(n.toString());return}let N=Number(k.toFixed(2)),_=Number(n);(isNaN(_)||Math.abs(N-_)>=U3)&&(y.current.lastUpdatedValue=I,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:N,property:l,originalAppState:P,setInputValue:L=>w(String(L)),app:d,setAppState:h}),d.syncActionResult({captureUpdate:Y3.IMMEDIATELY}))},v=Kd({});return v.current.handleInputValue=x,W3(()=>{let I=f.current,C=v.current;return()=>{let P=I?.value;P&&C.handleInputValue?.(P,y.current.originalElements,y.current.originalAppState),window.removeEventListener(Qi.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(Qi.POINTER_UP,C.onPointerUp,!1)}},[i]),i?AN("div",{className:CN("drag-input-container",!i&&"disabled"),"data-testid":e,children:[vg("div",{className:"drag-input-label",ref:b,onPointerDown:I=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(f.current.value);isNaN(C)&&(C=0);let P=null,k=d.scene.getNonDeletedElements().reduce((H,Y)=>(H.set(Y.id,PN(Y)),H),new Map),N=r.map(H=>k.get(H.id)),_=wg(c),L=0,B=0,G=H=>{if(P&&k!==null&&N!==null){let Y=H.clientX-P.x;Y!==0&&(B+=Y,Math.abs(B)>=m&&(B=Math.sign(B)*Math.floor(Math.abs(B)/m),L+=B,t({accumulatedChange:L,instantChange:B,originalElements:N,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:H.shiftKey,property:l,scene:s,originalAppState:_,setInputValue:D=>w(String(D)),app:d,setAppState:h}),B=0))}P={x:H.clientX,y:H.clientY}},j=()=>{window.removeEventListener(Qi.POINTER_MOVE,G,!1),d.syncActionResult({captureUpdate:Y3.IMMEDIATELY}),p?.({app:d,setAppState:h,originalElements:N,originalAppState:_}),P=null,L=0,B=0,N=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(Qi.POINTER_UP,j,!1)};v.current.onPointerMove=G,v.current.onPointerUp=j,window.addEventListener(Qi.POINTER_MOVE,G,!1),window.addEventListener(Qi.POINTER_UP,j,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?vg(si,{icon:o}):e}),vg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:I=>{if(i){let C=I.target;C instanceof HTMLInputElement&&I.key===MN.ENTER&&(x(C.value,r,c),d.focusContainer())}},ref:f,value:E,onChange:I=>{y.current.updatePending=!0,w(I.target.value)},onFocus:I=>{I.target.select(),y.current.originalElements=r,y.current.originalAppState=wg(c)},onBlur:I=>{E?i&&x(I.target.value,y.current.originalElements,y.current.originalAppState):w(n.toString())},disabled:!i})]}):null},ot=LN;import{jsx as BN}from"react/jsx-runtime";var DN=15,RN=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),l=o[0];if(l&&!_N(l)){let s=a.get(l.id);if(!s)return;if(n!==void 0){let f=V3(n);r.mutateElement(s,{angle:f}),Z3(s,r,i.state);let b=X3(s,a);b&&!K3(s)&&r.mutateElement(b,{angle:f});return}let c=Math.round($3(l.angle)*100)/100,m=Math.round(e),p=(c+m)%360;t&&(p=_e(p,DN)),p=p<0?p+360:p;let d=V3(p);r.mutateElement(s,{angle:d}),Z3(s,r,i.state);let h=X3(s,a);h&&!K3(s)&&r.mutateElement(h,{angle:d})}},NN=({element:e,scene:o,appState:t,property:n})=>BN(ot,{label:"A",icon:Cs,value:Math.round($3(e.angle)%360*100)/100,elements:[e],dragInputCallback:RN,editable:Mt(e,"angle"),scene:o,appState:t,property:n}),j3=NN;import{jsx as ON}from"react/jsx-runtime";var q3=5,FN=({property:e,scene:o,appState:t,setAppState:n})=>ON(ot,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{n(s=>{let c;return r?c=r:i&&(c=a?_e(s.gridStep+q3*Math.sign(i),q3):s.gridStep+i),c?(c=e1(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),J3=FN;import{clamp as Zd,round as Ig}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as $d}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as Q3,getUncroppedWidthAndHeight as oI}from"@excalidraw/element";import{resizeSingleElement as eI}from"@excalidraw/element";import{isImageElement as nI}from"@excalidraw/element";import{isFrameLikeElement as Tg}from"@excalidraw/element";import{getElementsInResizingFrame as Sg}from"@excalidraw/element";import{replaceAllElementsInFrame as rI}from"@excalidraw/element";import{jsx as WN}from"react/jsx-runtime";var tI=10,zN=e=>e.type==="image",HN=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:c,app:m,setAppState:p})=>{let d=c.getNonDeletedElementsMap(),h=o[0],f=d.get(h.id);if(h&&f){let b=n||zN(h),E=h.width/h.height;if(l.croppingElementId===h.id){let w=d.get(h.id);if(!w||!nI(w)||!w.crop)return;let y=w.crop,x={...y},v=w.scale[0]===-1,I=w.scale[1]===-1,{width:C,height:P}=oI(w),k=y.naturalWidth/C,N=y.naturalHeight/P,_=v?y.width+y.x:y.naturalWidth-y.x,L=I?y.height+y.y:y.naturalHeight-y.y,B=Q3*k,G=Q3*N;if(i!==void 0){if(a==="width"){let O=i*k,Q=Zd(O,B,_);x={...x,width:Q,x:v?y.x+y.width-Q:y.x}}else if(a==="height"){let O=i*N,Q=Zd(O,G,L);x={...x,height:Q,y:I?y.y+y.height-Q:y.y}}c.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}let j=a==="width"?s:0,H=a==="height"?s:0,Y=Zd(y.width+j,B,_),D=Zd(y.height+H,B,L);x={...y,x:v?y.x+y.width-Y:y.x,y:I?y.y+y.height-D:y.y,width:Y,height:D},c.mutateElement(w,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}if(i!==void 0){let w=Math.max(a==="width"?i:b?i*E:h.width,$d),y=Math.max(a==="height"?i:b?i/E:h.height,$d);if(eI(w,y,f,h,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Tg(f)){let x=Sg(c.getElementsIncludingDeleted(),f,l,c.getNonDeletedElementsMap()),v=rI(c.getElementsIncludingDeleted(),x,f,m);c.replaceAllElements(v)}return}{let w=a==="width"?e:0,y=a==="height"?e:0,x=Math.max(0,h.width+w);a==="width"&&(r?x=_e(x,tI):x=Math.round(x));let v=Math.max(0,h.height+y);if(a==="height"&&(r?v=_e(v,tI):v=Math.round(v)),b&&(a==="width"?v=Math.round(x/E*100)/100:x=Math.round(v*E*100)/100),v=Math.max($d,v),x=Math.max($d,x),eI(x,v,f,h,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Tg(f)){let I=Sg(c.getElementsIncludingDeleted(),f,l,c.getNonDeletedElementsMap());p({elementsToHighlight:I})}}}},GN=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Tg(a)){let l=Sg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=rI(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},UN=({property:e,element:o,scene:t,appState:n})=>{let r=Ig(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&nI(o)&&o.crop){let{width:i,height:a}=oI(o);if(e==="width"){let l=i/o.crop.naturalWidth;r=Ig(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;r=Ig(o.crop.height*l,2)}}return WN(ot,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:HN,value:r,editable:Mt(o,e),scene:t,appState:n,property:e,dragFinishedCallback:GN})},Cg=UN;import{getBoundTextElement as YN,redrawTextBoundingBox as VN}from"@excalidraw/element";import{hasBoundTextElement as XN,isTextElement as aI}from"@excalidraw/element";import{jsx as jN}from"react/jsx-runtime";var iI=4,KN=4,ZN=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!aI(l))return;let s;if(n!==void 0)s=Math.max(Math.round(n),iI);else if(a.type==="text"){let c=Math.round(a.fontSize),m=Math.round(e);s=Math.max(c+m,iI),t&&(s=_e(s,KN))}s&&(r.mutateElement(l,{fontSize:s}),VN(l,r.getContainerElement(l),r))}},$N=({element:e,scene:o,appState:t,property:n})=>{let r=aI(e)?e:XN(e)?YN(e,o.getNonDeletedElementsMap()):null;return r?jN(ot,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:ZN,icon:Jn,appState:t,scene:o,property:n}):null},lI=$N;import{degreesToRadians as sI,radiansToDegrees as mI}from"@excalidraw/math";import{getBoundTextElement as cI}from"@excalidraw/element";import{isArrowElement as dI}from"@excalidraw/element";import{isInGroup as kg}from"@excalidraw/element";import{jsx as eB}from"react/jsx-runtime";var qN=15,JN=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(c=>a.get(c.id)).filter(c=>c&&!kg(c)&&Mt(c,r)),s=o.filter(c=>!kg(c)&&Mt(c,r));if(n!==void 0){let c=sI(n);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:c});let p=cI(m,a);p&&!dI(m)&&i.mutateElement(p,{angle:c})}i.triggerUpdate();return}for(let c=0;c<l.length;c++){let m=l[c];if(!m)continue;let p=s[c],d=Math.round(mI(p.angle)*100)/100,h=Math.round(e),f=(d+h)%360;t&&(f=_e(f,qN)),f=f<0?f+360:f;let b=sI(f);i.mutateElement(m,{angle:b});let E=cI(m,a);E&&!dI(m)&&i.mutateElement(E,{angle:b})}i.triggerUpdate()},QN=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(s=>!kg(s)&&Mt(s,"angle")),i=r.map(s=>Math.round(mI(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>Mt(s,"angle"));return eB(ot,{label:"A",icon:Cs,value:a,elements:e,dragInputCallback:JN,editable:l,appState:t,scene:o,property:n})},pI=QN;import{pointFrom as uI}from"@excalidraw/math";import{useMemo as tB}from"react";import{MIN_WIDTH_OR_HEIGHT as On}from"@excalidraw/common";import{getElementsInResizingFrame as Mg,isFrameLikeElement as Pg,replaceAllElementsInFrame as fI,updateBoundElements as oB}from"@excalidraw/element";import{rescalePointsInElement as nB,resizeSingleElement as hI}from"@excalidraw/element";import{getBoundTextElement as rB,handleBindTextResize as iB}from"@excalidraw/element";import{isTextElement as bI}from"@excalidraw/element";import{getCommonBounds as jd}from"@excalidraw/element";import{jsx as mB}from"react/jsx-runtime";var ea=10,aB=(e,o,t,n)=>{let r=n.x-e,i=n.y-o,a=n.width*t,l=n.height*t,s=e+r*t,c=o+i*t;return{width:a,height:l,x:s,y:c,...nB(n,a,l,!1),...bI(n)?{fontSize:n.fontSize*t}:{}}},lB=(e,o,t,n,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),c=aB(e,o,n,i);l.mutateElement(r,c);let m=rB(i,a);if(m){let p=m.fontSize*n;oB(r,l);let d=s.get(m.id);d&&bI(d)&&(l.mutateElement(d,{fontSize:p}),iB(r,l,t==="width"?"e":"s",!0))}},gI=(e,o,t,n,r,i,a,l,s,c)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let m=o/t;for(let p=0;p<l.length;p++){let d=l[p],h=a[p];lB(r[0],r[1],i,m,h,d,s,c)}},sB=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:c})=>{let m=a.getNonDeletedElementsMap(),p=Ji(o,n);if(i!==void 0){for(let b of p){let E=qi(b,m,t);if(E.length>1){let w=E.map(B=>B.latest),y=E.map(B=>B.original),[x,v,I,C]=jd(y),P=I-x,k=C-v,N=P/k,_=Math.max(On,l==="width"?Math.max(0,i):P),L=Math.max(On,l==="height"?Math.max(0,i):k);gI(_,L,k,N,uI(x,v),l,w,y,t,a)}else{let[w]=E,y=w?.latest,x=w?.original;if(y&&x&&Mt(y,l)){let v=l==="width"?Math.max(0,i):y.width;l==="width"&&(r?v=_e(v,ea):v=Math.round(v));let I=l==="height"?Math.max(0,i):y.height;if(l==="height"&&(r?I=_e(I,ea):I=Math.round(I)),v=Math.max(On,v),I=Math.max(On,I),hI(v,I,y,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Pg(y)){let C=Mg(a.getElementsIncludingDeleted(),y,n,a.getNonDeletedElementsMap()),P=fI(a.getElementsIncludingDeleted(),C,y,c);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let d=l==="width"?e:0,h=l==="height"?e:0,f=[];for(let b of p){let E=qi(b,m,t);if(E.length>1){let w=E.map(B=>B.latest),y=E.map(B=>B.original),[x,v,I,C]=jd(y),P=I-x,k=C-v,N=P/k,_=Math.max(0,P+d);l==="width"&&(r?_=_e(_,ea):_=Math.round(_));let L=Math.max(0,k+h);l==="height"&&(r?L=_e(L,ea):L=Math.round(L)),_=Math.max(On,_),L=Math.max(On,L),gI(_,L,k,N,uI(x,v),l,w,y,t,a)}else{let[w]=E,y=w?.latest,x=w?.original;if(y&&x&&Mt(y,l)){let v=Math.max(0,x.width+d);l==="width"&&(r?v=_e(v,ea):v=Math.round(v));let I=Math.max(0,x.height+h);if(l==="height"&&(r?I=_e(I,ea):I=Math.round(I)),v=Math.max(On,v),I=Math.max(On,I),hI(v,I,y,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Pg(y)){let C=Mg(a.getElementsIncludingDeleted(),y,n,a.getNonDeletedElementsMap());f.push(...C)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},cB=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Pg(a)){let l=Mg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=fI(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},dB=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=tB(()=>n.map(c=>{let m=qi(c,t);if(m.length>1){let[d,h,f,b]=jd(m.map(E=>E.latest));return Math.round((e==="width"?f-d:b-h)*100)/100}let[p]=m;return Math.round((e==="width"?p.latest.width:p.latest.height)*100)/100}),[t,n,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return mB(ot,{label:e==="width"?"W":"H",elements:o,dragInputCallback:sB,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:cB})},Lg=dB;import{getBoundTextElement as pB,redrawTextBoundingBox as EI}from"@excalidraw/element";import{hasBoundTextElement as uB,isTextElement as hB}from"@excalidraw/element";import{isInGroup as gB}from"@excalidraw/element";import{jsx as yB}from"react/jsx-runtime";var xI=4,fB=4,bB=(e,o)=>e.reduce((t,n)=>{if(!n||gB(n))return t;if(hB(n))return t.push(n),t;if(uB(n)){let r=pB(n,o);if(r)return t.push(r),t}return t},[]),EB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(n){l=Math.max(Math.round(n),xI);for(let s of a)r.mutateElement(s,{fontSize:l}),EI(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=o;for(let c=0;c<a.length;c++){let m=a[c],p=s[c],d=Math.round(p.fontSize),h=Math.round(e),f=Math.max(d+h,xI);t&&(f=_e(f,fB)),r.mutateElement(m,{fontSize:f}),EI(m,r.getContainerElement(m),r)}r.triggerUpdate()}},xB=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=bB(e,r);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return yB(ot,{label:"F",icon:Jn,elements:i,dragInputCallback:EB,value:l,editable:s,scene:o,property:n,appState:t})},yI=xB;import{pointFrom as zn,pointRotateRads as qd}from"@excalidraw/math";import{useMemo as wB}from"react";import{isTextElement as vB}from"@excalidraw/element";import{getCommonBounds as Ag}from"@excalidraw/element";import{jsx as kB}from"react/jsx-runtime";var IB=(e,o,t,n,r,i,a)=>{for(let l=0;l<n.length;l++){let s=n[l],[c,m]=[s.x+s.width/2,s.y+s.height/2],[p,d]=qd(zn(s.x,s.y),zn(c,m),s.angle),h=e==="x"?Math.round(p+o):p,f=e==="y"?Math.round(d+t):d;wr(h,f,s,i,a,r,!1)}},TB=(e,o,t,n,r,i)=>{let a=r.getNonDeletedElementsMap(),[l,s,,]=Ag(t),c=e-l,m=o-s;for(let p=0;p<t.length;p++){let d=t[p],h=a.get(d.id);if(h&&(!vB(h)||!h.containerId)){let[f,b]=[h.x+h.width/2,h.y+h.height/2],[E,w]=qd(zn(h.x,h.y),zn(f,b),h.angle);wr(E+c,w+m,d,r,i,n,!1)}}},SB=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a,originalAppState:l,app:s})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let h of Ji(o,l)){let f=qi(h,c,t);if(f.length>1){let[b,E,,]=Ag(f.map(x=>x.latest));TB(i==="x"?r:b,i==="y"?r:E,f.map(x=>x.original),t,a,s.state)}else{let b=f[0]?.original,E=f[0]?.latest;if(b&&E&&Mt(E,i)){let[w,y]=[b.x+b.width/2,b.y+b.height/2],[x,v]=qd(zn(b.x,b.y),zn(w,y),b.angle);wr(i==="x"?r:x,i==="y"?r:v,b,a,s.state,t,!1)}}}a.triggerUpdate();return}let m=n?_e(e,Ml):e;IB(i,i==="x"?m:0,i==="y"?m:0,o,t,a,s.state),a.triggerUpdate()},CB=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=wB(()=>n.map(s=>{let c=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(c.length>1){let[b,E]=Ag(c);return Math.round((e==="x"?b:E)*100)/100}let[m]=c,[p,d]=[m.x+m.width/2,m.y+m.height/2],[h,f]=qd(zn(m.x,m.y),zn(p,d),m.angle);return Math.round((e==="x"?h:f)*100)/100}),[n,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return kB(ot,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:SB,value:l,property:e,scene:r,appState:i})},_g=CB;import{clamp as Pl,pointFrom as Jd,pointRotateRads as vI,round as wI}from"@excalidraw/math";import{getFlipAdjustedCropPosition as MB,getUncroppedWidthAndHeight as PB}from"@excalidraw/element";import{isImageElement as II}from"@excalidraw/element";import{jsx as _B}from"react/jsx-runtime";var LB=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s,app:c})=>{let m=l.getNonDeletedElementsMap(),p=t[0],[d,h]=[p.x+p.width/2,p.y+p.height/2],[f,b]=vI(Jd(p.x,p.y),Jd(d,h),p.angle);if(s.croppingElementId===p.id){let v=m.get(p.id);if(!v||!II(v)||!v.crop)return;let I=v.crop,C=I,P=v.scale[0]===-1,k=v.scale[1]===-1,{width:N,height:_}=PB(v);if(i!==void 0){if(a==="x"){let G=i*(I.naturalWidth/N);P?C={...I,x:Pl(I.naturalWidth-G-I.width,0,I.naturalWidth-I.width)}:C={...I,x:Pl(i*(I.naturalWidth/N),0,I.naturalWidth-I.width)}}a==="y"&&(C={...I,y:Pl(i*(I.naturalHeight/_),0,I.naturalHeight-I.height)}),l.mutateElement(v,{crop:C});return}let L=(a==="x"?o:0)*(P?-1:1),B=(a==="y"?o:0)*(k?-1:1);C={...I,x:Pl(I.x+L,0,I.naturalWidth-I.width),y:Pl(I.y+B,0,I.naturalHeight-I.height)},l.mutateElement(v,{crop:C});return}if(i!==void 0){wr(a==="x"?i:f,a==="y"?i:b,p,l,c.state,n);return}let E=a==="x"?e:0,w=a==="y"?e:0,y=a==="x"?Math.round(r?_e(p.x+E,Ml):f+E):f,x=a==="y"?Math.round(r?_e(p.y+w,Ml):b+w):b;wr(y,x,p,l,c.state,n)},AB=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,a]=vI(Jd(o.x,o.y),Jd(o.x+o.width/2,o.y+o.height/2),o.angle),l=wI(e==="x"?i:a,2);if(r.croppingElementId===o.id&&II(o)&&o.crop){let s=MB(o);s&&(l=wI(e==="x"?s.x:s.y,2))}return _B(ot,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:LB,scene:n,value:l,property:e,appState:r})},Dg=AB;import{Fragment as Bg,jsx as te,jsxs as Pt}from"react/jsx-runtime";var GB=50,Ll=e=>{let o=vo(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=_n(e.app);return te(UB,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},Me=({children:e,columns:o=1,heading:t,style:n,...r})=>te("div",{className:DB("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});Me.displayName="StatsRow";var em=({children:e,order:o,style:t,...n})=>te("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});em.displayName="StatsRows";Ll.StatsRow=Me;Ll.StatsRows=em;var UB=BB(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),m=he(),p=n.length===1?n[0]:null,d=n.length>1?n:null,h=r.croppingElementId&&Ng(p),f=h?OB(p):null,[b,E]=NB({width:0,height:0}),w=Rg(()=>RB(v=>{let I=FB(v);E({width:Math.round(I[2])-Math.round(I[0]),height:Math.round(I[3])-Math.round(I[1])})},GB),[]);SI(()=>{w(s)},[i,s,w]),SI(()=>()=>w.cancel(),[w]);let y=Rg(()=>Ji(n,r),[n,r]),x=Rg(()=>zB(n),[n]);return te("div",{className:"exc-stats",children:Pt(ze,{padding:3,children:[Pt("div",{className:"title",children:[te("h2",{children:g("stats.title")}),te("div",{className:"close",onClick:o,children:Ut})]}),Pt(Ba,{label:te("h3",{children:g("stats.generalStats")}),open:!!(r.stats.panels&Qd.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Qd.generalStats}})),children:[Pt(em,{children:[te(Me,{heading:!0,children:g("stats.scene")}),Pt(Me,{columns:2,children:[te("div",{children:g("stats.shapes")}),te("div",{children:s.length})]}),Pt(Me,{columns:2,children:[te("div",{children:g("stats.width")}),te("div",{children:b.width})]}),Pt(Me,{columns:2,children:[te("div",{children:g("stats.height")}),te("div",{children:b.height})]}),a&&Pt(Bg,{children:[te(Me,{heading:!0,children:"Canvas"}),te(Me,{children:te(J3,{property:"gridStep",scene:l,appState:r,setAppState:m})})]})]}),t?.(s,r)]}),!x&&n.length>0&&te("div",{id:"elementStats",style:{marginTop:12},children:te(Ba,{label:te("h3",{children:g("stats.elementProperties")}),open:!!(r.stats.panels&Qd.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Qd.elementProperties}})),children:Pt(em,{children:[p&&Pt(Bg,{children:[h&&te(Me,{heading:!0,children:g("labels.unCroppedDimension")}),r.croppingElementId&&Ng(p)&&f&&Pt(Me,{columns:2,children:[te("div",{children:g("stats.width")}),te("div",{children:TI(f.width,2)})]}),r.croppingElementId&&Ng(p)&&f&&Pt(Me,{columns:2,children:[te("div",{children:g("stats.height")}),te("div",{children:TI(f.height,2)})]}),te(Me,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?g("labels.imageCropping"):g(`element.${p.type}`)}),te(Me,{children:te(Dg,{element:p,property:"x",elementsMap:c,scene:l,appState:r})}),te(Me,{children:te(Dg,{element:p,property:"y",elementsMap:c,scene:l,appState:r})}),te(Me,{children:te(Cg,{property:"width",element:p,scene:l,appState:r})}),te(Me,{children:te(Cg,{property:"height",element:p,scene:l,appState:r})}),te(Me,{children:te(j3,{property:"angle",element:p,scene:l,appState:r})}),te(Me,{children:te(lI,{property:"fontSize",element:p,scene:l,appState:r})})]}),d&&Pt(Bg,{children:[HB(d)&&te(Me,{heading:!0,children:g("element.group")}),Pt(Me,{columns:2,style:{margin:"0.3125rem 0"},children:[te("div",{children:g("stats.shapes")}),te("div",{children:n.length})]}),te(Me,{children:te(_g,{property:"x",elements:d,elementsMap:c,atomicUnits:y,scene:l,appState:r})}),te(Me,{children:te(_g,{property:"y",elements:d,elementsMap:c,atomicUnits:y,scene:l,appState:r})}),te(Me,{children:te(Lg,{property:"width",elements:d,elementsMap:c,atomicUnits:y,scene:l,appState:r})}),te(Me,{children:te(Lg,{property:"height",elements:d,elementsMap:c,atomicUnits:y,scene:l,appState:r})}),te(Me,{children:te(pI,{property:"angle",elements:d,scene:l,appState:r})}),te(Me,{children:te(yI,{property:"fontSize",elements:d,scene:l,appState:r,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as WB,useEffect as CI,useState as kI}from"react";import{normalizeLink as YB,KEYS as Fg}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as VB,getLinkIdAndTypeFromSelection as XB}from"@excalidraw/element";import{jsx as ta,jsxs as tm}from"react/jsx-runtime";var KB=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=VB})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=kI(a),[c,m]=kI(!1);CI(()=>{let d=q(i,t),h=a;if(d.length>0&&r){let f=XB(d,t);f&&(h=YB(r(f.id,f.type)))}s(h)},[i,t,t.selectedElementIds,a,r]);let p=WB(()=>{if(l&&l!==i.get(e)?.link){let d=i.get(e);d&&n.mutateElement(d,{link:l})}if(!l&&c&&e){let d=i.get(e);d&&n.mutateElement(d,{link:null})}o?.()},[e,l,i,c,n,o]);return CI(()=>{let d=h=>{t.openDialog?.name==="elementLinkSelector"&&h.key===Fg.ENTER&&p(),t.openDialog?.name==="elementLinkSelector"&&h.key===Fg.ESCAPE&&o?.()};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[t,o,p]),tm("div",{className:"ElementLinkDialog",children:[tm("div",{className:"ElementLinkDialog__header",children:[ta("h2",{children:g("elementLink.title")}),ta("p",{children:g("elementLink.desc")})]}),tm("div",{className:"ElementLinkDialog__input",children:[ta(Pn,{value:l??"",onChange:d=>{c||m(!0),s(d)},onKeyDown:d=>{d.key===Fg.ENTER&&p()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&ta(V,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:Yo})]}),tm("div",{className:"ElementLinkDialog__actions",children:[ta(qo,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),ta(qo,{label:g("buttons.confirm"),onClick:p,actionType:"primary"})]})]})},MI=KB;import ZB,{useState as $B}from"react";import{Fragment as jB,jsx as Og}from"react/jsx-runtime";var PI=({children:e,onClose:o})=>{let[t,n]=$B(!!e),{container:r}=ke(),i=ZB.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return Og(jB,{children:t&&Og(We,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:Og("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import qB from"clsx";import{jsx as JB}from"react/jsx-runtime";var LI=({children:e,side:o,className:t})=>JB("div",{className:qB("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import DI,{useMemo as iF}from"react";import RI from"clsx";import{isDarwin as NI,isFirefox as BI,isWindows as aF}from"@excalidraw/common";import{KEYS as oa}from"@excalidraw/common";import{SHAPES as lF}from"@excalidraw/element/shapes";import{isFirefox as AI,KEYS as _I}from"@excalidraw/common";import{SHAPES as QB}from"@excalidraw/element/shapes";import{Fragment as rF,jsx as Pe,jsxs as vr}from"react/jsx-runtime";var eF=e=>vr(rF,{children:[Pe("h3",{children:e.title}),Pe("div",{className:"HelpDialog__islands-container",children:e.children})]}),zg=e=>vr("div",{className:`HelpDialog__island ${e.className}`,children:[Pe("h4",{className:"HelpDialog__island-title",children:e.caption}),Pe("div",{className:"HelpDialog__island-content",children:e.children})]});function*tF(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var oF=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),nt=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Pe(nF,{children:oF(a)},a)));return vr("div",{className:"HelpDialog__shortcut",children:[Pe("div",{children:e}),Pe("div",{className:"HelpDialog__key-container",children:[...tF(n,t?g("helpDialog.or"):null)]})]})},nF=e=>Pe("kbd",{className:"HelpDialog__key",...e});function Hg(){return vr(eF,{title:g("helpDialog.shortcuts"),children:[vr(zg,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[Pe(nt,{label:g("toolBar.hand"),shortcuts:[_I.H]}),QB.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:o})=>Pe(nt,{label:g(`toolBar.${e}`),shortcuts:[...o]},e)),Pe(nt,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),A("Enter")],isOr:!0}),Pe(nt,{label:g("helpDialog.cropFinish"),shortcuts:[A("Enter"),A("Escape")],isOr:!0})]}),vr(zg,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[Pe(nt,{label:g("helpDialog.smartZoom"),shortcuts:[_I.F]}),Pe(nt,{label:g("buttons.zenMode"),shortcuts:[A("Alt+Z")]}),Pe(nt,{label:g("buttons.objectsSnapMode"),shortcuts:[A("Alt+S")]}),Pe(nt,{label:g("commandPalette.title"),shortcuts:AI?[Ae("commandPalette")]:[Ae("commandPalette"),Ae("commandPalette",1)]})]}),vr(zg,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[Pe(nt,{label:g("labels.pasteAsPlaintext"),shortcuts:[A("CtrlOrCmd+Shift+V")]}),Pe(nt,{label:g("labels.multiSelect"),shortcuts:[A(`Shift+${g("helpDialog.click")}`)]}),Pe(nt,{label:g("helpDialog.deepSelect"),shortcuts:[A(`CtrlOrCmd+${g("helpDialog.click")}`)]}),Pe(nt,{label:g("helpDialog.deepBoxSelect"),shortcuts:[A(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(Sn||AI)&&Pe(nt,{label:g("labels.copyAsPng"),shortcuts:[A("Shift+Alt+C")]}),Pe(nt,{label:g("helpDialog.toggleElementLock"),shortcuts:[A("CtrlOrCmd+Shift+L")]}),Pe(nt,{label:g("labels.group"),shortcuts:[A("CtrlOrCmd+G")]}),Pe(nt,{label:g("labels.ungroup"),shortcuts:[A("CtrlOrCmd+Shift+G")]}),Pe(nt,{label:g("labels.flipHorizontal"),shortcuts:[A("Shift+H")]}),Pe(nt,{label:g("labels.flipVertical"),shortcuts:[A("Shift+V")]})]})]})}import{Fragment as OI,jsx as W,jsxs as Ir}from"react/jsx-runtime";var sF=e=>Ir(OI,{children:[W("h3",{children:e.title}),W("div",{className:"HelpDialog__islands-container",children:e.children})]}),Gg=e=>Ir("div",{className:`HelpDialog__island ${e.className}`,children:[W("h4",{className:"HelpDialog__island-title",children:e.caption}),W("div",{className:"HelpDialog__island-content",children:e.children})]});function*cF(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var dF=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),$=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>W(mF,{children:dF(a)},a)));return Ir("div",{className:"HelpDialog__shortcut",children:[W("div",{children:e}),W("div",{className:"HelpDialog__key-container",children:[...cF(n,t?g("helpDialog.or"):null)]})]})},mF=e=>W("kbd",{className:"HelpDialog__key",...e}),FI=({onClose:e})=>{let[o,t]=DI.useState(!1),n=DI.useCallback(()=>{e&&e()},[e]),r=iF(()=>o?W("button",{className:RI("toggle-button",{}),onClick:()=>t(!1),children:g("helpDialog.myoc.showingAll")}):W("button",{className:RI("toggle-button",{}),onClick:()=>t(!0),children:g("helpDialog.myoc.showingBasic")}),[o]);return W(OI,{children:W(We,{onCloseRequest:n,title:g("helpDialog.title"),className:"HelpDialog",titleButton:r,children:o?Ir(sF,{title:g("helpDialog.shortcuts"),children:[Ir(Gg,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[W($,{label:g("toolBar.hand"),shortcuts:[oa.H]}),lF.map(({value:i,key:a})=>W($,{label:g(`toolBar.${i}`),shortcuts:[...a]},i)),W($,{label:g("toolBar.frame"),shortcuts:[oa.F]}),W($,{label:g("toolBar.laser"),shortcuts:[oa.K]}),W($,{label:g("labels.eyeDropper"),shortcuts:[oa.I,"Shift+S","Shift+G"]}),W($,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[A("CtrlOrCmd+Enter")]}),W($,{label:g("helpDialog.editText"),shortcuts:[A("Enter")]}),W($,{label:g("helpDialog.textNewLine"),shortcuts:[A("Enter"),A("Shift+Enter")]}),W($,{label:g("helpDialog.textFinish"),shortcuts:[A("Esc"),A("CtrlOrCmd+Enter")]}),W($,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),W($,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),W($,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),A("Enter")],isOr:!0}),W($,{label:g("helpDialog.cropFinish"),shortcuts:[A("Enter"),A("Escape")],isOr:!0}),W($,{label:g("toolBar.lock"),shortcuts:[oa.Q]}),W($,{label:g("helpDialog.preventBinding"),shortcuts:[A("CtrlOrCmd")]}),W($,{label:g("toolBar.link"),shortcuts:[A("CtrlOrCmd+K")]}),W($,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ir(Gg,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[W($,{label:g("helpDialog.smartZoom"),shortcuts:[oa.F]}),W($,{label:g("buttons.zoomIn"),shortcuts:[A("CtrlOrCmd++")]}),W($,{label:g("buttons.zoomOut"),shortcuts:[A("CtrlOrCmd+-")]}),W($,{label:g("buttons.resetZoom"),shortcuts:[A("CtrlOrCmd+0")]}),W($,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),W($,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),W($,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),W($,{label:g("buttons.zenMode"),shortcuts:[A("Alt+Z")]}),W($,{label:g("buttons.objectsSnapMode"),shortcuts:[A("Alt+S")]}),W($,{label:g("labels.toggleGrid"),shortcuts:[A("CtrlOrCmd+'")]}),W($,{label:g("labels.viewMode"),shortcuts:[A("Alt+R")]}),W($,{label:g("stats.fullTitle"),shortcuts:[A("Alt+/")]}),W($,{label:g("search.title"),shortcuts:[Ae("searchMenu")]}),W($,{label:g("commandPalette.title"),shortcuts:BI?[Ae("commandPalette")]:[Ae("commandPalette"),Ae("commandPalette",1)]})]}),Ir(Gg,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[W($,{label:g("labels.moveCanvas"),shortcuts:[A(`Space+${g("helpDialog.drag")}`),A(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),W($,{label:g("labels.delete"),shortcuts:[A("Delete")]}),W($,{label:g("labels.cut"),shortcuts:[A("CtrlOrCmd+X")]}),W($,{label:g("labels.copy"),shortcuts:[A("CtrlOrCmd+C")]}),W($,{label:g("labels.paste"),shortcuts:[A("CtrlOrCmd+V")]}),W($,{label:g("labels.pasteAsPlaintext"),shortcuts:[A("CtrlOrCmd+Shift+V")]}),W($,{label:g("labels.selectAll"),shortcuts:[A("CtrlOrCmd+A")]}),W($,{label:g("labels.multiSelect"),shortcuts:[A(`Shift+${g("helpDialog.click")}`)]}),W($,{label:g("helpDialog.deepSelect"),shortcuts:[A(`CtrlOrCmd+${g("helpDialog.click")}`)]}),W($,{label:g("helpDialog.deepBoxSelect"),shortcuts:[A(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(Sn||BI)&&W($,{label:g("labels.copyAsPng"),shortcuts:[A("Shift+Alt+C")]}),W($,{label:g("labels.copyStyles"),shortcuts:[A("CtrlOrCmd+Alt+C")]}),W($,{label:g("labels.pasteStyles"),shortcuts:[A("CtrlOrCmd+Alt+V")]}),W($,{label:g("labels.sendToBack"),shortcuts:[NI?A("CtrlOrCmd+Alt+["):A("CtrlOrCmd+Shift+[")]}),W($,{label:g("labels.bringToFront"),shortcuts:[NI?A("CtrlOrCmd+Alt+]"):A("CtrlOrCmd+Shift+]")]}),W($,{label:g("labels.sendBackward"),shortcuts:[A("CtrlOrCmd+[")]}),W($,{label:g("labels.bringForward"),shortcuts:[A("CtrlOrCmd+]")]}),W($,{label:g("labels.alignTop"),shortcuts:[A("CtrlOrCmd+Shift+Up")]}),W($,{label:g("labels.alignBottom"),shortcuts:[A("CtrlOrCmd+Shift+Down")]}),W($,{label:g("labels.alignLeft"),shortcuts:[A("CtrlOrCmd+Shift+Left")]}),W($,{label:g("labels.alignRight"),shortcuts:[A("CtrlOrCmd+Shift+Right")]}),W($,{label:g("labels.arrangeElements"),shortcuts:[A("Shift+R")]}),W($,{label:g("labels.duplicateSelection"),shortcuts:[A("CtrlOrCmd+D"),A(`Alt+${g("helpDialog.drag")}`)]}),W($,{label:g("helpDialog.toggleElementLock"),shortcuts:[A("CtrlOrCmd+Shift+L")]}),W($,{label:g("buttons.undo"),shortcuts:[A("CtrlOrCmd+Z")]}),W($,{label:g("buttons.redo"),shortcuts:aF?[A("CtrlOrCmd+Y"),A("CtrlOrCmd+Shift+Z")]:[A("CtrlOrCmd+Shift+Z")]}),W($,{label:g("labels.group"),shortcuts:[A("CtrlOrCmd+G")]}),W($,{label:g("labels.ungroup"),shortcuts:[A("CtrlOrCmd+Shift+G")]}),W($,{label:g("labels.flipHorizontal"),shortcuts:[A("Shift+H")]}),W($,{label:g("labels.flipVertical"),shortcuts:[A("Shift+V")]}),W($,{label:g("labels.showStroke"),shortcuts:[A("S")]}),W($,{label:g("labels.showBackground"),shortcuts:[A("G")]}),W($,{label:g("labels.showFonts"),shortcuts:[A("Shift+F")]}),W($,{label:g("labels.decreaseFontSize"),shortcuts:[A("CtrlOrCmd+Shift+<")]}),W($,{label:g("labels.increaseFontSize"),shortcuts:[A("CtrlOrCmd+Shift+>")]})]})]}):W(Hg,{})})})};import{CANVAS_SEARCH_TAB as pF,DEFAULT_SIDEBAR as uF}from"@excalidraw/common";import{isFlowchartNodeElement as hF,isImageElement as zI,isLinearElement as HI,isLineElement as gF,isTextBindableContainer as fF,isTextElement as bF}from"@excalidraw/element";import{isNodeInFlowchart as EF}from"@excalidraw/element";import{jsx as Ug}from"react/jsx-runtime";var Ee=e=>Array.isArray(e)?`<kbd>${e.map(A).join(" + ")}</kbd>`:`<kbd>${A(e)}</kbd>`,xF=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===uF.name&&e.openSidebar.tab===pF&&e.searchMatches?.matches.length)return g("hints.dismissSearch",{shortcut:Ee("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(wt(e))return g("hints.eraserRevert",{shortcut:Ee("Alt")});let c=n.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return g("hints.arrowBindModifiers",{shortcut_1:Ee("Ctrl"),shortcut_2:Ee("Alt")});if(r.type==="arrow"||r.type==="line")return s?g("hints.linearElementMulti",{shortcut_1:Ee("Escape"),shortcut_2:Ee("Enter")}):r.type==="arrow"?g("hints.arrowTool",{shortcut:Ee("A")}):g("hints.linearElement");if(r.type==="freedraw")return g("hints.freeDraw");if(r.type==="text")return g("hints.text");if(r.type==="embeddable")return g("hints.embeddable");if(i&&l==="mouse"&&c.length===1){let m=c[0];return HI(m)&&m.points.length===2?g("hints.lockAngle",{shortcut:Ee("Shift")}):zI(m)?g("hints.resizeImage",{shortcut_1:Ee("Shift"),shortcut_2:Ee("Alt")}):g("hints.resize",{shortcut_1:Ee("Shift"),shortcut_2:Ee("Alt")})}if(a&&l==="mouse")return g("hints.rotate",{shortcut:Ee("Shift")});if(c.length===1&&bF(c[0]))return g("hints.text_selected",{shortcut:Ee("Enter")});if(e.editingTextElement)return g("hints.text_editing",{shortcut_1:Ee("Escape"),shortcut_2:Ee(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return g("hints.leaveCropEditor",{shortcut_1:Ee("Enter"),shortcut_2:Ee("Escape")});if(c.length===1&&zI(c[0]))return g("hints.enterCropEditor",{shortcut:Ee("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return g("hints.deepBoxSelect",{shortcut:Ee("CtrlOrCmd")});if(_n(n)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping",{shortcut:Ee("CtrlOrCmd")});if(!c.length&&!o)return g("hints.canvasPanning",{shortcut_1:Ee(g("keys.mmb")),shortcut_2:Ee("Space")});if(c.length===1){if(HI(c[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected",{shortcut_1:Ee("Delete"),shortcut_2:Ee(["CtrlOrCmd","D"])}):g("hints.lineEditor_nothingSelected",{shortcut_1:Ee("Shift"),shortcut_2:Ee("Alt")}):gF(c[0])?g("hints.lineEditor_line_info",{shortcut:Ee("Enter")}):g("hints.lineEditor_info",{shortcut_1:Ee("CtrlOrCmd"),shortcut_2:Ee(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&fF(c[0])){let m=g("hints.bindTextToElement",{shortcut:Ee("Enter")}),p=g("hints.createFlowchart",{shortcut:Ee(["CtrlOrCmd","\u2191\u2193"])});return hF(c[0])?EF(c[0],n.scene.getNonDeletedElementsMap())?[m,p]:[m,p]:m}}}return null},GI=({appState:e,isMobile:o,editorInterface:t,app:n})=>{let r=xF({appState:e,isMobile:o,editorInterface:t,app:n});if(!r)return null;let a=(Array.isArray(r)?r.map(l=>l.replace(/\. ?$/,"")).join(", "):r).split(/(<kbd>[^<]+<\/kbd>)/g).map((l,s)=>{if(s%2===1){let c=l[0]==="<"&&l.match(/^<kbd>([^<]+)<\/kbd>$/);return Ug("kbd",{children:c?c[1]:l},s)}return l});return Ug("div",{className:"HintViewer",children:Ug("span",{children:a})})};import{useEffect as YI,useRef as SF,useState as Hn}from"react";import{DEFAULT_EXPORT_PADDING as CF,EXPORT_IMAGE_TYPES as Wg,isFirefox as kF,EXPORT_SCALES as MF,cloneJSON as VI}from"@excalidraw/common";import{useCallback as yF,useRef as wF,useState as vF}from"react";var IF=2e3,UI=()=>{let[e,o]=vF(null),t=wF(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},IF)},r=yF(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import TF from"clsx";import{jsx as WI}from"react/jsx-runtime";var Al=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>WI("div",{className:TF("Switch",{toggled:t,disabled:r}),children:WI("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>n(!t),onKeyDown:i=>{i.key===" "&&n(!t)}})});import{jsx as Le,jsxs as Gn}from"react/jsx-runtime";var PF=()=>Gn("div",{children:[Le("h3",{children:g("canvasError.cannotShowPreview")}),Le("p",{children:Le("span",{children:g("canvasError.canvasTooBig")})}),Gn("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),LF=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i})=>{let a=ve(o,e),[l,s]=Hn(i),[c,m]=Hn(a),[p,d]=Hn(e.exportBackground),[h,f]=Hn(e.exportWithDarkMode),[b,E]=Hn(e.exportEmbedScene),[w,y]=Hn(e.exportScale),x=SF(null),[v,I]=Hn(null),{onCopy:C,copyStatus:P,resetCopyStatus:k}=UI();YI(()=>{k()},[l,p,h,w,b,k]);let{exportedElements:N,exportingFrame:_}=ir(o,e,c);return YI(()=>{let L=x.current;if(!L)return;let B=L.offsetWidth,G=L.offsetHeight;B&&Li({elements:N,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:h,exportScale:w,exportEmbedScene:b},files:t,exportPadding:CF,maxWidthOrHeight:Math.max(B,G),exportingFrame:_}).then(j=>(I(null),jn(j).then(()=>{L.replaceChildren(j)}).catch(H=>{throw H.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):H}))).catch(j=>{console.error(j),I(j)})},[e,t,N,_,l,p,h,w,b]),Gn("div",{className:"ImageExportModal",children:[Le("h3",{children:g("imageExportDialog.header")}),Gn("div",{className:"ImageExportModal__preview",children:[Le("div",{className:"ImageExportModal__preview__canvas",ref:x,children:v&&Le(PF,{})}),Le("div",{className:"ImageExportModal__preview__filename",children:!Fr&&Le("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:L=>{s(L.target.value),n.executeAction(eu,"ui",L.target.value)}})})]}),Gn("div",{className:"ImageExportModal__settings",children:[Le("h3",{children:g("imageExportDialog.header")}),a&&Le(_l,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Le(Al,{name:"exportOnlySelected",checked:c,onChange:L=>{m(L)}})}),Le(_l,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Le(Al,{name:"exportBackgroundSwitch",checked:p,onChange:L=>{d(L),n.executeAction(tu,"ui",L)}})}),Le(_l,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Le(Al,{name:"exportDarkModeSwitch",checked:h,onChange:L=>{f(L),n.executeAction(ox,"ui",L)}})}),Le(_l,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Le(Al,{name:"exportEmbedSwitch",checked:b,onChange:L=>{E(L),n.executeAction(bc,"ui",L)}})}),Le(_l,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Le(Od,{name:"exportScale",value:w,onChange:L=>{y(L),n.executeAction(tx,"ui",L)},choices:MF.map(L=>({value:L,label:`${L}\xD7`}))})}),Gn("div",{className:"ImageExportModal__settings__buttons",children:[Le(Nn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>r(Wg.png,N,{exportingFrame:_}),icon:Zm,children:g("imageExportDialog.button.exportToPng")}),Le(Nn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>r(Wg.svg,N,{exportingFrame:_}),icon:Zm,children:g("imageExportDialog.button.exportToSvg")}),(Sn||kF)&&Le(Nn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(Wg.clipboard,N,{exportingFrame:_}),C()},icon:Vr,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},_l=({label:e,children:o,tooltip:t,name:n})=>Gn("div",{className:"ImageExportModal__settings__setting",title:e,children:[Gn("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&Le(ct,{label:t,long:!0,children:H0})]}),Le("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),XI=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Hn(()=>({appStateSnapshot:VI(o),elementsSnapshot:VI(e)}));return Le(We,{onCloseRequest:i,size:"wide",title:!1,children:Le(LF,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:n,onExportImage:r,name:a})})};import _F from"react";import{getFrame as DF}from"@excalidraw/common";import{jsx as AF}from"react/jsx-runtime";var Yg={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"}},Vg=({children:e,color:o})=>AF("div",{className:"Card",style:{"--card-color":Yg[o].base,"--card-color-darker":Yg[o].darker,"--card-color-darkest":Yg[o].darkest},children:e});import{Fragment as NF,jsx as fo,jsxs as om}from"react/jsx-runtime";var RF=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return fo("div",{className:"ExportDialog ExportDialog--json",children:om("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&om(Vg,{color:"lime",children:[fo("div",{className:"Card-icon",children:Z1}),fo("h2",{children:g("exportDialog.disk_title")}),om("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!Fr&&r.renderAction("changeProjectName")]}),fo(V,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Ka,"ui")}})]}),s&&om(Vg,{color:"pink",children:[fo("div",{className:"Card-icon",children:ya}),fo("h2",{children:g("exportDialog.link_title")}),fo("div",{className:"Card-details",children:g("exportDialog.link_details")}),fo(V,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{le("export","link",`ui (${DF()})`),await s(e,o,n),l()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,a)]})})},KI=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let l=_F.useCallback(()=>{a({openDialog:null})},[a]);return fo(NF,{children:o.openDialog?.name==="jsonExport"&&fo(We,{onCloseRequest:l,title:g("buttons.export"),children:fo(RF,{elements:e,appState:o,setAppState:a,files:t,actionManager:n,onCloseRequest:l,exportOpts:r,canvas:i})})})};import BF from"clsx";import{jsx as ZI,jsxs as OF}from"react/jsx-runtime";var FF="small",$I=e=>OF("label",{className:BF("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${FF}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[ZI("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),ZI("div",{className:"ToolIcon__icon",children:Kr})]});import{Fragment as JI,jsx as J,jsxs as Gt}from"react/jsx-runtime";var XF=({UIOptions:e})=>Gt(bt,{__fallback:!0,children:[J(bt.DefaultItems.LoadScene,{}),J(bt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&J(bt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&J(bt.DefaultItems.SaveAsImage,{}),J(bt.DefaultItems.SearchMenu,{}),J(bt.DefaultItems.Help,{}),J(bt.Separator,{}),J(bt.Group,{title:"Excalidraw links",children:J(bt.DefaultItems.Socials,{})}),J(bt.Separator,{}),J(bt.DefaultItems.ToggleTheme,{}),J(bt.DefaultItems.ChangeCanvasBackground,{})]}),KF=()=>Gt(Ud,{__fallback:!0,children:[J(Ud.Actions.SaveToDisk,{}),J(Ud.Actions.ExportToImage,{})]}),ZF=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopLeftUI:m,renderTopRightUI:p,renderCustomStats:d,UIOptions:h,onExportImage:f,renderWelcomeScreen:b,children:E,app:w,isCollaborating:y,generateLinkForSelection:x})=>{let v=de(),C=je()==="compact",P=_v(),k=C?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},N=P.tunnelsJotai.Provider,[_,L]=ue(bn),B=()=>h.canvasActions.export?J(KI,{elements:r,appState:o,files:t,actionManager:e,exportOpts:h.canvasActions.export,canvas:i,setAppState:n}):null,G=()=>!h.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:J(XI,{elements:r,appState:o,files:t,actionManager:e,onExportImage:f,onCloseRequest:()=>n({openDialog:null}),name:w.getName()}),j=()=>Gt("div",{style:{position:"relative"},children:[J(P.MainMenuTunnel.Out,{}),b&&J(P.WelcomeScreenMenuHintTunnel.Out,{})]}),H=()=>{let ee=C;return J(Il,{heading:"selectedShapeActions",className:Tr("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:ee?J(ze,{className:Tr("compact-shape-actions-island"),padding:0,style:{maxHeight:`${o.height-166}px`},children:J(D2,{appState:o,elementsMap:w.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:w,setAppState:n})}):J(ze,{className:HF.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:J(M2,{appState:o,elementsMap:w.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:w})})})},Y=()=>{let ee=YF(o,r),K=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return J(LI,{side:"top",children:Gt("div",{className:"App-menu App-menu_top",children:[Gt(Tt.Col,{gap:k.menuTopGap,className:Tr("App-menu_top__left"),children:[j(),J("div",{className:Tr("selected-shape-actions-container",{"selected-shape-actions-container--compact":C}),children:ee&&H()})]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&J(Il,{heading:"shapes",className:"shapes-section",children:ae=>Gt("div",{style:{position:"relative"},children:[b&&J(P.WelcomeScreenToolbarHintTunnel.Out,{}),J(Tt.Col,{gap:k.toolbarColGap,align:"start",children:Gt(Tt.Row,{gap:k.toolbarRowGap,className:Tr("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Gt(ze,{padding:k.islandPadding,className:Tr("App-toolbar",{"zen-mode":o.zenModeEnabled,"App-toolbar--compact":C}),children:[J(GI,{appState:o,isMobile:v.formFactor==="phone",editorInterface:v,app:w}),ae,Gt(Tt.Row,{gap:k.toolbarInnerRowGap,children:[J(Wv,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),J(Dd,{checked:ao(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),J(N2,{setAppState:n,activeTool:o.activeTool,UIOptions:h,app:w})]})]}),y&&J(ze,{style:{marginLeft:k.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:J($I,{title:g("toolBar.laser"),checked:o.activeTool.type===jI.laser,onChange:()=>w.setActiveTool({type:jI.laser}),isMobile:!0})})]})})]})}),Gt("div",{className:Tr("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled,"layer-ui__wrapper__top-right--compact":C}),children:[o.collaborators.size>0&&J(Bd,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),p?.(v.formFactor==="phone",o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!O||o.openSidebar?.name!==Xg.name)&&J(P.DefaultSidebarTriggerTunnel.Out,{}),K&&J(Ll,{app:w,onClose:()=>{e.executeAction(Ii)},renderCustomStats:d})]})]})})},D=()=>J(Vd,{__fallback:!0,onDock:ee=>{le("sidebar",`toggleDock (${ee?"dock":"undock"})`,`(${v.formFactor==="phone"?"mobile":"desktop"})`)}}),O=ds(Sl),Q=Gt(JI,{children:[E,J(XF,{UIOptions:h}),J(Vd.Trigger,{__fallback:!0,icon:mb,title:UF(g("toolBar.library")),onToggle:ee=>{ee&&le("sidebar",`${Xg.name} (open)`,`button (${v.formFactor==="phone"?"mobile":"desktop"})`)},tab:Xg.defaultTab}),J(KF,{}),o.isLoading&&J(_d,{delay:250}),o.errorMessage&&J(PI,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),_&&v.formFactor!=="phone"&&J(Cb,{colorPickerType:_.colorPickerType,onCancel:()=>{L(null)},onChange:(ee,K,ae,{altKey:be})=>{if(!(ee!=="elementBackground"&&ee!=="elementStroke"))if(ae.length){for(let ce of ae)WF(ce,GF(r),{[be&&_.swapPreviewOnAlt?ee==="elementBackground"?"strokeColor":"backgroundColor":ee==="elementBackground"?"backgroundColor":"strokeColor"]:K}),VF.delete(ce);w.scene.triggerUpdate()}else n(ee==="elementBackground"?{currentItemBackgroundColor:K}:{currentItemStrokeColor:K})},onSelect:(ee,K)=>{L(ae=>ae?.keepOpenOnAlt&&K.altKey?ae:null),_?.onSelect?.(ee,K)}}),o.openDialog?.name==="help"&&J(FI,{onClose:()=>{n({openDialog:null})}}),o.openDialog?.name==="elementLinkSelector"&&J(MI,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:w.scene,appState:o,generateLinkForSelection:x}),J(P.OverwriteConfirmDialogTunnel.Out,{}),G(),B(),o.pasteDialog.shown&&J(zv,{setAppState:n,appState:o,onClose:()=>n({pasteDialog:{shown:!1,data:null}})}),v.formFactor==="phone"&&J(Fv,{app:w,appState:o,elements:r,actionManager:e,renderJSONExportDialog:B,renderImageExportDialog:G,setAppState:n,onHandToolToggle:l,onPenModeToggle:s,renderTopLeftUI:m,renderTopRightUI:p,renderSidebars:D,renderWelcomeScreen:b,UIOptions:h}),v.formFactor!=="phone"&&Gt(JI,{children:[Gt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&O&&v.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[b&&J(P.WelcomeScreenCenterTunnel.Out,{}),Y(),J(Xv,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:b}),o.scrolledOutside&&J("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(ee=>({...Zn(r,ee)}))},children:g("buttons.scrollBackToContent")})]}),D()]})]});return J(pp.Provider,{value:o,children:J(N,{children:J(jh.Provider,{value:P,children:Q})})})},qI=e=>{let{startBoundElement:o,cursorButton:t,scrollX:n,scrollY:r,...i}=e;return i},$F=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:a,...l}=o;return nm(qI(n),qI(a),{selectedElementIds:nm,selectedGroupIds:nm})&&nm(r,l)},QI=zF.memo(ZF,$F);import jF from"clsx";import{jsx as e5,jsxs as JF}from"react/jsx-runtime";var qF="small",Kg=e=>JF("label",{className:jF("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${qF}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[e5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),e5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as QF,useRef as eO}from"react";import{jsx as t5}from"react/jsx-runtime";var o5=({trails:e})=>{let o=eO(null);return QF(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),t5("div",{className:"SVGLayer",children:t5("svg",{ref:o})})};import PO,{useEffect as LO,useRef as E5}from"react";import{CURSOR_TYPE as x5,isShallowEqual as AO,sceneCoordsToViewportCoords as _O}from"@excalidraw/common";var rt=class rt{static start(o,t){let n=t({deltaTime:0,state:void 0});n&&(rt.animations.set(o,{animation:t,lastTime:0,state:n}),rt.isRunning||(rt.isRunning=!0,Er()?requestAnimationFrame(rt.tick):setTimeout(rt.tick,0)))}static tick(){if(rt.animations.size>0){for(let[o,t]of rt.animations){let n=performance.now(),r=t.lastTime===0?0:n-t.lastTime,i=t.animation({deltaTime:r,state:t.state});if(i)t.lastTime=n,t.state=i;else if(rt.animations.delete(o),rt.animations.size===0){rt.isRunning=!1;return}}Er()?requestAnimationFrame(rt.tick):setTimeout(rt.tick,0)}}static running(o){return rt.animations.has(o)}static cancel(o){rt.animations.delete(o)}};S(rt,"isRunning",!1),S(rt,"animations",new Map);var Dl=rt;import{clamp as qg,pointFrom as lO,pointsEqual as sO}from"@excalidraw/math";import{arrayToMap as cO,BIND_MODE_TIMEOUT as Rl,DEFAULT_TRANSFORM_HANDLE_SPACING as ef,FRAME_STYLE as to,getFeatureFlag as dO,invariant as l5,THEME as Bl}from"@excalidraw/common";import{deconstructDiamondElement as p5,deconstructRectanguloidElement as u5,elementCenterPoint as h5,getOmitSidesForEditorInterface as Zg,getTransformHandles as mO,getTransformHandlesFromCoords as pO,hasBoundingBox as uO,isElbowArrow as Nl,isFrameLikeElement as Fl,isImageElement as s5,isLinearElement as hO,isLineElement as gO,isTextElement as c5,LinearElementEditor as Sr}from"@excalidraw/element";import{renderSelectionElement as fO}from"@excalidraw/element";import{getElementsInGroup as Jg,getSelectedGroupIds as bO,isSelectedViaGroup as EO,selectGroupsFromGivenElements as xO}from"@excalidraw/element";import{getCommonBounds as Qg,getElementAbsoluteCoords as rm}from"@excalidraw/element";import{pointFrom as mt}from"@excalidraw/math";import{THEME as tO}from"@excalidraw/common";var oO="#ff6b6b",nO="#ff0000",n5=1,r5=2,i5=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===tO.LIGHT||o.zenModeEnabled?oO:nO,n=(o.zenModeEnabled?n5*1.5:n5)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let r of o.snapLines)r.type==="pointer"?(e.lineWidth=n,e.strokeStyle=t,iO(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,aO(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,rO(r,e,o));e.restore()},rO=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];eo(n,r,o)}for(let n of e.points)a5(n,t,o)},iO=(e,o,t)=>{a5(e.points[0],t,o),t.zenModeEnabled||eo(e.points[0],e.points[1],o)},a5=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?r5*1.5:r5)/t.zoom.value;n.beginPath(),n.moveTo(e-r,o-r),n.lineTo(e+r,o+r),n.moveTo(e+r,o-r),n.lineTo(e-r,o+r),n.stroke(),n.restore()},eo=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},aO=(e,o,t,n,r)=>{let i=8/n.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];n.zenModeEnabled||eo(mt(e[0],e[1]-i),mt(e[0],e[1]+i),r),eo(mt(s[0]-l,s[1]-a),mt(s[0]-l,s[1]+a),r),eo(mt(s[0]+l,s[1]-a),mt(s[0]+l,s[1]+a),r),n.zenModeEnabled||(eo(mt(o[0],o[1]-i),mt(o[0],o[1]+i),r),eo(e,o,r))}else{let s=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||eo(mt(e[0]-i,e[1]),mt(e[0]+i,e[1]),r),eo(mt(s[0]-a,s[1]-l),mt(s[0]+a,s[1]-l),r),eo(mt(s[0]-a,s[1]+l),mt(s[0]+a,s[1]+l),r),n.zenModeEnabled||(eo(mt(o[0]-i,o[1]),mt(o[0]+i,o[1]),r),eo(e,o,r))}};var yO=(e,o)=>{l5(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;l5(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),g5(t,e,o),e.restore()},wO=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r))return;let i=Sr.getElement(n,t);if(!i)return;let a=Sr.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),g5(a,e,o),e.restore()},g5=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",ns(o,e[0],e[1],Sr.POINT_HANDLE_SIZE/t.zoom.value,!1)},$g=(e,o,t,n,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)"),ns(e,t[0],t[1],(a?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!a||r)},vO=(e,o,t,n)=>{let r=o.frameId&&t.get(o.frameId);switch(r&&Fl(r)&&(e.translate(r.x,r.y),e.beginPath(),to.radius&&e.roundRect?e.roundRect(-1,-1,r.width+1,r.height+1,to.radius/n.zoom.value):e.rect(-1,-1,r.width+1,r.height+1),e.clip(),e.translate(-r.x,-r.y)),o.type){case"magicframe":case"frame":e.save(),e.translate(o.x,o.y),e.lineWidth=to.strokeWidth/n.zoom.value,e.strokeStyle=n.theme===Bl.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",to.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,o.width,o.height,to.radius/n.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,o.width,o.height),e.restore();break;default:e.save();let i=h5(o,t);switch(e.translate(i[0],i[1]),e.rotate(o.angle),e.translate(-i[0],-i[1]),e.translate(o.x,o.y),e.lineWidth=qg(1.75,o.strokeWidth,4)/Math.max(.25,n.zoom.value),e.strokeStyle=n.theme===Bl.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",o.type){case"ellipse":e.beginPath(),e.ellipse(o.width/2,o.height/2,o.width/2,o.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[a,l]=p5(o);a.forEach(s=>{e.beginPath(),e.moveTo(s[0][0]-o.x,s[0][1]-o.y),e.lineTo(s[1][0]-o.x,s[1][1]-o.y),e.stroke()}),l.forEach(s=>{let[c,m,p,d]=s;e.beginPath(),e.moveTo(c[0]-o.x,c[1]-o.y),e.bezierCurveTo(m[0]-o.x,m[1]-o.y,p[0]-o.x,p[1]-o.y,d[0]-o.x,d[1]-o.y),e.stroke()})}break;default:{let[a,l]=u5(o);a.forEach(s=>{e.beginPath(),e.moveTo(s[0][0]-o.x,s[0][1]-o.y),e.lineTo(s[1][0]-o.x,s[1][1]-o.y),e.stroke()}),l.forEach(s=>{let[c,m,p,d]=s;e.beginPath(),e.moveTo(c[0]-o.x,c[1]-o.y),e.bezierCurveTo(m[0]-o.x,m[1]-o.y,p[0]-o.x,p[1]-o.y,d[0]-o.x,d[1]-o.y),e.stroke()})}break}e.restore();break}},IO=(e,o,t,n,r,i,a)=>{let l=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,s=Rl-(a?.runtime??(l?0:Rl)),c=qg(1/Rl*s,1e-4,1),m=t.strokeWidth/2,p=t.frameId&&n.get(t.frameId);switch(p&&Fl(p)&&(o.translate(p.x,p.y),o.beginPath(),to.radius&&o.roundRect?o.roundRect(-1,-1,p.width+1,p.height+1,to.radius/r.zoom.value):o.rect(-1,-1,p.width+1,p.height+1),o.clip(),o.translate(-p.x,-p.y)),t.type){case"magicframe":case"frame":o.save(),o.translate(t.x,t.y),o.lineWidth=to.strokeWidth/r.zoom.value,o.strokeStyle=r.theme===Bl.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,to.radius&&o.roundRect?(o.beginPath(),o.roundRect(0,0,t.width,t.height,to.radius/r.zoom.value),o.stroke(),o.closePath()):o.strokeRect(0,0,t.width,t.height),o.restore();break;default:o.save();let h=h5(t,n),f=h[0]+r.scrollX,b=h[1]+r.scrollY;switch(o.translate(f,b),o.rotate(t.angle),o.translate(-f,-b),o.translate(t.x+r.scrollX-m,t.y+r.scrollY-m),o.lineWidth=qg(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),o.strokeStyle=r.theme===Bl.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":o.beginPath(),o.ellipse((t.width+m*2)/2,(t.height+m*2)/2,(t.width+m*2)/2,(t.height+m*2)/2,0,0,2*Math.PI),o.closePath(),o.stroke();break;case"diamond":{let[E,w]=p5(t,m);E.forEach(y=>{o.beginPath(),o.moveTo(y[0][0]-t.x+m,y[0][1]-t.y+m),o.lineTo(y[1][0]-t.x+m,y[1][1]-t.y+m),o.stroke()}),w.forEach(y=>{let[x,v,I,C]=y;o.beginPath(),o.moveTo(x[0]-t.x+m,x[1]-t.y+m),o.bezierCurveTo(v[0]-t.x+m,v[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m),o.stroke()})}break;default:{let[E,w]=u5(t,m);E.forEach(y=>{o.beginPath(),o.moveTo(y[0][0]-t.x+m,y[0][1]-t.y+m),o.lineTo(y[1][0]-t.x+m,y[1][1]-t.y+m),o.stroke()}),w.forEach(y=>{let[x,v,I,C]=y;o.beginPath(),o.moveTo(x[0]-t.x+m,x[1]-t.y+m),o.bezierCurveTo(v[0]-t.x+m,v[1]-t.y+m,I[0]-t.x+m,I[1]-t.y+m,C[0]-t.x+m,C[1]-t.y+m),o.stroke()})}break}o.restore();break}if(!l||(a?.runtime??0)>Rl)return;let d=.5*(Math.min(t.width,t.height)/2);if(!Fl(t)){o.save(),o.translate(t.x+r.scrollX,t.y+r.scrollY);let h=1/Rl*s;o.strokeStyle="rgba(0, 0, 0, 0.2)",o.lineWidth=1/r.zoom.value,o.setLineDash([4/r.zoom.value,4/r.zoom.value]),o.lineDashOffset=-h*10/r.zoom.value,o.beginPath(),o.ellipse(t.width/2,t.height/2,d,d,0,0,2*Math.PI),o.stroke(),o.fillStyle="rgba(0, 0, 0, 0.04)",o.beginPath(),o.ellipse(t.width/2,t.height/2,d*(1-c),d*(1-c),0,0,2*Math.PI),o.fill(),o.restore()}return{runtime:(a?.runtime??0)+i}},TO=(e,o,t,n,r,i,a)=>{if(dO("COMPLEX_BINDINGS"))return IO(e,o,t,n,r,i,a);o.save(),o.translate(r.scrollX,r.scrollY),vO(o,t,n,r),o.restore()},f5=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:m,dashed:p,activeEmbeddable:d}=t,h=a-r,f=l-i,E=(t.padding??ef*2)/o.zoom.value,w=8/o.zoom.value,y=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(d?4:1)/o.zoom.value;let x=s.length;for(let v=0;v<x;++v)e.strokeStyle=s[v],p&&e.setLineDash([w,y+(w+y)*(x-1)]),e.lineDashOffset=(w+y)*v,ha(e,r-E,i-E,h+E*2,f+E*2,c,m,n);e.restore()},SO=(e,o,t,n)=>{let[r,i,a,l]=rm(t,n),s=a-r,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=to.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),ha(e,r,i,s,c,r+s/2,i+c/2,t.angle,!1,to.radius/o.zoom.value),e.restore()},d5=(e,o,t,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},a=t.filter(m=>m.groupIds.length===0),l=t.filter(m=>m.groupIds.length>0),s=m=>{let[p,d,h,f]=Qg(m);return{angle:0,x1:p,x2:h,y1:d,y2:f,selectionColors:r,dashed:i,cx:p+(h-p)/2,cy:d+(f-d)/2,activeEmbeddable:!1}},c=m=>{let p=Jg(t,m);return s(p)};Object.entries(xO(l,o)).filter(([m,p])=>p).map(([m,p])=>m).map(m=>c(m)).concat(a.map(m=>s([m]))).forEach(m=>f5(e,o,m))},jg=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=Sr.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=Sr,a=o.selectedLinearElement?.isEditing?i:i/2,l=Nl(t),s=gO(t);if(r.forEach((c,m)=>{if(l&&m!==0&&m!==r.length-1)return;let p=m>0&&(m!==r.length-1||!s||!t.polygon)&&sO(c,m===r.length-1?r[0]:r[m-1],2/o.zoom.value),d=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!d&&m===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(d=!0),$g(e,o,c,a,d,!1,p)}),Nl(t)){let c=t.fixedSegments?.map(m=>m.index)||[];r.slice(0,-1).forEach((m,p)=>{Sr.isSegmentTooShort(t,r[p+1],r[p],p,o.zoom)||$g(e,o,lO((m[0]+r[p+1][0])/2,(m[1]+r[p+1][1])/2),i/2,!1,!c.includes(p+1),!1)})}else Sr.getEditorMidPoints(t,n,o).filter((m,p,d)=>m!==null&&!(Nl(t)&&(p===0||p===d.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||r.length===2)&&$g(e,o,m,i/2,!1,!0,!1)});e.restore()},m5=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[l,s,c,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?ns(e,l+c/2,s+m/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,m,2/t.zoom.value),e.fill(),e.stroke()):ha(e,l,s,c,m,l+c/2,s+m/2,r,!0),e.restore()}})},CO=(e,o,t,n,r)=>{let[i,a,,,l,s]=rm(n,r),c=3,m=20,p=c/t.zoom.value,d=p/2,h=l-i+p,f=s-a+p,b=Math.min(m/t.zoom.value,h),E=Math.min(m/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=p,[[[-h,-f],[0,d],[b,d],[d,0],[d,E]],[[h-d,-f],[d,d],[-b+d,d],[0,0],[0,E]],[[-h,f],[0,-d],[b,-d],[d,0],[d,-E]],[[h-d,f],[d,-d],[-b+d,-d],[0,0],[0,-E]]].forEach(y=>{let[[x,v],[I,C],[P,k],[N,_],[L,B]]=y;e.save(),e.translate(l,s),e.rotate(n.angle),e.beginPath(),e.moveTo(x+I,v+C),e.lineTo(x+P,v+k),e.stroke(),e.beginPath(),e.moveTo(x+N,v+_),e.lineTo(x+L,v+B),e.stroke(),e.restore()}),e.restore()},kO=(e,o,t,n)=>{o.save();let r=ef*2/t.zoom.value,i=e.width+r*2,a=e.height+r*2,l=e.x+i/2,s=e.y+a/2,c=-(i/2+r),m=-(a/2+r);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.strokeRect(c,m,i,a),o.restore()},MO=({app:e,canvas:o,elementsMap:t,visibleElements:n,selectedElements:r,allElementsMap:i,scale:a,appState:l,renderConfig:s,editorInterface:c,animationState:m,deltaTime:p})=>{if(o===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[d,h]=rs(o,a),f=m,b=is({canvas:o,scale:a,normalizedWidth:d,normalizedHeight:h});b.save(),b.scale(l.zoom.value,l.zoom.value);let E;if(n.forEach(x=>{l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===x.id&&x&&(E=x)}),E&&jg(b,l,E,t),l.selectionElement&&!l.isCropping)try{fO(l.selectionElement,b,l,s.selectionColor)}catch(x){console.error(x)}if(l.editingTextElement&&c5(l.editingTextElement)){let x=i.get(l.editingTextElement.id);x&&!x.autoResize&&kO(x,b,l,s.selectionColor)}if(l.isBindingEnabled&&l.suggestedBinding?f={...m,bindingHighlight:TO(e,b,l.suggestedBinding,i,l,p,m?.bindingHighlight)}:f={...m,bindingHighlight:void 0},l.frameToHighlight&&SO(b,l,l.frameToHighlight,t),l.elementsToHighlight&&d5(b,l,l.elementsToHighlight),l.activeLockedId){let x=i.get(l.activeLockedId),v=x?[x]:Jg(i,l.activeLockedId);d5(b,l,v,{colors:["#ced4da"],dashed:!0})}let w=r.some(x=>Fl(x));if(r.length===1&&l.selectedLinearElement?.isEditing&&l.selectedLinearElement.elementId===r[0].id&&jg(b,l,r[0],t),l.selectedLinearElement){let x=l.selectedLinearElement,v=r.find(I=>I.id===x.elementId);l.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?yO(b,l):(Nl(v)?x.hoverPointIndex===0||x.hoverPointIndex===v.points.length-1:x.hoverPointIndex>=0)&&wO(b,l,t))}if(!l.multiElement&&!l.newElement&&!l.selectedLinearElement?.isEditing){let x=uO(r,l,c),v=r.length===1&&hO(r[0]);v&&l.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&jg(b,l,r[0],t);let I=s.selectionColor||"#000";if(x){let C=cO(r),P=[];for(let N of t.values()){let _=[],L=s.remoteSelectedElementIds.get(N.id);if(v&&Nl(N)&&(N.startBinding||N.endBinding)||(C.has(N.id)&&!EO(l,N)&&_.push(I),L&&_.push(...L.map(B=>cr(B,l.collaborators.get(B))))),_.length){let[B,G,j,H,Y,D]=rm(N,t,!0);P.push({angle:N.angle,x1:B,y1:G,x2:j,y2:H,selectionColors:N.locked?["#ced4da"]:_,dashed:!!L||N.locked,cx:Y,cy:D,activeEmbeddable:l.activeEmbeddable?.element===N&&l.activeEmbeddable.state==="active",padding:N.id===l.croppingElementId||s5(N)?0:void 0})}}let k=N=>{let _=Jg(t,N),[L,B,G,j]=Qg(_);P.push({angle:0,x1:L,x2:G,y1:B,y2:j,selectionColors:_.some(H=>H.locked)?["#ced4da"]:["#000"],dashed:!0,cx:L+(G-L)/2,cy:B+(j-B)/2,activeEmbeddable:!1})};for(let N of bO(l))k(N);l.editingGroupId&&k(l.editingGroupId),P.forEach(N=>f5(b,l,N))}if(b.save(),b.translate(l.scrollX,l.scrollY),r.length===1){b.fillStyle="#fff";let C=mO(r[0],l.zoom,t,"mouse",Zg(c));if(!l.viewModeEnabled&&x&&!c5(l.editingTextElement)&&!l.croppingElementId&&m5(b,s,l,C,r[0].angle),l.croppingElementId&&!l.isCropping){let P=t.get(l.croppingElementId);P&&s5(P)&&CO(b,s,l,P,t)}}else if(r.length>1&&!l.isRotating&&!r.some(C=>C.locked)){let C=ef*2/l.zoom.value;b.fillStyle="#fff";let[P,k,N,_]=Qg(r,t),L=b.getLineDash();b.setLineDash([2/l.zoom.value]);let B=b.lineWidth;b.lineWidth=1/l.zoom.value,b.strokeStyle=I,ha(b,P-C,k-C,N-P+C*2,_-k+C*2,(P+N)/2,(k+_)/2,0),b.lineWidth=B,b.setLineDash(L);let G=pO([P,k,N,_,(P+N)/2,(k+_)/2],0,l.zoom,"mouse",w?{...Zg(c),rotation:!0}:Zg(c));r.some(j=>!j.locked)&&m5(b,s,l,G,0)}b.restore()}l.searchMatches?.matches.forEach(({id:x,focus:v,matchedLines:I})=>{let C=t.get(x);if(C){let[P,k,,,N,_]=rm(C,t,!0);b.save(),l.theme===Bl.LIGHT?v?b.fillStyle="rgba(255, 124, 0, 0.4)":b.fillStyle="rgba(255, 226, 0, 0.4)":v?b.fillStyle="rgba(229, 82, 0, 0.4)":b.fillStyle="rgba(99, 52, 0, 0.4)";let L=Fl(C)?l.zoom.value:1;b.translate(l.scrollX,l.scrollY),b.translate(N,_),b.rotate(C.angle),I.forEach(B=>{(B.showOnCanvas||v)&&b.fillRect(P+B.offsetX/L-N,k+B.offsetY/L-_,B.width/L,B.height/L)}),b.restore()}}),i5(b,l),b.restore(),px({context:b,renderConfig:s,appState:l,normalizedWidth:d,normalizedHeight:h});let y;return s.renderScrollbars&&(y=lv(t,d,h,l),b.save(),b.fillStyle=av,b.strokeStyle="rgba(255,255,255,0.8)",[y.horizontal,y.vertical].forEach(x=>{x&&vc(b,x.x,x.y,x.width,x.height,jt/2)}),b.restore()),{scrollBars:y,atLeastOneVisibleElement:n.length>0,elementsMap:t,animationState:f}},b5=e=>{let o=MO(e);return e.callback(o),o};import{jsx as NO}from"react/jsx-runtime";var y5="animateInteractiveScene",DO=e=>{let o=E5(!1),t=E5(null);return LO(()=>{if(!o.current){o.current=!0;return}let n=new Map,r=new Map,i=new Map,a=new Map,l=new Map;e.appState.collaborators.forEach((c,m)=>{if(c.selectedElementIds)for(let p of Object.keys(c.selectedElementIds))i.has(p)||i.set(p,[]),i.get(p).push(m);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(m,c.username),c.userState&&l.set(m,c.userState),r.set(m,_O({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),n.set(m,c.button))});let s=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";t.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:n,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:l,selectionColor:s,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.lastViewportPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},Dl.running(y5)||Dl.start(y5,({deltaTime:c,state:m})=>{let p=b5({...t.current,deltaTime:c,animationState:m}).animationState;if(p){for(let d in p)if(p[d]!==void 0)return p}})}),NO("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?x5.GRAB:x5.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:g("labels.drawingCanvas")})},w5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,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,suggestedBinding:e.suggestedBinding,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale}),RO=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:AO(w5(e.appState),w5(o.appState)),tf=PO.memo(DO,RO);import BO,{useEffect as v5,useRef as I5}from"react";import{isShallowEqual as T5}from"@excalidraw/common";import{jsx as zO}from"react/jsx-runtime";var FO=e=>{let o=I5(null),t=I5(!1);return v5(()=>{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]),v5(()=>{let n=o.current;if(!n)return;let r=e.canvas;t.current||(t.current=!0,n.replaceChildren(r),r.classList.add("excalidraw__canvas","static")),s1({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Er())}),zO("div",{className:"excalidraw__canvas-wrapper",ref:o})},S5=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}),OO=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:T5(S5(e.appState),S5(o.appState))&&T5(e.renderConfig,o.renderConfig),of=BO.memo(FO,OO);import{useEffect as XO,useRef as KO}from"react";import{throttleRAF as HO}from"@excalidraw/common";import{getTargetFrame as GO,isInvisiblySmallElement as UO,renderElement as WO,shouldApplyFrameClip as YO}from"@excalidraw/element";var C5=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=rs(e,i),m=is({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});if(m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(UO(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let d=GO(t,n,a);d&&YO(t,d,a,n)&&a1(d,m,l,a)}WO(t,n,r,o,m,l,a)}else m.clearRect(0,0,s,c);m.restore()}},VO=HO(e=>{C5(e)},{trailing:!0}),k5=(e,o)=>{if(o){VO(e);return}C5(e)};import{jsx as $O}from"react/jsx-runtime";var ZO=e=>{let o=KO(null);return XO(()=>{o.current&&k5({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Er())}),$O("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:o})},M5=ZO;import{useCallback as jO,useEffect as qO,useRef as JO}from"react";import{jsx as P5,jsxs as ez}from"react/jsx-runtime";var QO=5e3,L5=({message:e,onClose:o,closable:t=!1,duration:n=QO,style:r})=>{let i=JO(0),a=n!==1/0,l=jO(()=>{a&&(i.current=window.setTimeout(()=>o(),n))},[o,n,a]);return qO(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,n,a]),ez("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[P5("p",{className:"Toast__message",children:e}),t&&P5(V,{icon:Ut,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{findShapeByKey as rG}from"@excalidraw/element/shapes";import{getCommonBounds as tz,getElementsInGroup as oz,selectGroupsFromGivenElements as nz}from"@excalidraw/element";import{sceneCoordsToViewportCoords as rz}from"@excalidraw/common";import{flushSync as iz}from"react-dom";import{jsx as lz}from"react/jsx-runtime";var az=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:oz(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=tz(n),{x:a,y:l}=rz({sceneX:r,sceneY:i},e.state);return lz("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{iz(()=>{let s=nz(n,e.state);e.setState({selectedElementIds:n.reduce((c,m)=>({...c,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(Ja)},title:g("labels.elementLock.unlock"),children:L1})},A5=az;import{Fragment as aG,jsx as we,jsxs as gm}from"react/jsx-runtime";var RT=Ho.createContext(null),NT=Ho.createContext(null),Af={formFactor:"desktop",desktopUIMode:"full",userAgent:_T(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},Df=Ho.createContext(Af);Df.displayName="EditorInterfaceContext";var Rf=Ho.createContext({container:null,id:null});Rf.displayName="ExcalidrawContainerContext";var Nf=Ho.createContext([]);Nf.displayName="ExcalidrawElementsContext";var Bf=Ho.createContext({...Br(),width:0,height:0,offsetLeft:0,offsetTop:0});Bf.displayName="ExcalidrawAppStateContext";var Ff=Ho.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Ff.displayName="ExcalidrawSetAppStateContext";var Of=Ho.createContext(null);Of.displayName="ExcalidrawActionManagerContext";var qe=()=>Xn(RT),Io=()=>Xn(NT),de=()=>Xn(Df),je=()=>fm(de()),ke=()=>Xn(Rf),En=()=>Xn(Nf),vo=()=>Xn(Bf),he=()=>Xn(Ff),at=()=>Xn(Of),Xl=!1,kf=0,Kl=null,Ar=!1,Zl=!1,Mf=!1,$l={horizontal:null,vertical:null},Vn=0,jl=!1,Pf=new Map,Lf=!1,MT=0,PT=!1,ql=null,fe={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},_f=class e extends Ho.Component{constructor(t){super(t);S(this,"canvas");S(this,"interactiveCanvas",null);S(this,"rc");S(this,"unmounted",!1);S(this,"actionManager");S(this,"editorInterface",Af);S(this,"stylesPanelMode",fm(Af));S(this,"excalidrawContainerRef",Ho.createRef());S(this,"scene");S(this,"fonts");S(this,"renderer");S(this,"visibleElements");S(this,"resizeObserver");S(this,"library");S(this,"libraryItemsFromStorage");S(this,"id");S(this,"store");S(this,"history");S(this,"excalidrawContainerValue");S(this,"files",{});S(this,"imageCache",new Map);S(this,"iFrameRefs",new Map);S(this,"embedsValidationStatus",new Map);S(this,"initializedEmbeds",new Set);S(this,"handleToastClose",()=>{this.setToast(null)});S(this,"elementsPendingErasure",new Set);S(this,"flowChartCreator",new PH);S(this,"flowChartNavigator",new LH);S(this,"bindModeHandler",null);S(this,"hitLinkElement");S(this,"lastPointerDownEvent",null);S(this,"lastPointerUpEvent",null);S(this,"lastPointerMoveEvent",null);S(this,"lastPointerMoveCoords",null);S(this,"lastViewportPosition",{x:0,y:0});S(this,"animationFrameHandler",new vd);S(this,"laserTrails",new Cd(this.animationFrameHandler,this));S(this,"eraserTrail",new Ad(this.animationFrameHandler,this));S(this,"lassoTrail",new Ld(this.animationFrameHandler,this));S(this,"onChangeEmitter",new Mr);S(this,"onPointerDownEmitter",new Mr);S(this,"onPointerUpEmitter",new Mr);S(this,"onUserFollowEmitter",new Mr);S(this,"onScrollChangeEmitter",new Mr);S(this,"missingPointerEventCleanupEmitter",new Mr);S(this,"onRemoveEventListenersEmitter",new Mr);S(this,"updateEditorAtom",(t,...n)=>{let r=$e.set(t,...n);return this.triggerRender(),r});S(this,"previousHoveredBindableElement",null);S(this,"getEffectiveGridSize",()=>_n(this)?this.state.gridSize:null);S(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),Vl.delete(t)});S(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(ln(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=ff(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else la(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});S(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);S(this,"frameNameBoundsCache",{get:t=>{let n=this.frameNameBoundsCache._cache.get(t.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Be({clientX:i.x,clientY:i.y},this.state),l=Be({clientX:i.right,clientY:i.bottom},this.state);return n={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,n),n}return null}return n},_cache:new Map});S(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});S(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===lm.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&Lt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!iT(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:a,y:l}=cm({sceneX:i.x,sceneY:i.y},this.state),s=6,c,m=IH(i);if(i.id===this.state.editingFrame){let p=m;c=we("input",{autoFocus:!0,value:p,onChange:d=>{this.scene.mutateElement(i,{name:d.target.value})},onFocus:d=>d.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:d=>{(d.key===X.ESCAPE||d.key===X.ENTER)&&this.resetEditingFrame(i)},style:{background:t?zz(this.state.viewBackgroundColor):this.state.viewBackgroundColor,zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${No.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:t?No.nameColorDarkTheme:No.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:p.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=m;return we("div",{id:this.getFrameNameDOMId(i),className:mf.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+No.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:No.nameFontSize,color:t?No.nameColorDarkTheme:No.nameColorLightTheme,lineHeight:No.nameLineHeight,width:"max-content",maxWidth:r?.id===i.id&&r?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Ne.MOVE,pointerEvents:this.state.viewModeEnabled?na.disabled:na.enabled},onPointerDown:p=>this.handleCanvasPointerDown(p),onWheel:p=>this.handleWheel(p),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});S(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});S(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());S(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());S(this,"getSceneElements",()=>this.scene.getNonDeletedElements());S(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});S(this,"onExportImage",async(t,n,r)=>{le("export",t,"ui");let i=await ar(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(Bz).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&ls(i)&&this.setState({fileHandle:i})});S(this,"magicGenerations",new Map);S(this,"updateMagicGeneration",({frameElement:t,data:n})=>{n.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,n),this.triggerRender()});S(this,"plugins",{});S(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:Fo.magicframe}),le("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&nT(t[0])&&t[0];if(!n&&t.some(i=>Lt(i)||i.frameId)){this.setActiveTool({type:Fo.magicframe});return}le("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,l,s]=ia(t),c=50;r=Q5({...No,x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let m of t)this.scene.mutateElement(m,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});S(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(bn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=t==="background"&&r.altKey||t==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:xt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:xt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?Wn(l,{[i?"strokeColor":"backgroundColor"]:n}):l),captureUpdate:xt.IMMEDIATELY})},keepOpenOnAlt:!1})});S(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});S(this,"syncActionResult",Re(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let n=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),n=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||lm.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(m=>{r?.id===m.id&&r!==m&&vT(m)&&Eo(m)&&(r=m)}),r?.isDeleted&&(r=null),this.setState(m=>{let p=t.appState||{};return{...m,...p,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),n=!0}n||this.scene.triggerUpdate()}));S(this,"onBlur",Re(()=>{Ar=!1,this.setState({isBindingEnabled:!0})}));S(this,"onUnload",()=>{this.onBlur()});S(this,"disableEvent",t=>{t.preventDefault()});S(this,"resetHistory",()=>{this.history.clear()});S(this,"resetStore",()=>{this.store.clear()});S(this,"resetScene",Re(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...Br(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));S(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async a=>{if(!a.files.length)return;let l=a.files[0],s=await l.getFile();this.loadFileToCanvas(new File([s],s.name||"",{type:s.type}),l)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(a=>{console.error(a)})}catch(a){console.error(a),t={appState:{errorMessage:a.message||"Encountered an error during importing or restoring scene data"}}}let n=$n(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=zr(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r={...r,...Zn(n,{...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({elements:n,appState:r,files:t?.files,captureUpdate:xt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(a=>{this.fonts.onLoaded(a)}),If(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});S(this,"getFormFactor",(t,n)=>this.props.UIOptions.getFormFactor?.(t,n)??Yz(t,n));S(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=Zz(),a=_T(typeof navigator<"u"?navigator.userAgent:""),l=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:xz,s=df(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(n,r),userAgent:a,canFitSidebar:n>l,isLandscape:n>r});this.editorInterface=s,this.reconcileStylesPanelMode(s)});S(this,"reconcileStylesPanelMode",t=>{let n=fm(t);if(n===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=n,r!=="full"&&n==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});S(this,"setDesktopUIMode",t=>{let n=$z(t);this.editorInterface=df(this.editorInterface,{desktopUIMode:n}),this.reconcileStylesPanelMode(this.editorInterface)});S(this,"onResize",Re(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Vl.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));S(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});S(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&($l=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});S(this,"onScroll",X5(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},yz));S(this,"onCut",Re(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||zl(t.target)||(this.actionManager.executeAction(Sc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));S(this,"onCopy",Re(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||zl(t.target)||(this.actionManager.executeAction(wi,"keyboard",t),t.preventDefault(),t.stopPropagation())}));S(this,"onTouchStart",t=>{if(Vz&&t.preventDefault(),!Xl){Xl=!0,t.touches.length===1&&(Kl={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(kf),kf=window.setTimeout(e.resetTapTwice,wz);return}if(Xl&&t.touches.length===1&&Kl){let n=t.touches[0];Cr(oe(n.clientX,n.clientY),oe(Kl.x,Kl.y))<=Uz&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY})),Xl=!1,clearTimeout(kf)}t.touches.length===2&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null})});S(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}):fe.pointers.clear()});S(this,"pasteFromClipboard",Re(async t=>{let n=!!Lf,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||zl(r)))return;let l=await Xa(t),s=l.getFiles(),c=await JE(l,n);if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(m){console.error(m)}await this.insertClipboardContent(c,s,n),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t?.preventDefault()}));S(this,"addElementsFromPasteOrLibrary",t=>{let n=$n(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=ia(n),s=ra(r,a)/2,c=ra(i,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,p=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:d,y:h}=Be({clientX:m,clientY:p},this.state),f=d-s,b=h-c,[E,w]=pt(f,b,this.getEffectiveGridSize()),{duplicatedElements:y}=pf({type:"everything",elements:n.map(k=>Wn(k,{x:k.x+E-r,y:k.y+w-i})),randomizeSeed:!t.retainSeed}),x=this.scene.getElementsIncludingDeleted(),v=[...x,...y];v=this.props.onDuplicate?.(v,x)||v,bT(v,dm(y));let C=this.getTopLayerFrameAtSceneCoords({x:d,y:h});if(C){let k=SH(y,C);yf(v,k,C,this.state)}this.scene.replaceAllElements(v),y.forEach(k=>{if(Eo(k)&&uf(k)){let N=dT(k,this.scene.getElementsMapIncludingDeleted());bH(k,N,this.scene)}}),Kz&&cn.loadElementsFonts(y).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let P=VH(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&$e.get(Sl)?this.state.openSidebar:null,...no({editingGroupId:null,selectedElementIds:P.reduce((k,N)=>(uf(N)||(k[N.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},!0),t.fitToContent&&this.scrollToContent(y,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});S(this,"setAppState",(t,n)=>{this.setState(t,n)});S(this,"removePointer",t=>{Vn&&this.resetContextMenuTimer(),fe.pointers.delete(t.pointerId)});S(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||le("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...Oo(this.state,n.activeTool.locked?{type:this.state.preferredSelectionTool.type}:n.activeTool),locked:!n.activeTool.locked}}))});S(this,"updateFrameRendering",t=>{this.setState(n=>{let r=typeof t=="function"?t(n.frameRendering):t;return{frameRendering:{enabled:r?.enabled??n.frameRendering.enabled,clip:r?.clip??n.frameRendering.clip,name:r?.name??n.frameRendering.name,outline:r?.outline??n.frameRendering.outline}}})});S(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});S(this,"onHandToolToggle",()=>{this.actionManager.executeAction(IE)});S(this,"zoomCanvas",t=>{this.setState({...Ko({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:xo(t)},this.state)})});S(this,"cancelInProgressAnimation",null);S(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let s;if(If(t)?s=DH(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):If(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:s}=za({canvasOffsets:n.canvasOffsets,targetElements:r,appState:this.state,fitToViewport:!!n?.fitToViewport,viewportZoomFactor:n?.viewportZoomFactor,minZoom:n?.minZoom,maxZoom:n?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=Zn(r,this.state);a=s.scrollX,l=s.scrollY}if(n?.animate){let s=this.state.scrollX,c=this.state.scrollY,m=this.state.zoom.value,p=Nz({fromValues:{scrollX:s,scrollY:c,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(d,h,f,b)=>{if(b==="zoom")return d*Math.pow(h/d,Fz(f))},onStep:({scrollX:d,scrollY:h,zoom:f})=>{this.setState({scrollX:d,scrollY:h,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:n?.duration??500});this.cancelInProgressAnimation=()=>{p(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});S(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});S(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});S(this,"setToast",t=>{this.setState({toast:t})});S(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),n=await t.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,uz,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});S(this,"addFiles",Re(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));S(this,"addMissingFiles",(t,n=!1)=>{let r=n?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!r[l.id]&&(i[l.id]=l,r[l.id]=l,l.mimeType===Bo.svg))try{let s=f1(cT(b1(l.dataURL)),Bo.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});S(this,"updateScene",Re(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let l=n||void 0,s=r?jz({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}r&&this.setState(r),n&&this.scene.replaceAllElements(n),i&&this.setState({collaborators:i})}));S(this,"applyDeltas",(t,n)=>{let r=TT.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return TT.applyTo(r,a,i,n)});S(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));S(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});S(this,"toggleSidebar",({name:t,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===n?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&n&&(a.tab=n),this.setState({openSidebar:a}),!!i});S(this,"updateCurrentCursorPosition",Re(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));S(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,n=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),r=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Uo().rtl?{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width),0)+i,bottom:i,left:Math.max(n?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width)+i,0),bottom:i,left:Math.max(r?.right??0,0)+i}});S(this,"onKeyDown",Re(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!K5(t.target)){if((t.key===X.ESCAPE||t.key===X.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=q(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&Pr(a[0])&&t.key===X.ENTER){this.startImageCropping(a[0]);return}if(t.key===X.ESCAPE)this.updateEditorAtom(uo,null);else if(t.key===X.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(mf.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=Pi(a);$e.get(uo)?.type==="panel"&&Hu(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(uo,{type:"panel"})}if(t.key===X.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=im(t.key);if(t[X.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=q(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&dH(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,hT(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!gf(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let s=q(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let c=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),hT(t.key));if(c){this.setState(p=>({selectedElementIds:ye({[c]:!0},p)}));let m=this.scene.getNonDeletedElementsMap().get(c);m&&!gf([m],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(m,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[X.CTRL_OR_CMD]&&t.key===X.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:Ae("commandPalette")})}),t.preventDefault();return}if(t[X.CTRL_OR_CMD]&&t.key.toLowerCase()===X.V&&(Lf=t.shiftKey,clearTimeout(MT),MT=window.setTimeout(()=>{Lf=!1},100)),t[X.CTRL_OR_CMD]&&zl(t.target)&&(t.code===O5.MINUS||t.code===O5.EQUAL)){t.preventDefault();return}if(zl(t.target)&&t.key!==X.ESCAPE||im(t.key)&&K5(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(t.key===X.PAGE_UP||t.key===X.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===X.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||(t.key===X.ALT&&an("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),this.actionManager.handleKeyDown(t))||this.state.viewModeEnabled)return;if(t[X.CTRL_OR_CMD]&&this.state.isBindingEnabled&&(an("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({isBindingEnabled:!1})),im(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=new Set;a.filter(p=>Yn(p)).filter(p=>{let d=p.startBinding&&!a.some(f=>f.id===p.startBinding?.elementId),h=p.endBinding&&!a.some(f=>f.id===p.endBinding?.elementId);return d||h}).forEach(p=>l.add(p.id)),a=a.filter(p=>!l.has(p.id));let s=this.getEffectiveGridSize()&&(t.shiftKey?U5:this.getEffectiveGridSize())||(t.shiftKey?fz:U5),c=0,m=0;t.key===X.ARROW_LEFT?c=-s:t.key===X.ARROW_RIGHT?c=s:t.key===X.ARROW_UP?m=-s:t.key===X.ARROW_DOWN&&(m=s),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+c,y:p.y+m},{informMutation:!1,isDragging:!1}),pm(p,this.scene,{simultaneouslyUpdated:a})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===X.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[X.CTRL_OR_CMD]||Tf(l))Et(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),At(l)||this.actionManager.executeAction(Vi));else if(Eo(l)||fH(l)){let s;Eo(l)||(s=l);let c=Ef(l,this.state,this.scene.getNonDeletedElementsMap()),m=c.x,p=c.y;this.startTextEditing({sceneX:m,sceneY:p,container:s}),t.preventDefault();return}else Lt(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=rG(t.key,this);a?(this.state.activeTool.type!==a&&le("toolbar",a,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Un.sharp?Un.round:l.currentItemArrowType===Un.round?Un.elbow:Un.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===X.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===X.SPACE&&fe.pointers.size===0&&(Ar=!0,xe(this.interactiveCanvas,Ne.GRAB),t.preventDefault()),(t.key===X.G||t.key===X.S)&&!t.altKey&&!t[X.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===X.G&&(yo(this.state.activeTool.type)||a.some(l=>yo(l.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 a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>Eo(l)||bf(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===X.K&&!t.altKey&&!t[X.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:"laser"});return}let n=t.key.toLocaleLowerCase(),r=n===X.S&&t.shiftKey,i=t.key===X.I||n===X.G&&t.shiftKey;(r||i)&&this.openEyeDropper({type:r?"stroke":"background"})}));S(this,"onKeyUp",Re(t=>{if(t.key===X.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,Ne.GRAB):mm(this.state.activeTool.type)?Rt(this.interactiveCanvas):(Nt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Ar=!1),(t.key===X.ALT&&this.state.bindMode==="skip"||!t[X.CTRL_OR_CMD]&&!Gl(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent)){let n=Be({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=bo(oe(n.x,n.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=pe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());Yn(i)&&an("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(i,r)}}if(!t[X.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),im(t.key)){q5(this.scene.getSelectedElements(this.state).filter(aa),this.scene,this.state);let n=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Sf).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...CT(r,n.get(r.startBinding.elementId),"start",n)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...CT(r,n.get(r.endBinding.elementId),"end",n)}})}),this.setState({suggestedBinding:null})}if(t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:xt.IMMEDIATELY})),!t[X.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:ye({[n.id]:!0},r)})),gf([n],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(n,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:xt.IMMEDIATELY})}}));S(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);S(this,"setActiveTool",(t,n=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=Oo(this.state,t);r.type==="hand"?xe(this.interactiveCanvas,Ne.GRAB):Ar||Nt(this.interactiveCanvas,{...this.state,activeTool:r}),_z(document.activeElement)&&this.focusContainer(),sH(r.type)||this.setState({suggestedBinding:null}),r.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:mm(r.type)?i.selectedLinearElement:null};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,...a,activeTool:r,...n?{}:{selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null}}:r.type!=="selection"?{...i,...a,activeTool:r,selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null}:{...i,...a,activeTool:r}})});S(this,"setOpenDialog",t=>{this.setState({openDialog:t})});S(this,"setCursor",t=>{xe(this.interactiveCanvas,t)});S(this,"resetCursor",()=>{Rt(this.interactiveCanvas)});S(this,"isTouchScreenMultiTouchGesture",()=>fe.pointers.size>=2);S(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${Z5()}`);S(this,"onGestureStart",Re(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null}),fe.initialScale=this.state.zoom.value}));S(this,"onGestureChange",Re(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=fe.initialScale;n&&this.setState(r=>({...Ko({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:xo(n*t.scale)},r)}))}));S(this,"onGestureEnd",Re(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}),fe.initialScale=null}));S(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&s&&(bf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let c=null,m=this.scene.getSelectedElements(this.state);m.length===1?Eo(m[0])?c=m[0]:i?c=bf(m[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(t,n):c=this.getTextElementAtPosition(t,n);let p=c?.fontFamily||this.state.currentItemFontFamily,d=c?.lineHeight||V5(p),h=this.state.currentItemFontSize;if(!c&&l&&i&&!aa(i)){let w=FH(sf({fontSize:h,fontFamily:p}),d),y=OH(h,d),x=Math.max(i.height,y),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:x,width:v}),t=i.x+v/2,n=i.y+x/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:n}),b=c||eT({x:s?s.elementCenterX:t,y:s?s.elementCenterY:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:h,fontFamily:p,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?Tz.MIDDLE:G5,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:d,angle:i?aa(i)?0:i.angle:0,frameId:f?f.id:null});if(!c&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!c)if(i&&l){let E=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,E+1)}else this.scene.insertElement(b);a||c||i?this.handleTextWysiwyg(b,{isExistingElement:!!c}):this.setState({newElement:b,multiElement:null})});S(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});S(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});S(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=Be(t,this.state);if(n.length===1&&Et(n[0])){let l=n[0];if((t[X.CTRL_OR_CMD]&&Sf(l)||Tf(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(Vi);return}else if(this.state.selectedLinearElement&&At(n[0])){let s=pe.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=s?pe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),pe.deleteFixedSegment(n[0],this.scene,c);let m=pe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),p=m?pe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:p,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&Tf(l))return}if(n.length===1&&Pr(n[0])){this.startImageCropping(n[0]);return}if(Rt(this.interactiveCanvas),WH(this.state).length>0){let l=this.getElementAtPosition(r,i),s=l&&UH(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...no({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(Rt(this.interactiveCanvas),!t[X.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(Wl(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(oT(s)||!Rz(s.backgroundColor)||Yl({point:oe(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let c=Ef(s,this.state,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});S(this,"getElementLinkAtPosition",(t,n)=>{if(n&&n.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let l=r[a];if(n&&l.id===n.id&&(i=a),l.link&&a>=i&&os(l,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return l}});S(this,"redirectToLink",(t,n)=>{let r=Cr(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>gz)return;let i=Be(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=os(this.hitLinkElement,a,this.state,oe(i.x,i.y),this.editorInterface.formFactor==="phone"),s=Be(this.lastPointerUpEvent,this.state),c=os(this.hitLinkElement,a,this.state,oe(s.x,s.y),this.editorInterface.formFactor==="phone");if(l&&c){Pu();let m=this.hitLinkElement.link;if(m){m=lf(m);let p;if(this.props.onLinkOpen&&(p=Dz(re.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},p)),!p?.defaultPrevented){let d=Pz(m)?"_self":"_blank",h=window.open(void 0,d);h&&(h.opener=null,h.location=m)}}}});S(this,"getTopLayerFrameAtSceneCoords",t=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&mT(t,i,n));return r.length?r[r.length-1]:null});S(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let n=Be(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i},fe.pointers.has(t.pointerId)&&fe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let a=fe.initialScale;if(fe.pointers.size===2&&fe.lastCenter&&a&&fe.initialDistance){let f=Fh(fe.pointers),b=f.x-fe.lastCenter.x,E=f.y-fe.lastCenter.y;fe.lastCenter=f;let w=Oh(Array.from(fe.pointers.values())),y=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/fe.initialDistance,x=y?xo(a*y):this.state.zoom.value;this.setState(v=>{let I=Ko({viewportX:f.x,viewportY:f.y,nextZoom:x},v);return this.translateCanvas({zoom:I.zoom,scrollX:I.scrollX+2*(b/x),scrollY:I.scrollY+2*(E/x),shouldCacheIgnoreZoom:!0}),null}),this.resetShouldCacheIgnoreZoomDebounced()}else fe.lastCenter=fe.initialDistance=fe.initialScale=null;if(Ar||Zl||Mf||ao(this.state))return;let s=Xh($l,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?Rt(this.interactiveCanvas):Nt(this.interactiveCanvas,this.state)),!this.state.newElement&&Xw(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=Vw(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(E=>{let w=Hl(E.snapLines,b),y=E.originSnapOffset?Hl(E.originSnapOffset,f):f;return E.snapLines===w&&E.originSnapOffset===y?null:{snapLines:w,originSnapOffset:y}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let f=this.state.newElement?null:pe.handlePointerMoveInEditMode(t,r,i,this);f&&f!==this.state.selectedLinearElement&&oo(()=>{this.setState({selectedLinearElement:f})})}if(lH(this.state.activeTool.type)){let{newElement:f}=this.state;if(!f&&Gl(this.state)){let b=bo(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),E=>Cf(this.state.zoom));b?this.setState({suggestedBinding:b}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:f,selectedLinearElement:b}=this.state,{x:E,y:w,points:y}=f,x=y[y.length-1],{lastCommittedPoint:v}=b;if(Nt(this.interactiveCanvas,this.state),x===v)aa(this.state.newElement)&&Gl(this.state)&&bo(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),C=>Cf(this.state.zoom))?(this.actionManager.executeAction(gt,"ui",{event:t.nativeEvent,sceneCoords:{x:r,y:i}}),this.setState({suggestedBinding:null,startBoundElement:null}),this.state.activeTool.locked||(Rt(this.interactiveCanvas),this.setState(C=>({newElement:null,activeTool:Oo(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ye({...C.selectedElementIds,[f.id]:!0},C),selectedLinearElement:new pe(f,this.scene.getNonDeletedElementsMap())})))):Cr(oe(r-E,i-w),x)>=af?(this.scene.mutateElement(f,{points:[...y,oe(r-E,i-w)]},{informMutation:!1,isDragging:!1}),zo(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:y[y.length-1],selectedPointsIndices:[f.points.length-1],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:f.points.length-1}}})):xe(this.interactiveCanvas,Ne.POINTER);else if(y.length>2&&v&&Cr(oe(r-E,i-w),v)<af)xe(this.interactiveCanvas,Ne.POINTER),this.scene.mutateElement(f,{points:y.slice(0,-1)},{informMutation:!1,isDragging:!1}),this.setState({selectedLinearElement:{...b,selectedPointsIndices:b.selectedPointsIndices?.includes(f.points.length)?[...b.selectedPointsIndices.filter(I=>I!==f.points.length&&I!==f.points.length-1),f.points.length-1]:b.selectedPointsIndices,lastCommittedPoint:f.points[f.points.length-1],initialState:{...b.initialState,lastClickedPoint:f.points.length-1}}});else{lT(y,this.state.zoom.value)&&xe(this.interactiveCanvas,Ne.POINTER);let I=this.scene.getNonDeletedElementsMap();if(Sf(f)){let P=bo(oe(r,i),this.scene.getNonDeletedElements(),I);an("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(f,P)}zo(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let C=pe.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);C&&this.setState(C)}return}if(this.state.activeTool.type==="arrow"){let f=bo(oe(r,i),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),b=>Cf(this.state.zoom));f&&!oG(oe(r,i),f,this.scene.getNonDeletedElementsMap())&&this.setState({suggestedBinding:f})}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),p=this.scene.getSelectedElements(this.state);if(p.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"&&!(p.length===1&&At(p[0]))&&!(Et(p[0])&&(this.editorInterface.userAgent.isMobileDevice||p[0].points.length===2))){let f=xT(m,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(f&&f.transformHandleType){xe(this.interactiveCanvas,ET(f));return}}}else if(p.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let f=yT(ia(p),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(f){xe(this.interactiveCanvas,ET({transformHandleType:f}));return}}let d=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),h=null;d&&d.locked?h=null:h=d,this.hitLinkElement=this.getElementLinkAtPosition(n,d),!wt(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(xe(this.interactiveCanvas,Ne.POINTER),jx(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Pu(),h&&(h.link||ln(h))&&this.state.selectedElementIds[h.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?xe(this.interactiveCanvas,Eo(h)?Ne.TEXT:Ne.CROSSHAIR):this.state.viewModeEnabled?xe(this.interactiveCanvas,Ne.GRAB):this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,Ne.AUTO):s?xe(this.interactiveCanvas,Ne.AUTO):t[X.CTRL_OR_CMD]?xe(this.interactiveCanvas,Ne.AUTO):(h||this.isHittingCommonBoundingBoxOfSelectedElements(n,p))&&!h?.locked&&(h&&Wl(h)&&this.isIframeLikeElementCenter(h,t,r,i)?(xe(this.interactiveCanvas,Ne.POINTER),this.setState({activeEmbeddable:{element:h,state:"hover"}})):(!h||!At(h)||!(h.startBinding||h.endBinding))&&((this.state.activeTool.type!=="lasso"||p.length>0)&&xe(this.interactiveCanvas,Ne.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}))),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)),this.state.openDialog?.name==="elementLinkSelector"&&h?this.setState(f=>({hoveredElementIds:Hl(f.hoveredElementIds,no({editingGroupId:f.editingGroupId,selectedElementIds:{[h.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!h&&this.setState(f=>({hoveredElementIds:Hl(f.hoveredElementIds,{})})))});S(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});S(this,"handleTouchMove",t=>{jl=!0});S(this,"handleCanvasPointerDown",t=>{let n=Be(t,this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i};let a=t.target;if(a.setPointerCapture&&a.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(f=>({searchMatches:f.searchMatches&&{focusedId:null,matches:f.searchMatches.matches.map(b=>({...b,focus:!1}))}})),this.updateEditorAtom(xg,null)),$e.get(uo)&&this.updateEditorAtom(uo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let f=this.state.newElement;this.updateScene({...f.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(b=>b.id!==f.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBinding:null,selectedElementIds:ye(Object.keys(this.state.selectedElementIds).filter(b=>b!==f.id).reduce((b,E)=>(b[E]=this.state.selectedElementIds[E],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?xt.EVENTUALLY:xt.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(f=>({penMode:!0,penDetected:!0})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=df(this.editorInterface,{isTouchScreen:!0})),Zl||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===kr.ERASER&&this.state.activeTool.type!==Fo.eraser){this.setState({activeTool:Oo(this.state,{type:Fo.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let f=()=>{b(),E?.(),wt(this.state)&&this.setState({activeTool:Oo(this.state,{...this.state.activeTool.lastActiveTool||{type:Fo.selection},lastActiveToolBeforeEraser:null})})},b=Fe(window,re.POINTER_UP,f,{once:!0}),E;requestAnimationFrame(()=>{E=this.missingPointerEventCleanupEmitter.once(f)})});return}if(t.button!==kr.MAIN&&t.button!==kr.TOUCH&&t.button!==kr.ERASER||fe.pointers.size>1)return;let s=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,s)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,s))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let f=s.hit.element&&this.isASelectedElement(s.hit.element);!s.hit.hasHitCommonBoundingBoxOfSelectedElements&&!s.resize.handleType&&!f&&(this.lassoTrail.startPath(s.origin.x,s.origin.y,t.shiftKey),s.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&s.hit.element&&!f&&(this.setState(b=>{let E={...b.selectedElementIds,[s.hit.element.id]:!0},w=[];Object.keys(b.selectedElementIds).forEach(x=>{let v=this.scene.getElement(x);v&&w.push(v)});let y=s.hit.element;if(Lt(y))xf(w,y.id).forEach(x=>{delete E[x.id]});else if(y.frameId)E[y.frameId]&&delete E[y.id];else{let x=y.groupIds,v=new Set(x.flatMap(I=>Lr(this.scene.getNonDeletedElements(),I)).filter(I=>Lt(I)).map(I=>I.id));v.size>0&&w.forEach(I=>{I.frameId&&v.has(I.frameId)&&(delete E[I.id],I.groupIds.flatMap(C=>Lr(this.scene.getNonDeletedElements(),C)).forEach(C=>{delete E[C.id]}))})}return{...no({editingGroupId:b.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),b,this),showHyperlinkPopup:y.link||ln(y)?"info":!1}}),s.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,s):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,s):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,s):this.state.activeTool.type==="custom"?Nt(this.interactiveCanvas,this.state):this.state.activeTool.type===Fo.frame||this.state.activeTool.type===Fo.magicframe?this.createFrameElementOnPointerDown(s,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(s.lastCoords.x,s.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,s);this.props?.onPointerDown?.(this.state.activeTool,s),this.onPointerDownEmitter.trigger(this.state.activeTool,s,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(s.lastCoords.x,s.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(s),p=this.onPointerUpFromPointerDownHandler(s),d=this.onKeyDownFromPointerDownHandler(s),h=this.onKeyUpFromPointerDownHandler(s);this.missingPointerEventCleanupEmitter.once(f=>p(f||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(re.POINTER_MOVE,m),window.addEventListener(re.POINTER_UP,p),window.addEventListener(re.KEYDOWN,d),window.addEventListener(re.KEYUP,h),s.eventListeners.onMove=m,s.eventListeners.onUp=p,s.eventListeners.onKeyUp=h,s.eventListeners.onKeyDown=d)});S(this,"handleCanvasPointerUp",t=>{an("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpEvent=t;let n=Be({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=n;this.lastPointerMoveCoords={x:r,y:i};let a=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.editorInterface.formFactor==="phone"&&a<300){let l=this.getElementAtPosition(n.x,n.y);if(Wl(l)&&this.isIframeLikeElementCenter(l,t,n.x,n.y)){this.handleEmbeddableCenterClick(l);return}}if(this.editorInterface.isTouchScreen){let l=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,l)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?a<300&&Wl(this.hitLinkElement)&&!i1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,oe(n.x,n.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.editorInterface.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});S(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(jl=!1,Vn?jl=!0:Vn=window.setTimeout(()=>{Vn=0,jl||this.handleCanvasContextMenu(t)},Iz))});S(this,"resetContextMenuTimer",()=>{clearTimeout(Vn),Vn=0,jl=!1});S(this,"maybeCleanupAfterMissingPointerUp",t=>{ql?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});S(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(fe.pointers.size<=1&&(t.button===kr.WHEEL||t.button===kr.MAIN&&Ar||ao(this.state)||this.state.viewModeEnabled)))return!1;Zl=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);xe(this.interactiveCanvas,Ne.GRABBING);let{clientX:i,clientY:a}=t,l=kd(c=>{let m=i-c.clientX,p=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!n&&(Math.abs(m)>1||Math.abs(p)>1)){n=!0;let d=f=>{document.body.removeEventListener(re.PASTE,d),f.stopPropagation()},h=()=>{setTimeout(()=>{document.body.removeEventListener(re.PASTE,d),window.removeEventListener(re.POINTER_UP,h)},100)};document.body.addEventListener(re.PASTE,d),window.addEventListener(re.POINTER_UP,h)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-p/this.state.zoom.value})}),s=Re(ql=()=>{ql=null,Zl=!1,Ar||(this.state.viewModeEnabled?xe(this.interactiveCanvas,Ne.GRAB):Nt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(re.POINTER_MOVE,l),window.removeEventListener(re.POINTER_UP,s),window.removeEventListener(re.BLUR,s),l.flush()});return window.addEventListener(re.BLUR,s),window.addEventListener(re.POINTER_MOVE,l,{passive:!0}),window.addEventListener(re.POINTER_UP,s),!0});S(this,"clearSelectionIfNotUsingSelection",()=>{mm(this.state.activeTool.type)||this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});S(this,"handleSelectionOnPointerDown",(t,n)=>{if(mm(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&&!At(a[0])&&!(Et(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=xT(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType))}else a.length>1&&(n.resize.handleType=yT(ia(a),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=cf(KH(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&Et(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=ZH(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement,h=pe.handlePointerDown(t,this,this.store,n.origin,d,this.scene);if(h.hitElement&&(n.hit.element=h.hitElement),h.linearElementEditor&&this.setState({selectedLinearElement:h.linearElementEditor}),h.didAddPoint)return!0}let l=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),s=l.filter(d=>!d.locked),c=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:l});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!s.some(d=>this.state.selectedElementIds[d.id])?n.hit.element=null:n.hit.element=n.hit.element??this.getElementAtPosition(n.origin.x,n.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(n.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&n.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),n.hit.element&&this.getElementLinkAtPosition({x:n.origin.x,y:n.origin.y},n.hit.element))return!1;n.hit.allHitElements=s;let m=n.hit.element,p=n.hit.allHitElements.some(d=>this.isASelectedElement(d));if((m===null||!p)&&!t.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||m&&m?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState(d=>({selectedLinearElement:d.selectedLinearElement?{...d.selectedLinearElement,isEditing:!!m&&m.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:d.selectedLinearElement?ye({[d.selectedLinearElement.elementId]:!0},this.state):ye({},d)}));else if(m!=null){if(t[X.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(n.origin.x,n.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[m.id]||(n.hit.wasAddedToSelection=!0),this.setState(d=>({...GH(d,m),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!fT(m,this.state.editingGroupId)&&this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!p&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(d=>{let h={...d.selectedElementIds,[m.id]:!0},f=[];if(Object.keys(d.selectedElementIds).forEach(b=>{let E=this.scene.getElement(b);E&&f.push(E)}),Lt(m))xf(f,m.id).forEach(b=>{delete h[b.id]});else if(m.frameId)h[m.frameId]&&delete h[m.id];else{let b=m.groupIds,E=new Set(b.flatMap(w=>Lr(this.scene.getNonDeletedElements(),w)).filter(w=>Lt(w)).map(w=>w.id));E.size>0&&f.forEach(w=>{w.frameId&&E.has(w.frameId)&&(delete h[w.id],w.groupIds.flatMap(y=>Lr(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete h[y.id]}))})}return d.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(b=>d.selectedGroupIds[b])||(h={[m.id]:!0})),{...no({editingGroupId:d.editingGroupId,selectedElementIds:h},this.scene.getNonDeletedElements(),d,this),showHyperlinkPopup:m.link||ln(m)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});S(this,"handleTextOnPointerDown",(t,n)=>{if(this.state.editingTextElement)return;let r=n.origin.x,i=n.origin.y,a=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);oT(a)&&(l=a,r=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Rt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Oo(this.state,{type:this.state.preferredSelectionTool.type})})});S(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,a]=pt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,c=eH({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[oe(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(p=>{let d={...p.selectedElementIds};return delete d[c.id],{selectedElementIds:ye(d,p)}});let m=bo(oe(r.origin.x,r.origin.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());this.setState({newElement:c,startBoundElement:m,suggestedBinding:null})});S(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[a,l]=pt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=tH({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.scene.insertElement(s),s});S(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,a]=pt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=um(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=J5({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:r});return this.scene.insertElement(s),s});S(this,"newImagePlaceholder",({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0})=>{let[i,a]=pt(t,n,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return rH({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,x:i-s/2,y:a-s/2,width:s,height:s})});S(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(t.ctrlKey&&oo(()=>{this.setState({isBindingEnabled:!1})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(zo(a,"selectedLinearElement is expected to be set"),i.type==="line"&&lT(i.points,this.state.zoom.value)){oo(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(gt);return}if(At(i)&&i.points.length>1){this.actionManager.executeAction(gt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}let{x:l,y:s}=i,{lastCommittedPoint:c}=a,m=Gl(this.state)&&bo(oe(this.lastPointerMoveCoords?.x??l+i.points[i.points.length-1][0],this.lastPointerMoveCoords?.y??s+i.points[i.points.length-1][1]),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(Yn(i)&&m||i.points.length>1&&c&&Cr(oe(r.origin.x-l,r.origin.y-s),c)<af){this.actionManager.executeAction(gt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(p=>({selectedElementIds:ye({...p.selectedElementIds,[i.id]:!0},p)})),xe(this.interactiveCanvas,Ne.POINTER)}else{let[i,a]=pt(r.origin.x,r.origin.y,t[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,p]=n==="arrow"?[s,c]:[null,null],d=n==="arrow"?oH({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Un.round?{type:am.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:p,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Un.elbow,fixedSegments:this.state.currentItemArrowType===Un.elbow?[]:null}):iH({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:am.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null}),h=oe(r.origin.x,r.origin.y),f=this.scene.getNonDeletedElementsMap(),b=Gl(this.state)?bo(h,this.scene.getNonDeletedElements(),f):null;this.scene.mutateElement(d,{points:[oe(0,0),oe(0,0)]}),this.scene.insertElement(d),Yn(d)&&eG(d,new Map([[0,{point:oe(0,0),isDragging:!1}]]),h[0],h[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:H5(t.nativeEvent)}),oo(()=>{this.setState(E=>{let w=null,y=E.selectedElementIds;if(Et(d)){w=new pe(d,this.scene.getNonDeletedElementsMap());let x=d.points.length-1;w={...w,selectedPointsIndices:[x],initialState:{...w.initialState,lastClickedPoint:x,origin:oe(r.origin.x,r.origin.y)}}}return y=this.state.activeTool.locked?E.selectedElementIds:ye({[d.id]:!0},E),{...E,bindMode:"orbit",newElement:d,startBoundElement:b,suggestedBinding:b||null,selectedElementIds:y,selectedLinearElement:w}})}),Yn(d)&&an("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(d,b)}});S(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=pt(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),l={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=J5({type:"embeddable",...l}):s=nH({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});S(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=pt(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,...No},l=n===Fo.magicframe?Q5(a):Qz(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});S(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});S(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(Yn(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);hm(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);hm(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(l=>l.id!==i.id)})}}else hf(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let l=this.scene.getElement(a.id);l?.startBinding?.elementId===i.id&&hm(l,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),l?.endBinding?.elementId===i.id&&hm(l,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||uf(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,Wn(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});S(this,"initializeImage",async(t,n)=>{if(!Sm(n))throw new Error(g("errors.unsupportedFileType"));let r=n.type,i=n.size>=this.state.dontResizeLimitMBs*1024*1024;if(xe(this.interactiveCanvas,"wait"),r===Bo.svg)try{n=Pm(cT(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}else if(i)try{n=await cs(n,{maxWidthOrHeight:hz}),console.info("Excalidraw: image resized")}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>W5)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(W5/1024/1024)}MB`}));let a=await(this.props.generateIdForFile?.(n)||g1(n));if(console.info("Excalidraw File ID:",a),!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));let l=this.files[a]?.dataURL||await Mm(n);return new Promise(async(s,c)=>{try{let m=this.getLatestInitializedImageElement(t,a);if(this.addMissingFiles([{mimeType:r,id:a,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(a)){this.addNewImagesToImageCache();let{erroredFiles:d}=await this.updateImageCache([m]);if(d.size)throw new Error("Image cache update resulted with an error.")}let p=await this.imageCache.get(a)?.image;if(p&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,a);let d=this.getImageNaturalDimensions(m,p);Object.assign(m,d)}s(m)}catch(m){console.error(m),c(new Error(g("errors.imageInsertError")))}})});S(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return Wn(r,{fileId:n})});S(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Be({clientX:t,clientY:n},this.state),a=await es({description:"Image",extensions:Object.keys(bz),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Oo(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(gt)})}});S(this,"getImageNaturalDimensions",(t,n)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(n.naturalHeight,i),l=a*(n.naturalWidth/n.naturalHeight),s=t.x+t.width/2-l/2,c=t.y+t.height/2-a/2;return{x:s,y:c,width:l,height:a,crop:null}});S(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await gH({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(xt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Ul(a)&&i.has(a.fileId)?Wn(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});S(this,"addNewImagesToImageCache",async(t=hH(this.scene.getNonDeletedElements()),n=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,n);if(i.size)for(let a of r)i.has(a.fileId)&&Vl.delete(a);i.size&&this.scene.triggerUpdate()}});S(this,"scheduleImageRefresh",sz(()=>{this.addNewImagesToImageCache()},Ez));S(this,"updateBindingEnabledOnPointerMove",t=>{let n=Jz(t);this.state.isBindingEnabled!==n&&this.setState({isBindingEnabled:n})});S(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(re.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(re.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(re.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(re.TOUCH_END,this.onTouchEnd))});S(this,"insertImages",async(t,n,r)=>{let i=50/this.state.zoom.value,a=ST(t.map(()=>this.newImagePlaceholder({sceneX:n,sceneY:r})),n,r,i);a.forEach(d=>this.scene.insertElement(d));let l=await Promise.all(a.map(async(d,h)=>{try{return await this.initializeImage(d,await fa(t[h]))}catch(f){return this.setState({errorMessage:f.message||g("errors.imageInsertError")}),Wn(d,{isDeleted:!0})}})),s=dm(l),c=ST(l.filter(d=>!d.isDeleted),n,r,i),m=dm(c),p=this.scene.getElementsIncludingDeleted().map(d=>m.get(d.id)??s.get(d.id)??d);this.updateScene({appState:{selectedElementIds:ye(Object.fromEntries(c.map(d=>[d.id,!0])),this.state)},elements:p,captureUpdate:xt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(gt)})});S(this,"handleAppOnDrop",async t=>{let{x:n,y:r}=Be(t,this.state),i=await Xa(t),a=i.getFiles();if(a.length===1){let{file:p,fileHandle:d}=a[0];if(p&&(p.type===Bo.png||p.type===Bo.svg))try{let h=await ss(p,this.state,this.scene.getElementsIncludingDeleted(),d);this.syncActionResult({...h,appState:{...h.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:xt.IMMEDIATELY});return}catch(h){if(h.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}}let l=a.map(p=>p.file).filter(p=>Sm(p));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,n,r);let s=i.getData(Bo.excalidrawlibIds),c=i.getData(Bo.excalidrawlib);if(s||c){try{let p=null;if(s){let{itemIds:d}=JSON.parse(s);p=(await this.library.getLatestLibrary()).filter(f=>d.includes(f.id))}else c&&(p=h1(c));p?.length&&(p=p.map(d=>({...d,elements:pf({type:"everything",elements:d.elements,randomizeSeed:!0}).duplicatedElements})),this.addElementsFromPasteOrLibrary({elements:Ri(p),position:t,files:null}))}catch(p){this.setState({errorMessage:p.message})}return}if(a.length>0){let{file:p,fileHandle:d}=a[0];p&&await this.loadFileToCanvas(p,d)}let m=i.findByType(Bo.text);if(m){let p=m.value;if(p&&ff(p,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(p)||um(p)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:n,sceneY:r,link:lf(p)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});S(this,"loadFileToCanvas",async(t,n)=>{t=await fa(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Cm(t,this.state,r,n)}catch(a){let l=a instanceof o1;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let s=l?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===Bo.excalidraw?(DT(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:xt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:xt.IMMEDIATELY})):i.type===Bo.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});S(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==kr.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type)return;let{x:n,y:r}=Be(t,this.state),i=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:n,y:r},a),s=i||l?"element":"canvas",c=this.excalidrawContainerRef.current,{top:m,left:p}=c.getBoundingClientRect(),d=t.clientX-p,h=t.clientY-m;le("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...no({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Et(i)?new pe(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:h,left:d,items:this.getContextMenuItems(s)}})})});S(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){wT({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:ra(t.origin.x,a.x),height:ra(t.origin.y,a.y),shouldMaintainAspectRatio:Ol(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,c]=pt(a.x,a.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=Ul(l)&&this.imageCache.get(l.fileId)?.image,p=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:d,snapLines:h}=Yw(l,this,n,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=d.x,c+=d.y,this.setState({snapLines:h}),Yn(l)||wT({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:ra(t.originInGrid.x,s),height:ra(t.originInGrid.y,c),shouldMaintainAspectRatio:Pr(l)?!Ol(n):Ol(n),shouldResizeFromCenter:z5(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:p,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===Fo.frame||this.state.activeTool.type===Fo.magicframe)&&this.setState({elementsToHighlight:wf(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});S(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,l]=pt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&Pr(s)){let c=t.originalElements.get(s.id),m=Ul(s)&&this.imageCache.get(s.fileId)?.image;if(c&&Pr(c)&&m&&!(m instanceof Promise)){let[p,d]=pt(i.x,i.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),h={x:p-t.originInGrid.x,y:d-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:f,snapLines:b}=Uh([s],[c],this,n,h,r);this.scene.mutateElement(s,AH(s,this.scene.getNonDeletedElementsMap(),r,m.naturalWidth,m.naturalHeight,a+f.x,l+f.y,n.shiftKey?c.width/c.height:void 0)),pm(s,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:b})}return!0}return!1});S(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(p=>Lt(p)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&At(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=pt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(p=>{xf(this.scene.getNonDeletedElements(),p.id).forEach(h=>{m.set(p.id+h.id,{x:h.x-p.x,y:h.y-p.y})})}),!this.state.selectedElementsAreBeingDragged){let[p,d]=pt(l.x,l.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),h={x:p-t.originInGrid.x,y:d-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:b,snapLines:E}=Uh(r,q(f,this.state),this,n,h,a);s+=b.x,c+=b.y,this.setState({snapLines:E})}if($H(t.originalElements,a,r,this.scene,H5(n),z5(n),r.some(p=>Pr(p))?!Ol(n):Ol(n),s,c,t.resize.center.x,t.resize.center.y)){let p=new Set;return i.forEach(d=>{wf(this.scene.getNonDeletedElements(),d,this.state,this.scene.getNonDeletedElementsMap()).forEach(h=>p.add(h))}),this.setState({elementsToHighlight:[...p]}),!0}return!1});S(this,"getContextMenuItems",t=>{let n=[];if(n.push(kc,Cc),t==="canvas")return this.state.viewModeEnabled?[...n,Pc,vi,Jc,Ii]:[gu,Ye,kc,Cc,Mc,Ye,cp,oy,Ye,Pc,fu,vi,Jc,Ii];if(n.push(Mc),this.state.viewModeEnabled)return[wi,...n];let r=this.editorInterface.formFactor==="desktop"?[Ye,ip,ap,lp,sp]:[];return[Ye,Sc,wi,gu,Ye,ww,vw,Iw,Ye,_h,pu,Ye,...n,Ye,ru,iu,Ye,lu,Aw,xu,yu,Gx,su,Ye,mu,...r,Ye,uu,hu,Ye,Vi,Ye,qa,Fc,Ye,pv,dp,Ja,Ye,Sa]});S(this,"handleWheel",Re(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&t.target.classList.contains(mf.FRAME_NAME))){t[X.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Zl)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=Sz*100,l=Math.abs(r),s=r;l>a&&(s=a*i);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(m=>({...Ko({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:xo(c)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(r||n)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-n/i.value,scrollY:l-r/i.value}))}));S(this,"savePointer",(t,n,r)=>{if(!t||!n)return;let{x:i,y:a}=Be({clientX:t,clientY:n},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:r,pointersMap:fe.pointers})});S(this,"resetShouldCacheIgnoreZoomDebounced",X5(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));S(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let n=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:l}=n.getBoundingClientRect(),{width:s,height:c,offsetTop:m,offsetLeft:p}=this.state;if(r===s&&i===c&&a===p&&l===m){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});S(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});S(this,"watchState",()=>{});let n=Br(),{excalidrawAPI:r,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=n.theme,name:m=`${g("labels.untitled")}-${Z5()}`,wheelZoomsOnDefault:p=!1}=t;if(this.state={...n,theme:c,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??n.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:p},this.refreshEditorInterface(),this.stylesPanelMode=fm(this.editorInterface),this.id=dz(),this.library=new My(this),this.actionManager=new wd(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new IT,this.canvas=document.createElement("canvas"),this.rc=cz.canvas(this.canvas),this.renderer=new El(this.scene),this.visibleElements=[],this.store=new JH(this),this.history=new gl(this.store),r){let d={updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,addImageElementsToScene:this.insertImages,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:h=>{this.actionManager.registerAction(h)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:h=>this.onChangeEmitter.on(h),onIncrement:h=>this.store.onStoreIncrementEmitter.on(h),onPointerDown:h=>this.onPointerDownEmitter.on(h),onPointerUp:h=>this.onPointerUpEmitter.on(h),onScrollChange:h=>this.onScrollChangeEmitter.on(h),onUserFollow:h=>this.onUserFollowEmitter.on(h)};typeof r=="function"?r(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new cn(this.scene),this.history=new gl(this.store),this.actionManager.registerAll(As),this.actionManager.registerAction(kw(this.history)),this.actionManager.registerAction(Mw(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(t.data)}catch{}if(n)switch(t.origin){case"https://player.vimeo.com":if(n.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:n.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(n.event==="infoDelivery"&&n.info&&n.id&&typeof n.info.playerState=="number"){let r=n.id,i=n.info.playerState;Object.values(sm).includes(i)&&Pf.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){zo(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),n=bo(oe(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=pe.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&n?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),oo(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:n}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;zo(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=n-this.state.selectedLinearElement.pointerOffset.y,l=this.state.multiElement?pe.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):pe.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);l&&this.setState(l)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,n){if(t.isDeleted||At(t))return;let r=()=>{if(this.bindModeHandler=null,zo(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 f=this.state.selectedLinearElement.selectedPointsIndices.includes(0),b=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!f&&!b||f&&b)return}let{x:p,y:d}=this.lastPointerMoveCoords,h=bo(oe(p,d),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(h&&this.state.bindMode!=="skip"){zo(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let f=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===h.id;oo(()=>{zo(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:f}}})});let b=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;zo(b,"Last event must exist");let E=p-this.state.selectedLinearElement.pointerOffset.x,w=d-this.state.selectedLinearElement.pointerOffset.y,y=this.state.multiElement?pe.handlePointerMove(b,this,E,w,this.state.selectedLinearElement):pe.handlePointDragging(b,this,E,w,this.state.selectedLinearElement);y&&this.setState(y)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let p=this.scene.getNonDeletedElementsMap(),d=this.state.selectedLinearElement.selectedPointsIndices.includes(0),h=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),f=d?n:t.startBinding&&p.get(t.startBinding.elementId),b=h?n:t.endBinding&&p.get(t.endBinding.elementId),E=f&&kT(f,p),w=b&&kT(b,p);i=!!(E&&w&&f.id!==b.id&&tG(E,w))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),l=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),s=a?"startBinding":l?"endBinding":null,c=a?"endBinding":l?"startBinding":null,m=c&&t[c]?.mode==="inside"&&t[c]?.elementId===n?.id||s&&t[s]?.mode==="inside"&&n?.id===t[s]?.elementId;s&&c&&t[s]?.mode==="inside"&&n?.id!==t[s]?.elementId&&t[c]?.elementId!==t[s]?.elementId&&this.scene.mutateElement(t,{[s]:{...t[s],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!n||this.previousHoveredBindableElement&&n.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&oo(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!m&&(this.bindModeHandler=setTimeout(r,Wz)),this.previousHoveredBindableElement=n}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),la(t)))return;let n=this.getHTMLIFrameElement(t);if(n?.contentWindow){if(n.src.includes("youtube")){let r=Pf.get(t.id);switch(r||(Pf.set(t.id,sm.UNSTARTED),n.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),r){case sm.PLAYING:case sm.BUFFERING:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}n.src.includes("player.vimeo.com")&&n.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,n,r,i){return t&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>ln(a)&&this.embedsValidationStatus.get(a.id)===!0||la(a));return we(aG,{children:i.map(a=>{let{x:l,y:s}=cm({sceneX:a.x,sceneY:a.y},this.state),c=iT(a,n,r,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(c&&!m&&this.initializedEmbeds.add(a.id),!(c||m))return null;let d;if(la(a)){d=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let E=b.html;d={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>E}}else if(b.status==="pending")d={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>sT(`
|
|
20
20
|
<style>
|
|
21
21
|
html, body {
|
|
22
22
|
width: 100%;
|
|
23
23
|
height: 100%;
|
|
24
|
-
color: ${this.state.theme===
|
|
24
|
+
color: ${this.state.theme===lm.DARK?"white":"black"};
|
|
25
25
|
}
|
|
26
26
|
body {
|
|
27
27
|
display: flex;
|
|
@@ -88,7 +88,7 @@ ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipbo
|
|
|
88
88
|
</svg>
|
|
89
89
|
</div>
|
|
90
90
|
<div>Generating...</div>
|
|
91
|
-
`)};else{let E;b.code==="ERR_GENERATION_INTERRUPTED"?E="Generation was interrupted...":E=b.message||"Generation failed",d={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>
|
|
91
|
+
`)};else{let E;b.code==="ERR_GENERATION_INTERRUPTED"?E="Generation was interrupted...":E=b.message||"Generation failed",d={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>sT(`
|
|
92
92
|
<style>
|
|
93
93
|
html, body {
|
|
94
94
|
height: 100%;
|
|
@@ -98,7 +98,7 @@ ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipbo
|
|
|
98
98
|
flex-direction: column;
|
|
99
99
|
align-items: center;
|
|
100
100
|
justify-content: center;
|
|
101
|
-
color: ${
|
|
101
|
+
color: ${pz.red[3]};
|
|
102
102
|
}
|
|
103
103
|
h1, h3 {
|
|
104
104
|
margin-top: 0;
|
|
@@ -107,7 +107,7 @@ ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipbo
|
|
|
107
107
|
</style>
|
|
108
108
|
<h1>Error!</h1>
|
|
109
109
|
<h3>${E}</h3>
|
|
110
|
-
`)}}}else d=bm(Pz(a.link||""));let h=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return we("div",{className:B5("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:zH(a,kf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?kz:1),"--embeddable-radius":`${mH(Math.min(a.width,a.height),a)}px`},children:xm("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:h?ma.enabled:ma.disabled},children:[f&&we("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),we("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(mn(a)?this.props.renderEmbeddable?.(a,this.state):null)??we("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:d?.type==="document"?d.srcdoc(this.state.theme):void 0,src:d?.type!=="document"?d?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${d?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:n,renderTopLeftUI:r,renderCustomStats:i}=this.props,a=this.scene.getSceneNonce(),{elementsMap:l,visibleElements:s}=this.renderer.getRenderableElements({sceneNonce:a,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id});this.visibleElements=s;let c=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",p=t[0],d=$e.get(ho)?.type==="panel";return we("div",{translate:"no",className:B5("excalidraw excalidraw-container notranslate",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone"}),style:{"--ui-pointerEvents":m?ma.disabled:ma.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:we(OT.Provider,{value:this,children:we(zT.Provider,{value:this.props,children:we(zf.Provider,{value:this.excalidrawContainerValue,children:we(Of.Provider,{value:this.editorInterface,children:we(Uf.Provider,{value:this.setAppState,children:we(Gf.Provider,{value:this.state,children:xm(Hf.Provider,{value:this.scene.getNonDeletedElements(),children:[xm(Wf.Provider,{value:this.actionManager,children:[we(n5,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Xo().code,renderTopLeftUI:r,renderTopRightUI:n,renderCustomStats:i,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),we("div",{className:"excalidraw-textEditorContainer"}),we("div",{className:"excalidraw-contextMenuContainer"}),we("div",{className:"excalidraw-eye-dropper-container"}),we(a5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&we(qx,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),t.length===1&&ga(p)&&p.customData?.generationData?.status==="done"&&xm(qw,{element:p,elementsMap:l,children:[we(Jg,{title:g("labels.copySource"),icon:Qr,checked:!1,onChange:()=>this.onIframeSrcCopy(p)}),we(Jg,{title:"Enter fullscreen",icon:Z0,checked:!1,onChange:()=>{let h=this.getHTMLIFrameElement(p);if(h)try{h.requestFullscreen(),this.setState({activeEmbeddable:{element:p,state:"active"},selectedElementIds:{[p.id]:!0},newElement:null,selectionElement:null})}catch(f){console.warn(f),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&we(R5,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&we(Dv,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:h=>{this.setState({contextMenu:null},()=>{this.focusContainer(),h?.()})}}),we(sf,{canvas:this.canvas,rc:this.rc,elementsMap:l,allElementsMap:c,visibleElements:s,sceneNonce:a,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:Rn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes,theme:this.state.theme}}),this.state.newElement&&we(_5,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:l,allElementsMap:c,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),we(lf,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:l,visibleElements:s,allElementsMap:c,selectedElements:t,sceneNonce:a,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&we(Nv,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&we(N5,{app:this,activeLockedId:this.state.activeLockedId}),d&&we(hy,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,n){let r=this.plugins.diagramToCode?.generate;if(!r){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=IH(this.scene.getNonDeletedElements(),t).filter(l=>!lT(l));if(!i.length){n==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),le("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),le("ai","generate (start)","d2c");try{let{html:l}=await r({frame:t,children:i});if(le("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){le("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(po(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let n=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{jl(r)&&n[r.fileId]&&(this.imageCache.delete(r.fileId),Ql.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,RT()||NT()){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)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(r=>{t(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Sz&&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),Vz()&&!DH()&&this.setState({errorMessage:we(Pv,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new kT,this.fonts=new un(this.scene),this.renderer=new Cl(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),Ql.destroy(),jt.destroy(),clearTimeout(Kn),ve.clearCache(),ro.clearCache(),Kn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Fe(document,re.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Fe(this.excalidrawContainerRef.current,re.WHEEL,this.handleWheel,{passive:!1}),Fe(window,re.MESSAGE,this.onWindowMessage,!1),Fe(document,re.POINTER_UP,this.removePointer,{passive:!1}),Fe(document,re.COPY,this.onCopy,{passive:!1}),Fe(document,re.KEYUP,this.onKeyUp,{passive:!0}),Fe(document,re.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Fe(document.fonts,"loadingdone",t=>{let n=t.fontfaces;this.fonts.onLoaded(n)},{passive:!1}),Fe(document,re.GESTURE_START,this.onGestureStart,!1),Fe(document,re.GESTURE_CHANGE,this.onGestureChange,!1),Fe(document,re.GESTURE_END,this.onGestureEnd,!1),Fe(window,re.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Fe(document,re.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),Fe(document,re.PASTE,this.pasteFromClipboard,{passive:!1}),Fe(document,re.CUT,this.onCut,{passive:!1}),Fe(window,re.RESIZE,this.onResize,!1),Fe(window,re.UNLOAD,this.onUnload,!1),Fe(window,re.BLUR,this.onBlur,!1),Fe(this.excalidrawContainerRef.current,re.WHEEL,this.handleWheel,{passive:!1}),Fe(this.excalidrawContainerRef.current,re.DRAG_OVER,this.disableEvent,!1),Fe(this.excalidrawContainerRef.current,re.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Fe(Lz(this.excalidrawContainerRef.current),re.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,n){this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),n.userToFollow&&!this.state.collaborators.has(n.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(n.zoom.value!==this.state.zoom.value||n.scrollX!==this.state.scrollX||n.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),n.userToFollow!==this.state.userToFollow&&(n.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:n.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&wt(this.state)&&this.setState({activeTool:Uo(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&n.theme!==this.state.theme&&$p(this.interactiveCanvas,this.state.theme),n.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),wt(n)&&!wt(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),n.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(n.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&n.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===mm.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(gt)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){es=!1,ts=null}async insertClipboardContent(t,n,r){let{x:i,y:a}=Be({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(n.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(t.spreadsheet&&!r){this.setState({pasteDialog:{data:t.spreadsheet,shown:!0}});return}let l=n.map(m=>m.file);if(l.length===0&&t.text&&!r){let m=t.text.trim();m.startsWith("<svg")&&m.endsWith("</svg>")&&l.push(Dm(m))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:g("errors.imageToolNotSupported")});return}if(t.elements){let m=t.programmaticAPI?oG(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:m,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r});return}if(!t.text)return;let s=Fz(t.text).split(/\n+/).map(m=>m.trim()).filter(Boolean),c=s.map(m=>pH(m)).filter(m=>wf(m,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(m)||bm(m)?.type==="video"));if(!r&&c.length>0&&c.length===s.length){let m=[];for(let p of c){let d=m[m.length-1],h=this.insertEmbeddableElement({sceneX:d?d.x+d.width+20:i,sceneY:a,link:pf(p)});h&&m.push(h)}m.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(m.map(p=>[p.id,!0]))}));return}this.addTextFromPaste(t.text,r)}async addElementsFromMixedContentPaste(t,{isPlainPaste:n,sceneX:r,sceneY:i}){if(!n&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(m=>m.type==="imageUrl").map(m=>m.value),l=await Promise.all(a.map(async m=>{try{return{file:await I1(m)}}catch(p){let d=p.message;return p.cause==="FETCH_ERROR"?d=g("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(d=g("errors.unsupportedFileType")),{errorMessage:d}}})),s=l.filter(m=>!!m.file).map(m=>m.file);await this.insertImages(s,r,i);let c=l.find(m=>!!m.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
|
|
110
|
+
`)}}}else d=um(Lz(a.link||""));let h=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return we("div",{className:_5("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:HH(a,vf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?Mz:1),"--embeddable-radius":`${pH(Math.min(a.width,a.height),a)}px`},children:gm("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:h?na.enabled:na.disabled},children:[f&&we("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),we("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(ln(a)?this.props.renderEmbeddable?.(a,this.state):null)??we("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:d?.type==="document"?d.srcdoc(this.state.theme):void 0,src:d?.type!=="document"?d?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${d?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:n,renderTopLeftUI:r,renderCustomStats:i}=this.props,a=this.scene.getSceneNonce(),{elementsMap:l,visibleElements:s}=this.renderer.getRenderableElements({sceneNonce:a,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id});this.visibleElements=s;let c=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",p=t[0],d=$e.get(uo)?.type==="panel";return we("div",{translate:"no",className:_5("excalidraw excalidraw-container notranslate",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone"}),style:{"--ui-pointerEvents":m?na.disabled:na.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:we(RT.Provider,{value:this,children:we(NT.Provider,{value:this.props,children:we(Rf.Provider,{value:this.excalidrawContainerValue,children:we(Df.Provider,{value:this.editorInterface,children:we(Ff.Provider,{value:this.setAppState,children:we(Bf.Provider,{value:this.state,children:gm(Nf.Provider,{value:this.scene.getNonDeletedElements(),children:[gm(Of.Provider,{value:this.actionManager,children:[we(QI,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Uo().code,renderTopLeftUI:r,renderTopRightUI:n,renderCustomStats:i,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),we("div",{className:"excalidraw-textEditorContainer"}),we("div",{className:"excalidraw-contextMenuContainer"}),we("div",{className:"excalidraw-eye-dropper-container"}),we(o5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&we(Zx,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),t.length===1&&la(p)&&p.customData?.generationData?.status==="done"&&gm(Kw,{element:p,elementsMap:l,children:[we(Kg,{title:g("labels.copySource"),icon:Vr,checked:!1,onChange:()=>this.onIframeSrcCopy(p)}),we(Kg,{title:"Enter fullscreen",icon:V0,checked:!1,onChange:()=>{let h=this.getHTMLIFrameElement(p);if(h)try{h.requestFullscreen(),this.setState({activeEmbeddable:{element:p,state:"active"},selectedElementIds:{[p.id]:!0},newElement:null,selectionElement:null})}catch(f){console.warn(f),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&we(L5,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&we(Pv,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:h=>{this.setState({contextMenu:null},()=>{this.focusContainer(),h?.()})}}),we(of,{canvas:this.canvas,rc:this.rc,elementsMap:l,allElementsMap:c,visibleElements:s,sceneNonce:a,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:_n(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes,theme:this.state.theme}}),this.state.newElement&&we(M5,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:l,allElementsMap:c,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),we(tf,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:l,visibleElements:s,allElementsMap:c,selectedElements:t,sceneNonce:a,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&we(Av,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&we(A5,{app:this,activeLockedId:this.state.activeLockedId}),d&&we(my,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,n){let r=this.plugins.diagramToCode?.generate;if(!r){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=TH(this.scene.getNonDeletedElements(),t).filter(l=>!nT(l));if(!i.length){n==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),le("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),le("ai","generate (start)","d2c");try{let{html:l}=await r({frame:t,children:i});if(le("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){le("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(mo(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let n=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{Ul(r)&&n[r.fileId]&&(this.imageCache.delete(r.fileId),Vl.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,LT()||AT()){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)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(r=>{t(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Cz&&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),Xz()&&!RH()&&this.setState({errorMessage:we(Sv,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new IT,this.fonts=new cn(this.scene),this.renderer=new El(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),Vl.destroy(),$t.destroy(),clearTimeout(Vn),ve.clearCache(),no.clearCache(),Vn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Fe(document,re.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Fe(this.excalidrawContainerRef.current,re.WHEEL,this.handleWheel,{passive:!1}),Fe(window,re.MESSAGE,this.onWindowMessage,!1),Fe(document,re.POINTER_UP,this.removePointer,{passive:!1}),Fe(document,re.COPY,this.onCopy,{passive:!1}),Fe(document,re.KEYUP,this.onKeyUp,{passive:!0}),Fe(document,re.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Fe(document.fonts,"loadingdone",t=>{let n=t.fontfaces;this.fonts.onLoaded(n)},{passive:!1}),Fe(document,re.GESTURE_START,this.onGestureStart,!1),Fe(document,re.GESTURE_CHANGE,this.onGestureChange,!1),Fe(document,re.GESTURE_END,this.onGestureEnd,!1),Fe(window,re.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Fe(document,re.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),Fe(document,re.PASTE,this.pasteFromClipboard,{passive:!1}),Fe(document,re.CUT,this.onCut,{passive:!1}),Fe(window,re.RESIZE,this.onResize,!1),Fe(window,re.UNLOAD,this.onUnload,!1),Fe(window,re.BLUR,this.onBlur,!1),Fe(this.excalidrawContainerRef.current,re.WHEEL,this.handleWheel,{passive:!1}),Fe(this.excalidrawContainerRef.current,re.DRAG_OVER,this.disableEvent,!1),Fe(this.excalidrawContainerRef.current,re.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Fe(Az(this.excalidrawContainerRef.current),re.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,n){this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),n.userToFollow&&!this.state.collaborators.has(n.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(n.zoom.value!==this.state.zoom.value||n.scrollX!==this.state.scrollX||n.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),n.userToFollow!==this.state.userToFollow&&(n.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:n.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&wt(this.state)&&this.setState({activeTool:Oo(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&n.theme!==this.state.theme&&Vp(this.interactiveCanvas,this.state.theme),n.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),wt(n)&&!wt(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),n.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(n.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&n.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===lm.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(gt)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){Xl=!1,Kl=null}async insertClipboardContent(t,n,r){let{x:i,y:a}=Be({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(n.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(t.spreadsheet&&!r){this.setState({pasteDialog:{data:t.spreadsheet,shown:!0}});return}let l=n.map(m=>m.file);if(l.length===0&&t.text&&!r){let m=t.text.trim();m.startsWith("<svg")&&m.endsWith("</svg>")&&l.push(Pm(m))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:g("errors.imageToolNotSupported")});return}if(t.elements){let m=t.programmaticAPI?nG(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:m,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r});return}if(!t.text)return;let s=Oz(t.text).split(/\n+/).map(m=>m.trim()).filter(Boolean),c=s.map(m=>uH(m)).filter(m=>ff(m,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(m)||um(m)?.type==="video"));if(!r&&c.length>0&&c.length===s.length){let m=[];for(let p of c){let d=m[m.length-1],h=this.insertEmbeddableElement({sceneX:d?d.x+d.width+20:i,sceneY:a,link:lf(p)});h&&m.push(h)}m.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(m.map(p=>[p.id,!0]))}));return}this.addTextFromPaste(t.text,r)}async addElementsFromMixedContentPaste(t,{isPlainPaste:n,sceneX:r,sceneY:i}){if(!n&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(m=>m.type==="imageUrl").map(m=>m.value),l=await Promise.all(a.map(async m=>{try{return{file:await E1(m)}}catch(p){let d=p.message;return p.cause==="FETCH_ERROR"?d=g("errors.failedToFetchImage"):p.cause==="UNSUPPORTED"&&(d=g("errors.unsupportedFileType")),{errorMessage:d}}})),s=l.filter(m=>!!m.file).map(m=>m.file);await this.insertImages(s,r,i);let c=l.find(m=>!!m.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
|
|
111
111
|
|
|
112
|
-
`),n)}}addTextFromPaste(t,n=!1){let{x:r,y:i}=Be({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:
|
|
113
|
-
`),b=f.reduce((E,w,y)=>{let x=RH(w).trim();if(x.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:h}),I=xT(x,l,s),C=I.width>p,P=C?AH(x,l,p):x;I=C?xT(P,l,s):I;let k=r-I.width/2,N=h-I.height/2,_=rT({...a,x:k,y:N,text:P,originalText:x,lineHeight:s,autoResize:!C,frameId:v?v.id:null});E.push(_),h+=_.height+d}else f[y-1]?.trim()&&(h+=NH(a.fontSize,s)+d);return E},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:ye(Object.fromEntries(b.map(E=>[E.id,!0])),this.state)}),!n&&b.length>1&&DT===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:A("CtrlOrCmd+Shift+V")}),duration:5e3}),DT=!0))}handleTextWysiwyg(t,{isExistingElement:n=!1}){let r=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&xo(s)?Vn(s,{originalText:a,isDeleted:l??s.isDeleted,...iH(s,hT(s,r),r,a)}):s)])};cv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:c}=um({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:Re(a=>{i(a,!1),CT(t)&&fm(t,this.scene)}),onSubmit:Re(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let c=t.containerId?t.containerId:t.id;no(()=>{this.setState(m=>({selectedElementIds:ye({...m.selectedElementIds,[c]:!0},m)}))})}s&&jz(this.scene.getNonDeletedElements(),[t]),(!s||n)&&this.store.scheduleCapture(),no(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Nt(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,n){let r=this.getElementAtPosition(t,n,{includeBoundTextElement:!0});return r&&xo(r)&&!r.isDeleted?r:null}getElementAtPosition(t,n,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,n,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return Jl({point:oe(t,n),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Lt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,n,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(r?.includeLockedElements||!s.locked)&&(r?.includeBoundTextElement||!(xo(s)&&s.containerId)))).filter(s=>this.hitElement(t,n,s)).filter(s=>{let c=kf(s,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?gT({x:t,y:n},c,a):!0}).filter(s=>ga(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(Z5/this.state.zoom.value))}hitElement(t,n,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&bH([r],this.state,this.editorInterface)&&JH(oe(t,n),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||SH(oe(t,n),r,this.scene.getNonDeletedElementsMap())?!0:Jl({point:oe(t,n),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Lt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,n){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return sT(i[0],!1)?i[0]:null;let a=null;for(let l=r.length-1;l>=0;--l){if(r[l].isDeleted)continue;let[s,c,m,p]=eT(r[l],this.scene.getNonDeletedElementsMap());if(ha(r[l])&&Jl({point:oe(t,n),element:r[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[l])})){a=r[l];break}else if(s<t&&t<m&&c<n&&n<p){a=r[l];break}}return sT(a,!1)?a:null}handleHoverSelectedLinearElement(t,n,r){let i=this.scene.getNonDeletedElementsMap(),a=pe.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;Jl({point:oe(n,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=pe.getPointIndexUnderCursor(a,i,this.state.zoom,n,r),s=pe.getSegmentMidpointHitCoords(t,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),(At(a)?l===0||l===a.points.length-1:l>=0)||s?xe(this.interactiveCanvas,Ne.POINTER):this.hitElement(n,r,a)&&(!At(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&xe(this.interactiveCanvas,Ne.MOVE)):this.hitElement(n,r,a)&&(!At(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&xe(this.interactiveCanvas,Ne.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),pe.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else xe(this.interactiveCanvas,Ne.AUTO)}updateGestureOnPointerDown(t){fe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),fe.pointers.size===2&&(fe.lastCenter=Uh(fe.pointers),fe.initialScale=this.state.zoom.value,fe.initialDistance=Wh(Array.from(fe.pointers.values())))}initialPointerDownState(t){let n=Be(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,l,s]=ua(r),c=r.findIndex(At)===0;return{origin:n,withCmdOrCtrl:t[X.CTRL_OR_CMD],originInGrid:hf(pt(n.x,n.y,t[X.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:qh(ns,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...n},originalElements:this.scene.getNonDeletedElements().reduce((m,p)=>(m.set(p.id,iT(p)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(n,r)},drag:{hasOccurred:!1,offset:null,origin:{...n},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,n){if(!(n.scrollbars.isOverEither&&!this.state.multiElement))return!1;Df=!0,n.lastCoords.x=t.clientX,n.lastCoords.y=t.clientY;let r=Ad(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,n)}),i=Re(()=>{is=null,Df=!1,Nt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(re.POINTER_MOVE,r),window.removeEventListener(re.POINTER_UP,i),r.flush()});return is=i,window.addEventListener(re.POINTER_MOVE,r),window.addEventListener(re.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,n){if(n.length<2)return!1;let r=Math.max(Z5/this.state.zoom.value,1),[i,a,l,s]=ua(n);return t.x>i-r&&t.x<l+r&&t.y>a-r&&t.y<s+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:sH(t)?dm.ADAPTIVE_RADIUS:dm.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,n,r=!1){ln({event:t,app:this,selectedElements:n})&&(r||!jt.getReferenceSnapPoints())&&jt.setReferenceSnapPoints(Xw(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,n,r=!1){ln({event:t,app:this,selectedElements:n})&&(r||!jt.getVisibleGaps())&&jt.setVisibleGaps(Vw(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Re(n=>{this.maybeHandleResize(t,n)||this.maybeDragNewGenericElement(t,n)})}onKeyUpFromPointerDownHandler(t){return Re(n=>{n.key===X.ALT&&n.preventDefault(),!this.maybeHandleResize(t,n)&&this.maybeDragNewGenericElement(t,n)})}onPointerMoveFromPointerDownHandler(t){return Ad(n=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Be(n,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[d,h]=pt(r.x,r.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(f<0){let E=pe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:d,y:h},this.state,this.scene.getNonDeletedElementsMap());f=E?pe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,E,this.scene.getNonDeletedElementsMap()):-1}let b=pe.moveFixedSegment(this.state.selectedLinearElement,f,d,h,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,initialState:b.initialState}});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=hf(jH(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(n.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(n,t))return;if(wt(this.state)){this.handleEraser(n,r);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y);let[l,s]=pt(r.x,r.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,n)||this.maybeHandleResize(t,n)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement;if(pe.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let h=pe.addMidpoint(this.state.selectedLinearElement,r,this,!n[X.CTRL_OR_CMD],this.scene);if(!h)return;no(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:h.pointerDownState,selectedPointsIndices:h.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else{if(d.initialState.segmentMidpoint.value!==null&&!d.initialState.segmentMidpoint.added)return;if(d.initialState.lastClickedPoint>-1){let h=pe.getElement(d.elementId,c);if(h?.isDeleted)return;if(Xn(h)){let b=Eo(oe(r.x,r.y),this.scene.getNonDeletedElements(),c);dn("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(h,b)}if(n.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&dn("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),d.initialState.lastClickedPoint===-1)return;let f=pe.handlePointDragging(n,this,r.x,r.y,d);if(f){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(f.suggestedBinding!==this.state.suggestedBinding||!Q5(f.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||f.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||f.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==f.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==f.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(f);return}}}}let m=t.hit.allHitElements.some(d=>this.isASelectedElement(d)),p=this.state.selectedLinearElement?.isEditing&&n.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!p&&!t.drag.blockDragging){let d=this.scene.getSelectedElements(this.state);if(d.length>0&&d.every(E=>E.locked))return;let h=d.find(E=>Lt(E)),f=this.getTopLayerFrameAtSceneCoords(r),b=f&&!h?f:null;if(this.state.frameToHighlight!==b&&no(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&d.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),d.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let E={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},w=[...t.originalElements.values()],y=n.shiftKey;if(y){let I=Math.abs(E.x),C=Math.abs(E.y),P=y&&I<C,k=y&&I>C;P&&(E.x=0),k&&(E.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&_r(I)&&I.crop!==null&&t.hit.element===I){let C=I.crop,P=jl(I)&&this.imageCache.get(I.fileId)?.image;if(P&&!(P instanceof Promise)){let k=dz(O5(r.x-i.x,r.y-i.y),Math.max(this.state.zoom.value,2)),[N,_,L,B,G,j]=eT(I,c),H=df(cf(oe(N,_),oe(G,j),I.angle)),Y=df(cf(oe(L,_),oe(G,j),I.angle)),D=df(cf(oe(N,B),oe(G,j),I.angle)),O=G5(z5(Y,H)),Q=G5(z5(D,H)),ee=O5(H5(k,O),H5(k,Q)),K={...C,x:F5(C.x+ee[0]*Math.sign(I.scale[0]),0,P.naturalWidth-C.width),y:F5(C.y+ee[1]*Math.sign(I.scale[1]),0,P.naturalHeight-C.height)};this.scene.mutateElement(I,{crop:K});return}}}this.maybeCacheVisibleGaps(n,d),this.maybeCacheReferenceSnapPoints(n,d);let{snapOffset:x,snapLines:v}=Kw(w,E,this,n,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||$H(t,d,E,this.scene,x,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),n.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),C=t.hit.element,P=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});C&&t.hit.wasAddedToSelection&&!P.find(Y=>Y.id===C.id)&&P.push(C);let k=new Map(P.map(Y=>[Y.id,Y])),{duplicatedElements:N,duplicateElementsMap:_,elementsWithDuplicates:L,origIdToDuplicateId:B}=bf({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:Y,origElement:D})=>({frameId:Y.frameId??D.frameId,seed:zz()})});N.forEach(Y=>{t.originalElements.set(Y.id,iT(Y))});let G=L.map(Y=>{if(k.has(Y.id)){let D=t.originalElements.get(Y.id);if(D)return Vn(Y,{x:D.x,y:D.y})}return Y}),j=this.props.onDuplicate?.(G,I),H=wT(j||G,hm(N));no(()=>{if(t.hit.element){let Y=B.get(t.hit.element.id),D=Y&&_.get(Y);t.hit.element=D||null}t.hit.allHitElements=t.hit.allHitElements.reduce((Y,D)=>{let O=B.get(D.id),Q=O&&_.get(O);return Q&&Y.push(Q),Y},[]),t.drag.origin=Be(n,this.state),this.setState(Y=>({...VH(N,this.scene.getNonDeletedElements(),Y)})),this.scene.replaceAllElements(H),P.forEach(Y=>{xf(Y)&&Y.boundElements?.some(D=>D.type==="arrow")&&fm(Y,this.scene)}),this.maybeCacheVisibleGaps(n,P,!0),this.maybeCacheReferenceSnapPoints(n,P,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,n.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},n.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,n.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,n)}else if(this.state.activeTool.type==="lasso")!n.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,n.shiftKey);else{let d=this.state.newElement;if(!d)return;if(d.type==="freedraw"){let h=d.points,f=r.x-d.x,b=r.y-d.y,E=h.length>0&&h[h.length-1];if(!(E&&E[0]===f&&E[1]===b)){let y=d.simulatePressure?d.pressures:[...d.pressures,n.pressure];this.scene.mutateElement(d,{points:[...h,oe(f,b)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:d})}}else if(Et(d)&&!d.isDeleted){t.drag.hasOccurred=!0;let h=d.points;Wo(h.length>1,"Do not create linear elements with less than 2 points");let f=this.state.selectedLinearElement;f||(f=new pe(d,this.scene.getNonDeletedElementsMap()),f={...f,selectedPointsIndices:[1],initialState:{...f.initialState,lastClickedPoint:1}}),this.setState({newElement:d,...pe.handlePointDragging(n,this,l,s,f)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let d=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)pe.handleBoxSelection(n,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let h=!0;!n.shiftKey&&ve(d,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>ro({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):h=!1);let f=this.state.selectionElement?a1(d,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let E={...h&&b.selectedElementIds,...f.reduce((w,y)=>(w[y.id]=!0,w),{})};return t.hit.element&&(f.length?delete E[t.hit.element.id]:E[t.hit.element.id]=!0),b=h?b:{...b,selectedGroupIds:{},editingGroupId:null},{...ro({editingGroupId:b.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&Et(f[0])?new pe(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||mn(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,n){if(n.scrollbars.isOverHorizontal){let r=t.clientX,i=r-n.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(ns.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.x=r,!0}if(n.scrollbars.isOverVertical){let r=t.clientY,i=r-n.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(ns.vertical?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Re(n=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(n),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:i,resizingElement:a,croppingElementId:l,multiElement:s,activeTool:c,isResizing:m,isRotating:p,isCropping:d}=this.state;this.setState(y=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Zl(y.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),jt.setReferenceSnapPoints(null),jt.setVisibleGaps(null),this.savePointer(n.clientX,n.clientY,"up");let h=t.hit.allHitElements,f=Be({clientX:n.clientX,clientY:n.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!h.some(y=>this.state.selectedElementIds[y.id])){let y=this.getElementAtPosition(f.x,f.y,{includeLockedElements:!0});this.store.scheduleCapture(),y?.locked?this.setState({activeLockedId:y.groupIds.length>0?y.groupIds.at(-1)||"":y.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(dn("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let y=r.get(t.hit.element.id);xf(y)&&y.boundElements?.filter(x=>x.type==="arrow").map(x=>r.get(x.id)).filter(x=>At(x)).forEach(x=>{x&&this.scene.mutateElement(x,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(gt);else{let y=pe.handlePointerUp(n,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(gt,"ui",{event:n,sceneCoords:f}),y!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:y,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let y=pe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());y&&this.scene.mutateElement(y,{})}if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction(gt,"ui",{event:n,sceneCoords:f}),this.state.newElement&&this.state.multiElement&&Et(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:y}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:y.points[y.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(re.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(re.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(re.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(re.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,n),i?.type==="freedraw"){let y=Be(n,this.state),x=i.points,v=y.x-i.x,I=y.y-i.y;v===x[0][0]&&I===x[0][1]&&(I+=1e-4,v+=1e-4);let C=i.simulatePressure?[]:[...i.pressures,n.pressure];this.scene.mutateElement(i,{points:[...x,oe(v,I)],pressures:C}),this.actionManager.executeAction(gt);return}if(Et(i)){i.points.length>1&&i.points[1][0]!==0&&i.points[1][1]!==0&&this.store.scheduleCapture();let y=Be(n,this.state),x=Pr(oe(y.x,y.y),oe(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||x<Hz)&&i&&!s)if(this.editorInterface.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-v/2,points:[oe(0,0),oe(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(gt)}else{let v=y.x-i.x,I=y.y-i.y;this.scene.mutateElement(i,{points:[i.points[0],oe(v,I)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:i,newElement:i})}else t.drag.hasOccurred&&!s&&(Et(i)&&this.actionManager.executeAction(gt,"ui",{event:n,sceneCoords:f}),this.setState({suggestedBinding:null,startBoundElement:null}),c.locked?this.setState(v=>({newElement:null})):(Rt(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:Uo(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ye({...v.selectedElementIds,[i.id]:!0},v),selectedLinearElement:new pe(i,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(xo(i)){let y=OH(uf({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<y&&this.scene.mutateElement(i,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&dT(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(y=>y.id!==i.id),appState:{newElement:null},captureUpdate:xt.NEVER});return}if(Lt(i)){let y=yH(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Sf(this.scene.getElementsMapIncludingDeleted(),y,i,this.state))}if(i&&(this.scene.mutateElement(i,dH(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let y=Be(n,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let x=this.scene.getElement(this.state.selectedLinearElement.elementId);if(x?.frameId){let v=kf(x,r);v&&x&&(wH(x,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(x,{groupIds:[]}),xH([x],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let x=this.getTopLayerFrameAtSceneCoords(y),v=this.scene.getSelectedElements(this.state),I=this.scene.getElementsMapIncludingDeleted(),C=P=>{if(P.length>0){for(let k of P){let N=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,N)},{informMutation:!1,isDragging:!1})}I.forEach(k=>{k.groupIds.length&&Dr(I,k.groupIds[k.groupIds.length-1]).length<2&&this.scene.mutateElement(k,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(x&&!this.state.selectedElementIds[x.id]){let P=v.filter(k=>k.frameId!==x.id&&bT(k,I,this.state));this.state.editingGroupId&&C(P),I=Sf(I,P,x,this.state)}else if(!x&&this.state.editingGroupId){let P=v.filter(k=>k.frameId&&!bT(k,I,this.state));C(P)}I=fT(I,this.state,this),this.scene.replaceAllElements(I)}}if(a&&this.store.scheduleCapture(),a&&dT(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(y=>y.id!==a.id),captureUpdate:xt.NEVER}),t.resize.isResizing){let y=fT(this.scene.getElementsIncludingDeleted(),this.state,this),x=this.scene.getSelectedElements(this.state).filter(v=>Lt(v));for(let v of x)y=EH(y,Cf(this.scene.getElementsIncludingDeleted(),v,this.state,r),v,this);this.scene.replaceAllElements(y)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&Et(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new pe(b,this.scene.getNonDeletedElementsMap())}),(!l||l&&(!b&&!d||b&&b.id!==l))&&this.finishImageCropping();let E=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(wt(this.state)&&E&&w){if(this.eraserTrail.endPath(),Pr(oe(E.clientX,E.clientY),oe(w.clientX,w.clientY))===0){let x=Be({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(x.x,x.y).forEach(I=>this.elementsPendingErasure.add(I.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(n.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?WH(this.state,b)?this.setState(y=>{let x={...y.selectedElementIds};for(let v of b.groupIds.flatMap(I=>Dr(this.scene.getNonDeletedElements(),I)))delete x[v.id];return{selectedGroupIds:{...y.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,I)=>({...v,...I}),{})},selectedElementIds:ye(x,y)}}):this.state.selectedLinearElement?.isDragging||this.setState(y=>{let x={...y.selectedElementIds};delete x[b.id];let v=q(this.scene.getNonDeletedElements(),{selectedElementIds:x});return{...ro({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),selectedLinearElement:v.length===1&&Et(v[0])?new pe(v[0],this.scene.getNonDeletedElementsMap()):y.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(y=>{let x={...y.selectedElementIds,[b.id]:!0};return delete x[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>Dr(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete x[v.id]}),{...ro({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:b.link||mn(b)?"info":!1}}):this.setState(y=>({selectedElementIds:ye({...y.selectedElementIds,[b.id]:!0},y)})):this.setState(y=>({...ro({editingGroupId:y.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),y,this),selectedLinearElement:Et(b)&&y.selectedLinearElement?.elementId!==b.id?new pe(b,this.scene.getNonDeletedElementsMap()):y.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&At(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&CH({point:oe(t.origin.x,t.origin.y),element:b,elementsMap:r,threshold:this.getElementHitThreshold(b),frameNameBound:Lt(b)?this.frameNameBoundsCache.get(b):null},r)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Qi):this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),xe(this.interactiveCanvas,Ne.AUTO);return}if(!c.locked&&c.type!=="freedraw"&&i&&this.setState(y=>({selectedElementIds:ye({...y.selectedElementIds,[i.id]:!0},y),showHyperlinkPopup:mn(i)&&!i.link?"editor":y.showHyperlinkPopup})),(c.type!=="selection"||ve(this.scene.getNonDeletedElements(),this.state)||!Q5(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||m||p||d){let y=this.scene.getSelectedElements(this.state).filter(ha);tT(y,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}!c.locked&&c.type!=="freedraw"&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?(Rt(this.interactiveCanvas),this.setState({newElement:null,suggestedBinding:null,activeTool:Uo(this.state,{type:this.state.preferredSelectionTool.type})})):this.setState({newElement:null,suggestedBinding:null}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&fe.pointers.size<=1&&ql(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(n=>({selectedElementIds:ye({},n),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:n.editingGroupId&&t!=null&&yT(t,n.editingGroupId)?n.editingGroupId:null})),this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,n,r,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=If(i,r,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,n-l)<wz){let{x:p,y:d}=um({sceneX:a,sceneY:l},r);return{viewportX:p,viewportY:d,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:n,top:r}=t.getBoundingClientRect();return{offsetLeft:n,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Vr.find(n=>n.code===this.props.langCode)||vo;await ws(t),this.setAppState({})}},nG=()=>{(RT()||NT())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(FT(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};nG();var HT=Ff;import{useEffect as iG,useState as aG}from"react";import{jsx as lG}from"react/jsx-runtime";var GT=e=>{let[o,t]=aG(!0);return iG(()=>{let n=async()=>{await ws(r),t(!1)},r=Vr.find(i=>i.code===e.langCode)||vo;n()},[e.langCode]),o?lG(Bd,{theme:e.theme}):e.children};import sG from"clsx";import{jsx as UT}from"react/jsx-runtime";var WT=({children:e})=>{let{FooterCenterTunnel:o}=Ge(),t=Te();return UT(o.In,{children:UT("div",{className:sG("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},cG=WT;WT.displayName="FooterCenter";import dG from"clsx";import{MQ_MIN_WIDTH_DESKTOP as mG}from"@excalidraw/common";import{jsx as uG,jsxs as hG}from"react/jsx-runtime";var YT=({isCollaborating:e,onSelect:o,editorInterface:t,...n})=>{let r=Te(),i=t?.formFactor!=="desktop"||r.width<mG;return hG(Ot,{...n,className:dG("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:i?void 0:"auto"},title:g("labels.liveCollaboration"),children:[i?e0:g("labels.share"),r.collaborators.size>0&&uG("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},pG=YT;YT.displayName="LiveCollaborationTrigger";import{jsx as $n,jsxs as XT}from"react/jsx-runtime";var gG=()=>$n("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:$n("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"})}),fG=()=>XT("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[$n("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)"}),$n("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)"}),$n("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)"}),$n("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)"})]}),VT=({style:e,size:o="small",withText:t})=>XT("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[$n(gG,{}),t&&$n(fG,{})]});import{Fragment as $T,jsx as Ve,jsxs as Yf}from"react/jsx-runtime";var Vf=({icon:e,shortcut:o,children:t})=>{let n=de();return Yf($T,{children:[Ve("div",{className:"welcome-screen-menu-item__icon",children:e}),Ve("div",{className:"welcome-screen-menu-item__text",children:t}),o&&n.formFactor!=="phone"&&Ve("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};Vf.displayName="WelcomeScreenMenuItemContent";var as=({onSelect:e,children:o,icon:t,shortcut:n,className:r="",...i})=>Ve("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:Ve(Vf,{icon:t,shortcut:n,children:o})});as.displayName="WelcomeScreenMenuItem";var KT=({children:e,href:o,icon:t,shortcut:n,className:r="",...i})=>Ve("a",{...i,className:`welcome-screen-menu-item ${r}`,href:o,target:"_blank",rel:"noopener",children:Ve(Vf,{icon:t,shortcut:n,children:e})});KT.displayName="WelcomeScreenMenuItemLink";var io=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Ge();return Ve(o.In,{children:Ve("div",{className:"welcome-screen-center",children:e||Yf($T,{children:[Ve(Xf,{}),Ve(Kf,{children:g("welcomeScreen.defaults.center_heading")}),Yf(Zf,{children:[Ve(jf,{}),Ve($f,{})]})]})})})};io.displayName="Center";var Xf=({children:e})=>Ve("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ve(VT,{withText:!0})});Xf.displayName="Logo";var Kf=({children:e})=>Ve("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Kf.displayName="Heading";var Zf=({children:e})=>Ve("div",{className:"welcome-screen-menu",children:e});Zf.displayName="Menu";var $f=()=>{let e=at();return Ve(as,{onSelect:()=>e.executeAction(mr),shortcut:"?",icon:qr,children:g("helpDialog.title")})};$f.displayName="MenuItemHelp";var jf=()=>{let e=Te(),o=at();return e.viewModeEnabled?null:Ve(as,{onSelect:()=>o.executeAction(Ii),shortcut:Ae("loadScene"),icon:Jr,children:g("buttons.load")})};jf.displayName="MenuItemLoadScene";var ZT=({onSelect:e})=>{let{t:o}=Ue();return Ve(as,{shortcut:null,onSelect:e,icon:Ms,children:o("labels.liveCollaboration")})};ZT.displayName="MenuItemLiveCollaborationTrigger";io.Logo=Xf;io.Heading=Kf;io.Menu=Zf;io.MenuItem=as;io.MenuItemLink=KT;io.MenuItemHelp=$f;io.MenuItemLoadScene=jf;io.MenuItemLiveCollaborationTrigger=ZT;import{jsx as fa,jsxs as qf}from"react/jsx-runtime";var wm=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Ge();return fa(o.In,{children:qf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[B1,fa("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};wm.displayName="MenuHint";var vm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Ge();return fa(o.In,{children:qf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[fa("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),O1]})})};vm.displayName="ToolbarHint";var Im=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Ge();return fa(o.In,{children:qf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[fa("div",{children:e||g("welcomeScreen.defaults.helpHint")}),F1]})})};Im.displayName="HelpHint";import{Fragment as jT,jsx as ls,jsxs as EG}from"react/jsx-runtime";var Tm=e=>ls(jT,{children:e.children||EG(jT,{children:[ls(io,{}),ls(wm,{}),ls(vm,{}),ls(Im,{})]})});Tm.displayName="WelcomeScreen";Tm.Center=io;Tm.Hints={MenuHint:wm,ToolbarHint:vm,HelpHint:Im};var bG=Tm;var xG=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},qT=xG;import{getSceneVersion as U7e,hashElementsVersion as W7e,hashString as Y7e,getNonDeletedElements as V7e}from"@excalidraw/element";import{getTextFromElements as K7e}from"@excalidraw/element";import{isInvisiblySmallElement as $7e}from"@excalidraw/element";import yG from"lodash.throttle";import{arrayToMap as wG,isDevEnv as JT,isTestEnv as QT}from"@excalidraw/common";import{orderByFractionalIndex as vG,syncInvalidIndices as eS,validateFractionalIndices as IG}from"@excalidraw/element";var TG=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<=t.versionNonce)),SG=yG((e,o,t)=>{if(JT()||QT()||window?.DEBUG_FRACTIONAL_INDICES){let n=eS(e.map(r=>({...r})));IG(n,{shouldThrow:QT()||JT(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),CG=(e,o,t)=>{let n=wG(e),r=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=n.get(l.id),c=TG(t,s,l);s&&c?(r.push(s),i.add(s.id)):(r.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(r.push(l),i.add(l.id));let a=vG(r);return SG(a,e,o),eS(a),a};import{isLinearElement as r8e}from"@excalidraw/element";import{FONT_FAMILY as a8e,THEME as l8e,MIME_TYPES as s8e,ROUNDNESS as Oc,DEFAULT_LASER_COLOR as c8e,UserIdleState as d8e,normalizeLink as m8e,sceneCoordsToViewportCoords as gy,viewportCoordsToSceneCoords as p8e,getFormFactor as u8e}from"@excalidraw/common";import{mutateElement as Hc,newElementWith as g8e,bumpVersion as Ri}from"@excalidraw/element";import{CaptureUpdateAction as bv}from"@excalidraw/element";import{getCommonBounds as C8e,getVisibleSceneBounds as k8e,convertToExcalidrawElements as M8e}from"@excalidraw/element";import{useLayoutEffect as kG}from"react";var MG=e=>{let o=qe();return kG(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as D8e}from"@excalidraw/element";import{setCustomTextMetricsProvider as N8e}from"@excalidraw/element";import{jsx as Jf}from"react/jsx-runtime";qT();var _G=e=>{let{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i=!1,onPointerUpdate:a,renderTopLeftUI:l,renderTopRightUI:s,langCode:c=vo.code,viewModeEnabled:m,zenModeEnabled:p,gridModeEnabled:d,libraryReturnUrl:h,theme:f,name:b,renderCustomStats:E,onPaste:w,detectScroll:y=!0,handleKeyboardGlobally:x=!1,onLibraryChange:v,autoFocus:I=!1,generateIdForFile:C,onLinkOpen:P,generateLinkForSelection:k,onPointerDown:N,onPointerUp:_,onScrollChange:L,onDuplicate:B,children:G,validateEmbeddable:j,renderEmbeddable:H,showDeprecatedFonts:Y,wheelZoomsOnDefault:D,strokeColorTopPicks:O,backgroundColorTopPicks:Q,renderScrollbars:ee}=e,K=e.UIOptions?.canvasActions,ae={...e.UIOptions,canvasActions:{...tS.canvasActions,...K},tools:{image:e.UIOptions?.tools?.image??!0}};return K?.export&&(ae.canvasActions.export.saveFileToDisk=K.export?.saveFileToDisk??tS.canvasActions.export.saveFileToDisk),ae.canvasActions.toggleTheme===null&&typeof f>"u"&&(ae.canvasActions.toggleTheme=!0),LG(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ce=Oe=>{typeof Oe.scale=="number"&&Oe.scale!==1&&Oe.preventDefault()};return document.addEventListener("touchmove",ce,{passive:!1}),()=>{document.removeEventListener("touchmove",ce)}},[]),Jf(k1,{store:$e,children:Jf(GT,{langCode:c,theme:f,children:Jf(HT,{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i,onPointerUpdate:a,renderTopLeftUI:l,renderTopRightUI:s,langCode:c,viewModeEnabled:m,zenModeEnabled:p,gridModeEnabled:d,libraryReturnUrl:h,theme:f,name:b,renderCustomStats:E,UIOptions:ae,onPaste:w,detectScroll:y,handleKeyboardGlobally:x,onLibraryChange:v,autoFocus:I,generateIdForFile:C,onLinkOpen:P,generateLinkForSelection:k,onPointerDown:N,onPointerUp:_,onScrollChange:L,onDuplicate:B,validateEmbeddable:j,renderEmbeddable:H,showDeprecatedFonts:Y,wheelZoomsOnDefault:D,strokeColorTopPicks:O,backgroundColorTopPicks:Q,renderScrollbars:ee,children:G})})})},DG=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:n={},...r}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(n),c=Object.keys(a);return s.length!==c.length?!1:s.every(p=>p==="getFormFactor"?!0:p==="canvasActions"?Object.keys(n.canvasActions).every(h=>h==="export"&&n?.canvasActions?.export&&a?.canvasActions?.export?n.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:n?.canvasActions?.[h]===a?.canvasActions?.[h]):n[p]===a[p])&&AG(r,l)},RG=PG.memo(_G,DG);RG.displayName="Excalidraw";export{Ot as Button,bv as CaptureUpdateAction,c8e as DEFAULT_LASER_COLOR,$d as DefaultSidebar,MG as DiagramToCodePlugin,Ga as Ellipsify,RG as Excalidraw,a8e as FONT_FAMILY,cG as Footer,pG as LiveCollaborationTrigger,s8e as MIME_TYPES,bt as MainMenu,Oc as ROUNDNESS,eo as Sidebar,Ol as Stats,l8e as THEME,d8e as UserIdleState,bG as WelcomeScreen,Ri as bumpVersion,M8e as convertToExcalidrawElements,vo as defaultLang,lw as elementPartiallyOverlapsWithOrContainsBBox,sw as elementsOverlappingBBox,yy as exportToBlob,Oi as exportToCanvas,mA as exportToClipboard,zi as exportToSvg,C8e as getCommonBounds,_m as getDataURL,u8e as getFormFactor,Vc as getLibraryItemsHash,V7e as getNonDeletedElements,U7e as getSceneVersion,K7e as getTextFromElements,k8e as getVisibleSceneBounds,W7e as hashElementsVersion,Y7e as hashString,Ah as isElementInsideBBox,D8e as isElementLink,$7e as isInvisiblySmallElement,r8e as isLinearElement,Vr as languages,fs as loadFromBlob,Am as loadLibraryFromBlob,Lm as loadSceneOrLibraryFromBlob,Py as mergeLibraryItems,Hc as mutateElement,g8e as newElementWith,m8e as normalizeLink,Ju as parseLibraryTokensFromUrl,CG as reconcileElements,Ur as restoreAppState,aS as restoreElement,qn as restoreElements,Ia as restoreLibraryItems,gy as sceneCoordsToViewportCoords,wa as serializeAsJSON,iS as serializeLibraryAsJSON,N8e as setCustomTextMetricsProvider,de as useEditorInterface,kA as useHandleLibrary,Ue as useI18n,je as useStylesPanelMode,p8e as viewportCoordsToSceneCoords,SE as zoomToFitBounds};
|
|
112
|
+
`),n)}}addTextFromPaste(t,n=!1){let{x:r,y:i}=Be({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:kz,verticalAlign:G5,locked:!1},l=sf({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=V5(a.fontFamily),[c,,m]=MH(this.state),p=Math.max(Math.min((m-c)*.5,800),200),d=10,h=i,f=n?[t]:t.split(`
|
|
113
|
+
`),b=f.reduce((E,w,y)=>{let x=NH(w).trim();if(x.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:h}),I=gT(x,l,s),C=I.width>p,P=C?_H(x,l,p):x;I=C?gT(P,l,s):I;let k=r-I.width/2,N=h-I.height/2,_=eT({...a,x:k,y:N,text:P,originalText:x,lineHeight:s,autoResize:!C,frameId:v?v.id:null});E.push(_),h+=_.height+d}else f[y-1]?.trim()&&(h+=BH(a.fontSize,s)+d);return E},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:ye(Object.fromEntries(b.map(E=>[E.id,!0])),this.state)}),!n&&b.length>1&&PT===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:A("CtrlOrCmd+Shift+V")}),duration:5e3}),PT=!0))}handleTextWysiwyg(t,{isExistingElement:n=!1}){let r=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&Eo(s)?Wn(s,{originalText:a,isDeleted:l??s.isDeleted,...aH(s,dT(s,r),r,a)}):s)])};iv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:c}=cm({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:Re(a=>{i(a,!1),vT(t)&&pm(t,this.scene)}),onSubmit:Re(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let c=t.containerId?t.containerId:t.id;oo(()=>{this.setState(m=>({selectedElementIds:ye({...m.selectedElementIds,[c]:!0},m)}))})}s&&qz(this.scene.getNonDeletedElements(),[t]),(!s||n)&&this.store.scheduleCapture(),oo(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Nt(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,n){let r=this.getElementAtPosition(t,n,{includeBoundTextElement:!0});return r&&Eo(r)&&!r.isDeleted?r:null}getElementAtPosition(t,n,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,n,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return Yl({point:oe(t,n),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Lt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,n,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(r?.includeLockedElements||!s.locked)&&(r?.includeBoundTextElement||!(Eo(s)&&s.containerId)))).filter(s=>this.hitElement(t,n,s)).filter(s=>{let c=vf(s,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?mT({x:t,y:n},c,a):!0}).filter(s=>la(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(Y5/this.state.zoom.value))}hitElement(t,n,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&EH([r],this.state,this.editorInterface)&&QH(oe(t,n),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||CH(oe(t,n),r,this.scene.getNonDeletedElementsMap())?!0:Yl({point:oe(t,n),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Lt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,n){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return rT(i[0],!1)?i[0]:null;let a=null;for(let l=r.length-1;l>=0;--l){if(r[l].isDeleted)continue;let[s,c,m,p]=j5(r[l],this.scene.getNonDeletedElementsMap());if(aa(r[l])&&Yl({point:oe(t,n),element:r[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[l])})){a=r[l];break}else if(s<t&&t<m&&c<n&&n<p){a=r[l];break}}return rT(a,!1)?a:null}handleHoverSelectedLinearElement(t,n,r){let i=this.scene.getNonDeletedElementsMap(),a=pe.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;Yl({point:oe(n,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=pe.getPointIndexUnderCursor(a,i,this.state.zoom,n,r),s=pe.getSegmentMidpointHitCoords(t,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),(At(a)?l===0||l===a.points.length-1:l>=0)||s?xe(this.interactiveCanvas,Ne.POINTER):this.hitElement(n,r,a)&&(!At(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&xe(this.interactiveCanvas,Ne.MOVE)):this.hitElement(n,r,a)&&(!At(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&xe(this.interactiveCanvas,Ne.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),pe.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else xe(this.interactiveCanvas,Ne.AUTO)}updateGestureOnPointerDown(t){fe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),fe.pointers.size===2&&(fe.lastCenter=Fh(fe.pointers),fe.initialScale=this.state.zoom.value,fe.initialDistance=Oh(Array.from(fe.pointers.values())))}initialPointerDownState(t){let n=Be(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,l,s]=ia(r),c=r.findIndex(At)===0;return{origin:n,withCmdOrCtrl:t[X.CTRL_OR_CMD],originInGrid:cf(pt(n.x,n.y,t[X.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:Xh($l,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...n},originalElements:this.scene.getNonDeletedElements().reduce((m,p)=>(m.set(p.id,tT(p)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(n,r)},drag:{hasOccurred:!1,offset:null,origin:{...n},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,n){if(!(n.scrollbars.isOverEither&&!this.state.multiElement))return!1;Mf=!0,n.lastCoords.x=t.clientX,n.lastCoords.y=t.clientY;let r=kd(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,n)}),i=Re(()=>{ql=null,Mf=!1,Nt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(re.POINTER_MOVE,r),window.removeEventListener(re.POINTER_UP,i),r.flush()});return ql=i,window.addEventListener(re.POINTER_MOVE,r),window.addEventListener(re.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,n){if(n.length<2)return!1;let r=Math.max(Y5/this.state.zoom.value,1),[i,a,l,s]=ia(n);return t.x>i-r&&t.x<l+r&&t.y>a-r&&t.y<s+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:cH(t)?am.ADAPTIVE_RADIUS:am.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,n,r=!1){on({event:t,app:this,selectedElements:n})&&(r||!$t.getReferenceSnapPoints())&&$t.setReferenceSnapPoints(Uw(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,n,r=!1){on({event:t,app:this,selectedElements:n})&&(r||!$t.getVisibleGaps())&&$t.setVisibleGaps(Gw(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Re(n=>{this.maybeHandleResize(t,n)||this.maybeDragNewGenericElement(t,n)})}onKeyUpFromPointerDownHandler(t){return Re(n=>{n.key===X.ALT&&n.preventDefault(),!this.maybeHandleResize(t,n)&&this.maybeDragNewGenericElement(t,n)})}onPointerMoveFromPointerDownHandler(t){return kd(n=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Be(n,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[d,h]=pt(r.x,r.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(f<0){let E=pe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:d,y:h},this.state,this.scene.getNonDeletedElementsMap());f=E?pe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,E,this.scene.getNonDeletedElementsMap()):-1}let b=pe.moveFixedSegment(this.state.selectedLinearElement,f,d,h,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,initialState:b.initialState}});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=cf(qH(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(n.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(n,t))return;if(wt(this.state)){this.handleEraser(n,r);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y);let[l,s]=pt(r.x,r.y,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,n)||this.maybeHandleResize(t,n)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let d=this.state.selectedLinearElement;if(pe.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let h=pe.addMidpoint(this.state.selectedLinearElement,r,this,!n[X.CTRL_OR_CMD],this.scene);if(!h)return;oo(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:h.pointerDownState,selectedPointsIndices:h.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else{if(d.initialState.segmentMidpoint.value!==null&&!d.initialState.segmentMidpoint.added)return;if(d.initialState.lastClickedPoint>-1){let h=pe.getElement(d.elementId,c);if(h?.isDeleted)return;if(Yn(h)){let b=bo(oe(r.x,r.y),this.scene.getNonDeletedElements(),c);an("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(h,b)}if(n.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&an("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),d.initialState.lastClickedPoint===-1)return;let f=pe.handlePointDragging(n,this,r.x,r.y,d);if(f){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(f.suggestedBinding!==this.state.suggestedBinding||!$5(f.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||f.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||f.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==f.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==f.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(f);return}}}}let m=t.hit.allHitElements.some(d=>this.isASelectedElement(d)),p=this.state.selectedLinearElement?.isEditing&&n.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!p&&!t.drag.blockDragging){let d=this.scene.getSelectedElements(this.state);if(d.length>0&&d.every(E=>E.locked))return;let h=d.find(E=>Lt(E)),f=this.getTopLayerFrameAtSceneCoords(r),b=f&&!h?f:null;if(this.state.frameToHighlight!==b&&oo(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&d.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),d.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let E={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},w=[...t.originalElements.values()],y=n.shiftKey;if(y){let I=Math.abs(E.x),C=Math.abs(E.y),P=y&&I<C,k=y&&I>C;P&&(E.x=0),k&&(E.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&Pr(I)&&I.crop!==null&&t.hit.element===I){let C=I.crop,P=Ul(I)&&this.imageCache.get(I.fileId)?.image;if(P&&!(P instanceof Promise)){let k=mz(R5(r.x-i.x,r.y-i.y),Math.max(this.state.zoom.value,2)),[N,_,L,B,G,j]=j5(I,c),H=rf(nf(oe(N,_),oe(G,j),I.angle)),Y=rf(nf(oe(L,_),oe(G,j),I.angle)),D=rf(nf(oe(N,B),oe(G,j),I.angle)),O=F5(N5(Y,H)),Q=F5(N5(D,H)),ee=R5(B5(k,O),B5(k,Q)),K={...C,x:D5(C.x+ee[0]*Math.sign(I.scale[0]),0,P.naturalWidth-C.width),y:D5(C.y+ee[1]*Math.sign(I.scale[1]),0,P.naturalHeight-C.height)};this.scene.mutateElement(I,{crop:K});return}}}this.maybeCacheVisibleGaps(n,d),this.maybeCacheReferenceSnapPoints(n,d);let{snapOffset:x,snapLines:v}=Ww(w,E,this,n,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||jH(t,d,E,this.scene,x,n[X.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),n.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),C=t.hit.element,P=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});C&&t.hit.wasAddedToSelection&&!P.find(Y=>Y.id===C.id)&&P.push(C);let k=new Map(P.map(Y=>[Y.id,Y])),{duplicatedElements:N,duplicateElementsMap:_,elementsWithDuplicates:L,origIdToDuplicateId:B}=pf({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:Y,origElement:D})=>({frameId:Y.frameId??D.frameId,seed:Hz()})});N.forEach(Y=>{t.originalElements.set(Y.id,tT(Y))});let G=L.map(Y=>{if(k.has(Y.id)){let D=t.originalElements.get(Y.id);if(D)return Wn(Y,{x:D.x,y:D.y})}return Y}),j=this.props.onDuplicate?.(G,I),H=bT(j||G,dm(N));oo(()=>{if(t.hit.element){let Y=B.get(t.hit.element.id),D=Y&&_.get(Y);t.hit.element=D||null}t.hit.allHitElements=t.hit.allHitElements.reduce((Y,D)=>{let O=B.get(D.id),Q=O&&_.get(O);return Q&&Y.push(Q),Y},[]),t.drag.origin=Be(n,this.state),this.setState(Y=>({...XH(N,this.scene.getNonDeletedElements(),Y)})),this.scene.replaceAllElements(H),P.forEach(Y=>{hf(Y)&&Y.boundElements?.some(D=>D.type==="arrow")&&pm(Y,this.scene)}),this.maybeCacheVisibleGaps(n,P,!0),this.maybeCacheReferenceSnapPoints(n,P,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,n.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},n.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,n.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,n)}else if(this.state.activeTool.type==="lasso")!n.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,n.shiftKey);else{let d=this.state.newElement;if(!d)return;if(d.type==="freedraw"){let h=d.points,f=r.x-d.x,b=r.y-d.y,E=h.length>0&&h[h.length-1];if(!(E&&E[0]===f&&E[1]===b)){let y=d.simulatePressure?d.pressures:[...d.pressures,n.pressure];this.scene.mutateElement(d,{points:[...h,oe(f,b)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:d})}}else if(Et(d)&&!d.isDeleted){t.drag.hasOccurred=!0;let h=d.points;zo(h.length>1,"Do not create linear elements with less than 2 points");let f=this.state.selectedLinearElement;f||(f=new pe(d,this.scene.getNonDeletedElementsMap()),f={...f,selectedPointsIndices:[1],initialState:{...f.initialState,lastClickedPoint:1}}),this.setState({newElement:d,...pe.handlePointDragging(n,this,l,s,f)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let d=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)pe.handleBoxSelection(n,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let h=!0;!n.shiftKey&&ve(d,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>no({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):h=!1);let f=this.state.selectionElement?t1(d,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let E={...h&&b.selectedElementIds,...f.reduce((w,y)=>(w[y.id]=!0,w),{})};return t.hit.element&&(f.length?delete E[t.hit.element.id]:E[t.hit.element.id]=!0),b=h?b:{...b,selectedGroupIds:{},editingGroupId:null},{...no({editingGroupId:b.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&Et(f[0])?new pe(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||ln(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,n){if(n.scrollbars.isOverHorizontal){let r=t.clientX,i=r-n.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*($l.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.x=r,!0}if(n.scrollbars.isOverVertical){let r=t.clientY,i=r-n.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*($l.vertical?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Re(n=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(n),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:i,resizingElement:a,croppingElementId:l,multiElement:s,activeTool:c,isResizing:m,isRotating:p,isCropping:d}=this.state;this.setState(y=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Hl(y.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),$t.setReferenceSnapPoints(null),$t.setVisibleGaps(null),this.savePointer(n.clientX,n.clientY,"up");let h=t.hit.allHitElements,f=Be({clientX:n.clientX,clientY:n.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!h.some(y=>this.state.selectedElementIds[y.id])){let y=this.getElementAtPosition(f.x,f.y,{includeLockedElements:!0});this.store.scheduleCapture(),y?.locked?this.setState({activeLockedId:y.groupIds.length>0?y.groupIds.at(-1)||"":y.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(an("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let y=r.get(t.hit.element.id);hf(y)&&y.boundElements?.filter(x=>x.type==="arrow").map(x=>r.get(x.id)).filter(x=>At(x)).forEach(x=>{x&&this.scene.mutateElement(x,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(gt);else{let y=pe.handlePointerUp(n,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(gt,"ui",{event:n,sceneCoords:f}),y!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:y,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let y=pe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());y&&this.scene.mutateElement(y,{})}if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction(gt,"ui",{event:n,sceneCoords:f}),this.state.newElement&&this.state.multiElement&&Et(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:y}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:y.points[y.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(re.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(re.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(re.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(re.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,n),i?.type==="freedraw"){let y=Be(n,this.state),x=i.points,v=y.x-i.x,I=y.y-i.y;v===x[0][0]&&I===x[0][1]&&(I+=1e-4,v+=1e-4);let C=i.simulatePressure?[]:[...i.pressures,n.pressure];this.scene.mutateElement(i,{points:[...x,oe(v,I)],pressures:C}),this.actionManager.executeAction(gt);return}if(Et(i)){i.points.length>1&&i.points[1][0]!==0&&i.points[1][1]!==0&&this.store.scheduleCapture();let y=Be(n,this.state),x=Cr(oe(y.x,y.y),oe(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||x<Gz)&&i&&!s)if(this.editorInterface.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-v/2,points:[oe(0,0),oe(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(gt)}else{let v=y.x-i.x,I=y.y-i.y;this.scene.mutateElement(i,{points:[i.points[0],oe(v,I)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:i,newElement:i})}else t.drag.hasOccurred&&!s&&(Et(i)&&this.actionManager.executeAction(gt,"ui",{event:n,sceneCoords:f}),this.setState({suggestedBinding:null,startBoundElement:null}),c.locked?this.setState(v=>({newElement:null})):(Rt(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:Oo(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:ye({...v.selectedElementIds,[i.id]:!0},v),selectedLinearElement:new pe(i,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(Eo(i)){let y=zH(sf({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<y&&this.scene.mutateElement(i,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&aT(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(y=>y.id!==i.id),appState:{newElement:null},captureUpdate:xt.NEVER});return}if(Lt(i)){let y=wH(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(yf(this.scene.getElementsMapIncludingDeleted(),y,i,this.state))}if(i&&(this.scene.mutateElement(i,mH(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let y=Be(n,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let x=this.scene.getElement(this.state.selectedLinearElement.elementId);if(x?.frameId){let v=vf(x,r);v&&x&&(vH(x,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(x,{groupIds:[]}),yH([x],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let x=this.getTopLayerFrameAtSceneCoords(y),v=this.scene.getSelectedElements(this.state),I=this.scene.getElementsMapIncludingDeleted(),C=P=>{if(P.length>0){for(let k of P){let N=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,N)},{informMutation:!1,isDragging:!1})}I.forEach(k=>{k.groupIds.length&&Lr(I,k.groupIds[k.groupIds.length-1]).length<2&&this.scene.mutateElement(k,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(x&&!this.state.selectedElementIds[x.id]){let P=v.filter(k=>k.frameId!==x.id&&uT(k,I,this.state));this.state.editingGroupId&&C(P),I=yf(I,P,x,this.state)}else if(!x&&this.state.editingGroupId){let P=v.filter(k=>k.frameId&&!uT(k,I,this.state));C(P)}I=pT(I,this.state,this),this.scene.replaceAllElements(I)}}if(a&&this.store.scheduleCapture(),a&&aT(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(y=>y.id!==a.id),captureUpdate:xt.NEVER}),t.resize.isResizing){let y=pT(this.scene.getElementsIncludingDeleted(),this.state,this),x=this.scene.getSelectedElements(this.state).filter(v=>Lt(v));for(let v of x)y=xH(y,wf(this.scene.getElementsIncludingDeleted(),v,this.state,r),v,this);this.scene.replaceAllElements(y)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&Et(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new pe(b,this.scene.getNonDeletedElementsMap())}),(!l||l&&(!b&&!d||b&&b.id!==l))&&this.finishImageCropping();let E=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(wt(this.state)&&E&&w){if(this.eraserTrail.endPath(),Cr(oe(E.clientX,E.clientY),oe(w.clientX,w.clientY))===0){let x=Be({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(x.x,x.y).forEach(I=>this.elementsPendingErasure.add(I.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(n.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?YH(this.state,b)?this.setState(y=>{let x={...y.selectedElementIds};for(let v of b.groupIds.flatMap(I=>Lr(this.scene.getNonDeletedElements(),I)))delete x[v.id];return{selectedGroupIds:{...y.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,I)=>({...v,...I}),{})},selectedElementIds:ye(x,y)}}):this.state.selectedLinearElement?.isDragging||this.setState(y=>{let x={...y.selectedElementIds};delete x[b.id];let v=q(this.scene.getNonDeletedElements(),{selectedElementIds:x});return{...no({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),selectedLinearElement:v.length===1&&Et(v[0])?new pe(v[0],this.scene.getNonDeletedElementsMap()):y.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(y=>{let x={...y.selectedElementIds,[b.id]:!0};return delete x[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>Lr(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete x[v.id]}),{...no({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:b.link||ln(b)?"info":!1}}):this.setState(y=>({selectedElementIds:ye({...y.selectedElementIds,[b.id]:!0},y)})):this.setState(y=>({...no({editingGroupId:y.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),y,this),selectedLinearElement:Et(b)&&y.selectedLinearElement?.elementId!==b.id?new pe(b,this.scene.getNonDeletedElementsMap()):y.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&At(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&kH({point:oe(t.origin.x,t.origin.y),element:b,elementsMap:r,threshold:this.getElementHitThreshold(b),frameNameBound:Lt(b)?this.frameNameBoundsCache.get(b):null},r)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Vi):this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),xe(this.interactiveCanvas,Ne.AUTO);return}if(!c.locked&&c.type!=="freedraw"&&i&&this.setState(y=>({selectedElementIds:ye({...y.selectedElementIds,[i.id]:!0},y),showHyperlinkPopup:ln(i)&&!i.link?"editor":y.showHyperlinkPopup})),(c.type!=="selection"||ve(this.scene.getNonDeletedElements(),this.state)||!$5(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||m||p||d){let y=this.scene.getSelectedElements(this.state).filter(aa);q5(y,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}!c.locked&&c.type!=="freedraw"&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?(Rt(this.interactiveCanvas),this.setState({newElement:null,suggestedBinding:null,activeTool:Oo(this.state,{type:this.state.preferredSelectionTool.type})})):this.setState({newElement:null,suggestedBinding:null}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&fe.pointers.size<=1&&Wl(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(n=>({selectedElementIds:ye({},n),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:n.editingGroupId&&t!=null&&fT(t,n.editingGroupId)?n.editingGroupId:null})),this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,n,r,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Ef(i,r,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,n-l)<vz){let{x:p,y:d}=cm({sceneX:a,sceneY:l},r);return{viewportX:p,viewportY:d,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:n,top:r}=t.getBoundingClientRect();return{offsetLeft:n,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Ur.find(n=>n.code===this.props.langCode)||wo;await us(t),this.setAppState({})}},iG=()=>{(LT()||AT())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(DT(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};iG();var BT=_f;import{useEffect as lG,useState as sG}from"react";import{jsx as cG}from"react/jsx-runtime";var FT=e=>{let[o,t]=sG(!0);return lG(()=>{let n=async()=>{await us(r),t(!1)},r=Ur.find(i=>i.code===e.langCode)||wo;n()},[e.langCode]),o?cG(_d,{theme:e.theme}):e.children};import dG from"clsx";import{jsx as OT}from"react/jsx-runtime";var zT=({children:e})=>{let{FooterCenterTunnel:o}=Ge(),t=Te();return OT(o.In,{children:OT("div",{className:dG("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},mG=zT;zT.displayName="FooterCenter";import pG from"clsx";import{MQ_MIN_WIDTH_DESKTOP as uG}from"@excalidraw/common";import{jsx as gG,jsxs as fG}from"react/jsx-runtime";var HT=({isCollaborating:e,onSelect:o,editorInterface:t,...n})=>{let r=Te(),i=t?.formFactor!=="desktop"||r.width<uG;return fG(Ot,{...n,className:pG("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:i?void 0:"auto"},title:g("labels.liveCollaboration"),children:[i?q1:g("labels.share"),r.collaborators.size>0&&gG("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},hG=HT;HT.displayName="LiveCollaborationTrigger";import{jsx as Kn,jsxs as UT}from"react/jsx-runtime";var bG=()=>Kn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Kn("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"})}),EG=()=>UT("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Kn("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)"}),Kn("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)"}),Kn("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)"}),Kn("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)"})]}),GT=({style:e,size:o="small",withText:t})=>UT("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Kn(bG,{}),t&&Kn(EG,{})]});import{Fragment as VT,jsx as Ve,jsxs as zf}from"react/jsx-runtime";var Hf=({icon:e,shortcut:o,children:t})=>{let n=de();return zf(VT,{children:[Ve("div",{className:"welcome-screen-menu-item__icon",children:e}),Ve("div",{className:"welcome-screen-menu-item__text",children:t}),o&&n.formFactor!=="phone"&&Ve("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};Hf.displayName="WelcomeScreenMenuItemContent";var Jl=({onSelect:e,children:o,icon:t,shortcut:n,className:r="",...i})=>Ve("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:Ve(Hf,{icon:t,shortcut:n,children:o})});Jl.displayName="WelcomeScreenMenuItem";var WT=({children:e,href:o,icon:t,shortcut:n,className:r="",...i})=>Ve("a",{...i,className:`welcome-screen-menu-item ${r}`,href:o,target:"_blank",rel:"noopener",children:Ve(Hf,{icon:t,shortcut:n,children:e})});WT.displayName="WelcomeScreenMenuItemLink";var ro=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Ge();return Ve(o.In,{children:Ve("div",{className:"welcome-screen-center",children:e||zf(VT,{children:[Ve(Gf,{}),Ve(Uf,{children:g("welcomeScreen.defaults.center_heading")}),zf(Wf,{children:[Ve(Vf,{}),Ve(Yf,{})]})]})})})};ro.displayName="Center";var Gf=({children:e})=>Ve("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ve(GT,{withText:!0})});Gf.displayName="Logo";var Uf=({children:e})=>Ve("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Uf.displayName="Heading";var Wf=({children:e})=>Ve("div",{className:"welcome-screen-menu",children:e});Wf.displayName="Menu";var Yf=()=>{let e=at();return Ve(Jl,{onSelect:()=>e.executeAction(sr),shortcut:"?",icon:Wr,children:g("helpDialog.title")})};Yf.displayName="MenuItemHelp";var Vf=()=>{let e=Te(),o=at();return e.viewModeEnabled?null:Ve(Jl,{onSelect:()=>o.executeAction(gi),shortcut:Ae("loadScene"),icon:Yr,children:g("buttons.load")})};Vf.displayName="MenuItemLoadScene";var YT=({onSelect:e})=>{let{t:o}=Ue();return Ve(Jl,{shortcut:null,onSelect:e,icon:Ts,children:o("labels.liveCollaboration")})};YT.displayName="MenuItemLiveCollaborationTrigger";ro.Logo=Gf;ro.Heading=Uf;ro.Menu=Wf;ro.MenuItem=Jl;ro.MenuItemLink=WT;ro.MenuItemHelp=Yf;ro.MenuItemLoadScene=Vf;ro.MenuItemLiveCollaborationTrigger=YT;import{jsx as sa,jsxs as Xf}from"react/jsx-runtime";var bm=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Ge();return sa(o.In,{children:Xf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[A1,sa("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};bm.displayName="MenuHint";var Em=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Ge();return sa(o.In,{children:Xf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[sa("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),D1]})})};Em.displayName="ToolbarHint";var xm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Ge();return sa(o.In,{children:Xf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[sa("div",{children:e||g("welcomeScreen.defaults.helpHint")}),_1]})})};xm.displayName="HelpHint";import{Fragment as XT,jsx as Ql,jsxs as yG}from"react/jsx-runtime";var ym=e=>Ql(XT,{children:e.children||yG(XT,{children:[Ql(ro,{}),Ql(bm,{}),Ql(Em,{}),Ql(xm,{})]})});ym.displayName="WelcomeScreen";ym.Center=ro;ym.Hints={MenuHint:bm,ToolbarHint:Em,HelpHint:xm};var xG=ym;var wG=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},KT=wG;import{getSceneVersion as H7e,hashElementsVersion as G7e,hashString as U7e,getNonDeletedElements as W7e}from"@excalidraw/element";import{getTextFromElements as V7e}from"@excalidraw/element";import{isInvisiblySmallElement as K7e}from"@excalidraw/element";import vG from"lodash.throttle";import{arrayToMap as IG,isDevEnv as ZT,isTestEnv as $T}from"@excalidraw/common";import{orderByFractionalIndex as TG,syncInvalidIndices as jT,validateFractionalIndices as SG}from"@excalidraw/element";var CG=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<=t.versionNonce)),kG=vG((e,o,t)=>{if(ZT()||$T()||window?.DEBUG_FRACTIONAL_INDICES){let n=jT(e.map(r=>({...r})));SG(n,{shouldThrow:$T()||ZT(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),MG=(e,o,t)=>{let n=IG(e),r=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=n.get(l.id),c=CG(t,s,l);s&&c?(r.push(s),i.add(s.id)):(r.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(r.push(l),i.add(l.id));let a=TG(r);return kG(a,e,o),jT(a),a};import{isLinearElement as o8e}from"@excalidraw/element";import{FONT_FAMILY as r8e,THEME as i8e,MIME_TYPES as a8e,ROUNDNESS as Rc,DEFAULT_LASER_COLOR as l8e,UserIdleState as s8e,normalizeLink as c8e,sceneCoordsToViewportCoords as py,viewportCoordsToSceneCoords as d8e,getFormFactor as m8e}from"@excalidraw/common";import{mutateElement as Bc,newElementWith as u8e,bumpVersion as Ci}from"@excalidraw/element";import{CaptureUpdateAction as uv}from"@excalidraw/element";import{getCommonBounds as T8e,getVisibleSceneBounds as S8e,convertToExcalidrawElements as C8e}from"@excalidraw/element";import{useLayoutEffect as PG}from"react";var LG=e=>{let o=qe();return PG(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as A8e}from"@excalidraw/element";import{setCustomTextMetricsProvider as D8e}from"@excalidraw/element";import{jsx as Kf}from"react/jsx-runtime";KT();var RG=e=>{let{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i=!1,onPointerUpdate:a,renderTopLeftUI:l,renderTopRightUI:s,langCode:c=wo.code,viewModeEnabled:m,zenModeEnabled:p,gridModeEnabled:d,libraryReturnUrl:h,theme:f,name:b,renderCustomStats:E,onPaste:w,detectScroll:y=!0,handleKeyboardGlobally:x=!1,onLibraryChange:v,autoFocus:I=!1,generateIdForFile:C,onLinkOpen:P,generateLinkForSelection:k,onPointerDown:N,onPointerUp:_,onScrollChange:L,onDuplicate:B,children:G,validateEmbeddable:j,renderEmbeddable:H,showDeprecatedFonts:Y,wheelZoomsOnDefault:D,strokeColorTopPicks:O,backgroundColorTopPicks:Q,renderScrollbars:ee}=e,K=e.UIOptions?.canvasActions,ae={...e.UIOptions,canvasActions:{...qT.canvasActions,...K},tools:{image:e.UIOptions?.tools?.image??!0}};return K?.export&&(ae.canvasActions.export.saveFileToDisk=K.export?.saveFileToDisk??qT.canvasActions.export.saveFileToDisk),ae.canvasActions.toggleTheme===null&&typeof f>"u"&&(ae.canvasActions.toggleTheme=!0),_G(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ce=Oe=>{typeof Oe.scale=="number"&&Oe.scale!==1&&Oe.preventDefault()};return document.addEventListener("touchmove",ce,{passive:!1}),()=>{document.removeEventListener("touchmove",ce)}},[]),Kf(v1,{store:$e,children:Kf(FT,{langCode:c,theme:f,children:Kf(BT,{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i,onPointerUpdate:a,renderTopLeftUI:l,renderTopRightUI:s,langCode:c,viewModeEnabled:m,zenModeEnabled:p,gridModeEnabled:d,libraryReturnUrl:h,theme:f,name:b,renderCustomStats:E,UIOptions:ae,onPaste:w,detectScroll:y,handleKeyboardGlobally:x,onLibraryChange:v,autoFocus:I,generateIdForFile:C,onLinkOpen:P,generateLinkForSelection:k,onPointerDown:N,onPointerUp:_,onScrollChange:L,onDuplicate:B,validateEmbeddable:j,renderEmbeddable:H,showDeprecatedFonts:Y,wheelZoomsOnDefault:D,strokeColorTopPicks:O,backgroundColorTopPicks:Q,renderScrollbars:ee,children:G})})})},NG=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:n={},...r}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(n),c=Object.keys(a);return s.length!==c.length?!1:s.every(p=>p==="getFormFactor"?!0:p==="canvasActions"?Object.keys(n.canvasActions).every(h=>h==="export"&&n?.canvasActions?.export&&a?.canvasActions?.export?n.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:n?.canvasActions?.[h]===a?.canvasActions?.[h]):n[p]===a[p])&&DG(r,l)},BG=AG.memo(RG,NG);BG.displayName="Excalidraw";export{Ot as Button,uv as CaptureUpdateAction,l8e as DEFAULT_LASER_COLOR,Vd as DefaultSidebar,LG as DiagramToCodePlugin,Da as Ellipsify,BG as Excalidraw,r8e as FONT_FAMILY,mG as Footer,hG as LiveCollaborationTrigger,a8e as MIME_TYPES,bt as MainMenu,Rc as ROUNDNESS,Qt as Sidebar,Ll as Stats,i8e as THEME,s8e as UserIdleState,xG as WelcomeScreen,Ci as bumpVersion,C8e as convertToExcalidrawElements,wo as defaultLang,nw as elementPartiallyOverlapsWithOrContainsBBox,rw as elementsOverlappingBBox,by as exportToBlob,Li as exportToCanvas,lA as exportToClipboard,Ai as exportToSvg,T8e as getCommonBounds,Mm as getDataURL,m8e as getFormFactor,Gc as getLibraryItemsHash,W7e as getNonDeletedElements,H7e as getSceneVersion,V7e as getTextFromElements,S8e as getVisibleSceneBounds,G7e as hashElementsVersion,U7e as hashString,Ch as isElementInsideBBox,A8e as isElementLink,K7e as isInvisiblySmallElement,o8e as isLinearElement,Ur as languages,ss as loadFromBlob,km as loadLibraryFromBlob,Cm as loadSceneOrLibraryFromBlob,Cy as mergeLibraryItems,Bc as mutateElement,u8e as newElementWith,c8e as normalizeLink,Zu as parseLibraryTokensFromUrl,MG as reconcileElements,zr as restoreAppState,oS as restoreElement,$n as restoreElements,ga as restoreLibraryItems,py as sceneCoordsToViewportCoords,ua as serializeAsJSON,tS as serializeLibraryAsJSON,D8e as setCustomTextMetricsProvider,de as useEditorInterface,IA as useHandleLibrary,Ue as useI18n,je as useStylesPanelMode,d8e as viewportCoordsToSceneCoords,vE as zoomToFitBounds};
|