@myoc/excalidraw 0.19.546 → 0.19.547

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/dist/dev/{chunk-GEFQQ6MF.js → chunk-6X722ZMM.js} +2 -2
  3. package/dist/dev/{chunk-XE3CQOUC.js → chunk-OWS32STE.js} +3 -3
  4. package/dist/dev/{chunk-35XUJXYN.js → chunk-VBVJJWUO.js} +5 -1
  5. package/dist/dev/chunk-VBVJJWUO.js.map +7 -0
  6. package/dist/dev/data/{image-K27274LO.js → image-SHO5VNS6.js} +3 -3
  7. package/dist/dev/index.css +0 -3
  8. package/dist/dev/index.css.map +2 -2
  9. package/dist/dev/index.js +225 -65
  10. package/dist/dev/index.js.map +4 -4
  11. package/dist/dev/locales/{en-CBVTFJ6O.js → en-V2WTRX5T.js} +2 -2
  12. package/dist/dev/subset-shared.chunk.js +1 -1
  13. package/dist/dev/subset-worker.chunk.js +1 -1
  14. package/dist/prod/{chunk-QYIN2RK3.js → chunk-FZE33ODQ.js} +2 -2
  15. package/dist/prod/{chunk-VXOLR3OR.js → chunk-MZBVWY5X.js} +4 -4
  16. package/dist/prod/{chunk-X54XK3GS.js → chunk-U23VT5B7.js} +1 -1
  17. package/dist/prod/data/image-ELTE3WZG.js +1 -0
  18. package/dist/prod/index.css +1 -1
  19. package/dist/prod/index.js +13 -13
  20. package/dist/prod/locales/{en-7BECMN3G.js → en-ALU5NMSJ.js} +1 -1
  21. package/dist/prod/subset-shared.chunk.js +1 -1
  22. package/dist/prod/subset-worker.chunk.js +1 -1
  23. package/dist/types/excalidraw/actions/manager.d.ts +3 -1
  24. package/dist/types/excalidraw/actions/shortcuts.d.ts +1 -0
  25. package/dist/types/excalidraw/actions/types.d.ts +1 -1
  26. package/dist/types/excalidraw/components/App.d.ts +7 -3
  27. package/dist/types/excalidraw/index.d.ts +1 -1
  28. package/dist/types/excalidraw/types.d.ts +11 -0
  29. package/package.json +4 -4
  30. package/dist/dev/chunk-35XUJXYN.js.map +0 -7
  31. package/dist/prod/data/image-355PB44S.js +0 -1
  32. /package/dist/dev/{chunk-GEFQQ6MF.js.map → chunk-6X722ZMM.js.map} +0 -0
  33. /package/dist/dev/{chunk-XE3CQOUC.js.map → chunk-OWS32STE.js.map} +0 -0
  34. /package/dist/dev/data/{image-K27274LO.js.map → image-SHO5VNS6.js.map} +0 -0
  35. /package/dist/dev/locales/{en-CBVTFJ6O.js.map → en-V2WTRX5T.js.map} +0 -0
@@ -1,24 +1,24 @@
1
- import{$ as Bu,A as xx,B as Ru,C as Ps,D as Nc,E as Nu,F as yx,G as wx,H as Bc,I as ks,J as Fc,K as Oc,L as Ms,M as zc,N as vx,O as Ix,P as Tx,Q as Gc,R as Or,S as BA,T as zr,U as Ri,W as Sx,Y as Cx,Z as Px,_ as Hc,a as Au,aa as Ni,b as $n,ba as As,c as vo,ca as Ds,d as Fr,da as kx,e as Di,ea as Uc,f as jn,fa as Mx,g as ux,ga as Ax,h as Re,ha as Dx,i as hx,ia as Lx,j as de,ja as Fu,k as Li,ka as _x,l as Xo,la as Rx,m as gx,ma as Nx,n as Du,na as Gr,o as fx,p as Ss,q as Ex,r as Rc,s as bx,t as Lu,u as _u,v as Io,w as Zo,x as rn,y as Cs,z as _i}from"./chunk-QYIN2RK3.js";import{a as S}from"./chunk-X54XK3GS.js";import{G as Mu}from"./chunk-VXOLR3OR.js";import{c as px}from"./chunk-5XKZK2GL.js";import{b as mx,c as NA,d as w}from"./chunk-SRAX5OIU.js";import BX,{useCallback as FX,useContext as OX,useEffect as zX,useRef as GX,useState as HX}from"react";import{applyDarkModeFilter as wYe,DEFAULT_IMAGE_OPTIONS as Pn,DEFAULT_UI_OPTIONS as RA,getStrokeWidthByKey as vYe,isShallowEqual as UX}from"@excalidraw/common";import cM from"clsx";import gY from"lodash.throttle";import Sn,{useContext as Yo}from"react";import{flushSync as Gt}from"react-dom";import fY from"roughjs/bin/rough";import{nanoid as EY}from"nanoid";import{clamp as fc,pointFrom as oe,pointDistance as go,vector as dM,pointRotateRads as Sb,vectorFromPoint as Cb,vectorSubtract as mM,vectorDot as pM,vectorNormalize as uM}from"@excalidraw/math";import{CODES as Lr,shouldResizeFromCenter as hM,shouldMaintainAspectRatio as Ec,shouldRotateWithDiscreteAngle as gM,isArrowKey as Pb,KEYS as V,APP_NAME as bY,CURSOR_TYPE as Me,DEFAULT_STROKE_STREAMLINE as xY,DEFAULT_STROKE_STREAMLINE_PRECISE as yY,DEFAULT_TRANSFORM_HANDLE_SPACING as wY,DEFAULT_VERTICAL_ALIGN as fM,DRAGGING_THRESHOLD as EM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as vY,ELEMENT_TRANSLATE_AMOUNT as bM,EVENT as Q,FRAME_STYLE as Go,IMAGE_MIME_TYPES as IY,IMAGE_RENDER_TIMEOUT as TY,LINE_CONFIRM_THRESHOLD as kb,MIME_TYPES as In,MQ_RIGHT_SIDEBAR_MIN_WIDTH as SY,POINTER_BUTTON as Tn,ROUNDNESS as au,SCROLL_TIMEOUT as CY,TAP_TWICE_TIMEOUT as xM,TEXT_TO_CENTER_SNAP_THRESHOLD as PY,THEME as bc,TOUCH_CTX_MENU_TIMEOUT as kY,VERTICAL_ALIGN as MY,YOUTUBE_STATES as su,ZOOM_STEP as AY,MIN_ZOOM as DY,POINTER_EVENTS as fs,TOOL_TYPE as Yn,supportsResizeObserver as LY,DEFAULT_COLLISION_THRESHOLD as yM,DEFAULT_TEXT_ALIGN as _Y,ARROW_TYPE as _r,DEFAULT_REDUCED_GLOBAL_ALPHA as RY,isLocalLink as NY,normalizeLink as lu,toValidURL as BY,getGridPoint as kt,getLineHeight as wM,debounce as vM,distance as Es,getFontString as Mb,getNearestScrollableContainer as FY,isInputLike as IM,isToolIcon as OY,isWritableElement as xc,sceneCoordsToViewportCoords as cu,tupleToCoors as Ab,viewportCoordsToSceneCoords as Ce,wrapEvent as zY,updateObject as Db,updateActiveTool as on,isTransparent as GY,muteFSAbortError as HY,isTestEnv as uA,isDevEnv as hA,updateStable as yc,addEventListener as we,normalizeEOL as UY,getDateTime as TM,isShallowEqual as SM,arrayToMap as wc,applyDarkModeFilter as WY,AppEventBus as VY,randomInteger as YY,CLASSES as Lb,Emitter as fo,MINIMUM_ARROW_SIZE as KY,DOUBLE_TAP_POSITION_THRESHOLD as CM,BIND_MODE_TIMEOUT as XY,invariant as Eo,getFeatureFlag as Ho,createUserAgentDescriptor as gA,getFormFactor as ZY,deriveStylesPanelMode as wu,isIOS as $Y,isBrave as jY,isSafari as qY,loadDesktopUIModePreference as JY,setDesktopUIMode as QY,isSelectionLikeTool as du,oneOf as PM,getStrokeWidthByKey as eK,getViewpointFlipSign as Kn}from"@excalidraw/common";import{getObservedAppState as tK,getCommonBounds as bs,getElementAbsoluteCoords as kM,bindOrUnbindBindingElements as MM,fixBindingsAfterDeletion as nK,getHoveredElementForBinding as Rr,isBindingEnabled as mu,updateBoundElements as pu,LinearElementEditor as fe,newElementWith as bo,newFrameElement as oK,newFreeDrawElement as rK,newEmbeddableElement as AM,newMagicFrameElement as iK,newIframeElement as aK,newArrowElement as sK,newElement as lK,newImageElement as cK,newLinearElement as dK,newTextElement as DM,refreshTextDimensions as mK,deepCopyElement as LM,duplicateElements as _M,hasBoundTextElement as RM,isArrowElement as vc,isBindingElement as xo,isBindingElementType as pK,isBoundToContainer as NM,isFrameLikeElement as Tt,isImageElement as Xn,isEmbeddableElement as Uo,isInitializedImageElement as Si,isLinearElement as Ht,isLinearElementType as uK,isUsingAdaptiveRadius as hK,isIframeElement as _b,isIframeLikeElement as Ic,isTextBindableContainer as BM,isElbowArrow as Zt,isBindableElement as Rb,isTextElement as $t,getNormalizedDimensions as gK,isElementCompletelyInViewport as fK,isElementInViewport as FM,isInvisiblySmallElement as OM,generateThumbHash as EK,getCornerRadius as bK,isPathALoop as zM,embeddableURLValidator as Nb,maybeParseEmbedSrc as xK,getEmbedLink as uu,getInitializedImageElements as yK,normalizeSVG as GM,updateImageCache as Bb,getBoundTextElement as Fb,getContainerCenter as Ob,getContainerElement as HM,isValidTextContainer as UM,redrawTextBoundingBox as wK,hasBoundingBox as vK,getCommonFrameId as WM,getFrameChildren as zb,getFrameChildrenInsertionIndex as IK,isCursorInFrame as VM,addElementsToFrame as Gb,replaceAllElementsInFrame as TK,removeElementsFromFrame as SK,getElementsInResizingFrame as Hb,getElementsInNewFrame as CK,getContainingFrame as Ub,elementOverlapsWithFrame as PK,updateFrameMembershipOfSelectedElements as YM,isElementInFrame as KM,getFrameLikeTitle as kK,filterElementsEligibleAsFrameChildren as MK,hitElementBoundText as AK,hitElementBoundingBoxOnly as DK,hitElementItself as Tc,getVisibleSceneBounds as LK,cropElement as _K,wrapText as RK,isElementLink as XM,isMeasureTextSupported as NK,normalizeText as BK,measureText as ZM,getLineHeightInPx as $M,getApproxMinLineWidth as FK,getApproxMinLineHeight as OK,getMinTextElementWidth as zK,ShapeCache as Ci,getRenderOpacity as GK,editGroupForSelectedElement as HK,getElementsInGroup as Pi,getSelectedGroupIdForElement as UK,getSelectedGroupIds as WK,isElementInGroup as jM,isSelectedViaGroup as VK,selectGroupsForSelectedElements as Zn,syncInvalidIndices as fA,syncMovedIndices as qM,excludeElementsInFramesFromSelection as YK,getSelectionStateForElements as JM,makeNextSelectedElementIds as De,getResizeOffsetXY as KK,getResizeArrowDirection as XK,transformElements as ZK,getCursorForResizingElement as QM,getElementWithTransformHandleType as eA,getTransformHandleTypeFromCoords as tA,dragNewElement as nA,dragSelectedElements as $K,getDragOffsetXY as jK,Scene as oA,Store as qK,CaptureUpdateAction as jt,hitElementBoundingBox as JK,isLineElement as Wb,isSimpleArrow as Vb,StoreDelta as rA,positionElementsOnGrid as iA,calculateFixedPointForNonElbowArrowBinding as aA,bindOrUnbindBindingElement as QK,mutateElement as hu,getElementBounds as sA,doBoundsIntersect as eX,isPointInElement as lA,maxBindingDistance_simple as cA,convertToExcalidrawElements as tX,getSnapOutlineMidPoint as Yb,handleFocusPointDrag as nX,handleFocusPointHover as oX,handleFocusPointPointerDown as rX,handleFocusPointPointerUp as iX,maybeHandleArrowPointlikeDrag as gu,getUncroppedWidthAndHeight as aX,getActiveTextElement as dA,isEligibleFrameChildType as sX,getBindingStrategyForDraggingBindingElementEndpoints as lX,isNonDeletedElement as fu}from"@excalidraw/element";import{KEYS as gh,MOBILE_ACTION_BUTTON_BG as jA,updateActiveTool as qA}from"@excalidraw/common";import{getNonDeletedElements as ld}from"@excalidraw/element";import{fixBindingsAfterDeletion as JA}from"@excalidraw/element";import{LinearElementEditor as A0}from"@excalidraw/element/linearElementEditor";import{newElementWith as sd}from"@excalidraw/element";import{getContainerElement as D0}from"@excalidraw/element";import{isBoundToContainer as id,isElbowArrow as QA,isFrameLikeElement as e3}from"@excalidraw/element";import{getFrameChildren as t3}from"@excalidraw/element";import{getElementsInGroup as fh,selectGroupsForSelectedElements as n3}from"@excalidraw/element";import{CaptureUpdateAction as ad}from"@excalidraw/element";import{isDevEnv as GA}from"@excalidraw/common";import{atom as Je,createStore as FA}from"jotai";import{createIsolation as OA}from"jotai-scope";var Bx=OA();var{useAtom:Ke,useSetAtom:Fx,useAtomValue:Bi,useStore:ZX}=Bx,Ox=Bx.Provider,bt=FA();var zA=mx({"./locales/ar-SA.json":()=>import("./locales/ar-SA-E6E2KRZ5.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-RDMGQYMZ.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-CHUVCTEA.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-ZMOEPIQW.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-OHZAWF5C.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-K4A7PUP4.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-RVP6YORC.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-ENJX4GIQ.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-VYBKDWRU.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-6MCXRRVA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-WEDZAIPA.js"),"./locales/en.json":()=>import("./locales/en-7BECMN3G.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-LLEALNRO.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-M4Y34NOW.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-XSMVGGRV.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-K2D3DDUS.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-EQKMVJSO.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-RCPQTYJV.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-RHAGKYKH.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-3UDCLKHN.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-T3REA7IL.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-KW4N25IN.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-LJVXK4LO.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-GGGK3KPX.js"),"./locales/kaa.json":()=>import("./locales/kaa-TSEHAWJR.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-IWXTEINV.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-6GNYSAU7.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-ILUXSOEW.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-FJWHM3OT.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-DRDDAECA.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-IYFIPPJI.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-7F754RSS.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-BYRIZ3PC.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-RBYJSIJ6.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-EKTZIYSK.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-UECYYIUK.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-JPXGIDBA.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-4RSIVDPZ.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-GPHFXISR.js"),"./locales/percentages.json":()=>import("./locales/percentages-Q7USCRWZ.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-HKHPAEVK.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-UBWN6CKP.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-XDY4S4SD.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-2B3UXAQO.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-EW52HAV3.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-PIEHI4JX.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-TZXYYIFD.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-VUDQNDF3.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-IJTJRA7S.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-Q5PXZT3U.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HK66ZQXE.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-CLYYPVPL.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-YR4OMRYF.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-CY4LSY5Y.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-UDAEMEBG.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-EGBL23FT.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-ZOJEG32A.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-TM5HZP7M.js")});var HA=85,qn={code:"en",label:"English"},Oi=[qn,...[{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=>px[e.code]>=HA).sort((e,n)=>e.label>n.label?1:-1)],Vc="__test__";GA()&&Oi.unshift({code:Vc,label:"test language"},{code:`${Vc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Fi=qn,Wc={},Yc=async e=>{if(Fi=e,document.documentElement.dir=Fi.rtl?"rtl":"ltr",document.documentElement.lang=Fi.code,e.code.startsWith(Vc))Wc={};else try{Wc=await zA(`./locales/${Fi.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Wc=Mu}bt.set(Gx,e.code)},Jn=()=>Fi,zx=(e,n)=>{for(let t=0;t<n.length;++t){let o=n[t];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},f=(e,n,t)=>{if(Fi.code.startsWith(Vc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=zx(Wc,o)||zx(Mu,o)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(S.PROD)return console.warn(i),"";throw new Error(i)}if(n)for(let i in n)r=r.replace(`{{${i}}}`,String(n[i]));return r},Gx=Je(qn.code),Ne=()=>{let e=Bi(Gx);return{t:f,langCode:e}};import UA from"clsx";import nt from"react";import{THEME as WA}from"@excalidraw/common";import{Fragment as Ie,jsx as h,jsxs as R}from"react/jsx-runtime";var An=e=>"var(--icon-fill-color)",Hx=e=>e===WA.LIGHT?"#fff":"#1e1e1e",A=(e,n=512)=>{let{width:t=512,height:o=t,mirror:r,style:i,...a}=typeof n=="number"?{width:n}:n;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${o}`,className:UA({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},le={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Lt={width:40,height:20},cZ=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),H),dZ=A(R("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),H),mZ=A("M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM288 248C288 234.7 277.3 224 264 224C250.7 224 240 234.7 240 248L240 392C240 405.3 250.7 416 264 416C277.3 416 288 405.3 288 392L288 248zM400 248C400 234.7 389.3 224 376 224C362.7 224 352 234.7 352 248L352 392C352 405.3 362.7 416 376 416C389.3 416 400 405.3 400 392L400 248z",640),Ls=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),H),Ux=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),H),Wx=A(R("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),H),Ou=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),H),To=A(R("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),le),$o=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),le),Vx=A(h("g",{fill:"currentColor",children:h("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),Yx=A(R(Ie,{children:[h("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),Kx=A(R(Ie,{children:[h("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),Xx=A(R(Ie,{children:[h("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),pZ=A(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),Kc=A(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),zi=A(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Gi=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),H),Hi=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),H),Ui=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),H),Xc=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),H),jo=A(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),le),Zx=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),H),Qn=A(R("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),le),Dn=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),H),$x=A(R("g",{stroke:"currentColor",strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),H),Hr=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),le),Zc=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),H),zu=A(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),le),Gu=A(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),le),jx=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),h("path",{d:"M3 4v4h4"})]}),H),Ur=A(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),le),qo=A(R("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),le),_s=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),le),Rs=A(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),le),Ns=A(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...le,strokeWidth:1.5}),qx=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),H),Bs=A(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),le),Wi=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),Jx=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),uZ=A(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),le),Qx=A(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),le),e1=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),le),t1=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),H),$c=A(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Fs=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),le),n1=A("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),o1=A("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),jc=A(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),le),hZ=A("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),gZ=A("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),Hu=["M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z","M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z","M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"],eo=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Hu.map(e=>h("path",{d:e},e))]}),H),r1=A(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),i1=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),H),a1=A("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),fZ=A("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),EZ=A("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),s1=A("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),bZ=A("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Uu=A(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),le),Wu=A(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),le),l1=A("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),c1=A(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),le),xZ=A("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),yZ=A("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),wZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),H),vZ=A(R(Ie,{children:[h("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),h("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),IZ=A(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),d1=R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),m1=R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),Vu=A(m1,H),Yu=A(m1,{...H,style:{transform:"rotate(180deg)"}}),Ku=A(d1,H),Xu=A(d1,{...H,style:{transform:"rotate(180deg)"}}),Zu=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),$u=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),ju=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),qu=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),p1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),u1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),Ju=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),le),Qu=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),le),qc=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),H),TZ=A("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),SZ=A("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),an=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),CZ=A("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),PZ=A("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),kZ=A("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),eh=nt.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:An(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:An(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:An(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:An(e),strokeWidth:"2"}),R("g",{fill:Hx(e),stroke:An(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),th=nt.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:An(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:An(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:An(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:An(e),strokeWidth:"2"}),R("g",{fill:Hx(e),stroke:An(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),h1=A(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),le),g1=A(R(Ie,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),le),f1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),E1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...le,fill:"currentColor"}),nh=A(h(Ie,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),le),b1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),le),x1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),le),MZ=nt.memo(({theme:e})=>A(h("path",{d:"M6 10H34",stroke:An(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),y1=A(R("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),H),w1=A(R("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),H),v1=A(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),le),I1=A(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),le),T1=A(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),le),oh=A(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),rh=A(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"2.75",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"3.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),S1=A(R("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),le),C1=A(R("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),H),P1=nt.memo(({flip:e=!1})=>A(R("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[h("path",{d:"M7,11 H19"}),h("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),Lt)),k1=nt.memo(({flip:e=!1})=>A(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),Lt)),M1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Lt)),A1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[h("path",{d:"M7,11 H23"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Lt)),D1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),Lt)),L1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M7,11 H25",strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),Lt)),_1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Lt)),R1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[h("path",{d:"M7,11 H21"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Lt)),N1=nt.memo(({flip:e=!1})=>A(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:h("path",{d:"M11,11 H31 M31,5 V17"})}),Lt)),B1=nt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17"})}),Lt)),F1=nt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),Lt)),O1=nt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),Lt)),z1=nt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),Lt)),G1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),h("circle",{cx:"15",cy:"11",r:"4"})]}),Lt)),H1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),h("circle",{cx:"23",cy:"11",r:"4"})]}),Lt)),U1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),W1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),V1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),Y1=A(h(Ie,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),le),Wr=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),H),K1=A(h(Ie,{children:R("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),H),Os=A(h(Ie,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),le),VA=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 8l-4 4l4 4"}),h("path",{d:"M17 8l4 4l-4 4"}),h("path",{d:"M14 4l-4 16"})]}),H),Jc=VA,X1=A(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),H),Z1=A(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),H),$1=A(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),H),j1=nt.memo(({theme:e})=>A(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),H)),q1=nt.memo(({theme:e})=>A(R("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),H)),J1=nt.memo(({theme:e})=>A(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),H)),Qc=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),H),AZ=A(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),DZ=A(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Q1=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),H),ih=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),H),e0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),H),t0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),H),n0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),LZ=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),_Z=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),H),o0=A(R(Ie,{children:[h("path",{d:"M7 5v14"}),h("path",{d:"M19 6l-9 6l9 6z"})]}),H),r0=A(R(Ie,{children:[h("path",{d:"M17 5v14"}),h("path",{d:"M5 6l9 6l-9 6z"})]}),H),i0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 6h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10a1 1 0 0 1 1 -1z"}),h("path",{d:"M7 6v12"}),h("path",{d:"M17 6v12"}),h("path",{d:"M3 10h4"}),h("path",{d:"M3 14h4"}),h("path",{d:"M17 10h4"}),h("path",{d:"M17 14h4"})]}),H),a0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),s0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),H),ah=["M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z","M11 7l6 6"],Vi=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),ah.map(e=>h("path",{d:e},e))]}),H),to=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),H),RZ=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),h("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),H),NZ=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),h("path",{d:"M4 15l8 4l8 -4"}),h("path",{d:"M12 4v7"}),h("path",{d:"M15 8l-3 3l-3 -3"})]}),H),BZ=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),le),Vr=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0"}),h("path",{d:"M10 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7"})]}),H),no=A(R("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),h("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),FZ=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),H),OZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),H),zZ=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),H),GZ=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),H),Yr=A(R("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),H),l0=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),h("path",{d:"M3 3l18 18"})]}),H),HZ=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),UZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),oo=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),H),WZ=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),H),VZ=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 8l0 4l2 2"}),h("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),H),c0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),H),d0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),H),YZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),H),m0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),H),p0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),H),u0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),H),h0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),H),sh=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),H),ed=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),H),g0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),H),f0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),H),Jo=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),H),KZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),H),E0=A(R("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...H,strokeWidth:1.5}),XZ=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),H),ZZ=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),H),b0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),H),x0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),H),Qo=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),H),er=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),H),tr=A(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),td=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),y0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),w0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),lh=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),H),v0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),H),ch=A(R("g",{strokeWidth:"1.25",children:[h("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),H),dh=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),h("polyline",{points:"2 8 3 6 4 8"}),h("polyline",{points:"2 12 3 14 4 12"}),h("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),h("polyline",{points:"9 17 7 18 9 19"}),h("polyline",{points:"15 17 17 18 15 19"})]}),H),$Z=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),h("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),H),mh=A(h("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:h("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})})),I0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),H),T0=A(R("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),H),ph=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),h("path",{d:"M13.5 6.5l4 4"})]}),H),jZ=A(R("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l-5 5l5 5"}),h("path",{d:"M17 7l-5 5l5 5"})]}),H),qZ=A(R("g",{strokeWidth:"1.75",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"}),h("path",{d:"M15 4l0 16"})]}),H),JZ=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),H),QZ=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 4l18 0"}),h("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),h("path",{d:"M12 16l0 4"}),h("path",{d:"M9 20l6 0"}),h("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),H),nd=h("div",{style:{width:"1rem",height:"1rem"}}),S0=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"6 9 12 15 18 9"})]}),H),C0=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"9 6 15 12 9 18"})]}),H),P0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),H);import k0 from"clsx";import hh,{useEffect as XA,useRef as M0,useState as ZA}from"react";import{isPromiseLike as $A}from"@excalidraw/common";import YA from"react";import{jsx as uh}from"react/jsx-runtime";var KA=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(YA.useRef(Date.now()).current%1600);return uh("div",{className:`Spinner ${o}`,children:uh("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:uh("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},So=KA;import{jsx as zs,jsxs as od}from"react/jsx-runtime";var $=hh.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=hh.useRef(null);hh.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=ZA(!1),c=M0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if($A(u))try{l(!0),await u}catch(E){if(E instanceof Rc)console.warn(E);else throw E}finally{c.current&&l(!1)}};XA(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=M0(null);return o.type==="button"||o.type==="icon"?od("button",{className:k0("ToolIcon_type_button",a,t,n&&!o.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!o.hidden,"ToolIcon--plain":o.type==="icon"}),style:o.style,"data-testid":o["data-testid"],hidden:o.hidden,title:o.title,"aria-label":o["aria-label"],type:"button",onClick:d,ref:i,disabled:s||o.isLoading||!!o.disabled,children:[(o.icon||o.label)&&od("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&zs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&zs(So,{})]}),o.showAriaLabel&&od("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&zs(So,{})]}),o.children]}):zs("button",{className:k0("ToolIcon","ToolIcon_type_toggle",a,t,{"ToolIcon--checked":o.checked}),type:"button",style:o.style,title:o.title,"aria-label":o["aria-label"],"aria-keyshortcuts":o["aria-keyshortcuts"],"aria-pressed":o.checked,"data-testid":o["data-testid"],disabled:!!o.disabled,"aria-disabled":!!o.disabled,onPointerDown:p=>{m.current=p.pointerType||null},onPointerUp:()=>{requestAnimationFrame(()=>{m.current=null})},onClick:()=>{o.onSelect?.({pointerType:m.current})},ref:i,children:od("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&zs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});$.displayName="IconButton";var rd=[],O=e=>(rd=rd.concat(e),e);import{jsx as r3}from"react/jsx-runtime";var o3=(e,n,t)=>{let o=new Set(de(e.filter(d=>e3(d)),n).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of o){let m=t3(e,d);for(let p of m)if(!a.has(p.id)){if(id(p)){let u=D0(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let s=!0,l=e.map(d=>{if(n.selectedElementIds[d.id]){let m=id(d)?D0(d,i):null;return d.frameId&&o.has(d.frameId)?(s=!1,r[d.id]=!0,d):m?.frameId&&o.has(m?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&QA(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),sd(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,id(d)||(r[d.id]=!0),sd(d,{frameId:null})):id(d)&&n.selectedElementIds[d.containerId]?sd(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=fh(l,n.editingGroupId).filter(m=>!m.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{c=null,d[0]&&(r[d[0].id]=!0);let m=d[0];if(m){let p=m.groupIds.findIndex(E=>E===n.editingGroupId),u=m.groupIds[p+1];if(u){let E=fh(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...n3({selectedElementIds:r,editingGroupId:c},ld(l),n,null)}}},L0=(e,n)=>{if(e.editingGroupId){let t=fh(ld(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Gs=O({name:"deleteSelectedElements",label:"labels.delete",icon:Ur,trackEvent:{category:"element",action:"delete"},perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:s}=n.selectedLinearElement,l=o.scene.getNonDeletedElementsMap(),c=A0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?sd(p,{isDeleted:!0}):p),m=L0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:ad.IMMEDIATELY}}return A0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:ad.IMMEDIATELY}}let{elements:r,appState:i}=o3(e,n,o);return JA(r,r.filter(a=>a.isDeleted)),i=L0(i,r),{elements:r,appState:{...i,activeTool:qA(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Re(ld(e),n)?ad.IMMEDIATELY:ad.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===gh.BACKSPACE||e.key===gh.DELETE)&&!e[gh.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=mt()==="mobile";return r3($,{type:"button",icon:Ur,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Re(ld(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?jA:{}}})}});import{KEYS as Yi,CODES as Ki,isDarwin as cd}from"@excalidraw/common";import{moveOneLeft as i3,moveOneRight as a3,moveAllLeft as s3,moveAllRight as l3}from"@excalidraw/element";import{CaptureUpdateAction as dd}from"@excalidraw/element";import{isDarwin as _0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,_0?f("keys.option"):f("keys.alt")).replace(/\bShift\b/i,f("keys.shift")).replace(/\b(Enter|Return)\b/i,f("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,_0?f("keys.cmd"):f("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,f("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,f("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,f("keys.delete"));import{jsx as md}from"react/jsx-runtime";var Eh=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Yu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:i3(e,n,o.scene),appState:n,captureUpdate:dd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Yi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ki.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>md("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Yu})}),bh=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Vu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:a3(e,n,o.scene),appState:n,captureUpdate:dd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Yi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ki.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>md("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Vu})}),xh=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Xu,trackEvent:{category:"element"},perform:(e,n)=>({elements:s3(e,n),appState:n,captureUpdate:dd.IMMEDIATELY}),keyTest:e=>cd?e[Yi.CTRL_OR_CMD]&&e.altKey&&e.code===Ki.BRACKET_LEFT:e[Yi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ki.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>md("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${cd?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Xu})}),yh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Ku,trackEvent:{category:"element"},perform:(e,n)=>({elements:l3(e,n),appState:n,captureUpdate:dd.IMMEDIATELY}),keyTest:e=>cd?e[Yi.CTRL_OR_CMD]&&e.altKey&&e.code===Ki.BRACKET_RIGHT:e[Yi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ki.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>md("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${cd?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Ku})});import{getNonDeletedElements as c3}from"@excalidraw/element";import{LinearElementEditor as d3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as m3,isTextElement as p3}from"@excalidraw/element";import{arrayToMap as u3,KEYS as R0}from"@excalidraw/common";import{selectGroupsForSelectedElements as h3}from"@excalidraw/element";import{CaptureUpdateAction as g3}from"@excalidraw/element";var wh=O({name:"selectAll",label:"labels.selectAll",icon:m0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(p3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...h3({editingGroupId:null,selectedElementIds:r},c3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&m3(e[0])?new d3(e[0],u3(e)):null},captureUpdate:g3.IMMEDIATELY}},keyTest:e=>e[R0.CTRL_OR_CMD]&&e.key===R0.A});import{DEFAULT_GRID_SIZE as N0,KEYS as B0,MOBILE_ACTION_BUTTON_BG as f3,arrayToMap as F0}from"@excalidraw/common";import{getNonDeletedElements as O0}from"@excalidraw/element";import{LinearElementEditor as E3}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as b3,getSelectionStateForElements as x3}from"@excalidraw/element";import{syncMovedIndices as y3}from"@excalidraw/element";import{duplicateElements as w3}from"@excalidraw/element";import{CaptureUpdateAction as z0}from"@excalidraw/element";import{jsx as v3}from"react/jsx-runtime";var vh=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:_s,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=E3.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:z0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=w3({type:"in-place",elements:e,idsOfElementsToDuplicate:F0(b3(e,n,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:n,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:s})=>{let l=a.frameId&&s.get(a.frameId);return{x:a.x+N0/2,y:a.y+N0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:y3(i,F0(r)),appState:{...n,...x3(r,O0(i),n)},captureUpdate:z0.IMMEDIATELY}},keyTest:e=>e[B0.CTRL_OR_CMD]&&e.key===B0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=mt()==="mobile";return v3($,{type:"button",icon:_s,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Re(O0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?f3:{}}})}});import{pointFrom as t6}from"@excalidraw/math";import{useEffect as Wh,useMemo as Kh,useRef as Vh,useState as n6}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as o6,COLOR_PALETTE as r6,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Ky,DEFAULT_ELEMENT_BACKGROUND_PICKS as i6,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as a6,DEFAULT_ELEMENT_STROKE_PICKS as s6,ARROW_TYPE as dn,DEFAULT_FONT_FAMILY as l6,DEFAULT_FONT_SIZE as c6,FONT_FAMILY as d6,ROUNDNESS as Ld,STROKE_WIDTH_KEYS as m6,VERTICAL_ALIGN as Ad,KEYS as na,randomInteger as p6,arrayToMap as Xh,getFontFamilyString as u6,getLineHeight as h6,isTransparent as g6,getStrokeWidthByKey as Xy,reduceToCommonValue as f6,invariant as Rd,FONT_SIZES as Dd}from"@excalidraw/common";import{canBecomePolygon as E6,getNonDeletedElements as Zy,isNonDeletedElement as b6}from"@excalidraw/element";import{bindBindingElement as Hy,calculateFixedPointForElbowArrowBinding as Uy,updateBoundElements as x6}from"@excalidraw/element";import{LinearElementEditor as Xr}from"@excalidraw/element/linearElementEditor";import{newElementWith as st}from"@excalidraw/element";import{getArrowheadForPicker as Wy}from"@excalidraw/element";import{getBoundTextElement as cr,redrawTextBoundingBox as Qs}from"@excalidraw/element";import{isArrowElement as _d,isBoundToContainer as y6,isElbowArrow as $y,isLinearElement as Yh,isLineElement as Vy,isTextElement as Wt,isUsingAdaptiveRadius as w6}from"@excalidraw/element";import{hasStrokeColor as v6}from"@excalidraw/element";import{updateElbowArrowPoints as I6,CaptureUpdateAction as ot,toggleLinePolygonState as T6}from"@excalidraw/element";import{deriveStylesPanelMode as S6}from"@excalidraw/common";import{isDevEnv as I3}from"@excalidraw/common";var T3=new Set(["command_palette","export"]),Ue=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!T3.has(e)||I3())return;S.PROD||console.info("trackEvent",{category:e,action:n,label:t,value:o}),window.sa_event&&window.sa_event(n,{category:e,label:t,value:o})}catch(r){console.error("error during analytics",r)}};import k3 from"clsx";import S3 from"clsx";import{forwardRef as C3}from"react";import{jsx as P3}from"react/jsx-runtime";var G0=C3((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return P3("button",{type:"button",ref:n,title:t,"data-testid":r,className:S3(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as A3,jsx as Ih,jsxs as M3}from"react/jsx-runtime";var qt=e=>Ih(A3,{children:e.options.map(n=>e.type==="button"?Ih(G0,{icon:n.icon,title:n.text,testId:n.testId,active:n.active??e.value===n.value,onClick:t=>e.onClick(n.value,t)},n.text):M3("label",{className:k3({active:e.value===n.value}),title:n.text,children:[Ih("input",{type:"radio",name:e.group,onChange:()=>e.onChange(n.value),checked:e.value===n.value,"data-testid":n.testId}),n.icon]},n.text))});import{Popover as xy}from"radix-ui";import yy from"clsx";import{memo as q5,useRef as wy,useEffect as J5}from"react";import{applyDarkModeFilter as Q5,COLOR_OUTLINE_CONTRAST_THRESHOLD as Ey,COLOR_PALETTE as vy,DEFAULT_ELEMENT_BACKGROUND_PICKS as e4,DEFAULT_ELEMENT_STROKE_PICKS as t4,isColorDark as by,isWritableElement as n4,THEME as o4}from"@excalidraw/common";import{jsx as D3}from"react/jsx-runtime";var pd=()=>D3("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as F3,useLayoutEffect as O3,useRef as z3}from"react";import{createPortal as G3}from"react-dom";import{EVENT as nr,isColorDark as H3,KEYS as U3,MIME_TYPES as W3,THEME as V3,removeDarkModeFilter as Y3,rgbToHex as K3}from"@excalidraw/common";import H0 from"react";var Th=H0.createContext(null),xe=()=>H0.useContext(Th);import{useState as L3,useLayoutEffect as U0}from"react";import{THEME as _3}from"@excalidraw/common";var ud=e=>{let[n,t]=L3(null),o=Ee(),{theme:r}=xe(),{container:i}=Oe();return U0(()=>{n&&(n.className="",n.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),n.classList.toggle("excalidraw--mobile",o.formFactor==="phone"),n.classList.toggle("theme--dark",r===_3.DARK))},[n,r,o.formFactor,e?.className]),U0(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let s=document.createElement("div");return a.appendChild(s),t(s),()=>{a.removeChild(s)}},[i,e?.parentSelector]),n};import{useEffect as R3}from"react";import{EVENT as hd}from"@excalidraw/common";function Xi(e,n,t){R3(()=>{function o(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return n(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||n(i)}return document.addEventListener(hd.POINTER_DOWN,o),document.addEventListener(hd.TOUCH_START,o),()=>{document.removeEventListener(hd.POINTER_DOWN,o),document.removeEventListener(hd.TOUCH_START,o)}},[e,n,t])}import{useRef as N3}from"react";var Zi=e=>{let n=N3(e);return Object.assign(n.current,e),n.current};import{clamp as B3}from"@excalidraw/math";var W0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return B3(r,0,Math.max(0,t-n))},gd=({cursor:e,element:n,container:t,gap:o})=>({left:W0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:W0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as Z3}from"react/jsx-runtime";var V0=ah.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),X3=`url(data:${W3.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" stroke-width="5">${V0}</g><g stroke="#1b1b1f" stroke-width="1.25">${V0}</g></svg>`)}) 2 21, auto`,Ut=Je(null),Y0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=ud({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=xe(),a=$i(),s=St(),l=de(a,i),c=Zi({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=Oe();O3(()=>{if(r)return r.style.cursor=X3,()=>{r.style.cursor=""}},[r]),F3(()=>{let p=m.current;if(!p||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:M})=>{let D=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return K3(D[0],D[1],D[2])},b=P=>i.theme===V3.DARK?Y3(P):P,v=({clientX:P,clientY:M,altKey:D})=>{let{top:_,left:k}=gd({cursor:{x:P,y:M},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:7});p.style.top=`${_}px`,p.style.left=`${k}px`;let L=g({clientX:P,clientY:M});u&&c.onChange(o,b(L),c.selectedElements,{altKey:D}),p.style.background=L,p.style.setProperty("--eye-dropper-preview-border-color",H3(L)?"#fff":"#222")},y=()=>{c.onCancel()},x=(P,M)=>{c.onSelect(P,M)},I=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===U3.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),y())};return r.tabIndex=-1,r.focus(),v({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(nr.KEYDOWN,C),r.addEventListener(nr.POINTER_DOWN,I),r.addEventListener(nr.POINTER_UP,T),window.addEventListener("pointermove",v,{passive:!0}),window.addEventListener(nr.BLUR,y),()=>{u=!1,r.removeEventListener(nr.KEYDOWN,C),r.removeEventListener(nr.POINTER_DOWN,I),r.removeEventListener(nr.POINTER_UP,T),window.removeEventListener("pointermove",v),window.removeEventListener(nr.BLUR,y)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=z3(null);return Xi(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?G3(Z3("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as Sh}from"radix-ui";import J3 from"clsx";import Q3 from"react";import{isInteractive as e5}from"@excalidraw/common";import $3 from"react";import j3 from"clsx";import{jsx as q3}from"react/jsx-runtime";var Xe=$3.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>q3("div",{className:j3("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as Ch,jsxs as t5}from"react/jsx-runtime";var Co=Q3.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:c=!1},d)=>{let m=Ee(),p=m.formFactor==="phone"&&!m.isLandscape;return Ch(Sh.Portal,{container:n,children:t5(Sh.Content,{ref:d,className:J3("focus-visible-none",e),"data-prevent-outside-click":!0,side:p?"bottom":"right",align:p?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:n??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:m.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onOpenAutoFocus:u=>{c&&m.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!e5(document.activeElement)&&n.focus(),r()},children:[Ch(Xe,{padding:3,style:o,children:t}),Ch(Sh.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 n5,useCallback as Ph}from"react";var fd=()=>document.querySelector(".excalidraw-wysiwyg"),Ed=()=>{let e=fd();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Hs=e=>{setTimeout(()=>{let n=fd();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},Us=(e,n,t,o)=>{n&&o&&o();let r=n&&t?Ed():null;e(),n&&t&&Hs(r)},K0=()=>{let[e,n]=n5(null),t=Ph(()=>{let i=Ed();n(i)},[]),o=Ph(()=>{setTimeout(()=>{let i=fd();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=Ph(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},X0=(e=100)=>{let n=fd();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import $0 from"clsx";import{useCallback as i5,useEffect as Mh,useRef as j0,useState as q0}from"react";import{KEYS as Ah,normalizeInputColor as a5}from"@excalidraw/common";import{isTransparent as o5,MAX_CUSTOM_COLORS_USED_IN_CANVAS as r5}from"@excalidraw/common";var or=({palette:e,color:n})=>{if(!n)return null;for(let[t,o]of Object.entries(e))if(Array.isArray(o)){let r=o.indexOf(n);if(r>-1)return{colorName:t,shade:r}}else if(o===n)return{colorName:t,shade:null};return null},Ws=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),kh=({color:e,palette:n})=>!Object.values(n).flat().includes(e),Z0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!o5(s)&&kh({color:s,palette:t})}),i=new Map;return r.forEach(a=>{let s=a[o[n]];i.has(s)?i.set(s,i.get(s)+1):i.set(s,1)}),[...i.entries()].sort((a,s)=>s[1]-a[1]).map(a=>a[0]).slice(0,r5)},sn=Je(null);import{Fragment as s5,jsx as Vs,jsxs as Dh}from"react/jsx-runtime";var J0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=Ee(),[a,s]=q0(e),[l,c]=q0(null),[d,m]=Ke(sn);Mh(()=>{s(e)},[e]);let p=i5(v=>{let y=v.toLowerCase().trim(),x=a5(y);x?(n(x),c(null)):y.length===0?c(null):/^#?[0-9a-f]+$/.test(y)?c(f("colorPicker.invalidHexLength")):c(f("colorPicker.invalidColor")),s(y)},[n]),u=j0(null),E=j0(null);Mh(()=>{u.current&&u.current.focus()},[d]);let[g,b]=Ke(Ut);return Mh(()=>()=>{b(null)},[b]),Dh("div",{className:"color-picker__input-label-container",children:[Dh("div",{className:$0("color-picker__input-label",{"has-error":l}),children:[Vs("div",{className:"color-picker__input-hash",children:"#"}),Vs("input",{ref:d==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,"aria-invalid":!!l,onChange:v=>{p(v.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e),c(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:v=>{v.key!==Ah.TAB&&(v.key===Ah.ESCAPE&&E.current?.focus(),v.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&Dh(s5,{children:[Vs("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Vs("div",{ref:E,className:$0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(v=>v?null:{keepOpenOnAlt:!1,onSelect:y=>n(y),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${Ah.I.toLocaleUpperCase()} or ${N("Alt")} `,children:Vi})]})]}),l&&Vs("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import Rh,{useEffect as Nh,useImperativeHandle as z5,useState as G5}from"react";import{EVENT as py}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as H5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as U5,KEYS as W5}from"@excalidraw/common";import f5 from"clsx";import{useEffect as E5,useRef as b5}from"react";import{applyDarkModeFilter as x5,THEME as y5}from"@excalidraw/common";import{isColorDark as l5}from"@excalidraw/common";import{jsxs as d5}from"react/jsx-runtime";var c5=({color:e,keyLabel:n,isShade:t=!1})=>d5("div",{className:"color-picker__button__hotkey-label",style:{color:l5(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),ji=c5;import{createContext as m5,useContext as p5,useEffect as u5,useMemo as Q0,useRef as ey,useState as h5}from"react";import{colorToHex as ty,isTransparent as g5}from"@excalidraw/common";var Kr="excalidraw-color-dnd-ghost",ny="excalidraw-color-dnd-active",oy=10,ry=100,iy=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=ty(e);return t!==null&&t===ty(n)},Lh=m5(null),ln=()=>p5(Lh),ay=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=h5(null),i=ey(null),a=ey({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=Q0(()=>{let l=null,c=()=>{l?.activated?r({color:l.color,origin:l.origin,overIndex:l.overIndex,duplicateIndex:l.duplicateIndex,slotSpan:l.slotSpan}):r(null)},d=()=>{let k=i.current;if(!k||!l)return!1;let L=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((W,G)=>Number(W.dataset.topPickIndex)-Number(G.dataset.topPickIndex));if(!L.length)return!1;l.slotRects=L.map(W=>W.getBoundingClientRect());let[F,K]=l.slotRects;l.slotSpan=K?K.left-F.left:F.width+4;let z=k.getBoundingClientRect(),U=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-U,right:z.right+U,top:z.top-14,bottom:z.bottom+14},!0},m=(k,L)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${L-l.ghostH/2}px)`)},p=(k,L,F,K)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==L)&&(l.ghostW=k,l.ghostH=L,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${L}px`,m(F,K))},u=(k,L)=>{if(!l)return;let{sourceRect:F,sourceEl:K,color:z}=l,U=document.createElement("div");U.className=Kr;let W=document.createElement("div");if(W.className=`${Kr}__swatch`,g5(z))W.classList.add("is-transparent");else{let G=getComputedStyle(K).backgroundColor;W.style.backgroundColor=G&&G!=="rgba(0, 0, 0, 0)"?G:z}U.appendChild(W),document.body.appendChild(U),l.ghost=U,l.ghostW=F.width,l.ghostH=F.height,U.style.width=`${F.width}px`,U.style.height=`${F.height}px`,m(k,L),requestAnimationFrame(()=>{l?.ghost===U&&U.classList.add(`${Kr}--lifted`)}),document.body.classList.add(ny),l.activated=!0,c()},E=(k,L)=>{if(!l?.hitRect)return;let{hitRect:F,slotRects:K}=l,z=null,U=null;if(k>=F.left&&k<=F.right&&L>=F.top&&L<=F.bottom){let W=0,G=1/0;if(K.forEach((ie,me)=>{let B=Math.abs(k-(ie.left+ie.width/2));B<G&&(G=B,W=me)}),l.origin.kind==="swatch"){let ie=a.current.picks.findIndex(me=>iy(me,l.color));ie!==-1?U=ie:z=W}else z=W}if(z!==l.overIndex||U!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=U;let{ghost:W}=l;W&&(W.classList.toggle(`${Kr}--over`,z!==null),W.classList.toggle(`${Kr}--blocked`,U!==null)),c()}if(z!==null){let W=l.slotRects[z];p(W.width,W.height,k,L)}else p(l.sourceRect.width,l.sourceRect.height,k,L)},g=k=>{if(!l?.ghost)return;let{ghost:L}=l;l.ghost=null,L.classList.add(`${Kr}--dropping`);let F=k.rect;F&&(L.style.width=`${F.width}px`,L.style.height=`${F.height}px`,L.style.transform=`translate(${F.left}px, ${F.top}px)`),window.setTimeout(()=>{L.classList.add(`${Kr}--fade`)},160),window.setTimeout(()=>{L.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let L=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let F of L)F.style.transition="none",F.style.transform="none";k.offsetWidth;for(let F of L)F.style.transition=""},v=()=>{let k=L=>{L.preventDefault(),L.stopPropagation()};window.addEventListener("click",k,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener("click",k,{capture:!0})},100)},y=()=>{window.removeEventListener("pointermove",C,!0),window.removeEventListener("pointerup",P,!0),window.removeEventListener("pointercancel",M,!0),window.removeEventListener("keydown",D,!0)},x=()=>{y(),document.body.classList.remove(ny),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},I=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},T=(k,L)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,L),E(k,L)}},C=k=>{if(!(!l||k.pointerId!==l.pointerId)){if(l.lastX=k.clientX,l.lastY=k.clientY,!l.activated){if(Math.hypot(k.clientX-l.startX,k.clientY-l.startY)<oy){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let L=performance.now()-l.startTime;if(L<ry){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=oy&&T(l.lastX,l.lastY))},ry-L));return}if(T(k.clientX,k.clientY),!l?.activated)return}k.preventDefault(),m(k.clientX,k.clientY),E(k.clientX,k.clientY)}},P=k=>{if(!l||k.pointerId!==l.pointerId)return;if(!l.activated){x();return}k.preventDefault(),k.stopPropagation(),v();let{overIndex:L,origin:F,color:K,slotRects:z}=l,{picks:U,onPicksChange:W}=a.current;if(b(),L!==null){if(F.kind==="swatch"){if(!U.some(G=>iy(G,K))){let G=[...U];G[L]=K,W(G)}}else if(F.index!==L){let G=[...U],[ie]=G.splice(F.index,1);G.splice(L,0,ie),W(G)}g({rect:z[L]})}else g({rect:l.sourceRect});x()},M=k=>{l&&k.pointerId===l.pointerId&&I(!0)},D=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),I(!0))};return{begin:(k,L,F)=>{!a.current.enabled||l||k.button!==0||!L||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:L,origin:F,sourceEl:k.currentTarget,sourceRect:k.currentTarget.getBoundingClientRect(),activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener("pointermove",C,!0),window.addEventListener("pointerup",P,!0),window.addEventListener("pointercancel",M,!0),window.addEventListener("keydown",D,!0))},destroy:()=>I(!1)}},[]);return u5(()=>()=>s.destroy(),[s]),Q0(()=>({dragState:o,startSwatchDrag:(l,c)=>s.begin(l,c,{kind:"swatch"}),startPickDrag:(l,c,d)=>s.begin(l,d,{kind:"pick",index:c}),setStripEl:l=>{i.current=l}}),[o,s])};import{jsx as _h,jsxs as w5}from"react/jsx-runtime";var sy=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=Ke(sn),s=ln(),l=b5(null);return E5(()=>{l.current&&l.current.focus()},[t,i]),_h("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=x5(c,e===y5.DARK);return w5("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:f5("color-picker__button color-picker__button--large has-outline",{active:t===c,"is-transparent":c==="transparent"||!c}),onClick:()=>{o(c),a("custom")},onPointerDown:s?p=>s.startSwatchDrag(p,c):void 0,title:c,"aria-label":r,style:{"--swatch-color":m},children:[_h("div",{className:"color-picker__button-outline"}),_h(ji,{color:m,keyLabel:d+1})]},d)})})};import v5 from"clsx";import{useEffect as I5,useRef as T5}from"react";import{applyDarkModeFilter as S5,isColorDark as C5,THEME as P5}from"@excalidraw/common";import{jsx as bd,jsxs as M5}from"react/jsx-runtime";var k5=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=or({color:t,palette:n}),[l,c]=Ke(sn),d=ln(),m=T5(null);return I5(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),bd("div",{className:"color-picker-content--default",children:Object.entries(n).map(([p,u],E)=>{let g=(Array.isArray(u)?u[r]:u)||"transparent";if(a?.includes(g))return bd("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=Ws[E],v=S5(g,e===P5.DARK),y=f(`colors.${p.replace(/\d+/,"")}`,null,"");return M5("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:v5("color-picker__button color-picker__button--large",{"has-outline":!C5(g,255),active:s?.colorName===p,"is-transparent":g==="transparent"||!g}),onClick:()=>{o(g),c("baseColors")},onPointerDown:d?x=>d.startSwatchDrag(x,g):void 0,title:`${y}${g.startsWith("#")?` ${g}`:""} \u2014 ${b}`,"aria-label":`${y} \u2014 ${b}`,style:g?{"--swatch-color":v}:void 0,"data-testid":`color-${p}`,children:[bd("div",{className:"color-picker__button-outline"}),i&&bd(ji,{color:v,keyLabel:b})]},p)})})},ly=k5;import{jsx as D5}from"react/jsx-runtime";var A5=({children:e})=>D5("div",{className:"color-picker__heading",children:e}),qi=A5;import L5 from"clsx";import{useEffect as _5,useRef as R5}from"react";import{applyDarkModeFilter as N5,THEME as B5}from"@excalidraw/common";import{jsx as Ys,jsxs as cy}from"react/jsx-runtime";var dy=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=or({color:n||"transparent",palette:o}),[a,s]=Ke(sn),l=ln(),c=R5(null);if(_5(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return Ys("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=N5(u,e===B5.DARK);return cy("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:L5("color-picker__button color-picker__button--large",{active:E===m}),"aria-label":"Shade",title:`${d} - ${E+1}`,style:u?{"--swatch-color":g}:void 0,onClick:()=>{t(u),s("shades")},onPointerDown:l?b=>l.startSwatchDrag(b,u):void 0,children:[Ys("div",{className:"color-picker__button-outline"}),r&&Ys(ji,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return cy("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Ys("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Ys("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:f("colorPicker.noShades")})]})};import{COLORS_PER_ROW as Ji,COLOR_PALETTE as F5,KEYS as Ks}from"@excalidraw/common";var xd=(e,n,t)=>{let o=Math.ceil(t/Ji);switch(n=n??-1,e){case"ArrowLeft":{let r=n-1;return r<0?t-1:r}case"ArrowRight":return(n+1)%t;case"ArrowDown":{let r=n+Ji;return r>=t?n%Ji:r}case"ArrowUp":{let r=n-Ji,i=r<0?Ji*o+r:r;return i>=t?void 0:i}}},O5=({e,colorObj:n,onChange:t,palette:o,customColors:r,setActiveColorPickerSection:i,activeShade:a,excludedColors:s})=>{if(n?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(o[n.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&r[Number(e.key)-1])return t(r[Number(e.key)-1]),i("custom"),!0;if(Ws.includes(e.key)){let l=Ws.indexOf(e.key),c=Object.keys(o)[l],d=o[c],m=Array.isArray(d)?d[a]:d;return m==null||s?.includes(m)||(t(m),i("baseColors")),!0}return!1},my=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d,excludedColors:m})=>{if(e[Ks.CTRL_OR_CMD])return!1;if(e.key===Ks.ESCAPE)return d(e),!0;if(e.key===Ks.ALT)return c(!0),!0;if(e.key===Ks.I)return c(),!0;let p=or({color:o,palette:t});if(e.key===Ks.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[I,T])=>(T&&x.push(I),x),[]),g=E.indexOf(n),b=e.shiftKey?-1:1,v=g+b>E.length-1?0:g+b<0?E.length-1:g+b,y=E[v];return y&&a(y),y==="custom"?r(i[0]):y==="baseColors"&&(Object.entries(t).find(([I,T])=>Array.isArray(T)?T.includes(o):T===o?I:null)||r(F5.black)),e.preventDefault(),e.stopPropagation(),!0}if(O5({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:l,excludedColors:m}))return!0;if(n==="shades"&&p){let{shade:u}=p,E=xd(e.key,u,Ji);if(E!==void 0)return r(t[p.colorName][E]),!0}if(n==="baseColors"&&p){let{colorName:u}=p,E=Object.keys(t),g=E.indexOf(u),b=xd(e.key,g,E.length),v=0;for(;b!==void 0&&v++<E.length;){let y=t[E[b]],x=Array.isArray(y)?y[l]:y;if(!m?.includes(x))break;b=xd(e.key,b,E.length)}if(b!==void 0){let y=E[b],x=t[y];return r(Array.isArray(x)?x[l]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=xd(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as Po,jsxs as yd}from"react/jsx-runtime";var uy=Rh.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:s,showTitle:l,onEyeDropperToggle:c,onEscape:d,showHotKey:m=!0,excludedColors:p},u)=>{let E=l?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=Rh.useState(()=>o==="canvasBackground"?[]:Z0(r,o,i)),[b,v]=Ke(sn),y=ln(),x=or({color:n,palette:i});Nh(()=>{if(!b){let P=!!n&&kh({color:n,palette:i}),M=P&&!g.includes(n);v(M?null:P?"custom":x?.shade!=null?"shades":"baseColors")}},[b,n,i,v,x,g]);let[I,T]=G5(x?.shade??(o==="elementBackground"?H5:U5));Nh(()=>{x?.shade!=null&&T(x.shade);let P=M=>{M.key===W5.ALT&&c(!1)};return document.addEventListener(py.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(py.KEYUP,P,{capture:!0})}},[x,c]);let C=Rh.useRef(null);return z5(u,()=>C.current),Nh(()=>{C?.current?.focus()},[]),Po("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:yd("div",{ref:C,onKeyDown:P=>{my({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:v,updateData:a,activeShade:I,onEscape:d,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&Po("div",{className:"color-picker__title",children:E}),!!g.length&&yd("div",{children:[Po(qi,{children:f("colorPicker.mostUsedCustomColors")}),Po(sy,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),yd("div",{children:[Po(qi,{children:f("colorPicker.colors")}),Po(ly,{theme:e,color:n,palette:i,onChange:t,activeShade:I,showHotKey:m,excludedColors:p})]}),yd("div",{children:[Po(qi,{children:f("colorPicker.shades")}),Po(dy,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,y&&Po("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import hy from"clsx";import{ContextMenu as Xs}from"radix-ui";import{applyDarkModeFilter as V5,COLOR_OUTLINE_CONTRAST_THRESHOLD as Y5,DEFAULT_CANVAS_BACKGROUND_PICKS as K5,DEFAULT_ELEMENT_BACKGROUND_PICKS as X5,DEFAULT_ELEMENT_STROKE_PICKS as Z5,isColorDark as $5,THEME as j5}from"@excalidraw/common";import{jsx as rr,jsxs as gy}from"react/jsx-runtime";var fy=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=ln(),l=s?.dragState??null,{container:c}=Oe(),d;if(t==="elementStroke"&&(d=Z5),t==="elementBackground"&&(d=X5),t==="canvasBackground"&&(d=K5),r&&(d=r),!d)return console.error("Invalid type for TopPicks"),null;let m=u=>{if(!l||l.origin.kind!=="pick"||l.overIndex===null)return 0;let E=l.origin.index,g=l.overIndex;if(E===g)return 0;let b=u;return u===E?b=g:(u>E&&(b-=1),b>=g&&(b+=1)),(b-u)*l.slotSpan},p=gy("div",{className:hy("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&rr("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:rr("rect",{})}),d.map((u,E)=>{let g=m(E),b=V5(u,e===j5.DARK);return rr("button",{className:hy("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!$5(u,Y5),"is-dnd-source":l?.origin.kind==="pick"&&l.origin.index===E,"is-dnd-target":l?.origin.kind==="swatch"&&l.overIndex===E,"is-dnd-duplicate":l?.duplicateIndex===E}),style:{"--swatch-color":b,transform:g?`translateX(${g}px)`:void 0},type:"button",title:u,onClick:()=>n(u),onPointerDown:s?v=>s.startPickDrag(v,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:rr("div",{className:"color-picker__button-outline"})},u)})]});return i?gy(Xs.Root,{children:[rr(Xs.Trigger,{asChild:!0,children:p}),rr(Xs.Portal,{container:c,children:rr(Xs.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:rr(Xs.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as cn,jsxs as wd}from"react/jsx-runtime";var r4=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=vy,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=Oe(),m=mt(),p=m!=="full",u=m==="mobile",[,E]=Ke(sn),[g,b]=Ke(Ut),v=wd("div",{children:[cn(qi,{children:f("colorPicker.hexCode")}),cn(J0,{color:n||"",label:o,onChange:I=>{t(I)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),y=wy(null),x=()=>{y.current?.focus()};return cn(Co,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:I=>{if(I.target instanceof HTMLElement&&I.target.closest(".color-picker__context-menu")){I.preventDefault();return}n4(I.target)||(I.target instanceof HTMLElement&&I.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),I.preventDefault()},onPointerDownOutside:I=>{g&&I.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let I=document.querySelector(".excalidraw-wysiwyg");I&&I.focus()},0)},children:i?cn(uy,{ref:y,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:I=>{let T=l.editingTextElement?Ed():null;t(I),l.editingTextElement&&T&&Hs(T)},onEyeDropperToggle:I=>{b(T=>I?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):I===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:I=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!u,children:v}):v})},i4=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",a4=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=mt(),l=s!=="full",c=s==="mobile",d=ln(),m=n?Q5(n,o===o4.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&X0(),i()};return wd(xy.Trigger,{type:"button",className:yy("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!by(n,Ey),"compact-sizing":l,"mobile-border":c}),"aria-label":e,style:m?{"--swatch-color":m}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:p,onPointerDown:d?u=>d.startSwatchDrag(u,n):void 0,children:[cn("div",{className:"color-picker__button-outline",children:!n&&r1}),l&&n&&r==="stroke"&&cn("div",{className:"color-picker__button-background",children:cn("span",{style:{color:m&&by(m,Ey)?"#fff":"#111"},children:T0})})]})},s4=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=vy,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=wy(l.openPopup);J5(()=>{m.current=l.openPopup},[l.openPopup]);let u=mt()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?t4:e4),v=ay({enabled:E,picks:b,onPicksChange:y=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:y}})}});return cn(Lh.Provider,{value:E?v:null,children:wd("div",{role:"dialog","aria-modal":"true",className:yy("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&cn(fy,{theme:l.theme,activeColor:n,onChange:y=>{t(y),i4(l.openPopup)&&l.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:g?.length?g:a,isCustomized:!!g?.length,onReset:E&&d?()=>{s({colorTopPicks:{...l.colorTopPicks,[d]:null}})}:void 0}),!u&&cn(pd,{}),wd(xy.Root,{open:l.openPopup===e,onOpenChange:y=>{y&&s({openPopup:e})},children:[cn(a4,{color:n,label:o,type:e,theme:l.theme,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!l.editingTextElement,onToggle:()=>{l.openPopup===e?s({openPopup:null}):l.openPopup?s({openPopup:e}):s({openPopup:e})}}),l.openPopup===e&&cn(r4,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},l4=(e,n)=>e.appState.openPopup===e.type||n.appState.openPopup===n.type?!1:e.type===n.type&&e.color===n.color&&e.label===n.label&&e.appState.openPopup===n.appState.openPopup&&e.palette===n.palette&&e.topPicks===n.topPicks&&e.excludedColors===n.excludedColors&&e.customizableTopPicks===n.customizableTopPicks&&e.appState.theme===n.appState.theme&&e.appState.colorTopPicks===n.appState.colorTopPicks&&!!e.appState.editingTextElement==!!n.appState.editingTextElement,Qi=q5(s4,l4);import{Popover as B4}from"radix-ui";import F4 from"clsx";import O4,{useCallback as z4,useMemo as G4}from"react";import{FONT_FAMILY as zh}from"@excalidraw/common";import C4,{useMemo as sr,useState as P4,useRef as Cy,useEffect as Py,useCallback as ky}from"react";import{arrayToList as k4,debounce as M4,FONT_FAMILY as lr,getFontFamilyString as A4}from"@excalidraw/common";import c4 from"clsx";import d4 from"react";import{jsx as m4,jsxs as p4}from"react/jsx-runtime";var vd=d4.forwardRef(({className:e,placeholder:n,onChange:t},o)=>p4("div",{className:c4("QuickSearch__wrapper",e),children:[oo,m4("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import u4 from"clsx";import{Children as h4}from"react";import{jsx as Iy}from"react/jsx-runtime";var Id=({className:e,placeholder:n,children:t})=>{let o=!h4.count(t);return Iy("div",{className:u4("ScrollableList__wrapper",e),role:"menu",children:o?Iy("div",{className:"empty",children:n}):t})};import{jsx as g4,jsxs as f4}from"react/jsx-runtime";var Ty=({children:e,className:n="",style:t,title:o})=>f4("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&g4("p",{className:"dropdown-menu-group-title",children:o}),e]}),Zs=Ty;Ty.displayName="DropdownMenuGroup";import{THEME as T4}from"@excalidraw/common";import{DropdownMenu as S4}from"radix-ui";import E4,{useContext as b4}from"react";import{composeEventHandlers as x4}from"@excalidraw/common";var Bh=E4.createContext({}),ir=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),Td=e=>{let n=b4(Bh);return x4(e,t=>{n.onSelect?.(t)})};import{jsx as y4}from"react/jsx-runtime";var $s=({children:e,...n})=>y4("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as v4,jsx as js,jsxs as I4}from"react/jsx-runtime";var w4=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=Ee();return I4(v4,{children:[n&&js("div",{className:"dropdown-menu-item__icon",children:n}),js("div",{style:e,className:"dropdown-menu-item__text",children:js($s,{children:o})}),r&&js("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&js("div",{className:"dropdown-menu-item__shortcut",children:t})]})},ar=w4;import{jsx as Sd}from"react/jsx-runtime";var Fh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=Td(s);return Sd(S4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Sd("button",{...l,value:t,className:ir(i,a),title:l.title??l["aria-label"],children:Sd(ar,{icon:e,shortcut:r,badge:n,children:o})})})};Fh.displayName="DropdownMenuItem";var ea={GREEN:"green",RED:"red",BLUE:"blue"},Cd=({type:e=ea.BLUE,children:n})=>{let{theme:t}=ro(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===T4.LIGHT?"1.5px solid white":"none"};switch(e){case ea.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ea.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case ea.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Sd("div",{className:"DropDownMenuItemBadge",style:o,children:n})};Cd.displayName="DropdownMenuItemBadge";Fh.Badge=Cd;var Jt=Fh;import{KEYS as ta}from"@excalidraw/common";var Sy=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[ta.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===ta.F)return n.current?.focus(),!0;if(e.key===ta.ESCAPE)return r(),!0;if(e.key===ta.ENTER)return t?.value&&i(t.value),!0;if(e.key===ta.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===ta.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as ko,jsxs as _4}from"react/jsx-runtime";var D4=e=>{switch(e){case lr.Excalifont:case lr.Virgil:return Qn;case lr.Nunito:case lr.Helvetica:return Os;case lr["Lilita One"]:return K1;case lr["Comic Shanns"]:case lr.Cascadia:return Jc;default:return Os}},L4=(e,n)=>Object.entries(lr).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",My=C4.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=Oe(),l=St(),{fonts:c}=l,{showDeprecatedFonts:d}=Ln(),m=mt(),[p,u]=P4(""),E=Cy(null),g=sr(()=>Array.from(Io.registered.entries()).filter(([k,{metadata:L}])=>!L.private&&!L.fallback).map(([k,{metadata:L,fontFaces:F}])=>{let K={value:k,icon:D4(k),text:L4(k,F)};return L.deprecated&&Object.assign(K,{deprecated:L.deprecated,badge:{type:ea.RED,placeholder:f("fontList.badge.old")}}),K}).sort((k,L)=>k.text.toLowerCase()>L.text.toLowerCase()?1:-1),[]),b=sr(()=>new Set(c.getSceneFamilies()),[e]),v=sr(()=>g.filter(k=>b.has(k.value)),[g,b]),y=sr(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=sr(()=>k4([...v,...y].filter(k=>k.text?.toLowerCase().includes(p))),[v,y,p]),I=sr(()=>{let k;return n?k=x.find(L=>L.value===n):e&&(k=x.find(L=>L.value===e)),!k&&p&&(x[0]?.value?o(x[0].value):r()),k},[n,e,p,x,o,r]),T=ky(k=>{let L=null;if(l.state.editingTextElement){let F=document.querySelector(".excalidraw-wysiwyg");F&&(L={start:F.selectionStart,end:F.selectionEnd})}t(k),l.state.editingTextElement&&L&&setTimeout(()=>{let F=document.querySelector(".excalidraw-wysiwyg");F&&L&&(F.focus(),F.selectionStart=L.start,F.selectionEnd=L.end)},0)},[t,l.state.editingTextElement]),C=ky(k=>{Sy({event:k,inputRef:E,hoveredFont:I,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[I,x,T,o,a]);Py(()=>(i(),()=>{a()}),[]);let P=sr(()=>x.filter(k=>b.has(k.value)),[x,b]),M=sr(()=>x.filter(k=>!b.has(k.value)),[x,b]),D=({font:k,order:L})=>{let F=Cy(null),K=k.value===I?.value,z=k.value===e;return Py(()=>{K&&(L===0?F.current?.scrollIntoView?.({block:"end"}):F.current?.scrollIntoView?.({block:"nearest"}))},[K,L]),ko("button",{ref:F,type:"button",value:k.value,className:ir("",z,K),title:k.text,tabIndex:z?0:-1,onClick:U=>{T(Number(U.currentTarget.value))},onMouseMove:()=>{I?.value!==k.value&&o(k.value)},children:ko(ar,{icon:k.icon,badge:k.badge&&ko(Cd,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:A4({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(ko(Zs,{title:f("fontList.sceneFonts"),children:P.map((k,L)=>ko(D,{font:k,order:L},k.value))},"group_1")),M.length&&_.push(ko(Zs,{title:f("fontList.availableFonts"),children:M.map((k,L)=>ko(D,{font:k,order:L+P.length},k.value))},"group_2")),_4(Co,{className:"properties-content",container:s,style:{width:"15rem"},onClose:()=>{a(),l.state.editingTextElement&&setTimeout(()=>{let k=document.querySelector(".excalidraw-wysiwyg");k&&k.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!l.state.editingTextElement,children:[m==="full"&&ko(vd,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:M4(u,20)}),ko(Id,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,n)=>e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as R4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as N4}from"@excalidraw/common";import{jsx as Oh}from"react/jsx-runtime";var Ay=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=We(),r=t?{...N4,width:"2rem",height:"2rem"}:{};return Oh(R4.Trigger,{asChild:!0,children:Oh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:Oh($,{type:"toggle",icon:Dn,title:f("labels.showFonts"),"aria-label":f("labels.showFonts"),className:"standalone properties-trigger","data-testid":"font-family-show-fonts",checked:n,onSelect:()=>{o(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as qs,jsxs as Dy}from"react/jsx-runtime";var Ly=[{value:zh.Excalifont,icon:Qn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:zh.Nunito,icon:Os,text:f("labels.normal"),testId:"font-family-normal"},{value:zh["Comic Shanns"],icon:Jc,text:f("labels.code"),testId:"font-family-code"}],Cte=new Set(Ly.map(e=>e.value));var _y=O4.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=G4(()=>Ly,[]),c=z4(d=>{d&&o(d)},[o]);return Dy("div",{role:"dialog","aria-modal":"true",className:F4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&qs("div",{className:"buttonList",children:qs(qt,{type:"button",options:l,value:n,onClick:c})}),!s&&qs(pd,{}),Dy(B4.Root,{open:e,onOpenChange:a,children:[qs(Ay,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&qs(My,{selectedFontFamily:n,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,n)=>e.isOpened===n.isOpened&&e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as Gh}from"radix-ui";import V4 from"clsx";import Fy,{useEffect as Y4,useMemo as K4}from"react";import{isArrowKey as X4,KEYS as Mo}from"@excalidraw/common";import{jsx as H4}from"react/jsx-runtime";var Pd=({className:e,icon:n,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:n});import{Fragment as W4,jsx as Ry,jsxs as Ny}from"react/jsx-runtime";var U4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>Ny(W4,{children:[Ny("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Ry(Pd,{icon:n?y0:td})]}),n&&Ry("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),Js=U4;import{jsx as io,jsxs as Md}from"react/jsx-runtime";var Z4=Je(!1),kd=4,$4="default",j4=e=>e.flatMap(n=>n.options),By=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},q4=(e,n)=>e.some(t=>t.options.some(n)),J4=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/kd)},(t,o)=>n.options.slice(o*kd,o*kd+kd)));function Q4({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=Oe(),[s,l]=Ke(Z4),c=[...e,...n],d=j4(c),m=J4([...e,...s?n:[]]),p=g=>{let b=d.find(v=>v.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===Mo.TAB){let v=d.findIndex(x=>x.value===t),y=g.shiftKey?(d.length+v-1)%d.length:(v+1)%d.length;r(d[y].value)}else if(X4(g.key)){let v=Jn().rtl,y=d.findIndex(x=>x.value===t);if(y!==-1){let x=d.length,I=y;switch(g.key){case(v?Mo.ARROW_LEFT:Mo.ARROW_RIGHT):I=(y+1)%x;break;case(v?Mo.ARROW_RIGHT:Mo.ARROW_LEFT):I=(x+y-1)%x;break;case Mo.ARROW_DOWN:{let T=m.findIndex(P=>P.some(M=>M.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(T+1)%m.length],D=M[Math.min(P,M.length-1)]??d[y];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case Mo.ARROW_UP:{let T=m.findIndex(P=>P.some(M=>M.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(m.length+T-1)%m.length],D=M[Math.min(P,M.length-1)]??d[y];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[I].value)}g.preventDefault()}else(g.key===Mo.ESCAPE||g.key===Mo.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};Y4(()=>{q4(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>io("div",{className:"picker-content",children:g.map(b=>Md("button",{type:"button",className:V4("picker-option",{active:t===b.value}),onClick:()=>{r(b.value)},title:b.keyBinding?`${b.text} \u2014 ${b.keyBinding.toUpperCase()}`:b.text,"aria-label":b.text||"none","aria-keyshortcuts":b.keyBinding||void 0,ref:v=>{t===b.value&&setTimeout(()=>{v?.focus()},0)},children:[b.icon,b.keyBinding&&io("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,v)=>b.name===$4?io(Fy.Fragment,{children:u(b.options)},`${b.name}-${v}`):Md("div",{className:"picker-section",children:[io("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${v}`));return io(Gh.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:p,collisionBoundary:a??void 0,children:Md("div",{className:"picker-sections",children:[E(e),n.length>0&&io(Js,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:io("div",{className:"picker-sections",children:E(n)})})]})})}function Hh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=Fy.useState(!1),s=K4(()=>By(t,l=>l.value===e)??By(o??[],l=>l.value===e),[t,o,e]);return io("div",{children:Md(Gh.Root,{open:i,onOpenChange:l=>a(l),children:[io(Gh.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&io(Q4,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import Oy,{useEffect as e6}from"react";import{jsx as Uh,jsxs as zy}from"react/jsx-runtime";var Gy=({label:e,value:n,onChange:t,min:o=0,max:r=100,step:i=10,minLabel:a=o,hasCommonValue:s=!0,testId:l})=>{let c=Oy.useRef(null),d=Oy.useRef(null);return e6(()=>{if(c.current&&d.current){let m=c.current,p=d.current,u=m.offsetWidth,E=parseFloat(getComputedStyle(m).getPropertyValue("--slider-thumb-size"))||16,g=(n-o)/(r-o||1)*100,b=g/100*(u-E)+E/2;p.style.left=`${b}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${g}%, var(--button-bg) ${g}%, var(--button-bg) 100%)`}},[r,o,n]),zy("label",{className:"control-label",children:[e,zy("div",{className:"range-wrapper",children:[Uh("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:c,type:"range",min:o,max:r,step:i,onChange:m=>{t(+m.target.value)},value:n,className:"range-input","data-testid":l}),Uh("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),Uh("div",{className:"zero-label",children:a})]})]})};import{Fragment as Bd,jsx as ee,jsxs as xt}from"react/jsx-runtime";var jy=.1,Zr=e=>{let n=S6(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Ct=(e,n,t,o=!1)=>{let r=Xh(de(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(b6(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},ut=function(e,n,t,o,r){let i=n.state.editingTextElement,a=Zy(e),s=null;if(i&&(s=t(i)),!s)if(Re(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=f6(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},C6=(e,n,t)=>y6(n)||!n.autoResize?n:t.mutateElement(n,{x:e.textAlign==="left"?e.x:e.x+(e.width-n.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-n.height)/2}),Zh=(e,n,t,o,r)=>{let i=new Set,a=Ct(e,n,s=>{if(Wt(s)){let l=o(s);i.add(l);let c=st(s,{fontSize:l});return Qs(c,t.scene.getContainerElement(s),t.scene),c=C6(s,c,t.scene),c}return s},!0);return de(e,n,{includeBoundTextElement:!0}).forEach(s=>{Wt(s)&&x6(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:ot.IMMEDIATELY}},P6=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Ct(e,n,o=>v6(o.type)?st(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?ot.IMMEDIATELY:ot.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Zr(o);return xt(Bd,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.stroke")}),ee(Qi,{topPicks:s6,palette:a6,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:ut(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),k6=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:ot.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!g6(t.currentItemBackgroundColor)&&i.every(s=>Vy(s)&&E6(s.points))){let s=Xh(i);r=e.map(l=>s.has(l.id)&&Vy(l)?st(l,{backgroundColor:t.currentItemBackgroundColor,...T6(l,!0)}):l)}else r=Ct(e,n,s=>st(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:ot.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=Zr(o);return xt(Bd,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(Qi,{topPicks:i6,palette:Ky,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:ut(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),Nd=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:ot.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=Zr(o);return xt(Bd,{children:[r==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(Qi,{topPicks:o6,palette:Ky,excludedColors:[r6.transparent],customizableTopPicks:"bucketFill",type:"elementBackground",label:f("labels.background"),color:o.bucketFill.getBucketFillBackgroundColor(n.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:n,updateData:t})]})}}),M6=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(Ue("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Ct(e,n,r=>st(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=de(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return xt("fieldset",{children:[ee("legend",{children:f("labels.fill")}),ee("div",{className:"buttonList",children:ee(qt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?h1:g1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:f1,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:E1,testId:"fill-solid"}],value:ut(e,o,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:n.currentItemFillStyle),onClick:(a,s)=>{let l=s.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(l)}})})]})}}),A6=e=>m6.find(n=>Xy(e.type,n)===e.strokeWidth)??null,D6=(e,n)=>Xy(e.type,n),L6=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(Rd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Ct(e,n,o=>st(o,{strokeWidth:D6(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>xt("fieldset",{children:[ee("legend",{children:f("labels.strokeWidth")}),ee("div",{className:"buttonList",children:ee(qt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:nh,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:b1,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:x1,testId:"strokeWidth-bold"}],value:ut(e,o,A6,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),_6=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>st(o,{seed:p6(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>xt("fieldset",{children:[ee("legend",{children:f("labels.sloppiness")}),ee("div",{className:"buttonList",children:ee(qt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:v1},{value:1,text:f("labels.artist"),icon:I1},{value:2,text:f("labels.cartoonist"),icon:T1}],value:ut(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),R6=O({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Ct(e,n,r=>r.type!=="freedraw"?r:st(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:ot.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=ut(e,o,a=>a.strokeOptions?.variability,a=>a.type==="freedraw",a=>a?null:n.currentItemStrokeVariability)??n.currentItemStrokeVariability;if(r?.cycle){let a=i==="variable";return ee($,{type:"button",icon:a?rh:oh,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return xt("fieldset",{children:[ee("legend",{children:f("labels.pressure")}),ee("div",{className:"buttonList",children:ee(qt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:oh},{value:"variable",text:f("labels.pressure_variable"),icon:rh}],value:i,onChange:a=>t(a)})})]})}}),Lne=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>st(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>xt("fieldset",{children:[ee("legend",{children:f("labels.strokeStyle")}),ee("div",{className:"buttonList",children:ee(qt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:nh},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:y1},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:w1}],value:ut(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),N6=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>st(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=ut(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return ee(Gy,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),B6=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>Zh(e,n,o,()=>(Rd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Zr(o);return xt("fieldset",{children:[ee("legend",{children:f("labels.fontSize")}),ee("div",{className:"buttonList",children:ee(qt,{group:"font-size",options:[{value:Dd.sm,text:f("labels.small"),icon:U1,testId:"fontSize-small"},{value:Dd.md,text:f("labels.medium"),icon:W1,testId:"fontSize-medium"},{value:Dd.lg,text:f("labels.large"),icon:V1,testId:"fontSize-large"},{value:Dd.xl,text:f("labels.veryLarge"),icon:Y1,testId:"fontSize-veryLarge"}],value:ut(e,o,a=>{if(Wt(a))return a.fontSize;let s=cr(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Wt(a)||cr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||c6),onChange:a=>{Us(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),$h=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Wr,trackEvent:!1,perform:(e,n,t,o)=>Zh(e,n,o,r=>Math.round(1/(1+jy)*r.fontSize)),keyTest:e=>e[na.CTRL_OR_CMD]&&e.shiftKey&&(e.key===na.CHEVRON_LEFT||e.key===na.COMMA)}),jh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Wr,trackEvent:!1,perform:(e,n,t,o)=>Zh(e,n,o,r=>Math.round(r.fontSize*(1+jy))),keyTest:e=>e[na.CTRL_OR_CMD]&&e.shiftKey&&(e.key===na.CHEVRON_RIGHT||e.key===na.PERIOD)}),F6=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,n,t,o)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...s}=t;if(i)return{elements:Ct(e,n,g=>{let b=r?.get(g.id);return b?st(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:ot.NEVER};Rd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=ot.EVENTUALLY,m,p=!1;if(l)m=l,d=ot.IMMEDIATELY;else if(c){m=c,d=ot.EVENTUALLY;let E=de(e,n,{includeBoundTextElement:!0}).filter(g=>Wt(g));if(E.length>200)p=!0;else{let g=0,b=0;for(;g<E.length&&b<5e3;){let v=E[g];b+=v?.originalText.length||0,g++}b>5e3&&(p=!0)}}let u={appState:{...n,...s},captureUpdate:d};if(m&&!p){let E=new Map,g=new Set,b=!1,v=Array.from(Io.loadedFontsCache.values()),y=Object.entries(d6).find(([T,C])=>C===m)?.[0];c&&y&&v.some(T=>T.startsWith(y))&&(b=!0),Object.assign(u,{elements:Ct(e,n,T=>{if(Wt(T)&&(T.fontFamily!==m||l)){let C=st(T,{fontFamily:m,lineHeight:h6(m)}),P=r?.get(T.containerId||"")||{},M=o.scene.getContainerElement(T);return a&&M&&P&&o.scene.mutateElement(M,{...P}),b||(g=new Set([...g,...Array.from(C.originalText)])),E.set(C,M),C}return T},!0)});let x=`10px ${u6({fontFamily:m})}`,I=Array.from(g.values()).join();if(b||window.document.fonts.check(x,I))for(let[T,C]of E)Qs(T,C,o.scene);else window.document.fonts.load(x,I).then(T=>{for(let[C,P]of E){let M=o.scene.getElement(C.id),D=P?o.scene.getElement(P.id):null;M&&Qs(M,D,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=Vh(new Map),i=Vh(null),[a,s]=n6({}),l=Vh(!0),{stylesPanelMode:c,isCompact:d}=Zr(t),m=Kh(()=>{let p=(u,E)=>ut(u,t,g=>{if(Wt(g))return g.fontFamily;let b=cr(g,E);return b?b.fontFamily:null},g=>Wt(g)||cr(g,E)!==null,g=>g?null:n.currentItemFontFamily||l6);return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?p(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?p(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]);return Wh(()=>{i.current=m},[m]),Wh(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),Wh(()=>(l.current=!1,()=>{l.current=!0}),[]),xt(Bd,{children:[c==="full"&&ee("legend",{children:f("labels.fontFamily")}),ee(_y,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{Us(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:p}),r.current.clear()},d,!!n.editingTextElement)},onHover:p=>{s({currentHoveredFontFamily:p,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:p=>{if(p){r.current.clear();let{editingTextElement:u}=n;if(u?.type==="text"){let E=t.scene.getElement(u.id);r.current.set(u.id,st(E||u,{},!0))}else{let E=de(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,st(g,{},!0))}s({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s({...u}),r.current.clear(),d&&n.editingTextElement&&Hs(null)}}})]})}}),O6=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Wt(r)){let i=st(r,{textAlign:t});return Qs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=Zr(o);return xt("fieldset",{children:[ee("legend",{children:f("labels.textAlign")}),ee("div",{className:"buttonList",children:ee(qt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:X1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:Z1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:$1,testId:"align-right"}],value:ut(e,o,s=>{if(Wt(s))return s.textAlign;let l=cr(s,i);return l?l.textAlign:null},s=>Wt(s)||cr(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{Us(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),z6=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Wt(r)){let i=st(r,{verticalAlign:t});return Qs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=Zr(o);return ee("fieldset",{children:ee("div",{className:"buttonList",children:ee(qt,{group:"text-align",options:[{value:Ad.TOP,text:f("labels.alignTop"),icon:ee(j1,{theme:n.theme}),testId:"align-top"},{value:Ad.MIDDLE,text:f("labels.centerVertically"),icon:ee(J1,{theme:n.theme}),testId:"align-middle"},{value:Ad.BOTTOM,text:f("labels.alignBottom"),icon:ee(q1,{theme:n.theme}),testId:"align-bottom"}],value:ut(e,o,a=>{if(Wt(a)&&a.containerId)return a.verticalAlign;let s=cr(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Wt(a)||cr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:Ad.MIDDLE),onChange:a=>{Us(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),_ne=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>$y(o)?o:st(o,{roundness:t==="round"?{type:w6(o.type)?Ld.ADAPTIVE_RADIUS:Ld.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=Li(Zy(e),n).some(s=>s.roundness?.type===Ld.LEGACY);return xt("fieldset",{children:[ee("legend",{children:f("labels.edges")}),xt("div",{className:"buttonList",children:[ee(qt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:S1},{value:"round",text:f("labels.round"),icon:C1}],value:ut(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!_d(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),Yy=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:ee(P1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:ee(k1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:ee(M1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:ee(A1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:ee(D1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ee(L1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:ee(_1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:ee(R1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:ee(N1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:ee(B1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:ee(F1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:ee(O1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:ee(z1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:ee(G1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:ee(H1,{flip:e}),keyBinding:null}]}]}),Rne=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(Rd(t,"actionChangeArrowhead: value must be defined"),{elements:Ct(e,n,o=>{if(Yh(o)){let{position:r,type:i}=t;if(r==="start")return st(o,{startArrowhead:i});if(r==="end")return st(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=Jn().rtl,i=Kh(()=>Yy(!r),[r]),a=Kh(()=>Yy(!!r),[r]);return xt("fieldset",{children:[ee("legend",{children:f("labels.arrowheads")}),xt("div",{className:"iconSelectList buttonList",children:[ee(Hh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:ut(e,o,s=>Yh(s)&&Ss(s.type)?Wy(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),ee(Hh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:ut(e,o,s=>Yh(s)&&Ss(s.type)?Wy(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),G6=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,n,t,o)=>!1,PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>xt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),Nne=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Ct(e,n,s=>{if(!_d(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=Xr.getPointAtIndexGlobalCoordinates(s,0,l),d=Xr.getPointAtIndexGlobalCoordinates(s,-1,l),m=st(s,{x:t===dn.elbow?c[0]:s.x,y:t===dn.elbow?c[1]:s.y,roundness:t===dn.round?{type:Ld.PROPORTIONAL_RADIUS}:null,elbowed:t===dn.elbow,angle:t===dn.elbow?0:s.angle,points:t===dn.elbow||s.elbowed?[Xr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),Xr.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if($y(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=Xr.getPointAtIndexGlobalCoordinates(m,0,p),E=Xr.getPointAtIndexGlobalCoordinates(m,-1,p),g=m.startBinding&&p.get(m.startBinding.elementId),b=m.endBinding&&p.get(m.endBinding.elementId),v=g&&m.startBinding?{...m.startBinding,...Uy(m,g,"start",p,n.isBindingEnabled)}:null,y=b&&m.endBinding?{...m.endBinding,...Uy(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:v,endBinding:y,...I6(m,p,{points:[u,E].map(x=>t6(x[0]-m.x,x[1]-m.y)),startBinding:v,endBinding:y,fixedSegments:null})}}else{let p=o.scene.getNonDeletedElementsMap();if(m.startBinding){let u=p.get(m.startBinding.elementId);u&&Hy(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&Hy(m,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return m}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new Xr(s,Xh(e)))}return{elements:r,appState:i,captureUpdate:ot.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>xt("fieldset",{children:[ee("legend",{children:f("labels.arrowtypes")}),ee("div",{className:"buttonList",children:ee(qt,{group:"arrowtypes",options:[{value:dn.sharp,text:f("labels.arrowtype_sharp"),icon:Qo,testId:"sharp-arrow"},{value:dn.round,text:f("labels.arrowtype_round"),icon:tr,testId:"round-arrow"},{value:dn.elbow,text:f("labels.arrowtype_elbowed"),icon:er,testId:"elbow-arrow"}],value:ut(e,o,r=>_d(r)?r.elbowed?dn.elbow:r.roundness?dn.round:dn.sharp:null,r=>_d(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as X6,MAX_ZOOM as Z6,MIN_ZOOM as $6,THEME as el,ZOOM_STEP as Qy,CODES as $r,KEYS as Od}from"@excalidraw/common";import{getNonDeletedElements as tl}from"@excalidraw/element";import{getCommonBounds as nl}from"@excalidraw/element";import{CaptureUpdateAction as ia}from"@excalidraw/element";import{useEffect as H6}from"react";import{jsx as W6}from"react/jsx-runtime";var oa=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let n=document.createElement("div");return document.body.appendChild(n),n.classList.add("excalidraw-tooltip"),n},qh=(e,n,t="bottom")=>{let o=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,s=n.left+n.width/2-o.width/2;s<0?s=a:s+o.width>=r&&(s=r-o.width-a);let l;t==="bottom"?(l=n.top+n.height+a,l+o.height>=i&&(l=n.top-o.height-a)):(l=n.top-o.height-a,l<0&&(l=n.top+n.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},U6=(e,n,t,o)=>{n.classList.add("excalidraw-tooltip--visible"),n.style.minWidth=o?"50ch":"10ch",n.style.maxWidth=o?"50ch":"15ch",n.textContent=t;let r=e.getBoundingClientRect();qh(n,r)},ht=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(H6(()=>()=>oa().classList.remove("excalidraw-tooltip--visible"),[]),r?null:W6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>U6(i.currentTarget,oa(),n,t),onPointerLeave:()=>oa().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as qy,useRef as Jy,useState as V6}from"react";var Y6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Jh=(e,n,t)=>{if(e?.isDestroyed)return;let o=e?.getAppState();if(!o){if(!t)return;console.warn("useAppStateValue: excalidrawAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Excalidraw/> component tree?"),o=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},Zo())}return Y6(o,n)};function ra(e,n=!0){let t=Fd(),[,o]=V6(0),r=Jy(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Jh(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Jh(t,e,n)),qy(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,a=>{i.latestValue=a,o(s=>s+1)})},[t]),r.current.latestValue}function K6(e,n){let t=Fd(),o=Jy({selector:e,callback:n});o.current.selector=e,o.current.callback=n,qy(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Jh(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Wd,jsxs as J6}from"react/jsx-runtime";var j6=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!n.viewModeEnabled,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:t?.viewBackgroundColor?ia.IMMEDIATELY:ia.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Wd(Qi,{palette:null,topPicks:X6,label:f("labels.canvasBackground"),type:"canvasBackground",color:n.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:n,updateData:t})}),zd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:zu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...vo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:jn(n.zoom.value+Qy)},n)},captureUpdate:ia.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=ra(t=>t.zoom.value);return Wd($,{type:"button",className:"zoom-in-button zoom-button",icon:zu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=Z6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===$r.EQUAL||e.code===$r.NUM_ADD)&&(e[Od.CTRL_OR_CMD]||e.shiftKey)}),Gd=O({name:"zoomOut",label:"buttons.zoomOut",icon:Gu,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...vo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:jn(n.zoom.value-Qy)},n)},captureUpdate:ia.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=ra(t=>t.zoom.value);return Wd($,{type:"button",className:"zoom-out-button zoom-button",icon:Gu,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=$6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===$r.MINUS||e.code===$r.NUM_SUBTRACT)&&(e[Od.CTRL_OR_CMD]||e.shiftKey)}),Hd=O({name:"resetZoom",label:"buttons.resetZoom",icon:jx,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?.lockZoom?n.scrollConstraints.zoom:1;return{appState:{...n,...vo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:jn(r)},n)},captureUpdate:ia.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=ra(t=>t.zoom.value);return Wd(ht,{label:f("buttons.resetZoom"),style:{height:"100%"},children:J6($,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(n*100).toFixed(0),"%"]})})},keyTest:e=>(e.code===$r.ZERO||e.code===$r.NUM_ZERO)&&(e[Od.CTRL_OR_CMD]||e.shiftKey)}),Qh=e=>[e.x,e.y,e.x+e.width,e.y+e.height],poe=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:ed,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?nl(tl(r)):n.scrollConstraints?Qh(n.scrollConstraints):nl(tl(e)),a=Fr({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...$n(a.appState)}}},keyTest:void 0}),uoe=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:ed,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?nl(tl(r)):n.scrollConstraints?Qh(n.scrollConstraints):nl(tl(e)),a=Fr({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...$n(a.appState)}}},keyTest:void 0}),q6=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:ed,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?Qh(n.scrollConstraints):nl(tl(e)),i=Fr({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...$n(i.appState)}}},keyTest:void 0}),Ud=O({name:"toggleTheme",label:(e,n)=>n.theme===el.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===el.LIGHT?Rs:Ns,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===el.LIGHT?el.DARK:el.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:ia.EVENTUALLY}},keyTest:e=>!e[Od.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===$r.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as sD}from"@excalidraw/math";import{bindOrUnbindBindingElement as dw}from"@excalidraw/element/binding";import{isValidPolygon as mw,newElementWith as ng}from"@excalidraw/element";import{LinearElementEditor as sl}from"@excalidraw/element/linearElementEditor";import{isBindingElement as og,isFreeDrawElement as pw,isLinearElement as uw,isLineElement as jd}from"@excalidraw/element";import{KEYS as qd,arrayToMap as lD,invariant as hw,shouldRotateWithDiscreteAngle as cD,updateActiveTool as gw}from"@excalidraw/common";import{isPathALoop as dD}from"@excalidraw/element";import{isInvisiblySmallElement as rg}from"@excalidraw/element";import{CaptureUpdateAction as ig}from"@excalidraw/element";import nD from"clsx";import{useEffect as oD,useState as rD}from"react";import{KEYS as mn,capitalizeString as jr}from"@excalidraw/common";import{useEffect as Q6,useState as eD}from"react";import ew from"clsx";import{capitalizeString as Vd}from"@excalidraw/common";import{Popover as eg}from"radix-ui";import{jsx as Yd,jsxs as tD}from"react/jsx-runtime";var aa=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=eD(!1),c=t.type,d=a.type===c,m=16,{container:p}=Oe();return!n.some(u=>u.type===c)&&s&&l(!1),Q6(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),tD(eg.Root,{open:s,children:[Yd(eg.Trigger,{asChild:!0,children:Yd($,{className:ew({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>tt(e,u.type)),title:Vd(a.title),"aria-label":Vd(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Yd(eg.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Yd($,{className:ew({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:tt(e,u),title:Vd(u),"aria-label":Vd(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(Ue("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as tg}from"react/jsx-runtime";var iD=e=>e,$e=iD({hand:{icon:Q1,letterKey:mn.H,toggle:!0},selection:{icon:Kc,letterKey:mn.V,fillable:!0},rectangle:{icon:Gi,letterKey:mn.R,fillable:!0},diamond:{icon:Hi,letterKey:mn.D,fillable:!0},ellipse:{icon:Ui,letterKey:mn.O,fillable:!0},arrow:{icon:Xc,letterKey:mn.A,fillable:!0},line:{icon:jo,letterKey:mn.L,fillable:!0},freedraw:{icon:Qn,letterKey:mn.P},text:{icon:Dn,letterKey:mn.T},image:{icon:Hr},eraser:{icon:Zc,letterKey:mn.E,toggle:!0},frame:{icon:to,letterKey:mn.F},autoshape:{icon:Vr,letterKey:mn.X,fillable:!1},embeddable:{icon:qo},laser:{icon:no},bucketfill:{icon:eo},lasso:{icon:zi,fillable:!1}});var sa=["autoshape","rectangle","diamond","ellipse","arrow","line"],la=Object.keys($e).filter(e=>$e[e].toggle),Kd=e=>{let{letterKey:n,shiftKey:t}=$e[e];if(!n)return n;let o=jr(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},ca=e=>Kd(e),aD=e=>{let n=Kd(e);return n?.length===1?n:void 0},tw=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys($e)){let{letterKey:i,shiftKey:a}=$e[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},tt=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Vt=(e,n)=>{let t=$e[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=jr(f(`toolBar.${e}`)),d=l?null:ca(o);return tg($,{className:nD({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:tt(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:s||l?void 0:aD(o),"aria-label":c,"aria-keyshortcuts":d??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:m})=>{if(!i.state.penDetected&&m==="pen"&&i.togglePenMode(!0),n?.onSelect){n.onSelect(i,{pointerType:m});return}i.state.activeTool.type!==e&&(Ue("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${jr(e)}IconButton`,r},Xd=Vt("hand"),nw=Vt("rectangle"),ow=Vt("diamond"),rw=Vt("ellipse"),iw=Vt("arrow"),aw=Vt("line"),ol=Vt("freedraw"),rl=Vt("text"),il=Vt("image"),al=Vt("eraser"),sw=Vt("frame"),Hoe=Vt("autoshape"),lw=Vt("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(Ue("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),cw=Vt("lasso",{shortcutType:"selection"}),Zd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:$e.selection.icon,fillable:$e.selection.fillable,title:jr(f("toolBar.selection"))},{type:"lasso",icon:$e.lasso.icon,fillable:$e.lasso.fillable,title:jr(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return tg(aa,{app:e,options:o,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,"data-testid":"toolbar-selection",onToolChange:i=>{(i==="selection"||i==="lasso")&&(e.setActiveTool({type:i}),t({preferredSelectionTool:{type:i,initialized:!0}}))},displayedOption:r})},$d=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:$e.freedraw.icon,fillable:$e.freedraw.fillable,title:jr(f("toolBar.freedraw"))},{type:"autoshape",icon:$e.autoshape.icon,fillable:$e.autoshape.fillable,title:jr(f("toolBar.autoshape"))}],[o,r]=rD(n.type==="autoshape"?"autoshape":"freedraw");oD(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return tg(aa,{app:e,options:t,activeTool:n,defaultOption:o,"data-testid":"toolbar-freedraw",onToolChange:a=>{(a==="freedraw"||a==="autoshape")&&(r(a),e.setActiveTool({type:a}))},displayedOption:i})};import{jsx as mD}from"react/jsx-runtime";var gt=O({name:"finalize",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=!0,i=e,{focusContainer:a,scene:s}=o,l=s.getNonDeletedElementsMap(),c=n.activeTool.type==="autoshape";if(t&&n.selectedLinearElement){let{event:b,sceneCoords:v}=t,y=sl.getElement(n.selectedLinearElement.elementId,l);hw(y,"Arrow element should exist if selectedLinearElement is set"),hw(v,"sceneCoords should be defined if actionFinalize is called with event");let x=sl.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(og(y)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let I=!!n.newElement,T=I||!n.selectedLinearElement.selectedPointsIndices?[y.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=cD(b),P=b[qd.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),M=T.reduce((D,_)=>(D.set(_,{point:C?y.points[_]:sl.createPointAt(y,l,v.x-x.pointerOffset.x,v.y-x.pointerOffset.y,P)}),D),new Map)??new Map;dw(y,M,v.x,v.y,s,n,{newArrow:I,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else jd(y)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!mw(y.points)&&s.mutateElement(y,{polygon:!1});if(x!==n.selectedLinearElement){y&&rg(y)&&(i=i.map(T=>T.id===y.id?ng(T,{isDeleted:!0}):T));let I=n.activeTool?.locked;return{elements:y.points.length<2||rg(y)?e.map(T=>T.id===y.id?ng(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:I||c?null:{...x,selectedPointsIndices:null,isEditing:!1,initialState:{...x.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:ig.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let d=o.drawShape.hasPendingGesture();(d||c)&&(o.drawShape.finalize(),d&&(i=o.scene.getElementsIncludingDeleted()));let m=null;if(n.multiElement)m=n.multiElement;else if(!c&&!d&&(n.newElement?.type==="freedraw"||og(n.newElement)))m=n.newElement;else if(Object.keys(n.selectedElementIds).length===1){let b=l.get(Object.keys(n.selectedElementIds)[0]);b&&(m=b)}if(m){if(n.selectedLinearElement&&n.multiElement&&m.type!=="freedraw"&&n.lastPointerDownWith!=="touch"){let{points:b}=m,{lastCommittedPoint:v}=n.selectedLinearElement;if((!v||b[b.length-1]!==v)&&(r=!1,s.mutateElement(m,{points:m.points.slice(0,-1)}),og(m)&&m.endBinding&&m.points.length>1)){let y=!!n.newElement,x=new Map([[m.points.length-1,{point:m.points[m.points.length-1],isDragging:!1}]]),I=sl.getPointAtIndexGlobalCoordinates(m,-1,l);dw(m,x,I[0],I[1],s,n,{newArrow:y})}}if(m&&rg(m)&&(i=i.map(b=>b.id===m?.id?ng(b,{isDeleted:!0}):b)),uw(m)||pw(m)){if(dD(m.points,n.zoom.value)&&(jd(m)||pw(m))){let v=m.points,y=v[0],x=v.map((I,T)=>T===v.length-1?sD(y[0],y[1]):I);jd(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}jd(m)&&!mw(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;la.includes(n.activeTool.type)?p=gw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=gw(n,{type:o.state.preferredSelectionTool.type});let u=o.isToolLocked(),E=n.activeTool.type==="autoshape"||(u||n.activeTool.type==="freedraw")&&!!m;E||o.cursor.applyForTool(p);let g=m&&uw(m)?new sl(m,lD(i)):n.selectedLinearElement;return g=g&&{...g,isEditing:n.newElement?!1:g.isEditing,initialState:{...g.initialState,lastClickedPoint:-1,origin:null}},{elements:i,appState:{...n,cursorButton:"up",activeTool:E?n.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:c?{}:m&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[m.id]:!0}:n.selectedElementIds,selectedLinearElement:c?null:g},captureUpdate:r?ig.IMMEDIATELY:ig.NEVER}},keyTest:(e,n)=>e.key===qd.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===qd.ESCAPE||e.key===qd.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>mD($,{type:"button",icon:s1,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:n,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as bw,isSomeElementSelected as pD,makeNextSelectedElementIds as uD,selectGroupsForSelectedElements as hD}from"@excalidraw/element";import{CaptureUpdateAction as fw}from"@excalidraw/element";import{KEYS as gD,isWritableElement as fD,updateActiveTool as Ew}from"@excalidraw/common";var ED=(e,n)=>la.includes(e.activeTool.type)?Ew(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):Ew(e,{type:n.state.preferredSelectionTool.type}),bD=(e,n,t)=>{if(!e.editingGroupId)return null;let o=n.scene.getNonDeletedElements(),r=n.scene.getSelectedElements({selectedElementIds:t,elements:o}),i=r.length?r:bw(o,e.editingGroupId);for(let a of i){let s=a.groupIds.indexOf(e.editingGroupId);if(s!==-1&&a.groupIds[s+1])return a.groupIds[s+1]}return null},xD=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=ED(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:bw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...hD({editingGroupId:bD(n,o,a),selectedElementIds:a},i,n,o),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:fw.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:uD({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:fw.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==gD.ESCAPE||fD(e.target)?!1:!n.newElement&&n.multiElement===null&&!n.selectedLinearElement?.isEditing&&(n.activeEmbeddable!==null||n.activeTool.type!==o.state.preferredSelectionTool.type||!!n.editingGroupId||!!n.selectedLinearElement||pD(o.scene.getNonDeletedElements(),n))});import{KEYS as sm,THEME as pl}from"@excalidraw/common";import{CaptureUpdateAction as _n}from"@excalidraw/element";import yD from"clsx";import{jsx as xw,jsxs as wD}from"react/jsx-runtime";var ag=({children:e,checked:n,onChange:t,className:o})=>wD("div",{className:yD("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[xw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:$c}),xw("div",{className:"Checkbox-label",children:e})]});import{THEME as ll}from"@excalidraw/common";import{jsx as cl}from"react/jsx-runtime";var ww=e=>{let n=e.title||(e.value===ll.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return cl($,{type:"icon",icon:e.value===ll.LIGHT?yw.MOON:yw.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===ll.DARK?ll.LIGHT:ll.DARK),"data-testid":"toggle-dark-mode"})},yw={SUN:cl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:cl("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:cl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:cl("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 vD}from"react";import{focusNearestParent as ID,KEYS as TD}from"@excalidraw/common";import{jsx as vw,jsxs as SD}from"react/jsx-runtime";var Iw=e=>{let{id:n}=Oe(),[t,o]=vD(e.value),r=a=>{e.ignoreFocus||ID(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===TD.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return SD("div",{className:"ProjectName",children:[vw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),vw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as CD,useEffect as PD,useRef as kD}from"react";import{jsx as Jd,jsxs as LD}from"react/jsx-runtime";var MD=5e3,AD=({progress:e})=>Jd("div",{className:"Toast__progress-bar",children:Jd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),DD=({message:e,onClose:n,closable:t=!1,duration:o=MD,style:r})=>{let i=kD(0),a=o!==1/0,s=CD(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return PD(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),LD("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Jd("div",{className:"Toast__message",children:e}),t&&Jd($,{icon:an,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},Qd=Object.assign(DD,{ProgressBar:AD});import{DEFAULT_EXPORT_PADDING as qD,DEFAULT_FILENAME as JD,IMAGE_MIME_TYPES as Mw,isFirefox as QD,MIME_TYPES as eL,cloneJSON as tL,SVG_DOCUMENT_PREAMBLE as nL,arrayToMap as oL}from"@excalidraw/common";import{getNonDeletedElements as rL}from"@excalidraw/element";import{isFrameLikeElement as iL}from"@excalidraw/element";import{getElementsOverlappingFrame as aL}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as _D,EXPORT_DATA_TYPES as dl,MIME_TYPES as Ae,arrayToMap as RD,isMemberOf as ND,isPromiseLike as BD,EVENT as em}from"@excalidraw/common";import{mutateElement as FD}from"@excalidraw/element";import{deepCopyElement as OD}from"@excalidraw/element";import{isFrameLikeElement as zD,isInitializedImageElement as Sw}from"@excalidraw/element";import{getContainingFrame as Tw}from"@excalidraw/element";var Cw=`web ${Ae.excalidrawClipboard}`,iie="clipboard"in navigator&&"readText"in navigator.clipboard,tm="clipboard"in navigator&&"writeText"in navigator.clipboard,dr="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,GD=()=>"clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,HD=e=>!!([dl.excalidraw,dl.excalidrawClipboard,dl.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),nm=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(em.PASTE,{clipboardData:new DataTransfer});if(e)for(let[o,r]of Object.entries(e)){if(typeof r!="string"){n=n||[],n.push(r);continue}try{if(t.clipboardData?.items.add(r,o),t.clipboardData?.getData(o)!==r)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(n){let o=-1;for(let r of n){o++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[o]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},UD=({elements:e,files:n})=>{let t=RD(e),o=new Set(e.filter(s=>zD(s))),r=!1,i=e.reduce((s,l)=>(Sw(l)&&(r=!0,n&&n[l.fileId]&&(s[l.fileId]=n[l.fileId])),s),{});r&&!n&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:dl.excalidrawClipboard,elements:e.map(s=>{if(Tw(s,t)&&!o.has(Tw(s,t))){let l=OD(s);return FD(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},WD=async e=>{let n=await createImageBitmap(e);try{let t=document.createElement("canvas");t.width=n.width,t.height=n.height;let o=t.getContext("2d");if(!o)throw new Error("Could not create a canvas context for clipboard image");return o.drawImage(n,0,0),await new Promise((r,i)=>{t.toBlob(a=>{a?r(a):i(new Error("Could not encode clipboard image as PNG"))},Ae.png)})}finally{n.close()}},om=async(e,n,t)=>{let o=UD({elements:e,files:n}),r=e.length===1&&Sw(e[0])?n?.[e[0].fileId]:null,i=r&&Bu(r.mimeType)&&r.dataURL?Ax(r.dataURL,r.fileName):null;if(i){let a=i.type===Ae.png?i:WD(i);if(GD())try{await navigator.clipboard.write([new ClipboardItem({[Cw]:new Blob([o],{type:Ae.excalidrawClipboard}),[Ae.png]:a})]);return}catch(s){console.error("Error copying image with ClipboardItem",s)}if(t?.clipboardData?.items)try{let s=i.type===Ae.png?i:new File([await a],`${i.name.replace(/\.[^/.]+$/,"")||"image"}.png`,{type:Ae.png});t.clipboardData.items.add(s),await ao({[Ae.excalidrawClipboard]:o},t);return}catch(s){console.error("Error copying image to clipboard event",s)}}await ao({[Ae.excalidrawClipboard]:o,[Ae.text]:o},t)};function Pw(e){let n=[];for(let t of e.childNodes)if(t.nodeType===3){let o=t.textContent?.trim();o&&n.push({type:"text",value:o})}else if(t instanceof HTMLImageElement){let o=t.getAttribute("src");o&&o.startsWith("http")&&n.push({type:"imageUrl",value:o})}else n=n.concat(Pw(t));return n}var VD=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,Ae.html),o=Pw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},rm=async()=>{let e={},n;try{n=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let o=await navigator.clipboard?.readText();if(o)return{[Ae.text]:o}}}catch(o){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${o.message}). Failling back to navigator.clipboard.read()`);else{if(o.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${o.message}`),e;throw o}}throw t}for(let t of n)for(let o of t.types){if(o===Cw){try{e[Ae.excalidrawClipboard]=await(await t.getType(o)).text()}catch(r){console.warn(`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}continue}if(ND(_D,o))try{if(o===Ae.text||o===Ae.html||o===Ae.excalidrawClipboard)e[o]=await(await t.getType(o)).text();else if(Bu(o)){let r=await t.getType(o),i=Nx(r,o,void 0);e[o]=i}else throw new _u(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof _u?r.message:`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},YD=async(e,n=!1)=>{try{let t=e.findByType(Ae.html),o=!n&&t&&VD(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(Ae.text)??o.value.map(r=>r.value).join(`
2
- `).trim()}:o:{type:"text",value:(e.getData(Ae.text)||"").trim()}}catch{return{type:"text",value:""}}},KD=function(e){return this.find(n=>n.type===e)||null},XD=function(e){return this.find(t=>t.type===e)?.value??null},ZD=function(){return this.filter(e=>e.kind==="file")},sg=e=>{let n=lg(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),Ae.text,Ae.html,"text/uri-list","public.url","public.plain-text","text/x-moz-url"])),r={};for(let i of o)try{let a=n?.getData(i);a&&(r[i]=a)}catch{}return{items:Array.from(n?.items??[]).map(i=>({kind:i.kind,type:i.type})),files:Array.from(n?.files??[]).map(i=>({name:i.name,type:i.type,size:i.size,lastModified:i.lastModified})),types:t,data:r}},$D=e=>e.map(n=>n.kind==="string"?{kind:n.kind,type:n.type,value:n.value}:{kind:n.kind,type:n.type,file:{name:n.file.name,type:n.file.type,size:n.file.size,lastModified:n.file.lastModified}}),im=(e,n,t)=>{let o=[],r=[],i=[],a=(u,E)=>{let g=E?.trim();g&&!u.includes(g)&&u.push(g)},s=(u,E)=>{E.split(/\r?\n/).map(g=>g.trim()).filter(g=>g&&!g.startsWith("#")).forEach(g=>a(u,g))};e.forEach(u=>{if(u.kind==="string")if(u.type===Ae.html)try{let E=new DOMParser().parseFromString(u.value,Ae.html);for(let g of Array.from(E.body.querySelectorAll("img")))a(o,g.getAttribute("src")),a(i,g.getAttribute("alt"))}catch{}else u.type===Ae.text?a(r,u.value):u.type==="text/uri-list"&&s(r,u.value)});let l=[...o,...r.filter(u=>!o.includes(u))],c=Array.from({length:n},()=>({})),d={...t??{items:[],files:[],types:[],data:{}},parsedItems:$D(e)};c.forEach((u,E)=>{let g=l[E],b=i[E];g&&(u.src=g),b&&(u.alt=b),u.rawDragData=d});let m=l.slice(c.length),p=c[0];return p&&m.length>0&&m.forEach((u,E)=>{p[`additionalUrl${E+1}`]=u}),c},kw=e=>{let n;lg(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=new Set;for(let o of Array.from(n||[]))t.has(o.type)||t.add(o.type);return t},mr=async e=>{let n;lg(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=(await Promise.all(Array.from(n||[]).map(async o=>{if(o.kind==="file"){let r=o.getAsFile();if(r){let i=await Rx(o);return r=await Gr(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(o.kind==="string"){let{type:r}=o,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{o.getAsString(s=>a(s))}),{type:r,kind:"string",value:i}}return null}))).filter(o=>o!=null);return Object.assign(t,{findByType:KD,getData:XD,getFiles:ZD})},ml=async(e,n=!1)=>{let t=e.getData(Ae.excalidrawClipboard),o=t?{type:"text",value:t}:await YD(e,n);if(o.type==="mixedContent")return{mixedContent:o.value};try{let r=JSON.parse(o.value),i=r.type===dl.excalidrawClipboardWithAPI;if(HD(r))return{elements:r.elements,files:r.files,text:n?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:i}}catch{}return{text:o.value}},am=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[Ae.png]:e})])}catch(n){if(BD(e))await navigator.clipboard.write([new ClipboardItem({[Ae.png]:await e})]);else throw n}},ao=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[Ae.text]:e}:e);try{if(n){for(let[r,i]of t)if(n.clipboardData?.setData(r,i),n.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let o=t.find(([r])=>r===Ae.text);if(tm&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!jD(o[1]))throw new Error("Error copying to clipboard.")},jD=e=>{e||(e=" ");let n=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[n?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${o}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let r=!1;try{t.select(),t.setSelectionRange(0,t.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),r},lg=e=>e.type===em.PASTE||e.type===em.COPY||e.type===em.CUT;var qr=(e,{selectedElementIds:n},t)=>{let o=rL(e),r=oL(o),i=t&&Re(o,{selectedElementIds:n}),a=null,s=i?de(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&iL(l)?(a=l,s=aL(o,l,r)):s.length>1&&(s=de(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:tL(s)}},Jr=async(e,n,t,o,{exportBackground:r,exportPadding:i=qD,viewBackgroundColor:a,name:s=t.name||JD,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Or(n,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return Ru(m.then(p=>new Blob([nL+p.outerHTML],{type:eL.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Mw.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await ao(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let d=Gc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Ds(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-355PB44S.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:Ps(n,t,o,"local")})))),Ru(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Mw.png],fileHandle:l})}else if(e==="clipboard")try{let m=Ds(d);await am(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):QD&&m.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
1
+ import{$ as Fu,A as xx,B as Nu,C as Ps,D as Nc,E as Bu,F as yx,G as wx,H as Bc,I as ks,J as Fc,K as Oc,L as Ms,M as zc,N as vx,O as Ix,P as Tx,Q as Gc,R as Gr,S as zA,T as Hr,U as Bi,W as Sx,Y as Cx,Z as Px,_ as Hc,a as Du,aa as Fi,b as $n,ba as As,c as vo,ca as Ds,d as zr,da as kx,e as _i,ea as Uc,f as jn,fa as Mx,g as ux,ga as Ax,h as Ne,ha as Dx,i as hx,ia as Lx,j as de,ja as Ou,k as Ri,ka as _x,l as Xo,la as Rx,m as gx,ma as Nx,n as Lu,na as Ur,o as fx,p as Ss,q as Ex,r as Rc,s as bx,t as _u,u as Ru,v as Io,w as Zo,x as rn,y as Cs,z as Ni}from"./chunk-FZE33ODQ.js";import{a as S}from"./chunk-U23VT5B7.js";import{G as Au}from"./chunk-MZBVWY5X.js";import{c as px}from"./chunk-5XKZK2GL.js";import{b as mx,c as OA,d as y}from"./chunk-SRAX5OIU.js";import GX,{useCallback as HX,useContext as UX,useEffect as WX,useRef as VX,useState as YX}from"react";import{applyDarkModeFilter as CYe,DEFAULT_IMAGE_OPTIONS as Pn,DEFAULT_UI_OPTIONS as FA,getStrokeWidthByKey as PYe,isShallowEqual as KX}from"@excalidraw/common";import pM from"clsx";import bY from"lodash.throttle";import Sn,{useContext as Yo}from"react";import{flushSync as Gt}from"react-dom";import xY from"roughjs/bin/rough";import{nanoid as yY}from"nanoid";import{clamp as fc,pointFrom as oe,pointDistance as go,vector as uM,pointRotateRads as Sb,vectorFromPoint as Cb,vectorSubtract as hM,vectorDot as gM,vectorNormalize as fM}from"@excalidraw/math";import{CODES as Rr,shouldResizeFromCenter as EM,shouldMaintainAspectRatio as Ec,shouldRotateWithDiscreteAngle as bM,isArrowKey as Pb,KEYS as V,APP_NAME as wY,CURSOR_TYPE as Me,DEFAULT_STROKE_STREAMLINE as vY,DEFAULT_STROKE_STREAMLINE_PRECISE as IY,DEFAULT_TRANSFORM_HANDLE_SPACING as TY,DEFAULT_VERTICAL_ALIGN as xM,DRAGGING_THRESHOLD as yM,ELEMENT_SHIFT_TRANSLATE_AMOUNT as SY,ELEMENT_TRANSLATE_AMOUNT as wM,EVENT as Q,FRAME_STYLE as Go,IMAGE_MIME_TYPES as CY,IMAGE_RENDER_TIMEOUT as PY,LINE_CONFIRM_THRESHOLD as kb,MIME_TYPES as In,MQ_RIGHT_SIDEBAR_MIN_WIDTH as kY,POINTER_BUTTON as Tn,ROUNDNESS as su,SCROLL_TIMEOUT as MY,TAP_TWICE_TIMEOUT as vM,TEXT_TO_CENTER_SNAP_THRESHOLD as AY,THEME as bc,TOUCH_CTX_MENU_TIMEOUT as DY,VERTICAL_ALIGN as LY,YOUTUBE_STATES as lu,ZOOM_STEP as _Y,MIN_ZOOM as RY,POINTER_EVENTS as fs,TOOL_TYPE as Yn,supportsResizeObserver as NY,DEFAULT_COLLISION_THRESHOLD as IM,DEFAULT_TEXT_ALIGN as BY,ARROW_TYPE as Nr,DEFAULT_REDUCED_GLOBAL_ALPHA as FY,isLocalLink as OY,normalizeLink as cu,toValidURL as zY,getGridPoint as kt,getLineHeight as TM,debounce as SM,distance as Es,getFontString as Mb,getNearestScrollableContainer as GY,isInputLike as CM,isToolIcon as HY,isWritableElement as xc,sceneCoordsToViewportCoords as du,tupleToCoors as Ab,viewportCoordsToSceneCoords as Ce,wrapEvent as UY,updateObject as Db,updateActiveTool as on,isTransparent as WY,muteFSAbortError as VY,isTestEnv as fA,isDevEnv as EA,updateStable as yc,addEventListener as we,normalizeEOL as YY,getDateTime as PM,isShallowEqual as kM,capitalizeString as KY,arrayToMap as wc,applyDarkModeFilter as XY,AppEventBus as ZY,randomInteger as $Y,CLASSES as Lb,Emitter as fo,MINIMUM_ARROW_SIZE as jY,DOUBLE_TAP_POSITION_THRESHOLD as MM,BIND_MODE_TIMEOUT as qY,invariant as Eo,getFeatureFlag as Ho,createUserAgentDescriptor as bA,getFormFactor as JY,deriveStylesPanelMode as vu,isIOS as QY,isBrave as eK,isSafari as tK,loadDesktopUIModePreference as nK,setDesktopUIMode as oK,isSelectionLikeTool as mu,oneOf as AM,getStrokeWidthByKey as rK,getViewpointFlipSign as Kn}from"@excalidraw/common";import{getObservedAppState as iK,getCommonBounds as bs,getElementAbsoluteCoords as DM,bindOrUnbindBindingElements as LM,fixBindingsAfterDeletion as aK,getHoveredElementForBinding as Br,isBindingEnabled as pu,updateBoundElements as uu,LinearElementEditor as Ee,newElementWith as bo,newFrameElement as sK,newFreeDrawElement as lK,newEmbeddableElement as _M,newMagicFrameElement as cK,newIframeElement as dK,newArrowElement as mK,newElement as pK,newImageElement as uK,newLinearElement as hK,newTextElement as RM,refreshTextDimensions as gK,deepCopyElement as NM,duplicateElements as BM,hasBoundTextElement as FM,isArrowElement as vc,isBindingElement as xo,isBindingElementType as fK,isBoundToContainer as OM,isFrameLikeElement as St,isImageElement as Xn,isEmbeddableElement as Uo,isInitializedImageElement as Pi,isLinearElement as Ht,isLinearElementType as EK,isUsingAdaptiveRadius as bK,isIframeElement as _b,isIframeLikeElement as Ic,isTextBindableContainer as zM,isElbowArrow as Zt,isBindableElement as Rb,isTextElement as $t,getNormalizedDimensions as xK,isElementCompletelyInViewport as yK,isElementInViewport as GM,isInvisiblySmallElement as HM,generateThumbHash as wK,getCornerRadius as vK,isPathALoop as UM,embeddableURLValidator as Nb,maybeParseEmbedSrc as IK,getEmbedLink as hu,getInitializedImageElements as TK,normalizeSVG as WM,updateImageCache as Bb,getBoundTextElement as Fb,getContainerCenter as Ob,getContainerElement as VM,isValidTextContainer as YM,redrawTextBoundingBox as SK,hasBoundingBox as CK,getCommonFrameId as KM,getFrameChildren as zb,getFrameChildrenInsertionIndex as PK,isCursorInFrame as XM,addElementsToFrame as Gb,replaceAllElementsInFrame as kK,removeElementsFromFrame as MK,getElementsInResizingFrame as Hb,getElementsInNewFrame as AK,getContainingFrame as Ub,elementOverlapsWithFrame as DK,updateFrameMembershipOfSelectedElements as ZM,isElementInFrame as $M,getFrameLikeTitle as LK,filterElementsEligibleAsFrameChildren as _K,hitElementBoundText as RK,hitElementBoundingBoxOnly as NK,hitElementItself as Tc,getVisibleSceneBounds as BK,cropElement as FK,wrapText as OK,isElementLink as jM,isMeasureTextSupported as zK,normalizeText as GK,measureText as qM,getLineHeightInPx as JM,getApproxMinLineWidth as HK,getApproxMinLineHeight as UK,getMinTextElementWidth as WK,ShapeCache as ki,getRenderOpacity as VK,editGroupForSelectedElement as YK,getElementsInGroup as Mi,getSelectedGroupIdForElement as KK,getSelectedGroupIds as XK,isElementInGroup as QM,isSelectedViaGroup as ZK,selectGroupsForSelectedElements as Zn,syncInvalidIndices as xA,syncMovedIndices as eA,excludeElementsInFramesFromSelection as $K,getSelectionStateForElements as tA,makeNextSelectedElementIds as Le,getResizeOffsetXY as jK,getResizeArrowDirection as qK,transformElements as JK,getCursorForResizingElement as nA,getElementWithTransformHandleType as oA,getTransformHandleTypeFromCoords as rA,dragNewElement as iA,dragSelectedElements as QK,getDragOffsetXY as eX,Scene as aA,Store as tX,CaptureUpdateAction as jt,hitElementBoundingBox as nX,isLineElement as Wb,isSimpleArrow as Vb,StoreDelta as sA,positionElementsOnGrid as lA,calculateFixedPointForNonElbowArrowBinding as cA,bindOrUnbindBindingElement as oX,mutateElement as gu,getElementBounds as dA,doBoundsIntersect as rX,isPointInElement as mA,maxBindingDistance_simple as pA,convertToExcalidrawElements as iX,getSnapOutlineMidPoint as Yb,handleFocusPointDrag as aX,handleFocusPointHover as sX,handleFocusPointPointerDown as lX,handleFocusPointPointerUp as cX,maybeHandleArrowPointlikeDrag as fu,getUncroppedWidthAndHeight as dX,getActiveTextElement as uA,isEligibleFrameChildType as mX,getBindingStrategyForDraggingBindingElementEndpoints as pX,isNonDeletedElement as Eu}from"@excalidraw/element";import{KEYS as fh,MOBILE_ACTION_BUTTON_BG as QA,updateActiveTool as e3}from"@excalidraw/common";import{getNonDeletedElements as ld}from"@excalidraw/element";import{fixBindingsAfterDeletion as t3}from"@excalidraw/element";import{LinearElementEditor as A0}from"@excalidraw/element/linearElementEditor";import{newElementWith as sd}from"@excalidraw/element";import{getContainerElement as D0}from"@excalidraw/element";import{isBoundToContainer as id,isElbowArrow as n3,isFrameLikeElement as o3}from"@excalidraw/element";import{getFrameChildren as r3}from"@excalidraw/element";import{getElementsInGroup as Eh,selectGroupsForSelectedElements as i3}from"@excalidraw/element";import{CaptureUpdateAction as ad}from"@excalidraw/element";import{isDevEnv as WA}from"@excalidraw/common";import{atom as Qe,createStore as GA}from"jotai";import{createIsolation as HA}from"jotai-scope";var Bx=HA();var{useAtom:Xe,useSetAtom:Fx,useAtomValue:Oi,useStore:JX}=Bx,Ox=Bx.Provider,bt=GA();var UA=mx({"./locales/ar-SA.json":()=>import("./locales/ar-SA-E6E2KRZ5.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-RDMGQYMZ.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-CHUVCTEA.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-ZMOEPIQW.js"),"./locales/bn-IN.json":()=>import("./locales/bn-IN-OHZAWF5C.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-K4A7PUP4.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-RVP6YORC.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-ENJX4GIQ.js"),"./locales/de-CH.json":()=>import("./locales/de-CH-VYBKDWRU.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-6MCXRRVA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-WEDZAIPA.js"),"./locales/en.json":()=>import("./locales/en-ALU5NMSJ.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-LLEALNRO.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-M4Y34NOW.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-XSMVGGRV.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-K2D3DDUS.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-EQKMVJSO.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-RCPQTYJV.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-RHAGKYKH.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-3UDCLKHN.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-T3REA7IL.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-KW4N25IN.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-LJVXK4LO.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-GGGK3KPX.js"),"./locales/kaa.json":()=>import("./locales/kaa-TSEHAWJR.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-IWXTEINV.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-6GNYSAU7.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-ILUXSOEW.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-FJWHM3OT.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-DRDDAECA.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-IYFIPPJI.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-7F754RSS.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-BYRIZ3PC.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-RBYJSIJ6.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-EKTZIYSK.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-UECYYIUK.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-JPXGIDBA.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-4RSIVDPZ.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-GPHFXISR.js"),"./locales/percentages.json":()=>import("./locales/percentages-Q7USCRWZ.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-HKHPAEVK.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-UBWN6CKP.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-XDY4S4SD.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-2B3UXAQO.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-EW52HAV3.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-PIEHI4JX.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-TZXYYIFD.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-VUDQNDF3.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-IJTJRA7S.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-Q5PXZT3U.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HK66ZQXE.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-CLYYPVPL.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-YR4OMRYF.js"),"./locales/uz-UZ.json":()=>import("./locales/uz-UZ-CY4LSY5Y.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-UDAEMEBG.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-EGBL23FT.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-ZOJEG32A.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-TM5HZP7M.js")});var VA=85,qn={code:"en",label:"English"},Gi=[qn,...[{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=>px[e.code]>=VA).sort((e,n)=>e.label>n.label?1:-1)],Vc="__test__";WA()&&Gi.unshift({code:Vc,label:"test language"},{code:`${Vc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var zi=qn,Wc={},Yc=async e=>{if(zi=e,document.documentElement.dir=zi.rtl?"rtl":"ltr",document.documentElement.lang=zi.code,e.code.startsWith(Vc))Wc={};else try{Wc=await UA(`./locales/${zi.code}.json`)}catch(n){console.error(`Failed to load language ${e.code}:`,n.message),Wc=Au}bt.set(Gx,e.code)},Jn=()=>zi,zx=(e,n)=>{for(let t=0;t<n.length;++t){let o=n[t];if(e[o]===void 0)return;e=e[o]}if(typeof e=="string")return e},f=(e,n,t)=>{if(zi.code.startsWith(Vc))return`\u202A[[${n?`${e}(${JSON.stringify(n).slice(1,-1)})`:e}]]\u202C`;let o=e.split("."),r=zx(Wc,o)||zx(Au,o)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(S.PROD)return console.warn(i),"";throw new Error(i)}if(n)for(let i in n)r=r.replace(`{{${i}}}`,String(n[i]));return r},Gx=Qe(qn.code),Ae=()=>{let e=Oi(Gx);return{t:f,langCode:e}};import YA from"clsx";import nt from"react";import{THEME as KA}from"@excalidraw/common";import{Fragment as Ie,jsx as h,jsxs as R}from"react/jsx-runtime";var An=e=>"var(--icon-fill-color)",Hx=e=>e===KA.LIGHT?"#fff":"#1e1e1e",A=(e,n=512)=>{let{width:t=512,height:o=t,mirror:r,style:i,...a}=typeof n=="number"?{width:n}:n;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${o}`,className:YA({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},le={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Lt={width:40,height:20},uZ=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),H),hZ=A(R("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),H),gZ=A("M320 112C434.9 112 528 205.1 528 320C528 434.9 434.9 528 320 528C205.1 528 112 434.9 112 320C112 205.1 205.1 112 320 112zM320 576C461.4 576 576 461.4 576 320C576 178.6 461.4 64 320 64C178.6 64 64 178.6 64 320C64 461.4 178.6 576 320 576zM288 248C288 234.7 277.3 224 264 224C250.7 224 240 234.7 240 248L240 392C240 405.3 250.7 416 264 416C277.3 416 288 405.3 288 392L288 248zM400 248C400 234.7 389.3 224 376 224C362.7 224 352 234.7 352 248L352 392C352 405.3 362.7 416 376 416C389.3 416 400 405.3 400 392L400 248z",640),Ls=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),H),Ux=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"}),h("path",{d:"M19 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"})]}),H),Wx=A(R("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),H),zu=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),H),To=A(R("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),le),$o=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),le),Vx=A(h("g",{fill:"currentColor",children:h("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),Yx=A(R(Ie,{children:[h("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),Kx=A(R(Ie,{children:[h("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),Xx=A(R(Ie,{children:[h("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),fZ=A(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),Kc=A(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Hi=A(R("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Ui=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),H),Wi=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),H),Vi=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),H),Xc=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),H),jo=A(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),le),Zx=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),H),Qn=A(R("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),le),Dn=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),H),$x=A(R("g",{stroke:"currentColor",strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),H),Wr=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),le),Zc=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),H),Gu=A(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),le),Hu=A(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),le),jx=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),h("path",{d:"M3 4v4h4"})]}),H),Vr=A(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),le),qo=A(R("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),le),_s=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),le),Rs=A(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),le),Ns=A(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...le,strokeWidth:1.5}),qx=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),H),Bs=A(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),le),Yi=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),Jx=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),EZ=A(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),le),Qx=A(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),le),e1=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),le),t1=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),H),$c=A(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Fs=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),le),n1=A("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),o1=A("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),jc=A(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),le),bZ=A("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),xZ=A("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),Uu=["M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z","M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z","M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"],eo=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),Uu.map(e=>h("path",{d:e},e))]}),H),r1=A(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),i1=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),H),a1=A("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),yZ=A("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),wZ=A("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),s1=A("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),vZ=A("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Wu=A(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),le),Vu=A(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),le),l1=A("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),c1=A(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),le),IZ=A("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),TZ=A("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),SZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),H),CZ=A(R(Ie,{children:[h("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),h("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),PZ=A(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),d1=R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),m1=R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),Yu=A(m1,H),Ku=A(m1,{...H,style:{transform:"rotate(180deg)"}}),Xu=A(d1,H),Zu=A(d1,{...H,style:{transform:"rotate(180deg)"}}),$u=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),ju=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),qu=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),Ju=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),p1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),u1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),Qu=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),le),eh=A(R("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),le),qc=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),H),kZ=A("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),MZ=A("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),an=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),AZ=A("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),DZ=A("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),LZ=A("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),th=nt.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:An(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:An(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:An(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:An(e),strokeWidth:"2"}),R("g",{fill:Hx(e),stroke:An(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),nh=nt.memo(({theme:e})=>A(R(Ie,{children:[h("path",{d:"M25 26H111V111H25",fill:An(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:An(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:An(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:An(e),strokeWidth:"2"}),R("g",{fill:Hx(e),stroke:An(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),h1=A(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),le),g1=A(R(Ie,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),le),f1=A(R(Ie,{children:[R("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),E1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...le,fill:"currentColor"}),oh=A(h(Ie,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),le),b1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),le),x1=A(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),le),_Z=nt.memo(({theme:e})=>A(h("path",{d:"M6 10H34",stroke:An(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),y1=A(R("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),H),w1=A(R("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),H),v1=A(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),le),I1=A(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),le),T1=A(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),le),rh=A(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),ih=A(R("g",{children:[h("path",{d:"M4 12 C 5 8, 6 8, 8 12",fill:"none",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8 12 C 9 16, 10 16, 12 12",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M12 12 C 14 8, 15 8, 16 12",fill:"none",strokeWidth:"2.75",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M16 12 C 17 16, 18 16, 19 12",fill:"none",strokeWidth:"3.25",strokeLinecap:"round",strokeLinejoin:"round"})]}),H),S1=A(R("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),le),C1=A(R("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),H),P1=nt.memo(({flip:e=!1})=>A(R("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",opacity:.3,strokeWidth:2,fill:"none",strokeLinecap:"round",children:[h("path",{d:"M7,11 H19"}),h("path",{d:"M25,6 L33,16 M33,6 L25,16"})]}),Lt)),k1=nt.memo(({flip:e=!1})=>A(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M7,11 H33 M23,5 L33,11 L23,17"})}),Lt)),M1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H23",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Lt)),A1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",children:[h("path",{d:"M7,11 H23"}),h("path",{d:"M23,5 L35,11 L23,17 Z"})]}),Lt)),D1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M7,11 H25",strokeWidth:2,strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),Lt)),L1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M7,11 H25",strokeLinecap:"round"}),h("circle",{cx:"29",cy:"11",r:"4"})]}),Lt)),_1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",children:[h("path",{d:"M7,11 H21",strokeWidth:2,strokeLinecap:"round"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Lt)),R1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,strokeLinecap:"round",children:[h("path",{d:"M7,11 H21"}),h("path",{d:"M21,11 L28,5 L35,11 L28,17 Z"})]}),Lt)),N1=nt.memo(({flip:e=!1})=>A(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",strokeLinecap:"round",children:h("path",{d:"M11,11 H31 M31,5 V17"})}),Lt)),B1=nt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17"})}),Lt)),F1=nt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,11 L7,5 M15,11 L7,17"})}),Lt)),O1=nt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M23,5 V17 M15,11 L7,5 M15,11 L7,17"})}),Lt)),z1=nt.memo(({flip:e=!1})=>A(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M35,11 H7 M15,5 V17 M7,5 V17"})}),Lt)),G1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H19 M11,11 H7 M7,5 V17"}),h("circle",{cx:"15",cy:"11",r:"4"})]}),Lt)),H1=nt.memo(({flip:e=!1})=>A(R("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M35,11 H27 M19,11 H7 M15,11 L7,5 M15,11 L7,17"}),h("circle",{cx:"23",cy:"11",r:"4"})]}),Lt)),U1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),W1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),V1=A(R(Ie,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),le),Y1=A(h(Ie,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),le),Yr=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),H),K1=A(h(Ie,{children:R("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),H),Os=A(h(Ie,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),le),XA=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 8l-4 4l4 4"}),h("path",{d:"M17 8l4 4l-4 4"}),h("path",{d:"M14 4l-4 16"})]}),H),Jc=XA,X1=A(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),H),Z1=A(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),H),$1=A(R("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),H),j1=nt.memo(({theme:e})=>A(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),H)),q1=nt.memo(({theme:e})=>A(R("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),H)),J1=nt.memo(({theme:e})=>A(R("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),H)),Qc=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),H),RZ=A(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),NZ=A(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Q1=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),H),ah=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),H),e0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),H),t0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),H),n0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),BZ=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),FZ=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),H),o0=A(R(Ie,{children:[h("path",{d:"M7 5v14"}),h("path",{d:"M19 6l-9 6l9 6z"})]}),H),r0=A(R(Ie,{children:[h("path",{d:"M17 5v14"}),h("path",{d:"M5 6l9 6l-9 6z"})]}),H),i0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 6h16a1 1 0 0 1 1 1v10a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10a1 1 0 0 1 1 -1z"}),h("path",{d:"M7 6v12"}),h("path",{d:"M17 6v12"}),h("path",{d:"M3 10h4"}),h("path",{d:"M3 14h4"}),h("path",{d:"M17 10h4"}),h("path",{d:"M17 14h4"})]}),H),a0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),s0=A(R(Ie,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),H),sh=["M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z","M11 7l6 6"],Ki=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),sh.map(e=>h("path",{d:e},e))]}),H),to=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),H),OZ=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4"}),h("path",{d:"M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"})]}),H),zZ=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l-2 1l8 4l8 -4l-2 -1"}),h("path",{d:"M4 15l8 4l8 -4"}),h("path",{d:"M12 4v7"}),h("path",{d:"M15 8l-3 3l-3 -3"})]}),H),GZ=A(R("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),le),Kr=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 9.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0"}),h("path",{d:"M10 12a2 2 0 0 1 2 -2h7a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2h-7a2 2 0 0 1 -2 -2l0 -7"})]}),H),no=A(R("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),h("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),HZ=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),H),UZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),H),WZ=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),H),VZ=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),H),Xr=A(R("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),H),l0=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),h("path",{d:"M3 3l18 18"})]}),H),YZ=A(R("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),KZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),oo=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),H),XZ=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),H),ZZ=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 8l0 4l2 2"}),h("path",{d:"M3.05 11a9 9 0 1 1 .5 4m-.5 5v-5h5"})]}),H),c0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),H),d0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),H),$Z=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),H),m0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),H),p0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),H),u0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),H),h0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),H),lh=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),H),ed=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),H),g0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),H),f0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),H),Jo=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),H),jZ=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),H),E0=A(R("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...H,strokeWidth:1.5}),qZ=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),H),JZ=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),H),b0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),H),x0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),H),Qo=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),H),er=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),H),tr=A(R("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),td=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),y0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),w0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),ch=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),H),v0=A(R("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),H),dh=A(R("g",{strokeWidth:"1.25",children:[h("rect",{x:"4",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"4",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"10",width:"4",height:"4",rx:"1"}),h("rect",{x:"4",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"10",y:"16",width:"4",height:"4",rx:"1"}),h("rect",{x:"16",y:"16",width:"4",height:"4",rx:"1"})]}),H),mh=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"7",y:"6",width:"10",height:"8",rx:"1",strokeDasharray:"2 2"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"14"}),h("polyline",{points:"2 8 3 6 4 8"}),h("polyline",{points:"2 12 3 14 4 12"}),h("line",{x1:"7",y1:"18",x2:"17",y2:"18"}),h("polyline",{points:"9 17 7 18 9 19"}),h("polyline",{points:"15 17 17 18 15 19"})]}),H),QZ=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 11v8a1 1 0 0 0 1 1h8m-9 -14v-1a1 1 0 0 1 1 -1h1m5 0h2m5 0h1a1 1 0 0 1 1 1v1m0 5v2m0 5v1a1 1 0 0 1 -1 1h-1"}),h("path",{d:"M4 12h7a1 1 0 0 1 1 1v7"})]}),H),ph=A(h("svg",{stroke:"currentColor",fill:"currentColor",strokeWidth:.5,viewBox:"0 0 640 512",children:h("path",{d:"M15 15C24.4 5.7 39.6 5.7 49 15l63 63L112 40c0-13.3 10.7-24 24-24s24 10.7 24 24l0 96c0 13.3-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l38.1 0L15 49C5.7 39.6 5.7 24.4 15 15zM133.5 243.9C158.6 193.6 222.7 112 320 112s161.4 81.6 186.5 131.9c3.8 7.6 3.8 16.5 0 24.2C481.4 318.4 417.3 400 320 400s-161.4-81.6-186.5-131.9c-3.8-7.6-3.8-16.5 0-24.2zM320 320a64 64 0 1 0 0-128 64 64 0 1 0 0 128zM591 15c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9l-63 63 38.1 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-96 0c-13.3 0-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24s24 10.7 24 24l0 38.1 63-63zM15 497c-9.4-9.4-9.4-24.6 0-33.9l63-63L40 400c-13.3 0-24-10.7-24-24s10.7-24 24-24l96 0c13.3 0 24 10.7 24 24l0 96c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-38.1L49 497c-9.4 9.4-24.6 9.4-33.9 0zm576 0l-63-63 0 38.1c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-96c0-13.3 10.7-24 24-24l96 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-38.1 0 63 63c9.4 9.4 9.4 24.6 0 33.9s-24.6 9.4-33.9 0z"})})),I0=A(R("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),H),T0=A(R("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 10l4 -4 L6 14l8 -8 L6 18l12 -12 L10 18l8 -8 L14 18l4 -4"})]}),H),uh=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4"}),h("path",{d:"M13.5 6.5l4 4"})]}),H),e$=A(R("g",{strokeWidth:1,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l-5 5l5 5"}),h("path",{d:"M17 7l-5 5l5 5"})]}),H),t$=A(R("g",{strokeWidth:"1.75",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z"}),h("path",{d:"M15 4l0 16"})]}),H),n$=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 20l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c3.255 2.777 3.695 7.266 1.029 10.501c-2.666 3.235 -7.615 4.215 -11.574 2.293l-4.7 1"})]}),H),o$=A(R("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 4l18 0"}),h("path",{d:"M4 4v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-10"}),h("path",{d:"M12 16l0 4"}),h("path",{d:"M9 20l6 0"}),h("path",{d:"M8 12l3 -3l2 2l3 -3"})]}),H),nd=h("div",{style:{width:"1rem",height:"1rem"}}),S0=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"6 9 12 15 18 9"})]}),H),C0=A(R("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"9 6 15 12 9 18"})]}),H),P0=A(R("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 6l8 0"}),h("path",{d:"M16 6l4 0"}),h("path",{d:"M8 12m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 12l2 0"}),h("path",{d:"M10 12l10 0"}),h("path",{d:"M17 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M4 18l11 0"}),h("path",{d:"M19 18l1 0"})]}),H);import k0 from"clsx";import gh,{useEffect as jA,useRef as M0,useState as qA}from"react";import{isPromiseLike as JA}from"@excalidraw/common";import ZA from"react";import{jsx as hh}from"react/jsx-runtime";var $A=({size:e="1em",circleWidth:n=8,synchronized:t=!1,className:o=""})=>{let i=-(ZA.useRef(Date.now()).current%1600);return hh("div",{className:`Spinner ${o}`,children:hh("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:hh("circle",{cx:"50",cy:"50",r:50-n/2,strokeWidth:n,fill:"none",strokeMiterlimit:"10"})})})},So=$A;import{jsx as zs,jsxs as od}from"react/jsx-runtime";var $=gh.forwardRef(({size:e="medium",visible:n=!0,className:t="",...o},r)=>{let i=gh.useRef(null);gh.useImperativeHandle(r,()=>i.current);let a=`ToolIcon_size_${e}`,[s,l]=qA(!1),c=M0(!0),d=async p=>{let u="onClick"in o&&o.onClick?.(p);if(JA(u))try{l(!0),await u}catch(E){if(E instanceof Rc)console.warn(E);else throw E}finally{c.current&&l(!1)}};jA(()=>(c.current=!0,()=>{c.current=!1}),[]);let m=M0(null);return o.type==="button"||o.type==="icon"?od("button",{className:k0("ToolIcon_type_button",a,t,n&&!o.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!o.hidden,"ToolIcon--plain":o.type==="icon"}),style:o.style,"data-testid":o["data-testid"],hidden:o.hidden,title:o.title,"aria-label":o["aria-label"],type:"button",onClick:d,ref:i,disabled:s||o.isLoading||!!o.disabled,children:[(o.icon||o.label)&&od("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!o.disabled,children:[o.icon||o.label,o.keyBindingLabel&&zs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel}),o.isLoading&&zs(So,{})]}),o.showAriaLabel&&od("div",{className:"ToolIcon__label",children:[o["aria-label"]," ",s&&zs(So,{})]}),o.children]}):zs("button",{className:k0("ToolIcon","ToolIcon_type_toggle",a,t,{"ToolIcon--checked":o.checked}),type:"button",style:o.style,title:o.title,"aria-label":o["aria-label"],"aria-keyshortcuts":o["aria-keyshortcuts"],"aria-pressed":o.checked,"data-testid":o["data-testid"],disabled:!!o.disabled,"aria-disabled":!!o.disabled,onPointerDown:p=>{m.current=p.pointerType||null},onPointerUp:()=>{requestAnimationFrame(()=>{m.current=null})},onClick:()=>{o.onSelect?.({pointerType:m.current})},ref:i,children:od("div",{className:"ToolIcon__icon",children:[o.icon,o.keyBindingLabel&&zs("span",{className:"ToolIcon__keybinding",children:o.keyBindingLabel})]})})});$.displayName="IconButton";var rd=[],O=e=>(rd=rd.concat(e),e);import{jsx as s3}from"react/jsx-runtime";var a3=(e,n,t)=>{let o=new Set(de(e.filter(d=>o3(d)),n).map(d=>d.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let d of o){let m=r3(e,d);for(let p of m)if(!a.has(p.id)){if(id(p)){let u=D0(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let s=!0,l=e.map(d=>{if(n.selectedElementIds[d.id]){let m=id(d)?D0(d,i):null;return d.frameId&&o.has(d.frameId)?(s=!1,r[d.id]=!0,d):m?.frameId&&o.has(m?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&n3(u)&&t.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),sd(d,{isDeleted:!0}))}return d.frameId&&o.has(d.frameId)?(s=!1,id(d)||(r[d.id]=!0),sd(d,{frameId:null})):id(d)&&n.selectedElementIds[d.containerId]?sd(d,{isDeleted:!0}):d}),c=n.editingGroupId;if(s&&n.editingGroupId){let d=Eh(l,n.editingGroupId).filter(m=>!m.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{c=null,d[0]&&(r[d[0].id]=!0);let m=d[0];if(m){let p=m.groupIds.findIndex(E=>E===n.editingGroupId),u=m.groupIds[p+1];if(u){let E=Eh(l,u).filter(g=>!g.isDeleted);E.length>1&&(c=u,E.forEach(g=>{r[g.id]=!0}))}}}}return{elements:l,appState:{...n,...i3({selectedElementIds:r,editingGroupId:c},ld(l),n,null)}}},L0=(e,n)=>{if(e.editingGroupId){let t=Eh(ld(n),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Gs=O({name:"deleteSelectedElements",label:"labels.delete",icon:Vr,trackEvent:{category:"element",action:"delete"},perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:s}=n.selectedLinearElement,l=o.scene.getNonDeletedElementsMap(),c=A0.getElement(a,l);if(!c||s==null)return!1;if(s.length>=c.points.length){let d=e.map(p=>p.id===c.id?sd(p,{isDeleted:!0}):p),m=L0(n,d);return{elements:d,appState:{...m,selectedLinearElement:null},captureUpdate:ad.IMMEDIATELY}}return A0.deletePoints(c,o,s),{elements:e,appState:{...n,selectedLinearElement:{...n.selectedLinearElement,selectedPointsIndices:s?.[0]>0?[s[0]-1]:[0]}},captureUpdate:ad.IMMEDIATELY}}let{elements:r,appState:i}=a3(e,n,o);return t3(r,r.filter(a=>a.isDeleted)),i=L0(i,r),{elements:r,appState:{...i,activeTool:e3(n,{type:o.state.preferredSelectionTool.type}),multiElement:null,newElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ne(ld(e),n)?ad.IMMEDIATELY:ad.EVENTUALLY}},keyTest:(e,n,t)=>(e.key===fh.BACKSPACE||e.key===fh.DELETE)&&!e[fh.CTRL_OR_CMD],PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=mt()==="mobile";return s3($,{type:"button",icon:Vr,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),disabled:!Ne(ld(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?QA:{}}})}});import{KEYS as Xi,CODES as Zi,isDarwin as cd}from"@excalidraw/common";import{moveOneLeft as l3,moveOneRight as c3,moveAllLeft as d3,moveAllRight as m3}from"@excalidraw/element";import{CaptureUpdateAction as dd}from"@excalidraw/element";import{isDarwin as _0}from"@excalidraw/common";var N=e=>e.replace(/\b(Opt(?:ion)?|Alt)\b/i,_0?f("keys.option"):f("keys.alt")).replace(/\bShift\b/i,f("keys.shift")).replace(/\b(Enter|Return)\b/i,f("keys.enter")).replace(/\b(Ctrl|Cmd|Command|CtrlOrCmd)\b/gi,_0?f("keys.cmd"):f("keys.ctrl")).replace(/\b(Esc(?:ape)?)\b/i,f("keys.escape")).replace(/\b(Space(?:bar)?)\b/i,f("keys.spacebar")).replace(/\b(Del(?:ete)?)\b/i,f("keys.delete"));import{jsx as md}from"react/jsx-runtime";var bh=O({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Ku,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:l3(e,n,o.scene),appState:n,captureUpdate:dd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Xi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Zi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>md("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${N("CtrlOrCmd+[")}`,children:Ku})}),xh=O({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Yu,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:c3(e,n,o.scene),appState:n,captureUpdate:dd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Xi.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Zi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>md("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${N("CtrlOrCmd+]")}`,children:Yu})}),yh=O({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Zu,trackEvent:{category:"element"},perform:(e,n)=>({elements:d3(e,n),appState:n,captureUpdate:dd.IMMEDIATELY}),keyTest:e=>cd?e[Xi.CTRL_OR_CMD]&&e.altKey&&e.code===Zi.BRACKET_LEFT:e[Xi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Zi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:n})=>md("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${cd?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")}`,children:Zu})}),wh=O({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Xu,trackEvent:{category:"element"},perform:(e,n)=>({elements:m3(e,n),appState:n,captureUpdate:dd.IMMEDIATELY}),keyTest:e=>cd?e[Xi.CTRL_OR_CMD]&&e.altKey&&e.code===Zi.BRACKET_RIGHT:e[Xi.CTRL_OR_CMD]&&e.shiftKey&&e.code===Zi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:n})=>md("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${cd?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")}`,children:Xu})});import{getNonDeletedElements as p3}from"@excalidraw/element";import{LinearElementEditor as u3}from"@excalidraw/element/linearElementEditor";import{isLinearElement as h3,isTextElement as g3}from"@excalidraw/element";import{arrayToMap as f3,KEYS as R0}from"@excalidraw/common";import{selectGroupsForSelectedElements as E3}from"@excalidraw/element";import{CaptureUpdateAction as b3}from"@excalidraw/element";var vh=O({name:"selectAll",label:"labels.selectAll",icon:m0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,n,t,o)=>{if(n.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(g3(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...n,...E3({editingGroupId:null,selectedElementIds:r},p3(e),n,o),selectedLinearElement:Object.keys(r).length===1&&h3(e[0])?new u3(e[0],f3(e)):null},captureUpdate:b3.IMMEDIATELY}},keyTest:e=>e[R0.CTRL_OR_CMD]&&e.key===R0.A});import{DEFAULT_GRID_SIZE as N0,KEYS as B0,MOBILE_ACTION_BUTTON_BG as x3,arrayToMap as F0}from"@excalidraw/common";import{getNonDeletedElements as O0}from"@excalidraw/element";import{LinearElementEditor as y3}from"@excalidraw/element/linearElementEditor";import{getSelectedElements as w3,getSelectionStateForElements as v3}from"@excalidraw/element";import{syncMovedIndices as I3}from"@excalidraw/element";import{duplicateElements as T3}from"@excalidraw/element";import{CaptureUpdateAction as z0}from"@excalidraw/element";import{jsx as S3}from"react/jsx-runtime";var Ih=O({name:"duplicateSelection",label:"labels.duplicateSelection",icon:_s,trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(n.selectedElementsAreBeingDragged)return!1;if(n.selectedLinearElement?.isEditing)try{let a=y3.duplicateSelectedPoints(n,o.scene);return{elements:e,appState:a,captureUpdate:z0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=T3({type:"in-place",elements:e,idsOfElementsToDuplicate:F0(w3(e,n,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:n,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:s})=>{let l=a.frameId&&s.get(a.frameId);return{x:a.x+N0/2,y:a.y+N0/2,frameId:l??a.frameId}}});if(o.props.onDuplicate&&i){let a=o.props.onDuplicate(i,e);a&&(i=a)}return{elements:I3(i,F0(r)),appState:{...n,...v3(r,O0(i),n)},captureUpdate:z0.IMMEDIATELY}},keyTest:e=>e[B0.CTRL_OR_CMD]&&e.key===B0.D,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=mt()==="mobile";return S3($,{type:"button",icon:_s,title:`${f("labels.duplicateSelection")} \u2014 ${N("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),disabled:!Ne(O0(e),n),style:{...r&&n.openPopup!=="compactOtherProperties"?x3:{}}})}});import{pointFrom as r6}from"@excalidraw/math";import{useEffect as Vh,useMemo as Xh,useRef as Yh,useState as i6}from"react";import{BUCKET_FILL_BACKGROUND_PICKS as a6,COLOR_PALETTE as s6,DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Ky,DEFAULT_ELEMENT_BACKGROUND_PICKS as l6,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as c6,DEFAULT_ELEMENT_STROKE_PICKS as d6,ARROW_TYPE as dn,DEFAULT_FONT_FAMILY as m6,DEFAULT_FONT_SIZE as p6,FONT_FAMILY as u6,ROUNDNESS as Ld,STROKE_WIDTH_KEYS as h6,VERTICAL_ALIGN as Ad,KEYS as ra,randomInteger as g6,arrayToMap as Zh,getFontFamilyString as f6,getLineHeight as E6,isTransparent as b6,getStrokeWidthByKey as Xy,reduceToCommonValue as x6,invariant as Rd,FONT_SIZES as Dd}from"@excalidraw/common";import{canBecomePolygon as y6,getNonDeletedElements as Zy,isNonDeletedElement as w6}from"@excalidraw/element";import{bindBindingElement as Hy,calculateFixedPointForElbowArrowBinding as Uy,updateBoundElements as v6}from"@excalidraw/element";import{LinearElementEditor as $r}from"@excalidraw/element/linearElementEditor";import{newElementWith as st}from"@excalidraw/element";import{getArrowheadForPicker as Wy}from"@excalidraw/element";import{getBoundTextElement as cr,redrawTextBoundingBox as Qs}from"@excalidraw/element";import{isArrowElement as _d,isBoundToContainer as I6,isElbowArrow as $y,isLinearElement as Kh,isLineElement as Vy,isTextElement as Wt,isUsingAdaptiveRadius as T6}from"@excalidraw/element";import{hasStrokeColor as S6}from"@excalidraw/element";import{updateElbowArrowPoints as C6,CaptureUpdateAction as ot,toggleLinePolygonState as P6}from"@excalidraw/element";import{deriveStylesPanelMode as k6}from"@excalidraw/common";import{isDevEnv as C3}from"@excalidraw/common";var P3=new Set(["command_palette","export"]),We=(e,n,t,o)=>{try{if(typeof window>"u"||S.VITE_WORKER_ID||S.VITE_APP_ENABLE_TRACKING!=="true"||!P3.has(e)||C3())return;S.PROD||console.info("trackEvent",{category:e,action:n,label:t,value:o}),window.sa_event&&window.sa_event(n,{category:e,label:t,value:o})}catch(r){console.error("error during analytics",r)}};import D3 from"clsx";import k3 from"clsx";import{forwardRef as M3}from"react";import{jsx as A3}from"react/jsx-runtime";var G0=M3((e,n)=>{let{title:t,className:o,testId:r,active:i,icon:a,onClick:s}=e;return A3("button",{type:"button",ref:n,title:t,"data-testid":r,className:k3(o,{active:i}),onClick:s,style:e.style,children:a},t)});import{Fragment as _3,jsx as Th,jsxs as L3}from"react/jsx-runtime";var qt=e=>Th(_3,{children:e.options.map(n=>e.type==="button"?Th(G0,{icon:n.icon,title:n.text,testId:n.testId,active:n.active??e.value===n.value,onClick:t=>e.onClick(n.value,t)},n.text):L3("label",{className:D3({active:e.value===n.value}),title:n.text,children:[Th("input",{type:"radio",name:e.group,onChange:()=>e.onChange(n.value),checked:e.value===n.value,"data-testid":n.testId}),n.icon]},n.text))});import{Popover as xy}from"radix-ui";import yy from"clsx";import{memo as e4,useRef as wy,useEffect as t4}from"react";import{applyDarkModeFilter as n4,COLOR_OUTLINE_CONTRAST_THRESHOLD as Ey,COLOR_PALETTE as vy,DEFAULT_ELEMENT_BACKGROUND_PICKS as o4,DEFAULT_ELEMENT_STROKE_PICKS as r4,isColorDark as by,isWritableElement as i4,THEME as a4}from"@excalidraw/common";import{jsx as R3}from"react/jsx-runtime";var pd=()=>R3("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as G3,useLayoutEffect as H3,useRef as U3}from"react";import{createPortal as W3}from"react-dom";import{EVENT as nr,isColorDark as V3,KEYS as Y3,MIME_TYPES as K3,THEME as X3,removeDarkModeFilter as Z3,rgbToHex as $3}from"@excalidraw/common";import H0 from"react";var Sh=H0.createContext(null),ye=()=>H0.useContext(Sh);import{useState as N3,useLayoutEffect as U0}from"react";import{THEME as B3}from"@excalidraw/common";var ud=e=>{let[n,t]=N3(null),o=fe(),{theme:r}=ye(),{container:i}=ze();return U0(()=>{n&&(n.className="",n.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),n.classList.toggle("excalidraw--mobile",o.formFactor==="phone"),n.classList.toggle("theme--dark",r===B3.DARK))},[n,r,o.formFactor,e?.className]),U0(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let s=document.createElement("div");return a.appendChild(s),t(s),()=>{a.removeChild(s)}},[i,e?.parentSelector]),n};import{useEffect as F3}from"react";import{EVENT as hd}from"@excalidraw/common";function $i(e,n,t){F3(()=>{function o(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return n(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||n(i)}return document.addEventListener(hd.POINTER_DOWN,o),document.addEventListener(hd.TOUCH_START,o),()=>{document.removeEventListener(hd.POINTER_DOWN,o),document.removeEventListener(hd.TOUCH_START,o)}},[e,n,t])}import{useRef as O3}from"react";var ji=e=>{let n=O3(e);return Object.assign(n.current,e),n.current};import{clamp as z3}from"@excalidraw/math";var W0=({cursorPosition:e,elementSize:n,containerSize:t,gap:o})=>{let r=e+o+n>t?e-o-n:e+o;return z3(r,0,Math.max(0,t-n))},gd=({cursor:e,element:n,container:t,gap:o})=>({left:W0({cursorPosition:e.x-t.left,elementSize:n.width,containerSize:t.width,gap:o}),top:W0({cursorPosition:e.y-t.top,elementSize:n.height,containerSize:t.height,gap:o})});import{jsx as q3}from"react/jsx-runtime";var V0=sh.map((e,n)=>`<path fill="${n===0?"#fff":""}" d="${e}" />`).join(""),j3=`url(data:${K3.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" stroke-width="5">${V0}</g><g stroke="#1b1b1f" stroke-width="1.25">${V0}</g></svg>`)}) 2 21, auto`,Ut=Qe(null),Y0=({onCancel:e,onChange:n,onSelect:t,colorPickerType:o})=>{let r=ud({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ye(),a=qi(),s=xt(),l=de(a,i),c=ji({app:s,onCancel:e,onChange:n,onSelect:t,selectedElements:l}),{container:d}=ze();H3(()=>{if(r)return r.style.cursor=j3,()=>{r.style.cursor=""}},[r]),G3(()=>{let p=m.current;if(!p||!s.canvas||!r)return;let u=!1,E=s.canvas.getContext("2d"),g=({clientX:P,clientY:M})=>{let D=E.getImageData((P-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return $3(D[0],D[1],D[2])},b=P=>i.theme===X3.DARK?Z3(P):P,v=({clientX:P,clientY:M,altKey:D})=>{let{top:_,left:k}=gd({cursor:{x:P,y:M},element:{width:p.offsetWidth,height:p.offsetHeight},container:r.getBoundingClientRect(),gap:7});p.style.top=`${_}px`,p.style.left=`${k}px`;let L=g({clientX:P,clientY:M});u&&c.onChange(o,b(L),c.selectedElements,{altKey:D}),p.style.background=L,p.style.setProperty("--eye-dropper-preview-border-color",V3(L)?"#fff":"#222")},w=()=>{c.onCancel()},x=(P,M)=>{c.onSelect(P,M)},I=P=>{u=!0,P.stopImmediatePropagation()},T=P=>{u=!1,d?.focus(),P.stopImmediatePropagation(),P.preventDefault(),x(b(g(P)),P)},C=P=>{P.key===Y3.ESCAPE&&(P.preventDefault(),P.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),v({clientX:c.app.viewport.lastPosition.x,clientY:c.app.viewport.lastPosition.y,altKey:!1}),r.addEventListener(nr.KEYDOWN,C),r.addEventListener(nr.POINTER_DOWN,I),r.addEventListener(nr.POINTER_UP,T),window.addEventListener("pointermove",v,{passive:!0}),window.addEventListener(nr.BLUR,w),()=>{u=!1,r.removeEventListener(nr.KEYDOWN,C),r.removeEventListener(nr.POINTER_DOWN,I),r.removeEventListener(nr.POINTER_UP,T),window.removeEventListener("pointermove",v),window.removeEventListener(nr.BLUR,w)}},[c,s.canvas,r,o,d,i.offsetLeft,i.offsetTop,i.theme]);let m=U3(null);return $i(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?W3(q3("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import{Popover as Ch}from"radix-ui";import t5 from"clsx";import n5 from"react";import{isInteractive as o5}from"@excalidraw/common";import J3 from"react";import Q3 from"clsx";import{jsx as e5}from"react/jsx-runtime";var Ze=J3.forwardRef(({children:e,padding:n,className:t,style:o,"data-viewport-ui":r,"data-viewport-ui-name":i},a)=>e5("div",{className:Q3("Island",t),style:{"--padding":n,...o},"data-viewport-ui":r,"data-viewport-ui-name":i,ref:a,children:e}));import{jsx as Ph,jsxs as r5}from"react/jsx-runtime";var Co=n5.forwardRef(({className:e,container:n,children:t,style:o,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:s,onPointerDownOutside:l,preventAutoFocusOnTouch:c=!1},d)=>{let m=fe(),p=m.formFactor==="phone"&&!m.isLandscape;return Ph(Ch.Portal,{container:n,children:r5(Ch.Content,{ref:d,className:t5("focus-visible-none",e),"data-prevent-outside-click":!0,side:p?"bottom":"right",align:p?"center":"start",alignOffset:-16,sideOffset:20,collisionBoundary:n??void 0,style:{zIndex:"var(--zIndex-ui-styles-popup)",marginLeft:m.formFactor==="phone"?"0.5rem":void 0},onPointerLeave:s,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:l,onOpenAutoFocus:u=>{c&&m.isTouchScreen&&u.preventDefault()},onCloseAutoFocus:u=>{u.stopPropagation(),u.preventDefault(),n&&!o5(document.activeElement)&&n.focus(),r()},children:[Ph(Ze,{padding:3,style:o,children:t}),Ph(Ch.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 i5,useCallback as kh}from"react";var fd=()=>document.querySelector(".excalidraw-wysiwyg"),Ed=()=>{let e=fd();return e?{start:e.selectionStart,end:e.selectionEnd}:null},Hs=e=>{setTimeout(()=>{let n=fd();n&&(n.focus(),e&&(n.selectionStart=e.start,n.selectionEnd=e.end))},0)},Us=(e,n,t,o)=>{n&&o&&o();let r=n&&t?Ed():null;e(),n&&t&&Hs(r)},K0=()=>{let[e,n]=i5(null),t=kh(()=>{let i=Ed();n(i)},[]),o=kh(()=>{setTimeout(()=>{let i=fd();i&&(i.focus(),e&&(i.selectionStart=e.start,i.selectionEnd=e.end,n(null)))},0)},[e]),r=kh(()=>{n(null)},[]);return{saveCaretPosition:t,restoreCaretPosition:o,clearSavedPosition:r,hasSavedPosition:!!e}},X0=(e=100)=>{let n=fd();if(n){let t=n.onblur;n.onblur=null,setTimeout(()=>{n.onblur=t},e)}};import $0 from"clsx";import{useCallback as l5,useEffect as Ah,useRef as j0,useState as q0}from"react";import{KEYS as Dh,normalizeInputColor as c5}from"@excalidraw/common";import{isTransparent as a5,MAX_CUSTOM_COLORS_USED_IN_CANVAS as s5}from"@excalidraw/common";var or=({palette:e,color:n})=>{if(!n)return null;for(let[t,o]of Object.entries(e))if(Array.isArray(o)){let r=o.indexOf(n);if(r>-1)return{colorName:t,shade:r}}else if(o===n)return{colorName:t,shade:null};return null},Ws=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Mh=({color:e,palette:n})=>!Object.values(n).flat().includes(e),Z0=(e,n,t)=>{let o={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let s=a[o[n]];return!a5(s)&&Mh({color:s,palette:t})}),i=new Map;return r.forEach(a=>{let s=a[o[n]];i.has(s)?i.set(s,i.get(s)+1):i.set(s,1)}),[...i.entries()].sort((a,s)=>s[1]-a[1]).map(a=>a[0]).slice(0,s5)},sn=Qe(null);import{Fragment as d5,jsx as Vs,jsxs as Lh}from"react/jsx-runtime";var J0=({color:e,onChange:n,label:t,colorPickerType:o,placeholder:r})=>{let i=fe(),[a,s]=q0(e),[l,c]=q0(null),[d,m]=Xe(sn);Ah(()=>{s(e)},[e]);let p=l5(v=>{let w=v.toLowerCase().trim(),x=c5(w);x?(n(x),c(null)):w.length===0?c(null):/^#?[0-9a-f]+$/.test(w)?c(f("colorPicker.invalidHexLength")):c(f("colorPicker.invalidColor")),s(w)},[n]),u=j0(null),E=j0(null);Ah(()=>{u.current&&u.current.focus()},[d]);let[g,b]=Xe(Ut);return Ah(()=>()=>{b(null)},[b]),Lh("div",{className:"color-picker__input-label-container",children:[Lh("div",{className:$0("color-picker__input-label",{"has-error":l}),children:[Vs("div",{className:"color-picker__input-hash",children:"#"}),Vs("input",{ref:d==="hex"?u:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,"aria-invalid":!!l,onChange:v=>{p(v.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{s(e),c(null)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:v=>{v.key!==Dh.TAB&&(v.key===Dh.ESCAPE&&E.current?.focus(),v.stopPropagation())},placeholder:r}),i.formFactor!=="phone"&&Lh(d5,{children:[Vs("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Vs("div",{ref:E,className:$0("excalidraw-eye-dropper-trigger",{selected:g}),onClick:()=>b(v=>v?null:{keepOpenOnAlt:!1,onSelect:w=>n(w),colorPickerType:o}),title:`${f("labels.eyeDropper")} \u2014 ${Dh.I.toLocaleUpperCase()} or ${N("Alt")} `,children:Ki})]})]}),l&&Vs("div",{className:"color-picker__error-message",role:"alert",children:l})]})};import Nh,{useEffect as Bh,useImperativeHandle as U5,useState as W5}from"react";import{EVENT as py}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as V5,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as Y5,KEYS as K5}from"@excalidraw/common";import x5 from"clsx";import{useEffect as y5,useRef as w5}from"react";import{applyDarkModeFilter as v5,THEME as I5}from"@excalidraw/common";import{isColorDark as m5}from"@excalidraw/common";import{jsxs as u5}from"react/jsx-runtime";var p5=({color:e,keyLabel:n,isShade:t=!1})=>u5("div",{className:"color-picker__button__hotkey-label",style:{color:m5(e)?"#fff":"#000"},children:[t&&"\u21E7",n]}),Ji=p5;import{createContext as h5,useContext as g5,useEffect as f5,useMemo as Q0,useRef as ey,useState as E5}from"react";import{colorToHex as ty,isTransparent as b5}from"@excalidraw/common";var Zr="excalidraw-color-dnd-ghost",ny="excalidraw-color-dnd-active",oy=10,ry=100,iy=(e,n)=>{if(e.toLowerCase()===n.toLowerCase())return!0;let t=ty(e);return t!==null&&t===ty(n)},_h=h5(null),ln=()=>g5(_h),ay=({enabled:e,picks:n,onPicksChange:t})=>{let[o,r]=E5(null),i=ey(null),a=ey({enabled:e,picks:n,onPicksChange:t});a.current={enabled:e,picks:n,onPicksChange:t};let s=Q0(()=>{let l=null,c=()=>{l?.activated?r({color:l.color,origin:l.origin,overIndex:l.overIndex,duplicateIndex:l.duplicateIndex,slotSpan:l.slotSpan}):r(null)},d=()=>{let k=i.current;if(!k||!l)return!1;let L=Array.from(k.querySelectorAll("[data-top-pick-index]")).sort((W,G)=>Number(W.dataset.topPickIndex)-Number(G.dataset.topPickIndex));if(!L.length)return!1;l.slotRects=L.map(W=>W.getBoundingClientRect());let[F,K]=l.slotRects;l.slotSpan=K?K.left-F.left:F.width+4;let z=k.getBoundingClientRect(),U=Math.max(Math.abs(l.slotSpan)/2,10);return l.hitRect={left:z.left-U,right:z.right+U,top:z.top-14,bottom:z.bottom+14},!0},m=(k,L)=>{l?.ghost&&(l.ghost.style.transform=`translate(${k-l.ghostW/2}px, ${L-l.ghostH/2}px)`)},p=(k,L,F,K)=>{l?.ghost&&(l.ghostW!==k||l.ghostH!==L)&&(l.ghostW=k,l.ghostH=L,l.ghost.style.width=`${k}px`,l.ghost.style.height=`${L}px`,m(F,K))},u=(k,L)=>{if(!l)return;let{sourceRect:F,sourceEl:K,color:z}=l,U=document.createElement("div");U.className=Zr;let W=document.createElement("div");if(W.className=`${Zr}__swatch`,b5(z))W.classList.add("is-transparent");else{let G=getComputedStyle(K).backgroundColor;W.style.backgroundColor=G&&G!=="rgba(0, 0, 0, 0)"?G:z}U.appendChild(W),document.body.appendChild(U),l.ghost=U,l.ghostW=F.width,l.ghostH=F.height,U.style.width=`${F.width}px`,U.style.height=`${F.height}px`,m(k,L),requestAnimationFrame(()=>{l?.ghost===U&&U.classList.add(`${Zr}--lifted`)}),document.body.classList.add(ny),l.activated=!0,c()},E=(k,L)=>{if(!l?.hitRect)return;let{hitRect:F,slotRects:K}=l,z=null,U=null;if(k>=F.left&&k<=F.right&&L>=F.top&&L<=F.bottom){let W=0,G=1/0;if(K.forEach((ie,me)=>{let B=Math.abs(k-(ie.left+ie.width/2));B<G&&(G=B,W=me)}),l.origin.kind==="swatch"){let ie=a.current.picks.findIndex(me=>iy(me,l.color));ie!==-1?U=ie:z=W}else z=W}if(z!==l.overIndex||U!==l.duplicateIndex){l.overIndex=z,l.duplicateIndex=U;let{ghost:W}=l;W&&(W.classList.toggle(`${Zr}--over`,z!==null),W.classList.toggle(`${Zr}--blocked`,U!==null)),c()}if(z!==null){let W=l.slotRects[z];p(W.width,W.height,k,L)}else p(l.sourceRect.width,l.sourceRect.height,k,L)},g=k=>{if(!l?.ghost)return;let{ghost:L}=l;l.ghost=null,L.classList.add(`${Zr}--dropping`);let F=k.rect;F&&(L.style.width=`${F.width}px`,L.style.height=`${F.height}px`,L.style.transform=`translate(${F.left}px, ${F.top}px)`),window.setTimeout(()=>{L.classList.add(`${Zr}--fade`)},160),window.setTimeout(()=>{L.remove()},340)},b=()=>{let k=i.current;if(!k||!l?.activated)return;let L=Array.from(k.querySelectorAll("[data-top-pick-index]"));for(let F of L)F.style.transition="none",F.style.transform="none";k.offsetWidth;for(let F of L)F.style.transition=""},v=()=>{let k=L=>{L.preventDefault(),L.stopPropagation()};window.addEventListener("click",k,{capture:!0,once:!0}),window.setTimeout(()=>{window.removeEventListener("click",k,{capture:!0})},100)},w=()=>{window.removeEventListener("pointermove",C,!0),window.removeEventListener("pointerup",P,!0),window.removeEventListener("pointercancel",M,!0),window.removeEventListener("keydown",D,!0)},x=()=>{w(),document.body.classList.remove(ny),l?.activationTimer!=null&&window.clearTimeout(l.activationTimer),l=null,r(null)},I=k=>{l&&(b(),l.ghost&&(k?g({rect:l.sourceRect}):(l.ghost.remove(),l.ghost=null)),x())},T=(k,L)=>{if(!(!l||l.activated)){if(!d()){x();return}u(k,L),E(k,L)}},C=k=>{if(!(!l||k.pointerId!==l.pointerId)){if(l.lastX=k.clientX,l.lastY=k.clientY,!l.activated){if(Math.hypot(k.clientX-l.startX,k.clientY-l.startY)<oy){l.activationTimer!==null&&(window.clearTimeout(l.activationTimer),l.activationTimer=null);return}let L=performance.now()-l.startTime;if(L<ry){l.activationTimer===null&&(l.activationTimer=window.setTimeout(()=>{l&&(l.activationTimer=null,Math.hypot(l.lastX-l.startX,l.lastY-l.startY)>=oy&&T(l.lastX,l.lastY))},ry-L));return}if(T(k.clientX,k.clientY),!l?.activated)return}k.preventDefault(),m(k.clientX,k.clientY),E(k.clientX,k.clientY)}},P=k=>{if(!l||k.pointerId!==l.pointerId)return;if(!l.activated){x();return}k.preventDefault(),k.stopPropagation(),v();let{overIndex:L,origin:F,color:K,slotRects:z}=l,{picks:U,onPicksChange:W}=a.current;if(b(),L!==null){if(F.kind==="swatch"){if(!U.some(G=>iy(G,K))){let G=[...U];G[L]=K,W(G)}}else if(F.index!==L){let G=[...U],[ie]=G.splice(F.index,1);G.splice(L,0,ie),W(G)}g({rect:z[L]})}else g({rect:l.sourceRect});x()},M=k=>{l&&k.pointerId===l.pointerId&&I(!0)},D=k=>{l?.activated&&k.key==="Escape"&&(k.preventDefault(),k.stopPropagation(),I(!0))};return{begin:(k,L,F)=>{!a.current.enabled||l||k.button!==0||!L||(l={pointerId:k.pointerId,startX:k.clientX,startY:k.clientY,startTime:performance.now(),lastX:k.clientX,lastY:k.clientY,activationTimer:null,color:L,origin:F,sourceEl:k.currentTarget,sourceRect:k.currentTarget.getBoundingClientRect(),activated:!1,ghost:null,ghostW:0,ghostH:0,slotRects:[],slotSpan:0,hitRect:null,overIndex:null,duplicateIndex:null},window.addEventListener("pointermove",C,!0),window.addEventListener("pointerup",P,!0),window.addEventListener("pointercancel",M,!0),window.addEventListener("keydown",D,!0))},destroy:()=>I(!1)}},[]);return f5(()=>()=>s.destroy(),[s]),Q0(()=>({dragState:o,startSwatchDrag:(l,c)=>s.begin(l,c,{kind:"swatch"}),startPickDrag:(l,c,d)=>s.begin(l,d,{kind:"pick",index:c}),setStripEl:l=>{i.current=l}}),[o,s])};import{jsx as Rh,jsxs as T5}from"react/jsx-runtime";var sy=({theme:e,colors:n,color:t,onChange:o,label:r})=>{let[i,a]=Xe(sn),s=ln(),l=w5(null);return y5(()=>{l.current&&l.current.focus()},[t,i]),Rh("div",{className:"color-picker-content--default",children:n.map((c,d)=>{let m=v5(c,e===I5.DARK);return T5("button",{ref:t===c?l:void 0,tabIndex:-1,type:"button",className:x5("color-picker__button color-picker__button--large has-outline",{active:t===c,"is-transparent":c==="transparent"||!c}),onClick:()=>{o(c),a("custom")},onPointerDown:s?p=>s.startSwatchDrag(p,c):void 0,title:c,"aria-label":r,style:{"--swatch-color":m},children:[Rh("div",{className:"color-picker__button-outline"}),Rh(Ji,{color:m,keyLabel:d+1})]},d)})})};import S5 from"clsx";import{useEffect as C5,useRef as P5}from"react";import{applyDarkModeFilter as k5,isColorDark as M5,THEME as A5}from"@excalidraw/common";import{jsx as bd,jsxs as L5}from"react/jsx-runtime";var D5=({theme:e,palette:n,color:t,onChange:o,activeShade:r,showHotKey:i=!0,excludedColors:a})=>{let s=or({color:t,palette:n}),[l,c]=Xe(sn),d=ln(),m=P5(null);return C5(()=>{m.current&&l==="baseColors"&&m.current.focus()},[s?.colorName,l]),bd("div",{className:"color-picker-content--default",children:Object.entries(n).map(([p,u],E)=>{let g=(Array.isArray(u)?u[r]:u)||"transparent";if(a?.includes(g))return bd("div",{className:"color-picker__button color-picker__button--large",style:{visibility:"hidden"},"aria-hidden":"true"},p);let b=Ws[E],v=k5(g,e===A5.DARK),w=f(`colors.${p.replace(/\d+/,"")}`,null,"");return L5("button",{ref:s?.colorName===p?m:void 0,tabIndex:-1,type:"button",className:S5("color-picker__button color-picker__button--large",{"has-outline":!M5(g,255),active:s?.colorName===p,"is-transparent":g==="transparent"||!g}),onClick:()=>{o(g),c("baseColors")},onPointerDown:d?x=>d.startSwatchDrag(x,g):void 0,title:`${w}${g.startsWith("#")?` ${g}`:""} \u2014 ${b}`,"aria-label":`${w} \u2014 ${b}`,style:g?{"--swatch-color":v}:void 0,"data-testid":`color-${p}`,children:[bd("div",{className:"color-picker__button-outline"}),i&&bd(Ji,{color:v,keyLabel:b})]},p)})})},ly=D5;import{jsx as R5}from"react/jsx-runtime";var _5=({children:e})=>R5("div",{className:"color-picker__heading",children:e}),Qi=_5;import N5 from"clsx";import{useEffect as B5,useRef as F5}from"react";import{applyDarkModeFilter as O5,THEME as z5}from"@excalidraw/common";import{jsx as Ys,jsxs as cy}from"react/jsx-runtime";var dy=({theme:e,color:n,onChange:t,palette:o,showHotKey:r})=>{let i=or({color:n||"transparent",palette:o}),[a,s]=Xe(sn),l=ln(),c=F5(null);if(B5(()=>{c.current&&a==="shades"&&c.current.focus()},[i,a]),i){let{colorName:d,shade:m}=i,p=o[d];if(Array.isArray(p))return Ys("div",{className:"color-picker-content--default shades",children:p.map((u,E)=>{let g=O5(u,e===z5.DARK);return cy("button",{ref:E===m&&a==="shades"?c:void 0,tabIndex:-1,type:"button",className:N5("color-picker__button color-picker__button--large",{active:E===m}),"aria-label":"Shade",title:`${d} - ${E+1}`,style:u?{"--swatch-color":g}:void 0,onClick:()=>{t(u),s("shades")},onPointerDown:l?b=>l.startSwatchDrag(b,u):void 0,children:[Ys("div",{className:"color-picker__button-outline"}),r&&Ys(Ji,{color:g,keyLabel:E+1,isShade:!0})]},E)})})}return cy("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Ys("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Ys("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:f("colorPicker.noShades")})]})};import{COLORS_PER_ROW as ea,COLOR_PALETTE as G5,KEYS as Ks}from"@excalidraw/common";var xd=(e,n,t)=>{let o=Math.ceil(t/ea);switch(n=n??-1,e){case"ArrowLeft":{let r=n-1;return r<0?t-1:r}case"ArrowRight":return(n+1)%t;case"ArrowDown":{let r=n+ea;return r>=t?n%ea:r}case"ArrowUp":{let r=n-ea,i=r<0?ea*o+r:r;return i>=t?void 0:i}}},H5=({e,colorObj:n,onChange:t,palette:o,customColors:r,setActiveColorPickerSection:i,activeShade:a,excludedColors:s})=>{if(n?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(o[n.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&r[Number(e.key)-1])return t(r[Number(e.key)-1]),i("custom"),!0;if(Ws.includes(e.key)){let l=Ws.indexOf(e.key),c=Object.keys(o)[l],d=o[c],m=Array.isArray(d)?d[a]:d;return m==null||s?.includes(m)||(t(m),i("baseColors")),!0}return!1},my=({event:e,activeColorPickerSection:n,palette:t,color:o,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:s,activeShade:l,onEyeDropperToggle:c,onEscape:d,excludedColors:m})=>{if(e[Ks.CTRL_OR_CMD])return!1;if(e.key===Ks.ESCAPE)return d(e),!0;if(e.key===Ks.ALT)return c(!0),!0;if(e.key===Ks.I)return c(),!0;let p=or({color:o,palette:t});if(e.key===Ks.TAB){let u={custom:!!i.length,baseColors:!0,shades:p?.shade!=null,hex:!0},E=Object.entries(u).reduce((x,[I,T])=>(T&&x.push(I),x),[]),g=E.indexOf(n),b=e.shiftKey?-1:1,v=g+b>E.length-1?0:g+b<0?E.length-1:g+b,w=E[v];return w&&a(w),w==="custom"?r(i[0]):w==="baseColors"&&(Object.entries(t).find(([I,T])=>Array.isArray(T)?T.includes(o):T===o?I:null)||r(G5.black)),e.preventDefault(),e.stopPropagation(),!0}if(H5({e,colorObj:p,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:l,excludedColors:m}))return!0;if(n==="shades"&&p){let{shade:u}=p,E=xd(e.key,u,ea);if(E!==void 0)return r(t[p.colorName][E]),!0}if(n==="baseColors"&&p){let{colorName:u}=p,E=Object.keys(t),g=E.indexOf(u),b=xd(e.key,g,E.length),v=0;for(;b!==void 0&&v++<E.length;){let w=t[E[b]],x=Array.isArray(w)?w[l]:w;if(!m?.includes(x))break;b=xd(e.key,b,E.length)}if(b!==void 0){let w=E[b],x=t[w];return r(Array.isArray(x)?x[l]:x),!0}}if(n==="custom"){let u=o!=null?i.indexOf(o):0,E=xd(e.key,u,i.length);if(E!==void 0){let g=i[E];return r(g),!0}}return!1};import{jsx as Po,jsxs as yd}from"react/jsx-runtime";var uy=Nh.forwardRef(({theme:e,color:n,onChange:t,type:o,elements:r,palette:i,updateData:a,children:s,showTitle:l,onEyeDropperToggle:c,onEscape:d,showHotKey:m=!0,excludedColors:p},u)=>{let E=l?o==="elementStroke"?f("labels.stroke"):o==="elementBackground"?f("labels.background"):null:null,[g]=Nh.useState(()=>o==="canvasBackground"?[]:Z0(r,o,i)),[b,v]=Xe(sn),w=ln(),x=or({color:n,palette:i});Bh(()=>{if(!b){let P=!!n&&Mh({color:n,palette:i}),M=P&&!g.includes(n);v(M?null:P?"custom":x?.shade!=null?"shades":"baseColors")}},[b,n,i,v,x,g]);let[I,T]=W5(x?.shade??(o==="elementBackground"?V5:Y5));Bh(()=>{x?.shade!=null&&T(x.shade);let P=M=>{M.key===K5.ALT&&c(!1)};return document.addEventListener(py.KEYUP,P,{capture:!0}),()=>{document.removeEventListener(py.KEYUP,P,{capture:!0})}},[x,c]);let C=Nh.useRef(null);return U5(u,()=>C.current),Bh(()=>{C?.current?.focus()},[]),Po("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:yd("div",{ref:C,onKeyDown:P=>{my({event:P,activeColorPickerSection:b,palette:i,color:n,onChange:t,onEyeDropperToggle:c,customColors:g,setActiveColorPickerSection:v,updateData:a,activeShade:I,onEscape:d,excludedColors:p})&&(P.preventDefault(),P.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[E&&Po("div",{className:"color-picker__title",children:E}),!!g.length&&yd("div",{children:[Po(Qi,{children:f("colorPicker.mostUsedCustomColors")}),Po(sy,{theme:e,colors:g,color:n,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),yd("div",{children:[Po(Qi,{children:f("colorPicker.colors")}),Po(ly,{theme:e,color:n,palette:i,onChange:t,activeShade:I,showHotKey:m,excludedColors:p})]}),yd("div",{children:[Po(Qi,{children:f("colorPicker.shades")}),Po(dy,{theme:e,color:n,onChange:t,palette:i,showHotKey:m})]}),s,w&&Po("div",{className:"color-picker__tip",children:f("colorPicker.topPicksTip")})]})})});import hy from"clsx";import{ContextMenu as Xs}from"radix-ui";import{applyDarkModeFilter as X5,COLOR_OUTLINE_CONTRAST_THRESHOLD as Z5,DEFAULT_CANVAS_BACKGROUND_PICKS as $5,DEFAULT_ELEMENT_BACKGROUND_PICKS as j5,DEFAULT_ELEMENT_STROKE_PICKS as q5,isColorDark as J5,THEME as Q5}from"@excalidraw/common";import{jsx as rr,jsxs as gy}from"react/jsx-runtime";var fy=({theme:e,onChange:n,type:t,activeColor:o,topPicks:r,onReset:i,isCustomized:a})=>{let s=ln(),l=s?.dragState??null,{container:c}=ze(),d;if(t==="elementStroke"&&(d=q5),t==="elementBackground"&&(d=j5),t==="canvasBackground"&&(d=$5),r&&(d=r),!d)return console.error("Invalid type for TopPicks"),null;let m=u=>{if(!l||l.origin.kind!=="pick"||l.overIndex===null)return 0;let E=l.origin.index,g=l.overIndex;if(E===g)return 0;let b=u;return u===E?b=g:(u>E&&(b-=1),b>=g&&(b+=1)),(b-u)*l.slotSpan},p=gy("div",{className:hy("color-picker__top-picks",{"is-dnd-active":!!l}),ref:s?.setStripEl,children:[l&&rr("svg",{className:"color-picker__top-picks__dnd-outline","aria-hidden":"true",children:rr("rect",{})}),d.map((u,E)=>{let g=m(E),b=X5(u,e===Q5.DARK);return rr("button",{className:hy("color-picker__button",{active:u===o,"is-transparent":u==="transparent"||!u,"has-outline":!J5(u,Z5),"is-dnd-source":l?.origin.kind==="pick"&&l.origin.index===E,"is-dnd-target":l?.origin.kind==="swatch"&&l.overIndex===E,"is-dnd-duplicate":l?.duplicateIndex===E}),style:{"--swatch-color":b,transform:g?`translateX(${g}px)`:void 0},type:"button",title:u,onClick:()=>n(u),onPointerDown:s?v=>s.startPickDrag(v,E,u):void 0,"data-testid":`color-top-pick-${u}`,"data-top-pick-index":E,children:rr("div",{className:"color-picker__button-outline"})},u)})]});return i?gy(Xs.Root,{children:[rr(Xs.Trigger,{asChild:!0,children:p}),rr(Xs.Portal,{container:c,children:rr(Xs.Content,{className:"color-picker__context-menu",style:{zIndex:"var(--zIndex-ui-styles-popup)"},children:rr(Xs.Item,{className:"color-picker__context-menu-item",disabled:!a,onSelect:i,children:f("colorPicker.resetTopPicks")})})})]}):p};import{jsx as cn,jsxs as wd}from"react/jsx-runtime";var s4=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=vy,updateData:a,getOpenPopup:s,appState:l,excludedColors:c})=>{let{container:d}=ze(),m=mt(),p=m!=="full",u=m==="mobile",[,E]=Xe(sn),[g,b]=Xe(Ut),v=wd("div",{children:[cn(Qi,{children:f("colorPicker.hexCode")}),cn(J0,{color:n||"",label:o,onChange:I=>{t(I)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),w=wy(null),x=()=>{w.current?.focus()};return cn(Co,{container:d,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!l.editingTextElement,onFocusOutside:I=>{if(I.target instanceof HTMLElement&&I.target.closest(".color-picker__context-menu")){I.preventDefault();return}i4(I.target)||(I.target instanceof HTMLElement&&I.target.matches(":active")?window.addEventListener("pointerup",x,{once:!0}):x()),I.preventDefault()},onPointerDownOutside:I=>{g&&I.preventDefault()},onClose:()=>{s()===e&&a({openPopup:null}),E(null),l.editingTextElement&&setTimeout(()=>{let I=document.querySelector(".excalidraw-wysiwyg");I&&I.focus()},0)},children:i?cn(uy,{ref:w,palette:i,excludedColors:c,color:n,theme:l.theme,onChange:I=>{let T=l.editingTextElement?Ed():null;t(I),l.editingTextElement&&T&&Hs(T)},onEyeDropperToggle:I=>{b(T=>I?(T=T||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},T.keepOpenOnAlt=!0,T):I===!1||T?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:I=>{g?b(null):a({openPopup:null})},type:e,elements:r,updateData:a,showTitle:p,showHotKey:!u,children:v}):v})},l4=e=>e==="elementStroke"||e==="elementBackground"||e==="canvasBackground",c4=({label:e,color:n,type:t,theme:o,mode:r="background",onToggle:i,editingTextElement:a})=>{let s=mt(),l=s!=="full",c=s==="mobile",d=ln(),m=n?n4(n,o===a4.DARK):null,p=u=>{u.preventDefault(),u.stopPropagation(),a&&X0(),i()};return wd(xy.Trigger,{type:"button",className:yy("color-picker__button active-color properties-trigger",{"is-transparent":!n||n==="transparent","has-outline":!n||!by(n,Ey),"compact-sizing":l,"mobile-border":c}),"aria-label":e,style:m?{"--swatch-color":m}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),"data-openpopup":t,onClick:p,onPointerDown:d?u=>d.startSwatchDrag(u,n):void 0,children:[cn("div",{className:"color-picker__button-outline",children:!n&&r1}),l&&n&&r==="stroke"&&cn("div",{className:"color-picker__button-background",children:cn("span",{style:{color:m&&by(m,Ey)?"#fff":"#111"},children:T0})})]})},d4=({type:e,color:n,onChange:t,label:o,elements:r,palette:i=vy,topPicks:a,updateData:s,appState:l,excludedColors:c,customizableTopPicks:d})=>{let m=wy(l.openPopup);t4(()=>{m.current=l.openPopup},[l.openPopup]);let u=mt()!=="full",E=!!d&&!u,g=E&&d?l.colorTopPicks?.[d]:null,b=g?.length?g:a??(e==="elementStroke"?r4:o4),v=ay({enabled:E,picks:b,onPicksChange:w=>{d&&s({colorTopPicks:{...l.colorTopPicks,[d]:w}})}});return cn(_h.Provider,{value:E?v:null,children:wd("div",{role:"dialog","aria-modal":"true",className:yy("color-picker-container",{"color-picker-container--no-top-picks":u}),children:[!u&&cn(fy,{theme:l.theme,activeColor:n,onChange:w=>{t(w),l4(l.openPopup)&&l.openPopup!==e&&setTimeout(()=>s({openPopup:e}),0)},type:e,topPicks:g?.length?g:a,isCustomized:!!g?.length,onReset:E&&d?()=>{s({colorTopPicks:{...l.colorTopPicks,[d]:null}})}:void 0}),!u&&cn(pd,{}),wd(xy.Root,{open:l.openPopup===e,onOpenChange:w=>{w&&s({openPopup:e})},children:[cn(c4,{color:n,label:o,type:e,theme:l.theme,mode:e==="elementStroke"?"stroke":"background",editingTextElement:!!l.editingTextElement,onToggle:()=>{l.openPopup===e?s({openPopup:null}):l.openPopup?s({openPopup:e}):s({openPopup:e})}}),l.openPopup===e&&cn(s4,{type:e,color:n,onChange:t,label:o,elements:r,palette:i,excludedColors:c,updateData:s,getOpenPopup:()=>m.current,appState:l})]})]})})},m4=(e,n)=>e.appState.openPopup===e.type||n.appState.openPopup===n.type?!1:e.type===n.type&&e.color===n.color&&e.label===n.label&&e.appState.openPopup===n.appState.openPopup&&e.palette===n.palette&&e.topPicks===n.topPicks&&e.excludedColors===n.excludedColors&&e.customizableTopPicks===n.customizableTopPicks&&e.appState.theme===n.appState.theme&&e.appState.colorTopPicks===n.appState.colorTopPicks&&!!e.appState.editingTextElement==!!n.appState.editingTextElement,ta=e4(d4,m4);import{Popover as z4}from"radix-ui";import G4 from"clsx";import H4,{useCallback as U4,useMemo as W4}from"react";import{FONT_FAMILY as Gh}from"@excalidraw/common";import M4,{useMemo as sr,useState as A4,useRef as Cy,useEffect as Py,useCallback as ky}from"react";import{arrayToList as D4,debounce as L4,FONT_FAMILY as lr,getFontFamilyString as _4}from"@excalidraw/common";import p4 from"clsx";import u4 from"react";import{jsx as h4,jsxs as g4}from"react/jsx-runtime";var vd=u4.forwardRef(({className:e,placeholder:n,onChange:t},o)=>g4("div",{className:p4("QuickSearch__wrapper",e),children:[oo,h4("input",{ref:o,className:"QuickSearch__input",type:"text",placeholder:n,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import f4 from"clsx";import{Children as E4}from"react";import{jsx as Iy}from"react/jsx-runtime";var Id=({className:e,placeholder:n,children:t})=>{let o=!E4.count(t);return Iy("div",{className:f4("ScrollableList__wrapper",e),role:"menu",children:o?Iy("div",{className:"empty",children:n}):t})};import{jsx as b4,jsxs as x4}from"react/jsx-runtime";var Ty=({children:e,className:n="",style:t,title:o})=>x4("div",{className:`dropdown-menu-group ${n}`,style:t,children:[o&&b4("p",{className:"dropdown-menu-group-title",children:o}),e]}),Zs=Ty;Ty.displayName="DropdownMenuGroup";import{THEME as P4}from"@excalidraw/common";import{DropdownMenu as k4}from"radix-ui";import y4,{useContext as w4}from"react";import{composeEventHandlers as v4}from"@excalidraw/common";var Fh=y4.createContext({}),ir=(e="",n=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e} ${n?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),Td=e=>{let n=w4(Fh);return v4(e,t=>{n.onSelect?.(t)})};import{jsx as I4}from"react/jsx-runtime";var $s=({children:e,...n})=>I4("span",{...n,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...n.style},children:e});import{Fragment as S4,jsx as js,jsxs as C4}from"react/jsx-runtime";var T4=({textStyle:e,icon:n,shortcut:t,children:o,badge:r})=>{let i=fe();return C4(S4,{children:[n&&js("div",{className:"dropdown-menu-item__icon",children:n}),js("div",{style:e,className:"dropdown-menu-item__text",children:js($s,{children:o})}),r&&js("div",{className:"dropdown-menu-item__badge",children:r}),t&&i.formFactor!=="phone"&&js("div",{className:"dropdown-menu-item__shortcut",children:t})]})},ar=T4;import{jsx as Sd}from"react/jsx-runtime";var Oh=({icon:e,badge:n,value:t,children:o,shortcut:r,className:i,selected:a,onSelect:s,...l})=>{let c=Td(s);return Sd(k4.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:Sd("button",{...l,value:t,className:ir(i,a),title:l.title??l["aria-label"],children:Sd(ar,{icon:e,shortcut:r,badge:n,children:o})})})};Oh.displayName="DropdownMenuItem";var na={GREEN:"green",RED:"red",BLUE:"blue"},Cd=({type:e=na.BLUE,children:n})=>{let{theme:t}=ro(),o={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===P4.LIGHT?"1.5px solid white":"none"};switch(e){case na.GREEN:Object.assign(o,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case na.RED:Object.assign(o,{backgroundColor:"pink",color:"darkred"});break;case na.BLUE:default:Object.assign(o,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Sd("div",{className:"DropDownMenuItemBadge",style:o,children:n})};Cd.displayName="DropdownMenuItemBadge";Oh.Badge=Cd;var Jt=Oh;import{KEYS as oa}from"@excalidraw/common";var Sy=({event:e,inputRef:n,hoveredFont:t,filteredFonts:o,onClose:r,onSelect:i,onHover:a})=>{if(!e[oa.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===oa.F)return n.current?.focus(),!0;if(e.key===oa.ESCAPE)return r(),!0;if(e.key===oa.ENTER)return t?.value&&i(t.value),!0;if(e.key===oa.ARROW_DOWN)return t?.next?a(t.next.value):o[0]?.value&&a(o[0].value),!0;if(e.key===oa.ARROW_UP)return t?.prev?a(t.prev.value):o[o.length-1]?.value&&a(o[o.length-1].value),!0};import{jsx as ko,jsxs as B4}from"react/jsx-runtime";var R4=e=>{switch(e){case lr.Excalifont:case lr.Virgil:return Qn;case lr.Nunito:case lr.Helvetica:return Os;case lr["Lilita One"]:return K1;case lr["Comic Shanns"]:case lr.Cascadia:return Jc;default:return Os}},N4=(e,n)=>Object.entries(lr).find(([,t])=>t===e)?.[0]??n[0]?.fontFace?.family??"Unknown",My=M4.memo(({selectedFontFamily:e,hoveredFontFamily:n,onSelect:t,onHover:o,onLeave:r,onOpen:i,onClose:a})=>{let{container:s}=ze(),l=xt(),{fonts:c}=l,{showDeprecatedFonts:d}=Ln(),m=mt(),[p,u]=A4(""),E=Cy(null),g=sr(()=>Array.from(Io.registered.entries()).filter(([k,{metadata:L}])=>!L.private&&!L.fallback).map(([k,{metadata:L,fontFaces:F}])=>{let K={value:k,icon:R4(k),text:N4(k,F)};return L.deprecated&&Object.assign(K,{deprecated:L.deprecated,badge:{type:na.RED,placeholder:f("fontList.badge.old")}}),K}).sort((k,L)=>k.text.toLowerCase()>L.text.toLowerCase()?1:-1),[]),b=sr(()=>new Set(c.getSceneFamilies()),[e]),v=sr(()=>g.filter(k=>b.has(k.value)),[g,b]),w=sr(()=>g.filter(k=>!b.has(k.value)&&(d||!k.deprecated)),[g,b,d]),x=sr(()=>D4([...v,...w].filter(k=>k.text?.toLowerCase().includes(p))),[v,w,p]),I=sr(()=>{let k;return n?k=x.find(L=>L.value===n):e&&(k=x.find(L=>L.value===e)),!k&&p&&(x[0]?.value?o(x[0].value):r()),k},[n,e,p,x,o,r]),T=ky(k=>{let L=null;if(l.state.editingTextElement){let F=document.querySelector(".excalidraw-wysiwyg");F&&(L={start:F.selectionStart,end:F.selectionEnd})}t(k),l.state.editingTextElement&&L&&setTimeout(()=>{let F=document.querySelector(".excalidraw-wysiwyg");F&&L&&(F.focus(),F.selectionStart=L.start,F.selectionEnd=L.end)},0)},[t,l.state.editingTextElement]),C=ky(k=>{Sy({event:k,inputRef:E,hoveredFont:I,filteredFonts:x,onSelect:T,onHover:o,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[I,x,T,o,a]);Py(()=>(i(),()=>{a()}),[]);let P=sr(()=>x.filter(k=>b.has(k.value)),[x,b]),M=sr(()=>x.filter(k=>!b.has(k.value)),[x,b]),D=({font:k,order:L})=>{let F=Cy(null),K=k.value===I?.value,z=k.value===e;return Py(()=>{K&&(L===0?F.current?.scrollIntoView?.({block:"end"}):F.current?.scrollIntoView?.({block:"nearest"}))},[K,L]),ko("button",{ref:F,type:"button",value:k.value,className:ir("",z,K),title:k.text,tabIndex:z?0:-1,onClick:U=>{T(Number(U.currentTarget.value))},onMouseMove:()=>{I?.value!==k.value&&o(k.value)},children:ko(ar,{icon:k.icon,badge:k.badge&&ko(Cd,{type:k.badge.type,children:k.badge.placeholder}),textStyle:{fontFamily:_4({fontFamily:k.value})},children:k.text})})},_=[];return P.length&&_.push(ko(Zs,{title:f("fontList.sceneFonts"),children:P.map((k,L)=>ko(D,{font:k,order:L},k.value))},"group_1")),M.length&&_.push(ko(Zs,{title:f("fontList.availableFonts"),children:M.map((k,L)=>ko(D,{font:k,order:L+P.length},k.value))},"group_2")),B4(Co,{className:"properties-content",container:s,style:{width:"15rem"},onClose:()=>{a(),l.state.editingTextElement&&setTimeout(()=>{let k=document.querySelector(".excalidraw-wysiwyg");k&&k.focus()},0)},onPointerLeave:r,onKeyDown:C,preventAutoFocusOnTouch:!!l.state.editingTextElement,children:[m==="full"&&ko(vd,{ref:E,placeholder:f("quickSearch.placeholder"),onChange:L4(u,20)}),ko(Id,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,n)=>e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as F4}from"radix-ui";import{MOBILE_ACTION_BUTTON_BG as O4}from"@excalidraw/common";import{jsx as zh}from"react/jsx-runtime";var Ay=({selectedFontFamily:e,isOpened:n=!1,compactMode:t=!1})=>{let o=Ve(),r=t?{...O4,width:"2rem",height:"2rem"}:{};return zh(F4.Trigger,{asChild:!0,children:zh("div",{"data-openpopup":"fontFamily",className:"properties-trigger",children:zh($,{type:"toggle",icon:Dn,title:f("labels.showFonts"),"aria-label":f("labels.showFonts"),className:"standalone properties-trigger","data-testid":"font-family-show-fonts",checked:n,onSelect:()=>{o(i=>({openPopup:i.openPopup==="fontFamily"?null:i.openPopup}))},style:{border:"none",...r}})})})};import{jsx as qs,jsxs as Dy}from"react/jsx-runtime";var Ly=[{value:Gh.Excalifont,icon:Qn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Gh.Nunito,icon:Os,text:f("labels.normal"),testId:"font-family-normal"},{value:Gh["Comic Shanns"],icon:Jc,text:f("labels.code"),testId:"font-family-code"}],Ate=new Set(Ly.map(e=>e.value));var _y=H4.memo(({isOpened:e,selectedFontFamily:n,hoveredFontFamily:t,onSelect:o,onHover:r,onLeave:i,onPopupChange:a,compactMode:s=!1})=>{let l=W4(()=>Ly,[]),c=U4(d=>{d&&o(d)},[o]);return Dy("div",{role:"dialog","aria-modal":"true",className:G4("FontPicker__container",{"FontPicker__container--compact":s}),children:[!s&&qs("div",{className:"buttonList",children:qs(qt,{type:"button",options:l,value:n,onClick:c})}),!s&&qs(pd,{}),Dy(z4.Root,{open:e,onOpenChange:a,children:[qs(Ay,{selectedFontFamily:n,isOpened:e,compactMode:s}),e&&qs(My,{selectedFontFamily:n,hoveredFontFamily:t,onSelect:c,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,n)=>e.isOpened===n.isOpened&&e.selectedFontFamily===n.selectedFontFamily&&e.hoveredFontFamily===n.hoveredFontFamily);import{Popover as Hh}from"radix-ui";import X4 from"clsx";import Fy,{useEffect as Z4,useMemo as $4}from"react";import{isArrowKey as j4,KEYS as Mo}from"@excalidraw/common";import{jsx as V4}from"react/jsx-runtime";var Pd=({className:e,icon:n,size:t="1em"})=>V4("span",{className:e,style:{width:t,height:"100%",margin:"0 0.5ex 0 0.5ex",display:"inline-flex",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:n});import{Fragment as K4,jsx as Ry,jsxs as Ny}from"react/jsx-runtime";var Y4=({label:e,open:n,openTrigger:t,children:o,className:r,showCollapsedIcon:i=!0})=>Ny(K4,{children:[Ny("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&Ry(Pd,{icon:n?y0:td})]}),n&&Ry("div",{style:{display:"flex",flexDirection:"column"},children:o})]}),Js=Y4;import{jsx as io,jsxs as Md}from"react/jsx-runtime";var q4=Qe(!1),kd=4,J4="default",Q4=e=>e.flatMap(n=>n.options),By=(e,n)=>{for(let t of e){let o=t.options.find(n);if(o)return o}return null},e6=(e,n)=>e.some(t=>t.options.some(n)),t6=e=>e.flatMap(n=>Array.from({length:Math.ceil(n.options.length/kd)},(t,o)=>n.options.slice(o*kd,o*kd+kd)));function n6({visibleSections:e,hiddenSections:n=[],value:t,label:o,onChange:r,onClose:i}){let{container:a}=ze(),[s,l]=Xe(q4),c=[...e,...n],d=Q4(c),m=t6([...e,...s?n:[]]),p=g=>{let b=d.find(v=>v.keyBinding===g.key.toLowerCase());if(!(g.metaKey||g.altKey||g.ctrlKey)&&b)r(b.value),g.preventDefault();else if(g.key===Mo.TAB){let v=d.findIndex(x=>x.value===t),w=g.shiftKey?(d.length+v-1)%d.length:(v+1)%d.length;r(d[w].value)}else if(j4(g.key)){let v=Jn().rtl,w=d.findIndex(x=>x.value===t);if(w!==-1){let x=d.length,I=w;switch(g.key){case(v?Mo.ARROW_LEFT:Mo.ARROW_RIGHT):I=(w+1)%x;break;case(v?Mo.ARROW_RIGHT:Mo.ARROW_LEFT):I=(x+w-1)%x;break;case Mo.ARROW_DOWN:{let T=m.findIndex(P=>P.some(M=>M.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(T+1)%m.length],D=M[Math.min(P,M.length-1)]??d[w];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}case Mo.ARROW_UP:{let T=m.findIndex(P=>P.some(M=>M.value===t)),C=m[T];if(T!==-1&&C){let P=C.findIndex(_=>_.value===t),M=m[(m.length+T-1)%m.length],D=M[Math.min(P,M.length-1)]??d[w];r(D.value),g.preventDefault(),g.nativeEvent.stopImmediatePropagation(),g.stopPropagation();return}break}}r(d[I].value)}g.preventDefault()}else(g.key===Mo.ESCAPE||g.key===Mo.ENTER)&&(g.preventDefault(),i());g.nativeEvent.stopImmediatePropagation(),g.stopPropagation()};Z4(()=>{e6(n,g=>g.value===t)&&l(!0)},[t,n,l]);let u=g=>io("div",{className:"picker-content",children:g.map(b=>Md("button",{type:"button",className:X4("picker-option",{active:t===b.value}),onClick:()=>{r(b.value)},title:b.keyBinding?`${b.text} \u2014 ${b.keyBinding.toUpperCase()}`:b.text,"aria-label":b.text||"none","aria-keyshortcuts":b.keyBinding||void 0,ref:v=>{t===b.value&&setTimeout(()=>{v?.focus()},0)},children:[b.icon,b.keyBinding&&io("span",{className:"picker-keybinding",children:b.keyBinding})]},b.text))}),E=g=>g.map((b,v)=>b.name===J4?io(Fy.Fragment,{children:u(b.options)},`${b.name}-${v}`):Md("div",{className:"picker-section",children:[io("div",{className:"picker-section-label",children:b.name}),u(b.options)]},`${b.name}-${v}`));return io(Hh.Content,{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,side:"bottom",align:"start",sideOffset:12,alignOffset:12,style:{zIndex:"var(--zIndex-ui-styles-popup)"},onKeyDown:p,collisionBoundary:a??void 0,children:Md("div",{className:"picker-sections",children:[E(e),n.length>0&&io(Js,{label:f("labels.more_options"),open:s,openTrigger:()=>{l(g=>!g)},className:"picker-collapsible",children:io("div",{className:"picker-sections",children:E(n)})})]})})}function Uh({value:e,label:n,visibleSections:t,hiddenSections:o,onChange:r}){let[i,a]=Fy.useState(!1),s=$4(()=>By(t,l=>l.value===e)??By(o??[],l=>l.value===e),[t,o,e]);return io("div",{children:Md(Hh.Root,{open:i,onOpenChange:l=>a(l),children:[io(Hh.Trigger,{type:"button","aria-label":n,onClick:()=>a(!i),className:i?"active":"",children:s?.icon}),i&&io(n6,{visibleSections:t,hiddenSections:o,value:e,label:n,onChange:r,onClose:()=>{a(!1)}})]})})}import Oy,{useEffect as o6}from"react";import{jsx as Wh,jsxs as zy}from"react/jsx-runtime";var Gy=({label:e,value:n,onChange:t,min:o=0,max:r=100,step:i=10,minLabel:a=o,hasCommonValue:s=!0,testId:l})=>{let c=Oy.useRef(null),d=Oy.useRef(null);return o6(()=>{if(c.current&&d.current){let m=c.current,p=d.current,u=m.offsetWidth,E=parseFloat(getComputedStyle(m).getPropertyValue("--slider-thumb-size"))||16,g=(n-o)/(r-o||1)*100,b=g/100*(u-E)+E/2;p.style.left=`${b}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${g}%, var(--button-bg) ${g}%, var(--button-bg) 100%)`}},[r,o,n]),zy("label",{className:"control-label",children:[e,zy("div",{className:"range-wrapper",children:[Wh("input",{style:{"--color-slider-track":s?void 0:"var(--button-bg)"},ref:c,type:"range",min:o,max:r,step:i,onChange:m=>{t(+m.target.value)},value:n,className:"range-input","data-testid":l}),Wh("div",{className:"value-bubble",ref:d,children:n!==o?n:null}),Wh("div",{className:"zero-label",children:a})]})]})};import{Fragment as Bd,jsx as ee,jsxs as yt}from"react/jsx-runtime";var jy=.1,jr=e=>{let n=k6(e.editorInterface);return{stylesPanelMode:n,isCompact:n!=="full",isMobile:n==="mobile"}},Ct=(e,n,t,o=!1)=>{let r=Zh(de(e,n,{includeBoundTextElement:o}));return e.map(i=>r.get(i.id)||i.id===n.editingTextElement?.id?(w6(i)||console.error("[NONDELETED][INVARIANT] changeProperty(): skipping deleted selected/editing element"),t(i)):i)},ut=function(e,n,t,o,r){let i=n.state.editingTextElement,a=Zy(e),s=null;if(i&&(s=t(i)),!s)if(Ne(a,n.state)){let c=n.scene.getSelectedElements(n.state),d=o===!0?c:c.filter(m=>o(m));s=x6(d,t)??(typeof r=="function"?r(!0):r)}else s=typeof r=="function"?r(!1):r;return s},M6=(e,n,t)=>I6(n)||!n.autoResize?n:t.mutateElement(n,{x:e.textAlign==="left"?e.x:e.x+(e.width-n.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-n.height)/2}),$h=(e,n,t,o,r)=>{let i=new Set,a=Ct(e,n,s=>{if(Wt(s)){let l=o(s);i.add(l);let c=st(s,{fontSize:l});return Qs(c,t.scene.getContainerElement(s),t.scene),c=M6(s,c,t.scene),c}return s},!0);return de(e,n,{includeBoundTextElement:!0}).forEach(s=>{Wt(s)&&v6(s,t.scene)}),{elements:a,appState:{...n,currentItemFontSize:i.size===1?[...i][0]:r??n.currentItemFontSize},captureUpdate:ot.IMMEDIATELY}},A6=O({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,n,t)=>({...t?.currentItemStrokeColor&&{elements:Ct(e,n,o=>S6(o.type)?st(o,{strokeColor:t.currentItemStrokeColor}):o,!0)},appState:{...n,...t},captureUpdate:t?.currentItemStrokeColor?ot.IMMEDIATELY:ot.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=jr(o);return yt(Bd,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.stroke")}),ee(ta,{topPicks:d6,palette:c6,customizableTopPicks:"elementStroke",type:"elementStroke",label:f("labels.stroke"),color:ut(e,o,a=>a.strokeColor,!0,a=>a?null:n.currentItemStrokeColor),onChange:a=>t({currentItemStrokeColor:a}),elements:e,appState:n,updateData:t})]})}}),D6=O({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t,o)=>{if(!t?.currentItemBackgroundColor)return{appState:{...n,...t},captureUpdate:ot.EVENTUALLY};let r,i=o.scene.getSelectedElements(n);if(!b6(t.currentItemBackgroundColor)&&i.every(s=>Vy(s)&&y6(s.points))){let s=Zh(i);r=e.map(l=>s.has(l.id)&&Vy(l)?st(l,{backgroundColor:t.currentItemBackgroundColor,...P6(l,!0)}):l)}else r=Ct(e,n,s=>st(s,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...n,...t},captureUpdate:ot.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{stylesPanelMode:i}=jr(o);return yt(Bd,{children:[i==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(ta,{topPicks:l6,palette:Ky,customizableTopPicks:"elementBackground",type:"elementBackground",label:f("labels.background"),color:ut(e,o,a=>a.backgroundColor,!0,a=>a?null:n.currentItemBackgroundColor),onChange:a=>t({currentItemBackgroundColor:a}),elements:e,appState:n,updateData:t})]})}}),Nd=O({name:"changeBucketFillBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:ot.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let{stylesPanelMode:r}=jr(o);return yt(Bd,{children:[r==="full"&&ee("h3",{"aria-hidden":"true",children:f("labels.background")}),ee(ta,{topPicks:a6,palette:Ky,excludedColors:[s6.transparent],customizableTopPicks:"bucketFill",type:"elementBackground",label:f("labels.background"),color:o.bucketFill.getBucketFillBackgroundColor(n.currentItemBackgroundColor),onChange:i=>t({currentItemBackgroundColor:i}),elements:e,appState:n,updateData:t})]})}}),L6=O({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,n,t,o)=>(We("element","changeFillStyle",`${t} (${o.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),{elements:Ct(e,n,r=>st(r,{fillStyle:t})),appState:{...n,currentItemFillStyle:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=de(e,n),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return yt("fieldset",{children:[ee("legend",{children:f("labels.fill")}),ee("div",{className:"buttonList",children:ee(qt,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${N("Alt-Click")})`,icon:i?h1:g1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:f1,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:E1,testId:"fill-solid"}],value:ut(e,o,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:n.currentItemFillStyle),onClick:(a,s)=>{let l=s.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(l)}})})]})}}),_6=e=>h6.find(n=>Xy(e.type,n)===e.strokeWidth)??null,R6=(e,n)=>Xy(e.type,n),N6=O({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,n,t)=>(Rd(t,"actionChangeStrokeWidth: value must be defined"),{elements:Ct(e,n,o=>st(o,{strokeWidth:R6(o,t)})),appState:{...n,currentItemStrokeWidthKey:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>yt("fieldset",{children:[ee("legend",{children:f("labels.strokeWidth")}),ee("div",{className:"buttonList",children:ee(qt,{group:"stroke-width",options:[{value:"thin",text:f("labels.thin"),icon:oh,testId:"strokeWidth-thin"},{value:"medium",text:f("labels.medium"),icon:b1,testId:"strokeWidth-medium"},{value:"bold",text:f("labels.bold"),icon:x1,testId:"strokeWidth-bold"}],value:ut(e,o,_6,i=>i.hasOwnProperty("strokeWidth"),i=>i?null:n.currentItemStrokeWidthKey),onChange:i=>t(i)})})]})}),B6=O({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>st(o,{seed:g6(),roughness:t})),appState:{...n,currentItemRoughness:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>yt("fieldset",{children:[ee("legend",{children:f("labels.sloppiness")}),ee("div",{className:"buttonList",children:ee(qt,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:v1},{value:1,text:f("labels.artist"),icon:I1},{value:2,text:f("labels.cartoonist"),icon:T1}],value:ut(e,o,i=>i.roughness,i=>i.hasOwnProperty("roughness"),i=>i?null:n.currentItemRoughness),onChange:i=>t(i)})})]})}),F6=O({name:"changeFreedrawMode",label:"labels.pressure",trackEvent:!1,perform:(e,n,t)=>{let o=t||"constant";return{elements:Ct(e,n,r=>r.type!=="freedraw"?r:st(r,{strokeOptions:{...r.strokeOptions,variability:o}})),appState:{...n,currentItemStrokeVariability:o},captureUpdate:ot.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=ut(e,o,a=>a.strokeOptions?.variability,a=>a.type==="freedraw",a=>a?null:n.currentItemStrokeVariability)??n.currentItemStrokeVariability;if(r?.cycle){let a=i==="variable";return ee($,{type:"button",icon:a?ih:rh,title:f("labels.pressure"),"aria-label":f("labels.pressure"),onClick:()=>t(a?"constant":"variable")})}return yt("fieldset",{children:[ee("legend",{children:f("labels.pressure")}),ee("div",{className:"buttonList",children:ee(qt,{group:"strokeOptions.variability",options:[{value:"constant",text:f("labels.pressure_constant"),icon:rh},{value:"variable",text:f("labels.pressure_variable"),icon:ih}],value:i,onChange:a=>t(a)})})]})}}),Bne=O({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>st(o,{strokeStyle:t})),appState:{...n,currentItemStrokeStyle:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>yt("fieldset",{children:[ee("legend",{children:f("labels.strokeStyle")}),ee("div",{className:"buttonList",children:ee(qt,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:oh},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:y1},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:w1}],value:ut(e,o,i=>i.strokeStyle,i=>i.hasOwnProperty("strokeStyle"),i=>i?null:n.currentItemStrokeStyle),onChange:i=>t(i)})})]})}),O6=O({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>st(o,{opacity:t}),!0),appState:{...n,currentItemOpacity:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=ut(e,t,i=>i.opacity,!0,i=>i?null:n.currentItemOpacity);return ee(Gy,{label:f("labels.opacity"),value:r??n.currentItemOpacity,hasCommonValue:r!==null,onChange:o,min:0,max:100,step:10,testId:"opacity"})}}),z6=O({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,n,t,o)=>$h(e,n,o,()=>(Rd(t,"actionChangeFontSize: Expected a font size value"),t),t),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=jr(o);return yt("fieldset",{children:[ee("legend",{children:f("labels.fontSize")}),ee("div",{className:"buttonList",children:ee(qt,{group:"font-size",options:[{value:Dd.sm,text:f("labels.small"),icon:U1,testId:"fontSize-small"},{value:Dd.md,text:f("labels.medium"),icon:W1,testId:"fontSize-medium"},{value:Dd.lg,text:f("labels.large"),icon:V1,testId:"fontSize-large"},{value:Dd.xl,text:f("labels.veryLarge"),icon:Y1,testId:"fontSize-veryLarge"}],value:ut(e,o,a=>{if(Wt(a))return a.fontSize;let s=cr(a,o.scene.getNonDeletedElementsMap());return s?s.fontSize:null},a=>Wt(a)||cr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:n.currentItemFontSize||p6),onChange:a=>{Us(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),jh=O({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Yr,trackEvent:!1,perform:(e,n,t,o)=>$h(e,n,o,r=>Math.round(1/(1+jy)*r.fontSize)),keyTest:e=>e[ra.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ra.CHEVRON_LEFT||e.key===ra.COMMA)}),qh=O({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Yr,trackEvent:!1,perform:(e,n,t,o)=>$h(e,n,o,r=>Math.round(r.fontSize*(1+jy))),keyTest:e=>e[ra.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ra.CHEVRON_RIGHT||e.key===ra.PERIOD)}),G6=O({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,n,t,o)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...s}=t;if(i)return{elements:Ct(e,n,g=>{let b=r?.get(g.id);return b?st(g,{...b}):g},!0),appState:{...n,...s},captureUpdate:ot.NEVER};Rd(t,"actionChangeFontFamily: value must be defined");let{currentItemFontFamily:l,currentHoveredFontFamily:c}=t,d=ot.EVENTUALLY,m,p=!1;if(l)m=l,d=ot.IMMEDIATELY;else if(c){m=c,d=ot.EVENTUALLY;let E=de(e,n,{includeBoundTextElement:!0}).filter(g=>Wt(g));if(E.length>200)p=!0;else{let g=0,b=0;for(;g<E.length&&b<5e3;){let v=E[g];b+=v?.originalText.length||0,g++}b>5e3&&(p=!0)}}let u={appState:{...n,...s},captureUpdate:d};if(m&&!p){let E=new Map,g=new Set,b=!1,v=Array.from(Io.loadedFontsCache.values()),w=Object.entries(u6).find(([T,C])=>C===m)?.[0];c&&w&&v.some(T=>T.startsWith(w))&&(b=!0),Object.assign(u,{elements:Ct(e,n,T=>{if(Wt(T)&&(T.fontFamily!==m||l)){let C=st(T,{fontFamily:m,lineHeight:E6(m)}),P=r?.get(T.containerId||"")||{},M=o.scene.getContainerElement(T);return a&&M&&P&&o.scene.mutateElement(M,{...P}),b||(g=new Set([...g,...Array.from(C.originalText)])),E.set(C,M),C}return T},!0)});let x=`10px ${f6({fontFamily:m})}`,I=Array.from(g.values()).join();if(b||window.document.fonts.check(x,I))for(let[T,C]of E)Qs(T,C,o.scene);else window.document.fonts.load(x,I).then(T=>{for(let[C,P]of E){let M=o.scene.getElement(C.id),D=P?o.scene.getElement(P.id):null;M&&Qs(M,D,o.scene)}o.fonts.onLoaded(T)})}return u},PanelComponent:({elements:e,appState:n,app:t,updateData:o})=>{let r=Yh(new Map),i=Yh(null),[a,s]=i6({}),l=Yh(!0),{stylesPanelMode:c,isCompact:d}=jr(t),m=Xh(()=>{let p=(u,E)=>ut(u,t,g=>{if(Wt(g))return g.fontFamily;let b=cr(g,E);return b?b.fontFamily:null},g=>Wt(g)||cr(g,E)!==null,g=>g?null:n.currentItemFontFamily||m6);return a.openPopup==="fontFamily"&&n.openPopup==="fontFamily"?p(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&n.openPopup!=="fontFamily"?p(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,n,e,t]);return Vh(()=>{i.current=m},[m]),Vh(()=>{Object.keys(a).length&&(o(a),s({}))},[a]),Vh(()=>(l.current=!1,()=>{l.current=!0}),[]),yt(Bd,{children:[c==="full"&&ee("legend",{children:f("labels.fontFamily")}),ee(_y,{isOpened:n.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:n.currentHoveredFontFamily,compactMode:c!=="full",onSelect:p=>{Us(()=>{s({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:p}),r.current.clear()},d,!!n.editingTextElement)},onHover:p=>{s({currentHoveredFontFamily:p,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{s({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:p=>{if(p){r.current.clear();let{editingTextElement:u}=n;if(u?.type==="text"){let E=t.scene.getElement(u.id);r.current.set(u.id,st(E||u,{},!0))}else{let E=de(e,n,{includeBoundTextElement:!0});for(let g of E)r.current.set(g.id,st(g,{},!0))}s({...a,openPopup:"fontFamily"})}else{let u={currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s({...u}),r.current.clear(),d&&n.editingTextElement&&Hs(null)}}})]})}}),H6=O({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Wt(r)){let i=st(r,{textAlign:t});return Qs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n,currentItemTextAlign:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let i=o.scene.getNonDeletedElementsMap(),{isCompact:a}=jr(o);return yt("fieldset",{children:[ee("legend",{children:f("labels.textAlign")}),ee("div",{className:"buttonList",children:ee(qt,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:X1,testId:"align-left"},{value:"center",text:f("labels.center"),icon:Z1,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:$1,testId:"align-right"}],value:ut(e,o,s=>{if(Wt(s))return s.textAlign;let l=cr(s,i);return l?l.textAlign:null},s=>Wt(s)||cr(s,i)!==null,s=>s?null:n.currentItemTextAlign),onChange:s=>{Us(()=>t(s),a,!!n.editingTextElement,r?.onPreventClose)}})})]})}}),U6=O({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:Ct(e,n,r=>{if(Wt(r)){let i=st(r,{verticalAlign:t});return Qs(i,o.scene.getContainerElement(r),o.scene),i}return r},!0),appState:{...n},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,data:r})=>{let{isCompact:i}=jr(o);return ee("fieldset",{children:ee("div",{className:"buttonList",children:ee(qt,{group:"text-align",options:[{value:Ad.TOP,text:f("labels.alignTop"),icon:ee(j1,{theme:n.theme}),testId:"align-top"},{value:Ad.MIDDLE,text:f("labels.centerVertically"),icon:ee(J1,{theme:n.theme}),testId:"align-middle"},{value:Ad.BOTTOM,text:f("labels.alignBottom"),icon:ee(q1,{theme:n.theme}),testId:"align-bottom"}],value:ut(e,o,a=>{if(Wt(a)&&a.containerId)return a.verticalAlign;let s=cr(a,o.scene.getNonDeletedElementsMap());return s?s.verticalAlign:null},a=>Wt(a)||cr(a,o.scene.getNonDeletedElementsMap())!==null,a=>a?null:Ad.MIDDLE),onChange:a=>{Us(()=>t(a),i,!!n.editingTextElement,r?.onPreventClose)}})})})}}),Fne=O({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,n,t)=>({elements:Ct(e,n,o=>$y(o)?o:st(o,{roundness:t==="round"?{type:T6(o.type)?Ld.ADAPTIVE_RADIUS:Ld.PROPORTIONAL_RADIUS}:null})),appState:{...n,currentItemRoundness:t},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>{let a=Ri(Zy(e),n).some(s=>s.roundness?.type===Ld.LEGACY);return yt("fieldset",{children:[ee("legend",{children:f("labels.edges")}),yt("div",{className:"buttonList",children:[ee(qt,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:S1},{value:"round",text:f("labels.round"),icon:C1}],value:ut(e,o,s=>a?null:s.roundness?"round":"sharp",s=>!_d(s)&&s.hasOwnProperty("roundness"),s=>s?null:n.currentItemRoundness),onChange:s=>t(s)}),r("togglePolygon")]})]})}}),Yy=e=>({visibleSections:[{name:"default",options:[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:ee(P1,{flip:e})},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:ee(k1,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:ee(M1,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:ee(A1,{flip:e}),keyBinding:"r"}]}],hiddenSections:[{name:"default",options:[{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:ee(D1,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:ee(L1,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:ee(_1,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:ee(R1,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:ee(N1,{flip:e})}]},{name:f("labels.cardinality"),options:[{value:"cardinality_one",text:f("labels.arrowhead_cardinality_one"),icon:ee(B1,{flip:e}),keyBinding:"x"},{value:"cardinality_many",text:f("labels.arrowhead_cardinality_many"),icon:ee(F1,{flip:e}),keyBinding:"c"},{value:"cardinality_one_or_many",text:f("labels.arrowhead_cardinality_one_or_many"),icon:ee(O1,{flip:e}),keyBinding:"v"},{value:"cardinality_exactly_one",text:f("labels.arrowhead_cardinality_exactly_one"),icon:ee(z1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_one",text:f("labels.arrowhead_cardinality_zero_or_one"),icon:ee(G1,{flip:e}),keyBinding:null},{value:"cardinality_zero_or_many",text:f("labels.arrowhead_cardinality_zero_or_many"),icon:ee(H1,{flip:e}),keyBinding:null}]}]}),One=O({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,n,t)=>(Rd(t,"actionChangeArrowhead: value must be defined"),{elements:Ct(e,n,o=>{if(Kh(o)){let{position:r,type:i}=t;if(r==="start")return st(o,{startArrowhead:i});if(r==="end")return st(o,{endArrowhead:i})}return o}),appState:{...n,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:ot.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>{let r=Jn().rtl,i=Xh(()=>Yy(!r),[r]),a=Xh(()=>Yy(!!r),[r]);return yt("fieldset",{children:[ee("legend",{children:f("labels.arrowheads")}),yt("div",{className:"iconSelectList buttonList",children:[ee(Uh,{visibleSections:i.visibleSections,hiddenSections:i.hiddenSections,label:"arrowhead_start",value:ut(e,o,s=>Kh(s)&&Ss(s.type)?Wy(s.startArrowhead):n.currentItemStartArrowhead,!0,s=>s?null:n.currentItemStartArrowhead),onChange:s=>t({position:"start",type:s})}),ee(Uh,{visibleSections:a.visibleSections,hiddenSections:a.hiddenSections,label:"arrowhead_end",value:ut(e,o,s=>Kh(s)&&Ss(s.type)?Wy(s.endArrowhead):n.currentItemEndArrowhead,!0,s=>s?null:n.currentItemEndArrowhead),onChange:s=>t({position:"end",type:s})})]})]})}}),W6=O({name:"changeArrowProperties",label:"Change arrow properties",trackEvent:!1,perform:(e,n,t,o)=>!1,PanelComponent:({elements:e,appState:n,updateData:t,app:o,renderAction:r})=>yt("div",{className:"selected-shape-actions",children:[r("changeArrowhead"),r("changeArrowType")]})}),zne=O({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,n,t,o)=>{let r=Ct(e,n,s=>{if(!_d(s))return s;let l=o.scene.getNonDeletedElementsMap(),c=$r.getPointAtIndexGlobalCoordinates(s,0,l),d=$r.getPointAtIndexGlobalCoordinates(s,-1,l),m=st(s,{x:t===dn.elbow?c[0]:s.x,y:t===dn.elbow?c[1]:s.y,roundness:t===dn.round?{type:Ld.PROPORTIONAL_RADIUS}:null,elbowed:t===dn.elbow,angle:t===dn.elbow?0:s.angle,points:t===dn.elbow||s.elbowed?[$r.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},c,l),$r.pointFromAbsoluteCoords({...s,x:c[0],y:c[1],angle:0},d,l)]:s.points});if($y(m)){m.fixedSegments=null;let p=o.scene.getNonDeletedElementsMap();o.dismissLinearEditor();let u=$r.getPointAtIndexGlobalCoordinates(m,0,p),E=$r.getPointAtIndexGlobalCoordinates(m,-1,p),g=m.startBinding&&p.get(m.startBinding.elementId),b=m.endBinding&&p.get(m.endBinding.elementId),v=g&&m.startBinding?{...m.startBinding,...Uy(m,g,"start",p,n.isBindingEnabled)}:null,w=b&&m.endBinding?{...m.endBinding,...Uy(m,b,"end",p,n.isBindingEnabled)}:null;m={...m,startBinding:v,endBinding:w,...C6(m,p,{points:[u,E].map(x=>r6(x[0]-m.x,x[1]-m.y)),startBinding:v,endBinding:w,fixedSegments:null})}}else{let p=o.scene.getNonDeletedElementsMap();if(m.startBinding){let u=p.get(m.startBinding.elementId);u&&Hy(m,u,n.bindMode==="inside"?"inside":"orbit","start",o.scene)}if(m.endBinding){let u=p.get(m.endBinding.elementId);u&&Hy(m,u,n.bindMode==="inside"?"inside":"orbit","end",o.scene)}}return m}),i={...n,currentItemArrowType:t},a=n.selectedLinearElement?.elementId;if(a){let s=r.find(l=>l.id===a);s&&(i.selectedLinearElement=new $r(s,Zh(e)))}return{elements:r,appState:i,captureUpdate:ot.IMMEDIATELY}},PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>yt("fieldset",{children:[ee("legend",{children:f("labels.arrowtypes")}),ee("div",{className:"buttonList",children:ee(qt,{group:"arrowtypes",options:[{value:dn.sharp,text:f("labels.arrowtype_sharp"),icon:Qo,testId:"sharp-arrow"},{value:dn.round,text:f("labels.arrowtype_round"),icon:tr,testId:"round-arrow"},{value:dn.elbow,text:f("labels.arrowtype_elbowed"),icon:er,testId:"elbow-arrow"}],value:ut(e,o,r=>_d(r)?r.elbowed?dn.elbow:r.roundness?dn.round:dn.sharp:null,r=>_d(r),r=>r?null:n.currentItemArrowType),onChange:r=>t(r)})})]})});import{DEFAULT_CANVAS_BACKGROUND_PICKS as j6,MAX_ZOOM as q6,MIN_ZOOM as J6,THEME as el,ZOOM_STEP as Qy,CODES as qr,KEYS as Od}from"@excalidraw/common";import{getNonDeletedElements as tl}from"@excalidraw/element";import{getCommonBounds as nl}from"@excalidraw/element";import{CaptureUpdateAction as sa}from"@excalidraw/element";import{useEffect as V6}from"react";import{jsx as K6}from"react/jsx-runtime";var ia=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let n=document.createElement("div");return document.body.appendChild(n),n.classList.add("excalidraw-tooltip"),n},Jh=(e,n,t="bottom")=>{let o=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,s=n.left+n.width/2-o.width/2;s<0?s=a:s+o.width>=r&&(s=r-o.width-a);let l;t==="bottom"?(l=n.top+n.height+a,l+o.height>=i&&(l=n.top-o.height-a)):(l=n.top-o.height-a,l<0&&(l=n.top+n.height+a)),Object.assign(e.style,{top:`${l}px`,left:`${s}px`})},Y6=(e,n,t,o)=>{n.classList.add("excalidraw-tooltip--visible"),n.style.minWidth=o?"50ch":"10ch",n.style.maxWidth=o?"50ch":"15ch",n.textContent=t;let r=e.getBoundingClientRect();Jh(n,r)},ht=({children:e,label:n,long:t=!1,style:o,disabled:r})=>(V6(()=>()=>ia().classList.remove("excalidraw-tooltip--visible"),[]),r?null:K6("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>Y6(i.currentTarget,ia(),n,t),onPointerLeave:()=>ia().classList.remove("excalidraw-tooltip--visible"),style:o,children:e}));import{useEffect as qy,useRef as Jy,useState as X6}from"react";var Z6=(e,n)=>typeof n=="function"?n(e):Array.isArray(n)?e:e[n],Qh=(e,n,t)=>{if(e?.isDestroyed)return;let o=e?.getAppState();if(!o){if(!t)return;console.warn("useAppStateValue: excalidrawAPI not defined yet for internal component while it should always be defined. Are you sure you're rendering inside of <Excalidraw/> component tree?"),o=Object.assign({width:0,height:0,offsetLeft:0,offsetTop:0},Zo())}return Z6(o,n)};function aa(e,n=!0){let t=Fd(),[,o]=X6(0),r=Jy(null);return r.current||(r.current={selector:e,isInitialized:!!t,latestValue:Qh(t,e,n)}),r.current.selector=e,!r.current.isInitialized&&t&&!t.isDestroyed&&(r.current.isInitialized=!0,r.current.latestValue=Qh(t,e,n)),qy(()=>{let i=r.current;if(!(!t||t.isDestroyed||!i))return t.onStateChange(i.selector,a=>{i.latestValue=a,o(s=>s+1)})},[t]),r.current.latestValue}function $6(e,n){let t=Fd(),o=Jy({selector:e,callback:n});o.current.selector=e,o.current.callback=n,qy(()=>{if(!(!t||t.isDestroyed))return o.current.callback(Qh(t,o.current.selector,!0),t.getAppState()),t.onStateChange(o.current.selector,(r,i)=>{o.current.callback(r,i)})},[t])}import{jsx as Wd,jsxs as tD}from"react/jsx-runtime";var Q6=O({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.changeViewBackgroundColor&&!n.viewModeEnabled,perform:(e,n,t)=>({appState:{...n,...t},captureUpdate:t?.viewBackgroundColor?sa.IMMEDIATELY:sa.EVENTUALLY}),PanelComponent:({elements:e,appState:n,updateData:t,appProps:o,data:r})=>Wd(ta,{palette:null,topPicks:j6,label:f("labels.canvasBackground"),type:"canvasBackground",color:n.viewBackgroundColor,onChange:i=>t({viewBackgroundColor:i}),"data-testid":"canvas-background-picker",elements:e,appState:n,updateData:t})}),zd=O({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,navigation:!0,icon:Gu,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...vo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:jn(n.zoom.value+Qy)},n)},captureUpdate:sa.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=aa(t=>t.zoom.value);return Wd($,{type:"button",className:"zoom-in-button zoom-button",icon:Gu,title:`${f("buttons.zoomIn")} \u2014 ${N("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:n>=q6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===qr.EQUAL||e.code===qr.NUM_ADD)&&(e[Od.CTRL_OR_CMD]||e.shiftKey)}),Gd=O({name:"zoomOut",label:"buttons.zoomOut",icon:Hu,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>(o.requestUnfollow(),{appState:{...n,...vo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:jn(n.zoom.value-Qy)},n)},captureUpdate:sa.EVENTUALLY}),PanelComponent:({updateData:e})=>{let n=aa(t=>t.zoom.value);return Wd($,{type:"button",className:"zoom-out-button zoom-button",icon:Hu,title:`${f("buttons.zoomOut")} \u2014 ${N("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:n<=J6,onClick:()=>{e(null)}})},keyTest:e=>(e.code===qr.MINUS||e.code===qr.NUM_SUBTRACT)&&(e[Od.CTRL_OR_CMD]||e.shiftKey)}),Hd=O({name:"resetZoom",label:"buttons.resetZoom",icon:jx,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?.lockZoom?n.scrollConstraints.zoom:1;return{appState:{...n,...vo({viewportX:n.width/2+n.offsetLeft,viewportY:n.height/2+n.offsetTop,nextZoom:jn(r)},n)},captureUpdate:sa.EVENTUALLY}},PanelComponent:({updateData:e})=>{let n=aa(t=>t.zoom.value);return Wd(ht,{label:f("buttons.resetZoom"),style:{height:"100%"},children:tD($,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(n*100).toFixed(0),"%"]})})},keyTest:e=>(e.code===qr.ZERO||e.code===qr.NUM_ZERO)&&(e[Od.CTRL_OR_CMD]||e.shiftKey)}),eg=e=>[e.x,e.y,e.x+e.width,e.y+e.height],foe=O({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:ed,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?nl(tl(r)):n.scrollConstraints?eg(n.scrollConstraints):nl(tl(e)),a=zr({bounds:i,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...$n(a.appState)}}},keyTest:void 0}),Eoe=O({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:ed,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=o.scene.getSelectedElements(n),i=r.length?nl(tl(r)):n.scrollConstraints?eg(n.scrollConstraints):nl(tl(e)),a=zr({bounds:i,appState:n,fit:"contain",canvasOffsets:o.viewport.getOffsets()});return{...a,appState:{...a.appState,...$n(a.appState)}}},keyTest:void 0}),eD=O({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:ed,viewMode:!0,navigation:!0,trackEvent:{category:"canvas"},predicate:(e,n,t,o)=>o.isNavigationEnabled(),perform:(e,n,t,o)=>{o.requestUnfollow();let r=n.scrollConstraints?eg(n.scrollConstraints):nl(tl(e)),i=zr({bounds:r,appState:n,fit:"scale-down",canvasOffsets:o.viewport.getOffsets()});return{...i,appState:{...i.appState,...$n(i.appState)}}},keyTest:void 0}),Ud=O({name:"toggleTheme",label:(e,n)=>n.theme===el.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:(e,n)=>e.theme===el.LIGHT?Rs:Ns,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=t||(n.theme===el.LIGHT?el.DARK:el.LIGHT);return o.props.onThemeChange?(o.props.onThemeChange(r),!1):{appState:{...n,theme:r},captureUpdate:sa.EVENTUALLY}},keyTest:e=>!e[Od.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===qr.D,predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.toggleTheme});import{pointFrom as dD}from"@excalidraw/math";import{bindOrUnbindBindingElement as mw}from"@excalidraw/element/binding";import{isValidPolygon as pw,newElementWith as og}from"@excalidraw/element";import{LinearElementEditor as sl}from"@excalidraw/element/linearElementEditor";import{isBindingElement as rg,isFreeDrawElement as uw,isLinearElement as hw,isLineElement as jd}from"@excalidraw/element";import{KEYS as qd,arrayToMap as mD,invariant as gw,shouldRotateWithDiscreteAngle as pD,updateActiveTool as fw}from"@excalidraw/common";import{isPathALoop as uD}from"@excalidraw/element";import{isInvisiblySmallElement as ig}from"@excalidraw/element";import{CaptureUpdateAction as ag}from"@excalidraw/element";import iD from"clsx";import{useEffect as aD,useState as sD}from"react";import{KEYS as mn,capitalizeString as Jr}from"@excalidraw/common";import{useEffect as nD,useState as oD}from"react";import ew from"clsx";import{capitalizeString as Vd}from"@excalidraw/common";import{Popover as tg}from"radix-ui";import{jsx as Yd,jsxs as rD}from"react/jsx-runtime";var la=({app:e,options:n,activeTool:t,defaultOption:o,"data-testid":r,onToolChange:i,displayedOption:a})=>{let[s,l]=oD(!1),c=t.type,d=a.type===c,m=16,{container:p}=ze();return!n.some(u=>u.type===c)&&s&&l(!1),nD(()=>{let u=e.onPointerDownEmitter.on(()=>{l(!1)});return()=>u?.()},[e]),rD(tg.Root,{open:s,children:[Yd(tg.Trigger,{asChild:!0,children:Yd($,{className:ew({fillable:a.fillable}),type:"toggle",icon:a.icon,checked:d,disabled:n.every(u=>tt(e,u.type)),title:Vd(a.title),"aria-label":Vd(a.title),"data-testid":r,onSelect:()=>{l(u=>!u),i(o)}})}),Yd(tg.Content,{className:"tool-popover-content",sideOffset:m,collisionBoundary:p??void 0,children:n.map(({type:u,icon:E,title:g,fillable:b})=>Yd($,{className:ew({fillable:b}),type:"toggle",icon:E,checked:c===u,disabled:tt(e,u),title:Vd(u),"aria-label":Vd(u),"data-testid":`toolbar-${u}`,onSelect:()=>{e.state.activeTool.type!==u&&(We("toolbar",u,"ui"),e.setActiveTool({type:u}),i?.(u))}},u))})]})};import{jsx as ng}from"react/jsx-runtime";var lD=e=>e,Be=lD({hand:{icon:Q1,letterKey:mn.H,toggle:!0},selection:{icon:Kc,letterKey:mn.V,fillable:!0},rectangle:{icon:Ui,letterKey:mn.R,fillable:!0},diamond:{icon:Wi,letterKey:mn.D,fillable:!0},ellipse:{icon:Vi,letterKey:mn.O,fillable:!0},arrow:{icon:Xc,letterKey:mn.A,fillable:!0},line:{icon:jo,letterKey:mn.L,fillable:!0},freedraw:{icon:Qn,letterKey:mn.P},text:{icon:Dn,letterKey:mn.T},image:{icon:Wr},eraser:{icon:Zc,letterKey:mn.E,toggle:!0},frame:{icon:to,letterKey:mn.F},autoshape:{icon:Kr,letterKey:mn.X,fillable:!1},embeddable:{icon:qo},laser:{icon:no},bucketfill:{icon:eo},lasso:{icon:Hi,fillable:!1}}),tw=["selection","freedraw","text","image","eraser"],dr=["autoshape","rectangle","diamond","ellipse","arrow","line"],ca=Object.keys(Be).filter(e=>Be[e].toggle),Kd=e=>{let{letterKey:n,shiftKey:t}=Be[e];if(!n)return n;let o=Jr(typeof n=="string"?n:n[0]);return t?N(`Shift+${o}`):o},mr=e=>Kd(e),cD=e=>{let n=Kd(e);return n?.length===1?n:void 0},nw=(e,n,t=!1)=>{let o=e.toLowerCase();for(let r of Object.keys(Be)){let{letterKey:i,shiftKey:a}=Be[r];if(t===!!a&&i&&(typeof i=="string"?i===o:i.includes(o)))return r==="selection"?n.state.preferredSelectionTool.type:r}return null},tt=(e,n)=>e.props.activeTool!=null&&e.props.activeTool.type!==n,Vt=(e,n)=>{let t=Be[e],o=n?.shortcutType??e,r=({app:i,activeTool:a,hideKeyBinding:s,hideShortcut:l})=>{let c=Jr(f(`toolBar.${e}`)),d=l?null:mr(o);return ng($,{className:iD({fillable:t.fillable}),type:"toggle",icon:t.icon,checked:a.type===e,disabled:tt(i,e),title:d?`${c} \u2014 ${d}`:c,keyBindingLabel:s||l?void 0:cD(o),"aria-label":c,"aria-keyshortcuts":d??void 0,"data-testid":`toolbar-${e}`,onSelect:({pointerType:m})=>{if(!i.state.penDetected&&m==="pen"&&i.togglePenMode(!0),n?.onSelect){n.onSelect(i,{pointerType:m});return}i.state.activeTool.type!==e&&(We("toolbar",e,"ui"),i.setActiveTool({type:e}))}})};return r.displayName=`${Jr(e)}IconButton`,r},Xd=Vt("hand"),ow=Vt("rectangle"),rw=Vt("diamond"),iw=Vt("ellipse"),aw=Vt("arrow"),sw=Vt("line"),ol=Vt("freedraw"),rl=Vt("text"),il=Vt("image"),al=Vt("eraser"),lw=Vt("frame"),Yoe=Vt("autoshape"),cw=Vt("selection",{onSelect:(e,{pointerType:n})=>{if(e.state.activeTool.type==="selection"&&n!==null){e.setActiveTool({type:"lasso"});return}e.state.activeTool.type!=="selection"&&(We("toolbar","selection","ui"),e.setActiveTool({type:"selection"}))}}),dw=Vt("lasso",{shortcutType:"selection"}),Zd=({app:e,activeTool:n,setAppState:t})=>{let o=[{type:"selection",icon:Be.selection.icon,fillable:Be.selection.fillable,title:Jr(f("toolBar.selection"))},{type:"lasso",icon:Be.lasso.icon,fillable:Be.lasso.fillable,title:Jr(f("toolBar.lasso"))}],r=o.find(i=>i.type===e.state.preferredSelectionTool.type)||o[0];return ng(la,{app:e,options:o,activeTool:n,defaultOption:e.state.preferredSelectionTool.type,"data-testid":"toolbar-selection",onToolChange:i=>{(i==="selection"||i==="lasso")&&(e.setActiveTool({type:i}),t({preferredSelectionTool:{type:i,initialized:!0}}))},displayedOption:r})},$d=({app:e,activeTool:n})=>{let t=[{type:"freedraw",icon:Be.freedraw.icon,fillable:Be.freedraw.fillable,title:Jr(f("toolBar.freedraw"))},{type:"autoshape",icon:Be.autoshape.icon,fillable:Be.autoshape.fillable,title:Jr(f("toolBar.autoshape"))}],[o,r]=sD(n.type==="autoshape"?"autoshape":"freedraw");aD(()=>{(n.type==="freedraw"||n.type==="autoshape")&&r(n.type)},[n.type]);let i=t.find(a=>a.type===o)||t[0];return ng(la,{app:e,options:t,activeTool:n,defaultOption:o,"data-testid":"toolbar-freedraw",onToolChange:a=>{(a==="freedraw"||a==="autoshape")&&(r(a),e.setActiveTool({type:a}))},displayedOption:i})};import{jsx as hD}from"react/jsx-runtime";var gt=O({name:"finalize",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=!0,i=e,{focusContainer:a,scene:s}=o,l=s.getNonDeletedElementsMap(),c=n.activeTool.type==="autoshape";if(t&&n.selectedLinearElement){let{event:b,sceneCoords:v}=t,w=sl.getElement(n.selectedLinearElement.elementId,l);gw(w,"Arrow element should exist if selectedLinearElement is set"),gw(v,"sceneCoords should be defined if actionFinalize is called with event");let x=sl.handlePointerUp(b,n.selectedLinearElement,n,o.scene);if(rg(w)&&!n.selectedLinearElement.segmentMidPointHoveredCoords){let I=!!n.newElement,T=I||!n.selectedLinearElement.selectedPointsIndices?[w.points.length-1]:n.selectedLinearElement.selectedPointsIndices,C=pD(b),P=b[qd.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),M=T.reduce((D,_)=>(D.set(_,{point:C?w.points[_]:sl.createPointAt(w,l,v.x-x.pointerOffset.x,v.y-x.pointerOffset.y,P)}),D),new Map)??new Map;mw(w,M,v.x,v.y,s,n,{newArrow:I,altKey:b.altKey,angleLocked:C,gridSize:o.getEffectiveGridSize()})}else jd(w)&&n.selectedLinearElement?.isEditing&&!n.newElement&&!pw(w.points)&&s.mutateElement(w,{polygon:!1});if(x!==n.selectedLinearElement){w&&ig(w)&&(i=i.map(T=>T.id===w.id?og(T,{isDeleted:!0}):T));let I=n.activeTool?.locked;return{elements:w.points.length<2||ig(w)?e.map(T=>T.id===w.id?og(T,{isDeleted:!0}):T):i,appState:{...n,cursorButton:"up",selectedElementIds:c?{}:n.selectedElementIds,selectedLinearElement:I||c?null:{...x,selectedPointsIndices:null,isEditing:!1,initialState:{...x.initialState,lastClickedPoint:-1},pointerOffset:{x:0,y:0}},selectionElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,newElement:null,multiElement:null},captureUpdate:ag.IMMEDIATELY}}}window.document.activeElement instanceof HTMLElement&&a();let d=o.drawShape.hasPendingGesture();(d||c)&&(o.drawShape.finalize(),d&&(i=o.scene.getElementsIncludingDeleted()));let m=null;if(n.multiElement)m=n.multiElement;else if(!c&&!d&&(n.newElement?.type==="freedraw"||rg(n.newElement)))m=n.newElement;else if(Object.keys(n.selectedElementIds).length===1){let b=l.get(Object.keys(n.selectedElementIds)[0]);b&&(m=b)}if(m){if(n.selectedLinearElement&&n.multiElement&&m.type!=="freedraw"&&n.lastPointerDownWith!=="touch"){let{points:b}=m,{lastCommittedPoint:v}=n.selectedLinearElement;if((!v||b[b.length-1]!==v)&&(r=!1,s.mutateElement(m,{points:m.points.slice(0,-1)}),rg(m)&&m.endBinding&&m.points.length>1)){let w=!!n.newElement,x=new Map([[m.points.length-1,{point:m.points[m.points.length-1],isDragging:!1}]]),I=sl.getPointAtIndexGlobalCoordinates(m,-1,l);mw(m,x,I[0],I[1],s,n,{newArrow:w})}}if(m&&ig(m)&&(i=i.map(b=>b.id===m?.id?og(b,{isDeleted:!0}):b)),hw(m)||uw(m)){if(uD(m.points,n.zoom.value)&&(jd(m)||uw(m))){let v=m.points,w=v[0],x=v.map((I,T)=>T===v.length-1?dD(w[0],w[1]):I);jd(m)?s.mutateElement(m,{points:x,polygon:!0}):s.mutateElement(m,{points:x})}jd(m)&&!pw(m.points)&&s.mutateElement(m,{polygon:!1})}}let p;ca.includes(n.activeTool.type)?p=fw(n,{...n.activeTool.lastActiveTool||{type:o.state.preferredSelectionTool.type},lastActiveTool:null}):p=fw(n,{type:o.state.preferredSelectionTool.type});let u=o.isToolLocked(),E=n.activeTool.type==="autoshape"||(u||n.activeTool.type==="freedraw")&&!!m;E||o.cursor.applyForTool(p);let g=m&&hw(m)?new sl(m,mD(i)):n.selectedLinearElement;return g=g&&{...g,isEditing:n.newElement?!1:g.isEditing,initialState:{...g.initialState,lastClickedPoint:-1,origin:null}},{elements:i,appState:{...n,cursorButton:"up",activeTool:E?n.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null,selectedElementIds:c?{}:m&&!u&&n.activeTool.type!=="freedraw"?{...n.selectedElementIds,[m.id]:!0}:n.selectedElementIds,selectedLinearElement:c?null:g},captureUpdate:r?ag.IMMEDIATELY:ag.NEVER}},keyTest:(e,n)=>e.key===qd.ESCAPE&&n.selectedLinearElement?.isEditing||(e.key===qd.ESCAPE||e.key===qd.ENTER)&&n.multiElement!==null,PanelComponent:({appState:e,updateData:n,data:t})=>hD($,{type:"button",icon:s1,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:n,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{getElementsInGroup as xw,isSomeElementSelected as gD,makeNextSelectedElementIds as fD,selectGroupsForSelectedElements as ED}from"@excalidraw/element";import{CaptureUpdateAction as Ew}from"@excalidraw/element";import{KEYS as bD,isWritableElement as xD,updateActiveTool as bw}from"@excalidraw/common";var yD=(e,n)=>ca.includes(e.activeTool.type)?bw(e,{...e.activeTool.lastActiveTool||{type:n.state.preferredSelectionTool.type},lastActiveTool:null}):bw(e,{type:n.state.preferredSelectionTool.type}),wD=(e,n,t)=>{if(!e.editingGroupId)return null;let o=n.scene.getNonDeletedElements(),r=n.scene.getSelectedElements({selectedElementIds:t,elements:o}),i=r.length?r:xw(o,e.editingGroupId);for(let a of i){let s=a.groupIds.indexOf(e.editingGroupId);if(s!==-1&&a.groupIds[s+1])return a.groupIds[s+1]}return null},vD=O({name:"deselect",label:"",trackEvent:!1,perform:(e,n,t,o)=>{let r=yD(n,o);if(o.cursor.applyForTool(r),n.editingGroupId){let i=o.scene.getNonDeletedElements(),a=Object.keys(n.selectedElementIds).length>0?n.selectedElementIds:xw(i,n.editingGroupId).reduce((s,l)=>(s[l.id]=!0,s),{});return{appState:{...n,...ED({editingGroupId:wD(n,o,a),selectedElementIds:a},i,n,o),activeEmbeddable:null,activeTool:r,selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Ew.IMMEDIATELY}}return{appState:{...n,activeEmbeddable:null,activeTool:r,editingGroupId:null,selectedElementIds:fD({},n),selectedGroupIds:{},selectedLinearElement:null,selectionElement:null,showHyperlinkPopup:!1,suggestedBinding:null,hoveredArrowTextAnchor:null,frameToHighlight:null},captureUpdate:Ew.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key!==bD.ESCAPE||xD(e.target)?!1:!n.newElement&&n.multiElement===null&&!n.selectedLinearElement?.isEditing&&(n.activeEmbeddable!==null||n.activeTool.type!==o.state.preferredSelectionTool.type||!!n.editingGroupId||!!n.selectedLinearElement||gD(o.scene.getNonDeletedElements(),n))});import{KEYS as sm,THEME as pl}from"@excalidraw/common";import{CaptureUpdateAction as _n}from"@excalidraw/element";import ID from"clsx";import{jsx as yw,jsxs as TD}from"react/jsx-runtime";var sg=({children:e,checked:n,onChange:t,className:o})=>TD("div",{className:ID("Checkbox",o,{"is-checked":n}),onClick:r=>{t(!n,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[yw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":n,children:$c}),yw("div",{className:"Checkbox-label",children:e})]});import{THEME as ll}from"@excalidraw/common";import{jsx as cl}from"react/jsx-runtime";var vw=e=>{let n=e.title||(e.value===ll.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return cl($,{type:"icon",icon:e.value===ll.LIGHT?ww.MOON:ww.SUN,title:n,"aria-label":n,onClick:()=>e.onChange(e.value===ll.DARK?ll.LIGHT:ll.DARK),"data-testid":"toggle-dark-mode"})},ww={SUN:cl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:cl("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:cl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:cl("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 SD}from"react";import{focusNearestParent as CD,KEYS as PD}from"@excalidraw/common";import{jsx as Iw,jsxs as kD}from"react/jsx-runtime";var Tw=e=>{let{id:n}=ze(),[t,o]=SD(e.value),r=a=>{e.ignoreFocus||CD(a.target);let s=a.target.value;s!==e.value&&e.onChange(s)},i=a=>{if(a.key===PD.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return kD("div",{className:"ProjectName",children:[Iw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Iw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${n}-filename`,value:t,onChange:a=>o(a.target.value)})]})};import{useCallback as MD,useEffect as AD,useRef as DD}from"react";import{jsx as Jd,jsxs as ND}from"react/jsx-runtime";var LD=5e3,_D=({progress:e})=>Jd("div",{className:"Toast__progress-bar",children:Jd("div",{className:"Toast__progress-bar-fill",style:{width:`${Math.min(5,Math.round(e*100))}%`}})}),RD=({message:e,onClose:n,closable:t=!1,duration:o=LD,style:r})=>{let i=DD(0),a=o!==1/0,s=MD(()=>{a&&(i.current=window.setTimeout(()=>n(),o))},[n,o,a]);return AD(()=>{if(a)return s(),()=>clearTimeout(i.current)},[s,e,o,a]),ND("div",{className:"Toast",role:"status",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?s:void 0,style:r,children:[Jd("div",{className:"Toast__message",children:e}),t&&Jd($,{icon:an,"aria-label":"close",type:"icon",onClick:n,className:"close"})]})},Qd=Object.assign(RD,{ProgressBar:_D});import{DEFAULT_EXPORT_PADDING as eL,DEFAULT_FILENAME as tL,IMAGE_MIME_TYPES as Aw,isFirefox as nL,MIME_TYPES as oL,cloneJSON as rL,SVG_DOCUMENT_PREAMBLE as iL,arrayToMap as aL}from"@excalidraw/common";import{getNonDeletedElements as sL}from"@excalidraw/element";import{isFrameLikeElement as lL}from"@excalidraw/element";import{getElementsOverlappingFrame as cL}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as BD,EXPORT_DATA_TYPES as dl,MIME_TYPES as De,arrayToMap as FD,isMemberOf as OD,isPromiseLike as zD,EVENT as em}from"@excalidraw/common";import{mutateElement as GD}from"@excalidraw/element";import{deepCopyElement as HD}from"@excalidraw/element";import{isFrameLikeElement as UD,isInitializedImageElement as Cw}from"@excalidraw/element";import{getContainingFrame as Sw}from"@excalidraw/element";var Pw=`web ${De.excalidrawClipboard}`,cie="clipboard"in navigator&&"readText"in navigator.clipboard,tm="clipboard"in navigator&&"writeText"in navigator.clipboard,pr="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,WD=()=>"clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,VD=e=>!!([dl.excalidraw,dl.excalidrawClipboard,dl.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),nm=({types:e,files:n})=>{!e&&!n&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(em.PASTE,{clipboardData:new DataTransfer});if(e)for(let[o,r]of Object.entries(e)){if(typeof r!="string"){n=n||[],n.push(r);continue}try{if(t.clipboardData?.items.add(r,o),t.clipboardData?.getData(o)!==r)throw new Error(`Failed to set "${o}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(n){let o=-1;for(let r of n){o++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[o]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},YD=({elements:e,files:n})=>{let t=FD(e),o=new Set(e.filter(s=>UD(s))),r=!1,i=e.reduce((s,l)=>(Cw(l)&&(r=!0,n&&n[l.fileId]&&(s[l.fileId]=n[l.fileId])),s),{});r&&!n&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:dl.excalidrawClipboard,elements:e.map(s=>{if(Sw(s,t)&&!o.has(Sw(s,t))){let l=HD(s);return GD(l,t,{frameId:null}),l}return s}),files:n?i:void 0};return JSON.stringify(a)},KD=async e=>{let n=await createImageBitmap(e);try{let t=document.createElement("canvas");t.width=n.width,t.height=n.height;let o=t.getContext("2d");if(!o)throw new Error("Could not create a canvas context for clipboard image");return o.drawImage(n,0,0),await new Promise((r,i)=>{t.toBlob(a=>{a?r(a):i(new Error("Could not encode clipboard image as PNG"))},De.png)})}finally{n.close()}},om=async(e,n,t)=>{let o=YD({elements:e,files:n}),r=e.length===1&&Cw(e[0])?n?.[e[0].fileId]:null,i=r&&Fu(r.mimeType)&&r.dataURL?Ax(r.dataURL,r.fileName):null;if(i){let a=i.type===De.png?i:KD(i);if(WD())try{await navigator.clipboard.write([new ClipboardItem({[Pw]:new Blob([o],{type:De.excalidrawClipboard}),[De.png]:a})]);return}catch(s){console.error("Error copying image with ClipboardItem",s)}if(t?.clipboardData?.items)try{let s=i.type===De.png?i:new File([await a],`${i.name.replace(/\.[^/.]+$/,"")||"image"}.png`,{type:De.png});t.clipboardData.items.add(s),await ao({[De.excalidrawClipboard]:o},t);return}catch(s){console.error("Error copying image to clipboard event",s)}}await ao({[De.excalidrawClipboard]:o,[De.text]:o},t)};function kw(e){let n=[];for(let t of e.childNodes)if(t.nodeType===3){let o=t.textContent?.trim();o&&n.push({type:"text",value:o})}else if(t instanceof HTMLImageElement){let o=t.getAttribute("src");o&&o.startsWith("http")&&n.push({type:"imageUrl",value:o})}else n=n.concat(kw(t));return n}var XD=e=>{let n=e.value;try{let t=new DOMParser().parseFromString(n,De.html),o=kw(t.body);if(o.length)return{type:"mixedContent",value:o}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},rm=async()=>{let e={},n;try{n=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let o=await navigator.clipboard?.readText();if(o)return{[De.text]:o}}}catch(o){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${o.message}). Failling back to navigator.clipboard.read()`);else{if(o.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${o.message}`),e;throw o}}throw t}for(let t of n)for(let o of t.types){if(o===Pw){try{e[De.excalidrawClipboard]=await(await t.getType(o)).text()}catch(r){console.warn(`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}continue}if(OD(BD,o))try{if(o===De.text||o===De.html||o===De.excalidrawClipboard)e[o]=await(await t.getType(o)).text();else if(Fu(o)){let r=await t.getType(o),i=Nx(r,o,void 0);e[o]=i}else throw new Ru(`Unsupported clipboard type: ${o}`)}catch(r){console.warn(r instanceof Ru?r.message:`Cannot retrieve ${o} from clipboardItem: ${r.message}`)}}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},ZD=async(e,n=!1)=>{try{let t=e.findByType(De.html),o=!n&&t&&XD(t);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.getData(De.text)??o.value.map(r=>r.value).join(`
2
+ `).trim()}:o:{type:"text",value:(e.getData(De.text)||"").trim()}}catch{return{type:"text",value:""}}},$D=function(e){return this.find(n=>n.type===e)||null},jD=function(e){return this.find(t=>t.type===e)?.value??null},qD=function(){return this.filter(e=>e.kind==="file")},lg=e=>{let n=cg(e)?e.clipboardData:e.dataTransfer,t=Array.from(n?.types??[]),o=Array.from(new Set([...t.filter(i=>i!=="Files"),De.text,De.html,"text/uri-list","public.url","public.plain-text","text/x-moz-url"])),r={};for(let i of o)try{let a=n?.getData(i);a&&(r[i]=a)}catch{}return{items:Array.from(n?.items??[]).map(i=>({kind:i.kind,type:i.type})),files:Array.from(n?.files??[]).map(i=>({name:i.name,type:i.type,size:i.size,lastModified:i.lastModified})),types:t,data:r}},JD=e=>e.map(n=>n.kind==="string"?{kind:n.kind,type:n.type,value:n.value}:{kind:n.kind,type:n.type,file:{name:n.file.name,type:n.file.type,size:n.file.size,lastModified:n.file.lastModified}}),im=(e,n,t)=>{let o=[],r=[],i=[],a=(u,E)=>{let g=E?.trim();g&&!u.includes(g)&&u.push(g)},s=(u,E)=>{E.split(/\r?\n/).map(g=>g.trim()).filter(g=>g&&!g.startsWith("#")).forEach(g=>a(u,g))};e.forEach(u=>{if(u.kind==="string")if(u.type===De.html)try{let E=new DOMParser().parseFromString(u.value,De.html);for(let g of Array.from(E.body.querySelectorAll("img")))a(o,g.getAttribute("src")),a(i,g.getAttribute("alt"))}catch{}else u.type===De.text?a(r,u.value):u.type==="text/uri-list"&&s(r,u.value)});let l=[...o,...r.filter(u=>!o.includes(u))],c=Array.from({length:n},()=>({})),d={...t??{items:[],files:[],types:[],data:{}},parsedItems:JD(e)};c.forEach((u,E)=>{let g=l[E],b=i[E];g&&(u.src=g),b&&(u.alt=b),u.rawDragData=d});let m=l.slice(c.length),p=c[0];return p&&m.length>0&&m.forEach((u,E)=>{p[`additionalUrl${E+1}`]=u}),c},Mw=e=>{let n;cg(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=new Set;for(let o of Array.from(n||[]))t.has(o.type)||t.add(o.type);return t},ur=async e=>{let n;cg(e)?n=e.clipboardData?.items:n=e.dataTransfer?.items;let t=(await Promise.all(Array.from(n||[]).map(async o=>{if(o.kind==="file"){let r=o.getAsFile();if(r){let i=await Rx(o);return r=await Ur(r),{type:r.type,kind:"file",file:r,fileHandle:i}}}else if(o.kind==="string"){let{type:r}=o,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(r):i=await new Promise(a=>{o.getAsString(s=>a(s))}),{type:r,kind:"string",value:i}}return null}))).filter(o=>o!=null);return Object.assign(t,{findByType:$D,getData:jD,getFiles:qD})},ml=async(e,n=!1)=>{let t=e.getData(De.excalidrawClipboard),o=t?{type:"text",value:t}:await ZD(e,n);if(o.type==="mixedContent")return{mixedContent:o.value};try{let r=JSON.parse(o.value),i=r.type===dl.excalidrawClipboardWithAPI;if(VD(r))return{elements:r.elements,files:r.files,text:n?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:i}}catch{}return{text:o.value}},am=async e=>{try{await navigator.clipboard.write([new ClipboardItem({[De.png]:e})])}catch(n){if(zD(e))await navigator.clipboard.write([new ClipboardItem({[De.png]:await e})]);else throw n}},ao=async(e,n)=>{e=e||"";let t=Object.entries(typeof e=="string"?{[De.text]:e}:e);try{if(n){for(let[r,i]of t)if(n.clipboardData?.setData(r,i),n.clipboardData?.getData(r)!==i)throw new Error("Failed to setData on clipboardEvent");return}}catch(r){console.error(r)}let o=t.find(([r])=>r===De.text);if(tm&&o)try{await navigator.clipboard.writeText(o[1]);return}catch(r){console.error(r)}if(o&&!QD(o[1]))throw new Error("Error copying to clipboard.")},QD=e=>{e||(e=" ");let n=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[n?"right":"left"]="-9999px";let o=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${o}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let r=!1;try{t.select(),t.setSelectionRange(0,t.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),r},cg=e=>e.type===em.PASTE||e.type===em.COPY||e.type===em.CUT;var Qr=(e,{selectedElementIds:n},t)=>{let o=sL(e),r=aL(o),i=t&&Ne(o,{selectedElementIds:n}),a=null,s=i?de(o,{selectedElementIds:n},{includeBoundTextElement:!0}):o;if(i){let l=s[0];s.length===1&&lL(l)?(a=l,s=cL(o,l,r)):s.length>1&&(s=de(o,{selectedElementIds:n},{includeBoundTextElement:!0,includeElementsInFrames:!0}))}return{exportingFrame:a,exportedElements:rL(s)}},ei=async(e,n,t,o,{exportBackground:r,exportPadding:i=eL,viewBackgroundColor:a,name:s=t.name||tL,fileHandle:l=null,exportingFrame:c=null})=>{if(n.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let m=Gr(n,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},o,{exportingFrame:c});if(e==="svg")return Nu(m.then(p=>new Blob([iL+p.outerHTML],{type:oL.svg})),{description:"Export to SVG",name:s,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Aw.svg],fileHandle:l});if(e==="clipboard-svg"){let p=await m.then(u=>u.outerHTML);try{await ao(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let d=Gc(n,t,o,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let m=Ds(d);return t.exportEmbedScene&&(m=m.then(p=>import("./data/image-ELTE3WZG.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:Ps(n,t,o,"local")})))),Nu(m,{description:"Export to PNG",name:s,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Aw.png],fileHandle:l})}else if(e==="clipboard")try{let m=Ds(d);await am(m)}catch(m){throw console.warn(m),m.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):nL&&m.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
3
3
 
4
- ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Aw=async(e,n,t)=>{let o=Cx(n);if(!Px(o))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:r,appState:i,files:a}=await e,{exportBackground:s,viewBackgroundColor:l}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:d}=qr(r,i,!1);return await Jr(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as lL,jsx as pr,jsxs as Rw}from"react/jsx-runtime";var dg=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:_n.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>pr(Iw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),Dw=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:_n.EVENTUALLY})}),mg=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:_n.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>pr(ag,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),lm=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:_n.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Rw(ag,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),pr(ht,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:pr("div",{className:"excalidraw-tooltip-icon",children:l1})})]})}),da=!1,cg=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?Rw(lL,{children:[t,pr(Qd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function sL(e,n){if(n.app.state.isLoading&&(cg(n.app,{progress:null}),await n.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(n.signal.aborted){e.return();return}if(t.type==="progress")cg(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(cg(n.app,{progress:null}),await e)}function Lw(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await sL(o.props.onExport("json",{elements:e,appState:n,files:t},{signal:i}),{app:o,signal:i})}catch(l){l?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",l)}s({elements:e,appState:n,files:o.files})});return{abortController:r,data:a}}var Qr=O({name:"saveToActiveFile",label:"buttons.save",icon:Bs,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(da)return!1;da=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=Lw(e,n,o.files,o);try{let{fileHandle:l}=Hc(r)?await Aw(s,r,i):await Nc({data:s,filename:i,fileHandle:r});return{captureUpdate:_n.NEVER,appState:{fileHandle:l,toast:{message:r&&l?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${l.name}"`):f("toast.fileSaved"),duration:1500}}}}catch(l){return a.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:_n.NEVER,appState:{toast:null}}}finally{da=!1}},keyTest:e=>!1}),ul=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Bs,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(da)return!1;da=!0;let{abortController:r,data:i}=Lw(e,n,o.files,o);try{let{fileHandle:a}=await Nc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:_n.NEVER,appState:{openDialog:null,fileHandle:a,toast:{message:f("toast.fileSaved"),duration:3e3}}}}catch(a){return r.abort(),a?.name!=="AbortError"?console.error(a):console.warn(a),{captureUpdate:_n.NEVER,appState:{toast:null}}}finally{da=!1}},keyTest:e=>e.key.toLowerCase()===sm.S&&e.shiftKey&&e[sm.CTRL_OR_CMD],PanelComponent:({updateData:e})=>pr($,{type:"button",icon:o1,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:Ee().formFactor==="phone",hidden:!_i,onClick:()=>e(null),"data-testid":"save-as-button"})}),ma=O({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{try{let{elements:r,appState:i,files:a}=await Nu(n,e);return{elements:r,appState:i,files:a,captureUpdate:_n.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:_n.EVENTUALLY}}},keyTest:e=>e[sm.CTRL_OR_CMD]&&e.key===sm.O}),_w=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?pl.DARK:pl.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:_n.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>pr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:pr(ww,{value:e.exportWithDarkMode?pl.DARK:pl.LIGHT,onChange:t=>{n(t===pl.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as cL,DEFAULT_FONT_FAMILY as dL,DEFAULT_TEXT_ALIGN as mL,getLineHeight as pL}from"@excalidraw/common";import{newElementWith as cm}from"@excalidraw/element";import{hasBoundTextElement as uL,canApplyRoundnessTypeToElement as hL,getDefaultRoundnessTypeForElement as gL,isFrameLikeElement as fL,isArrowElement as EL,isExcalidrawElement as bL,isTextElement as Nw}from"@excalidraw/element";import{getBoundTextElement as xL,redrawTextBoundingBox as yL}from"@excalidraw/element";import{CaptureUpdateAction as pg}from"@excalidraw/element";var Bw="{}",wL=O({name:"copyStyles",label:"labels.copyStyles",icon:sh,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&uL(i)){let a=xL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(Bw=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:pg.EVENTUALLY}}}),vL=O({name:"pasteStyles",label:"labels.pasteStyles",icon:sh,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(Bw),i=r[0],a=r[1];if(!bL(i))return{elements:e,captureUpdate:pg.EVENTUALLY};let s=de(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(Nw(c)&&c.containerId&&(d=a),!d)return c;let m=cm(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?hL(d.roundness.type,c)?d.roundness:gL(c):null});if(Nw(m)){let p=d.fontSize||cL,u=d.fontFamily||dL,E=cm(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||mL,lineHeight:d.lineHeight||pL(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),yL(E,g,o.scene)}return m.type==="arrow"&&EL(d)&&(m=cm(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),fL(c)&&(m=cm(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:pg.IMMEDIATELY}}});import{KEYS as IL}from"@excalidraw/common";import{CaptureUpdateAction as TL}from"@excalidraw/element";var ei=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Jx,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,n,t,{focusContainer:o})=>(n.openDialog?.name==="help"&&o(),{appState:{...n,openDialog:n.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:TL.EVENTUALLY}),keyTest:e=>e.key===IL.QUESTION_MARK});import{getNonDeletedElements as mm}from"@excalidraw/element";import{newElementWith as Ow}from"@excalidraw/element";import{isBoundToContainer as SL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as CL,getElementsInResizingFrame as PL,getFrameLikeElements as kL,getRootElements as ML,groupByFrameLikes as AL,removeElementsFromFrame as DL,replaceAllElementsInFrame as LL}from"@excalidraw/element";import{KEYS as pm,randomId as _L,arrayToMap as hg}from"@excalidraw/common";import{getSelectedGroupIds as dm,selectGroup as RL,selectGroupsForSelectedElements as NL,getElementsInGroup as Fw,addToGroup as BL,removeFromSelectedGroups as FL,isElementInGroup as zw}from"@excalidraw/element";import{syncMovedIndices as OL}from"@excalidraw/element";import{CaptureUpdateAction as hl}from"@excalidraw/element";import{jsx as pa}from"react/jsx-runtime";var zL=(e,n)=>{if(e.length>=2){let t=n?e[0].groupIds.indexOf(n):-1,o=t>-1?e[0].groupIds.slice(0,t):e[0].groupIds;for(let r of o)if(e.every(i=>zw(i,r)))return!0}return!1},ug=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!zL(t,e.editingGroupId)&&!CL(t)},gg=O({name:"group",label:"labels.group",icon:e=>pa(eh,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!ug(n,o))return!1;let r=ML(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:hl.EVENTUALLY};let i=dm(n);if(i.length===1){let b=i[0],v=new Set(Fw(e,b).map(I=>I.id)),y=new Set(r.map(I=>I.id));if(new Set([...Array.from(v),...Array.from(y)]).size===v.size)return{appState:n,elements:e,captureUpdate:hl.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&AL(r).forEach((v,y)=>{DL(v,o.scene.getNonDeletedElementsMap())});let l=_L(),c=hg(r);a=a.map(b=>c.get(b.id)?Ow(b,{groupIds:BL(b.groupIds,l,n.editingGroupId)}):b);let d=Fw(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!zw(b,l)),g=OL([...E,...d,...u],hg(d));return{appState:{...n,...RL(l,{...n,selectedGroupIds:{}},mm(a))},elements:g,captureUpdate:hl.IMMEDIATELY}},predicate:(e,n,t,o)=>ug(n,o),keyTest:e=>!e.shiftKey&&e[pm.CTRL_OR_CMD]&&e.key===pm.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pa($,{hidden:!ug(n,o),type:"button",icon:pa(eh,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Re(mm(e),n)})}),fg=O({name:"ungroup",label:"labels.ungroup",icon:e=>pa(th,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=dm(n),i=hg(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:hl.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{SL(p)&&s.push(p.id);let u=FL(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:Ow(p,{groupIds:u})});let l=NL(n,mm(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return kL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=LL(a,PL(a,p,n,i),p))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((p,[u,E])=>(E&&!s.includes(u)&&(p[u]=!0),p),{}),{appState:{...n,...l},elements:a,captureUpdate:hl.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[pm.CTRL_OR_CMD]&&e.key===pm.G.toUpperCase(),predicate:(e,n)=>dm(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>pa($,{type:"button",hidden:dm(n).length===0,icon:pa(th,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Re(mm(e),n)})});import KL from"clsx";import{CaptureUpdateAction as Vw}from"@excalidraw/element";import{invariant as XL}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as GL,COLOR_VOICE_CALL as HL,COLOR_WHITE as hm,THEME as UL,UserIdleState as Gw}from"@excalidraw/common";var um=(e,n,t,o,r,i,a)=>{e.beginPath(),e.moveTo(n+i,t),e.lineTo(n+o-i,t),e.quadraticCurveTo(n+o,t,n+o,t+i),e.lineTo(n+o,t+r-i),e.quadraticCurveTo(n+o,t+r,n+o-i,t+r),e.lineTo(n+i,t+r),e.quadraticCurveTo(n,t+r,n,t+r-i),e.lineTo(n,t+i),e.quadraticCurveTo(n,t,n+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function WL(e){let n=0;if(e.length===0)return n;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);n=(n<<5)-n+o}return n}var ti=(e,n)=>`hsl(${Math.abs(WL(n?.id||e))%37*10}, 100%, 83%)`,Hw=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},Uw=({context:e,renderConfig:n,appState:t,normalizedWidth:o,normalizedHeight:r})=>{for(let[i,a]of n.remotePointerViewportCoords){let{x:s,y:l}=a,c=t.collaborators.get(i);s-=t.offsetLeft,l-=t.offsetTop;let d=11,m=14,p=s<0||s>o-d||l<0||l>r-m;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,r-m);let u=ti(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===Gw.IDLE||E===Gw.AWAY;g&&(e.globalAlpha=.3),n.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let b=t.theme===UL.DARK?"#2f6330":HL,v=c?.isSpeaking;v&&(e.fillStyle=b,e.strokeStyle=b,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=hm,e.strokeStyle=hm,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(s-1,l-1),e.lineTo(s-1,l+15),e.lineTo(s+5,l+10),e.lineTo(s+12,l+9),e.closePath(),e.fill()):(e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.fill(),e.stroke());let y=n.remotePointerUsernames.get(i)||"";if(!p&&y){e.font="600 12px sans-serif";let x=(v?s+0:s)+d/2,I=(v?l+0:l)+m+2,T=5,C=3,P=e.measureText(y),M=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,D=Math.max(M,12),_=x-1,k=I-1,L=P.width+2+T*2+2,F=D+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,L,F,8),e.fillStyle=u,e.fill(),e.strokeStyle=hm,e.stroke(),v&&(e.beginPath(),e.roundRect(_-2,k-2,L+4,F+4,8),e.strokeStyle=b,e.stroke())):um(e,_,k,L,F,8,hm),e.fillStyle=GL,e.fillText(y,x+T+1,I+C+P.actualBoundingBoxAscent+Math.floor((D-M)/2)+2),v){e.fillStyle=b;let K=8,z=8,U=5;e.fillRect(_+L+z,k+(F/2-K/2),2,K),e.fillRect(_+L+z+U,k+(F/2-K*2/2),2,K*2),e.fillRect(_+L+z+U*2,k+(F/2-K/2),2,K)}}e.restore(),e.closePath()}};import VL from"clsx";import{useState as YL}from"react";import{jsx as Ww}from"react/jsx-runtime";var Eg=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=Hw(t),[a,s]=YL(!1),l=!a&&o,c=l?void 0:{background:e};return Ww("div",{className:VL("Avatar",r),style:c,onClick:n,children:l?Ww("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as so,jsxs as gm}from"react/jsx-runtime";var ZL=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(XL(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.props.userToFollow?.socketId===t.socketId||t.isCurrentUser?(o.requestUnfollow(),{appState:n,captureUpdate:Vw.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:Vw.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=ti(o,r),l=KL({"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?gm("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[so("div",{}),so("div",{}),so("div",{})]}):r.isMuted?so("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:d0}):so("div",{title:f("userList.hint.inCall"),children:c0}):null;return i?gm("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:r.isCurrentUser?void 0:()=>e(r),children:[so(Eg,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),so("div",{className:"UserList__collaborator-name",children:r.username}),gm("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&so("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Yr}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):gm("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[so(Eg,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&so("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as ua}from"@excalidraw/element";import{isFrameLikeElement as JL}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as QL}from"@excalidraw/element";import{KEYS as ur,arrayToMap as e_}from"@excalidraw/common";import{alignElements as t_}from"@excalidraw/element";import{CaptureUpdateAction as oi}from"@excalidraw/element";import{getSelectedElementsByGroup as n_}from"@excalidraw/element";import $L from"clsx";import{jsx as Yw}from"react/jsx-runtime";var ni=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>Yw("div",{className:$L("Switch",{toggled:t,disabled:r}),children:Yw("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});var jL={stacking:!1},qL={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},lo=(e,n)=>({smartZoom:{...qL,...n?.smartZoom},align:{...jL,...e.alignConfiguration,...n?.align},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as hr,jsxs as d_}from"react/jsx-runtime";var lt=(e,n)=>{let t=n.scene.getSelectedElements(e);return n_(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>JL(o))},ha=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),{align:i,arrange:a}=lo(n,t.props.editorPreferences),s=t_(r,o,t.scene,n,{stacking:i.stacking,gap:a.gap}),l=e_(s);return QL(e.map(c=>l.get(c.id)||c),n,t)},o_=O({name:"toggleAlignStacking",label:"labels.stacking",trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>{let r=lo(n,o.props.editorPreferences).align.stacking,i=typeof t=="boolean"?t:!r;return o.props.onEditorPreferencesChange?.({align:{stacking:i}}),{appState:{...n,alignConfiguration:{stacking:i}},captureUpdate:oi.NEVER}},PanelComponent:({appState:e,updateData:n,appProps:t})=>{let o=lo(e,t.editorPreferences).align.stacking;return d_("div",{className:"align-stacking-toggle",children:[hr("label",{htmlFor:"alignStacking",children:f("labels.stacking")}),hr(ni,{name:"alignStacking",checked:o,title:f("labels.stacking"),onChange:r=>n(r)})]})}}),r_=O({name:"alignTop",label:"labels.alignTop",icon:Zu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"start",axis:"y"}),captureUpdate:oi.IMMEDIATELY}),keyTest:e=>e[ur.CTRL_OR_CMD]&&e.shiftKey&&e.key===ur.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>hr($,{hidden:!lt(n,o),type:"button",icon:Zu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Re(ua(e),n)})}),i_=O({name:"alignBottom",label:"labels.alignBottom",icon:$u,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"end",axis:"y"}),captureUpdate:oi.IMMEDIATELY}),keyTest:e=>e[ur.CTRL_OR_CMD]&&e.shiftKey&&e.key===ur.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>hr($,{hidden:!lt(n,o),type:"button",icon:$u,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Re(ua(e),n)})}),a_=O({name:"alignLeft",label:"labels.alignLeft",icon:ju,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"start",axis:"x"}),captureUpdate:oi.IMMEDIATELY}),keyTest:e=>e[ur.CTRL_OR_CMD]&&e.shiftKey&&e.key===ur.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>hr($,{hidden:!lt(n,o),type:"button",icon:ju,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Re(ua(e),n)})}),s_=O({name:"alignRight",label:"labels.alignRight",icon:qu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"end",axis:"x"}),captureUpdate:oi.IMMEDIATELY}),keyTest:e=>e[ur.CTRL_OR_CMD]&&e.shiftKey&&e.key===ur.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>hr($,{hidden:!lt(n,o),type:"button",icon:qu,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Re(ua(e),n)})}),l_=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Ju,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"center",axis:"y"}),captureUpdate:oi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>hr($,{hidden:!lt(n,o),type:"button",icon:Ju,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Re(ua(e),n)})}),c_=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Qu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"center",axis:"x"}),captureUpdate:oi.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>hr($,{hidden:!lt(n,o),type:"button",icon:Qu,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Re(ua(e),n)})});import{getNonDeletedElements as Kw}from"@excalidraw/element";import{isFrameLikeElement as m_}from"@excalidraw/element";import{CODES as Xw,KEYS as Zw,arrayToMap as p_}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as u_}from"@excalidraw/element";import{distributeElements as h_}from"@excalidraw/element";import{CaptureUpdateAction as $w}from"@excalidraw/element";import{getSelectedElementsByGroup as g_}from"@excalidraw/element";import{jsx as Jw}from"react/jsx-runtime";var jw=(e,n)=>{let t=n.scene.getSelectedElements(e);return g_(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>m_(o))},qw=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=h_(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=p_(i);return u_(e.map(s=>a.get(s.id)||s),n,t)},f_=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:qw(e,n,o,{space:"between",axis:"x"}),captureUpdate:$w.IMMEDIATELY}),keyTest:e=>!e[Zw.CTRL_OR_CMD]&&e.altKey&&e.code===Xw.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Jw($,{hidden:!jw(n,o),type:"button",icon:p1,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Re(Kw(e),n)})}),E_=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:qw(e,n,o,{space:"between",axis:"y"}),captureUpdate:$w.IMMEDIATELY}),keyTest:e=>!e[Zw.CTRL_OR_CMD]&&e.altKey&&e.code===Xw.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Jw($,{hidden:!jw(n,o),type:"button",icon:u1,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Re(Kw(e),n)})});import{arrayToMap as Qw,KEYS as b_,matchKey as x_}from"@excalidraw/common";import{CaptureUpdateAction as y_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as w_}from"@excalidraw/element/frame";import{arrangeElements as v_}from"@excalidraw/element/arrange";import{jsx as S_}from"react/jsx-runtime";var I_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=Qw(e),{arrange:i}=lo(n,t.props.editorPreferences),a=v_(t.scene,o,r,i.algorithm,i.gap),s=Qw(a);return w_(e.map(l=>s.get(l.id)||l),n,t)},T_=lt,bg=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:ch,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>T_(n,o),perform:(e,n,t,o)=>({appState:n,elements:I_(e,n,o),captureUpdate:y_.IMMEDIATELY}),keyTest:e=>e.shiftKey&&x_(e,b_.A),PanelComponent:({updateData:e})=>S_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+A")}`,children:ch})});import{arrayToMap as ev}from"@excalidraw/common";import{CaptureUpdateAction as C_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as P_}from"@excalidraw/element/frame";import{normaliseElements as k_}from"@excalidraw/element/normalise";import{jsx as D_}from"react/jsx-runtime";var M_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=ev(e),{normalise:i}=lo(n,t.props.editorPreferences),a=k_(t.scene,o,r,i.mode,i.metric),s=ev(a);return P_(e.map(l=>s.get(l.id)||l),n,t)},A_=lt,xg=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:dh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>A_(n,o),perform:(e,n,t,o)=>({appState:n,elements:M_(e,n,o),captureUpdate:C_.IMMEDIATELY}),PanelComponent:({updateData:e})=>D_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:dh})});import{getNonDeletedElements as L_}from"@excalidraw/element";import{bindOrUnbindBindingElements as __}from"@excalidraw/element";import{getCommonBoundingBox as tv}from"@excalidraw/element";import{newElementWith as R_}from"@excalidraw/element";import{deepCopyElement as N_}from"@excalidraw/element";import{resizeMultipleElements as B_}from"@excalidraw/element";import{isArrowElement as nv,isElbowArrow as F_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as ov}from"@excalidraw/element";import{CODES as rv,KEYS as O_,arrayToMap as z_}from"@excalidraw/common";import{CaptureUpdateAction as iv}from"@excalidraw/element";var yg=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:h0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:ov(av(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:iv.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===rv.H}),wg=O({name:"flipVertical",label:"labels.flipVertical",icon:u0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:ov(av(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:iv.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===rv.V&&!e[O_.CTRL_OR_CMD]}),av=(e,n,t,o,r)=>{let i=de(L_(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=G_(i,n,o,r),s=z_(a);return e.map(l=>s.get(l.id)||l)},G_=(e,n,t,o)=>{if(e.every(p=>nv(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return R_(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=tv(e);B_(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,N_(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),__(e.filter(nv),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>F_(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=tv(e),[d,m]=[r-l,i-c];return s.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),a.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),e};import{CODES as sv,KEYS as lv}from"@excalidraw/common";import{CaptureUpdateAction as H_}from"@excalidraw/element";var cv=(e,n)=>({appState:{viewpointFlip:{...e.viewpointFlip,[n]:!e.viewpointFlip[n]}},captureUpdate:H_.NEVER}),ga=O({name:"flipViewpointHorizontal",label:"labels.flipViewpointHorizontal",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>cv(n,"horizontal"),checked:e=>e.viewpointFlip.horizontal,keyTest:e=>!e[lv.CTRL_OR_CMD]&&!e.altKey&&e.shiftKey&&e.code===sv.R}),fa=O({name:"flipViewpointVertical",label:"labels.flipViewpointVertical",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>cv(n,"vertical"),checked:e=>e.viewpointFlip.vertical,keyTest:e=>!e[lv.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===sv.R});import{isTextElement as U_}from"@excalidraw/element";import{getTextFromElements as W_}from"@excalidraw/element";import{CODES as V_,KEYS as fm,isFirefox as Y_}from"@excalidraw/common";import{CaptureUpdateAction as Qt}from"@excalidraw/element";var Ea=O({name:"copy",label:"labels.copy",icon:_s,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await om(r,o.files,t)}catch(i){return{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Qt.EVENTUALLY}},keyTest:e=>e[fm.CTRL_OR_CMD]&&e.key===fm.C}),vg=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await rm()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),Y_?{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(nm({types:r}))}catch(i){return console.error(i),{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Qt.EVENTUALLY}},keyTest:void 0}),Em=O({name:"cut",label:"labels.cut",icon:t0,trackEvent:{category:"element"},perform:(e,n,t,o)=>(Ea.perform(e,n,t,o),Gs.perform(e,n,null,o)),keyTest:e=>e[fm.CTRL_OR_CMD]&&e.key===fm.X}),K_=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:g0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Qt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=qr(e,n,!0);try{await Jr("clipboard-svg",r,n,o.files,{...n,exportingFrame:i,name:o.getName()});let a=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:Qt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Qt.EVENTUALLY}}},predicate:e=>tm&&e.length>0,keywords:["svg","clipboard","copy"]}),X_=O({name:"copyAsPng",label:"labels.copyAsPng",icon:f0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Qt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=qr(e,n,!0);try{return await Jr("clipboard",i,n,o.files,{...n,exportingFrame:a,name:o.getName()}),{appState:{...n,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:r.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:Qt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Qt.EVENTUALLY}}},predicate:e=>dr&&e.length>0,keyTest:e=>e.code===V_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Z_=O({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0});try{ao(W_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Qt.EVENTUALLY}},predicate:(e,n,t,o)=>tm&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(U_),keywords:["text","clipboard","copy"]});import{CODES as $_,KEYS as j_}from"@excalidraw/common";import{CaptureUpdateAction as q_}from"@excalidraw/element";var ba=O({name:"gridMode",icon:b0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,n){return{appState:{...n,gridModeEnabled:!this.checked(n),objectsSnapModeEnabled:!1},captureUpdate:q_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[j_.CTRL_OR_CMD]&&e.code===$_.QUOTE});import J_ from"clsx";import{KEYS as dv}from"@excalidraw/common";import{CaptureUpdateAction as Q_}from"@excalidraw/element/store";import{getElementBounds as mv}from"@excalidraw/element";import{isImageElement as eR}from"@excalidraw/element/typeChecks";import{jsx as nR}from"react/jsx-runtime";var pv="Press <kbd>F</kbd> quickly to smart zoom the canvas, or hold and click on an item to smart zoom to it",xa=Je(!1),uv=(e,n,t,o)=>{let r=e.filter(eR).sort((s,l)=>{let[c,d]=mv(s,n),[m,p]=mv(l,n);return d-p||c-m});if(r.length===0)return null;let i=r.findIndex(s=>s.id===t),a=o==="next"?(i+1)%r.length:(i<0?r.length-1:i-1+r.length)%r.length;return r[a]},tR=({data:e,updateData:n})=>{let t=Bi(xa);return nR($,{type:"button",icon:mh,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${dv.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:dv.F.toLocaleUpperCase(),className:J_({"smart-zoom-button--key-held":t})})},Rn=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:mh,viewMode:!0,perform:(e,n,t,o)=>{let r=lo(n,o.props.editorPreferences).smartZoom,i=t&&t.length>0?t:de(e,n);return o.viewport.setViewport({target:i.length?i:e,fit:r.fitToViewport?"contain":"none",animation:r.animate?{duration:r.duration}:!1,offsets:r.respectUIElements?{ui:!0}:void 0,viewportZoomFactor:r.viewportZoomFactor}),{captureUpdate:Q_.NEVER}},PanelComponent:tR});import{CODES as oR,KEYS as rR}from"@excalidraw/common";import{CaptureUpdateAction as iR}from"@excalidraw/element";var _t=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Jo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:iR.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[rR.CTRL_OR_CMD]&&e.altKey&&e.code===oR.S});import{CaptureUpdateAction as aR}from"@excalidraw/element";var gl=O({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,n){let t=n.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...n,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:aR.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as sR}from"@excalidraw/element";var fl=O({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,n){return{appState:{...n,isMidpointSnappingEnabled:!this.checked(n)},captureUpdate:sR.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as lR,KEYS as cR}from"@excalidraw/common";import{CaptureUpdateAction as dR}from"@excalidraw/element";var gr=O({name:"stats",label:"stats.fullTitle",icon:p0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:dR.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[cR.CTRL_OR_CMD]&&e.altKey&&e.code===lR.SLASH});import{BOUND_TEXT_PADDING as hv,ROUNDNESS as gv,TEXT_ALIGN as bv,VERTICAL_ALIGN as xv,arrayToMap as yv,getFontString as mR,getStrokeWidthByKey as pR}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as uR,isBoundToContainer as fv,resetOriginalContainerCache as hR,updateOriginalContainerCache as gR}from"@excalidraw/element";import{computeBoundTextPosition as fR,computeContainerDimensionForBoundText as Ev,getBoundTextElement as wv,redrawTextBoundingBox as vv}from"@excalidraw/element";import{hasBoundTextElement as ER,isArrowElement as bR,isTextBindableContainer as Ig,isTextElement as El,isUsingAdaptiveRadius as xR}from"@excalidraw/element";import{measureText as yR}from"@excalidraw/element";import{syncMovedIndices as Iv}from"@excalidraw/element";import{newElement as wR}from"@excalidraw/element";import{CaptureUpdateAction as Tg}from"@excalidraw/element";var Sg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>ER(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=wv(a,i);if(s){let{width:l,height:c}=yR(s.originalText,mR(s),s.lineHeight),d=uR(a.id);hR(a.id);let{x:m,y:p}=fR(a,s,i);o.scene.mutateElement(s,{containerId:null,width:l,height:c,text:s.originalText,x:m,y:p}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:n,captureUpdate:Tg.IMMEDIATELY}}}),Cg=O({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);if(r.length===2){let i=El(r[0])||El(r[1]),a;if(Ig(r[0])?a=r[0]:Ig(r[1])&&(a=r[1]),i&&a&&wv(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;El(r[0])&&Ig(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:xv.MIDDLE,textAlign:bv.CENTER,autoResize:!0,angle:bR(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return vv(i,a,o.scene),gR(a.id,s),{elements:vR(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:Tg.IMMEDIATELY}}}),vR=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===t.id);o.splice(r,1);let i=o.findIndex(a=>a.id===n.id);return o.splice(i+1,0,t),Iv(o,yv([n,t])),o},IR=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===n.id);o.splice(r,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i,0,n),Iv(o,yv([n,t])),o},Tv=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>El(a)&&!fv(a));return r.length>0&&i},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=e.slice(),a={};for(let s of r)if(El(s)&&!fv(s)){let l=wR({type:"rectangle",backgroundColor:n.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:n.currentItemFillStyle,strokeColor:n.currentItemStrokeColor,roughness:n.currentItemRoughness,strokeWidth:pR("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:xR("rectangle")?gv.ADAPTIVE_RADIUS:gv.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-hv,y:s.y-hv,width:Ev(s.width,"rectangle"),height:Ev(s.height,"rectangle"),groupIds:s.groupIds,frameId:s.frameId});if(s.boundElements?.length){let c=s.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===s.id&&(p={...p,elementId:l.id}),u?.elementId===s.id&&(u={...u,elementId:l.id}),(p||u)&&o.scene.mutateElement(m,{startBinding:p,endBinding:u})})}o.scene.mutateElement(s,{containerId:l.id,verticalAlign:xv.MIDDLE,boundElements:null,textAlign:bv.CENTER,autoResize:!0}),vv(s,l,o.scene),i=IR([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:Tg.IMMEDIATELY}}});import{getNonDeletedElements as Rv,isEmbeddableElement as GR}from"@excalidraw/element";import{KEYS as Nv}from"@excalidraw/common";import{CaptureUpdateAction as HR}from"@excalidraw/element";import{pointFrom as kv}from"@excalidraw/math";import TR from"clsx";import{useCallback as Sv,useEffect as Cv,useLayoutEffect as SR,useRef as CR,useState as PR}from"react";import{EVENT as Pg,HYPERLINK_TOOLTIP_DELAY as kR,KEYS as bm}from"@excalidraw/common";import{getElementAbsoluteCoords as Lg}from"@excalidraw/element";import{hitElementBoundingBox as MR}from"@excalidraw/element";import{isElementLink as AR}from"@excalidraw/element";import{getEmbedLink as DR,embeddableURLValidator as LR}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Mv,viewportCoordsToSceneCoords as _R,wrapEvent as RR,isLocalLink as NR,normalizeLink as kg}from"@excalidraw/common";import{isEmbeddableElement as Mg}from"@excalidraw/element";import{jsx as ya,jsxs as Pv}from"react/jsx-runtime";var _g=380,BR=42,Ag=5,Av=85,FR=500,Dg=!1,xm=new Map,Dv=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=ro(),l=Ln(),c=Ee(),d=e.link||"",[m,p]=PR(d),u=CR(null),E=s.showHyperlinkPopup==="editor",g=Sv(()=>{if(!u.current)return;let I=kg(u.current.value)||null;if(!e.link&&I&&Ue("hyperlink","create"),Mg(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!I){n.mutateElement(e,{link:null}),i(e,!1);return}if(!LR(I,l.validateEmbeddable))I&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&xm.set(e.id,e.link),n.mutateElement(e,{link:I}),i(e,!1);else{let{width:T,height:C}=e,P=DR(I);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let M=P?P.intrinsicSize.w/P.intrinsicSize.h:1,D=xm.get(e.id)!==e.link;n.mutateElement(e,{...D?{width:P?.type==="video"?T>C?T:C*M:T,height:P?.type==="video"&&T>C?T/M:C}:{},link:I}),i(e,!0),xm.has(e.id)&&xm.delete(e.id)}}else n.mutateElement(e,{link:I})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);SR(()=>()=>{g()},[g]),Cv(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),Cv(()=>{let I=null,T=C=>{if(E)return;I&&clearTimeout(I),zR(e,a,s,kv(C.clientX,C.clientY))&&(I=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},FR))};return window.addEventListener(Pg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(Pg.POINTER_MOVE,T,!1),I&&clearTimeout(I)}},[s,e,E,t,a]);let b=Sv(()=>{Ue("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),v=()=>{Ue("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:y,y:x}=Lv(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:Pv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${y}px`,width:_g,padding:Ag},children:[E?ya("input",{className:TR("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:m,onChange:I=>p(I.target.value),autoFocus:!0,onKeyDown:I=>{I.stopPropagation(),I[bm.CTRL_OR_CMD]&&I.key===bm.K&&I.preventDefault(),(I.key===bm.ENTER||I.key===bm.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?ya("a",{href:kg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:NR(e.link)?"_self":"_blank",onClick:I=>{if(e.link&&o){let T=RR(Pg.EXCALIDRAW_LINK,I.nativeEvent);o({...e,link:kg(e.link)},T),T.defaultPrevented&&I.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ya("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),Pv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&ya($,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:v,className:"excalidraw-hyperlinkContainer--edit",icon:Qn}),ya($,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:v0}),d&&!Mg(e)&&ya($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Ur})]})]})},Lv=(e,n,t)=>{let[o,r]=Lg(e,t),{x:i,y:a}=Mv({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-_g/2,l=a-n.offsetTop-Av;return{x:s,y:l}},Rg=(e,n)=>{let t=de(e,n);return Mg(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},bl=null,_v=(e,n,t)=>{bl&&clearTimeout(bl),bl=window.setTimeout(()=>OR(e,n,t),kR)},OR=(e,n,t)=>{if(!e.link)return;let o=oa();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=AR(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=Lg(e,t),[l,c,d,m]=yx([r,i,a,s],e.angle,n),p=Mv({sceneX:l,sceneY:c},n);qh(o,{left:p.x,top:p.y,width:d,height:m},"top"),Ue("hyperlink","tooltip","link-icon"),Dg=!0},ym=()=>{bl&&clearTimeout(bl),Dg&&(Dg=!1,oa().classList.remove("excalidraw-tooltip--visible"))},zR=(e,n,t,[o,r])=>{let{x:i,y:a}=_R({clientX:o,clientY:r},t),s=15/t.zoom.value;if(MR(kv(i,a),e,n))return!1;let[l,c,d]=Lg(e,n);if(i>=l&&i<=d&&a>=c-Av&&a<=c)return!1;let{x:m,y:p}=Lv(e,t,n);return!(o>=m-s&&o<=m+_g+Ag*2+s&&r>=p-s&&r<=p+s+Ag*2+BR)};import{jsx as UR}from"react/jsx-runtime";var Ng=O({name:"hyperlink",label:(e,n)=>Rg(Rv(e),n),icon:Fs,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:HR.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[Nv.CTRL_OR_CMD]&&e.key===Nv.K,predicate:(e,n)=>de(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=de(e,n);return UR($,{type:"toggle",icon:Fs,"aria-label":f(Rg(Rv(e),n)),title:`${GR(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onSelect:()=>t(null),checked:o.length===1&&!!o[0].link})}});import{KEYS as Bv,arrayToMap as Fg,randomId as WR}from"@excalidraw/common";import{elementsAreInSameGroup as VR,getNonDeletedElements as Fv,newElementWith as Ov,selectGroupsFromGivenElements as zv}from"@excalidraw/element";import{CaptureUpdateAction as Gv}from"@excalidraw/element";var Bg=e=>e.every(n=>!n.locked),xl=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return Bg(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=de(n,e);return Bg(t)?$o:To},trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=Bg(r),a=Fg(r),s=r.length>1&&VR(r),c=r.length===1||s?null:WR(),d={...n.lockedMultiSelections};if(i)d={...n.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let v=r[0].groupIds.at(-1);delete d[v]}let m=e.map(v=>{if(!a.has(v.id))return v;let y=v.groupIds;return i?c&&(y=[...y,c]):y=y.filter(x=>!n.lockedMultiSelections[x]),Ov(v,{locked:i,groupIds:y.length!==v.groupIds.length?y:v.groupIds})}),p=Fg(m),u=i?{}:Object.fromEntries(r.map(v=>[v.id,!0])),E=r.map(v=>p.get(v.id)||v),g=i?{}:zv(Fv(E),n),b=i?c||(s?r[0].groupIds.at(-1):r[0].id):null;return{elements:m,appState:{...n,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:n.selectedLinearElement,lockedMultiSelections:d,activeLockedId:b},captureUpdate:Gv.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===Bv.L&&e[Bv.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),Hv=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:To,predicate:(e,n)=>de(e,n).length===0&&e.some(o=>o.locked),perform:(e,n)=>{let t=e.filter(s=>s.locked),o=e.map(s=>{if(s.locked){let l=s.groupIds.filter(c=>!n.lockedMultiSelections[c]);return Ov(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=Fg(o),i=t.map(s=>r.get(s.id)||s),a=Fv(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:zv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:Gv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as o8,isLinearElement as r8,isLineElement as ka}from"@excalidraw/element";import{arrayToMap as i8,invariant as T2}from"@excalidraw/common";import{toggleLinePolygonState as a8,CaptureUpdateAction as S2}from"@excalidraw/element";import{getSizeFromPoints as fSe,randomInteger as t8,getUpdatedTimestamp as n8}from"@excalidraw/common";import{simplify as NN}from"points-on-curve";import{getStroke as BN,getStrokePoints as qTe}from"perfect-freehand";function Qe([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function wa([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function rt([e,n,t],o){return[e*o,n*o,t*o]}function ii([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function yt([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function Uv(e,n,t){return Qe(e,rt(wa(n,e),t))}function Og(e,n,t){return Math.atan2(t[1]-e[1],t[0]-e[0])-Math.atan2(n[1]-e[1],n[0]-e[0])}function zg(e){return Math.atan2(Math.sin(e),Math.cos(e))}function Gg([e,n]){return Math.sqrt(e**2+n**2)}function ri([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function Wv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=ri(e[t-1],e[t]);return n+=ri(e[e.length-2],e[e.length-1]),n}var YR=(e,n,t)=>Math.max(n,Math.min(t,e));function Vv(e,n,t){let o=ri(n,t);if(o===0)return ri(e,n);let r=YR(((e[0]-n[0])*(t[0]-n[0])+(e[1]-n[1])*(t[1]-n[1]))/o**2,0,1),i=[n[0]+r*(t[0]-n[0]),n[1]+r*(t[1]-n[1]),e[2]];return ri(i,e)}function yl(e,n){if(n===0||e.length<=2)return e;let t=e[0],o=e[e.length-1],[r,i]=e.reduce(([a,s],l,c)=>{let d=Vv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...yl([t,...e.slice(1,i),a],n).slice(0,-1),a,...yl([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var fr=class fr{constructor(n){w(this,"options");w(this,"originalPoints",[]);w(this,"stablePoints",[]);w(this,"tailPoints",[]);w(this,"isFresh",!0);this.options=Object.assign({},fr.defaults,n)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(n){let t=this.originalPoints[this.originalPoints.length-1];if(!(t&&t[0]===n[0]&&t[1]===n[1])){if(this.originalPoints.push(n),this.isFresh){this.isFresh=!1,this.stablePoints.push(n);return}this.options.streamline>0&&(n=Uv(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),Wv(this.tailPoints)>fr.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase==="tail")throw new Error("Not implemented yet");this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(n,t,o,r,i){return(n??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:o,totalLength:r})}getStrokeOutline(n){if(this.isFresh)return[];let t=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase==="input"&&(t=yl(t,this.options.simplify));let o=t.length;if(o===0)return[];if(o===1){let P=t[0],M=this.getSize(n,P[2],0,o,0);if(M<.5)return[];let D=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)D.push(Qe(P,rt(yt([1,0,0],_),M)));return D.push(Qe(P,rt([1,0,0],this.getSize(n,P[2],0,o,0)))),D}if(o===2){let P=t[0],M=t[1],D=this.getSize(n,P[2],0,o,0),_=this.getSize(n,M[2],0,o,0);if(D<.5||_<.5)return[];let k=[],L=Og(P,[P[0],P[1]-100,P[2]],M);for(let F=L;F<=Math.PI+L;F+=Math.PI/16)k.push(Qe(P,rt(yt([1,0,0],F),D)));for(let F=Math.PI+L;F<=Math.PI*2+L;F+=Math.PI/16)k.push(Qe(M,rt(yt([1,0,0],F),_)));return k.push(k[0]),k}let r=[],i=[],a=0,s=0,l=0,c=0;for(let P=1;P<o-1;P++){let M=t[P-1],D=t[P],_=t[P+1],k=D[2],L=ri(M,D);c+=L,a=s+(L-s)*.2;let F=this.getSize(n,k,P,o,c);if(F===0){l=P+1;continue}let K=ii(wa(M,D)),z=ii(wa(_,D)),U=yt(K,Math.PI/2),W=yt(K,-Math.PI/2),G=yt(z,Math.PI/2),ie=yt(z,-Math.PI/2),me=Qe(D,rt(U,F)),B=Qe(D,rt(W,F)),Y=Qe(D,rt(G,F)),pe=Qe(D,rt(ie,F)),ae=Qe(U,ie),be=Qe(W,G),ce=Qe(D,rt(Gg(ae)===0?K:ii(ae),F)),Fe=Qe(D,rt(Gg(be)===0?z:ii(be),F)),se=zg(Og(D,M,_)),Le=fr.constants.cornerDetectionMaxAngle/180*Math.PI*fr.constants.cornerDetectionVariance(a);if(Math.abs(se)<Le){let _e=Math.abs(zg(Math.PI-se));if(_e===0)continue;if(se<0){i.push(B,Fe);for(let Se=0;Se<=_e;Se+=_e/4)r.push(Qe(D,yt(rt(U,F),Se)));for(let Se=_e;Se>=0;Se-=_e/4)i.push(Qe(D,yt(rt(U,F),Se)));i.push(Fe,Y)}else{r.push(me,ce);for(let Se=0;Se<=_e;Se+=_e/4)i.push(Qe(D,yt(rt(U,-F),-Se)));for(let Se=_e;Se>=0;Se-=_e/4)r.push(Qe(D,yt(rt(U,-F),-Se)));r.push(ce,pe)}}else r.push(ce),i.push(Fe);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],M=[];for(let D=0;D<=Math.PI*2;D+=Math.PI/16)M.push(Qe(P,rt(yt([1,0,0],D),this.options.size)));return M.push(Qe(P,rt([1,0,0],this.options.size))),M}return[]}let d=t[l],m=t[l+1],p=t[o-2],u=t[o-1],E=ii(wa(m,d)),g=ii(wa(p,u)),b=yt(E,-Math.PI/2),v=yt(g,Math.PI/2),y=this.getSize(n,d[2],0,o,0),x=[],I=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,c),T=[];if(y>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift(Qe(d,yt(rt(b,y),-P)));x.unshift(Qe(d,rt(b,-y)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push(Qe(u,yt(rt(v,-I),-P)));let C=[...x,...r,...T.reverse(),...i.reverse()];return x.length>0&&C.push(x[0]),this.options.simplify>0&&this.options.simplifyPhase==="output"?yl(C,this.options.simplify):C}};w(fr,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),w(fr,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var va=fr;import{pointsOnBezierCurves as Xde}from"points-on-curve";import{invariant as $de}from"@excalidraw/common";import{curve as qde,lineSegment as Jde,pointFrom as Qde,pointDistance as eme,pointFromArray as tme,pointFromVector as nme,pointRotateRads as ome,polygon as rme,polygonFromPoints as ime,PRECISION as ame,segmentsIntersectAt as sme,vector as lme,vectorAdd as cme,vectorFromPoint as dme,vectorScale as mme}from"@excalidraw/math";import{getElementAbsoluteCoords as ume}from"@excalidraw/element";var Hg=e=>{if(!e)return[];for(let n of e.sets)if(n.type==="path")return n.ops;return e.sets[0].ops};import{pointFrom as FN,pointDistance as b2,pointRotateRads as tSe}from"@excalidraw/math";import{ROUGHNESS as ON,THEME as sf,isTransparent as _l,assertNever as zN,COLOR_PALETTE as GN,LINE_POLYGON_POINT_MERGE_DISTANCE as oSe,applyDarkModeFilter as Rl,DEFAULT_STROKE_STREAMLINE as HN}from"@excalidraw/common";import{RoughGenerator as UN}from"roughjs/bin/generator";import lTe from"roughjs/bin/rough";import{isRightAngleRads as dTe,lineSegment as mTe,pointFrom as pTe,pointRotateRads as uTe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as gTe,DEFAULT_REDUCED_GLOBAL_ALPHA as fTe,ELEMENT_READY_TO_ERASE_OPACITY as ETe,FRAME_STYLE as bTe,DARK_THEME_FILTER as xTe,MIME_TYPES as E2,THEME as yTe,distance as wTe,getFontString as vTe,isRTL as ITe,getVerticalOffset as TTe,invariant as STe,applyDarkModeFilter as CTe,isSafari as PTe}from"@excalidraw/common";import DIe from"roughjs/bin/rough";import{arrayToMap as _Ie,invariant as f2,rescalePoints as RIe,sizeOf as NIe}from"@excalidraw/common";import{degreesToRadians as nf,lineSegment as FIe,pointFrom as wt,pointFromArray as kN,pointRotateRads as Pa}from"@excalidraw/math";import{pointsOnBezierCurves as GIe}from"points-on-curve";import{pointCenter as $2e,pointFrom as j2e,pointRotateRads as q2e,pointsEqual as J2e,pointDistance as Q2e,vectorFromPoint as eIe,curveLength as tIe,curvePointAtLength as nIe}from"@excalidraw/math";import{DRAGGING_THRESHOLD as iIe,KEYS as aIe,shouldRotateWithDiscreteAngle as sIe,getGridPoint as lIe,invariant as cIe,isShallowEqual as dIe,getFeatureFlag as mIe}from"@excalidraw/common";import{arrayToMap as d2e,getFeatureFlag as m2e,getGridPoint as p2e,invariant as u2e,isTransparent as h2e}from"@excalidraw/common";import{PRECISION as f2e,clamp as E2e,lineSegment as b2e,pointDistance as x2e,pointDistanceSq as y2e,pointFrom as w2e,pointFromArray as v2e,pointFromVector as I2e,pointRotateRads as T2e,pointsEqual as S2e,vectorFromPoint as C2e,vectorNormalize as P2e,vectorScale as k2e}from"@excalidraw/math";import{invariant as Dve,isTransparent as Lve}from"@excalidraw/common";import{curveIntersectLineSegment as Rve,isPointWithinBounds as Nve,lineSegment as Bve,lineSegmentIntersectionPoints as Fve,pointFrom as Ove,pointFromVector as zve,pointRotateRads as Gve,pointsEqual as Hve,vectorFromPoint as Uve,vectorNormalize as Wve,vectorScale as Vve}from"@excalidraw/math";import{ellipse as Kve,ellipseSegmentInterceptPoints as Xve}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as $R,DEFAULT_PROPORTIONAL_RADIUS as Vg,invariant as Tme,LINE_CONFIRM_THRESHOLD as jR,ROUNDNESS as Yg}from"@excalidraw/common";import{bezierEquation as Cme,curve as Pme,curveCatmullRomCubicApproxPoints as kme,curveOffsetPoints as Mme,lineSegment as Ame,lineSegmentIntersectionPoints as Dme,pointDistance as qR,pointFrom as Lme,pointFromArray as _me,pointFromVector as Rme,pointRotateRads as Nme,pointTranslate as Bme,rectangle as Fme,vectorFromPoint as Ome,vectorNormalize as zme,vectorScale as Gme}from"@excalidraw/math";import{ROUNDNESS as Eme,assertNever as bme}from"@excalidraw/common";import{pointsEqual as yme}from"@excalidraw/math";var Yv=e=>!!e&&e.type==="embeddable",Ug=e=>!!e&&e.type==="iframe",Wg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),pn=e=>e!=null&&e.type==="text";var co=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var un=e=>e!=null&&XR(e.type);var Nn=e=>e!=null&&e.type==="arrow",Bn=e=>Nn(e)&&e.elbowed;var XR=e=>e==="arrow"||e==="line";var Ao=e=>e!==null&&"containerId"in e&&e.containerId!==null&&pn(e);var Ia=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return qR(t,o)<=jR/n}return!1},wl=(e,n)=>{if(n.roundness?.type===Yg.PROPORTIONAL_RADIUS||n.roundness?.type===Yg.LEGACY)return e*Vg;if(n.roundness?.type===Yg.ADAPTIVE_RADIUS){let t=n.roundness?.value??$R,o=t/Vg;return e<=o?e*Vg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as dve,ARROW_LABEL_WIDTH_FRACTION as mve,BOUND_TEXT_PADDING as pve,DEFAULT_FONT_SIZE as uve,TEXT_ALIGN as hve,VERTICAL_ALIGN as gve,getFontString as fve,isProdEnv as Eve,invariant as bve}from"@excalidraw/common";import{pointFrom as yve,pointRotateRads as wve}from"@excalidraw/math";import{BOUND_TEXT_PADDING as epe,DEFAULT_FONT_SIZE as tpe,DEFAULT_FONT_FAMILY as npe,getFontString as ope,isTestEnv as rpe,normalizeEOL as ipe}from"@excalidraw/common";var ape="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as upe,isTestEnv as hpe}from"@excalidraw/common";import{toIterable as owe}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as xpe,viewportCoordsToSceneCoords as ype}from"@excalidraw/common";import{normalizeRadians as vpe,radiansBetweenAngles as Ipe,radiansDifference as Tpe}from"@excalidraw/math";import{pointsEqual as Cpe}from"@excalidraw/math";import{arrayToMap as due,isShallowEqual as tN}from"@excalidraw/common";import{arrayToMap as Vpe}from"@excalidraw/common";import{isPointWithinBounds as Kpe,pointFrom as Xpe,segmentsIntersectAt as Zpe}from"@excalidraw/math";import{arrayToMap as Lpe}from"@excalidraw/common";import{validateOrderKey as Rpe,generateNKeysBetween as Npe}from"@excalidraw/fractional-indexing";var Kg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var bue=function(){let e=null,n=null,t=null,o=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===n||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,n=i.selectedElementIds),t);return o.clearCache=()=>{e=null,n=null,t=null},o}(),Cl=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){ai(i)?(r.push(i),o.add(i.id)):console.error("[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection");continue}if(t?.includeBoundTextElement&&Ao(i)&&ai(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{co(a)&&Kg(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var Zg=(e,n)=>tN(n.selectedElementIds,e)?n.selectedElementIds:e;var nN=function(){let e=null,n=null,t=null,o=(i,a,s,l)=>{if(t!==void 0&&a===n&&i===e&&s.editingGroupId===t?.editingGroupId)return t;let c={};for(let p of i){let u=p.groupIds;if(s.editingGroupId){let E=u.indexOf(s.editingGroupId);E>-1&&(u=u.slice(0,E))}if(u.length>0){let E=u[u.length-1];c[E]=!0}}let d={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let E=u.groupIds.find(g=>c[g]);return E&&(p[u.id]=!0,Array.isArray(d[E])?d[E].push(u.id):d[E]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return n=a,e=i,t={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:Zg({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Cl(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Zg(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var Bue=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as Lhe,VERTICAL_ALIGN as _he}from"@excalidraw/common";import{pointDistance as Nhe,pointFromVector as Bhe,pointsEqual as Fhe,vector as Ohe,vectorDot as zhe,vectorFromPoint as Ghe,vectorNormalize as Hhe,vectorScale as Uhe}from"@excalidraw/math";import{invariant as Zue,isDevEnv as $ue,isTestEnv as jue}from"@excalidraw/common";import{pointFrom as Jue,pointFromVector as Que,pointRotateRads as ehe,pointScaleFromOrigin as the,pointsEqual as nhe,triangleIncludesPoint as ohe,vectorCross as rhe,vectorFromPoint as iN,vectorScale as ihe}from"@excalidraw/math";var Ml=[1,0],Sm=[0,1],Al=[-1,0],Cm=[0,-1],Pm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?Ml:n<=-r?Al:t>o?Sm:Cm},e2=(e,n)=>Pm(iN(e,n)),km=(e,n)=>Mm(e2(e,n)),kl=(e,n)=>e[0]===n[0]&&e[1]===n[1],Mm=e=>kl(e,Ml)||kl(e,Al);import{DEFAULT_ELEMENT_PROPS as dhe,DEFAULT_FONT_FAMILY as mhe,DEFAULT_FONT_SIZE as phe,DEFAULT_TEXT_ALIGN as uhe,DEFAULT_VERTICAL_ALIGN as hhe,DEFAULT_STROKE_STREAMLINE as ghe,VERTICAL_ALIGN as fhe,randomInteger as Ehe,randomId as bhe,getFontString as xhe,getUpdatedTimestamp as yhe,getLineHeight as whe}from"@excalidraw/common";import{pointsOnBezierCurves as mge,simplify as pge}from"points-on-curve";import{curveToBezier as hge}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as fge,lineSegment as Ege,lineSegmentIntersectionPoints as bge,pointDistance as xge,pointFrom as yge,pointRotateRads as wge,polygonArea as vge,polygonIncludesPoint as Ige,polygonIncludesPointNonZero as Tge,polygonSignedArea as Sge}from"@excalidraw/math";import{isOpaqueColor as Pge,isTransparent as kge}from"@excalidraw/common";var r2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as Qhe,distanceToLineSegment as ege,pointRotateRads as tge}from"@excalidraw/math";import{ellipse as oge,ellipseDistanceFromPoint as rge}from"@excalidraw/math/ellipse";import{pointFrom as Uge,pointCenter as Wge,pointRotateRads as Vge,vectorFromPoint as Yge,vectorNormalize as Kge,vectorSubtract as Xge,vectorAdd as Zge,vectorScale as $ge,pointFromVector as jge,clamp as qge,isCloseTo as Jge}from"@excalidraw/math";import{arrayToMap as PEe,arrayToObject as kEe,assertNever as MEe,isDevEnv as AEe,isShallowEqual as DEe,isTestEnv as LEe,randomInteger as _Ee}from"@excalidraw/common";import{assertNever as Rfe,COLOR_PALETTE as Nfe,isDevEnv as Bfe,isTestEnv as Ffe,randomId as Ofe,Emitter as zfe,toIterable as Gfe}from"@excalidraw/common";import{ORIG_ID as mfe,randomId as pfe,randomInteger as ufe,arrayToMap as hfe,castArray as gfe,findLastIndex as ffe,getUpdatedTimestamp as Efe,isTestEnv as bfe}from"@excalidraw/common";import{arrayToMap as ofe}from"@excalidraw/common";import lN from"lodash.throttle";import{randomInteger as tEe,arrayToMap as nEe,toBrandedType as oEe,isDevEnv as s2,isTestEnv as l2,toArray as rEe}from"@excalidraw/common";import{isNonDeletedElement as aEe}from"@excalidraw/element";import{isFrameLikeElement as lEe}from"@excalidraw/element";import{getElementsInGroup as dEe}from"@excalidraw/element";import{syncInvalidIndices as pEe,syncMovedIndices as uEe,validateFractionalIndices as cN}from"@excalidraw/element";import{getSelectedElements as gEe}from"@excalidraw/element";import{mutateElement as EEe}from"@excalidraw/element";var bEe=lN(e=>{(s2()||l2()||window?.DEBUG_FRACTIONAL_INDICES)&&cN(e,{shouldThrow:s2()||l2(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as rbe,getGridPoint as ibe,getFontString as abe,DRAGGING_THRESHOLD as sbe}from"@excalidraw/common";import{clamp as bbe,pointDistance as xbe,pointFrom as ybe,pointScaleFromOrigin as wbe,pointsEqual as vbe,pointTranslate as Ibe,vector as Tbe,vectorCross as Sbe,vectorFromPoint as Cbe,vectorScale as Pbe}from"@excalidraw/math";import{BinaryHeap as Mbe,invariant as Abe,isAnyTrue as Dbe,getSizeFromPoints as Lbe,isDevEnv as _be,arrayToMap as Rbe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as Zbe,normalizeLink as $be}from"@excalidraw/common";import{FONT_FAMILY as exe,VERTICAL_ALIGN as txe,escapeDoubleQuotes as nxe,getFontString as oxe}from"@excalidraw/common";import{invariant as pxe,toBrandedType as uxe}from"@excalidraw/common";import{clamp as gxe,pointFrom as fxe}from"@excalidraw/math";import{pointDistance as Yxe,pointFrom as Kxe}from"@excalidraw/math";import{invariant as Zxe}from"@excalidraw/common";import{arrayToMap as Axe,findIndex as Dxe,findLastIndex as Lxe}from"@excalidraw/common";import{isFiniteNumber as Rxe}from"@excalidraw/math";import{decodeAnimated as r1e}from"@discourse/gif";var TN="gif.worker.js";var a1e=new URL(TN,import.meta.url).toString();import{DEFAULT_GIF_AUTO_DECODE_MAX_FILE_SIZE_BYTES as p1e,MIME_TYPES as u1e,SVG_NS as h1e}from"@excalidraw/common";import{rgbaToThumbHash as f1e,thumbHashToRGBA as E1e}from"thumbhash";import{pointCenter as B1e,normalizeRadians as F1e,pointFrom as O1e,pointRotateRads as z1e}from"@excalidraw/math";import{MIN_FONT_SIZE as H1e,SHIFT_LOCKING_ANGLE as U1e,rescalePoints as W1e,getFontString as V1e}from"@excalidraw/common";import{pointFrom as E0e,pointOnLineSegment as b0e,pointRotateRads as x0e}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as w0e}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as r0e}from"@excalidraw/common";import{pointFrom as a0e,pointRotateRads as s0e}from"@excalidraw/math";import{KEYS as On}from"@excalidraw/common";var L0e=[{icon:Kc,value:"selection",key:On.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:Gi,value:"rectangle",key:On.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Hi,value:"diamond",key:On.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Ui,value:"ellipse",key:On.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Xc,value:"arrow",key:On.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:jo,value:"line",key:On.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Qn,value:"freedraw",key:[On.P,On.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Dn,value:"text",key:On.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Hr,value:"image",key:[On.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Zc,value:"eraser",key:On.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as V0e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as K0e,DEFAULT_FONT_SIZE as X0e,TEXT_ALIGN as Z0e,VERTICAL_ALIGN as $0e,getSizeFromPoints as j0e,randomId as q0e,arrayToMap as J0e,assertNever as Q0e,cloneJSON as eye,getFontString as tye,isDevEnv as nye,toBrandedType as oye,getLineHeight as rye}from"@excalidraw/common";import{getBoundsFromPoints as Pye,getElementAbsoluteCoords as kye}from"@excalidraw/element/bounds";import{newArrowElement as Aye,newElement as Dye,newLinearElement as Lye}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as Rye,getStrokeWidthByKey as Nye,ROUNDNESS as Bye}from"@excalidraw/common";import{convexHull as Oye,distanceToLineSegment as zye,elongation as Gye,kurtosis as Hye,lineSegment as Uye,orientPrincipalAxes as Wye,pointFrom as Vye,polygonArea as Yye,principalAxes as Kye,principalCoords as Xye,skewness as Zye}from"@excalidraw/math";var Jye=[{type:"rectangle",hullFillRatio:1,cornerTurnShare:.95,kurtosisProduct:1.83},{type:"diamond",hullFillRatio:.5,cornerTurnShare:.95,kurtosisProduct:3.24},{type:"ellipse",hullFillRatio:Math.PI/4,cornerTurnShare:.55,kurtosisProduct:2.25}];var ai=e=>!e.isDeleted;var yN=10/1.5;var wm=e=>{let n=Math.floor(e.width/2)+1,t=0,o=e.width,r=Math.floor(e.height/2)+1,i=n,a=e.height;return[n,t,o,r,i,a,0,r]};var MN=20,AN=15,DN=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"cardinality_many":case"cardinality_one_or_many":case"cardinality_zero_or_many":return AN;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return MN;default:return 15}},LN=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Nt=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=Hg(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;f2(s.length===6,"Op data length is not 6");let l=wt(s[4],s[5]),c=wt(s[2],s[3]),d=wt(s[0],s[1]),m=i[a-1],p=wt(0,0);if(m.op==="move"){let G=kN(m.data);f2(G!=null,"Op data is not a point"),p=G}else m.op==="bcurveTo"&&(p=wt(m.data[4],m.data[5]));let u=(G,ie)=>Math.pow(1-G,3)*l[ie]+3*G*Math.pow(1-G,2)*c[ie]+3*Math.pow(G,2)*(1-G)*d[ie]+p[ie]*Math.pow(G,3),[E,g]=t==="start"?p:l,[b,v]=[u(.3,0),u(.3,1)],y=Math.hypot(E-b,g-v),x=(E-b)/y,I=(g-v)/y,T=DN(o),C=0;{let[G,ie]=t==="end"?e.points[e.points.length-1]:e.points[0],[me,B]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(G-me,ie-B)}let M=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),D=E-x*M*r,_=g-I*M*r,k=D-x*M,L=_-I*M;if(o==="circle"||o==="circle_outline"){let G=Math.hypot(L-_,k-D)+e.strokeWidth-2;return[D,_,G]}let F=LN(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[G,ie]=Pa(wt(D,_),wt(k,L),nf(-F)),[me,B]=Pa(wt(D,_),wt(k,L),nf(F));return[k,L,G,ie,me,B]}let[K,z]=Pa(wt(k,L),wt(D,_),-F*Math.PI/180),[U,W]=Pa(wt(k,L),wt(D,_),nf(F));if(o==="diamond"||o==="diamond_outline"){let G,ie;if(t==="start"){let[me,B]=e.points.length>1?e.points[1]:[0,0];[G,ie]=Pa(wt(D+M*2,_),wt(D,_),Math.atan2(B-_,me-D))}else{let[me,B]=e.points.length>1?e.points[e.points.length-2]:[0,0];[G,ie]=Pa(wt(D-M*2,_),wt(D,_),Math.atan2(_-B,D-me))}return[D,_,K,z,G,ie,U,W]}return[D,_,K,z,U,W]};var _N=typeof document<"u"?document.createElement("img"):{src:""};_N.src=`data:${E2.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 RN=typeof document<"u"?document.createElement("img"):{src:""};RN.src=`data:${E2.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 of=new WeakMap;var Yt=class Yt{};w(Yt,"rg",new UN),w(Yt,"cache",new WeakMap),w(Yt,"get",(n,t)=>{let o=Yt.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),w(Yt,"delete",n=>{Yt.cache.delete(n),of.delete(n)}),w(Yt,"destroy",()=>{Yt.cache=new WeakMap}),w(Yt,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Yt.get(n,t?t.theme:null);if(o!==void 0)return o;of.delete(n);let r=YN(n,Yt.rg,t||{isExporting:!1,canvasBackgroundColor:GN.white,embedsValidationStatus:null,theme:sf.LIGHT});return t?.isExporting||Yt.cache.set(n,{shape:r,theme:t?.theme||sf.LIGHT}),r});var Ca=Yt,WN=e=>[8,8+e],v2=e=>[1.5,6+e];function VN(e){let n=e.roughness,t=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&t>=50||o>=15&&e.roundness&&r2(e.type)||un(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var Lo=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?WN(e.strokeWidth):e.strokeStyle==="dotted"?v2(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:VN(e),stroke:Rl(e.strokeColor,t),preserveVertices:n||e.roughness<ON.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=_l(e.backgroundColor)?void 0:Rl(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return Ia(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:Rl(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},x2=(e,n,t)=>Wg(e)&&(n||Yv(e)&&t?.get(e.id)!==!0)&&_l(e.backgroundColor)&&_l(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Ug(e)?{...e,strokeColor:_l(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:_l(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Ll=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},Dm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,s,l]=n;return[e.line(i,a,o,r,t),e.line(s,l,o,r,t)]},li=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=v2(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},rf=(e,n,t,o,r,i=1)=>{if(o===null)return[];let[a,s,l]=o,c={...n,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,n.roughness||0)};return delete c.strokeLineDash,[e.circle(a,s,l*i,c)]},y2=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=Rl(e.strokeColor,s),c=Rl(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return rf(r,i,l,Nt(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=Nt(e,n,t,o);if(p===null)return[];let[u,E,g,b,v,y]=p,x={...i,fill:o==="triangle_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete x.strokeLineDash,[r.polygon([[u,E],[g,b],[v,y],[u,E]],x)]}case"diamond":case"diamond_outline":{let p=Nt(e,n,t,o);if(p===null)return[];let[u,E,g,b,v,y,x,I]=p,T={...i,fill:o==="diamond_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete T.strokeLineDash,[r.polygon([[u,E],[g,b],[v,y],[x,I],[u,E]],T)]}case"cardinality_one":return Ll(r,Nt(e,n,t,o),li(e,i));case"cardinality_many":return Dm(r,Nt(e,n,t,o),li(e,i));case"cardinality_one_or_many":{let p=li(e,i);return[...Dm(r,Nt(e,n,t,"cardinality_many"),p),...Ll(r,Nt(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=li(e,i);return[...Ll(r,Nt(e,n,t,"cardinality_one",-.5),p),...Ll(r,Nt(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=li(e,i);return[...rf(r,i,l,Nt(e,n,t,"circle_outline",1.5),c,m),...Ll(r,Nt(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=li(e,i);return[...Dm(r,Nt(e,n,t,"cardinality_many"),p),...rf(r,i,l,Nt(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return Dm(r,Nt(e,n,t,o),li(e,i))}};var YN=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===sf.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=wl(Math.min(l,c),e);s=n.path(`M ${d} 0 L ${l-d} 0 Q ${l} 0, ${l} ${d} L ${l} ${c-d} Q ${l} ${c}, ${l-d} ${c} L ${d} ${c} Q 0 ${c}, 0 ${c-d} L 0 ${d} Q 0 0, ${d} 0`,Lo(x2(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,Lo(x2(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=wm(e);if(e.roundness){let b=wl(Math.abs(l-E),e),v=wl(Math.abs(m-c),e);s=n.path(`M ${l+b} ${c+v} L ${d-b} ${m-v}
4
+ ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Dw=async(e,n,t)=>{let o=Cx(n);if(!Px(o))throw new Error("fileHandle should exist and should be of type svg or png when resaving");let{elements:r,appState:i,files:a}=await e,{exportBackground:s,viewBackgroundColor:l}=i;i={...i,exportEmbedScene:!0};let{exportedElements:c,exportingFrame:d}=Qr(r,i,!1);return await ei(o,c,i,a,{exportBackground:s,viewBackgroundColor:l,name:t,fileHandle:n,exportingFrame:d}),{fileHandle:n}};import{Fragment as mL,jsx as hr,jsxs as Nw}from"react/jsx-runtime";var mg=O({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,n,t)=>({appState:{...n,name:t},captureUpdate:_n.EVENTUALLY}),PanelComponent:({appState:e,updateData:n,appProps:t,data:o,app:r})=>hr(Tw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>n(i),ignoreFocus:o?.ignoreFocus??!1})}),Lw=O({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,n,t)=>({appState:{...n,exportScale:t},captureUpdate:_n.EVENTUALLY})}),pg=O({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,n,t)=>({appState:{...n,exportBackground:t},captureUpdate:_n.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>hr(sg,{checked:e.exportBackground,onChange:t=>n(t),children:f("imageExportDialog.label.withBackground")})}),lm=O({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,n,t)=>({appState:{...n,exportEmbedScene:t},captureUpdate:_n.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>Nw(sg,{checked:e.exportEmbedScene,onChange:t=>n(t),children:[f("imageExportDialog.label.embedScene"),hr(ht,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:hr("div",{className:"excalidraw-tooltip-icon",children:l1})})]})}),da=!1,dg=(e,n)=>{let t=n.message??f("progressDialog.defaultMessage");e.setAppState({toast:{message:n.progress!=null?Nw(mL,{children:[t,hr(Qd.ProgressBar,{progress:n.progress})]}):t,duration:1/0}})};async function dL(e,n){if(n.app.state.isLoading&&(dg(n.app,{progress:null}),await n.app.onStateChange({predicate:t=>!t.isLoading})),e!=null&&typeof e=="object"&&Symbol.asyncIterator in e){for await(let t of e){if(n.signal.aborted){e.return();return}if(t.type==="progress")dg(n.app,{message:t.message,progress:t.progress??null});else if(t.type==="done")return}return}e instanceof Promise&&(dg(n.app,{progress:null}),await e)}function _w(e,n,t,o){let r=new AbortController,i=r.signal,a=new Promise(async s=>{try{o.props.onExport&&await dL(o.props.onExport("json",{elements:e,appState:n,files:t},{signal:i}),{app:o,signal:i})}catch(l){l?.name==="AbortError"?console.warn(`onExport() aborted by host app (signal aborted: ${i.aborted})`):console.error("Error during props.onExport() handling",l)}s({elements:e,appState:n,files:o.files})});return{abortController:r,data:a}}var ti=O({name:"saveToActiveFile",label:"buttons.save",icon:Bs,trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.saveToActiveFile&&!!n.fileHandle&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{if(da)return!1;da=!0;let r=n.fileHandle,i=o.getName(),{abortController:a,data:s}=_w(e,n,o.files,o);try{let{fileHandle:l}=Hc(r)?await Dw(s,r,i):await Nc({data:s,filename:i,fileHandle:r});return{captureUpdate:_n.NEVER,appState:{fileHandle:l,toast:{message:r&&l?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${l.name}"`):f("toast.fileSaved"),duration:1500}}}}catch(l){return a.abort(),l?.name!=="AbortError"?console.error(l):console.warn(l),{captureUpdate:_n.NEVER,appState:{toast:null}}}finally{da=!1}},keyTest:e=>!1}),ul=O({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Bs,viewMode:!0,trackEvent:{category:"export"},perform:async(e,n,t,o)=>{if(da)return!1;da=!0;let{abortController:r,data:i}=_w(e,n,o.files,o);try{let{fileHandle:a}=await Nc({data:i,filename:o.getName(),fileHandle:null});return{captureUpdate:_n.NEVER,appState:{openDialog:null,fileHandle:a,toast:{message:f("toast.fileSaved"),duration:3e3}}}}catch(a){return r.abort(),a?.name!=="AbortError"?console.error(a):console.warn(a),{captureUpdate:_n.NEVER,appState:{toast:null}}}finally{da=!1}},keyTest:e=>e.key.toLowerCase()===sm.S&&e.shiftKey&&e[sm.CTRL_OR_CMD],PanelComponent:({updateData:e})=>hr($,{type:"button",icon:o1,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:fe().formFactor==="phone",hidden:!Ni,onClick:()=>e(null),"data-testid":"save-as-button"})}),ma=O({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,n,t,o)=>!!o.props.UIOptions.canvasActions.loadScene&&!n.viewModeEnabled,perform:async(e,n,t,o)=>{try{let{elements:r,appState:i,files:a}=await Bu(n,e);return{elements:r,appState:i,files:a,captureUpdate:_n.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...n,errorMessage:r.message},files:o.files,captureUpdate:_n.EVENTUALLY}}},keyTest:e=>e[sm.CTRL_OR_CMD]&&e.key===sm.O}),Rw=O({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,n,t,o)=>(o.sessionExportThemeOverride=t?pl.DARK:pl.LIGHT,{appState:{...n,exportWithDarkMode:t},captureUpdate:_n.EVENTUALLY}),PanelComponent:({appState:e,updateData:n})=>hr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:hr(vw,{value:e.exportWithDarkMode?pl.DARK:pl.LIGHT,onChange:t=>{n(t===pl.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as pL,DEFAULT_FONT_FAMILY as uL,DEFAULT_TEXT_ALIGN as hL,getLineHeight as gL}from"@excalidraw/common";import{newElementWith as cm}from"@excalidraw/element";import{hasBoundTextElement as fL,canApplyRoundnessTypeToElement as EL,getDefaultRoundnessTypeForElement as bL,isFrameLikeElement as xL,isArrowElement as yL,isExcalidrawElement as wL,isTextElement as Bw}from"@excalidraw/element";import{getBoundTextElement as vL,redrawTextBoundingBox as IL}from"@excalidraw/element";import{CaptureUpdateAction as ug}from"@excalidraw/element";var Fw="{}",TL=O({name:"copyStyles",label:"labels.copyStyles",icon:lh,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=[],i=e.find(a=>n.selectedElementIds[a.id]);if(r.push(i),i&&fL(i)){let a=vL(i,o.scene.getNonDeletedElementsMap());r.push(a)}return i&&(Fw=JSON.stringify(r)),{appState:{...n,toast:{message:f("toast.copyStyles")}},captureUpdate:ug.EVENTUALLY}}}),SL=O({name:"pasteStyles",label:"labels.pasteStyles",icon:lh,trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=JSON.parse(Fw),i=r[0],a=r[1];if(!wL(i))return{elements:e,captureUpdate:ug.EVENTUALLY};let s=de(e,n,{includeBoundTextElement:!0}),l=s.map(c=>c.id);return{elements:e.map(c=>{if(l.includes(c.id)){let d=i;if(Bw(c)&&c.containerId&&(d=a),!d)return c;let m=cm(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?EL(d.roundness.type,c)?d.roundness:bL(c):null});if(Bw(m)){let p=d.fontSize||pL,u=d.fontFamily||uL,E=cm(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||hL,lineHeight:d.lineHeight||gL(u)});m=E;let g=null;E.containerId&&(g=s.find(b=>b.id===E.containerId)||null),IL(E,g,o.scene)}return m.type==="arrow"&&yL(d)&&(m=cm(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),xL(c)&&(m=cm(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:ug.IMMEDIATELY}}});import{KEYS as CL}from"@excalidraw/common";import{CaptureUpdateAction as PL}from"@excalidraw/element";var ni=O({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Jx,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,n,t,{focusContainer:o})=>(n.openDialog?.name==="help"&&o(),{appState:{...n,openDialog:n.openDialog?.name==="help"?null:{name:"help"},openMenu:null,openPopup:null},captureUpdate:PL.EVENTUALLY}),keyTest:e=>e.key===CL.QUESTION_MARK});import{getNonDeletedElements as mm}from"@excalidraw/element";import{newElementWith as zw}from"@excalidraw/element";import{isBoundToContainer as kL}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as ML,getElementsInResizingFrame as AL,getFrameLikeElements as DL,getRootElements as LL,groupByFrameLikes as _L,removeElementsFromFrame as RL,replaceAllElementsInFrame as NL}from"@excalidraw/element";import{KEYS as pm,randomId as BL,arrayToMap as gg}from"@excalidraw/common";import{getSelectedGroupIds as dm,selectGroup as FL,selectGroupsForSelectedElements as OL,getElementsInGroup as Ow,addToGroup as zL,removeFromSelectedGroups as GL,isElementInGroup as Gw}from"@excalidraw/element";import{syncMovedIndices as HL}from"@excalidraw/element";import{CaptureUpdateAction as hl}from"@excalidraw/element";import{jsx as pa}from"react/jsx-runtime";var UL=(e,n)=>{if(e.length>=2){let t=n?e[0].groupIds.indexOf(n):-1,o=t>-1?e[0].groupIds.slice(0,t):e[0].groupIds;for(let r of o)if(e.every(i=>Gw(i,r)))return!0}return!1},hg=(e,n)=>{let t=n.scene.getSelectedElements({selectedElementIds:e.selectedElementIds,includeBoundTextElement:!1});return t.length>=2&&!UL(t,e.editingGroupId)&&!ML(t)},fg=O({name:"group",label:"labels.group",icon:e=>pa(th,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{if(!hg(n,o))return!1;let r=LL(o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:n,elements:e,captureUpdate:hl.EVENTUALLY};let i=dm(n);if(i.length===1){let b=i[0],v=new Set(Ow(e,b).map(I=>I.id)),w=new Set(r.map(I=>I.id));if(new Set([...Array.from(v),...Array.from(w)]).size===v.size)return{appState:n,elements:e,captureUpdate:hl.EVENTUALLY}}let a=[...e];new Set(r.map(b=>b.frameId)).size>1&&_L(r).forEach((v,w)=>{RL(v,o.scene.getNonDeletedElementsMap())});let l=BL(),c=gg(r);a=a.map(b=>c.get(b.id)?zw(b,{groupIds:zL(b.groupIds,l,n.editingGroupId)}):b);let d=Ow(a,l),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),E=a.slice(0,p).filter(b=>!Gw(b,l)),g=HL([...E,...d,...u],gg(d));return{appState:{...n,...FL(l,{...n,selectedGroupIds:{}},mm(a))},elements:g,captureUpdate:hl.IMMEDIATELY}},predicate:(e,n,t,o)=>hg(n,o),keyTest:e=>!e.shiftKey&&e[pm.CTRL_OR_CMD]&&e.key===pm.G,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>pa($,{hidden:!hg(n,o),type:"button",icon:pa(th,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${N("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Ne(mm(e),n)})}),Eg=O({name:"ungroup",label:"labels.ungroup",icon:e=>pa(nh,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=dm(n),i=gg(e);if(r.length===0)return{appState:n,elements:e,captureUpdate:hl.EVENTUALLY};let a=[...e],s=[];a=a.map(p=>{kL(p)&&s.push(p.id);let u=GL(p.groupIds,n.selectedGroupIds);return u.length===p.groupIds.length?p:zw(p,{groupIds:u})});let l=OL(n,mm(a),n,null),c=o.scene.getSelectedElements(n),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return DL(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=NL(a,AL(a,p,n,i),p))}),l.selectedElementIds=Object.entries(l.selectedElementIds).reduce((p,[u,E])=>(E&&!s.includes(u)&&(p[u]=!0),p),{}),{appState:{...n,...l},elements:a,captureUpdate:hl.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[pm.CTRL_OR_CMD]&&e.key===pm.G.toUpperCase(),predicate:(e,n)=>dm(n).length>0,PanelComponent:({elements:e,appState:n,updateData:t})=>pa($,{type:"button",hidden:dm(n).length===0,icon:pa(nh,{theme:n.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${N("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Ne(mm(e),n)})});import $L from"clsx";import{CaptureUpdateAction as Yw}from"@excalidraw/element";import{invariant as jL}from"@excalidraw/common";import{COLOR_CHARCOAL_BLACK as WL,COLOR_VOICE_CALL as VL,COLOR_WHITE as hm,THEME as YL,UserIdleState as Hw}from"@excalidraw/common";var um=(e,n,t,o,r,i,a)=>{e.beginPath(),e.moveTo(n+i,t),e.lineTo(n+o-i,t),e.quadraticCurveTo(n+o,t,n+o,t+i),e.lineTo(n+o,t+r-i),e.quadraticCurveTo(n+o,t+r,n+o-i,t+r),e.lineTo(n+i,t+r),e.quadraticCurveTo(n,t+r,n,t+r-i),e.lineTo(n,t+i),e.quadraticCurveTo(n,t,n+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function KL(e){let n=0;if(e.length===0)return n;for(let t=0;t<e.length;t++){let o=e.charCodeAt(t);n=(n<<5)-n+o}return n}var oi=(e,n)=>`hsl(${Math.abs(KL(n?.id||e))%37*10}, 100%, 83%)`,Uw=e=>{let n=e?.trim()?.codePointAt(0);return(n?String.fromCodePoint(n):"?").toUpperCase()},Ww=({context:e,renderConfig:n,appState:t,normalizedWidth:o,normalizedHeight:r})=>{for(let[i,a]of n.remotePointerViewportCoords){let{x:s,y:l}=a,c=t.collaborators.get(i);s-=t.offsetLeft,l-=t.offsetTop;let d=11,m=14,p=s<0||s>o-d||l<0||l>r-m;s=Math.max(s,0),s=Math.min(s,o-d),l=Math.max(l,0),l=Math.min(l,r-m);let u=oi(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let E=n.remotePointerUserStates.get(i),g=p||E===Hw.IDLE||E===Hw.AWAY;g&&(e.globalAlpha=.3),n.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(s,l,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let b=t.theme===YL.DARK?"#2f6330":VL,v=c?.isSpeaking;v&&(e.fillStyle=b,e.strokeStyle=b,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=hm,e.strokeStyle=hm,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),g?(e.moveTo(s-1,l-1),e.lineTo(s-1,l+15),e.lineTo(s+5,l+10),e.lineTo(s+12,l+9),e.closePath(),e.fill()):(e.moveTo(s,l),e.lineTo(s+0,l+14),e.lineTo(s+4,l+9),e.lineTo(s+11,l+8),e.closePath(),e.fill(),e.stroke());let w=n.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let x=(v?s+0:s)+d/2,I=(v?l+0:l)+m+2,T=5,C=3,P=e.measureText(w),M=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,D=Math.max(M,12),_=x-1,k=I-1,L=P.width+2+T*2+2,F=D+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(_,k,L,F,8),e.fillStyle=u,e.fill(),e.strokeStyle=hm,e.stroke(),v&&(e.beginPath(),e.roundRect(_-2,k-2,L+4,F+4,8),e.strokeStyle=b,e.stroke())):um(e,_,k,L,F,8,hm),e.fillStyle=WL,e.fillText(w,x+T+1,I+C+P.actualBoundingBoxAscent+Math.floor((D-M)/2)+2),v){e.fillStyle=b;let K=8,z=8,U=5;e.fillRect(_+L+z,k+(F/2-K/2),2,K),e.fillRect(_+L+z+U,k+(F/2-K*2/2),2,K*2),e.fillRect(_+L+z+U*2,k+(F/2-K/2),2,K)}}e.restore(),e.closePath()}};import XL from"clsx";import{useState as ZL}from"react";import{jsx as Vw}from"react/jsx-runtime";var bg=({color:e,onClick:n,name:t,src:o,className:r})=>{let i=Uw(t),[a,s]=ZL(!1),l=!a&&o,c=l?void 0:{background:e};return Vw("div",{className:XL("Avatar",r),style:c,onClick:n,children:l?Vw("img",{className:"Avatar-img",src:o,alt:i,referrerPolicy:"no-referrer",onError:()=>s(!0)}):i})};import{jsx as so,jsxs as gm}from"react/jsx-runtime";var qL=O({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,n,t,o)=>(jL(t,"actionGoToCollaborator: collaborator should be defined when actionGoToCollaborator is called"),!t.socketId||o.props.userToFollow?.socketId===t.socketId||t.isCurrentUser?(o.requestUnfollow(),{appState:n,captureUpdate:Yw.EVENTUALLY}):(o.emitUserFollowIntent({userToFollow:{socketId:t.socketId,username:t.username||""},action:"FOLLOW"}),{appState:{...n,openMenu:n.openMenu==="canvas"?null:n.openMenu},captureUpdate:Yw.EVENTUALLY})),PanelComponent:({updateData:e,data:n,appState:t})=>{let{socketId:o,collaborator:r,withName:i,isBeingFollowed:a}=n,s=oi(o,r),l=$L({"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?gm("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[so("div",{}),so("div",{}),so("div",{})]}):r.isMuted?so("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:d0}):so("div",{title:f("userList.hint.inCall"),children:c0}):null;return i?gm("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${l}`,style:{"--avatar-size":"1.5rem"},onClick:r.isCurrentUser?void 0:()=>e(r),children:[so(bg,{color:s,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:l}),so("div",{className:"UserList__collaborator-name",children:r.username}),gm("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&so("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Xr}),r.isCurrentUser&&` (${f("labels.you")})`,c]})]}):gm("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${l}`,children:[so(bg,{color:s,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:l}),c&&so("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{getNonDeletedElements as ua}from"@excalidraw/element";import{isFrameLikeElement as t_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as n_}from"@excalidraw/element";import{KEYS as gr,arrayToMap as o_}from"@excalidraw/common";import{alignElements as r_}from"@excalidraw/element";import{CaptureUpdateAction as ii}from"@excalidraw/element";import{getSelectedElementsByGroup as i_}from"@excalidraw/element";import JL from"clsx";import{jsx as Kw}from"react/jsx-runtime";var ri=({title:e,name:n,checked:t,onChange:o,disabled:r=!1})=>Kw("div",{className:JL("Switch",{toggled:t,disabled:r}),children:Kw("input",{name:n,id:n,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>o(!t),onKeyDown:i=>{i.key===" "&&o(!t)}})});var QL={stacking:!1},e_={fitToViewport:!0,animate:!0,duration:200,respectUIElements:!1,viewportZoomFactor:.8},lo=(e,n)=>({smartZoom:{...e_,...n?.smartZoom},align:{...QL,...e.alignConfiguration,...n?.align},arrange:{...e.arrangeConfiguration,...n?.arrange},normalise:{...e.normaliseConfiguration,...n?.normalise}});import{jsx as fr,jsxs as u_}from"react/jsx-runtime";var lt=(e,n)=>{let t=n.scene.getSelectedElements(e);return i_(t,n.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(o=>t_(o))},ha=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),{align:i,arrange:a}=lo(n,t.props.editorPreferences),s=r_(r,o,t.scene,n,{stacking:i.stacking,gap:a.gap}),l=o_(s);return n_(e.map(c=>l.get(c.id)||c),n,t)},a_=O({name:"toggleAlignStacking",label:"labels.stacking",trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>{let r=lo(n,o.props.editorPreferences).align.stacking,i=typeof t=="boolean"?t:!r;return o.props.onEditorPreferencesChange?.({align:{stacking:i}}),{appState:{...n,alignConfiguration:{stacking:i}},captureUpdate:ii.NEVER}},PanelComponent:({appState:e,updateData:n,appProps:t})=>{let o=lo(e,t.editorPreferences).align.stacking;return u_("div",{className:"align-stacking-toggle",children:[fr("label",{htmlFor:"alignStacking",children:f("labels.stacking")}),fr(ri,{name:"alignStacking",checked:o,title:f("labels.stacking"),onChange:r=>n(r)})]})}}),s_=O({name:"alignTop",label:"labels.alignTop",icon:$u,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"start",axis:"y"}),captureUpdate:ii.IMMEDIATELY}),keyTest:e=>e[gr.CTRL_OR_CMD]&&e.shiftKey&&e.key===gr.ARROW_UP,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>fr($,{hidden:!lt(n,o),type:"button",icon:$u,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${N("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Ne(ua(e),n)})}),l_=O({name:"alignBottom",label:"labels.alignBottom",icon:ju,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"end",axis:"y"}),captureUpdate:ii.IMMEDIATELY}),keyTest:e=>e[gr.CTRL_OR_CMD]&&e.shiftKey&&e.key===gr.ARROW_DOWN,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>fr($,{hidden:!lt(n,o),type:"button",icon:ju,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${N("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Ne(ua(e),n)})}),c_=O({name:"alignLeft",label:"labels.alignLeft",icon:qu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"start",axis:"x"}),captureUpdate:ii.IMMEDIATELY}),keyTest:e=>e[gr.CTRL_OR_CMD]&&e.shiftKey&&e.key===gr.ARROW_LEFT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>fr($,{hidden:!lt(n,o),type:"button",icon:qu,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${N("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Ne(ua(e),n)})}),d_=O({name:"alignRight",label:"labels.alignRight",icon:Ju,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"end",axis:"x"}),captureUpdate:ii.IMMEDIATELY}),keyTest:e=>e[gr.CTRL_OR_CMD]&&e.shiftKey&&e.key===gr.ARROW_RIGHT,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>fr($,{hidden:!lt(n,o),type:"button",icon:Ju,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${N("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Ne(ua(e),n)})}),m_=O({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Qu,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"center",axis:"y"}),captureUpdate:ii.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>fr($,{hidden:!lt(n,o),type:"button",icon:Qu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Ne(ua(e),n)})}),p_=O({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:eh,trackEvent:{category:"element"},predicate:(e,n,t,o)=>lt(n,o),perform:(e,n,t,o)=>({appState:n,elements:ha(e,n,o,{position:"center",axis:"x"}),captureUpdate:ii.IMMEDIATELY}),PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>fr($,{hidden:!lt(n,o),type:"button",icon:eh,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Ne(ua(e),n)})});import{getNonDeletedElements as Xw}from"@excalidraw/element";import{isFrameLikeElement as h_}from"@excalidraw/element";import{CODES as Zw,KEYS as $w,arrayToMap as g_}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as f_}from"@excalidraw/element";import{distributeElements as E_}from"@excalidraw/element";import{CaptureUpdateAction as jw}from"@excalidraw/element";import{getSelectedElementsByGroup as b_}from"@excalidraw/element";import{jsx as Qw}from"react/jsx-runtime";var qw=(e,n)=>{let t=n.scene.getSelectedElements(e);return b_(t,n.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(o=>h_(o))},Jw=(e,n,t,o)=>{let r=t.scene.getSelectedElements(n),i=E_(r,t.scene.getNonDeletedElementsMap(),o,n,t.scene),a=g_(i);return f_(e.map(s=>a.get(s.id)||s),n,t)},x_=O({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Jw(e,n,o,{space:"between",axis:"x"}),captureUpdate:jw.IMMEDIATELY}),keyTest:e=>!e[$w.CTRL_OR_CMD]&&e.altKey&&e.code===Zw.H,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Qw($,{hidden:!qw(n,o),type:"button",icon:p1,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${N("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Ne(Xw(e),n)})}),y_=O({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,n,t,o)=>({appState:n,elements:Jw(e,n,o,{space:"between",axis:"y"}),captureUpdate:jw.IMMEDIATELY}),keyTest:e=>!e[$w.CTRL_OR_CMD]&&e.altKey&&e.code===Zw.V,PanelComponent:({elements:e,appState:n,updateData:t,app:o})=>Qw($,{hidden:!qw(n,o),type:"button",icon:u1,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${N("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Ne(Xw(e),n)})});import{arrayToMap as ev,KEYS as w_,matchKey as v_}from"@excalidraw/common";import{CaptureUpdateAction as I_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as T_}from"@excalidraw/element/frame";import{arrangeElements as S_}from"@excalidraw/element/arrange";import{jsx as k_}from"react/jsx-runtime";var C_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=ev(e),{arrange:i}=lo(n,t.props.editorPreferences),a=S_(t.scene,o,r,i.algorithm,i.gap),s=ev(a);return T_(e.map(l=>s.get(l.id)||l),n,t)},P_=lt,xg=O({name:"arrangeElements",label:"labels.arrangeElements",keywords:["arrange","rearrange","spread"],icon:dh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>P_(n,o),perform:(e,n,t,o)=>({appState:n,elements:C_(e,n,o),captureUpdate:I_.IMMEDIATELY}),keyTest:e=>e.shiftKey&&v_(e,w_.A),PanelComponent:({updateData:e})=>k_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:`${f("labels.arrangeElements")} \u2014 ${N("Shift+A")}`,children:dh})});import{arrayToMap as tv}from"@excalidraw/common";import{CaptureUpdateAction as M_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as A_}from"@excalidraw/element/frame";import{normaliseElements as D_}from"@excalidraw/element/normalise";import{jsx as R_}from"react/jsx-runtime";var L_=(e,n,t)=>{let o=t.scene.getSelectedElements(n),r=tv(e),{normalise:i}=lo(n,t.props.editorPreferences),a=D_(t.scene,o,r,i.mode,i.metric),s=tv(a);return A_(e.map(l=>s.get(l.id)||l),n,t)},__=lt,yg=O({name:"normaliseElements",label:"labels.normaliseElements",keywords:["normalize","normalise","scale","size","image"],icon:mh,trackEvent:{category:"element"},viewMode:!1,predicate:(e,n,t,o)=>__(n,o),perform:(e,n,t,o)=>({appState:n,elements:L_(e,n,o),captureUpdate:M_.IMMEDIATELY}),PanelComponent:({updateData:e})=>R_("button",{type:"button",className:"arrangeButton",onClick:()=>e(null),title:f("labels.normaliseElements"),children:mh})});import{getNonDeletedElements as N_}from"@excalidraw/element";import{bindOrUnbindBindingElements as B_}from"@excalidraw/element";import{getCommonBoundingBox as nv}from"@excalidraw/element";import{newElementWith as F_}from"@excalidraw/element";import{deepCopyElement as O_}from"@excalidraw/element";import{resizeMultipleElements as z_}from"@excalidraw/element";import{isArrowElement as ov,isElbowArrow as G_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as rv}from"@excalidraw/element";import{CODES as iv,KEYS as H_,arrayToMap as U_}from"@excalidraw/common";import{CaptureUpdateAction as av}from"@excalidraw/element";var wg=O({name:"flipHorizontal",label:"labels.flipHorizontal",icon:h0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:rv(sv(e,o.scene.getNonDeletedElementsMap(),n,"horizontal",o),n,o),appState:n,captureUpdate:av.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===iv.H}),vg=O({name:"flipVertical",label:"labels.flipVertical",icon:u0,trackEvent:{category:"element"},perform:(e,n,t,o)=>({elements:rv(sv(e,o.scene.getNonDeletedElementsMap(),n,"vertical",o),n,o),appState:n,captureUpdate:av.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===iv.V&&!e[H_.CTRL_OR_CMD]}),sv=(e,n,t,o,r)=>{let i=de(N_(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=W_(i,n,o,r),s=U_(a);return e.map(l=>s.get(l.id)||l)},W_=(e,n,t,o)=>{if(e.every(p=>ov(p)&&(p.startBinding||p.endBinding)))return e.map(p=>{let u=p;return F_(u,{startArrowhead:u.endArrowhead,endArrowhead:u.startArrowhead})});let{midX:r,midY:i}=nv(e);z_(e,n,"nw",o.scene,new Map(Array.from(n.values()).map(p=>[p.id,O_(p)])),{flipByX:t==="horizontal",flipByY:t==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),B_(e.filter(ov),o.scene,o.state);let{elbowArrows:a,otherElements:s}=e.reduce((p,u)=>G_(u)?{...p,elbowArrows:p.elbowArrows.concat(u)}:{...p,otherElements:p.otherElements.concat(u)},{elbowArrows:[],otherElements:[]}),{midX:l,midY:c}=nv(e),[d,m]=[r-l,i-c];return s.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),a.forEach(p=>o.scene.mutateElement(p,{x:p.x+d,y:p.y+m})),e};import{CODES as lv,KEYS as cv}from"@excalidraw/common";import{CaptureUpdateAction as V_}from"@excalidraw/element";var dv=(e,n)=>({appState:{viewpointFlip:{...e.viewpointFlip,[n]:!e.viewpointFlip[n]}},captureUpdate:V_.NEVER}),ga=O({name:"flipViewpointHorizontal",label:"labels.flipViewpointHorizontal",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>dv(n,"horizontal"),checked:e=>e.viewpointFlip.horizontal,keyTest:e=>!e[cv.CTRL_OR_CMD]&&!e.altKey&&e.shiftKey&&e.code===lv.R}),fa=O({name:"flipViewpointVertical",label:"labels.flipViewpointVertical",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>dv(n,"vertical"),checked:e=>e.viewpointFlip.vertical,keyTest:e=>!e[cv.CTRL_OR_CMD]&&e.altKey&&e.shiftKey&&e.code===lv.R});import{isTextElement as Y_}from"@excalidraw/element";import{getTextFromElements as K_}from"@excalidraw/element";import{CODES as X_,KEYS as fm,isFirefox as Z_}from"@excalidraw/common";import{CaptureUpdateAction as Qt}from"@excalidraw/element";var Ea=O({name:"copy",label:"labels.copy",icon:_s,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await om(r,o.files,t)}catch(i){return{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:i.message}}}return{captureUpdate:Qt.EVENTUALLY}},keyTest:e=>e[fm.CTRL_OR_CMD]&&e.key===fm.C}),Ig=O({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,n,t,o)=>{let r;try{r=await rm()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),Z_?{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{o.pasteFromClipboard(nm({types:r}))}catch(i){return console.error(i),{captureUpdate:Qt.EVENTUALLY,appState:{...n,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Qt.EVENTUALLY}},keyTest:void 0}),Em=O({name:"cut",label:"labels.cut",icon:t0,trackEvent:{category:"element"},perform:(e,n,t,o)=>(Ea.perform(e,n,t,o),Gs.perform(e,n,null,o)),keyTest:e=>e[fm.CTRL_OR_CMD]&&e.key===fm.X}),$_=O({name:"copyAsSvg",label:"labels.copyAsSvg",icon:g0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Qt.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Qr(e,n,!0);try{await ei("clipboard-svg",r,n,o.files,{...n,exportingFrame:i,name:o.getName()});let a=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:Qt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Qt.EVENTUALLY}}},predicate:e=>tm&&e.length>0,keywords:["svg","clipboard","copy"]}),j_=O({name:"copyAsPng",label:"labels.copyAsPng",icon:f0,trackEvent:{category:"element"},perform:async(e,n,t,o)=>{if(!o.canvas)return{captureUpdate:Qt.EVENTUALLY};let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Qr(e,n,!0);try{return await ei("clipboard",i,n,o.files,{...n,exportingFrame:a,name:o.getName()}),{appState:{...n,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:r.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:n.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:Qt.EVENTUALLY}}catch(s){return console.error(s),{appState:{...n,errorMessage:s.message},captureUpdate:Qt.EVENTUALLY}}},predicate:e=>pr&&e.length>0,keyTest:e=>e.code===X_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),q_=O({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0});try{ao(K_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Qt.EVENTUALLY}},predicate:(e,n,t,o)=>tm&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0}).some(Y_),keywords:["text","clipboard","copy"]});import{CODES as J_,KEYS as Q_}from"@excalidraw/common";import{CaptureUpdateAction as eR}from"@excalidraw/element";var ba=O({name:"gridMode",icon:b0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,n){return{appState:{...n,gridModeEnabled:!this.checked(n),objectsSnapModeEnabled:!1},captureUpdate:eR.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[Q_.CTRL_OR_CMD]&&e.code===J_.QUOTE});import tR from"clsx";import{KEYS as mv}from"@excalidraw/common";import{CaptureUpdateAction as nR}from"@excalidraw/element/store";import{getElementBounds as pv}from"@excalidraw/element";import{isImageElement as oR}from"@excalidraw/element/typeChecks";import{jsx as iR}from"react/jsx-runtime";var uv="Press <kbd>F</kbd> quickly to smart zoom the canvas, or hold and click on an item to smart zoom to it",xa=Qe(!1),hv=(e,n,t,o)=>{let r=e.filter(oR).sort((s,l)=>{let[c,d]=pv(s,n),[m,p]=pv(l,n);return d-p||c-m});if(r.length===0)return null;let i=r.findIndex(s=>s.id===t),a=o==="next"?(i+1)%r.length:(i<0?r.length-1:i-1+r.length)%r.length;return r[a]},rR=({data:e,updateData:n})=>{let t=Oi(xa);return iR($,{type:"button",icon:ph,"aria-label":f("labels.smartZoom"),title:`${f("labels.smartZoom")} - ${mv.F.toLocaleUpperCase()}`,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-smart-zoom",keyBindingLabel:mv.F.toLocaleUpperCase(),className:tR({"smart-zoom-button--key-held":t})})},Rn=O({name:"smartZoom",label:"toolBar.smartZoom",trackEvent:{category:"toolbar"},icon:ph,viewMode:!0,perform:(e,n,t,o)=>{let r=lo(n,o.props.editorPreferences).smartZoom,i=t&&t.length>0?t:de(e,n);return o.viewport.setViewport({target:i.length?i:e,fit:r.fitToViewport?"contain":"none",animation:r.animate?{duration:r.duration}:!1,offsets:r.respectUIElements?{ui:!0}:void 0,viewportZoomFactor:r.viewportZoomFactor}),{captureUpdate:nR.NEVER}},PanelComponent:rR});import{CODES as aR,KEYS as sR}from"@excalidraw/common";import{CaptureUpdateAction as lR}from"@excalidraw/element";var _t=O({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Jo,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,n){return{appState:{...n,objectsSnapModeEnabled:!this.checked(n),gridModeEnabled:!1},captureUpdate:lR.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,n,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[sR.CTRL_OR_CMD]&&e.altKey&&e.code===aR.S});import{CaptureUpdateAction as cR}from"@excalidraw/element";var gl=O({name:"arrowBinding",label:"labels.arrowBinding",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>e.bindingPreference==="disabled"},perform(e,n){let t=n.bindingPreference==="enabled"?"disabled":"enabled";return{appState:{...n,bindingPreference:t,isBindingEnabled:t==="enabled"},captureUpdate:cR.NEVER}},checked:e=>e.bindingPreference==="enabled"});import{CaptureUpdateAction as dR}from"@excalidraw/element";var fl=O({name:"midpointSnapping",label:"labels.midpointSnapping",viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.isMidpointSnappingEnabled},perform(e,n){return{appState:{...n,isMidpointSnappingEnabled:!this.checked(n)},captureUpdate:dR.NEVER}},checked:e=>e.isMidpointSnappingEnabled});import{CODES as mR,KEYS as pR}from"@excalidraw/common";import{CaptureUpdateAction as uR}from"@excalidraw/element";var Er=O({name:"stats",label:"stats.fullTitle",icon:p0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,n){return{appState:{...n,stats:{...n.stats,open:!this.checked(n)}},captureUpdate:uR.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[pR.CTRL_OR_CMD]&&e.altKey&&e.code===mR.SLASH});import{BOUND_TEXT_PADDING as gv,ROUNDNESS as fv,TEXT_ALIGN as xv,VERTICAL_ALIGN as yv,arrayToMap as wv,getFontString as hR,getStrokeWidthByKey as gR}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as fR,isBoundToContainer as Ev,resetOriginalContainerCache as ER,updateOriginalContainerCache as bR}from"@excalidraw/element";import{computeBoundTextPosition as xR,computeContainerDimensionForBoundText as bv,getBoundTextElement as vv,redrawTextBoundingBox as Iv}from"@excalidraw/element";import{hasBoundTextElement as yR,isArrowElement as wR,isTextBindableContainer as Tg,isTextElement as El,isUsingAdaptiveRadius as vR}from"@excalidraw/element";import{measureText as IR}from"@excalidraw/element";import{syncMovedIndices as Tv}from"@excalidraw/element";import{newElement as TR}from"@excalidraw/element";import{CaptureUpdateAction as Sg}from"@excalidraw/element";var Cg=O({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>o.scene.getSelectedElements(n).some(i=>yR(i)),perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=o.scene.getNonDeletedElementsMap();return r.forEach(a=>{let s=vv(a,i);if(s){let{width:l,height:c}=IR(s.originalText,hR(s),s.lineHeight),d=fR(a.id);ER(a.id);let{x:m,y:p}=xR(a,s,i);o.scene.mutateElement(s,{containerId:null,width:l,height:c,text:s.originalText,x:m,y:p}),o.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==s.id),height:d||a.height})}}),{elements:e,appState:n,captureUpdate:Sg.IMMEDIATELY}}}),Pg=O({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);if(r.length===2){let i=El(r[0])||El(r[1]),a;if(Tg(r[0])?a=r[0]:Tg(r[1])&&(a=r[1]),i&&a&&vv(a,o.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i,a;El(r[0])&&Tg(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),o.scene.mutateElement(i,{containerId:a.id,verticalAlign:yv.MIDDLE,textAlign:xv.CENTER,autoResize:!0,angle:wR(a)?0:a?.angle??0}),o.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let s=a.height;return Iv(i,a,o.scene),bR(a.id,s),{elements:SR(e,a,i),appState:{...n,selectedElementIds:{[a.id]:!0}},captureUpdate:Sg.IMMEDIATELY}}}),SR=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===t.id);o.splice(r,1);let i=o.findIndex(a=>a.id===n.id);return o.splice(i+1,0,t),Tv(o,wv([n,t])),o},CR=(e,n,t)=>{let o=e.slice(),r=o.findIndex(a=>a.id===n.id);o.splice(r,1);let i=o.findIndex(a=>a.id===t.id);return o.splice(i,0,n),Tv(o,wv([n,t])),o},Sv=O({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=r.some(a=>El(a)&&!Ev(a));return r.length>0&&i},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n),i=e.slice(),a={};for(let s of r)if(El(s)&&!Ev(s)){let l=TR({type:"rectangle",backgroundColor:n.currentItemBackgroundColor,boundElements:[...s.boundElements||[],{id:s.id,type:"text"}],angle:s.angle,fillStyle:n.currentItemFillStyle,strokeColor:n.currentItemStrokeColor,roughness:n.currentItemRoughness,strokeWidth:gR("rectangle",n.currentItemStrokeWidthKey),strokeStyle:n.currentItemStrokeStyle,roundness:n.currentItemRoundness==="round"?{type:vR("rectangle")?fv.ADAPTIVE_RADIUS:fv.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:s.x-gv,y:s.y-gv,width:bv(s.width,"rectangle"),height:bv(s.height,"rectangle"),groupIds:s.groupIds,frameId:s.frameId});if(s.boundElements?.length){let c=s.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===s.id&&(p={...p,elementId:l.id}),u?.elementId===s.id&&(u={...u,elementId:l.id}),(p||u)&&o.scene.mutateElement(m,{startBinding:p,endBinding:u})})}o.scene.mutateElement(s,{containerId:l.id,verticalAlign:yv.MIDDLE,boundElements:null,textAlign:xv.CENTER,autoResize:!0}),Iv(s,l,o.scene),i=CR([...i,l],l,s),a[l.id]=!0}return{elements:i,appState:{...n,selectedElementIds:a},captureUpdate:Sg.IMMEDIATELY}}});import{getNonDeletedElements as Nv,isEmbeddableElement as WR}from"@excalidraw/element";import{KEYS as Bv}from"@excalidraw/common";import{CaptureUpdateAction as VR}from"@excalidraw/element";import{pointFrom as Mv}from"@excalidraw/math";import PR from"clsx";import{useCallback as Cv,useEffect as Pv,useLayoutEffect as kR,useRef as MR,useState as AR}from"react";import{EVENT as kg,HYPERLINK_TOOLTIP_DELAY as DR,KEYS as bm}from"@excalidraw/common";import{getElementAbsoluteCoords as _g}from"@excalidraw/element";import{hitElementBoundingBox as LR}from"@excalidraw/element";import{isElementLink as _R}from"@excalidraw/element";import{getEmbedLink as RR,embeddableURLValidator as NR}from"@excalidraw/element";import{sceneCoordsToViewportCoords as Av,viewportCoordsToSceneCoords as BR,wrapEvent as FR,isLocalLink as OR,normalizeLink as Mg}from"@excalidraw/common";import{isEmbeddableElement as Ag}from"@excalidraw/element";import{jsx as ya,jsxs as kv}from"react/jsx-runtime";var Rg=380,zR=42,Dg=5,Dv=85,GR=500,Lg=!1,xm=new Map,Lv=({element:e,scene:n,setAppState:t,onLinkOpen:o,setToast:r,updateEmbedValidationStatus:i})=>{let a=n.getNonDeletedElementsMap(),s=ro(),l=Ln(),c=fe(),d=e.link||"",[m,p]=AR(d),u=MR(null),E=s.showHyperlinkPopup==="editor",g=Cv(()=>{if(!u.current)return;let I=Mg(u.current.value)||null;if(!e.link&&I&&We("hyperlink","create"),Ag(e)){if(s.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!I){n.mutateElement(e,{link:null}),i(e,!1);return}if(!NR(I,l.validateEmbeddable))I&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&xm.set(e.id,e.link),n.mutateElement(e,{link:I}),i(e,!1);else{let{width:T,height:C}=e,P=RR(I);P?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let M=P?P.intrinsicSize.w/P.intrinsicSize.h:1,D=xm.get(e.id)!==e.link;n.mutateElement(e,{...D?{width:P?.type==="video"?T>C?T:C*M:T,height:P?.type==="video"&&T>C?T/M:C}:{},link:I}),i(e,!0),xm.has(e.id)&&xm.delete(e.id)}}else n.mutateElement(e,{link:I})},[e,n,r,l.validateEmbeddable,s.activeEmbeddable,t,i]);kR(()=>()=>{g()},[g]),Pv(()=>{E&&u?.current&&!(c.formFactor==="phone"||c.isTouchScreen)&&u.current.select()},[E,c.formFactor,c.isTouchScreen]),Pv(()=>{let I=null,T=C=>{if(E)return;I&&clearTimeout(I),UR(e,a,s,Mv(C.clientX,C.clientY))&&(I=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},GR))};return window.addEventListener(kg.POINTER_MOVE,T,!1),()=>{window.removeEventListener(kg.POINTER_MOVE,T,!1),I&&clearTimeout(I)}},[s,e,E,t,a]);let b=Cv(()=>{We("hyperlink","delete"),n.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,n]),v=()=>{We("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:w,y:x}=_v(e,s,a);return s.contextMenu||s.selectedElementsAreBeingDragged||s.resizingElement||s.isRotating||s.openMenu||s.viewModeEnabled?null:kv("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${x}px`,left:`${w}px`,width:Rg,padding:Dg},children:[E?ya("input",{className:PR("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:m,onChange:I=>p(I.target.value),autoFocus:!0,onKeyDown:I=>{I.stopPropagation(),I[bm.CTRL_OR_CMD]&&I.key===bm.K&&I.preventDefault(),(I.key===bm.ENTER||I.key===bm.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?ya("a",{href:Mg(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:OR(e.link)?"_self":"_blank",onClick:I=>{if(e.link&&o){let T=FR(kg.EXCALIDRAW_LINK,I.nativeEvent);o({...e,link:Mg(e.link)},T),T.defaultPrevented&&I.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ya("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),kv("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!E&&ya($,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:v,className:"excalidraw-hyperlinkContainer--edit",icon:Qn}),ya($,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:v0}),d&&!Ag(e)&&ya($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:Vr})]})]})},_v=(e,n,t)=>{let[o,r]=_g(e,t),{x:i,y:a}=Av({sceneX:o+e.width/2,sceneY:r},n),s=i-n.offsetLeft-Rg/2,l=a-n.offsetTop-Dv;return{x:s,y:l}},Ng=(e,n)=>{let t=de(e,n);return Ag(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},bl=null,Rv=(e,n,t)=>{bl&&clearTimeout(bl),bl=window.setTimeout(()=>HR(e,n,t),DR)},HR=(e,n,t)=>{if(!e.link)return;let o=ia();o.classList.add("excalidraw-tooltip--visible"),o.style.maxWidth="20rem",o.textContent=_R(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,s]=_g(e,t),[l,c,d,m]=yx([r,i,a,s],e.angle,n),p=Av({sceneX:l,sceneY:c},n);Jh(o,{left:p.x,top:p.y,width:d,height:m},"top"),We("hyperlink","tooltip","link-icon"),Lg=!0},ym=()=>{bl&&clearTimeout(bl),Lg&&(Lg=!1,ia().classList.remove("excalidraw-tooltip--visible"))},UR=(e,n,t,[o,r])=>{let{x:i,y:a}=BR({clientX:o,clientY:r},t),s=15/t.zoom.value;if(LR(Mv(i,a),e,n))return!1;let[l,c,d]=_g(e,n);if(i>=l&&i<=d&&a>=c-Dv&&a<=c)return!1;let{x:m,y:p}=_v(e,t,n);return!(o>=m-s&&o<=m+Rg+Dg*2+s&&r>=p-s&&r<=p+s+Dg*2+zR)};import{jsx as YR}from"react/jsx-runtime";var Bg=O({name:"hyperlink",label:(e,n)=>Ng(Nv(e),n),icon:Fs,perform:(e,n)=>n.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...n,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:VR.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[Bv.CTRL_OR_CMD]&&e.key===Bv.K,predicate:(e,n)=>de(e,n).length===1,PanelComponent:({elements:e,appState:n,updateData:t})=>{let o=de(e,n);return YR($,{type:"toggle",icon:Fs,"aria-label":f(Ng(Nv(e),n)),title:`${WR(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${N("CtrlOrCmd+K")}`,onSelect:()=>t(null),checked:o.length===1&&!!o[0].link})}});import{KEYS as Fv,arrayToMap as Og,randomId as KR}from"@excalidraw/common";import{elementsAreInSameGroup as XR,getNonDeletedElements as Ov,newElementWith as zv,selectGroupsFromGivenElements as Gv}from"@excalidraw/element";import{CaptureUpdateAction as Hv}from"@excalidraw/element";var Fg=e=>e.every(n=>!n.locked),xl=O({name:"toggleElementLock",label:(e,n,t)=>{let o=t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1});return Fg(o)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,n)=>{let t=de(n,e);return Fg(t)?$o:To},trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=Fg(r),a=Og(r),s=r.length>1&&XR(r),c=r.length===1||s?null:KR(),d={...n.lockedMultiSelections};if(i)d={...n.lockedMultiSelections,...c?{[c]:!0}:{}};else if(s){let v=r[0].groupIds.at(-1);delete d[v]}let m=e.map(v=>{if(!a.has(v.id))return v;let w=v.groupIds;return i?c&&(w=[...w,c]):w=w.filter(x=>!n.lockedMultiSelections[x]),zv(v,{locked:i,groupIds:w.length!==v.groupIds.length?w:v.groupIds})}),p=Og(m),u=i?{}:Object.fromEntries(r.map(v=>[v.id,!0])),E=r.map(v=>p.get(v.id)||v),g=i?{}:Gv(Ov(E),n),b=i?c||(s?r[0].groupIds.at(-1):r[0].id):null;return{elements:m,appState:{...n,selectedElementIds:u,selectedGroupIds:g,selectedLinearElement:i?null:n.selectedLinearElement,lockedMultiSelections:d,activeLockedId:b},captureUpdate:Hv.IMMEDIATELY}},keyTest:(e,n,t,o)=>e.key.toLocaleLowerCase()===Fv.L&&e[Fv.CTRL_OR_CMD]&&e.shiftKey&&o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}).length>0}),Uv=O({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:To,predicate:(e,n)=>de(e,n).length===0&&e.some(o=>o.locked),perform:(e,n)=>{let t=e.filter(s=>s.locked),o=e.map(s=>{if(s.locked){let l=s.groupIds.filter(c=>!n.lockedMultiSelections[c]);return zv(s,{locked:!1,groupIds:s.groupIds.length!==l.length?l:s.groupIds})}return s}),r=Og(o),i=t.map(s=>r.get(s.id)||s),a=Ov(i);return{elements:o,appState:{...n,selectedElementIds:Object.fromEntries(a.map(s=>[s.id,!0])),selectedGroupIds:Gv(a,n),lockedMultiSelections:{},activeLockedId:null},captureUpdate:Hv.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as a8,isLinearElement as s8,isLineElement as ka}from"@excalidraw/element";import{arrayToMap as l8,invariant as S2}from"@excalidraw/common";import{toggleLinePolygonState as c8,CaptureUpdateAction as C2}from"@excalidraw/element";import{getSizeFromPoints as ySe,randomInteger as r8,getUpdatedTimestamp as i8}from"@excalidraw/common";import{simplify as ON}from"points-on-curve";import{getStroke as zN,getStrokePoints as tSe}from"perfect-freehand";function et([e,n,t],[o,r,i]){return[e+o,n+r,t+i]}function wa([e,n,t],[o,r,i]){return[e-o,n-r,t-i]}function rt([e,n,t],o){return[e*o,n*o,t*o]}function si([e,n,t]){return[e/Math.sqrt(e**2+n**2),n/Math.sqrt(e**2+n**2),t]}function wt([e,n,t],o){return[Math.cos(o)*e-Math.sin(o)*n,Math.sin(o)*e+Math.cos(o)*n,t]}function Wv(e,n,t){return et(e,rt(wa(n,e),t))}function zg(e,n,t){return Math.atan2(t[1]-e[1],t[0]-e[0])-Math.atan2(n[1]-e[1],n[0]-e[0])}function Gg(e){return Math.atan2(Math.sin(e),Math.cos(e))}function Hg([e,n]){return Math.sqrt(e**2+n**2)}function ai([e,n],[t,o]){return Math.sqrt((t-e)**2+(o-n)**2)}function Vv(e){if(e.length<2)return 0;let n=0;for(let t=1;t<=e.length-1;t++)n+=ai(e[t-1],e[t]);return n+=ai(e[e.length-2],e[e.length-1]),n}var ZR=(e,n,t)=>Math.max(n,Math.min(t,e));function Yv(e,n,t){let o=ai(n,t);if(o===0)return ai(e,n);let r=ZR(((e[0]-n[0])*(t[0]-n[0])+(e[1]-n[1])*(t[1]-n[1]))/o**2,0,1),i=[n[0]+r*(t[0]-n[0]),n[1]+r*(t[1]-n[1]),e[2]];return ai(i,e)}function yl(e,n){if(n===0||e.length<=2)return e;let t=e[0],o=e[e.length-1],[r,i]=e.reduce(([a,s],l,c)=>{let d=Yv(l,t,o);return d>a?[d,c]:[a,s]},[0,-1]);if(r>=n){let a=e[i];return[...yl([t,...e.slice(1,i),a],n).slice(0,-1),a,...yl([a,...e.slice(i,-1),o],n).slice(1)]}return[t,o]}var br=class br{constructor(n){y(this,"options");y(this,"originalPoints",[]);y(this,"stablePoints",[]);y(this,"tailPoints",[]);y(this,"isFresh",!0);this.options=Object.assign({},br.defaults,n)}get lastPoint(){return this.tailPoints[this.tailPoints.length-1]??this.stablePoints[this.stablePoints.length-1]}addPoint(n){let t=this.originalPoints[this.originalPoints.length-1];if(!(t&&t[0]===n[0]&&t[1]===n[1])){if(this.originalPoints.push(n),this.isFresh){this.isFresh=!1,this.stablePoints.push(n);return}this.options.streamline>0&&(n=Wv(this.lastPoint,n,1-this.options.streamline)),this.tailPoints.push(n),Vv(this.tailPoints)>br.constants.maxTailLength&&this.stabilizeTail()}}close(){this.stabilizeTail()}stabilizeTail(){if(this.options.simplify>0&&this.options.simplifyPhase==="tail")throw new Error("Not implemented yet");this.stablePoints.push(...this.tailPoints),this.tailPoints=[]}getSize(n,t,o,r,i){return(n??this.options.size)*this.options.sizeMapping({pressure:t,runningLength:i,currentIndex:o,totalLength:r})}getStrokeOutline(n){if(this.isFresh)return[];let t=[...this.stablePoints,...this.tailPoints];this.options.simplify>0&&this.options.simplifyPhase==="input"&&(t=yl(t,this.options.simplify));let o=t.length;if(o===0)return[];if(o===1){let P=t[0],M=this.getSize(n,P[2],0,o,0);if(M<.5)return[];let D=[];for(let _=0;_<=Math.PI*2;_+=Math.PI/16)D.push(et(P,rt(wt([1,0,0],_),M)));return D.push(et(P,rt([1,0,0],this.getSize(n,P[2],0,o,0)))),D}if(o===2){let P=t[0],M=t[1],D=this.getSize(n,P[2],0,o,0),_=this.getSize(n,M[2],0,o,0);if(D<.5||_<.5)return[];let k=[],L=zg(P,[P[0],P[1]-100,P[2]],M);for(let F=L;F<=Math.PI+L;F+=Math.PI/16)k.push(et(P,rt(wt([1,0,0],F),D)));for(let F=Math.PI+L;F<=Math.PI*2+L;F+=Math.PI/16)k.push(et(M,rt(wt([1,0,0],F),_)));return k.push(k[0]),k}let r=[],i=[],a=0,s=0,l=0,c=0;for(let P=1;P<o-1;P++){let M=t[P-1],D=t[P],_=t[P+1],k=D[2],L=ai(M,D);c+=L,a=s+(L-s)*.2;let F=this.getSize(n,k,P,o,c);if(F===0){l=P+1;continue}let K=si(wa(M,D)),z=si(wa(_,D)),U=wt(K,Math.PI/2),W=wt(K,-Math.PI/2),G=wt(z,Math.PI/2),ie=wt(z,-Math.PI/2),me=et(D,rt(U,F)),B=et(D,rt(W,F)),Y=et(D,rt(G,F)),pe=et(D,rt(ie,F)),ae=et(U,ie),xe=et(W,G),ce=et(D,rt(Hg(ae)===0?K:si(ae),F)),Oe=et(D,rt(Hg(xe)===0?z:si(xe),F)),se=Gg(zg(D,M,_)),_e=br.constants.cornerDetectionMaxAngle/180*Math.PI*br.constants.cornerDetectionVariance(a);if(Math.abs(se)<_e){let Re=Math.abs(Gg(Math.PI-se));if(Re===0)continue;if(se<0){i.push(B,Oe);for(let Se=0;Se<=Re;Se+=Re/4)r.push(et(D,wt(rt(U,F),Se)));for(let Se=Re;Se>=0;Se-=Re/4)i.push(et(D,wt(rt(U,F),Se)));i.push(Oe,Y)}else{r.push(me,ce);for(let Se=0;Se<=Re;Se+=Re/4)i.push(et(D,wt(rt(U,-F),-Se)));for(let Se=Re;Se>=0;Se-=Re/4)r.push(et(D,wt(rt(U,-F),-Se)));r.push(ce,pe)}}else r.push(ce),i.push(Oe);s=a}if(l>=o-2){if(this.options.keepHead){let P=t[o-1],M=[];for(let D=0;D<=Math.PI*2;D+=Math.PI/16)M.push(et(P,rt(wt([1,0,0],D),this.options.size)));return M.push(et(P,rt([1,0,0],this.options.size))),M}return[]}let d=t[l],m=t[l+1],p=t[o-2],u=t[o-1],E=si(wa(m,d)),g=si(wa(p,u)),b=wt(E,-Math.PI/2),v=wt(g,Math.PI/2),w=this.getSize(n,d[2],0,o,0),x=[],I=this.options.keepHead?this.options.size:this.getSize(n,p[2],o-2,o,c),T=[];if(w>.1){for(let P=0;P<=Math.PI;P+=Math.PI/16)x.unshift(et(d,wt(rt(b,w),-P)));x.unshift(et(d,rt(b,-w)))}else x.push(d);for(let P=0;P<=Math.PI*3;P+=Math.PI/16)T.push(et(u,wt(rt(v,-I),-P)));let C=[...x,...r,...T.reverse(),...i.reverse()];return x.length>0&&C.push(x[0]),this.options.simplify>0&&this.options.simplifyPhase==="output"?yl(C,this.options.simplify):C}};y(br,"defaults",{size:2,streamline:.45,simplify:.1,simplifyPhase:"output",keepHead:!1,sizeMapping:()=>1}),y(br,"constants",{cornerDetectionMaxAngle:75,cornerDetectionVariance:n=>n>35?.5:1,maxTailLength:50});var va=br;import{pointsOnBezierCurves as qde}from"points-on-curve";import{invariant as Qde}from"@excalidraw/common";import{curve as tme,lineSegment as nme,pointFrom as ome,pointDistance as rme,pointFromArray as ime,pointFromVector as ame,pointRotateRads as sme,polygon as lme,polygonFromPoints as cme,PRECISION as dme,segmentsIntersectAt as mme,vector as pme,vectorAdd as ume,vectorFromPoint as hme,vectorScale as gme}from"@excalidraw/math";import{getElementAbsoluteCoords as Eme}from"@excalidraw/element";var Ug=e=>{if(!e)return[];for(let n of e.sets)if(n.type==="path")return n.ops;return e.sets[0].ops};import{pointFrom as GN,pointDistance as x2,pointRotateRads as iSe}from"@excalidraw/math";import{ROUGHNESS as HN,THEME as lf,isTransparent as _l,assertNever as UN,COLOR_PALETTE as WN,LINE_POLYGON_POINT_MERGE_DISTANCE as sSe,applyDarkModeFilter as Rl,DEFAULT_STROKE_STREAMLINE as VN}from"@excalidraw/common";import{RoughGenerator as YN}from"roughjs/bin/generator";import pTe from"roughjs/bin/rough";import{isRightAngleRads as hTe,lineSegment as gTe,pointFrom as fTe,pointRotateRads as ETe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as xTe,DEFAULT_REDUCED_GLOBAL_ALPHA as yTe,ELEMENT_READY_TO_ERASE_OPACITY as wTe,FRAME_STYLE as vTe,DARK_THEME_FILTER as ITe,MIME_TYPES as b2,THEME as TTe,distance as STe,getFontString as CTe,isRTL as PTe,getVerticalOffset as kTe,invariant as MTe,applyDarkModeFilter as ATe,isSafari as DTe}from"@excalidraw/common";import NIe from"roughjs/bin/rough";import{arrayToMap as FIe,invariant as E2,rescalePoints as OIe,sizeOf as zIe}from"@excalidraw/common";import{degreesToRadians as of,lineSegment as HIe,pointFrom as vt,pointFromArray as DN,pointRotateRads as Pa}from"@excalidraw/math";import{pointsOnBezierCurves as VIe}from"points-on-curve";import{pointCenter as Q2e,pointFrom as eIe,pointRotateRads as tIe,pointsEqual as nIe,pointDistance as oIe,vectorFromPoint as rIe,curveLength as iIe,curvePointAtLength as aIe}from"@excalidraw/math";import{DRAGGING_THRESHOLD as cIe,KEYS as dIe,shouldRotateWithDiscreteAngle as mIe,getGridPoint as pIe,invariant as uIe,isShallowEqual as hIe,getFeatureFlag as gIe}from"@excalidraw/common";import{arrayToMap as h2e,getFeatureFlag as g2e,getGridPoint as f2e,invariant as E2e,isTransparent as b2e}from"@excalidraw/common";import{PRECISION as y2e,clamp as w2e,lineSegment as v2e,pointDistance as I2e,pointDistanceSq as T2e,pointFrom as S2e,pointFromArray as C2e,pointFromVector as P2e,pointRotateRads as k2e,pointsEqual as M2e,vectorFromPoint as A2e,vectorNormalize as D2e,vectorScale as L2e}from"@excalidraw/math";import{invariant as Nve,isTransparent as Bve}from"@excalidraw/common";import{curveIntersectLineSegment as Ove,isPointWithinBounds as zve,lineSegment as Gve,lineSegmentIntersectionPoints as Hve,pointFrom as Uve,pointFromVector as Wve,pointRotateRads as Vve,pointsEqual as Yve,vectorFromPoint as Kve,vectorNormalize as Xve,vectorScale as Zve}from"@excalidraw/math";import{ellipse as jve,ellipseSegmentInterceptPoints as qve}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as JR,DEFAULT_PROPORTIONAL_RADIUS as Yg,invariant as kme,LINE_CONFIRM_THRESHOLD as QR,ROUNDNESS as Kg}from"@excalidraw/common";import{bezierEquation as Ame,curve as Dme,curveCatmullRomCubicApproxPoints as Lme,curveOffsetPoints as _me,lineSegment as Rme,lineSegmentIntersectionPoints as Nme,pointDistance as eN,pointFrom as Bme,pointFromArray as Fme,pointFromVector as Ome,pointRotateRads as zme,pointTranslate as Gme,rectangle as Hme,vectorFromPoint as Ume,vectorNormalize as Wme,vectorScale as Vme}from"@excalidraw/math";import{ROUNDNESS as wme,assertNever as vme}from"@excalidraw/common";import{pointsEqual as Tme}from"@excalidraw/math";var Kv=e=>!!e&&e.type==="embeddable",Wg=e=>!!e&&e.type==="iframe",Vg=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),pn=e=>e!=null&&e.type==="text";var co=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var un=e=>e!=null&&jR(e.type);var Nn=e=>e!=null&&e.type==="arrow",Bn=e=>Nn(e)&&e.elbowed;var jR=e=>e==="arrow"||e==="line";var Ao=e=>e!==null&&"containerId"in e&&e.containerId!==null&&pn(e);var Ia=(e,n=1)=>{if(e.length>=3){let[t,o]=[e[0],e[e.length-1]];return eN(t,o)<=QR/n}return!1},wl=(e,n)=>{if(n.roundness?.type===Kg.PROPORTIONAL_RADIUS||n.roundness?.type===Kg.LEGACY)return e*Yg;if(n.roundness?.type===Kg.ADAPTIVE_RADIUS){let t=n.roundness?.value??JR,o=t/Yg;return e<=o?e*Yg:t}return 0};import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as hve,ARROW_LABEL_WIDTH_FRACTION as gve,BOUND_TEXT_PADDING as fve,DEFAULT_FONT_SIZE as Eve,TEXT_ALIGN as bve,VERTICAL_ALIGN as xve,getFontString as yve,isProdEnv as wve,invariant as vve}from"@excalidraw/common";import{pointFrom as Tve,pointRotateRads as Sve}from"@excalidraw/math";import{BOUND_TEXT_PADDING as rpe,DEFAULT_FONT_SIZE as ipe,DEFAULT_FONT_FAMILY as ape,getFontString as spe,isTestEnv as lpe,normalizeEOL as cpe}from"@excalidraw/common";var dpe="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Epe,isTestEnv as bpe}from"@excalidraw/common";import{toIterable as swe}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Ipe,viewportCoordsToSceneCoords as Tpe}from"@excalidraw/common";import{normalizeRadians as Cpe,radiansBetweenAngles as Ppe,radiansDifference as kpe}from"@excalidraw/math";import{pointsEqual as Ape}from"@excalidraw/math";import{arrayToMap as hue,isShallowEqual as rN}from"@excalidraw/common";import{arrayToMap as Zpe}from"@excalidraw/common";import{isPointWithinBounds as jpe,pointFrom as qpe,segmentsIntersectAt as Jpe}from"@excalidraw/math";import{arrayToMap as Bpe}from"@excalidraw/common";import{validateOrderKey as Ope,generateNKeysBetween as zpe}from"@excalidraw/fractional-indexing";var Xg=(e,n)=>{let t=[];for(let o of e.values())o.frameId===n&&t.push(o);return t};var vue=function(){let e=null,n=null,t=null,o=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===n||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,n=i.selectedElementIds),t);return o.clearCache=()=>{e=null,n=null,t=null},o}(),Cl=(e,n,t)=>{let o=new Set,r=[];for(let i of e.values()){if(n.selectedElementIds[i.id]){li(i)?(r.push(i),o.add(i.id)):console.error("[NONDELETED][INVARIANT] getSelectedElements skipping deleted selected element which should not be in the selection");continue}if(t?.includeBoundTextElement&&Ao(i)&&li(i)&&n.selectedElementIds[i?.containerId]){r.push(i),o.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{co(a)&&Xg(e,a.id).forEach(s=>!o.has(s.id)&&i.push(s)),i.push(a)}),i}return r};var $g=(e,n)=>rN(n.selectedElementIds,e)?n.selectedElementIds:e;var iN=function(){let e=null,n=null,t=null,o=(i,a,s,l)=>{if(t!==void 0&&a===n&&i===e&&s.editingGroupId===t?.editingGroupId)return t;let c={};for(let p of i){let u=p.groupIds;if(s.editingGroupId){let E=u.indexOf(s.editingGroupId);E>-1&&(u=u.slice(0,E))}if(u.length>0){let E=u[u.length-1];c[E]=!0}}let d={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let E=u.groupIds.find(g=>c[g]);return E&&(p[u.id]=!0,Array.isArray(d[E])?d[E].push(u.id):d[E]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return n=a,e=i,t={editingGroupId:s.editingGroupId,selectedGroupIds:c,selectedElementIds:$g({...s.selectedElementIds,...m},l)},t},r=(i,a,s,l)=>{let c=l?l.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Cl(a,i);return c.length?o(c,a,i,s):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:$g(i.selectedElementIds,s)}};return r.clearCache=()=>{n=null,e=null,t=null},r}();var Gue=[1,4/3,3/4,3/2,2/3,2,1/2];import{TEXT_ALIGN as Bhe,VERTICAL_ALIGN as Fhe}from"@excalidraw/common";import{pointDistance as zhe,pointFromVector as Ghe,pointsEqual as Hhe,vector as Uhe,vectorDot as Whe,vectorFromPoint as Vhe,vectorNormalize as Yhe,vectorScale as Khe}from"@excalidraw/math";import{invariant as Jue,isDevEnv as Que,isTestEnv as ehe}from"@excalidraw/common";import{pointFrom as nhe,pointFromVector as ohe,pointRotateRads as rhe,pointScaleFromOrigin as ihe,pointsEqual as ahe,triangleIncludesPoint as she,vectorCross as lhe,vectorFromPoint as lN,vectorScale as che}from"@excalidraw/math";var Ml=[1,0],Sm=[0,1],Al=[-1,0],Cm=[0,-1],Pm=e=>{let[n,t]=e,o=Math.abs(n),r=Math.abs(t);return n>r?Ml:n<=-r?Al:t>o?Sm:Cm},t2=(e,n)=>Pm(lN(e,n)),km=(e,n)=>Mm(t2(e,n)),kl=(e,n)=>e[0]===n[0]&&e[1]===n[1],Mm=e=>kl(e,Ml)||kl(e,Al);import{DEFAULT_ELEMENT_PROPS as hhe,DEFAULT_FONT_FAMILY as ghe,DEFAULT_FONT_SIZE as fhe,DEFAULT_TEXT_ALIGN as Ehe,DEFAULT_VERTICAL_ALIGN as bhe,DEFAULT_STROKE_STREAMLINE as xhe,VERTICAL_ALIGN as yhe,randomInteger as whe,randomId as vhe,getFontString as Ihe,getUpdatedTimestamp as The,getLineHeight as She}from"@excalidraw/common";import{pointsOnBezierCurves as gge,simplify as fge}from"points-on-curve";import{curveToBezier as bge}from"points-on-curve/lib/curve-to-bezier";import{distanceToLineSegment as yge,lineSegment as wge,lineSegmentIntersectionPoints as vge,pointDistance as Ige,pointFrom as Tge,pointRotateRads as Sge,polygonArea as Cge,polygonIncludesPoint as Pge,polygonIncludesPointNonZero as kge,polygonSignedArea as Mge}from"@excalidraw/math";import{isOpaqueColor as Dge,isTransparent as Lge}from"@excalidraw/common";var i2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";import{curvePointDistance as oge,distanceToLineSegment as rge,pointRotateRads as ige}from"@excalidraw/math";import{ellipse as sge,ellipseDistanceFromPoint as lge}from"@excalidraw/math/ellipse";import{pointFrom as Kge,pointCenter as Xge,pointRotateRads as Zge,vectorFromPoint as $ge,vectorNormalize as jge,vectorSubtract as qge,vectorAdd as Jge,vectorScale as Qge,pointFromVector as efe,clamp as tfe,isCloseTo as nfe}from"@excalidraw/math";import{arrayToMap as DEe,arrayToObject as LEe,assertNever as _Ee,isDevEnv as REe,isShallowEqual as NEe,isTestEnv as BEe,randomInteger as FEe}from"@excalidraw/common";import{assertNever as Ofe,COLOR_PALETTE as zfe,isDevEnv as Gfe,isTestEnv as Hfe,randomId as Ufe,Emitter as Wfe,toIterable as Vfe}from"@excalidraw/common";import{ORIG_ID as gfe,randomId as ffe,randomInteger as Efe,arrayToMap as bfe,castArray as xfe,findLastIndex as yfe,getUpdatedTimestamp as wfe,isTestEnv as vfe}from"@excalidraw/common";import{arrayToMap as sfe}from"@excalidraw/common";import mN from"lodash.throttle";import{randomInteger as iEe,arrayToMap as aEe,toBrandedType as sEe,isDevEnv as l2,isTestEnv as c2,toArray as lEe}from"@excalidraw/common";import{isNonDeletedElement as dEe}from"@excalidraw/element";import{isFrameLikeElement as pEe}from"@excalidraw/element";import{getElementsInGroup as hEe}from"@excalidraw/element";import{syncInvalidIndices as fEe,syncMovedIndices as EEe,validateFractionalIndices as pN}from"@excalidraw/element";import{getSelectedElements as xEe}from"@excalidraw/element";import{mutateElement as wEe}from"@excalidraw/element";var vEe=mN(e=>{(l2()||c2()||window?.DEBUG_FRACTIONAL_INDICES)&&pN(e,{shouldThrow:l2()||c2(),includeBoundTextValidation:!0})},1e3*60,{leading:!0,trailing:!1});import{TEXT_AUTOWRAP_THRESHOLD as lbe,getGridPoint as cbe,getFontString as dbe,DRAGGING_THRESHOLD as mbe}from"@excalidraw/common";import{clamp as vbe,pointDistance as Ibe,pointFrom as Tbe,pointScaleFromOrigin as Sbe,pointsEqual as Cbe,pointTranslate as Pbe,vector as kbe,vectorCross as Mbe,vectorFromPoint as Abe,vectorScale as Dbe}from"@excalidraw/math";import{BinaryHeap as _be,invariant as Rbe,isAnyTrue as Nbe,getSizeFromPoints as Bbe,isDevEnv as Fbe,arrayToMap as Obe}from"@excalidraw/common";import{ELEMENT_LINK_KEY as Jbe,normalizeLink as Qbe}from"@excalidraw/common";import{FONT_FAMILY as rxe,VERTICAL_ALIGN as ixe,escapeDoubleQuotes as axe,getFontString as sxe}from"@excalidraw/common";import{invariant as fxe,toBrandedType as Exe}from"@excalidraw/common";import{clamp as xxe,pointFrom as yxe}from"@excalidraw/math";import{pointDistance as $xe,pointFrom as jxe}from"@excalidraw/math";import{invariant as Jxe}from"@excalidraw/common";import{arrayToMap as Rxe,findIndex as Nxe,findLastIndex as Bxe}from"@excalidraw/common";import{isFiniteNumber as Oxe}from"@excalidraw/math";import{decodeAnimated as l1e}from"@discourse/gif";var PN="gif.worker.js";var d1e=new URL(PN,import.meta.url).toString();import{DEFAULT_GIF_AUTO_DECODE_MAX_FILE_SIZE_BYTES as f1e,MIME_TYPES as E1e,SVG_NS as b1e}from"@excalidraw/common";import{rgbaToThumbHash as y1e,thumbHashToRGBA as w1e}from"thumbhash";import{pointCenter as G1e,normalizeRadians as H1e,pointFrom as U1e,pointRotateRads as W1e}from"@excalidraw/math";import{MIN_FONT_SIZE as Y1e,SHIFT_LOCKING_ANGLE as K1e,rescalePoints as X1e,getFontString as Z1e}from"@excalidraw/common";import{pointFrom as w0e,pointOnLineSegment as v0e,pointRotateRads as I0e}from"@excalidraw/math";import{SIDE_RESIZING_THRESHOLD as S0e}from"@excalidraw/common";import{DEFAULT_TRANSFORM_HANDLE_SPACING as l0e}from"@excalidraw/common";import{pointFrom as d0e,pointRotateRads as m0e}from"@excalidraw/math";import{KEYS as On}from"@excalidraw/common";var B0e=[{icon:Kc,value:"selection",key:On.V,numericKey:void 0,fillable:!0,myocSimplifiedMode:!0},{icon:Ui,value:"rectangle",key:On.R,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Wi,value:"diamond",key:On.D,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Vi,value:"ellipse",key:On.O,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Xc,value:"arrow",key:On.A,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:jo,value:"line",key:On.L,numericKey:void 0,fillable:!0,myocSimplifiedMode:!1},{icon:Qn,value:"freedraw",key:[On.P,On.X],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Dn,value:"text",key:On.T,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Wr,value:"image",key:[On.I],numericKey:void 0,fillable:!1,myocSimplifiedMode:!0},{icon:Zc,value:"eraser",key:On.E,numericKey:void 0,fillable:!1,myocSimplifiedMode:!0}];import{pointFrom as Z0e}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as j0e,DEFAULT_FONT_SIZE as q0e,TEXT_ALIGN as J0e,VERTICAL_ALIGN as Q0e,getSizeFromPoints as eye,randomId as tye,arrayToMap as nye,assertNever as oye,cloneJSON as rye,getFontString as iye,isDevEnv as aye,toBrandedType as sye,getLineHeight as lye}from"@excalidraw/common";import{getBoundsFromPoints as Dye,getElementAbsoluteCoords as Lye}from"@excalidraw/element/bounds";import{newArrowElement as Rye,newElement as Nye,newLinearElement as Bye}from"@excalidraw/element/newElement";import{ELEMENT_PENDING_DRAW_SHAPE_OPACITY as Oye,getStrokeWidthByKey as zye,ROUNDNESS as Gye}from"@excalidraw/common";import{convexHull as Uye,distanceToLineSegment as Wye,elongation as Vye,kurtosis as Yye,lineSegment as Kye,orientPrincipalAxes as Xye,pointFrom as Zye,polygonArea as $ye,principalAxes as jye,principalCoords as qye,skewness as Jye}from"@excalidraw/math";var nwe=[{type:"rectangle",hullFillRatio:1,cornerTurnShare:.95,kurtosisProduct:1.83},{type:"diamond",hullFillRatio:.5,cornerTurnShare:.95,kurtosisProduct:3.24},{type:"ellipse",hullFillRatio:Math.PI/4,cornerTurnShare:.55,kurtosisProduct:2.25}];var li=e=>!e.isDeleted;var IN=10/1.5;var wm=e=>{let n=Math.floor(e.width/2)+1,t=0,o=e.width,r=Math.floor(e.height/2)+1,i=n,a=e.height;return[n,t,o,r,i,a,0,r]};var LN=20,_N=15,RN=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"cardinality_many":case"cardinality_one_or_many":case"cardinality_zero_or_many":return _N;case"cardinality_one":case"cardinality_exactly_one":case"cardinality_zero_or_one":return LN;default:return 15}},NN=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},Nt=(e,n,t,o,r=0)=>{if(o===null||n.length<1)return null;let i=Ug(n[0]);if(i.length<1)return null;let a=t==="start"?1:i.length-1,s=i[a].data;E2(s.length===6,"Op data length is not 6");let l=vt(s[4],s[5]),c=vt(s[2],s[3]),d=vt(s[0],s[1]),m=i[a-1],p=vt(0,0);if(m.op==="move"){let G=DN(m.data);E2(G!=null,"Op data is not a point"),p=G}else m.op==="bcurveTo"&&(p=vt(m.data[4],m.data[5]));let u=(G,ie)=>Math.pow(1-G,3)*l[ie]+3*G*Math.pow(1-G,2)*c[ie]+3*Math.pow(G,2)*(1-G)*d[ie]+p[ie]*Math.pow(G,3),[E,g]=t==="start"?p:l,[b,v]=[u(.3,0),u(.3,1)],w=Math.hypot(E-b,g-v),x=(E-b)/w,I=(g-v)/w,T=RN(o),C=0;{let[G,ie]=t==="end"?e.points[e.points.length-1]:e.points[0],[me,B]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(G-me,ie-B)}let M=Math.min(T,C*(o==="diamond"||o==="diamond_outline"?.25:.5)),D=E-x*M*r,_=g-I*M*r,k=D-x*M,L=_-I*M;if(o==="circle"||o==="circle_outline"){let G=Math.hypot(L-_,k-D)+e.strokeWidth-2;return[D,_,G]}let F=NN(o);if(o==="cardinality_many"||o==="cardinality_one_or_many"){let[G,ie]=Pa(vt(D,_),vt(k,L),of(-F)),[me,B]=Pa(vt(D,_),vt(k,L),of(F));return[k,L,G,ie,me,B]}let[K,z]=Pa(vt(k,L),vt(D,_),-F*Math.PI/180),[U,W]=Pa(vt(k,L),vt(D,_),of(F));if(o==="diamond"||o==="diamond_outline"){let G,ie;if(t==="start"){let[me,B]=e.points.length>1?e.points[1]:[0,0];[G,ie]=Pa(vt(D+M*2,_),vt(D,_),Math.atan2(B-_,me-D))}else{let[me,B]=e.points.length>1?e.points[e.points.length-2]:[0,0];[G,ie]=Pa(vt(D-M*2,_),vt(D,_),Math.atan2(_-B,D-me))}return[D,_,K,z,G,ie,U,W]}return[D,_,K,z,U,W]};var BN=typeof document<"u"?document.createElement("img"):{src:""};BN.src=`data:${b2.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 FN=typeof document<"u"?document.createElement("img"):{src:""};FN.src=`data:${b2.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 rf=new WeakMap;var Yt=class Yt{};y(Yt,"rg",new YN),y(Yt,"cache",new WeakMap),y(Yt,"get",(n,t)=>{let o=Yt.cache.get(n);if(o&&(t===null||o.theme===t))return o.shape}),y(Yt,"delete",n=>{Yt.cache.delete(n),rf.delete(n)}),y(Yt,"destroy",()=>{Yt.cache=new WeakMap}),y(Yt,"generateElementShape",(n,t)=>{let o=t?.isExporting?void 0:Yt.get(n,t?t.theme:null);if(o!==void 0)return o;rf.delete(n);let r=ZN(n,Yt.rg,t||{isExporting:!1,canvasBackgroundColor:WN.white,embedsValidationStatus:null,theme:lf.LIGHT});return t?.isExporting||Yt.cache.set(n,{shape:r,theme:t?.theme||lf.LIGHT}),r});var Ca=Yt,KN=e=>[8,8+e],I2=e=>[1.5,6+e];function XN(e){let n=e.roughness,t=Math.max(e.width,e.height),o=Math.min(e.width,e.height);return o>=20&&t>=50||o>=15&&e.roundness&&i2(e.type)||un(e)&&t>=50?n:Math.min(n/(t<10?3:2),2.5)}var Lo=(e,n=!1,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?KN(e.strokeWidth):e.strokeStyle==="dotted"?I2(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:XN(e),stroke:Rl(e.strokeColor,t),preserveVertices:n||e.roughness<HN.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=_l(e.backgroundColor)?void 0:Rl(e.backgroundColor,t),e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return Ia(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:Rl(e.backgroundColor,t)),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},y2=(e,n,t)=>Vg(e)&&(n||Kv(e)&&t?.get(e.id)!==!0)&&_l(e.backgroundColor)&&_l(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:Wg(e)?{...e,strokeColor:_l(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:_l(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Ll=(e,n,t)=>{if(n===null)return[];let[,,o,r,i,a]=n;return[e.line(o,r,i,a,t)]},Dm=(e,n,t)=>{if(n===null)return[];let[o,r,i,a,s,l]=n;return[e.line(i,a,o,r,t),e.line(s,l,o,r,t)]},di=(e,n)=>{let t={...n};if(e.strokeStyle==="dotted"){let o=I2(e.strokeWidth-1);t.strokeLineDash=[o[0],o[1]-1]}else delete t.strokeLineDash;return t.roughness=Math.min(1,t.roughness||0),t},af=(e,n,t,o,r,i=1)=>{if(o===null)return[];let[a,s,l]=o,c={...n,fill:r,fillStyle:"solid",stroke:t,roughness:Math.min(.5,n.roughness||0)};return delete c.strokeLineDash,[e.circle(a,s,l*i,c)]},w2=(e,n,t,o,r,i,a,s)=>{if(o===null)return[];let l=Rl(e.strokeColor,s),c=Rl(a,s),d=-.25,m=.8;switch(o){case"circle":case"circle_outline":return af(r,i,l,Nt(e,n,t,o),o==="circle_outline"?c:l);case"triangle":case"triangle_outline":{let p=Nt(e,n,t,o);if(p===null)return[];let[u,E,g,b,v,w]=p,x={...i,fill:o==="triangle_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete x.strokeLineDash,[r.polygon([[u,E],[g,b],[v,w],[u,E]],x)]}case"diamond":case"diamond_outline":{let p=Nt(e,n,t,o);if(p===null)return[];let[u,E,g,b,v,w,x,I]=p,T={...i,fill:o==="diamond_outline"?c:l,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)};return delete T.strokeLineDash,[r.polygon([[u,E],[g,b],[v,w],[x,I],[u,E]],T)]}case"cardinality_one":return Ll(r,Nt(e,n,t,o),di(e,i));case"cardinality_many":return Dm(r,Nt(e,n,t,o),di(e,i));case"cardinality_one_or_many":{let p=di(e,i);return[...Dm(r,Nt(e,n,t,"cardinality_many"),p),...Ll(r,Nt(e,n,t,"cardinality_one",d),p)]}case"cardinality_exactly_one":{let p=di(e,i);return[...Ll(r,Nt(e,n,t,"cardinality_one",-.5),p),...Ll(r,Nt(e,n,t,"cardinality_one"),p)]}case"cardinality_zero_or_one":{let p=di(e,i);return[...af(r,i,l,Nt(e,n,t,"circle_outline",1.5),c,m),...Ll(r,Nt(e,n,t,"cardinality_one",-.5),p)]}case"cardinality_zero_or_many":{let p=di(e,i);return[...Dm(r,Nt(e,n,t,"cardinality_many"),p),...af(r,i,l,Nt(e,n,t,"circle_outline",1.5),c,m)]}case"bar":case"arrow":default:return Dm(r,Nt(e,n,t,o),di(e,i))}};var ZN=(e,n,{isExporting:t,canvasBackgroundColor:o,embedsValidationStatus:r,theme:i})=>{let a=i===lf.DARK;switch(e.type){case"rectangle":case"iframe":case"embeddable":{let s;if(e.roundness){let l=e.width,c=e.height,d=wl(Math.min(l,c),e);s=n.path(`M ${d} 0 L ${l-d} 0 Q ${l} 0, ${l} ${d} L ${l} ${c-d} Q ${l} ${c}, ${l-d} ${c} L ${d} ${c} Q 0 ${c}, 0 ${c-d} L 0 ${d} Q 0 0, ${d} 0`,Lo(y2(e,t,r),!0,a))}else s=n.rectangle(0,0,e.width,e.height,Lo(y2(e,t,r),!1,a));return s}case"diamond":{let s,[l,c,d,m,p,u,E,g]=wm(e);if(e.roundness){let b=wl(Math.abs(l-E),e),v=wl(Math.abs(m-c),e);s=n.path(`M ${l+b} ${c+v} L ${d-b} ${m-v}
5
5
  C ${d} ${m}, ${d} ${m}, ${d-b} ${m+v}
6
6
  L ${p+b} ${u-v}
7
7
  C ${p} ${u}, ${p} ${u}, ${p-b} ${u-v}
8
8
  L ${E+b} ${g+v}
9
9
  C ${E} ${g}, ${E} ${g}, ${E+b} ${g-v}
10
10
  L ${l-b} ${c+v}
11
- C ${l} ${c}, ${l} ${c}, ${l+b} ${c+v}`,Lo(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],Lo(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,Lo(e,!1,a));case"line":case"arrow":{let s,l=Lo(e,!1,a),c=e.points.length?e.points:[FN(0,0)];if(Bn(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path(KN(c,16),Lo(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),s=[]):e.roundness?s=[n.curve(c,l)]:l.fill?s=[n.polygon(c,l)]:s=[n.linearPath(c,l)],e.type==="arrow"){let{startArrowhead:d=null,endArrowhead:m="arrow"}=e;if(d!==null){let p=y2(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=y2(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(Ia(e.points)){let l=NN(e.points,.75);s.push(n.curve(l,{...Lo(e,!1,a),stroke:"none"}))}return s.push(XN(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return zN(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},KN=(e,n)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],s=e[r],l=km(s,i),c=km(a,s),d=Math.min(n,b2(e[r],a)/2,b2(e[r],i)/2);l?i[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):i[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d]),t.push(e[r]),c?a[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):a[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)o.push(`L ${t[r][0]} ${t[r][1]}`),o.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")};var XN=e=>e8(JN(e)),af={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},ZN={SIZE_FACTOR:1.4},I2=e=>e.strokeOptions?.streamline??HN,$N=e=>{let n=e.simulatePressure?e.points:e.points.length?e.points.map(([t,o],r)=>[t,o,e.pressures[r]]):[[0,0,.5]];return BN(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*af.SIZE_FACTOR,thinning:af.THINNING,smoothing:af.SMOOTHING,streamline:I2(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},jN=e=>new va({size:e.strokeWidth*ZN.SIZE_FACTOR,streamline:I2(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),qN=e=>{let n=jN(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},JN=e=>e.strokeOptions?.variability==="constant"?qN(e):$N(e);var w2=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],QN=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,e8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,w2(o,i[0]),"L",i[0],"Z"):t.push(o,w2(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(QN,"$1")};var si=(e,n,t=!1)=>{let o=!1;for(let r in n){let i=n[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;o=!0}}return!o&&!t?e:{...e,...n,version:n.version??e.version+1,versionNonce:n.versionNonce??t8(),updated:n8()}};import{jsx as C2}from"react/jsx-runtime";var Ma=O({name:"toggleLinearEditor",label:(e,n,t)=>t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.selectedLinearElement?.isEditing&&r.length===1&&r8(r[0])&&!o8(r[0]))},perform(e,n,t,o){T2(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);T2(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:S2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!o)return null;let r=f(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return C2($,{type:"button",icon:x0,title:r,"aria-label":r,onClick:()=>n(null)})}}),ASe=O({name:"togglePolygon",icon:Ou,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!ka(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds});return r.length>0&&r.every(i=>ka(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!ka(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=i8(i);return{elements:e.map(l=>!s.has(l.id)||!ka(l)?l:si(l,{backgroundColor:a?l.backgroundColor:"transparent",...a8(l,a)})),appState:n,captureUpdate:S2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!ka(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>ka(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return C2($,{type:"toggle",icon:Ou,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as P2,CANVAS_SEARCH_TAB as k2,CLASSES as s8,DEFAULT_SIDEBAR as M2}from"@excalidraw/common";import{CaptureUpdateAction as l8}from"@excalidraw/element";var Nl=O({name:"searchMenu",icon:oo,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,n,t,o){if(n.openDialog)return!1;if(n.openSidebar?.name===M2.name&&n.openSidebar.tab===k2){let r=o.excalidrawContainerValue.container?.querySelector(`.${s8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:M2.name,tab:k2},openDialog:null},captureUpdate:l8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[P2.CTRL_OR_CMD]&&e.key===P2.F});import{isImageElement as c8}from"@excalidraw/element";import{CaptureUpdateAction as d8}from"@excalidraw/element";import{jsx as m8}from"react/jsx-runtime";var lf=O({name:"cropEditor",label:"helpDialog.cropStart",icon:lh,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,n,t,o){let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...n,isCropping:!1,croppingElementId:r.id},captureUpdate:d8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&c8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return m8($,{type:"button",icon:lh,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as p8}from"@excalidraw/element";import{mutateElement as u8}from"@excalidraw/element";import{newFrameElement as h8}from"@excalidraw/element";import{isFrameLikeElement as Lm}from"@excalidraw/element";import{addElementsToFrame as g8,removeAllElementsFromFrame as f8}from"@excalidraw/element";import{getFrameChildren as E8}from"@excalidraw/element";import{getElementsInGroup as b8}from"@excalidraw/element";import{getCommonBounds as x8}from"@excalidraw/element";import{CaptureUpdateAction as Aa}from"@excalidraw/element";var A2=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&Lm(t[0])},D2=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(Lm(r)){let i=E8(p8(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...n,selectedElementIds:i.reduce((a,s)=>(a[s.id]=!0,a),{})},captureUpdate:Aa.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:Aa.EVENTUALLY}},predicate:(e,n,t,o)=>A2(n,o)}),L2=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return Lm(r)?{elements:f8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:Aa.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:Aa.EVENTUALLY}},predicate:(e,n,t,o)=>A2(n,o)}),GCe=O({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>({elements:e,appState:{...n,frameRendering:{...n.frameRendering,enabled:!n.frameRendering.enabled}},captureUpdate:Aa.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),_2=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=de(e,n);return r.length>0&&!r.some(i=>Lm(i))},perform:(e,n,t,o)=>{let r=de(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=x8(r,i),d=16,m=h8({x:a-d,y:s-d,width:l-a+d*2,height:c-s+d*2});if(n.editingGroupId){let u=b8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);u8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:g8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:Aa.IMMEDIATELY}}});import{KEYS as La,matchKey as mf,arrayToMap as R2,MOBILE_ACTION_BUTTON_BG as N2}from"@excalidraw/common";import{CaptureUpdateAction as df}from"@excalidraw/element";import{orderByFractionalIndex as C8}from"@excalidraw/element";import{Emitter as y8}from"@excalidraw/common";import{CaptureUpdateAction as w8,StoreChange as v8,StoreDelta as I8}from"@excalidraw/element";var Da=class extends I8{applyTo(n,t,o){let[r,i]=this.elements.applyTo(n,o.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,s]=this.appState.applyTo(t,r);return[r,a,i||s]}static calculate(n,t){return super.calculate(n,t)}static inverse(n){return super.inverse(n)}static applyLatestChanges(n,t,o,r){return super.applyLatestChanges(n,t,o,r)}},ci=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},Bl=class e{constructor(n){this.store=n;w(this,"onHistoryChangedEmitter",new y8);w(this,"undoStack",[]);w(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(n){if(n.isEmpty()||n instanceof Da)return;let t=Da.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new ci(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(n,t){return this.perform(n,t,()=>e.pop(this.undoStack),o=>e.push(this.redoStack,o))}redo(n,t){return this.perform(n,t,()=>e.pop(this.redoStack),o=>e.push(this.undoStack,o))}perform(n,t,o,r){try{let i=o();if(i===null)return;let a=w8.IMMEDIATELY,s=this.store.snapshot,l=n,c=t,d=!1;for(;i;){try{[l,c,d]=i.applyTo(l,c,s);let m=s.elements,p=s.maybeClone(a,l,c),u=v8.create(s,p),E=Da.applyLatestChanges(i,m,l);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),s=p}finally{r(i)}if(d)break;i=o()}return[l,c]}finally{this.onHistoryChangedEmitter.trigger(new ci(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(n){if(!n.length)return null;let t=n.pop();return t!==void 0?t:null}static push(n,t){let o=Da.inverse(t);return n.push(o)}};import{useEffect as T8,useState as S8}from"react";var cf=(e,n)=>{let[t,o]=S8(n);return T8(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as z2}from"react/jsx-runtime";var B2=(e,n,t)=>{if(!n.multiElement&&!n.resizingElement&&!n.editingTextElement&&!n.newElement&&!n.selectedElementsAreBeingDragged&&!n.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let o=t();if(!o)return{captureUpdate:df.EVENTUALLY};let[r,i]=o,a=C8(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:df.NEVER}}return{captureUpdate:df.EVENTUALLY}},F2=e=>({name:"undo",label:"buttons.undo",icon:Uu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>B2(r,t,()=>e.undo(R2(n),t)),keyTest:n=>n[La.CTRL_OR_CMD]&&mf(n,La.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=cf(e.onHistoryChangedEmitter,new ci(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=mt()==="mobile";return z2($,{type:"button",icon:Uu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?N2:{}}})}}),O2=e=>({name:"redo",label:"buttons.redo",icon:Wu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>B2(r,t,()=>e.redo(R2(n),t)),keyTest:n=>n[La.CTRL_OR_CMD]&&n.shiftKey&&mf(n,La.Z)||n[La.CTRL_OR_CMD]&&!n.shiftKey&&mf(n,La.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=cf(e.onHistoryChangedEmitter,new ci(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=mt()==="mobile";return z2($,{type:"button",icon:Wu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?N2:{}}})}});import{getFontString as P8}from"@excalidraw/common";import{getTextAnchorRatios as k8,isExcalidrawElement as M8,isNonDeletedElement as A8,newElementWith as D8,updateBoundElements as L8}from"@excalidraw/element";import{measureText as _8}from"@excalidraw/element";import{isTextElement as pf}from"@excalidraw/element";import{CaptureUpdateAction as R8}from"@excalidraw/element";var uf=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=de(e,n);return o.length===1&&pf(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=de(e,n),i=M8(t)&&pf(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!pf(a))return!1;let s=_8(a.originalText,P8(a),a.lineHeight),l=k8(a),c=D8(a,{autoResize:!0,width:s.width,height:s.height,x:a.x+(a.width-s.width)*l.x,y:a.y+(a.height-s.height)*l.y,text:a.originalText});return A8(c)&&L8(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:R8.IMMEDIATELY}}});import{CODES as N8,KEYS as B8}from"@excalidraw/common";import F8 from"clsx";import{CaptureUpdateAction as O8}from"@excalidraw/element";import{jsx as z8}from"react/jsx-runtime";var _a=O({name:"viewMode",label:"labels.viewMode",icon:Yr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:O8.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[B8.CTRL_OR_CMD]&&e.altKey&&!e.shiftKey&&e.code===N8.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>{if(t.viewModeOnly||o.viewModeOnly)return null;let r=t.viewModeEnabled?"Edit mode":f("labels.viewMode");return z8($,{type:"button",icon:t.viewModeEnabled?ph:Yr,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:F8({enabled:t.viewModeEnabled})})}});import{isPromiseLike as G8}from"@excalidraw/common";import{jsx as H8}from"react/jsx-runtime";var hf=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&Ue(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},_m=class{constructor(n,t,o,r){w(this,"actions",{});w(this,"updater");w(this,"getAppState");w(this,"getElementsIncludingDeleted");w(this,"app");w(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);w(this,"renderAction",(n,t)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[n]&&"PanelComponent"in this.actions[n]&&(!(n in o)||o[n])){let r=this.actions[n],i=r.PanelComponent;i.displayName="PanelComponent";let a=s=>{this.isActionBlockedByViewportTransition(r)||(hf(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return H8(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});w(this,"isActionEnabled",n=>{let t=this.getElementsIncludingDeleted(),o=this.getAppState();return!n.predicate||n.predicate(t,o,this.app.props,this.app)});this.updater=i=>{if(G8(i))i.then(a=>n(a));else return n(i)},this.getAppState=t,this.getElementsIncludingDeleted=o,this.app=r}registerAction(n){this.actions[n.name]=n}registerAll(n){n.forEach(t=>this.registerAction(t))}handleKeyDown(n){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let t=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in t?t[l.name]:!0)&&l.keyTest&&l.keyTest(n,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let r=o[0];if(!this.app.isInteractionEnabled()&&r.navigation!==!0||this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(r))return n.preventDefault(),n.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),s=null;return hf(r,"keyboard",a,i,this.app,null),n.preventDefault(),n.stopPropagation(),this.updater(o[0].perform(i,a,s,this.app)),!0}executeAction(n,t="api",o=null){if(t!=="api"&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&n.navigation===!0)||this.isActionBlockedByViewportTransition(n))return;let r=this.getElementsIncludingDeleted(),i=this.getAppState();hf(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var gf=e=>{let n=Array.from(e.values());return{x:G2(n,t=>t.x)/n.length,y:G2(n,t=>t.y)/n.length}},ff=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),G2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as X,pointRotateRads as Er,rangeInclusive as hn,rangeIntersection as Rm,rangesOverlap as Nm}from"@excalidraw/math";import{TOOL_TYPE as di,KEYS as H2}from"@excalidraw/common";import{getCommonBounds as Ef,getDraggedElementsBounds as bf,getElementAbsoluteCoords as U8}from"@excalidraw/element";import{isBoundToContainer as Y2}from"@excalidraw/element";import{getMaximumGroups as K2}from"@excalidraw/element";import{getSelectedElements as W8,getVisibleAndNonSelectedElements as X2}from"@excalidraw/element";var V8=8,U2=99999,Bm=e=>V8/e,Bt=class Bt{};w(Bt,"referenceSnapPoints",null),w(Bt,"visibleGaps",null),w(Bt,"setReferenceSnapPoints",n=>{Bt.referenceSnapPoints=n}),w(Bt,"getReferenceSnapPoints",()=>Bt.referenceSnapPoints),w(Bt,"setVisibleGaps",n=>{Bt.visibleGaps=n}),w(Bt,"getVisibleGaps",()=>Bt.visibleGaps),w(Bt,"destroy",()=>{Bt.referenceSnapPoints=null,Bt.visibleGaps=null});var gn=Bt,br=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,_o=({event:e,app:n,selectedElements:t})=>{if(e){let o=n.state.activeTool.type==="lasso"&&n.state.selectedElementsAreBeingDragged;return(n.state.activeTool.type!=="lasso"||o)&&(n.state.objectsSnapModeEnabled&&!e[H2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[H2.CTRL_OR_CMD]&&!br(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},Y8=(e,n,t=.01)=>Math.abs(e-n)<=t,Fl=(e,n,{omitCenter:t,boundingBoxCorners:o,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,c,d,m,p]=U8(a,n);r&&(s+=r.x,c+=r.x,m+=r.x,l+=r.y,d+=r.y,p+=r.y);let u=(c-s)/2,E=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=Er(X(s,l+E),X(m,p),a.angle),b=Er(X(s+u,l),X(m,p),a.angle),v=Er(X(c,l+E),X(m,p),a.angle),y=Er(X(s+u,d),X(m,p),a.angle),x=X(m,p);i=t?[g,b,v,y]:[g,b,v,y,x]}else{let g=Er(X(s,l),X(m,p),a.angle),b=Er(X(c,l),X(m,p),a.angle),v=Er(X(s,d),X(m,p),a.angle),y=Er(X(c,d),X(m,p),a.angle),x=X(m,p);i=t?[g,b,v,y]:[g,b,v,y,x]}}else if(e.length>1){let[a,s,l,c]=bf(e,r??{x:0,y:0}),d=l-a,m=c-s,p=X(a,s),u=X(l,s),E=X(a,c),g=X(l,c),b=X(a+d/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>X(je(a[0]),je(a[1])))},Z2=(e,n,t,o)=>X2(e,n,t,o),$2=(e,n,t,o)=>{let r=Z2(e,n,t,o),i=K2(r,o).filter(m=>!(m.length===1&&Y2(m[0]))).map(m=>Ef(m).map(p=>je(p))),a=i.sort((m,p)=>m[0]-p[0]),s=[],l=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++l>U2)break e;let E=a[u],[,g,b,v]=p,[y,x,,I]=E;b<y&&Nm(hn(g,v),hn(x,I))&&s.push({startBounds:p,endBounds:E,startSide:[X(b,g),X(b,v)],endSide:[X(y,x),X(y,I)],length:y-b,overlap:Rm(hn(g,v),hn(x,I))})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];l=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++l>U2)break e;let E=c[u],[g,,b,v]=p,[y,x,I]=E;v<x&&Nm(hn(g,b),hn(y,I))&&d.push({startBounds:p,endBounds:E,startSide:[X(g,v),X(b,v)],endSide:[X(y,x),X(I,x)],length:x-v,overlap:Rm(hn(g,b),hn(y,I))})}}return{horizontalGaps:s,verticalGaps:d}},W2=(e,n,t,o,r,i,a)=>{if(!_o({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=gn.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=bf(e,n).map(b=>je(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!Nm(hn(m,u),b.overlap))continue;let v=b.startSide[0][0]+b.length/2,y=je(v-E);if(b.length>p-d&&Math.abs(y)<=a.x){Math.abs(y)<a.x&&(r.length=0),a.x=Math.abs(y);let _={type:"gap",direction:"center_horizontal",gap:b,offset:y};r.push(_);continue}let[,,I]=b.endBounds,T=d-I,C=je(b.length-T);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(r.length=0),a.x=Math.abs(C);let _={type:"gap",direction:"side_right",gap:b,offset:C};r.push(_);continue}let[P,,,]=b.startBounds,M=P-p,D=je(M-b.length);if(Math.abs(D)<=a.x){Math.abs(D)<a.x&&(r.length=0),a.x=Math.abs(D);let _={type:"gap",direction:"side_left",gap:b,offset:D};r.push(_);continue}}for(let b of c){if(!Nm(hn(d,p),b.overlap))continue;let v=b.startSide[0][1]+b.length/2,y=je(v-g);if(b.length>u-m&&Math.abs(y)<=a.y){Math.abs(y)<a.y&&(i.length=0),a.y=Math.abs(y);let _={type:"gap",direction:"center_vertical",gap:b,offset:y};i.push(_);continue}let[,I,,]=b.startBounds,T=I-u,C=je(T-b.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let _={type:"gap",direction:"side_top",gap:b,offset:C};i.push(_);continue}let[,,,P]=b.endBounds,M=je(m-P),D=b.length-M;if(Math.abs(D)<=a.y){Math.abs(D)<a.y&&(i.length=0),a.y=Math.abs(D);let _={type:"gap",direction:"side_bottom",gap:b,offset:D};i.push(_);continue}}}},j2=(e,n,t,o)=>{let r=Z2(e,n,t,o);return K2(r,o).filter(i=>!(i.length===1&&Y2(i[0]))).flatMap(i=>Fl(i,o))},Ra=(e,n,t,o,r,i,a)=>{if(!_o({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=gn.getReferenceSnapPoints();if(s)for(let l of n)for(let c of s){let d=c[0]-l[0],m=c[1]-l[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(r.length=0),r.push({type:"point",points:[l,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[l,c],offset:m}),a.y=Math.abs(m))}},q2=(e,n,t,o,r)=>{let i=t.state,a=W8(e,i);if(!_o({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=je(n.x),n.y=je(n.y);let s=[],l=[],c=Bm(i.zoom.value),d={x:c,y:c},m=Fl(a,r,{dragOffset:n});Ra(a,m,t,o,s,l,d),W2(a,n,t,o,s,l,d);let p={x:s[0]?.offset??0,y:l[0]?.offset??0};d.x=0,d.y=0,s.length=0,l.length=0;let u={x:je(n.x+p.x),y:je(n.y+p.y)};Ra(a,Fl(a,r,{dragOffset:u}),t,o,s,l,d),W2(a,u,t,o,s,l,d);let E=xf(s,l),g=X8(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},je=e=>Math.round(e*10**6)/10**6,V2=e=>{let n=new Map;for(let t of e){let o=t.join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},xf=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=je(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>X(je(a[0]),je(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=je(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>X(je(a[0]),je(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:V2(i.map(a=>X(Number(r),a[1])).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:V2(i.map(a=>X(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},K8=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[je(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},X8=(e,n,t)=>{let[o,r,i,a]=bf(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,v=Rm(hn(r,a),l.gap.overlap),y=Rm(hn(o,i),l.gap.overlap);switch(l.direction){case"center_horizontal":{if(v){let x=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[X(l.gap.startSide[0][0],x),X(o,x)]},{type:"gap",direction:"horizontal",points:[X(i,x),X(l.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[X(x,l.gap.startSide[0][1]),X(x,r)]},{type:"gap",direction:"vertical",points:[X(x,a),X(x,l.gap.endSide[0][1])]})}break}case"side_right":{if(v){let x=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[X(m,x),X(u,x)]},{type:"gap",direction:"horizontal",points:[X(g,x),X(o,x)]})}break}case"side_left":{if(v){let x=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[X(i,x),X(c,x)]},{type:"gap",direction:"horizontal",points:[X(m,x),X(u,x)]})}break}case"side_top":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[X(x,a),X(x,d)]},{type:"gap",direction:"vertical",points:[X(x,p),X(x,E)]})}break}case"side_bottom":{if(y){let x=(y[0]+y[1])/2;s.push({type:"gap",direction:"vertical",points:[X(x,p),X(x,E)]},{type:"gap",direction:"vertical",points:[X(x,b),X(x,r)]})}break}}}return K8(s.map(l=>({...l,points:l.points.map(c=>X(je(c[0]),je(c[1])))})))},yf=(e,n,t,o,r,i)=>{if(!_o({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!Y8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=Ef(n);i&&(i.includes("e")?l+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?s+=r.y:i.includes("s")&&(c+=r.y));let d=[];if(i)switch(i){case"e":{d.push(X(l,s),X(l,c));break}case"w":{d.push(X(a,s),X(a,c));break}case"n":{d.push(X(a,s),X(l,s));break}case"s":{d.push(X(a,c),X(l,c));break}case"ne":{d.push(X(l,s));break}case"nw":{d.push(X(a,s));break}case"se":{d.push(X(l,c));break}case"sw":{d.push(X(a,c));break}}let m=Bm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];Ra(n,d,t,o,u,E,p);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};p.x=0,p.y=0,u.length=0,E.length=0;let[b,v,y,x]=Ef(e).map(C=>je(C)),I=[X(b,v),X(b,x),X(y,v),X(y,x)];Ra(e,I,t,o,u,E,p);let T=xf(u,E);return{snapOffset:g,snapLines:T}},J2=(e,n,t,o,r,i)=>{if(!_o({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[X(o.x+r.x,o.y+r.y)],s=Bm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];Ra([e],a,n,t,c,d,l);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let p=Fl([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ra([e],p,n,t,c,d,l);let u=xf(c,d);return{snapOffset:m,snapLines:u}},Q2=(e,n,t,o,r)=>{if(!_o({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=X2(e,[],n.state,r),a=Bm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=Fl([d],r);for(let p of m){let u=p[0]-t.x;Math.abs(u)<=Math.abs(s.x)&&(Math.abs(u)<Math.abs(s.x)&&(c.length=0),c.push({type:"pointer",points:[p,X(p[0],t.y)],direction:"vertical"}),s.x=u);let E=p[1]-t.y;Math.abs(E)<=Math.abs(s.y)&&(Math.abs(E)<Math.abs(s.y)&&(l.length=0),l.push({type:"pointer",points:[p,X(t.x,p[1])],direction:"horizontal"}),s.y=E)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:l.length>0?l[0].points[0][1]-t.y:0},snapLines:[...c,...l]}},eI=e=>e===di.rectangle||e===di.ellipse||e===di.diamond||e===di.frame||e===di.magicframe||e===di.image||e===di.text;import{getCommonFrameId as Z8,getFrameChildrenInsertionIndex as $8,isElementInViewport as j8}from"@excalidraw/element";import{arrayToMap as q8,memoize as J8,toBrandedType as Q8}from"@excalidraw/common";var Ol=class{constructor(n){w(this,"scene");w(this,"_getRenderableElements",J8(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l,editingTextElement:c,newElement:d})=>{let m=this.scene.getNonDeletedElements(),{elementsMap:p,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:m,editingTextElement:c,newElement:d}),E=this.getVisibleCanvasElements({elementsMap:p,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l});return{elementsMap:p,visibleElements:E,newElementCanvasElement:u,canvasNonce:n}}));w(this,"getRenderableElements",n=>{let{newElement:t}=n,o=`${this.scene.getSceneNonce()}${t?.frameId?`:${t.versionNonce}`:""}`,r=this._getRenderableElements({canvasNonce:o,zoom:n.zoom,offsetLeft:n.offsetLeft,offsetTop:n.offsetTop,scrollX:n.scrollX,scrollY:n.scrollY,height:n.height,width:n.width,editingTextElement:n.editingTextElement,newElement:n.newElement});if(n.frameToHighlight&&n.selectedElementsAreBeingDragged&&Z8(n.selectedElements)!==n.frameToHighlight.id){let i=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:r.visibleElements,selectedElements:n.selectedElements,frameToHighlight:n.frameToHighlight});return{...r,visibleElements:i}}return r});this.scene=n}getVisibleCanvasElements({elementsMap:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l}){let c=[];for(let d of n.values())j8(d,l,s,{zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a},n)&&c.push(d);return c}getRenderableElementsMap({elements:n,editingTextElement:t,newElement:o}){let r=Q8(new Map),i=o?.frameId?null:o;for(let a of n)i?.id!==a.id&&(!t||t.type!=="text"||a.id!==t.id)&&r.set(a.id,a);return{elementsMap:r,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:n,selectedElements:t,frameToHighlight:o}){if(!t.length)return n;let r=q8(t),i=n.filter(s=>!r.has(s.id)),a=$8(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){Ix.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as r7,easeOut as oI}from"@excalidraw/common";import{SVG_NS as nI,getSvgPathFromStroke as n7,sceneCoordsToViewportCoords as o7}from"@excalidraw/common";import{version as e7}from"react";import{unstable_batchedUpdates as tI}from"react-dom";import{throttleRAF as t7}from"@excalidraw/common";var qe=e=>n=>{tI(e,n)},Fm=e=>t7(n=>{tI(e,n)}),Na=(()=>{let e;try{let t=e7.split(".");e=Number(t[0])>17}catch{e=!1}let n=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(n||(n=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var he=class he{static start(n,t){if(he.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};he.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw he.animations.get(n)===o&&(he.animations.delete(n),he.cancelScheduledFrameIfIdle()),i}if(he.animations.get(n)===o){if(!r){he.animations.delete(n),he.cancelScheduledFrameIfIdle();return}o.state=r,he.scheduleNextFrame()}}static scheduleNextFrame(){he.scheduledFrame||(Na()?he.scheduledFrame={id:requestAnimationFrame(he.tick),type:"raf"}:he.scheduledFrame={id:setTimeout(he.tick,0),type:"timeout"})}static cancelScheduledFrame(){he.scheduledFrame&&(he.scheduledFrame.type==="raf"?cancelAnimationFrame(he.scheduledFrame.id):clearTimeout(he.scheduledFrame.id),he.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return he.animations.size>0?!1:(he.cancelScheduledFrame(),!0)}static tick(){if(he.scheduledFrame=null,he.animations.size>0){let n=[...he.animations];for(let[t,o]of n){if(he.animations.get(t)!==o)continue;let r=performance.now(),i=o.lastTime===0?0:r-o.lastTime,a=o.animation({deltaTime:i,state:o.state});if(he.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(he.animations.delete(t),he.cancelScheduledFrameIfIdle())return}}if(he.cancelScheduledFrameIfIdle())return;he.scheduleNextFrame()}}static running(n){return he.animations.has(n)}static cancel(n){he.animations.delete(n),he.cancelScheduledFrameIfIdle()}static reset(){he.animations.clear(),he.cancelScheduledFrame()}};w(he,"scheduledFrame",null),w(he,"animations",new Map);var ct=he;var Om=class Om{constructor(n,t){this.app=n;this.options=t;w(this,"currentTrail");w(this,"pastTrails",[]);w(this,"container");w(this,"trailElement");w(this,"trailAnimation");w(this,"key");this.key=`animated-trail-${Om.counter++}`,this.trailElement=document.createElementNS(nI,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(nI,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(n,t){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===n&&this.currentTrail.originalPoints[o-1][1]===t}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(n){n&&(this.container=n),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),ct.running(this.key)||ct.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){ct.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new va(this.options),this.currentTrail.addPoint([n,t,performance.now()]),this.update()}addPointToPath(n,t){this.currentTrail&&(this.currentTrail.addPoint([n,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let n=[];for(let o of this.pastTrails)n.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);n.push(o)}if(this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline(o.options.size/this.app.state.zoom.value).length!==0),n.length===0)return this.trailElement.setAttribute("d",""),!1;let t=n.join(" ").trim();return this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),!0}drawTrail(n,t){let o=n.getStrokeOutline(n.options.size/t.zoom.value).map(([i,a])=>{let s=o7({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return n7(r,!0)}};w(Om,"counter",0);var zn=Om;var zm=class{constructor(n){this.app=n;w(this,"localTrail");w(this,"collabTrails",new Map);w(this,"container");this.localTrail=new zn(n,{...this.getTrailOptions(),fill:()=>r7})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:n=>{let r=Math.max(0,1-(performance.now()-n.pressure)/1e3),i=(50-Math.min(50,n.totalLength-n.currentIndex))/50;return Math.min(oI(i),oI(r))}}}startPath(n,t){this.localTrail.startPath(n,t)}addPointToPath(n,t){this.localTrail.addPointToPath(n,t)}endPath(){this.localTrail.endPath()}start(n){this.container=n,this.localTrail.start(n)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(n){for(let[t,o]of this.collabTrails)n?.get(t)||(o.stop(),this.collabTrails.delete(t))}updateCollabTrails(n){if(this.stopCollabTrails(n),!(!this.container||n.size===0))for(let[t,o]of n.entries()){if(o.isCurrentUser)continue;let r=this.collabTrails.get(t);if(r||(r=new zn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||ti(t,o)}),r.start(this.container),this.collabTrails.set(t,r)),o.pointer&&o.pointer.tool==="laser"){let i=o.button==="down",a=o.button==="up",s=r.hasCurrentTrail;i&&!s&&r.startPath(o.pointer.x,o.pointer.y);let l=!r.hasLastPoint(o.pointer.x,o.pointer.y);i&&l&&r.addPointToPath(o.pointer.x,o.pointer.y),a&&s&&(r.addPointToPath(o.pointer.x,o.pointer.y),r.endPath())}}}};import{DEFAULT_TRANSFORM_HANDLE_SPACING as i7}from"@excalidraw/common";import{pointFrom as zl,pointRotateRads as Gm}from"@excalidraw/math";var a7=12,wf=16,s7=10,l7=wf+2,c7=.8,vf=e=>i7*2/e,If=(e,n,t)=>{let o=vf(n);if(t!=="desktop"||wf>(e.height+o*2)*n*c7)return null;let r=a7/n,i=wf/n,a=zl(e.x+e.width/2,e.y+e.height/2),s=Gm(zl(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:Gm(zl(s[0],s[1]-i/2),s,e.angle),end:Gm(zl(s[0],s[1]+i/2),s,e.angle),hitboxWidth:s7/n,hitboxHeight:l7/n}},rI=(e,n,t,o)=>{let r=If(n,t,o);if(!r)return!1;let i=Gm(zl(e.x,e.y),r.center,-n.angle);return Math.abs(i[0]-r.center[0])<=r.hitboxWidth/2&&Math.abs(i[1]-r.center[1])<=r.hitboxHeight/2};import{CODES as Tf,KEYS as Gl,CLASSES as Sf,POINTER_BUTTON as d7,THEME as m7,isWritableElement as p7,getFontString as iI,getFontFamilyString as aI,isTestEnv as sI,MIME_TYPES as Cf,applyDarkModeFilter as u7,isRTL as h7,getViewpointFlipSign as lI}from"@excalidraw/common";import{pointFrom as cI,pointRotateRads as g7}from"@excalidraw/math";import{getTextFromElements as f7,originalContainerCache as E7,updateBoundElements as dI,updateOriginalContainerCache as mI}from"@excalidraw/element";import{LinearElementEditor as b7}from"@excalidraw/element/linearElementEditor";import{bumpVersion as x7}from"@excalidraw/element";import{getBoundTextElementId as y7,getContainerElement as Pf,getTextElementAngle as w7,redrawTextBoundingBox as v7,getBoundTextMaxHeight as I7,getBoundTextMaxWidth as pI,computeContainerDimensionForBoundText as uI,computeBoundTextPosition as T7,getBoundTextElement as S7}from"@excalidraw/element";import{getTextWidth as C7}from"@excalidraw/element";import{getLineHeightInPx as P7}from"@excalidraw/element";import{getLineWidth as k7}from"@excalidraw/element";import{normalizeText as hI}from"@excalidraw/element";import{wrapText as M7}from"@excalidraw/element";import{getWrappedTextLines as A7}from"@excalidraw/element";import{isArrowElement as Hm,isBoundToContainer as D7,isTextElement as gI}from"@excalidraw/element";var L7=(e,n,t,o,r,i)=>{let{zoom:a}=o,s=180*t/Math.PI,l=e*(a.value-1)/2,c=n*(a.value-1)/2;return e>r&&a.value!==1&&(l=r*(a.value-1)/2),n>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${l}px, ${c}px) scale(${a.value*lI(o.viewpointFlip.horizontal)}, ${a.value*lI(o.viewpointFlip.vertical)}) rotate(${s}deg)`},_7=(e,n)=>{let t=e.lastIndexOf(`
11
+ C ${l} ${c}, ${l} ${c}, ${l+b} ${c+v}`,Lo(e,!0,a))}else s=n.polygon([[l,c],[d,m],[p,u],[E,g]],Lo(e,!1,a));return s}case"ellipse":return n.ellipse(e.width/2,e.height/2,e.width,e.height,Lo(e,!1,a));case"line":case"arrow":{let s,l=Lo(e,!1,a),c=e.points.length?e.points:[GN(0,0)];if(Bn(e)?c.every(d=>Math.abs(d[0])<=1e6&&Math.abs(d[1])<=1e6)?s=[n.path($N(c,16),Lo(e,!0,a))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(c)),s=[]):e.roundness?s=[n.curve(c,l)]:l.fill?s=[n.polygon(c,l)]:s=[n.linearPath(c,l)],e.type==="arrow"){let{startArrowhead:d=null,endArrowhead:m="arrow"}=e;if(d!==null){let p=w2(e,s,"start",d,n,l,o,a);s.push(...p)}if(m!==null){let p=w2(e,s,"end",m,n,l,o,a);s.push(...p)}}return s}case"freedraw":{let s=[];if(Ia(e.points)){let l=ON(e.points,.75);s.push(n.curve(l,{...Lo(e,!1,a),stroke:"none"}))}return s.push(jN(e)),s}case"frame":case"magicframe":case"text":case"image":return null;default:return UN(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},$N=(e,n)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],s=e[r],l=km(s,i),c=km(a,s),d=Math.min(n,x2(e[r],a)/2,x2(e[r],i)/2);l?i[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):i[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d]),t.push(e[r]),c?a[0]<s[0]?t.push([e[r][0]-d,e[r][1]]):t.push([e[r][0]+d,e[r][1]]):a[1]<s[1]?t.push([e[r][0],e[r][1]-d]):t.push([e[r][0],e[r][1]+d])}let o=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)o.push(`L ${t[r][0]} ${t[r][1]}`),o.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return o.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),o.join(" ")};var jN=e=>o8(t8(e)),sf={SIZE_FACTOR:4.25,THINNING:.6,SMOOTHING:.5},qN={SIZE_FACTOR:1.4},T2=e=>e.strokeOptions?.streamline??VN,JN=e=>{let n=e.simulatePressure?e.points:e.points.length?e.points.map(([t,o],r)=>[t,o,e.pressures[r]]):[[0,0,.5]];return zN(n,{simulatePressure:e.simulatePressure,size:e.strokeWidth*sf.SIZE_FACTOR,thinning:sf.THINNING,smoothing:sf.SMOOTHING,streamline:T2(e),easing:t=>Math.sin(t*Math.PI/2),last:!0})},QN=e=>new va({size:e.strokeWidth*qN.SIZE_FACTOR,streamline:T2(e),simplify:0,sizeMapping:n=>Math.max(.1,n.pressure)}),e8=e=>{let n=QN(e);return e.points.map(([t,o])=>n.addPoint([t,o,1])),n.getStrokeOutline().map(([t,o])=>[t,o])},t8=e=>e.strokeOptions?.variability==="constant"?e8(e):JN(e);var v2=(e,n)=>[(e[0]+n[0])/2,(e[1]+n[1])/2],n8=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g,o8=e=>{if(!e.length)return"";let n=e.length-1;return e.reduce((t,o,r,i)=>(r===n?t.push(o,v2(o,i[0]),"L",i[0],"Z"):t.push(o,v2(o,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(n8,"$1")};var ci=(e,n,t=!1)=>{let o=!1;for(let r in n){let i=n[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;o=!0}}return!o&&!t?e:{...e,...n,version:n.version??e.version+1,versionNonce:n.versionNonce??r8(),updated:i8()}};import{jsx as P2}from"react/jsx-runtime";var Ma=O({name:"toggleLinearEditor",label:(e,n,t)=>t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.selectedLinearElement?.isEditing&&r.length===1&&s8(r[0])&&!a8(r[0]))},perform(e,n,t,o){S2(n.selectedLinearElement,"No selected linear element found");let r=o.scene.getElement(n.selectedLinearElement.elementId);S2(r,"No selected element found");let i={...n.selectedLinearElement,isEditing:!n.selectedLinearElement.isEditing};return{appState:{...n,selectedLinearElement:i},captureUpdate:C2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0];if(!o)return null;let r=f(o.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return P2($,{type:"button",icon:x0,title:r,"aria-label":r,onClick:()=>n(null)})}}),RSe=O({name:"togglePolygon",icon:zu,keywords:["loop"],label:(e,n,t)=>!t.scene.getSelectedElements({selectedElementIds:n.selectedElementIds}).some(i=>!ka(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds});return r.length>0&&r.every(i=>ka(i)&&i.points.length>=4)},perform(e,n,t,o){let r=o.scene.getSelectedElements(n);if(r.some(l=>!ka(l)))return!1;let i=r,a=i.some(l=>!l.polygon),s=l8(i);return{elements:e.map(l=>!s.has(l.id)||!ka(l)?l:ci(l,{backgroundColor:a?l.backgroundColor:"transparent",...c8(l,a)})),appState:n,captureUpdate:C2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(o.length===0||o.some(a=>!ka(a)||!a.polygon||a.points.length<3))return null;let r=o.every(a=>ka(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return P2($,{type:"toggle",icon:zu,title:i,"aria-label":i,checked:r,onSelect:()=>n(null),style:{marginLeft:"auto"}})}});import{KEYS as k2,CANVAS_SEARCH_TAB as M2,CLASSES as d8,DEFAULT_SIDEBAR as A2}from"@excalidraw/common";import{CaptureUpdateAction as m8}from"@excalidraw/element";var Nl=O({name:"searchMenu",icon:oo,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,n,t,o){if(n.openDialog)return!1;if(n.openSidebar?.name===A2.name&&n.openSidebar.tab===M2){let r=o.excalidrawContainerValue.container?.querySelector(`.${d8.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...n,openSidebar:{name:A2.name,tab:M2},openDialog:null},captureUpdate:m8.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,n,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[k2.CTRL_OR_CMD]&&e.key===k2.F});import{isImageElement as p8}from"@excalidraw/element";import{CaptureUpdateAction as u8}from"@excalidraw/element";import{jsx as h8}from"react/jsx-runtime";var cf=O({name:"cropEditor",label:"helpDialog.cropStart",icon:ch,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,n,t,o){let r=o.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...n,isCropping:!1,croppingElementId:r.id},captureUpdate:u8.IMMEDIATELY}},predicate:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n);return!!(!n.croppingElementId&&r.length===1&&p8(r[0]))},PanelComponent:({appState:e,updateData:n,app:t})=>{let o=f("helpDialog.cropStart");return h8($,{type:"button",icon:ch,title:o,"aria-label":o,onClick:()=>n(null)})}});import{getNonDeletedElements as g8}from"@excalidraw/element";import{mutateElement as f8}from"@excalidraw/element";import{newFrameElement as E8}from"@excalidraw/element";import{isFrameLikeElement as Lm}from"@excalidraw/element";import{addElementsToFrame as b8,removeAllElementsFromFrame as x8}from"@excalidraw/element";import{getFrameChildren as y8}from"@excalidraw/element";import{getElementsInGroup as w8}from"@excalidraw/element";import{getCommonBounds as v8}from"@excalidraw/element";import{CaptureUpdateAction as Aa}from"@excalidraw/element";var D2=(e,n)=>{let t=n.scene.getSelectedElements(e);return t.length===1&&Lm(t[0])},L2=O({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;if(Lm(r)){let i=y8(g8(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...n,selectedElementIds:i.reduce((a,s)=>(a[s.id]=!0,a),{})},captureUpdate:Aa.IMMEDIATELY}}return{elements:e,appState:n,captureUpdate:Aa.EVENTUALLY}},predicate:(e,n,t,o)=>D2(n,o)}),_2=O({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,n,t,o)=>{let r=o.scene.getSelectedElements(n).at(0)||null;return Lm(r)?{elements:x8(e,r),appState:{...n,selectedElementIds:{[r.id]:!0}},captureUpdate:Aa.IMMEDIATELY}:{elements:e,appState:n,captureUpdate:Aa.EVENTUALLY}},predicate:(e,n,t,o)=>D2(n,o)}),VCe=O({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,n)=>({elements:e,appState:{...n,frameRendering:{...n.frameRendering,enabled:!n.frameRendering.enabled}},captureUpdate:Aa.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),R2=O({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,n,t,o)=>{let r=de(e,n);return r.length>0&&!r.some(i=>Lm(i))},perform:(e,n,t,o)=>{let r=de(e,n),i=o.scene.getNonDeletedElementsMap(),[a,s,l,c]=v8(r,i),d=16,m=E8({x:a-d,y:s-d,width:l-a+d*2,height:c-s+d*2});if(n.editingGroupId){let u=w8(r,n.editingGroupId);for(let E of u){let g=E.groupIds.indexOf(n.editingGroupId);f8(E,i,{groupIds:E.groupIds.slice(0,g)})}}return{elements:b8([...o.scene.getElementsIncludingDeleted(),m],r,m),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:Aa.IMMEDIATELY}}});import{KEYS as La,matchKey as pf,arrayToMap as N2,MOBILE_ACTION_BUTTON_BG as B2}from"@excalidraw/common";import{CaptureUpdateAction as mf}from"@excalidraw/element";import{orderByFractionalIndex as M8}from"@excalidraw/element";import{Emitter as I8}from"@excalidraw/common";import{CaptureUpdateAction as T8,StoreChange as S8,StoreDelta as C8}from"@excalidraw/element";var Da=class extends C8{applyTo(n,t,o){let[r,i]=this.elements.applyTo(n,o.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,s]=this.appState.applyTo(t,r);return[r,a,i||s]}static calculate(n,t){return super.calculate(n,t)}static inverse(n){return super.inverse(n)}static applyLatestChanges(n,t,o,r){return super.applyLatestChanges(n,t,o,r)}},mi=class{constructor(n=!0,t=!0){this.isUndoStackEmpty=n;this.isRedoStackEmpty=t}},Bl=class e{constructor(n){this.store=n;y(this,"onHistoryChangedEmitter",new I8);y(this,"undoStack",[]);y(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(n){if(n.isEmpty()||n instanceof Da)return;let t=Da.inverse(n);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new mi(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(n,t){return this.perform(n,t,()=>e.pop(this.undoStack),o=>e.push(this.redoStack,o))}redo(n,t){return this.perform(n,t,()=>e.pop(this.redoStack),o=>e.push(this.undoStack,o))}perform(n,t,o,r){try{let i=o();if(i===null)return;let a=T8.IMMEDIATELY,s=this.store.snapshot,l=n,c=t,d=!1;for(;i;){try{[l,c,d]=i.applyTo(l,c,s);let m=s.elements,p=s.maybeClone(a,l,c),u=S8.create(s,p),E=Da.applyLatestChanges(i,m,l);E.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:E}),i=E),s=p}finally{r(i)}if(d)break;i=o()}return[l,c]}finally{this.onHistoryChangedEmitter.trigger(new mi(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(n){if(!n.length)return null;let t=n.pop();return t!==void 0?t:null}static push(n,t){let o=Da.inverse(t);return n.push(o)}};import{useEffect as P8,useState as k8}from"react";var df=(e,n)=>{let[t,o]=k8(n);return P8(()=>{let r=e.on(i=>{o(i)});return()=>{r()}},[e]),t};import{jsx as G2}from"react/jsx-runtime";var F2=(e,n,t)=>{if(!n.multiElement&&!n.resizingElement&&!n.editingTextElement&&!n.newElement&&!n.selectedElementsAreBeingDragged&&!n.selectionElement&&!e.flowchart.isCreatingChart&&!e.drawShape.hasPendingGesture()){let o=t();if(!o)return{captureUpdate:mf.EVENTUALLY};let[r,i]=o,a=M8(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:mf.NEVER}}return{captureUpdate:mf.EVENTUALLY}},O2=e=>({name:"undo",label:"buttons.undo",icon:Wu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>F2(r,t,()=>e.undo(N2(n),t)),keyTest:n=>n[La.CTRL_OR_CMD]&&pf(n,La.Z)&&!n.shiftKey,PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isUndoStackEmpty:i}=df(e.onHistoryChangedEmitter,new mi(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=mt()==="mobile";return G2($,{type:"button",icon:Wu,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-undo",style:{...a?B2:{}}})}}),z2=e=>({name:"redo",label:"buttons.redo",icon:Vu,trackEvent:{category:"history"},viewMode:!1,perform:(n,t,o,r)=>F2(r,t,()=>e.redo(N2(n),t)),keyTest:n=>n[La.CTRL_OR_CMD]&&n.shiftKey&&pf(n,La.Z)||n[La.CTRL_OR_CMD]&&!n.shiftKey&&pf(n,La.Y),PanelComponent:({appState:n,updateData:t,data:o,app:r})=>{let{isRedoStackEmpty:i}=df(e.onHistoryChangedEmitter,new mi(e.isUndoStackEmpty,e.isRedoStackEmpty)),a=mt()==="mobile";return G2($,{type:"button",icon:Vu,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:i,"data-testid":"button-redo",style:{...a?B2:{}}})}});import{getFontString as A8}from"@excalidraw/common";import{getTextAnchorRatios as D8,isExcalidrawElement as L8,isNonDeletedElement as _8,newElementWith as R8,updateBoundElements as N8}from"@excalidraw/element";import{measureText as B8}from"@excalidraw/element";import{isTextElement as uf}from"@excalidraw/element";import{CaptureUpdateAction as F8}from"@excalidraw/element";var hf=O({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,n,t)=>{let o=de(e,n);return o.length===1&&uf(o[0])&&!o[0].autoResize},perform:(e,n,t,o)=>{let r=de(e,n),i=L8(t)&&uf(t)?t:r[0],a=e.find(d=>d.id===i?.id);if(!a||!uf(a))return!1;let s=B8(a.originalText,A8(a),a.lineHeight),l=D8(a),c=R8(a,{autoResize:!0,width:s.width,height:s.height,x:a.x+(a.width-s.width)*l.x,y:a.y+(a.height-s.height)*l.y,text:a.originalText});return _8(c)&&N8(c,o.scene,{changedElements:new Map([[c.id,c]])}),{appState:n,elements:e.map(d=>d.id===c.id?c:d),captureUpdate:F8.IMMEDIATELY}}});import{CODES as O8,KEYS as z8}from"@excalidraw/common";import G8 from"clsx";import{CaptureUpdateAction as H8}from"@excalidraw/element";import{jsx as U8}from"react/jsx-runtime";var _a=O({name:"viewMode",label:"labels.viewMode",icon:Xr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,n){return n.viewModeOnly?!1:{appState:{...n,viewModeEnabled:!this.checked(n)},captureUpdate:H8.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,n,t,o)=>!n.viewModeOnly&&!t.viewModeOnly&&typeof t.viewModeEnabled>"u"&&o.isInteractionEnabled(),keyTest:e=>!e[z8.CTRL_OR_CMD]&&e.altKey&&!e.shiftKey&&e.code===O8.R,PanelComponent:({data:e,updateData:n,appState:t,appProps:o})=>{if(t.viewModeOnly||o.viewModeOnly)return null;let r=t.viewModeEnabled?"Edit mode":f("labels.viewMode");return U8($,{type:"button",icon:t.viewModeEnabled?uh:Xr,"aria-label":r,onClick:()=>n(null),size:e?.size||"medium","data-testid":"button-view-mode",className:G8({enabled:t.viewModeEnabled})})}});import{isPromiseLike as W8}from"@excalidraw/common";import{jsx as V8}from"react/jsx-runtime";var gf=(e,n,t,o,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,o,i))&&We(e.trackEvent.category,e.trackEvent.action||e.name,`${n} (${r.editorInterface.formFactor==="phone"?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},_m=class{constructor(n,t,o,r){y(this,"actions",{});y(this,"updater");y(this,"getAppState");y(this,"getElementsIncludingDeleted");y(this,"app");y(this,"isActionBlockedByViewportTransition",n=>n.navigation===!0&&this.app.viewport.isLockedTransitionPending);y(this,"isActionEnabledByCanvasOptions",n=>{let t=this.app.props.UIOptions.canvasActions;return n.name==="saveFileToDisk"?!!(t.export&&typeof t.export=="object"&&t.export.saveFileToDisk):n.name in t?!!t[n.name]:!0});y(this,"renderAction",(n,t)=>{let o=this.app.props.UIOptions.canvasActions;if(this.actions[n]&&"PanelComponent"in this.actions[n]&&(!(n in o)||o[n])){let r=this.actions[n],i=r.PanelComponent;i.displayName="PanelComponent";let a=s=>{this.isActionBlockedByViewportTransition(r)||(gf(r,"ui",this.getAppState(),this.getElementsIncludingDeleted(),this.app,s),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),s,this.app)))};return V8(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:a,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});y(this,"isActionEnabled",n=>{let t=this.getElementsIncludingDeleted(),o=this.getAppState();return!n.predicate||n.predicate(t,o,this.app.props,this.app)});y(this,"isActionAvailableForUI",n=>{let t=this.getAppState();return this.isActionEnabledByCanvasOptions(n)&&this.isActionEnabled(n)&&(!t.viewModeEnabled||n.viewMode===!0)&&(this.app.isInteractionEnabled()||this.app.isNavigationEnabled()&&n.navigation===!0)&&!this.isActionBlockedByViewportTransition(n)});this.updater=i=>{if(W8(i))i.then(a=>n(a));else return n(i)},this.getAppState=t,this.getElementsIncludingDeleted=o,this.app=r}registerAction(n){this.actions[n.name]=n}registerAll(n){n.forEach(t=>this.registerAction(t))}handleKeyDown(n){if(!this.app.isInteractionEnabled()&&!this.app.isNavigationEnabled())return!1;let t=this.app.props.UIOptions.canvasActions,o=Object.values(this.actions).sort((l,c)=>(c.keyPriority||0)-(l.keyPriority||0)).filter(l=>(l.name in t?t[l.name]:!0)&&l.keyTest&&l.keyTest(n,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(o.length!==1)return o.length>1&&console.warn("Canceling as multiple actions match this shortcut",o),!1;let r=o[0];if(!this.app.isInteractionEnabled()&&r.navigation!==!0||this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;if(this.isActionBlockedByViewportTransition(r))return n.preventDefault(),n.stopPropagation(),!0;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),s=null;return gf(r,"keyboard",a,i,this.app,null),n.preventDefault(),n.stopPropagation(),this.updater(o[0].perform(i,a,s,this.app)),!0}executeAction(n,t="api",o=null){if(t!=="api"&&!this.app.isInteractionEnabled()&&!(this.app.isNavigationEnabled()&&n.navigation===!0)||this.isActionBlockedByViewportTransition(n))return;let r=this.getElementsIncludingDeleted(),i=this.getAppState();gf(n,t,i,r,this.app,o),this.updater(n.perform(r,i,o,this.app))}};var ff=e=>{let n=Array.from(e.values());return{x:H2(n,t=>t.x)/n.length,y:H2(n,t=>t.y)/n.length}},Ef=([e,n])=>Math.hypot(e.x-n.x,e.y-n.y),H2=(e,n)=>e.reduce((t,o)=>t+n(o),0);import{pointFrom as X,pointRotateRads as xr,rangeInclusive as hn,rangeIntersection as Rm,rangesOverlap as Nm}from"@excalidraw/math";import{TOOL_TYPE as pi,KEYS as U2}from"@excalidraw/common";import{getCommonBounds as bf,getDraggedElementsBounds as xf,getElementAbsoluteCoords as Y8}from"@excalidraw/element";import{isBoundToContainer as K2}from"@excalidraw/element";import{getMaximumGroups as X2}from"@excalidraw/element";import{getSelectedElements as K8,getVisibleAndNonSelectedElements as Z2}from"@excalidraw/element";var X8=8,W2=99999,Bm=e=>X8/e,Bt=class Bt{};y(Bt,"referenceSnapPoints",null),y(Bt,"visibleGaps",null),y(Bt,"setReferenceSnapPoints",n=>{Bt.referenceSnapPoints=n}),y(Bt,"getReferenceSnapPoints",()=>Bt.referenceSnapPoints),y(Bt,"setVisibleGaps",n=>{Bt.visibleGaps=n}),y(Bt,"getVisibleGaps",()=>Bt.visibleGaps),y(Bt,"destroy",()=>{Bt.referenceSnapPoints=null,Bt.visibleGaps=null});var gn=Bt,yr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,_o=({event:e,app:n,selectedElements:t})=>{if(e){let o=n.state.activeTool.type==="lasso"&&n.state.selectedElementsAreBeingDragged;return(n.state.activeTool.type!=="lasso"||o)&&(n.state.objectsSnapModeEnabled&&!e[U2.CTRL_OR_CMD]||!n.state.objectsSnapModeEnabled&&e[U2.CTRL_OR_CMD]&&!yr(n))}return t.length===1&&t[0].type==="arrow"?!1:n.state.objectsSnapModeEnabled},Z8=(e,n,t=.01)=>Math.abs(e-n)<=t,Fl=(e,n,{omitCenter:t,boundingBoxCorners:o,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[s,l,c,d,m,p]=Y8(a,n);r&&(s+=r.x,c+=r.x,m+=r.x,l+=r.y,d+=r.y,p+=r.y);let u=(c-s)/2,E=(d-l)/2;if((a.type==="diamond"||a.type==="ellipse")&&!o){let g=xr(X(s,l+E),X(m,p),a.angle),b=xr(X(s+u,l),X(m,p),a.angle),v=xr(X(c,l+E),X(m,p),a.angle),w=xr(X(s+u,d),X(m,p),a.angle),x=X(m,p);i=t?[g,b,v,w]:[g,b,v,w,x]}else{let g=xr(X(s,l),X(m,p),a.angle),b=xr(X(c,l),X(m,p),a.angle),v=xr(X(s,d),X(m,p),a.angle),w=xr(X(c,d),X(m,p),a.angle),x=X(m,p);i=t?[g,b,v,w]:[g,b,v,w,x]}}else if(e.length>1){let[a,s,l,c]=xf(e,r??{x:0,y:0}),d=l-a,m=c-s,p=X(a,s),u=X(l,s),E=X(a,c),g=X(l,c),b=X(a+d/2,s+m/2);i=t?[p,u,E,g]:[p,u,E,g,b]}return i.map(a=>X(je(a[0]),je(a[1])))},$2=(e,n,t,o)=>Z2(e,n,t,o),j2=(e,n,t,o)=>{let r=$2(e,n,t,o),i=X2(r,o).filter(m=>!(m.length===1&&K2(m[0]))).map(m=>bf(m).map(p=>je(p))),a=i.sort((m,p)=>m[0]-p[0]),s=[],l=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++l>W2)break e;let E=a[u],[,g,b,v]=p,[w,x,,I]=E;b<w&&Nm(hn(g,v),hn(x,I))&&s.push({startBounds:p,endBounds:E,startSide:[X(b,g),X(b,v)],endSide:[X(w,x),X(w,I)],length:w-b,overlap:Rm(hn(g,v),hn(x,I))})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];l=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++l>W2)break e;let E=c[u],[g,,b,v]=p,[w,x,I]=E;v<x&&Nm(hn(g,b),hn(w,I))&&d.push({startBounds:p,endBounds:E,startSide:[X(g,v),X(b,v)],endSide:[X(w,x),X(I,x)],length:x-v,overlap:Rm(hn(g,b),hn(w,I))})}}return{horizontalGaps:s,verticalGaps:d}},V2=(e,n,t,o,r,i,a)=>{if(!_o({app:t,event:o,selectedElements:e}))return[];if(e.length===0)return[];let s=gn.getVisibleGaps();if(s){let{horizontalGaps:l,verticalGaps:c}=s,[d,m,p,u]=xf(e,n).map(b=>je(b)),E=(d+p)/2,g=(m+u)/2;for(let b of l){if(!Nm(hn(m,u),b.overlap))continue;let v=b.startSide[0][0]+b.length/2,w=je(v-E);if(b.length>p-d&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(r.length=0),a.x=Math.abs(w);let _={type:"gap",direction:"center_horizontal",gap:b,offset:w};r.push(_);continue}let[,,I]=b.endBounds,T=d-I,C=je(b.length-T);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(r.length=0),a.x=Math.abs(C);let _={type:"gap",direction:"side_right",gap:b,offset:C};r.push(_);continue}let[P,,,]=b.startBounds,M=P-p,D=je(M-b.length);if(Math.abs(D)<=a.x){Math.abs(D)<a.x&&(r.length=0),a.x=Math.abs(D);let _={type:"gap",direction:"side_left",gap:b,offset:D};r.push(_);continue}}for(let b of c){if(!Nm(hn(d,p),b.overlap))continue;let v=b.startSide[0][1]+b.length/2,w=je(v-g);if(b.length>u-m&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let _={type:"gap",direction:"center_vertical",gap:b,offset:w};i.push(_);continue}let[,I,,]=b.startBounds,T=I-u,C=je(T-b.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let _={type:"gap",direction:"side_top",gap:b,offset:C};i.push(_);continue}let[,,,P]=b.endBounds,M=je(m-P),D=b.length-M;if(Math.abs(D)<=a.y){Math.abs(D)<a.y&&(i.length=0),a.y=Math.abs(D);let _={type:"gap",direction:"side_bottom",gap:b,offset:D};i.push(_);continue}}}},q2=(e,n,t,o)=>{let r=$2(e,n,t,o);return X2(r,o).filter(i=>!(i.length===1&&K2(i[0]))).flatMap(i=>Fl(i,o))},Ra=(e,n,t,o,r,i,a)=>{if(!_o({app:t,event:o,selectedElements:e})||e.length===0&&n.length===0)return[];let s=gn.getReferenceSnapPoints();if(s)for(let l of n)for(let c of s){let d=c[0]-l[0],m=c[1]-l[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(r.length=0),r.push({type:"point",points:[l,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[l,c],offset:m}),a.y=Math.abs(m))}},J2=(e,n,t,o,r)=>{let i=t.state,a=K8(e,i);if(!_o({app:t,event:o,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};n.x=je(n.x),n.y=je(n.y);let s=[],l=[],c=Bm(i.zoom.value),d={x:c,y:c},m=Fl(a,r,{dragOffset:n});Ra(a,m,t,o,s,l,d),V2(a,n,t,o,s,l,d);let p={x:s[0]?.offset??0,y:l[0]?.offset??0};d.x=0,d.y=0,s.length=0,l.length=0;let u={x:je(n.x+p.x),y:je(n.y+p.y)};Ra(a,Fl(a,r,{dragOffset:u}),t,o,s,l,d),V2(a,u,t,o,s,l,d);let E=yf(s,l),g=j8(a,u,[...s,...l].filter(b=>b.type==="gap"));return{snapOffset:p,snapLines:[...E,...g]}},je=e=>Math.round(e*10**6)/10**6,Y2=e=>{let n=new Map;for(let t of e){let o=t.join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},yf=(e,n)=>{let t={},o={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=je(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>X(je(a[0]),je(a[1]))))}}if(n.length>0){for(let r of n)if(r.type==="point"){let i=je(r.points[0][1]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>X(je(a[0]),je(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:Y2(i.map(a=>X(Number(r),a[1])).sort((a,s)=>a[1]-s[1]))})).concat(Object.entries(o).map(([r,i])=>({type:"points",points:Y2(i.map(a=>X(a[0],Number(r))).sort((a,s)=>a[0]-s[0]))})))},$8=e=>{let n=new Map;for(let t of e){let o=t.points.flat().map(r=>[je(r)]).join(",");n.has(o)||n.set(o,t)}return Array.from(n.values())},j8=(e,n,t)=>{let[o,r,i,a]=xf(e,n),s=[];for(let l of t){let[c,d,m,p]=l.gap.startBounds,[u,E,g,b]=l.gap.endBounds,v=Rm(hn(r,a),l.gap.overlap),w=Rm(hn(o,i),l.gap.overlap);switch(l.direction){case"center_horizontal":{if(v){let x=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[X(l.gap.startSide[0][0],x),X(o,x)]},{type:"gap",direction:"horizontal",points:[X(i,x),X(l.gap.endSide[0][0],x)]})}break}case"center_vertical":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[X(x,l.gap.startSide[0][1]),X(x,r)]},{type:"gap",direction:"vertical",points:[X(x,a),X(x,l.gap.endSide[0][1])]})}break}case"side_right":{if(v){let x=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[X(m,x),X(u,x)]},{type:"gap",direction:"horizontal",points:[X(g,x),X(o,x)]})}break}case"side_left":{if(v){let x=(v[0]+v[1])/2;s.push({type:"gap",direction:"horizontal",points:[X(i,x),X(c,x)]},{type:"gap",direction:"horizontal",points:[X(m,x),X(u,x)]})}break}case"side_top":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[X(x,a),X(x,d)]},{type:"gap",direction:"vertical",points:[X(x,p),X(x,E)]})}break}case"side_bottom":{if(w){let x=(w[0]+w[1])/2;s.push({type:"gap",direction:"vertical",points:[X(x,p),X(x,E)]},{type:"gap",direction:"vertical",points:[X(x,b),X(x,r)]})}break}}}return $8(s.map(l=>({...l,points:l.points.map(c=>X(je(c[0]),je(c[1])))})))},wf=(e,n,t,o,r,i)=>{if(!_o({event:o,selectedElements:e,app:t})||e.length===0||e.length===1&&!Z8(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,s,l,c]=bf(n);i&&(i.includes("e")?l+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?s+=r.y:i.includes("s")&&(c+=r.y));let d=[];if(i)switch(i){case"e":{d.push(X(l,s),X(l,c));break}case"w":{d.push(X(a,s),X(a,c));break}case"n":{d.push(X(a,s),X(l,s));break}case"s":{d.push(X(a,c),X(l,c));break}case"ne":{d.push(X(l,s));break}case"nw":{d.push(X(a,s));break}case"se":{d.push(X(l,c));break}case"sw":{d.push(X(a,c));break}}let m=Bm(t.state.zoom.value),p={x:m,y:m},u=[],E=[];Ra(n,d,t,o,u,E,p);let g={x:u[0]?.offset??0,y:E[0]?.offset??0};p.x=0,p.y=0,u.length=0,E.length=0;let[b,v,w,x]=bf(e).map(C=>je(C)),I=[X(b,v),X(b,x),X(w,v),X(w,x)];Ra(e,I,t,o,u,E,p);let T=yf(u,E);return{snapOffset:g,snapLines:T}},Q2=(e,n,t,o,r,i)=>{if(!_o({event:t,selectedElements:[e],app:n}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[X(o.x+r.x,o.y+r.y)],s=Bm(n.state.zoom.value),l={x:s,y:s},c=[],d=[];Ra([e],a,n,t,c,d,l);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};l.x=0,l.y=0,c.length=0,d.length=0;let p=Fl([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ra([e],p,n,t,c,d,l);let u=yf(c,d);return{snapOffset:m,snapLines:u}},eI=(e,n,t,o,r)=>{if(!_o({event:o,selectedElements:[],app:n}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Z2(e,[],n.state,r),a=Bm(n.state.zoom.value),s={x:a,y:a},l=[],c=[];for(let d of i){let m=Fl([d],r);for(let p of m){let u=p[0]-t.x;Math.abs(u)<=Math.abs(s.x)&&(Math.abs(u)<Math.abs(s.x)&&(c.length=0),c.push({type:"pointer",points:[p,X(p[0],t.y)],direction:"vertical"}),s.x=u);let E=p[1]-t.y;Math.abs(E)<=Math.abs(s.y)&&(Math.abs(E)<Math.abs(s.y)&&(l.length=0),l.push({type:"pointer",points:[p,X(t.x,p[1])],direction:"horizontal"}),s.y=E)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:l.length>0?l[0].points[0][1]-t.y:0},snapLines:[...c,...l]}},tI=e=>e===pi.rectangle||e===pi.ellipse||e===pi.diamond||e===pi.frame||e===pi.magicframe||e===pi.image||e===pi.text;import{getCommonFrameId as q8,getFrameChildrenInsertionIndex as J8,isElementInViewport as Q8}from"@excalidraw/element";import{arrayToMap as e7,memoize as t7,toBrandedType as n7}from"@excalidraw/common";var Ol=class{constructor(n){y(this,"scene");y(this,"_getRenderableElements",t7(({canvasNonce:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l,editingTextElement:c,newElement:d})=>{let m=this.scene.getNonDeletedElements(),{elementsMap:p,newElementCanvasElement:u}=this.getRenderableElementsMap({elements:m,editingTextElement:c,newElement:d}),E=this.getVisibleCanvasElements({elementsMap:p,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l});return{elementsMap:p,visibleElements:E,newElementCanvasElement:u,canvasNonce:n}}));y(this,"getRenderableElements",n=>{let{newElement:t}=n,o=`${this.scene.getSceneNonce()}${t?.frameId?`:${t.versionNonce}`:""}`,r=this._getRenderableElements({canvasNonce:o,zoom:n.zoom,offsetLeft:n.offsetLeft,offsetTop:n.offsetTop,scrollX:n.scrollX,scrollY:n.scrollY,height:n.height,width:n.width,editingTextElement:n.editingTextElement,newElement:n.newElement});if(n.frameToHighlight&&n.selectedElementsAreBeingDragged&&q8(n.selectedElements)!==n.frameToHighlight.id){let i=this.sortSelectedElementsIntoHighlightedFrame({visibleElements:r.visibleElements,selectedElements:n.selectedElements,frameToHighlight:n.frameToHighlight});return{...r,visibleElements:i}}return r});this.scene=n}getVisibleCanvasElements({elementsMap:n,zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a,height:s,width:l}){let c=[];for(let d of n.values())Q8(d,l,s,{zoom:t,offsetLeft:o,offsetTop:r,scrollX:i,scrollY:a},n)&&c.push(d);return c}getRenderableElementsMap({elements:n,editingTextElement:t,newElement:o}){let r=n7(new Map),i=o?.frameId?null:o;for(let a of n)i?.id!==a.id&&(!t||t.type!=="text"||a.id!==t.id)&&r.set(a.id,a);return{elementsMap:r,newElementCanvasElement:i}}sortSelectedElementsIntoHighlightedFrame({visibleElements:n,selectedElements:t,frameToHighlight:o}){if(!t.length)return n;let r=e7(t),i=n.filter(s=>!r.has(s.id)),a=J8(i,o.id);return a===null?n:[...i.slice(0,a),...t,...i.slice(a)]}destroy(){Ix.cancel(),this._getRenderableElements.clear()}};import{DEFAULT_LASER_COLOR as s7,easeOut as rI}from"@excalidraw/common";import{SVG_NS as oI,getSvgPathFromStroke as i7,sceneCoordsToViewportCoords as a7}from"@excalidraw/common";import{version as o7}from"react";import{unstable_batchedUpdates as nI}from"react-dom";import{throttleRAF as r7}from"@excalidraw/common";var qe=e=>n=>{nI(e,n)},Fm=e=>r7(n=>{nI(e,n)}),Na=(()=>{let e;try{let t=o7.split(".");e=Number(t[0])>17}catch{e=!1}let n=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(n||(n=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();var he=class he{static start(n,t){if(he.animations.has(n))return;let o={animation:t,lastTime:0,state:void 0};he.animations.set(n,o);let r;try{r=t({deltaTime:0,state:void 0})}catch(i){throw he.animations.get(n)===o&&(he.animations.delete(n),he.cancelScheduledFrameIfIdle()),i}if(he.animations.get(n)===o){if(!r){he.animations.delete(n),he.cancelScheduledFrameIfIdle();return}o.state=r,he.scheduleNextFrame()}}static scheduleNextFrame(){he.scheduledFrame||(Na()?he.scheduledFrame={id:requestAnimationFrame(he.tick),type:"raf"}:he.scheduledFrame={id:setTimeout(he.tick,0),type:"timeout"})}static cancelScheduledFrame(){he.scheduledFrame&&(he.scheduledFrame.type==="raf"?cancelAnimationFrame(he.scheduledFrame.id):clearTimeout(he.scheduledFrame.id),he.scheduledFrame=null)}static cancelScheduledFrameIfIdle(){return he.animations.size>0?!1:(he.cancelScheduledFrame(),!0)}static tick(){if(he.scheduledFrame=null,he.animations.size>0){let n=[...he.animations];for(let[t,o]of n){if(he.animations.get(t)!==o)continue;let r=performance.now(),i=o.lastTime===0?0:r-o.lastTime,a=o.animation({deltaTime:i,state:o.state});if(he.animations.get(t)===o){if(a)o.lastTime=r,o.state=a;else if(he.animations.delete(t),he.cancelScheduledFrameIfIdle())return}}if(he.cancelScheduledFrameIfIdle())return;he.scheduleNextFrame()}}static running(n){return he.animations.has(n)}static cancel(n){he.animations.delete(n),he.cancelScheduledFrameIfIdle()}static reset(){he.animations.clear(),he.cancelScheduledFrame()}};y(he,"scheduledFrame",null),y(he,"animations",new Map);var ct=he;var Om=class Om{constructor(n,t){this.app=n;this.options=t;y(this,"currentTrail");y(this,"pastTrails",[]);y(this,"container");y(this,"trailElement");y(this,"trailAnimation");y(this,"key");this.key=`animated-trail-${Om.counter++}`,this.trailElement=document.createElementNS(oI,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(oI,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(n,t){if(this.currentTrail){let o=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[o-1][0]===n&&this.currentTrail.originalPoints[o-1][1]===t}return!1}cleanup(){this.pastTrails=[],this.currentTrail=void 0,this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}start(n){n&&(this.container=n),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),ct.running(this.key)||ct.start(this.key,()=>this.onFrame()?{keep:!0}:(this.cleanup(),null))}stop(){ct.cancel(this.key),this.cleanup()}startPath(n,t){this.currentTrail=new va(this.options),this.currentTrail.addPoint([n,t,performance.now()]),this.update()}addPointToPath(n,t){this.currentTrail&&(this.currentTrail.addPoint([n,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let n=[];for(let o of this.pastTrails)n.push(this.drawTrail(o,this.app.state));if(this.currentTrail){let o=this.drawTrail(this.currentTrail,this.app.state);n.push(o)}if(this.pastTrails=this.pastTrails.filter(o=>o.getStrokeOutline(o.options.size/this.app.state.zoom.value).length!==0),n.length===0)return this.trailElement.setAttribute("d",""),!1;let t=n.join(" ").trim();return this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),!0}drawTrail(n,t){let o=n.getStrokeOutline(n.options.size/t.zoom.value).map(([i,a])=>{let s=a7({sceneX:i,sceneY:a},t);return[s.x,s.y]}),r=this.trailAnimation?o.slice(0,o.length/2):o;return i7(r,!0)}};y(Om,"counter",0);var zn=Om;var zm=class{constructor(n){this.app=n;y(this,"localTrail");y(this,"collabTrails",new Map);y(this,"container");this.localTrail=new zn(n,{...this.getTrailOptions(),fill:()=>s7})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:n=>{let r=Math.max(0,1-(performance.now()-n.pressure)/1e3),i=(50-Math.min(50,n.totalLength-n.currentIndex))/50;return Math.min(rI(i),rI(r))}}}startPath(n,t){this.localTrail.startPath(n,t)}addPointToPath(n,t){this.localTrail.addPointToPath(n,t)}endPath(){this.localTrail.endPath()}start(n){this.container=n,this.localTrail.start(n)}stop(){this.localTrail.stop(),this.stopCollabTrails(),this.container=void 0}stopCollabTrails(n){for(let[t,o]of this.collabTrails)n?.get(t)||(o.stop(),this.collabTrails.delete(t))}updateCollabTrails(n){if(this.stopCollabTrails(n),!(!this.container||n.size===0))for(let[t,o]of n.entries()){if(o.isCurrentUser)continue;let r=this.collabTrails.get(t);if(r||(r=new zn(this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||oi(t,o)}),r.start(this.container),this.collabTrails.set(t,r)),o.pointer&&o.pointer.tool==="laser"){let i=o.button==="down",a=o.button==="up",s=r.hasCurrentTrail;i&&!s&&r.startPath(o.pointer.x,o.pointer.y);let l=!r.hasLastPoint(o.pointer.x,o.pointer.y);i&&l&&r.addPointToPath(o.pointer.x,o.pointer.y),a&&s&&(r.addPointToPath(o.pointer.x,o.pointer.y),r.endPath())}}}};import{DEFAULT_TRANSFORM_HANDLE_SPACING as l7}from"@excalidraw/common";import{pointFrom as zl,pointRotateRads as Gm}from"@excalidraw/math";var c7=12,vf=16,d7=10,m7=vf+2,p7=.8,If=e=>l7*2/e,Tf=(e,n,t)=>{let o=If(n);if(t!=="desktop"||vf>(e.height+o*2)*n*p7)return null;let r=c7/n,i=vf/n,a=zl(e.x+e.width/2,e.y+e.height/2),s=Gm(zl(a[0]+e.width/2+o+r,a[1]),a,e.angle);return{center:s,start:Gm(zl(s[0],s[1]-i/2),s,e.angle),end:Gm(zl(s[0],s[1]+i/2),s,e.angle),hitboxWidth:d7/n,hitboxHeight:m7/n}},iI=(e,n,t,o)=>{let r=Tf(n,t,o);if(!r)return!1;let i=Gm(zl(e.x,e.y),r.center,-n.angle);return Math.abs(i[0]-r.center[0])<=r.hitboxWidth/2&&Math.abs(i[1]-r.center[1])<=r.hitboxHeight/2};import{CODES as Sf,KEYS as Gl,CLASSES as Cf,POINTER_BUTTON as u7,THEME as h7,isWritableElement as g7,getFontString as aI,getFontFamilyString as sI,isTestEnv as lI,MIME_TYPES as Pf,applyDarkModeFilter as f7,isRTL as E7,getViewpointFlipSign as cI}from"@excalidraw/common";import{pointFrom as dI,pointRotateRads as b7}from"@excalidraw/math";import{getTextFromElements as x7,originalContainerCache as y7,updateBoundElements as mI,updateOriginalContainerCache as pI}from"@excalidraw/element";import{LinearElementEditor as w7}from"@excalidraw/element/linearElementEditor";import{bumpVersion as v7}from"@excalidraw/element";import{getBoundTextElementId as I7,getContainerElement as kf,getTextElementAngle as T7,redrawTextBoundingBox as S7,getBoundTextMaxHeight as C7,getBoundTextMaxWidth as uI,computeContainerDimensionForBoundText as hI,computeBoundTextPosition as P7,getBoundTextElement as k7}from"@excalidraw/element";import{getTextWidth as M7}from"@excalidraw/element";import{getLineHeightInPx as A7}from"@excalidraw/element";import{getLineWidth as D7}from"@excalidraw/element";import{normalizeText as gI}from"@excalidraw/element";import{wrapText as L7}from"@excalidraw/element";import{getWrappedTextLines as _7}from"@excalidraw/element";import{isArrowElement as Hm,isBoundToContainer as R7,isTextElement as fI}from"@excalidraw/element";var N7=(e,n,t,o,r,i)=>{let{zoom:a}=o,s=180*t/Math.PI,l=e*(a.value-1)/2,c=n*(a.value-1)/2;return e>r&&a.value!==1&&(l=r*(a.value-1)/2),n>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${l}px, ${c}px) scale(${a.value*cI(o.viewpointFlip.horizontal)}, ${a.value*cI(o.viewpointFlip.vertical)}) rotate(${s}deg)`},B7=(e,n)=>{let t=e.lastIndexOf(`
12
12
  `,Math.max(0,n-1))+1,o=e.indexOf(`
13
- `,n),r=e.slice(t,o===-1?e.length:o);return h7(r)?"rtl":"ltr"},R7=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},N7=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=R7(e),a=document.createElement("div"),s=document.createTextNode(e),l=document.createRange(),c=[];a.dir=o,Object.assign(a.style,{position:"fixed",top:"0",left:"0",margin:0,padding:0,border:0,opacity:"0",pointerEvents:"none",whiteSpace:"pre",font:n,lineHeight:`${t}px`}),a.append(s),document.body.append(a);try{for(let u of i){l.setStart(s,u),l.setEnd(s,u);let E=l.getBoundingClientRect();if(!Number.isFinite(E.left))return null;c.push(E.left)}}catch{return null}finally{a.remove()}let d=Math.min(...c),m=i[0],p=1/0;for(let u=0;u<i.length;u++){let E=Math.abs(c[u]-d-r);E<p&&(p=E,m=i[u])}return m},fI=({onChange:e,onSubmit:n,getViewportCoords:t,element:o,canvas:r,excalidrawContainer:i,app:a,autoSelect:s=!0,initialCaretSceneCoords:l=null})=>{let c=null,d=(B,Y)=>{if(!Y.style.fontFamily||!Y.style.fontSize)return!1;let pe=Y.style.fontFamily.replace(/"/g,"");return aI({fontFamily:B.fontFamily})!==pe||`${B.fontSize}px`!==Y.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let B=a.state,Y=a.scene.getElement(o.id);if(!Y)return;let{textAlign:pe,verticalAlign:ae}=Y,be=a.scene.getNonDeletedElementsMap();if(Y&&gI(Y)){let ce=Y.x,Fe=Y.y,se=Pf(Y,a.scene.getNonDeletedElementsMap()),Le=Y.width,_e=Y.height,Se=Y.width,Mt=Y.height;if(se&&Y.containerId){if(Hm(se)){let At=b7.getBoundTextElementPosition(se,Y,be);ce=At.x,Fe=At.y}let vs=d(Y,u),yo;if(vs?yo=mI(se.id,se.height):(yo=E7[se.id],yo||(yo=mI(se.id,se.height))),Se=pI(se,Y),Mt=I7(se,Y),!Hm(se)&&_e>Mt){let At=uI(_e,se.type);a.scene.mutateElement(se,{height:At}),dI(se,a.scene);return}else if(!Hm(se)&&se.height>yo.height&&_e<Mt){let At=uI(_e,se.type);a.scene.mutateElement(se,{height:At}),dI(se,a.scene)}else{let{x:At,y:Is}=T7(se,Y,be);ce=At,Fe=Is}}let[kn,Mn]=t(ce,Fe);se?Le+=.5:(Se=(B.viewpointFlip.horizontal?kn-8:B.width-8-kn)/B.zoom.value,Le=Math.min(Le,Se)),_e*=1.05;let Ko=iI(Y),ki=w7(Y,se),Mi=(B.viewpointFlip.vertical?Mn:B.height-Mn)/B.zoom.value;Object.assign(u.style,{font:Ko,lineHeight:Y.lineHeight,width:`${Le}px`,height:`${_e}px`,left:`${kn}px`,top:`${Mn}px`,transform:L7(Le,_e,ki,B,Se,Mi),textAlign:pe,verticalAlign:ae,color:u7(Y.strokeColor,B.theme===m7.DARK),opacity:Y.opacity/100,maxHeight:`${Mi}px`}),c={angle:ki,font:Ko,height:Y.height,lineHeightPx:P7(Y.fontSize,Y.lineHeight),textAlign:pe,width:Y.width,x:ce,y:Fe},u.scrollTop=0,sI()&&(u.style.fontFamily=aI(Y)),a.scene.mutateElement(Y,{x:ce,y:Fe})}},u=document.createElement("textarea");u.dir="auto",u.tabIndex=0,u.dataset.type="wysiwyg",u.wrap="off",u.classList.add("excalidraw-wysiwyg");let E="pre",g="normal";(D7(o)||!o.autoResize)&&(E="pre-wrap",g="break-word"),Object.assign(u.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:g,whiteSpace:E,overflowWrap:"break-word",boxSizing:"content-box"}),u.value=o.originalText,p();let b=()=>{if(!l||!c)return null;let B=c,Y=cI(B.x+B.width/2,B.y+B.height/2),[pe,ae]=g7(cI(l.x,l.y),Y,-B.angle),be=pe-B.x,ce=ae-B.y,Fe=A7(u.value,B.font,E==="pre-wrap"?B.width:1/0),se=Math.max(0,Math.min(Fe.length-1,Math.floor(ce/B.lineHeightPx))),Le=Fe[se],_e=_7(u.value,Le.start),Se=k7(Le.text,B.font),Mt=B.textAlign==="center"?(B.width-Se)/2:B.textAlign==="right"?B.width-Se:0,kn=be-Mt;if(!Le.text)return Le.start;let Mn=N7({text:Le.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:_e,targetX:kn});return Le.start+(Mn||0)},v=(()=>{let B=b();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let Y=kw(B),pe=null;if(Y.has(Cf.excalidrawClipboard)||Y.has(Cf.excalidraw)){B.preventDefault(),pe=await mr(B);try{let se=await ml(pe);if(se.elements){let Le=f7(se.elements);if(Le){let{selectionStart:_e,selectionEnd:Se,value:Mt}=u;u.value=Mt.slice(0,_e)+Le+Mt.slice(Se);let kn=_e+Le.length;u.selectionStart=u.selectionEnd=kn,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}pe=pe||await mr(B);let ae=pe.findByType(Cf.text);if(!ae)return;let be=hI(ae.value);if(!be)return;let ce=Pf(o,a.scene.getNonDeletedElementsMap()),Fe=iI({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(ce){let se=S7(ce,a.scene.getNonDeletedElementsMap()),Le=M7(`${u.value}${be}`,Fe,pI(ce,se)),_e=C7(Le,Fe);u.style.width=`${_e}px`}},u.oninput=()=>{let B=hI(u.value);if(u.value!==B){let Y=u.selectionStart;u.value=B,u.selectionStart=Y,u.selectionEnd=Y}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&zd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(zd),p();else if(!B.shiftKey&&Gd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Gd),p();else if(!B.shiftKey&&Hd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Hd),p();else if($h.keyTest(B))a.actionManager.executeAction($h);else if(jh.keyTest(B))a.actionManager.executeAction(jh);else if(B.key===Gl.ESCAPE)B.preventDefault(),D=!0,_();else if(Qr.keyTest(B))B.preventDefault(),_(),a.actionManager.executeAction(Qr);else if(B.key===Gl.ENTER&&B[Gl.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;D=!0,_()}else if(B.key===Gl.TAB||B[Gl.CTRL_OR_CMD]&&(B.code===Tf.BRACKET_LEFT||B.code===Tf.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===Tf.BRACKET_LEFT?C():T(),u.dispatchEvent(new Event("input"))}};let y=4,x=" ".repeat(y),I=new RegExp(`^ {1,${y}}`),T=()=>{let{selectionStart:B,selectionEnd:Y}=u,pe=P(),ae=u.value;pe.forEach(be=>{let ce=ae.slice(0,be),Fe=ae.slice(be);ae=`${ce}${x}${Fe}`}),u.value=ae,u.selectionStart=B+y,u.selectionEnd=Y+y*pe.length},C=()=>{let{selectionStart:B,selectionEnd:Y}=u,pe=P(),ae=[],be=u.value;pe.forEach(ce=>{let Fe=be.slice(ce,ce+y).match(I);if(Fe){let se=be.slice(0,ce),Le=be.slice(ce+Fe[0].length);be=`${se}${Le}`,ae.push(ce)}}),u.value=be,ae.length&&(B>ae[ae.length-1]?u.selectionStart=Math.max(B-y,ae[ae.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,Y-y*ae.length))},P=()=>{let{selectionStart:B,selectionEnd:Y,value:pe}=u,ae=pe.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-ae,pe.slice(B,Y).split(`
14
- `).reduce((ce,Fe,se,Le)=>ce.concat(se?ce[se-1]+Le[se-1].length+1:B),[]).reverse()},M=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},D=!1,_=()=>{if(ie)return;ie=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let Y=Pf(B,a.scene.getNonDeletedElementsMap());if(Y){if(u.value.trim()){let pe=y7(Y);!pe||pe!==o.id?a.scene.mutateElement(Y,{boundElements:(Y.boundElements||[]).concat({type:"text",id:o.id})}):Hm(Y)&&x7(Y)}else a.scene.mutateElement(Y,{boundElements:Y.boundElements?.filter(pe=>!gI(pe))});v7(B,Y,a.scene)}n({viaKeyboard:D,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,me&&me.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",M,!0),window.removeEventListener("pointerdown",K),window.removeEventListener("pointerup",L),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),U(),z(),W(),G(),u.remove()},L=B=>{window.removeEventListener("pointerup",L);let Y=B?.target,pe=Y instanceof HTMLElement&&Y.classList.contains("properties-trigger"),ae=(Y instanceof HTMLElement||Y instanceof SVGElement)&&!!Y.closest(".properties-content"),be=(Y instanceof HTMLElement||Y instanceof SVGElement)&&(!!Y.closest(`.${Sf.SHAPE_ACTIONS_MENU}`)||!!Y.closest(".compact-shape-actions-island"));setTimeout(()=>{be||pe||ae||(u.onblur=_,u.focus(),v&&(u.setSelectionRange(v.start,v.end),v=null))})},F=()=>{u.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",_)},K=B=>{let Y=B?.target;if(B.button===d7.WHEEL){Y instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),F();return}let pe=Y instanceof HTMLElement&&Y.classList.contains("properties-trigger"),ae=(Y instanceof HTMLElement||Y instanceof SVGElement)&&!!Y.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${Sf.SHAPE_ACTIONS_MENU}, .${Sf.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!p7(B.target)||pe||ae?F():B.target instanceof HTMLCanvasElement&&!sI()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==m&&p()}),U=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),W=a.onScrollChangeEmitter.on(()=>{p()}),G=a.onStateChange("viewpointFlip",()=>{p()}),ie=!1;s&&!v&&u.select(),L();let me=null;return r&&"ResizeObserver"in window?(me=new window.ResizeObserver(()=>{p()}),me.observe(r)):window.addEventListener("resize",p),u.onpointerdown=B=>B.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",K,{capture:!0})}),window.addEventListener("beforeunload",_),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),_};import{getGlobalCSSVariable as Um}from"@excalidraw/common";import{getCommonBounds as B7}from"@excalidraw/element";var Ro=4,fn=6,EI="rgba(0,0,0,0.3)",bI=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=B7(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(Um("sat"))||0,bottom:parseInt(Um("sab"))||0,left:parseInt(Um("sal"))||0,right:parseInt(Um("sar"))||0},m=Jn().rtl,p=-o.scrollX+d.left,u=-o.scrollY+d.top,E=p+l-d.right,g=u+c-d.bottom,b=Math.min(r,p),v=Math.min(i,u),y=Math.max(a,E),x=Math.max(s,g),I=a-r,T=s-i,C=y-b,P=x-v,M=Math.max(Ro*2,d.left+d.right)+fn*2,D=n*(l/C)-M,_=Math.max(Ro*2,d.top+d.bottom)+fn*2,k=t*(c/P)-_,L=C>I?C*o.zoom.value/(D+M):n/(D+M),F=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===y?null:{x:Math.max(d.left,Ro)+fn+(p-b)/C*n,y:t-fn-Math.max(Ro,d.bottom),width:D,height:fn,deltaMultiplier:L},vertical:u===v&&g===x?null:{x:m?Math.max(d.left,Ro):n-fn-Math.max(d.right,Ro),y:Math.max(d.top,Ro)+fn+(u-v)/P*t,width:fn,height:k,deltaMultiplier:F}}},kf=(e,n,t)=>{let[o,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=n&&n<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:o||r,isOverHorizontal:o,isOverVertical:r}};import{pointFrom as tB}from"@excalidraw/math";import{getElementLineSegments as nB}from"@excalidraw/element";import{LinearElementEditor as oB}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as rB,isLinearElement as iB}from"@excalidraw/element";import{getFrameChildren as aB}from"@excalidraw/element";import{selectGroupsForSelectedElements as sB}from"@excalidraw/element";import{arrayToMap as lB,easeOut as SI,isShallowEqual as cB}from"@excalidraw/common";import{simplify as F7}from"points-on-curve";import{polygonFromPoints as O7,lineSegment as Vm,pointFrom as Ba,pointOnLineSegment as z7,polygonIncludesPointNonZero as G7,PRECISION as Wm}from"@excalidraw/math";import{boundsContainBounds as yI,computeBoundTextPosition as H7,doBoundsIntersect as U7,elementOverlapsWithFrame as W7,getBoundTextElement as wI,getContainingFrame as V7,getElementBounds as vI,intersectElementWithLineSegment as Y7,isBoundToContainer as II,pointInsideBoundsInclusive as K7}from"@excalidraw/element";var TI=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=F7(n,s));let d=t.filter(g=>!g.locked&&!II(g));a.clear(),i.clear();let m=n.reduce((g,b)=>[Math.min(g[0],b[0]),Math.min(g[1],b[1]),Math.max(g[2],b[0]),Math.max(g[3],b[1])],[1/0,1/0,-1/0,-1/0]),p=O7(c),u=[m[0]-Wm,m[1]-Wm,m[2]+Wm,m[3]+Wm];for(let g of d){let b=vI(g,o),v=X7(g,b,o),y=Z7(b,v);if(U7(m,y)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!yI(u,y))continue;let x=$7(g,o,r,v),I=J7(p,x,y,l);l==="contain"?I&&!xI(c,g,o,v)&&a.add(g.id):I?a.add(g.id):xI(c,g,o,v)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?q7([...a],o):[...i,...a]}},X7=(e,n,t)=>{let o=V7(e,t);if(!o)return null;let r=vI(o,t);return yI(r,n)?null:W7(e,o,t)?r:null},Z7=(e,n)=>n?[Math.max(e[0],n[0]),Math.max(e[1],n[1]),Math.min(e[2],n[2]),Math.min(e[3],n[3])]:e,$7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=wI(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?j7(s,o):s},j7=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[s,l],[c,d]]of e){let m=c-s,p=d-l,u=0,E=1,g=!0;for(let[b,v]of[[-m,s-t],[m,r-s],[-p,l-o],[p,i-l]]){if(b===0){if(v<0){g=!1;break}continue}let y=v/b;if(b<0){if(y>E){g=!1;break}u=Math.max(u,y)}else{if(y<u){g=!1;break}E=Math.min(E,y)}}g&&a.push(Vm(Ba(s+u*m,l+u*p),Ba(s+E*m,l+E*p)))}return a},q7=(e,n)=>{if(!e.some(r=>n.get(r)?.groupIds.length))return e;let t=new Map;for(let r of n.values()){let i=r.groupIds.at(-1);if(!i||r.locked||II(r))continue;let a=t.get(i);a?a.push(r.id):t.set(i,[r.id])}if(!t.size)return e;let o=new Set(e);return e.filter(r=>{let i=n.get(r)?.groupIds.at(-1),a=i?t.get(i):null;return!a||a.every(s=>o.has(s))})},J7=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>G7(a,e)||o==="contain"&&eB(a,e);return n.length===0?Q7(t)[r](i):n[r](a=>a[r](i))},Q7=([e,n,t,o])=>[Ba(e,n),Ba(t,n),Ba(t,o),Ba(e,o)],eB=(e,n)=>n.some((t,o)=>o>0&&z7(e,Vm(n[o-1],t))),xI=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Vm(e[l],s)).concat([Vm(e[e.length-1],e[0])]),i=wI(n,t),a=(s,l)=>{let c=Y7(s,t,l,0,!o);return o?c.some(d=>K7(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...H7(n,i,t)},s))};var Ym=class extends zn{constructor(t){super(t,{animateTrail:!0,streamline:.4,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/(1/0)),s=(5e3-Math.min(5e3,o.totalLength-o.currentIndex))/5e3;return Math.min(SI(s),SI(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});w(this,"intersectedElements",new Set);w(this,"enclosedElements",new Set);w(this,"elementsSegments",null);w(this,"canvasTranslate",null);w(this,"keepPreviousSelection",!1);w(this,"selectElementsFromIds",t=>{this.app.setState(o=>{let r=t.reduce((l,c)=>(l[c]=!0,l),{});if(this.keepPreviousSelection)for(let l of Object.keys(o.selectedElementIds))r[l]=!0;for(let[l]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(l);if(c&&rB(c)){let d=aB(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=sB({editingGroupId:o.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),o,this.app),a=[...Object.keys(i.selectedElementIds)],s=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!s.length&&iB(this.app.scene.getNonDeletedElement(a[0]))?new oB(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});w(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});w(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>tB(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!cB(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=lB(this.app.visibleElements);for(let i of this.app.visibleElements){let a=nB(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=TI({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value,mode:this.app.state.boxSelectionMode});this.selectElementsFromIds(r)}})}startPath(t,o,r=!1){this.endPath(),super.startPath(t,o),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as dB,easeOut as CI,THEME as mB}from"@excalidraw/common";import{computeBoundTextPosition as pB,doBoundsIntersect as uB,getBoundTextElement as hB,getElementBounds as gB,getElementLineSegments as fB,getFreedrawOutlineAsSegments as EB,getFreedrawOutlinePoints as bB,intersectElementWithLineSegment as PI,isArrowElement as xB,isFreeDrawElement as kI,isLineElement as yB,isPointInElement as wB}from"@excalidraw/element";import{lineSegment as vB,lineSegmentsDistance as MI,pointFrom as NI,polygon as IB,polygonIncludesPointNonZero as TB}from"@excalidraw/math";import{getElementsInGroup as AI}from"@excalidraw/element";import{shouldTestInside as SB}from"@excalidraw/element";import{hasBoundTextElement as DI,isBoundToContainer as LI}from"@excalidraw/element";import{getBoundTextElementId as _I}from"@excalidraw/element";var Km=class extends zn{constructor(t){super(t,{streamline:.2,size:5,keepHead:!0,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/200),s=(10-Math.min(10,o.totalLength-o.currentIndex))/10;return Math.min(CI(s),CI(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===mB.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")});w(this,"elementsToErase",new Set);w(this,"groupsToErase",new Set)}startPath(t,o){this.endPath(),super.startPath(t,o),this.elementsToErase.clear()}addPointToPath(t,o,r=!1){return super.addPointToPath(t,o),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let o=super.getCurrentTrail()?.originalPoints?.map(s=>NI(s[0],s[1]))||[];if(o.length<2)return[];let r=vB(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=dB(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(RI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=AI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(LI(s)&&this.elementsToErase.delete(s.containerId),DI(s)){let d=_I(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&RI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=AI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(DI(s)){let d=_I(s);d&&this.elementsToErase.add(d)}LI(s)&&this.elementsToErase.add(s.containerId),this.elementsToErase.add(s.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},RI=(e,n,t,o)=>{let r=e[1],i=kI(n)?15:n.strokeWidth/2,a=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],s=gB(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!uB(a,l))return!1;if(SB(n)&&wB(r,n,t))return!0;if(kI(n)){let d=bB(n),m=EB(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if(MI(E,e)<=p)return!0;let u=IB(...d.map(([E,g])=>NI(n.x+E,n.y+g)));return!!TB(e[0],u)}let c=hB(n,t);if(xB(n)||yB(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=fB(n,t);for(let p of m)if(MI(p,e)<=d)return!0;return!1}return PI(n,t,e,0,!0).length>0||!!c&&PI({...c,...pB(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as HB}from"@excalidraw/common";import{newElement as UB}from"@excalidraw/element";import{COLOR_PALETTE as CB,DEFAULT_FONT_FAMILY as PB,DEFAULT_FONT_SIZE as kB,VERTICAL_ALIGN as MB}from"@excalidraw/common";var BI=44,FI=22,OI=66,zI=48,Hl=14,GI=304,HI=320,Mf=5.87,UI=28,WI=4,VI=2,Af=10,YI=10,KI=8,mo=12,Fa=256,mi=10,Df=4,Oa=mo*2,Lf=mo*2,XI=100,ZI=140,Ul=.35,$I=mo/2,xr=20,Xm=mo*2,_f=mo,ze={fillStyle:"hachure",fontFamily:PB,fontSize:kB,opacity:100,roughness:1,strokeColor:CB.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:MB.MIDDLE,locked:!1};import{pointFrom as za}from"@excalidraw/math";import{COLOR_PALETTE as eT,DEFAULT_CHART_COLOR_INDEX as AB,FONT_FAMILY as Bf,FONT_SIZES as Zm,ROUNDNESS as jI,DEFAULT_FONT_SIZE as DB,getAllColorsSpecificShade as LB,getFontString as Ff,getLineHeight as Of,ROUGHNESS as qI}from"@excalidraw/common";import{getApproxMinLineWidth as zf,measureText as yr,newElement as Nf,newLinearElement as Rf,newTextElement as Ga,wrapText as tT}from"@excalidraw/element";var pi=LB(AB),_B=e=>e.labels?.length??e.series[0]?.values.length??0,Ha=(e,n)=>{if(!e)return!1;let t=_B(e);return t<2?!1:n==="radar"?t>=3:!0},JI=(e,n)=>{let t=n<=1?0:Math.min(OI,(n-1)*FI);return e+t},$m=(e,n)=>{if(e==="line"){let o=JI(zI,n);return{slotWidth:o,gap:Hl,chartHeight:HI,xLabelMaxWidth:o+Hl*3+Af}}let t=JI(BI,n);return{slotWidth:t,gap:Hl,chartHeight:GI,xLabelMaxWidth:t+Hl*3+Af}},Ua=(e,n)=>{let t=(n.slotWidth+n.gap)*e.series[0].values.length+n.gap,o=n.chartHeight+n.gap*2;return{chartWidth:t,chartHeight:o}},nT=()=>{let e=Fa+Lf*2,n=Fa+Lf*2;return{chartWidth:e,chartHeight:n}},RB=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},Wa=(e,n)=>{if(e<=0||pi.length===0)return[];let t=pi.length,o=(n%t+t)%t,r=[o],i=Math.min(e,t),a=new Set(Array.from({length:t},(s,l)=>l).filter(s=>s!==o));for(;r.length<i;){let s=-1,l=-1,c=-1;for(let d of a){let m=r.map(E=>RB(d,E,t)),p=Math.min(...m),u=m.reduce((E,g)=>E+g,0)/m.length;(p>l||p===l&&u>c)&&(s=d,l=p,c=u)}r.push(s),a.delete(s)}return Array.from({length:e},(s,l)=>pi[r[l%r.length]])},Va=e=>{if(pi.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*pi.length);let n=e.toString(),t=0;for(let o=0;o<n.length;o++)t=t*31+n.charCodeAt(o)|0;return Math.abs(t)%pi.length},Ya=e=>pi[e],oT=(e,n)=>{let t=e.flatMap(s=>s.values.map(l=>Math.max(0,l))),o=t.filter(s=>s>0),r=Math.max(1,...t),i=o.length>0?Math.min(...o):1,a=e.length===1&&i>0&&r/i>=XI;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},NB=e=>/\s/.test(e.trim()),jm=(e,n,t)=>NB(e)?tT(e,n,t):e,rT=(e,n,t,o,r,i)=>{let a=Bf.Excalifont,s=Zm.sm,l=Of(a),c=Ff({fontFamily:a,fontSize:s}),d=Math.min(ZI,r*(e.length>8?.56:.72)),m=zf(c,l),p=e.map((g,b)=>{let v=n[b],y=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>yr(z,c,l).width)),x=Math.max(m,d,y),I=jm(g,c,x),T=yr(I,c,l),C=Math.cos(v),P=Math.sin(v),M=C>Ul?"left":C<-Ul?"right":"center",D=M==="center"?T.width/2:0,_=Math.abs(C)*D+Math.abs(P)*(T.height/2),k=Oa+_+$I,L=t+C*(r+k),F=o+P*(r+k),K=P>Ul?mo/3:P<-Ul?-mo/3:0;return Ga({backgroundColor:i,...ze,text:I,originalText:g,x:L,y:F+K,fontFamily:a,fontSize:s,lineHeight:l,textAlign:M,verticalAlign:"middle"})}),u=Math.min(...p.map(g=>g.y)),E=Math.max(...p.map(g=>g.y+g.height));return{axisLabels:p,axisLabelTopY:u,axisLabelBottomY:E}},Ka=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=Bf["Lilita One"],s=Zm.lg,l=Of(a),c=Ff({fontFamily:a,fontSize:s}),d=e.map((I,T)=>{let C=I.title?.trim()||`Series ${T+1}`,P=jm(C,c,Fa),M=yr(P,c,l),D=xr+_f+M.width;return{label:C,displayLabel:P,color:n[T],width:D,height:M.height}}),m=Math.max(xr/2,...d.map(I=>I.height/2)),p=Math.max(r,o+m+Oa),u=Xm,E=xr*.6,g=d.reduce((I,T)=>I+T.width,0)+Xm*Math.max(0,d.length-1),b=g+u*2,v=m*2+E*2,y=[];y.push(Nf({...ze,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:eT.black,x:t-b/2,y:p-v/2,width:b,height:v,roughness:qI.architect,roundness:{type:jI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(I=>{y.push(Nf({...ze,backgroundColor:I.color,type:"rectangle",x,y:p-xr/2,width:xr,height:xr,fillStyle:"solid",strokeColor:I.color,roughness:qI.architect,roundness:{type:jI.PROPORTIONAL_RADIUS}})),y.push(Ga({...ze,text:I.displayLabel,originalText:I.label,autoResize:!1,x:x+xr+_f,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=I.width+Xm}),y},BB=(e,n,t,o)=>{if(yr(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(yr(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},FB=(e,n,t,o)=>{if(yr(e,t,o).width<=n)return{wrapped:!1,text:e};let r=e.trim().split(/\s+/).filter(Boolean);return r.length>1&&!r.some(a=>yr(a,t,o).width>n)&&n>=zf(t,o)?{wrapped:!0,text:tT(e,t,n)}:{wrapped:!1,text:BB(e,n,t,o)}},iT=(e,n,t)=>{let o=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return{width:e*o+n*r,height:e*r+n*o}},QI=e=>e.includes("..."),OB=(e,n,t,o,r)=>{let i=Math.max(UI,Math.ceil(zf(o,r))),a=Math.max(i,Math.floor(n)),s=[];for(let u=a;u>=i;u-=4)s.push(u);s[s.length-1]!==i&&s.push(i);let l=u=>{let E=QI(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
15
- `).length;return{ellipsified:E,visibleChars:g,lineCount:b}},c=(u,E)=>{let g=l(u),b=l(E);return g.ellipsified!==b.ellipsified?!g.ellipsified:g.visibleChars!==b.visibleChars?g.visibleChars>b.visibleChars:g.lineCount!==b.lineCount?g.lineCount<b.lineCount:u.rotatedHeight<E.rotatedHeight},d=null,m=null,p=null;for(let u of s){let{wrapped:E,text:g}=FB(e,u,o,r),b=yr(g,o,r),v=iT(b.width,b.height,Mf),y={originalText:e,text:g,metrics:b,rotatedWidth:v.width,rotatedHeight:v.height,wrapped:E},x=v.width-t;if(x<=0){(!d||c(y,d))&&(d=y);continue}(!m||x<m.overflow||x===m.overflow&&c(y,m.spec))&&(m={overflow:x,spec:y}),!QI(y.text)&&(!p||x<p.overflow||x===p.overflow&&c(y,p.spec))&&(p={overflow:x,spec:y})}return d||(p&&m&&p.overflow<=m.overflow+KI?p.spec:m.spec)},qm=e=>{if(e.type!=="text")return e.y+e.height;let n=iT(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},Wl=(e,n,t,o,r)=>{let i=ze.fontFamily,a=Zm.sm,s=Of(i),l=Ff({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-WI*2+YI),d=t;return e.labels?.map((m,p)=>{let u=OB(m,r.xLabelMaxWidth,c,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+VI+(u.rotatedHeight-u.metrics.height)/2;return Ga({backgroundColor:o,...ze,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:Mf,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},zB=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=Ga({backgroundColor:o,...ze,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=Ga({backgroundColor:o,...ze,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},GB=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=Ua(e,r),s=Rf({backgroundColor:o,...ze,type:"line",x:n,y:t,width:i,points:[za(0,0),za(i,0)]}),l=Rf({backgroundColor:o,...ze,type:"line",x:n,y:t,height:a,points:[za(0,0),za(0,-a)]}),c=Rf({backgroundColor:o,...ze,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:mi,points:[za(0,0),za(i,0)]});return[s,l,c]},Jm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=Ua(e,r),c=e.title?Ga({backgroundColor:o,...ze,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-DB,roundness:null,textAlign:"center",fontSize:Zm.xl,fontFamily:Bf["Lilita One"]}):null,d=a?Nf({backgroundColor:o,...ze,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:eT.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...Wl(e,n,t,o,r),...zB(e,n,t,o,r,i),...GB(e,n,t,o,r)]};var aT=(e,n,t,o)=>{let r=e.series,i=$m("bar",r.length),a=Math.max(1,...r.flatMap(I=>I.values.map(T=>Math.max(0,T)))),s=Va(o),l=Ya(s),c=Wa(r.length,s),d=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,m=r.length>1?Math.max(2,(i.slotWidth-d*(r.length-1))/r.length):i.slotWidth,p=r.length*m+d*(r.length-1),u=(i.slotWidth-p)/2,E=r[0].values.flatMap((I,T)=>r.map((C,P)=>{let D=Math.max(0,C.values[T]??0)/a*i.chartHeight,_=r.length>1?c[P]:l;return UB({backgroundColor:_,...ze,type:"rectangle",fillStyle:r.length>1?"solid":ze.fillStyle,strokeColor:r.length>1?_:ze.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+P*(m+d),y:t-D-i.gap,width:m,height:D})})),g=Jm(e,n,t,l,i,a,HB()),b=Wl(e,n,t,l,i),v=Math.max(t+i.gap/2,...b.map(I=>qm(I))),{chartWidth:y}=Ua(e,i),x=Ka(r,c,n+y/2,v,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as Gf}from"@excalidraw/math";import{isDevEnv as WB}from"@excalidraw/common";import{newElement as VB,newLinearElement as sT}from"@excalidraw/element";var lT=(e,n,t,o)=>{let r=e.series,i=$m("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=Va(o),l=Ya(s),c=Wa(r.length,s),d=r.map((x,I)=>{let T=x.values.map((_,k)=>Gf(k*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),C=Math.max(...T.map(_=>_[0])),P=Math.max(...T.map(_=>_[1])),M=Math.min(...T.map(_=>_[0])),D=Math.min(...T.map(_=>_[1]));return sT({backgroundColor:"transparent",...ze,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-D,width:C-M,strokeColor:c[I],strokeWidth:2,points:T})}),m=r.flatMap((x,I)=>x.values.map((T,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,M=-(T/a)*i.chartHeight+i.gap/2;return VB({backgroundColor:c[I],...ze,fillStyle:"solid",strokeColor:c[I],strokeWidth:2,type:"ellipse",x:n+P+i.slotWidth/2,y:t+M-i.gap*2,width:i.gap,height:i.gap})})),u=r[0].values.map((x,I)=>Math.max(0,...r.map(T=>T.values[I]??0))).map((x,I)=>{let T=I*(i.slotWidth+i.gap)+i.gap/2,C=x/a*i.chartHeight+i.gap/2+i.gap;return sT({backgroundColor:l,...ze,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:mi,points:[Gf(0,0),Gf(0,C)]})}),E=Jm(e,n,t,l,i,a,WB()),g=Wl(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>qm(x))),{chartWidth:v}=Ua(e,i),y=Ka(r,c,n+v/2,b,t+i.gap*5,l);return[...E,...d,...u,...m,...y]};var Gn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},YB=(e,n)=>e.slice(1).every(t=>Gn(t[n])!==null),cT=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>Gn(m)===null),s=a?e.slice(1):e;if(s.length<1)return{ok:!1,reason:"No data rows"};if(s.some(m=>m.slice(1).some(p=>Gn(p)===null)))return{ok:!1,reason:"Value is not numeric"};if(n-1>s.length){let m=a?e[0].slice(1).map(E=>E.trim()):null,p=s.map(E=>({title:E[0]?.trim()||null,values:E.slice(1).map(g=>Gn(g))}));return{ok:!0,data:{title:p.length===1?p[0].title:a&&e[0][0].trim()||null,labels:m,series:p}}}let d=e[0].slice(1).map((m,p)=>{let u=p+1,E=`Series ${u}`;return{title:a&&m.trim()||E,values:s.map(g=>Gn(g[u]))}});return{ok:!0,data:{title:a&&e[0][0].trim()||null,labels:s.map(m=>m[0]),series:d}}}if(n===1){if(!YB(e,0))return{ok:!1,reason:"Value is not numeric"};let a=Gn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>Gn(c[0]));return l.length<2?{ok:!1,reason:"Less than two rows"}:{ok:!0,data:{title:s,labels:null,series:[{title:s,values:l}]}}}let t=Gn(e[0][1])===null,o=t?e.slice(1):e;if(o.length<2)return{ok:!1,reason:"Less than 2 rows"};if(o.some(a=>Gn(a[1])===null))return{ok:!1,reason:"Value is not numeric"};let i=t?e[0][1]:null;return{ok:!0,data:{title:i,labels:o.map(a=>a[0]),series:[{title:i,values:o.map(a=>Gn(a[1]))}]}}},Qm=e=>{let n=s=>e.replace(/\r\n?/g,`
13
+ `,n),r=e.slice(t,o===-1?e.length:o);return E7(r)?"rtl":"ltr"},F7=e=>{let n=[0],t=0;for(let o of Array.from(e))t+=o.length,n.push(t);return n},O7=({text:e,font:n,lineHeightPx:t,direction:o,targetX:r})=>{if(!e||!document.body||typeof document.createRange!="function")return null;let i=F7(e),a=document.createElement("div"),s=document.createTextNode(e),l=document.createRange(),c=[];a.dir=o,Object.assign(a.style,{position:"fixed",top:"0",left:"0",margin:0,padding:0,border:0,opacity:"0",pointerEvents:"none",whiteSpace:"pre",font:n,lineHeight:`${t}px`}),a.append(s),document.body.append(a);try{for(let u of i){l.setStart(s,u),l.setEnd(s,u);let E=l.getBoundingClientRect();if(!Number.isFinite(E.left))return null;c.push(E.left)}}catch{return null}finally{a.remove()}let d=Math.min(...c),m=i[0],p=1/0;for(let u=0;u<i.length;u++){let E=Math.abs(c[u]-d-r);E<p&&(p=E,m=i[u])}return m},EI=({onChange:e,onSubmit:n,getViewportCoords:t,element:o,canvas:r,excalidrawContainer:i,app:a,autoSelect:s=!0,initialCaretSceneCoords:l=null})=>{let c=null,d=(B,Y)=>{if(!Y.style.fontFamily||!Y.style.fontSize)return!1;let pe=Y.style.fontFamily.replace(/"/g,"");return sI({fontFamily:B.fontFamily})!==pe||`${B.fontSize}px`!==Y.style.fontSize},m=a.state.theme,p=()=>{m=a.state.theme;let B=a.state,Y=a.scene.getElement(o.id);if(!Y)return;let{textAlign:pe,verticalAlign:ae}=Y,xe=a.scene.getNonDeletedElementsMap();if(Y&&fI(Y)){let ce=Y.x,Oe=Y.y,se=kf(Y,a.scene.getNonDeletedElementsMap()),_e=Y.width,Re=Y.height,Se=Y.width,Mt=Y.height;if(se&&Y.containerId){if(Hm(se)){let At=w7.getBoundTextElementPosition(se,Y,xe);ce=At.x,Oe=At.y}let vs=d(Y,u),yo;if(vs?yo=pI(se.id,se.height):(yo=y7[se.id],yo||(yo=pI(se.id,se.height))),Se=uI(se,Y),Mt=C7(se,Y),!Hm(se)&&Re>Mt){let At=hI(Re,se.type);a.scene.mutateElement(se,{height:At}),mI(se,a.scene);return}else if(!Hm(se)&&se.height>yo.height&&Re<Mt){let At=hI(Re,se.type);a.scene.mutateElement(se,{height:At}),mI(se,a.scene)}else{let{x:At,y:Is}=P7(se,Y,xe);ce=At,Oe=Is}}let[kn,Mn]=t(ce,Oe);se?_e+=.5:(Se=(B.viewpointFlip.horizontal?kn-8:B.width-8-kn)/B.zoom.value,_e=Math.min(_e,Se)),Re*=1.05;let Ko=aI(Y),Ai=T7(Y,se),Di=(B.viewpointFlip.vertical?Mn:B.height-Mn)/B.zoom.value;Object.assign(u.style,{font:Ko,lineHeight:Y.lineHeight,width:`${_e}px`,height:`${Re}px`,left:`${kn}px`,top:`${Mn}px`,transform:N7(_e,Re,Ai,B,Se,Di),textAlign:pe,verticalAlign:ae,color:f7(Y.strokeColor,B.theme===h7.DARK),opacity:Y.opacity/100,maxHeight:`${Di}px`}),c={angle:Ai,font:Ko,height:Y.height,lineHeightPx:A7(Y.fontSize,Y.lineHeight),textAlign:pe,width:Y.width,x:ce,y:Oe},u.scrollTop=0,lI()&&(u.style.fontFamily=sI(Y)),a.scene.mutateElement(Y,{x:ce,y:Oe})}},u=document.createElement("textarea");u.dir="auto",u.tabIndex=0,u.dataset.type="wysiwyg",u.wrap="off",u.classList.add("excalidraw-wysiwyg");let E="pre",g="normal";(R7(o)||!o.autoResize)&&(E="pre-wrap",g="break-word"),Object.assign(u.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:g,whiteSpace:E,overflowWrap:"break-word",boxSizing:"content-box"}),u.value=o.originalText,p();let b=()=>{if(!l||!c)return null;let B=c,Y=dI(B.x+B.width/2,B.y+B.height/2),[pe,ae]=b7(dI(l.x,l.y),Y,-B.angle),xe=pe-B.x,ce=ae-B.y,Oe=_7(u.value,B.font,E==="pre-wrap"?B.width:1/0),se=Math.max(0,Math.min(Oe.length-1,Math.floor(ce/B.lineHeightPx))),_e=Oe[se],Re=B7(u.value,_e.start),Se=D7(_e.text,B.font),Mt=B.textAlign==="center"?(B.width-Se)/2:B.textAlign==="right"?B.width-Se:0,kn=xe-Mt;if(!_e.text)return _e.start;let Mn=O7({text:_e.text,font:B.font,lineHeightPx:B.lineHeightPx,direction:Re,targetX:kn});return _e.start+(Mn||0)},v=(()=>{let B=b();return B===null?null:{start:B,end:B}})();e&&(u.onpaste=async B=>{let Y=Mw(B),pe=null;if(Y.has(Pf.excalidrawClipboard)||Y.has(Pf.excalidraw)){B.preventDefault(),pe=await ur(B);try{let se=await ml(pe);if(se.elements){let _e=x7(se.elements);if(_e){let{selectionStart:Re,selectionEnd:Se,value:Mt}=u;u.value=Mt.slice(0,Re)+_e+Mt.slice(Se);let kn=Re+_e.length;u.selectionStart=u.selectionEnd=kn,u.dispatchEvent(new Event("input"))}}return}catch{console.warn("failed to parse excalidraw clipboard data")}}pe=pe||await ur(B);let ae=pe.findByType(Pf.text);if(!ae)return;let xe=gI(ae.value);if(!xe)return;let ce=kf(o,a.scene.getNonDeletedElementsMap()),Oe=aI({fontSize:a.state.currentItemFontSize,fontFamily:a.state.currentItemFontFamily});if(ce){let se=k7(ce,a.scene.getNonDeletedElementsMap()),_e=L7(`${u.value}${xe}`,Oe,uI(ce,se)),Re=M7(_e,Oe);u.style.width=`${Re}px`}},u.oninput=()=>{let B=gI(u.value);if(u.value!==B){let Y=u.selectionStart;u.value=B,u.selectionStart=Y,u.selectionEnd=Y}e(u.value)}),u.onkeydown=B=>{if(!B.shiftKey&&zd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(zd),p();else if(!B.shiftKey&&Gd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Gd),p();else if(!B.shiftKey&&Hd.keyTest(B))B.preventDefault(),a.actionManager.executeAction(Hd),p();else if(jh.keyTest(B))a.actionManager.executeAction(jh);else if(qh.keyTest(B))a.actionManager.executeAction(qh);else if(B.key===Gl.ESCAPE)B.preventDefault(),D=!0,_();else if(ti.keyTest(B))B.preventDefault(),_(),a.actionManager.executeAction(ti);else if(B.key===Gl.ENTER&&B[Gl.CTRL_OR_CMD]){if(B.preventDefault(),B.isComposing||B.keyCode===229)return;D=!0,_()}else if(B.key===Gl.TAB||B[Gl.CTRL_OR_CMD]&&(B.code===Sf.BRACKET_LEFT||B.code===Sf.BRACKET_RIGHT)){if(B.preventDefault(),B.isComposing)return;B.shiftKey||B.code===Sf.BRACKET_LEFT?C():T(),u.dispatchEvent(new Event("input"))}};let w=4,x=" ".repeat(w),I=new RegExp(`^ {1,${w}}`),T=()=>{let{selectionStart:B,selectionEnd:Y}=u,pe=P(),ae=u.value;pe.forEach(xe=>{let ce=ae.slice(0,xe),Oe=ae.slice(xe);ae=`${ce}${x}${Oe}`}),u.value=ae,u.selectionStart=B+w,u.selectionEnd=Y+w*pe.length},C=()=>{let{selectionStart:B,selectionEnd:Y}=u,pe=P(),ae=[],xe=u.value;pe.forEach(ce=>{let Oe=xe.slice(ce,ce+w).match(I);if(Oe){let se=xe.slice(0,ce),_e=xe.slice(ce+Oe[0].length);xe=`${se}${_e}`,ae.push(ce)}}),u.value=xe,ae.length&&(B>ae[ae.length-1]?u.selectionStart=Math.max(B-w,ae[ae.length-1]):u.selectionStart=B,u.selectionEnd=Math.max(u.selectionStart,Y-w*ae.length))},P=()=>{let{selectionStart:B,selectionEnd:Y,value:pe}=u,ae=pe.slice(0,B).match(/[^\n]*$/)[0].length;return B=B-ae,pe.slice(B,Y).split(`
14
+ `).reduce((ce,Oe,se,_e)=>ce.concat(se?ce[se-1]+_e[se-1].length+1:B),[]).reverse()},M=B=>{B.target instanceof HTMLCanvasElement&&(B.preventDefault(),B.stopPropagation())},D=!1,_=()=>{if(ie)return;ie=!0,k();let B=a.scene.getElement(o.id);if(!B)return;let Y=kf(B,a.scene.getNonDeletedElementsMap());if(Y){if(u.value.trim()){let pe=I7(Y);!pe||pe!==o.id?a.scene.mutateElement(Y,{boundElements:(Y.boundElements||[]).concat({type:"text",id:o.id})}):Hm(Y)&&v7(Y)}else a.scene.mutateElement(Y,{boundElements:Y.boundElements?.filter(pe=>!fI(pe))});S7(B,Y,a.scene)}n({viaKeyboard:D,nextOriginalText:u.value})},k=()=>{u.onblur=null,u.oninput=null,u.onkeydown=null,me&&me.disconnect(),window.removeEventListener("resize",p),window.removeEventListener("wheel",M,!0),window.removeEventListener("pointerdown",K),window.removeEventListener("pointerup",L),window.removeEventListener("blur",_),window.removeEventListener("beforeunload",_),U(),z(),W(),G(),u.remove()},L=B=>{window.removeEventListener("pointerup",L);let Y=B?.target,pe=Y instanceof HTMLElement&&Y.classList.contains("properties-trigger"),ae=(Y instanceof HTMLElement||Y instanceof SVGElement)&&!!Y.closest(".properties-content"),xe=(Y instanceof HTMLElement||Y instanceof SVGElement)&&(!!Y.closest(`.${Cf.SHAPE_ACTIONS_MENU}`)||!!Y.closest(".compact-shape-actions-island"));setTimeout(()=>{xe||pe||ae||(u.onblur=_,u.focus(),v&&(u.setSelectionRange(v.start,v.end),v=null))})},F=()=>{u.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",_)},K=B=>{let Y=B?.target;if(B.button===u7.WHEEL){Y instanceof HTMLTextAreaElement&&(B.preventDefault(),a.handleCanvasPanUsingWheelOrSpaceDrag(B)),F();return}let pe=Y instanceof HTMLElement&&Y.classList.contains("properties-trigger"),ae=(Y instanceof HTMLElement||Y instanceof SVGElement)&&!!Y.closest(".properties-content");(B.target instanceof HTMLElement||B.target instanceof SVGElement)&&(B.target.closest(`.${Cf.SHAPE_ACTIONS_MENU}, .${Cf.ZOOM_ACTIONS}`)||B.target.closest(".compact-shape-actions-island"))&&!g7(B.target)||pe||ae?F():B.target instanceof HTMLCanvasElement&&!lI()&&requestAnimationFrame(()=>{_()})},z=a.onChangeEmitter.on(B=>{a.state.theme!==m&&p()}),U=a.scene.onUpdate(()=>{p(),!!document.activeElement?.closest(".properties-content")||u.focus()}),W=a.onScrollChangeEmitter.on(()=>{p()}),G=a.onStateChange("viewpointFlip",()=>{p()}),ie=!1;s&&!v&&u.select(),L();let me=null;return r&&"ResizeObserver"in window?(me=new window.ResizeObserver(()=>{p()}),me.observe(r)):window.addEventListener("resize",p),u.onpointerdown=B=>B.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",K,{capture:!0})}),window.addEventListener("beforeunload",_),i?.querySelector(".excalidraw-textEditorContainer").appendChild(u),_};import{getGlobalCSSVariable as Um}from"@excalidraw/common";import{getCommonBounds as z7}from"@excalidraw/element";var Ro=4,fn=6,bI="rgba(0,0,0,0.3)",xI=(e,n,t,o)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,s]=z7(e),l=n/o.zoom.value,c=t/o.zoom.value,d={top:parseInt(Um("sat"))||0,bottom:parseInt(Um("sab"))||0,left:parseInt(Um("sal"))||0,right:parseInt(Um("sar"))||0},m=Jn().rtl,p=-o.scrollX+d.left,u=-o.scrollY+d.top,E=p+l-d.right,g=u+c-d.bottom,b=Math.min(r,p),v=Math.min(i,u),w=Math.max(a,E),x=Math.max(s,g),I=a-r,T=s-i,C=w-b,P=x-v,M=Math.max(Ro*2,d.left+d.right)+fn*2,D=n*(l/C)-M,_=Math.max(Ro*2,d.top+d.bottom)+fn*2,k=t*(c/P)-_,L=C>I?C*o.zoom.value/(D+M):n/(D+M),F=P>T?P*o.zoom.value/(k+_):t/(k+_);return{horizontal:p===b&&E===w?null:{x:Math.max(d.left,Ro)+fn+(p-b)/C*n,y:t-fn-Math.max(Ro,d.bottom),width:D,height:fn,deltaMultiplier:L},vertical:u===v&&g===x?null:{x:m?Math.max(d.left,Ro):n-fn-Math.max(d.right,Ro),y:Math.max(d.top,Ro)+fn+(u-v)/P*t,width:fn,height:k,deltaMultiplier:F}}},Mf=(e,n,t)=>{let[o,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=n&&n<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:o||r,isOverHorizontal:o,isOverVertical:r}};import{pointFrom as rB}from"@excalidraw/math";import{getElementLineSegments as iB}from"@excalidraw/element";import{LinearElementEditor as aB}from"@excalidraw/element/linearElementEditor";import{isFrameLikeElement as sB,isLinearElement as lB}from"@excalidraw/element";import{getFrameChildren as cB}from"@excalidraw/element";import{selectGroupsForSelectedElements as dB}from"@excalidraw/element";import{arrayToMap as mB,easeOut as CI,isShallowEqual as pB}from"@excalidraw/common";import{simplify as G7}from"points-on-curve";import{polygonFromPoints as H7,lineSegment as Vm,pointFrom as Ba,pointOnLineSegment as U7,polygonIncludesPointNonZero as W7,PRECISION as Wm}from"@excalidraw/math";import{boundsContainBounds as wI,computeBoundTextPosition as V7,doBoundsIntersect as Y7,elementOverlapsWithFrame as K7,getBoundTextElement as vI,getContainingFrame as X7,getElementBounds as II,intersectElementWithLineSegment as Z7,isBoundToContainer as TI,pointInsideBoundsInclusive as $7}from"@excalidraw/element";var SI=e=>{let{lassoPath:n,elements:t,elementsMap:o,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:s,mode:l="contain"}=e,c=n;s&&(c=G7(n,s));let d=t.filter(g=>!g.locked&&!TI(g));a.clear(),i.clear();let m=n.reduce((g,b)=>[Math.min(g[0],b[0]),Math.min(g[1],b[1]),Math.max(g[2],b[0]),Math.max(g[3],b[1])],[1/0,1/0,-1/0,-1/0]),p=H7(c),u=[m[0]-Wm,m[1]-Wm,m[2]+Wm,m[3]+Wm];for(let g of d){let b=II(g,o),v=j7(g,b,o),w=q7(b,v);if(Y7(m,w)&&!i.has(g.id)&&!a.has(g.id)){if(l==="contain"&&!wI(u,w))continue;let x=J7(g,o,r,v),I=tB(p,x,w,l);l==="contain"?I&&!yI(c,g,o,v)&&a.add(g.id):I?a.add(g.id):yI(c,g,o,v)&&i.add(g.id)}}return{selectedElementIds:l==="contain"?eB([...a],o):[...i,...a]}},j7=(e,n,t)=>{let o=X7(e,t);if(!o)return null;let r=II(o,t);return wI(r,n)?null:K7(e,o,t)?r:null},q7=(e,n)=>n?[Math.max(e[0],n[0]),Math.max(e[1],n[1]),Math.min(e[2],n[2]),Math.min(e[3],n[3])]:e,J7=(e,n,t,o)=>{let r=t.get(e.id)??[],i=vI(e,n),a=i?t.get(i.id):null,s=a?.length?[...r,...a]:r;return o?Q7(s,o):s},Q7=(e,n)=>{let[t,o,r,i]=n,a=[];for(let[[s,l],[c,d]]of e){let m=c-s,p=d-l,u=0,E=1,g=!0;for(let[b,v]of[[-m,s-t],[m,r-s],[-p,l-o],[p,i-l]]){if(b===0){if(v<0){g=!1;break}continue}let w=v/b;if(b<0){if(w>E){g=!1;break}u=Math.max(u,w)}else{if(w<u){g=!1;break}E=Math.min(E,w)}}g&&a.push(Vm(Ba(s+u*m,l+u*p),Ba(s+E*m,l+E*p)))}return a},eB=(e,n)=>{if(!e.some(r=>n.get(r)?.groupIds.length))return e;let t=new Map;for(let r of n.values()){let i=r.groupIds.at(-1);if(!i||r.locked||TI(r))continue;let a=t.get(i);a?a.push(r.id):t.set(i,[r.id])}if(!t.size)return e;let o=new Set(e);return e.filter(r=>{let i=n.get(r)?.groupIds.at(-1),a=i?t.get(i):null;return!a||a.every(s=>o.has(s))})},tB=(e,n,t,o)=>{let r=o==="contain"?"every":"some",i=a=>W7(a,e)||o==="contain"&&oB(a,e);return n.length===0?nB(t)[r](i):n[r](a=>a[r](i))},nB=([e,n,t,o])=>[Ba(e,n),Ba(t,n),Ba(t,o),Ba(e,o)],oB=(e,n)=>n.some((t,o)=>o>0&&U7(e,Vm(n[o-1],t))),yI=(e,n,t,o)=>{let r=e.slice(1).map((s,l)=>Vm(e[l],s)).concat([Vm(e[e.length-1],e[0])]),i=vI(n,t),a=(s,l)=>{let c=Z7(s,t,l,0,!o);return o?c.some(d=>$7(d,o)):c.length>0};return r.some(s=>a(n,s)||!!i&&a({...i,...V7(n,i,t)},s))};var Ym=class extends zn{constructor(t){super(t,{animateTrail:!0,streamline:.4,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/(1/0)),s=(5e3-Math.min(5e3,o.totalLength-o.currentIndex))/5e3;return Math.min(CI(s),CI(a))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});y(this,"intersectedElements",new Set);y(this,"enclosedElements",new Set);y(this,"elementsSegments",null);y(this,"canvasTranslate",null);y(this,"keepPreviousSelection",!1);y(this,"selectElementsFromIds",t=>{this.app.setState(o=>{let r=t.reduce((l,c)=>(l[c]=!0,l),{});if(this.keepPreviousSelection)for(let l of Object.keys(o.selectedElementIds))r[l]=!0;for(let[l]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(l);if(c&&sB(c)){let d=cB(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=dB({editingGroupId:o.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),o,this.app),a=[...Object.keys(i.selectedElementIds)],s=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!s.length&&lB(this.app.scene.getNonDeletedElement(a[0]))?new aB(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});y(this,"addPointToPath",(t,o,r=!1)=>{super.addPointToPath(t,o),this.keepPreviousSelection=r,this.updateSelection()});y(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>rB(r[0],r[1])),o={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!pB(o,this.canvasTranslate??{})){this.canvasTranslate=o,this.elementsSegments=new Map;let r=mB(this.app.visibleElements);for(let i of this.app.visibleElements){let a=iB(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=SI({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value,mode:this.app.state.boxSelectionMode});this.selectElementsFromIds(r)}})}startPath(t,o,r=!1){this.endPath(),super.startPath(t,o),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as uB,easeOut as PI,THEME as hB}from"@excalidraw/common";import{computeBoundTextPosition as gB,doBoundsIntersect as fB,getBoundTextElement as EB,getElementBounds as bB,getElementLineSegments as xB,getFreedrawOutlineAsSegments as yB,getFreedrawOutlinePoints as wB,intersectElementWithLineSegment as kI,isArrowElement as vB,isFreeDrawElement as MI,isLineElement as IB,isPointInElement as TB}from"@excalidraw/element";import{lineSegment as SB,lineSegmentsDistance as AI,pointFrom as BI,polygon as CB,polygonIncludesPointNonZero as PB}from"@excalidraw/math";import{getElementsInGroup as DI}from"@excalidraw/element";import{shouldTestInside as kB}from"@excalidraw/element";import{hasBoundTextElement as LI,isBoundToContainer as _I}from"@excalidraw/element";import{getBoundTextElementId as RI}from"@excalidraw/element";var Km=class extends zn{constructor(t){super(t,{streamline:.2,size:5,keepHead:!0,sizeMapping:o=>{let a=Math.max(0,1-(performance.now()-o.pressure)/200),s=(10-Math.min(10,o.totalLength-o.currentIndex))/10;return Math.min(PI(s),PI(a))},fill:()=>t.props.renderCustomizations?.traceColor??(t.state.theme===hB.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")});y(this,"elementsToErase",new Set);y(this,"groupsToErase",new Set)}startPath(t,o){this.endPath(),super.startPath(t,o),this.elementsToErase.clear()}addPointToPath(t,o,r=!1){return super.addPointToPath(t,o),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let o=super.getCurrentTrail()?.originalPoints?.map(s=>BI(s[0],s[1]))||[];if(o.length<2)return[];let r=SB(o[o.length-1],o[o.length-2]),i=this.app.visibleElements.filter(s=>!s.locked),a=uB(i);for(let s of i)if(t&&this.elementsToErase.has(s.id)){if(NI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=DI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(_I(s)&&this.elementsToErase.delete(s.containerId),LI(s)){let d=RI(s);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(s.id)}}else if(!t&&!this.elementsToErase.has(s.id)&&NI(r,s,a,this.app.state.zoom.value)){let c=s.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=DI(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(LI(s)){let d=RI(s);d&&this.elementsToErase.add(d)}_I(s)&&this.elementsToErase.add(s.containerId),this.elementsToErase.add(s.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},NI=(e,n,t,o)=>{let r=e[1],i=MI(n)?15:n.strokeWidth/2,a=[Math.min(e[0][0],e[1][0])-i,Math.min(e[0][1],e[1][1])-i,Math.max(e[0][0],e[1][0])+i,Math.max(e[0][1],e[1][1])+i],s=bB(n,t),l=[s[0]-i,s[1]-i,s[2]+i,s[3]+i];if(!fB(a,l))return!1;if(kB(n)&&TB(r,n,t))return!0;if(MI(n)){let d=wB(n),m=yB(n,d,t),p=Math.max(2.25,5/o);for(let E of m)if(AI(E,e)<=p)return!0;let u=CB(...d.map(([E,g])=>BI(n.x+E,n.y+g)));return!!PB(e[0],u)}let c=EB(n,t);if(vB(n)||IB(n)&&!n.polygon){let d=Math.max(n.strokeWidth,n.strokeWidth*2/o),m=xB(n,t);for(let p of m)if(AI(p,e)<=d)return!0;return!1}return kI(n,t,e,0,!0).length>0||!!c&&kI({...c,...gB(n,c,t)},t,e,0,!0).length>0};import{isDevEnv as VB}from"@excalidraw/common";import{newElement as YB}from"@excalidraw/element";import{COLOR_PALETTE as MB,DEFAULT_FONT_FAMILY as AB,DEFAULT_FONT_SIZE as DB,VERTICAL_ALIGN as LB}from"@excalidraw/common";var FI=44,OI=22,zI=66,GI=48,Hl=14,HI=304,UI=320,Af=5.87,WI=28,VI=4,YI=2,Df=10,KI=10,XI=8,mo=12,Fa=256,ui=10,Lf=4,Oa=mo*2,_f=mo*2,ZI=100,$I=140,Ul=.35,jI=mo/2,wr=20,Xm=mo*2,Rf=mo,Ge={fillStyle:"hachure",fontFamily:AB,fontSize:DB,opacity:100,roughness:1,strokeColor:MB.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:LB.MIDDLE,locked:!1};import{pointFrom as za}from"@excalidraw/math";import{COLOR_PALETTE as tT,DEFAULT_CHART_COLOR_INDEX as _B,FONT_FAMILY as Ff,FONT_SIZES as Zm,ROUNDNESS as qI,DEFAULT_FONT_SIZE as RB,getAllColorsSpecificShade as NB,getFontString as Of,getLineHeight as zf,ROUGHNESS as JI}from"@excalidraw/common";import{getApproxMinLineWidth as Gf,measureText as vr,newElement as Bf,newLinearElement as Nf,newTextElement as Ga,wrapText as nT}from"@excalidraw/element";var hi=NB(_B),BB=e=>e.labels?.length??e.series[0]?.values.length??0,Ha=(e,n)=>{if(!e)return!1;let t=BB(e);return t<2?!1:n==="radar"?t>=3:!0},QI=(e,n)=>{let t=n<=1?0:Math.min(zI,(n-1)*OI);return e+t},$m=(e,n)=>{if(e==="line"){let o=QI(GI,n);return{slotWidth:o,gap:Hl,chartHeight:UI,xLabelMaxWidth:o+Hl*3+Df}}let t=QI(FI,n);return{slotWidth:t,gap:Hl,chartHeight:HI,xLabelMaxWidth:t+Hl*3+Df}},Ua=(e,n)=>{let t=(n.slotWidth+n.gap)*e.series[0].values.length+n.gap,o=n.chartHeight+n.gap*2;return{chartWidth:t,chartHeight:o}},oT=()=>{let e=Fa+_f*2,n=Fa+_f*2;return{chartWidth:e,chartHeight:n}},FB=(e,n,t)=>{let o=Math.abs(e-n);return Math.min(o,t-o)},Wa=(e,n)=>{if(e<=0||hi.length===0)return[];let t=hi.length,o=(n%t+t)%t,r=[o],i=Math.min(e,t),a=new Set(Array.from({length:t},(s,l)=>l).filter(s=>s!==o));for(;r.length<i;){let s=-1,l=-1,c=-1;for(let d of a){let m=r.map(E=>FB(d,E,t)),p=Math.min(...m),u=m.reduce((E,g)=>E+g,0)/m.length;(p>l||p===l&&u>c)&&(s=d,l=p,c=u)}r.push(s),a.delete(s)}return Array.from({length:e},(s,l)=>hi[r[l%r.length]])},Va=e=>{if(hi.length===0)return 0;if(typeof e!="number"||!Number.isFinite(e))return Math.floor(Math.random()*hi.length);let n=e.toString(),t=0;for(let o=0;o<n.length;o++)t=t*31+n.charCodeAt(o)|0;return Math.abs(t)%hi.length},Ya=e=>hi[e],rT=(e,n)=>{let t=e.flatMap(s=>s.values.map(l=>Math.max(0,l))),o=t.filter(s=>s>0),r=Math.max(1,...t),i=o.length>0?Math.min(...o):1,a=e.length===1&&i>0&&r/i>=ZI;return{renderSteps:!1,normalize:(s,l)=>{let c=Math.max(0,s);return a?Math.log10(c+1)/Math.log10(r+1):c/r}}},OB=e=>/\s/.test(e.trim()),jm=(e,n,t)=>OB(e)?nT(e,n,t):e,iT=(e,n,t,o,r,i)=>{let a=Ff.Excalifont,s=Zm.sm,l=zf(a),c=Of({fontFamily:a,fontSize:s}),d=Math.min($I,r*(e.length>8?.56:.72)),m=Gf(c,l),p=e.map((g,b)=>{let v=n[b],w=Math.max(0,...g.trim().split(/\s+/).filter(Boolean).map(z=>vr(z,c,l).width)),x=Math.max(m,d,w),I=jm(g,c,x),T=vr(I,c,l),C=Math.cos(v),P=Math.sin(v),M=C>Ul?"left":C<-Ul?"right":"center",D=M==="center"?T.width/2:0,_=Math.abs(C)*D+Math.abs(P)*(T.height/2),k=Oa+_+jI,L=t+C*(r+k),F=o+P*(r+k),K=P>Ul?mo/3:P<-Ul?-mo/3:0;return Ga({backgroundColor:i,...Ge,text:I,originalText:g,x:L,y:F+K,fontFamily:a,fontSize:s,lineHeight:l,textAlign:M,verticalAlign:"middle"})}),u=Math.min(...p.map(g=>g.y)),E=Math.max(...p.map(g=>g.y+g.height));return{axisLabels:p,axisLabelTopY:u,axisLabelBottomY:E}},Ka=(e,n,t,o,r,i)=>{if(e.length<=1)return[];let a=Ff["Lilita One"],s=Zm.lg,l=zf(a),c=Of({fontFamily:a,fontSize:s}),d=e.map((I,T)=>{let C=I.title?.trim()||`Series ${T+1}`,P=jm(C,c,Fa),M=vr(P,c,l),D=wr+Rf+M.width;return{label:C,displayLabel:P,color:n[T],width:D,height:M.height}}),m=Math.max(wr/2,...d.map(I=>I.height/2)),p=Math.max(r,o+m+Oa),u=Xm,E=wr*.6,g=d.reduce((I,T)=>I+T.width,0)+Xm*Math.max(0,d.length-1),b=g+u*2,v=m*2+E*2,w=[];w.push(Bf({...Ge,backgroundColor:"transparent",type:"rectangle",fillStyle:"solid",strokeColor:tT.black,x:t-b/2,y:p-v/2,width:b,height:v,roughness:JI.architect,roundness:{type:qI.PROPORTIONAL_RADIUS}}));let x=t-g/2;return d.forEach(I=>{w.push(Bf({...Ge,backgroundColor:I.color,type:"rectangle",x,y:p-wr/2,width:wr,height:wr,fillStyle:"solid",strokeColor:I.color,roughness:JI.architect,roundness:{type:qI.PROPORTIONAL_RADIUS}})),w.push(Ga({...Ge,text:I.displayLabel,originalText:I.label,autoResize:!1,x:x+wr+Rf,y:p,fontFamily:a,fontSize:s,lineHeight:l,textAlign:"left",verticalAlign:"middle"})),x+=I.width+Xm}),w},zB=(e,n,t,o)=>{if(vr(e,t,o).width<=n)return e;let r=e.length;for(;r>1;){let i=`${e.slice(0,r)}...`;if(vr(i,t,o).width<=n)return i;r--}return e[0]?`${e[0]}...`:e},GB=(e,n,t,o)=>{if(vr(e,t,o).width<=n)return{wrapped:!1,text:e};let r=e.trim().split(/\s+/).filter(Boolean);return r.length>1&&!r.some(a=>vr(a,t,o).width>n)&&n>=Gf(t,o)?{wrapped:!0,text:nT(e,t,n)}:{wrapped:!1,text:zB(e,n,t,o)}},aT=(e,n,t)=>{let o=Math.abs(Math.cos(t)),r=Math.abs(Math.sin(t));return{width:e*o+n*r,height:e*r+n*o}},eT=e=>e.includes("..."),HB=(e,n,t,o,r)=>{let i=Math.max(WI,Math.ceil(Gf(o,r))),a=Math.max(i,Math.floor(n)),s=[];for(let u=a;u>=i;u-=4)s.push(u);s[s.length-1]!==i&&s.push(i);let l=u=>{let E=eT(u.text),g=u.text.replace(/\.\.\./g,"").replace(/\n/g,"").length,b=u.text.split(`
15
+ `).length;return{ellipsified:E,visibleChars:g,lineCount:b}},c=(u,E)=>{let g=l(u),b=l(E);return g.ellipsified!==b.ellipsified?!g.ellipsified:g.visibleChars!==b.visibleChars?g.visibleChars>b.visibleChars:g.lineCount!==b.lineCount?g.lineCount<b.lineCount:u.rotatedHeight<E.rotatedHeight},d=null,m=null,p=null;for(let u of s){let{wrapped:E,text:g}=GB(e,u,o,r),b=vr(g,o,r),v=aT(b.width,b.height,Af),w={originalText:e,text:g,metrics:b,rotatedWidth:v.width,rotatedHeight:v.height,wrapped:E},x=v.width-t;if(x<=0){(!d||c(w,d))&&(d=w);continue}(!m||x<m.overflow||x===m.overflow&&c(w,m.spec))&&(m={overflow:x,spec:w}),!eT(w.text)&&(!p||x<p.overflow||x===p.overflow&&c(w,p.spec))&&(p={overflow:x,spec:w})}return d||(p&&m&&p.overflow<=m.overflow+XI?p.spec:m.spec)},qm=e=>{if(e.type!=="text")return e.y+e.height;let n=aT(e.width,e.height,e.angle);return e.y+e.height/2+n.height/2},Wl=(e,n,t,o,r)=>{let i=Ge.fontFamily,a=Zm.sm,s=zf(i),l=Of({fontFamily:i,fontSize:a}),c=Math.max(1,r.slotWidth+r.gap-VI*2+KI),d=t;return e.labels?.map((m,p)=>{let u=HB(m,r.xLabelMaxWidth,c,l,s),E=n+p*(r.slotWidth+r.gap)+r.gap+r.slotWidth/2,g=d+YI+(u.rotatedHeight-u.metrics.height)/2;return Ga({backgroundColor:o,...Ge,text:u.text,originalText:u.wrapped?m:u.text,autoResize:!u.wrapped,x:E,y:g,angle:Af,fontSize:a,lineHeight:s,textAlign:"center",verticalAlign:"top"})})||[]},UB=(e,n,t,o,r,i=Math.max(...e.series[0].values))=>{let a=Ga({backgroundColor:o,...Ge,x:n-r.gap,y:t-r.gap,text:"0",textAlign:"right"}),s=Ga({backgroundColor:o,...Ge,x:n-r.gap,y:t-r.chartHeight-a.height/2,text:i.toLocaleString(),textAlign:"right"});return[a,s]},WB=(e,n,t,o,r)=>{let{chartWidth:i,chartHeight:a}=Ua(e,r),s=Nf({backgroundColor:o,...Ge,type:"line",x:n,y:t,width:i,points:[za(0,0),za(i,0)]}),l=Nf({backgroundColor:o,...Ge,type:"line",x:n,y:t,height:a,points:[za(0,0),za(0,-a)]}),c=Nf({backgroundColor:o,...Ge,type:"line",x:n,y:t-r.chartHeight-r.gap,strokeStyle:"dotted",width:i,opacity:ui,points:[za(0,0),za(i,0)]});return[s,l,c]},Jm=(e,n,t,o,r,i=Math.max(...e.series[0].values),a)=>{let{chartWidth:s,chartHeight:l}=Ua(e,r),c=e.title?Ga({backgroundColor:o,...Ge,text:e.title,x:n+s/2,y:t-r.chartHeight-r.gap*2-RB,roundness:null,textAlign:"center",fontSize:Zm.xl,fontFamily:Ff["Lilita One"]}):null,d=a?Bf({backgroundColor:o,...Ge,type:"rectangle",x:n,y:t-l,width:s,height:l,strokeColor:tT.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...c?[c]:[],...Wl(e,n,t,o,r),...UB(e,n,t,o,r,i),...WB(e,n,t,o,r)]};var sT=(e,n,t,o)=>{let r=e.series,i=$m("bar",r.length),a=Math.max(1,...r.flatMap(I=>I.values.map(T=>Math.max(0,T)))),s=Va(o),l=Ya(s),c=Wa(r.length,s),d=r.length>1?Math.max(1,Math.floor(i.gap/(r.length+1))):0,m=r.length>1?Math.max(2,(i.slotWidth-d*(r.length-1))/r.length):i.slotWidth,p=r.length*m+d*(r.length-1),u=(i.slotWidth-p)/2,E=r[0].values.flatMap((I,T)=>r.map((C,P)=>{let D=Math.max(0,C.values[T]??0)/a*i.chartHeight,_=r.length>1?c[P]:l;return YB({backgroundColor:_,...Ge,type:"rectangle",fillStyle:r.length>1?"solid":Ge.fillStyle,strokeColor:r.length>1?_:Ge.strokeColor,x:n+T*(i.slotWidth+i.gap)+i.gap+u+P*(m+d),y:t-D-i.gap,width:m,height:D})})),g=Jm(e,n,t,l,i,a,VB()),b=Wl(e,n,t,l,i),v=Math.max(t+i.gap/2,...b.map(I=>qm(I))),{chartWidth:w}=Ua(e,i),x=Ka(r,c,n+w/2,v,t+i.gap*5,l);return[...g,...E,...x]};import{pointFrom as Hf}from"@excalidraw/math";import{isDevEnv as KB}from"@excalidraw/common";import{newElement as XB,newLinearElement as lT}from"@excalidraw/element";var cT=(e,n,t,o)=>{let r=e.series,i=$m("line",r.length),a=Math.max(1,...r.flatMap(x=>x.values)),s=Va(o),l=Ya(s),c=Wa(r.length,s),d=r.map((x,I)=>{let T=x.values.map((_,k)=>Hf(k*(i.slotWidth+i.gap),-(_/a)*i.chartHeight)),C=Math.max(...T.map(_=>_[0])),P=Math.max(...T.map(_=>_[1])),M=Math.min(...T.map(_=>_[0])),D=Math.min(...T.map(_=>_[1]));return lT({backgroundColor:"transparent",...Ge,type:"line",x:n+i.gap+i.slotWidth/2,y:t-i.gap,height:P-D,width:C-M,strokeColor:c[I],strokeWidth:2,points:T})}),m=r.flatMap((x,I)=>x.values.map((T,C)=>{let P=C*(i.slotWidth+i.gap)+i.gap/2,M=-(T/a)*i.chartHeight+i.gap/2;return XB({backgroundColor:c[I],...Ge,fillStyle:"solid",strokeColor:c[I],strokeWidth:2,type:"ellipse",x:n+P+i.slotWidth/2,y:t+M-i.gap*2,width:i.gap,height:i.gap})})),u=r[0].values.map((x,I)=>Math.max(0,...r.map(T=>T.values[I]??0))).map((x,I)=>{let T=I*(i.slotWidth+i.gap)+i.gap/2,C=x/a*i.chartHeight+i.gap/2+i.gap;return lT({backgroundColor:l,...Ge,type:"line",x:n+T+i.slotWidth/2+i.gap/2,y:t-C,height:C,strokeStyle:"dotted",opacity:ui,points:[Hf(0,0),Hf(0,C)]})}),E=Jm(e,n,t,l,i,a,KB()),g=Wl(e,n,t,l,i),b=Math.max(t+i.gap/2,...g.map(x=>qm(x))),{chartWidth:v}=Ua(e,i),w=Ka(r,c,n+v/2,b,t+i.gap*5,l);return[...E,...d,...u,...m,...w]};var Gn=e=>{let n=/^([-+]?)[$\u20AC\u00A3\u00A5\u20A9]?([-+]?)([\d.,]+)[%]?$/.exec(e);return n?parseFloat(`${(n[1]||n[2])+n[3]}`.replace(/,/g,"")):null},ZB=(e,n)=>e.slice(1).every(t=>Gn(t[n])!==null),dT=e=>{let n=e[0].length;if(n>2){let a=e[0].every(m=>Gn(m)===null),s=a?e.slice(1):e;if(s.length<1)return{ok:!1,reason:"No data rows"};if(s.some(m=>m.slice(1).some(p=>Gn(p)===null)))return{ok:!1,reason:"Value is not numeric"};if(n-1>s.length){let m=a?e[0].slice(1).map(E=>E.trim()):null,p=s.map(E=>({title:E[0]?.trim()||null,values:E.slice(1).map(g=>Gn(g))}));return{ok:!0,data:{title:p.length===1?p[0].title:a&&e[0][0].trim()||null,labels:m,series:p}}}let d=e[0].slice(1).map((m,p)=>{let u=p+1,E=`Series ${u}`;return{title:a&&m.trim()||E,values:s.map(g=>Gn(g[u]))}});return{ok:!0,data:{title:a&&e[0][0].trim()||null,labels:s.map(m=>m[0]),series:d}}}if(n===1){if(!ZB(e,0))return{ok:!1,reason:"Value is not numeric"};let a=Gn(e[0][0])===null,s=a?e[0][0]:null,l=(a?e.slice(1):e).map(c=>Gn(c[0]));return l.length<2?{ok:!1,reason:"Less than two rows"}:{ok:!0,data:{title:s,labels:null,series:[{title:s,values:l}]}}}let t=Gn(e[0][1])===null,o=t?e.slice(1):e;if(o.length<2)return{ok:!1,reason:"Less than 2 rows"};if(o.some(a=>Gn(a[1])===null))return{ok:!1,reason:"Value is not numeric"};let i=t?e[0][1]:null;return{ok:!0,data:{title:i,labels:o.map(a=>a[0]),series:[{title:i,values:o.map(a=>Gn(a[1]))}]}}},Qm=e=>{let n=s=>e.replace(/\r\n?/g,`
16
16
  `).split(`
17
- `).filter(l=>l.trim().length>0).map(l=>l.split(s).map(c=>c.trim())),t=[" ",",",";"].map(s=>{let l=n(s),c=l[0]?.length??0,d=l.length>0&&l.every(m=>m.length===c);return{delimiter:s,parsed:l,numCols:c,isConsistent:d}}),r=(t.find(s=>s.isConsistent&&s.numCols>1)??t.find(s=>s.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(s=>s.length===i)?cT(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Xa}from"@excalidraw/math";import{FONT_FAMILY as KB,FONT_SIZES as XB,getFontString as ZB,getLineHeight as $B,ROUGHNESS as dT}from"@excalidraw/common";import{measureText as jB,newLinearElement as Hf,newTextElement as qB}from"@excalidraw/element";var mT=(e,n,t,o)=>{if(!Ha(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,U)=>`Value ${U+1}`),i=e.series,{normalize:a,renderSteps:s}=oT(i,r.length),l=Va(o),c=Ya(l),d=Wa(i.length,l),{chartWidth:m,chartHeight:p}=nT(),u=n+m/2,E=t-p/2,g=Fa/2,b=r.map((z,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:v,axisLabelTopY:y,axisLabelBottomY:x}=rT(r,b,u,E,g,c),I=KB["Lilita One"],T=XB.xl,C=$B(I),P=ZB({fontFamily:I,fontSize:T}),M=e.title?jm(e.title,P,m+Oa*2):null,D=M?jB(M,P,C):null,_=M?qB({backgroundColor:c,...ze,text:M,originalText:e.title??M,x:n+m/2,y:y-Oa-D.height/2,fontFamily:I,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:Df},(z,U)=>{let W=(U+1)/Df,G=g*W,ie=b.map(me=>Xa(Math.cos(me)*G,Math.sin(me)*G));return ie.push(Xa(ie[0][0],ie[0][1])),Hf({backgroundColor:"transparent",...ze,type:"line",x:u,y:E,width:G*2,height:G*2,strokeStyle:"solid",roughness:dT.architect,opacity:mi,polygon:!0,points:ie})}):[],L=b.map(z=>{let U=Math.cos(z)*g,W=Math.sin(z)*g;return Hf({backgroundColor:"transparent",...ze,type:"line",x:u,y:E,width:Math.abs(U),height:Math.abs(W),strokeStyle:"solid",roughness:dT.architect,opacity:mi,points:[Xa(0,0),Xa(U,W)]})}),F=i.map((z,U)=>{let W=b.map((G,ie)=>{let me=z.values[ie]??0,B=a(me,ie)*g;return Xa(Math.cos(G)*B,Math.sin(G)*B)});return W.push(Xa(W[0][0],W[0][1])),Hf({backgroundColor:"transparent",...ze,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[U],strokeWidth:2,polygon:!0,points:W})}),K=Ka(i,d,u,x,t+mo*5,c);return[..._?[_]:[],...v,...k,...L,...F,...K]};var Uf=(e,n,t,o,r)=>e==="line"?lT(n,t,o,r):e==="radar"?mT(n,t,o,r):aT(n,t,o,r);import{clamp as ep,pointFrom as Za,pointsEqual as rF,bezierEquation as wT,pointRotateRads as tp,pointDistance as iF}from"@excalidraw/math";import{arrayToMap as aF,BIND_MODE_TIMEOUT as Vl,DEFAULT_TRANSFORM_HANDLE_SPACING as vT,FRAME_STYLE as bn,getFeatureFlag as sF,invariant as fT,shouldRotateWithDiscreteAngle as IT,THEME as No}from"@excalidraw/common";import{deconstructDiamondElement as Xf,deconstructRectanguloidElement as TT,elementCenterPoint as $a,getDiamondBaseCorners as lF,FOCUS_POINT_SIZE as cF,getOmitSidesForEditorInterface as Wf,getTransformHandles as dF,getTransformHandlesFromCoords as mF,hasBoundingBox as pF,hitElementItself as uF,isArrowElement as ST,isBindableElement as CT,isElbowArrow as ja,isFrameLikeElement as qa,isImageElement as np,isLinearElement as hF,isLineElement as gF,maxBindingDistance_simple as fF,isTextElement as EF,LinearElementEditor as xn,getActiveTextElement as bF,getElementsInGroup as Zf,getSelectedGroupIds as xF,isSelectedViaGroup as yF,selectGroupsFromGivenElements as wF}from"@excalidraw/element";import{renderSelectionElement as vF}from"@excalidraw/element";import{getCommonBounds as $f,getElementAbsoluteCoords as Kl}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as ET,isFocusPointVisible as IF}from"@excalidraw/element";import{pointFrom as Pt}from"@excalidraw/math";import{THEME as JB}from"@excalidraw/common";var QB="#ff6b6b",eF="#ff0000",pT=1,uT=2,hT=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===JB.LIGHT||n.zenModeEnabled?QB:eF,o=(n.zenModeEnabled?pT*1.5:pT)/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY);for(let r of n.snapLines)r.type==="pointer"?(e.lineWidth=o,e.strokeStyle=t,nF(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,oF(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,tF(r,e,n));e.restore()},tF=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];En(o,r,n)}for(let o of e.points)gT(o,t,n)},nF=(e,n,t)=>{gT(e.points[0],t,n),t.zenModeEnabled||En(e.points[0],e.points[1],n)},gT=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?uT*1.5:uT)/t.zoom.value;o.beginPath(),o.moveTo(e-r,n-r),o.lineTo(e+r,n+r),o.moveTo(e+r,n-r),o.lineTo(e-r,n+r),o.stroke(),o.restore()},En=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},oF=(e,n,t,o,r)=>{let i=8/o.zoom.value,a=i/2,s=i/4;if(t==="horizontal"){let l=[(e[0]+n[0])/2,e[1]];o.zenModeEnabled||En(Pt(e[0],e[1]-i),Pt(e[0],e[1]+i),r),En(Pt(l[0]-s,l[1]-a),Pt(l[0]-s,l[1]+a),r),En(Pt(l[0]+s,l[1]-a),Pt(l[0]+s,l[1]+a),r),o.zenModeEnabled||(En(Pt(n[0],n[1]-i),Pt(n[0],n[1]+i),r),En(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||En(Pt(e[0]-i,e[1]),Pt(e[0]+i,e[1]),r),En(Pt(l[0]-a,l[1]-s),Pt(l[0]+a,l[1]-s),r),En(Pt(l[0]-a,l[1]+s),Pt(l[0]+a,l[1]+s),r),o.zenModeEnabled||(En(Pt(n[0]-i,n[1]),Pt(n[0]+i,n[1]),r),En(e,n,r))}};var TF=(e,n)=>{fT(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;fT(t,"midPointCoords is null"),op(t,e,n)},SF=(e,n,t)=>{let{elementId:o,hoverPointIndex:r}=n.selectedLinearElement;if(n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(r)||n.selectedLinearElement?.isDragging)return;let i=xn.getElement(o,t);if(!i)return;let a=xn.getPointAtIndexGlobalCoordinates(i,r,t);op(a,e,n)},op=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",ks(n,e[0],e[1],xn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},CF=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!ST(i)||i.isDeleted)return;let a=r==="label"?xn.getBoundTextElementCenter(i,t):xn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);op(a,e,n)},Vf=(e,n,t,o,r,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",r?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),ks(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},PF=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&qa(a)&&(e.translate(a.x,a.y),e.beginPath(),bn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,bn.radius/o.zoom.value):e.rect(-1,-1,a.width+1,a.height+1),e.clip(),e.translate(-a.x,-a.y)),n.element.type){case"magicframe":case"frame":e.save(),e.translate(n.element.x,n.element.y),e.lineWidth=bn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===No.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",bn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,bn.radius/o.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,n.element.width,n.element.height),e.restore();break;default:e.save();let s=$a(n.element,t);switch(e.translate(s[0],s[1]),e.rotate(n.element.angle),e.translate(-s[0],-s[1]),e.translate(n.element.x,n.element.y),e.lineWidth=ep(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===No.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",n.element.type){case"ellipse":e.beginPath(),e.ellipse(n.element.width/2,n.element.height/2,n.element.width/2,n.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[l,c]=Xf(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break;default:{let[l,c]=TT(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break}e.restore();break}if(o.isMidpointSnappingEnabled&&!o.gridModeEnabled&&!i&&(qa(n.element)||CT(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&xn.getElement(s?.elementId,t),c=r&&uF({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&ja(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=$a(n.element,t),p;if(n.element.type==="diamond"){let b=$a(n.element,t);p=lF(n.element).map(v=>{let y=wT(v,.5),x=tp(y,b,n.element.angle);return Za(x[0],x[1])})}else p=[{x:n.element.width,y:n.element.height/2},{x:n.element.width/2,y:n.element.height},{x:0,y:n.element.height/2},{x:n.element.width/2,y:0}].map(v=>{let y=Za(v.x+n.element.x,v.y+n.element.y),x=tp(y,m,n.element.angle);return Za(x[0],x[1])});let u=r&&p.reduce((b,v,y)=>{let x=iF(v,r);return y===-1||x<b.distance?{idx:y,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=fF(o.zoom)+n.element.strokeWidth/2;p.forEach((b,v)=>{let y=(!c||d)&&u?.idx===v&&u.distance<=g,x=!y&&(d||v===u?.idx&&u.distance<=g*2);y?(e.fillStyle=o.theme===No.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill()):x&&(e.fillStyle=o.theme===No.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill())}),e.restore()}}},kF=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=Vl-(a?.runtime??(s?0:Vl)),c=ep(1/Vl*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&qa(m)&&(n.translate(m.x,m.y),n.beginPath(),bn.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,bn.radius/r.zoom.value):n.rect(-1,-1,m.width+1,m.height+1),n.clip(),n.translate(-m.x,-m.y)),t.type){case"magicframe":case"frame":n.save(),n.translate(t.x,t.y),n.lineWidth=bn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===No.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,bn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,bn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=$a(t,o),E=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(n.translate(E,g),n.rotate(t.angle),n.translate(-E,-g),n.translate(t.x+r.scrollX-d,t.y+r.scrollY-d),n.lineWidth=ep(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===No.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":n.beginPath(),n.ellipse((t.width+d*2)/2,(t.height+d*2)/2,(t.width+d*2)/2,(t.height+d*2)/2,0,0,2*Math.PI),n.closePath(),n.stroke();break;case"diamond":{let[b,v]=Xf(t,d);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+d,y[0][1]-t.y+d),n.lineTo(y[1][0]-t.x+d,y[1][1]-t.y+d),n.stroke()}),v.forEach(y=>{let[x,I,T,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break;default:{let[b,v]=TT(t,d);b.forEach(y=>{n.beginPath(),n.moveTo(y[0][0]-t.x+d,y[0][1]-t.y+d),n.lineTo(y[1][0]-t.x+d,y[1][1]-t.y+d),n.stroke()}),v.forEach(y=>{let[x,I,T,C]=y;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break}n.restore();break}if(!s||(a?.runtime??0)>Vl)return;let p=.5*(Math.min(t.width,t.height)/2);if(!qa(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/Vl*l;if(n.strokeStyle="rgba(0, 0, 0, 0.2)",n.lineWidth=1/r.zoom.value,n.setLineDash([4/r.zoom.value,4/r.zoom.value]),n.lineDashOffset=-u*10/r.zoom.value,n.beginPath(),n.ellipse(t.width/2,t.height/2,p,p,0,0,2*Math.PI),n.stroke(),n.fillStyle="rgba(0, 0, 0, 0.04)",n.beginPath(),n.ellipse(t.width/2,t.height/2,p*(1-c),p*(1-c),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!IT(e.lastPointerMoveEvent))){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let E=5/r.zoom.value,g=5/r.zoom.value,b=E+g,v;if(t.type==="diamond"){let[,y]=Xf(t),x=$a(t,o);v=y.map(I=>{let T=wT(I,.5),C=tp(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let y=$a(t,o);v=[{x:t.width/2,y:0},{x:t.width,y:t.height/2},{x:t.width/2,y:t.height},{x:0,y:t.height/2}].map(I=>{let T=Za(I.x+t.x,I.y+t.y),C=tp(T,y,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}v.forEach(y=>{n.clearRect(y.x-b,y.y-b,b*2,b*2)}),n.fillStyle=r.theme===No.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,v.forEach(y=>{n.beginPath(),n.arc(y.x,y.y,E,0,2*Math.PI),n.fill()}),n.restore()}}return{runtime:(a?.runtime??0)+i}},MF=(e,n,t,o,r,i,a)=>{if(t===null)return;if(sF("COMPLEX_BINDINGS"))return kF(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Za(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&IT(e.lastPointerMoveEvent);PF(n,t,o,r,s,l),n.restore()},PT=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:s,selectionColors:l,cx:c,cy:d,dashed:m,activeEmbeddable:p}=t,u=a-r,E=s-i,b=(t.padding??vT*2)/n.zoom.value,v=8/n.zoom.value,y=4/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=(p?4:1)/n.zoom.value;let x=l.length;for(let I=0;I<x;++I)e.strokeStyle=l[I],m&&e.setLineDash([v,y+(v+y)*(x-1)]),e.lineDashOffset=(v+y)*I,Ms(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},AF=(e,n,t,o)=>{let[r,i,a,s]=Kl(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=bn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),Ms(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,bn.radius/n.zoom.value),e.restore()},bT=(e,n,t,o)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=o||{},a=t.filter(d=>d.groupIds.length===0),s=t.filter(d=>d.groupIds.length>0),l=d=>{let[m,p,u,E]=$f(d);return{angle:0,x1:m,x2:u,y1:p,y2:E,selectionColors:r,dashed:i,cx:m+(u-m)/2,cy:p+(E-p)/2,activeEmbeddable:!1}},c=d=>{let m=Zf(t,d);return l(m)};Object.entries(wF(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>PT(e,n,d))},Yf=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=xn.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=xn,a=n.selectedLinearElement?.isEditing?i:i/2,s=ja(t),l=gF(t);if(r.forEach((c,d)=>{if(s&&d!==0&&d!==r.length-1)return;let m=d>0&&(d!==r.length-1||!l||!t.polygon)&&rF(c,d===r.length-1?r[0]:r[d-1],2/n.zoom.value),p=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(d);l&&t.polygon&&!p&&d===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Vf(e,n,c,a,p,!1,m)}),ja(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{xn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||Vf(e,n,Za((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else xn.getEditorMidPoints(t,o,n).filter((d,m,p)=>d!==null&&!(ja(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&Vf(e,n,d,i/2,!1,!0,!1)});e.restore()},DF=(e,n,t,o)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([4/n.zoom.value,4/n.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(o[0],o[1]),e.stroke(),e.restore()},LF=(e,n,t,o,r)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",ks(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},xT=({arrow:e,appState:n,type:t,context:o,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!CT(a)||a.isDeleted)return;let s=ET(i.fixedPoint,a,r);if(!IF(s,e,a,r,n,t))return;let l=n.selectedLinearElement,c=!!l?.isDragging,d=t==="start"?0:e.points.length-1,m=!!l?.selectedPointsIndices?.includes(d);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&op(s,o,n),!(m&&c)){let p=ET(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=xn.getPointAtIndexGlobalCoordinates(e,d,r);DF(o,n,E,p),LF(o,n,p,cF/1.5,u)}},yT=(e,n,t,o,r)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,c,d]=a;e.save(),e.lineWidth=1/t.zoom.value,n.selectionColor&&(e.strokeStyle=n.selectionColor),i==="rotation"?ks(e,s+c/2,l+d/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/t.zoom.value),e.fill(),e.stroke()):Ms(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},_F=(e,n,t,o,r)=>{let[i,a,,,s,l]=Kl(o,r),c=3,d=20,m=c/t.zoom.value,p=m/2,u=s-i+m,E=l-a+m,g=Math.min(d/t.zoom.value,u),b=Math.min(d/t.zoom.value,E);e.save(),e.fillStyle=n.selectionColor,e.strokeStyle=n.selectionColor,e.lineWidth=m,[[[-u,-E],[0,p],[g,p],[p,0],[p,b]],[[u-p,-E],[p,p],[-g+p,p],[0,0],[0,b]],[[-u,E],[0,-p],[g,-p],[p,0],[p,-b]],[[u-p,E],[p,-p],[-g+p,-p],[0,0],[0,-b]]].forEach(y=>{let[[x,I],[T,C],[P,M],[D,_],[k,L]]=y;e.save(),e.translate(s,l),e.rotate(o.angle),e.beginPath(),e.moveTo(x+T,I+C),e.lineTo(x+P,I+M),e.stroke(),e.beginPath(),e.moveTo(x+D,I+_),e.lineTo(x+k,I+L),e.stroke(),e.restore()}),e.restore()},RF=(e,n,t,o)=>{n.save();let r=vf(t.zoom.value),i=e.width+r*2,a=e.height+r*2,s=e.x+e.width/2,l=e.y+e.height/2,c=-(e.width/2+r),d=-(e.height/2+r);n.translate(s+t.scrollX,l+t.scrollY),n.rotate(e.angle),n.lineWidth=1/t.zoom.value,n.strokeStyle=o,n.globalAlpha=.5,n.setLineDash([6/t.zoom.value,4/t.zoom.value]),n.strokeRect(c,d,i,a),n.restore()},NF=(e,n,t,o,r)=>{let i=If(e,t.zoom.value,r);i&&(n.save(),n.globalAlpha=.5,n.lineWidth=1.5/t.zoom.value,n.lineCap="round",n.strokeStyle=o,n.beginPath(),n.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),n.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),n.stroke(),n.restore())},BF=(e,n,t,o,r,i)=>{for(let a of n){if(!np(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let d=Yl(a,t,r,"center");d&&MT(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,r,s?.downloadError??void 0)}else{let d=o.imageLoadingProgress.get(a.fileId);if(d!==void 0){let m=Yl(a,t,r,"center");m&&kT(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=Yl(a,t,r,"top-right");d&&OF(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},Yl=(e,n,t,o)=>{if(!np(e))return null;let[r,i,a,s]=Kl(e,n),l=t.zoom.value,c=Math.min(a-r,s-i)*l,d=Math.min(o==="center"?14:11.7,c/(o==="center"?4:4.62))/l,m=Math.min((o==="center"?3:2.6)/l,d/2);if(d<=0||m<=0)return null;if(o==="top-right"){let p=6/l;return{centerX:a-p-d,centerY:i+p+d,radius:d,lineWidth:m}}return{centerX:(r+a)/2,centerY:(i+s)/2,radius:d,lineWidth:m}},kT=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===No.DARK?"rgba(255, 255, 255, 0.35)":"rgba(0, 0, 0, 0.25)"),e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),i>0&&(e.strokeStyle=l?.color??s,e.beginPath(),e.arc(n,t,o,-Math.PI/2,-Math.PI/2+Math.PI*2*ep(i,0,1)),e.stroke()),e.restore()},Kf=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,FF=(e,n,t,o,r)=>{e.save(),e.strokeStyle=r.color,e.lineWidth=r.lineWidth,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(n-o*.48,t+o*.26),e.bezierCurveTo(n-o*.68,t+o*.14,n-o*.58,t-o*.22,n-o*.34,t-o*.22),e.bezierCurveTo(n-o*.14,t-o*.48,n+o*.26,t-o*.48,n+o*.34,t-o*.18),e.bezierCurveTo(n+o*.58,t-o*.2,n+o*.7,t+o*.26,n+o*.42,t+o*.26),e.lineTo(n-o*.48,t+o*.26),e.stroke(),e.restore()},OF=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??Kf("--color-primary",s),d=i.color??Kf("--color-warning-darkest","#ec8b14");if(l==="failed"){MT(e,n,t,o,a,{color:i.color??Kf("--color-danger","#e03131")});return}if(l==="uploading"&&kT(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),FF(e,n,t-o*.02,o*1.125,{color:l==="error"?d:c,lineWidth:Math.max(r*.75,1/a.zoom.value)}),l==="error"){e.save(),e.strokeStyle=d,e.fillStyle=d,e.lineWidth=Math.max(r*.75,1/a.zoom.value),e.lineCap="round",e.beginPath();let m=o*.18,p=t-o*.09;e.moveTo(n-m,p-m),e.lineTo(n+m,p+m),e.moveTo(n+m,p-m),e.lineTo(n-m,p+m),e.stroke(),e.restore()}else l==="pending"&&(e.save(),e.strokeStyle=c,e.lineWidth=Math.max(r*.65,1/a.zoom.value),e.lineCap="round",e.beginPath(),e.moveTo(n,t+o*.072),e.lineTo(n,t-o*.18),e.moveTo(n-o*.144,t-o*.036),e.lineTo(n,t-o*.18),e.lineTo(n+o*.144,t-o*.036),e.stroke(),e.restore())},MT=(e,n,t,o,r,i)=>{e.save();let a=i?.color??"#e03131",s=Math.max(o*.16,1.5/r.zoom.value);i?.backgroundColor&&(e.fillStyle=i.backgroundColor,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.fill()),e.strokeStyle=a,e.lineWidth=s,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),e.strokeStyle=a,e.fillStyle=a,e.lineCap="round",e.beginPath(),e.moveTo(n,t-o*.45),e.lineTo(n,t+o*.12),e.stroke(),e.beginPath(),e.arc(n,t+o*.48,o*.11,0,Math.PI*2),e.fill(),i?.text&&(e.font=`600 ${Math.max(11/r.zoom.value,o*.65)}px Assistant, system-ui, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif`,e.textAlign="center",e.textBaseline="top",e.fillText(i.text,n,t+o+6/r.zoom.value)),e.restore()},zF=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:s,renderConfig:l,editorInterface:c,animationState:d,deltaTime:m})=>{if(n===null)return{};let[p,u]=Fc(n,a),E=d,g=Oc({canvas:n,scale:a,normalizedWidth:p,normalizedHeight:u});g.save(),zc(g,s);let b;if(o.forEach(C=>{s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===C.id&&C&&(b=C)}),b&&Yf(g,s,b,t),s.selectionElement&&!s.isCropping)try{vF(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let v=bF(r,s);if(v&&!v.autoResize&&NF(v,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&RF(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:MF(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&CF(g,s,i),s.frameToHighlight&&AF(g,s,s.frameToHighlight,t),s.elementsToHighlight&&bT(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:Zf(i,s.activeLockedId);bT(g,s,P,{colors:["#ced4da"],dashed:!0})}let y=r.some(C=>qa(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&Yf(g,s,r[0],t);let x=s.selectedLinearElement,I=x&&xn.getElement(x.elementId,i);if(I&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?TF(g,s):(ja(I)?x.hoverPointIndex===0||x.hoverPointIndex===I.points.length-1:x.hoverPointIndex>=0)&&SF(g,s,t)),ST(I)&&(xT({arrow:I,elementsMap:i,appState:s,context:g,type:"start"}),xT({arrow:I,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=pF(r,s,c),P=r.length===1&&hF(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Yf(g,s,r[0],t);let M=l.selectionColor||"#000";if(C){let D=aF(r),_=[];for(let L of t.values()){let F=[],K=l.remoteSelectedElementIds.get(L.id);if(P&&ja(L)&&(L.startBinding||L.endBinding)||(D.has(L.id)&&!yF(s,L)&&F.push(M),K&&F.push(...K.map(z=>ti(z,s.collaborators.get(z))))),F.length){let[z,U,W,G,ie,me]=Kl(L,t,!0);_.push({angle:L.angle,x1:z,y1:U,x2:W,y2:G,selectionColors:L.locked?["#ced4da"]:F,dashed:!!K||L.locked,cx:ie,cy:me,activeEmbeddable:s.activeEmbeddable?.element===L&&s.activeEmbeddable.state==="active",padding:L.id===s.croppingElementId||np(L)?0:void 0})}}let k=L=>{let F=Zf(t,L),[K,z,U,W]=$f(F);_.push({angle:0,x1:K,x2:U,y1:z,y2:W,selectionColors:F.some(G=>G.locked)?["#ced4da"]:["#000"],dashed:!0,cx:K+(U-K)/2,cy:z+(W-z)/2,activeEmbeddable:!1})};for(let L of xF(s))k(L);s.editingGroupId&&k(s.editingGroupId),_.forEach(L=>PT(g,s,L))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let D=dF(r[0],s.zoom,t,"mouse",Wf(c));if(!s.viewModeEnabled&&C&&!EF(s.editingTextElement)&&!s.croppingElementId&&yT(g,l,s,D,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&np(_)&&_F(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(D=>D.locked)){let D=vT*2/s.zoom.value;g.fillStyle="#fff";let[_,k,L,F]=$f(r,t),K=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=M,Ms(g,_-D,k-D,L-_+D*2,F-k+D*2,(_+L)/2,(k+F)/2,0),g.lineWidth=z,g.setLineDash(K);let U=mF([_,k,L,F,(_+L)/2,(k+F)/2],0,s.zoom,"mouse",y?{...Wf(c),rotation:!0}:Wf(c));r.some(W=>!W.locked)&&yT(g,l,s,U,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:M})=>{let D=t.get(C);if(D){let[_,k,,,L,F]=Kl(D,t,!0);g.save(),s.theme===No.LIGHT?P?g.fillStyle="rgba(255, 124, 0, 0.4)":g.fillStyle="rgba(255, 226, 0, 0.4)":P?g.fillStyle="rgba(229, 82, 0, 0.4)":g.fillStyle="rgba(99, 52, 0, 0.4)";let K=qa(D)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(L,F),g.rotate(D.angle),M.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/K-L,k+z.offsetY/K-F,z.width/K,z.height/K)}),g.restore()}}),hT(g,s),BF(g,o,t,e,s,l.selectionColor),g.restore(),Uw({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=bI(t,p,u,s),g.save(),g.fillStyle=EI,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&um(g,C.x,C.y,C.width,C.height,fn/2)}),g.restore()),{scrollBars:T,animationState:E}},jf=e=>{let n=zF(e);return e.callback(n),n};import{useEffect as jl,useMemo as AT,useRef as tE,useState as GF}from"react";import{bumpVersion as Xl,getLinearElementSubType as Qa,mutateElement as nE,updateElbowArrowPoints as HF}from"@excalidraw/element";import{pointFrom as ip,pointRotateRads as UF}from"@excalidraw/math";import{hasBoundTextElement as WF,isArrowBoundToElement as VF,isArrowElement as YF,isElbowArrow as KF,isLinearElement as aE,isUsingAdaptiveRadius as XF}from"@excalidraw/element";import{getCommonBoundingBox as ZF,getElementAbsoluteCoords as $F}from"@excalidraw/element";import{getBoundTextElement as NT,getBoundTextMaxHeight as jF,getBoundTextMaxWidth as qF,redrawTextBoundingBox as JF}from"@excalidraw/element";import{wrapText as QF}from"@excalidraw/element";import{assertNever as eO,CLASSES as tO,getFontString as qf,isProdEnv as nO,mapFind as oO,reduceToCommonValue as rO,ROUNDNESS as Jf,sceneCoordsToViewportCoords as iO,updateActiveTool as DT}from"@excalidraw/common";import{measureText as LT}from"@excalidraw/element";import{LinearElementEditor as aO}from"@excalidraw/element/linearElementEditor";import{newArrowElement as Qf,newElement as sO,newLinearElement as lO}from"@excalidraw/element";import{ShapeCache as cO}from"@excalidraw/element";import{updateBindings as dO}from"@excalidraw/element";import{jsx as iE}from"react/jsx-runtime";var mO=8,pO=10,Zl=["rectangle","diamond","ellipse"],$l=["line","sharpArrow","curvedArrow","elbowArrow"],uO=new Set(Zl),hO=new Set($l),es=e=>uO.has(e),ap=e=>e==="arrow"||hO.has(e),po=Je(null),ql=new Map,Jl=new Map,gO=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=tE(null);return jl(()=>{if(n.length===0){e.updateEditorAtom(po,null);return}let o=sp(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(po,null),t.current=null)},[n,e]),jl(()=>()=>{ql.clear(),Jl.clear()},[]),iE(fO,{app:e,elements:n})},fO=({app:e,elements:n})=>{let t=sp(n),o=AT(()=>t==="generic"?FT(n):[],[t,n]),r=AT(()=>t==="linear"?rE(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>Qa(m)===Qa(r[0])):!1,[a,s]=GF({x:0,y:0}),l=tE(""),c=tE(null);jl(()=>{let m=[...o,...r].sort((b,v)=>b.id.localeCompare(v.id)),p=`
18
- ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${m.map(b=>b.id).join(",")}`;if(p===l.current)return;l.current=p;let u;if(m.length===1){let[b,,,v,y,x]=$F(m[0],e.scene.getNonDeletedElementsMap());u=UF(ip(b,v),ip(y,x),m[0].angle)}else{let{minX:b,maxY:v}=ZF(m);u=ip(b,v)}let{x:E,y:g}=iO({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),jl(()=>{for(let m of r){let p=oE(m.id,wO(m));Jl.has(p)||Jl.set(p,m)}},[r]),jl(()=>{for(let m of o)if(!ql.has(m.id)){let p=NT(m,e.scene.getNonDeletedElementsMap());p&&ql.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",jo],["sharpArrow",Qo],["curvedArrow",tr],["elbowArrow",er]]:t==="generic"?[["rectangle",Gi],["diamond",Hi],["ellipse",Ui]]:[];return iE("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(pO+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-mO}px`,zIndex:2},className:tO.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&Qa(r[0])===m);return iE($,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&Ue("convertElementType",m,"ui"),sE(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},EO=(e,n,t)=>{let o=qF(e,n),r=jF(e,n),i=QF(n.text,qf(n),o),a=LT(i,qf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=LT(n.text,qf(l),n.lineHeight)}nE(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),JF(n,e,t)},sE=(e,{conversionType:n,nextType:t,direction:o="right"})=>{if(!n)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((s,l)=>({...s,[l.id]:!0}),{}),a=o==="right"?1:-1;if(n==="generic"){let s=FT(r),c=s.every(d=>d.type===s[0].type)?Zl.indexOf(s[0].type):-1;if(t=t??Zl[(c+Zl.length+a)%Zl.length],t&&es(t)){let d={};for(let p of s){let u=RT(p,t,e);d[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?m.push(d[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(d)){let u=NT(p,e.scene.getNonDeletedElementsMap());u&&(ql.get(p.id)&&nE(u,e.scene.getNonDeletedElementsMap(),{fontSize:ql.get(p.id)?.fontSize??u.fontSize}),EO(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:DT(p,{type:"selection"})}))}}if(n==="linear"){let s=rE(r);if(!t){let c=rO(s,Qa),d=c?$l.indexOf(c):-1;t=$l[(d+$l.length+a)%$l.length]}if(ap(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Jl.get(oE(m.id,t));if(p&&Qa(p)===t)d.set(p.id,p),c.push(p);else{let u=RT(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(aE(m))if(KF(m)){let p=bO(m);if(p.length<2)continue;let u=[];for(let g=1;g<p.length-2;g++)u.push({start:p[g],end:p[g+1],index:g+1});let E=HF(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});nE(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=oO(["line","sharpArrow","curvedArrow"],u=>Jl.get(oE(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=rE(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new aO(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:DT(c,{type:"selection"})}))}return!0},sp=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(es(t.type))return"generic";BT(t)&&(n=!0)}return n?"linear":null},BT=e=>aE(e)&&(!YF(e)||!VF(e)&&!WF(e)),oE=(e,n)=>`${e}:${n}`,FT=e=>e.filter(n=>es(n.type)),rE=e=>e.filter(n=>BT(n)),rp=20,Ja=(e,n)=>e[0]===n[0],eE=(e,n)=>e[1]===n[1],_T=(e,n)=>Ja(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),bO=e=>{let n=[e.points[0]],t=xO(e.points);for(let i=1;i<t.length;++i){let a=n[n.length-1],s=[...t[i]];Math.abs(s[0]-a[0])<rp?s[0]=a[0]:Math.abs(s[1]-a[1])<rp&&(s[1]=a[1]),Ja(a,s)||eE(a,s)||n.push(ip(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)Ja(n[i-1],n[i])&&Ja(n[i],n[i+1])||eE(n[i-1],n[i])&&eE(n[i],n[i+1])||o.push(n[i]);o.push(n[n.length-1]);let r=[o[0]];for(let i=1;i<o.length-1;++i){let a=r[r.length-1],s=o[i],l=o[i+1],c=Ja(a,s),d=Ja(s,l);if(c!==d){let m=_T(a,s),p=_T(s,l);if(m<rp||p<rp){if(p<m)c?l[0]=a[0]:l[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=s[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=s[1];continue}}r.push(s)}return r.push(o[o.length-1]),r},xO=e=>{if(e.length===0)return[];let n=[e[0]];for(let t=1;t<e.length;t++){let[o,r]=n[n.length-1],[i,a]=e[t];(o!==i||r!==a)&&n.push(e[t])}return n},RT=(e,n,t)=>{if(!yO(e.type,n)){if(!nO())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(cO.delete(e),es(n)){let o=Xl(sO({...e,type:n,roundness:e.roundness?{type:XF(n)?Jf.ADAPTIVE_RADIUS:Jf.PROPORTIONAL_RADIUS}:e.roundness}));return dO(o,t.scene,t.state),o}if(ap(n))switch(n){case"line":return Xl(lO({...e,type:"line"}));case"sharpArrow":return Xl(Qf({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Xl(Qf({...e,type:"arrow",elbowed:!1,roundness:{type:Jf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Xl(Qf({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return eO(n,`unhandled conversion type: ${n}`),e},yO=(e,n)=>!!(es(e)&&es(n)||ap(e)&&ap(n)),wO=e=>aE(e)?Qa(e):e.type,OT=gO;import{bindBindingElementToFixedPoint as vO,dragNewTextElement as IO,getBoundTextElement as TO,getEndpointBoundTextDragAnchor as SO,getTextBindingForArrowEndpoint as CO,getUnboundArrowEndpointAtPoint as PO,isArrowElement as kO,isBindingEnabled as MO,isEndpointBoundText as AO,isTextElement as DO}from"@excalidraw/element";import{pointFrom as LO}from"@excalidraw/math";var lp=class{constructor(n){this.app=n;w(this,"updateHoveredAnchor",n=>{let t=this.app.state.activeTool.type==="text"&&!this.app.state.editingTextElement&&!this.app.state.newElement?this.getAnchorAtPosition(n.x,n.y):null,o=this.app.state.hoveredArrowTextAnchor;return(o?.elementId!==t?.elementId||o?.anchor!==t?.anchor)&&this.app.setState({hoveredArrowTextAnchor:t}),t});w(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!MO(this.app.state))return null;let o=PO(LO(n,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!o||this.app.getTextElementAtPosition(n,t))return null;let r=this.app.getElementAtPosition(n,t,{includeLockedElements:!0});return r&&r.id!==o.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(o.arrow.id)?null:o}getAnchorAtPosition(n,t){let o=this.getBindableEndpointAtPosition(n,t);if(o)return{elementId:o.arrow.id,anchor:o.startOrEnd};let r=this.app.getTextBindableContainerAtPosition(n,t);return!kO(r)||TO(r,this.app.scene.getNonDeletedElementsMap())?null:this.app.getTextWysiwygSnappedToCenterPosition(n,t,this.app.state,r)?{elementId:r.id,anchor:"label"}:null}getTextBinding({arrow:n,startOrEnd:t},o){return CO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){vO(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!DO(n)||!AO(n,this.app.scene.getNonDeletedElementsMap())?!1:(IO({newElement:n,...SO(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as _O,BUCKET_FILL_BACKGROUND_PICKS as RO,COLOR_PALETTE as GT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as NO,getSizeFromPoints as BO,isTransparent as FO,THEME as OO}from"@excalidraw/common";import{pointFrom as zT}from"@excalidraw/math";import{computeBucketFillPolygon as zO,isBucketFillCompatible as GO,isFrameLikeElement as HO,isRestylableFill as UO,newLinearElement as WO,ShapeCache as VO}from"@excalidraw/element";var lE=RO.filter(e=>e!==GT.white),cp=class{constructor(n){this.app=n;w(this,"temporaryEyeDropper",null);w(this,"pending",null);w(this,"handlePointerDown",n=>{this.pending=n});w(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});w(this,"cancel",()=>{this.pending=null});w(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=lE.indexOf(n),o=lE[(t+1)%lE.length];this.app.actionManager.executeAction(Nd,"keyboard",{currentItemBackgroundColor:o})});w(this,"openTemporaryEyeDropper",()=>{if(bt.get(Ut))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(Nd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Ut,n)});w(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&bt.get(Ut)===n&&this.app.updateEditorAtom(Ut,null)});w(this,"restyle",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor);n.backgroundColor===t&&n.fillStyle===this.app.state.currentItemFillStyle&&n.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(n,{backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),VO.delete(n),this.app.scheduleCapture())});w(this,"fill",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=zT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=zO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&GO(a)){this.restyle(a);return}s.reason==="too_complex"?this.app.setToast({message:f("bucketfill.tooComplex"),duration:3e3}):(s.reason==="open_region"||s.reason==="too_small"||s.reason==="invalid_polygon")&&this.app.setToast({message:f("bucketfill.noRegion"),duration:3e3});return}if(a&&UO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=BO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(y=>zT(y[0]-d,y[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?HO(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:s.boundaryElementIds.map(y=>r.get(y)?.groupIds).filter(y=>!!y).reduce((y,x)=>y===null?x:y.filter(I=>x.includes(I)),null)??[],b=WO({type:"line",x:d,y:m,width:l,height:c,points:p,polygon:!0,strokeColor:"transparent",backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:"solid",roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:E,groupIds:g}),v=this.app.scene.getElementsIncludingDeleted().findIndex(y=>y.id===s.insertion.elementId);this.app.scene.insertElementsAtIndex([b],v<0?null:s.insertion.placement==="above"?v+1:v),this.app.scheduleCapture()});w(this,"getBucketFillBackgroundColor",(n,t)=>FO(n)?GT.green[NO]:_O(n,t===OO.DARK))}};import{CURSOR_TYPE as Ql,MIME_TYPES as mp,THEME as HT}from"@excalidraw/common";var UT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',YO='<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"/>',WT='<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"/>',KO=`data:${mp.svg},${encodeURIComponent(`${UT}${WT}</svg>`)}`,XO=`data:${mp.svg},${encodeURIComponent(`${UT}${YO}${WT}</svg>`)}`,ZO=e=>{let n=Hu.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${mp.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" fill="#fff" stroke-width="5">${n}</g><g stroke="#1b1b1f" stroke-width="1.25">${n}</g></svg>`)}`},dp=class{constructor(n){this.app=n;w(this,"toolCursorMemo",null);w(this,"eraserCanvasCache",null);w(this,"eraserPreviewDataURL",null);w(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});w(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(Ql.GRAB):this.clear():this.applyForTool()});w(this,"applyForTool",(n=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let o=n.type==="eraser"||n.type==="laser"||n.type==="bucketfill"?this.app.state.theme:void 0,r=n.type==="bucketfill"?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,o):void 0,i=this.toolCursorMemo;if(!(i?.canvas===t&&i.type===n.type&&i.bucketFillColor===r&&i.theme===o)){if(n.type==="selection")this.clear();else if(Cs({activeTool:n}))this.set(Ql.GRAB);else if(rn({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(Ql.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${ZO(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===HT.LIGHT?KO:XO;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(Ql.AUTO):this.set(Ql.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});w(this,"clear",()=>{this.set("")});w(this,"applyEraser",()=>{let t=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==t){let o=t===HT.DARK;this.eraserCanvasCache=document.createElement("canvas"),this.eraserCanvasCache.theme=t,this.eraserCanvasCache.height=20,this.eraserCanvasCache.width=20;let r=this.eraserCanvasCache.getContext("2d");r.lineWidth=1,r.beginPath(),r.arc(this.eraserCanvasCache.width/2,this.eraserCanvasCache.height/2,5,0,2*Math.PI),r.fillStyle=o?"#000":"#fff",r.fill(),r.strokeStyle=o?"#fff":"#000",r.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(mp.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as QO}from"@excalidraw/common";import{bindBindingElement as e9,convertToShape as t9,convertToShapeHandlePointerMoveFromPointerDown as n9,getHoveredElementForBinding as VT,isBindingElement as o9,isLineElement as r9,LinearElementEditor as cE,maxBindingDistance_simple as YT,newArrowElement as i9,updateBoundPoint as a9}from"@excalidraw/element";import{getStrokeWidthByKey as $O,THEME as jO}from"@excalidraw/common";import{clamp as qO,pointFrom as JO}from"@excalidraw/math";var pp=class{constructor(n){this.app=n;w(this,"trail");this.trail=new zn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===jO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>qO($O("line",this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(n,t){this.trail.startPath(n,t)}addPointToPath(n,t){this.trail.addPointToPath(n,t)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let n=this.trail.getCurrentTrail();return n?n.originalPoints.map(([t,o])=>JO(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var up=class{constructor(n){this.app=n;w(this,"trail");w(this,"gestureInProgress",!1);w(this,"stop",()=>{this.trail.stop()});w(this,"hasPendingGesture",()=>this.gestureInProgress);w(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(gt),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});w(this,"handlePointerMove",n=>n9(this.app,n));w(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=YT(t.state.zoom),a=["start","end"].map(d=>{let m=cE.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:VT(m,r,o,i)}}),s=!!a[0].target&&a[0].target===a[1].target,l=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:d,globalPoint:m,target:p}of a)p&&e9(n,p,s?"inside":"orbit",d,t.scene,m,t.state.isBindingEnabled,l);if(s)return;let c=new Map;for(let{startOrEnd:d,target:m}of a){if(!m)continue;let p=a9(n,d==="start"?"startBinding":"endBinding",d==="start"?n.startBinding:n.endBinding,m,o);p&&c.set(d==="start"?0:n.points.length-1,{point:p})}c.size&&cE.movePoints(n,t.scene,c)});w(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=YT(t.state.zoom),[a,s]=[0,-1].map(l=>VT(cE.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:i9({type:"arrow",x:n.x,y:n.y,width:n.width,height:n.height,startArrowhead:null,endArrowhead:t.state.currentItemEndArrowhead,points:n.points,groupIds:n.groupIds,frameId:n.frameId,locked:!1,angle:n.angle,strokeColor:n.strokeColor,backgroundColor:n.backgroundColor,fillStyle:n.fillStyle,roughness:n.roughness,opacity:n.opacity,strokeStyle:n.strokeStyle,strokeWidth:n.strokeWidth})});w(this,"finalize",()=>{let{app:n}=this,t=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),t.length>=3){let o=n.state.newElement||t9(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:QO(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&r9(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&o9(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new pp(n)}};import{isArrowKey as s9,KEYS as ui}from"@excalidraw/common";import{makeNextSelectedElementIds as l9,CaptureUpdateAction as c9,FlowChartCreator as d9,FlowChartNavigator as m9,getSelectedElements as KT,isFlowchartNodeElement as p9}from"@excalidraw/element";var hp=class e{constructor(n){this.app=n;w(this,"creator",new d9);w(this,"navigator",new m9);w(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});w(this,"handleKeyEvent",n=>{let t=this.resolveKeyboardEventToOperation(n);switch(t.type){case"none":return!1;case"canceled":return this.app.triggerRender(!0),!0;case"creating":return n.preventDefault(),t.pending.length&&this.app.revealIfHidden(t.pending),!0;case"navigating":{n.preventDefault();let o=t.nodeId&&this.app.scene.getNonDeletedElementsMap().get(t.nodeId);return o&&this.selectAndReveal(o),!0}case"committed":{t.nodes.length&&this.app.insertNewElements(t.nodes);let o=t.nodes[0];return o&&this.selectAndReveal(o),this.captureUpdate(),!0}case"navigationEnded":return this.captureUpdate(),!0}})}get pendingNodes(){return this.creator.pendingNodes}get isCreatingChart(){return this.creator.isCreatingChart}resolveKeyboardEventToOperation(n){let{creator:t,navigator:o,app:r}=this;if(n.type==="keydown"){if(n.key===ui.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!s9(n.key))return{type:"none"};if(n[ui.CTRL_OR_CMD]&&!n.shiftKey){let a=KT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&p9(a[0])&&t.createNodes(a[0],r.state,e.getLinkDirectionFromKey(n.key),r.scene),{type:"creating",pending:t.pendingNodes??[]}}if(n.altKey){let a=r.scene.getNonDeletedElementsMap(),s=KT(a,r.state);if(s.length===1)return{type:"navigating",nodeId:o.exploreByDirection(s[0],a,e.getLinkDirectionFromKey(n.key))}}return{type:"none"}}let i=!n.altKey&&o.isExploring;if(i&&o.clear(),!n[ui.CTRL_OR_CMD]&&t.isCreatingChart){let a=t.pendingNodes??[];return t.clear(),{type:"committed",nodes:a}}return i?{type:"navigationEnded"}:{type:"none"}}selectAndReveal(n){this.app.setState(t=>({selectedElementIds:l9({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:c9.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case ui.ARROW_UP:return"up";case ui.ARROW_DOWN:return"down";case ui.ARROW_RIGHT:return"right";case ui.ARROW_LEFT:return"left";default:return"right"}}};import{createGifPlaybackMetadata as XT,hasPlayableGif as u9,isInitializedImageElement as h9,newElementWith as ZT,ShapeCache as g9}from"@excalidraw/element";import{MIME_TYPES as $T}from"@excalidraw/common";var gp=class{constructor(n){this.app=n;w(this,"playbackRaf",null);w(this,"runtimeState",new Map);w(this,"stop",()=>{this.playbackRaf!==null&&(cancelAnimationFrame(this.playbackRaf),this.playbackRaf=null),this.runtimeState.clear()});w(this,"getFrameIndex",n=>n.gifPlayback?.playing?this.runtimeState.get(n.id)?.frameIndex??n.gifPlayback.frameIndex:n.gifPlayback?.frameIndex);w(this,"setFrameIndex",(n,t)=>{this.runtimeState.set(n.id,{frameIndex:t,lastFrameTime:performance.now()})});w(this,"ensureLoop",()=>{this.playbackRaf!==null||this.app.unmounted||u9(this.app.scene.getNonDeletedElements(),this.app.imageCache)&&(this.playbackRaf=requestAnimationFrame(this.tick))});w(this,"createPlaceholderDecodeState",(n,t)=>{if(t.type!==$T.gif)return null;let o=n.id;this.app.imageCache.set(o,{image:new Promise(()=>{}),mimeType:$T.gif,gifDecodeStatus:"pending"});let r=ZT(n,{fileId:o,gifPlayback:XT({playing:!0})});return this.app.scene.replaceAllElements(this.app.scene.getElementsIncludingDeleted().map(i=>i.id===r.id?r:i)),this.app.imagePlaceholderUpdateEmitter.trigger(),o});w(this,"ensureElementPlaybackMetadata",(n,t={})=>n.gifPlayback&&(t.playing===void 0||n.gifPlayback.playing===t.playing)?n:ZT(n,{gifPlayback:n.gifPlayback?{...n.gifPlayback,playing:t.playing??n.gifPlayback.playing}:XT(t)}));w(this,"removePlaceholderDecodeState",n=>{n&&this.app.imageCache.delete(n)});w(this,"tick",()=>{if(this.playbackRaf=null,this.app.unmounted)return;let n=performance.now(),t=!1,o=!1;for(let r of this.app.scene.getNonDeletedElements()){if(!h9(r)||!r.gifPlayback?.playing)continue;let i=this.app.imageCache.get(r.fileId)?.gif;if(!i||i.frames.length<2)continue;o=!0;let a=Math.max(r.gifPlayback.speed||1,.1),s=this.runtimeState.get(r.id)??{frameIndex:r.gifPlayback.frameIndex,lastFrameTime:n};this.runtimeState.set(r.id,s);let l=s.frameIndex,c=i.delays[l]??100;n-s.lastFrameTime>=c/a&&(s.frameIndex=(l+1)%i.frames.length,s.lastFrameTime=n,g9.delete(r),t=!0)}t&&this.app.imagePlaceholderUpdateEmitter.trigger(),o&&(this.playbackRaf=requestAnimationFrame(this.tick))})}};import{debounce as f9,easeOut as tS,isBounds as E9}from"@excalidraw/common";import{clamp as nS}from"@excalidraw/math";import{getCommonBounds as jT,getElementsInGroup as b9,isElementLink as x9,isExcalidrawElement as y9,parseElementLinkFromURL as w9}from"@excalidraw/element";var fp="animateScrollToContent",ts="animateScrollConstraintsSnapBack",qT=500,v9=250,I9=200,dE=302,JT={full:216,compact:64},T9=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.x=="number"&&typeof n.y=="number"&&(n.width==null||typeof n.width=="number")&&(n.height==null||typeof n.height=="number")},S9=(e,n)=>{let t=n.get(e);return t?[t]:b9(n,e)},QT=(e,n,t)=>{if(typeof e=="string"){let a=x9(e),s=a?"link":"element",l=a?w9(e):e,c=l?S9(l,n):[];return c.length?{bounds:jT(c,n),type:s}:{bounds:null,type:s}}if(E9(e))return{bounds:e,type:"area"};if(T9(e)&&!y9(e)){let a=e.width??t.width,s=e.height??t.height;return{bounds:[e.x,e.y,e.x+a,e.y+s],type:"area"}}let o=Array.isArray(e)?e:[e],r=o.reduce((a,s)=>{if(s&&!s.isDeleted){let l=n.get(s.id);l&&a.push(l)}return a},[]),i=!r.length;return(r.length!==o.length||i)&&console.warn("supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out"),i?{bounds:null,type:"element"}:{bounds:jT(r,n),type:"element"}},C9=e=>e===!1?0:e===!0||e==null?Au:Math.max(e,0),P9=(e,n,t="scale-down",o,r)=>{let{appState:i}=Fr({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},eS=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=P9(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[s,l,c,d]=n,m={x:s,y:l,width:c-s,height:d-l,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:a.zoom.value,overscroll:C9(r.overscroll),offsets:o};return{...$n({...e,...a,scrollConstraints:m}),scrollConstraints:m}},k9=({from:e,target:n,factor:t})=>{if(t>=1)return{...n};let o=e.zoom.value*Math.pow(n.zoom.value/e.zoom.value,t),r=n.zoom.value===e.zoom.value?t:(o-e.zoom.value)/(n.zoom.value-e.zoom.value);return{scrollX:((1-r)*e.scrollX*e.zoom.value+r*n.scrollX*n.zoom.value)/o,scrollY:((1-r)*e.scrollY*e.zoom.value+r*n.scrollY*n.zoom.value)/o,zoom:{value:o}}},M9=e=>e===!1?null:e===!0||e==null?qT:e.duration??qT,A9=(e,n,t,o,r)=>{ct.start(fp,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=tS(nS(l,0,1));return l<1?(o({...k9({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},D9=(e,n,t=v9)=>{let o=$n(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||ct.running(fp))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;ct.start(ts,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-tS(nS(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=$n(m),u=p.zoom.value;return{scrollX:p.scrollX+r*d/u,scrollY:p.scrollY+i*d/u,zoom:p.zoom}}),c<1?{elapsed:l}:null})},Ep=class{constructor(n,t){this.app=n;this.dependencies=t;w(this,"lastPosition",{x:0,y:0});w(this,"activeTransition",null);w(this,"uiLastMeasured",new Map);w(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});w(this,"resolveOffsets",n=>{if(!n)return n;let{ui:t,...o}=n;if(!t)return o;let r=this.getOffsets(t===!0?void 0:t);return{top:o.top??r.top,right:o.right??r.right,bottom:o.bottom??r.bottom,left:o.left??r.left}});w(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=Jn().rtl,i={top:0,right:0,bottom:0,left:0},a=new Set;if(t&&o)for(let u of t.querySelectorAll("[data-viewport-ui]")){let E=u.getBoundingClientRect(),g={top:E.top-o.top,right:E.right-o.left,bottom:E.bottom-o.top,left:E.left-o.left,width:E.width};switch(u.dataset.viewportUi){case"top":i.top=Math.max(i.top,g.bottom);break;case"bottom":i.bottom=Math.max(i.bottom,this.app.state.height-g.top);break;case"side":{let[b,v]=g.left+g.width/2<this.app.state.width/2?["left",g.right]:["right",this.app.state.width-g.left];i[b]=Math.max(i[b],v);let y=u.dataset.viewportUiName;y&&(a.add(y),v>0&&this.uiLastMeasured.set(y,{side:b,offset:v}));break}}}if(n?.reserve&&this.app.editorInterface.formFactor!=="phone"){let u=(E,g)=>{if(a.has(E))return;let{side:b,offset:v}=this.uiLastMeasured.get(E)??g;i[b]=Math.max(i[b],v)};n.reserve.stylesPanel&&u("stylesPanel",{side:r?"right":"left",offset:this.dependencies.getStylesPanelMode()==="compact"?JT.compact:JT.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:dE})}let s=n?.padding??24,l=n?.paddingTop??s,c=(r?n?.paddingLeft:n?.paddingRight)??s,d=n?.paddingBottom??s,m=(r?n?.paddingRight:n?.paddingLeft)??s,p={top:i.top+l,right:i.right+c,bottom:i.bottom+d,left:i.left+m};return{top:n?.top??p.top,right:(r?n?.left:n?.right)??p.right,bottom:n?.bottom??p.bottom,left:(r?n?.right:n?.left)??p.left}});w(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=QT(n.target,t,o);return r?eS(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});w(this,"setViewport",n=>{if(n===null){this.cancelTransition(),ct.cancel(ts),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:o,lock:r,animation:i,viewportZoomFactor:a}=n,s=this.resolveOffsets(n.offsets),{bounds:l,type:c}=QT(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!l){c==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let d=eS(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=M9(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),ct.cancel(ts),this.snapBackDebounced.cancel(),m===null){this.app.setState({...d,shouldCacheIgnoreZoom:!1});return}let u={target:d};this.activeTransition=u,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),A9(p,d,m,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});w(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||ct.cancel(ts),this.app.setState({shouldCacheIgnoreZoom:!1}),this.app.requestUnfollow();let o=this.app.state.zoom.value;return this.app.setState(n),this.app.setState(r=>{if(!r.scrollConstraints)return null;let a=!t?.zoomPreConstrained&&r.zoom.value!==o?0:r.scrollConstraints.overscroll;return a>0&&this.snapBackDebounced(),$n(r,a)}),!0});w(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?$n(t,n):null)});w(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});w(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||D9(this.app.state,n=>this.app.setState(t=>n(t)))});w(this,"snapBackDebounced",f9(this.snapBack,I9));w(this,"cancelTransition",()=>{this.activeTransition=null,ct.cancel(fp)});w(this,"destroy",()=>{this.cancelTransition(),ct.cancel(ts),this.snapBackDebounced.cancel()})}get isAnimating(){return ct.running(fp)||ct.running(ts)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import bp from"react";var L9=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,_9=/{{([\w-]+)}}/,R9=/<([\w-]+)>/,N9=/<\/([\w-]+)>/,B9=(e,n)=>{let t=[{name:"",children:[]}];return e.split(L9).filter(Boolean).forEach(o=>{let r=o.match(R9),i=o.match(N9),a=o.match(_9);if(r!==null){let s=r[1];n.hasOwnProperty(s)?t.push({name:s,children:[]}):console.warn(`Trans: missed to pass in prop ${s} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let l=t.pop(),c=bp.createElement(bp.Fragment,{},...l.children),d=n[l.name];typeof d=="function"&&t[t.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let s=a[1];n.hasOwnProperty(s)?t[t.length-1].children.push(n[s]):console.warn(`Trans: key ${s} not in props for interpolating ${e}`)}else t[t.length-1].children.push(o)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},F9=({i18nKey:e,children:n,...t})=>{let{t:o}=Ne();return bp.createElement(bp.Fragment,{},...B9(o(e),t))},hi=F9;import{jsx as yn,jsxs as oS}from"react/jsx-runtime";var O9=()=>oS("div",{"data-testid":"brave-measure-text-error",children:[yn("p",{children:yn(hi,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(hi,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(hi,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>yn("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),yn("p",{children:yn(hi,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>yn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>oS("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),rS=O9;import K9 from"clsx";import X9 from"react";import{isDarwin as iS}from"@excalidraw/common";var z9={toggleTheme:[N("Shift+Alt+D")],saveScene:[N("CtrlOrCmd+S")],loadScene:[N("CtrlOrCmd+O")],imageExport:[N("CtrlOrCmd+Shift+E")],cut:[N("CtrlOrCmd+X")],copy:[N("CtrlOrCmd+C")],paste:[N("CtrlOrCmd+V")],copyStyles:[N("CtrlOrCmd+Alt+C")],pasteStyles:[N("CtrlOrCmd+Alt+V")],selectAll:[N("CtrlOrCmd+A")],deleteSelectedElements:[N("Delete")],duplicateSelection:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)],sendBackward:[N("CtrlOrCmd+[")],bringForward:[N("CtrlOrCmd+]")],sendToBack:[iS?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[iS?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")],copyAsPng:[N("Shift+Alt+C")],group:[N("CtrlOrCmd+G")],ungroup:[N("CtrlOrCmd+Shift+G")],gridMode:[N("CtrlOrCmd+'")],objectsSnapMode:[N("Alt+S")],stats:[N("Alt+/")],flipHorizontal:[N("Shift+H")],flipVertical:[N("Shift+V")],flipViewpointHorizontal:[N("Shift+R")],flipViewpointVertical:[N("Alt+Shift+R")],viewMode:[N("Alt+R")],hyperlink:[N("CtrlOrCmd+K")],toggleElementLock:[N("CtrlOrCmd+Shift+L")],resetZoom:[N("CtrlOrCmd+0")],zoomOut:[N("CtrlOrCmd+-")],zoomIn:[N("CtrlOrCmd++")],zoomToFitSelection:[],zoomToFit:[],zoomToFitSelectionInViewport:[],smartZoom:[N("F")],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[N("Shift+A")],toolLock:[N("Q")]},et=(e,n=0)=>{let t=z9[e];return t&&t.length>0?t[n]||t[0]:""};import{useLayoutEffect as G9,useRef as aS,useEffect as sS}from"react";import{unstable_batchedUpdates as H9}from"react-dom";import{KEYS as U9,queryFocusableElements as W9}from"@excalidraw/common";import{clamp as lS}from"@excalidraw/math";import V9 from"clsx";import{jsx as Y9}from"react/jsx-runtime";var wr=10,cS=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=aS(null);sS(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===U9.TAB){let u=W9(d),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===d?(p.shiftKey?u[u.length-1]?.focus():u[0].focus(),p.preventDefault(),p.stopImmediatePropagation()):g===0&&p.shiftKey?(u[u.length-1]?.focus(),p.preventDefault(),p.stopImmediatePropagation()):g===u.length-1&&!p.shiftKey&&(u[0]?.focus(),p.preventDefault(),p.stopImmediatePropagation())}};return d.addEventListener("keydown",m),()=>d.removeEventListener("keydown",m)},[]);let c=aS(null);return G9(()=>{if(r&&l.current&&t!=null&&n!=null){let d=l.current,{width:m,height:p}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===n)return;c.current={top:t,left:n};let u=Math.max(0,i-wr*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${wr}px`,d.style.overflowX="scroll"):d.style.left=`${lS(n,wr,i-wr-m)}px`;let E=Math.max(0,a-wr*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${wr}px`,d.style.overflowY="scroll"):d.style.top=`${lS(t,wr,a-wr-p)}px`}},[t,n,r,i,a]),sS(()=>{if(o){let d=m=>{l.current?.contains(m.target)||H9(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),Y9("div",{className:V9("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as Bo,jsxs as mS}from"react/jsx-runtime";var Ge="separator",dS=e=>"onSelect"in e,pS=X9.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=ro(),a=$i(),s=n.reduce((l,c)=>c?c===Ge||dS(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return Bo(cS,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:Bo("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===Ge)return!s[c-1]||s[c-1]===Ge?null:Bo("hr",{className:"context-menu-item-separator"},c);if(dS(l))return Bo("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:mS("button",{type:"button",className:"context-menu-item",children:[Bo("div",{className:"context-menu-item__label",children:l.label}),Bo("kbd",{className:"context-menu-item__shortcut"})]})},l.key);let d=l.name,m="";return l.label&&(typeof l.label=="function"?m=f(l.label(a,i,e.app)):m=f(l.label)),Bo("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:mS("button",{type:"button",className:K9("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[Bo("div",{className:"context-menu-item__label",children:m}),Bo("kbd",{className:"context-menu-item__shortcut",children:d?et(d):""})]})},c)})})})});import{useId as Z9}from"react";import $9 from"clsx";import{Fragment as j9,jsx as ec,jsxs as uS}from"react/jsx-runtime";var xp=({border:e,style:n})=>ec("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),yp=({label:e,border:n})=>{let t=Z9(),o=uS(j9,{children:[e.icon&&ec("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return uS("div",{className:$9("viewport-status-frame__badge",{"viewport-status-frame__badge--clickable":e.onClick}),role:"status",style:{"--viewport-status-frame-badge-background":e.background||n||"var(--color-primary)",color:e.color},children:[e.onClick&&ec("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),ec("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&ec("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:an})]})};import gs from"clsx";import vV from"react";import{CLASSES as IV,TOOL_TYPE as Gk,arrayToMap as TV,isShallowEqual as tu}from"@excalidraw/common";import{mutateElement as SV,ShapeCache as CV}from"@excalidraw/element";import{showSelectedShapeActions as PV}from"@excalidraw/element";import{createIsolation as q9}from"jotai-scope";import mE from"react";import Fo from"tunnel-rat";var pE=mE.createContext(null),it=()=>mE.useContext(pE),J9=q9(),hS=()=>mE.useMemo(()=>({MainMenuTunnel:Fo(),WelcomeScreenMenuHintTunnel:Fo(),WelcomeScreenToolbarHintTunnel:Fo(),WelcomeScreenHelpHintTunnel:Fo(),WelcomeScreenCenterTunnel:Fo(),FooterCenterTunnel:Fo(),DefaultSidebarTriggerTunnel:Fo(),DefaultSidebarTabTriggersTunnel:Fo(),OverwriteConfirmDialogTunnel:Fo(),tunnelsJotai:J9}),[]);import Ir from"clsx";import{useRef as sz}from"react";import{Popover as vr}from"radix-ui";import{CLASSES as SS}from"@excalidraw/common";import{isArrowElement as TS}from"@excalidraw/element";import{forwardRef as gS}from"react";import fS from"clsx";import{jsx as ES}from"react/jsx-runtime";var Q9=gS(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>ES("div",{className:fS("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),ez=gS(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>ES("div",{className:fS("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Ft={Row:Q9,Col:ez};import{isTransparent as bS}from"@excalidraw/common";import{shouldAllowVerticalAlign as tz,suppportsHorizontalAlign as nz,hasBoundTextElement as xS,isElbowArrow as oz,isImageElement as yS,isLinearElement as rz,isTextElement as iz,hasStrokeColor as wS,toolIsArrow as az}from"@excalidraw/element";var vS=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return wS(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>wS(o.type))},IS=(e,n)=>Xo(e.activeTool.type)||n.some(t=>Xo(t.type)),wp=(e,n,t,o)=>{let r=e.activeTool.type,i=d=>d(r)||n.some(m=>d(m.type)),a=n.length===1,s=n.length===2&&(xS(n[0])||xS(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:vS(e,n),backgroundColor:IS(e,n),fill:r==="bucketfill"||Xo(r)&&!bS(e.currentItemBackgroundColor)||n.some(d=>Xo(d.type)&&!bS(d.backgroundColor)),strokeWidth:i(gx),freedrawMode:i(fx),strokeStyle:i(Du),sloppiness:i(Du),roundness:i(Ex),arrowType:i(az),arrowheads:i(Ss),text:r==="text"||n.some(iz),textAlign:r==="text"||nz(n,t),verticalAlign:tz(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||de(t,e).some(d=>d.type==="freedraw"),align:!s&&lt(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(yS)&&lt(e,o),link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&yS(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&rz(n[0])&&!oz(n[0])}};import{Fragment as en,jsx as q,jsxs as Te}from"react/jsx-runtime";var uE=Ir([SS.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),CS=({renderAction:e})=>Te("fieldset",{children:[q("legend",{children:f("labels.layers")}),Te("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),PS=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Te("fieldset",{className:"align-fieldset","aria-label":f("labels.align"),children:[Te("div",{className:"align-fieldset-header",children:[q("span",{className:"align-fieldset-label",children:f("labels.align")}),e("toggleAlignStacking")]}),Te("div",{className:"buttonList",children:[o?Te(en,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Te(en,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),q("div",{style:{flexBasis:"100%",height:0}}),Te("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Te(en,{children:[q("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},kS=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=Li(n,e),i=wp(e,r,n,o);return e.activeTool.type==="bucketfill"?Te("div",{className:"selected-shape-actions",children:[q("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Te("div",{className:"selected-shape-actions",children:[q("div",{children:i.strokeColor&&t("changeStrokeColor")}),i.backgroundColor&&q("div",{children:t("changeBackgroundColor")}),i.fill&&t("changeFillStyle"),i.strokeWidth&&t("changeStrokeWidth"),i.strokeStyle&&q(en,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&q(en,{children:t("changeSloppiness")}),i.roundness&&q(en,{children:t("changeRoundness")}),i.arrowType&&q(en,{children:t("changeArrowType")}),i.text&&Te(en,{children:[q("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&q(en,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&q(CS,{renderAction:t}),i.align&&q(PS,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Te("fieldset",{children:[q("legend",{children:f("labels.actions")}),Te("div",{className:"buttonList",children:[t("duplicateSelection"),t("deleteSelectedElements"),t("group"),t("ungroup"),i.link&&t("hyperlink"),i.cropEditor&&t("cropEditor"),i.lineEditor&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},MS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let i=o.hasSelection||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",a=e.openPopup==="compactStrokeStyles";return i?q("div",{className:"compact-action-item",children:Te(vr.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[q(vr.Trigger,{asChild:!0,children:q("button",{type:"button",className:Ir("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:I0})}),a&&q(Co,{className:uE,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Te("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&q(en,{children:n("changeStrokeStyle")}),o.sloppiness&&q(en,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},AS=({appState:e,renderAction:n,setAppState:t,targetElements:o,predicates:r,container:i,app:a})=>{if(!r.arrowType)return null;let s=e.openPopup==="compactArrowProperties";return q("div",{className:"compact-action-item",children:Te(vr.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[q(vr.Trigger,{asChild:!0,children:q("button",{type:"button",className:Ir("compact-action-button properties-trigger",{active:s}),title:f("labels.arrowtypes"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:s?null:"compactArrowProperties"})},children:(()=>{let l=ut(o,a,c=>TS(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>TS(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?er:l==="round"?tr:Qo})()})}),s&&q(Co,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},DS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=K0(),s=e.openPopup==="compactTextProperties";return q("div",{className:"compact-action-item",children:Te(vr.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[q(vr.Trigger,{asChild:!0,children:q("button",{type:"button",className:Ir("compact-action-button properties-trigger",{active:s}),title:f("labels.textAlign"),onClick:l=>{l.preventDefault(),l.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"}))},children:$x})}),e.openPopup==="compactTextProperties"&&q(Co,{className:uE,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Te("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},LS=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let s=e.openPopup==="compactOtherProperties";return t.showExtraActions?q("div",{className:"compact-action-item",children:Te(vr.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[q(vr.Trigger,{asChild:!0,children:q("button",{type:"button",className:Ir("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:Ux})}),s&&q(Co,{className:uE,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Te("div",{className:"selected-shape-actions",children:[t.layers&&q(CS,{renderAction:n}),t.align&&q(PS,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Te("fieldset",{children:[q("legend",{children:f("labels.actions")}),Te("div",{className:"buttonList",children:[n("group"),n("ungroup"),t.linkSingleOnly&&n("hyperlink"),t.cropEditor&&n("cropEditor"),n("smartZoom"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},lz=({renderAction:e,predicates:n})=>n.lineEditor?q("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,_S=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Li(n,e),a=wp(e,i,n,o),{container:s}=Oe();return Te("div",{className:"compact-shape-actions",children:[a.strokeColor&&q("div",{className:Ir("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),a.freedrawMode&&q("div",{className:"compact-action-item",children:t("changeFreedrawMode",{cycle:!0})}),q(MS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(AS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),a.lineEditor&&q("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Te(en,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(DS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),a.showExtraActions&&q("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&q("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),q(LS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},RS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Li(n,e),a=wp(e,i,n,o),{container:s}=Oe(),l=sz(null),c=l.current?.getBoundingClientRect()?.width??0,d=9,m=6,p=32,u=d*p+(d-1)*m,E=p+m,g=c>=u+E,b=c>=u+2*E;return Te(Xe,{className:"compact-shape-actions mobile-shape-actions",style:{flexDirection:"row",boxShadow:"none",padding:0,zIndex:2,backgroundColor:"transparent",height:p*1.35,marginBottom:4,alignItems:"center",gap:m,pointerEvents:"none"},ref:l,children:[Te("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&q("div",{className:Ir("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),q(MS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(AS,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),q(lz,{renderAction:t,predicates:a}),a.text&&Te(en,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(DS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),q(LS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Te("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[q("div",{className:"compact-action-item",children:t("undo")}),q("div",{className:"compact-action-item",children:t("redo")}),b&&q("div",{className:"compact-action-item",children:t("duplicateSelection")}),g&&q("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},NS=({renderAction:e})=>q(Ft.Col,{gap:1,className:SS.ZOOM_ACTIONS,children:Te(Ft.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),BS=({renderAction:e,className:n})=>Te("div",{className:`undo-redo-buttons ${n}`,children:[q("div",{className:"undo-button-container",children:q(ht,{label:f("buttons.undo"),children:e("undo")})}),q("div",{className:"redo-button-container",children:Te(ht,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),FS=({showExitZenModeBtn:e})=>q("button",{type:"button",className:Ir("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import cz from"clsx";import{useState as dz,useEffect as mz}from"react";import{THEME as pz}from"@excalidraw/common";import{jsx as hE,jsxs as uz}from"react/jsx-runtime";var vp=({delay:e,theme:n})=>{let[t,o]=dz(!!e);return mz(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:uz("div",{className:cz("LoadingMessage",{"LoadingMessage--dark":n===pz.DARK}),children:[hE("div",{children:hE(So,{})}),hE("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as Cp,useEffect as iC}from"react";import Uz from"clsx";import{KEYS as bE,capitalizeString as aC}from"@excalidraw/common";import rC from"react";import{DropdownMenu as Oz}from"radix-ui";import{CLASSES as zz}from"@excalidraw/common";import hz from"clsx";import{useCallback as gz,useEffect as fz,useRef as Ez}from"react";import{CLASSES as bz,EVENT as OS,KEYS as xz}from"@excalidraw/common";import{DropdownMenu as yz}from"radix-ui";import{jsx as Ip}from"react/jsx-runtime";var zS=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=Ee(),l=Ez(null),c=Zi({onClickOutside:n});Xi(l,gz(m=>{l.current?.closest(`.${bz.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),fz(()=>{if(!r)return;let m=u=>{u.key===xz.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(OS.KEYDOWN,m,p),()=>{document.removeEventListener(OS.KEYDOWN,m,p)}},[c,r]);let d=hz(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return Ip(Bh.Provider,{value:{onSelect:o},children:Ip(yz.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?Ip(Ft.Col,{className:"dropdown-menu-container",children:e}):Ip(Xe,{className:"dropdown-menu-container",padding:2,children:e})})})};zS.displayName="DropdownMenuContent";var GS=zS;import{jsx as vz}from"react/jsx-runtime";var wz=({children:e,className:n="",selected:t,...o})=>vz("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),HS=wz;import{DropdownMenu as Iz}from"radix-ui";import{jsx as gE}from"react/jsx-runtime";var US=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=Td(r);return gE(Iz.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:gE("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:ir(i,a),title:l.title??l["aria-label"],children:gE(ar,{icon:e,shortcut:n,children:o})})})},ns=US;US.displayName="DropdownMenuItemLink";import{jsx as Tz}from"react/jsx-runtime";var WS=()=>Tz("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),VS=WS;WS.displayName="DropdownMenuSeparator";import{DropdownMenu as Dz}from"radix-ui";import Sz from"clsx";import{DropdownMenu as Cz}from"radix-ui";import{useCallback as Pz,useState as YS}from"react";import{jsx as EE}from"react/jsx-runtime";var fE=-4,kz=4,KS=({children:e,className:n})=>{let t=Ee(),o=Sz(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=Pz(c=>{if(c){let m=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(m){let p=c.getBoundingClientRect().width,E=window.innerWidth-m.right;E<p+20&&(a(E-p+fE),l(fE+8))}}},[]),[i,a]=YS(kz),[s,l]=YS(fE);return EE(Cz.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?EE(Ft.Col,{className:"dropdown-menu-container",children:e}):EE(Xe,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},XS=KS;KS.displayName="DropdownMenuSubContent";import{DropdownMenu as Mz}from"radix-ui";import{jsx as ZS,jsxs as Az}from"react/jsx-runtime";var $S=({children:e,icon:n,shortcut:t,className:o})=>Az(Mz.SubTrigger,{className:`${ir(o)} dropdown-menu__submenu-trigger`,children:[ZS(ar,{icon:n,shortcut:t,children:e}),ZS("div",{className:"dropdown-menu__submenu-trigger-icon",children:C0})]}),jS=$S;$S.displayName="DropdownMenuSubTrigger";import qS from"react";var Tp=e=>n=>{let t=qS.Children.toArray(n).find(o=>qS.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},JS=Tp("DropdownMenuTrigger"),QS=Tp("DropdownMenuContent"),eC=Tp("DropdownMenuSubTrigger"),tC=Tp("DropdownMenuSubContent");import{jsxs as Lz}from"react/jsx-runtime";var Sp=({children:e})=>{let n=eC(e),t=tC(e);return Lz(Dz.Sub,{children:[n,t]})};Sp.Trigger=jS;Sp.Content=XS;Sp.displayName="DropdownMenuSub";var Tr=Sp;import _z from"clsx";import{DropdownMenu as Rz}from"radix-ui";import{jsx as Nz}from"react/jsx-runtime";var nC=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=Ee(),a=_z(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return Nz(Rz.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},oC=nC;nC.displayName="DropdownMenuTrigger";import{jsx as Fz}from"react/jsx-runtime";var Bz=e=>Fz(Jt,{...e,icon:e.checked?$c:nd}),uo=Bz;import{jsx as Hz,jsxs as Gz}from"react/jsx-runtime";var Hn=({children:e,open:n})=>{let t=JS(e),o=QS(e),r=o&&rC.isValidElement(o)?rC.cloneElement(o,{open:n}):o;return Hz(Oz.Root,{open:n,modal:!1,children:Gz("div",{className:zz.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Hn.Trigger=oC;Hn.Content=GS;Hn.Item=Jt;Hn.ItemCheckbox=uo;Hn.ItemLink=ns;Hn.ItemCustom=HS;Hn.Group=Zs;Hn.Separator=VS;Hn.Sub=Tr;var ge=Hn;Hn.displayName="DropdownMenu";import{Fragment as xE,jsx as Be,jsxs as os}from"react/jsx-runtime";var Wz=({actionManager:e,app:n})=>{if(!e.isActionEnabled(_t))return null;let t=f("buttons.objectsSnapMode");return Be($,{type:"toggle",icon:Jo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(_t,"ui")})},Vz=({app:e})=>Be($,{type:"button",icon:Vi,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),sC=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=Cp(!1),[l,c]=Cp("rectangle"),[d,m]=Cp("arrow");iC(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&c(o.type)},[o.type]),iC(()=>{(o.type==="arrow"||o.type==="line")&&m(o.type)},[o.type]);let p=o.type==="frame",u=o.type==="autoshape",E=o.type==="laser",g=o.type==="embeddable",b=o.type==="bucketfill",v=["rectangle","diamond","ellipse"].map(G=>({type:G,icon:$e[G].icon,title:aC(f(`toolBar.${G}`)),fillable:$e[G].fillable})),y=["arrow","line"].map(G=>({type:G,icon:$e[G].icon,title:aC(f(`toolBar.${G}`)),fillable:$e[G].fillable})),[x,I]=Cp(0),T=36,C=4,P=7,M=P*T+(P-1)*C,D=T+C,_=x>=M+1*D,k=i&&x>=M+2*D,L=x>=M+3*D,F=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(G=>!(_&&G==="text"||(!i||k)&&G==="image"||L&&G==="frame")),K=r&&sa.includes(o.type),z=K||F.includes(o.type),U=z?K?$e[o.type].icon:o.type==="text"?Dn:o.type==="image"?Hr:o.type==="frame"?to:o.type==="embeddable"?qo:o.type==="laser"?no:o.type==="bucketfill"?eo:Ls:Ls,W={app:e,activeTool:o,hideShortcut:!0};return os("div",{className:"mobile-toolbar",ref:G=>{G&&I(G.getBoundingClientRect().width)},children:[Be(Xd,{...W}),Be(Zd,{...W,setAppState:t}),r?Be(ol,{...W}):Be($d,{...W}),Be(al,{...W}),!r&&Be(aa,{app:e,options:v,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:G=>{(G==="rectangle"||G==="diamond"||G==="ellipse")&&(c(G),e.setActiveTool({type:G}))},displayedOption:v.find(G=>G.type===l)||v[0]}),!r&&Be(aa,{app:e,options:y,activeTool:o,defaultOption:d,"data-testid":"toolbar-arrow",onToolChange:G=>{(G==="arrow"||G==="line")&&(m(G),e.setActiveTool({type:G}))},displayedOption:y.find(G=>G.type===d)||y[0]}),_&&Be(rl,{...W}),r&&k&&Be(Vz,{app:e}),k&&Be(il,{...W}),!r&&L&&Be(sw,{...W,hideShortcut:!0}),os(ge,{open:a,children:[Be(ge.Trigger,{className:Uz("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":z||a}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:T,height:T,display:"flex",alignItems:"center",justifyContent:"center"},children:U}),os(ge.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&sa.map(G=>Be(ge.Item,{onSelect:()=>e.setActiveTool({type:G}),icon:$e[G].icon,"data-testid":`toolbar-${G}`,selected:o.type===G,shortcut:Kd(G),disabled:tt(e,G),children:f(`toolBar.${G}`)},G)),!r&&Be("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(_t)&&Be(ge.Item,{onSelect:()=>n.executeAction(_t,"ui"),icon:Jo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:et("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&os(xE,{children:[r&&Be("div",{className:"App-toolbar__dropdown-divider"}),Be(ge.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?$o:To,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:bE.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Be(ge.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Dn,shortcut:bE.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:tt(e,"text"),children:f("toolBar.text")}),i&&!k&&Be(ge.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Hr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:tt(e,"image"),children:f("toolBar.image")}),!r&&!L&&Be(ge.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:to,shortcut:bE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:tt(e,"frame"),children:f("toolBar.frame")}),!r&&os(xE,{children:[Be(ge.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:qo,"data-testid":"toolbar-embeddable",selected:g,disabled:tt(e,"embeddable"),children:f("toolBar.embeddable")}),Be(ge.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Vr,shortcut:ca("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:tt(e,"autoshape"),children:f("toolBar.autoshape")}),Be(ge.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:no,"data-testid":"toolbar-laser",selected:E,disabled:tt(e,"laser"),children:f("toolBar.laser")}),Be(ge.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:eo,"data-testid":"toolbar-bucketfill",selected:b,disabled:tt(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&os(xE,{children:[Be("div",{className:"App-toolbar__divider"}),Be(Wz,{actionManager:n,app:e})]})]})};import Yz from"clsx";import{jsx as Kz}from"react/jsx-runtime";var Pp=({children:e,side:n,className:t})=>Kz("div",{className:Yz("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import Xz from"clsx";import{jsx as Zz}from"react/jsx-runtime";var rs=e=>e.penDetected?Zz($,{className:Xz("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Zx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as lC,jsx as vt,jsxs as gi}from"react/jsx-runtime";var cC=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:s,defaultUIEnabled:l,scrollBackToContentUIEnabled:c,app:d,onPenModeToggle:m})=>{let{WelcomeScreenCenterTunnel:p,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:E}=it(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=vt("div",{className:"excalidraw-ui-top-right",children:i?.(!0,e)??(!e.viewModeEnabled&&gi(lC,{children:[l&&vt(rs,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),vt(E.Out,{})]}))}),M=gi("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),vt(u.Out,{})]});return gi("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[M,P]})},b=()=>vt(sC,{app:d,actionManager:t,setAppState:o}),v=c&&e.scrolledOutside,y=l,x=l&&(!e.viewModeEnabled||y),I=v&&!e.openMenu&&!e.openSidebar?vt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({...Di(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?vt(yp,{label:T,border:d.props.viewportStatusFrame?.border}):null;return gi(lC,{children:[a(),vt("div",{className:"App-welcome-screen",children:s&&vt(p.Out,{})}),x&&gi("div",{className:"App-bottom-bar",style:{marginBottom:fn+Ro,left:14,transform:"none"},"data-viewport-ui":"bottom",children:[I&&vt("div",{className:"floating-status-stack",children:I}),gi("div",{className:"App-bottom-bar__actions-row",children:[y&&gi(Xe,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&vt("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),vt("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&vt(RS,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&vt(Xe,{className:"App-toolbar",style:{justifyContent:"flex-start"},children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&I&&vt("div",{className:"floating-status-stack",children:I}),C&&vt("div",{className:"viewport-status-frame__badge-row",children:C}),vt(Pp,{side:"top",className:"App-top-bar",children:g()})]})};import fC,{useLayoutEffect as EC,useRef as bC,useState as xC}from"react";import{newTextElement as yC}from"@excalidraw/element";import tG from"clsx";import{useEffect as nG,useState as oG}from"react";import{KEYS as rG,queryFocusableElements as hC}from"@excalidraw/common";import{useCallback as $z,useState as jz}from"react";var dC=()=>{let[e,n]=jz(null),t=$z(o=>n(o),[]);return[e,t]};import mC from"clsx";import{useRef as qz}from"react";import{createPortal as Jz}from"react-dom";import{KEYS as Qz}from"@excalidraw/common";import{jsx as pC,jsxs as eG}from"react/jsx-runtime";var uC=e=>{let{closeOnClickOutside:n=!0}=e,t=ud({className:mC("excalidraw-modal-container",e.portalContainerClassName)}),o=qz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===Qz.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return Jz(eG("div",{className:mC("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[pC("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),pC("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as kp,jsxs as gC}from"react/jsx-runtime";function iG(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var wn=e=>{let[n,t]=dC(),[o]=oG(document.activeElement),{id:r}=Oe(),i=Ee().formFactor==="phone";nG(()=>{if(!n)return;let l=hC(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===rG.TAB){let m=hC(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&d.shiftKey?(m[m.length-1].focus(),d.preventDefault()):u===m.length-1&&!d.shiftKey&&(m[0].focus(),d.preventDefault())}};return n.addEventListener("keydown",c),()=>n.removeEventListener("keydown",c)},[n,e.autofocus]);let a=We(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return kp(uC,{className:tG("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:iG(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:gC(Xe,{ref:t,children:[e.title&&gC("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[kp("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&kp("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:an}),kp("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as Oo,jsxs as Mp}from"react/jsx-runtime";var aG=e=>{switch(e){case"bar":return f("labels.chartType_bar");case"line":return f("labels.chartType_line");case"radar":return f("labels.chartType_radar");default:return e}},sG=e=>{let n=bC(null),[t,o]=xC(null),{theme:r}=xe();EC(()=>{if(!e.spreadsheet){o(null);return}let a=Uf(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){o(null),n.current?.replaceChildren();return}o(a);let s,l=n.current;return(async()=>(s=await Or(a,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),s.querySelector(".style-fonts")?.remove(),l.replaceChildren(),l.appendChild(s)))(),()=>{l.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=aG(e.chartType);return Mp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Oo("div",{className:"ChartPreview__canvas",ref:n}),Oo("div",{className:"ChartPreview__label",children:i})]})},lG=e=>{let n=bC(null),{theme:t}=xe();return EC(()=>{if(!e.rawText)return;let o=yC({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Or([o],{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:t==="dark"},null,{skipInliningFonts:!0});i.querySelector(".style-fonts")?.remove(),r.replaceChildren(),r.appendChild(i)})(),()=>{r.replaceChildren()}},[e.rawText,t]),Mp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Oo("div",{className:"ChartPreview__canvas",ref:n}),Oo("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},wC=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=St(),[i,a]=xC(Math.random()),s=fC.useCallback(()=>{a(Math.random())},[]),l=fC.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),Ue("paste","chart",m),t(),r()},d=m=>{let p=yC({text:m,x:0,y:0});o([p]),Ue("paste","chart","plaintext"),t(),r()};return Oo(wn,{size:"regular",onCloseRequest:l,title:Mp("div",{className:"PasteChartDialog__title",children:[Oo("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),Oo("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:eo})]}),className:"PasteChartDialog",autofocus:!1,children:Mp("div",{className:"container",children:[["bar","line","radar"].map(m=>Ha(e,m)?Oo(sG,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&Oo(lG,{rawText:n,onClick:d})]})})};import{Fragment as cG,jsx as vC,jsxs as dG}from"react/jsx-runtime";var tc=({heading:e,children:n,...t})=>{let{id:o}=Oe(),r=vC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return vC("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):dG(cG,{children:[r,n]})})};import{Popover as nc}from"radix-ui";import IC from"clsx";import Ap,{useLayoutEffect as mG}from"react";import{supportsResizeObserver as pG,isShallowEqual as uG}from"@excalidraw/common";import{Fragment as vE,jsx as It,jsxs as is}from"react/jsx-runtime";var hG=4,gG=8,yE=38,TC=21,fG=({shouldWrap:e,children:n,username:t})=>e?It(ht,{label:t||"Unknown user",children:n}):It(vE,{children:n}),wE=({actionManager:e,collaborator:n,socketId:t,withName:o=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:n,withName:o,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return It(fG,{username:n.username,shouldWrap:r,children:s},t)},EG=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],Dp=Ap.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=at(),a=typeof r=="function"?r(!!n):r,s=Array.from(t,([C,P])=>({...P,socketId:C})).filter(C=>C.username?.trim()),l=s.find(C=>C.isCurrentUser),c=s.filter(C=>!C.isCurrentUser),[d,m]=Ap.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=Ap.useRef(null);mG(()=>{if(u.current){let C=M=>{g(M)};if(C(u.current.clientWidth),!pG)return;let P=new ResizeObserver(M=>{for(let D of M){let{width:_}=D.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=Ap.useState(hG*yE),b=l?E-TC:E,v=Math.max(1,Math.min(8,Math.floor(b/yE))),y=l?Math.max(0,v-1):v,x=c.slice(0,y),I=l?[...x,l]:x,T=I.map(C=>{let P=wE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?is(nc.Root,{children:[It(nc.Trigger,{asChild:!0,children:is("div",{className:"UserList__pill",children:[P,It("div",{className:"UserList__pill-chevron",children:S0})]})}),It(nc.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:is(Xe,{padding:2,children:[s.length>=gG&&It(vd,{placeholder:f("quickSearch.placeholder"),onChange:m}),It(Id,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[It("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(M=>wE({actionManager:i,collaborator:M,socketId:M.socketId,withName:!0,isBeingFollowed:M.socketId===o}))]:[]}),a&&is(vE,{children:[It("div",{className:"UserList__menu-divider"}),It(nc.Close,{asChild:!0,children:It("div",{className:"dropdown-menu",children:a})})]}),It(nc.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]},C.socketId):P});return n?is("div",{className:IC("UserList UserList_mobile",e),children:[It("div",{className:"UserList_mobile__avatars",children:s.map(C=>wE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&is(vE,{children:[It("div",{className:"UserList__menu-divider"}),a]})]}):It("div",{className:"UserList__wrapper",ref:u,children:It("div",{className:IC("UserList",e),style:{"--max-avatars":I.length+(l?TC/yE:0)},children:T})})},(e,n)=>{if(e.collaborators.size!==n.collaborators.size||e.mobile!==n.mobile||e.className!==n.className||e.userToFollow!==n.userToFollow||e.currentUserControls!==n.currentUserControls)return!1;let t=n.collaborators.keys();for(let[o,r]of e.collaborators){let i=n.collaborators.get(o);if(!i||o!==t.next().value||!uG(r,i,EG))return!1}return!0});import oc from"clsx";import{jsx as SC}from"react/jsx-runtime";var CC=e=>SC(ht,{label:`${f("helpDialog.title")} \u2014 ?`,children:SC("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:Wi})});import{jsx as tn,jsxs as IE}from"react/jsx-runtime";var PC=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=it(),l=St();return IE("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&tn("div",{className:oc("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:tn(Ft.Col,{gap:2,children:IE(tc,{heading:"canvasActions",children:[!e.viewModeOnly&&tn(ht,{label:e.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:tn("div",{className:oc("view-mode-button"),children:n.renderAction("viewMode")})}),tn(ht,{label:f("buttons.smartZoom"),children:tn("div",{className:oc("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&tn(NS,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&tn(BS,{renderAction:n.renderAction,className:oc("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),tn(a.Out,{}),(r||o)&&tn("div",{className:oc("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:IE("div",{style:{position:"relative"},children:[o&&tn(s.Out,{}),r&&tn(CC,{onClick:()=>n.executeAction(ei)})]})}),r&&tn(FS,{showExitZenModeBtn:t})]})},kC=PC;PC.displayName="Footer";import{composeEventHandlers as SG}from"@excalidraw/common";import{useLayoutEffect as bG,useRef as xG}from"react";import{jsx as yG}from"react/jsx-runtime";var fi=(e,n)=>{let t=Je(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=it(),[,a]=i(t),s=xG({preferHost:!1,counter:0});return bG(()=>{let l=s.current;return a(c=>{let d=c+1;return l.counter=d,d}),()=>{a(c=>{let d=c-1;return l.counter=d,d||(l.preferHost=!1),d})}},[a]),r.__fallback||(s.current.preferHost=!0),!s.current.counter&&r.__fallback&&s.current.preferHost||s.current.counter>1&&r.__fallback?null:yG(n,{...r})};return o.displayName=e,o};var PE={};NA(PE,{ChangeCanvasBackground:()=>zC,Export:()=>GC,Help:()=>FC,LiveCollaborationTrigger:()=>UC,LoadScene:()=>_C,Preferences:()=>ho,PreferencesToggleGridModeItem:()=>CE,SaveAsImage:()=>NC,SaveToActiveFile:()=>RC,SearchMenu:()=>BC,Socials:()=>HC,ToggleTheme:()=>OC});import TG from"clsx";import{THEME as ic}from"@excalidraw/common";var TE=Je({active:!1});async function MC({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{bt.set(TE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import wG from"clsx";import{jsx as AC,jsxs as vG}from"react/jsx-runtime";var Lp=function({onChange:e,value:n,choices:t,name:o}){return AC("div",{className:"RadioGroup",children:t.map(r=>vG("div",{className:wG("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[AC("input",{name:o,type:"radio",checked:r.value===n,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as IG,jsx as rc,jsxs as DC}from"react/jsx-runtime";var LC=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=Ee();return DC(IG,{children:[DC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&rc("div",{className:"dropdown-menu-item__icon",children:a}),rc("label",{className:"dropdown-menu-item__text",children:rc($s,{children:r})}),rc(Lp,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&rc("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};LC.displayName="DropdownMenuItemContentRadio";var SE=LC;import{Fragment as jC,jsx as ye,jsxs as ac}from"react/jsx-runtime";var _C=()=>{let{t:e}=Ne(),n=at(),t=$i();return n.isActionEnabled(ma)?ye(Jt,{icon:jc,onSelect:async()=>{(!t.length||await MC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:ye(hi,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>ye("strong",{children:r}),br:()=>ye("br",{})})}))&&n.executeAction(ma)},"data-testid":"load-button",shortcut:et("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};_C.displayName="LoadScene";var RC=()=>{let{t:e}=Ne(),n=at();return n.isActionEnabled(Qr)?ye(Jt,{shortcut:et("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(Qr),icon:n1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};RC.displayName="SaveToActiveFile";var NC=()=>{let e=We(),{t:n}=Ne();return ye(Jt,{icon:i1,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:et("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};NC.displayName="SaveAsImage";var BC=e=>{let{t:n}=Ne(),t=at();return ye(Jt,{icon:oo,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Nl)},shortcut:et("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};BC.displayName="SearchMenu";var FC=()=>{let{t:e}=Ne(),n=at();return ye(Jt,{"data-testid":"help-menu-item",icon:Wi,onSelect:()=>n.executeAction(ei),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};FC.displayName="Help";var OC=e=>{let{t:n}=Ne(),t=xe(),o=at(),r=et("toggleTheme"),i=Ln();return o.isActionEnabled(Ud)?e?.allowSystemTheme?ye(SE,{name:"theme",value:e.theme,onChange:a=>{if(i.onThemeChange){i.onThemeChange(a);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:ic.LIGHT,label:Ns,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:ic.DARK,label:Rs,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:E0,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):ye(Jt,{onSelect:a=>{a.preventDefault(),o.executeAction(Ud)},icon:t.theme===ic.DARK?Ns:Rs,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===ic.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===ic.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};OC.displayName="ToggleTheme";var zC=()=>{let{t:e}=Ne(),n=xe(),t=at(),o=Ln();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:ac("div",{style:{marginTop:"0.75rem"},children:[ye("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),ye("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};zC.displayName="ChangeCanvasBackground";var GC=()=>{let{t:e}=Ne(),n=We();return ye(Jt,{icon:Bs,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};GC.displayName="Export";var HC=()=>{let{t:e}=Ne();return ac(jC,{children:[ye(ns,{icon:Qx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),ye(ns,{icon:t1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),ye(ns,{icon:e1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};HC.displayName="Socials";var UC=({onSelect:e,isCollaborating:n})=>{let{t}=Ne();return ye(Jt,{"data-testid":"collab-button",icon:qc,className:TG({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};UC.displayName="LiveCollaborationTrigger";var WC=()=>{let{t:e}=Ne(),n=St(),t=xe();return ye(uo,{checked:t.activeTool.locked,shortcut:et("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},VC=()=>{let{t:e}=Ne(),n=xe(),t=We();return ye(SE,{name:"boxSelectionMode",icon:nd,value:n.boxSelectionMode,onChange:o=>{t({boxSelectionMode:o})},choices:[{value:"contain",label:e("labels.boxSelectionContain"),ariaLabel:e("labels.boxSelectionContain")},{value:"overlap",label:e("labels.boxSelectionOverlap"),ariaLabel:e("labels.boxSelectionOverlap")}],children:e("labels.boxSelectionMode")})},YC=()=>{let{t:e}=Ne(),n=at(),t=xe();return ye(uo,{checked:t.objectsSnapModeEnabled,shortcut:et("objectsSnapMode"),onSelect:o=>{n.executeAction(_t),o.preventDefault()},children:e("buttons.objectsSnapMode")})},KC=()=>{let{t:e}=Ne(),n=at(),t=xe();return ye(uo,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(gl),o.preventDefault()},children:e("labels.arrowBinding")})},XC=()=>{let{t:e}=Ne(),n=at(),t=xe();return ye(uo,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(fl),o.preventDefault()},children:e("labels.midpointSnapping")})},CE=()=>{let{t:e}=Ne(),n=at(),t=xe();return ye(uo,{checked:t.gridModeEnabled,shortcut:et("gridMode"),onSelect:o=>{n.executeAction(ba),o.preventDefault()},children:e("labels.toggleGrid")})},ZC=()=>{let{t:e}=Ne(),n=at(),t=xe();return t.viewModeOnly?null:ye(uo,{checked:t.viewModeEnabled,shortcut:et("viewMode"),onSelect:o=>{n.executeAction(_a),o.preventDefault()},children:e("labels.viewMode")})},$C=()=>{let{t:e}=Ne(),n=at(),t=xe();return ye(uo,{checked:t.stats.open,shortcut:et("stats"),onSelect:o=>{n.executeAction(gr),o.preventDefault()},children:e("stats.fullTitle")})},ho=({children:e,additionalItems:n})=>{let{t}=Ne();return ac(Tr,{children:[ye(Tr.Trigger,{icon:P0,children:t("labels.preferences")}),ac(Tr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||ac(jC,{children:[ye(VC,{}),ye(WC,{}),ye(YC,{}),ye(CE,{}),ye(ZC,{}),ye($C,{}),ye(KC,{}),ye(XC,{})]}),n]})]})};ho.ToggleToolLock=WC;ho.BoxSelectionMode=VC;ho.ToggleSnapMode=YC;ho.ToggleArrowBinding=KC;ho.ToggleMidpointSnapping=XC;ho.ToggleGridMode=CE;ho.ToggleViewMode=ZC;ho.ToggleElementProperties=$C;ho.displayName="Preferences";import{jsx as _p,jsxs as kE}from"react/jsx-runtime";var CG=Object.assign(fi("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=it(),o=Ee(),r=xe(),i=Ln(),a=We();return _p(t.In,{children:kE(ge,{open:r.openMenu==="canvas",children:[_p(ge.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:qx}),kE(ge.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:SG(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&kE("fieldset",{className:"UserList-Wrapper",children:[_p("legend",{children:f("labels.collaborators")}),_p(Dp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:ge.Trigger,Item:ge.Item,ItemLink:ge.ItemLink,ItemCustom:ge.ItemCustom,Group:ge.Group,Separator:ge.Separator,Sub:Tr,DefaultItems:PE}),Ot=CG;import PG from"clsx";import{forwardRef as kG,useState as MG}from"react";import{isPromiseLike as AG}from"@excalidraw/common";import{jsx as Rp,jsxs as DG}from"react/jsx-runtime";var Sr=kG(({children:e,icon:n,onClick:t,label:o,variant:r="filled",color:i="primary",size:a="medium",fullWidth:s,className:l,status:c,disabled:d},m)=>{let[p,u]=MG(!1),E=async b=>{let v=t?.(b);if(AG(v)){let y=window.setTimeout(()=>{u(!0)},50);try{await v}catch(x){if(x instanceof Rc)console.warn(x);else throw x}finally{clearTimeout(y),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,Rp("button",{className:PG("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":s},l),onClick:E,type:"button","aria-label":o,ref:m,disabled:d||g==="loading"||g==="success",children:DG("div",{className:"ExcButton__contents",children:[g==="loading"?Rp(So,{className:"ExcButton__statusIcon"}):g==="success"&&Rp("div",{className:"ExcButton__statusIcon",children:a0}),n&&Rp("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as as,jsxs as RG}from"react/jsx-runtime";var Np=({title:e,children:n,actionLabel:t,onClick:o})=>RG("div",{className:"OverwriteConfirm__Actions__Action",children:[as("h4",{children:e}),as("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),as(Sr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),LG=()=>{let{t:e}=Ne(),n=at(),t=We();return as(Np,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(lm,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},_G=()=>{let{t:e}=Ne(),n=at();return as(Np,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(ul,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},ME=Object.assign(({children:e})=>as("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:LG,SaveToDisk:_G});import{jsx as Cr,jsxs as qC}from"react/jsx-runtime";var Bp=Object.assign(fi("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=it(),[t,o]=Ke(TE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return Cr(n.In,{children:Cr(wn,{onCloseRequest:r,title:!1,size:916,children:qC("div",{className:"OverwriteConfirm",children:[Cr("h3",{children:t.title}),qC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Cr("div",{className:"OverwriteConfirm__Description__icon",children:s0}),Cr("div",{children:t.description}),Cr("div",{className:"OverwriteConfirm__Description__spacer"}),Cr(Sr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Cr(ME,{children:e})]})})})}),{Actions:ME,Action:Np});import{round as HP}from"@excalidraw/math";import JH from"clsx";import QH from"lodash.throttle";import{useEffect as UP,useMemo as WE,useState as eU,memo as tU}from"react";import{STATS_PANELS as Yp}from"@excalidraw/common";import{getCommonBounds as nU}from"@excalidraw/element";import{getUncroppedWidthAndHeight as oU}from"@excalidraw/element";import{isImageElement as VE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as rU}from"@excalidraw/element";import{elementsAreInSameGroup as iU}from"@excalidraw/element";import{degreesToRadians as iP,radiansToDegrees as cP}from"@excalidraw/math";import{getBoundTextElement as aP}from"@excalidraw/element";import{isArrowElement as sP,isElbowArrow as ZG}from"@excalidraw/element";import{updateBindings as lP}from"@excalidraw/element";import UG from"clsx";import{useEffect as oP,useRef as Op,useState as WG}from"react";import{EVENT as cs,KEYS as VG,cloneJSON as AE}from"@excalidraw/common";import{deepCopyElement as YG}from"@excalidraw/element";import{CaptureUpdateAction as rP}from"@excalidraw/element";import{pointFrom as Pr,pointRotateRads as Fp}from"@excalidraw/math";import{getBoundTextElement as NG,getNonDeletedElements as BG,isBindingElement as FG,unbindBindingElement as JC}from"@excalidraw/element";import{isFrameLikeElement as tP}from"@excalidraw/element";import{getSelectedGroupIds as OG,getElementsInGroup as zG,isInGroup as GG}from"@excalidraw/element";import{getFrameChildren as HG}from"@excalidraw/element";import{updateBindings as QC}from"@excalidraw/element";import{DRAGGING_THRESHOLD as eP}from"@excalidraw/common";var nP=.01,sc=10,Kt=(e,n)=>!(n==="angle"&&tP(e)),Ze=(e,n)=>{let t=e+n/2;return t-t%n},ss=(e,n,t)=>Object.keys(e).map(o=>({original:(t??n).get(o),latest:n.get(o)})).filter(o=>o.original!==void 0&&o.latest!==void 0);var Ei=(e,n,t,o,r,i,a=!0)=>{if(FG(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<eP&&Math.abs(n-t.y)<eP)return;JC(t,"start",o),JC(t,"end",o)}let s=o.getNonDeletedElementsMap(),l=s.get(t.id);if(!l)return;let[c,d]=[t.x+t.width/2,t.y+t.height/2],[m,p]=Fp(Pr(t.x,t.y),Pr(c,d),t.angle),u=e-m,E=n-p,[g,b]=Fp(Pr(e,n),Pr(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),QC(l,o,r);let v=NG(t,i);if(v){let y=s.get(v.id);y&&o.mutateElement(y,{x:v.x+u,y:v.y+E},{informMutation:a,isDragging:!1})}if(tP(t)){let y=HG(i,t.id);y.forEach(x=>{let I=s.get(x.id);if(!I)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,M]=Fp(Pr(x.x,x.y),Pr(T,C),x.angle),D=Math.round(P+u),_=Math.round(M+E),[k,L]=Fp(Pr(D,_),Pr(T+u,C+E),-x.angle);o.mutateElement(I,{x:k,y:L},{informMutation:a,isDragging:!1}),QC(I,o,r,{simultaneouslyUpdated:BG(y)})})}},ls=(e,n)=>{let o=OG(n).map(r=>zG(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!GG(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as DE,jsxs as XG}from"react/jsx-runtime";var KG=({label:e,icon:n,dragInputCallback:t,value:o,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:c,sensitivity:d=1,dragFinishedCallback:m})=>{let p=St(),u=We(),E=Op(null),g=Op(null),[b,v]=WG(o.toString()),y=Op(null);y.current||(y.current={originalAppState:AE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),oP(()=>{let T=o.toString();v(T),y.current.lastUpdatedValue=T},[o]);let x=(T,C,P)=>{if(!y.current.updatePending)return!1;y.current.updatePending=!1;let M=Number(T);if(isNaN(M)){v(o.toString());return}let D=Number(M.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(D-_)>=nP)&&(y.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:D,property:s,originalAppState:P,setInputValue:k=>v(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:rP.IMMEDIATELY}))},I=Op({});return I.current.handleInputValue=x,oP(()=>{let T=E.current,C=I.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,y.current.originalElements,y.current.originalAppState),window.removeEventListener(cs.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(cs.POINTER_UP,C.onPointerUp,!1)}},[i]),i?XG("div",{className:UG("drag-input-container",!i&&"disabled"),"data-testid":e,children:[DE("div",{className:"drag-input-label",ref:g,onPointerDown:T=>{if(E.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(E.current.value);isNaN(C)&&(C=0);let P=null,M=p.scene.getNonDeletedElements().reduce((z,U)=>(z.set(U.id,YG(U)),z),new Map),D=r.map(z=>M.get(z.id)),_=AE(c),k=0,L=0,F=z=>{if(P&&M!==null&&D!==null){let U=z.clientX-P.x;U!==0&&(L+=U,Math.abs(L)>=d&&(L=Math.sign(L)*Math.floor(Math.abs(L)/d),k+=L,t({accumulatedChange:k,instantChange:L,originalElements:D,originalElementsMap:M,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:W=>v(String(W)),app:p,setAppState:u}),L=0))}P={x:z.clientX,y:z.clientY}},K=()=>{window.removeEventListener(cs.POINTER_MOVE,F,!1),p.syncActionResult({captureUpdate:rP.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:D,originalAppState:_}),P=null,k=0,L=0,D=null,M=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(cs.POINTER_UP,K,!1)};I.current.onPointerMove=F,I.current.onPointerUp=K,window.addEventListener(cs.POINTER_MOVE,F,!1),window.addEventListener(cs.POINTER_UP,K,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?DE(Pd,{icon:n}):e}),DE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===VG.ENTER&&(x(C.value,r,c),p.focusContainer())}},ref:E,value:b,onChange:T=>{y.current.updatePending=!0,v(T.target.value)},onFocus:T=>{T.target.select(),y.current.originalElements=r,y.current.originalAppState=AE(c)},onBlur:T=>{b?i&&x(T.target.value,y.current.originalElements,y.current.originalAppState):v(o.toString())},disabled:!i})]}):null},ft=KG;import{jsx as JG}from"react/jsx-runtime";var $G=15,jG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!ZG(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=iP(o);r.mutateElement(l,{angle:E}),lP(l,r,i.state);let g=aP(l,a);g&&!sP(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(cP(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=Ze(m,$G)),m=m<0?m+360:m;let p=iP(m);r.mutateElement(l,{angle:p}),lP(l,r,i.state);let u=aP(l,a);u&&!sP(l)&&r.mutateElement(u,{angle:p})}},qG=({element:e,scene:n,appState:t,property:o})=>JG(ft,{label:"A",icon:Qc,value:Math.round(cP(e.angle)%360*100)/100,elements:[e],dragInputCallback:jG,editable:Kt(e,"angle"),scene:n,appState:t,property:o}),dP=qG;import{jsx as eH}from"react/jsx-runtime";var mP=5,QG=({property:e,scene:n,appState:t,setAppState:o})=>eH(ft,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:s})=>{o(l=>{let c;return r?c=r:i&&(c=a?Ze(l.gridStep+mP*Math.sign(i),mP):l.gridStep+i),c?(c=ux(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),pP=QG;import{clamp as zp,round as LE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Gp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as uP,getNonDeletedElements as tH,getUncroppedWidthAndHeight as fP}from"@excalidraw/element";import{resizeSingleElement as hP}from"@excalidraw/element";import{isImageElement as EP}from"@excalidraw/element";import{isFrameLikeElement as _E}from"@excalidraw/element";import{getElementsInResizingFrame as RE}from"@excalidraw/element";import{replaceAllElementsInFrame as bP}from"@excalidraw/element";import{jsx as aH}from"react/jsx-runtime";var gP=10,nH=e=>e.type==="image",oH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:s,instantChange:l,scene:c,app:d,setAppState:m})=>{let p=c.getNonDeletedElementsMap(),u=n[0],E=p.get(u.id);if(u&&E){let g=o||nH(u),b=u.width/u.height;if(s.croppingElementId===u.id){let v=p.get(u.id);if(!v||!EP(v)||!v.crop)return;let y=v.crop,x={...y},I=v.scale[0]===-1,T=v.scale[1]===-1,{width:C,height:P}=fP(v),M=y.naturalWidth/C,D=y.naturalHeight/P,_=I?y.width+y.x:y.naturalWidth-y.x,k=T?y.height+y.y:y.naturalHeight-y.y,L=uP*M,F=uP*D;if(i!==void 0){if(a==="width"){let G=i*M,ie=zp(G,L,_);x={...x,width:ie,x:I?y.x+y.width-ie:y.x}}else if(a==="height"){let G=i*D,ie=zp(G,F,k);x={...x,height:ie,y:T?y.y+y.height-ie:y.y}}c.mutateElement(v,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}let K=a==="width"?l:0,z=a==="height"?l:0,U=zp(y.width+K,L,_),W=zp(y.height+z,L,k);x={...y,x:I?y.x+y.width-U:y.x,y:T?y.y+y.height-W:y.y,width:U,height:W},c.mutateElement(v,{crop:x,width:x.width/(y.naturalWidth/C),height:x.height/(y.naturalHeight/P)});return}if(i!==void 0){let v=Math.max(a==="width"?i:g?i*b:u.width,Gp),y=Math.max(a==="height"?i:g?i/b:u.height,Gp);if(hP(v,y,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),_E(E)){let x=RE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),I=bP(c.getElementsIncludingDeleted(),x,E);c.replaceAllElements(I)}return}{let v=a==="width"?e:0,y=a==="height"?e:0,x=Math.max(0,u.width+v);a==="width"&&(r?x=Ze(x,gP):x=Math.round(x));let I=Math.max(0,u.height+y);if(a==="height"&&(r?I=Ze(I,gP):I=Math.round(I)),g&&(a==="width"?I=Math.round(x/b*100)/100:x=Math.round(I*b*100)/100),I=Math.max(Gp,I),x=Math.max(Gp,x),hP(x,I,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),_E(E)){let T=tH(RE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},rH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&_E(a)){let s=RE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=bP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},iH=({property:e,element:n,scene:t,appState:o})=>{let r=LE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&EP(n)&&n.crop){let{width:i,height:a}=fP(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=LE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=LE(n.crop.height*s,2)}}return aH(ft,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:oH,value:r,editable:Kt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:rH})},NE=iH;import{getBoundTextElement as sH,redrawTextBoundingBox as lH}from"@excalidraw/element";import{hasBoundTextElement as cH,isTextElement as yP}from"@excalidraw/element";import{jsx as uH}from"react/jsx-runtime";var xP=4,dH=4,mH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n[0];if(a){let s=i.get(a.id);if(!s||!yP(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),xP);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,xP),t&&(l=Ze(l,dH))}l&&(r.mutateElement(s,{fontSize:l}),lH(s,r.getContainerElement(s),r))}},pH=({element:e,scene:n,appState:t,property:o})=>{let r=yP(e)?e:cH(e)?sH(e,n.getNonDeletedElementsMap()):null;return r?uH(ft,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:mH,icon:Wr,appState:t,scene:n,property:o}):null},wP=pH;import{degreesToRadians as vP,radiansToDegrees as SP}from"@excalidraw/math";import{getBoundTextElement as IP}from"@excalidraw/element";import{isArrowElement as TP}from"@excalidraw/element";import{isInGroup as BE}from"@excalidraw/element";import{jsx as EH}from"react/jsx-runtime";var hH=15,gH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=n.map(c=>a.get(c.id)).filter(c=>c&&!BE(c)&&Kt(c,r)),l=n.filter(c=>!BE(c)&&Kt(c,r));if(o!==void 0){let c=vP(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=IP(d,a);m&&!TP(d)&&i.mutateElement(m,{angle:c})}i.triggerUpdate();return}for(let c=0;c<s.length;c++){let d=s[c];if(!d)continue;let m=l[c],p=Math.round(SP(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=Ze(E,hH)),E=E<0?E+360:E;let g=vP(E);i.mutateElement(d,{angle:g});let b=IP(d,a);b&&!TP(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},fH=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!BE(l)&&Kt(l,"angle")),i=r.map(l=>Math.round(SP(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Kt(l,"angle"));return EH(ft,{label:"A",icon:Qc,value:a,elements:e,dragInputCallback:gH,editable:s,appState:t,scene:n,property:o})},CP=fH;import{pointFrom as AP}from"@excalidraw/math";import{useMemo as xH}from"react";import{MIN_WIDTH_OR_HEIGHT as kr}from"@excalidraw/common";import{getElementsInResizingFrame as FE,getNonDeletedElements as yH,isFrameLikeElement as OE,replaceAllElementsInFrame as _P,updateBoundElements as wH}from"@excalidraw/element";import{rescalePointsInElement as vH,resizeSingleElement as DP}from"@excalidraw/element";import{getBoundTextElement as IH,handleBindTextResize as TH}from"@excalidraw/element";import{isTextElement as RP}from"@excalidraw/element";import{MIME_TYPES as bi}from"@excalidraw/common";import{getNonDeletedElements as PP}from"@excalidraw/element";var Hp=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=PP(zr(e,null,{deleteInvisibleElements:!0})),l=Ri(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return Gc(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(m,p),b=o<g?o/g:n?.exportScale??1;return u.width=m*b,u.height=p*b,{canvas:u,scale:b}}let E=r?.(m,p)||{width:m,height:p};return u.width=E.width,u.height=E.height,{canvas:u,scale:E.scale??1}})},kP=async e=>{let{mimeType:n=bi.png,quality:t}=e;n===bi.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${bi.png}" mimeType`),n==="image/jpg"&&(n=bi.jpg),n===bi.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${bi.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Hp(e);return t=t||(/image\/jpe?g/.test(n)?.92:.8),new Promise((r,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&n===bi.png&&e.appState?.exportEmbedScene&&(a=await Sx({blob:a,metadata:Ps(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},MP=async({elements:e,appState:n=Zo(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=PP(zr(e,null,{deleteInvisibleElements:!0})),d={...Ri(n,null),exportPadding:o};return Or(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},bH=async e=>{if(e.type==="svg"){let n=await MP(e);await ao(n.outerHTML)}else if(e.type==="png")await am(kP(e));else if(e.type==="json")await om(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as Z8e}from"@excalidraw/element";import{getCommonBounds as Up}from"@excalidraw/element";import{jsx as AH}from"react/jsx-runtime";var ds=10,SH=(e,n,t,o)=>{let r=o.x-e,i=o.y-n,a=o.width*t,s=o.height*t,l=e+r*t,c=n+i*t;return{width:a,height:s,x:l,y:c,...vH(o,a,s,!1),...RP(o)?{fontSize:o.fontSize*t}:{}}},CH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=SH(e,n,o,i);s.mutateElement(r,c);let d=IH(i,a);if(d){let m=d.fontSize*o;wH(r,s);let p=l.get(d.id);p&&RP(p)&&(s.mutateElement(p,{fontSize:m}),TH(r,s,t==="width"?"e":"s",!0))}},LP=(e,n,t,o,r,i,a,s,l,c)=>{i==="width"?n=Math.round(e/o*100)/100:e=Math.round(n*o*100)/100;let d=n/t;for(let m=0;m<s.length;m++){let p=s[m],u=a[m];CH(r[0],r[1],i,d,u,p,l,c)}},PH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:s,setAppState:l,app:c})=>{let d=a.getNonDeletedElementsMap(),m=ls(n,o);if(i!==void 0){for(let g of m){let b=ss(g,d,t);if(b.length>1){let v=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,T,C]=Up(y),P=T-x,M=C-I,D=P/M,_=Math.max(kr,s==="width"?Math.max(0,i):P),k=Math.max(kr,s==="height"?Math.max(0,i):M);LP(_,k,M,D,AP(x,I),s,v,y,t,a)}else{let[v]=b,y=v?.latest,x=v?.original;if(y&&x&&Kt(y,s)){let I=s==="width"?Math.max(0,i):y.width;s==="width"&&(r?I=Ze(I,ds):I=Math.round(I));let T=s==="height"?Math.max(0,i):y.height;if(s==="height"&&(r?T=Ze(T,ds):T=Math.round(T)),I=Math.max(kr,I),T=Math.max(kr,T),DP(I,T,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),OE(y)){let C=FE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()),P=_P(a.getElementsIncludingDeleted(),C,y);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=s==="width"?e:0,u=s==="height"?e:0,E=[];for(let g of m){let b=ss(g,d,t);if(b.length>1){let v=b.map(L=>L.latest),y=b.map(L=>L.original),[x,I,T,C]=Up(y),P=T-x,M=C-I,D=P/M,_=Math.max(0,P+p);s==="width"&&(r?_=Ze(_,ds):_=Math.round(_));let k=Math.max(0,M+u);s==="height"&&(r?k=Ze(k,ds):k=Math.round(k)),_=Math.max(kr,_),k=Math.max(kr,k),LP(_,k,M,D,AP(x,I),s,v,y,t,a)}else{let[v]=b,y=v?.latest,x=v?.original;if(y&&x&&Kt(y,s)){let I=Math.max(0,x.width+p);s==="width"&&(r?I=Ze(I,ds):I=Math.round(I));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=Ze(T,ds):T=Math.round(T)),I=Math.max(kr,I),T=Math.max(kr,T),DP(I,T,y,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),OE(y)){let C=yH(FE(a.getElementsIncludingDeleted(),y,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},kH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&OE(a)){let s=FE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=_P(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},MH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=xH(()=>o.map(c=>{let d=ss(c,t);if(d.length>1){let[p,u,E,g]=Up(d.map(b=>b.latest));return Math.round((e==="width"?E-p:g-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[t,o,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return AH(ft,{label:e==="width"?"W":"H",elements:n,dragInputCallback:PH,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:kH})},zE=MH;import{getBoundTextElement as DH,redrawTextBoundingBox as NP}from"@excalidraw/element";import{hasBoundTextElement as LH,isTextElement as _H}from"@excalidraw/element";import{isInGroup as RH}from"@excalidraw/element";import{jsx as zH}from"react/jsx-runtime";var BP=4,NH=4,BH=(e,n)=>e.reduce((t,o)=>{if(!o||RH(o))return t;if(_H(o))return t.push(o),t;if(LH(o)){let r=DH(o,n);if(r)return t.push(r),t}return t},[]),FH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n.map(l=>i.get(l.id)),s;if(o){s=Math.max(Math.round(o),BP);for(let l of a)r.mutateElement(l,{fontSize:s}),NP(l,r.getContainerElement(l),r);r.triggerUpdate()}else{let l=n;for(let c=0;c<a.length;c++){let d=a[c],m=l[c],p=Math.round(m.fontSize),u=Math.round(e),E=Math.max(p+u,BP);t&&(E=Ze(E,NH)),r.mutateElement(d,{fontSize:E}),NP(d,r.getContainerElement(d),r)}r.triggerUpdate()}},OH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=BH(e,r);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),s=new Set(a).size===1?a[0]:"Mixed",l=a.length>0;return zH(ft,{label:"F",icon:Wr,elements:i,dragInputCallback:FH,value:s,editable:l,scene:n,property:o,appState:t})},FP=OH;import{pointFrom as Mr,pointRotateRads as Wp}from"@excalidraw/math";import{useMemo as GH}from"react";import{isTextElement as HH}from"@excalidraw/element";import{getCommonBounds as GE}from"@excalidraw/element";import{jsx as KH}from"react/jsx-runtime";var UH=(e,n,t,o,r,i,a)=>{for(let s=0;s<o.length;s++){let l=o[s],[c,d]=[l.x+l.width/2,l.y+l.height/2],[m,p]=Wp(Mr(l.x,l.y),Mr(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;Ei(u,E,l,i,a,r,!1)}},WH=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=GE(t),c=e-s,d=n-l;for(let m=0;m<t.length;m++){let p=t[m],u=a.get(p.id);if(u&&(!HH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,v]=Wp(Mr(u.x,u.y),Mr(E,g),u.angle);Ei(b+c,v+d,p,r,i,o,!1)}}},VH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldChangeByStepSize:o,nextValue:r,property:i,scene:a,originalAppState:s,app:l})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of ls(n,s)){let E=ss(u,c,t);if(E.length>1){let[g,b,,]=GE(E.map(x=>x.latest));WH(i==="x"?r:g,i==="y"?r:b,E.map(x=>x.original),t,a,l.state)}else{let g=E[0]?.original,b=E[0]?.latest;if(g&&b&&Kt(b,i)){let[v,y]=[g.x+g.width/2,g.y+g.height/2],[x,I]=Wp(Mr(g.x,g.y),Mr(v,y),g.angle);Ei(i==="x"?r:x,i==="y"?r:I,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?Ze(e,sc):e;UH(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},YH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=GH(()=>o.map(l=>{let c=Object.keys(l).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,b]=GE(c);return Math.round((e==="x"?g:b)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,E]=Wp(Mr(d.x,d.y),Mr(m,p),d.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),s=new Set(a).size===1?a[0]:"Mixed";return KH(ft,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:VH,value:s,property:e,scene:r,appState:i})},HE=YH;import{clamp as lc,pointFrom as Vp,pointRotateRads as zP,round as OP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as XH,getUncroppedWidthAndHeight as ZH}from"@excalidraw/element";import{isImageElement as GP}from"@excalidraw/element";import{jsx as qH}from"react/jsx-runtime";var $H=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:s,originalAppState:l,app:c})=>{let d=s.getNonDeletedElementsMap(),m=t[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[E,g]=zP(Vp(m.x,m.y),Vp(p,u),m.angle);if(l.croppingElementId===m.id){let I=d.get(m.id);if(!I||!GP(I)||!I.crop)return;let T=I.crop,C=T,P=I.scale[0]===-1,M=I.scale[1]===-1,{width:D,height:_}=ZH(I);if(i!==void 0){if(a==="x"){let F=i*(T.naturalWidth/D);P?C={...T,x:lc(T.naturalWidth-F-T.width,0,T.naturalWidth-T.width)}:C={...T,x:lc(i*(T.naturalWidth/D),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:lc(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),s.mutateElement(I,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),L=(a==="y"?n:0)*(M?-1:1);C={...T,x:lc(T.x+k,0,T.naturalWidth-T.width),y:lc(T.y+L,0,T.naturalHeight-T.height)},s.mutateElement(I,{crop:C});return}if(i!==void 0){Ei(a==="x"?i:E,a==="y"?i:g,m,s,c.state,o);return}let b=a==="x"?e:0,v=a==="y"?e:0,y=a==="x"?Math.round(r?Ze(m.x+b,sc):E+b):E,x=a==="y"?Math.round(r?Ze(m.y+v,sc):g+v):g;Ei(y,x,m,s,c.state,o)},jH=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=zP(Vp(n.x,n.y),Vp(n.x+n.width/2,n.y+n.height/2),n.angle),a=OP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&GP(n)&&n.crop){let s=XH(n);s&&(a=OP(e==="x"?s.x:s.y,2))}return qH(ft,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:$H,scene:t,value:a,property:e,appState:o})},UE=jH;import{Fragment as YE,jsx as ne,jsxs as Xt}from"react/jsx-runtime";var aU=50,cc=e=>{let n=ro(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=br(e.app);return ne(sU,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Ve=({children:e,columns:n=1,heading:t,style:o,...r})=>ne("div",{className:JH("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Ve.displayName="StatsRow";var Kp=({children:e,order:n,style:t,...o})=>ne("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Kp.displayName="StatsRows";cc.StatsRow=Ve;cc.StatsRows=Kp;var sU=tU(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),c=s.getNonDeletedElementsMap(),d=We(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&VE(m),E=u?oU(m):null,[g,b]=eU({width:0,height:0}),v=WE(()=>QH(I=>{let T=nU(I);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},aU),[]);UP(()=>{v(l)},[i,l,v]),UP(()=>()=>v.cancel(),[v]);let y=WE(()=>ls(o,r),[o,r]),x=WE(()=>rU(o),[o]);return ne("div",{className:"exc-stats",children:Xt(Xe,{padding:3,children:[Xt("div",{className:"title",children:[ne("h2",{children:f("stats.title")}),ne("div",{className:"close",onClick:n,children:an})]}),Xt(Js,{label:ne("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Yp.generalStats),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Yp.generalStats}})),children:[Xt(Kp,{children:[ne(Ve,{heading:!0,children:f("stats.scene")}),Xt(Ve,{columns:2,children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:l.length})]}),Xt(Ve,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:g.width})]}),Xt(Ve,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:g.height})]}),a&&Xt(YE,{children:[ne(Ve,{heading:!0,children:"Canvas"}),ne(Ve,{children:ne(pP,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&ne("div",{id:"elementStats",style:{marginTop:12},children:ne(Js,{label:ne("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Yp.elementProperties),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Yp.elementProperties}})),children:Xt(Kp,{children:[m&&Xt(YE,{children:[u&&ne(Ve,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&VE(m)&&E&&Xt(Ve,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:HP(E.width,2)})]}),r.croppingElementId&&VE(m)&&E&&Xt(Ve,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:HP(E.height,2)})]}),ne(Ve,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):m.type==="magicframe"?f("element.frame"):f(`element.${m.type}`)}),ne(Ve,{children:ne(UE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),ne(Ve,{children:ne(UE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),ne(Ve,{children:ne(NE,{property:"width",element:m,scene:s,appState:r})}),ne(Ve,{children:ne(NE,{property:"height",element:m,scene:s,appState:r})}),ne(Ve,{children:ne(dP,{property:"angle",element:m,scene:s,appState:r})}),ne(Ve,{children:ne(wP,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Xt(YE,{children:[iU(p)&&ne(Ve,{heading:!0,children:f("element.group")}),Xt(Ve,{columns:2,style:{margin:"0.3125rem 0"},children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:o.length})]}),ne(Ve,{children:ne(HE,{property:"x",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(Ve,{children:ne(HE,{property:"y",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(Ve,{children:ne(zE,{property:"width",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(Ve,{children:ne(zE,{property:"height",elements:p,elementsMap:c,atomicUnits:y,scene:s,appState:r})}),ne(Ve,{children:ne(CP,{property:"angle",elements:p,scene:s,appState:r})}),ne(Ve,{children:ne(FP,{property:"fontSize",elements:p,scene:s,appState:r,elementsMap:c})})]})]})})})]})})},(e,n)=>e.sceneNonce===n.sceneNonce&&e.selectedElements===n.selectedElements&&e.appState.stats.panels===n.appState.stats.panels&&e.gridModeEnabled===n.gridModeEnabled&&e.appState.gridStep===n.appState.gridStep&&e.appState.croppingElementId===n.appState.croppingElementId);import{useCallback as xU,useEffect as VP,useState as YP}from"react";import{normalizeLink as yU,KEYS as $E}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as wU,getLinkIdAndTypeFromSelection as vU}from"@excalidraw/element";import lU from"clsx";import{jsx as Xp,jsxs as dU}from"react/jsx-runtime";var cU=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return dU("button",{className:lU("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Xp("div",{style:a?{visibility:"hidden"}:{},children:o}),Xp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Xp("div",{style:{position:"absolute",inset:0},children:Xp(So,{})})]})},KE=cU;import XE from"clsx";import{forwardRef as hU,useRef as gU,useImperativeHandle as fU,useLayoutEffect as EU,useState as bU}from"react";import mU from"clsx";import{composeEventHandlers as pU}from"@excalidraw/common";import{jsx as uU}from"react/jsx-runtime";var vn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>uU("button",{onClick:pU(i.onClick,a=>{n()}),type:e,className:mU("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as ZE,jsxs as WP}from"react/jsx-runtime";var Zp=hU(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,icon:l,className:c,type:d,...m},p)=>{let u=gU(null);fU(p,()=>u.current),EU(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=bU(!1);return WP("div",{className:XE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&ZE("div",{className:"ExcTextField__label",children:n}),WP("div",{className:XE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[ZE("input",{className:XE({"is-redacted":"value"in m&&m.value&&s&&!E}),readOnly:r,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:o,ref:u,onChange:b=>e?.(b.target.value),onKeyDown:a,type:d}),s&&ZE(vn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?l0:Yr})]})]})});import{jsx as ms,jsxs as $p}from"react/jsx-runtime";var IU=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=wU})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=YP(a),[c,d]=YP(!1);VP(()=>{let p=de(i,t),u=a;if(p.length>0&&r){let E=vU(p,t);E&&(u=yU(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=xU(()=>{if(s&&s!==i.get(e)?.link){let p=i.get(e);p&&o.mutateElement(p,{link:s})}if(!s&&c&&e){let p=i.get(e);p&&o.mutateElement(p,{link:null})}n?.()},[e,s,i,c,o,n]);return VP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===$E.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===$E.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),$p("div",{className:"ElementLinkDialog",children:[$p("div",{className:"ElementLinkDialog__header",children:[ms("h2",{children:f("elementLink.title")}),ms("p",{children:f("elementLink.desc")})]}),$p("div",{className:"ElementLinkDialog__input",children:[ms(Zp,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===$E.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&ms($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Ur})]}),$p("div",{className:"ElementLinkDialog__actions",children:[ms(KE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),ms(KE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},KP=IU;import TU,{useState as SU}from"react";import{Fragment as CU,jsx as jE}from"react/jsx-runtime";var XP=({children:e,onClose:n})=>{let[t,o]=SU(!!e),{container:r}=Oe(),i=TU.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return jE(CU,{children:t&&jE(wn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:jE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import qE from"clsx";import Un from"react";import{MIME_TYPES as ZP,sceneCoordsToViewportCoords as JE}from"@excalidraw/common";import{getCommonBounds as qP,isInitializedImageElement as $P,ShapeCache as PU}from"@excalidraw/element";import{Fragment as _U,jsx as zt,jsxs as xi}from"react/jsx-runtime";var kU=zt("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:zt("path",{d:"M8 5v14l11 -7z"})}),MU=xi("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[zt("path",{d:"M8 5v14"}),zt("path",{d:"M16 5v14"})]}),AU=76,JP=4,dc=AU+JP,jP=8,yi=8,DU=(e,n)=>{let t=n/2;return Math.min(Math.max(e,t+yi),window.innerWidth-t-yi)},LU=(e,n)=>{let[,,t,o]=qP([e]),r=JE({sceneX:t,sceneY:o},n);return{left:Math.min(Math.max(r.x-n.offsetLeft,8),n.width-8),top:Math.min(Math.max(r.y-n.offsetTop,8),n.height-8)}},QP=({app:e,files:n,setAppState:t})=>{let o=ro(),[,r]=Un.useReducer(T=>T+1,0),[i,a]=Un.useState(0),[s,l]=Un.useState(!1),c=Un.useRef(null),d=Un.useRef(null),m=Un.useRef(null),p=Un.useRef(null),u=Un.useRef(null),E=Un.useRef(!1),[g,b]=Un.useState(null);Un.useLayoutEffect(()=>{let T=o.openPopup;if(T!=="gifSpeedPicker"&&T!=="gifFrameGallery"){g!==null&&b(null);return}let C=T==="gifSpeedPicker"?c.current:d.current,P=T==="gifSpeedPicker"?m.current:p.current;if(!C||!P)return;let M=C.getBoundingClientRect(),D=P.getBoundingClientRect(),_=DU(M.left+M.width/2,D.width),k=T==="gifSpeedPicker"?Math.max(yi,M.top-D.height-yi):Math.min(window.innerHeight-D.height-yi,M.bottom+yi),L={left:_,top:Math.max(yi,k)};b(F=>F?.left===L.left&&F.top===L.top?F:L)},[i,g,o.openPopup,o.scrollX,o.scrollY,o.zoom.value]);let v=(T,C)=>{PU.delete(T),e.scene.mutateElement(T,{gifPlayback:C}),e.scheduleUpdate(),t({}),r(),C.playing&&e.ensureGifPlaybackLoop()},y=e.scene.getNonDeletedElements().flatMap(T=>{if(!$P(T)||n[T.fileId]?.mimeType!==ZP.gif||e.imageCache.get(T.fileId)?.gifDecodeStatus!=="deferred")return[];let C=LU(T,o);return[zt("div",{className:"gif-playback-controls gif-playback-controls--deferred",style:C,onPointerDown:P=>P.stopPropagation(),children:zt("button",{type:"button",className:"gif-playback-controls__load-large",title:"Load Large GIF",onClick:()=>{e.loadDeferredGif(T.fileId)},children:"Load Large GIF"})},T.id)]}),x=e.scene.getSelectedElements(o);return xi(_U,{children:[y,(()=>{if(x.length!==1)return null;let T=x[0];if(!$P(T)||n[T.fileId]?.mimeType!==ZP.gif)return null;let C=e.imageCache.get(T.fileId),P=C?.gif,[M,,D,_]=qP([T]),k=JE({sceneX:M,sceneY:_},o),F=JE({sceneX:D,sceneY:_},o).x-k.x,K=k.x-o.offsetLeft+F/2,z=Math.max(12,Math.min(o.height-86,k.y-o.offsetTop+16));if(C?.gifDecodeStatus==="pending")return null;let U=P?.frames.length??0;if(!P||U<2)return null;let W=T.gifPlayback??{frameIndex:0,speed:1,playing:!1},G=e.state,ie=e.getGifPlaybackFrameIndex(T)??W.frameIndex,me=Math.min(Math.max(ie,0),U-1),B=Math.min(G.height-120,z+48),Y=Math.max(12,z-52),pe=Z=>{let ke=(Z+U)%U;e.setGifPlaybackFrameIndex(T,ke),v(T,{...W,frameIndex:ke,playing:!1})},ae=Z=>{Z.stopPropagation(),pe(me+(Z.deltaY<0?1:-1))},be=Z=>{e.setGifPlaybackFrameIndex(T,me),v(T,{...W,frameIndex:me,playing:Z})},ce=[.25,.5,.75,1,1.25,1.5,1.75,2,4],Fe=Z=>{let ke=ce.indexOf(Z);return ke!==-1?ke:ce.reduce((Dt,Ts,_c)=>Math.abs(Ts-Z)<Math.abs(ce[Dt]-Z)?_c:Dt,0)},se=Z=>{v(T,{...W,speed:Z})},Le=Z=>{let ke=Fe(W.speed);se(ce[Math.min(Math.max(ke+Z,0),ce.length-1)])},_e=Number.isInteger(W.speed)?`${W.speed}`:`${W.speed}`,Se=U*dc-JP,Mt=Math.min(Math.max(G.width*.9,1),Se),kn=Math.max(Se-Mt,0),Mn=Math.min(i,kn),Ko=Math.max(Math.floor(Mn/dc)-jP,0),ki=Math.ceil(Mt/dc)+jP*2,Mi=Math.min(Ko+ki,U),vs=P.frames.slice(Ko,Mi),yo=Z=>{Z.pointerType!=="mouse"||Z.button!==0||(u.current={pointerId:Z.pointerId,startClientX:Z.clientX,startScrollLeft:Z.currentTarget.scrollLeft,didDrag:!1},Z.stopPropagation())},At=Z=>{let ke=u.current;if(!ke||ke.pointerId!==Z.pointerId)return;let Dt=Z.clientX-ke.startClientX;!ke.didDrag&&Math.abs(Dt)<=3||(ke.didDrag||(ke.didDrag=!0,Z.currentTarget.setPointerCapture?.(Z.pointerId),l(!0)),Z.currentTarget.scrollLeft=ke.startScrollLeft-Dt,a(Z.currentTarget.scrollLeft),Z.preventDefault(),Z.stopPropagation())},Is=Z=>{let ke=u.current;!ke||ke.pointerId!==Z.pointerId||(E.current=ke.didDrag,u.current=null,Z.currentTarget.hasPointerCapture?.(Z.pointerId)&&Z.currentTarget.releasePointerCapture(Z.pointerId),l(!1),Z.stopPropagation())},Ai=Z=>{let ke=u.current;!ke||ke.pointerId!==Z.pointerId||(u.current=null,l(!1),Z.stopPropagation())},wo=Z=>{Z.pointerType!=="mouse"&&Z.stopPropagation()};return xi("div",{className:"gif-playback-controls",style:{left:K,top:z},onPointerDown:Z=>Z.stopPropagation(),children:[o.openPopup==="gifSpeedPicker"&&zt("div",{className:"gif-speed-picker",ref:m,style:g??{left:K,top:Y},children:ce.map(Z=>{let ke=Number.isInteger(Z)?`${Z}`:`${Z}`;return xi("button",{type:"button",className:qE("gif-speed-picker__speed",{"gif-speed-picker__speed--selected":Z===W.speed}),onClick:()=>se(Z),title:`${ke}x`,children:["x",ke]},Z)})}),xi("div",{className:"gif-playback-controls__bar",children:[xi("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--speed",ref:c,onClick:()=>t({openPopup:o.openPopup==="gifSpeedPicker"?null:"gifSpeedPicker"}),onWheel:Z=>{Z.stopPropagation(),Le(Z.deltaY<0?1:-1)},title:"Speed",children:["x",_e]}),zt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>pe(me-1),onWheel:ae,title:"Previous frame",children:o0}),zt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>be(!W.playing),onWheel:ae,title:W.playing?"Pause":"Play",children:W.playing?MU:kU}),zt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>pe(me+1),onWheel:ae,title:"Next frame",children:r0}),zt("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--frames",ref:d,onClick:()=>{o.openPopup!=="gifFrameGallery"&&a(Math.max(me*dc-Mt/2,0)),t({openPopup:o.openPopup==="gifFrameGallery"?null:"gifFrameGallery"})},onWheel:ae,title:"Frames",children:i0})]}),o.openPopup==="gifFrameGallery"&&zt("div",{className:qE("gif-frame-gallery",{"gif-frame-gallery--dragging":s}),style:{...g??{left:K,top:B},width:Mt},ref:Z=>{p.current=Z,Z&&Z.scrollLeft!==Mn&&(Z.scrollLeft=Mn)},onScroll:Z=>{a(Z.currentTarget.scrollLeft)},onPointerDownCapture:wo,onPointerMoveCapture:wo,onPointerUpCapture:wo,onPointerCancelCapture:wo,onPointerDown:yo,onPointerMove:At,onPointerUp:Is,onPointerCancel:Ai,onLostPointerCapture:Ai,onClickCapture:Z=>{if(E.current){E.current=!1,Z.preventDefault(),Z.stopPropagation();return}E.current=!1},onWheelCapture:Z=>{Z.stopPropagation(),Z.currentTarget.scrollLeft+=Z.deltaY,a(Z.currentTarget.scrollLeft)},children:zt("div",{className:"gif-frame-gallery__spacer",style:{width:Se},children:vs.map((Z,ke)=>{let Dt=Ko+ke;return xi("button",{type:"button",className:qE("gif-frame-gallery__frame",{"gif-frame-gallery__frame--selected":Dt===me}),style:{left:Dt*dc},onClick:()=>pe(Dt),title:`Frame ${Dt+1}`,children:[zt("canvas",{width:Z.width,height:Z.height,ref:Ts=>{Ts?.getContext("2d")?.drawImage(Z,0,0)}}),zt("span",{children:Dt+1})]},Dt)})})})]})})()]})};import ek,{useMemo as HU}from"react";import tk from"clsx";import{isDarwin as nk,isFirefox as UU,isWindows as WU}from"@excalidraw/common";import{KEYS as ps}from"@excalidraw/common";import{SHAPES as VU}from"@excalidraw/element/shapes";import{isFirefox as RU,KEYS as QE}from"@excalidraw/common";import{SHAPES as NU}from"@excalidraw/element/shapes";import{Fragment as GU,jsx as He,jsxs as wi}from"react/jsx-runtime";var BU=e=>wi(GU,{children:[He("h3",{children:e.title}),He("div",{className:"HelpDialog__islands-container",children:e.children})]}),eb=e=>wi("div",{className:`HelpDialog__island ${e.className}`,children:[He("h4",{className:"HelpDialog__island-title",children:e.caption}),He("div",{className:"HelpDialog__island-content",children:e.children})]});function*FU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var OU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),pt=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>He(zU,{children:OU(a)},a)));return wi("div",{className:"HelpDialog__shortcut",children:[He("div",{children:e}),He("div",{className:"HelpDialog__key-container",children:[...FU(o,t?f("helpDialog.or"):null)]})]})},zU=e=>He("kbd",{className:"HelpDialog__key",...e});function tb(){return wi(BU,{title:f("helpDialog.shortcuts"),children:[wi(eb,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[He(pt,{label:f("toolBar.hand"),shortcuts:[QE.H]}),NU.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>He(pt,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),He(pt,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),He(pt,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),wi(eb,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[He(pt,{label:f("helpDialog.smartZoom"),shortcuts:[QE.F]}),He(pt,{label:f("labels.flipViewpointHorizontal"),shortcuts:[N("Shift+R")]}),He(pt,{label:f("labels.flipViewpointVertical"),shortcuts:[N("Alt+Shift+R")]}),He(pt,{label:f("helpDialog.dragToZoom"),shortcuts:[`${QE.Z}+${f("helpDialog.drag")}`]}),He(pt,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),wi(eb,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[He(pt,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),He(pt,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),He(pt,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),He(pt,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(dr||RU)&&He(pt,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),He(pt,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),He(pt,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),He(pt,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),He(pt,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),He(pt,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as rk,jsx as j,jsxs as vi}from"react/jsx-runtime";var YU=e=>vi(rk,{children:[j("h3",{children:e.title}),j("div",{className:"HelpDialog__islands-container",children:e.children})]}),nb=e=>vi("div",{className:`HelpDialog__island ${e.className}`,children:[j("h4",{className:"HelpDialog__island-title",children:e.caption}),j("div",{className:"HelpDialog__island-content",children:e.children})]});function*KU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var XU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),J=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>j(ZU,{children:XU(a)},a)));return vi("div",{className:"HelpDialog__shortcut",children:[j("div",{children:e}),j("div",{className:"HelpDialog__key-container",children:[...KU(o,t?f("helpDialog.or"):null)]})]})},ZU=e=>j("kbd",{className:"HelpDialog__key",...e}),ok=({onClose:e})=>{let[n,t]=ek.useState(!1),o=ek.useCallback(()=>{e&&e()},[e]),r=HU(()=>n?j("button",{className:tk("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):j("button",{className:tk("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return j(rk,{children:j(wn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?vi(YU,{title:f("helpDialog.shortcuts"),children:[vi(nb,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[j(J,{label:f("toolBar.hand"),shortcuts:[ps.H]}),VU.map(({value:i,key:a})=>j(J,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),j(J,{label:f("toolBar.frame"),shortcuts:[ps.F]}),j(J,{label:f("labels.eyeDropper"),shortcuts:[ps.I,"Shift+S","Shift+I"]}),j(J,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),j(J,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),j(J,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),j(J,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),j(J,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(J,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(J,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),j(J,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),j(J,{label:f("toolBar.lock"),shortcuts:[ps.Q]}),j(J,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),j(J,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),j(J,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),vi(nb,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[j(J,{label:f("helpDialog.smartZoom"),shortcuts:[ps.F]}),j(J,{label:f("helpDialog.dragToZoom"),shortcuts:[`${ps.Z}+${f("helpDialog.drag")}`]}),j(J,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),j(J,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),j(J,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),j(J,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),j(J,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),j(J,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),j(J,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),j(J,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),j(J,{label:f("labels.flipViewpointHorizontal"),shortcuts:[N("Shift+R")]}),j(J,{label:f("labels.flipViewpointVertical"),shortcuts:[N("Alt+Shift+R")]}),j(J,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),j(J,{label:f("search.title"),shortcuts:[et("searchMenu")]})]}),vi(nb,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[j(J,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),j(J,{label:f("labels.delete"),shortcuts:[N("Delete")]}),j(J,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),j(J,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),j(J,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),j(J,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),j(J,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),j(J,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),j(J,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),j(J,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(dr||UU)&&j(J,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),j(J,{label:f("labels.sendToBack"),shortcuts:[nk?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),j(J,{label:f("labels.bringToFront"),shortcuts:[nk?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),j(J,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),j(J,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),j(J,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),j(J,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),j(J,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),j(J,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),j(J,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+A")]}),j(J,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),j(J,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),j(J,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),j(J,{label:f("buttons.redo"),shortcuts:WU?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),j(J,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),j(J,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),j(J,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),j(J,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),j(J,{label:f("labels.showStroke"),shortcuts:[N("S")]}),j(J,{label:f("labels.showBackground"),shortcuts:[N("G")]}),j(J,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),j(J,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),j(J,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):j(tb,{})})})};import{CANVAS_SEARCH_TAB as $U,DEFAULT_SIDEBAR as jU}from"@excalidraw/common";import{isArrowElement as qU,isFlowchartNodeElement as JU,isImageElement as ik,isLinearElement as ak,isLineElement as QU,isTextBindableContainer as eW,isTextElement as tW}from"@excalidraw/element";import{isNodeInFlowchart as nW}from"@excalidraw/element";import{jsx as ob}from"react/jsx-runtime";var ve=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,oW=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar?.name===jU.name&&e.openSidebar.tab===$U&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:ve("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(rn(e))return f("hints.eraserRevert",{shortcut:ve("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:ve("Ctrl"),shortcut_2:ve("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:ve("Escape"),shortcut_2:ve("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:ve("A")}):f("hints.linearElement");if(r.type==="freedraw")return f("hints.freeDraw");if(r.type==="text")return f("hints.text");if(r.type==="embeddable")return f("hints.embeddable");if(r.type==="autoshape")return f("hints.autoshape");if(i&&s==="mouse"&&c.length===1){let d=c[0];return ak(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:ve("Shift")}):ik(d)?f("hints.resizeImage",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")}):f("hints.resize",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:ve("Shift")});if(c.length===1&&tW(c[0]))return f("hints.text_selected",{shortcut:ve("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:ve("Escape"),shortcut_2:ve(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:ve("Enter"),shortcut_2:ve("Escape")});if(c.length===1&&ik(c[0]))return f("hints.enterCropEditor",{shortcut_1:ve("double click"),shortcut_2:ve("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:ve("CtrlOrCmd")});if(br(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:ve("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:ve(f("keys.mmb")),shortcut_2:ve("Space")});if(c.length===1){if(ak(c[0]))return qU(c[0])&&e.selectedLinearElement?.elementId===c[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===c[0].points.length-1)?f("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:ve("Delete"),shortcut_2:ve(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")}):QU(c[0])?f("hints.lineEditor_line_info",{shortcut:ve("Enter")}):f("hints.lineEditor_info",{shortcut_1:ve("CtrlOrCmd"),shortcut_2:ve(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&eW(c[0])){let d=f("hints.bindTextToElement",{shortcut:ve("Enter")}),m=f("hints.createFlowchart",{shortcut:ve(["CtrlOrCmd","\u2191\u2193"])});return JU(c[0])?nW(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},jp=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let i=Bi(xa)?pv:e.viewModeEnabled?null:oW({appState:e,isMobile:n,editorInterface:t,app:o});if(!i)return null;let s=(Array.isArray(i)?i.map(l=>l.replace(/\. ?$/,"")).join(", "):i).split(/(<kbd>[^<]+<\/kbd>)/g).map((l,c)=>{if(c%2===1){let d=l[0]==="<"&&l.match(/^<kbd>([^<]+)<\/kbd>$/);return ob("kbd",{children:d?d[1]:l},c)}return l});return ob("div",{className:"HintViewer",children:ob("span",{children:s})})};import{useEffect as lk,useRef as ck,useState as Ii}from"react";import{DEFAULT_EXPORT_PADDING as lW,EXPORT_IMAGE_TYPES as rb,isFirefox as cW,EXPORT_SCALES as dW,cloneJSON as dk}from"@excalidraw/common";import{useCallback as rW,useRef as iW,useState as aW}from"react";var sW=2e3,sk=()=>{let[e,n]=aW(null),t=iW(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},sW)},r=rW(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import{jsx as Ye,jsxs as Ar}from"react/jsx-runtime";var mW=()=>Ar("div",{children:[Ye("h3",{children:f("canvasError.cannotShowPreview")}),Ye("p",{children:Ye("span",{children:f("canvasError.canvasTooBig")})}),Ar("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),pW=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=Re(n,e),[l,c]=Ii(i),[d,m]=Ii(s),[p,u]=Ii(e.exportBackground),[E,g]=Ii(e.exportEmbedScene),[b,v]=Ii(e.exportScale),y=ck(null),x=ck(0),[I,T]=Ii(null),{onCopy:C,copyStatus:P,resetCopyStatus:M}=sk();lk(()=>{M()},[l,p,a,b,E,M]);let{exportedElements:D,exportingFrame:_}=qr(n,e,d);return lk(()=>{let k=y.current;if(!k)return;let L=k.offsetWidth,F=k.offsetHeight;if(!L)return;let K=++x.current,z=()=>K!==x.current;return Hp({elements:D,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:lW,maxWidthOrHeight:Math.max(L,F),exportingFrame:_}).then(async U=>{if(!z()){try{await Ds(U)}catch(W){throw W.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):W}z()||(T(null),k.replaceChildren(U))}}).catch(U=>{z()||(console.error(U),T(U))}),()=>{x.current+=1}},[e,t,D,_,l,p,a,b,E]),Ar("div",{className:"ImageExportModal",children:[Ye("h3",{children:f("imageExportDialog.header")}),Ar("div",{className:"ImageExportModal__preview",children:[Ye("div",{className:"ImageExportModal__preview__canvas",ref:y,children:I&&Ye(mW,{})}),Ye("div",{className:"ImageExportModal__preview__filename",children:!_i&&Ye("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction(dg,"ui",k.target.value)}})})]}),Ar("div",{className:"ImageExportModal__settings",children:[Ye("h3",{children:f("imageExportDialog.header")}),s&&Ye(mc,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ye(ni,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),Ye(mc,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ye(ni,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(mg,"ui",k)}})}),Ye(mc,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ye(ni,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(_w,"ui",k)}})}),Ye(mc,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ye(ni,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(lm,"ui",k)}})}),Ye(mc,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Ye(Lp,{name:"exportScale",value:b,onChange:k=>{v(k),o.executeAction(Dw,"ui",k)},choices:dW.map(k=>({value:k,label:`${k}\xD7`}))})}),Ar("div",{className:"ImageExportModal__settings__buttons",children:[Ye(Sr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(rb.png,D,{exportingFrame:_}),icon:ih,children:f("imageExportDialog.button.exportToPng")}),Ye(Sr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(rb.svg,D,{exportingFrame:_}),icon:ih,children:f("imageExportDialog.button.exportToSvg")}),(dr||cW)&&Ye(Sr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(rb.clipboard,D,{exportingFrame:_}),C()},icon:e0,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},mc=({label:e,children:n,tooltip:t,name:o})=>Ar("div",{className:"ImageExportModal__settings__setting",title:e,children:[Ar("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ye(ht,{label:t,long:!0,children:n0})]}),Ye("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),mk=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=Ii(()=>({appStateSnapshot:dk(n),elementsSnapshot:dk(e)}));return Ye(wn,{onCloseRequest:i,size:"wide",title:!1,children:Ye(pW,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import eV from"clsx";import{CANVAS_SEARCH_TAB as Ak,DEFAULT_SIDEBAR as tV}from"@excalidraw/common";import uW from"clsx";import hW from"lodash.debounce";import{Fragment as gW,memo as fW,useEffect as pc,useMemo as pk,useRef as ib,useState as uk}from"react";import{CLASSES as EW,EVENT as bW,FONT_FAMILY as ab,FRAME_STYLE as sb,getLineHeight as xW}from"@excalidraw/common";import{getCommonBounds as yW,isElementCompletelyInViewport as wW}from"@excalidraw/element";import{measureText as uc}from"@excalidraw/element";import{KEYS as us,randomInteger as hk,addEventListener as vW,getFontString as qp}from"@excalidraw/common";import{newTextElement as IW}from"@excalidraw/element";import{isTextElement as bk,isFrameLikeElement as Jp}from"@excalidraw/element";import{getDefaultFrameName as xk}from"@excalidraw/element/frame";import{Fragment as _W,jsx as Et,jsxs as Wn}from"react/jsx-runtime";var TW=Je(""),lb=Je(null),SW=350,yk=()=>{let e=St(),n=We(),t=ib(null),[o,r]=Ke(TW),i=o.trim(),[a,s]=uk(!1),[l,c]=uk({nonce:null,items:[]}),d=ib(null),m=ib(void 0),[p,u]=Ke(lb),E=e.scene.getNonDeletedElementsMap();pc(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,Ek(i,e,(x,I)=>{c({nonce:hk(),items:x}),d.current=i,m.current=e.scene.getSceneNonce(),n({searchMatches:x.length?{focusedId:null,matches:x.map(T=>({id:T.element.id,focus:!1,matchedLines:T.matchedLines}))}:null})}))},[a,i,E,e,n,u,m]);let g=()=>{l.items.length>0&&u(x=>x===null?0:(x+1)%l.items.length)},b=()=>{l.items.length>0&&u(x=>x===null?0:x-1<0?l.items.length-1:x-1)};pc(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:p!==null&&x.searchMatches?.matches[p]?.id||null,matches:x.searchMatches.matches.map((T,C)=>C===p?{...T,focus:!0}:{...T,focus:!1})}}:null)},[p,n]),pc(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let I=e.state.zoom.value,T=IW({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:Jp(x.element)?sb.nameFontSize:x.element.fontSize,fontFamily:Jp(x.element)?ab.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,M=P*I<C;if(!wW([T],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.viewport.getOffsets())||M){let D=M&&P<C?"contain":"scale-down";e.viewport.setViewport({target:yW([T]),fit:D,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),pc(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let v=Zi({goToNextItem:g,goToPreviousItem:b,searchMatches:l});pc(()=>{let x=I=>{if(I.key===us.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){I.preventDefault(),I.stopPropagation(),n({openSidebar:null});return}if(I[us.CTRL_OR_CMD]&&I.key===us.F){if(I.preventDefault(),I.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}I.target instanceof HTMLElement&&I.target.closest(".layer-ui__search")&&v.searchMatches.items.length&&(I.key===us.ENTER&&(I.stopPropagation(),v.goToNextItem()),I.key===us.ARROW_UP?(I.stopPropagation(),v.goToPreviousItem()):I.key===us.ARROW_DOWN&&(I.stopPropagation(),v.goToNextItem()))};return vW(window,bW.KEYDOWN,x,{capture:!0,passive:!1})},[n,v,e]);let y=`${l.items.length} ${l.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return Wn("div",{className:"layer-ui__search",children:[Wn("div",{className:"layer-ui__search-header",children:[Et(Zp,{className:EW.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:oo,onChange:x=>{r(x),s(!0);let I=x.trim();Ek(I,e,(T,C)=>{c({nonce:hk(),items:T}),u(C),d.current=I,m.current=e.scene.getSceneNonce(),n({searchMatches:T.length?{focusedId:null,matches:T.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),s(!1)})},selectOnRender:!0}),Et(vn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:an})]}),Wn("div",{className:"layer-ui__search-count",children:[l.items.length>0&&Wn(_W,{children:[p!==null&&p>-1?Wn("div",{children:[p+1," / ",y]}):Et("div",{children:y}),Wn("div",{className:"result-nav",children:[Et(vn,{onSelect:()=>{g()},className:"result-nav-btn",children:td}),Et(vn,{onSelect:()=>{b()},className:"result-nav-btn",children:w0})]})]}),l.items.length===0&&i&&d.current&&Et("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),Et(kW,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},gk=e=>{let n=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return Et("div",{tabIndex:-1,className:uW("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Et("div",{className:"preview-text",children:n.flatMap((t,o)=>Et(gW,{children:o===2?Et("b",{children:t}):t},o))})})},CW=e=>{let n=pk(()=>e.matches.items.filter(o=>Jp(o.element)),[e.matches]),t=pk(()=>e.matches.items.filter(o=>bk(o.element)),[e.matches]);return Wn("div",{className:"layer-ui__search-results",children:[n.length>0&&Wn("div",{className:"layer-ui__search-result-container",children:[Wn("div",{className:"layer-ui__search-result-title",children:[Et("div",{className:"title-icon",children:to}),Et("div",{children:f("search.frames")})]}),n.map((o,r)=>Et(gk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&Et("div",{className:"layer-ui__divider"})]}),t.length>0&&Wn("div",{className:"layer-ui__search-result-container",children:[Wn("div",{className:"layer-ui__search-result-title",children:[Et("div",{className:"title-icon",children:Dn}),Et("div",{children:f("search.texts")})]}),t.map((o,r)=>Et(gk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},PW=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,kW=fW(CW,PW),fk=(e,n,t)=>{let i=e.slice(0,n),a=i.split(/\s+/),s=i.endsWith(" "),l=a.length-2-1-(s?0:1),c=a.slice(l<=0?0:l).join(" ")+(s?" ":""),d=20;c=c.length>d?c.slice(-d):c;let m=e.slice(n+t.length),p=m.split(/\s+/),u=!m.startsWith(" "),E=u?6:5,g=(u?"":" ")+p.slice(0,E).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+g,moreBefore:l>0,moreAfter:p.length>E}},MW=(e,n)=>{let t=e.split(`
17
+ `).filter(l=>l.trim().length>0).map(l=>l.split(s).map(c=>c.trim())),t=[" ",",",";"].map(s=>{let l=n(s),c=l[0]?.length??0,d=l.length>0&&l.every(m=>m.length===c);return{delimiter:s,parsed:l,numCols:c,isConsistent:d}}),r=(t.find(s=>s.isConsistent&&s.numCols>1)??t.find(s=>s.isConsistent)??t[0]).parsed;if(r.length===0)return{ok:!1,reason:"No values"};let i=r[0].length;return r.every(s=>s.length===i)?dT(r):{ok:!1,reason:"All rows don't have same number of columns"}};import{pointFrom as Xa}from"@excalidraw/math";import{FONT_FAMILY as $B,FONT_SIZES as jB,getFontString as qB,getLineHeight as JB,ROUGHNESS as mT}from"@excalidraw/common";import{measureText as QB,newLinearElement as Uf,newTextElement as eF}from"@excalidraw/element";var pT=(e,n,t,o)=>{if(!Ha(e,"radar"))return null;let r=e.labels??e.series[0].values.map((z,U)=>`Value ${U+1}`),i=e.series,{normalize:a,renderSteps:s}=rT(i,r.length),l=Va(o),c=Ya(l),d=Wa(i.length,l),{chartWidth:m,chartHeight:p}=oT(),u=n+m/2,E=t-p/2,g=Fa/2,b=r.map((z,U)=>-Math.PI/2+Math.PI*2*U/r.length),{axisLabels:v,axisLabelTopY:w,axisLabelBottomY:x}=iT(r,b,u,E,g,c),I=$B["Lilita One"],T=jB.xl,C=JB(I),P=qB({fontFamily:I,fontSize:T}),M=e.title?jm(e.title,P,m+Oa*2):null,D=M?QB(M,P,C):null,_=M?eF({backgroundColor:c,...Ge,text:M,originalText:e.title??M,x:n+m/2,y:w-Oa-D.height/2,fontFamily:I,fontSize:T,lineHeight:C,textAlign:"center"}):null,k=s?Array.from({length:Lf},(z,U)=>{let W=(U+1)/Lf,G=g*W,ie=b.map(me=>Xa(Math.cos(me)*G,Math.sin(me)*G));return ie.push(Xa(ie[0][0],ie[0][1])),Uf({backgroundColor:"transparent",...Ge,type:"line",x:u,y:E,width:G*2,height:G*2,strokeStyle:"solid",roughness:mT.architect,opacity:ui,polygon:!0,points:ie})}):[],L=b.map(z=>{let U=Math.cos(z)*g,W=Math.sin(z)*g;return Uf({backgroundColor:"transparent",...Ge,type:"line",x:u,y:E,width:Math.abs(U),height:Math.abs(W),strokeStyle:"solid",roughness:mT.architect,opacity:ui,points:[Xa(0,0),Xa(U,W)]})}),F=i.map((z,U)=>{let W=b.map((G,ie)=>{let me=z.values[ie]??0,B=a(me,ie)*g;return Xa(Math.cos(G)*B,Math.sin(G)*B)});return W.push(Xa(W[0][0],W[0][1])),Uf({backgroundColor:"transparent",...Ge,type:"line",x:u,y:E,width:g*2,height:g*2,strokeColor:d[U],strokeWidth:2,polygon:!0,points:W})}),K=Ka(i,d,u,x,t+mo*5,c);return[..._?[_]:[],...v,...k,...L,...F,...K]};var Wf=(e,n,t,o,r)=>e==="line"?cT(n,t,o,r):e==="radar"?pT(n,t,o,r):sT(n,t,o,r);import{isDarwin as uT}from"@excalidraw/common";var hT={toggleTheme:[N("Shift+Alt+D")],saveScene:[N("CtrlOrCmd+S")],loadScene:[N("CtrlOrCmd+O")],imageExport:[N("CtrlOrCmd+Shift+E")],cut:[N("CtrlOrCmd+X")],copy:[N("CtrlOrCmd+C")],paste:[N("CtrlOrCmd+V")],copyStyles:[N("CtrlOrCmd+Alt+C")],pasteStyles:[N("CtrlOrCmd+Alt+V")],selectAll:[N("CtrlOrCmd+A")],deleteSelectedElements:[N("Delete")],duplicateSelection:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)],sendBackward:[N("CtrlOrCmd+[")],bringForward:[N("CtrlOrCmd+]")],sendToBack:[uT?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")],bringToFront:[uT?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")],copyAsPng:[N("Shift+Alt+C")],group:[N("CtrlOrCmd+G")],ungroup:[N("CtrlOrCmd+Shift+G")],gridMode:[N("CtrlOrCmd+'")],objectsSnapMode:[N("Alt+S")],stats:[N("Alt+/")],flipHorizontal:[N("Shift+H")],flipVertical:[N("Shift+V")],flipViewpointHorizontal:[N("Shift+R")],flipViewpointVertical:[N("Alt+Shift+R")],viewMode:[N("Alt+R")],hyperlink:[N("CtrlOrCmd+K")],toggleElementLock:[N("CtrlOrCmd+Shift+L")],resetZoom:[N("CtrlOrCmd+0")],zoomOut:[N("CtrlOrCmd+-")],zoomIn:[N("CtrlOrCmd++")],zoomToFitSelection:[],zoomToFit:[],zoomToFitSelectionInViewport:[],smartZoom:[N("F")],saveFileToDisk:[N("CtrlOrCmd+S")],saveToActiveFile:[N("CtrlOrCmd+S")],toggleShortcuts:[N("?")],searchMenu:[N("CtrlOrCmd+F")],wrapSelectionInFrame:[],arrangeElements:[N("Shift+A")],toolLock:[N("Q")]},Je=(e,n=0)=>{let t=hT[e];return t&&t.length>0?t[n]||t[0]:""},gT=e=>{if(Object.prototype.hasOwnProperty.call(hT,e))return Je(e)||void 0};import{clamp as ep,pointFrom as Za,pointsEqual as sF,bezierEquation as ST,pointRotateRads as tp,pointDistance as lF}from"@excalidraw/math";import{arrayToMap as cF,BIND_MODE_TIMEOUT as Vl,DEFAULT_TRANSFORM_HANDLE_SPACING as CT,FRAME_STYLE as bn,getFeatureFlag as dF,invariant as yT,shouldRotateWithDiscreteAngle as PT,THEME as No}from"@excalidraw/common";import{deconstructDiamondElement as Zf,deconstructRectanguloidElement as kT,elementCenterPoint as $a,getDiamondBaseCorners as mF,FOCUS_POINT_SIZE as pF,getOmitSidesForEditorInterface as Vf,getTransformHandles as uF,getTransformHandlesFromCoords as hF,hasBoundingBox as gF,hitElementItself as fF,isArrowElement as MT,isBindableElement as AT,isElbowArrow as ja,isFrameLikeElement as qa,isImageElement as np,isLinearElement as EF,isLineElement as bF,maxBindingDistance_simple as xF,isTextElement as yF,LinearElementEditor as xn,getActiveTextElement as wF,getElementsInGroup as $f,getSelectedGroupIds as vF,isSelectedViaGroup as IF,selectGroupsFromGivenElements as TF}from"@excalidraw/element";import{renderSelectionElement as SF}from"@excalidraw/element";import{getCommonBounds as jf,getElementAbsoluteCoords as Kl}from"@excalidraw/element";import{getGlobalFixedPointForBindableElement as wT,isFocusPointVisible as CF}from"@excalidraw/element";import{pointFrom as Pt}from"@excalidraw/math";import{THEME as tF}from"@excalidraw/common";var nF="#ff6b6b",oF="#ff0000",fT=1,ET=2,bT=(e,n)=>{if(!n.snapLines.length)return;let t=n.theme===tF.LIGHT||n.zenModeEnabled?nF:oF,o=(n.zenModeEnabled?fT*1.5:fT)/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY);for(let r of n.snapLines)r.type==="pointer"?(e.lineWidth=o,e.strokeStyle=t,iF(r,e,n)):r.type==="gap"?(e.lineWidth=o,e.strokeStyle=t,aF(r.points[0],r.points[1],r.direction,n,e)):r.type==="points"&&(e.lineWidth=o,e.strokeStyle=t,rF(r,e,n));e.restore()},rF=(e,n,t)=>{if(!t.zenModeEnabled){let o=e.points[0],r=e.points[e.points.length-1];En(o,r,n)}for(let o of e.points)xT(o,t,n)},iF=(e,n,t)=>{xT(e.points[0],t,n),t.zenModeEnabled||En(e.points[0],e.points[1],n)},xT=([e,n],t,o)=>{o.save();let r=(t.zenModeEnabled?ET*1.5:ET)/t.zoom.value;o.beginPath(),o.moveTo(e-r,n-r),o.lineTo(e+r,n+r),o.moveTo(e+r,n-r),o.lineTo(e-r,n+r),o.stroke(),o.restore()},En=(e,n,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(n[0],n[1]),t.stroke()},aF=(e,n,t,o,r)=>{let i=8/o.zoom.value,a=i/2,s=i/4;if(t==="horizontal"){let l=[(e[0]+n[0])/2,e[1]];o.zenModeEnabled||En(Pt(e[0],e[1]-i),Pt(e[0],e[1]+i),r),En(Pt(l[0]-s,l[1]-a),Pt(l[0]-s,l[1]+a),r),En(Pt(l[0]+s,l[1]-a),Pt(l[0]+s,l[1]+a),r),o.zenModeEnabled||(En(Pt(n[0],n[1]-i),Pt(n[0],n[1]+i),r),En(e,n,r))}else{let l=[e[0],(e[1]+n[1])/2];o.zenModeEnabled||En(Pt(e[0]-i,e[1]),Pt(e[0]+i,e[1]),r),En(Pt(l[0]-a,l[1]-s),Pt(l[0]+a,l[1]-s),r),En(Pt(l[0]-a,l[1]+s),Pt(l[0]+a,l[1]+s),r),o.zenModeEnabled||(En(Pt(n[0]-i,n[1]),Pt(n[0]+i,n[1]),r),En(e,n,r))}};var PF=(e,n)=>{yT(n.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=n.selectedLinearElement;yT(t,"midPointCoords is null"),op(t,e,n)},kF=(e,n,t)=>{let{elementId:o,hoverPointIndex:r}=n.selectedLinearElement;if(n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(r)||n.selectedLinearElement?.isDragging)return;let i=xn.getElement(o,t);if(!i)return;let a=xn.getPointAtIndexGlobalCoordinates(i,r,t);op(a,e,n)},op=(e,n,t)=>{n.save(),n.translate(t.scrollX,t.scrollY),n.fillStyle="rgba(105, 101, 219, 0.4)",ks(n,e[0],e[1],xn.POINT_HANDLE_SIZE/t.zoom.value,!1),n.restore()},MF=(e,n,t)=>{let{elementId:o,anchor:r}=n.hoveredArrowTextAnchor,i=t.get(o);if(!i||!MT(i)||i.isDeleted)return;let a=r==="label"?xn.getBoundTextElementCenter(i,t):xn.getPointAtIndexGlobalCoordinates(i,r==="start"?0:-1,t);op(a,e,n)},Yf=(e,n,t,o,r,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",r?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),ks(e,t[0],t[1],(a?o*(n.selectedLinearElement?.isEditing?1.5:2):o)/n.zoom.value,!i,!a||r)},AF=(e,n,t,o,r,i=!1)=>{let a=n.element.frameId&&t.get(n.element.frameId);switch(a&&qa(a)&&(e.translate(a.x,a.y),e.beginPath(),bn.radius&&e.roundRect?e.roundRect(-1,-1,a.width+1,a.height+1,bn.radius/o.zoom.value):e.rect(-1,-1,a.width+1,a.height+1),e.clip(),e.translate(-a.x,-a.y)),n.element.type){case"magicframe":case"frame":e.save(),e.translate(n.element.x,n.element.y),e.lineWidth=bn.strokeWidth/o.zoom.value,e.strokeStyle=o.theme===No.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",bn.radius&&e.roundRect?(e.beginPath(),e.roundRect(0,0,n.element.width,n.element.height,bn.radius/o.zoom.value),e.stroke(),e.closePath()):e.strokeRect(0,0,n.element.width,n.element.height),e.restore();break;default:e.save();let s=$a(n.element,t);switch(e.translate(s[0],s[1]),e.rotate(n.element.angle),e.translate(-s[0],-s[1]),e.translate(n.element.x,n.element.y),e.lineWidth=ep(1.75,n.element.strokeWidth,4)/Math.max(.25,o.zoom.value),e.strokeStyle=o.theme===No.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",n.element.type){case"ellipse":e.beginPath(),e.ellipse(n.element.width/2,n.element.height/2,n.element.width/2,n.element.height/2,0,0,2*Math.PI),e.closePath(),e.stroke();break;case"diamond":{let[l,c]=Zf(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break;default:{let[l,c]=kT(n.element);l.forEach(d=>{e.beginPath(),e.moveTo(d[0][0]-n.element.x,d[0][1]-n.element.y),e.lineTo(d[1][0]-n.element.x,d[1][1]-n.element.y),e.stroke()}),c.forEach(d=>{let[m,p,u,E]=d;e.beginPath(),e.moveTo(m[0]-n.element.x,m[1]-n.element.y),e.bezierCurveTo(p[0]-n.element.x,p[1]-n.element.y,u[0]-n.element.x,u[1]-n.element.y,E[0]-n.element.x,E[1]-n.element.y),e.stroke()})}break}e.restore();break}if(o.isMidpointSnappingEnabled&&!o.gridModeEnabled&&!i&&(qa(n.element)||AT(n.element))){let s=o.selectedLinearElement,l=s?.elementId&&xn.getElement(s?.elementId,t),c=r&&fF({point:r,element:n.element,elementsMap:t,threshold:0,overrideShouldTestInside:!0}),d=l&&ja(l)||o.activeTool.type==="arrow"&&o.currentItemArrowType==="elbow";if(!c||d){e.save();let m=$a(n.element,t),p;if(n.element.type==="diamond"){let b=$a(n.element,t);p=mF(n.element).map(v=>{let w=ST(v,.5),x=tp(w,b,n.element.angle);return Za(x[0],x[1])})}else p=[{x:n.element.width,y:n.element.height/2},{x:n.element.width/2,y:n.element.height},{x:0,y:n.element.height/2},{x:n.element.width/2,y:0}].map(v=>{let w=Za(v.x+n.element.x,v.y+n.element.y),x=tp(w,m,n.element.angle);return Za(x[0],x[1])});let u=r&&p.reduce((b,v,w)=>{let x=lF(v,r);return w===-1||x<b.distance?{idx:w,distance:x}:b},{idx:-1,distance:1/0}),E=4/o.zoom.value,g=xF(o.zoom)+n.element.strokeWidth/2;p.forEach((b,v)=>{let w=(!c||d)&&u?.idx===v&&u.distance<=g,x=!w&&(d||v===u?.idx&&u.distance<=g*2);w?(e.fillStyle=o.theme===No.DARK?"rgba(3, 93, 161, 1)":"rgba(106, 189, 252, 1)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill()):x&&(e.fillStyle=o.theme===No.DARK?"rgba(0, 0, 0, 0.8)":"rgba(65, 65, 65, 0.5)",e.beginPath(),e.arc(b[0],b[1],E,0,2*Math.PI),e.fill())}),e.restore()}}},DF=(e,n,t,o,r,i,a)=>{let s=e.state.bindMode==="orbit"&&e.bindModeHandler!==null,l=Vl-(a?.runtime??(s?0:Vl)),c=ep(1/Vl*l,1e-4,1),d=t.strokeWidth/2,m=t.frameId&&o.get(t.frameId);switch(m&&qa(m)&&(n.translate(m.x,m.y),n.beginPath(),bn.radius&&n.roundRect?n.roundRect(-1,-1,m.width+1,m.height+1,bn.radius/r.zoom.value):n.rect(-1,-1,m.width+1,m.height+1),n.clip(),n.translate(-m.x,-m.y)),t.type){case"magicframe":case"frame":n.save(),n.translate(t.x,t.y),n.lineWidth=bn.strokeWidth/r.zoom.value,n.strokeStyle=r.theme===No.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,bn.radius&&n.roundRect?(n.beginPath(),n.roundRect(0,0,t.width,t.height,bn.radius/r.zoom.value),n.stroke(),n.closePath()):n.strokeRect(0,0,t.width,t.height),n.restore();break;default:n.save();let u=$a(t,o),E=u[0]+r.scrollX,g=u[1]+r.scrollY;switch(n.translate(E,g),n.rotate(t.angle),n.translate(-E,-g),n.translate(t.x+r.scrollX-d,t.y+r.scrollY-d),n.lineWidth=ep(2.5,t.strokeWidth*1.75,4)/Math.max(.25,r.zoom.value),n.strokeStyle=r.theme===No.DARK?`rgba(3, 93, 161, ${c/2})`:`rgba(106, 189, 252, ${c/2})`,t.type){case"ellipse":n.beginPath(),n.ellipse((t.width+d*2)/2,(t.height+d*2)/2,(t.width+d*2)/2,(t.height+d*2)/2,0,0,2*Math.PI),n.closePath(),n.stroke();break;case"diamond":{let[b,v]=Zf(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),v.forEach(w=>{let[x,I,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break;default:{let[b,v]=kT(t,d);b.forEach(w=>{n.beginPath(),n.moveTo(w[0][0]-t.x+d,w[0][1]-t.y+d),n.lineTo(w[1][0]-t.x+d,w[1][1]-t.y+d),n.stroke()}),v.forEach(w=>{let[x,I,T,C]=w;n.beginPath(),n.moveTo(x[0]-t.x+d,x[1]-t.y+d),n.bezierCurveTo(I[0]-t.x+d,I[1]-t.y+d,T[0]-t.x+d,T[1]-t.y+d,C[0]-t.x+d,C[1]-t.y+d),n.stroke()})}break}n.restore();break}if(!s||(a?.runtime??0)>Vl)return;let p=.5*(Math.min(t.width,t.height)/2);if(!qa(t)){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let u=1/Vl*l;if(n.strokeStyle="rgba(0, 0, 0, 0.2)",n.lineWidth=1/r.zoom.value,n.setLineDash([4/r.zoom.value,4/r.zoom.value]),n.lineDashOffset=-u*10/r.zoom.value,n.beginPath(),n.ellipse(t.width/2,t.height/2,p,p,0,0,2*Math.PI),n.stroke(),n.fillStyle="rgba(0, 0, 0, 0.04)",n.beginPath(),n.ellipse(t.width/2,t.height/2,p*(1-c),p*(1-c),0,0,2*Math.PI),n.fill(),n.restore(),r.isMidpointSnappingEnabled&&!r.gridModeEnabled&&(!e.lastPointerMoveEvent||!PT(e.lastPointerMoveEvent))){n.save(),n.translate(t.x+r.scrollX,t.y+r.scrollY);let E=5/r.zoom.value,g=5/r.zoom.value,b=E+g,v;if(t.type==="diamond"){let[,w]=Zf(t),x=$a(t,o);v=w.map(I=>{let T=ST(I,.5),C=tp(T,x,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}else{let w=$a(t,o);v=[{x:t.width/2,y:0},{x:t.width,y:t.height/2},{x:t.width/2,y:t.height},{x:0,y:t.height/2}].map(I=>{let T=Za(I.x+t.x,I.y+t.y),C=tp(T,w,t.angle);return{x:C[0]-t.x,y:C[1]-t.y}})}v.forEach(w=>{n.clearRect(w.x-b,w.y-b,b*2,b*2)}),n.fillStyle=r.theme===No.DARK?`rgba(3, 93, 161, ${c})`:`rgba(106, 189, 252, ${c})`,v.forEach(w=>{n.beginPath(),n.arc(w.x,w.y,E,0,2*Math.PI),n.fill()}),n.restore()}}return{runtime:(a?.runtime??0)+i}},LF=(e,n,t,o,r,i,a)=>{if(t===null)return;if(dF("COMPLEX_BINDINGS"))return DF(e,n,t.element,o,r,i,a);n.save(),n.translate(r.scrollX,r.scrollY);let s=e.lastPointerMoveCoords?Za(e.lastPointerMoveCoords.x,e.lastPointerMoveCoords.y):null,l=!!e.lastPointerMoveEvent&&PT(e.lastPointerMoveEvent);AF(n,t,o,r,s,l),n.restore()},DT=(e,n,t)=>{let{angle:o,x1:r,y1:i,x2:a,y2:s,selectionColors:l,cx:c,cy:d,dashed:m,activeEmbeddable:p}=t,u=a-r,E=s-i,b=(t.padding??CT*2)/n.zoom.value,v=8/n.zoom.value,w=4/n.zoom.value;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=(p?4:1)/n.zoom.value;let x=l.length;for(let I=0;I<x;++I)e.strokeStyle=l[I],m&&e.setLineDash([v,w+(v+w)*(x-1)]),e.lineDashOffset=(v+w)*I,Ms(e,r-b,i-b,u+b*2,E+b*2,c,d,o);e.restore()},_F=(e,n,t,o)=>{let[r,i,a,s]=Kl(t,o),l=a-r,c=s-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=bn.strokeWidth/n.zoom.value,e.save(),e.translate(n.scrollX,n.scrollY),Ms(e,r,i,l,c,r+l/2,i+c/2,t.angle,!1,bn.radius/n.zoom.value),e.restore()},vT=(e,n,t,o)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=o||{},a=t.filter(d=>d.groupIds.length===0),s=t.filter(d=>d.groupIds.length>0),l=d=>{let[m,p,u,E]=jf(d);return{angle:0,x1:m,x2:u,y1:p,y2:E,selectionColors:r,dashed:i,cx:m+(u-m)/2,cy:p+(E-p)/2,activeEmbeddable:!1}},c=d=>{let m=$f(t,d);return l(m)};Object.entries(TF(s,n)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>l([d]))).forEach(d=>DT(e,n,d))},Kf=(e,n,t,o)=>{if(!n.selectedLinearElement)return;e.save(),e.translate(n.scrollX,n.scrollY),e.lineWidth=1/n.zoom.value;let r=xn.getPointsGlobalCoordinates(t,o),{POINT_HANDLE_SIZE:i}=xn,a=n.selectedLinearElement?.isEditing?i:i/2,s=ja(t),l=bF(t);if(r.forEach((c,d)=>{if(s&&d!==0&&d!==r.length-1)return;let m=d>0&&(d!==r.length-1||!l||!t.polygon)&&sF(c,d===r.length-1?r[0]:r[d-1],2/n.zoom.value),p=!!n.selectedLinearElement?.isEditing&&!!n.selectedLinearElement?.selectedPointsIndices?.includes(d);l&&t.polygon&&!p&&d===t.points.length-1&&n.selectedLinearElement?.isEditing&&n.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Yf(e,n,c,a,p,!1,m)}),ja(t)){let c=t.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{xn.isSegmentTooShort(t,r[m+1],r[m],m,n.zoom,o)||Yf(e,n,Za((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else xn.getEditorMidPoints(t,o,n).filter((d,m,p)=>d!==null&&!(ja(t)&&(m===0||m===p.length-1))).forEach(d=>{(n.selectedLinearElement?.isEditing||r.length===2)&&Yf(e,n,d,i/2,!1,!0,!1)});e.restore()},RF=(e,n,t,o)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([4/n.zoom.value,4/n.zoom.value]),e.beginPath(),e.moveTo(t[0],t[1]),e.lineTo(o[0],o[1]),e.stroke(),e.restore()},NF=(e,n,t,o,r)=>{e.save(),e.translate(n.scrollX,n.scrollY),e.strokeStyle="rgba(134, 131, 226, 0.6)",e.lineWidth=1/n.zoom.value,e.setLineDash([]),e.fillStyle=r?"rgba(134, 131, 226, 0.9)":"rgba(255, 255, 255, 0.9)",ks(e,t[0],t[1],o/n.zoom.value,!0,!0),e.restore()},IT=({arrow:e,appState:n,type:t,context:o,elementsMap:r})=>{let i=t==="start"?e.startBinding:e.endBinding,a=i?.elementId&&r.get(i.elementId);if(!a||!AT(a)||a.isDeleted)return;let s=wT(i.fixedPoint,a,r);if(!CF(s,e,a,r,n,t))return;let l=n.selectedLinearElement,c=!!l?.isDragging,d=t==="start"?0:e.points.length-1,m=!!l?.selectedPointsIndices?.includes(d);if(l?.hoveredFocusPointBinding===t&&!l.draggedFocusPointBinding&&op(s,o,n),!(m&&c)){let p=wT(i.fixedPoint,a,r),u=l?.hoveredFocusPointBinding===t,E=xn.getPointAtIndexGlobalCoordinates(e,d,r);RF(o,n,E,p),NF(o,n,p,pF/1.5,u)}},TT=(e,n,t,o,r)=>{Object.keys(o).forEach(i=>{let a=o[i];if(a!==void 0){let[s,l,c,d]=a;e.save(),e.lineWidth=1/t.zoom.value,n.selectionColor&&(e.strokeStyle=n.selectionColor),i==="rotation"?ks(e,s+c/2,l+d/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(s,l,c,d,2/t.zoom.value),e.fill(),e.stroke()):Ms(e,s,l,c,d,s+c/2,l+d/2,r,!0),e.restore()}})},BF=(e,n,t,o,r)=>{let[i,a,,,s,l]=Kl(o,r),c=3,d=20,m=c/t.zoom.value,p=m/2,u=s-i+m,E=l-a+m,g=Math.min(d/t.zoom.value,u),b=Math.min(d/t.zoom.value,E);e.save(),e.fillStyle=n.selectionColor,e.strokeStyle=n.selectionColor,e.lineWidth=m,[[[-u,-E],[0,p],[g,p],[p,0],[p,b]],[[u-p,-E],[p,p],[-g+p,p],[0,0],[0,b]],[[-u,E],[0,-p],[g,-p],[p,0],[p,-b]],[[u-p,E],[p,-p],[-g+p,-p],[0,0],[0,-b]]].forEach(w=>{let[[x,I],[T,C],[P,M],[D,_],[k,L]]=w;e.save(),e.translate(s,l),e.rotate(o.angle),e.beginPath(),e.moveTo(x+T,I+C),e.lineTo(x+P,I+M),e.stroke(),e.beginPath(),e.moveTo(x+D,I+_),e.lineTo(x+k,I+L),e.stroke(),e.restore()}),e.restore()},FF=(e,n,t,o)=>{n.save();let r=If(t.zoom.value),i=e.width+r*2,a=e.height+r*2,s=e.x+e.width/2,l=e.y+e.height/2,c=-(e.width/2+r),d=-(e.height/2+r);n.translate(s+t.scrollX,l+t.scrollY),n.rotate(e.angle),n.lineWidth=1/t.zoom.value,n.strokeStyle=o,n.globalAlpha=.5,n.setLineDash([6/t.zoom.value,4/t.zoom.value]),n.strokeRect(c,d,i,a),n.restore()},OF=(e,n,t,o,r)=>{let i=Tf(e,t.zoom.value,r);i&&(n.save(),n.globalAlpha=.5,n.lineWidth=1.5/t.zoom.value,n.lineCap="round",n.strokeStyle=o,n.beginPath(),n.moveTo(i.start[0]+t.scrollX,i.start[1]+t.scrollY),n.lineTo(i.end[0]+t.scrollX,i.end[1]+t.scrollY),n.stroke(),n.restore())},zF=(e,n,t,o,r,i)=>{for(let a of n){if(!np(a)||!a.fileId)continue;let s=o.imageStatus.get(a.fileId);if(!!s?.downloadError){let d=Yl(a,t,r,"center");d&&_T(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,r,s?.downloadError??void 0)}else{let d=o.imageLoadingProgress.get(a.fileId);if(d!==void 0){let m=Yl(a,t,r,"center");m&&LT(e,m.centerX+r.scrollX,m.centerY+r.scrollY,m.radius,m.lineWidth,d,r,i)}}let c=s?.uploadProgress;if(c){let d=Yl(a,t,r,"top-right");d&&HF(e,d.centerX+r.scrollX,d.centerY+r.scrollY,d.radius,d.lineWidth,c,r,i)}}},Yl=(e,n,t,o)=>{if(!np(e))return null;let[r,i,a,s]=Kl(e,n),l=t.zoom.value,c=Math.min(a-r,s-i)*l,d=Math.min(o==="center"?14:11.7,c/(o==="center"?4:4.62))/l,m=Math.min((o==="center"?3:2.6)/l,d/2);if(d<=0||m<=0)return null;if(o==="top-right"){let p=6/l;return{centerX:a-p-d,centerY:i+p+d,radius:d,lineWidth:m}}return{centerX:(r+a)/2,centerY:(i+s)/2,radius:d,lineWidth:m}},LT=(e,n,t,o,r,i,a,s,l)=>{e.save(),e.lineWidth=r,e.lineCap="round",e.strokeStyle=l?.trackColor??(a.theme===No.DARK?"rgba(255, 255, 255, 0.35)":"rgba(0, 0, 0, 0.25)"),e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),i>0&&(e.strokeStyle=l?.color??s,e.beginPath(),e.arc(n,t,o,-Math.PI/2,-Math.PI/2+Math.PI*2*ep(i,0,1)),e.stroke()),e.restore()},Xf=(e,n)=>typeof window>"u"?n:window.getComputedStyle(document.documentElement).getPropertyValue(e).trim()||n,GF=(e,n,t,o,r)=>{e.save(),e.strokeStyle=r.color,e.lineWidth=r.lineWidth,e.lineCap="round",e.lineJoin="round",e.beginPath(),e.moveTo(n-o*.48,t+o*.26),e.bezierCurveTo(n-o*.68,t+o*.14,n-o*.58,t-o*.22,n-o*.34,t-o*.22),e.bezierCurveTo(n-o*.14,t-o*.48,n+o*.26,t-o*.48,n+o*.34,t-o*.18),e.bezierCurveTo(n+o*.58,t-o*.2,n+o*.7,t+o*.26,n+o*.42,t+o*.26),e.lineTo(n-o*.48,t+o*.26),e.stroke(),e.restore()},HF=(e,n,t,o,r,i,a,s)=>{let l=i.state??"uploading",c=i.color??Xf("--color-primary",s),d=i.color??Xf("--color-warning-darkest","#ec8b14");if(l==="failed"){_T(e,n,t,o,a,{color:i.color??Xf("--color-danger","#e03131")});return}if(l==="uploading"&&LT(e,n,t,o,r,i.progress??0,a,s,{color:c,trackColor:i.trackColor}),GF(e,n,t-o*.02,o*1.125,{color:l==="error"?d:c,lineWidth:Math.max(r*.75,1/a.zoom.value)}),l==="error"){e.save(),e.strokeStyle=d,e.fillStyle=d,e.lineWidth=Math.max(r*.75,1/a.zoom.value),e.lineCap="round",e.beginPath();let m=o*.18,p=t-o*.09;e.moveTo(n-m,p-m),e.lineTo(n+m,p+m),e.moveTo(n+m,p-m),e.lineTo(n-m,p+m),e.stroke(),e.restore()}else l==="pending"&&(e.save(),e.strokeStyle=c,e.lineWidth=Math.max(r*.65,1/a.zoom.value),e.lineCap="round",e.beginPath(),e.moveTo(n,t+o*.072),e.lineTo(n,t-o*.18),e.moveTo(n-o*.144,t-o*.036),e.lineTo(n,t-o*.18),e.lineTo(n+o*.144,t-o*.036),e.stroke(),e.restore())},_T=(e,n,t,o,r,i)=>{e.save();let a=i?.color??"#e03131",s=Math.max(o*.16,1.5/r.zoom.value);i?.backgroundColor&&(e.fillStyle=i.backgroundColor,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.fill()),e.strokeStyle=a,e.lineWidth=s,e.beginPath(),e.arc(n,t,o,0,Math.PI*2),e.stroke(),e.strokeStyle=a,e.fillStyle=a,e.lineCap="round",e.beginPath(),e.moveTo(n,t-o*.45),e.lineTo(n,t+o*.12),e.stroke(),e.beginPath(),e.arc(n,t+o*.48,o*.11,0,Math.PI*2),e.fill(),i?.text&&(e.font=`600 ${Math.max(11/r.zoom.value,o*.65)}px Assistant, system-ui, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif`,e.textAlign="center",e.textBaseline="top",e.fillText(i.text,n,t+o+6/r.zoom.value)),e.restore()},UF=({app:e,canvas:n,elementsMap:t,visibleElements:o,selectedElements:r,allElementsMap:i,scale:a,appState:s,renderConfig:l,editorInterface:c,animationState:d,deltaTime:m})=>{if(n===null)return{};let[p,u]=Fc(n,a),E=d,g=Oc({canvas:n,scale:a,normalizedWidth:p,normalizedHeight:u});g.save(),zc(g,s);let b;if(o.forEach(C=>{s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===C.id&&C&&(b=C)}),b&&Kf(g,s,b,t),s.selectionElement&&!s.isCropping)try{SF(s.selectionElement,g,s,l.selectionColor)}catch(C){console.error(C)}let v=wF(r,s);if(v&&!v.autoResize&&OF(v,g,s,l.selectionColor,c.formFactor),s.editingTextElement){let C=i.get(s.editingTextElement.id);C&&!C.autoResize&&FF(C,g,s,l.selectionColor)}if(s.isBindingEnabled&&s.suggestedBinding?E={...d,bindingHighlight:LF(e,g,s.suggestedBinding,i,s,m,d?.bindingHighlight)}:E={...d,bindingHighlight:void 0},s.hoveredArrowTextAnchor&&MF(g,s,i),s.frameToHighlight&&_F(g,s,s.frameToHighlight,t),s.elementsToHighlight&&vT(g,s,s.elementsToHighlight),s.activeLockedId){let C=i.get(s.activeLockedId),P=C?[C]:$f(i,s.activeLockedId);vT(g,s,P,{colors:["#ced4da"],dashed:!0})}let w=r.some(C=>qa(C));r.length===1&&s.selectedLinearElement?.isEditing&&s.selectedLinearElement.elementId===r[0].id&&Kf(g,s,r[0],t);let x=s.selectedLinearElement,I=x&&xn.getElement(x.elementId,i);if(I&&(s.selectedLinearElement.isDragging||(x.segmentMidPointHoveredCoords?PF(g,s):(ja(I)?x.hoverPointIndex===0||x.hoverPointIndex===I.points.length-1:x.hoverPointIndex>=0)&&kF(g,s,t)),MT(I)&&(IT({arrow:I,elementsMap:i,appState:s,context:g,type:"start"}),IT({arrow:I,elementsMap:i,appState:s,context:g,type:"end"}))),!s.multiElement&&!s.newElement&&!s.selectedLinearElement?.isEditing){let C=gF(r,s,c),P=r.length===1&&EF(r[0]);P&&s.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Kf(g,s,r[0],t);let M=l.selectionColor||"#000";if(C){let D=cF(r),_=[];for(let L of t.values()){let F=[],K=l.remoteSelectedElementIds.get(L.id);if(P&&ja(L)&&(L.startBinding||L.endBinding)||(D.has(L.id)&&!IF(s,L)&&F.push(M),K&&F.push(...K.map(z=>oi(z,s.collaborators.get(z))))),F.length){let[z,U,W,G,ie,me]=Kl(L,t,!0);_.push({angle:L.angle,x1:z,y1:U,x2:W,y2:G,selectionColors:L.locked?["#ced4da"]:F,dashed:!!K||L.locked,cx:ie,cy:me,activeEmbeddable:s.activeEmbeddable?.element===L&&s.activeEmbeddable.state==="active",padding:L.id===s.croppingElementId||np(L)?0:void 0})}}let k=L=>{let F=$f(t,L),[K,z,U,W]=jf(F);_.push({angle:0,x1:K,x2:U,y1:z,y2:W,selectionColors:F.some(G=>G.locked)?["#ced4da"]:["#000"],dashed:!0,cx:K+(U-K)/2,cy:z+(W-z)/2,activeEmbeddable:!1})};for(let L of vF(s))k(L);s.editingGroupId&&k(s.editingGroupId),_.forEach(L=>DT(g,s,L))}if(g.save(),g.translate(s.scrollX,s.scrollY),r.length===1){g.fillStyle="#fff";let D=uF(r[0],s.zoom,t,"mouse",Vf(c));if(!s.viewModeEnabled&&C&&!yF(s.editingTextElement)&&!s.croppingElementId&&TT(g,l,s,D,r[0].angle),s.croppingElementId&&!s.isCropping){let _=t.get(s.croppingElementId);_&&np(_)&&BF(g,l,s,_,t)}}else if(r.length>1&&!s.isRotating&&!r.some(D=>D.locked)){let D=CT*2/s.zoom.value;g.fillStyle="#fff";let[_,k,L,F]=jf(r,t),K=g.getLineDash();g.setLineDash([2/s.zoom.value]);let z=g.lineWidth;g.lineWidth=1/s.zoom.value,g.strokeStyle=M,Ms(g,_-D,k-D,L-_+D*2,F-k+D*2,(_+L)/2,(k+F)/2,0),g.lineWidth=z,g.setLineDash(K);let U=hF([_,k,L,F,(_+L)/2,(k+F)/2],0,s.zoom,"mouse",w?{...Vf(c),rotation:!0}:Vf(c));r.some(W=>!W.locked)&&TT(g,l,s,U,0)}g.restore()}s.searchMatches?.matches.forEach(({id:C,focus:P,matchedLines:M})=>{let D=t.get(C);if(D){let[_,k,,,L,F]=Kl(D,t,!0);g.save(),s.theme===No.LIGHT?P?g.fillStyle="rgba(255, 124, 0, 0.4)":g.fillStyle="rgba(255, 226, 0, 0.4)":P?g.fillStyle="rgba(229, 82, 0, 0.4)":g.fillStyle="rgba(99, 52, 0, 0.4)";let K=qa(D)?s.zoom.value:1;g.translate(s.scrollX,s.scrollY),g.translate(L,F),g.rotate(D.angle),M.forEach(z=>{(z.showOnCanvas||P)&&g.fillRect(_+z.offsetX/K-L,k+z.offsetY/K-F,z.width/K,z.height/K)}),g.restore()}}),bT(g,s),zF(g,o,t,e,s,l.selectionColor),g.restore(),Ww({context:g,renderConfig:l,appState:s,normalizedWidth:p,normalizedHeight:u});let T;return l.renderScrollbars&&(T=xI(t,p,u,s),g.save(),g.fillStyle=bI,g.strokeStyle="rgba(255,255,255,0.8)",[T.horizontal,T.vertical].forEach(C=>{C&&um(g,C.x,C.y,C.width,C.height,fn/2)}),g.restore()),{scrollBars:T,animationState:E}},qf=e=>{let n=UF(e);return e.callback(n),n};import{useEffect as jl,useMemo as RT,useRef as nE,useState as WF}from"react";import{bumpVersion as Xl,getLinearElementSubType as Qa,mutateElement as oE,updateElbowArrowPoints as VF}from"@excalidraw/element";import{pointFrom as ip,pointRotateRads as YF}from"@excalidraw/math";import{hasBoundTextElement as KF,isArrowBoundToElement as XF,isArrowElement as ZF,isElbowArrow as $F,isLinearElement as sE,isUsingAdaptiveRadius as jF}from"@excalidraw/element";import{getCommonBoundingBox as qF,getElementAbsoluteCoords as JF}from"@excalidraw/element";import{getBoundTextElement as zT,getBoundTextMaxHeight as QF,getBoundTextMaxWidth as eO,redrawTextBoundingBox as tO}from"@excalidraw/element";import{wrapText as nO}from"@excalidraw/element";import{assertNever as oO,CLASSES as rO,getFontString as Jf,isProdEnv as iO,mapFind as aO,reduceToCommonValue as sO,ROUNDNESS as Qf,sceneCoordsToViewportCoords as lO,updateActiveTool as NT}from"@excalidraw/common";import{measureText as BT}from"@excalidraw/element";import{LinearElementEditor as cO}from"@excalidraw/element/linearElementEditor";import{newArrowElement as eE,newElement as dO,newLinearElement as mO}from"@excalidraw/element";import{ShapeCache as pO}from"@excalidraw/element";import{updateBindings as uO}from"@excalidraw/element";import{jsx as aE}from"react/jsx-runtime";var hO=8,gO=10,Zl=["rectangle","diamond","ellipse"],$l=["line","sharpArrow","curvedArrow","elbowArrow"],fO=new Set(Zl),EO=new Set($l),es=e=>fO.has(e),ap=e=>e==="arrow"||EO.has(e),po=Qe(null),ql=new Map,Jl=new Map,bO=({app:e})=>{let n=e.scene.getSelectedElements(e.state),t=nE(null);return jl(()=>{if(n.length===0){e.updateEditorAtom(po,null);return}let o=sp(n);o&&!t.current?t.current=o:(t.current&&!o||t.current&&o!==t.current)&&(e.updateEditorAtom(po,null),t.current=null)},[n,e]),jl(()=>()=>{ql.clear(),Jl.clear()},[]),aE(xO,{app:e,elements:n})},xO=({app:e,elements:n})=>{let t=sp(n),o=RT(()=>t==="generic"?HT(n):[],[t,n]),r=RT(()=>t==="linear"?iE(n):[],[t,n]),i=t==="generic"?o.every(m=>m.type===o[0].type):t==="linear"?r.every(m=>Qa(m)===Qa(r[0])):!1,[a,s]=WF({x:0,y:0}),l=nE(""),c=nE(null);jl(()=>{let m=[...o,...r].sort((b,v)=>b.id.localeCompare(v.id)),p=`
18
+ ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${m.map(b=>b.id).join(",")}`;if(p===l.current)return;l.current=p;let u;if(m.length===1){let[b,,,v,w,x]=JF(m[0],e.scene.getNonDeletedElementsMap());u=YF(ip(b,v),ip(w,x),m[0].angle)}else{let{minX:b,maxY:v}=qF(m);u=ip(b,v)}let{x:E,y:g}=lO({sceneX:u[0],sceneY:u[1]},e.state);s({x:E,y:g})},[o,r,e.scene,e.state]),jl(()=>{for(let m of r){let p=rE(m.id,TO(m));Jl.has(p)||Jl.set(p,m)}},[r]),jl(()=>{for(let m of o)if(!ql.has(m.id)){let p=zT(m,e.scene.getNonDeletedElementsMap());p&&ql.set(m.id,{fontSize:p.fontSize})}},[o,e.scene]);let d=t==="linear"?[["line",jo],["sharpArrow",Qo],["curvedArrow",tr],["elbowArrow",er]]:t==="generic"?[["rectangle",Ui],["diamond",Wi],["ellipse",Vi]]:[];return aE("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(gO+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-hO}px`,zIndex:2},className:rO.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(t==="generic"&&o[0].type===m||t==="linear"&&Qa(r[0])===m);return aE($,{type:"toggle",icon:p,checked:u,title:m,"aria-label":m,"data-testid":`toolbar-${m}`,onSelect:()=>{u||(e.state.activeTool.type!==m&&We("convertElementType",m,"ui"),lE(e,{conversionType:t,nextType:m}),c.current?.focus())}},`${n[0].id}${n[0].version}_${m}`)})})},yO=(e,n,t)=>{let o=eO(e,n),r=QF(e,n),i=nO(n.text,Jf(n),o),a=BT(i,Jf(n),n.lineHeight),s=n.fontSize;for(;(a.width>o||a.height>r)&&s>0;){s-=1;let l={...n,fontSize:s};a=BT(n.text,Jf(l),n.lineHeight)}oE(n,t.getNonDeletedElementsMap(),{fontSize:s,width:a.width,height:a.height}),tO(n,e,t)},lE=(e,{conversionType:n,nextType:t,direction:o="right"})=>{if(!n)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((s,l)=>({...s,[l.id]:!0}),{}),a=o==="right"?1:-1;if(n==="generic"){let s=HT(r),c=s.every(d=>d.type===s[0].type)?Zl.indexOf(s[0].type):-1;if(t=t??Zl[(c+Zl.length+a)%Zl.length],t&&es(t)){let d={};for(let p of s){let u=OT(p,t,e);d[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?m.push(d[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(d)){let u=zT(p,e.scene.getNonDeletedElementsMap());u&&(ql.get(p.id)&&oE(u,e.scene.getNonDeletedElementsMap(),{fontSize:ql.get(p.id)?.fontSize??u.fontSize}),yO(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:NT(p,{type:"selection"})}))}}if(n==="linear"){let s=iE(r);if(!t){let c=sO(s,Qa),d=c?$l.indexOf(c):-1;t=$l[(d+$l.length+a)%$l.length]}if(ap(t)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of s){let p=Jl.get(rE(m.id,t));if(p&&Qa(p)===t)d.set(p.id,p),c.push(p);else{let u=OT(m,t,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(sE(m))if($F(m)){let p=wO(m);if(p.length<2)continue;let u=[];for(let g=1;g<p.length-2;g++)u.push({start:p[g],end:p[g+1],index:g+1});let E=VF(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});oE(m,e.scene.getNonDeletedElementsMap(),{...E,endArrowhead:"arrow"})}else{let p=aO(["line","sharpArrow","curvedArrow"],u=>Jl.get(rE(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let l=iE(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:l.length===1?new cO(l[0],e.scene.getNonDeletedElementsMap()):null,activeTool:NT(c,{type:"selection"})}))}return!0},sp=e=>{if(e.length===0)return null;let n=!1;for(let t of e){if(es(t.type))return"generic";GT(t)&&(n=!0)}return n?"linear":null},GT=e=>sE(e)&&(!ZF(e)||!XF(e)&&!KF(e)),rE=(e,n)=>`${e}:${n}`,HT=e=>e.filter(n=>es(n.type)),iE=e=>e.filter(n=>GT(n)),rp=20,Ja=(e,n)=>e[0]===n[0],tE=(e,n)=>e[1]===n[1],FT=(e,n)=>Ja(e,n)?Math.abs(e[1]-n[1]):Math.abs(e[0]-n[0]),wO=e=>{let n=[e.points[0]],t=vO(e.points);for(let i=1;i<t.length;++i){let a=n[n.length-1],s=[...t[i]];Math.abs(s[0]-a[0])<rp?s[0]=a[0]:Math.abs(s[1]-a[1])<rp&&(s[1]=a[1]),Ja(a,s)||tE(a,s)||n.push(ip(a[0],s[1])),n.push(s)}let o=[n[0]];for(let i=1;i<n.length-1;++i)Ja(n[i-1],n[i])&&Ja(n[i],n[i+1])||tE(n[i-1],n[i])&&tE(n[i],n[i+1])||o.push(n[i]);o.push(n[n.length-1]);let r=[o[0]];for(let i=1;i<o.length-1;++i){let a=r[r.length-1],s=o[i],l=o[i+1],c=Ja(a,s),d=Ja(s,l);if(c!==d){let m=FT(a,s),p=FT(s,l);if(m<rp||p<rp){if(p<m)c?l[0]=a[0]:l[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=s[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=s[1];continue}}r.push(s)}return r.push(o[o.length-1]),r},vO=e=>{if(e.length===0)return[];let n=[e[0]];for(let t=1;t<e.length;t++){let[o,r]=n[n.length-1],[i,a]=e[t];(o!==i||r!==a)&&n.push(e[t])}return n},OT=(e,n,t)=>{if(!IO(e.type,n)){if(!iO())throw Error(`Invalid conversion from ${e.type} to ${n}.`);return e}if(e.type===n)return e;if(pO.delete(e),es(n)){let o=Xl(dO({...e,type:n,roundness:e.roundness?{type:jF(n)?Qf.ADAPTIVE_RADIUS:Qf.PROPORTIONAL_RADIUS}:e.roundness}));return uO(o,t.scene,t.state),o}if(ap(n))switch(n){case"line":return Xl(mO({...e,type:"line"}));case"sharpArrow":return Xl(eE({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Xl(eE({...e,type:"arrow",elbowed:!1,roundness:{type:Qf.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Xl(eE({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return oO(n,`unhandled conversion type: ${n}`),e},IO=(e,n)=>!!(es(e)&&es(n)||ap(e)&&ap(n)),TO=e=>sE(e)?Qa(e):e.type,UT=bO;import{bindBindingElementToFixedPoint as SO,dragNewTextElement as CO,getBoundTextElement as PO,getEndpointBoundTextDragAnchor as kO,getTextBindingForArrowEndpoint as MO,getUnboundArrowEndpointAtPoint as AO,isArrowElement as DO,isBindingEnabled as LO,isEndpointBoundText as _O,isTextElement as RO}from"@excalidraw/element";import{pointFrom as NO}from"@excalidraw/math";var lp=class{constructor(n){this.app=n;y(this,"updateHoveredAnchor",n=>{let t=this.app.state.activeTool.type==="text"&&!this.app.state.editingTextElement&&!this.app.state.newElement?this.getAnchorAtPosition(n.x,n.y):null,o=this.app.state.hoveredArrowTextAnchor;return(o?.elementId!==t?.elementId||o?.anchor!==t?.anchor)&&this.app.setState({hoveredArrowTextAnchor:t}),t});y(this,"refresh",()=>{this.app.lastPointerMoveCoords&&this.updateHoveredAnchor(this.app.lastPointerMoveCoords)})}getBindableEndpointAtPosition(n,t){if(!LO(this.app.state))return null;let o=AO(NO(n,t),this.app.scene.getNonDeletedElements(),this.app.scene.getNonDeletedElementsMap(),this.app.state.zoom);if(!o||this.app.getTextElementAtPosition(n,t))return null;let r=this.app.getElementAtPosition(n,t,{includeLockedElements:!0});return r&&r.id!==o.arrow.id&&this.app.scene.getElementIndex(r.id)>this.app.scene.getElementIndex(o.arrow.id)?null:o}getAnchorAtPosition(n,t){let o=this.getBindableEndpointAtPosition(n,t);if(o)return{elementId:o.arrow.id,anchor:o.startOrEnd};let r=this.app.getTextBindableContainerAtPosition(n,t);return!DO(r)||PO(r,this.app.scene.getNonDeletedElementsMap())?null:this.app.getTextWysiwygSnappedToCenterPosition(n,t,this.app.state,r)?{elementId:r.id,anchor:"label"}:null}getTextBinding({arrow:n,startOrEnd:t},o){return MO(n,t,this.app.scene.getNonDeletedElementsMap(),o)}bindText({arrow:n,startOrEnd:t},o,r){SO(n,o,t,r,this.app.scene)}maybeDragNewText(n,t){return!RO(n)||!_O(n,this.app.scene.getNonDeletedElementsMap())?!1:(CO({newElement:n,...kO(n),pointerX:t.x,zoom:this.app.state.zoom.value,scene:this.app.scene}),!0)}};import{applyDarkModeFilter as BO,BUCKET_FILL_BACKGROUND_PICKS as FO,COLOR_PALETTE as VT,DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as OO,getSizeFromPoints as zO,isTransparent as GO,THEME as HO}from"@excalidraw/common";import{pointFrom as WT}from"@excalidraw/math";import{computeBucketFillPolygon as UO,isBucketFillCompatible as WO,isFrameLikeElement as VO,isRestylableFill as YO,newLinearElement as KO,ShapeCache as XO}from"@excalidraw/element";var cE=FO.filter(e=>e!==VT.white),cp=class{constructor(n){this.app=n;y(this,"temporaryEyeDropper",null);y(this,"pending",null);y(this,"handlePointerDown",n=>{this.pending=n});y(this,"handlePointerUp",()=>{let n=this.pending;this.pending=null,n&&this.fill(n)});y(this,"cancel",()=>{this.pending=null});y(this,"cycleBackgroundColor",()=>{let n=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),t=cE.indexOf(n),o=cE[(t+1)%cE.length];this.app.actionManager.executeAction(Nd,"keyboard",{currentItemBackgroundColor:o})});y(this,"openTemporaryEyeDropper",()=>{if(bt.get(Ut))return;let n={colorPickerType:"elementBackground",keepOpenOnAlt:!0,onSelect:t=>{this.app.actionManager.executeAction(Nd,"ui",{currentItemBackgroundColor:t})}};this.temporaryEyeDropper=n,this.app.updateEditorAtom(Ut,n)});y(this,"closeTemporaryEyeDropper",()=>{let n=this.temporaryEyeDropper;this.temporaryEyeDropper=null,n&&bt.get(Ut)===n&&this.app.updateEditorAtom(Ut,null)});y(this,"restyle",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor);n.backgroundColor===t&&n.fillStyle===this.app.state.currentItemFillStyle&&n.opacity===this.app.state.currentItemOpacity||(this.app.scene.mutateElement(n,{backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,opacity:this.app.state.currentItemOpacity}),XO.delete(n),this.app.scheduleCapture())});y(this,"fill",n=>{let t=this.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor),o=this.app.scene.getNonDeletedElements(),r=this.app.scene.getNonDeletedElementsMap(),i=WT(n.x,n.y),a=this.app.getElementAtPosition(i[0],i[1]),s=UO({point:i,elements:o,elementsMap:r});if(!s.ok){if(a&&WO(a)){this.restyle(a);return}s.reason==="too_complex"?this.app.setToast({message:f("bucketfill.tooComplex"),duration:3e3}):(s.reason==="open_region"||s.reason==="too_small"||s.reason==="invalid_polygon")&&this.app.setToast({message:f("bucketfill.noRegion"),duration:3e3});return}if(a&&YO({hitElement:a,scenePoints:s.scenePoints,elementsMap:r})){this.restyle(a);return}let{width:l,height:c}=zO(s.scenePoints),[d,m]=s.scenePoints[0],p=s.scenePoints.map(w=>WT(w[0]-d,w[1]-m)),u=s.ownerId?r.get(s.ownerId):null,E=u?VO(u)?u.id:u.frameId:this.app.getTopLayerFrameAtSceneCoords(n)?.id??null,g=u?u.groupIds:s.boundaryElementIds.map(w=>r.get(w)?.groupIds).filter(w=>!!w).reduce((w,x)=>w===null?x:w.filter(I=>x.includes(I)),null)??[],b=KO({type:"line",x:d,y:m,width:l,height:c,points:p,polygon:!0,strokeColor:"transparent",backgroundColor:t,fillStyle:this.app.state.currentItemFillStyle,strokeWidth:1,strokeStyle:"solid",roughness:0,roundness:null,opacity:this.app.state.currentItemOpacity,frameId:E,groupIds:g}),v=this.app.scene.getElementsIncludingDeleted().findIndex(w=>w.id===s.insertion.elementId);this.app.scene.insertElementsAtIndex([b],v<0?null:s.insertion.placement==="above"?v+1:v),this.app.scheduleCapture()});y(this,"getBucketFillBackgroundColor",(n,t)=>GO(n)?VT.green[OO]:BO(n,t===HO.DARK))}};import{CURSOR_TYPE as Ql,MIME_TYPES as mp,THEME as YT}from"@excalidraw/common";var KT='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',ZO='<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"/>',XT='<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"/>',$O=`data:${mp.svg},${encodeURIComponent(`${KT}${XT}</svg>`)}`,jO=`data:${mp.svg},${encodeURIComponent(`${KT}${ZO}${XT}</svg>`)}`,qO=e=>{let n=Uu.map((t,o)=>`<path d="${t}" ${o<2?`fill="${e}"`:""} />`).join("");return`data:${mp.svg},${encodeURIComponent(`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke-linecap="round" stroke-linejoin="round"><g stroke="#fff" fill="#fff" stroke-width="5">${n}</g><g stroke="#1b1b1f" stroke-width="1.25">${n}</g></svg>`)}`},dp=class{constructor(n){this.app=n;y(this,"toolCursorMemo",null);y(this,"eraserCanvasCache",null);y(this,"eraserPreviewDataURL",null);y(this,"set",n=>{this.toolCursorMemo=null,this.canvas&&(this.canvas.style.cursor=n)});y(this,"reset",()=>{this.app.state.viewModeEnabled&&!this.app.isActiveToolPointerCapturing()?this.app.isNavigationEnabled()?this.set(Ql.GRAB):this.clear():this.applyForTool()});y(this,"applyForTool",(n=this.app.state.activeTool)=>{let t=this.canvas;if(!t)return;let o=n.type==="eraser"||n.type==="laser"||n.type==="bucketfill"?this.app.state.theme:void 0,r=n.type==="bucketfill"?this.app.bucketFill.getBucketFillBackgroundColor(this.app.state.currentItemBackgroundColor,o):void 0,i=this.toolCursorMemo;if(!(i?.canvas===t&&i.type===n.type&&i.bucketFillColor===r&&i.theme===o)){if(n.type==="selection")this.clear();else if(Cs({activeTool:n}))this.set(Ql.GRAB);else if(rn({activeTool:n}))this.applyEraser();else if(n.type==="autoshape")this.set(Ql.CROSSHAIR);else if(n.type==="bucketfill")this.set(`url(${qO(r)}) 5 18, auto`);else if(n.type==="laser"){let a=this.app.state.theme===YT.LIGHT?$O:jO;this.set(`url(${a}), auto`)}else["image","custom"].includes(n.type)?n.type!=="image"&&this.set(Ql.AUTO):this.set(Ql.CROSSHAIR);this.toolCursorMemo={canvas:t,type:n.type,bucketFillColor:r,theme:o}}});y(this,"clear",()=>{this.set("")});y(this,"applyEraser",()=>{let t=this.app.state.theme;if(!this.eraserCanvasCache||this.eraserCanvasCache.theme!==t){let o=t===YT.DARK;this.eraserCanvasCache=document.createElement("canvas"),this.eraserCanvasCache.theme=t,this.eraserCanvasCache.height=20,this.eraserCanvasCache.width=20;let r=this.eraserCanvasCache.getContext("2d");r.lineWidth=1,r.beginPath(),r.arc(this.eraserCanvasCache.width/2,this.eraserCanvasCache.height/2,5,0,2*Math.PI),r.fillStyle=o?"#000":"#fff",r.fill(),r.strokeStyle=o?"#fff":"#000",r.stroke(),this.eraserPreviewDataURL=this.eraserCanvasCache.toDataURL(mp.svg)}this.set(`url(${this.eraserPreviewDataURL}) ${20/2} ${20/2}, auto`)})}get canvas(){return this.app.interactiveCanvas}};import{randomInteger as n9}from"@excalidraw/common";import{bindBindingElement as o9,convertToShape as r9,convertToShapeHandlePointerMoveFromPointerDown as i9,getHoveredElementForBinding as ZT,isBindingElement as a9,isLineElement as s9,LinearElementEditor as dE,maxBindingDistance_simple as $T,newArrowElement as l9,updateBoundPoint as c9}from"@excalidraw/element";import{getStrokeWidthByKey as JO,THEME as QO}from"@excalidraw/common";import{clamp as e9,pointFrom as t9}from"@excalidraw/math";var pp=class{constructor(n){this.app=n;y(this,"trail");this.trail=new zn(this.app,{...this.getTrailOptions(),fill:()=>n.props.renderCustomizations?.traceColor??(n.state.theme===QO.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)")})}getTrailOptions(){return{simplify:0,streamline:.4,size:1,sizeMapping:()=>e9(JO("line",this.app.state.currentItemStrokeWidthKey)*.65*this.app.state.zoom.value,1.25,4)}}startPath(n,t){this.trail.startPath(n,t)}addPointToPath(n,t){this.trail.addPointToPath(n,t)}endPath(){this.trail.endPath()}clearTrails(){this.trail.clearTrails()}getCurrentPoints(){let n=this.trail.getCurrentTrail();return n?n.originalPoints.map(([t,o])=>t9(t,o)):[]}start(n){this.trail.start(n)}stop(){this.trail.stop()}};var up=class{constructor(n){this.app=n;y(this,"trail");y(this,"gestureInProgress",!1);y(this,"stop",()=>{this.trail.stop()});y(this,"hasPendingGesture",()=>this.gestureInProgress);y(this,"handlePointerDown",n=>{this.gestureInProgress&&this.app.actionManager.executeAction(gt),this.gestureInProgress=!0,this.trail.startPath(n.lastCoords.x,n.lastCoords.y)});y(this,"handlePointerMove",n=>i9(this.app,n));y(this,"bindRecognizedArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=$T(t.state.zoom),a=["start","end"].map(d=>{let m=dE.getPointAtIndexGlobalCoordinates(n,d==="start"?0:-1,o);return{startOrEnd:d,globalPoint:m,target:ZT(m,r,o,i)}}),s=!!a[0].target&&a[0].target===a[1].target,l=t.state.isMidpointSnappingEnabled&&!t.state.gridModeEnabled;for(let{startOrEnd:d,globalPoint:m,target:p}of a)p&&o9(n,p,s?"inside":"orbit",d,t.scene,m,t.state.isBindingEnabled,l);if(s)return;let c=new Map;for(let{startOrEnd:d,target:m}of a){if(!m)continue;let p=c9(n,d==="start"?"startBinding":"endBinding",d==="start"?n.startBinding:n.endBinding,m,o);p&&c.set(d==="start"?0:n.points.length-1,{point:p})}c.size&&dE.movePoints(n,t.scene,c)});y(this,"maybeUpgradeLineToArrow",n=>{let{app:t}=this,o=t.scene.getNonDeletedElementsMap(),r=t.scene.getNonDeletedElements(),i=$T(t.state.zoom),[a,s]=[0,-1].map(l=>ZT(dE.getPointAtIndexGlobalCoordinates(n,l,o),r,o,i));return!a&&!s||a===s?null:l9({type:"arrow",x:n.x,y:n.y,width:n.width,height:n.height,startArrowhead:null,endArrowhead:t.state.currentItemEndArrowhead,points:n.points,groupIds:n.groupIds,frameId:n.frameId,locked:!1,angle:n.angle,strokeColor:n.strokeColor,backgroundColor:n.backgroundColor,fillStyle:n.fillStyle,roughness:n.roughness,opacity:n.opacity,strokeStyle:n.strokeStyle,strokeWidth:n.strokeWidth})});y(this,"finalize",()=>{let{app:n}=this,t=this.gestureInProgress?this.trail.getCurrentPoints():[];if(this.gestureInProgress=!1,this.trail.endPath(),t.length>=3){let o=n.state.newElement||r9(t,n.state,n.scene.getNonDeletedElementsMap(),n.state.newElement,n.scene.getNonDeletedFramesLikes());if(o){let r={...o,seed:n9(),opacity:n.state.currentItemOpacity};n.state.isBindingEnabled&&s9(r)&&(r=this.maybeUpgradeLineToArrow(r)??r),n.insertNewElement(r),n.state.isBindingEnabled&&a9(r)&&this.bindRecognizedArrow(r)}}this.trail.clearTrails()});this.trail=new pp(n)}};import{isArrowKey as d9,KEYS as gi}from"@excalidraw/common";import{makeNextSelectedElementIds as m9,CaptureUpdateAction as p9,FlowChartCreator as u9,FlowChartNavigator as h9,getSelectedElements as jT,isFlowchartNodeElement as g9}from"@excalidraw/element";var hp=class e{constructor(n){this.app=n;y(this,"creator",new u9);y(this,"navigator",new h9);y(this,"clear",()=>{this.creator.clear(),this.navigator.clear()});y(this,"handleKeyEvent",n=>{let t=this.resolveKeyboardEventToOperation(n);switch(t.type){case"none":return!1;case"canceled":return this.app.triggerRender(!0),!0;case"creating":return n.preventDefault(),t.pending.length&&this.app.revealIfHidden(t.pending),!0;case"navigating":{n.preventDefault();let o=t.nodeId&&this.app.scene.getNonDeletedElementsMap().get(t.nodeId);return o&&this.selectAndReveal(o),!0}case"committed":{t.nodes.length&&this.app.insertNewElements(t.nodes);let o=t.nodes[0];return o&&this.selectAndReveal(o),this.captureUpdate(),!0}case"navigationEnded":return this.captureUpdate(),!0}})}get pendingNodes(){return this.creator.pendingNodes}get isCreatingChart(){return this.creator.isCreatingChart}resolveKeyboardEventToOperation(n){let{creator:t,navigator:o,app:r}=this;if(n.type==="keydown"){if(n.key===gi.ESCAPE&&t.isCreatingChart)return t.clear(),{type:"canceled"};if(!d9(n.key))return{type:"none"};if(n[gi.CTRL_OR_CMD]&&!n.shiftKey){let a=jT(r.scene.getNonDeletedElementsMap(),r.state);return a.length===1&&g9(a[0])&&t.createNodes(a[0],r.state,e.getLinkDirectionFromKey(n.key),r.scene),{type:"creating",pending:t.pendingNodes??[]}}if(n.altKey){let a=r.scene.getNonDeletedElementsMap(),s=jT(a,r.state);if(s.length===1)return{type:"navigating",nodeId:o.exploreByDirection(s[0],a,e.getLinkDirectionFromKey(n.key))}}return{type:"none"}}let i=!n.altKey&&o.isExploring;if(i&&o.clear(),!n[gi.CTRL_OR_CMD]&&t.isCreatingChart){let a=t.pendingNodes??[];return t.clear(),{type:"committed",nodes:a}}return i?{type:"navigationEnded"}:{type:"none"}}selectAndReveal(n){this.app.setState(t=>({selectedElementIds:m9({[n.id]:!0},t)})),this.app.revealIfHidden([n])}captureUpdate(){this.app.syncActionResult({captureUpdate:p9.IMMEDIATELY})}static getLinkDirectionFromKey(n){switch(n){case gi.ARROW_UP:return"up";case gi.ARROW_DOWN:return"down";case gi.ARROW_RIGHT:return"right";case gi.ARROW_LEFT:return"left";default:return"right"}}};import{createGifPlaybackMetadata as qT,hasPlayableGif as f9,isInitializedImageElement as E9,newElementWith as JT,ShapeCache as b9}from"@excalidraw/element";import{MIME_TYPES as QT}from"@excalidraw/common";var gp=class{constructor(n){this.app=n;y(this,"playbackRaf",null);y(this,"runtimeState",new Map);y(this,"stop",()=>{this.playbackRaf!==null&&(cancelAnimationFrame(this.playbackRaf),this.playbackRaf=null),this.runtimeState.clear()});y(this,"getFrameIndex",n=>n.gifPlayback?.playing?this.runtimeState.get(n.id)?.frameIndex??n.gifPlayback.frameIndex:n.gifPlayback?.frameIndex);y(this,"setFrameIndex",(n,t)=>{this.runtimeState.set(n.id,{frameIndex:t,lastFrameTime:performance.now()})});y(this,"ensureLoop",()=>{this.playbackRaf!==null||this.app.unmounted||f9(this.app.scene.getNonDeletedElements(),this.app.imageCache)&&(this.playbackRaf=requestAnimationFrame(this.tick))});y(this,"createPlaceholderDecodeState",(n,t)=>{if(t.type!==QT.gif)return null;let o=n.id;this.app.imageCache.set(o,{image:new Promise(()=>{}),mimeType:QT.gif,gifDecodeStatus:"pending"});let r=JT(n,{fileId:o,gifPlayback:qT({playing:!0})});return this.app.scene.replaceAllElements(this.app.scene.getElementsIncludingDeleted().map(i=>i.id===r.id?r:i)),this.app.imagePlaceholderUpdateEmitter.trigger(),o});y(this,"ensureElementPlaybackMetadata",(n,t={})=>n.gifPlayback&&(t.playing===void 0||n.gifPlayback.playing===t.playing)?n:JT(n,{gifPlayback:n.gifPlayback?{...n.gifPlayback,playing:t.playing??n.gifPlayback.playing}:qT(t)}));y(this,"removePlaceholderDecodeState",n=>{n&&this.app.imageCache.delete(n)});y(this,"tick",()=>{if(this.playbackRaf=null,this.app.unmounted)return;let n=performance.now(),t=!1,o=!1;for(let r of this.app.scene.getNonDeletedElements()){if(!E9(r)||!r.gifPlayback?.playing)continue;let i=this.app.imageCache.get(r.fileId)?.gif;if(!i||i.frames.length<2)continue;o=!0;let a=Math.max(r.gifPlayback.speed||1,.1),s=this.runtimeState.get(r.id)??{frameIndex:r.gifPlayback.frameIndex,lastFrameTime:n};this.runtimeState.set(r.id,s);let l=s.frameIndex,c=i.delays[l]??100;n-s.lastFrameTime>=c/a&&(s.frameIndex=(l+1)%i.frames.length,s.lastFrameTime=n,b9.delete(r),t=!0)}t&&this.app.imagePlaceholderUpdateEmitter.trigger(),o&&(this.playbackRaf=requestAnimationFrame(this.tick))})}};import{debounce as x9,easeOut as iS,isBounds as y9}from"@excalidraw/common";import{clamp as aS}from"@excalidraw/math";import{getCommonBounds as eS,getElementsInGroup as w9,isElementLink as v9,isExcalidrawElement as I9,parseElementLinkFromURL as T9}from"@excalidraw/element";var fp="animateScrollToContent",ts="animateScrollConstraintsSnapBack",tS=500,S9=250,C9=200,mE=302,nS={full:216,compact:64},P9=e=>{if(!e||typeof e!="object"||Array.isArray(e))return!1;let n=e;return typeof n.x=="number"&&typeof n.y=="number"&&(n.width==null||typeof n.width=="number")&&(n.height==null||typeof n.height=="number")},k9=(e,n)=>{let t=n.get(e);return t?[t]:w9(n,e)},oS=(e,n,t)=>{if(typeof e=="string"){let a=v9(e),s=a?"link":"element",l=a?T9(e):e,c=l?k9(l,n):[];return c.length?{bounds:eS(c,n),type:s}:{bounds:null,type:s}}if(y9(e))return{bounds:e,type:"area"};if(P9(e)&&!I9(e)){let a=e.width??t.width,s=e.height??t.height;return{bounds:[e.x,e.y,e.x+a,e.y+s],type:"area"}}let o=Array.isArray(e)?e:[e],r=o.reduce((a,s)=>{if(s&&!s.isDeleted){let l=n.get(s.id);l&&a.push(l)}return a},[]),i=!r.length;return(r.length!==o.length||i)&&console.warn("supplied element target(s) for setViewport contain deleted or non-existent elements which have been filtered out"),i?{bounds:null,type:"element"}:{bounds:eS(r,n),type:"element"}},M9=e=>e===!1?0:e===!0||e==null?Du:Math.max(e,0),A9=(e,n,t="scale-down",o,r)=>{let{appState:i}=zr({bounds:n,appState:e,fit:t,canvasOffsets:o,steppedZoom:!1,viewportZoomFactor:r});return{scrollX:i.scrollX,scrollY:i.scrollY,zoom:i.zoom}},rS=(e,n,{fit:t,offsets:o,lock:r,viewportZoomFactor:i})=>{let a=A9(e,n,t,o,i);if(!r?.scroll&&!r?.zoom)return{...a,scrollConstraints:null};let[s,l,c,d]=n,m={x:s,y:l,width:c-s,height:d-l,lockScroll:!!r.scroll,lockZoom:!!r.zoom,zoom:a.zoom.value,overscroll:M9(r.overscroll),offsets:o};return{...$n({...e,...a,scrollConstraints:m}),scrollConstraints:m}},D9=({from:e,target:n,factor:t})=>{if(t>=1)return{...n};let o=e.zoom.value*Math.pow(n.zoom.value/e.zoom.value,t),r=n.zoom.value===e.zoom.value?t:(o-e.zoom.value)/(n.zoom.value-e.zoom.value);return{scrollX:((1-r)*e.scrollX*e.zoom.value+r*n.scrollX*n.zoom.value)/o,scrollY:((1-r)*e.scrollY*e.zoom.value+r*n.scrollY*n.zoom.value)/o,zoom:{value:o}}},L9=e=>e===!1?null:e===!0||e==null?tS:e.duration??tS,_9=(e,n,t,o,r)=>{ct.start(fp,({deltaTime:i,state:a})=>{let s=(a?.elapsed??0)+i,l=Math.min(s/t,1),c=iS(aS(l,0,1));return l<1?(o({...D9({from:e,target:n,factor:c}),shouldCacheIgnoreZoom:!0}),{elapsed:s}):(r(),null)})},R9=(e,n,t=S9)=>{let o=$n(e);if(o.scrollX===e.scrollX&&o.scrollY===e.scrollY&&o.zoom.value===e.zoom.value||ct.running(fp))return;let r=(e.scrollX-o.scrollX)*e.zoom.value,i=(e.scrollY-o.scrollY)*e.zoom.value;ct.start(ts,({deltaTime:a,state:s})=>{let l=(s?.elapsed??0)+a,c=Math.min(l/t,1),d=1-iS(aS(c,0,1));return n(m=>{if(!m.scrollConstraints)return null;let p=$n(m),u=p.zoom.value;return{scrollX:p.scrollX+r*d/u,scrollY:p.scrollY+i*d/u,zoom:p.zoom}}),c<1?{elapsed:l}:null})},Ep=class{constructor(n,t){this.app=n;this.dependencies=t;y(this,"lastPosition",{x:0,y:0});y(this,"activeTransition",null);y(this,"uiLastMeasured",new Map);y(this,"invalidateUIOffset",n=>{this.uiLastMeasured.delete(n)});y(this,"resolveOffsets",n=>{if(!n)return n;let{ui:t,...o}=n;if(!t)return o;let r=this.getOffsets(t===!0?void 0:t);return{top:o.top??r.top,right:o.right??r.right,bottom:o.bottom??r.bottom,left:o.left??r.left}});y(this,"getOffsets",n=>{let t=this.dependencies.getContainer(),o=t?.getBoundingClientRect(),r=Jn().rtl,i={top:0,right:0,bottom:0,left:0},a=new Set;if(t&&o)for(let u of t.querySelectorAll("[data-viewport-ui]")){let E=u.getBoundingClientRect(),g={top:E.top-o.top,right:E.right-o.left,bottom:E.bottom-o.top,left:E.left-o.left,width:E.width};switch(u.dataset.viewportUi){case"top":i.top=Math.max(i.top,g.bottom);break;case"bottom":i.bottom=Math.max(i.bottom,this.app.state.height-g.top);break;case"side":{let[b,v]=g.left+g.width/2<this.app.state.width/2?["left",g.right]:["right",this.app.state.width-g.left];i[b]=Math.max(i[b],v);let w=u.dataset.viewportUiName;w&&(a.add(w),v>0&&this.uiLastMeasured.set(w,{side:b,offset:v}));break}}}if(n?.reserve&&this.app.editorInterface.formFactor!=="phone"){let u=(E,g)=>{if(a.has(E))return;let{side:b,offset:v}=this.uiLastMeasured.get(E)??g;i[b]=Math.max(i[b],v)};n.reserve.stylesPanel&&u("stylesPanel",{side:r?"right":"left",offset:this.dependencies.getStylesPanelMode()==="compact"?nS.compact:nS.full}),n.reserve.sidebar&&u("sidebar",{side:r?"left":"right",offset:mE})}let s=n?.padding??24,l=n?.paddingTop??s,c=(r?n?.paddingLeft:n?.paddingRight)??s,d=n?.paddingBottom??s,m=(r?n?.paddingRight:n?.paddingLeft)??s,p={top:i.top+l,right:i.right+c,bottom:i.bottom+d,left:i.left+m};return{top:n?.top??p.top,right:(r?n?.left:n?.right)??p.right,bottom:n?.bottom??p.bottom,left:(r?n?.right:n?.left)??p.left}});y(this,"resolveInitialViewport",(n,t,o)=>{let{bounds:r}=oS(n.target,t,o);return r?rS(o,r,{...n,offsets:this.resolveOffsets(n.offsets)}):null});y(this,"setViewport",n=>{if(n===null){this.cancelTransition(),ct.cancel(ts),this.snapBackDebounced.cancel(),this.app.setState({scrollConstraints:null,shouldCacheIgnoreZoom:!1});return}let{target:t,fit:o,lock:r,animation:i,viewportZoomFactor:a}=n,s=this.resolveOffsets(n.offsets),{bounds:l,type:c}=oS(t,this.app.scene.getNonDeletedElementsMap(),this.app.state);if(!l){c==="link"&&this.app.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}});return}let d=rS(this.app.state,l,{fit:o,offsets:s,lock:r,viewportZoomFactor:a}),m=L9(i),p={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom};if(this.cancelTransition(),ct.cancel(ts),this.snapBackDebounced.cancel(),m===null){this.app.setState({...d,shouldCacheIgnoreZoom:!1});return}let u={target:d};this.activeTransition=u,this.app.state.scrollConstraints&&this.app.setState({scrollConstraints:null}),_9(p,d,m,E=>{this.activeTransition===u&&this.app.setState(E)},()=>{this.activeTransition===u&&(this.activeTransition=null,this.app.setState({...u.target,shouldCacheIgnoreZoom:!1}))})});y(this,"translate",(n,t)=>{if(this.isLockedTransitionPending)return!1;this.cancelTransition(),t?.preserveScrollConstraintsSnapBack||ct.cancel(ts),this.app.setState({shouldCacheIgnoreZoom:!1}),this.app.requestUnfollow();let o=this.app.state.zoom.value;return this.app.setState(n),this.app.setState(r=>{if(!r.scrollConstraints)return null;let a=!t?.zoomPreConstrained&&r.zoom.value!==o?0:r.scrollConstraints.overscroll;return a>0&&this.snapBackDebounced(),$n(r,a)}),!0});y(this,"constrain",(n=0)=>{this.app.setState(t=>t.scrollConstraints?$n(t,n):null)});y(this,"releaseOverscroll",()=>{this.app.state.scrollConstraints&&(this.snapBackDebounced.cancel(),this.snapBack())});y(this,"snapBack",()=>{this.app.unmounted||this.dependencies.isGestureActive()||R9(this.app.state,n=>this.app.setState(t=>n(t)))});y(this,"snapBackDebounced",x9(this.snapBack,C9));y(this,"cancelTransition",()=>{this.activeTransition=null,ct.cancel(fp)});y(this,"destroy",()=>{this.cancelTransition(),ct.cancel(ts),this.snapBackDebounced.cancel()})}get isAnimating(){return ct.running(fp)||ct.running(ts)}get isLockedTransitionPending(){return!!this.activeTransition?.target.scrollConstraints}};import bp from"react";var N9=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,B9=/{{([\w-]+)}}/,F9=/<([\w-]+)>/,O9=/<\/([\w-]+)>/,z9=(e,n)=>{let t=[{name:"",children:[]}];return e.split(N9).filter(Boolean).forEach(o=>{let r=o.match(F9),i=o.match(O9),a=o.match(B9);if(r!==null){let s=r[1];n.hasOwnProperty(s)?t.push({name:s,children:[]}):console.warn(`Trans: missed to pass in prop ${s} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let l=t.pop(),c=bp.createElement(bp.Fragment,{},...l.children),d=n[l.name];typeof d=="function"&&t[t.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${o} for interpolating ${e}`);else if(a!==null){let s=a[1];n.hasOwnProperty(s)?t[t.length-1].children.push(n[s]):console.warn(`Trans: key ${s} not in props for interpolating ${e}`)}else t[t.length-1].children.push(o)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},G9=({i18nKey:e,children:n,...t})=>{let{t:o}=Ae();return bp.createElement(bp.Fragment,{},...z9(o(e),t))},fi=G9;import{jsx as yn,jsxs as sS}from"react/jsx-runtime";var H9=()=>sS("div",{"data-testid":"brave-measure-text-error",children:[yn("p",{children:yn(fi,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(fi,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>yn("span",{style:{fontWeight:600},children:e})})}),yn("p",{children:yn(fi,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>yn("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),yn("p",{children:yn(fi,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>yn("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>sS("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),lS=H9;import Z9 from"clsx";import $9 from"react";import{useLayoutEffect as U9,useRef as cS,useEffect as dS}from"react";import{unstable_batchedUpdates as W9}from"react-dom";import{KEYS as V9,queryFocusableElements as Y9}from"@excalidraw/common";import{clamp as mS}from"@excalidraw/math";import K9 from"clsx";import{jsx as X9}from"react/jsx-runtime";var Ir=10,pS=({children:e,left:n,top:t,onCloseRequest:o,fitInViewport:r=!1,viewportWidth:i=window.innerWidth,viewportHeight:a=window.innerHeight,className:s})=>{let l=cS(null);dS(()=>{let d=l.current;if(!d)return;d.contains(document.activeElement)||d.focus();let m=p=>{if(p.key===V9.TAB){let u=Y9(d),{activeElement:E}=document,g=u.findIndex(b=>b===E);E===d?(p.shiftKey?u[u.length-1]?.focus():u[0].focus(),p.preventDefault(),p.stopImmediatePropagation()):g===0&&p.shiftKey?(u[u.length-1]?.focus(),p.preventDefault(),p.stopImmediatePropagation()):g===u.length-1&&!p.shiftKey&&(u[0]?.focus(),p.preventDefault(),p.stopImmediatePropagation())}};return d.addEventListener("keydown",m),()=>d.removeEventListener("keydown",m)},[]);let c=cS(null);return U9(()=>{if(r&&l.current&&t!=null&&n!=null){let d=l.current,{width:m,height:p}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===n)return;c.current={top:t,left:n};let u=Math.max(0,i-Ir*2);m>=u?(d.style.width=`${u}px`,d.style.left=`${Ir}px`,d.style.overflowX="scroll"):d.style.left=`${mS(n,Ir,i-Ir-m)}px`;let E=Math.max(0,a-Ir*2);p>=E?(d.style.height=`${E}px`,d.style.top=`${Ir}px`,d.style.overflowY="scroll"):d.style.top=`${mS(t,Ir,a-Ir-p)}px`}},[t,n,r,i,a]),dS(()=>{if(o){let d=m=>{l.current?.contains(m.target)||W9(()=>o(m))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[o]),X9("div",{className:K9("popover",s),ref:l,tabIndex:-1,children:e})};import{jsx as Bo,jsxs as hS}from"react/jsx-runtime";var He="separator",uS=e=>"onSelect"in e,gS=$9.memo(({actionManager:e,items:n,top:t,left:o,onClose:r})=>{let i=ro(),a=qi(),s=n.reduce((l,c)=>c?c===He||uS(c)?(l.push(c),l):((!c.predicate||c.predicate(a,i,e.app.props,e.app))&&l.push(c),l):l,[]);return Bo(pS,{onCloseRequest:()=>{r()},top:t,left:o,fitInViewport:!0,viewportWidth:i.width,viewportHeight:i.height,className:"context-menu-popover",children:Bo("ul",{className:"context-menu",onContextMenu:l=>l.preventDefault(),children:s.map((l,c)=>{if(l===He)return!s[c-1]||s[c-1]===He?null:Bo("hr",{className:"context-menu-item-separator"},c);if(uS(l))return Bo("li",{"data-testid":l.key,onClick:()=>{r(()=>{l.onSelect()})},children:hS("button",{type:"button",className:"context-menu-item",children:[Bo("div",{className:"context-menu-item__label",children:l.label}),Bo("kbd",{className:"context-menu-item__shortcut"})]})},l.key);let d=l.name,m="";return l.label&&(typeof l.label=="function"?m=f(l.label(a,i,e.app)):m=f(l.label)),Bo("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(l,"contextMenu")})},children:hS("button",{type:"button",className:Z9("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:l.checked?.(i)}),children:[Bo("div",{className:"context-menu-item__label",children:m}),Bo("kbd",{className:"context-menu-item__shortcut",children:d?Je(d):""})]})},c)})})})});import{useId as j9}from"react";import q9 from"clsx";import{Fragment as J9,jsx as ec,jsxs as fS}from"react/jsx-runtime";var xp=({border:e,style:n})=>ec("div",{className:"viewport-status-frame__border",style:{borderColor:e,...n}}),yp=({label:e,border:n})=>{let t=j9(),o=fS(J9,{children:[e.icon&&ec("span",{className:"viewport-status-frame__badge-icon",children:e.icon}),e.label]});return fS("div",{className:q9("viewport-status-frame__badge",{"viewport-status-frame__badge--clickable":e.onClick}),role:"status",style:{"--viewport-status-frame-badge-background":e.background||n||"var(--color-primary)",color:e.color},children:[e.onClick&&ec("button",{type:"button",className:"viewport-status-frame__badge-action","aria-labelledby":t,onClick:e.onClick}),ec("div",{className:"viewport-status-frame__badge-label",id:e.onClick?t:void 0,children:o}),e.onClose&&ec("button",{type:"button",className:"viewport-status-frame__badge-close","aria-label":f("buttons.close"),onClick:e.onClose,children:an})]})};import gs from"clsx";import SV from"react";import{CLASSES as CV,TOOL_TYPE as Wk,arrayToMap as PV,isShallowEqual as nu}from"@excalidraw/common";import{mutateElement as kV,ShapeCache as MV}from"@excalidraw/element";import{showSelectedShapeActions as AV}from"@excalidraw/element";import{createIsolation as Q9}from"jotai-scope";import pE from"react";import Fo from"tunnel-rat";var uE=pE.createContext(null),it=()=>pE.useContext(uE),ez=Q9(),ES=()=>pE.useMemo(()=>({MainMenuTunnel:Fo(),WelcomeScreenMenuHintTunnel:Fo(),WelcomeScreenToolbarHintTunnel:Fo(),WelcomeScreenHelpHintTunnel:Fo(),WelcomeScreenCenterTunnel:Fo(),FooterCenterTunnel:Fo(),DefaultSidebarTriggerTunnel:Fo(),DefaultSidebarTabTriggersTunnel:Fo(),OverwriteConfirmDialogTunnel:Fo(),tunnelsJotai:ez}),[]);import Sr from"clsx";import{useRef as cz}from"react";import{Popover as Tr}from"radix-ui";import{CLASSES as kS}from"@excalidraw/common";import{isArrowElement as PS}from"@excalidraw/element";import{forwardRef as bS}from"react";import xS from"clsx";import{jsx as yS}from"react/jsx-runtime";var tz=bS(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>yS("div",{className:xS("Stack Stack_horizontal",r),style:{"--gap":n,alignItems:t,justifyContent:o,...i},ref:a,children:e})),nz=bS(({children:e,gap:n,align:t,justifyContent:o,className:r,style:i},a)=>yS("div",{className:xS("Stack Stack_vertical",r),style:{"--gap":n,justifyItems:t,justifyContent:o,...i},ref:a,children:e})),Ft={Row:tz,Col:nz};import{isTransparent as wS}from"@excalidraw/common";import{shouldAllowVerticalAlign as oz,suppportsHorizontalAlign as rz,hasBoundTextElement as vS,isElbowArrow as iz,isImageElement as IS,isLinearElement as az,isTextElement as sz,hasStrokeColor as TS,toolIsArrow as lz}from"@excalidraw/element";var SS=(e,n)=>{let t=n[0]?.type||null;for(let o of n)if(o.type!==t){t=null;break}return TS(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||n.some(o=>TS(o.type))},CS=(e,n)=>Xo(e.activeTool.type)||n.some(t=>Xo(t.type)),wp=(e,n,t,o)=>{let r=e.activeTool.type,i=d=>d(r)||n.some(m=>d(m.type)),a=n.length===1,s=n.length===2&&(vS(n[0])||vS(n[1])),l=!!(e.editingTextElement||e.newElement),c=n.length>0;return{hasSelection:c,showExtraActions:c&&!l,strokeColor:SS(e,n),backgroundColor:CS(e,n),fill:r==="bucketfill"||Xo(r)&&!wS(e.currentItemBackgroundColor)||n.some(d=>Xo(d.type)&&!wS(d.backgroundColor)),strokeWidth:i(gx),freedrawMode:i(fx),strokeStyle:i(Lu),sloppiness:i(Lu),roundness:i(Ex),arrowType:i(lz),arrowheads:i(Ss),text:r==="text"||n.some(sz),textAlign:r==="text"||rz(n,t),verticalAlign:oz(n,t),opacity:r!=="autoshape"||c,layers:r!=="freedraw"&&r!=="autoshape"&&!n.some(d=>d.type==="freedraw")||de(t,e).some(d=>d.type==="freedraw"),align:!s&&lt(e,o),distribute:n.length>2,imageLayout:n.length>1&&n.every(IS)&&lt(e,o),link:a||s,linkSingleOnly:a,cropEditor:!e.croppingElementId&&a&&IS(n[0]),lineEditor:!e.selectedLinearElement?.isEditing&&a&&az(n[0])&&!iz(n[0])}};import{Fragment as en,jsx as q,jsxs as Te}from"react/jsx-runtime";var hE=Sr([kS.SHAPE_ACTIONS_THEME_SCOPE,"properties-content"]),MS=({renderAction:e})=>Te("fieldset",{children:[q("legend",{children:f("labels.layers")}),Te("div",{className:"buttonList",children:[e("sendToBack"),e("sendBackward"),e("bringForward"),e("bringToFront")]})]}),AS=({renderAction:e,showDistribute:n,showImageLayout:t})=>{let o=document.documentElement.getAttribute("dir")==="rtl";return Te("fieldset",{className:"align-fieldset","aria-label":f("labels.align"),children:[Te("div",{className:"align-fieldset-header",children:[q("span",{className:"align-fieldset-label",children:f("labels.align")}),e("toggleAlignStacking")]}),Te("div",{className:"buttonList",children:[o?Te(en,{children:[e("alignRight"),e("alignHorizontallyCentered"),e("alignLeft")]}):Te(en,{children:[e("alignLeft"),e("alignHorizontallyCentered"),e("alignRight")]}),n&&e("distributeHorizontally"),q("div",{style:{flexBasis:"100%",height:0}}),Te("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[e("alignTop"),e("alignVerticallyCentered"),e("alignBottom"),n&&e("distributeVertically")]}),t&&Te(en,{children:[q("div",{style:{flexBasis:"100%",height:0}}),e("arrangeElements"),e("normaliseElements")]})]})]})},DS=({appState:e,elementsMap:n,renderAction:t,app:o})=>{let r=Ri(n,e),i=wp(e,r,n,o);return e.activeTool.type==="bucketfill"?Te("div",{className:"selected-shape-actions",children:[q("div",{children:t("changeBucketFillBackgroundColor")}),t("changeFillStyle"),t("changeOpacity")]}):Te("div",{className:"selected-shape-actions",children:[q("div",{children:i.strokeColor&&t("changeStrokeColor")}),i.backgroundColor&&q("div",{children:t("changeBackgroundColor")}),i.fill&&t("changeFillStyle"),i.strokeWidth&&t("changeStrokeWidth"),i.strokeStyle&&q(en,{children:t("changeStrokeStyle")}),i.freedrawMode&&t("changeFreedrawMode"),i.sloppiness&&q(en,{children:t("changeSloppiness")}),i.roundness&&q(en,{children:t("changeRoundness")}),i.arrowType&&q(en,{children:t("changeArrowType")}),i.text&&Te(en,{children:[q("fieldset",{children:t("changeFontFamily")}),t("changeFontSize"),i.textAlign&&t("changeTextAlign")]}),i.verticalAlign&&t("changeVerticalAlign"),i.arrowheads&&q(en,{children:t("changeArrowhead")}),i.opacity&&t("changeOpacity"),i.layers&&q(MS,{renderAction:t}),i.align&&q(AS,{renderAction:t,showDistribute:i.distribute,showImageLayout:i.imageLayout}),i.showExtraActions&&Te("fieldset",{children:[q("legend",{children:f("labels.actions")}),Te("div",{className:"buttonList",children:[t("duplicateSelection"),t("deleteSelectedElements"),t("group"),t("ungroup"),i.link&&t("hyperlink"),i.cropEditor&&t("cropEditor"),i.lineEditor&&t("toggleLinearEditor"),t("smartZoom")]})]})]})},LS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let i=o.hasSelection||e.activeTool.type!=="selection"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser"&&e.activeTool.type!=="lasso",a=e.openPopup==="compactStrokeStyles";return i?q("div",{className:"compact-action-item",children:Te(Tr.Root,{open:a,onOpenChange:s=>{t(s?{openPopup:"compactStrokeStyles"}:{openPopup:null})},children:[q(Tr.Trigger,{asChild:!0,children:q("button",{type:"button",className:Sr("compact-action-button properties-trigger",{active:a}),title:f("labels.stroke"),onClick:s=>{s.preventDefault(),s.stopPropagation(),t({openPopup:a?null:"compactStrokeStyles"})},children:I0})}),a&&q(Co,{className:hE,container:r,style:{maxWidth:"13rem"},onClose:()=>{},children:Te("div",{className:"selected-shape-actions",children:[o.fill&&n("changeFillStyle"),o.strokeWidth&&n("changeStrokeWidth"),o.freedrawMode&&n("changeFreedrawMode"),o.strokeStyle&&q(en,{children:n("changeStrokeStyle")}),o.sloppiness&&q(en,{children:n("changeSloppiness")}),o.roundness&&n("changeRoundness"),o.opacity&&n("changeOpacity")]})})]})}):null},_S=({appState:e,renderAction:n,setAppState:t,targetElements:o,predicates:r,container:i,app:a})=>{if(!r.arrowType)return null;let s=e.openPopup==="compactArrowProperties";return q("div",{className:"compact-action-item",children:Te(Tr.Root,{open:s,onOpenChange:l=>{t(l?{openPopup:"compactArrowProperties"}:{openPopup:null})},children:[q(Tr.Trigger,{asChild:!0,children:q("button",{type:"button",className:Sr("compact-action-button properties-trigger",{active:s}),title:f("labels.arrowtypes"),onClick:l=>{l.preventDefault(),l.stopPropagation(),t({openPopup:s?null:"compactArrowProperties"})},children:(()=>{let l=ut(o,a,c=>PS(c)?c.elbowed?"elbow":c.roundness?"round":"sharp":null,c=>PS(c),c=>c?null:e.currentItemArrowType);return l==="elbow"?er:l==="round"?tr:Qo})()})}),s&&q(Co,{container:i,className:"properties-content",style:{maxWidth:"13rem"},onClose:()=>{},children:n("changeArrowProperties")})]})})},RS=({appState:e,renderAction:n,setAppState:t,predicates:o,container:r})=>{let{saveCaretPosition:i,restoreCaretPosition:a}=K0(),s=e.openPopup==="compactTextProperties";return q("div",{className:"compact-action-item",children:Te(Tr.Root,{open:s,onOpenChange:l=>{l?(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"})):(t({openPopup:null}),e.editingTextElement&&a())},children:[q(Tr.Trigger,{asChild:!0,children:q("button",{type:"button",className:Sr("compact-action-button properties-trigger",{active:s}),title:f("labels.textAlign"),onClick:l=>{l.preventDefault(),l.stopPropagation(),s?t({openPopup:null}):(e.editingTextElement&&i(),t({openPopup:"compactTextProperties"}))},children:$x})}),e.openPopup==="compactTextProperties"&&q(Co,{className:hE,container:r,style:{maxWidth:"13rem"},preventAutoFocusOnTouch:!!e.editingTextElement,onClose:()=>{e.editingTextElement&&a()},children:Te("div",{className:"selected-shape-actions",children:[o.text&&n("changeFontSize"),o.textAlign&&n("changeTextAlign"),o.verticalAlign&&n("changeVerticalAlign")]})})]})})},NS=({appState:e,renderAction:n,predicates:t,setAppState:o,container:r,showDuplicate:i,showDelete:a})=>{let s=e.openPopup==="compactOtherProperties";return t.showExtraActions?q("div",{className:"compact-action-item",children:Te(Tr.Root,{open:s,onOpenChange:l=>{o(l?{openPopup:"compactOtherProperties"}:{openPopup:null})},children:[q(Tr.Trigger,{asChild:!0,children:q("button",{type:"button",className:Sr("compact-action-button properties-trigger",{active:s}),title:f("labels.actions"),onClick:l=>{l.preventDefault(),l.stopPropagation(),o({openPopup:s?null:"compactOtherProperties"})},children:Ux})}),s&&q(Co,{className:hE,container:r,style:{maxWidth:"12rem",justifyContent:"center",alignItems:"center"},onClose:()=>{},children:Te("div",{className:"selected-shape-actions",children:[t.layers&&q(MS,{renderAction:n}),t.align&&q(AS,{renderAction:n,showDistribute:t.distribute,showImageLayout:t.imageLayout}),Te("fieldset",{children:[q("legend",{children:f("labels.actions")}),Te("div",{className:"buttonList",children:[n("group"),n("ungroup"),t.linkSingleOnly&&n("hyperlink"),t.cropEditor&&n("cropEditor"),n("smartZoom"),i&&n("duplicateSelection"),a&&n("deleteSelectedElements")]})]})]})})]})}):null},dz=({renderAction:e,predicates:n})=>n.lineEditor?q("div",{className:"compact-action-item",children:e("toggleLinearEditor")}):null,BS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Ri(n,e),a=wp(e,i,n,o),{container:s}=ze();return Te("div",{className:"compact-shape-actions",children:[a.strokeColor&&q("div",{className:Sr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),a.freedrawMode&&q("div",{className:"compact-action-item",children:t("changeFreedrawMode",{cycle:!0})}),q(LS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(_S,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),a.lineEditor&&q("div",{className:"compact-action-item",children:t("toggleLinearEditor")}),a.text&&Te(en,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(RS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),a.showExtraActions&&q("div",{className:"compact-action-item",children:t("duplicateSelection")}),a.showExtraActions&&q("div",{className:"compact-action-item",children:t("deleteSelectedElements")}),q(NS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s})]})},FS=({appState:e,elementsMap:n,renderAction:t,app:o,setAppState:r})=>{let i=Ri(n,e),a=wp(e,i,n,o),{container:s}=ze(),l=cz(null),c=l.current?.getBoundingClientRect()?.width??0,d=9,m=6,p=32,u=d*p+(d-1)*m,E=p+m,g=c>=u+E,b=c>=u+2*E;return Te(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:[Te("div",{style:{display:"flex",flexDirection:"row",gap:m,flex:1},children:[a.strokeColor&&q("div",{className:Sr("compact-action-item"),children:t("changeStrokeColor")}),a.backgroundColor&&q("div",{className:"compact-action-item",children:t(e.activeTool.type==="bucketfill"?"changeBucketFillBackgroundColor":"changeBackgroundColor")}),q(LS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s}),q(_S,{appState:e,renderAction:t,setAppState:r,targetElements:i,predicates:a,container:s,app:o}),q(dz,{renderAction:t,predicates:a}),a.text&&Te(en,{children:[q("div",{className:"compact-action-item",children:t("changeFontFamily")}),q(RS,{appState:e,renderAction:t,setAppState:r,predicates:a,container:s})]}),q(NS,{appState:e,renderAction:t,predicates:a,setAppState:r,container:s,showDuplicate:!b,showDelete:!g})]}),Te("div",{style:{display:"flex",flexDirection:"row",gap:m},children:[q("div",{className:"compact-action-item",children:t("undo")}),q("div",{className:"compact-action-item",children:t("redo")}),b&&q("div",{className:"compact-action-item",children:t("duplicateSelection")}),g&&q("div",{className:"compact-action-item",children:t("deleteSelectedElements")})]})]})},OS=({renderAction:e})=>q(Ft.Col,{gap:1,className:kS.ZOOM_ACTIONS,children:Te(Ft.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),zS=({renderAction:e,className:n})=>Te("div",{className:`undo-redo-buttons ${n}`,children:[q("div",{className:"undo-button-container",children:q(ht,{label:f("buttons.undo"),children:e("undo")})}),q("div",{className:"redo-button-container",children:Te(ht,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),GS=({showExitZenModeBtn:e})=>q("button",{type:"button",className:Sr("disable-zen-mode",{"disable-zen-mode--visible":e}),children:f("buttons.exitZenMode")});import mz from"clsx";import{useState as pz,useEffect as uz}from"react";import{THEME as hz}from"@excalidraw/common";import{jsx as gE,jsxs as gz}from"react/jsx-runtime";var vp=({delay:e,theme:n})=>{let[t,o]=pz(!!e);return uz(()=>{if(!e)return;let r=setTimeout(()=>{o(!1)},e);return()=>clearTimeout(r)},[e]),t?null:gz("div",{className:mz("LoadingMessage",{"LoadingMessage--dark":n===hz.DARK}),children:[gE("div",{children:gE(So,{})}),gE("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import{useState as Cp,useEffect as lC}from"react";import Vz from"clsx";import{KEYS as xE,capitalizeString as cC}from"@excalidraw/common";import sC from"react";import{DropdownMenu as Gz}from"radix-ui";import{CLASSES as Hz}from"@excalidraw/common";import fz from"clsx";import{useCallback as Ez,useEffect as bz,useRef as xz}from"react";import{CLASSES as yz,EVENT as HS,KEYS as wz}from"@excalidraw/common";import{DropdownMenu as vz}from"radix-ui";import{jsx as Ip}from"react/jsx-runtime";var US=({children:e,onClickOutside:n,className:t="",onSelect:o,open:r=!0,align:i="end",style:a})=>{let s=fe(),l=xz(null),c=ji({onClickOutside:n});$i(l,Ez(m=>{l.current?.closest(`.${yz.DROPDOWN_MENU_EVENT_WRAPPER}`)?.contains(m.target)||c.onClickOutside?.()},[c])),bz(()=>{if(!r)return;let m=u=>{u.key===wz.ESCAPE&&(u.preventDefault(),u.stopImmediatePropagation(),c.onClickOutside?.())},p={capture:!0};return document.addEventListener(HS.KEYDOWN,m,p),()=>{document.removeEventListener(HS.KEYDOWN,m,p)}},[c,r]);let d=fz(`dropdown-menu ${t}`,{"dropdown-menu--mobile":s.formFactor==="phone"}).trim();return Ip(Fh.Provider,{value:{onSelect:o},children:Ip(vz.Content,{ref:l,className:d,style:a,"data-testid":"dropdown-menu",align:i,sideOffset:8,onCloseAutoFocus:m=>m.preventDefault(),children:s.formFactor==="phone"?Ip(Ft.Col,{className:"dropdown-menu-container",children:e}):Ip(Ze,{className:"dropdown-menu-container",padding:2,children:e})})})};US.displayName="DropdownMenuContent";var WS=US;import{jsx as Tz}from"react/jsx-runtime";var Iz=({children:e,className:n="",selected:t,...o})=>Tz("div",{...o,className:`dropdown-menu-item-base dropdown-menu-item-custom ${n} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),VS=Iz;import{DropdownMenu as Sz}from"radix-ui";import{jsx as fE}from"react/jsx-runtime";var YS=({icon:e,shortcut:n,href:t,children:o,onSelect:r,className:i="",selected:a,rel:s="noopener",...l})=>{let c=Td(r);return fE(Sz.Item,{className:"radix-menu-item",onSelect:c,asChild:!0,children:fE("a",{...l,href:t,target:"_blank",rel:`noopener ${s}`,className:ir(i,a),title:l.title??l["aria-label"],children:fE(ar,{icon:e,shortcut:n,children:o})})})},ns=YS;YS.displayName="DropdownMenuItemLink";import{jsx as Cz}from"react/jsx-runtime";var KS=()=>Cz("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:"6px 0",flex:"0 0 auto"}}),XS=KS;KS.displayName="DropdownMenuSeparator";import{DropdownMenu as _z}from"radix-ui";import Pz from"clsx";import{DropdownMenu as kz}from"radix-ui";import{useCallback as Mz,useState as ZS}from"react";import{jsx as bE}from"react/jsx-runtime";var EE=-4,Az=4,$S=({children:e,className:n})=>{let t=fe(),o=Pz(`dropdown-menu dropdown-submenu ${n}`,{"dropdown-menu--mobile":t.formFactor==="phone"}).trim(),r=Mz(c=>{if(c){let m=c.closest(".dropdown-menu-container")?.getBoundingClientRect();if(m){let p=c.getBoundingClientRect().width,E=window.innerWidth-m.right;E<p+20&&(a(E-p+EE),l(EE+8))}}},[]),[i,a]=ZS(Az),[s,l]=ZS(EE);return bE(kz.SubContent,{className:o,sideOffset:i,alignOffset:s,collisionPadding:8,ref:r,children:t.formFactor==="phone"?bE(Ft.Col,{className:"dropdown-menu-container",children:e}):bE(Ze,{className:"dropdown-menu-container",padding:2,style:{zIndex:1},children:e})})},jS=$S;$S.displayName="DropdownMenuSubContent";import{DropdownMenu as Dz}from"radix-ui";import{jsx as qS,jsxs as Lz}from"react/jsx-runtime";var JS=({children:e,icon:n,shortcut:t,className:o})=>Lz(Dz.SubTrigger,{className:`${ir(o)} dropdown-menu__submenu-trigger`,children:[qS(ar,{icon:n,shortcut:t,children:e}),qS("div",{className:"dropdown-menu__submenu-trigger-icon",children:C0})]}),QS=JS;JS.displayName="DropdownMenuSubTrigger";import eC from"react";var Tp=e=>n=>{let t=eC.Children.toArray(n).find(o=>eC.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName===e);return t||null},tC=Tp("DropdownMenuTrigger"),nC=Tp("DropdownMenuContent"),oC=Tp("DropdownMenuSubTrigger"),rC=Tp("DropdownMenuSubContent");import{jsxs as Rz}from"react/jsx-runtime";var Sp=({children:e})=>{let n=oC(e),t=rC(e);return Rz(_z.Sub,{children:[n,t]})};Sp.Trigger=QS;Sp.Content=jS;Sp.displayName="DropdownMenuSub";var Cr=Sp;import Nz from"clsx";import{DropdownMenu as Bz}from"radix-ui";import{jsx as Fz}from"react/jsx-runtime";var iC=({className:e="",children:n,onToggle:t,title:o,...r})=>{let i=fe(),a=Nz(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.formFactor==="phone"}).trim();return Fz(Bz.Trigger,{className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:o,...r,children:n})},aC=iC;iC.displayName="DropdownMenuTrigger";import{jsx as zz}from"react/jsx-runtime";var Oz=e=>zz(Jt,{...e,icon:e.checked?$c:nd}),uo=Oz;import{jsx as Wz,jsxs as Uz}from"react/jsx-runtime";var Hn=({children:e,open:n})=>{let t=tC(e),o=nC(e),r=o&&sC.isValidElement(o)?sC.cloneElement(o,{open:n}):o;return Wz(Gz.Root,{open:n,modal:!1,children:Uz("div",{className:Hz.DROPDOWN_MENU_EVENT_WRAPPER,style:{display:"contents"},children:[t,r]})})};Hn.Trigger=aC;Hn.Content=WS;Hn.Item=Jt;Hn.ItemCheckbox=uo;Hn.ItemLink=ns;Hn.ItemCustom=VS;Hn.Group=Zs;Hn.Separator=XS;Hn.Sub=Cr;var ge=Hn;Hn.displayName="DropdownMenu";import{Fragment as yE,jsx as Fe,jsxs as os}from"react/jsx-runtime";var Yz=({actionManager:e,app:n})=>{if(!e.isActionEnabled(_t))return null;let t=f("buttons.objectsSnapMode");return Fe($,{type:"toggle",icon:Jo,checked:n.state.objectsSnapModeEnabled,title:t,"aria-label":t,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(_t,"ui")})},Kz=({app:e})=>Fe($,{type:"button",icon:Ki,title:f("labels.eyeDropper"),"aria-label":f("labels.eyeDropper"),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),dC=({app:e,actionManager:n,setAppState:t})=>{let o=e.state.activeTool,r=e.state.myocSimplifiedMode,i=e.props.UIOptions.tools?.image!==!1,[a,s]=Cp(!1),[l,c]=Cp("rectangle"),[d,m]=Cp("arrow");lC(()=>{(o.type==="rectangle"||o.type==="diamond"||o.type==="ellipse")&&c(o.type)},[o.type]),lC(()=>{(o.type==="arrow"||o.type==="line")&&m(o.type)},[o.type]);let p=o.type==="frame",u=o.type==="autoshape",E=o.type==="laser",g=o.type==="embeddable",b=o.type==="bucketfill",v=["rectangle","diamond","ellipse"].map(G=>({type:G,icon:Be[G].icon,title:cC(f(`toolBar.${G}`)),fillable:Be[G].fillable})),w=["arrow","line"].map(G=>({type:G,icon:Be[G].icon,title:cC(f(`toolBar.${G}`)),fillable:Be[G].fillable})),[x,I]=Cp(0),T=36,C=4,P=7,M=P*T+(P-1)*C,D=T+C,_=x>=M+1*D,k=i&&x>=M+2*D,L=x>=M+3*D,F=(r?["text","image"]:["text","image","frame","embeddable","laser","bucketfill"]).filter(G=>!(_&&G==="text"||(!i||k)&&G==="image"||L&&G==="frame")),K=r&&dr.includes(o.type),z=K||F.includes(o.type),U=z?K?Be[o.type].icon:o.type==="text"?Dn:o.type==="image"?Wr:o.type==="frame"?to:o.type==="embeddable"?qo:o.type==="laser"?no:o.type==="bucketfill"?eo:Ls:Ls,W={app:e,activeTool:o,hideShortcut:!0};return os("div",{className:"mobile-toolbar",ref:G=>{G&&I(G.getBoundingClientRect().width)},children:[Fe(Xd,{...W}),Fe(Zd,{...W,setAppState:t}),r?Fe(ol,{...W}):Fe($d,{...W}),Fe(al,{...W}),!r&&Fe(la,{app:e,options:v,activeTool:o,defaultOption:l,"data-testid":"toolbar-rectangle",onToolChange:G=>{(G==="rectangle"||G==="diamond"||G==="ellipse")&&(c(G),e.setActiveTool({type:G}))},displayedOption:v.find(G=>G.type===l)||v[0]}),!r&&Fe(la,{app:e,options:w,activeTool:o,defaultOption:d,"data-testid":"toolbar-arrow",onToolChange:G=>{(G==="arrow"||G==="line")&&(m(G),e.setActiveTool({type:G}))},displayedOption:w.find(G=>G.type===d)||w[0]}),_&&Fe(rl,{...W}),r&&k&&Fe(Kz,{app:e}),k&&Fe(il,{...W}),!r&&L&&Fe(lw,{...W,hideShortcut:!0}),os(ge,{open:a,children:[Fe(ge.Trigger,{className:Vz("App-toolbar__extra-tools-trigger App-toolbar__extra-tools-trigger--mobile",{"App-toolbar__extra-tools-trigger--selected":z||a}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),style:{width:T,height:T,display:"flex",alignItems:"center",justifyContent:"center"},children:U}),os(ge.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",align:"start",children:[r&&dr.map(G=>Fe(ge.Item,{onSelect:()=>e.setActiveTool({type:G}),icon:Be[G].icon,"data-testid":`toolbar-${G}`,selected:o.type===G,shortcut:Kd(G),disabled:tt(e,G),children:f(`toolBar.${G}`)},G)),!r&&Fe("div",{className:"App-toolbar__dropdown-divider"}),!r&&n.isActionEnabled(_t)&&Fe(ge.Item,{onSelect:()=>n.executeAction(_t,"ui"),icon:Jo,"data-testid":"toolbar-objects-snap-mode",selected:e.state.objectsSnapModeEnabled,shortcut:Je("objectsSnapMode"),children:f("buttons.objectsSnapMode")}),e.props.activeTool==null&&os(yE,{children:[r&&Fe("div",{className:"App-toolbar__dropdown-divider"}),Fe(ge.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?$o:To,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:xE.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")})]}),!_&&Fe(ge.Item,{onSelect:()=>e.setActiveTool({type:"text"}),icon:Dn,shortcut:xE.T.toLocaleUpperCase(),"data-testid":"toolbar-text",selected:o.type==="text",disabled:tt(e,"text"),children:f("toolBar.text")}),i&&!k&&Fe(ge.Item,{onSelect:()=>e.setActiveTool({type:"image"}),icon:Wr,"data-testid":"toolbar-image",selected:o.type==="image",disabled:tt(e,"image"),children:f("toolBar.image")}),!r&&!L&&Fe(ge.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:to,shortcut:xE.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:p,disabled:tt(e,"frame"),children:f("toolBar.frame")}),!r&&os(yE,{children:[Fe(ge.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:qo,"data-testid":"toolbar-embeddable",selected:g,disabled:tt(e,"embeddable"),children:f("toolBar.embeddable")}),Fe(ge.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Kr,shortcut:mr("autoshape"),"data-testid":"toolbar-autoshape",selected:u,disabled:tt(e,"autoshape"),children:f("toolBar.autoshape")}),Fe(ge.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:no,"data-testid":"toolbar-laser",selected:E,disabled:tt(e,"laser"),children:f("toolBar.laser")}),Fe(ge.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:eo,"data-testid":"toolbar-bucketfill",selected:b,disabled:tt(e,"bucketfill"),children:f("toolBar.bucketfill")})]})]})]}),r&&os(yE,{children:[Fe("div",{className:"App-toolbar__divider"}),Fe(Yz,{actionManager:n,app:e})]})]})};import Xz from"clsx";import{jsx as Zz}from"react/jsx-runtime";var Pp=({children:e,side:n,className:t})=>Zz("div",{className:Xz("FixedSideContainer",`FixedSideContainer_side_${n}`,t),children:e});import $z from"clsx";import{jsx as jz}from"react/jsx-runtime";var rs=e=>e.penDetected?jz($,{className:$z("ToolIcon__penMode",{"is-mobile":e.isMobile}),type:"toggle",icon:Zx,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,onSelect:()=>e.onChange?.()}):null;import{Fragment as mC,jsx as It,jsxs as Ei}from"react/jsx-runtime";var pC=({appState:e,elements:n,actionManager:t,setAppState:o,renderTopLeftUI:r,renderTopRightUI:i,renderSidebars:a,renderWelcomeScreen:s,defaultUIEnabled:l,scrollBackToContentUIEnabled:c,app:d,onPenModeToggle:m})=>{let{WelcomeScreenCenterTunnel:p,MainMenuTunnel:u,DefaultSidebarTriggerTunnel:E}=it(),g=()=>{if(e.openDialog?.name==="elementLinkSelector")return null;let P=It("div",{className:"excalidraw-ui-top-right",children:i?.(!0,e)??(!e.viewModeEnabled&&Ei(mC,{children:[l&&It(rs,{checked:e.penMode,onChange:()=>m(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),It(E.Out,{})]}))}),M=Ei("div",{className:"excalidraw-ui-top-left",children:[r?.(!0,e),It(u.Out,{})]});return Ei("div",{className:"App-toolbar-content",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[M,P]})},b=()=>It(dC,{app:d,actionManager:t,setAppState:o}),v=c&&e.scrolledOutside,w=l,x=l&&(!e.viewModeEnabled||w),I=v&&!e.openMenu&&!e.openSidebar?It("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(P=>({..._i(n,P)}))},children:f("buttons.scrollBackToContent")}):null,T=d.props.viewportStatusFrame?.label,C=T?It(yp,{label:T,border:d.props.viewportStatusFrame?.border}):null;return Ei(mC,{children:[a(),It("div",{className:"App-welcome-screen",children:s&&It(p.Out,{})}),x&&Ei("div",{className:"App-bottom-bar",style:{marginBottom:fn+Ro,left:14,transform:"none"},"data-viewport-ui":"bottom",children:[I&&It("div",{className:"floating-status-stack",children:I}),Ei("div",{className:"App-bottom-bar__actions-row",children:[w&&Ei(Ze,{className:"mobile-canvas-actions",children:[!e.viewModeOnly&&It("div",{className:"view-mode-button",children:t.renderAction("viewMode")}),It("div",{className:"smart-zoom-button",children:t.renderAction("smartZoom")})]}),!e.viewModeEnabled&&It(FS,{appState:e,elementsMap:d.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:d,setAppState:o})]}),!e.viewModeEnabled&&It(Ze,{className:"App-toolbar",style:{justifyContent:"flex-start"},children:e.openDialog?.name!=="elementLinkSelector"&&b()})]}),!x&&I&&It("div",{className:"floating-status-stack",children:I}),C&&It("div",{className:"viewport-status-frame__badge-row",children:C}),It(Pp,{side:"top",className:"App-top-bar",children:g()})]})};import xC,{useLayoutEffect as yC,useRef as wC,useState as vC}from"react";import{newTextElement as IC}from"@excalidraw/element";import oG from"clsx";import{useEffect as rG,useState as iG}from"react";import{KEYS as aG,queryFocusableElements as EC}from"@excalidraw/common";import{useCallback as qz,useState as Jz}from"react";var uC=()=>{let[e,n]=Jz(null),t=qz(o=>n(o),[]);return[e,t]};import hC from"clsx";import{useRef as Qz}from"react";import{createPortal as eG}from"react-dom";import{KEYS as tG}from"@excalidraw/common";import{jsx as gC,jsxs as nG}from"react/jsx-runtime";var fC=e=>{let{closeOnClickOutside:n=!0}=e,t=ud({className:hC("excalidraw-modal-container",e.portalContainerClassName)}),o=Qz(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===tG.ESCAPE&&(i.preventDefault(),i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return eG(nG("div",{className:hC("Modal",e.className,{"animations-disabled":o.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,children:[gC("div",{className:"Modal__background",onClick:n?e.onCloseRequest:void 0}),gC("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as kp,jsxs as bC}from"react/jsx-runtime";function sG(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var wn=e=>{let[n,t]=uC(),[o]=iG(document.activeElement),{id:r}=ze(),i=fe().formFactor==="phone";rG(()=>{if(!n)return;let l=EC(n);setTimeout(()=>{l.length>0&&e.autofocus!==!1&&(l[1]||l[0]).focus()});let c=d=>{if(d.key===aG.TAB){let m=EC(n),{activeElement:p}=document,u=m.findIndex(E=>E===p);u===0&&d.shiftKey?(m[m.length-1].focus(),d.preventDefault()):u===m.length-1&&!d.shiftKey&&(m[0].focus(),d.preventDefault())}};return n.addEventListener("keydown",c),()=>n.removeEventListener("keydown",c)},[n,e.autofocus]);let a=Ve(),s=()=>{a({openMenu:null}),o.focus(),e.onCloseRequest()};return kp(fC,{className:oG("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:sG(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,portalContainerClassName:e.portalContainerClassName,children:bC(Ze,{ref:t,children:[e.title&&bC("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:[kp("span",{className:"Dialog__titleContent",children:e.title}),e.titleButton]}),i&&kp("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:an}),kp("div",{className:"Dialog__content",children:e.children})]})})};import{jsx as Oo,jsxs as Mp}from"react/jsx-runtime";var lG=e=>{switch(e){case"bar":return f("labels.chartType_bar");case"line":return f("labels.chartType_line");case"radar":return f("labels.chartType_radar");default:return e}},cG=e=>{let n=wC(null),[t,o]=vC(null),{theme:r}=ye();yC(()=>{if(!e.spreadsheet){o(null);return}let a=Wf(e.chartType,e.spreadsheet,0,0,e.colorSeed);if(!a){o(null),n.current?.replaceChildren();return}o(a);let s,l=n.current;return(async()=>(s=await Gr(a,{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:r==="dark"},null,{skipInliningFonts:!0}),s.querySelector(".style-fonts")?.remove(),l.replaceChildren(),l.appendChild(s)))(),()=>{l.replaceChildren()}},[e.spreadsheet,e.chartType,e.colorSeed,r]);let i=lG(e.chartType);return Mp("button",{type:"button",className:"ChartPreview","aria-label":i,onClick:()=>{t&&e.onClick(e.chartType,t)},children:[Oo("div",{className:"ChartPreview__canvas",ref:n}),Oo("div",{className:"ChartPreview__label",children:i})]})},dG=e=>{let n=wC(null),{theme:t}=ye();return yC(()=>{if(!e.rawText)return;let o=IC({text:e.rawText,x:0,y:0}),r=n.current;return(async()=>{let i=await Gr([o],{exportBackground:!1,viewBackgroundColor:"#fff",exportWithDarkMode:t==="dark"},null,{skipInliningFonts:!0});i.querySelector(".style-fonts")?.remove(),r.replaceChildren(),r.appendChild(i)})(),()=>{r.replaceChildren()}},[e.rawText,t]),Mp("button",{type:"button",className:"ChartPreview","aria-label":f("labels.chartType_plaintext"),onClick:()=>{e.onClick(e.rawText)},children:[Oo("div",{className:"ChartPreview__canvas",ref:n}),Oo("div",{className:"ChartPreview__label",children:f("labels.chartType_plaintext")})]})},TC=({data:e,rawText:n,onClose:t})=>{let{onInsertElements:o,focusContainer:r}=xt(),[i,a]=vC(Math.random()),s=xC.useCallback(()=>{a(Math.random())},[]),l=xC.useCallback(()=>{t&&t()},[t]),c=(m,p)=>{o(p),We("paste","chart",m),t(),r()},d=m=>{let p=IC({text:m,x:0,y:0});o([p]),We("paste","chart","plaintext"),t(),r()};return Oo(wn,{size:"regular",onCloseRequest:l,title:Mp("div",{className:"PasteChartDialog__title",children:[Oo("div",{className:"PasteChartDialog__titleText",children:f("labels.pasteCharts")}),Oo("div",{className:"PasteChartDialog__reshuffleBtn",onClick:s,role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),s())},children:eo})]}),className:"PasteChartDialog",autofocus:!1,children:Mp("div",{className:"container",children:[["bar","line","radar"].map(m=>Ha(e,m)?Oo(cG,{chartType:m,spreadsheet:e,colorSeed:i,onClick:c},m):null),n&&Oo(dG,{rawText:n,onClick:d})]})})};import{Fragment as mG,jsx as SC,jsxs as pG}from"react/jsx-runtime";var tc=({heading:e,children:n,...t})=>{let{id:o}=ze(),r=SC("h2",{className:"visually-hidden",id:`${o}-${e}-title`,children:f(`headings.${e}`)});return SC("section",{...t,"aria-labelledby":`${o}-${e}-title`,children:typeof n=="function"?n(r):pG(mG,{children:[r,n]})})};import{Popover as nc}from"radix-ui";import CC from"clsx";import Ap,{useLayoutEffect as uG}from"react";import{supportsResizeObserver as hG,isShallowEqual as gG}from"@excalidraw/common";import{Fragment as IE,jsx as Tt,jsxs as is}from"react/jsx-runtime";var fG=4,EG=8,wE=38,PC=21,bG=({shouldWrap:e,children:n,username:t})=>e?Tt(ht,{label:t||"Unknown user",children:n}):Tt(IE,{children:n}),vE=({actionManager:e,collaborator:n,socketId:t,withName:o=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:n,withName:o,isBeingFollowed:i},s=e.renderAction("goToCollaborator",a);return Tt(bG,{username:n.username,shouldWrap:r,children:s},t)},xG=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted","isCurrentUser"],Dp=Ap.memo(({className:e,mobile:n,collaborators:t,userToFollow:o,currentUserControls:r})=>{let i=at(),a=typeof r=="function"?r(!!n):r,s=Array.from(t,([C,P])=>({...P,socketId:C})).filter(C=>C.username?.trim()),l=s.find(C=>C.isCurrentUser),c=s.filter(C=>!C.isCurrentUser),[d,m]=Ap.useState(""),p=s.filter(C=>C.username?.toLowerCase().includes(d)),u=Ap.useRef(null);uG(()=>{if(u.current){let C=M=>{g(M)};if(C(u.current.clientWidth),!hG)return;let P=new ResizeObserver(M=>{for(let D of M){let{width:_}=D.contentRect;C(_)}});return P.observe(u.current),()=>{P.disconnect()}}},[]);let[E,g]=Ap.useState(fG*wE),b=l?E-PC:E,v=Math.max(1,Math.min(8,Math.floor(b/wE))),w=l?Math.max(0,v-1):v,x=c.slice(0,w),I=l?[...x,l]:x,T=I.map(C=>{let P=vE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o});return C.isCurrentUser?is(nc.Root,{children:[Tt(nc.Trigger,{asChild:!0,children:is("div",{className:"UserList__pill",children:[P,Tt("div",{className:"UserList__pill-chevron",children:S0})]})}),Tt(nc.Content,{className:"focus-visible-none",style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:is(Ze,{padding:2,children:[s.length>=EG&&Tt(vd,{placeholder:f("quickSearch.placeholder"),onChange:m}),Tt(Id,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:p.length>0?[Tt("div",{className:"hint",children:f("userList.hint.text")},"hint"),p.map(M=>vE({actionManager:i,collaborator:M,socketId:M.socketId,withName:!0,isBeingFollowed:M.socketId===o}))]:[]}),a&&is(IE,{children:[Tt("div",{className:"UserList__menu-divider"}),Tt(nc.Close,{asChild:!0,children:Tt("div",{className:"dropdown-menu",children:a})})]}),Tt(nc.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]},C.socketId):P});return n?is("div",{className:CC("UserList UserList_mobile",e),children:[Tt("div",{className:"UserList_mobile__avatars",children:s.map(C=>vE({actionManager:i,collaborator:C,socketId:C.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:C.socketId===o}))}),a&&is(IE,{children:[Tt("div",{className:"UserList__menu-divider"}),a]})]}):Tt("div",{className:"UserList__wrapper",ref:u,children:Tt("div",{className:CC("UserList",e),style:{"--max-avatars":I.length+(l?PC/wE:0)},children:T})})},(e,n)=>{if(e.collaborators.size!==n.collaborators.size||e.mobile!==n.mobile||e.className!==n.className||e.userToFollow!==n.userToFollow||e.currentUserControls!==n.currentUserControls)return!1;let t=n.collaborators.keys();for(let[o,r]of e.collaborators){let i=n.collaborators.get(o);if(!i||o!==t.next().value||!gG(r,i,xG))return!1}return!0});import oc from"clsx";import{jsx as kC}from"react/jsx-runtime";var MC=e=>kC(ht,{label:`${f("helpDialog.title")} \u2014 ?`,children:kC("button",{className:"help-icon",onClick:e.onClick,type:"button","aria-label":f("helpDialog.title"),children:Yi})});import{jsx as tn,jsxs as TE}from"react/jsx-runtime";var AC=({appState:e,actionManager:n,showExitZenModeBtn:t,renderWelcomeScreen:o,defaultUIEnabled:r,zoomUIEnabled:i})=>{let{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:s}=it(),l=xt();return TE("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[(r||i&&l.isNavigationEnabled())&&tn("div",{className:oc("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:tn(Ft.Col,{gap:2,children:TE(tc,{heading:"canvasActions",children:[!e.viewModeOnly&&tn(ht,{label:e.viewModeEnabled?"Edit mode":f("labels.viewMode"),children:tn("div",{className:oc("view-mode-button"),children:n.renderAction("viewMode")})}),tn(ht,{label:f("buttons.smartZoom"),children:tn("div",{className:oc("smart-zoom-button"),children:n.renderAction("smartZoom")})}),i&&l.isNavigationEnabled()&&tn(OS,{renderAction:n.renderAction}),r&&!e.viewModeEnabled&&tn(zS,{renderAction:n.renderAction,className:oc("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),tn(a.Out,{}),(r||o)&&tn("div",{className:oc("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:TE("div",{style:{position:"relative"},children:[o&&tn(s.Out,{}),r&&tn(MC,{onClick:()=>n.executeAction(ni)})]})}),r&&tn(GS,{showExitZenModeBtn:t})]})},DC=AC;AC.displayName="Footer";import{composeEventHandlers as kG}from"@excalidraw/common";import{useLayoutEffect as yG,useRef as wG}from"react";import{jsx as vG}from"react/jsx-runtime";var bi=(e,n)=>{let t=Qe(0),o=r=>{let{tunnelsJotai:{useAtom:i}}=it(),[,a]=i(t),s=wG({preferHost:!1,counter:0});return yG(()=>{let l=s.current;return a(c=>{let d=c+1;return l.counter=d,d}),()=>{a(c=>{let d=c-1;return l.counter=d,d||(l.preferHost=!1),d})}},[a]),r.__fallback||(s.current.preferHost=!0),!s.current.counter&&r.__fallback&&s.current.preferHost||s.current.counter>1&&r.__fallback?null:vG(n,{...r})};return o.displayName=e,o};var PE={};OA(PE,{ChangeCanvasBackground:()=>UC,Export:()=>WC,Help:()=>GC,LiveCollaborationTrigger:()=>YC,LoadScene:()=>BC,Preferences:()=>ho,PreferencesToggleGridModeItem:()=>CE,SaveAsImage:()=>OC,SaveToActiveFile:()=>FC,SearchMenu:()=>zC,Socials:()=>VC,ToggleTheme:()=>HC});import CG from"clsx";import{THEME as ic}from"@excalidraw/common";var SE=Qe({active:!1});async function LC({title:e,description:n,actionLabel:t,color:o}){return new Promise(r=>{bt.set(SE,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:n,actionLabel:t,color:o})})}import IG from"clsx";import{jsx as _C,jsxs as TG}from"react/jsx-runtime";var Lp=function({onChange:e,value:n,choices:t,name:o}){return _C("div",{className:"RadioGroup",children:t.map(r=>TG("div",{className:IG("RadioGroup__choice",{active:r.value===n}),title:r.ariaLabel,children:[_C("input",{name:o,type:"radio",checked:r.value===n,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as SG,jsx as rc,jsxs as RC}from"react/jsx-runtime";var NC=({value:e,shortcut:n,onChange:t,choices:o,children:r,name:i,icon:a})=>{let s=fe();return RC(SG,{children:[RC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[a&&rc("div",{className:"dropdown-menu-item__icon",children:a}),rc("label",{className:"dropdown-menu-item__text",children:rc($s,{children:r})}),rc(Lp,{name:i,value:e,onChange:t,choices:o})]}),n&&s.formFactor!=="phone"&&rc("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:n})]})};NC.displayName="DropdownMenuItemContentRadio";var _p=NC;import{Fragment as QC,jsx as be,jsxs as ac}from"react/jsx-runtime";var BC=()=>{let{t:e}=Ae(),n=at(),t=qi();return n.isActionEnabled(ma)?be(Jt,{icon:jc,onSelect:async()=>{(!t.length||await LC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:be(fi,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>be("strong",{children:r}),br:()=>be("br",{})})}))&&n.executeAction(ma)},"data-testid":"load-button",shortcut:Je("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};BC.displayName="LoadScene";var FC=()=>{let{t:e}=Ae(),n=at();return n.isActionEnabled(ti)?be(Jt,{shortcut:Je("saveScene"),"data-testid":"save-button",onSelect:()=>n.executeAction(ti),icon:n1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};FC.displayName="SaveToActiveFile";var OC=()=>{let e=Ve(),{t:n}=Ae();return be(Jt,{icon:i1,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Je("imageExport"),"aria-label":n("buttons.exportImage"),children:n("buttons.exportImage")})};OC.displayName="SaveAsImage";var zC=e=>{let{t:n}=Ae(),t=at();return be(Jt,{icon:oo,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Nl)},shortcut:Je("searchMenu"),"aria-label":n("search.title"),className:e?.className,children:n("search.title")})};zC.displayName="SearchMenu";var GC=()=>{let{t:e}=Ae(),n=at();return be(Jt,{"data-testid":"help-menu-item",icon:Yi,onSelect:()=>n.executeAction(ni),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};GC.displayName="Help";var HC=e=>{let{t:n}=Ae(),t=ye(),o=at(),r=Je("toggleTheme"),i=Ln();return o.isActionEnabled(Ud)?e?.allowSystemTheme?be(_p,{name:"theme",value:e.theme,onChange:a=>{if(i.onThemeChange){i.onThemeChange(a);return}console.warn("MainMenu.DefaultItems.ToggleTheme: `<Excalidraw/> props.onThemeChange` must be defined to use system theme selection.")},choices:[{value:ic.LIGHT,label:Ns,ariaLabel:`${n("buttons.lightMode")} - ${r}`},{value:ic.DARK,label:Rs,ariaLabel:`${n("buttons.darkMode")} - ${r}`},{value:"system",label:E0,ariaLabel:n("buttons.systemMode")}],children:n("labels.theme")}):be(Jt,{onSelect:a=>{a.preventDefault(),o.executeAction(Ud)},icon:t.theme===ic.DARK?Ns:Rs,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===ic.DARK?n("buttons.lightMode"):n("buttons.darkMode"),children:t.theme===ic.DARK?n("buttons.lightMode"):n("buttons.darkMode")}):null};HC.displayName="ToggleTheme";var UC=()=>{let{t:e}=Ae(),n=ye(),t=at(),o=Ln();return n.viewModeEnabled||!o.UIOptions.canvasActions.changeViewBackgroundColor?null:ac("div",{style:{marginTop:"0.75rem"},children:[be("div",{"data-testid":"canvas-background-label",style:{fontSize:"0.875rem",marginBottom:"0.25rem",marginLeft:"0.5rem"},children:e("labels.canvasBackground")}),be("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};UC.displayName="ChangeCanvasBackground";var WC=()=>{let{t:e}=Ae(),n=Ve();return be(Jt,{icon:Bs,onSelect:()=>{n({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};WC.displayName="Export";var VC=()=>{let{t:e}=Ae();return ac(QC,{children:[be(ns,{icon:Qx,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),be(ns,{icon:t1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),be(ns,{icon:e1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};VC.displayName="Socials";var YC=({onSelect:e,isCollaborating:n})=>{let{t}=Ae();return be(Jt,{"data-testid":"collab-button",icon:qc,className:CG({"active-collab":n}),onSelect:e,children:t("labels.liveCollaboration")})};YC.displayName="LiveCollaborationTrigger";var KC=()=>{let{t:e}=Ae(),n=xt(),t=ye();return be(uo,{checked:t.activeTool.locked,shortcut:Je("toolLock"),onSelect:o=>{n.toggleLock(),o.preventDefault()},children:e("labels.preferences_toolLock")})},XC=()=>{let{t:e}=Ae(),n=ye(),t=Ve();return be(_p,{name:"boxSelectionMode",icon:nd,value:n.boxSelectionMode,onChange:o=>{t({boxSelectionMode:o})},choices:[{value:"contain",label:e("labels.boxSelectionContain"),ariaLabel:e("labels.boxSelectionContain")},{value:"overlap",label:e("labels.boxSelectionOverlap"),ariaLabel:e("labels.boxSelectionOverlap")}],children:e("labels.boxSelectionMode")})},ZC=()=>{let{t:e}=Ae(),n=at(),t=ye();return be(uo,{checked:t.objectsSnapModeEnabled,shortcut:Je("objectsSnapMode"),onSelect:o=>{n.executeAction(_t),o.preventDefault()},children:e("buttons.objectsSnapMode")})},$C=()=>{let{t:e}=Ae(),n=at(),t=ye();return be(uo,{checked:t.bindingPreference==="enabled",onSelect:o=>{n.executeAction(gl),o.preventDefault()},children:e("labels.arrowBinding")})},jC=()=>{let{t:e}=Ae(),n=at(),t=ye();return be(uo,{checked:t.isMidpointSnappingEnabled,onSelect:o=>{n.executeAction(fl),o.preventDefault()},children:e("labels.midpointSnapping")})},CE=()=>{let{t:e}=Ae(),n=at(),t=ye();return be(uo,{checked:t.gridModeEnabled,shortcut:Je("gridMode"),onSelect:o=>{n.executeAction(ba),o.preventDefault()},children:e("labels.toggleGrid")})},qC=()=>{let{t:e}=Ae(),n=at(),t=ye();return t.viewModeOnly?null:be(uo,{checked:t.viewModeEnabled,shortcut:Je("viewMode"),onSelect:o=>{n.executeAction(_a),o.preventDefault()},children:e("labels.viewMode")})},PG=()=>{let{t:e}=Ae(),n=xt(),t=fe();if(t.formFactor!=="desktop")return null;let o=e("labels.preferences_myocDesktopUIDescription");return be(_p,{name:"myocDesktopUIMode",value:t.desktopUIMode,onChange:r=>n.setDesktopUIMode(r),choices:[{value:"full",label:e("labels.preferences_myocDesktopUIFull"),ariaLabel:`${e("labels.preferences_myocDesktopUIFull")}. ${o}`},{value:"compact",label:e("labels.preferences_myocDesktopUICompact"),ariaLabel:`${e("labels.preferences_myocDesktopUICompact")}. ${o}`}],children:be("span",{title:o,children:e("labels.preferences_myocDesktopUISize")})})},JC=()=>{let{t:e}=Ae(),n=at(),t=ye();return be(uo,{checked:t.stats.open,shortcut:Je("stats"),onSelect:o=>{n.executeAction(Er),o.preventDefault()},children:e("stats.fullTitle")})},ho=({children:e,additionalItems:n})=>{let{t}=Ae();return ac(Cr,{children:[be(Cr.Trigger,{icon:P0,children:t("labels.preferences")}),ac(Cr.Content,{className:"excalidraw-main-menu-preferences-submenu",children:[e||ac(QC,{children:[be(PG,{}),be(XC,{}),be(KC,{}),be(ZC,{}),be(CE,{}),be(qC,{}),be(JC,{}),be($C,{}),be(jC,{})]}),n]})]})};ho.ToggleToolLock=KC;ho.BoxSelectionMode=XC;ho.ToggleSnapMode=ZC;ho.ToggleArrowBinding=$C;ho.ToggleMidpointSnapping=jC;ho.ToggleGridMode=CE;ho.ToggleViewMode=qC;ho.ToggleElementProperties=JC;ho.displayName="Preferences";import{jsx as Rp,jsxs as kE}from"react/jsx-runtime";var MG=Object.assign(bi("MainMenu",({children:e,onSelect:n})=>{let{MainMenuTunnel:t}=it(),o=fe(),r=ye(),i=Ln(),a=Ve();return Rp(t.In,{children:kE(ge,{open:r.openMenu==="canvas",children:[Rp(ge.Trigger,{onToggle:()=>{a({openMenu:r.openMenu==="canvas"?null:"canvas",openPopup:null,openDialog:null})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:qx}),kE(ge.Content,{onClickOutside:()=>a({openMenu:null}),onSelect:kG(n,()=>{a({openMenu:null})}),className:"main-menu",align:"start",children:[e,o.formFactor==="phone"&&r.collaborators.size>0&&kE("fieldset",{className:"UserList-Wrapper",children:[Rp("legend",{children:f("labels.collaborators")}),Rp(Dp,{mobile:!0,collaborators:r.collaborators,userToFollow:i.userToFollow?.socketId||null,currentUserControls:i.currentUserControls})]})]})]})})}),{Trigger:ge.Trigger,Item:ge.Item,ItemLink:ge.ItemLink,ItemCustom:ge.ItemCustom,Group:ge.Group,Separator:ge.Separator,Sub:Cr,DefaultItems:PE}),Ot=MG;import AG from"clsx";import{forwardRef as DG,useState as LG}from"react";import{isPromiseLike as _G}from"@excalidraw/common";import{jsx as Np,jsxs as RG}from"react/jsx-runtime";var Pr=DG(({children:e,icon:n,onClick:t,label:o,variant:r="filled",color:i="primary",size:a="medium",fullWidth:s,className:l,status:c,disabled:d},m)=>{let[p,u]=LG(!1),E=async b=>{let v=t?.(b);if(_G(v)){let w=window.setTimeout(()=>{u(!0)},50);try{await v}catch(x){if(x instanceof Rc)console.warn(x);else throw x}finally{clearTimeout(w),u(!1)}}},g=p?"loading":c;return i=g==="success"?"success":i,Np("button",{className:AG("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":s},l),onClick:E,type:"button","aria-label":o,ref:m,disabled:d||g==="loading"||g==="success",children:RG("div",{className:"ExcButton__contents",children:[g==="loading"?Np(So,{className:"ExcButton__statusIcon"}):g==="success"&&Np("div",{className:"ExcButton__statusIcon",children:a0}),n&&Np("div",{className:"ExcButton__icon","aria-hidden":!0,children:n}),r!=="icon"&&(e??o)]})})});import{jsx as as,jsxs as FG}from"react/jsx-runtime";var Bp=({title:e,children:n,actionLabel:t,onClick:o})=>FG("div",{className:"OverwriteConfirm__Actions__Action",children:[as("h4",{children:e}),as("div",{className:"OverwriteConfirm__Actions__Action__content",children:n}),as(Pr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:o})]}),NG=()=>{let{t:e}=Ae(),n=at(),t=Ve();return as(Bp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{n.executeAction(lm,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},BG=()=>{let{t:e}=Ae(),n=at();return as(Bp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{n.executeAction(ul,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},ME=Object.assign(({children:e})=>as("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:NG,SaveToDisk:BG});import{jsx as kr,jsxs as eP}from"react/jsx-runtime";var Fp=Object.assign(bi("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:n}=it(),[t,o]=Xe(SE);if(!t.active)return null;let r=()=>{t.onClose(),o(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),o(a=>({...a,active:!1}))};return kr(n.In,{children:kr(wn,{onCloseRequest:r,title:!1,size:916,children:eP("div",{className:"OverwriteConfirm",children:[kr("h3",{children:t.title}),eP("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[kr("div",{className:"OverwriteConfirm__Description__icon",children:s0}),kr("div",{children:t.description}),kr("div",{className:"OverwriteConfirm__Description__spacer"}),kr(Pr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),kr(ME,{children:e})]})})})}),{Actions:ME,Action:Bp});import{round as VP}from"@excalidraw/math";import tU from"clsx";import nU from"lodash.throttle";import{useEffect as YP,useMemo as WE,useState as oU,memo as rU}from"react";import{STATS_PANELS as Kp}from"@excalidraw/common";import{getCommonBounds as iU}from"@excalidraw/element";import{getUncroppedWidthAndHeight as aU}from"@excalidraw/element";import{isImageElement as VE}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as sU}from"@excalidraw/element";import{elementsAreInSameGroup as lU}from"@excalidraw/element";import{degreesToRadians as lP,radiansToDegrees as pP}from"@excalidraw/math";import{getBoundTextElement as cP}from"@excalidraw/element";import{isArrowElement as dP,isElbowArrow as qG}from"@excalidraw/element";import{updateBindings as mP}from"@excalidraw/element";import YG from"clsx";import{useEffect as aP,useRef as zp,useState as KG}from"react";import{EVENT as cs,KEYS as XG,cloneJSON as AE}from"@excalidraw/common";import{deepCopyElement as ZG}from"@excalidraw/element";import{CaptureUpdateAction as sP}from"@excalidraw/element";import{pointFrom as Mr,pointRotateRads as Op}from"@excalidraw/math";import{getBoundTextElement as OG,getNonDeletedElements as zG,isBindingElement as GG,unbindBindingElement as tP}from"@excalidraw/element";import{isFrameLikeElement as rP}from"@excalidraw/element";import{getSelectedGroupIds as HG,getElementsInGroup as UG,isInGroup as WG}from"@excalidraw/element";import{getFrameChildren as VG}from"@excalidraw/element";import{updateBindings as nP}from"@excalidraw/element";import{DRAGGING_THRESHOLD as oP}from"@excalidraw/common";var iP=.01,sc=10,Kt=(e,n)=>!(n==="angle"&&rP(e)),$e=(e,n)=>{let t=e+n/2;return t-t%n},ss=(e,n,t)=>Object.keys(e).map(o=>({original:(t??n).get(o),latest:n.get(o)})).filter(o=>o.original!==void 0&&o.latest!==void 0);var xi=(e,n,t,o,r,i,a=!0)=>{if(GG(t)&&(t.startBinding||t.endBinding)){if(Math.abs(e-t.x)<oP&&Math.abs(n-t.y)<oP)return;tP(t,"start",o),tP(t,"end",o)}let s=o.getNonDeletedElementsMap(),l=s.get(t.id);if(!l)return;let[c,d]=[t.x+t.width/2,t.y+t.height/2],[m,p]=Op(Mr(t.x,t.y),Mr(c,d),t.angle),u=e-m,E=n-p,[g,b]=Op(Mr(e,n),Mr(c+u,d+E),-t.angle);o.mutateElement(l,{x:g,y:b},{informMutation:a,isDragging:!1}),nP(l,o,r);let v=OG(t,i);if(v){let w=s.get(v.id);w&&o.mutateElement(w,{x:v.x+u,y:v.y+E},{informMutation:a,isDragging:!1})}if(rP(t)){let w=VG(i,t.id);w.forEach(x=>{let I=s.get(x.id);if(!I)return;let[T,C]=[x.x+x.width/2,x.y+x.height/2],[P,M]=Op(Mr(x.x,x.y),Mr(T,C),x.angle),D=Math.round(P+u),_=Math.round(M+E),[k,L]=Op(Mr(D,_),Mr(T+u,C+E),-x.angle);o.mutateElement(I,{x:k,y:L},{informMutation:a,isDragging:!1}),nP(I,o,r,{simultaneouslyUpdated:zG(w)})})}},ls=(e,n)=>{let o=HG(n).map(r=>UG(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!WG(r)).forEach(r=>{o.push({[r.id]:!0})}),o};import{jsx as DE,jsxs as jG}from"react/jsx-runtime";var $G=({label:e,icon:n,dragInputCallback:t,value:o,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:s,scene:l,appState:c,sensitivity:d=1,dragFinishedCallback:m})=>{let p=xt(),u=Ve(),E=zp(null),g=zp(null),[b,v]=KG(o.toString()),w=zp(null);w.current||(w.current={originalAppState:AE(c),originalElements:r,lastUpdatedValue:b,updatePending:!1}),aP(()=>{let T=o.toString();v(T),w.current.lastUpdatedValue=T},[o]);let x=(T,C,P)=>{if(!w.current.updatePending)return!1;w.current.updatePending=!1;let M=Number(T);if(isNaN(M)){v(o.toString());return}let D=Number(M.toFixed(2)),_=Number(o);(isNaN(_)||Math.abs(D-_)>=iP)&&(w.current.lastUpdatedValue=T,t({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:l,nextValue:D,property:s,originalAppState:P,setInputValue:k=>v(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:sP.IMMEDIATELY}))},I=zp({});return I.current.handleInputValue=x,aP(()=>{let T=E.current,C=I.current;return()=>{let P=T?.value;P&&C.handleInputValue?.(P,w.current.originalElements,w.current.originalAppState),window.removeEventListener(cs.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(cs.POINTER_UP,C.onPointerUp,!1)}},[i]),i?jG("div",{className:YG("drag-input-container",!i&&"disabled"),"data-testid":e,children:[DE("div",{className:"drag-input-label",ref:g,onPointerDown:T=>{if(E.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(E.current.value);isNaN(C)&&(C=0);let P=null,M=p.scene.getNonDeletedElements().reduce((z,U)=>(z.set(U.id,ZG(U)),z),new Map),D=r.map(z=>M.get(z.id)),_=AE(c),k=0,L=0,F=z=>{if(P&&M!==null&&D!==null){let U=z.clientX-P.x;U!==0&&(L+=U,Math.abs(L)>=d&&(L=Math.sign(L)*Math.floor(Math.abs(L)/d),k+=L,t({accumulatedChange:k,instantChange:L,originalElements:D,originalElementsMap:M,shouldKeepAspectRatio:a,shouldChangeByStepSize:z.shiftKey,property:s,scene:l,originalAppState:_,setInputValue:W=>v(String(W)),app:p,setAppState:u}),L=0))}P={x:z.clientX,y:z.clientY}},K=()=>{window.removeEventListener(cs.POINTER_MOVE,F,!1),p.syncActionResult({captureUpdate:sP.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:D,originalAppState:_}),P=null,k=0,L=0,D=null,M=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(cs.POINTER_UP,K,!1)};I.current.onPointerMove=F,I.current.onPointerUp=K,window.addEventListener(cs.POINTER_MOVE,F,!1),window.addEventListener(cs.POINTER_UP,K,!1)}},onPointerEnter:()=>{g.current&&(g.current.style.cursor="ew-resize")},children:n?DE(Pd,{icon:n}):e}),DE("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:T=>{if(i){let C=T.target;C instanceof HTMLInputElement&&T.key===XG.ENTER&&(x(C.value,r,c),p.focusContainer())}},ref:E,value:b,onChange:T=>{w.current.updatePending=!0,v(T.target.value)},onFocus:T=>{T.target.select(),w.current.originalElements=r,w.current.originalAppState=AE(c)},onBlur:T=>{b?i&&x(T.target.value,w.current.originalElements,w.current.originalAppState):v(o.toString())},disabled:!i})]}):null},ft=$G;import{jsx as tH}from"react/jsx-runtime";var JG=15,QG=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r,app:i})=>{let a=r.getNonDeletedElementsMap(),s=n[0];if(s&&!qG(s)){let l=a.get(s.id);if(!l)return;if(o!==void 0){let E=lP(o);r.mutateElement(l,{angle:E}),mP(l,r,i.state);let g=cP(l,a);g&&!dP(l)&&r.mutateElement(g,{angle:E});return}let c=Math.round(pP(s.angle)*100)/100,d=Math.round(e),m=(c+d)%360;t&&(m=$e(m,JG)),m=m<0?m+360:m;let p=lP(m);r.mutateElement(l,{angle:p}),mP(l,r,i.state);let u=cP(l,a);u&&!dP(l)&&r.mutateElement(u,{angle:p})}},eH=({element:e,scene:n,appState:t,property:o})=>tH(ft,{label:"A",icon:Qc,value:Math.round(pP(e.angle)%360*100)/100,elements:[e],dragInputCallback:QG,editable:Kt(e,"angle"),scene:n,appState:t,property:o}),uP=eH;import{jsx as oH}from"react/jsx-runtime";var hP=5,nH=({property:e,scene:n,appState:t,setAppState:o})=>oH(ft,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:s})=>{o(l=>{let c;return r?c=r:i&&(c=a?$e(l.gridStep+hP*Math.sign(i),hP):l.gridStep+i),c?(c=ux(c),s(c),{gridStep:c}):(s(l.gridStep),null)})},scene:n,value:t.gridStep,property:e,appState:t}),gP=nH;import{clamp as Gp,round as LE}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Hp}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as fP,getNonDeletedElements as rH,getUncroppedWidthAndHeight as xP}from"@excalidraw/element";import{resizeSingleElement as EP}from"@excalidraw/element";import{isImageElement as yP}from"@excalidraw/element";import{isFrameLikeElement as _E}from"@excalidraw/element";import{getElementsInResizingFrame as RE}from"@excalidraw/element";import{replaceAllElementsInFrame as wP}from"@excalidraw/element";import{jsx as cH}from"react/jsx-runtime";var bP=10,iH=e=>e.type==="image",aH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldKeepAspectRatio:o,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:s,instantChange:l,scene:c,app:d,setAppState:m})=>{let p=c.getNonDeletedElementsMap(),u=n[0],E=p.get(u.id);if(u&&E){let g=o||iH(u),b=u.width/u.height;if(s.croppingElementId===u.id){let v=p.get(u.id);if(!v||!yP(v)||!v.crop)return;let w=v.crop,x={...w},I=v.scale[0]===-1,T=v.scale[1]===-1,{width:C,height:P}=xP(v),M=w.naturalWidth/C,D=w.naturalHeight/P,_=I?w.width+w.x:w.naturalWidth-w.x,k=T?w.height+w.y:w.naturalHeight-w.y,L=fP*M,F=fP*D;if(i!==void 0){if(a==="width"){let G=i*M,ie=Gp(G,L,_);x={...x,width:ie,x:I?w.x+w.width-ie:w.x}}else if(a==="height"){let G=i*D,ie=Gp(G,F,k);x={...x,height:ie,y:T?w.y+w.height-ie:w.y}}c.mutateElement(v,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}let K=a==="width"?l:0,z=a==="height"?l:0,U=Gp(w.width+K,L,_),W=Gp(w.height+z,L,k);x={...w,x:I?w.x+w.width-U:w.x,y:T?w.y+w.height-W:w.y,width:U,height:W},c.mutateElement(v,{crop:x,width:x.width/(w.naturalWidth/C),height:x.height/(w.naturalHeight/P)});return}if(i!==void 0){let v=Math.max(a==="width"?i:g?i*b:u.width,Hp),w=Math.max(a==="height"?i:g?i/b:u.height,Hp);if(EP(v,w,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),_E(E)){let x=RE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()),I=wP(c.getElementsIncludingDeleted(),x,E);c.replaceAllElements(I)}return}{let v=a==="width"?e:0,w=a==="height"?e:0,x=Math.max(0,u.width+v);a==="width"&&(r?x=$e(x,bP):x=Math.round(x));let I=Math.max(0,u.height+w);if(a==="height"&&(r?I=$e(I,bP):I=Math.round(I)),g&&(a==="width"?I=Math.round(x/b*100)/100:x=Math.round(I*b*100)/100),I=Math.max(Hp,I),x=Math.max(Hp,x),EP(x,I,E,u,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:g}),_E(E)){let T=rH(RE(c.getElementsIncludingDeleted(),E,s,c.getNonDeletedElementsMap()));m({elementsToHighlight:T})}}}},sH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&_E(a)){let s=RE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=wP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},lH=({property:e,element:n,scene:t,appState:o})=>{let r=LE(e==="width"?n.width:n.height,2);if(o.croppingElementId&&o.croppingElementId===n.id&&yP(n)&&n.crop){let{width:i,height:a}=xP(n);if(e==="width"){let s=i/n.crop.naturalWidth;r=LE(n.crop.width*s,2)}if(e==="height"){let s=a/n.crop.naturalHeight;r=LE(n.crop.height*s,2)}}return cH(ft,{label:e==="width"?"W":"H",elements:[n],dragInputCallback:aH,value:r,editable:Kt(n,e),scene:t,appState:o,property:e,dragFinishedCallback:sH})},NE=lH;import{getBoundTextElement as dH,redrawTextBoundingBox as mH}from"@excalidraw/element";import{hasBoundTextElement as pH,isTextElement as IP}from"@excalidraw/element";import{jsx as fH}from"react/jsx-runtime";var vP=4,uH=4,hH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n[0];if(a){let s=i.get(a.id);if(!s||!IP(s))return;let l;if(o!==void 0)l=Math.max(Math.round(o),vP);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);l=Math.max(c+d,vP),t&&(l=$e(l,uH))}l&&(r.mutateElement(s,{fontSize:l}),mH(s,r.getContainerElement(s),r))}},gH=({element:e,scene:n,appState:t,property:o})=>{let r=IP(e)?e:pH(e)?dH(e,n.getNonDeletedElementsMap()):null;return r?fH(ft,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:hH,icon:Yr,appState:t,scene:n,property:o}):null},TP=gH;import{degreesToRadians as SP,radiansToDegrees as kP}from"@excalidraw/math";import{getBoundTextElement as CP}from"@excalidraw/element";import{isArrowElement as PP}from"@excalidraw/element";import{isInGroup as BE}from"@excalidraw/element";import{jsx as yH}from"react/jsx-runtime";var EH=15,bH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),s=n.map(c=>a.get(c.id)).filter(c=>c&&!BE(c)&&Kt(c,r)),l=n.filter(c=>!BE(c)&&Kt(c,r));if(o!==void 0){let c=SP(o);for(let d of s){if(!d)continue;i.mutateElement(d,{angle:c});let m=CP(d,a);m&&!PP(d)&&i.mutateElement(m,{angle:c})}i.triggerUpdate();return}for(let c=0;c<s.length;c++){let d=s[c];if(!d)continue;let m=l[c],p=Math.round(kP(m.angle)*100)/100,u=Math.round(e),E=(p+u)%360;t&&(E=$e(E,EH)),E=E<0?E+360:E;let g=SP(E);i.mutateElement(d,{angle:g});let b=CP(d,a);b&&!PP(d)&&i.mutateElement(b,{angle:g})}i.triggerUpdate()},xH=({elements:e,scene:n,appState:t,property:o})=>{let r=e.filter(l=>!BE(l)&&Kt(l,"angle")),i=r.map(l=>Math.round(kP(l.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",s=r.some(l=>Kt(l,"angle"));return yH(ft,{label:"A",icon:Qc,value:a,elements:e,dragInputCallback:bH,editable:s,appState:t,scene:n,property:o})},MP=xH;import{pointFrom as _P}from"@excalidraw/math";import{useMemo as vH}from"react";import{MIN_WIDTH_OR_HEIGHT as Ar}from"@excalidraw/common";import{getElementsInResizingFrame as FE,getNonDeletedElements as IH,isFrameLikeElement as OE,replaceAllElementsInFrame as BP,updateBoundElements as TH}from"@excalidraw/element";import{rescalePointsInElement as SH,resizeSingleElement as RP}from"@excalidraw/element";import{getBoundTextElement as CH,handleBindTextResize as PH}from"@excalidraw/element";import{isTextElement as FP}from"@excalidraw/element";import{MIME_TYPES as yi}from"@excalidraw/common";import{getNonDeletedElements as AP}from"@excalidraw/element";var Up=({elements:e,appState:n,files:t,maxWidthOrHeight:o,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let s=AP(Hr(e,null,{deleteInvisibleElements:!0})),l=Bi(n,null),{exportBackground:c,viewBackgroundColor:d}=l;return Gc(s,{...l,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:d,exportingFrame:a},(m,p)=>{let u=document.createElement("canvas");if(o){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let g=Math.max(m,p),b=o<g?o/g:n?.exportScale??1;return u.width=m*b,u.height=p*b,{canvas:u,scale:b}}let E=r?.(m,p)||{width:m,height:p};return u.width=E.width,u.height=E.height,{canvas:u,scale:E.scale??1}})},DP=async e=>{let{mimeType:n=yi.png,quality:t}=e;n===yi.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${yi.png}" mimeType`),n==="image/jpg"&&(n=yi.jpg),n===yi.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${yi.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let o=await Up(e);return t=t||(/image\/jpe?g/.test(n)?.92:.8),new Promise((r,i)=>{o.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&n===yi.png&&e.appState?.exportEmbedScene&&(a=await Sx({blob:a,metadata:Ps(e.elements,e.appState,e.files||{},"local")})),r(a)},n,t)})},LP=async({elements:e,appState:n=Zo(),files:t={},exportPadding:o,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:s})=>{let l=AP(Hr(e,null,{deleteInvisibleElements:!0})),d={...Bi(n,null),exportPadding:o};return Gr(l,d,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:s})},wH=async e=>{if(e.type==="svg"){let n=await LP(e);await ao(n.outerHTML)}else if(e.type==="png")await am(DP(e));else if(e.type==="json")await om(e.elements,e.files);else throw new Error("Invalid export type")};import{elementsOverlappingBBox as J8e}from"@excalidraw/element";import{getCommonBounds as Wp}from"@excalidraw/element";import{jsx as _H}from"react/jsx-runtime";var ds=10,kH=(e,n,t,o)=>{let r=o.x-e,i=o.y-n,a=o.width*t,s=o.height*t,l=e+r*t,c=n+i*t;return{width:a,height:s,x:l,y:c,...SH(o,a,s,!1),...FP(o)?{fontSize:o.fontSize*t}:{}}},MH=(e,n,t,o,r,i,a,s)=>{let l=s.getNonDeletedElementsMap(),c=kH(e,n,o,i);s.mutateElement(r,c);let d=CH(i,a);if(d){let m=d.fontSize*o;TH(r,s);let p=l.get(d.id);p&&FP(p)&&(s.mutateElement(p,{fontSize:m}),PH(r,s,t==="width"?"e":"s",!0))}},NP=(e,n,t,o,r,i,a,s,l,c)=>{i==="width"?n=Math.round(e/o*100)/100:e=Math.round(n*o*100)/100;let d=n/t;for(let m=0;m<s.length;m++){let p=s[m],u=a[m];MH(r[0],r[1],i,d,u,p,l,c)}},AH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,originalAppState:o,shouldChangeByStepSize:r,nextValue:i,scene:a,property:s,setAppState:l,app:c})=>{let d=a.getNonDeletedElementsMap(),m=ls(n,o);if(i!==void 0){for(let g of m){let b=ss(g,d,t);if(b.length>1){let v=b.map(L=>L.latest),w=b.map(L=>L.original),[x,I,T,C]=Wp(w),P=T-x,M=C-I,D=P/M,_=Math.max(Ar,s==="width"?Math.max(0,i):P),k=Math.max(Ar,s==="height"?Math.max(0,i):M);NP(_,k,M,D,_P(x,I),s,v,w,t,a)}else{let[v]=b,w=v?.latest,x=v?.original;if(w&&x&&Kt(w,s)){let I=s==="width"?Math.max(0,i):w.width;s==="width"&&(r?I=$e(I,ds):I=Math.round(I));let T=s==="height"?Math.max(0,i):w.height;if(s==="height"&&(r?T=$e(T,ds):T=Math.round(T)),I=Math.max(Ar,I),T=Math.max(Ar,T),RP(I,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),OE(w)){let C=FE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()),P=BP(a.getElementsIncludingDeleted(),C,w);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=s==="width"?e:0,u=s==="height"?e:0,E=[];for(let g of m){let b=ss(g,d,t);if(b.length>1){let v=b.map(L=>L.latest),w=b.map(L=>L.original),[x,I,T,C]=Wp(w),P=T-x,M=C-I,D=P/M,_=Math.max(0,P+p);s==="width"&&(r?_=$e(_,ds):_=Math.round(_));let k=Math.max(0,M+u);s==="height"&&(r?k=$e(k,ds):k=Math.round(k)),_=Math.max(Ar,_),k=Math.max(Ar,k),NP(_,k,M,D,_P(x,I),s,v,w,t,a)}else{let[v]=b,w=v?.latest,x=v?.original;if(w&&x&&Kt(w,s)){let I=Math.max(0,x.width+p);s==="width"&&(r?I=$e(I,ds):I=Math.round(I));let T=Math.max(0,x.height+u);if(s==="height"&&(r?T=$e(T,ds):T=Math.round(T)),I=Math.max(Ar,I),T=Math.max(Ar,T),RP(I,T,w,x,t,a,s==="width"?"e":"s",{shouldInformMutation:!1}),OE(w)){let C=IH(FE(a.getElementsIncludingDeleted(),w,o,a.getNonDeletedElementsMap()));E.push(...C)}}}}l({elementsToHighlight:E}),a.triggerUpdate()},DH=({setAppState:e,app:n,originalElements:t,originalAppState:o})=>{let r=n.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&OE(a)){let s=FE(n.scene.getElementsIncludingDeleted(),a,o,n.scene.getNonDeletedElementsMap()),l=BP(n.scene.getElementsIncludingDeleted(),s,a);n.scene.replaceAllElements(l),e({elementsToHighlight:null})}},LH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=vH(()=>o.map(c=>{let d=ss(c,t);if(d.length>1){let[p,u,E,g]=Wp(d.map(b=>b.latest));return Math.round((e==="width"?E-p:g-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[t,o,e]),s=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",l=a.length>0;return _H(ft,{label:e==="width"?"W":"H",elements:n,dragInputCallback:AH,value:s,editable:l,appState:i,property:e,scene:r,dragFinishedCallback:DH})},zE=LH;import{getBoundTextElement as RH,redrawTextBoundingBox as OP}from"@excalidraw/element";import{hasBoundTextElement as NH,isTextElement as BH}from"@excalidraw/element";import{isInGroup as FH}from"@excalidraw/element";import{jsx as UH}from"react/jsx-runtime";var zP=4,OH=4,zH=(e,n)=>e.reduce((t,o)=>{if(!o||FH(o))return t;if(BH(o))return t.push(o),t;if(NH(o)){let r=RH(o,n);if(r)return t.push(r),t}return t},[]),GH=({accumulatedChange:e,originalElements:n,shouldChangeByStepSize:t,nextValue:o,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=n.map(l=>i.get(l.id)),s;if(o){s=Math.max(Math.round(o),zP);for(let l of a)r.mutateElement(l,{fontSize:s}),OP(l,r.getContainerElement(l),r);r.triggerUpdate()}else{let l=n;for(let c=0;c<a.length;c++){let d=a[c],m=l[c],p=Math.round(m.fontSize),u=Math.round(e),E=Math.max(p+u,zP);t&&(E=$e(E,OH)),r.mutateElement(d,{fontSize:E}),OP(d,r.getContainerElement(d),r)}r.triggerUpdate()}},HH=({elements:e,scene:n,appState:t,property:o,elementsMap:r})=>{let i=zH(e,r);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),s=new Set(a).size===1?a[0]:"Mixed",l=a.length>0;return UH(ft,{label:"F",icon:Yr,elements:i,dragInputCallback:GH,value:s,editable:l,scene:n,property:o,appState:t})},GP=HH;import{pointFrom as Dr,pointRotateRads as Vp}from"@excalidraw/math";import{useMemo as WH}from"react";import{isTextElement as VH}from"@excalidraw/element";import{getCommonBounds as GE}from"@excalidraw/element";import{jsx as $H}from"react/jsx-runtime";var YH=(e,n,t,o,r,i,a)=>{for(let s=0;s<o.length;s++){let l=o[s],[c,d]=[l.x+l.width/2,l.y+l.height/2],[m,p]=Vp(Dr(l.x,l.y),Dr(c,d),l.angle),u=e==="x"?Math.round(m+n):m,E=e==="y"?Math.round(p+t):p;xi(u,E,l,i,a,r,!1)}},KH=(e,n,t,o,r,i)=>{let a=r.getNonDeletedElementsMap(),[s,l,,]=GE(t),c=e-s,d=n-l;for(let m=0;m<t.length;m++){let p=t[m],u=a.get(p.id);if(u&&(!VH(u)||!u.containerId)){let[E,g]=[u.x+u.width/2,u.y+u.height/2],[b,v]=Vp(Dr(u.x,u.y),Dr(E,g),u.angle);xi(b+c,v+d,p,r,i,o,!1)}}},XH=({accumulatedChange:e,originalElements:n,originalElementsMap:t,shouldChangeByStepSize:o,nextValue:r,property:i,scene:a,originalAppState:s,app:l})=>{let c=a.getNonDeletedElementsMap();if(r!==void 0){for(let u of ls(n,s)){let E=ss(u,c,t);if(E.length>1){let[g,b,,]=GE(E.map(x=>x.latest));KH(i==="x"?r:g,i==="y"?r:b,E.map(x=>x.original),t,a,l.state)}else{let g=E[0]?.original,b=E[0]?.latest;if(g&&b&&Kt(b,i)){let[v,w]=[g.x+g.width/2,g.y+g.height/2],[x,I]=Vp(Dr(g.x,g.y),Dr(v,w),g.angle);xi(i==="x"?r:x,i==="y"?r:I,g,a,l.state,t,!1)}}}a.triggerUpdate();return}let d=o?$e(e,sc):e;YH(i,i==="x"?d:0,i==="y"?d:0,n,t,a,l.state),a.triggerUpdate()},ZH=({property:e,elements:n,elementsMap:t,atomicUnits:o,scene:r,appState:i})=>{let a=WH(()=>o.map(l=>{let c=Object.keys(l).map(g=>t.get(g)).filter(g=>g!==void 0);if(c.length>1){let[g,b]=GE(c);return Math.round((e==="x"?g:b)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,E]=Vp(Dr(d.x,d.y),Dr(m,p),d.angle);return Math.round((e==="x"?u:E)*100)/100}),[o,t,e]),s=new Set(a).size===1?a[0]:"Mixed";return $H(ft,{label:e==="x"?"X":"Y",elements:n,dragInputCallback:XH,value:s,property:e,scene:r,appState:i})},HE=ZH;import{clamp as lc,pointFrom as Yp,pointRotateRads as UP,round as HP}from"@excalidraw/math";import{getFlipAdjustedCropPosition as jH,getUncroppedWidthAndHeight as qH}from"@excalidraw/element";import{isImageElement as WP}from"@excalidraw/element";import{jsx as eU}from"react/jsx-runtime";var JH=({accumulatedChange:e,instantChange:n,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:r,nextValue:i,property:a,scene:s,originalAppState:l,app:c})=>{let d=s.getNonDeletedElementsMap(),m=t[0],[p,u]=[m.x+m.width/2,m.y+m.height/2],[E,g]=UP(Yp(m.x,m.y),Yp(p,u),m.angle);if(l.croppingElementId===m.id){let I=d.get(m.id);if(!I||!WP(I)||!I.crop)return;let T=I.crop,C=T,P=I.scale[0]===-1,M=I.scale[1]===-1,{width:D,height:_}=qH(I);if(i!==void 0){if(a==="x"){let F=i*(T.naturalWidth/D);P?C={...T,x:lc(T.naturalWidth-F-T.width,0,T.naturalWidth-T.width)}:C={...T,x:lc(i*(T.naturalWidth/D),0,T.naturalWidth-T.width)}}a==="y"&&(C={...T,y:lc(i*(T.naturalHeight/_),0,T.naturalHeight-T.height)}),s.mutateElement(I,{crop:C});return}let k=(a==="x"?n:0)*(P?-1:1),L=(a==="y"?n:0)*(M?-1:1);C={...T,x:lc(T.x+k,0,T.naturalWidth-T.width),y:lc(T.y+L,0,T.naturalHeight-T.height)},s.mutateElement(I,{crop:C});return}if(i!==void 0){xi(a==="x"?i:E,a==="y"?i:g,m,s,c.state,o);return}let b=a==="x"?e:0,v=a==="y"?e:0,w=a==="x"?Math.round(r?$e(m.x+b,sc):E+b):E,x=a==="y"?Math.round(r?$e(m.y+v,sc):g+v):g;xi(w,x,m,s,c.state,o)},QH=({property:e,element:n,scene:t,appState:o})=>{let[r,i]=UP(Yp(n.x,n.y),Yp(n.x+n.width/2,n.y+n.height/2),n.angle),a=HP(e==="x"?r:i,2);if(o.croppingElementId===n.id&&WP(n)&&n.crop){let s=jH(n);s&&(a=HP(e==="x"?s.x:s.y,2))}return eU(ft,{label:e==="x"?"X":"Y",elements:[n],dragInputCallback:JH,scene:t,value:a,property:e,appState:o})},UE=QH;import{Fragment as YE,jsx as ne,jsxs as Xt}from"react/jsx-runtime";var cU=50,cc=e=>{let n=ro(),t=e.app.scene.getSceneNonce()||1,o=e.app.scene.getSelectedElements({selectedElementIds:n.selectedElementIds,includeBoundTextElement:!1}),r=yr(e.app);return ne(dU,{...e,appState:n,sceneNonce:t,selectedElements:o,gridModeEnabled:r})},Ye=({children:e,columns:n=1,heading:t,style:o,...r})=>ne("div",{className:tU("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${n}, 1fr)`,...o},...r,children:e});Ye.displayName="StatsRow";var Xp=({children:e,order:n,style:t,...o})=>ne("div",{className:"exc-stats__rows",style:{order:n,...t},...o,children:e});Xp.displayName="StatsRows";cc.StatsRow=Ye;cc.StatsRows=Xp;var dU=rU(({app:e,onClose:n,renderCustomStats:t,selectedElements:o,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let s=e.scene,l=s.getNonDeletedElements(),c=s.getNonDeletedElementsMap(),d=Ve(),m=o.length===1?o[0]:null,p=o.length>1?o:null,u=r.croppingElementId&&VE(m),E=u?aU(m):null,[g,b]=oU({width:0,height:0}),v=WE(()=>nU(I=>{let T=iU(I);b({width:Math.round(T[2])-Math.round(T[0]),height:Math.round(T[3])-Math.round(T[1])})},cU),[]);YP(()=>{v(l)},[i,l,v]),YP(()=>()=>v.cancel(),[v]);let w=WE(()=>ls(o,r),[o,r]),x=WE(()=>sU(o),[o]);return ne("div",{className:"exc-stats",children:Xt(Ze,{padding:3,children:[Xt("div",{className:"title",children:[ne("h2",{children:f("stats.title")}),ne("div",{className:"close",onClick:n,children:an})]}),Xt(Js,{label:ne("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&Kp.generalStats),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Kp.generalStats}})),children:[Xt(Xp,{children:[ne(Ye,{heading:!0,children:f("stats.scene")}),Xt(Ye,{columns:2,children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:l.length})]}),Xt(Ye,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:g.width})]}),Xt(Ye,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:g.height})]}),a&&Xt(YE,{children:[ne(Ye,{heading:!0,children:"Canvas"}),ne(Ye,{children:ne(gP,{property:"gridStep",scene:s,appState:r,setAppState:d})})]})]}),t?.(l,r)]}),!x&&o.length>0&&ne("div",{id:"elementStats",style:{marginTop:12},children:ne(Js,{label:ne("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&Kp.elementProperties),openTrigger:()=>d(I=>({stats:{open:!0,panels:I.stats.panels^Kp.elementProperties}})),children:Xt(Xp,{children:[m&&Xt(YE,{children:[u&&ne(Ye,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&VE(m)&&E&&Xt(Ye,{columns:2,children:[ne("div",{children:f("stats.width")}),ne("div",{children:VP(E.width,2)})]}),r.croppingElementId&&VE(m)&&E&&Xt(Ye,{columns:2,children:[ne("div",{children:f("stats.height")}),ne("div",{children:VP(E.height,2)})]}),ne(Ye,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):m.type==="magicframe"?f("element.frame"):f(`element.${m.type}`)}),ne(Ye,{children:ne(UE,{element:m,property:"x",elementsMap:c,scene:s,appState:r})}),ne(Ye,{children:ne(UE,{element:m,property:"y",elementsMap:c,scene:s,appState:r})}),ne(Ye,{children:ne(NE,{property:"width",element:m,scene:s,appState:r})}),ne(Ye,{children:ne(NE,{property:"height",element:m,scene:s,appState:r})}),ne(Ye,{children:ne(uP,{property:"angle",element:m,scene:s,appState:r})}),ne(Ye,{children:ne(TP,{property:"fontSize",element:m,scene:s,appState:r})})]}),p&&Xt(YE,{children:[lU(p)&&ne(Ye,{heading:!0,children:f("element.group")}),Xt(Ye,{columns:2,style:{margin:"0.3125rem 0"},children:[ne("div",{children:f("stats.shapes")}),ne("div",{children:o.length})]}),ne(Ye,{children:ne(HE,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Ye,{children:ne(HE,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Ye,{children:ne(zE,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Ye,{children:ne(zE,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:s,appState:r})}),ne(Ye,{children:ne(MP,{property:"angle",elements:p,scene:s,appState:r})}),ne(Ye,{children:ne(GP,{property:"fontSize",elements:p,scene:s,appState:r,elementsMap:c})})]})]})})})]})})},(e,n)=>e.sceneNonce===n.sceneNonce&&e.selectedElements===n.selectedElements&&e.appState.stats.panels===n.appState.stats.panels&&e.gridModeEnabled===n.gridModeEnabled&&e.appState.gridStep===n.appState.gridStep&&e.appState.croppingElementId===n.appState.croppingElementId);import{useCallback as vU,useEffect as XP,useState as ZP}from"react";import{normalizeLink as IU,KEYS as $E}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as TU,getLinkIdAndTypeFromSelection as SU}from"@excalidraw/element";import mU from"clsx";import{jsx as Zp,jsxs as uU}from"react/jsx-runtime";var pU=({label:e,onClick:n,className:t,children:o,actionType:r,type:i="button",isLoading:a,...s})=>{let l=r?`Dialog__action-button--${r}`:"";return uU("button",{className:mU("Dialog__action-button",l,t),type:i,"aria-label":e,onClick:n,...s,children:[o&&Zp("div",{style:a?{visibility:"hidden"}:{},children:o}),Zp("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Zp("div",{style:{position:"absolute",inset:0},children:Zp(So,{})})]})},KE=pU;import XE from"clsx";import{forwardRef as EU,useRef as bU,useImperativeHandle as xU,useLayoutEffect as yU,useState as wU}from"react";import hU from"clsx";import{composeEventHandlers as gU}from"@excalidraw/common";import{jsx as fU}from"react/jsx-runtime";var vn=({type:e="button",onSelect:n,selected:t,children:o,className:r="",...i})=>fU("button",{onClick:gU(i.onClick,a=>{n()}),type:e,className:hU("excalidraw-button",r,{selected:t}),...i,children:o});import{jsx as ZE,jsxs as KP}from"react/jsx-runtime";var $p=EU(({onChange:e,label:n,fullWidth:t,placeholder:o,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:s=!1,icon:l,className:c,type:d,...m},p)=>{let u=bU(null);xU(p,()=>u.current),yU(()=>{i&&(u.current?.focus(),u.current?.select())},[i]);let[E,g]=wU(!1);return KP("div",{className:XE("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!l}),onClick:()=>{u.current?.focus()},children:[l,n&&ZE("div",{className:"ExcTextField__label",children:n}),KP("div",{className:XE("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[ZE("input",{className:XE({"is-redacted":"value"in m&&m.value&&s&&!E}),readOnly:r,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:o,ref:u,onChange:b=>e?.(b.target.value),onKeyDown:a,type:d}),s&&ZE(vn,{onSelect:()=>g(!E),style:{border:0,userSelect:"none"},children:E?l0:Xr})]})]})});import{jsx as ms,jsxs as jp}from"react/jsx-runtime";var CU=({sourceElementId:e,onClose:n,appState:t,scene:o,generateLinkForSelection:r=TU})=>{let i=o.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[s,l]=ZP(a),[c,d]=ZP(!1);XP(()=>{let p=de(i,t),u=a;if(p.length>0&&r){let E=SU(p,t);E&&(u=IU(r(E.id,E.type)))}l(u)},[i,t,t.selectedElementIds,a,r]);let m=vU(()=>{if(s&&s!==i.get(e)?.link){let p=i.get(e);p&&o.mutateElement(p,{link:s})}if(!s&&c&&e){let p=i.get(e);p&&o.mutateElement(p,{link:null})}n?.()},[e,s,i,c,o,n]);return XP(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===$E.ENTER&&m(),t.openDialog?.name==="elementLinkSelector"&&u.key===$E.ESCAPE&&n?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,n,m]),jp("div",{className:"ElementLinkDialog",children:[jp("div",{className:"ElementLinkDialog__header",children:[ms("h2",{children:f("elementLink.title")}),ms("p",{children:f("elementLink.desc")})]}),jp("div",{className:"ElementLinkDialog__input",children:[ms($p,{value:s??"",onChange:p=>{c||d(!0),l(p)},onKeyDown:p=>{p.key===$E.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&s&&ms($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),d(!0)},className:"ElementLinkDialog__remove",icon:Vr})]}),jp("div",{className:"ElementLinkDialog__actions",children:[ms(KE,{label:f("buttons.cancel"),onClick:()=>{n?.()},style:{marginRight:10}}),ms(KE,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},$P=CU;import PU,{useState as kU}from"react";import{Fragment as MU,jsx as jE}from"react/jsx-runtime";var jP=({children:e,onClose:n})=>{let[t,o]=kU(!!e),{container:r}=ze(),i=PU.useCallback(()=>{o(!1),n&&n(),r?.focus()},[n,r]);return jE(MU,{children:t&&jE(wn,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:jE("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import qE from"clsx";import Un from"react";import{MIME_TYPES as qP,sceneCoordsToViewportCoords as JE}from"@excalidraw/common";import{getCommonBounds as ek,isInitializedImageElement as JP,ShapeCache as AU}from"@excalidraw/element";import{Fragment as BU,jsx as zt,jsxs as wi}from"react/jsx-runtime";var DU=zt("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:zt("path",{d:"M8 5v14l11 -7z"})}),LU=wi("svg",{viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",children:[zt("path",{d:"M8 5v14"}),zt("path",{d:"M16 5v14"})]}),_U=76,tk=4,dc=_U+tk,QP=8,vi=8,RU=(e,n)=>{let t=n/2;return Math.min(Math.max(e,t+vi),window.innerWidth-t-vi)},NU=(e,n)=>{let[,,t,o]=ek([e]),r=JE({sceneX:t,sceneY:o},n);return{left:Math.min(Math.max(r.x-n.offsetLeft,8),n.width-8),top:Math.min(Math.max(r.y-n.offsetTop,8),n.height-8)}},nk=({app:e,files:n,setAppState:t})=>{let o=ro(),[,r]=Un.useReducer(T=>T+1,0),[i,a]=Un.useState(0),[s,l]=Un.useState(!1),c=Un.useRef(null),d=Un.useRef(null),m=Un.useRef(null),p=Un.useRef(null),u=Un.useRef(null),E=Un.useRef(!1),[g,b]=Un.useState(null);Un.useLayoutEffect(()=>{let T=o.openPopup;if(T!=="gifSpeedPicker"&&T!=="gifFrameGallery"){g!==null&&b(null);return}let C=T==="gifSpeedPicker"?c.current:d.current,P=T==="gifSpeedPicker"?m.current:p.current;if(!C||!P)return;let M=C.getBoundingClientRect(),D=P.getBoundingClientRect(),_=RU(M.left+M.width/2,D.width),k=T==="gifSpeedPicker"?Math.max(vi,M.top-D.height-vi):Math.min(window.innerHeight-D.height-vi,M.bottom+vi),L={left:_,top:Math.max(vi,k)};b(F=>F?.left===L.left&&F.top===L.top?F:L)},[i,g,o.openPopup,o.scrollX,o.scrollY,o.zoom.value]);let v=(T,C)=>{AU.delete(T),e.scene.mutateElement(T,{gifPlayback:C}),e.scheduleUpdate(),t({}),r(),C.playing&&e.ensureGifPlaybackLoop()},w=e.scene.getNonDeletedElements().flatMap(T=>{if(!JP(T)||n[T.fileId]?.mimeType!==qP.gif||e.imageCache.get(T.fileId)?.gifDecodeStatus!=="deferred")return[];let C=NU(T,o);return[zt("div",{className:"gif-playback-controls gif-playback-controls--deferred",style:C,onPointerDown:P=>P.stopPropagation(),children:zt("button",{type:"button",className:"gif-playback-controls__load-large",title:"Load Large GIF",onClick:()=>{e.loadDeferredGif(T.fileId)},children:"Load Large GIF"})},T.id)]}),x=e.scene.getSelectedElements(o);return wi(BU,{children:[w,(()=>{if(x.length!==1)return null;let T=x[0];if(!JP(T)||n[T.fileId]?.mimeType!==qP.gif)return null;let C=e.imageCache.get(T.fileId),P=C?.gif,[M,,D,_]=ek([T]),k=JE({sceneX:M,sceneY:_},o),F=JE({sceneX:D,sceneY:_},o).x-k.x,K=k.x-o.offsetLeft+F/2,z=Math.max(12,Math.min(o.height-86,k.y-o.offsetTop+16));if(C?.gifDecodeStatus==="pending")return null;let U=P?.frames.length??0;if(!P||U<2)return null;let W=T.gifPlayback??{frameIndex:0,speed:1,playing:!1},G=e.state,ie=e.getGifPlaybackFrameIndex(T)??W.frameIndex,me=Math.min(Math.max(ie,0),U-1),B=Math.min(G.height-120,z+48),Y=Math.max(12,z-52),pe=Z=>{let ke=(Z+U)%U;e.setGifPlaybackFrameIndex(T,ke),v(T,{...W,frameIndex:ke,playing:!1})},ae=Z=>{Z.stopPropagation(),pe(me+(Z.deltaY<0?1:-1))},xe=Z=>{e.setGifPlaybackFrameIndex(T,me),v(T,{...W,frameIndex:me,playing:Z})},ce=[.25,.5,.75,1,1.25,1.5,1.75,2,4],Oe=Z=>{let ke=ce.indexOf(Z);return ke!==-1?ke:ce.reduce((Dt,Ts,_c)=>Math.abs(Ts-Z)<Math.abs(ce[Dt]-Z)?_c:Dt,0)},se=Z=>{v(T,{...W,speed:Z})},_e=Z=>{let ke=Oe(W.speed);se(ce[Math.min(Math.max(ke+Z,0),ce.length-1)])},Re=Number.isInteger(W.speed)?`${W.speed}`:`${W.speed}`,Se=U*dc-tk,Mt=Math.min(Math.max(G.width*.9,1),Se),kn=Math.max(Se-Mt,0),Mn=Math.min(i,kn),Ko=Math.max(Math.floor(Mn/dc)-QP,0),Ai=Math.ceil(Mt/dc)+QP*2,Di=Math.min(Ko+Ai,U),vs=P.frames.slice(Ko,Di),yo=Z=>{Z.pointerType!=="mouse"||Z.button!==0||(u.current={pointerId:Z.pointerId,startClientX:Z.clientX,startScrollLeft:Z.currentTarget.scrollLeft,didDrag:!1},Z.stopPropagation())},At=Z=>{let ke=u.current;if(!ke||ke.pointerId!==Z.pointerId)return;let Dt=Z.clientX-ke.startClientX;!ke.didDrag&&Math.abs(Dt)<=3||(ke.didDrag||(ke.didDrag=!0,Z.currentTarget.setPointerCapture?.(Z.pointerId),l(!0)),Z.currentTarget.scrollLeft=ke.startScrollLeft-Dt,a(Z.currentTarget.scrollLeft),Z.preventDefault(),Z.stopPropagation())},Is=Z=>{let ke=u.current;!ke||ke.pointerId!==Z.pointerId||(E.current=ke.didDrag,u.current=null,Z.currentTarget.hasPointerCapture?.(Z.pointerId)&&Z.currentTarget.releasePointerCapture(Z.pointerId),l(!1),Z.stopPropagation())},Li=Z=>{let ke=u.current;!ke||ke.pointerId!==Z.pointerId||(u.current=null,l(!1),Z.stopPropagation())},wo=Z=>{Z.pointerType!=="mouse"&&Z.stopPropagation()};return wi("div",{className:"gif-playback-controls",style:{left:K,top:z},onPointerDown:Z=>Z.stopPropagation(),children:[o.openPopup==="gifSpeedPicker"&&zt("div",{className:"gif-speed-picker",ref:m,style:g??{left:K,top:Y},children:ce.map(Z=>{let ke=Number.isInteger(Z)?`${Z}`:`${Z}`;return wi("button",{type:"button",className:qE("gif-speed-picker__speed",{"gif-speed-picker__speed--selected":Z===W.speed}),onClick:()=>se(Z),title:`${ke}x`,children:["x",ke]},Z)})}),wi("div",{className:"gif-playback-controls__bar",children:[wi("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--speed",ref:c,onClick:()=>t({openPopup:o.openPopup==="gifSpeedPicker"?null:"gifSpeedPicker"}),onWheel:Z=>{Z.stopPropagation(),_e(Z.deltaY<0?1:-1)},title:"Speed",children:["x",Re]}),zt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>pe(me-1),onWheel:ae,title:"Previous frame",children:o0}),zt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>xe(!W.playing),onWheel:ae,title:W.playing?"Pause":"Play",children:W.playing?LU:DU}),zt("button",{type:"button",className:"gif-playback-controls__button",onClick:()=>pe(me+1),onWheel:ae,title:"Next frame",children:r0}),zt("button",{type:"button",className:"gif-playback-controls__button gif-playback-controls__button--frames",ref:d,onClick:()=>{o.openPopup!=="gifFrameGallery"&&a(Math.max(me*dc-Mt/2,0)),t({openPopup:o.openPopup==="gifFrameGallery"?null:"gifFrameGallery"})},onWheel:ae,title:"Frames",children:i0})]}),o.openPopup==="gifFrameGallery"&&zt("div",{className:qE("gif-frame-gallery",{"gif-frame-gallery--dragging":s}),style:{...g??{left:K,top:B},width:Mt},ref:Z=>{p.current=Z,Z&&Z.scrollLeft!==Mn&&(Z.scrollLeft=Mn)},onScroll:Z=>{a(Z.currentTarget.scrollLeft)},onPointerDownCapture:wo,onPointerMoveCapture:wo,onPointerUpCapture:wo,onPointerCancelCapture:wo,onPointerDown:yo,onPointerMove:At,onPointerUp:Is,onPointerCancel:Li,onLostPointerCapture:Li,onClickCapture:Z=>{if(E.current){E.current=!1,Z.preventDefault(),Z.stopPropagation();return}E.current=!1},onWheelCapture:Z=>{Z.stopPropagation(),Z.currentTarget.scrollLeft+=Z.deltaY,a(Z.currentTarget.scrollLeft)},children:zt("div",{className:"gif-frame-gallery__spacer",style:{width:Se},children:vs.map((Z,ke)=>{let Dt=Ko+ke;return wi("button",{type:"button",className:qE("gif-frame-gallery__frame",{"gif-frame-gallery__frame--selected":Dt===me}),style:{left:Dt*dc},onClick:()=>pe(Dt),title:`Frame ${Dt+1}`,children:[zt("canvas",{width:Z.width,height:Z.height,ref:Ts=>{Ts?.getContext("2d")?.drawImage(Z,0,0)}}),zt("span",{children:Dt+1})]},Dt)})})})]})})()]})};import ok,{useMemo as VU}from"react";import rk from"clsx";import{isDarwin as ik,isFirefox as YU,isWindows as KU}from"@excalidraw/common";import{KEYS as ps}from"@excalidraw/common";import{SHAPES as XU}from"@excalidraw/element/shapes";import{isFirefox as FU,KEYS as QE}from"@excalidraw/common";import{SHAPES as OU}from"@excalidraw/element/shapes";import{Fragment as WU,jsx as Ue,jsxs as Ii}from"react/jsx-runtime";var zU=e=>Ii(WU,{children:[Ue("h3",{children:e.title}),Ue("div",{className:"HelpDialog__islands-container",children:e.children})]}),eb=e=>Ii("div",{className:`HelpDialog__island ${e.className}`,children:[Ue("h4",{className:"HelpDialog__island-title",children:e.caption}),Ue("div",{className:"HelpDialog__island-content",children:e.children})]});function*GU(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var HU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),pt=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>Ue(UU,{children:HU(a)},a)));return Ii("div",{className:"HelpDialog__shortcut",children:[Ue("div",{children:e}),Ue("div",{className:"HelpDialog__key-container",children:[...GU(o,t?f("helpDialog.or"):null)]})]})},UU=e=>Ue("kbd",{className:"HelpDialog__key",...e});function tb(){return Ii(zU,{title:f("helpDialog.shortcuts"),children:[Ii(eb,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Ue(pt,{label:f("toolBar.hand"),shortcuts:[QE.H]}),OU.filter(({myocSimplifiedMode:e})=>e).map(({value:e,key:n})=>Ue(pt,{label:f(`toolBar.${e}`),shortcuts:[...n]},e)),Ue(pt,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),Ue(pt,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0})]}),Ii(eb,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Ue(pt,{label:f("helpDialog.smartZoom"),shortcuts:[QE.F]}),Ue(pt,{label:f("labels.flipViewpointHorizontal"),shortcuts:[N("Shift+R")]}),Ue(pt,{label:f("labels.flipViewpointVertical"),shortcuts:[N("Alt+Shift+R")]}),Ue(pt,{label:f("helpDialog.dragToZoom"),shortcuts:[`${QE.Z}+${f("helpDialog.drag")}`]}),Ue(pt,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]})]}),Ii(eb,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Ue(pt,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),Ue(pt,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),Ue(pt,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Ue(pt,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(pr||FU)&&Ue(pt,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),Ue(pt,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),Ue(pt,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),Ue(pt,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),Ue(pt,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),Ue(pt,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]})]})]})}import{Fragment as sk,jsx as j,jsxs as Ti}from"react/jsx-runtime";var ZU=e=>Ti(sk,{children:[j("h3",{children:e.title}),j("div",{className:"HelpDialog__islands-container",children:e.children})]}),nb=e=>Ti("div",{className:`HelpDialog__island ${e.className}`,children:[j("h4",{className:"HelpDialog__island-title",children:e.caption}),j("div",{className:"HelpDialog__island-content",children:e.children})]});function*$U(e,n){let t=!0;for(let o of e)t||(yield n),t=!1,yield o}var jU=e=>e.replace(/\b[a-z]\b/,n=>n.toUpperCase()),J=({label:e,shortcuts:n,isOr:t=!0})=>{let o=n.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>j(qU,{children:jU(a)},a)));return Ti("div",{className:"HelpDialog__shortcut",children:[j("div",{children:e}),j("div",{className:"HelpDialog__key-container",children:[...$U(o,t?f("helpDialog.or"):null)]})]})},qU=e=>j("kbd",{className:"HelpDialog__key",...e}),ak=({onClose:e})=>{let[n,t]=ok.useState(!1),o=ok.useCallback(()=>{e&&e()},[e]),r=VU(()=>n?j("button",{className:rk("toggle-button",{}),onClick:()=>t(!1),children:f("helpDialog.myoc.showingAll")}):j("button",{className:rk("toggle-button",{}),onClick:()=>t(!0),children:f("helpDialog.myoc.showingBasic")}),[n]);return j(sk,{children:j(wn,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",titleButton:r,portalContainerClassName:"HelpDialog__modalContainer",children:n?Ti(ZU,{title:f("helpDialog.shortcuts"),children:[Ti(nb,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[j(J,{label:f("toolBar.hand"),shortcuts:[ps.H]}),XU.map(({value:i,key:a})=>j(J,{label:f(`toolBar.${i}`),shortcuts:[...a]},i)),j(J,{label:f("toolBar.frame"),shortcuts:[ps.F]}),j(J,{label:f("labels.eyeDropper"),shortcuts:[ps.I,"Shift+S","Shift+I"]}),j(J,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[N("CtrlOrCmd+Enter")]}),j(J,{label:f("helpDialog.editText"),shortcuts:[N("Enter")]}),j(J,{label:f("helpDialog.textNewLine"),shortcuts:[N("Enter"),N("Shift+Enter")]}),j(J,{label:f("helpDialog.textFinish"),shortcuts:[N("Esc"),N("CtrlOrCmd+Enter")]}),j(J,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(J,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),j(J,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),N("Enter")],isOr:!0}),j(J,{label:f("helpDialog.cropFinish"),shortcuts:[N("Enter"),N("Escape")],isOr:!0}),j(J,{label:f("toolBar.lock"),shortcuts:[ps.Q]}),j(J,{label:f("helpDialog.preventBinding"),shortcuts:[N("CtrlOrCmd")]}),j(J,{label:f("toolBar.link"),shortcuts:[N("CtrlOrCmd+K")]}),j(J,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Ti(nb,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[j(J,{label:f("helpDialog.smartZoom"),shortcuts:[ps.F]}),j(J,{label:f("helpDialog.dragToZoom"),shortcuts:[`${ps.Z}+${f("helpDialog.drag")}`]}),j(J,{label:f("buttons.zoomIn"),shortcuts:[N("CtrlOrCmd++")]}),j(J,{label:f("buttons.zoomOut"),shortcuts:[N("CtrlOrCmd+-")]}),j(J,{label:f("buttons.resetZoom"),shortcuts:[N("CtrlOrCmd+0")]}),j(J,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),j(J,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),j(J,{label:f("buttons.objectsSnapMode"),shortcuts:[N("Alt+S")]}),j(J,{label:f("labels.toggleGrid"),shortcuts:[N("CtrlOrCmd+'")]}),j(J,{label:f("labels.viewMode"),shortcuts:[N("Alt+R")]}),j(J,{label:f("labels.flipViewpointHorizontal"),shortcuts:[N("Shift+R")]}),j(J,{label:f("labels.flipViewpointVertical"),shortcuts:[N("Alt+Shift+R")]}),j(J,{label:f("stats.fullTitle"),shortcuts:[N("Alt+/")]}),j(J,{label:f("search.title"),shortcuts:[Je("searchMenu")]})]}),Ti(nb,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[j(J,{label:f("labels.moveCanvas"),shortcuts:[N(`Space+${f("helpDialog.drag")}`),N(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),j(J,{label:f("labels.delete"),shortcuts:[N("Delete")]}),j(J,{label:f("labels.cut"),shortcuts:[N("CtrlOrCmd+X")]}),j(J,{label:f("labels.copy"),shortcuts:[N("CtrlOrCmd+C")]}),j(J,{label:f("labels.paste"),shortcuts:[N("CtrlOrCmd+V")]}),j(J,{label:f("labels.pasteAsPlaintext"),shortcuts:[N("CtrlOrCmd+Shift+V")]}),j(J,{label:f("labels.selectAll"),shortcuts:[N("CtrlOrCmd+A")]}),j(J,{label:f("labels.multiSelect"),shortcuts:[N(`Shift+${f("helpDialog.click")}`)]}),j(J,{label:f("helpDialog.deepSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.click")}`)]}),j(J,{label:f("helpDialog.deepBoxSelect"),shortcuts:[N(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(pr||YU)&&j(J,{label:f("labels.copyAsPng"),shortcuts:[N("Shift+Alt+C")]}),j(J,{label:f("labels.sendToBack"),shortcuts:[ik?N("CtrlOrCmd+Alt+["):N("CtrlOrCmd+Shift+[")]}),j(J,{label:f("labels.bringToFront"),shortcuts:[ik?N("CtrlOrCmd+Alt+]"):N("CtrlOrCmd+Shift+]")]}),j(J,{label:f("labels.sendBackward"),shortcuts:[N("CtrlOrCmd+[")]}),j(J,{label:f("labels.bringForward"),shortcuts:[N("CtrlOrCmd+]")]}),j(J,{label:f("labels.alignTop"),shortcuts:[N("CtrlOrCmd+Shift+Up")]}),j(J,{label:f("labels.alignBottom"),shortcuts:[N("CtrlOrCmd+Shift+Down")]}),j(J,{label:f("labels.alignLeft"),shortcuts:[N("CtrlOrCmd+Shift+Left")]}),j(J,{label:f("labels.alignRight"),shortcuts:[N("CtrlOrCmd+Shift+Right")]}),j(J,{label:f("labels.arrangeElements"),shortcuts:[N("Shift+A")]}),j(J,{label:f("labels.duplicateSelection"),shortcuts:[N("CtrlOrCmd+D"),N(`Alt+${f("helpDialog.drag")}`)]}),j(J,{label:f("helpDialog.toggleElementLock"),shortcuts:[N("CtrlOrCmd+Shift+L")]}),j(J,{label:f("buttons.undo"),shortcuts:[N("CtrlOrCmd+Z")]}),j(J,{label:f("buttons.redo"),shortcuts:KU?[N("CtrlOrCmd+Y"),N("CtrlOrCmd+Shift+Z")]:[N("CtrlOrCmd+Shift+Z")]}),j(J,{label:f("labels.group"),shortcuts:[N("CtrlOrCmd+G")]}),j(J,{label:f("labels.ungroup"),shortcuts:[N("CtrlOrCmd+Shift+G")]}),j(J,{label:f("labels.flipHorizontal"),shortcuts:[N("Shift+H")]}),j(J,{label:f("labels.flipVertical"),shortcuts:[N("Shift+V")]}),j(J,{label:f("labels.showStroke"),shortcuts:[N("S")]}),j(J,{label:f("labels.showBackground"),shortcuts:[N("G")]}),j(J,{label:f("labels.showFonts"),shortcuts:[N("Shift+F")]}),j(J,{label:f("labels.decreaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+<")]}),j(J,{label:f("labels.increaseFontSize"),shortcuts:[N("CtrlOrCmd+Shift+>")]})]})]}):j(tb,{})})})};import{CANVAS_SEARCH_TAB as JU,DEFAULT_SIDEBAR as QU}from"@excalidraw/common";import{isArrowElement as eW,isFlowchartNodeElement as tW,isImageElement as lk,isLinearElement as ck,isLineElement as nW,isTextBindableContainer as oW,isTextElement as rW}from"@excalidraw/element";import{isNodeInFlowchart as iW}from"@excalidraw/element";import{jsx as ob}from"react/jsx-runtime";var ve=e=>Array.isArray(e)?`<kbd>${e.map(N).join(" + ")}</kbd>`:`<kbd>${N(e)}</kbd>`,aW=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:s}=e,l=e.multiElement!==null;if(e.openSidebar?.name===QU.name&&e.openSidebar.tab===JU&&e.searchMatches?.matches.length)return f("hints.dismissSearch",{shortcut:ve("Escape")});if(e.openSidebar&&!t.canFitSidebar)return null;if(rn(e))return f("hints.eraserRevert",{shortcut:ve("Alt")});let c=o.scene.getSelectedElements(e);if(e.selectedLinearElement?.isDragging&&c[0]?.type==="arrow")return f("hints.arrowBindModifiers",{shortcut_1:ve("Ctrl"),shortcut_2:ve("Alt")});if(r.type==="arrow"||r.type==="line")return l?f("hints.linearElementMulti",{shortcut_1:ve("Escape"),shortcut_2:ve("Enter")}):r.type==="arrow"?f("hints.arrowTool",{shortcut:ve("A")}):f("hints.linearElement");if(r.type==="freedraw")return f("hints.freeDraw");if(r.type==="text")return f("hints.text");if(r.type==="embeddable")return f("hints.embeddable");if(r.type==="autoshape")return f("hints.autoshape");if(i&&s==="mouse"&&c.length===1){let d=c[0];return ck(d)&&d.points.length===2?f("hints.lockAngle",{shortcut:ve("Shift")}):lk(d)?f("hints.resizeImage",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")}):f("hints.resize",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")})}if(a&&s==="mouse")return f("hints.rotate",{shortcut:ve("Shift")});if(c.length===1&&rW(c[0]))return f("hints.text_selected",{shortcut:ve("Enter")});if(e.editingTextElement)return f("hints.text_editing",{shortcut_1:ve("Escape"),shortcut_2:ve(["CtrlOrCmd","Enter"])});if(e.croppingElementId)return f("hints.leaveCropEditor",{shortcut_1:ve("Enter"),shortcut_2:ve("Escape")});if(c.length===1&&lk(c[0]))return f("hints.enterCropEditor",{shortcut_1:ve("double click"),shortcut_2:ve("Enter")});if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return f("hints.deepBoxSelect",{shortcut:ve("CtrlOrCmd")});if(yr(o)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping",{shortcut:ve("CtrlOrCmd")});if(!c.length&&!n)return f("hints.canvasPanning",{shortcut_1:ve(f("keys.mmb")),shortcut_2:ve("Space")});if(c.length===1){if(ck(c[0]))return eW(c[0])&&e.selectedLinearElement?.elementId===c[0].id&&(e.selectedLinearElement.hoverPointIndex===0||e.selectedLinearElement.hoverPointIndex===c[0].points.length-1)?f("hints.toggleArrowhead"):e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected",{shortcut_1:ve("Delete"),shortcut_2:ve(["CtrlOrCmd","D"])}):f("hints.lineEditor_nothingSelected",{shortcut_1:ve("Shift"),shortcut_2:ve("Alt")}):nW(c[0])?f("hints.lineEditor_line_info",{shortcut:ve("Enter")}):f("hints.lineEditor_info",{shortcut_1:ve("CtrlOrCmd"),shortcut_2:ve(["CtrlOrCmd","Enter"])});if(!e.newElement&&!e.selectedElementsAreBeingDragged&&oW(c[0])){let d=f("hints.bindTextToElement",{shortcut:ve("Enter")}),m=f("hints.createFlowchart",{shortcut:ve(["CtrlOrCmd","\u2191\u2193"])});return tW(c[0])?iW(c[0],o.scene.getNonDeletedElementsMap())?[d,m]:[d,m]:d}}}return null},qp=({appState:e,isMobile:n,editorInterface:t,app:o})=>{let i=Oi(xa)?uv:e.viewModeEnabled?null:aW({appState:e,isMobile:n,editorInterface:t,app:o});if(!i)return null;let s=(Array.isArray(i)?i.map(l=>l.replace(/\. ?$/,"")).join(", "):i).split(/(<kbd>[^<]+<\/kbd>)/g).map((l,c)=>{if(c%2===1){let d=l[0]==="<"&&l.match(/^<kbd>([^<]+)<\/kbd>$/);return ob("kbd",{children:d?d[1]:l},c)}return l});return ob("div",{className:"HintViewer",children:ob("span",{children:s})})};import{useEffect as mk,useRef as pk,useState as Si}from"react";import{DEFAULT_EXPORT_PADDING as mW,EXPORT_IMAGE_TYPES as rb,isFirefox as pW,EXPORT_SCALES as uW,cloneJSON as uk}from"@excalidraw/common";import{useCallback as sW,useRef as lW,useState as cW}from"react";var dW=2e3,dk=()=>{let[e,n]=cW(null),t=lW(0),o=()=>{clearTimeout(t.current),n("success"),t.current=window.setTimeout(()=>{n(null)},dW)},r=sW(()=>{n(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:o}};import{jsx as Ke,jsxs as Lr}from"react/jsx-runtime";var hW=()=>Lr("div",{children:[Ke("h3",{children:f("canvasError.cannotShowPreview")}),Ke("p",{children:Ke("span",{children:f("canvasError.canvasTooBig")})}),Lr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),gW=({appStateSnapshot:e,elementsSnapshot:n,files:t,actionManager:o,onExportImage:r,name:i,exportWithDarkMode:a})=>{let s=Ne(n,e),[l,c]=Si(i),[d,m]=Si(s),[p,u]=Si(e.exportBackground),[E,g]=Si(e.exportEmbedScene),[b,v]=Si(e.exportScale),w=pk(null),x=pk(0),[I,T]=Si(null),{onCopy:C,copyStatus:P,resetCopyStatus:M}=dk();mk(()=>{M()},[l,p,a,b,E,M]);let{exportedElements:D,exportingFrame:_}=Qr(n,e,d);return mk(()=>{let k=w.current;if(!k)return;let L=k.offsetWidth,F=k.offsetHeight;if(!L)return;let K=++x.current,z=()=>K!==x.current;return Up({elements:D,appState:{...e,name:l,exportBackground:p,exportWithDarkMode:a,exportScale:b,exportEmbedScene:E},files:t,exportPadding:mW,maxWidthOrHeight:Math.max(L,F),exportingFrame:_}).then(async U=>{if(!z()){try{await Ds(U)}catch(W){throw W.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):W}z()||(T(null),k.replaceChildren(U))}}).catch(U=>{z()||(console.error(U),T(U))}),()=>{x.current+=1}},[e,t,D,_,l,p,a,b,E]),Lr("div",{className:"ImageExportModal",children:[Ke("h3",{children:f("imageExportDialog.header")}),Lr("div",{className:"ImageExportModal__preview",children:[Ke("div",{className:"ImageExportModal__preview__canvas",ref:w,children:I&&Ke(hW,{})}),Ke("div",{className:"ImageExportModal__preview__filename",children:!Ni&&Ke("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{c(k.target.value),o.executeAction(mg,"ui",k.target.value)}})})]}),Lr("div",{className:"ImageExportModal__settings",children:[Ke("h3",{children:f("imageExportDialog.header")}),s&&Ke(mc,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ke(ri,{name:"exportOnlySelected",checked:d,onChange:k=>{m(k)}})}),Ke(mc,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ke(ri,{name:"exportBackgroundSwitch",checked:p,onChange:k=>{u(k),o.executeAction(pg,"ui",k)}})}),Ke(mc,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ke(ri,{name:"exportDarkModeSwitch",checked:a,onChange:k=>{o.executeAction(Rw,"ui",k)}})}),Ke(mc,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ke(ri,{name:"exportEmbedSwitch",checked:E,onChange:k=>{g(k),o.executeAction(lm,"ui",k)}})}),Ke(mc,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Ke(Lp,{name:"exportScale",value:b,onChange:k=>{v(k),o.executeAction(Lw,"ui",k)},choices:uW.map(k=>({value:k,label:`${k}\xD7`}))})}),Lr("div",{className:"ImageExportModal__settings__buttons",children:[Ke(Pr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r(rb.png,D,{exportingFrame:_}),icon:ah,children:f("imageExportDialog.button.exportToPng")}),Ke(Pr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r(rb.svg,D,{exportingFrame:_}),icon:ah,children:f("imageExportDialog.button.exportToSvg")}),(pr||pW)&&Ke(Pr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await r(rb.clipboard,D,{exportingFrame:_}),C()},icon:e0,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},mc=({label:e,children:n,tooltip:t,name:o})=>Lr("div",{className:"ImageExportModal__settings__setting",title:e,children:[Lr("label",{htmlFor:o,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ke(ht,{label:t,long:!0,children:n0})]}),Ke("div",{className:"ImageExportModal__settings__setting__content",children:n})]}),hk=({elements:e,appState:n,files:t,actionManager:o,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:s,elementsSnapshot:l}]=Si(()=>({appStateSnapshot:uk(n),elementsSnapshot:uk(e)}));return Ke(wn,{onCloseRequest:i,size:"wide",title:!1,children:Ke(gW,{elementsSnapshot:l,appStateSnapshot:s,files:t,actionManager:o,onExportImage:r,name:a,exportWithDarkMode:n.exportWithDarkMode})})};import oV from"clsx";import{CANVAS_SEARCH_TAB as _k,DEFAULT_SIDEBAR as rV}from"@excalidraw/common";import fW from"clsx";import EW from"lodash.debounce";import{Fragment as bW,memo as xW,useEffect as pc,useMemo as gk,useRef as ib,useState as fk}from"react";import{CLASSES as yW,EVENT as wW,FONT_FAMILY as ab,FRAME_STYLE as sb,getLineHeight as vW}from"@excalidraw/common";import{getCommonBounds as IW,isElementCompletelyInViewport as TW}from"@excalidraw/element";import{measureText as uc}from"@excalidraw/element";import{KEYS as us,randomInteger as Ek,addEventListener as SW,getFontString as Jp}from"@excalidraw/common";import{newTextElement as CW}from"@excalidraw/element";import{isTextElement as wk,isFrameLikeElement as Qp}from"@excalidraw/element";import{getDefaultFrameName as vk}from"@excalidraw/element/frame";import{Fragment as BW,jsx as Et,jsxs as Wn}from"react/jsx-runtime";var PW=Qe(""),lb=Qe(null),kW=350,Ik=()=>{let e=xt(),n=Ve(),t=ib(null),[o,r]=Xe(PW),i=o.trim(),[a,s]=fk(!1),[l,c]=fk({nonce:null,items:[]}),d=ib(null),m=ib(void 0),[p,u]=Xe(lb),E=e.scene.getNonDeletedElementsMap();pc(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,yk(i,e,(x,I)=>{c({nonce:Ek(),items:x}),d.current=i,m.current=e.scene.getSceneNonce(),n({searchMatches:x.length?{focusedId:null,matches:x.map(T=>({id:T.element.id,focus:!1,matchedLines:T.matchedLines}))}:null})}))},[a,i,E,e,n,u,m]);let g=()=>{l.items.length>0&&u(x=>x===null?0:(x+1)%l.items.length)},b=()=>{l.items.length>0&&u(x=>x===null?0:x-1<0?l.items.length-1:x-1)};pc(()=>{n(x=>x.searchMatches?{searchMatches:{focusedId:p!==null&&x.searchMatches?.matches[p]?.id||null,matches:x.searchMatches.matches.map((T,C)=>C===p?{...T,focus:!0}:{...T,focus:!1})}}:null)},[p,n]),pc(()=>{if(l.items.length>0&&p!==null){let x=l.items[p];if(x){let I=e.state.zoom.value,T=CW({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:Qp(x.element)?sb.nameFontSize:x.element.fontSize,fontFamily:Qp(x.element)?ab.Assistant:x.element.fontFamily}),C=14,P=T.fontSize,M=P*I<C;if(!TW([T],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.viewport.getOffsets())||M){let D=M&&P<C?"contain":"scale-down";e.viewport.setViewport({target:IW([T]),fit:D,animation:{duration:300},offsets:{ui:!0}})}}}},[p,l,e]),pc(()=>()=>{u(null),d.current=null,m.current=void 0,n({searchMatches:null}),s(!1)},[n,u]);let v=ji({goToNextItem:g,goToPreviousItem:b,searchMatches:l});pc(()=>{let x=I=>{if(I.key===us.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){I.preventDefault(),I.stopPropagation(),n({openSidebar:null});return}if(I[us.CTRL_OR_CMD]&&I.key===us.F){if(I.preventDefault(),I.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&n({openDialog:null}),t.current?.focus(),t.current?.select())}I.target instanceof HTMLElement&&I.target.closest(".layer-ui__search")&&v.searchMatches.items.length&&(I.key===us.ENTER&&(I.stopPropagation(),v.goToNextItem()),I.key===us.ARROW_UP?(I.stopPropagation(),v.goToPreviousItem()):I.key===us.ARROW_DOWN&&(I.stopPropagation(),v.goToNextItem()))};return SW(window,wW.KEYDOWN,x,{capture:!0,passive:!1})},[n,v,e]);let w=`${l.items.length} ${l.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return Wn("div",{className:"layer-ui__search",children:[Wn("div",{className:"layer-ui__search-header",children:[Et($p,{className:yW.SEARCH_MENU_INPUT_WRAPPER,value:o,ref:t,placeholder:f("search.placeholder"),icon:oo,onChange:x=>{r(x),s(!0);let I=x.trim();yk(I,e,(T,C)=>{c({nonce:Ek(),items:T}),u(C),d.current=I,m.current=e.scene.getSceneNonce(),n({searchMatches:T.length?{focusedId:null,matches:T.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),s(!1)})},selectOnRender:!0}),Et(vn,{"data-testid":"sidebar-close",className:"layer-ui__search-close",onSelect:()=>{n({openSidebar:null})},"aria-label":f("buttons.close"),children:an})]}),Wn("div",{className:"layer-ui__search-count",children:[l.items.length>0&&Wn(BW,{children:[p!==null&&p>-1?Wn("div",{children:[p+1," / ",w]}):Et("div",{children:w}),Wn("div",{className:"result-nav",children:[Et(vn,{onSelect:()=>{g()},className:"result-nav-btn",children:td}),Et(vn,{onSelect:()=>{b()},className:"result-nav-btn",children:w0})]})]}),l.items.length===0&&i&&d.current&&Et("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),Et(DW,{matches:l,onItemClick:u,focusIndex:p,searchQuery:i})]})},bk=e=>{let n=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return Et("div",{tabIndex:-1,className:fW("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Et("div",{className:"preview-text",children:n.flatMap((t,o)=>Et(bW,{children:o===2?Et("b",{children:t}):t},o))})})},MW=e=>{let n=gk(()=>e.matches.items.filter(o=>Qp(o.element)),[e.matches]),t=gk(()=>e.matches.items.filter(o=>wk(o.element)),[e.matches]);return Wn("div",{className:"layer-ui__search-results",children:[n.length>0&&Wn("div",{className:"layer-ui__search-result-container",children:[Wn("div",{className:"layer-ui__search-result-title",children:[Et("div",{className:"title-icon",children:to}),Et("div",{children:f("search.frames")})]}),n.map((o,r)=>Et(bk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},o.element.id+o.index)),t.length>0&&Et("div",{className:"layer-ui__divider"})]}),t.length>0&&Wn("div",{className:"layer-ui__search-result-container",children:[Wn("div",{className:"layer-ui__search-result-title",children:[Et("div",{className:"title-icon",children:Dn}),Et("div",{children:f("search.texts")})]}),t.map((o,r)=>Et(bk,{searchQuery:e.searchQuery,preview:o.preview,highlighted:r+n.length===e.focusIndex,onClick:()=>e.onItemClick(r+n.length)},o.element.id+o.index))]})]})},AW=(e,n)=>e.matches.nonce===n.matches.nonce&&e.focusIndex===n.focusIndex,DW=xW(MW,AW),xk=(e,n,t)=>{let i=e.slice(0,n),a=i.split(/\s+/),s=i.endsWith(" "),l=a.length-2-1-(s?0:1),c=a.slice(l<=0?0:l).join(" ")+(s?" ":""),d=20;c=c.length>d?c.slice(-d):c;let m=e.slice(n+t.length),p=m.split(/\s+/),u=!m.startsWith(" "),E=u?6:5,g=(u?"":" ")+p.slice(0,E).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+g,moreBefore:l>0,moreAfter:p.length>E}},LW=(e,n)=>{let t=e.split(`
19
19
  `),o=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],s=t[i+1];if(s){let l=n.indexOf(s,r);if(l>a.length+r){let c=l-(a.length+r);for(;c>0;)a+=" ",c--}}o.push(a),r=r+a.length}return o.join(`
20
- `)},AW=(e,n,t)=>{let r=MW(e.text,e.originalText).split(`
21
- `),i=[],a=0,s=0;for(let m of r){let p=a,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:s}),a=u+1,s++}let l=t,c=e.originalText.slice(t,t+n.length),d=[];for(let m of i){if(c==="")break;if(l>=m.startIndex&&l<=m.endIndex){let p=m.endIndex+1-l,u=m.line.slice(0,l-m.startIndex),E=c.slice(0,p);c=c.slice(p);let g=uc(u,qp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let I=uc(m.line,qp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-I.width)/2:e.width-I.width;g.width+=T}let{width:b,height:v}=uc(E,qp(e),e.lineHeight),y=g.width,x=m.lineNumber*g.height;d.push({offsetX:y,offsetY:x,width:b,height:v,showOnCanvas:!0}),l+=p}}return d},DW=(e,n,t,o)=>{let r=e.name??xk(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=qp({fontSize:sb.nameFontSize,fontFamily:ab.Assistant}),l=xW(ab.Assistant),c=uc(a,s,l);a===""&&(c.width=0);let d=uc(i,s,l),m=c.width,p=-c.height-sb.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},LW=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),Ek=hW((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>bk(p)),i=o.filter(p=>Jp(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(LW(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=fk(E,u.index,e),b=AW(p,e,u.index);b.length>0&&a.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let l=[];for(let p of i){let u=null,E=p.name??xk(p);for(;(u=s.exec(E))!==null;){let g=fk(E,u.index,e),b=DW(p,e,u.index,n.state.zoom.value);b.length>0&&l.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let c=new Set(n.visibleElements.map(p=>p.id)),d=[...l,...a],m=d.findIndex(p=>c.has(p.element.id))??null;t(d,m)},SW);import KW from"clsx";import{useEffect as Ck,useLayoutEffect as Pk,useRef as Eb,useState as XW,forwardRef as kk,useImperativeHandle as ZW,useCallback as Ik}from"react";import{CLASSES as $W,EVENT as Tk,isDevEnv as jW,KEYS as qW,updateObject as JW}from"@excalidraw/common";import NW from"clsx";import{useContext as BW}from"react";import RW from"react";var Qp=RW.createContext({});import{jsx as cb,jsxs as wk}from"react/jsx-runtime";var db=({children:e,className:n})=>{let t=Ee(),o=BW(Qp),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return wk("div",{className:NW("sidebar__header",n),"data-testid":"sidebar-header",children:[e,wk("div",{className:"sidebar__header__buttons",children:[r&&cb(ht,{label:f("labels.sidebarLock"),children:cb(vn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:Wx})}),cb(vn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:an})]})]})};db.displayName="SidebarHeader";import{Tabs as FW}from"radix-ui";import{jsx as vk}from"react/jsx-runtime";var mb=({children:e,tab:n,onSelect:t,...o})=>vk(FW.Trigger,{value:n,asChild:!0,onSelect:t,children:vk("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});mb.displayName="SidebarTabTrigger";import{Tabs as OW}from"radix-ui";import{jsx as zW}from"react/jsx-runtime";var pb=({children:e,...n})=>zW(OW.List,{className:"sidebar-triggers",...n,children:e});pb.displayName="SidebarTabTriggers";import GW from"clsx";import{jsx as ub,jsxs as HW}from"react/jsx-runtime";var hb=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=We(),d=xe().openSidebar?.name===e;return ub("button",{type:"button",title:o,className:"sidebar-trigger__label-element","aria-label":o,"aria-keyshortcuts":"0","aria-pressed":d,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=!d;l({openSidebar:m?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(m)},children:HW("div",{className:GW("sidebar-trigger",a),style:s,children:[t&&ub("div",{children:t}),r&&ub("div",{className:"sidebar-trigger__label",children:r})]})})};hb.displayName="SidebarTrigger";import{Tabs as UW}from"radix-ui";import{jsx as WW}from"react/jsx-runtime";var gb=({children:e,...n})=>{let t=xe(),o=We();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return WW(UW.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};gb.displayName="SidebarTabs";import{Tabs as VW}from"radix-ui";import{jsx as YW}from"react/jsx-runtime";var fb=({tab:e,children:n,...t})=>YW(VW.Content,{...t,value:e,"data-testid":e,children:n});fb.displayName="SidebarTab";import{jsx as Sk}from"react/jsx-runtime";import{createElement as QW}from"react";var bb=Je(!1),Mk=kk(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{jW()&&t&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=We(),l=Fx(bb);Pk(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=Eb({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=JW(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=Eb(null);ZW(a,()=>d.current);let m=Ee(),p=Ik(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return Xi(d,Ik(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),Ck(()=>{let u=E=>{E.key===qW.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(Tk.KEYDOWN,u),()=>{document.removeEventListener(Tk.KEYDOWN,u)}},[p,o,m.canFitSidebar]),Sk(Xe,{...i,className:KW($W.SIDEBAR,{"sidebar--docked":o},r),"data-viewport-ui":m.formFactor!=="phone"?"side":void 0,"data-viewport-ui-name":m.formFactor!=="phone"?"sidebar":void 0,ref:d,children:Sk(Qp.Provider,{value:c.current,children:n})})});Mk.displayName="SidebarInner";var Dr=Object.assign(kk((e,n)=>{let t=xe(),{onStateChange:o}=e,r=Eb(t.openSidebar);Ck(()=>{(!t.openSidebar&&r?.current?.name===e.name||t.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&t.openSidebar!==r.current&&o?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,o,e.name]);let[i,a]=XW(!1);return Pk(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?QW(Mk,{...e,ref:n,key:e.name}):null}),{Header:db,TabTriggers:pb,TabTrigger:mb,Tabs:gb,Tab:fb,Trigger:hb});Dr.displayName="Sidebar";import{jsx as hs,jsxs as nV}from"react/jsx-runtime";import{createElement as oV}from"react";var Dk=fi("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=it();return hs(n.In,{children:hs(Dr.Trigger,{...e,className:"default-sidebar-trigger",name:tV.name})})});Dk.displayName="DefaultSidebarTrigger";var Lk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=it();return hs(n.In,{children:e})};Lk.displayName="DefaultTabTriggers";var xb=Object.assign(fi("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=xe(),a=We(),s=i.openSidebar?.tab===Ak,l=s?!1:t??i.defaultSidebarDockedPreference,c=!s&&t==null&&o!==!1;return oV(Dr,{...r,name:"default",key:"default",className:eV("default-sidebar",{"default-sidebar--search-only":s},n),docked:l,onDock:c?d=>{a({defaultSidebarDockedPreference:d}),o?.(d)}:void 0},nV(Dr.Tabs,{children:[!s&&hs(Dr.Header,{}),hs(Dr.Tab,{tab:Ak,children:hs(yk,{})}),!s&&e]}))}),{Trigger:Dk,TabTriggers:Lk});import iV from"react";import{getFrame as aV}from"@excalidraw/common";import{jsx as rV}from"react/jsx-runtime";var yb={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"}},wb=({children:e,color:n})=>rV("div",{className:"Card",style:{"--card-color":yb[n].base,"--card-color-darker":yb[n].darker,"--card-color-darkest":yb[n].darkest},children:e});import{Fragment as lV,jsx as Vn,jsxs as eu}from"react/jsx-runtime";var sV=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return Vn("div",{className:"ExportDialog ExportDialog--json",children:eu("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&eu(wb,{color:"lime",children:[Vn("div",{className:"Card-icon",children:a1}),Vn("h2",{children:f("exportDialog.disk_title")}),eu("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!_i&&r.renderAction("changeProjectName")]}),Vn($,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(ul,"ui")}})]}),l&&eu(wb,{color:"pink",children:[Vn("div",{className:"Card-icon",children:Fs}),Vn("h2",{children:f("exportDialog.link_title")}),Vn("div",{className:"Card-details",children:f("exportDialog.link_details")}),Vn($,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{Ue("export","link",`ui (${aV()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},_k=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=iV.useCallback(()=>{a({openDialog:null})},[a]);return Vn(lV,{children:n.openDialog?.name==="jsonExport"&&Vn(wn,{onCloseRequest:s,title:f("buttons.export"),children:Vn(sV,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import cV from"clsx";import{jsx as dV}from"react/jsx-runtime";var Rk=e=>dV($,{className:cV("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:no,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import Ok from"clsx";import{useState as uV}from"react";import{CANVAS_SEARCH_TAB as hV,DEFAULT_SIDEBAR as gV,KEYS as hc}from"@excalidraw/common";import mV from"clsx";import{jsx as pV}from"react/jsx-runtime";var Nk=e=>pV($,{className:mV("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?$o:To,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":"toolbar-lock",onSelect:()=>e.onChange?.()});import{Fragment as Ti,jsx as re,jsxs as zo}from"react/jsx-runtime";var fV=(e,n)=>e==="image"&&n.tools?.image===!1,EV=({app:e,activeTool:n,type:t,shortcut:o})=>re(ge.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:$e[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??ca(t),disabled:tt(e,t),children:f(`toolBar.${t}`)}),Bk=({app:e})=>re(ge.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?$o:To,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:hc.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),bV=({actionManager:e,app:n})=>{if(!e.isActionEnabled(_t))return null;let t=et("objectsSnapMode");return re(ge.Item,{onSelect:()=>e.executeAction(_t,"ui"),icon:Jo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},xV=({actionManager:e,app:n})=>{if(!e.isActionEnabled(_t))return null;let t=f("buttons.objectsSnapMode"),o=et("objectsSnapMode");return re($,{type:"toggle",icon:Jo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(_t,"ui")})},Fk=({actionManager:e,appState:n})=>{let t=f("search.title"),o=et("searchMenu");return re(ge.Item,{onSelect:()=>e.executeAction(Nl,"ui"),icon:oo,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===gV.name&&n.openSidebar.tab===hV,shortcut:o,children:t})},yV=({app:e})=>re($,{type:"button",icon:Vi,title:`${f("labels.eyeDropper")} - ${hc.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":hc.I.toLocaleUpperCase(),keyBindingLabel:hc.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),wV=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=uV(!1),l=mt()==="full",c=n.type==="frame",d=n.type==="autoshape",m=n.type==="laser",p=n.type==="bucketfill",u=l&&n.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",E=n.type==="embeddable",g=r&&sa.includes(n.type);return zo(ge,{open:a,children:[re(ge.Trigger,{className:Ok("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":g||c||E||!r&&l&&d||u||p||m&&!e.props.isCollaborating}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:g?$e[n.type].icon:c?to:E?qo:!r&&l&&d?Vr:m&&!e.props.isCollaborating?no:u?zi:p?eo:Ls}),re(ge.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?zo(Ti,{children:[l&&re(ge.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:zi,"data-testid":"toolbar-lasso",selected:u,disabled:tt(e,"lasso"),children:f("toolBar.lasso")}),sa.filter(b=>!fV(b,o)).map(b=>re(EV,{app:e,activeTool:n,type:b},b)),re("div",{className:"App-toolbar__dropdown-divider"}),re(Fk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&re(Ti,{children:re(Bk,{app:e})})]}):zo(Ti,{children:[re(ge.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:to,shortcut:hc.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:tt(e,"frame"),children:f("toolBar.frame")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:qo,"data-testid":"toolbar-embeddable",selected:E,disabled:tt(e,"embeddable"),children:f("toolBar.embeddable")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Vr,shortcut:ca("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:tt(e,"autoshape"),children:f("toolBar.autoshape")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:no,"data-testid":"toolbar-laser",selected:m,disabled:tt(e,"laser"),children:f("toolBar.laser")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:eo,"data-testid":"toolbar-bucketfill",selected:p,disabled:tt(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&re(ge.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:zi,"data-testid":"toolbar-lasso",selected:u,disabled:tt(e,"lasso"),children:f("toolBar.lasso")}),re("div",{className:"App-toolbar__dropdown-divider"}),re(bV,{actionManager:i,app:e}),re(Fk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&re(Bk,{app:e})]})})]})},zk=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=Ee(),c=mt()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?re(Zd,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?re(cw,{...m}):re(lw,{...m});return zo(Xe,{padding:1,className:Ok("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[re(jp,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,zo(Ft.Row,{gap:c?.5:1,children:[!c&&re(rs,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&zo(Ti,{children:[re(Nk,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),re("div",{className:"App-toolbar__divider"})]}),re(Xd,{...m}),u,p?zo(Ti,{children:[re(ol,{...m}),re(rl,{...m}),re(yV,{app:e}),o.tools?.image!==!1&&re(il,{...m}),re(al,{...m})]}):zo(Ti,{children:[re(nw,{...m}),re(ow,{...m}),re(rw,{...m}),re(iw,{...m}),re(aw,{...m}),c?re($d,{...m}):re(ol,{...m}),re(rl,{...m}),o.tools?.image!==!1&&re(il,{...m}),re(al,{...m})]}),re("div",{className:"App-toolbar__divider"}),re(wV,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&zo(Ti,{children:[re("div",{className:"App-toolbar__divider"}),re(xV,{actionManager:r,app:e})]})]})]})};import{Fragment as vb,jsx as te,jsxs as nn}from"react/jsx-runtime";var kV=({UIOptions:e})=>nn(Ot,{__fallback:!0,children:[te(Ot.DefaultItems.LoadScene,{}),te(Ot.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&te(Ot.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&te(Ot.DefaultItems.SaveAsImage,{}),te(Ot.DefaultItems.SearchMenu,{}),te(Ot.DefaultItems.Help,{}),te(Ot.Separator,{}),te(Ot.Group,{title:"Excalidraw links",children:te(Ot.DefaultItems.Socials,{})}),te(Ot.Separator,{}),te(Ot.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),te(Ot.DefaultItems.ChangeCanvasBackground,{})]}),MV=()=>nn(Bp,{__fallback:!0,children:[te(Bp.Actions.SaveToDisk,{}),te(Bp.Actions.ExportToImage,{})]}),AV=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:s,showExitZenModeBtn:l,renderTopLeftUI:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:v,zoomUIEnabled:y,scrollBackToContentUIEnabled:x,isCollaborating:I,generateLinkForSelection:T,currentUserControls:C})=>{let P=Ee(),M=Ln(),_=mt()==="compact",k=hS(),L=_?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},F=k.tunnelsJotai.Provider,[K,z]=Ke(Ut),U=()=>p.canvasActions.export?te(_k,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,W=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:te(mk,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),G=()=>nn("div",{style:{position:"relative"},children:[nn("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),te(k.MainMenuTunnel.Out,{}),te(k.DefaultSidebarTriggerTunnel.Out,{})]}),E&&te(k.WelcomeScreenMenuHintTunnel.Out,{})]}),ie=()=>te(tc,{heading:"selectedShapeActions",className:gs("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?te(Xe,{className:gs("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:te(_S,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):te(Xe,{className:IV.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:te(kS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),me=()=>{let ae=v&&PV(n,r),be=v&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return te(Pp,{side:"top",children:nn("div",{className:"App-menu App-menu_top",children:[nn(Ft.Col,{gap:L.menuTopGap,className:gs("App-menu_top__left"),children:[G(),v&&te("div",{className:gs("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:ae&&ie()}),v&&_&&!n.viewModeEnabled&&ae&&te(rs,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),v&&n.viewModeEnabled&&te("div",{className:"view-mode-hint",children:te(jp,{appState:n,isMobile:P.formFactor==="phone",editorInterface:P,app:b})}),v&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&te(tc,{heading:"shapes",className:"shapes-section",children:ce=>nn("div",{style:{position:"relative"},children:[E&&te(k.WelcomeScreenToolbarHintTunnel.Out,{}),te(Ft.Col,{gap:L.toolbarColGap,align:"start",children:nn(Ft.Row,{gap:L.toolbarRowGap,className:gs("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[te(zk,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ce}),I&&te(Xe,{style:{marginLeft:L.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:te(Rk,{title:f("toolBar.laser"),checked:n.activeTool.type===Gk.laser,onChange:()=>b.setActiveTool({type:Gk.laser}),isMobile:!0})})]})})]})}),nn("div",{className:gs("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":n.zenModeEnabled,"layer-ui__wrapper__top-right--compact":_}),children:[v&&n.collaborators.size>0&&te(Dp,{collaborators:n.collaborators,userToFollow:M.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),be&&te(cc,{app:b,onClose:()=>{e.executeAction(gr)},renderCustomStats:m})]})]})})},B=()=>te(xb,{}),Y=!1,pe=nn(vb,{children:[g,v&&te(vb,{children:te(kV,{UIOptions:p})}),te(MV,{}),v&&n.isLoading&&te(vp,{delay:250}),v&&n.errorMessage&&te(XP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),v&&K&&P.formFactor!=="phone"&&te(Y0,{colorPickerType:K.colorPickerType,onCancel:()=>{z(null)},onChange:(ae,be,ce,{altKey:Fe})=>{if(!(ae!=="elementBackground"&&ae!=="elementStroke"))if(ce.length){for(let se of ce)SV(se,TV(r),{[Fe&&K.swapPreviewOnAlt?ae==="elementBackground"?"strokeColor":"backgroundColor":ae==="elementBackground"?"backgroundColor":"strokeColor"]:be}),CV.delete(se);b.scene.triggerUpdate()}else o(ae==="elementBackground"?{currentItemBackgroundColor:be}:{currentItemStrokeColor:be})},onSelect:(ae,be)=>{z(ce=>ce?.keepOpenOnAlt&&be.altKey?ce:null),K?.onSelect?.(ae,be)}}),n.openDialog?.name==="help"&&te(ok,{onClose:()=>{o({openDialog:null})}}),v&&n.openDialog?.name==="elementLinkSelector"&&te(KP,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),te(k.OverwriteConfirmDialogTunnel.Out,{}),W(),U(),v&&n.openDialog?.name==="charts"&&te(wC,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),v&&te(QP,{app:b,files:t,setAppState:o}),P.formFactor==="phone"&&te(cC,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:U,renderImageExportDialog:W,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:B,renderWelcomeScreen:E,defaultUIEnabled:v,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&nn(vb,{children:[M.viewportStatusFrame?.border&&te(xp,{border:M.viewportStatusFrame.border,style:Y?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),nn("div",{className:"layer-ui__wrapper",style:Y?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&te(k.WelcomeScreenCenterTunnel.Out,{}),me(),te(kC,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:v,zoomUIEnabled:y}),(n.toast||x&&n.scrolledOutside||M.viewportStatusFrame?.label)&&nn("div",{className:"floating-status-stack",children:[n.toast&&te(Qd,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&te("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(ae=>({...Di(r,ae)}))},children:f("buttons.scrollBackToContent")}),M.viewportStatusFrame?.label&&te(yp,{label:M.viewportStatusFrame.label,border:M.viewportStatusFrame.border})]})]})]}),B()]});return te(Th.Provider,{value:n,children:te(F,{children:te(pE.Provider,{value:k,children:pe})})})},Hk=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:s,suggestedBinding:l,frameToHighlight:c,elementsToHighlight:d,...m}=e;return m},DV=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return tu(Hk(o),Hk(a),{selectedElementIds:tu,selectedGroupIds:tu})&&tu(r,s)},Uk=vV.memo(AV,DV);import{useEffect as LV,useRef as _V}from"react";import{jsx as Wk}from"react/jsx-runtime";var Vk=({trails:e})=>{let n=_V(null);return LV(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),Wk("div",{className:"SVGLayer",children:Wk("svg",{ref:n})})};import RV,{useEffect as Yk,useRef as Kk}from"react";import{isShallowEqual as NV,sceneCoordsToViewportCoords as BV}from"@excalidraw/common";import{jsx as zV}from"react/jsx-runtime";var Xk="animateInteractiveScene",FV=e=>{let n=Kk(!1),t=Kk(null);return Yk(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&jf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),Yk(()=>{if(!n.current){n.current=!0;return}let o=new Map,r=new Map,i=new Map,a=new Map,s=new Map;e.appState.collaborators.forEach((c,d)=>{if(c.selectedElementIds)for(let m of Object.keys(c.selectedElementIds))i.has(m)||i.set(m,[]),i.get(m).push(d);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(d,c.username),c.userState&&s.set(d,c.userState),r.set(d,BV({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),o.set(d,c.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";t.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:o,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:s,selectionColor:l,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},ct.running(Xk)||ct.start(Xk,({deltaTime:c,state:d})=>{let m=jf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),zV("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.onDoubleClick,children:f("labels.drawingCanvas")})},Zk=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewpointFlip:e.viewpointFlip,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,gridModeEnabled:e.gridModeEnabled,suggestedBinding:e.suggestedBinding,hoveredArrowTextAnchor:e.hoveredArrowTextAnchor,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),OV=(e,n)=>e.selectionNonce!==n.selectionNonce||e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements||e.selectedElements!==n.selectedElements||e.renderScrollbars!==n.renderScrollbars||e.interactionEnabled!==n.interactionEnabled||e.navigationEnabled!==n.navigationEnabled?!1:NV(Zk(e.appState),Zk(n.appState)),Ib=RV.memo(FV,OV);import qk,{useEffect as nu,useRef as gc}from"react";import{isShallowEqual as $k}from"@excalidraw/common";import{hasActiveGifDecode as GV}from"@excalidraw/element";import{jsx as WV}from"react/jsx-runtime";var HV=e=>{let n=gc(null),t=gc(!1),o=gc(e),r=gc(()=>{}),i=gc(null);o.current=e;let a=qk.useCallback(()=>{let s=o.current,l=n.current;if(!l)return;let c=getComputedStyle(l).getPropertyValue("--color-grid-bold").trim(),d=getComputedStyle(l).getPropertyValue("--color-grid-regular").trim();Tx({canvas:s.canvas,rc:s.rc,scale:s.scale,elementsMap:s.elementsMap,allElementsMap:s.allElementsMap,visibleElements:s.visibleElements,appState:s.appState,renderConfig:{...s.renderConfig,gridColorBold:c,gridColorRegular:d}},Na());let m=s.renderConfig.imageTransitionDuration??0,p=m>0&&s.visibleElements.some(E=>{if(E.type!=="image"||!E.fileId)return!1;let g=s.renderConfig.imageCache.get(E.fileId)?.transitionStart;return g!==void 0&&performance.now()-g<m}),u=GV(s.visibleElements,s.renderConfig.imageCache);(p||u)&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,nu(()=>{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]),nu(()=>{let s=n.current;if(!s)return;let l=e.canvas;t.current||(t.current=!0,s.replaceChildren(l),l.classList.add("excalidraw__canvas","static")),a()}),nu(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),nu(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),WV("div",{className:"excalidraw__canvas-wrapper",ref:n})},jk=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewpointFlip:e.viewpointFlip,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId,suggestedBinding:e.suggestedBinding}),UV=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:$k(jk(e.appState),jk(n.appState))&&$k(e.renderConfig,n.renderConfig),Tb=qk.memo(HV,UV);import{useEffect as jV,useRef as qV}from"react";import{throttleRAF as VV}from"@excalidraw/common";import{getTargetFrame as YV,isInvisiblySmallElement as KV,renderElement as XV,shouldApplyFrameClip as ZV}from"@excalidraw/element";var Jk=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Fc(e,i),d=Oc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),zc(d,a),t&&t.type!=="selection"){if(KV(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=YV(t,o,a);u&&ZV(t,u,a,o)&&vx(u,d,s,a)}XV(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},$V=VV(e=>{Jk(e)}),Qk=(e,n)=>{if(n){$V(e);return}Jk(e)};import{jsx as QV}from"react/jsx-runtime";var JV=e=>{let n=qV(null);return jV(()=>{n.current&&Qk({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Na())}),QV("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:n})},eM=JV;import eY from"clsx";import{useLayoutEffect as tY,useEffect as tM,useRef as nY,useState as oY}from"react";import{ARROW_TYPE as nM,EVENT as ou}from"@excalidraw/common";import{jsx as sY}from"react/jsx-runtime";var oM=700,rY=100,iY=16,aY=5*60*1e3,iM=Je(null),rM=e=>e===nM.elbow?er:e===nM.round?tr:Qo,ru=class{constructor(n){w(this,"app");w(this,"lastShownAt",0);w(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(iM,{content:n,nonce:Math.random()}))});w(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<aY);w(this,"onArrowTypeCycled",n=>{this.show(rM(n))});w(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?jo:rM(this.app.state.currentItemArrowType))});this.app=n}},aM=()=>{let[e,n]=Ke(iM),t=St(),{container:o}=Oe(),r=nY(null),[i,a]=oY(!1),s=e?.nonce;return tY(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=gd({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:iY});p.style.transform=`translate(${u}px, ${E}px)`};l(t.viewport.lastPosition.x,t.viewport.lastPosition.y);let c=d=>{l(d.clientX,d.clientY)};return window.addEventListener(ou.POINTER_MOVE,c),()=>{window.removeEventListener(ou.POINTER_MOVE,c)}},[s,o,t]),tM(()=>()=>{n(null)},[n]),tM(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},oM),c=window.setTimeout(()=>{n(null)},oM+rY),d=()=>{n(null)};return window.addEventListener(ou.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(ou.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?sY("div",{ref:r,className:eY("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var iu=class{constructor(n){this.getState=n;w(this,"listeners",[]);w(this,"onStateChange",(n,t,o)=>{let{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}=this.normalize(n,t,o);return a?l&&(queueMicrotask(()=>{let c=this.getState();a(i(c),c)}),s)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:s}):l?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:d=>c(d),once:!0})})})}isStateChangePredicateOptions(n){return typeof n=="object"&&!Array.isArray(n)&&"predicate"in n}subscribe(n){return this.listeners.push(n),()=>{this.listeners=this.listeners.filter(t=>t!==n)}}normalize(n,t,o){let r,i,a=t,s=o?.once??!1,l=!1;if(this.isStateChangePredicateOptions(n)){let{predicate:c,callback:d,once:m}=n;r=c,i=p=>p,a=d?(p,u)=>d(u):void 0,s=m??!1,l=c(this.getState())}else if(typeof n=="function"){let c=n;r=(d,m)=>c(d)!==c(m),i=d=>c(d)}else if(Array.isArray(n)){let c=n;r=(d,m)=>c.some(p=>d[p]!==m[p]),i=d=>d}else{let c=n;r=(d,m)=>d[c]!==m[c],i=d=>d[c]}return{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}}flush(n){if(!this.listeners.length)return;let t=this.getState(),o=[];for(let r of this.listeners)r.predicate(t,n)?(r.callback(r.getValue(t),t),r.once||o.push(r)):o.push(r);this.listeners=o}clear(){this.listeners=[]}};import{getCommonBounds as lY,getElementsInGroup as cY,isNonDeletedElement as sM,selectGroupsFromGivenElements as dY}from"@excalidraw/element";import{sceneCoordsToViewportCoords as mY}from"@excalidraw/common";import{flushSync as pY}from"react-dom";import{jsx as hY}from"react/jsx-runtime";var uY=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!sM(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&sM(t)?t:null,r=o?[o]:cY(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=lY(r),{x:s,y:l}=mY({sceneX:i,sceneY:a},e.state);return hY("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{pY(()=>{let c=dY(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(xl)},title:f("labels.elementLock.unlock"),children:Vx})},lM=uY;import{Fragment as uX,jsx as Pe,jsxs as Xb}from"react/jsx-runtime";var EA=Sn.createContext(null),bA=Sn.createContext(null),Zb={formFactor:"desktop",desktopUIMode:"full",userAgent:gA(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},jb=Sn.createContext(Zb);jb.displayName="EditorInterfaceContext";var cX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},qb=Sn.createContext({container:null,id:null});qb.displayName="ExcalidrawContainerContext";var Jb=Sn.createContext([]);Jb.displayName="ExcalidrawElementsContext";var Qb=Sn.createContext({...Zo(),width:0,height:0,offsetLeft:0,offsetTop:0});Qb.displayName="ExcalidrawAppStateContext";var ex=Sn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});ex.displayName="ExcalidrawSetAppStateContext";var tx=Sn.createContext(null);tx.displayName="ExcalidrawActionManagerContext";var ys=Sn.createContext(null);ys.displayName="ExcalidrawAPIContext";var vu=Sn.createContext(null);vu.displayName="ExcalidrawAPISetContext";var St=()=>Yo(EA),Ln=()=>Yo(bA),Ee=()=>Yo(jb),mt=()=>wu(Ee()),Oe=()=>Yo(qb),$i=()=>Yo(Jb),ro=()=>Yo(Qb),We=()=>Yo(ex),at=()=>Yo(tx),Fd=()=>Yo(ys),Sc=!1,Cc=0,Pc=null,Wo=!1,Eu=!1,Vo=!1,bu=!1,kc={horizontal:null,vertical:null},Nr=0,Mc=!1,Kb=new Map,dX=4,mX=300,mA=(e,n)=>n.horizontal===n.vertical?e:e==="nwse-resize"?"nesw-resize":e==="nesw-resize"?"nwse-resize":e,xu=!1,yu=0,pA=!1,xs=null,ue={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},$b=class e extends Sn.Component{constructor(t){super(t);w(this,"canvas");w(this,"interactiveCanvas",null);w(this,"sessionExportThemeOverride");w(this,"rc");w(this,"unmounted",!1);w(this,"actionManager");w(this,"editorInterface",Zb);w(this,"stylesPanelMode",wu(Zb));w(this,"excalidrawContainerRef",Sn.createRef());w(this,"scene");w(this,"fonts");w(this,"renderer");w(this,"visibleElements");w(this,"hasRenderableElements",!1);w(this,"resizeObserver");w(this,"id");w(this,"store");w(this,"history");w(this,"excalidrawContainerValue");w(this,"files",{});w(this,"imageCache",new Map);w(this,"imageLoadingProgress",new Map);w(this,"imageLoadingProgressEmitter",new fo);w(this,"imageStatus",new Map);w(this,"imageStatusEmitter",new fo);w(this,"imagePlaceholderUpdateEmitter",new fo);w(this,"iFrameRefs",new Map);w(this,"embedsValidationStatus",new Map);w(this,"initializedEmbeds",new Set);w(this,"elementsPendingErasure",new Set);w(this,"_initialized",!1);w(this,"editorLifecycleEvents",new VY(cX));w(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));w(this,"appStateObserver",new iu(()=>this.state));w(this,"onStateChange",this.appStateObserver.onStateChange);w(this,"bucketFill",new cp(this));w(this,"flowchart",new hp(this));w(this,"cursor",new dp(this));w(this,"gifPlayback",new gp(this));w(this,"zDragZoom",null);w(this,"arrowText",new lp(this));w(this,"viewport",new Ep(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>ue.pointers.size>=2||Vo}));w(this,"bindModeHandler",null);w(this,"textWysiwygSubmitHandler",null);w(this,"hitLinkElement");w(this,"lastPointerDownEvent",null);w(this,"lastPointerUpEvent",null);w(this,"lastPointerUpIsDoubleClick",!1);w(this,"lastPointerMoveEvent",null);w(this,"lastPointerMoveCoords",null);w(this,"lastCompletedCanvasClicks",[]);w(this,"lastKeyboardSmartZoomImageId",null);w(this,"smartZoomKeyDownAt",null);w(this,"smartZoomKeyHitElement",!1);w(this,"previousPointerMoveCoords",null);w(this,"drawShape",new up(this));w(this,"laserTrails",new zm(this));w(this,"eraserTrail",new Km(this));w(this,"lassoTrail",new Ym(this));w(this,"cursorHints",new ru(this));w(this,"onChangeEmitter",new fo);w(this,"onPointerDownEmitter",new fo);w(this,"onPointerUpEmitter",new fo);w(this,"onUserFollowEmitter",new fo);w(this,"onScrollChangeEmitter",new fo);w(this,"missingPointerEventCleanupEmitter",new fo);w(this,"onRemoveEventListenersEmitter",new fo);w(this,"api");w(this,"isToolSupported",(t,o=this.props)=>{if(t==="magicframe"||o.UIOptions.tools?.[t]===!1)return!1;if(this.isInteractionEnabled(o))return!0;let r=typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.tools:void 0;return t==="laser"?r?.laser===!0:t==="custom"?r?.custom===!0:!1});w(this,"updateEditorAtom",(t,...o)=>{let r=bt.set(t,...o);return this.triggerRender(),r});w(this,"previousHoveredBindableElement",null);w(this,"getEffectiveGridSize",()=>br(this)?this.state.gridSize:null);w(this,"getTextCreationGridPoint",(t,o)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(o)}});w(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&Ic(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Me.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));w(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=xM);w(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),Ci.delete(t)});w(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Uo(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=Nb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else _b(r)&&t.add(r.id);return!1}),o&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});w(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);w(this,"frameNameBoundsCache",{get:t=>{let o=this.frameNameBoundsCache._cache.get(t.id);if(!o||o.zoom!==this.state.zoom.value||o.viewpointFlip!==this.state.viewpointFlip||o.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Ce({clientX:i.x,clientY:i.y},this.state),s=Ce({clientX:i.right,clientY:i.bottom},this.state);return o={x:Math.min(a.x,s.x),y:Math.min(a.y,s.y),width:Math.abs(s.x-a.x),height:Math.abs(s.y-a.y),zoom:this.state.zoom.value,viewpointFlip:this.state.viewpointFlip,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,o),o}return null}return o},_cache:new Map});w(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});w(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===bc.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&Tt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!FM(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:a,y:s}=cu({sceneX:i.x+(this.state.viewpointFlip.horizontal?i.width:0),sceneY:i.y+(this.state.viewpointFlip.vertical?i.height:0)},this.state),l=6,c,d=kK(i);if(i.id===this.state.editingFrame){let m=d;c=Pe("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===V.ESCAPE||p.key===V.ENTER)&&this.resetEditingFrame(i)},style:{background:WY(this.state.viewBackgroundColor,t),zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Go.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?Go.nameColorDarkTheme:Go.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return Pe("div",{id:this.getFrameNameDOMId(i),className:Lb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+Go.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Go.nameFontSize,color:t?Go.nameColorDarkTheme:Go.nameColorLightTheme,lineHeight:Go.nameLineHeight,width:"max-content",maxWidth:r?.id===i.id&&r?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Me.MOVE,pointerEvents:this.state.viewModeEnabled?fs.disabled:fs.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});w(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});w(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());w(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());w(this,"getSceneElements",()=>this.scene.getNonDeletedElements());w(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});w(this,"onExportImage",async(t,o,r)=>{Ue("export",t,"ui");let i=await Jr(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(HY).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Hc(i)&&this.setState({fileHandle:i})});w(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Ut,{swapPreviewOnAlt:o,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,i)=>{let a=t==="stroke"?!o||!i.altKey:o&&i.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:jt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:jt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?bo(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:jt.IMMEDIATELY})},keepOpenOnAlt:!1})});w(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});w(this,"syncActionResult",qe(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let o=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),o=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled??this.state.viewModeEnabled,a=t?.appState?.theme||this.props.theme||bc.LIGHT,s=t?.appState?.name??this.state.name,l=t?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),this.isInteractionEnabled()||(i=!0),r=t.appState?.editingTextElement||null,t.elements&&r){let c=r.id,d=t.elements.find(m=>m.id===c);r=d&&fu(d)&&$t(d)?d:null}this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:!1,theme:a,name:s,errorMessage:l}}),o=!0}o||this.scene.triggerUpdate()}));w(this,"scheduleCapture",()=>this.store.scheduleCapture());w(this,"scheduleUpdate",()=>this.store.scheduleAction(jt.NEVER));w(this,"onBlur",qe(()=>{Wo=!1,this.resetSmartZoomKey(),this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));w(this,"onUnload",()=>{this.onBlur()});w(this,"disableEvent",t=>{t.preventDefault()});w(this,"preventBrowserZoomWheel",t=>{t[V.CTRL_OR_CMD]&&t.preventDefault()});w(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});w(this,"maybeHandlePageScrollKeyDown",t=>{if(t.key!==V.PAGE_UP&&t.key!==V.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===V.PAGE_DOWN&&(o=-o),t.shiftKey?this.viewport.translate(r=>({scrollX:r.scrollX+o})):this.viewport.translate(r=>({scrollY:r.scrollY+o})),!0});w(this,"preventBrowserZoomKeyDown",t=>{t[V.CTRL_OR_CMD]&&(t.code===Lr.EQUAL||t.code===Lr.MINUS||t.code===Lr.ZERO||t.code===Lr.NUM_ADD||t.code===Lr.NUM_SUBTRACT||t.code===Lr.NUM_ZERO)&&t.preventDefault()});w(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Wo=!1,Eu=!1,this.resetSmartZoomKey(),Vo=!1,bu=!1,xs=null,ue.pointers.clear(),ue.lastCenter=null,ue.initialDistance=null,ue.initialScale=null,clearTimeout(Cc),Cc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(yu),yu=0,xu=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),bt.set(Ut,null),bt.set(po,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&Tt(t)?t:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:null,openPopup:null,cursorButton:"up",bindMode:"orbit",activeEmbeddable:null,activeLockedId:null,selectedElementsAreBeingDragged:!1,selectionElement:null,resizingElement:null,isResizing:!1,isRotating:!1,isCropping:!1,croppingElementId:null,suggestedBinding:null,frameToHighlight:null,elementsToHighlight:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())});w(this,"handleInteractionStateChange",(t,o)=>{let r=this.isInteractionEnabled(t),i=r!==this.isInteractionEnabled(),a=t.viewModeEnabled!==this.props.viewModeEnabled,s=this.state.viewModeEnabled;this.isInteractionEnabled()?(a||i)&&(s=!!this.props.viewModeEnabled):s=!0,s!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:s});let l=r&&!o.viewModeEnabled,c=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||l&&!c)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(t)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,ym(),this.cursor.reset())),this.isEmbedsEnabled(t)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(o.activeTool.type,t)!==this.isToolSupported(this.state.activeTool.type)&&(this.isToolSupported(this.state.activeTool.type)||this.laserTrails.endPath(),this.cursor.reset()),!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)&&this.state.activeTool.type!=="selection"&&this.setState({activeTool:on(this.state,{type:"selection"})}),(this.isBrowserZoomEnabled(t)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(t)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),o.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())});w(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));w(this,"handleForcedToolChange",(t,o)=>{let r=this.props.activeTool;if(!r)return;let i=!this.isSameForcedTool(t.activeTool,r);if(r.type==="image"){i&&console.warn('"image" tool cannot be forced via "props.activeTool"');return}this.isSameForcedTool(r,this.state.activeTool)||(i||o.activeTool!==this.state.activeTool||this.isToolSupported(r.type,t)!==this.isToolSupported(r.type,this.props))&&this.setActiveTool(r)});w(this,"resetHistory",()=>{this.history.clear()});w(this,"resetStore",()=>{this.store.clear()});w(this,"resetScene",qe(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...Zo(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));w(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async l=>{if(!l.files.length)return;let c=l.files[0],d=await c.getFile();this.loadFileToCanvas(new File([d],d.name||"",{type:d.type}),c)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null}catch(l){console.error(l),t={appState:{errorMessage:l.message||"Encountered an error during importing or restoring scene data"}}}let o=zr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=Ri(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,viewModeOnly:this.props.viewModeOnly||r.viewModeOnly,viewModeEnabled:this.props.viewModeOnly||this.props.viewModeEnabled||r.viewModeEnabled,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast};let a={...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft},s=this.props.initialState?.viewport;if(s){let l=o.filter(m=>!m.isDeleted),c=wc(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,...Di(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:jt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),XM(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});w(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??ZY(t,o));w(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=JY(),a=gA(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:SY,l=Db(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(o,r),userAgent:a,canFitSidebar:o>s,isLandscape:o>r});this.editorInterface=l,this.reconcileStylesPanelMode(l)});w(this,"reconcileStylesPanelMode",t=>{let o=wu(t);if(o===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=o,this.viewport.invalidateUIOffset("stylesPanel"),r!=="full"&&o==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});w(this,"setDesktopUIMode",t=>{let o=QY(t);this.editorInterface=Db(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface)});w(this,"onResize",qe(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Ci.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));w(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});w(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&(kc=t),this.scheduleImageRefresh()});w(this,"onScroll",vM(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},CY));w(this,"onCut",qe(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||xc(t.target)||(this.actionManager.executeAction(Em,"keyboard",t),t.preventDefault(),t.stopPropagation())}));w(this,"onCopy",qe(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||xc(t.target)||(this.actionManager.executeAction(Ea,"keyboard",t),t.preventDefault(),t.stopPropagation())}));w(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if($Y&&t.preventDefault(),!Sc){Sc=!0,t.touches.length===1&&(Pc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Cc),Cc=window.setTimeout(e.resetTapTwice,xM);return}if(Sc&&t.touches.length===1&&Pc){let o=t.touches[0];go(oe(o.clientX,o.clientY),oe(Pc.x,Pc.y))<=CM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),Sc=!1,clearTimeout(Cc)}t.touches.length===2&&this.setState({selectedElementIds:De({},this.state),activeEmbeddable:null})}});w(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:De(this.state.previousSelectedElementIds,this.state)}):ue.pointers.clear())});w(this,"pasteFromClipboard",qe(async t=>{if(!this.isInteractionEnabled())return;let o=!!xu,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||xc(r)))return;let s=await mr(t),l=s.getFiles(),c=await ml(s,o);if(!c.elements&&l.length>0&&!o)try{let m=(await rm())[In.excalidrawClipboard];typeof m=="string"&&(s=await mr(nm({types:{[In.excalidrawClipboard]:m}})),l=s.getFiles(),c=await ml(s,o))}catch(d){console.warn(`Could not read editable image clipboard data: ${d.message}`)}if(this.state.viewModeEnabled){if(!this.containsImagePaste(c,l,o))return;if(!this.shouldInsertImageInViewMode({source:"paste",files:l.map(d=>d.file),data:c,event:t})){t?.preventDefault();return}}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(c,l,o),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t?.preventDefault()}));w(this,"addElementsFromPasteOrLibrary",t=>{let o=zr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=bs(o),l=Es(r,a)/2,c=Es(i,s)/2,d=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,m=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Ce({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,v]=kt(E,g,this.getEffectiveGridSize()),{duplicatedElements:y}=_M({type:"everything",elements:o.map(M=>bo(M,{x:M.x+b-r,y:M.y+v-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),I=[...x,...y];I=this.props.onDuplicate?.(I,x)||I,qM(I,wc(y));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let M=MK(y,C);I=Gb(I,M,C)}this.scene.replaceAllElements(I),y.forEach(M=>{if($t(M)&&NM(M)){let D=HM(M,this.scene.getElementsMapIncludingDeleted());wK(M,D,this.scene)}}),qY&&Io.loadElementsFonts(y).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let P=YK(y);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&bt.get(bb)?this.state.openSidebar:null,...JM(P,this.scene.getNonDeletedElements(),this.state)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t.fit&&this.viewport.setViewport({target:y,fit:t.fit,animation:!1,offsets:{ui:!0}})});w(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});w(this,"setAppState",(t,o)=>{let r=a=>!a||!this.state.viewModeOnly?a:{...a,viewModeOnly:!0,viewModeEnabled:!0},i=typeof t=="function"?(a,s)=>r(t(a,s)):r(t);this.setState(i,o)});w(this,"removePointer",t=>{Nr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=ue.pointers.size>=2;ue.pointers.delete(t.pointerId),o&&ue.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});w(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||Ue("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...on(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});w(this,"updateFrameRendering",t=>{this.setState(o=>{let r=typeof t=="function"?t(o.frameRendering):t;return{frameRendering:{enabled:r?.enabled??o.frameRendering.enabled,clip:r?.clip??o.frameRendering.clip,name:r?.name??o.frameRendering.name,outline:r?.outline??o.frameRendering.outline}}})});w(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});w(this,"revealIfHidden",t=>{!t.length||fK(t,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.viewport.getOffsets())||this.viewport.setViewport({target:bs(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});w(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:jn(t.zoom)},shouldCacheIgnoreZoom:!1})});w(this,"scrollToContent",(t,o)=>{this.viewport.setViewport({target:t??this.scene.getNonDeletedElements(),fit:o?.fitToViewport?"contain":"scale-down",animation:o?.animate?{duration:o.duration??500}:!1,offsets:{ui:!0}})});w(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});w(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});w(this,"setToast",t=>{this.setState({toast:t})});w(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),o=await t.match("shared-file");if(o){let r=await o.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,bY,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});w(this,"addFiles",qe(t=>{let o=new Map;for(let s of t){let l=s.id,c=this.imageCache.get(l);c&&!this.files[l]&&o.set(l,Promise.resolve(c.image))}let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate();let i=new Set(o.keys());Bb({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes}).then(async({updatedFiles:s})=>{for(let[l,c]of o){let d=this.imageCache.get(l);!d||!s.has(l)||(this.imageCache.set(l,{...d,placeholderImage:await c,transitionStart:performance.now()}),this.clearImageLoadingProgress(l))}i.size&&this.imagePlaceholderUpdateEmitter.trigger()}),i.size||this.addNewImagesToImageCache()}));w(this,"addImageElementsToScene",async(t,o,r)=>{let i=await Promise.all(t.map(async({file:s,customData:l})=>({file:await Gr(s),customData:l??{}}))),a=i.find(({file:s})=>!Ni(s));if(a)throw new Lu(a.file,f("errors.unsupportedFileType"));await this.insertImages(i.map(({file:s})=>s),o,r,i.map(({customData:s})=>s))});w(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await Gr(o);if(!Ni(r))throw new Error(f("errors.unsupportedFileType"));let i=new Image,a=new Promise((l,c)=>{i.onload=()=>l(i),i.onerror=()=>c(new Error(f("errors.imageInsertError")))}),s={image:a,mimeType:r.type,isPlaceholder:!0,gifDecodeStatus:r.type===In.gif?"pending":void 0};this.imageCache.set(t,s),s.gifDecodeStatus==="pending"&&this.imagePlaceholderUpdateEmitter.trigger(),i.src=await Uc(r);try{let l=await a;if(this.imageCache.get(t)!==s||this.files[t])return;this.imageCache.set(t,{...s,image:l}),this.clearImageShapeCacheForFileId(t),this.imagePlaceholderUpdateEmitter.trigger()}catch(l){throw this.imageCache.get(t)===s&&(this.imageCache.delete(t),this.imagePlaceholderUpdateEmitter.trigger()),l}});w(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=fc(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});w(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>({...r,downloadError:o===!0?{}:o||null}))});w(this,"setUploadProgress",(t,o,r)=>{if(o===null){this.updateImageStatus(t,i=>({...i,uploadProgress:null}));return}typeof o=="number"&&!Number.isFinite(o)||this.updateImageStatus(t,i=>{let a=i?.uploadProgress??void 0,s=r===void 0?a:r??void 0,l=typeof o=="number";return{...i,uploadProgress:{...s,state:l?"uploading":o,...l?{progress:fc(o,0,1)}:{progress:void 0}}}})});w(this,"updateImageStatus",(t,o)=>{let r=this.imageStatus.get(t),i=o(r);this.areImageStatusesEqual(r,i)||(i.downloadError===void 0&&!i.uploadProgress?this.imageStatus.delete(t):this.imageStatus.set(t,i),this.imageStatusEmitter.trigger())});w(this,"areImageStatusesEqual",(t,o)=>!!t?.downloadError==!!o?.downloadError&&!!t?.uploadProgress==!!o?.uploadProgress&&t?.downloadError?.backgroundColor===o?.downloadError?.backgroundColor&&t?.downloadError?.color===o?.downloadError?.color&&t?.downloadError?.trackColor===o?.downloadError?.trackColor&&t?.downloadError?.text===o?.downloadError?.text&&t?.downloadError?.onClick===o?.downloadError?.onClick&&t?.uploadProgress?.backgroundColor===o?.uploadProgress?.backgroundColor&&t?.uploadProgress?.color===o?.uploadProgress?.color&&t?.uploadProgress?.trackColor===o?.uploadProgress?.trackColor&&t?.uploadProgress?.state===o?.uploadProgress?.state&&t?.uploadProgress?.text===o?.uploadProgress?.text&&t?.uploadProgress?.onClick===o?.uploadProgress?.onClick&&t?.uploadProgress?.progress===o?.uploadProgress?.progress);w(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});w(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())Si(o)&&o.fileId===t&&Ci.delete(o)});w(this,"addMissingFiles",(t,o=!1)=>{let r=o?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let s of a)if(!r[s.id]&&(i[s.id]=s,r[s.id]=s,s.mimeType===In.svg))try{let l=Mx(GM(Dx(s.dataURL)),In.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});w(this,"updateScene",qe(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?tK({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:l})}r&&this.setState(r),o&&this.scene.replaceAllElements(o),i&&(this.laserTrails.updateCollabTrails(i),this.setState({collaborators:i}))}));w(this,"applyDeltas",(t,o)=>{let r=rA.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return rA.applyTo(r,a,i,o)});w(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));w(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});w(this,"toggleSidebar",({name:t,tab:o,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===o?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&o&&(a.tab=o),this.setState({openSidebar:a}),!!i});w(this,"updateCurrentCursorPosition",qe(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));w(this,"isPlainSmartZoomKey",t=>!t[V.CTRL_OR_CMD]&&!t.shiftKey&&!t.altKey&&t.key.toLocaleLowerCase()===V.F);w(this,"updateSmartZoomCursor",t=>{if(this.smartZoomKeyDownAt===null)return;let o=t?this.getElementAtPosition(t.x,t.y,{includeLockedElements:!0}):null;this.cursor.set(o?Me.POINTER:"zoom-in")});w(this,"resetSmartZoomKey",()=>{let t=this.smartZoomKeyDownAt!==null;this.smartZoomKeyDownAt=null,this.smartZoomKeyHitElement=!1,t&&(this.cursor.reset(),this.updateEditorAtom(xa,!1))});w(this,"handleSmartZoomKeyDown",t=>this.isPlainSmartZoomKey(t)?(!t.repeat&&this.smartZoomKeyDownAt===null&&(this.smartZoomKeyDownAt=Date.now(),this.smartZoomKeyHitElement=!1,this.updateEditorAtom(xa,!0),this.updateSmartZoomCursor(this.lastPointerMoveCoords)),t.preventDefault(),t.stopPropagation(),!0):!1);w(this,"handleSmartZoomKeyUp",t=>{if(t.key.toLocaleLowerCase()!==V.F||this.smartZoomKeyDownAt===null)return!1;let o=Date.now()-this.smartZoomKeyDownAt,r=!this.smartZoomKeyHitElement&&o<=mX;return this.resetSmartZoomKey(),t.stopPropagation(),r&&this.actionManager.executeAction(Rn,"keyboard",this.scene.getNonDeletedElements()),!0});w(this,"handleSmartZoomPointerDown",(t,o)=>{if(t.button!==Tn.MAIN||this.smartZoomKeyDownAt===null)return!1;let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});return r?(this.smartZoomKeyHitElement=!0,t.preventDefault(),t.stopPropagation(),this.actionManager.executeAction(Rn,"keyboard",[r]),!0):!1});w(this,"onKeyDown",qe(t=>{if(!this.isInteractionEnabled())return;if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(l,c){let d=l[c];return typeof d=="function"?d.bind(l):c==="key"?t.shiftKey?l.key.toUpperCase():l.key.toLowerCase():d}})),!IM(t.target)){if((t.key===V.ESCAPE||t.key===V.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=de(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&Xn(l[0])&&t.key===V.ENTER){this.startImageCropping(l[0]);return}if(l.length===0&&(t.key===V.ARROW_LEFT||t.key===V.ARROW_RIGHT)&&!t[V.CTRL_OR_CMD]&&!t.shiftKey&&!t.altKey){let c=this.scene.getNonDeletedElementsMap(),d=uv(this.scene.getNonDeletedElements(),c,this.lastKeyboardSmartZoomImageId,t.key===V.ARROW_RIGHT?"next":"previous");if(d){this.lastKeyboardSmartZoomImageId=d.id,this.actionManager.executeAction(Rn,"keyboard",[d]),t.preventDefault(),t.stopPropagation();return}}if(t.key===V.ESCAPE)this.updateEditorAtom(po,null);else if(t.key===V.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(Lb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=sp(l);bt.get(po)?.type==="panel"&&sE(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(po,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[V.CTRL_OR_CMD]&&t.key.toLowerCase()===V.V&&(xu=t.shiftKey,clearTimeout(yu),yu=window.setTimeout(()=>{xu=!1},100)),t[V.CTRL_OR_CMD]&&xc(t.target)&&(t.code===Lr.MINUS||t.code===Lr.EQUAL)){t.preventDefault();return}if(xc(t.target)&&t.key!==V.ESCAPE||Pb(t.key)&&IM(t.target))return;if(t.key===V.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===V.E&&t.shiftKey&&t[V.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}if(this.state.openDialog?.name==="elementLinkSelector")return;if(t.key===V.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else Ho("COMPLEX_BINDINGS")?this.handleSkipBindMode():gu({app:this,event:t});if(this.handleSmartZoomKeyDown(t)||this.actionManager.handleKeyDown(t))return;let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===V.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=tw(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!PM(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&Ue("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===_r.sharp?_r.round:this.state.currentItemArrowType===_r.round?_r.elbow:_r.sharp;this.setState({currentItemArrowType:c}),this.cursorHints.onArrowTypeCycled(c)}else(l==="arrow"||l==="line")&&this.cursorHints.onToolShortcut(l,/^\d$/.test(t.key)?"digit":"letter");l==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l},{toggle:!0}),t.stopPropagation();return}else if(t.key===V.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[V.CTRL_OR_CMD]&&!t.repeat&&(Ho("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),gu({app:this,event:t})),Pb(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),c=new Set;l.filter(u=>xo(u)).filter(u=>{let E=u.startBinding&&!l.some(b=>b.id===u.startBinding?.elementId),g=u.endBinding&&!l.some(b=>b.id===u.endBinding?.elementId);return E||g}).forEach(u=>c.add(u.id)),l=l.filter(u=>!c.has(u.id));let d=this.getEffectiveGridSize()&&(t.shiftKey?bM:this.getEffectiveGridSize())||(t.shiftKey?vY:bM),m=0,p=0;t.key===V.ARROW_LEFT?m=-d:t.key===V.ARROW_RIGHT?m=d:t.key===V.ARROW_UP?p=-d:t.key===V.ARROW_DOWN&&(p=d),m*=Kn(this.state.viewpointFlip.horizontal),p*=Kn(this.state.viewpointFlip.vertical),l.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),pu(u,this.scene,{simultaneouslyUpdated:l})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===V.ENTER){let l=this.scene.getSelectedElements(this.state);if(l.length===1){let c=l[0];if(t[V.CTRL_OR_CMD]||Wb(c))Ht(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),Zt(c)||this.actionManager.executeAction(Ma));else if($t(c)||UM(c)){let d;$t(c)||(d=c);let m=Ob(c,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:d}),t.preventDefault();return}else Tt(c)&&this.setState({editingFrame:c.id})}}if(t.key===V.SPACE&&ue.pointers.size===0&&(Wo=!0,this.cursor.set(Me.GRAB),t.preventDefault()),t.key.toLowerCase()===V.Z&&!t[V.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(Eu=!0,this.cursor.set("zoom-in"),t.preventDefault()),(t.key===V.G||t.key===V.S)&&!t.altKey&&!t[V.CTRL_OR_CMD]){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;t.key===V.G&&(Xo(this.state.activeTool.type)||l.some(c=>Xo(c.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===V.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[V.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===V.F){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;(this.state.activeTool.type==="text"||l.find(c=>$t(c)||Fb(c,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===V.I&&!t.shiftKey&&!t[V.CTRL_OR_CMD],a=r===V.S&&t.shiftKey&&!t[V.CTRL_OR_CMD]||i,s=r===V.I&&t.shiftKey&&!t[V.CTRL_OR_CMD];(a||s)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));w(this,"onKeyUp",qe(t=>{if(this.isInteractionEnabled()&&!this.handleSmartZoomKeyUp(t)){if(t.key===V.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.GRAB):du(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Wo=!1),t.key.toLowerCase()===V.Z&&(Eu=!1,this.cursor.reset()),t.key===V.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),gu({app:this,event:t})),(t.key===V.ALT&&this.state.bindMode==="skip"||!t[V.CTRL_OR_CMD]&&!mu(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Ho("COMPLEX_BINDINGS"))){let o=Ce({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Rr(oe(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=fe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());xo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[V.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Gt(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),gu({app:this,event:t})}if(Pb(t.key)){MM(this.scene.getSelectedElements(this.state).filter(vc),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Vb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...aA(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...aA(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));w(this,"setActiveTool",(t,o={})=>{let{keepSelection:r=!1}=o;if(!this.isToolSupported(t.type)){console.warn(this.isInteractionEnabled()?`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`:`"${t.type}" tool cannot be activated while the editor is non-interactive (see "interaction.enabled.tools")`);return}if(this.props.activeTool&&!this.isSameForcedTool(this.props.activeTool,t)){console.warn(`"${t.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(gt);let i=la.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?on(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?on(this.state,{...t,lastActiveTool:this.state.activeTool}):on(this.state,t);s.type==="hand"?this.cursor.set(Me.GRAB):Wo||this.cursor.applyForTool(s),OY(document.activeElement)&&this.focusContainer(),uK(s.type)||this.setState({suggestedBinding:null}),s.type==="image"&&this.onImageToolbarButtonClick(),this.setState(l=>{let c={snapLines:l.snapLines.length?[]:l.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:du(s.type)?l.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return s.type==="freedraw"&&this.store.scheduleCapture(),s.type==="lasso"?{...l,...c,activeTool:s,...r?{}:{selectedElementIds:De({},l),selectedGroupIds:De({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:De({},l),selectedGroupIds:De({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});w(this,"setOpenDialog",t=>{this.setState({openDialog:t})});w(this,"isTouchScreenMultiTouchGesture",()=>ue.pointers.size>=2);w(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${TM()}`);w(this,"onGestureStart",qe(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:De({},this.state),activeEmbeddable:null}),ue.initialScale=this.state.zoom.value)}));w(this,"onGestureChange",qe(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=ue.initialScale;o&&this.viewport.translate(r=>({...vo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:jn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));w(this,"onGestureEnd",qe(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:De(this.state.previousSelectedElementIds,this.state)}),ue.initialScale=null)}));w(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=dA(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&rI(o,r,this.state.zoom.value,this.editorInterface.formFactor))});w(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=dA(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(uf,"ui",r),this.cursor.reset(),!0)});w(this,"startTextEditing",({sceneX:t,sceneY:o,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:s,arrowEndpoint:l})=>{let c=!1,d=l&&this.arrowText.getTextBinding(l,this.getCurrentItemStrokeWidth("text"));d&&(i=null,r=!1,t=d.anchor[0],o=d.anchor[1]);let m=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&m&&(Fb(i,this.scene.getNonDeletedElementsMap())||(c=!0));let p=d?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=p?.fontFamily||this.state.currentItemFontFamily,E=p?.lineHeight||wM(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!vc(i)){let C=FK(Mb({fontSize:g,fontFamily:u}),E),P=OK(g,E),M=Math.max(i.height,P),D=Math.max(i.width,C);this.scene.mutateElement(i,{height:M,width:D}),t=i.x+D/2,o=i.y+M/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),v=d?{x:t,y:o}:m?{x:m.elementCenterX,y:m.elementCenterY}:p?{x:t,y:o}:{x:b?.x??t,y:b===null?o-$M(g,E)/2:b.y},y=this.getTopLayerFrameAtSceneCoords({x:v.x,y:v.y}),x=y&&(!c||!i||i.frameId===y.id)?y.id:null,I=p||DM({x:v.x,y:v.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:g,fontFamily:u,textAlign:d?.textAlign??(m?"center":this.state.currentItemTextAlign),verticalAlign:d?.verticalAlign??(m?MY.MIDDLE:fM),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?vc(i)?0:i.angle:0,frameId:x});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:I.id})}),this.setState({editingTextElement:I}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([I],T+1)}else this.insertNewElement(I);l&&d&&this.arrowText.bindText(l,I,d.fixedPoint),a||p||i?this.handleTextWysiwyg(I,{isExistingElement:!!p,initialCaretSceneCoords:p?s:null}):this.setState({newElement:I,multiElement:null})});w(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});w(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});w(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[o,r]=this.lastCompletedCanvasClicks;return go(oe(o.x,o.y),oe(r.x,r.y))<=CM});w(this,"handleCanvasDoubleClick",t=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.state.viewModeEnabled&&!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement)return;if(this.state.viewModeEnabled){let{x:l,y:c}=Ce(t,this.state),d=this.getElementAtPosition(l,c,{includeLockedElements:!0});d&&(this.cursor.reset(),this.actionManager.executeAction(Rn,"ui",[d]));return}if(this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!=="autoshape")return;let o=this.scene.getSelectedElements(this.state),{x:r,y:i}=Ce(t,this.state);if(o.length===1&&Ht(o[0])){let l=o[0];if((t[V.CTRL_OR_CMD]&&Vb(l)||Wb(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(Ma);return}else if(this.state.selectedLinearElement&&Zt(o[0])){let c=fe.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=c?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):-1;if(d&&d>-1){this.store.scheduleCapture(),fe.deleteFixedSegment(o[0],this.scene,d);let m=fe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),p=m?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,segmentMidpoint:{index:p,value:c,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&Wb(l))return}let a=this.getElementAtPosition(r,i,{includeLockedElements:!0});if(a&&Xn(a)){this.actionManager.executeAction(Rn,"ui",[a]);return}if(this.cursor.reset(),WK(this.state).length>0){let l=this.getElementAtPosition(r,i),c=l&&UK(l,this.state.selectedGroupIds);if(c){this.store.scheduleCapture(),this.setState(d=>({...d,...Zn({editingGroupId:c,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),d,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(Ic(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){if(this.getElementAtPosition(r,i,{includeLockedElements:!0})?.locked)return;let d=!t[V.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(d&&(this.state.activeTool.type==="autoshape"||RM(d)||!GY(d.backgroundColor)||Tc({point:oe(r,i),element:d,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(d)}))){let m=Ob(d,this.scene.getNonDeletedElementsMap());r=m.x,i=m.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:d||null})}}});w(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==Tn.MAIN){this.lastCompletedCanvasClicks=[];return}if(this.smartZoomKeyHitElement){t.preventDefault(),t.stopPropagation();return}let o=Ce(t,this.state);if(this.smartZoomKeyDownAt!==null&&!this.smartZoomKeyHitElement){let i=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(i){this.smartZoomKeyHitElement=!0,t.preventDefault(),t.stopPropagation(),this.actionManager.executeAction(Rn,"keyboard",[i]);return}}let r=this.getImageStatusActionAtPosition(o);if(r){t.preventDefault(),t.stopPropagation(),r();return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});w(this,"getImageStatusActionAtPosition",t=>{if(!this.imageStatus.size)return null;let o=this.scene.getNonDeletedElementsMap(),r=this.visibleElements.length?this.visibleElements:this.scene.getNonDeletedElements();for(let i=r.length-1;i>=0;i--){let a=r[i];if(!Xn(a)||!a.fileId)continue;let s=this.imageStatus.get(a.fileId),l=s?.uploadProgress?.onClick;if(l&&this.isPointInsideImageStatusOverlay(t,a,o,"top-right"))return()=>l(a.fileId);let c=s?.downloadError?.onClick;if(c&&this.isPointInsideImageStatusOverlay(t,a,o,"center"))return()=>c(a.fileId)}return null});w(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=Yl(o,r,this.state,i);return!!a&&go(oe(t.x,t.y),oe(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});w(this,"getElementLinkAtPosition",(t,o)=>{if(o&&o.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let s=r[a];if(o&&s.id===o.id&&(i=a),s.link&&a>=i&&Bc(s,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});w(this,"getElementLinkAtPositionForContextMenu",(t,o)=>{let r=this.getElementLinkAtPosition(t,o);if(r)return r;let i=this.scene.getNonDeletedElementsMap();for(let a of this.scene.getNonDeletedElements().slice().reverse())if(a.link&&!a.locked&&wx(a,i,this.state,oe(t.x,t.y)))return a});w(this,"handleElementLinkClick",t=>{let o=d=>d===Tn.MAIN||d===Tn.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=go(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>EM)return;let i=Ce(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),s=Bc(this.hitLinkElement,a,this.state,oe(i.x,i.y),this.editorInterface.formFactor==="phone"),l=Ce(this.lastPointerUpEvent,this.state),c=Bc(this.hitLinkElement,a,this.state,oe(l.x,l.y),this.editorInterface.formFactor==="phone");s&&c&&(ym(),this.openElementLink(this.hitLinkElement,t))});w(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=lu(r);let i;if(this.props.onLinkOpen&&o&&(i=zY(Q.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=NY(r)?"_self":"_blank",s=window.open(void 0,a);s&&(s.opener=null,s.location=r)}});w(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Me.POINTER),_v(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(ym(),!1));w(this,"maybeHandleElementLinkClick",(t,o)=>{if(this.editorInterface.isTouchScreen){let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(o,r)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(t),!0):!1});w(this,"handleInteractiveContentPointerMove",t=>{let o=Ce(t,this.state),r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let i=r?.locked?null:r;if(this.handleIframeLikeElementHover({hitElement:i,scenePointer:o,moveEvent:t}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(o,r):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()});w(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=Ce(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});w(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(l=>!l.locked&&VM(t,l,r));if(!i.length)return null;let a=i.at(-1),s=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(l=>!o?.excludeElementIds?.[l.id]);if(s){if(Tt(s)&&!s.locked)return a;let l=this.scene.getElementIndex(s.id),c=this.scene.getElementIndex(a.id);if(l!==-1&&c!==-1&&l<=c)return a;let d=o?.currentFrameId?i.find(m=>m.id===o.currentFrameId)??null:null;return d||(s.frameId?i.find(m=>m.id===s.frameId)??null:null)}return a});w(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});w(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&sX(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});w(this,"insertNewElements",t=>{if(!t.length)return;let o=[];for(let r of t){let i=o[o.length-1];i?.[0].frameId===r.frameId?i.push(r):o.push([r])}for(let r of o){let i=r[0].frameId,a=i?IK(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});w(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&Tt(o)?o:null)});w(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=jn(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...vo({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},s),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0}),this.resetShouldCacheIgnoreZoomDebounced()});w(this,"handleCanvasPointerMove",t=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(t),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!Vo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Ce(t,this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t);return}if(this.updateMultiTouchGesture(t),Wo||Vo||bu||Cs(this.state))return;let s=kf(kc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(s?this.cursor.set(Me.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Me.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&eI(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=Q2(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(v=>{let y=yc(v.snapLines,b),x=v.originSnapOffset?yc(v.originSnapOffset,g):g;return v.snapLines===y&&v.originSnapOffset===x?null:{snapLines:y,originSnapOffset:x}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(g=>g.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let g=this.state.newElement?null:fe.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Gt(()=>{this.setState({selectedLinearElement:g})})}if(pK(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&mu(this.state)){let b=oe(r,i),v=this.scene.getNonDeletedElementsMap(),y=Rr(b,this.scene.getNonDeletedElements(),v,cA(this.state.zoom));y?this.setState({suggestedBinding:{element:y,midPoint:Yb(b,y,v,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:b}=this.state,{x:v,y,points:x}=g,I=x[x.length-1],{lastCommittedPoint:T}=b;if(this.cursor.applyForTool(),I===T)go(oe(r-v,i-y),I)>=kb?(this.store.scheduleCapture(),Gt(()=>{Eo(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x[x.length-1],selectedPointsIndices:[g.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length}}})}),this.scene.mutateElement(g,{points:[...x,oe(r-v,i-y)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Me.POINTER);else if(x.length>2&&T&&go(oe(r-v,i-y),T)<kb){this.cursor.set(Me.POINTER),this.scene.mutateElement(g,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1});let C=g.points.length-1;this.setState({selectedLinearElement:{...b,selectedPointsIndices:b.selectedPointsIndices?[...new Set(b.selectedPointsIndices.map(P=>Math.min(P,C)))]:b.selectedPointsIndices,lastCommittedPoint:g.points[C],initialState:{...b.initialState,lastClickedPoint:C}}})}else{zM(x,this.state.zoom.value)&&this.cursor.set(Me.POINTER);let C=this.scene.getNonDeletedElementsMap();if(Vb(g)){let M=Rr(oe(r,i),this.scene.getNonDeletedElements(),C);Ho("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,M)}Eo(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=fe.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);P&&this.setState(P)}return}if(this.state.activeTool.type==="arrow"&&!this.state.newElement){let g=oe(r,i),b=Rr(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),cA(this.state.zoom)),v=this.scene.getNonDeletedElementsMap();b&&!lA(g,b,v)&&this.setState({suggestedBinding:{element:b,midPoint:Yb(g,b,v,this.state.zoom)}})}let l=!!t.buttons,c=this.state.activeTool.type==="laser";if(l||!c&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,o)){this.cursor.set(Me.POINTER);return}if(m.length===1&&!s&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(m.length===1&&Zt(m[0]))&&!(Ht(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=eA(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(mA(QM(g),this.state.viewpointFlip));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=tA(bs(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(mA(QM({transformHandleType:g}),this.state.viewpointFlip));return}}if(rn(this.state))return;let p=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p;let E=this.arrowText.updateHoveredAnchor(o);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:o,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(o,p)),!this.applyElementLinkHoverAffordance()){if(c)return;u&&(u.link||Uo(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?this.cursor.set(E?Me.POINTER:$t(u)?Me.TEXT:Me.CROSSHAIR):!t[V.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Me.MOVE):this.state.viewModeEnabled?this.cursor.set(Me.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.AUTO):s?this.cursor.set(Me.AUTO):!t[V.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Zt(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Me.MOVE):this.cursor.set(Me.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:yc(g.hoveredElementIds,Zn({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:yc(g.hoveredElementIds,{})})),this.updateSmartZoomCursor({x:r,y:i})});w(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});w(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(Mc=!0)});w(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),Vo||this.handleCanvasPanUsingWheelOrSpaceDrag(t));return}let o=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=Ce(t,this.state),{x:i,y:a}=r;if(this.lastPointerMoveCoords={x:i,y:a},this.handleSmartZoomPointerDown(t,r))return;let s=t.target;if(s.setPointerCapture&&s.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.state.activeTool.type!=="laser"&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(g=>({searchMatches:g.searchMatches&&{focusedId:null,matches:g.searchMatches.matches.map(b=>({...b,focus:!1}))}})),this.updateEditorAtom(lb,null)),bt.get(po)&&this.updateEditorAtom(po,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),Eu){t.preventDefault(),this.focusContainer(),this.zDragZoom={origin:{clientX:t.clientX,clientY:t.clientY},initialZoom:this.state.zoom.value},this.setState({cursorButton:"down"});return}if(t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let g=this.state.newElement;this.updateScene({...g.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(b=>b.id!==g.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:De(Object.keys(this.state.selectedElementIds).filter(b=>b!==g.id).reduce((b,v)=>(b[v]=this.state.selectedElementIds[v],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?jt.EVENTUALLY:jt.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:"variable"})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=Db(this.editorInterface,{isTouchScreen:!0})),Vo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Tn.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Yn.eraser){this.setState({activeTool:on(this.state,{type:Yn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),v?.(),rn(this.state)&&this.setState({activeTool:on(this.state,{...this.state.activeTool.lastActiveTool||{type:Yn.selection},lastActiveTool:null})})},b=we(window,Q.POINTER_UP,g,{once:!0}),v;requestAnimationFrame(()=>{v=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==Tn.MAIN&&t.button!==Tn.TOUCH&&t.button!==Tn.ERASER||ue.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let g=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[V.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(c.origin.x,c.origin.y,t.shiftKey),c.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&c.hit.element&&!g&&(this.setState(y=>{let x={...y.selectedElementIds,[c.hit.element.id]:!0},I=[];Object.keys(y.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&I.push(P)});let T=c.hit.element;if(Tt(T))zb(I,T.id).forEach(C=>{delete x[C.id]});else if(T.frameId)x[T.frameId]&&delete x[T.id];else{let C=T.groupIds,P=new Set(C.flatMap(M=>Pi(this.scene.getNonDeletedElements(),M)).filter(M=>Tt(M)).map(M=>M.id));P.size>0&&I.forEach(M=>{M.frameId&&P.has(M.frameId)&&(delete x[M.id],M.groupIds.flatMap(D=>Pi(this.scene.getNonDeletedElements(),D)).forEach(D=>{delete x[D.id]}))})}return{...Zn({editingGroupId:y.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),y,this),showHyperlinkPopup:T.link||Uo(T)?"info":!1}}),c.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,c):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="custom"?this.cursor.applyForTool():this.state.activeTool.type===Yn.frame||this.state.activeTool.type===Yn.magicframe?this.createFrameElementOnPointerDown(c,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(c.lastCoords.x,c.lastCoords.y):this.state.activeTool.type==="autoshape"?this.drawShape.handlePointerDown(c):this.state.activeTool.type===Yn.bucketfill?this.bucketFill.handlePointerDown(r):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,c);this.props?.onPointerDown?.(this.state.activeTool,c),this.onPointerDownEmitter.trigger(this.state.activeTool,c,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(c.lastCoords.x,c.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(c),p=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),E=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(g=>p(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(Q.POINTER_MOVE,m),window.addEventListener(Q.POINTER_UP,p),window.addEventListener(Q.KEYDOWN,u),window.addEventListener(Q.KEYUP,E),c.eventListeners.onMove=m,c.eventListeners.onUp=p,c.eventListeners.onKeyUp=E,c.eventListeners.onKeyDown=u)});w(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(Ho("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let o=Ce({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t),this.zDragZoom=null,this.setState({cursorButton:"up"});return}this.handleIframeLikeCenterClick()||!this.maybeHandleElementLinkClick(t,o)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});w(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(Mc=!1,Nr?Mc=!0:Nr=window.setTimeout(()=>{Nr=0,Mc||this.handleCanvasContextMenu(t)},kY))});w(this,"resetContextMenuTimer",()=>{clearTimeout(Nr),Nr=0,Mc=!1});w(this,"maybeCleanupAfterMissingPointerUp",t=>{xs?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});w(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ue.pointers.size<=1&&((t.button===Tn.WHEEL||t.button===Tn.MAIN&&Wo||Cs(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Vo=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let o=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);this.cursor.set(Me.GRABBING);let{clientX:i,clientY:a}=t,s=Fm(c=>{let d=i-c.clientX,m=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!o&&(Math.abs(d)>1||Math.abs(m)>1)){o=!0;let p=E=>{document.body.removeEventListener(Q.PASTE,p),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(Q.PASTE,p),window.removeEventListener(Q.POINTER_UP,u)},100)};document.body.addEventListener(Q.PASTE,p),window.addEventListener(Q.POINTER_UP,u)}this.viewport.translate({scrollX:this.state.scrollX-d*Kn(this.state.viewpointFlip.horizontal)/this.state.zoom.value,scrollY:this.state.scrollY-m*Kn(this.state.viewpointFlip.vertical)/this.state.zoom.value})}),l=qe(xs=()=>{xs=null,Vo=!1,Wo||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,s),window.removeEventListener(Q.POINTER_UP,l),window.removeEventListener(Q.BLUR,l),s.flush()});return window.addEventListener(Q.BLUR,l),window.addEventListener(Q.POINTER_MOVE,s,{passive:!0}),window.addEventListener(Q.POINTER_UP,l),!0});w(this,"updateMultiTouchGesture",t=>{ue.pointers.has(t.pointerId)&&ue.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=ue.initialScale;if(ue.pointers.size===2&&ue.lastCenter&&o&&ue.initialDistance){let r=gf(ue.pointers),i=r.x-ue.lastCenter.x,a=r.y-ue.lastCenter.y;ue.lastCenter=r;let s=ff(Array.from(ue.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/ue.initialDistance,c=l?jn(o*l):this.state.zoom.value;this.setState(d=>{let m=vo({viewportX:r.x,viewportY:r.y,nextZoom:c},d),p=m.zoom.value;return this.viewport.translate({zoom:m.zoom,scrollX:m.scrollX+2*i*Kn(d.viewpointFlip.horizontal)/p,scrollY:m.scrollY+2*a*Kn(d.viewpointFlip.vertical)/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else ue.lastCenter=ue.initialDistance=ue.initialScale=null});w(this,"clearSelectionIfNotUsingSelection",()=>{du(this.state.activeTool.type)||this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});w(this,"handleSelectionOnPointerDown",(t,o)=>{if(du(this.state.activeTool.type)){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!Zt(a[0])&&!(Ht(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=eA(r,this.state,o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);s!=null&&(s.transformHandleType==="rotation"?(this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType))}else a.length>1&&(o.resize.handleType=tA(bs(a),o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(o.resize.handleType)o.resize.isResizing=!0,o.resize.offset=Ab(KK(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Ht(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=XK(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=fe.handlePointerDown(t,this,this.store,o.origin,p,this.scene);if(u.hitElement&&(o.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let E=this.scene.getNonDeletedElementsMap(),g=fe.getElement(p.elementId,E);if(g&&xo(g)){let{hitFocusPoint:b,pointerOffset:v,arrowOtherEndpointInitialBinding:y}=rX(g,o,E,this.state);if(b)return this.setState({selectedLinearElement:{...p,hoveredFocusPointBinding:b,draggedFocusPointBinding:b,pointerOffset:v,initialState:{...p.initialState,arrowOtherEndpointInitialBinding:y}}}),!1}}let s=this.getElementsAtPosition(o.origin.x,o.origin.y,{includeLockedElements:!0}),l=s.filter(p=>!p.locked),c=this.getElementAtPosition(o.origin.x,o.origin.y,{allHitElements:s});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!l.some(p=>this.state.selectedElementIds[p.id])?o.hit.element=null:o.hit.element=o.hit.element??this.getElementAtPosition(o.origin.x,o.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(o.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&o.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),o.hit.element&&this.getElementLinkAtPosition({x:o.origin.x,y:o.origin.y},o.hit.element))return!1;o.hit.allHitElements=l;let d=o.hit.element,m=o.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!m)&&!t.shiftKey&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||d&&d?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState(p=>({selectedLinearElement:p.selectedLinearElement?{...p.selectedLinearElement,isEditing:!!d&&d.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:p.selectedLinearElement?De({[p.selectedLinearElement.elementId]:!0},this.state):De({},p)}));else if(d!=null){if(t[V.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(o.origin.x,o.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({...HK(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!jM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},E=[];if(Object.keys(p.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),Tt(d))zb(E,d.id).forEach(g=>{delete u[g.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let g=d.groupIds,b=new Set(g.flatMap(v=>Pi(this.scene.getNonDeletedElements(),v)).filter(v=>Tt(v)).map(v=>v.id));b.size>0&&E.forEach(v=>{v.frameId&&b.has(v.frameId)&&(delete u[v.id],v.groupIds.flatMap(y=>Pi(this.scene.getNonDeletedElements(),y)).forEach(y=>{delete u[y.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(g=>p.selectedGroupIds[g])||(u={[d.id]:!0})),{...Zn({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||Uo(d)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});w(this,"handleTextOnPointerDown",(t,o)=>{if(this.state.editingTextElement)return;let r=o.origin.x,i=o.origin.y;this.setState({hoveredArrowTextAnchor:null});let a=this.arrowText.getBindableEndpointAtPosition(r,i);if(a)this.startTextEditing({sceneX:r,sceneY:i,autoEdit:!1,arrowEndpoint:a});else{let s=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);RM(s)&&(l=s,r=s.x+s.width/2,i=s.y+s.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});w(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=kt(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=rK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("freedraw"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:l,strokeOptions:{variability:c,streamline:t.pointerType!=="mouse"?yY:xY},locked:!1,frameId:s?s.id:null,points:[oe(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:De(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});w(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=kt(t,o,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=aK({type:"iframe",x:a,y:s,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("iframe"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.insertNewElement(l),l});w(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=kt(t,o,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=uu(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=AM({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("embeddable"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:s.intrinsicSize.w,height:s.intrinsicSize.h,link:r});return this.insertNewElement(l),l});w(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,s]=kt(t,o,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:a,y:s}):null,c=100/this.state.zoom.value;return cK({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("image"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,customData:i,x:a-c/2,y:s-c/2,width:c,height:c})});w(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(Eo(a,"selectedLinearElement is expected to be set"),i.type==="line"&&zM(i.points,this.state.zoom.value)){Gt(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(gt);return}if(Zt(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:s,y:l}=i,{lastCommittedPoint:c}=a,d=Ce(t,this.state),{start:m,end:p}=xo(i)&&mu(this.state)?lX(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),d.x,d.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),E=m?.mode!=null&&p.mode!=null&&m.element.id===p.element.id&&!lA(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&go(oe(r.origin.x-s,r.origin.y-l),c)<kb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(gt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(v=>({selectedElementIds:De({...v.selectedElementIds,[i.id]:!0},v)})),this.cursor.set(Me.POINTER)}else{let[i,a]=kt(r.origin.x,r.origin.y,t[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,m]=o==="arrow"?[l,c]:[null,null],p=o==="arrow"?sK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===_r.round?{type:au.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===_r.elbow,fixedSegments:this.state.currentItemArrowType===_r.elbow?[]:null}):dK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:au.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=oe(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=mu(this.state)?Rr(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[oe(0,0),oe(0,0)]}),this.insertNewElement(p),xo(p)&&QK(p,new Map([[0,{point:oe(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:gM(t.nativeEvent)}),Gt(()=>{this.setState(b=>{let v=null,y=b.selectedElementIds;if(Ht(p)){v=new fe(p,this.scene.getNonDeletedElementsMap());let x=p.points.length-1;v={...v,selectedPointsIndices:[x],initialState:{...v.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:oe(r.origin.x,r.origin.y)}}}return y=this.isToolLocked()?b.selectedElementIds:De({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&xo(p)?{element:g,midPoint:Yb(u,g,E,this.state.zoom)}:null,selectedElementIds:y,selectedLinearElement:v}})}),xo(p)&&Ho("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});w(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=kt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),s={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},l;t==="embeddable"?l=AM({type:"embeddable",...s}):l=lK({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});w(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=kt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Go},s=o===Yn.magicframe?iK(a):oK(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});w(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});w(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(xo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);hu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);hu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else Rb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&hu(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&hu(s,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let o=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||NM(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,bo(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});w(this,"initializeImage",async(t,o)=>{if(!Ni(o))throw new Error(f("errors.unsupportedFileType"));this.cursor.set("wait");let r=this.gifPlayback.createPlaceholderDecodeState(t,o);if(o.type===In.svg)try{o=Fu(GM(await o.text()),o.name)}catch(d){throw console.warn(d),new Error(f("errors.svgImageInsertError"))}else if(o.type!==In.gif){let{maxWidthOrHeight:d}=this.props.imageOptions;try{o=await(this.props.compressImageFile??Lx)(o,{maxWidthOrHeight:d})}catch(m){console.error("Error trying to resize image file on insertion",m)}}let i=o.type,a=i===In.gif,s=await(this.props.generateIdForFile?.(o)||kx(o));if(!s)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[s]?.dataURL){let{maxFileSizeBytes:d}=this.props.imageOptions;if(o.size>d)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(d/1024/1024)}MB`}))}let c=this.files[s]?.dataURL||await Uc(o);return new Promise(async(d,m)=>{try{let p=this.getLatestInitializedImageElement(t,s);if(this.addMissingFiles([{mimeType:i,id:s,dataURL:c,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),a&&(p=this.gifPlayback.ensureElementPlaybackMetadata(p),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(g=>g.id===p.id?p:g)),this.imagePlaceholderUpdateEmitter.trigger()),!this.imageCache.get(s)){a||this.addNewImagesToImageCache();let{erroredFiles:g}=await this.updateImageCache([p]);if(g.size)throw new Error("Image cache update resulted with an error.")}let u=await this.imageCache.get(s)?.image,E=u?EK(u):null;if(u&&this.state.newElement?.id!==p.id){p=this.getLatestInitializedImageElement(t,s);let g=this.getImageNaturalDimensions(p,u);Object.assign(p,g)}p=bo(p,{fileName:o.name,thumbHash:E,gifPlayback:a?this.gifPlayback.ensureElementPlaybackMetadata(p,{playing:!0}).gifPlayback:null,status:"saved"}),this.files={...this.files,[s]:{...this.files[s],fileName:o.name,thumbHash:E??void 0}},r&&r!==s&&this.gifPlayback.removePlaceholderDecodeState(r),d(p)}catch(p){this.gifPlayback.removePlaceholderDecodeState(r),console.error(p),m(new Error(f("errors.imageInsertError")))}})});w(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return bo(r,{fileId:o})});w(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Ce({clientX:t,clientY:o},this.state),a=await xx({description:"Image",extensions:Object.keys(IY),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(gt)})}});w(this,"getImageNaturalDimensions",(t,o)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(o.naturalHeight,i),s=a*(o.naturalWidth/o.naturalHeight),l=t.x+t.width/2-s/2,c=t.y+t.height/2-a/2;return{x:l,y:c,width:s,height:a,crop:null}});w(this,"handleImageCacheUpdate",t=>{for(let o of this.scene.getNonDeletedElements())Si(o)&&o.fileId===t&&Ci.delete(o);this.imagePlaceholderUpdateEmitter.trigger(),this.scene.triggerUpdate(),this.ensureGifPlaybackLoop()});w(this,"updateImageCache",async(t,o=this.files)=>{let r=new Map;for(let s of t){let l=this.imageCache.get(s.fileId);l&&r.set(s.fileId,Promise.resolve(l.image))}let{updatedFiles:i,erroredFiles:a}=await Bb({imageCache:this.imageCache,fileIds:t.map(s=>s.fileId),files:o,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes});for(let[s,l]of r){let c=this.imageCache.get(s);!c||!i.has(s)||this.imageCache.set(s,{...c,placeholderImage:await l,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction(jt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(Si(s)){if(a.has(s.fileId))return bo(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return bo(s,{status:"saved"})}return s}))),{updatedFiles:i,erroredFiles:a}});w(this,"ensureGifPlaybackLoop",()=>{this.gifPlayback.ensureLoop()});w(this,"loadDeferredGif",async t=>{let o=this.imageCache.get(t);this.files[t]?.mimeType!==In.gif||!o||(this.imageCache.set(t,{...o,gifDecodeStatus:"pending"}),this.handleImageCacheUpdate(t),await Bb({imageCache:this.imageCache,fileIds:[t],files:this.files,onImageCacheUpdate:i=>this.handleImageCacheUpdate(i),forceGifDecode:!0}))});w(this,"getGifPlaybackFrameIndex",t=>this.gifPlayback.getFrameIndex(t));w(this,"setGifPlaybackFrameIndex",(t,o)=>{this.gifPlayback.setFrameIndex(t,o)});w(this,"addNewImagesToImageCache",async(t=yK(this.scene.getNonDeletedElements()),o=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,o);if(i.size)for(let a of r)i.has(a.fileId)&&Ci.delete(a);i.size&&this.scene.triggerUpdate()}});w(this,"scheduleImageRefresh",gY(()=>{this.addNewImagesToImageCache()},TY));w(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),this.interactiveCanvas.addEventListener(Q.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(Q.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(Q.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(Q.TOUCH_END,this.onTouchEnd))});w(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,s=iA(t.map((u,E)=>this.newImagePlaceholder({sceneX:o,sceneY:r,customData:i?.[E]})),o,r,a);this.insertNewElements(s);let l=await Promise.all(s.map(async(u,E)=>{try{return await this.initializeImage(u,await Gr(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),bo(u,{isDeleted:!0})}})),c=wc(l),d=iA(l.filter(u=>!u.isDeleted),o,r,a),m=wc(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:De(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:jt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(gt)})});w(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Ce(t,this.state),i=sg(t),a=await mr(t),s=a.getFiles(),l=s.map(d=>d.file).filter(d=>Ni(d));if(this.state.viewModeEnabled)return l.length===0||!this.isToolSupported("image")||!this.shouldInsertImageInViewMode({source:"drop",files:l,event:t})?void 0:this.insertImages(l,o,r,im(a,l.length,i));if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===In.png||d.type===In.svg))try{let p=await As(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,o,r,im(a,l.length,i));if(s.length>0){let{file:d,fileHandle:m}=s[0];d&&await this.loadFileToCanvas(d,m)}let c=a.findByType(In.text);if(c){let d=c.value;if(d&&Nb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||uu(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:lu(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});w(this,"loadFileToCanvas",async(t,o)=>{t=await Gr(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await As(t,this.state,r,o)}catch(a){let s=a instanceof bx;if(s&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let l=s?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:l})}if(!i)return;fA(r.concat(i.elements)),this.store.scheduleMicroAction({action:jt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({elements:i.elements,files:i.files,appState:{...i.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});w(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),!this.isInteractionEnabled()||(this.bucketFill.cancel(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Tn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Ce(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.isLinksEnabled()?this.getElementLinkAtPositionForContextMenu({x:o,y:r},i):void 0,s=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},s),c=l&&s.length===1&&s[0].link?s[0]:void 0,d=i??a??c,m=d||l?"element":"canvas",p=this.excalidrawContainerRef.current,{top:u,left:E}=p.getBoundingClientRect(),g=t.clientX-E,b=t.clientY-u;Ue("contextMenu","openContextMenu",m),this.setState({...d&&!this.state.selectedElementIds[d.id]?{...this.state,...Zn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Ht(d)?new fe(d,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(m,d)}})})});w(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){nA({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Es(t.origin.x,a.x),height:Es(t.origin.y,a.y),shouldMaintainAspectRatio:Ec(o),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let s=this.state.newElement;if(!s||this.arrowText.maybeDragNewText(s,a))return;let[l,c]=kt(a.x,a.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=Si(s)&&this.imageCache.get(s.fileId)?.image,m=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:p,snapLines:u}=J2(s,this,o,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:l-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());l+=p.x,c+=p.y,this.setState({snapLines:u}),xo(s)||nA({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:Es(t.originInGrid.x,l),height:Es(t.originInGrid.y,c),shouldMaintainAspectRatio:Xn(s)?!Ec(o):Ec(o),shouldResizeFromCenter:hM(o),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:s}),(this.state.activeTool.type===Yn.frame||this.state.activeTool.type===Yn.magicframe)&&this.setState({elementsToHighlight:Hb(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});w(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=kt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&Xn(l)){let c=t.originalElements.get(l.id),d=Si(l)&&this.imageCache.get(l.fileId)?.image;if(c&&Xn(c)&&d&&!(d instanceof Promise)){let[m,p]=kt(i.x,i.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:E,snapLines:g}=yf([l],[c],this,o,u,r);this.scene.mutateElement(l,_K(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),pu(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});w(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(Tt),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Zt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=kt(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{zb(this.scene.getNonDeletedElements(),m.id).forEach(u=>{d.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=kt(s.x,s.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y},E=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(o,r);let{snapOffset:g,snapLines:b}=yf(r,de(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(ZK(t.originalElements,a,r,this.scene,gM(o),hM(o),r.some(m=>Xn(m))?!Ec(o):Ec(o),l,c,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{Hb(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{fu(u)?m.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...m]}),!0}return!1});w(this,"getImageContextMenuItems",t=>{let o=this.props.imageContextMenuItems;if(!o)return[];let r=this.scene.getSelectedElements(this.state);return r.length>0&&r.every(i=>Xn(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&Xn(t)?[...o([t.id])]:[]});w(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>Xn(r))&&(!t||this.state.selectedElementIds[t.id])?[bg,xg]:[]});w(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=lu(t.link),r=XM(o);return[{key:"goToLink",label:r?f("labels.link.goToElement"):"Go to link",onSelect:()=>this.openElementLink(t)},!r&&{key:"copyLink",label:f("buttons.copyLink"),onSelect:async()=>{await ao(o),this.setState({toast:{message:f("toast.elementLinkCopied"),closable:!0}})}}]});w(this,"getContextMenuItems",(t,o)=>{let r=this.getImageContextMenuItems(o),i=this.getImageActionContextMenuItems(o),a=this.getElementLinkContextMenuItems(o);if(t==="canvas")return this.state.viewModeEnabled?[Rn,ga,fa,Ge,ba,_a,gr]:[vg,Ge,wh,Hv,Ge,ba,_t,gl,fl,Ge,ga,fa,Ge,_a,gr];if(this.state.viewModeEnabled)return[...a,a.length>0&&Ge,Rn,ga,fa,Ge,Ea,r.length>0&&Ge,...r];let s=this.editorInterface.formFactor==="desktop"?[Ge,Eh,bh,xh,yh]:[];return[Ge,Rn,ga,fa,Ge,Em,Ea,vg,r.length>0&&Ge,...r,i.length>0&&Ge,...i,Ge,D2,L2,_2,Ge,lf,Ge,gg,uf,Sg,Cg,Tv,fg,Ge,...s,Ge,yg,wg,Ge,Ma,Ge,Ng,a.length>0&&Ge,...a,Ge,vh,xl,Ge,Gs]});w(this,"handleWheel",qe(t=>{if(!this.isNavigationEnabled())return;if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&(t.target.classList.contains(Lb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[V.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Vo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=AY*100,s=Math.abs(r),l=r;s>a&&(l=a*i);let c=this.state.zoom.value-l/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,s/20);let d=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:DY;c=Math.max(c,d),this.viewport.translate(p=>({...vo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:jn(c)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a,viewpointFlip:s})=>({scrollX:a-(r||o)*Kn(s.horizontal)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:s,viewpointFlip:l})=>({scrollX:a-o*Kn(l.horizontal)/i.value,scrollY:s-r*Kn(l.vertical)/i.value}))}));w(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=Ce({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let s={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:s,button:r,pointersMap:ue.pointers})});w(this,"resetShouldCacheIgnoreZoomDebounced",vM(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));w(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:s}=o.getBoundingClientRect(),{width:l,height:c,offsetTop:d,offsetLeft:m}=this.state;if(r===l&&i===c&&a===m&&s===d){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:s},()=>{t&&t()}),this.viewport.constrain()}});w(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});w(this,"watchState",()=>{});let o=Zo(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${TM()}`,wheelZoomsOnDefault:d=!1}=t,m=null;t.activeTool&&(t.activeTool.type==="image"?console.warn('"image" tool cannot be forced via "props.activeTool"'):this.isToolSupported(t.activeTool.type,t)?m=on(o,t.activeTool):console.warn(`"${t.activeTool.type}" tool ("props.activeTool") cannot be activated \u2014 disabled via "UIOptions.tools", or not enabled while non-interactive (see "interaction.enabled.tools")`)),this.state={...o,theme:l,exportWithDarkMode:l===bc.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(t)?i||r:!0,viewModeOnly:i,activeTool:m??o.activeTool,zenModeEnabled:!1,objectsSnapModeEnabled:s,gridModeEnabled:a??o.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:d},this.refreshEditorInterface(),this.stylesPanelMode=wu(this.editorInterface),this.id=EY(),this.actionManager=new _m(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new oA,this.canvas=document.createElement("canvas"),this.rc=fY.canvas(this.canvas),this.renderer=new Ol(this.scene),this.visibleElements=[],this.store=new qK(this),this.history=new Bl(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Io(this.scene),this.history=new Bl(this.store),this.actionManager.registerAll(rd),this.actionManager.registerAction(F2(this.history)),this.actionManager.registerAction(O2(this.history)),this.api=this.createExcalidrawAPI()}get lastViewportPosition(){return this.viewport.lastPosition}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,addFiles:this.addFiles,addImagePlaceholder:this.addImagePlaceholder,setDownloadProgress:this.setDownloadProgress,setDownloadError:this.setDownloadError,setUploadProgress:this.setUploadProgress,addImageElementsToScene:this.addImageElementsToScene,scrollToViewport:this.scrollToViewport,scrollToContent:this.scrollToContent,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},setViewport:this.viewport.setViewport,getViewportOffsets:this.viewport.getOffsets,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:o=>{this.actionManager.registerAction(o)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:o=>this.onChangeEmitter.on(o),onIncrement:o=>this.store.onStoreIncrementEmitter.on(o),onPointerDown:o=>this.onPointerDownEmitter.on(o),onPointerUp:o=>this.onPointerUpEmitter.on(o),onScrollChange:o=>this.onScrollChangeEmitter.on(o),onUserFollow:o=>this.onUserFollowEmitter.on(o),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(t=this.props){return t.interaction!==!1&&typeof t.interaction!="object"}isLinksEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.links===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isNavigationEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.navigation===!0:t.interaction!==!1}isEmbedsEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.embeds===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isBrowserZoomEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.browserZoom===!0:!1}isToolLocked(){return this.state.activeTool.locked||this.props.activeTool!=null}isActiveToolPointerCapturing(){return this.isInteractionEnabled()?this.state.activeTool.type==="laser"||this.state.activeTool.type==="custom":this.isToolSupported(this.state.activeTool.type)}isDefaultUIEnabled(t=this.props){return t.ui!==!1&&(typeof t.ui!="object"||t.ui===null)}isUIControlEnabled(t,o=this.props){return typeof o.ui=="object"&&o.ui!==null?o.ui.enabled?.[t]===!0:o.ui!==!1}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let o=null;try{o=JSON.parse(t.data)}catch{}if(o)switch(t.origin){case"https://player.vimeo.com":if(o.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:o.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(o.event==="infoDelivery"&&o.info&&o.id&&typeof o.info.playerState=="number"){let r=o.id,i=o.info.playerState;Object.values(su).includes(i)&&Kb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){Eo(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=Rr(oe(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=fe.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&o?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Gt(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:o}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;Eo(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?fe.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):fe.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);s&&this.setState(s)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,o){if(t.isDeleted||Zt(t))return;let r=()=>{if(this.bindModeHandler=null,Eo(this.lastPointerMoveCoords,"Expected lastPointerMoveCoords to be set"),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let E=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!E&&!g||E&&g)return}let{x:m,y:p}=this.lastPointerMoveCoords,u=Rr(oe(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){Eo(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let E=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Gt(()=>{Eo(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:E}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;Eo(g,"Last event must exist");let b=m-this.state.selectedLinearElement.pointerOffset.x,v=p-this.state.selectedLinearElement.pointerOffset.y,y=this.state.multiElement?fe.handlePointerMove(g,this,b,v,this.state.selectedLinearElement):fe.handlePointDragging(g,this,b,v,this.state.selectedLinearElement);y&&this.setState(y)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let m=this.scene.getNonDeletedElementsMap(),p=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),E=p?o:t.startBinding&&m.get(t.startBinding.elementId),g=u?o:t.endBinding&&m.get(t.endBinding.elementId),b=E&&sA(E,m),v=g&&sA(g,m);i=!!(b&&v&&E.id!==g.id&&eX(b,v))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),s=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),l=a?"startBinding":s?"endBinding":null,c=a?"endBinding":s?"startBinding":null,d=c&&t[c]?.mode==="inside"&&t[c]?.elementId===o?.id||l&&t[l]?.mode==="inside"&&o?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&o?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!o||this.previousHoveredBindableElement&&o.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Gt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,XY)),this.previousHoveredBindableElement=o}cacheEmbeddableRef(t,o){o&&this.iFrameRefs.set(t.id,o)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==Tn.MAIN||Wo||!PM(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(Ce({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=oe(Ce({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(go(t,o)>EM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&ue.pointers.size<2&&Ic(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,o[0],o[1]))))return!1;let s=i;if(this.state.activeEmbeddable?.element===s&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:s,state:"active"},selectedElementIds:{[s.id]:!0},newElement:null,selectionElement:null})},100),_b(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=Kb.get(s.id);switch(c||(Kb.set(s.id,su.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case su.PLAYING:case su.BUFFERING:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return l.src.includes("player.vimeo.com")&&l.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*"),!0}isIframeLikeElementCenter(t,o,r,i){return t&&!o.altKey&&!o.shiftKey&&!o.metaKey&&!o.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,o=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Uo(a)&&this.embedsValidationStatus.get(a.id)===!0||_b(a));return Pe(uX,{children:i.map(a=>{let{x:s,y:l}=cu({sceneX:a.x,sceneY:a.y},this.state),c=FM(a,o,r,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(c&&!d&&this.initializedEmbeds.add(a.id),!(c||d))return null;let p=uu(BY(a.link||"")),u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",E=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover",g=p?.type==="video",b=fc(g?t:1,.75,dX);return Pe("div",{className:cM("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:c?`translate(${s-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t*Kn(this.state.viewpointFlip.horizontal)}, ${t*Kn(this.state.viewpointFlip.vertical)})`:"none",display:c?"block":"none",opacity:GK(a,Ub(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?RY:1),"--embeddable-radius":`${bK(Math.min(a.width,a.height),a)}px`},children:Xb("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?fs.enabled:fs.disabled},children:[E&&Pe("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Pe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:Pe("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(Uo(a)?this.props.renderEmbeddable?.(a,this.state):null)??Pe("iframe",{ref:v=>this.cacheEmbeddableRef(a,v),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:o,renderTopLeftUI:r,renderCustomStats:i}=this.props,{elementsMap:a,visibleElements:s,canvasNonce:l,newElementCanvasElement:c}=this.renderer.getRenderableElements({zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElement:this.state.newElement,selectedElements:t,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=s,this.hasRenderableElements=a.size>0;let d=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",p=t[0],u=bt.get(po)?.type==="panel";return Pe("div",{translate:"no",className:cM("excalidraw excalidraw-container notranslate",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone","excalidraw--non-interactive":!this.isInteractionEnabled(),"excalidraw--navigation":!this.isInteractionEnabled()&&this.isNavigationEnabled(),"excalidraw--tools":!this.isInteractionEnabled()&&this.isToolSupported(this.state.activeTool.type),"excalidraw--embeds":!this.isInteractionEnabled()&&this.isEmbedsEnabled(),"excalidraw--allow-browser-zoom":!this.isInteractionEnabled()&&this.isBrowserZoomEnabled(),"excalidraw--ui-hidden":!this.isDefaultUIEnabled(),"excalidraw--mobile-toolbar":this.editorInterface.formFactor==="phone"&&this.isDefaultUIEnabled()&&!this.state.viewModeEnabled,"excalidraw--viewport-status-border":!!this.props.viewportStatusFrame?.border,"excalidraw--viewport-status-label":!!this.props.viewportStatusFrame?.label,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":m?fs.disabled:fs.enabled,"--right-sidebar-width":`${dE}px`},ref:this.excalidrawContainerRef,onDrop:this.isInteractionEnabled()?this.handleAppOnDrop:void 0,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally||!this.isInteractionEnabled()?void 0:this.onKeyDown,onPointerEnter:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,onPointerLeave:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,children:Pe(ys.Provider,{value:this.api,children:Pe(EA.Provider,{value:this,children:Pe(bA.Provider,{value:this.props,children:Pe(qb.Provider,{value:this.excalidrawContainerValue,children:Pe(jb.Provider,{value:this.editorInterface,children:Pe(ex.Provider,{value:this.setAppState,children:Pe(Qb.Provider,{value:this.state,children:Xb(Jb.Provider,{value:this.scene.getNonDeletedElements(),children:[Xb(tx.Provider,{value:this.actionManager,children:[Pe(Uk,{canvas:this.canvas,appState:this.state,defaultUIEnabled:this.isDefaultUIEnabled(),zoomUIEnabled:this.isUIControlEnabled("zoom"),scrollBackToContentUIEnabled:this.isUIControlEnabled("scrollBackToContent"),files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,langCode:Jn().code,renderTopLeftUI:r,renderTopRightUI:o,renderCustomStats:i,showExitZenModeBtn:!1,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,currentUserControls:this.props.currentUserControls,children:this.props.children}),Pe("div",{className:"excalidraw-textEditorContainer"}),Pe("div",{className:"excalidraw-contextMenuContainer"}),Pe("div",{className:"excalidraw-eye-dropper-container"}),Pe(Vk,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Pe(aM,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Pe(Dv,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),this.isDefaultUIEnabled()&&this.state.contextMenu&&Pe(pS,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:E=>{this.setState({contextMenu:null},()=>{this.focusContainer(),E?.()})}}),Pe(Tb,{app:this,canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:d,visibleElements:s,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,renderGrid:br(this),renderLinks:this.isLinksEnabled(),imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),c&&Pe(eM,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Pe(Ib,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:s,allElementsMap:d,selectedElements:t,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,interactionEnabled:this.isInteractionEnabled(),navigationEnabled:this.isNavigationEnabled(),renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onClick:this.handleCanvasClick,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor==="phone"&&Pe(xp,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Pe(lM,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Pe(OT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{Si(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),Ci.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,uA()||hA()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(r=>{this.history.record(r.delta)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(r=>{this.props.onIncrement?.(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),LY&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorInterface(),this.updateDOMRect()}),this.resizeObserver?.observe(this.excalidrawContainerRef.current)),new URLSearchParams(window.location.search.slice(1)).has("web-share-target")?this.restoreFileFromShare():this.updateDOMRect(this.initializeScene),jY()&&!NK()&&this.setState({errorMessage:Pe(rS,{})});let o={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit("editor:mount",o),this.props.onMount?.(o),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){this.gifPlayback.stop(),this.api={...this.api,isDestroyed:!0};for(let t of Object.keys(this.api))(t.startsWith("get")||t==="onStateChange"||t==="onEvent")&&typeof this.api[t]=="function"&&(this.api[t]=()=>{throw new Error("ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit("editor:unmount"),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new oA,this.fonts=new Io(this.scene),this.renderer=new Ol(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.viewport.destroy(),this.removeEventListeners(),this.laserTrails.stop(),this.drawShape.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),Ci.destroy(),gn.destroy(),clearTimeout(Nr),Re.clearCache(),Zn.clearCache(),Nr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(we(window,Q.MESSAGE,this.onWindowMessage,!1),we(document,Q.POINTER_UP,this.removePointer,{passive:!1}),we(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),we(window,Q.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),we(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.handleNavigationModeKeyDown,!1),we(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(document,Q.GESTURE_START,this.onGestureStart,!1),we(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),we(document,Q.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),we(this.excalidrawContainerRef.current,Q.GESTURE_START,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.GESTURE_CHANGE,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(we(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(we(document,Q.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),we(document,Q.COPY,this.onCopy,{passive:!1}),we(document,Q.KEYUP,this.onKeyUp,{passive:!0}),we(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(document,Q.GESTURE_START,this.onGestureStart,!1),we(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),we(document,Q.GESTURE_END,this.onGestureEnd,!1),we(document,Q.PASTE,this.pasteFromClipboard,{passive:!1}),we(this.excalidrawContainerRef.current,Q.DRAG_OVER,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(we(document,Q.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),we(document,Q.CUT,this.onCut,{passive:!1}),we(window,Q.RESIZE,this.onResize,!1),we(window,Q.UNLOAD,this.onUnload,!1),we(window,Q.BLUR,this.onBlur,!1),we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(we(FY(this.excalidrawContainerRef.current),Q.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,o){!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit("editor:initialize",this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(t,o),this.handleForcedToolChange(t,o),this.ensureGifPlaybackLoop(),this.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===bc.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),(o.zoom.value!==this.state.zoom.value||o.scrollX!==this.state.scrollX||o.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),Object.keys(this.state.selectedElementIds).length&&rn(this.state)&&this.setState({activeTool:on(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&o.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type==="bucketfill"&&o.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),o.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),rn(o)&&!rn(this.state)&&this.eraserTrail.endPath(),(o.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&o.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===bc.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(gt)});let s=Object.keys(this.state.selectedElementIds);if(s.length){let c=s.filter(d=>{let m=this.scene.getElement(d);return!m||m.isDeleted});c.length&&this.setState(d=>{let m={...d.selectedElementIds};for(let p of c)delete m[p];return{selectedElementIds:De(m,d)}})}if(this.state.editingTextElement){let c=this.scene.getElement(this.state.editingTextElement.id);(!c||c.isDeleted)&&this.setState({editingTextElement:null})}let l=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==l&&this.setState({scrolledOutside:l}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){Sc=!1,Pc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Ce({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(o.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&t.text){let d=Qm(t.text);if(d.ok){this.setState({openDialog:{name:"charts",data:d.data,rawText:t.text}});return}}if(t.elements){let d=t.programmaticAPI?tX(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:d,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r,preserveFrameChildrenOrder:!0});return}let s=o.map(d=>d.file);if(s.length===0&&t.text&&!r){let d=t.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&s.push(Fu(d))}if(s.length>0){this.isToolSupported("image")?await this.insertImages(s,i,a):this.setState({errorMessage:f("errors.imageToolNotSupported")});return}if(!t.text)return;let l=UY(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>xK(d)).filter(d=>Nb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||uu(d)?.type==="video"));if(!r&&c.length>0&&c.length===l.length){let d=[];for(let m of c){let p=d[d.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:lu(m)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(m=>[m.id,!0]))}));return}this.addTextFromPaste(t.text,r)}containsImagePaste(t,o,r){if(o.some(a=>Ni(a.file))||!r&&t.mixedContent?.some(a=>a.type==="imageUrl"))return!0;if(r||!t.text)return!1;let i=t.text.trim();return i.startsWith("<svg")&&i.endsWith("</svg>")}shouldInsertImageInViewMode({source:t,files:o,data:r,event:i}){return this.state.viewModeEnabled?this.state.viewModeOnly||this.props.viewModeImageInsertBehavior==="reject"?(this.props.onViewModeImageInsertRejected?.({source:t,files:o,data:r,event:i}),!1):(Gt(()=>{this.setState({viewModeEnabled:!1})}),!0):!0}async addElementsFromMixedContentPaste(t,{isPlainPaste:o,sceneX:r,sceneY:i}){if(!o&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(d=>d.type==="imageUrl").map(d=>d.value),s=await Promise.all(a.map(async d=>{try{return{file:await _x(d)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=f("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=f("errors.unsupportedFileType")),{errorMessage:p}}})),l=s.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(l,r,i);let c=s.find(d=>!!d.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(s=>s.type==="text");a.length&&this.addTextFromPaste(a.map(s=>s.value).join(`
20
+ `)},_W=(e,n,t)=>{let r=LW(e.text,e.originalText).split(`
21
+ `),i=[],a=0,s=0;for(let m of r){let p=a,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:s}),a=u+1,s++}let l=t,c=e.originalText.slice(t,t+n.length),d=[];for(let m of i){if(c==="")break;if(l>=m.startIndex&&l<=m.endIndex){let p=m.endIndex+1-l,u=m.line.slice(0,l-m.startIndex),E=c.slice(0,p);c=c.slice(p);let g=uc(u,Jp(e),e.lineHeight);if(u===""&&(g.width=0),e.textAlign!=="left"&&m.line.length>0){let I=uc(m.line,Jp(e),e.lineHeight),T=e.textAlign==="center"?(e.width-I.width)/2:e.width-I.width;g.width+=T}let{width:b,height:v}=uc(E,Jp(e),e.lineHeight),w=g.width,x=m.lineNumber*g.height;d.push({offsetX:w,offsetY:x,width:b,height:v,showOnCanvas:!0}),l+=p}}return d},RW=(e,n,t,o)=>{let r=e.name??vk(e),i=r.slice(t,t+n.length),a=r.slice(0,t),s=Jp({fontSize:sb.nameFontSize,fontFamily:ab.Assistant}),l=vW(ab.Assistant),c=uc(a,s,l);a===""&&(c.width=0);let d=uc(i,s,l),m=c.width,p=-c.height-sb.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*o}]},NW=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),yk=EW((e,n,t)=>{if(!e||e===""){t([],null);return}let o=n.scene.getNonDeletedElements(),r=o.filter(p=>wk(p)),i=o.filter(p=>Qp(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],s=new RegExp(NW(e),"gi");for(let p of r){let u=null,E=p.originalText;for(;(u=s.exec(E))!==null;){let g=xk(E,u.index,e),b=_W(p,e,u.index);b.length>0&&a.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let l=[];for(let p of i){let u=null,E=p.name??vk(p);for(;(u=s.exec(E))!==null;){let g=xk(E,u.index,e),b=RW(p,e,u.index,n.state.zoom.value);b.length>0&&l.push({element:p,searchQuery:e,preview:g,index:u.index,matchedLines:b})}}let c=new Set(n.visibleElements.map(p=>p.id)),d=[...l,...a],m=d.findIndex(p=>c.has(p.element.id))??null;t(d,m)},kW);import $W from"clsx";import{useEffect as Mk,useLayoutEffect as Ak,useRef as Eb,useState as jW,forwardRef as Dk,useImperativeHandle as qW,useCallback as Ck}from"react";import{CLASSES as JW,EVENT as Pk,isDevEnv as QW,KEYS as eV,updateObject as tV}from"@excalidraw/common";import OW from"clsx";import{useContext as zW}from"react";import FW from"react";var eu=FW.createContext({});import{jsx as cb,jsxs as Tk}from"react/jsx-runtime";var db=({children:e,className:n})=>{let t=fe(),o=zW(eu),r=!!(t.canFitSidebar&&o.shouldRenderDockButton);return Tk("div",{className:OW("sidebar__header",n),"data-testid":"sidebar-header",children:[e,Tk("div",{className:"sidebar__header__buttons",children:[r&&cb(ht,{label:f("labels.sidebarLock"),children:cb(vn,{onSelect:()=>o.onDock?.(!o.docked),selected:!!o.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:Wx})}),cb(vn,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:o.onCloseRequest,"aria-label":f("buttons.close"),children:an})]})]})};db.displayName="SidebarHeader";import{Tabs as GW}from"radix-ui";import{jsx as Sk}from"react/jsx-runtime";var mb=({children:e,tab:n,onSelect:t,...o})=>Sk(GW.Trigger,{value:n,asChild:!0,onSelect:t,children:Sk("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...o,children:e})});mb.displayName="SidebarTabTrigger";import{Tabs as HW}from"radix-ui";import{jsx as UW}from"react/jsx-runtime";var pb=({children:e,...n})=>UW(HW.List,{className:"sidebar-triggers",...n,children:e});pb.displayName="SidebarTabTriggers";import WW from"clsx";import{jsx as ub,jsxs as VW}from"react/jsx-runtime";var hb=({name:e,tab:n,icon:t,title:o,children:r,onToggle:i,className:a,style:s})=>{let l=Ve(),d=ye().openSidebar?.name===e;return ub("button",{type:"button",title:o,className:"sidebar-trigger__label-element","aria-label":o,"aria-keyshortcuts":"0","aria-pressed":d,onClick:()=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=!d;l({openSidebar:m?{name:e,tab:n}:null,openMenu:null,openPopup:null}),i?.(m)},children:VW("div",{className:WW("sidebar-trigger",a),style:s,children:[t&&ub("div",{children:t}),r&&ub("div",{className:"sidebar-trigger__label",children:r})]})})};hb.displayName="SidebarTrigger";import{Tabs as YW}from"radix-ui";import{jsx as KW}from"react/jsx-runtime";var gb=({children:e,...n})=>{let t=ye(),o=Ve();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return KW(YW.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>o(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...n,children:e})};gb.displayName="SidebarTabs";import{Tabs as XW}from"radix-ui";import{jsx as ZW}from"react/jsx-runtime";var fb=({tab:e,children:n,...t})=>ZW(XW.Content,{...t,value:e,"data-testid":e,children:n});fb.displayName="SidebarTab";import{jsx as kk}from"react/jsx-runtime";import{createElement as nV}from"react";var bb=Qe(!1),Lk=Dk(({name:e,children:n,onDock:t,docked:o,className:r,...i},a)=>{QW()&&t&&o==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let s=Ve(),l=Fx(bb);Ak(()=>(l(!!o),()=>{l(!1)}),[l,o]);let c=Eb({});c.current.onCloseRequest=()=>{s({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=tV(c.current,{docked:o,shouldRenderDockButton:!!t&&o!=null});let d=Eb(null);qW(a,()=>d.current);let m=fe(),p=Ck(()=>{document.querySelector(".Dialog")||s({openSidebar:null})},[s]);return $i(d,Ck(u=>{u.target.closest(".sidebar-trigger")||(!o||!m.canFitSidebar)&&p()},[p,o,m.canFitSidebar])),Mk(()=>{let u=E=>{E.key===eV.ESCAPE&&(!o||!m.canFitSidebar)&&p()};return document.addEventListener(Pk.KEYDOWN,u),()=>{document.removeEventListener(Pk.KEYDOWN,u)}},[p,o,m.canFitSidebar]),kk(Ze,{...i,className:$W(JW.SIDEBAR,{"sidebar--docked":o},r),"data-viewport-ui":m.formFactor!=="phone"?"side":void 0,"data-viewport-ui-name":m.formFactor!=="phone"?"sidebar":void 0,ref:d,children:kk(eu.Provider,{value:c.current,children:n})})});Lk.displayName="SidebarInner";var _r=Object.assign(Dk((e,n)=>{let t=ye(),{onStateChange:o}=e,r=Eb(t.openSidebar);Mk(()=>{(!t.openSidebar&&r?.current?.name===e.name||t.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&t.openSidebar!==r.current&&o?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,o,e.name]);let[i,a]=jW(!1);return Ak(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?nV(Lk,{...e,ref:n,key:e.name}):null}),{Header:db,TabTriggers:pb,TabTrigger:mb,Tabs:gb,Tab:fb,Trigger:hb});_r.displayName="Sidebar";import{jsx as hs,jsxs as iV}from"react/jsx-runtime";import{createElement as aV}from"react";var Rk=bi("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:n}=it();return hs(n.In,{children:hs(_r.Trigger,{...e,className:"default-sidebar-trigger",name:rV.name})})});Rk.displayName="DefaultSidebarTrigger";var Nk=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:n}=it();return hs(n.In,{children:e})};Nk.displayName="DefaultTabTriggers";var xb=Object.assign(bi("DefaultSidebar",({children:e,className:n,docked:t,onDock:o,...r})=>{let i=ye(),a=Ve(),s=i.openSidebar?.tab===_k,l=s?!1:t??i.defaultSidebarDockedPreference,c=!s&&t==null&&o!==!1;return aV(_r,{...r,name:"default",key:"default",className:oV("default-sidebar",{"default-sidebar--search-only":s},n),docked:l,onDock:c?d=>{a({defaultSidebarDockedPreference:d}),o?.(d)}:void 0},iV(_r.Tabs,{children:[!s&&hs(_r.Header,{}),hs(_r.Tab,{tab:_k,children:hs(Ik,{})}),!s&&e]}))}),{Trigger:Rk,TabTriggers:Nk});import lV from"react";import{getFrame as cV}from"@excalidraw/common";import{jsx as sV}from"react/jsx-runtime";var yb={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"}},wb=({children:e,color:n})=>sV("div",{className:"Card",style:{"--card-color":yb[n].base,"--card-color-darker":yb[n].darker,"--card-color-darkest":yb[n].darkest},children:e});import{Fragment as mV,jsx as Vn,jsxs as tu}from"react/jsx-runtime";var dV=({elements:e,appState:n,setAppState:t,files:o,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:s})=>{let{onExportToBackend:l}=i;return Vn("div",{className:"ExportDialog ExportDialog--json",children:tu("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&tu(wb,{color:"lime",children:[Vn("div",{className:"Card-icon",children:a1}),Vn("h2",{children:f("exportDialog.disk_title")}),tu("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Ni&&r.renderAction("changeProjectName")]}),Vn($,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(ul,"ui")}})]}),l&&tu(wb,{color:"pink",children:[Vn("div",{className:"Card-icon",children:Fs}),Vn("h2",{children:f("exportDialog.link_title")}),Vn("div",{className:"Card-details",children:f("exportDialog.link_details")}),Vn($,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{We("export","link",`ui (${cV()})`),await l(e,n,o),s()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,n,o,a)]})})},Bk=({elements:e,appState:n,files:t,actionManager:o,exportOpts:r,canvas:i,setAppState:a})=>{let s=lV.useCallback(()=>{a({openDialog:null})},[a]);return Vn(mV,{children:n.openDialog?.name==="jsonExport"&&Vn(wn,{onCloseRequest:s,title:f("buttons.export"),children:Vn(dV,{elements:e,appState:n,setAppState:a,files:t,actionManager:o,onCloseRequest:s,exportOpts:r,canvas:i})})})};import pV from"clsx";import{jsx as uV}from"react/jsx-runtime";var Fk=e=>uV($,{className:pV("ToolIcon__LaserPointer",{"is-mobile":e.isMobile}),type:"toggle",size:"small",icon:no,checked:e.checked,title:`${e.title}`,"aria-label":`${e.title}`,"data-testid":"toolbar-LaserPointer",onSelect:()=>e.onChange?.()});import Hk from"clsx";import{useState as fV}from"react";import{CANVAS_SEARCH_TAB as EV,DEFAULT_SIDEBAR as bV,KEYS as hc}from"@excalidraw/common";import hV from"clsx";import{jsx as gV}from"react/jsx-runtime";var Ok=e=>gV($,{className:hV("ToolIcon__lock",{"is-mobile":e.isMobile}),type:"toggle",icon:e.checked?$o:To,checked:e.checked,disabled:e.disabled,title:`${e.title} \u2014 Q`,"aria-label":`${e.title}`,"data-testid":"toolbar-lock",onSelect:()=>e.onChange?.()});import{Fragment as Ci,jsx as re,jsxs as zo}from"react/jsx-runtime";var xV=(e,n)=>e==="image"&&n.tools?.image===!1,yV=({app:e,activeTool:n,type:t,shortcut:o})=>re(ge.Item,{onSelect:()=>e.setActiveTool({type:t}),icon:Be[t].icon,"data-testid":`toolbar-${t}`,selected:n.type===t,shortcut:o??mr(t),disabled:tt(e,t),children:f(`toolBar.${t}`)}),zk=({app:e})=>re(ge.Item,{onSelect:()=>e.toggleLock(),icon:e.state.activeTool.locked?$o:To,"data-testid":"toolbar-lock",selected:e.state.activeTool.locked,shortcut:hc.Q.toLocaleUpperCase(),children:f("toolBar.lock-short")}),wV=({actionManager:e,app:n})=>{if(!e.isActionEnabled(_t))return null;let t=Je("objectsSnapMode");return re(ge.Item,{onSelect:()=>e.executeAction(_t,"ui"),icon:Jo,"data-testid":"toolbar-objects-snap-mode",selected:n.state.objectsSnapModeEnabled,shortcut:t,children:f("buttons.objectsSnapMode")})},vV=({actionManager:e,app:n})=>{if(!e.isActionEnabled(_t))return null;let t=f("buttons.objectsSnapMode"),o=Je("objectsSnapMode");return re($,{type:"toggle",icon:Jo,checked:n.state.objectsSnapModeEnabled,title:`${t} - ${o}`,"aria-label":t,"aria-keyshortcuts":o,"data-testid":"toolbar-objects-snap-mode",onSelect:()=>e.executeAction(_t,"ui")})},Gk=({actionManager:e,appState:n})=>{let t=f("search.title"),o=Je("searchMenu");return re(ge.Item,{onSelect:()=>e.executeAction(Nl,"ui"),icon:oo,"data-testid":"toolbar-search-menu",selected:n.openSidebar?.name===bV.name&&n.openSidebar.tab===EV,shortcut:o,children:t})},IV=({app:e})=>re($,{type:"button",icon:Ki,title:`${f("labels.eyeDropper")} - ${hc.I.toLocaleUpperCase()}`,"aria-label":f("labels.eyeDropper"),"aria-keyshortcuts":hc.I.toLocaleUpperCase(),keyBindingLabel:hc.I.toLocaleUpperCase(),"data-testid":"toolbar-eyedropper",onClick:()=>e.openEyeDropper({type:"stroke",swapPreviewOnAlt:!1})}),TV=({app:e,activeTool:n,setAppState:t,UIOptions:o,isMyocSimplifiedMode:r,actionManager:i})=>{let[a,s]=fV(!1),l=mt()==="full",c=n.type==="frame",d=n.type==="autoshape",m=n.type==="laser",p=n.type==="bucketfill",u=l&&n.type==="lasso"&&e.state.preferredSelectionTool.type!=="lasso",E=n.type==="embeddable",g=r&&dr.includes(n.type);return zo(ge,{open:a,children:[re(ge.Trigger,{className:Hk("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":g||c||E||!r&&l&&d||u||p||m&&!e.props.isCollaborating}),onToggle:()=>{s(!a),t({openMenu:null,openPopup:null})},title:f("toolBar.extraTools"),children:g?Be[n.type].icon:c?to:E?qo:!r&&l&&d?Kr:m&&!e.props.isCollaborating?no:u?Hi:p?eo:Ls}),re(ge.Content,{onClickOutside:()=>s(!1),onSelect:()=>s(!1),className:"App-toolbar__extra-tools-dropdown",children:r?zo(Ci,{children:[l&&re(ge.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Hi,"data-testid":"toolbar-lasso",selected:u,disabled:tt(e,"lasso"),children:f("toolBar.lasso")}),dr.filter(b=>!xV(b,o)).map(b=>re(yV,{app:e,activeTool:n,type:b},b)),re("div",{className:"App-toolbar__dropdown-divider"}),re(Gk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&re(Ci,{children:re(zk,{app:e})})]}):zo(Ci,{children:[re(ge.Item,{onSelect:()=>e.setActiveTool({type:"frame"}),icon:to,shortcut:hc.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:c,disabled:tt(e,"frame"),children:f("toolBar.frame")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"embeddable"}),icon:qo,"data-testid":"toolbar-embeddable",selected:E,disabled:tt(e,"embeddable"),children:f("toolBar.embeddable")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"autoshape"}),icon:Kr,shortcut:mr("autoshape"),"data-testid":"toolbar-autoshape",selected:d,disabled:tt(e,"autoshape"),children:f("toolBar.autoshape")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"laser"}),icon:no,"data-testid":"toolbar-laser",selected:m,disabled:tt(e,"laser"),children:f("toolBar.laser")}),re(ge.Item,{onSelect:()=>e.setActiveTool({type:"bucketfill"}),icon:eo,"data-testid":"toolbar-bucketfill",selected:p,disabled:tt(e,"bucketfill"),children:f("toolBar.bucketfill")}),l&&re(ge.Item,{onSelect:()=>e.setActiveTool({type:"lasso"}),icon:Hi,"data-testid":"toolbar-lasso",selected:u,disabled:tt(e,"lasso"),children:f("toolBar.lasso")}),re("div",{className:"App-toolbar__dropdown-divider"}),re(wV,{actionManager:i,app:e}),re(Gk,{actionManager:i,appState:e.state}),e.props.activeTool==null&&re(zk,{app:e})]})})]})},Uk=({app:e,appState:n,setAppState:t,UIOptions:o,actionManager:r,onPenModeToggle:i,onLockToggle:a,heading:s})=>{let l=fe(),c=mt()==="compact",d=n.activeTool,m={app:e,activeTool:d},p=n.myocSimplifiedMode,u=c?re(Zd,{...m,setAppState:t}):n.preferredSelectionTool.type==="lasso"?re(dw,{...m}):re(cw,{...m});return zo(Ze,{padding:1,className:Hk("App-toolbar",{"zen-mode":n.zenModeEnabled,"App-toolbar--compact":c}),"data-viewport-ui":"top",children:[re(qp,{appState:n,isMobile:l.formFactor==="phone",editorInterface:l,app:e}),s,zo(Ft.Row,{gap:c?.5:1,children:[!c&&re(rs,{checked:n.penMode,onChange:()=>i(null),title:f("toolBar.penMode"),penDetected:n.penDetected}),e.props.activeTool==null&&!p&&zo(Ci,{children:[re(Ok,{checked:n.activeTool.locked,onChange:a,title:f("toolBar.lock"),disabled:e.props.activeTool!=null}),re("div",{className:"App-toolbar__divider"})]}),re(Xd,{...m}),u,p?zo(Ci,{children:[re(ol,{...m}),re(rl,{...m}),re(IV,{app:e}),o.tools?.image!==!1&&re(il,{...m}),re(al,{...m})]}):zo(Ci,{children:[re(ow,{...m}),re(rw,{...m}),re(iw,{...m}),re(aw,{...m}),re(sw,{...m}),c?re($d,{...m}):re(ol,{...m}),re(rl,{...m}),o.tools?.image!==!1&&re(il,{...m}),re(al,{...m})]}),re("div",{className:"App-toolbar__divider"}),re(TV,{app:e,activeTool:d,setAppState:t,UIOptions:o,isMyocSimplifiedMode:p,actionManager:r}),p&&zo(Ci,{children:[re("div",{className:"App-toolbar__divider"}),re(vV,{actionManager:r,app:e})]})]})]})};import{Fragment as vb,jsx as te,jsxs as nn}from"react/jsx-runtime";var DV=({UIOptions:e})=>nn(Ot,{__fallback:!0,children:[te(Ot.DefaultItems.LoadScene,{}),te(Ot.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&te(Ot.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&te(Ot.DefaultItems.SaveAsImage,{}),te(Ot.DefaultItems.SearchMenu,{}),te(Ot.DefaultItems.Help,{}),te(Ot.Separator,{}),te(Ot.Group,{title:"Excalidraw links",children:te(Ot.DefaultItems.Socials,{})}),te(Ot.Separator,{}),te(Ot.DefaultItems.ToggleTheme,{allowSystemTheme:!1}),te(Ot.DefaultItems.ChangeCanvasBackground,{})]}),LV=()=>nn(Fp,{__fallback:!0,children:[te(Fp.Actions.SaveToDisk,{}),te(Fp.Actions.ExportToImage,{})]}),_V=({actionManager:e,appState:n,files:t,setAppState:o,elements:r,canvas:i,onLockToggle:a,onPenModeToggle:s,showExitZenModeBtn:l,renderTopLeftUI:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:E,children:g,app:b,defaultUIEnabled:v,zoomUIEnabled:w,scrollBackToContentUIEnabled:x,isCollaborating:I,generateLinkForSelection:T,currentUserControls:C})=>{let P=fe(),M=Ln(),_=mt()==="compact",k=ES(),L=_?{menuTopGap:4,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:.5,islandPadding:1,collabMarginLeft:8}:{menuTopGap:6,toolbarColGap:4,toolbarRowGap:1,toolbarInnerRowGap:1,islandPadding:1,collabMarginLeft:8},F=k.tunnelsJotai.Provider,[K,z]=Xe(Ut),U=()=>p.canvasActions.export?te(Bk,{elements:r,appState:n,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:o}):null,W=()=>!p.canvasActions.saveAsImage||n.openDialog?.name!=="imageExport"?null:te(hk,{elements:r,appState:n,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>o({openDialog:null}),name:b.getName()}),G=()=>nn("div",{style:{position:"relative"},children:[nn("div",{className:"excalidraw-ui-top-left",children:[c?.(!1,n),te(k.MainMenuTunnel.Out,{}),te(k.DefaultSidebarTriggerTunnel.Out,{})]}),E&&te(k.WelcomeScreenMenuHintTunnel.Out,{})]}),ie=()=>te(tc,{heading:"selectedShapeActions",className:gs("selected-shape-actions zen-mode-transition",{"transition-left":n.zenModeEnabled}),children:_?te(Ze,{className:gs("compact-shape-actions-island"),padding:0,"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",style:{maxHeight:`${n.height-166}px`},children:te(BS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b,setAppState:o})}):te(Ze,{className:CV.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${n.height-166}px`},"data-viewport-ui":"side","data-viewport-ui-name":"stylesPanel",children:te(DS,{appState:n,elementsMap:b.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:b})})}),me=()=>{let ae=v&&AV(n,r),xe=v&&n.stats.open&&!n.zenModeEnabled&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector";return te(Pp,{side:"top",children:nn("div",{className:"App-menu App-menu_top",children:[nn(Ft.Col,{gap:L.menuTopGap,className:gs("App-menu_top__left"),children:[G(),v&&te("div",{className:gs("selected-shape-actions-container",{"selected-shape-actions-container--compact":_}),children:ae&&ie()}),v&&_&&!n.viewModeEnabled&&ae&&te(rs,{checked:n.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:n.penDetected})]}),v&&n.viewModeEnabled&&te("div",{className:"view-mode-hint",children:te(qp,{appState:n,isMobile:P.formFactor==="phone",editorInterface:P,app:b})}),v&&!n.viewModeEnabled&&n.openDialog?.name!=="elementLinkSelector"&&te(tc,{heading:"shapes",className:"shapes-section",children:ce=>nn("div",{style:{position:"relative"},children:[E&&te(k.WelcomeScreenToolbarHintTunnel.Out,{}),te(Ft.Col,{gap:L.toolbarColGap,align:"start",children:nn(Ft.Row,{gap:L.toolbarRowGap,className:gs("App-toolbar-container",{"zen-mode":n.zenModeEnabled}),children:[te(Uk,{app:b,appState:n,setAppState:o,UIOptions:p,actionManager:e,onPenModeToggle:s,onLockToggle:a,heading:ce}),I&&te(Ze,{style:{marginLeft:L.collabMarginLeft,alignSelf:"center",height:"fit-content"},children:te(Fk,{title:f("toolBar.laser"),checked:n.activeTool.type===Wk.laser,onChange:()=>b.setActiveTool({type:Wk.laser}),isMobile:!0})})]})})]})}),nn("div",{className:gs("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":n.zenModeEnabled,"layer-ui__wrapper__top-right--compact":_}),children:[v&&n.collaborators.size>0&&te(Dp,{collaborators:n.collaborators,userToFollow:M.userToFollow?.socketId||null,currentUserControls:C}),d?.(P.formFactor==="phone",n),xe&&te(cc,{app:b,onClose:()=>{e.executeAction(Er)},renderCustomStats:m})]})]})})},B=()=>te(xb,{}),Y=!1,pe=nn(vb,{children:[g,v&&te(vb,{children:te(DV,{UIOptions:p})}),te(LV,{}),v&&n.isLoading&&te(vp,{delay:250}),v&&n.errorMessage&&te(jP,{onClose:()=>o({errorMessage:null}),children:n.errorMessage}),v&&K&&P.formFactor!=="phone"&&te(Y0,{colorPickerType:K.colorPickerType,onCancel:()=>{z(null)},onChange:(ae,xe,ce,{altKey:Oe})=>{if(!(ae!=="elementBackground"&&ae!=="elementStroke"))if(ce.length){for(let se of ce)kV(se,PV(r),{[Oe&&K.swapPreviewOnAlt?ae==="elementBackground"?"strokeColor":"backgroundColor":ae==="elementBackground"?"backgroundColor":"strokeColor"]:xe}),MV.delete(se);b.scene.triggerUpdate()}else o(ae==="elementBackground"?{currentItemBackgroundColor:xe}:{currentItemStrokeColor:xe})},onSelect:(ae,xe)=>{z(ce=>ce?.keepOpenOnAlt&&xe.altKey?ce:null),K?.onSelect?.(ae,xe)}}),n.openDialog?.name==="help"&&te(ak,{onClose:()=>{o({openDialog:null})}}),v&&n.openDialog?.name==="elementLinkSelector"&&te($P,{sourceElementId:n.openDialog.sourceElementId,onClose:()=>{o({openDialog:null})},scene:b.scene,appState:n,generateLinkForSelection:T}),te(k.OverwriteConfirmDialogTunnel.Out,{}),W(),U(),v&&n.openDialog?.name==="charts"&&te(TC,{data:n.openDialog.data,rawText:n.openDialog.rawText,onClose:()=>o({openDialog:null})}),v&&te(nk,{app:b,files:t,setAppState:o}),P.formFactor==="phone"&&te(pC,{app:b,appState:n,elements:r,actionManager:e,renderJSONExportDialog:U,renderImageExportDialog:W,setAppState:o,onPenModeToggle:s,renderTopLeftUI:c,renderTopRightUI:d,renderSidebars:B,renderWelcomeScreen:E,defaultUIEnabled:v,scrollBackToContentUIEnabled:x}),P.formFactor!=="phone"&&nn(vb,{children:[M.viewportStatusFrame?.border&&te(xp,{border:M.viewportStatusFrame.border,style:Y?{right:"calc(var(--right-sidebar-width) - var(--space-factor) * 2)"}:void 0}),nn("div",{className:"layer-ui__wrapper",style:Y?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[E&&te(k.WelcomeScreenCenterTunnel.Out,{}),me(),te(DC,{appState:n,actionManager:e,showExitZenModeBtn:l,renderWelcomeScreen:E,defaultUIEnabled:v,zoomUIEnabled:w}),(n.toast||x&&n.scrolledOutside||M.viewportStatusFrame?.label)&&nn("div",{className:"floating-status-stack",children:[n.toast&&te(Qd,{message:n.toast.message,onClose:()=>o({toast:null}),duration:n.toast.duration,closable:n.toast.closable}),!n.toast&&x&&n.scrolledOutside&&te("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{o(ae=>({..._i(r,ae)}))},children:f("buttons.scrollBackToContent")}),M.viewportStatusFrame?.label&&te(yp,{label:M.viewportStatusFrame.label,border:M.viewportStatusFrame.border})]})]})]}),B()]});return te(Sh.Provider,{value:n,children:te(F,{children:te(uE.Provider,{value:k,children:pe})})})},Vk=e=>{let{cursorButton:n,scrollX:t,scrollY:o,zoom:r,shouldCacheIgnoreZoom:i,snapLines:a,originSnapOffset:s,suggestedBinding:l,frameToHighlight:c,elementsToHighlight:d,...m}=e;return m},RV=(e,n)=>{if(e.children!==n.children)return!1;let{canvas:t,appState:o,...r}=e,{canvas:i,appState:a,...s}=n;return nu(Vk(o),Vk(a),{selectedElementIds:nu,selectedGroupIds:nu})&&nu(r,s)},Yk=SV.memo(_V,RV);import{useEffect as NV,useRef as BV}from"react";import{jsx as Kk}from"react/jsx-runtime";var Xk=({trails:e})=>{let n=BV(null);return NV(()=>{if(n.current)for(let t of e)t.start(n.current);return()=>{for(let t of e)t.stop()}},e),Kk("div",{className:"SVGLayer",children:Kk("svg",{ref:n})})};import FV,{useEffect as Zk,useRef as $k}from"react";import{isShallowEqual as OV,sceneCoordsToViewportCoords as zV}from"@excalidraw/common";import{jsx as UV}from"react/jsx-runtime";var jk="animateInteractiveScene",GV=e=>{let n=$k(!1),t=$k(null);return Zk(()=>{let o=null,r=()=>{o===null&&(o=requestAnimationFrame(()=>{o=null,t.current&&qf({...t.current,callback:()=>{}})}))},i=e.app.imageLoadingProgressEmitter.on(r),a=e.app.imageStatusEmitter.on(r);return()=>{i(),a(),o!==null&&cancelAnimationFrame(o)}},[e.app]),Zk(()=>{if(!n.current){n.current=!0;return}let o=new Map,r=new Map,i=new Map,a=new Map,s=new Map;e.appState.collaborators.forEach((c,d)=>{if(c.selectedElementIds)for(let m of Object.keys(c.selectedElementIds))i.has(m)||i.set(m,[]),i.get(m).push(d);!c.pointer||c.pointer.renderCursor===!1||(c.username&&a.set(d,c.username),c.userState&&s.set(d,c.userState),r.set(d,zV({sceneX:c.pointer.x,sceneY:c.pointer.y},e.appState)),o.set(d,c.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";t.current={app:e.app,canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:o,remoteSelectedElementIds:i,remotePointerUsernames:a,remotePointerUserStates:s,selectionColor:l,renderScrollbars:e.renderScrollbars,lastViewportPosition:e.app.viewport.lastPosition},editorInterface:e.editorInterface,callback:e.renderInteractiveSceneCallback,animationState:{bindingHighlight:void 0},deltaTime:0},ct.running(jk)||ct.start(jk,({deltaTime:c,state:d})=>{let m=qf({...t.current,deltaTime:c,animationState:d}).animationState;if(m){for(let p in m)if(m[p]!==void 0)return m}})}),UV("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onClick:e.onClick,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.onDoubleClick,children:f("labels.drawingCanvas")})},qk=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewpointFlip:e.viewpointFlip,viewModeEnabled:e.viewModeEnabled,activeTool:e.activeTool,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,newElement:e.newElement,isBindingEnabled:e.isBindingEnabled,isMidpointSnappingEnabled:e.isMidpointSnappingEnabled,gridModeEnabled:e.gridModeEnabled,suggestedBinding:e.suggestedBinding,hoveredArrowTextAnchor:e.hoveredArrowTextAnchor,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId,hoveredElementIds:e.hoveredElementIds,frameRendering:e.frameRendering,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,exportScale:e.exportScale,currentItemArrowType:e.currentItemArrowType}),HV=(e,n)=>e.selectionNonce!==n.selectionNonce||e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements||e.selectedElements!==n.selectedElements||e.renderScrollbars!==n.renderScrollbars||e.interactionEnabled!==n.interactionEnabled||e.navigationEnabled!==n.navigationEnabled?!1:OV(qk(e.appState),qk(n.appState)),Ib=FV.memo(GV,HV);import eM,{useEffect as ou,useRef as gc}from"react";import{isShallowEqual as Jk}from"@excalidraw/common";import{hasActiveGifDecode as WV}from"@excalidraw/element";import{jsx as KV}from"react/jsx-runtime";var VV=e=>{let n=gc(null),t=gc(!1),o=gc(e),r=gc(()=>{}),i=gc(null);o.current=e;let a=eM.useCallback(()=>{let s=o.current,l=n.current;if(!l)return;let c=getComputedStyle(l).getPropertyValue("--color-grid-bold").trim(),d=getComputedStyle(l).getPropertyValue("--color-grid-regular").trim();Tx({canvas:s.canvas,rc:s.rc,scale:s.scale,elementsMap:s.elementsMap,allElementsMap:s.allElementsMap,visibleElements:s.visibleElements,appState:s.appState,renderConfig:{...s.renderConfig,gridColorBold:c,gridColorRegular:d}},Na());let m=s.renderConfig.imageTransitionDuration??0,p=m>0&&s.visibleElements.some(E=>{if(E.type!=="image"||!E.fileId)return!1;let g=s.renderConfig.imageCache.get(E.fileId)?.transitionStart;return g!==void 0&&performance.now()-g<m}),u=WV(s.visibleElements,s.renderConfig.imageCache);(p||u)&&i.current===null&&(i.current=requestAnimationFrame(()=>{i.current=null,r.current()}))},[]);return r.current=a,ou(()=>{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]),ou(()=>{let s=n.current;if(!s)return;let l=e.canvas;t.current||(t.current=!0,s.replaceChildren(l),l.classList.add("excalidraw__canvas","static")),a()}),ou(()=>{let s=null,l=e.app.imagePlaceholderUpdateEmitter.on(()=>{s===null&&(s=requestAnimationFrame(()=>{s=null,a()}))});return()=>{l(),s!==null&&cancelAnimationFrame(s)}},[e.app,a]),ou(()=>()=>{i.current!==null&&cancelAnimationFrame(i.current)},[]),KV("div",{className:"excalidraw__canvas-wrapper",ref:n})},Qk=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewpointFlip:e.viewpointFlip,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId,suggestedBinding:e.suggestedBinding}),YV=(e,n)=>e.canvasNonce!==n.canvasNonce||e.scale!==n.scale||e.elementsMap!==n.elementsMap||e.visibleElements!==n.visibleElements?!1:Jk(Qk(e.appState),Qk(n.appState))&&Jk(e.renderConfig,n.renderConfig),Tb=eM.memo(VV,YV);import{useEffect as QV,useRef as eY}from"react";import{throttleRAF as XV}from"@excalidraw/common";import{getTargetFrame as ZV,isInvisiblySmallElement as $V,renderElement as jV,shouldApplyFrameClip as qV}from"@excalidraw/element";var tM=({canvas:e,rc:n,newElement:t,elementsMap:o,allElementsMap:r,scale:i,appState:a,renderConfig:s})=>{if(e){let[l,c]=Fc(e,i),d=Oc({canvas:e,scale:i,normalizedWidth:l,normalizedHeight:c});if(d.save(),zc(d,a),t&&t.type!=="selection"){if($V(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let u=ZV(t,o,a);u&&qV(t,u,a,o)&&vx(u,d,s,a)}jV(t,o,r,n,d,s,a)}else d.clearRect(0,0,l,c);d.restore()}},JV=XV(e=>{tM(e)}),nM=(e,n)=>{if(n){JV(e);return}tM(e)};import{jsx as nY}from"react/jsx-runtime";var tY=e=>{let n=eY(null);return QV(()=>{n.current&&nM({canvas:n.current,scale:e.scale,newElement:e.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Na())}),nY("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:n})},oM=tY;import oY from"clsx";import{useLayoutEffect as rY,useEffect as rM,useRef as iY,useState as aY}from"react";import{ARROW_TYPE as iM,EVENT as ru}from"@excalidraw/common";import{jsx as dY}from"react/jsx-runtime";var aM=700,sY=100,lY=16,cY=5*60*1e3,lM=Qe(null),sM=e=>e===iM.elbow?er:e===iM.round?tr:Qo,iu=class{constructor(n){y(this,"app");y(this,"lastShownAt",0);y(this,"show",n=>{let{x:t,y:o}=this.app.viewport.lastPosition;t===0&&o===0||(this.lastShownAt=Date.now(),this.app.updateEditorAtom(lM,{content:n,nonce:Math.random()}))});y(this,"isOnCooldown",()=>Date.now()-this.lastShownAt<cY);y(this,"onArrowTypeCycled",n=>{this.show(sM(n))});y(this,"onToolShortcut",(n,t)=>{(t==="digit"||!this.isOnCooldown())&&this.show(n==="line"?jo:sM(this.app.state.currentItemArrowType))});this.app=n}},cM=()=>{let[e,n]=Xe(lM),t=xt(),{container:o}=ze(),r=iY(null),[i,a]=aY(!1),s=e?.nonce;return rY(()=>{if(s==null||!o)return;let l=(d,m)=>{let p=r.current;if(!p)return;let{left:u,top:E}=gd({cursor:{x:d,y:m},element:{width:p.offsetWidth,height:p.offsetHeight},container:o.getBoundingClientRect(),gap:lY});p.style.transform=`translate(${u}px, ${E}px)`};l(t.viewport.lastPosition.x,t.viewport.lastPosition.y);let c=d=>{l(d.clientX,d.clientY)};return window.addEventListener(ru.POINTER_MOVE,c),()=>{window.removeEventListener(ru.POINTER_MOVE,c)}},[s,o,t]),rM(()=>()=>{n(null)},[n]),rM(()=>{if(s==null)return;a(!1);let l=window.setTimeout(()=>{a(!0)},aM),c=window.setTimeout(()=>{n(null)},aM+sY),d=()=>{n(null)};return window.addEventListener(ru.POINTER_DOWN,d,{capture:!0}),()=>{window.clearTimeout(l),window.clearTimeout(c),window.removeEventListener(ru.POINTER_DOWN,d,{capture:!0})}},[s,n]),e?dY("div",{ref:r,className:oY("CursorHint",{"CursorHint--fade-out":i}),"data-testid":"cursor-hint",children:e.content}):null};var au=class{constructor(n){this.getState=n;y(this,"listeners",[]);y(this,"onStateChange",(n,t,o)=>{let{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}=this.normalize(n,t,o);return a?l&&(queueMicrotask(()=>{let c=this.getState();a(i(c),c)}),s)?()=>{}:this.subscribe({predicate:r,getValue:i,callback:a,once:s}):l?Promise.resolve(i(this.getState())):new Promise(c=>{this.subscribe({predicate:r,getValue:i,callback:d=>c(d),once:!0})})})}isStateChangePredicateOptions(n){return typeof n=="object"&&!Array.isArray(n)&&"predicate"in n}subscribe(n){return this.listeners.push(n),()=>{this.listeners=this.listeners.filter(t=>t!==n)}}normalize(n,t,o){let r,i,a=t,s=o?.once??!1,l=!1;if(this.isStateChangePredicateOptions(n)){let{predicate:c,callback:d,once:m}=n;r=c,i=p=>p,a=d?(p,u)=>d(u):void 0,s=m??!1,l=c(this.getState())}else if(typeof n=="function"){let c=n;r=(d,m)=>c(d)!==c(m),i=d=>c(d)}else if(Array.isArray(n)){let c=n;r=(d,m)=>c.some(p=>d[p]!==m[p]),i=d=>d}else{let c=n;r=(d,m)=>d[c]!==m[c],i=d=>d[c]}return{predicate:r,getValue:i,callback:a,once:s,matchesImmediately:l}}flush(n){if(!this.listeners.length)return;let t=this.getState(),o=[];for(let r of this.listeners)r.predicate(t,n)?(r.callback(r.getValue(t),t),r.once||o.push(r)):o.push(r);this.listeners=o}clear(){this.listeners=[]}};import{getCommonBounds as mY,getElementsInGroup as pY,isNonDeletedElement as dM,selectGroupsFromGivenElements as uY}from"@excalidraw/element";import{sceneCoordsToViewportCoords as hY}from"@excalidraw/common";import{flushSync as gY}from"react-dom";import{jsx as EY}from"react/jsx-runtime";var fY=({app:e,activeLockedId:n})=>{let t=e.scene.getElement(n);t&&!dM(t)&&console.error("[NONDELETED][INVARIANT] UnlockPopup: activeLockedId points to a deleted element");let o=t&&dM(t)?t:null,r=o?[o]:pY(e.scene.getNonDeletedElementsMap(),n);if(r.length===0)return null;let[i,a]=mY(r),{x:s,y:l}=hY({sceneX:i,sceneY:a},e.state);return EY("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${s-e.state.offsetLeft}px`},onClick:()=>{gY(()=>{let c=uY(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:c,activeLockedId:null})}),e.actionManager.executeAction(xl)},title:f("labels.elementLock.unlock"),children:Vx})},mM=fY;import{Fragment as EX,jsx as Pe,jsxs as Xb}from"react/jsx-runtime";var yA=Sn.createContext(null),wA=Sn.createContext(null),Zb={formFactor:"desktop",desktopUIMode:"full",userAgent:bA(typeof navigator<"u"?navigator.userAgent:""),isTouchScreen:!1,canFitSidebar:!1,isLandscape:!0},jb=Sn.createContext(Zb);jb.displayName="EditorInterfaceContext";var uX={"editor:mount":{cardinality:"once",replay:"last"},"editor:initialize":{cardinality:"once",replay:"last"},"editor:unmount":{cardinality:"once",replay:"last"}},qb=Sn.createContext({container:null,id:null});qb.displayName="ExcalidrawContainerContext";var Jb=Sn.createContext([]);Jb.displayName="ExcalidrawElementsContext";var Qb=Sn.createContext({...Zo(),width:0,height:0,offsetLeft:0,offsetTop:0});Qb.displayName="ExcalidrawAppStateContext";var ex=Sn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});ex.displayName="ExcalidrawSetAppStateContext";var tx=Sn.createContext(null);tx.displayName="ExcalidrawActionManagerContext";var ys=Sn.createContext(null);ys.displayName="ExcalidrawAPIContext";var Iu=Sn.createContext(null);Iu.displayName="ExcalidrawAPISetContext";var xt=()=>Yo(yA),Ln=()=>Yo(wA),fe=()=>Yo(jb),mt=()=>vu(fe()),ze=()=>Yo(qb),qi=()=>Yo(Jb),ro=()=>Yo(Qb),Ve=()=>Yo(ex),at=()=>Yo(tx),Fd=()=>Yo(ys),Sc=!1,Cc=0,Pc=null,Wo=!1,bu=!1,Vo=!1,xu=!1,kc={horizontal:null,vertical:null},Fr=0,Mc=!1,Kb=new Map,hX=4,gX=300,hA=(e,n)=>n.horizontal===n.vertical?e:e==="nwse-resize"?"nesw-resize":e==="nesw-resize"?"nwse-resize":e,yu=!1,wu=0,gA=!1,xs=null,ue={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},$b=class e extends Sn.Component{constructor(t){super(t);y(this,"canvas");y(this,"interactiveCanvas",null);y(this,"sessionExportThemeOverride");y(this,"rc");y(this,"unmounted",!1);y(this,"actionManager");y(this,"editorInterface",Zb);y(this,"stylesPanelMode",vu(Zb));y(this,"excalidrawContainerRef",Sn.createRef());y(this,"scene");y(this,"fonts");y(this,"renderer");y(this,"visibleElements");y(this,"hasRenderableElements",!1);y(this,"resizeObserver");y(this,"id");y(this,"store");y(this,"history");y(this,"excalidrawContainerValue");y(this,"files",{});y(this,"imageCache",new Map);y(this,"imageLoadingProgress",new Map);y(this,"imageLoadingProgressEmitter",new fo);y(this,"imageStatus",new Map);y(this,"imageStatusEmitter",new fo);y(this,"imagePlaceholderUpdateEmitter",new fo);y(this,"iFrameRefs",new Map);y(this,"embedsValidationStatus",new Map);y(this,"initializedEmbeds",new Set);y(this,"elementsPendingErasure",new Set);y(this,"_initialized",!1);y(this,"editorLifecycleEvents",new ZY(uX));y(this,"onEvent",this.editorLifecycleEvents.on.bind(this.editorLifecycleEvents));y(this,"appStateObserver",new au(()=>this.state));y(this,"onStateChange",this.appStateObserver.onStateChange);y(this,"bucketFill",new cp(this));y(this,"flowchart",new hp(this));y(this,"cursor",new dp(this));y(this,"gifPlayback",new gp(this));y(this,"zDragZoom",null);y(this,"arrowText",new lp(this));y(this,"viewport",new Ep(this,{getContainer:()=>this.excalidrawContainerRef.current,getStylesPanelMode:()=>this.stylesPanelMode,isGestureActive:()=>ue.pointers.size>=2||Vo}));y(this,"bindModeHandler",null);y(this,"textWysiwygSubmitHandler",null);y(this,"hitLinkElement");y(this,"lastPointerDownEvent",null);y(this,"lastPointerUpEvent",null);y(this,"lastPointerUpIsDoubleClick",!1);y(this,"lastPointerMoveEvent",null);y(this,"lastPointerMoveCoords",null);y(this,"lastCompletedCanvasClicks",[]);y(this,"lastKeyboardSmartZoomImageId",null);y(this,"smartZoomKeyDownAt",null);y(this,"smartZoomKeyHitElement",!1);y(this,"previousPointerMoveCoords",null);y(this,"drawShape",new up(this));y(this,"laserTrails",new zm(this));y(this,"eraserTrail",new Km(this));y(this,"lassoTrail",new Ym(this));y(this,"cursorHints",new iu(this));y(this,"onChangeEmitter",new fo);y(this,"onPointerDownEmitter",new fo);y(this,"onPointerUpEmitter",new fo);y(this,"onUserFollowEmitter",new fo);y(this,"onScrollChangeEmitter",new fo);y(this,"missingPointerEventCleanupEmitter",new fo);y(this,"onRemoveEventListenersEmitter",new fo);y(this,"api");y(this,"getCommandToolTypes",()=>this.state.myocSimplifiedMode?[...tw,...dr]:Object.keys(Be));y(this,"resolveCommandToolType",t=>{if(!Object.prototype.hasOwnProperty.call(Be,t))return null;let o=t;if(!this.getCommandToolTypes().includes(o))return null;let r=o==="selection"?this.state.preferredSelectionTool.type:o;return!this.isToolSupported(r)||this.props.activeTool!=null&&this.props.activeTool.type!==r?null:r});y(this,"getCommandActionEntry",(t,o)=>{if(!t.keyTest||!this.actionManager.isActionAvailableForUI(t))return null;let r=typeof t.label=="function"?t.label(o,this.state,this):t.label;if(!r.trim())return null;let i=typeof t.icon=="function"?t.icon(this.state,o):t.icon,a=gT(t.name);return{id:`action:${t.name}`,kind:"action",label:f(r,null,r),...i?{icon:i}:{},...t.keywords?{keywords:t.keywords}:{},...a?{shortcut:a}:{}}});y(this,"getCommandCatalog",()=>{let t=this.actionManager.getElementsIncludingDeleted(),o=Object.values(this.actionManager.actions).flatMap(i=>{let a=this.getCommandActionEntry(i,t);return a?[a]:[]}),r=this.getCommandToolTypes().flatMap(i=>{let a=this.resolveCommandToolType(i);if(!a)return[];let s=mr(i);return[{id:`tool:${i}`,kind:"tool",label:KY(f(`toolBar.${a}`)),icon:Be[a].icon,...s?{shortcut:s}:{}}]});return[...o,...r]});y(this,"executeCommand",t=>{if(t.startsWith("action:")){let i=t.slice(7);if(!Object.prototype.hasOwnProperty.call(this.actionManager.actions,i))return!1;let a=this.actionManager.actions[i];return!a||`action:${a.name}`!==t||!this.getCommandActionEntry(a,this.actionManager.getElementsIncludingDeleted())?!1:(this.actionManager.executeAction(a,"ui"),!0)}if(!t.startsWith("tool:"))return!1;let o=t.slice(5),r=this.resolveCommandToolType(o);return r?(this.setActiveTool({type:r}),!0):!1});y(this,"isToolSupported",(t,o=this.props)=>{if(t==="magicframe"||o.UIOptions.tools?.[t]===!1)return!1;if(this.isInteractionEnabled(o))return!0;let r=typeof o.interaction=="object"&&o.interaction!==null?o.interaction.enabled?.tools:void 0;return t==="laser"?r?.laser===!0:t==="custom"?r?.custom===!0:!1});y(this,"updateEditorAtom",(t,...o)=>{let r=bt.set(t,...o);return this.triggerRender(),r});y(this,"previousHoveredBindableElement",null);y(this,"getEffectiveGridSize",()=>yr(this)?this.state.gridSize:null);y(this,"getTextCreationGridPoint",(t,o)=>{let r=this.getEffectiveGridSize();if(r===null)return null;let i=a=>Math.floor(a/r)*r;return{x:i(t),y:i(o)}});y(this,"handleIframeLikeElementHover",({hitElement:t,scenePointer:o,moveEvent:r})=>t&&Ic(t)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(t,r,o.x,o.y))?(this.cursor.set(Me.POINTER),this.setState({activeEmbeddable:{element:t,state:"hover"}}),!0):(this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}),!1));y(this,"isDoubleClick",(t,o)=>t!=null&&o.timeStamp-t.timeStamp<=vM);y(this,"updateEmbedValidationStatus",(t,o)=>{this.embedsValidationStatus.set(t.id,o),ki.delete(t)});y(this,"updateEmbeddables",()=>{let t=new Set,o=!1;this.scene.getNonDeletedElements().filter(r=>{if(Uo(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){o=!0;let i=Nb(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else _b(r)&&t.add(r.id);return!1}),o&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});y(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);y(this,"frameNameBoundsCache",{get:t=>{let o=this.frameNameBoundsCache._cache.get(t.id);if(!o||o.zoom!==this.state.zoom.value||o.viewpointFlip!==this.state.viewpointFlip||o.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Ce({clientX:i.x,clientY:i.y},this.state),s=Ce({clientX:i.right,clientY:i.bottom},this.state);return o={x:Math.min(a.x,s.x),y:Math.min(a.y,s.y),width:Math.abs(s.x-a.x),height:Math.abs(s.y-a.y),zoom:this.state.zoom.value,viewpointFlip:this.state.viewpointFlip,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,o),o}return null}return o},_cache:new Map});y(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});y(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===bc.DARK,o=this.scene.getNonDeletedFramesLikes(),r=o.length>0&&this.state.searchMatches?.focusedId&&St(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return o.map(i=>{if(!GM(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:a,y:s}=du({sceneX:i.x+(this.state.viewpointFlip.horizontal?i.width:0),sceneY:i.y+(this.state.viewpointFlip.vertical?i.height:0)},this.state),l=6,c,d=LK(i);if(i.id===this.state.editingFrame){let m=d;c=Pe("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===V.ESCAPE||p.key===V.ENTER)&&this.resetEditingFrame(i)},style:{background:XY(this.state.viewBackgroundColor,t),zIndex:2,border:"none",display:"block",padding:`${l}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Go.nameFontSize}px`,transform:`translate(-${l}px, ${l}px)`,color:t?Go.nameColorDarkTheme:Go.nameColorLightTheme,overflow:"hidden",maxWidth:`${document.body.clientWidth-a-l}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return Pe("div",{id:this.getFrameNameDOMId(i),className:Lb.FRAME_NAME,style:{position:"absolute",bottom:`${this.state.height+Go.nameOffsetY-s+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Go.nameFontSize,color:t?Go.nameColorDarkTheme:Go.nameColorLightTheme,lineHeight:Go.nameLineHeight,width:"max-content",maxWidth:r?.id===i.id&&r?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Me.MOVE,pointerEvents:this.state.viewModeEnabled?fs.disabled:fs.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});y(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});y(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());y(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());y(this,"getSceneElements",()=>this.scene.getNonDeletedElements());y(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});y(this,"onExportImage",async(t,o,r)=>{We("export",t,"ui");let i=await ei(t,o,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(VY).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Hc(i)&&this.setState({fileHandle:i})});y(this,"openEyeDropper",({type:t,swapPreviewOnAlt:o=!0})=>{this.updateEditorAtom(Ut,{swapPreviewOnAlt:o,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,i)=>{let a=t==="stroke"?!o||!i.altKey:o&&i.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?a?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:jt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:jt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?bo(l,{[a?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:jt.IMMEDIATELY})},keepOpenOnAlt:!1})});y(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});y(this,"syncActionResult",qe(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let o=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),o=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled??this.state.viewModeEnabled,a=t?.appState?.theme||this.props.theme||bc.LIGHT,s=t?.appState?.name??this.state.name,l=t?.appState?.errorMessage??this.state.errorMessage;if(typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),this.isInteractionEnabled()||(i=!0),r=t.appState?.editingTextElement||null,t.elements&&r){let c=r.id,d=t.elements.find(m=>m.id===c);r=d&&Eu(d)&&$t(d)?d:null}this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:!1,theme:a,name:s,errorMessage:l}}),o=!0}o||this.scene.triggerUpdate()}));y(this,"scheduleCapture",()=>this.store.scheduleCapture());y(this,"scheduleUpdate",()=>this.store.scheduleAction(jt.NEVER));y(this,"onBlur",qe(()=>{Wo=!1,this.resetSmartZoomKey(),this.setState({isBindingEnabled:this.state.bindingPreference==="enabled"})}));y(this,"onUnload",()=>{this.onBlur()});y(this,"disableEvent",t=>{t.preventDefault()});y(this,"preventBrowserZoomWheel",t=>{t[V.CTRL_OR_CMD]&&t.preventDefault()});y(this,"handleNavigationModeKeyDown",t=>{if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}this.actionManager.handleKeyDown(t)});y(this,"maybeHandlePageScrollKeyDown",t=>{if(t.key!==V.PAGE_UP&&t.key!==V.PAGE_DOWN)return!1;let o=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;return t.key===V.PAGE_DOWN&&(o=-o),t.shiftKey?this.viewport.translate(r=>({scrollX:r.scrollX+o})):this.viewport.translate(r=>({scrollY:r.scrollY+o})),!0});y(this,"preventBrowserZoomKeyDown",t=>{t[V.CTRL_OR_CMD]&&(t.code===Rr.EQUAL||t.code===Rr.MINUS||t.code===Rr.ZERO||t.code===Rr.NUM_ADD||t.code===Rr.NUM_SUBTRACT||t.code===Rr.NUM_ZERO)&&t.preventDefault()});y(this,"terminateActiveInteraction",()=>{if(this.maybeCleanupAfterMissingPointerUp(null),Wo=!1,bu=!1,this.resetSmartZoomKey(),Vo=!1,xu=!1,xs=null,ue.pointers.clear(),ue.lastCenter=null,ue.initialDistance=null,ue.initialScale=null,clearTimeout(Cc),Cc=0,e.resetTapTwice(),this.resetContextMenuTimer(),clearTimeout(wu),wu=0,yu=!1,this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.flowchart.clear(),bt.set(Ut,null),bt.set(po,null),this.state.editingFrame){let t=this.scene.getNonDeletedElement(this.state.editingFrame);this.resetEditingFrame(t&&St(t)?t:null)}queueMicrotask(()=>{(!this.isInteractionEnabled()||this.state.viewModeEnabled)&&this.textWysiwygSubmitHandler?.()}),this.setState({contextMenu:null,openMenu:null,openPopup:null,cursorButton:"up",bindMode:"orbit",activeEmbeddable:null,activeLockedId:null,selectedElementsAreBeingDragged:!1,selectionElement:null,resizingElement:null,isResizing:!1,isRotating:!1,isCropping:!1,croppingElementId:null,suggestedBinding:null,frameToHighlight:null,elementsToHighlight:null,snapLines:[],showHyperlinkPopup:!1}),this.deselectElements(),this.isInteractionEnabled()||(this.setState({originSnapOffset:null}),this.cursor.reset())});y(this,"handleInteractionStateChange",(t,o)=>{let r=this.isInteractionEnabled(t),i=r!==this.isInteractionEnabled(),a=t.viewModeEnabled!==this.props.viewModeEnabled,s=this.state.viewModeEnabled;this.isInteractionEnabled()?(a||i)&&(s=!!this.props.viewModeEnabled):s=!0,s!==this.state.viewModeEnabled&&this.setState({viewModeEnabled:s});let l=r&&!o.viewModeEnabled,c=this.isInteractionEnabled()&&!this.state.viewModeEnabled;(i&&!this.isInteractionEnabled()||l&&!c)&&this.terminateActiveInteraction(),i&&this.addEventListeners(),this.isLinksEnabled(t)!==this.isLinksEnabled()&&(this.isLinksEnabled()||(this.hitLinkElement=void 0,ym(),this.cursor.reset())),this.isEmbedsEnabled(t)!==this.isEmbedsEnabled()&&(this.isEmbedsEnabled()||this.setState({activeEmbeddable:null})),this.isToolSupported(o.activeTool.type,t)!==this.isToolSupported(this.state.activeTool.type)&&(this.isToolSupported(this.state.activeTool.type)||this.laserTrails.endPath(),this.cursor.reset()),!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)&&this.state.activeTool.type!=="selection"&&this.setState({activeTool:on(this.state,{type:"selection"})}),(this.isBrowserZoomEnabled(t)!==this.isBrowserZoomEnabled()||this.isNavigationEnabled(t)!==this.isNavigationEnabled())&&(this.addEventListeners(),this.cursor.reset()),o.viewModeEnabled!==this.state.viewModeEnabled&&(this.isInteractionEnabled()&&this.addEventListeners(),this.state.viewModeEnabled||this.deselectElements(),this.cursor.reset())});y(this,"isSameForcedTool",(t,o)=>t?.type===o?.type&&(t?.type==="custom"?t.customType??null:null)===(o?.type==="custom"?o.customType??null:null));y(this,"handleForcedToolChange",(t,o)=>{let r=this.props.activeTool;if(!r)return;let i=!this.isSameForcedTool(t.activeTool,r);if(r.type==="image"){i&&console.warn('"image" tool cannot be forced via "props.activeTool"');return}this.isSameForcedTool(r,this.state.activeTool)||(i||o.activeTool!==this.state.activeTool||this.isToolSupported(r.type,t)!==this.isToolSupported(r.type,this.props))&&this.setActiveTool(r)});y(this,"resetHistory",()=>{this.history.clear()});y(this,"resetStore",()=>{this.store.clear()});y(this,"resetScene",qe(t=>{this.scene.replaceAllElements([]),this.setState(o=>({...Zo(),isLoading:t?.resetLoadingState?!1:o.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));y(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async l=>{if(!l.files.length)return;let c=l.files[0],d=await c.getFile();this.loadFileToCanvas(new File([d],d.name||"",{type:d.type}),c)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null}catch(l){console.error(l),t={appState:{errorMessage:l.message||"Encountered an error during importing or restoring scene data"}}}let o=Hr(t?.elements,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=Bi(t?.appState,null),i=r.activeTool;r.preferredSelectionTool.initialized||(r.preferredSelectionTool={type:this.editorInterface.formFactor==="phone"?"lasso":"selection",initialized:!0}),r={...r,theme:this.props.theme||r.theme,viewModeOnly:this.props.viewModeOnly||r.viewModeOnly,viewModeEnabled:this.props.viewModeOnly||this.props.viewModeEnabled||r.viewModeEnabled,openSidebar:r?.openSidebar||this.state.openSidebar,activeTool:i.type==="image"||i.type==="lasso"||i.type==="selection"?{...i,type:r.preferredSelectionTool.type}:r.activeTool,isLoading:!1,toast:this.state.toast};let a={...r,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft},s=this.props.initialState?.viewport;if(s){let l=o.filter(m=>!m.isDeleted),c=wc(l),d=this.viewport.resolveInitialViewport(s,c,a);d&&(r={...r,...d})}else t?.scrollToContent&&(r={...r,..._i(o,a)});this.resetStore(),this.resetHistory(),this.syncActionResult({elements:o,appState:r,files:t?.files,captureUpdate:jt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(l=>{this.fonts.onLoaded(l)}),jM(window.location.href)&&this.viewport.setViewport({target:window.location.href,fit:"scale-down",animation:!1})});y(this,"getFormFactor",(t,o)=>this.props.UIOptions.getFormFactor?.(t,o)??JY(t,o));y(this,"refreshEditorInterface",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:o,height:r}=t.getBoundingClientRect(),i=nK(),a=bA(typeof navigator<"u"?navigator.userAgent:""),s=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:kY,l=Db(this.editorInterface,{desktopUIMode:i??this.editorInterface.desktopUIMode,formFactor:this.getFormFactor(o,r),userAgent:a,canFitSidebar:o>s,isLandscape:o>r});this.editorInterface=l,this.reconcileStylesPanelMode(l)});y(this,"reconcileStylesPanelMode",t=>{let o=vu(t);if(o===this.stylesPanelMode)return;let r=this.stylesPanelMode;this.stylesPanelMode=o,this.viewport.invalidateUIOffset("stylesPanel"),r!=="full"&&o==="full"&&this.setState(i=>({preferredSelectionTool:{type:"selection",initialized:!0}}))});y(this,"setDesktopUIMode",t=>{let o=oK(t);!o||o===this.editorInterface.desktopUIMode||(this.editorInterface=Db(this.editorInterface,{desktopUIMode:o}),this.reconcileStylesPanelMode(this.editorInterface),this.forceUpdate())});y(this,"onResize",qe(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>ki.delete(t)),this.refreshEditorInterface(),this.updateDOMRect(),this.setState({})}));y(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});y(this,"renderInteractiveSceneCallback",({scrollBars:t})=>{t&&(kc=t),this.scheduleImageRefresh()});y(this,"onScroll",SM(()=>{let{offsetTop:t,offsetLeft:o}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===o&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:o})},MY));y(this,"onCut",qe(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||xc(t.target)||(this.actionManager.executeAction(Em,"keyboard",t),t.preventDefault(),t.stopPropagation())}));y(this,"onCopy",qe(t=>{!this.isInteractionEnabled()||!this.excalidrawContainerRef.current?.contains(document.activeElement)||xc(t.target)||(this.actionManager.executeAction(Ea,"keyboard",t),t.preventDefault(),t.stopPropagation())}));y(this,"onTouchStart",t=>{if(this.isInteractionEnabled()){if(QY&&t.preventDefault(),!Sc){Sc=!0,t.touches.length===1&&(Pc={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Cc),Cc=window.setTimeout(e.resetTapTwice,vM);return}if(Sc&&t.touches.length===1&&Pc){let o=t.touches[0];go(oe(o.clientX,o.clientY),oe(Pc.x,Pc.y))<=MM&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:o.clientX,clientY:o.clientY,type:"touch",altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1})),Sc=!1,clearTimeout(Cc)}t.touches.length===2&&this.setState({selectedElementIds:Le({},this.state),activeEmbeddable:null})}});y(this,"onTouchEnd",t=>{this.isInteractionEnabled()&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Le(this.state.previousSelectedElementIds,this.state)}):ue.pointers.clear())});y(this,"pasteFromClipboard",qe(async t=>{if(!this.isInteractionEnabled())return;let o=!!yu,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.viewport.lastPosition.x,this.viewport.lastPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||xc(r)))return;let s=await ur(t),l=s.getFiles(),c=await ml(s,o);if(!c.elements&&l.length>0&&!o)try{let m=(await rm())[In.excalidrawClipboard];typeof m=="string"&&(s=await ur(nm({types:{[In.excalidrawClipboard]:m}})),l=s.getFiles(),c=await ml(s,o))}catch(d){console.warn(`Could not read editable image clipboard data: ${d.message}`)}if(this.state.viewModeEnabled){if(!this.containsImagePaste(c,l,o))return;if(!this.shouldInsertImageInViewMode({source:"paste",files:l.map(d=>d.file),data:c,event:t})){t?.preventDefault();return}}if(this.props.onPaste)try{if(await this.props.onPaste(c,t)===!1)return}catch(d){console.error(d)}await this.insertClipboardContent(c,l,o),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t?.preventDefault()}));y(this,"addElementsFromPasteOrLibrary",t=>{let o=Hr(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,s]=bs(o),l=Es(r,a)/2,c=Es(i,s)/2,d=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.viewport.lastPosition.x:this.state.width/2+this.state.offsetLeft,m=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.viewport.lastPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Ce({clientX:d,clientY:m},this.state),E=p-l,g=u-c,[b,v]=kt(E,g,this.getEffectiveGridSize()),{duplicatedElements:w}=BM({type:"everything",elements:o.map(M=>bo(M,{x:M.x+b-r,y:M.y+v-i})),randomizeSeed:!t.retainSeed,preserveFrameChildrenOrder:t.preserveFrameChildrenOrder}),x=this.scene.getElementsIncludingDeleted(),I=[...x,...w];I=this.props.onDuplicate?.(I,x)||I,eA(I,wc(w));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let M=_K(w,C);I=Gb(I,M,C)}this.scene.replaceAllElements(I),w.forEach(M=>{if($t(M)&&OM(M)){let D=VM(M,this.scene.getElementsMapIncludingDeleted());SK(M,D,this.scene)}}),tK&&Io.loadElementsFonts(w).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let P=$K(w);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.editorInterface.canFitSidebar&&bt.get(bb)?this.state.openSidebar:null,...tA(P,this.scene.getNonDeletedElements(),this.state)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.state.preferredSelectionTool.type},{keepSelection:!0}),t.fit&&this.viewport.setViewport({target:w,fit:t.fit,animation:!1,offsets:{ui:!0}})});y(this,"addElementsFromPaste",t=>{this.addElementsFromPasteOrLibrary({...t,fit:t.fitToContent?"contain":void 0})});y(this,"setAppState",(t,o)=>{let r=a=>!a||!this.state.viewModeOnly?a:{...a,viewModeOnly:!0,viewModeEnabled:!0},i=typeof t=="function"?(a,s)=>r(t(a,s)):r(t);this.setState(i,o)});y(this,"removePointer",t=>{Fr&&this.resetContextMenuTimer(),t.type==="pointercancel"&&this.bucketFill.cancel();let o=ue.pointers.size>=2;ue.pointers.delete(t.pointerId),o&&ue.pointers.size<2&&this.state.scrollConstraints&&this.viewport.releaseOverscroll()});y(this,"toggleLock",(t="ui")=>{this.props.activeTool||(this.state.activeTool.locked||We("toolbar","toggleLock",`${t} (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),this.setState(o=>({activeTool:{...o.activeTool,...on(this.state,o.activeTool.locked?{type:this.state.preferredSelectionTool.type}:o.activeTool),locked:!o.activeTool.locked}})))});y(this,"updateFrameRendering",t=>{this.setState(o=>{let r=typeof t=="function"?t(o.frameRendering):t;return{frameRendering:{enabled:r?.enabled??o.frameRendering.enabled,clip:r?.clip??o.frameRendering.clip,name:r?.name??o.frameRendering.name,outline:r?.outline??o.frameRendering.outline}}})});y(this,"togglePenMode",t=>{this.setState(o=>({penMode:t??!o.penMode,penDetected:!0,currentItemStrokeVariability:o.penDetected?o.currentItemStrokeVariability:"variable"}))});y(this,"revealIfHidden",t=>{!t.length||yK(t,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.viewport.getOffsets())||this.viewport.setViewport({target:bs(t),fit:"scale-down",animation:{duration:300},offsets:{ui:!0}})});y(this,"scrollToViewport",(t,o)=>{this.setState({scrollX:t.scrollX,scrollY:t.scrollY,zoom:{value:jn(t.zoom)},shouldCacheIgnoreZoom:!1})});y(this,"scrollToContent",(t,o)=>{this.viewport.setViewport({target:t??this.scene.getNonDeletedElements(),fit:o?.fitToViewport?"contain":"scale-down",animation:o?.animate?{duration:o.duration??500}:!1,offsets:{ui:!0}})});y(this,"emitUserFollowIntent",t=>{this.onUserFollowEmitter.trigger(t),this.props.onUserFollow?.(t)});y(this,"requestUnfollow",()=>{this.props.userToFollow&&this.emitUserFollowIntent({userToFollow:this.props.userToFollow,action:"UNFOLLOW"})});y(this,"setToast",t=>{this.setState({toast:t})});y(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),o=await t.match("shared-file");if(o){let r=await o.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,wY,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});y(this,"addFiles",qe(t=>{let o=new Map;for(let s of t){let l=s.id,c=this.imageCache.get(l);c&&!this.files[l]&&o.set(l,Promise.resolve(c.image))}let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate();let i=new Set(o.keys());Bb({imageCache:this.imageCache,fileIds:Array.from(i),files:this.files,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes}).then(async({updatedFiles:s})=>{for(let[l,c]of o){let d=this.imageCache.get(l);!d||!s.has(l)||(this.imageCache.set(l,{...d,placeholderImage:await c,transitionStart:performance.now()}),this.clearImageLoadingProgress(l))}i.size&&this.imagePlaceholderUpdateEmitter.trigger()}),i.size||this.addNewImagesToImageCache()}));y(this,"addImageElementsToScene",async(t,o,r)=>{let i=await Promise.all(t.map(async({file:s,customData:l})=>({file:await Ur(s),customData:l??{}}))),a=i.find(({file:s})=>!Fi(s));if(a)throw new _u(a.file,f("errors.unsupportedFileType"));await this.insertImages(i.map(({file:s})=>s),o,r,i.map(({customData:s})=>s))});y(this,"addImagePlaceholder",async(t,o)=>{if(this.files[t])return;let r=await Ur(o);if(!Fi(r))throw new Error(f("errors.unsupportedFileType"));let i=new Image,a=new Promise((l,c)=>{i.onload=()=>l(i),i.onerror=()=>c(new Error(f("errors.imageInsertError")))}),s={image:a,mimeType:r.type,isPlaceholder:!0,gifDecodeStatus:r.type===In.gif?"pending":void 0};this.imageCache.set(t,s),s.gifDecodeStatus==="pending"&&this.imagePlaceholderUpdateEmitter.trigger(),i.src=await Uc(r);try{let l=await a;if(this.imageCache.get(t)!==s||this.files[t])return;this.imageCache.set(t,{...s,image:l}),this.clearImageShapeCacheForFileId(t),this.imagePlaceholderUpdateEmitter.trigger()}catch(l){throw this.imageCache.get(t)===s&&(this.imageCache.delete(t),this.imagePlaceholderUpdateEmitter.trigger()),l}});y(this,"setDownloadProgress",(t,o)=>{if(o===null){this.clearImageLoadingProgress(t);return}if(!Number.isFinite(o))return;let r=fc(o,0,1);this.imageLoadingProgress.get(t)!==r&&(this.imageLoadingProgress.set(t,r),this.imageLoadingProgressEmitter.trigger())});y(this,"setDownloadError",(t,o)=>{this.updateImageStatus(t,r=>({...r,downloadError:o===!0?{}:o||null}))});y(this,"setUploadProgress",(t,o,r)=>{if(o===null){this.updateImageStatus(t,i=>({...i,uploadProgress:null}));return}typeof o=="number"&&!Number.isFinite(o)||this.updateImageStatus(t,i=>{let a=i?.uploadProgress??void 0,s=r===void 0?a:r??void 0,l=typeof o=="number";return{...i,uploadProgress:{...s,state:l?"uploading":o,...l?{progress:fc(o,0,1)}:{progress:void 0}}}})});y(this,"updateImageStatus",(t,o)=>{let r=this.imageStatus.get(t),i=o(r);this.areImageStatusesEqual(r,i)||(i.downloadError===void 0&&!i.uploadProgress?this.imageStatus.delete(t):this.imageStatus.set(t,i),this.imageStatusEmitter.trigger())});y(this,"areImageStatusesEqual",(t,o)=>!!t?.downloadError==!!o?.downloadError&&!!t?.uploadProgress==!!o?.uploadProgress&&t?.downloadError?.backgroundColor===o?.downloadError?.backgroundColor&&t?.downloadError?.color===o?.downloadError?.color&&t?.downloadError?.trackColor===o?.downloadError?.trackColor&&t?.downloadError?.text===o?.downloadError?.text&&t?.downloadError?.onClick===o?.downloadError?.onClick&&t?.uploadProgress?.backgroundColor===o?.uploadProgress?.backgroundColor&&t?.uploadProgress?.color===o?.uploadProgress?.color&&t?.uploadProgress?.trackColor===o?.uploadProgress?.trackColor&&t?.uploadProgress?.state===o?.uploadProgress?.state&&t?.uploadProgress?.text===o?.uploadProgress?.text&&t?.uploadProgress?.onClick===o?.uploadProgress?.onClick&&t?.uploadProgress?.progress===o?.uploadProgress?.progress);y(this,"clearImageLoadingProgress",t=>{this.imageLoadingProgress.delete(t)&&this.imageLoadingProgressEmitter.trigger()});y(this,"clearImageShapeCacheForFileId",t=>{for(let o of this.scene.getNonDeletedElements())Pi(o)&&o.fileId===t&&ki.delete(o)});y(this,"addMissingFiles",(t,o=!1)=>{let r=o?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let s of a)if(!r[s.id]&&(i[s.id]=s,r[s.id]=s,s.mimeType===In.svg))try{let l=Mx(WM(Dx(s.dataURL)),In.svg);s.dataURL!==l&&(s.version=(s.version??1)+1,s.dataURL=l)}catch(l){console.error(l)}return this.files=r,{addedFiles:i}});y(this,"updateScene",qe(t=>{let{elements:o,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let s=o||void 0,l=r?iK({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:l})}r&&this.setState(r),o&&this.scene.replaceAllElements(o),i&&(this.laserTrails.updateCollabTrails(i),this.setState({collaborators:i}))}));y(this,"applyDeltas",(t,o)=>{let r=sA.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return sA.applyTo(r,a,i,o)});y(this,"mutateElement",(t,o,r=!0)=>this.scene.mutateElement(t,o,{informMutation:r,isDragging:!1}));y(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});y(this,"toggleSidebar",({name:t,tab:o,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===o?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&o&&(a.tab=o),this.setState({openSidebar:a}),!!i});y(this,"updateCurrentCursorPosition",qe(t=>{this.viewport.lastPosition.x=t.clientX,this.viewport.lastPosition.y=t.clientY}));y(this,"isPlainSmartZoomKey",t=>!t[V.CTRL_OR_CMD]&&!t.shiftKey&&!t.altKey&&t.key.toLocaleLowerCase()===V.F);y(this,"updateSmartZoomCursor",t=>{if(this.smartZoomKeyDownAt===null)return;let o=t?this.getElementAtPosition(t.x,t.y,{includeLockedElements:!0}):null;this.cursor.set(o?Me.POINTER:"zoom-in")});y(this,"resetSmartZoomKey",()=>{let t=this.smartZoomKeyDownAt!==null;this.smartZoomKeyDownAt=null,this.smartZoomKeyHitElement=!1,t&&(this.cursor.reset(),this.updateEditorAtom(xa,!1))});y(this,"handleSmartZoomKeyDown",t=>this.isPlainSmartZoomKey(t)?(!t.repeat&&this.smartZoomKeyDownAt===null&&(this.smartZoomKeyDownAt=Date.now(),this.smartZoomKeyHitElement=!1,this.updateEditorAtom(xa,!0),this.updateSmartZoomCursor(this.lastPointerMoveCoords)),t.preventDefault(),t.stopPropagation(),!0):!1);y(this,"handleSmartZoomKeyUp",t=>{if(t.key.toLocaleLowerCase()!==V.F||this.smartZoomKeyDownAt===null)return!1;let o=Date.now()-this.smartZoomKeyDownAt,r=!this.smartZoomKeyHitElement&&o<=gX;return this.resetSmartZoomKey(),t.stopPropagation(),r&&this.actionManager.executeAction(Rn,"keyboard",this.scene.getNonDeletedElements()),!0});y(this,"handleSmartZoomPointerDown",(t,o)=>{if(t.button!==Tn.MAIN||this.smartZoomKeyDownAt===null)return!1;let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});return r?(this.smartZoomKeyHitElement=!0,t.preventDefault(),t.stopPropagation(),this.actionManager.executeAction(Rn,"keyboard",[r]),!0):!1});y(this,"onKeyDown",qe(t=>{if(!this.isInteractionEnabled())return;if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(l,c){let d=l[c];return typeof d=="function"?d.bind(l):c==="key"?t.shiftKey?l.key.toUpperCase():l.key.toLowerCase():d}})),!CM(t.target)){if((t.key===V.ESCAPE||t.key===V.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let l=de(this.scene.getNonDeletedElementsMap(),this.state);if(l.length===1&&Xn(l[0])&&t.key===V.ENTER){this.startImageCropping(l[0]);return}if(l.length===0&&(t.key===V.ARROW_LEFT||t.key===V.ARROW_RIGHT)&&!t[V.CTRL_OR_CMD]&&!t.shiftKey&&!t.altKey){let c=this.scene.getNonDeletedElementsMap(),d=hv(this.scene.getNonDeletedElements(),c,this.lastKeyboardSmartZoomImageId,t.key===V.ARROW_RIGHT?"next":"previous");if(d){this.lastKeyboardSmartZoomImageId=d.id,this.actionManager.executeAction(Rn,"keyboard",[d]),t.preventDefault(),t.stopPropagation();return}}if(t.key===V.ESCAPE)this.updateEditorAtom(po,null);else if(t.key===V.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(Lb.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let c=sp(l);bt.get(po)?.type==="panel"&&lE(this,{conversionType:c,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),c&&this.updateEditorAtom(po,{type:"panel"})}if(this.flowchart.handleKeyEvent(t))return}if(t[V.CTRL_OR_CMD]&&t.key.toLowerCase()===V.V&&(yu=t.shiftKey,clearTimeout(wu),wu=window.setTimeout(()=>{yu=!1},100)),t[V.CTRL_OR_CMD]&&xc(t.target)&&(t.code===Rr.MINUS||t.code===Rr.EQUAL)){t.preventDefault();return}if(xc(t.target)&&t.key!==V.ESCAPE||Pb(t.key)&&CM(t.target))return;if(t.key===V.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===V.E&&t.shiftKey&&t[V.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(this.maybeHandlePageScrollKeyDown(t)){t.preventDefault();return}if(this.state.openDialog?.name==="elementLinkSelector")return;if(t.key===V.ALT)if(this.state.activeTool.type==="bucketfill"){this.bucketFill.openTemporaryEyeDropper(),t.preventDefault();return}else Ho("COMPLEX_BINDINGS")?this.handleSkipBindMode():fu({app:this,event:t});if(this.handleSmartZoomKeyDown(t)||this.actionManager.handleKeyDown(t))return;let o=this.props.viewModeEnabled===!0;if(!o&&this.state.viewModeEnabled&&t.key===V.ESCAPE){this.setActiveTool({type:"selection"});return}if(!o&&!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let l=nw(t.key,this,t.shiftKey);if(this.state.viewModeEnabled&&!AM(l,["laser","hand"]))return;if(l){if(this.state.activeTool.type!==l&&We("toolbar",l,`keyboard (${this.editorInterface.formFactor==="phone"?"mobile":"desktop"})`),l==="arrow"&&this.state.activeTool.type==="arrow"){let c=this.state.currentItemArrowType===Nr.sharp?Nr.round:this.state.currentItemArrowType===Nr.round?Nr.elbow:Nr.sharp;this.setState({currentItemArrowType:c}),this.cursorHints.onArrowTypeCycled(c)}else(l==="arrow"||l==="line")&&this.cursorHints.onToolShortcut(l,/^\d$/.test(t.key)?"digit":"letter");l==="bucketfill"&&this.state.activeTool.type==="bucketfill"?this.bucketFill.cycleBackgroundColor():l==="lasso"&&this.state.activeTool.type==="laser"?this.setActiveTool({type:this.state.preferredSelectionTool.type}):this.setActiveTool({type:l},{toggle:!0}),t.stopPropagation();return}else if(t.key===V.Q){this.toggleLock("keyboard"),t.stopPropagation();return}}if(this.state.viewModeEnabled)return;if(t[V.CTRL_OR_CMD]&&!t.repeat&&(Ho("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.arrowText.refresh(),fu({app:this,event:t})),Pb(t.key)){let l=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),c=new Set;l.filter(u=>xo(u)).filter(u=>{let E=u.startBinding&&!l.some(b=>b.id===u.startBinding?.elementId),g=u.endBinding&&!l.some(b=>b.id===u.endBinding?.elementId);return E||g}).forEach(u=>c.add(u.id)),l=l.filter(u=>!c.has(u.id));let d=this.getEffectiveGridSize()&&(t.shiftKey?wM:this.getEffectiveGridSize())||(t.shiftKey?SY:wM),m=0,p=0;t.key===V.ARROW_LEFT?m=-d:t.key===V.ARROW_RIGHT?m=d:t.key===V.ARROW_UP?p=-d:t.key===V.ARROW_DOWN&&(p=d),m*=Kn(this.state.viewpointFlip.horizontal),p*=Kn(this.state.viewpointFlip.vertical),l.forEach(u=>{this.scene.mutateElement(u,{x:u.x+m,y:u.y+p},{informMutation:!1,isDragging:!1}),uu(u,this.scene,{simultaneouslyUpdated:l})}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===V.ENTER){let l=this.scene.getSelectedElements(this.state);if(l.length===1){let c=l[0];if(t[V.CTRL_OR_CMD]||Wb(c))Ht(c)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==c.id)&&(this.store.scheduleCapture(),Zt(c)||this.actionManager.executeAction(Ma));else if($t(c)||YM(c)){let d;$t(c)||(d=c);let m=Ob(c,this.scene.getNonDeletedElementsMap()),p=m.x,u=m.y;this.startTextEditing({sceneX:p,sceneY:u,container:d}),t.preventDefault();return}else St(c)&&this.setState({editingFrame:c.id})}}if(t.key===V.SPACE&&ue.pointers.size===0&&(Wo=!0,this.cursor.set(Me.GRAB),t.preventDefault()),t.key.toLowerCase()===V.Z&&!t[V.CTRL_OR_CMD]&&!t.altKey&&!t.shiftKey&&(bu=!0,this.cursor.set("zoom-in"),t.preventDefault()),(t.key===V.G||t.key===V.S)&&!t.altKey&&!t[V.CTRL_OR_CMD]){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;t.key===V.G&&(Xo(this.state.activeTool.type)||l.some(c=>Xo(c.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===V.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[V.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===V.F){let l=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!l.length)return;(this.state.activeTool.type==="text"||l.find(c=>$t(c)||Fb(c,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}let r=t.key.toLocaleLowerCase(),i=r===V.I&&!t.shiftKey&&!t[V.CTRL_OR_CMD],a=r===V.S&&t.shiftKey&&!t[V.CTRL_OR_CMD]||i,s=r===V.I&&t.shiftKey&&!t[V.CTRL_OR_CMD];(a||s)&&this.openEyeDropper({type:a?"stroke":"background",swapPreviewOnAlt:!i})}));y(this,"onKeyUp",qe(t=>{if(this.isInteractionEnabled()&&!this.handleSmartZoomKeyUp(t)){if(t.key===V.SPACE&&(this.state.viewModeEnabled&&this.state.activeTool.type!=="laser"||this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.GRAB):mu(this.state.activeTool.type)?this.cursor.reset():(this.cursor.applyForTool(),this.setState({selectedElementIds:Le({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Wo=!1),t.key.toLowerCase()===V.Z&&(bu=!1,this.cursor.reset()),t.key===V.ALT&&(this.bucketFill.closeTemporaryEyeDropper(),fu({app:this,event:t})),(t.key===V.ALT&&this.state.bindMode==="skip"||!t[V.CTRL_OR_CMD]&&!pu(this.state))&&(this.setState({bindMode:"orbit"}),this.lastPointerMoveEvent&&Ho("COMPLEX_BINDINGS"))){let o=Ce({clientX:this.lastPointerMoveEvent.clientX,clientY:this.lastPointerMoveEvent.clientY},this.state),r=Br(oe(o.x,o.y),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(this.state.selectedLinearElement){let i=Ee.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());xo(i)&&this.handleDelayedBindModeChange(i,r)}}if(!t[V.CTRL_OR_CMD]){let o=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==o&&(Gt(()=>{this.setState({isBindingEnabled:o})}),this.arrowText.refresh()),fu({app:this,event:t})}if(Pb(t.key)){LM(this.scene.getSelectedElements(this.state).filter(vc),this.scene,this.state);let o=this.scene.getNonDeletedElementsMap();this.scene.getSelectedElements(this.state).filter(Vb).forEach(r=>{r.startBinding&&this.scene.mutateElement(r,{startBinding:{...r.startBinding,...cA(r,o.get(r.startBinding.elementId),"start",o)}}),r.endBinding&&this.scene.mutateElement(r,{endBinding:{...r.endBinding,...cA(r,o.get(r.endBinding.elementId),"end",o)}})}),this.setState({suggestedBinding:null})}this.flowchart.handleKeyEvent(t)}}));y(this,"setActiveTool",(t,o={})=>{let{keepSelection:r=!1}=o;if(!this.isToolSupported(t.type)){console.warn(this.isInteractionEnabled()?`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`:`"${t.type}" tool cannot be activated while the editor is non-interactive (see "interaction.enabled.tools")`);return}if(this.props.activeTool&&!this.isSameForcedTool(this.props.activeTool,t)){console.warn(`"${t.type}" tool activation ignored \u2014 the active tool is controlled by the host via "props.activeTool"`);return}this.drawShape.hasPendingGesture()&&this.actionManager.executeAction(gt);let i=ca.includes(t.type),s=o.toggle===!0&&i&&this.state.activeTool.type===t.type?on(this.state,{...this.state.activeTool.lastActiveTool||{type:this.state.preferredSelectionTool.type},lastActiveTool:null}):i&&this.state.activeTool.type!==t.type?on(this.state,{...t,lastActiveTool:this.state.activeTool}):on(this.state,t);s.type==="hand"?this.cursor.set(Me.GRAB):Wo||this.cursor.applyForTool(s),HY(document.activeElement)&&this.focusContainer(),EK(s.type)||this.setState({suggestedBinding:null}),s.type==="image"&&this.onImageToolbarButtonClick(),this.setState(l=>{let c={snapLines:l.snapLines.length?[]:l.snapLines,originSnapOffset:null,activeEmbeddable:null,selectedLinearElement:mu(s.type)?l.selectedLinearElement:null,frameToHighlight:null,hoveredArrowTextAnchor:null};return s.type==="freedraw"&&this.store.scheduleCapture(),s.type==="lasso"?{...l,...c,activeTool:s,...r?{}:{selectedElementIds:Le({},l),selectedGroupIds:Le({},l),editingGroupId:null,multiElement:null}}:s.type!=="selection"?{...l,...c,activeTool:s,selectedElementIds:Le({},l),selectedGroupIds:Le({},l),editingGroupId:null,multiElement:null}:{...l,...c,activeTool:s}})});y(this,"setOpenDialog",t=>{this.setState({openDialog:t})});y(this,"isTouchScreenMultiTouchGesture",()=>ue.pointers.size>=2);y(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${PM()}`);y(this,"onGestureStart",qe(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Le({},this.state),activeEmbeddable:null}),ue.initialScale=this.state.zoom.value)}));y(this,"onGestureChange",qe(t=>{if(!this.isNavigationEnabled()||(t.preventDefault(),this.isTouchScreenMultiTouchGesture()))return;let o=ue.initialScale;o&&this.viewport.translate(r=>({...vo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:jn(o*t.scale)},r)}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})}));y(this,"onGestureEnd",qe(t=>{this.isNavigationEnabled()&&(t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Le(this.state.previousSelectedElementIds,this.state)}),ue.initialScale=null)}));y(this,"isHittingTextAutoResizeHandle",(t,o)=>{let r=uA(t,this.state);return!!(r&&!r.isDeleted&&!r.autoResize&&iI(o,r,this.state.zoom.value,this.editorInterface.formFactor))});y(this,"handleTextAutoResizeHandlePointerDown",(t,o)=>{let r=uA(t,this.state);return!r||!this.isHittingTextAutoResizeHandle(t,o)?!1:(this.actionManager.executeAction(hf,"ui",r),this.cursor.reset(),!0)});y(this,"startTextEditing",({sceneX:t,sceneY:o,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0,initialCaretSceneCoords:s,arrowEndpoint:l})=>{let c=!1,d=l&&this.arrowText.getTextBinding(l,this.getCurrentItemStrokeWidth("text"));d&&(i=null,r=!1,t=d.anchor[0],o=d.anchor[1]);let m=r&&this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i);i&&m&&(Fb(i,this.scene.getNonDeletedElementsMap())||(c=!0));let p=d?null:this.getSelectedTextElement(i)||this.getTextElementAtPosition(t,o),u=p?.fontFamily||this.state.currentItemFontFamily,E=p?.lineHeight||TM(u),g=this.state.currentItemFontSize;if(!p&&c&&i&&!vc(i)){let C=HK(Mb({fontSize:g,fontFamily:u}),E),P=UK(g,E),M=Math.max(i.height,P),D=Math.max(i.width,C);this.scene.mutateElement(i,{height:M,width:D}),t=i.x+D/2,o=i.y+M/2,m&&(m=this.getTextWysiwygSnappedToCenterPosition(t,o,this.state,i))}let b=this.getTextCreationGridPoint(t,o),v=d?{x:t,y:o}:m?{x:m.elementCenterX,y:m.elementCenterY}:p?{x:t,y:o}:{x:b?.x??t,y:b===null?o-JM(g,E)/2:b.y},w=this.getTopLayerFrameAtSceneCoords({x:v.x,y:v.y}),x=w&&(!c||!i||i.frameId===w.id)?w.id:null,I=p||RM({x:v.x,y:v.y,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:g,fontFamily:u,textAlign:d?.textAlign??(m?"center":this.state.currentItemTextAlign),verticalAlign:d?.verticalAlign??(m?LY.MIDDLE:xM),containerId:c?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:E,angle:i?vc(i)?0:i.angle:0,frameId:x});if(!p&&c&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:I.id})}),this.setState({editingTextElement:I}),!p)if(i&&c){let T=this.scene.getElementIndex(i.id);this.scene.insertElementsAtIndex([I],T+1)}else this.insertNewElement(I);l&&d&&this.arrowText.bindText(l,I,d.fixedPoint),a||p||i?this.handleTextWysiwyg(I,{isExistingElement:!!p,initialCaretSceneCoords:p?s:null}):this.setState({newElement:I,multiElement:null})});y(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});y(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});y(this,"shouldHandleBrowserCanvasDoubleClick",t=>{if(t==="touch"||this.lastCompletedCanvasClicks.length===0)return!0;if(this.lastCompletedCanvasClicks.length<2)return!1;let[o,r]=this.lastCompletedCanvasClicks;return go(oe(o.x,o.y),oe(r.x,r.y))<=MM});y(this,"handleCanvasDoubleClick",t=>{if(!this.isInteractionEnabled()||this.state.editingTextElement||!this.state.viewModeEnabled&&!this.shouldHandleBrowserCanvasDoubleClick(t.type)||this.state.multiElement)return;if(this.state.viewModeEnabled){let{x:l,y:c}=Ce(t,this.state),d=this.getElementAtPosition(l,c,{includeLockedElements:!0});d&&(this.cursor.reset(),this.actionManager.executeAction(Rn,"ui",[d]));return}if(this.state.activeTool.type!==this.state.preferredSelectionTool.type&&this.state.activeTool.type!=="autoshape")return;let o=this.scene.getSelectedElements(this.state),{x:r,y:i}=Ce(t,this.state);if(o.length===1&&Ht(o[0])){let l=o[0];if((t[V.CTRL_OR_CMD]&&Vb(l)||Wb(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(Ma);return}else if(this.state.selectedLinearElement&&Zt(o[0])){let c=Ee.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=c?Ee.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):-1;if(d&&d>-1){this.store.scheduleCapture(),Ee.deleteFixedSegment(o[0],this.scene,d);let m=Ee.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),p=m?Ee.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:c,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&Wb(l))return}let a=this.getElementAtPosition(r,i,{includeLockedElements:!0});if(a&&Xn(a)){this.actionManager.executeAction(Rn,"ui",[a]);return}if(this.cursor.reset(),XK(this.state).length>0){let l=this.getElementAtPosition(r,i),c=l&&KK(l,this.state.selectedGroupIds);if(c){this.store.scheduleCapture(),this.setState(d=>({...d,...Zn({editingGroupId:c,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),d,this)}));return}}if(this.cursor.reset(),!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(Ic(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){if(this.getElementAtPosition(r,i,{includeLockedElements:!0})?.locked)return;let d=!t[V.CTRL_OR_CMD]&&this.getTextBindableContainerAtPosition(r,i);if(d&&(this.state.activeTool.type==="autoshape"||FM(d)||!WY(d.backgroundColor)||Tc({point:oe(r,i),element:d,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(d)}))){let m=Ob(d,this.scene.getNonDeletedElementsMap());r=m.x,i=m.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:d||null})}}});y(this,"handleCanvasClick",t=>{if(!this.isInteractionEnabled())return;if(t.button!==Tn.MAIN){this.lastCompletedCanvasClicks=[];return}if(this.smartZoomKeyHitElement){t.preventDefault(),t.stopPropagation();return}let o=Ce(t,this.state);if(this.smartZoomKeyDownAt!==null&&!this.smartZoomKeyHitElement){let i=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(i){this.smartZoomKeyHitElement=!0,t.preventDefault(),t.stopPropagation(),this.actionManager.executeAction(Rn,"keyboard",[i]);return}}let r=this.getImageStatusActionAtPosition(o);if(r){t.preventDefault(),t.stopPropagation(),r();return}this.lastCompletedCanvasClicks=[...this.lastCompletedCanvasClicks.slice(-1),{x:t.clientX,y:t.clientY}]});y(this,"getImageStatusActionAtPosition",t=>{if(!this.imageStatus.size)return null;let o=this.scene.getNonDeletedElementsMap(),r=this.visibleElements.length?this.visibleElements:this.scene.getNonDeletedElements();for(let i=r.length-1;i>=0;i--){let a=r[i];if(!Xn(a)||!a.fileId)continue;let s=this.imageStatus.get(a.fileId),l=s?.uploadProgress?.onClick;if(l&&this.isPointInsideImageStatusOverlay(t,a,o,"top-right"))return()=>l(a.fileId);let c=s?.downloadError?.onClick;if(c&&this.isPointInsideImageStatusOverlay(t,a,o,"center"))return()=>c(a.fileId)}return null});y(this,"isPointInsideImageStatusOverlay",(t,o,r,i)=>{let a=Yl(o,r,this.state,i);return!!a&&go(oe(t.x,t.y),oe(a.centerX,a.centerY))<=a.radius+2/this.state.zoom.value});y(this,"getElementLinkAtPosition",(t,o)=>{if(o&&o.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let s=r[a];if(o&&s.id===o.id&&(i=a),s.link&&a>=i&&Bc(s,this.scene.getNonDeletedElementsMap(),this.state,oe(t.x,t.y),this.editorInterface.formFactor==="phone"))return s}});y(this,"getElementLinkAtPositionForContextMenu",(t,o)=>{let r=this.getElementLinkAtPosition(t,o);if(r)return r;let i=this.scene.getNonDeletedElementsMap();for(let a of this.scene.getNonDeletedElements().slice().reverse())if(a.link&&!a.locked&&wx(a,i,this.state,oe(t.x,t.y)))return a});y(this,"handleElementLinkClick",t=>{let o=d=>d===Tn.MAIN||d===Tn.TOUCH;if(!o(this.lastPointerDownEvent.button)||!o(this.lastPointerUpEvent.button))return;let r=go(oe(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),oe(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>yM)return;let i=Ce(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),s=Bc(this.hitLinkElement,a,this.state,oe(i.x,i.y),this.editorInterface.formFactor==="phone"),l=Ce(this.lastPointerUpEvent,this.state),c=Bc(this.hitLinkElement,a,this.state,oe(l.x,l.y),this.editorInterface.formFactor==="phone");s&&c&&(ym(),this.openElementLink(this.hitLinkElement,t))});y(this,"openElementLink",(t,o)=>{let r=t.link;if(!r)return;r=cu(r);let i;if(this.props.onLinkOpen&&o&&(i=UY(Q.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...t,link:r},i)),!i?.defaultPrevented){let a=OY(r)?"_self":"_blank",s=window.open(void 0,a);s&&(s.opener=null,s.location=r)}});y(this,"applyElementLinkHoverAffordance",()=>this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.cursor.set(Me.POINTER),Rv(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap()),!0):(ym(),!1));y(this,"maybeHandleElementLinkClick",(t,o)=>{if(this.editorInterface.isTouchScreen){let r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(o,r)}return this.hitLinkElement&&this.lastPointerDownEvent&&!this.state.selectedElementIds[this.hitLinkElement.id]?(this.handleElementLinkClick(t),!0):!1});y(this,"handleInteractiveContentPointerMove",t=>{let o=Ce(t,this.state),r=this.getElementAtPosition(o.x,o.y,{includeLockedElements:!0});if(this.isEmbedsEnabled()){let i=r?.locked?null:r;if(this.handleIframeLikeElementHover({hitElement:i,scenePointer:o,moveEvent:t}))return}this.hitLinkElement=this.isLinksEnabled()?this.getElementLinkAtPosition(o,r):void 0,this.applyElementLinkHoverAffordance()||this.cursor.reset()});y(this,"handleInteractiveContentPointerUp",t=>{if(this.lastPointerUpEvent=t,this.isEmbedsEnabled()&&this.handleIframeLikeCenterClick())return;let o=Ce(t,this.state);this.isLinksEnabled()&&this.maybeHandleElementLinkClick(t,o)||this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});y(this,"getTopLayerFrameAtSceneCoords",(t,o)=>{let r=this.scene.getNonDeletedElementsMap(),i=this.scene.getNonDeletedFramesLikes().filter(l=>!l.locked&&XM(t,l,r));if(!i.length)return null;let a=i.at(-1),s=this.getElementsAtPosition(t.x,t.y,{includeLockedElements:!0}).findLast(l=>!o?.excludeElementIds?.[l.id]);if(s){if(St(s)&&!s.locked)return a;let l=this.scene.getElementIndex(s.id),c=this.scene.getElementIndex(a.id);if(l!==-1&&c!==-1&&l<=c)return a;let d=o?.currentFrameId?i.find(m=>m.id===o.currentFrameId)??null:null;return d||(s.frameId?i.find(m=>m.id===s.frameId)??null:null)}return a});y(this,"updateFrameToHighlight",t=>{this.state.frameToHighlight!==t&&this.setState({frameToHighlight:t})});y(this,"maybeUpdateFrameToHighlightOnPointerMove",(t,o)=>{this.state.newElement||this.state.multiElement||this.state.selectionElement||this.state.selectedElementsAreBeingDragged||this.updateFrameToHighlight(!o&&mX(this.state.activeTool.type)?this.getTopLayerFrameAtSceneCoords(t):null)});y(this,"insertNewElements",t=>{if(!t.length)return;let o=[];for(let r of t){let i=o[o.length-1];i?.[0].frameId===r.frameId?i.push(r):o.push([r])}for(let r of o){let i=r[0].frameId,a=i?PK(this.scene.getElementsIncludingDeleted(),i):null;this.scene.insertElementsAtIndex(r,a)}});y(this,"insertNewElement",t=>{this.insertNewElements([t]);let o=t.frameId?this.scene.getNonDeletedElement(t.frameId):null;this.updateFrameToHighlight(o&&St(o)?o:null)});y(this,"updateZDragZoom",t=>{if(!this.zDragZoom)return;let{origin:o,initialZoom:r}=this.zDragZoom,i=t.clientX-o.clientX,a=jn(r*Math.max(.1,1+i/100));this.viewport.translate(s=>({...vo({viewportX:o.clientX,viewportY:o.clientY,nextZoom:a},s),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0}),this.resetShouldCacheIgnoreZoomDebounced()});y(this,"handleCanvasPointerMove",t=>{if(!this.isInteractionEnabled()){this.isToolSupported(this.state.activeTool.type)&&this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.isNavigationEnabled()&&this.updateMultiTouchGesture(t),(this.isLinksEnabled()||this.isEmbedsEnabled())&&!Vo&&this.handleInteractiveContentPointerMove(t);return}this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent;let o=Ce(t,this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t);return}if(this.updateMultiTouchGesture(t),Wo||Vo||xu||Cs(this.state))return;let s=Mf(kc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;if(!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(s?this.cursor.set(Me.AUTO):this.getImageStatusActionAtPosition(o)?this.cursor.set(Me.POINTER):this.cursor.applyForTool()),this.maybeUpdateFrameToHighlightOnPointerMove({x:r,y:i},s),!this.state.newElement&&tI(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=eI(this.scene.getNonDeletedElements(),this,{x:r,y:i},t,this.scene.getNonDeletedElementsMap());this.setState(v=>{let w=yc(v.snapLines,b),x=v.originSnapOffset?yc(v.originSnapOffset,g):g;return v.snapLines===w&&v.originSnapOffset===x?null:{snapLines:w,originSnapOffset:x}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(g=>g.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let g=this.state.newElement?null:Ee.handlePointerMoveInEditMode(t,r,i,this);g&&g!==this.state.selectedLinearElement&&Gt(()=>{this.setState({selectedLinearElement:g})})}if(fK(this.state.activeTool.type)){let{newElement:g}=this.state;if(!g&&pu(this.state)){let b=oe(r,i),v=this.scene.getNonDeletedElementsMap(),w=Br(b,this.scene.getNonDeletedElements(),v,pA(this.state.zoom));w?this.setState({suggestedBinding:{element:w,midPoint:Yb(b,w,v,this.state.zoom)}}):this.state.suggestedBinding&&this.setState({suggestedBinding:null})}}if(this.state.multiElement&&this.state.selectedLinearElement){let{multiElement:g,selectedLinearElement:b}=this.state,{x:v,y:w,points:x}=g,I=x[x.length-1],{lastCommittedPoint:T}=b;if(this.cursor.applyForTool(),I===T)go(oe(r-v,i-w),I)>=kb?(this.store.scheduleCapture(),Gt(()=>{Eo(this.state.selectedLinearElement?.initialState,"initialState must be set"),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x[x.length-1],selectedPointsIndices:[g.points.length],initialState:{...this.state.selectedLinearElement.initialState,lastClickedPoint:g.points.length}}})}),this.scene.mutateElement(g,{points:[...x,oe(r-v,i-w)]},{informMutation:!1,isDragging:!1})):this.cursor.set(Me.POINTER);else if(x.length>2&&T&&go(oe(r-v,i-w),T)<kb){this.cursor.set(Me.POINTER),this.scene.mutateElement(g,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1});let C=g.points.length-1;this.setState({selectedLinearElement:{...b,selectedPointsIndices:b.selectedPointsIndices?[...new Set(b.selectedPointsIndices.map(P=>Math.min(P,C)))]:b.selectedPointsIndices,lastCommittedPoint:g.points[C],initialState:{...b.initialState,lastClickedPoint:C}}})}else{UM(x,this.state.zoom.value)&&this.cursor.set(Me.POINTER);let C=this.scene.getNonDeletedElementsMap();if(Vb(g)){let M=Br(oe(r,i),this.scene.getNonDeletedElements(),C);Ho("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(g,M)}Eo(this.state.selectedLinearElement,"Expected selectedLinearElement to be set to operate on a linear element");let P=Ee.handlePointerMove(t.nativeEvent,this,r,i,this.state.selectedLinearElement);P&&this.setState(P)}return}if(this.state.activeTool.type==="arrow"&&!this.state.newElement){let g=oe(r,i),b=Br(g,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),pA(this.state.zoom)),v=this.scene.getNonDeletedElementsMap();b&&!mA(g,b,v)&&this.setState({suggestedBinding:{element:b,midPoint:Yb(g,b,v,this.state.zoom)}})}let l=!!t.buttons,c=this.state.activeTool.type==="laser";if(l||!c&&this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(this.isHittingTextAutoResizeHandle(m,o)){this.cursor.set(Me.POINTER);return}if(m.length===1&&!s&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(m.length===1&&Zt(m[0]))&&!(Ht(m[0])&&(this.editorInterface.userAgent.isMobileDevice||m[0].points.length===2))){let g=oA(d,this.state,r,i,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);if(g&&g.transformHandleType){this.cursor.set(hA(nA(g),this.state.viewpointFlip));return}}}else if(m.length>1&&!s&&this.state.openDialog?.name!=="elementLinkSelector"){let g=rA(bs(m),r,i,this.state.zoom,t.pointerType,this.editorInterface);if(g){this.cursor.set(hA(nA({transformHandleType:g}),this.state.viewpointFlip));return}}if(rn(this.state))return;let p=this.getElementAtPosition(r,i,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p;let E=this.arrowText.updateHoveredAnchor(o);if(this.handleIframeLikeElementHover({hitElement:u,scenePointer:o,moveEvent:t})||(this.hitLinkElement=this.getElementLinkAtPosition(o,p)),!this.applyElementLinkHoverAffordance()){if(c)return;u&&(u.link||Uo(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?this.cursor.set(E?Me.POINTER:$t(u)?Me.TEXT:Me.CROSSHAIR):!t[V.CTRL_OR_CMD]&&this.isHittingCommonBoundingBoxOfSelectedElements(o,m)?this.cursor.set(Me.MOVE):this.state.viewModeEnabled?this.cursor.set(Me.GRAB):this.state.openDialog?.name==="elementLinkSelector"?this.cursor.set(Me.AUTO):s?this.cursor.set(Me.AUTO):!t[V.CTRL_OR_CMD]&&u?.id!==this.state.editingTextElement?.id?(u||this.isHittingCommonBoundingBoxOfSelectedElements(o,m))&&!u?.locked&&(!u||!Zt(u)||!(u.startBinding||u.endBinding))&&(this.state.activeTool.type!=="lasso"||m.length>0)&&this.cursor.set(Me.MOVE):this.cursor.set(Me.AUTO),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,r,i)}this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:yc(g.hoveredElementIds,Zn({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:yc(g.hoveredElementIds,{})})),this.updateSmartZoomCursor({x:r,y:i})});y(this,"handleEraser",(t,o)=>{let r=this.eraserTrail.addPointToPath(o.x,o.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});y(this,"handleTouchMove",t=>{this.isInteractionEnabled()&&(Mc=!0)});y(this,"handleCanvasPointerDown",t=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)){(this.isLinksEnabled()||this.isEmbedsEnabled())&&(this.lastPointerDownEvent=t),this.isNavigationEnabled()&&(this.updateGestureOnPointerDown(t),Vo||this.handleCanvasPanUsingWheelOrSpaceDrag(t));return}let o=this.scene.getSelectedElements(this.state);if(!t.ctrlKey){let g=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==g&&this.setState({isBindingEnabled:g})}let r=Ce(t,this.state),{x:i,y:a}=r;if(this.lastPointerMoveCoords={x:i,y:a},this.handleSmartZoomPointerDown(t,r))return;let s=t.target;if(s.setPointerCapture&&s.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.state.activeTool.type!=="laser"&&this.requestUnfollow(),this.state.searchMatches&&(this.setState(g=>({searchMatches:g.searchMatches&&{focusedId:null,matches:g.searchMatches.matches.map(b=>({...b,focus:!1}))}})),this.updateEditorAtom(lb,null)),bt.get(po)&&this.updateEditorAtom(po,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.state.openPopup&&this.setState({openPopup:null}),this.updateGestureOnPointerDown(t),bu){t.preventDefault(),this.focusContainer(),this.zDragZoom={origin:{clientX:t.clientX,clientY:t.clientY},initialZoom:this.state.zoom.value},this.setState({cursorButton:"down"});return}if(t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let g=this.state.newElement;this.updateScene({...g.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(b=>b.id!==g.id)}:{},appState:{newElement:null,editingTextElement:null,suggestedBinding:null,selectedElementIds:Le(Object.keys(this.state.selectedElementIds).filter(b=>b!==g.id).reduce((b,v)=>(b[v]=this.state.selectedElementIds[v],b),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?jt.EVENTUALLY:jt.NEVER});return}let l=document.getSelection();if(l?.anchorNode&&l.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(g=>({penMode:!0,penDetected:!0,currentItemStrokeVariability:"variable"})),!this.editorInterface.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.editorInterface=Db(this.editorInterface,{isTouchScreen:!0})),Vo||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Tn.ERASER&&this.isInteractionEnabled()&&!this.props.activeTool&&this.state.activeTool.type!==Yn.eraser){this.setState({activeTool:on(this.state,{type:Yn.eraser,lastActiveTool:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let g=()=>{b(),v?.(),rn(this.state)&&this.setState({activeTool:on(this.state,{...this.state.activeTool.lastActiveTool||{type:Yn.selection},lastActiveTool:null})})},b=we(window,Q.POINTER_UP,g,{once:!0}),v;requestAnimationFrame(()=>{v=this.missingPointerEventCleanupEmitter.once(g)})});return}if(t.button!==Tn.MAIN&&t.button!==Tn.TOUCH&&t.button!==Tn.ERASER||ue.pointers.size>1)return;let c=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleTextAutoResizeHandlePointerDown(o,c.origin)||this.handleDraggingScrollBar(t,c)||(this.clearSelectionIfNotUsingSelection(),this.handleSelectionOnPointerDown(t,c))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let g=c.hit.element&&this.isASelectedElement(c.hit.element);(t.altKey&&t[V.CTRL_OR_CMD]&&!c.resize.handleType||!c.hit.hasHitCommonBoundingBoxOfSelectedElements&&!c.resize.handleType&&!g)&&(this.lassoTrail.hasCurrentTrail||this.lassoTrail.startPath(c.origin.x,c.origin.y,t.shiftKey),c.drag.blockDragging=this.editorInterface.formFactor==="desktop"),this.editorInterface.formFactor!=="desktop"&&c.hit.element&&!g&&(this.setState(w=>{let x={...w.selectedElementIds,[c.hit.element.id]:!0},I=[];Object.keys(w.selectedElementIds).forEach(C=>{let P=this.scene.getElement(C);P&&I.push(P)});let T=c.hit.element;if(St(T))zb(I,T.id).forEach(C=>{delete x[C.id]});else if(T.frameId)x[T.frameId]&&delete x[T.id];else{let C=T.groupIds,P=new Set(C.flatMap(M=>Mi(this.scene.getNonDeletedElements(),M)).filter(M=>St(M)).map(M=>M.id));P.size>0&&I.forEach(M=>{M.frameId&&P.has(M.frameId)&&(delete x[M.id],M.groupIds.flatMap(D=>Mi(this.scene.getNonDeletedElements(),D)).forEach(D=>{delete x[D.id]}))})}return{...Zn({editingGroupId:w.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),w,this),showHyperlinkPopup:T.link||Uo(T)?"info":!1}}),c.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,c):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,c):this.state.activeTool.type==="custom"?this.cursor.applyForTool():this.state.activeTool.type===Yn.frame||this.state.activeTool.type===Yn.magicframe?this.createFrameElementOnPointerDown(c,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(c.lastCoords.x,c.lastCoords.y):this.state.activeTool.type==="autoshape"?this.drawShape.handlePointerDown(c):this.state.activeTool.type===Yn.bucketfill?this.bucketFill.handlePointerDown(r):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,c);this.props?.onPointerDown?.(this.state.activeTool,c),this.onPointerDownEmitter.trigger(this.state.activeTool,c,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(c.lastCoords.x,c.lastCoords.y);let m=this.onPointerMoveFromPointerDownHandler(c),p=this.onPointerUpFromPointerDownHandler(c),u=this.onKeyDownFromPointerDownHandler(c),E=this.onKeyUpFromPointerDownHandler(c);this.missingPointerEventCleanupEmitter.once(g=>p(g||t.nativeEvent)),(!this.state.viewModeEnabled||this.isActiveToolPointerCapturing())&&(window.addEventListener(Q.POINTER_MOVE,m),window.addEventListener(Q.POINTER_UP,p),window.addEventListener(Q.KEYDOWN,u),window.addEventListener(Q.KEYUP,E),c.eventListeners.onMove=m,c.eventListeners.onUp=p,c.eventListeners.onKeyUp=E,c.eventListeners.onKeyDown=u)});y(this,"handleCanvasPointerUp",t=>{if(!this.isInteractionEnabled()){(this.isLinksEnabled()||this.isEmbedsEnabled())&&this.handleInteractiveContentPointerUp(t);return}if(Ho("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.removePointer(t),this.lastPointerUpIsDoubleClick=this.isDoubleClick(this.lastPointerUpEvent,t),this.lastPointerUpEvent=t,!t.ctrlKey){let a=this.state.bindingPreference==="enabled";this.state.isBindingEnabled!==a&&this.setState({isBindingEnabled:a})}let o=Ce({clientX:t.clientX,clientY:t.clientY},this.state),{x:r,y:i}=o;if(this.lastPointerMoveCoords={x:r,y:i},this.zDragZoom){this.updateZDragZoom(t),this.zDragZoom=null,this.setState({cursorButton:"up"});return}this.handleIframeLikeCenterClick()||!this.maybeHandleElementLinkClick(t,o)&&this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});y(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(Mc=!1,Fr?Mc=!0:Fr=window.setTimeout(()=>{Fr=0,Mc||this.handleCanvasContextMenu(t)},DY))});y(this,"resetContextMenuTimer",()=>{clearTimeout(Fr),Fr=0,Mc=!1});y(this,"maybeCleanupAfterMissingPointerUp",t=>{xs?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});y(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(ue.pointers.size<=1&&((t.button===Tn.WHEEL||t.button===Tn.MAIN&&Wo||Cs(this.state))&&(this.isInteractionEnabled()||this.isNavigationEnabled())||this.state.viewModeEnabled&&!this.isActiveToolPointerCapturing())))return!1;Vo=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let o=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);this.cursor.set(Me.GRABBING);let{clientX:i,clientY:a}=t,s=Fm(c=>{let d=i-c.clientX,m=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!o&&(Math.abs(d)>1||Math.abs(m)>1)){o=!0;let p=E=>{document.body.removeEventListener(Q.PASTE,p),E.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(Q.PASTE,p),window.removeEventListener(Q.POINTER_UP,u)},100)};document.body.addEventListener(Q.PASTE,p),window.addEventListener(Q.POINTER_UP,u)}this.viewport.translate({scrollX:this.state.scrollX-d*Kn(this.state.viewpointFlip.horizontal)/this.state.zoom.value,scrollY:this.state.scrollY-m*Kn(this.state.viewpointFlip.vertical)/this.state.zoom.value})}),l=qe(xs=()=>{xs=null,Vo=!1,Wo||this.cursor.reset(),this.setState({cursorButton:"up"},this.viewport.releaseOverscroll),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,s),window.removeEventListener(Q.POINTER_UP,l),window.removeEventListener(Q.BLUR,l),s.flush()});return window.addEventListener(Q.BLUR,l),window.addEventListener(Q.POINTER_MOVE,s,{passive:!0}),window.addEventListener(Q.POINTER_UP,l),!0});y(this,"updateMultiTouchGesture",t=>{ue.pointers.has(t.pointerId)&&ue.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let o=ue.initialScale;if(ue.pointers.size===2&&ue.lastCenter&&o&&ue.initialDistance){let r=ff(ue.pointers),i=r.x-ue.lastCenter.x,a=r.y-ue.lastCenter.y;ue.lastCenter=r;let s=Ef(Array.from(ue.pointers.values())),l=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:s/ue.initialDistance,c=l?jn(o*l):this.state.zoom.value;this.setState(d=>{let m=vo({viewportX:r.x,viewportY:r.y,nextZoom:c},d),p=m.zoom.value;return this.viewport.translate({zoom:m.zoom,scrollX:m.scrollX+2*i*Kn(d.viewpointFlip.horizontal)/p,scrollY:m.scrollY+2*a*Kn(d.viewpointFlip.vertical)/p,shouldCacheIgnoreZoom:!0},{zoomPreConstrained:!0}),null}),this.viewport.isLockedTransitionPending||this.resetShouldCacheIgnoreZoomDebounced()}else ue.lastCenter=ue.initialDistance=ue.initialScale=null});y(this,"clearSelectionIfNotUsingSelection",()=>{mu(this.state.activeTool.type)||this.setState({selectedElementIds:Le({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});y(this,"handleSelectionOnPointerDown",(t,o)=>{if(mu(this.state.activeTool.type)){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!Zt(a[0])&&!(Ht(a[0])&&(this.editorInterface.userAgent.isMobileDevice||a[0].points.length===2))&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let s=oA(r,this.state,o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.editorInterface);s!=null&&(s.transformHandleType==="rotation"?(this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:s.element}),o.resize.handleType=s.transformHandleType))}else a.length>1&&(o.resize.handleType=rA(bs(a),o.origin.x,o.origin.y,this.state.zoom,t.pointerType,this.editorInterface));if(o.resize.handleType)o.resize.isResizing=!0,o.resize.offset=Ab(jK(o.resize.handleType,a,i,o.origin.x,o.origin.y)),a.length===1&&Ht(a[0])&&a[0].points.length===2&&(o.resize.arrowDirection=qK(o.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Ee.handlePointerDown(t,this,this.store,o.origin,p,this.scene);if(u.hitElement&&(o.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0;let E=this.scene.getNonDeletedElementsMap(),g=Ee.getElement(p.elementId,E);if(g&&xo(g)){let{hitFocusPoint:b,pointerOffset:v,arrowOtherEndpointInitialBinding:w}=lX(g,o,E,this.state);if(b)return this.setState({selectedLinearElement:{...p,hoveredFocusPointBinding:b,draggedFocusPointBinding:b,pointerOffset:v,initialState:{...p.initialState,arrowOtherEndpointInitialBinding:w}}}),!1}}let s=this.getElementsAtPosition(o.origin.x,o.origin.y,{includeLockedElements:!0}),l=s.filter(p=>!p.locked),c=this.getElementAtPosition(o.origin.x,o.origin.y,{allHitElements:s});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!l.some(p=>this.state.selectedElementIds[p.id])?o.hit.element=null:o.hit.element=o.hit.element??this.getElementAtPosition(o.origin.x,o.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(o.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&o.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),o.hit.element&&this.getElementLinkAtPosition({x:o.origin.x,y:o.origin.y},o.hit.element))return!1;o.hit.allHitElements=l;let d=o.hit.element,m=o.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!m)&&!t.shiftKey&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(!this.state.selectedLinearElement?.isEditing||d&&d?.id!==this.state.selectedLinearElement?.elementId)&&this.clearSelection(d),this.state.selectedLinearElement?.isEditing)this.setState(p=>({selectedLinearElement:p.selectedLinearElement?{...p.selectedLinearElement,isEditing:!!d&&d.id===this.state.selectedLinearElement?.elementId}:null,selectedElementIds:p.selectedLinearElement?Le({[p.selectedLinearElement.elementId]:!0},this.state):Le({},p)}));else if(d!=null){if(t[V.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(o.origin.x,o.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[d.id]||(o.hit.wasAddedToSelection=!0),this.setState(p=>({...YK(p,d),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!QM(d,this.state.editingGroupId)&&this.setState({selectedElementIds:Le({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!o.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},E=[];if(Object.keys(p.selectedElementIds).forEach(g=>{let b=this.scene.getElement(g);b&&E.push(b)}),St(d))zb(E,d.id).forEach(g=>{delete u[g.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let g=d.groupIds,b=new Set(g.flatMap(v=>Mi(this.scene.getNonDeletedElements(),v)).filter(v=>St(v)).map(v=>v.id));b.size>0&&E.forEach(v=>{v.frameId&&b.has(v.frameId)&&(delete u[v.id],v.groupIds.flatMap(w=>Mi(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete u[w.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(g=>p.selectedGroupIds[g])||(u={[d.id]:!0})),{...Zn({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||Uo(d)?"info":!1}}),o.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});y(this,"handleTextOnPointerDown",(t,o)=>{if(this.state.editingTextElement)return;let r=o.origin.x,i=o.origin.y;this.setState({hoveredArrowTextAnchor:null});let a=this.arrowText.getBindableEndpointAtPosition(r,i);if(a)this.startTextEditing({sceneX:r,sceneY:i,autoEdit:!1,arrowEndpoint:a});else{let s=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);FM(s)&&(l=s,r=s.x+s.width/2,i=s.y+s.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1,initialCaretSceneCoords:{x:r,y:i}})}this.isToolLocked()?this.cursor.reset():this.setState({activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset())});y(this,"handleFreeDrawElementOnPointerDown",(t,o,r)=>{let[i,a]=kt(r.origin.x,r.origin.y,null),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),l=t.pressure===.5,c=this.state.currentItemStrokeVariability,d=lK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("freedraw"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:l,strokeOptions:{variability:c,streamline:t.pointerType!=="mouse"?IY:vY},locked:!1,frameId:s?s.id:null,points:[oe(0,0)],pressures:l?[]:[t.pressure]});this.insertNewElement(d),this.setState(m=>{let p={...m.selectedElementIds};return delete p[d.id],{selectedElementIds:Le(p,m)}}),this.setState({newElement:d,suggestedBinding:null})});y(this,"insertIframeElement",({sceneX:t,sceneY:o,width:r,height:i})=>{let[a,s]=kt(t,o,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=dK({type:"iframe",x:a,y:s,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("iframe"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.insertNewElement(l),l});y(this,"insertEmbeddableElement",({sceneX:t,sceneY:o,link:r})=>{let[i,a]=kt(t,o,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=hu(r);if(!s)return;s.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let l=_M({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("embeddable"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:s.intrinsicSize.w,height:s.intrinsicSize.h,link:r});return this.insertNewElement(l),l});y(this,"newImagePlaceholder",({sceneX:t,sceneY:o,addToFrameUnderCursor:r=!0,customData:i})=>{let[a,s]=kt(t,o,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=r?this.getTopLayerFrameAtSceneCoords({x:a,y:s}):null,c=100/this.state.zoom.value;return uK({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("image"),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,customData:i,x:a-c/2,y:s-c/2,width:c,height:c})});y(this,"handleLinearElementOnPointerDown",(t,o,r)=>{if(t.ctrlKey&&Gt(()=>{this.setState({isBindingEnabled:this.state.bindingPreference!=="enabled"})}),this.state.multiElement){let{multiElement:i,selectedLinearElement:a}=this.state;if(Eo(a,"selectedLinearElement is expected to be set"),i.type==="line"&&UM(i.points,this.state.zoom.value)){Gt(()=>{this.setState({selectedLinearElement:{...a,lastCommittedPoint:i.points[i.points.length-1],initialState:{...a.initialState,lastClickedPoint:-1}}})}),this.actionManager.executeAction(gt);return}if(Zt(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:s,y:l}=i,{lastCommittedPoint:c}=a,d=Ce(t,this.state),{start:m,end:p}=xo(i)&&pu(this.state)?pX(i,new Map([[i.points.length-1,{point:i.points[i.points.length-1],isDragging:!1}]]),d.x,d.y,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.state,{newArrow:!!this.state.newElement,zoom:this.state.zoom}):{end:{mode:void 0}},u=this.scene.getNonDeletedElementsMap(),E=m?.mode!=null&&p.mode!=null&&m.element.id===p.element.id&&!mA(p.focusPoint,p.element,u),g=p.mode==="orbit"&&i.startBinding?.elementId!==p.element?.id,b=c&&go(oe(r.origin.x-s,r.origin.y-l),c)<kb;if(g||E||i.points.length>1&&b){this.actionManager.executeAction(gt,"ui",{event:t.nativeEvent,sceneCoords:{x:r.origin.x,y:r.origin.y}});return}this.setState(v=>({selectedElementIds:Le({...v.selectedElementIds,[i.id]:!0},v)})),this.cursor.set(Me.POINTER)}else{let[i,a]=kt(r.origin.x,r.origin.y,t[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:l,currentItemEndArrowhead:c}=this.state,[d,m]=o==="arrow"?[l,c]:[null,null],p=o==="arrow"?mK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Nr.round?{type:su.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:s?s.id:null,elbowed:this.state.currentItemArrowType===Nr.elbow,fixedSegments:this.state.currentItemArrowType===Nr.elbow?[]:null}):hK({type:o,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(o),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:su.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:s?s.id:null}),u=oe(r.origin.x,r.origin.y),E=this.scene.getNonDeletedElementsMap(),g=pu(this.state)?Br(u,this.scene.getNonDeletedElements(),E):null;this.scene.mutateElement(p,{points:[oe(0,0),oe(0,0)]}),this.insertNewElement(p),xo(p)&&oX(p,new Map([[0,{point:oe(0,0),isDragging:!1}]]),u[0],u[1],this.scene,this.state,{newArrow:!0,altKey:t.altKey,initialBinding:!0,angleLocked:bM(t.nativeEvent)}),Gt(()=>{this.setState(b=>{let v=null,w=b.selectedElementIds;if(Ht(p)){v=new Ee(p,this.scene.getNonDeletedElementsMap());let x=p.points.length-1;v={...v,selectedPointsIndices:[x],initialState:{...v.initialState,arrowStartIsInside:t.altKey,lastClickedPoint:x,origin:oe(r.origin.x,r.origin.y)}}}return w=this.isToolLocked()?b.selectedElementIds:Le({[p.id]:!0},b),{...b,bindMode:"orbit",newElement:p,suggestedBinding:g&&xo(p)?{element:g,midPoint:Yb(u,g,E,this.state.zoom)}:null,selectedElementIds:w,selectedLinearElement:v}})}),xo(p)&&Ho("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(p,g)}});y(this,"createGenericElementOnPointerDown",(t,o)=>{let[r,i]=kt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),s={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth(t),strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},l;t==="embeddable"?l=_M({type:"embeddable",...s}):l=pK({type:t,...s}),l.type==="selection"?this.setState({selectionElement:l}):(this.insertNewElement(l),this.setState({multiElement:null,newElement:l}))});y(this,"createFrameElementOnPointerDown",(t,o)=>{let[r,i]=kt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Go},s=o===Yn.magicframe?cK(a):sK(a);this.insertNewElement(s),this.setState({multiElement:null,newElement:s})});y(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});y(this,"eraseElements",()=>{let t=!1;this.elementsPendingErasure.forEach(r=>{let i=this.scene.getElement(r);if(xo(i)){if(i.startBinding){let a=this.scene.getElement(i.startBinding.elementId);gu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}if(i.endBinding){let a=this.scene.getElement(i.endBinding.elementId);gu(a,this.scene.getElementsMapIncludingDeleted(),{boundElements:a.boundElements.filter(s=>s.id!==i.id)})}}else Rb(i)&&i.boundElements?.forEach(a=>{if(a.type==="arrow"){let s=this.scene.getElement(a.id);s?.startBinding?.elementId===i.id&&gu(s,this.scene.getElementsMapIncludingDeleted(),{startBinding:null}),s?.endBinding?.elementId===i.id&&gu(s,this.scene.getElementsMapIncludingDeleted(),{endBinding:null})}})});let o=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||OM(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,bo(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(o))});y(this,"initializeImage",async(t,o)=>{if(!Fi(o))throw new Error(f("errors.unsupportedFileType"));this.cursor.set("wait");let r=this.gifPlayback.createPlaceholderDecodeState(t,o);if(o.type===In.svg)try{o=Ou(WM(await o.text()),o.name)}catch(d){throw console.warn(d),new Error(f("errors.svgImageInsertError"))}else if(o.type!==In.gif){let{maxWidthOrHeight:d}=this.props.imageOptions;try{o=await(this.props.compressImageFile??Lx)(o,{maxWidthOrHeight:d})}catch(m){console.error("Error trying to resize image file on insertion",m)}}let i=o.type,a=i===In.gif,s=await(this.props.generateIdForFile?.(o)||kx(o));if(!s)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[s]?.dataURL){let{maxFileSizeBytes:d}=this.props.imageOptions;if(o.size>d)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(d/1024/1024)}MB`}))}let c=this.files[s]?.dataURL||await Uc(o);return new Promise(async(d,m)=>{try{let p=this.getLatestInitializedImageElement(t,s);if(this.addMissingFiles([{mimeType:i,id:s,dataURL:c,fileName:o.name,created:Date.now(),lastRetrieved:Date.now()}]),a&&(p=this.gifPlayback.ensureElementPlaybackMetadata(p),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(g=>g.id===p.id?p:g)),this.imagePlaceholderUpdateEmitter.trigger()),!this.imageCache.get(s)){a||this.addNewImagesToImageCache();let{erroredFiles:g}=await this.updateImageCache([p]);if(g.size)throw new Error("Image cache update resulted with an error.")}let u=await this.imageCache.get(s)?.image,E=u?wK(u):null;if(u&&this.state.newElement?.id!==p.id){p=this.getLatestInitializedImageElement(t,s);let g=this.getImageNaturalDimensions(p,u);Object.assign(p,g)}p=bo(p,{fileName:o.name,thumbHash:E,gifPlayback:a?this.gifPlayback.ensureElementPlaybackMetadata(p,{playing:!0}).gifPlayback:null,status:"saved"}),this.files={...this.files,[s]:{...this.files[s],fileName:o.name,thumbHash:E??void 0}},r&&r!==s&&this.gifPlayback.removePlaceholderDecodeState(r),d(p)}catch(p){this.gifPlayback.removePlaceholderDecodeState(r),console.error(p),m(new Error(f("errors.imageInsertError")))}})});y(this,"getLatestInitializedImageElement",(t,o)=>{let r=this.scene.getElement(t.id)??t;return bo(r,{fileId:o})});y(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,o=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Ce({clientX:t,clientY:o},this.state),a=await xx({description:"Image",extensions:Object.keys(CY),multiple:!0});this.insertImages(a,r,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>{this.actionManager.executeAction(gt)})}});y(this,"getImageNaturalDimensions",(t,o)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(o.naturalHeight,i),s=a*(o.naturalWidth/o.naturalHeight),l=t.x+t.width/2-s/2,c=t.y+t.height/2-a/2;return{x:l,y:c,width:s,height:a,crop:null}});y(this,"handleImageCacheUpdate",t=>{for(let o of this.scene.getNonDeletedElements())Pi(o)&&o.fileId===t&&ki.delete(o);this.imagePlaceholderUpdateEmitter.trigger(),this.scene.triggerUpdate(),this.ensureGifPlaybackLoop()});y(this,"updateImageCache",async(t,o=this.files)=>{let r=new Map;for(let s of t){let l=this.imageCache.get(s.fileId);l&&r.set(s.fileId,Promise.resolve(l.image))}let{updatedFiles:i,erroredFiles:a}=await Bb({imageCache:this.imageCache,fileIds:t.map(s=>s.fileId),files:o,onImageCacheUpdate:s=>this.handleImageCacheUpdate(s),gifAutoDecodeMaxFileSizeBytes:this.props.imageOptions.gifAutoDecodeMaxFileSizeBytes});for(let[s,l]of r){let c=this.imageCache.get(s);!c||!i.has(s)||this.imageCache.set(s,{...c,placeholderImage:await l,transitionStart:performance.now()})}return(a.size||i.size)&&(this.store.scheduleAction(jt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(s=>{if(Pi(s)){if(a.has(s.fileId))return bo(s,{status:"error"});if(i.has(s.fileId)&&s.status==="error")return bo(s,{status:"saved"})}return s}))),{updatedFiles:i,erroredFiles:a}});y(this,"ensureGifPlaybackLoop",()=>{this.gifPlayback.ensureLoop()});y(this,"loadDeferredGif",async t=>{let o=this.imageCache.get(t);this.files[t]?.mimeType!==In.gif||!o||(this.imageCache.set(t,{...o,gifDecodeStatus:"pending"}),this.handleImageCacheUpdate(t),await Bb({imageCache:this.imageCache,fileIds:[t],files:this.files,onImageCacheUpdate:i=>this.handleImageCacheUpdate(i),forceGifDecode:!0}))});y(this,"getGifPlaybackFrameIndex",t=>this.gifPlayback.getFrameIndex(t));y(this,"setGifPlaybackFrameIndex",(t,o)=>{this.gifPlayback.setFrameIndex(t,o)});y(this,"addNewImagesToImageCache",async(t=TK(this.scene.getNonDeletedElements()),o=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,o);if(i.size)for(let a of r)i.has(a.fileId)&&ki.delete(a);i.size&&this.scene.triggerUpdate()}});y(this,"scheduleImageRefresh",bY(()=>{this.addNewImagesToImageCache()},PY));y(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.cursor.reset(),this.interactiveCanvas.addEventListener(Q.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(Q.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(Q.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(Q.TOUCH_END,this.onTouchEnd))});y(this,"insertImages",async(t,o,r,i)=>{let a=50/this.state.zoom.value,s=lA(t.map((u,E)=>this.newImagePlaceholder({sceneX:o,sceneY:r,customData:i?.[E]})),o,r,a);this.insertNewElements(s);let l=await Promise.all(s.map(async(u,E)=>{try{return await this.initializeImage(u,await Ur(t[E]))}catch(g){return this.setState({errorMessage:g.message||f("errors.imageInsertError")}),bo(u,{isDeleted:!0})}})),c=wc(l),d=lA(l.filter(u=>!u.isDeleted),o,r,a),m=wc(d),p=this.scene.getElementsIncludingDeleted().map(u=>m.get(u.id)??c.get(u.id)??u);this.updateScene({appState:{selectedElementIds:Le(Object.fromEntries(d.map(u=>[u.id,!0])),this.state)},elements:p,captureUpdate:jt.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(gt)})});y(this,"handleAppOnDrop",async t=>{if(!this.isInteractionEnabled())return;let{x:o,y:r}=Ce(t,this.state),i=lg(t),a=await ur(t),s=a.getFiles(),l=s.map(d=>d.file).filter(d=>Fi(d));if(this.state.viewModeEnabled)return l.length===0||!this.isToolSupported("image")||!this.shouldInsertImageInViewMode({source:"drop",files:l,event:t})?void 0:this.insertImages(l,o,r,im(a,l.length,i));if(s.length===1){let{file:d,fileHandle:m}=s[0];if(d&&(d.type===In.png||d.type===In.svg))try{let p=await As(d,this.state,this.scene.getElementsIncludingDeleted(),m);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}}if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,o,r,im(a,l.length,i));if(s.length>0){let{file:d,fileHandle:m}=s[0];d&&await this.loadFileToCanvas(d,m)}let c=a.findByType(In.text);if(c){let d=c.value;if(d&&Nb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||hu(d)?.type==="video")){let m=this.insertEmbeddableElement({sceneX:o,sceneY:r,link:cu(d)});m&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[m.id]:!0}}))}}});y(this,"loadFileToCanvas",async(t,o)=>{t=await Ur(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await As(t,this.state,r,o)}catch(a){let s=a instanceof bx;if(s&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let l=s?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:l})}if(!i)return;xA(r.concat(i.elements)),this.store.scheduleMicroAction({action:jt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({elements:i.elements,files:i.files,appState:{...i.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:jt.IMMEDIATELY})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});y(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),!this.isInteractionEnabled()||(this.bucketFill.cancel(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Tn.SECONDARY)&&this.state.activeTool.type!==this.state.preferredSelectionTool.type))return;let{x:o,y:r}=Ce(t,this.state),i=this.getElementAtPosition(o,r,{preferSelected:!0,includeLockedElements:!0}),a=this.isLinksEnabled()?this.getElementLinkAtPositionForContextMenu({x:o,y:r},i):void 0,s=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:o,y:r},s),c=l&&s.length===1&&s[0].link?s[0]:void 0,d=i??a??c,m=d||l?"element":"canvas",p=this.excalidrawContainerRef.current,{top:u,left:E}=p.getBoundingClientRect(),g=t.clientX-E,b=t.clientY-u;We("contextMenu","openContextMenu",m),this.setState({...d&&!this.state.selectedElementIds[d.id]?{...this.state,...Zn({editingGroupId:this.state.editingGroupId,selectedElementIds:{[d.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Ht(d)?new Ee(d,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:b,left:g,items:this.getContextMenuItems(m,d)}})})});y(this,"maybeDragNewGenericElement",(t,o,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&t.boxSelection.hasOccurred&&this.state.activeTool.type!=="eraser"){iA({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Es(t.origin.x,a.x),height:Es(t.origin.y,a.y),shouldMaintainAspectRatio:Ec(o),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let s=this.state.newElement;if(!s||this.arrowText.maybeDragNewText(s,a))return;let[l,c]=kt(a.x,a.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=Pi(s)&&this.imageCache.get(s.fileId)?.image,m=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(o,[s]);let{snapOffset:p,snapLines:u}=Q2(s,this,o,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:l-t.originInGrid.x,y:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());l+=p.x,c+=p.y,this.setState({snapLines:u}),xo(s)||iA({newElement:s,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:l,y:c,width:Es(t.originInGrid.x,l),height:Es(t.originInGrid.y,c),shouldMaintainAspectRatio:Xn(s)?!Ec(o):Ec(o),shouldResizeFromCenter:EM(o),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:s}),(this.state.activeTool.type===Yn.frame||this.state.activeTool.type===Yn.magicframe)&&this.setState({elementsToHighlight:Hb(this.scene.getNonDeletedElements(),s,this.state,this.scene.getNonDeletedElementsMap())})});y(this,"maybeHandleCrop",(t,o)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,s]=kt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&l&&Xn(l)){let c=t.originalElements.get(l.id),d=Pi(l)&&this.imageCache.get(l.fileId)?.image;if(c&&Xn(c)&&d&&!(d instanceof Promise)){let[m,p]=kt(i.x,i.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(o,[l]);let{snapOffset:E,snapLines:g}=wf([l],[c],this,o,u,r);this.scene.mutateElement(l,FK(l,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+E.x,s+E.y,o.shiftKey?c.width/c.height:void 0)),uu(l,this.scene),this.setState({isCropping:r&&r!=="rotation",snapLines:g})}return!0}return!1});y(this,"maybeHandleResize",(t,o)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(St),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&Zt(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let s=t.lastCoords,[l,c]=kt(s.x-t.resize.offset.x,s.y-t.resize.offset.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{zb(this.scene.getNonDeletedElements(),m.id).forEach(u=>{d.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=kt(s.x,s.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-t.originInGrid.x,y:p-t.originInGrid.y},E=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(o,r);let{snapOffset:g,snapLines:b}=wf(r,de(E,this.state),this,o,u,a);l+=g.x,c+=g.y,this.setState({snapLines:b})}if(JK(t.originalElements,a,r,this.scene,bM(o),EM(o),r.some(m=>Xn(m))?!Ec(o):Ec(o),l,c,t.resize.center.x,t.resize.center.y)){let m=new Set;return i.forEach(p=>{Hb(this.scene.getNonDeletedElements(),p,this.state,this.scene.getNonDeletedElementsMap()).forEach(u=>{Eu(u)?m.add(u):console.error("[NONDELETED][INVARIANT] Skipped highlighting deleted element in resizing frame")})}),this.setState({elementsToHighlight:[...m]}),!0}return!1});y(this,"getImageContextMenuItems",t=>{let o=this.props.imageContextMenuItems;if(!o)return[];let r=this.scene.getSelectedElements(this.state);return r.length>0&&r.every(i=>Xn(i))&&(!t||this.state.selectedElementIds[t.id])?[...o(r.map(i=>i.id))]:t&&Xn(t)?[...o([t.id])]:[]});y(this,"getImageActionContextMenuItems",t=>{let o=this.scene.getSelectedElements(this.state);return o.length>0&&o.every(r=>Xn(r))&&(!t||this.state.selectedElementIds[t.id])?[xg,yg]:[]});y(this,"getElementLinkContextMenuItems",t=>{if(!t?.link)return[];let o=cu(t.link),r=jM(o);return[{key:"goToLink",label:r?f("labels.link.goToElement"):"Go to link",onSelect:()=>this.openElementLink(t)},!r&&{key:"copyLink",label:f("buttons.copyLink"),onSelect:async()=>{await ao(o),this.setState({toast:{message:f("toast.elementLinkCopied"),closable:!0}})}}]});y(this,"getContextMenuItems",(t,o)=>{let r=this.getImageContextMenuItems(o),i=this.getImageActionContextMenuItems(o),a=this.getElementLinkContextMenuItems(o);if(t==="canvas")return this.state.viewModeEnabled?[Rn,ga,fa,He,ba,_a,Er]:[Ig,He,vh,Uv,He,ba,_t,gl,fl,He,ga,fa,He,_a,Er];if(this.state.viewModeEnabled)return[...a,a.length>0&&He,Rn,ga,fa,He,Ea,r.length>0&&He,...r];let s=this.editorInterface.formFactor==="desktop"?[He,bh,xh,yh,wh]:[];return[He,Rn,ga,fa,He,Em,Ea,Ig,r.length>0&&He,...r,i.length>0&&He,...i,He,L2,_2,R2,He,cf,He,fg,hf,Cg,Pg,Sv,Eg,He,...s,He,wg,vg,He,Ma,He,Bg,a.length>0&&He,...a,He,Ih,xl,He,Gs]});y(this,"handleWheel",qe(t=>{if(!this.isNavigationEnabled())return;if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement||t.target instanceof HTMLElement&&(t.target.classList.contains(Lb.FRAME_NAME)||t.target.classList.contains("excalidraw-eye-dropper-backdrop")))){t[V.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Vo)return;let{deltaX:o,deltaY:r}=t;if(t.metaKey||t.ctrlKey||this.state.wheelZoomsOnDefault){let i=Math.sign(r),a=_Y*100,s=Math.abs(r),l=r;s>a&&(l=a*i);let c=this.state.zoom.value-l/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,s/20);let d=this.state.scrollConstraints?.lockZoom?this.state.scrollConstraints.zoom:RY;c=Math.max(c,d),this.viewport.translate(p=>({...vo({viewportX:this.viewport.lastPosition.x,viewportY:this.viewport.lastPosition.y,nextZoom:jn(c)},p),shouldCacheIgnoreZoom:!0}),{zoomPreConstrained:!0,preserveScrollConstraintsSnapBack:!0})&&this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.viewport.translate(({zoom:i,scrollX:a,viewpointFlip:s})=>({scrollX:a-(r||o)*Kn(s.horizontal)/i.value}));return}this.viewport.translate(({zoom:i,scrollX:a,scrollY:s,viewpointFlip:l})=>({scrollX:a-o*Kn(l.horizontal)/i.value,scrollY:s-r*Kn(l.vertical)/i.value}))}));y(this,"savePointer",(t,o,r)=>{if(!this.isInteractionEnabled()&&!this.isToolSupported(this.state.activeTool.type)||!t||!o)return;let{x:i,y:a}=Ce({clientX:t,clientY:o},this.state);isNaN(i)||isNaN(a);let s={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:s,button:r,pointersMap:ue.pointers})});y(this,"resetShouldCacheIgnoreZoomDebounced",SM(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));y(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:s}=o.getBoundingClientRect(),{width:l,height:c,offsetTop:d,offsetLeft:m}=this.state;if(r===l&&i===c&&a===m&&s===d){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:s},()=>{t&&t()}),this.viewport.constrain()}});y(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});y(this,"watchState",()=>{});let o=Zo(),{viewModeEnabled:r=!1,viewModeOnly:i=!1,gridModeEnabled:a=!1,objectsSnapModeEnabled:s=!1,theme:l=o.theme,name:c=`${f("labels.untitled")}-${PM()}`,wheelZoomsOnDefault:d=!1}=t,m=null;t.activeTool&&(t.activeTool.type==="image"?console.warn('"image" tool cannot be forced via "props.activeTool"'):this.isToolSupported(t.activeTool.type,t)?m=on(o,t.activeTool):console.warn(`"${t.activeTool.type}" tool ("props.activeTool") cannot be activated \u2014 disabled via "UIOptions.tools", or not enabled while non-interactive (see "interaction.enabled.tools")`)),this.state={...o,theme:l,exportWithDarkMode:l===bc.DARK,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:this.isInteractionEnabled(t)?i||r:!0,viewModeOnly:i,activeTool:m??o.activeTool,zenModeEnabled:!1,objectsSnapModeEnabled:s,gridModeEnabled:a??o.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight,wheelZoomsOnDefault:d},this.refreshEditorInterface(),this.stylesPanelMode=vu(this.editorInterface),this.id=yY(),this.actionManager=new _m(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new aA,this.canvas=document.createElement("canvas"),this.rc=xY.canvas(this.canvas),this.renderer=new Ol(this.scene),this.visibleElements=[],this.store=new tX(this),this.history=new Bl(this.store),this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Io(this.scene),this.history=new Bl(this.store),this.actionManager.registerAll(rd),this.actionManager.registerAction(O2(this.history)),this.actionManager.registerAction(z2(this.history)),this.api=this.createExcalidrawAPI()}get lastViewportPosition(){return this.viewport.lastPosition}createExcalidrawAPI(){return{isDestroyed:!1,updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,addFiles:this.addFiles,addImagePlaceholder:this.addImagePlaceholder,setDownloadProgress:this.setDownloadProgress,setDownloadError:this.setDownloadError,setUploadProgress:this.setUploadProgress,addImageElementsToScene:this.addImageElementsToScene,scrollToViewport:this.scrollToViewport,scrollToContent:this.scrollToContent,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},setViewport:this.viewport.setViewport,getViewportOffsets:this.viewport.getOffsets,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:o=>{this.actionManager.registerAction(o)},getCommandCatalog:this.getCommandCatalog,executeCommand:this.executeCommand,refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.cursor.set,resetCursor:this.cursor.reset,getEditorInterface:()=>this.editorInterface,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:o=>this.onChangeEmitter.on(o),onIncrement:o=>this.store.onStoreIncrementEmitter.on(o),onPointerDown:o=>this.onPointerDownEmitter.on(o),onPointerUp:o=>this.onPointerUpEmitter.on(o),onScrollChange:o=>this.onScrollChangeEmitter.on(o),onUserFollow:o=>this.onUserFollowEmitter.on(o),onStateChange:this.onStateChange,onEvent:this.onEvent}}isInteractionEnabled(t=this.props){return t.interaction!==!1&&typeof t.interaction!="object"}isLinksEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.links===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isNavigationEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.navigation===!0:t.interaction!==!1}isEmbedsEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.embeds===!0||t.interaction.enabled?.interactiveContent===!0:t.interaction!==!1}isBrowserZoomEnabled(t=this.props){return typeof t.interaction=="object"&&t.interaction!==null?t.interaction.enabled?.browserZoom===!0:!1}isToolLocked(){return this.state.activeTool.locked||this.props.activeTool!=null}isActiveToolPointerCapturing(){return this.isInteractionEnabled()?this.state.activeTool.type==="laser"||this.state.activeTool.type==="custom":this.isToolSupported(this.state.activeTool.type)}isDefaultUIEnabled(t=this.props){return t.ui!==!1&&(typeof t.ui!="object"||t.ui===null)}isUIControlEnabled(t,o=this.props){return typeof o.ui=="object"&&o.ui!==null?o.ui.enabled?.[t]===!0:o.ui!==!1}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let o=null;try{o=JSON.parse(t.data)}catch{}if(o)switch(t.origin){case"https://player.vimeo.com":if(o.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:o.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(o.event==="infoDelivery"&&o.info&&o.id&&typeof o.info.playerState=="number"){let r=o.id,i=o.info.playerState;Object.values(lu).includes(i)&&Kb.set(r,i)}break}}handleSkipBindMode(){if(this.state.selectedLinearElement?.initialState&&!this.state.selectedLinearElement.initialState.arrowStartIsInside){Eo(this.lastPointerMoveCoords,"Missing last pointer move coords when changing bind skip mode for arrow start");let t=this.scene.getNonDeletedElementsMap(),o=Br(oe(this.lastPointerMoveCoords.x,this.lastPointerMoveCoords.y),this.scene.getNonDeletedElements(),t),r=Ee.getElement(this.state.selectedLinearElement.elementId,t);r?.startBinding&&o?.id===r.startBinding.elementId&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:!0}}})}if(this.state.bindMode==="orbit"&&(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),Gt(()=>{this.setState({bindMode:"skip"})}),this.lastPointerMoveCoords&&this.state.selectedLinearElement?.selectedPointsIndices&&this.state.selectedLinearElement?.selectedPointsIndices.length)){let{x:t,y:o}=this.lastPointerMoveCoords,r=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;Eo(r,"Last event must exist");let i=t-this.state.selectedLinearElement.pointerOffset.x,a=o-this.state.selectedLinearElement.pointerOffset.y,s=this.state.multiElement?Ee.handlePointerMove(r,this,i,a,this.state.selectedLinearElement):Ee.handlePointDragging(r,this,i,a,this.state.selectedLinearElement);s&&this.setState(s)}}resetDelayedBindMode(){this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode!=="orbit"&&setTimeout(()=>this.setState({bindMode:"orbit"}))}handleDelayedBindModeChange(t,o){if(t.isDeleted||Zt(t))return;let r=()=>{if(this.bindModeHandler=null,Eo(this.lastPointerMoveCoords,"Expected lastPointerMoveCoords to be set"),!this.state.multiElement){if(!this.state.selectedLinearElement||!this.state.selectedLinearElement.selectedPointsIndices||!this.state.selectedLinearElement.selectedPointsIndices.length)return;let E=this.state.selectedLinearElement.selectedPointsIndices.includes(0),g=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1);if(!E&&!g||E&&g)return}let{x:m,y:p}=this.lastPointerMoveCoords,u=Br(oe(m,p),this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap());if(u&&this.state.bindMode!=="skip"){Eo(this.state.selectedLinearElement?.elementId===t.id,"The selectedLinearElement is expected to not change while a bind mode timeout is ticking");let E=this.state.selectedLinearElement.initialState.arrowStartIsInside||t.startBinding?.elementId===u.id;Gt(()=>{Eo(this.state.selectedLinearElement,"this.state.selectedLinearElement must exist"),this.setState({bindMode:"inside",selectedLinearElement:{...this.state.selectedLinearElement,initialState:{...this.state.selectedLinearElement.initialState,arrowStartIsInside:E}}})});let g=this.lastPointerMoveEvent??this.lastPointerDownEvent?.nativeEvent;Eo(g,"Last event must exist");let b=m-this.state.selectedLinearElement.pointerOffset.x,v=p-this.state.selectedLinearElement.pointerOffset.y,w=this.state.multiElement?Ee.handlePointerMove(g,this,b,v,this.state.selectedLinearElement):Ee.handlePointDragging(g,this,b,v,this.state.selectedLinearElement);w&&this.setState(w)}},i=!1;if(this.state.selectedLinearElement?.selectedPointsIndices){let m=this.scene.getNonDeletedElementsMap(),p=this.state.selectedLinearElement.selectedPointsIndices.includes(0),u=this.state.selectedLinearElement.selectedPointsIndices.includes(t.points.length-1),E=p?o:t.startBinding&&m.get(t.startBinding.elementId),g=u?o:t.endBinding&&m.get(t.endBinding.elementId),b=E&&dA(E,m),v=g&&dA(g,m);i=!!(b&&v&&E.id!==g.id&&rX(b,v))}let a=this.state.selectedLinearElement?.selectedPointsIndices?.includes(0),s=this.state.selectedLinearElement?.selectedPointsIndices?.includes(t.points.length-1),l=a?"startBinding":s?"endBinding":null,c=a?"endBinding":s?"startBinding":null,d=c&&t[c]?.mode==="inside"&&t[c]?.elementId===o?.id||l&&t[l]?.mode==="inside"&&o?.id===t[l]?.elementId;l&&c&&t[l]?.mode==="inside"&&o?.id!==t[l]?.elementId&&t[c]?.elementId!==t[l]?.elementId&&this.scene.mutateElement(t,{[l]:{...t[l],mode:"orbit"}},{informMutation:!1,isDragging:!0}),!o||this.previousHoveredBindableElement&&o.id!==this.previousHoveredBindableElement.id?(this.bindModeHandler&&(clearTimeout(this.bindModeHandler),this.bindModeHandler=null),this.state.bindMode==="inside"&&Gt(()=>{this.setState({bindMode:"orbit"})}),this.previousHoveredBindableElement=null):!this.bindModeHandler&&(!this.state.newElement||!t.startBinding||i)&&!d&&(this.bindModeHandler=setTimeout(r,qY)),this.previousHoveredBindableElement=o}cacheEmbeddableRef(t,o){o&&this.iFrameRefs.set(t.id,o)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleIframeLikeCenterClick(){if(!this.lastPointerDownEvent||!this.lastPointerUpEvent||this.lastPointerDownEvent.button!==Tn.MAIN||Wo||!AM(this.state.activeTool.type,["laser","selection","lasso"]))return!1;let t=oe(Ce({clientX:this.lastPointerDownEvent.clientX,clientY:this.lastPointerDownEvent.clientY},this.state)),o=oe(Ce({clientX:this.lastPointerUpEvent.clientX,clientY:this.lastPointerUpEvent.clientY},this.state));if(go(t,o)>yM)return!1;let i=this.getElementAtPosition(t[0],t[1]);if(!(i&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<=300&&ue.pointers.size<2&&Ic(i)&&(this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.isIframeLikeElementCenter(i,this.lastPointerUpEvent,o[0],o[1]))))return!1;let s=i;if(this.state.activeEmbeddable?.element===s&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:s,state:"active"},selectedElementIds:{[s.id]:!0},newElement:null,selectionElement:null})},100),_b(s)))return!0;let l=this.getHTMLIFrameElement(s);if(!l?.contentWindow)return!0;if(l.src.includes("youtube")){let c=Kb.get(s.id);switch(c||(Kb.set(s.id,lu.UNSTARTED),l.contentWindow.postMessage(JSON.stringify({event:"listening",id:s.id}),"*")),c){case lu.PLAYING:case lu.BUFFERING:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:l.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}return l.src.includes("player.vimeo.com")&&l.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*"),!0}isIframeLikeElementCenter(t,o,r,i){return t&&!o.altKey&&!o.shiftKey&&!o.metaKey&&!o.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,o=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Uo(a)&&this.embedsValidationStatus.get(a.id)===!0||_b(a));return Pe(EX,{children:i.map(a=>{let{x:s,y:l}=du({sceneX:a.x,sceneY:a.y},this.state),c=GM(a,o,r,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(c&&!d&&this.initializedEmbeds.add(a.id),!(c||d))return null;let p=hu(zY(a.link||"")),u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",E=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover",g=p?.type==="video",b=fc(g?t:1,.75,hX);return Pe("div",{className:pM("excalidraw__embeddable-container",{"is-hovered":E}),style:{transform:c?`translate(${s-this.state.offsetLeft}px, ${l-this.state.offsetTop}px) scale(${t*Kn(this.state.viewpointFlip.horizontal)}, ${t*Kn(this.state.viewpointFlip.vertical)})`:"none",display:c?"block":"none",opacity:VK(a,Ub(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?FY:1),"--embeddable-radius":`${vK(Math.min(a.width,a.height),a)}px`},children:Xb("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?fs.enabled:fs.disabled},children:[E&&Pe("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Pe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:Pe("div",{className:"excalidraw__embeddable__content",style:{width:`${b*100}%`,height:`${b*100}%`,transform:`scale(${1/b})`},children:(Uo(a)?this.props.renderEmbeddable?.(a,this.state):null)??Pe("iframe",{ref:v=>this.cacheEmbeddableRef(a,v),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:o,renderTopLeftUI:r,renderCustomStats:i}=this.props,{elementsMap:a,visibleElements:s,canvasNonce:l,newElementCanvasElement:c}=this.renderer.getRenderableElements({zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElement:this.state.newElement,selectedElements:t,selectedElementsAreBeingDragged:this.state.selectedElementsAreBeingDragged,frameToHighlight:this.state.frameToHighlight});this.visibleElements=s,this.hasRenderableElements=a.size>0;let d=this.scene.getNonDeletedElementsMap(),m="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",p=t[0],u=bt.get(po)?.type==="panel";return Pe("div",{translate:"no",className:pM("excalidraw excalidraw-container notranslate",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.editorInterface.formFactor==="phone","excalidraw--non-interactive":!this.isInteractionEnabled(),"excalidraw--navigation":!this.isInteractionEnabled()&&this.isNavigationEnabled(),"excalidraw--tools":!this.isInteractionEnabled()&&this.isToolSupported(this.state.activeTool.type),"excalidraw--embeds":!this.isInteractionEnabled()&&this.isEmbedsEnabled(),"excalidraw--allow-browser-zoom":!this.isInteractionEnabled()&&this.isBrowserZoomEnabled(),"excalidraw--ui-hidden":!this.isDefaultUIEnabled(),"excalidraw--mobile-toolbar":this.editorInterface.formFactor==="phone"&&this.isDefaultUIEnabled()&&!this.state.viewModeEnabled,"excalidraw--viewport-status-border":!!this.props.viewportStatusFrame?.border,"excalidraw--viewport-status-label":!!this.props.viewportStatusFrame?.label,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":m?fs.disabled:fs.enabled,"--right-sidebar-width":`${mE}px`},ref:this.excalidrawContainerRef,onDrop:this.isInteractionEnabled()?this.handleAppOnDrop:void 0,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally||!this.isInteractionEnabled()?void 0:this.onKeyDown,onPointerEnter:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,onPointerLeave:this.isInteractionEnabled()?this.toggleOverscrollBehavior:void 0,children:Pe(ys.Provider,{value:this.api,children:Pe(yA.Provider,{value:this,children:Pe(wA.Provider,{value:this.props,children:Pe(qb.Provider,{value:this.excalidrawContainerValue,children:Pe(jb.Provider,{value:this.editorInterface,children:Pe(ex.Provider,{value:this.setAppState,children:Pe(Qb.Provider,{value:this.state,children:Xb(Jb.Provider,{value:this.scene.getNonDeletedElements(),children:[Xb(tx.Provider,{value:this.actionManager,children:[Pe(Yk,{canvas:this.canvas,appState:this.state,defaultUIEnabled:this.isDefaultUIEnabled(),zoomUIEnabled:this.isUIControlEnabled("zoom"),scrollBackToContentUIEnabled:this.isUIControlEnabled("scrollBackToContent"),files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,langCode:Jn().code,renderTopLeftUI:r,renderTopRightUI:o,renderCustomStats:i,showExitZenModeBtn:!1,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.state.preferredSelectionTool.type&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,currentUserControls:this.props.currentUserControls,children:this.props.children}),Pe("div",{className:"excalidraw-textEditorContainer"}),Pe("div",{className:"excalidraw-contextMenuContainer"}),Pe("div",{className:"excalidraw-eye-dropper-container"}),Pe(Xk,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail,this.drawShape.trail]}),this.isDefaultUIEnabled()&&Pe(cM,{}),this.isDefaultUIEnabled()&&t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Pe(Lv,{element:p,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},p.id),this.isDefaultUIEnabled()&&this.state.contextMenu&&Pe(gS,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:E=>{this.setState({contextMenu:null},()=>{this.focusContainer(),E?.()})}}),Pe(Tb,{app:this,canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:d,visibleElements:s,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,renderGrid:yr(this),renderLinks:this.isLinksEnabled(),imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowchart.pendingNodes,theme:this.state.theme}}),c&&Pe(oM,{appState:this.state,newElement:c,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:d,renderConfig:{imageCache:this.imageCache,getGifFrameIndex:this.gifPlayback.getFrameIndex,isExporting:!1,imageTransitionDuration:this.props.imageOptions.placeholderTransitionDuration,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null,theme:this.state.theme}}),Pe(Ib,{app:this,containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:s,allElementsMap:d,selectedElements:t,canvasNonce:l,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,editorInterface:this.editorInterface,interactionEnabled:this.isInteractionEnabled(),navigationEnabled:this.isNavigationEnabled(),renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onClick:this.handleCanvasClick,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.props.viewportStatusFrame?.border&&this.editorInterface.formFactor==="phone"&&Pe(xp,{border:this.props.viewportStatusFrame.border}),this.renderFrameNames(),this.isDefaultUIEnabled()&&this.state.activeLockedId&&Pe(mM,{app:this,activeLockedId:this.state.activeLockedId}),this.isDefaultUIEnabled()&&u&&Pe(UT,{app:this})]}),this.renderEmbeddables()]})})})})})})})})})}clearImageShapeCache(t){let o=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{Pi(r)&&o[r.fileId]&&(this.imageCache.delete(r.fileId),ki.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.api=this.createExcalidrawAPI(),this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,fA()||EA()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(r=>{this.history.record(r.delta)}),this.props.onIncrement&&this.store.onStoreIncrementEmitter.on(r=>{this.props.onIncrement?.(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),NY&&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),eK()&&!zK()&&this.setState({errorMessage:Pe(lS,{})});let o={excalidrawAPI:this.api,container:this.excalidrawContainerRef.current};this.editorLifecycleEvents.emit("editor:mount",o),this.props.onMount?.(o),this.props.onExcalidrawAPI?.(this.api)}componentWillUnmount(){this.gifPlayback.stop(),this.api={...this.api,isDestroyed:!0};for(let t of Object.keys(this.api))(t.startsWith("get")||t==="onStateChange"||t==="onEvent")&&typeof this.api[t]=="function"&&(this.api[t]=()=>{throw new Error("ExcalidrawAPI is no longer usable after the editor has been unmounted and will return invalid/empty data. You should check for `ExcalidrawAPI.isDestroyed` before calling get* methods on subscribing to state/event changes.")});this.editorLifecycleEvents.emit("editor:unmount"),this.props.onUnmount?.(),this.props.onExcalidrawAPI?.(null),window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new aA,this.fonts=new Io(this.scene),this.renderer=new Ol(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.viewport.destroy(),this.removeEventListeners(),this.laserTrails.stop(),this.drawShape.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),this.appStateObserver.clear(),this.editorLifecycleEvents.clear(),ki.destroy(),gn.destroy(),clearTimeout(Fr),Ne.clearCache(),Zn.clearCache(),Fr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){if(this.removeEventListeners(),this.onRemoveEventListenersEmitter.once(we(window,Q.MESSAGE,this.onWindowMessage,!1),we(document,Q.POINTER_UP,this.removePointer,{passive:!1}),we(document.fonts,"loadingdone",t=>{let o=t.fontfaces;this.fonts.onLoaded(o)},{passive:!1}),we(window,Q.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.isInteractionEnabled()){this.isNavigationEnabled()&&this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),we(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.handleNavigationModeKeyDown,!1),we(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(document,Q.GESTURE_START,this.onGestureStart,!1),we(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),we(document,Q.GESTURE_END,this.onGestureEnd,!1)),this.isBrowserZoomEnabled()||(this.isNavigationEnabled()||this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.preventBrowserZoomWheel,{passive:!1}),we(this.excalidrawContainerRef.current,Q.GESTURE_START,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.GESTURE_CHANGE,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.GESTURE_END,this.disableEvent,!1)),this.onRemoveEventListenersEmitter.once(we(this.props.handleKeyboardGlobally?document:this.excalidrawContainerRef.current,Q.KEYDOWN,this.preventBrowserZoomKeyDown,!1)));return}this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(we(document,Q.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1}),we(document,Q.COPY,this.onCopy,{passive:!1}),we(document,Q.KEYUP,this.onKeyUp,{passive:!0}),we(document,Q.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),we(document,Q.GESTURE_START,this.onGestureStart,!1),we(document,Q.GESTURE_CHANGE,this.onGestureChange,!1),we(document,Q.GESTURE_END,this.onGestureEnd,!1),we(document,Q.PASTE,this.pasteFromClipboard,{passive:!1}),we(this.excalidrawContainerRef.current,Q.DRAG_OVER,this.disableEvent,!1),we(this.excalidrawContainerRef.current,Q.DROP,this.disableEvent,!1)),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(we(document,Q.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),we(document,Q.CUT,this.onCut,{passive:!1}),we(window,Q.RESIZE,this.onResize,!1),we(window,Q.UNLOAD,this.onUnload,!1),we(window,Q.BLUR,this.onBlur,!1),we(this.excalidrawContainerRef.current,Q.WHEEL,this.handleWheel,{passive:!1})),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(we(GY(this.excalidrawContainerRef.current),Q.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,o){!this._initialized&&!this.state.isLoading&&(this._initialized=!0,this.editorLifecycleEvents.emit("editor:initialize",this.api),this.props.onInitialize?.(this.api)),this.handleInteractionStateChange(t,o),this.handleForcedToolChange(t,o),this.ensureGifPlaybackLoop(),this.appStateObserver.flush(o),this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=(this.sessionExportThemeOverride??this.state.theme)===bc.DARK;this.state.exportWithDarkMode!==a&&this.setState({exportWithDarkMode:a}),!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),(o.zoom.value!==this.state.zoom.value||o.scrollX!==this.state.scrollX||o.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),Object.keys(this.state.selectedElementIds).length&&rn(this.state)&&this.setState({activeTool:on(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&o.theme!==this.state.theme&&this.cursor.applyForTool(),this.state.activeTool.type==="bucketfill"&&o.currentItemBackgroundColor!==this.state.currentItemBackgroundColor&&this.cursor.applyForTool(),o.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),rn(o)&&!rn(this.state)&&this.eraserTrail.endPath(),(o.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&o.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===bc.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(gt)});let s=Object.keys(this.state.selectedElementIds);if(s.length){let c=s.filter(d=>{let m=this.scene.getElement(d);return!m||m.isDeleted});c.length&&this.setState(d=>{let m={...d.selectedElementIds};for(let p of c)delete m[p];return{selectedElementIds:Le(m,d)}})}if(this.state.editingTextElement){let c=this.scene.getElement(this.state.editingTextElement.id);(!c||c.isDeleted)&&this.setState({editingTextElement:null})}let l=this.state.editingTextElement||this.viewport.isAnimating?!1:!this.visibleElements.length&&this.hasRenderableElements;this.state.scrolledOutside!==l&&this.setState({scrolledOutside:l}),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(r,this.state,this.files),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){Sc=!1,Pc=null}async insertClipboardContent(t,o,r){let{x:i,y:a}=Ce({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(o.length===0&&!r&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:r,sceneX:i,sceneY:a});return}if(!r&&t.text){let d=Qm(t.text);if(d.ok){this.setState({openDialog:{name:"charts",data:d.data,rawText:t.text}});return}}if(t.elements){let d=t.programmaticAPI?iX(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:d,files:t.files||null,position:this.editorInterface.formFactor==="desktop"?"cursor":"center",retainSeed:r,preserveFrameChildrenOrder:!0});return}let s=o.map(d=>d.file);if(s.length===0&&t.text&&!r){let d=t.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&s.push(Ou(d))}if(s.length>0){this.isToolSupported("image")?await this.insertImages(s,i,a):this.setState({errorMessage:f("errors.imageToolNotSupported")});return}if(!t.text)return;let l=YY(t.text).split(/\n+/).map(d=>d.trim()).filter(Boolean),c=l.map(d=>IK(d)).filter(d=>Nb(d,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(d)||hu(d)?.type==="video"));if(!r&&c.length>0&&c.length===l.length){let d=[];for(let m of c){let p=d[d.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:cu(m)});u&&d.push(u)}d.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(d.map(m=>[m.id,!0]))}));return}this.addTextFromPaste(t.text,r)}containsImagePaste(t,o,r){if(o.some(a=>Fi(a.file))||!r&&t.mixedContent?.some(a=>a.type==="imageUrl"))return!0;if(r||!t.text)return!1;let i=t.text.trim();return i.startsWith("<svg")&&i.endsWith("</svg>")}shouldInsertImageInViewMode({source:t,files:o,data:r,event:i}){return this.state.viewModeEnabled?this.state.viewModeOnly||this.props.viewModeImageInsertBehavior==="reject"?(this.props.onViewModeImageInsertRejected?.({source:t,files:o,data:r,event:i}),!1):(Gt(()=>{this.setState({viewModeEnabled:!1})}),!0):!0}async addElementsFromMixedContentPaste(t,{isPlainPaste:o,sceneX:r,sceneY:i}){if(!o&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(d=>d.type==="imageUrl").map(d=>d.value),s=await Promise.all(a.map(async d=>{try{return{file:await _x(d)}}catch(m){let p=m.message;return m.cause==="FETCH_ERROR"?p=f("errors.failedToFetchImage"):m.cause==="UNSUPPORTED"&&(p=f("errors.unsupportedFileType")),{errorMessage:p}}})),l=s.filter(d=>!!d.file).map(d=>d.file);await this.insertImages(l,r,i);let c=s.find(d=>!!d.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(s=>s.type==="text");a.length&&this.addTextFromPaste(a.map(s=>s.value).join(`
22
22
 
23
- `),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=Ce({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:_Y,verticalAlign:fM,locked:!1},s=Mb({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=wM(a.fontFamily),[c,,d]=LK(this.state),m=Math.max(Math.min((d-c)*.5,800),200),p=10,u=i,E=o?[t]:t.split(`
24
- `),g=E.reduce((b,v,y)=>{let x=BK(v).trim();if(x.length){let I=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=ZM(x,s,l),C=T.width>m,P=C?RK(x,s,m):x;T=C?ZM(P,s,l):T;let M=r-T.width/2,D=u-T.height/2,_=DM({...a,x:M,y:D,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:I?I.id:null});b.push(_),u+=_.height+p}else E[y-1]?.trim()&&(u+=$M(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:De(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&pA===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),pA=!0))}handleTextWysiwyg(t,{isExistingElement:o=!1,initialCaretSceneCoords:r=null}){let i=this.scene.getElementsMapIncludingDeleted(),a=(s,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(c=>c.id===t.id&&$t(c)?bo(c,{originalText:s,isDeleted:l??c.isDeleted,...mK(c,HM(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=fI({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=cu({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:qe(s=>{a(s,!1),fu(t)&&pu(t,this.scene)}),onSubmit:qe(({viaKeyboard:s,nextOriginalText:l})=>{this.textWysiwygSubmitHandler=null;let c=!l.trim();a(l,c);let d=s&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(c?null:t.id):null;d&&Gt(()=>{this.setState(m=>({selectedElementIds:De({...m.selectedElementIds,[d]:!0},m)}))}),c&&nK(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Gt(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type==="autoshape")&&this.cursor.applyForTool(),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:r,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),a(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getSelectedTextElement(t){let o=this.scene.getSelectedElements(this.state);if(o.length!==1)return null;let r=o[0];return $t(r)?r:t?Fb(r,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(t,o){let r=this.scene.getSelectedElements(this.state);if(r.length!==1||!t||t.id!==r[0].id)return null;let i=r[0];if($t(i))return null;if(!UM(i))return;let a=this.getSelectedTextElement(i),s=this.getTextElementAtPosition(o.x,o.y);if(!(!a||s?.id!==a.id))return i}getTextElementAtPosition(t,o){let r=this.getElementAtPosition(t,o,{includeBoundTextElement:!0});return r&&$t(r)&&!r.isDeleted?r:null}getElementAtPosition(t,o,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,o,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let s=i.length-1;s>-1;s--)if(this.state.selectedElementIds[i[s].id])return i[s]}let a=i[i.length-1];return Tc({point:oe(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,o,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(l=>(r?.includeLockedElements||!l.locked)&&(r?.includeBoundTextElement||!($t(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=Ub(l,a);return c&&!fu(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!Ic(l)?VM({x:t,y:o},c,a):!0}).filter(l=>Ic(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(yM/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&vK([r],this.state,this.editorInterface)&&JK(oe(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||AK(oe(t,o),r,this.scene.getNonDeletedElementsMap())?!0:Tc({point:oe(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Tt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,o){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return BM(i[0],!1)?i[0]:null;let a=null;for(let s=r.length-1;s>=0;--s){if(r[s].isDeleted)continue;let[l,c,d,m]=kM(r[s],this.scene.getNonDeletedElementsMap());if(vc(r[s])&&Tc({point:oe(t,o),element:r[s],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[s])})){a=r[s];break}else if(l<t&&t<d&&c<o&&o<m){if(Tt(r[s]))continue;a=r[s];break}}return BM(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||$t(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=fe.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let s=-1,l=null;Tc({point:oe(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=fe.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=fe.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Zt(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Me.POINTER):this.hitElement(o,r,a)&&(!Zt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE)):this.hitElement(o,r,a)&&(!Zt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),fe.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=oX(a,o,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&this.cursor.set(Me.POINTER)}else this.cursor.set(Me.AUTO)}updateGestureOnPointerDown(t){ue.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ue.pointers.size===2&&(ue.lastCenter=gf(ue.pointers),ue.initialScale=this.state.zoom.value,ue.initialDistance=ff(Array.from(ue.pointers.values())))}initialPointerDownState(t){let o=Ce(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=bs(r),c=r.findIndex(Zt)===0;return{origin:o,withCmdOrCtrl:t[V.CTRL_OR_CMD],originInGrid:Ab(kt(o.x,o.y,t[V.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:kf(kc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,LM(m)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(s+i)/2,y:(l+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(o,r)},drag:{hasOccurred:!1,offset:null,origin:{...o},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,o){if(!(o.scrollbars.isOverEither&&!this.state.multiElement))return!1;bu=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=Fm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=qe(()=>{xs=null,bu=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,r),window.removeEventListener(Q.POINTER_UP,i),r.flush()});return xs=i,window.addEventListener(Q.POINTER_MOVE,r),window.addEventListener(Q.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,o){if(o.length<2)return!1;let r=Math.max(yM/this.state.zoom.value,1),i=wY*2/this.state.zoom.value,[a,s,l,c]=bs(o);return t.x>a-i-r&&t.x<l+i+r&&t.y>s-i-r&&t.y<c+i+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:hK(t)?au.ADAPTIVE_RADIUS:au.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return eK(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){_o({event:t,app:this,selectedElements:o})&&(r||!gn.getReferenceSnapPoints())&&gn.setReferenceSnapPoints(j2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){_o({event:t,app:this,selectedElements:o})&&(r||!gn.getVisibleGaps())&&gn.setVisibleGaps($2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return qe(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return qe(o=>{o.key===V.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return Fm(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Ce(o,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[p,u]=kt(r.x,r.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=fe.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?fe.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=fe.moveFixedSegment(this.state.selectedLinearElement,E,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:g.segmentMidPointHoveredCoords,initialState:g.initialState}});return}let i=this.previousPointerMoveCoords??t.origin;if(this.previousPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=Ab(jK(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(rn(this.state)){this.handleEraser(o,r);return}if(this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y),this.drawShape.handlePointerMove(r))return;let[s,l]=kt(r.x,r.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,o)||this.maybeHandleResize(t,o)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){nX(p,c,r,this.scene,this.state,this.getEffectiveGridSize(),o.altKey),this.setState({selectedLinearElement:{...p,isDragging:!1,selectedPointsIndices:[],initialState:{...p.initialState,lastClickedPoint:-1}}});return}if(fe.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=fe.addMidpoint(this.state.selectedLinearElement,r,this,!o[V.CTRL_OR_CMD],this.scene);if(!u)return;Gt(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(p.initialState.segmentMidpoint.value!==null&&!p.initialState.segmentMidpoint.added)return;if(p.initialState.lastClickedPoint>-1){let u=fe.getElement(p.elementId,c);if(u?.isDeleted)return;if(xo(u)){let g=Rr(oe(r.x,r.y),this.scene.getNonDeletedElements(),c);Ho("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Ho("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),p.initialState.lastClickedPoint===-1)return;let E=fe.handlePointDragging(o,this,r.x,r.y,p);if(E){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(E.suggestedBinding!==this.state.suggestedBinding||!SM(E.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||E.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||E.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==E.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==E.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(E);return}}}}let d=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!m&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(g=>g.locked))return;let E=p.some(g=>Tt(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:WM(p),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(E),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let g={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},b=[...t.originalElements.values()],v=o.shiftKey;if(v){let I=Math.abs(g.x),T=Math.abs(g.y),C=v&&I<T,P=v&&I>T;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&Xn(I)&&I.crop!==null&&t.hit.element===I){let T=I.crop,C=Si(I)&&this.imageCache.get(I.fileId)?.image;if(C&&!(C instanceof Promise)){let P=aX(I),M=dM(r.x-i.x,r.y-i.y);M[0]*=C.naturalWidth/P.width,M[1]*=C.naturalHeight/P.height;let[D,_,k,L,F,K]=kM(I,c),z=Cb(Sb(oe(D,_),oe(F,K),I.angle)),U=Cb(Sb(oe(k,_),oe(F,K),I.angle)),W=Cb(Sb(oe(D,L),oe(F,K),I.angle)),G=uM(mM(U,z)),ie=uM(mM(W,z)),me=dM(pM(M,G),pM(M,ie)),B={...T,x:fc(T.x-me[0]*Math.sign(I.scale[0]),0,C.naturalWidth-T.width),y:fc(T.y-me[1]*Math.sign(I.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(I,{crop:B});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:y,snapLines:x}=q2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||$K(t,p,g,this.scene,y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),o.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),T=t.hit.element,C=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});T&&t.hit.wasAddedToSelection&&!C.find(z=>z.id===T.id)&&C.push(T);let P=new Map(C.map(z=>[z.id,z])),{duplicatedElements:M,duplicateElementsMap:D,elementsWithDuplicates:_,origIdToDuplicateId:k}=_M({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:U})=>({frameId:z.frameId??U.frameId,seed:YY()})});M.forEach(z=>{t.originalElements.set(z.id,LM(z))});let L=_.map(z=>{if(P.has(z.id)){let U=t.originalElements.get(z.id);if(U)return bo(z,{x:U.x,y:U.y})}return z}),F=this.props.onDuplicate?.(L,I),K=qM(F||L,wc(M));Gt(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),U=z&&D.get(z);t.hit.element=U||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,U)=>{let W=k.get(U.id),G=W&&D.get(W);return G&&z.push(G),z},[]),t.drag.origin=Ce(o,this.state),this.setState(z=>({...JM(M,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(K),C.forEach(z=>{Rb(z)&&z.boundElements?.some(U=>U.type==="arrow")&&pu(z,this.scene)}),this.maybeCacheVisibleGaps(o,C,!0),this.maybeCacheReferenceSnapPoints(o,C,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,o.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},{keepSelection:o.shiftKey}),this.lassoTrail.startPath(t.origin.x,t.origin.y,o.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,o)}else if(this.state.activeTool.type==="lasso")!o.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,o.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,E=r.x-p.x,g=r.y-p.y,b=u.length>0&&u[u.length-1];if(!(b&&b[0]===E&&b[1]===g)){let y=p.simulatePressure?p.pressures:[...p.pressures,o.pressure];this.scene.mutateElement(p,{points:[...u,oe(E,g)],pressures:y},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Ht(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;Eo(u.length>1,"Do not create linear elements with less than 2 points");let E=this.state.selectedLinearElement;(!E||E.elementId!==p.id)&&(E=new fe(p,this.scene.getNonDeletedElementsMap())),E&&(E.initialState.lastClickedPoint<0||E.initialState.lastClickedPoint>=u.length)&&(console.warn("Last clicked point is out of bounds. Attempting to fix it."),E={...E,selectedPointsIndices:[u.length-1],initialState:{...E.initialState,prevSelectedPointsIndices:null,lastClickedPoint:u.length-1},hoverPointIndex:u.length-1}),this.setState({newElement:p,...fe.handlePointDragging(o,this,s,l,E)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)fe.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&Re(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Zn({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?hx(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(g=>{let b={...u&&g.selectedElementIds,...E.reduce((v,y)=>(v[y.id]=!0,v),{})};return t.hit.element&&(E.length?delete b[t.hit.element.id]:b[t.hit.element.id]=!0),g=u?g:{...g,selectedGroupIds:{},editingGroupId:null},{...Zn({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Ht(E[0])?new fe(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Uo(E[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,o){if(o.scrollbars.isOverHorizontal){let r=t.clientX,i=r-o.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-i*(kc.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.x=r,!0}if(o.scrollbars.isOverVertical){let r=t.clientY,i=r-o.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-i*(kc.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return qe(o=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(o),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush(),o.type==="pointerup"&&this.state.activeTool.type===Yn.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:s,multiElement:l,activeTool:c,isResizing:d,isRotating:m,isCropping:p}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:yc(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,gn.setReferenceSnapPoints(null),gn.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=Ce({clientX:o.clientX,clientY:o.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(x=>this.state.selectedElementIds[x.id])){let x=this.getElementAtPosition(E.x,E.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),x?.locked?this.setState({activeLockedId:x.groupIds.length>0?x.groupIds.at(-1)||"":x.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(Ho("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let x=r.get(t.hit.element.id);Rb(x)&&x.boundElements?.filter(I=>I.type==="arrow").map(I=>r.get(I.id)).filter(I=>Zt(I)).forEach(I=>{I&&this.scene.mutateElement(I,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(gt);else{let x=fe.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(gt,"ui",{event:o,sceneCoords:E}),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:x,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=fe.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(iX(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding:null}}})):t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(gt,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Ht(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:x}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x.points[x.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(Q.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(Q.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(Q.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(Q.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=Ce(o,this.state),I=i.points,T=x.x-i.x,C=x.y-i.y;T===I[0][0]&&C===I[0][1]&&(C+=1e-4,T+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...I,oe(T,C)],pressures:P}),this.actionManager.executeAction(gt);return}if(Ht(i)&&this.state.activeTool.type!=="autoshape"){let x=Ce(o,this.state),I=go(oe(x.x,x.y),oe(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||I<KY)&&i&&!l)if(this.editorInterface.isTouchScreen){let T=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-T/2,points:[oe(0,0),oe(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(gt)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),Ht(i)&&this.actionManager.executeAction(gt,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:De({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new fe(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if($t(i)){let x=zK(Mb({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<x&&this.scene.mutateElement(i,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&OM(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:jt.NEVER});return}if(Tt(i)){let x=CK(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Gb(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,gK(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Ce(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let I=this.scene.getElement(this.state.selectedLinearElement.elementId);if(I?.frameId){let T=Ub(I,r);T&&I&&(PK(I,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(I,{groupIds:[]}),SK([I],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let I=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:WM(I),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=M=>{if(M.length>0){for(let D of M){let _=D.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(D,{groupIds:D.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(D=>{D.groupIds.length&&Pi(C,D.groupIds[D.groupIds.length-1]).length<2&&this.scene.mutateElement(D,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let M=I.filter(D=>KM(D,C,this.state));this.state.editingGroupId&&P(M),C=Gb(C,M,T)}else if(!T&&this.state.editingGroupId){let M=I.filter(D=>D.frameId&&!KM(D,C,this.state));P(M)}C=YM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&OM(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:jt.NEVER}),t.resize.isResizing){let x=YM(this.scene.getElementsIncludingDeleted(),this.state,this),I=this.scene.getSelectedElements(this.state).filter(Tt);for(let T of I)x=TK(x,Hb(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Ht(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new fe(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!p||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,v=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(rn(this.state)&&b&&v){if(this.eraserTrail.endPath(),go(oe(b.clientX,b.clientY),oe(v.clientX,v.clientY))===0){let I=Ce({clientX:v.clientX,clientY:v.clientY},this.state);this.getElementsAtPosition(I.x,I.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(g&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(o.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[g.id]?VK(this.state,g)?this.setState(x=>{let I={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>Pi(this.scene.getNonDeletedElements(),C)))delete I[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:De(I,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let I={...x.selectedElementIds};delete I[g.id];let T=de(this.scene.getNonDeletedElements(),{selectedElementIds:I});return{...Zn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Ht(T[0])?new fe(T[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let I={...x.selectedElementIds,[g.id]:!0};return delete I[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>Pi(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete I[T.id]}),{...Zn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Uo(g)?"info":!1}}):this.setState(x=>({selectedElementIds:De({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Zn({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Ht(g)&&x.selectedLinearElement?.elementId!==g.id?new fe(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Zt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&DK({point:oe(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:Tt(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Ma):this.setState({selectedElementIds:De({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Me.AUTO);return}let y=this.getSelectedTextEditingContainerAtPosition(g,E);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[V.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&($t(g)&&this.state.selectedElementIds[g.id]&&this.scene.getSelectedElements(this.state).length===1||y)){this.startTextEditing({sceneX:E.x,sceneY:E.y,container:y,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:E});return}if(!this.isToolLocked()&&c.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:De({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Uo(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||Re(this.scene.getNonDeletedElements(),this.state)||!SM(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||p){let x=this.scene.getSelectedElements(this.state).filter(vc);MM(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(gt);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==Yn.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:De({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&jM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:De({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,o,r,i){if(i){let a=i.x+i.width/2,s=i.y+i.height/2,l=Ob(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<PY){let{x:m,y:p}=cu({sceneX:a,sceneY:s},r);return{viewportX:m,viewportY:p,elementCenterX:a,elementCenterY:s}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:o,top:r}=t.getBoundingClientRect();return{offsetLeft:o,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Oi.find(o=>o.code===this.props.langCode)||qn;await Yc(t),this.setAppState({})}},pX=()=>{(uA()||hA())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(fA(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};pX();var xA=$b;import{useEffect as hX,useState as gX}from"react";import{jsx as fX}from"react/jsx-runtime";var yA=e=>{let[n,t]=gX(!0);return hX(()=>{let o=async()=>{await Yc(r),t(!1)},r=Oi.find(i=>i.code===e.langCode)||qn;o()},[e.langCode]),n?fX(vp,{theme:e.theme}):e.children};import EX from"clsx";import{jsx as wA}from"react/jsx-runtime";var vA=({children:e})=>{let{FooterCenterTunnel:n}=it(),t=xe();return wA(n.In,{children:wA("div",{className:EX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},bX=vA;vA.displayName="FooterCenter";import xX from"clsx";import{MQ_MIN_WIDTH_DESKTOP as yX}from"@excalidraw/common";import{jsx as vX,jsxs as IX}from"react/jsx-runtime";var IA=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=xe(),i=t?.formFactor!=="desktop"||r.width<yX;return IX(vn,{...o,className:xX("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?c1:f("labels.share"),r.collaborators.size>0&&vX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},wX=IA;IA.displayName="LiveCollaborationTrigger";import{jsx as Br,jsxs as SA}from"react/jsx-runtime";var TX=()=>Br("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Br("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"})}),SX=()=>SA("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Br("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)"}),Br("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)"}),Br("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)"}),Br("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)"})]}),TA=({style:e,size:n="small",withText:t})=>SA("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[Br(TX,{}),t&&Br(SX,{})]});import{Fragment as kA,jsx as dt,jsxs as nx}from"react/jsx-runtime";var ox=({icon:e,shortcut:n,children:t})=>{let o=Ee();return nx(kA,{children:[dt("div",{className:"welcome-screen-menu-item__icon",children:e}),dt("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&dt("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};ox.displayName="WelcomeScreenMenuItemContent";var Ac=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>dt("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:dt(ox,{icon:t,shortcut:o,children:n})});Ac.displayName="WelcomeScreenMenuItem";var CA=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>dt("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:dt(ox,{icon:t,shortcut:o,children:e})});CA.displayName="WelcomeScreenMenuItemLink";var Cn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=it();return dt(n.In,{children:dt("div",{className:"welcome-screen-center",children:e||nx(kA,{children:[dt(rx,{}),dt(ix,{children:f("welcomeScreen.defaults.center_heading")}),nx(ax,{children:[dt(lx,{}),dt(sx,{})]})]})})})};Cn.displayName="Center";var rx=({children:e})=>dt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||dt(TA,{withText:!0})});rx.displayName="Logo";var ix=({children:e})=>dt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});ix.displayName="Heading";var ax=({children:e})=>dt("div",{className:"welcome-screen-menu",children:e});ax.displayName="Menu";var sx=()=>{let e=at();return dt(Ac,{onSelect:()=>e.executeAction(ei),shortcut:"?",icon:Wi,children:f("helpDialog.title")})};sx.displayName="MenuItemHelp";var lx=()=>{let e=xe(),n=at();return e.viewModeEnabled?null:dt(Ac,{onSelect:()=>n.executeAction(ma),shortcut:et("loadScene"),icon:jc,children:f("buttons.load")})};lx.displayName="MenuItemLoadScene";var PA=({onSelect:e})=>{let{t:n}=Ne();return dt(Ac,{shortcut:null,onSelect:e,icon:qc,children:n("labels.liveCollaboration")})};PA.displayName="MenuItemLiveCollaborationTrigger";Cn.Logo=rx;Cn.Heading=ix;Cn.Menu=ax;Cn.MenuItem=Ac;Cn.MenuItemLink=CA;Cn.MenuItemHelp=sx;Cn.MenuItemLoadScene=lx;Cn.MenuItemLiveCollaborationTrigger=PA;import{jsx as ws,jsxs as cx}from"react/jsx-runtime";var Iu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=it();return ws(n.In,{children:cx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Yx,ws("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};Iu.displayName="MenuHint";var Tu=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=it();return ws(n.In,{children:cx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ws("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),Xx]})})};Tu.displayName="ToolbarHint";var Su=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=it();return ws(n.In,{children:cx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ws("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Kx]})})};Su.displayName="HelpHint";import{Fragment as MA,jsx as Dc,jsxs as PX}from"react/jsx-runtime";var Cu=e=>Dc(MA,{children:e.children||PX(MA,{children:[Dc(Cn,{}),Dc(Iu,{}),Dc(Tu,{}),Dc(Su,{})]})});Cu.displayName="WelcomeScreen";Cu.Center=Cn;Cu.Hints={MenuHint:Iu,ToolbarHint:Tu,HelpHint:Su};var CX=Cu;var kX=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLast||Object.defineProperty(Array.prototype,"findLast",{value:function(e,n){return this.slice().reverse().find((t,o)=>e.call(n,t,this.length-o-1,this))},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,n){for(let t=0;t<this.length;t++)if(e.call(n,this[t],t,this))return t;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,n){let t=this.slice().reverse().findIndex((o,r)=>e.call(n,o,this.length-r-1,this));return t===-1?-1:this.length-t-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toReversed||Object.defineProperty(Array.prototype,"toReversed",{value:function(){return this.slice().reverse()},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toSorted||Object.defineProperty(Array.prototype,"toSorted",{value:function(e){return this.slice().sort(e)},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},AA=kX;import{configureGifWorkerUrl as HYe,getSceneVersion as UYe,hashElementsVersion as WYe,hashString as VYe,getNonDeletedElements as YYe}from"@excalidraw/element";import{getTextFromElements as XYe}from"@excalidraw/element";import{isInvisiblySmallElement as $Ye}from"@excalidraw/element";import MX from"lodash.throttle";import{arrayToMap as AX,isDevEnv as DA,isTestEnv as LA}from"@excalidraw/common";import{orderByFractionalIndex as DX,syncInvalidIndices as _A,validateFractionalIndices as LX}from"@excalidraw/element";var _X=(e,n,t)=>!!(n&&(n.id===e.editingTextElement?.id||n.id===e.resizingElement?.id||n.id===e.newElement?.id||n.version>t.version||n.version===t.version&&n.versionNonce<=t.versionNonce)),RX=MX((e,n,t)=>{if(DA()||LA()||window?.DEBUG_FRACTIONAL_INDICES){let o=_A(e.map(r=>({...r})));LX(o,{shouldThrow:LA()||DA(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),NX=(e,n,t)=>{let o=AX(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=_X(t,l,s);l&&c?(r.push(l),i.add(l.id)):(r.push(s),i.add(s.id))}for(let s of e)i.has(s.id)||(r.push(s),i.add(s.id));let a=DX(r);return RX(a,e,n),_A(a),a};import{isLinearElement as iKe}from"@excalidraw/element";import{FONT_FAMILY as sKe,THEME as lKe,MIME_TYPES as cKe,ROUNDNESS as dKe,DEFAULT_LASER_COLOR as mKe,UserIdleState as pKe,normalizeLink as uKe,sceneCoordsToViewportCoords as hKe,viewportCoordsToSceneCoords as gKe,getFormFactor as fKe,throttleRAF as EKe}from"@excalidraw/common";import{mutateElement as xKe,newElementWith as yKe,bumpVersion as wKe}from"@excalidraw/element";import{CaptureUpdateAction as IKe}from"@excalidraw/element";import{getCommonBounds as LKe,getVisibleSceneBounds as _Ke,convertToExcalidrawElements as RKe}from"@excalidraw/element";import{elementsOverlappingBBox as BKe}from"@excalidraw/element";import{isElementLink as zKe}from"@excalidraw/element";import{setCustomTextMetricsProvider as UKe}from"@excalidraw/element";import{jsx as Lc}from"react/jsx-runtime";AA();var BYe=({children:e})=>{let[n,t]=HX(null);return Lc(ys.Provider,{value:n,children:Lc(vu.Provider,{value:t,children:e})})},WX=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:l,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=qn.code,viewModeEnabled:v,viewModeOnly:y,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:M,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,onPaste:F,viewModeImageInsertBehavior:K,onViewModeImageInsertRejected:z,detectScroll:U=!0,handleKeyboardGlobally:W=!1,autoFocus:G=!1,compressImageFile:ie,generateIdForFile:me,onLinkOpen:B,generateLinkForSelection:Y,onPointerDown:pe,onPointerUp:ae,onScrollChange:be,onUserFollow:ce,userToFollow:Fe,onDuplicate:se,imageContextMenuItems:Le,children:_e,validateEmbeddable:Se,renderEmbeddable:Mt,showDeprecatedFonts:kn,wheelZoomsOnDefault:Mn,strokeColorTopPicks:Ko,backgroundColorTopPicks:ki,renderScrollbars:Mi,viewportStatusFrame:vs,currentUserControls:yo,imageOptions:At,showDropEventDebugAlert:Is}=e,Ai=e.UIOptions?.canvasActions,wo={...e.UIOptions,canvasActions:{...RA.canvasActions,...Ai},tools:{image:e.UIOptions?.tools?.image??!0}};Ai?.export&&(wo.canvasActions.export.saveFileToDisk=Ai.export?.saveFileToDisk??RA.canvasActions.export.saveFileToDisk),wo.canvasActions.toggleTheme===null&&(P==null||r)&&(wo.canvasActions.toggleTheme=!0);let Z={maxFileSizeBytes:At?.maxFileSizeBytes??Pn.maxFileSizeBytes,maxWidthOrHeight:At?.maxWidthOrHeight??Pn.maxWidthOrHeight,gifAutoDecodeMaxFileSizeBytes:At?.gifAutoDecodeMaxFileSizeBytes??Pn.gifAutoDecodeMaxFileSizeBytes,placeholderTransitionDuration:At?.placeholderTransitionDuration??Pn.placeholderTransitionDuration},ke=OX(vu),Dt=GX(l);Dt.current=l;let Ts=FX(Pu=>{ke?.(Pu),Dt.current?.(Pu)},[ke]),_c=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return zX(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),_c)return;let dx=ku=>{typeof ku.scale=="number"&&ku.scale!==1&&ku.preventDefault()};return document.addEventListener("touchmove",dx,{passive:!1}),()=>{document.removeEventListener("touchmove",dx)}},[_c]),Lc(Ox,{store:bt,children:Lc(yA,{langCode:b,theme:P,children:Lc(xA,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:Ts,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:v,viewModeOnly:y,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:M,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,UIOptions:wo,onPaste:F,viewModeImageInsertBehavior:K,onViewModeImageInsertRejected:z,detectScroll:U,handleKeyboardGlobally:W,autoFocus:G,compressImageFile:ie,generateIdForFile:me,onLinkOpen:B,generateLinkForSelection:Y,onPointerDown:pe,onPointerUp:ae,onScrollChange:be,onUserFollow:ce,userToFollow:Fe,onDuplicate:se,imageContextMenuItems:Le,validateEmbeddable:Se,renderEmbeddable:Mt,showDeprecatedFonts:kn,wheelZoomsOnDefault:Mn,strokeColorTopPicks:Ko,backgroundColorTopPicks:ki,renderScrollbars:Mi,viewportStatusFrame:vs,currentUserControls:yo,imageOptions:Z,showDropEventDebugAlert:Is,children:_e})})})},VX=(e,n)=>{if(e.children!==n.children)return!1;let{initialData:t,UIOptions:o={},imageOptions:r,interaction:i,ui:a,activeTool:s,...l}=e,{initialData:c,UIOptions:d={},imageOptions:m,interaction:p,ui:u,activeTool:E,...g}=n;if(!(s===E||s?.type===E?.type&&(s?.type==="custom"?s.customType:null)===(E?.type==="custom"?E.customType:null))||!(i===p||typeof i=="object"&&i!==null&&typeof p=="object"&&p!==null&&!!i.enabled?.links==!!p.enabled?.links&&!!i.enabled?.embeds==!!p.enabled?.embeds&&!!i.enabled?.interactiveContent==!!p.enabled?.interactiveContent&&!!i.enabled?.navigation==!!p.enabled?.navigation&&!!i.enabled?.browserZoom==!!p.enabled?.browserZoom&&!!i.enabled?.tools?.laser==!!p.enabled?.tools?.laser&&!!i.enabled?.tools?.custom==!!p.enabled?.tools?.custom)||!(a===u||typeof a=="object"&&a!==null&&typeof u=="object"&&u!==null&&!!a.enabled?.zoom==!!u.enabled?.zoom&&!!a.enabled?.scrollBackToContent==!!u.enabled?.scrollBackToContent))return!1;let x=Object.keys(o),I=Object.keys(d);if(x.length!==I.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(D=>D==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[D]===d?.canvasActions?.[D]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Pn.maxWidthOrHeight)===(m?.maxWidthOrHeight??Pn.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Pn.maxFileSizeBytes)===(m?.maxFileSizeBytes??Pn.maxFileSizeBytes)&&(r?.gifAutoDecodeMaxFileSizeBytes??Pn.gifAutoDecodeMaxFileSizeBytes)===(m?.gifAutoDecodeMaxFileSizeBytes??Pn.gifAutoDecodeMaxFileSizeBytes)&&(r?.placeholderTransitionDuration??Pn.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Pn.placeholderTransitionDuration);return T&&C&&UX(l,g)},YX=BX.memo(WX,VX);YX.displayName="Excalidraw";function FYe(e){return ra(e,!1)}export{vn as Button,IKe as CaptureUpdateAction,mKe as DEFAULT_LASER_COLOR,Au as DEFAULT_OVERSCROLL,xb as DefaultSidebar,$s as Ellipsify,YX as Excalidraw,ys as ExcalidrawAPIContext,BYe as ExcalidrawAPIProvider,sKe as FONT_FAMILY,Io as Fonts,bX as Footer,wX as LiveCollaborationTrigger,cKe as MIME_TYPES,Ot as MainMenu,dKe as ROUNDNESS,Dr as Sidebar,cc as Stats,lKe as THEME,Lu as UnsupportedImageFileTypeError,pKe as UserIdleState,CX as WelcomeScreen,wYe as applyDarkModeFilter,wKe as bumpVersion,sg as captureDragEventData,HYe as configureGifWorkerUrl,RKe as convertToExcalidrawElements,qn as defaultLang,BKe as elementsOverlappingBBox,kP as exportToBlob,Hp as exportToCanvas,bH as exportToClipboard,MP as exportToSvg,LKe as getCommonBounds,Uc as getDataURL,fKe as getFormFactor,YYe as getNonDeletedElements,UYe as getSceneVersion,vYe as getStrokeWidthByKey,XYe as getTextFromElements,_Ke as getVisibleSceneBounds,WYe as hashElementsVersion,VYe as hashString,zKe as isElementLink,$Ye as isInvisiblySmallElement,iKe as isLinearElement,Ha as isSpreadsheetValidForChartType,Oi as languages,As as loadFromBlob,xKe as mutateElement,yKe as newElementWith,uKe as normalizeLink,mr as parseDataTransferEvent,im as parseDragImageMetadata,NX as reconcileElements,Uf as renderSpreadsheet,Ri as restoreAppState,BA as restoreElement,zr as restoreElements,hKe as sceneCoordsToViewportCoords,Ps as serializeAsJSON,UKe as setCustomTextMetricsProvider,EKe as throttleRAF,Qm as tryParseSpreadsheet,Ee as useEditorInterface,Fd as useExcalidrawAPI,FYe as useExcalidrawStateValue,Ne as useI18n,K6 as useOnExcalidrawStateChange,mt as useStylesPanelMode,gKe as viewportCoordsToSceneCoords,Fr as zoomToFitBounds};
23
+ `),o)}}addTextFromPaste(t,o=!1){let{x:r,y:i}=Ce({clientX:this.viewport.lastPosition.x,clientY:this.viewport.lastPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.getCurrentItemStrokeWidth("text"),strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:BY,verticalAlign:xM,locked:!1},s=Mb({fontSize:a.fontSize,fontFamily:a.fontFamily}),l=TM(a.fontFamily),[c,,d]=BK(this.state),m=Math.max(Math.min((d-c)*.5,800),200),p=10,u=i,E=o?[t]:t.split(`
24
+ `),g=E.reduce((b,v,w)=>{let x=GK(v).trim();if(x.length){let I=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),T=qM(x,s,l),C=T.width>m,P=C?OK(x,s,m):x;T=C?qM(P,s,l):T;let M=r-T.width/2,D=u-T.height/2,_=RM({...a,x:M,y:D,text:P,originalText:x,lineHeight:l,autoResize:!C,frameId:I?I.id:null});b.push(_),u+=_.height+p}else E[w-1]?.trim()&&(u+=JM(a.fontSize,l)+p);return b},[]);g.length!==0&&(this.insertNewElements(g),this.store.scheduleCapture(),this.setState({selectedElementIds:Le(Object.fromEntries(g.map(b=>[b.id,!0])),this.state)}),!o&&g.length>1&&gA===!1&&this.editorInterface.formFactor!=="phone"&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:N("CtrlOrCmd+Shift+V")}),duration:5e3}),gA=!0))}handleTextWysiwyg(t,{isExistingElement:o=!1,initialCaretSceneCoords:r=null}){let i=this.scene.getElementsMapIncludingDeleted(),a=(s,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(c=>c.id===t.id&&$t(c)?bo(c,{originalText:s,isDeleted:l??c.isDeleted,...gK(c,VM(c,i),i,s)}):c)])};this.textWysiwygSubmitHandler=EI({canvas:this.canvas,getViewportCoords:(s,l)=>{let{x:c,y:d}=du({sceneX:s,sceneY:l},this.state);return[c-this.state.offsetLeft,d-this.state.offsetTop]},onChange:qe(s=>{a(s,!1),Eu(t)&&uu(t,this.scene)}),onSubmit:qe(({viaKeyboard:s,nextOriginalText:l})=>{this.textWysiwygSubmitHandler=null;let c=!l.trim();a(l,c);let d=s&&!this.isToolLocked()&&this.state.activeTool.type!=="autoshape"?t.containerId||(c?null:t.id):null;d&&Gt(()=>{this.setState(m=>({selectedElementIds:Le({...m.selectedElementIds,[d]:!0},m)}))}),c&&aK(this.scene.getNonDeletedElements(),[t]),(!c||o)&&this.store.scheduleCapture(),Gt(()=>{this.setState({newElement:null,editingTextElement:null})}),(this.isToolLocked()||this.state.activeTool.type==="autoshape")&&this.cursor.applyForTool(),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,initialCaretSceneCoords:r,autoSelect:!this.editorInterface.isTouchScreen}),this.deselectElements(),a(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Le({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getSelectedTextElement(t){let o=this.scene.getSelectedElements(this.state);if(o.length!==1)return null;let r=o[0];return $t(r)?r:t?Fb(r,this.scene.getNonDeletedElementsMap()):null}getSelectedTextEditingContainerAtPosition(t,o){let r=this.scene.getSelectedElements(this.state);if(r.length!==1||!t||t.id!==r[0].id)return null;let i=r[0];if($t(i))return null;if(!YM(i))return;let a=this.getSelectedTextElement(i),s=this.getTextElementAtPosition(o.x,o.y);if(!(!a||s?.id!==a.id))return i}getTextElementAtPosition(t,o){let r=this.getElementAtPosition(t,o,{includeBoundTextElement:!0});return r&&$t(r)&&!r.isDeleted?r:null}getElementAtPosition(t,o,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,o,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let s=i.length-1;s>-1;s--)if(this.state.selectedElementIds[i[s].id])return i[s]}let a=i[i.length-1];return Tc({point:oe(t,o),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:St(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,o,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(l=>(r?.includeLockedElements||!l.locked)&&(r?.includeBoundTextElement||!($t(l)&&l.containerId)))).filter(l=>this.hitElement(t,o,l)).filter(l=>{let c=Ub(l,a);return c&&!Eu(c)&&console.error("[NONDELETED][INVARIANT] Containing frame is deleted"),c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip&&!Ic(l)?XM({x:t,y:o},c,a):!0}).filter(l=>Ic(l)?(i.push(l),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(IM/this.state.zoom.value))}hitElement(t,o,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&CK([r],this.state,this.editorInterface)&&nX(oe(t,o),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||RK(oe(t,o),r,this.scene.getNonDeletedElementsMap())?!0:Tc({point:oe(t,o),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:St(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,o){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return zM(i[0],!1)?i[0]:null;let a=null;for(let s=r.length-1;s>=0;--s){if(r[s].isDeleted)continue;let[l,c,d,m]=DM(r[s],this.scene.getNonDeletedElementsMap());if(vc(r[s])&&Tc({point:oe(t,o),element:r[s],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[s])})){a=r[s];break}else if(l<t&&t<d&&c<o&&o<m){if(St(r[s]))continue;a=r[s];break}}return zM(a,!1)?a:null}isEditingTextContent(){return!!this.state.editingTextElement||$t(this.state.newElement)}handleHoverSelectedLinearElement(t,o,r){let i=this.scene.getNonDeletedElementsMap(),a=Ee.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let s=-1,l=null;Tc({point:oe(o,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(s=Ee.getPointIndexUnderCursor(a,i,this.state.zoom,o,r),l=Ee.getSegmentMidpointHitCoords(t,{x:o,y:r},this.state,this.scene.getNonDeletedElementsMap()),(Zt(a)?s===0||s===a.points.length-1:s>=0)||l?this.cursor.set(Me.POINTER):this.hitElement(o,r,a)&&(!Zt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE)):this.hitElement(o,r,a)&&(!Zt(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&this.cursor.set(Me.MOVE),this.state.selectedLinearElement.hoverPointIndex!==s&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:s}}),Ee.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,l)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:l}});let c=null,d=a;(d.startBinding||d.endBinding)&&(c=sX(a,o,r,this.scene,this.state)),this.state.selectedLinearElement.hoveredFocusPointBinding!==c&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1,hoveredFocusPointBinding:c}}),c&&this.cursor.set(Me.POINTER)}else this.cursor.set(Me.AUTO)}updateGestureOnPointerDown(t){ue.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ue.pointers.size===2&&(ue.lastCenter=ff(ue.pointers),ue.initialScale=this.state.zoom.value,ue.initialDistance=Ef(Array.from(ue.pointers.values())))}initialPointerDownState(t){let o=Ce(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,s,l]=bs(r),c=r.findIndex(Zt)===0;return{origin:o,withCmdOrCtrl:t[V.CTRL_OR_CMD],originInGrid:Ab(kt(o.x,o.y,t[V.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:Mf(kc,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...o},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,NM(m)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(s+i)/2,y:(l+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(o,r)},drag:{hasOccurred:!1,offset:null,origin:{...o},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,o){if(!(o.scrollbars.isOverEither&&!this.state.multiElement))return!1;xu=!0,o.lastCoords.x=t.clientX,o.lastCoords.y=t.clientY;let r=Fm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,o)}),i=qe(()=>{xs=null,xu=!1,this.cursor.applyForTool(),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(Q.POINTER_MOVE,r),window.removeEventListener(Q.POINTER_UP,i),r.flush()});return xs=i,window.addEventListener(Q.POINTER_MOVE,r),window.addEventListener(Q.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,o){if(o.length<2)return!1;let r=Math.max(IM/this.state.zoom.value,1),i=TY*2/this.state.zoom.value,[a,s,l,c]=bs(o);return t.x>a-i-r&&t.x<l+i+r&&t.y>s-i-r&&t.y<c+i+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:bK(t)?su.ADAPTIVE_RADIUS:su.PROPORTIONAL_RADIUS}:null}getCurrentItemStrokeWidth(t){return rK(t,this.state.currentItemStrokeWidthKey)}maybeCacheReferenceSnapPoints(t,o,r=!1){_o({event:t,app:this,selectedElements:o})&&(r||!gn.getReferenceSnapPoints())&&gn.setReferenceSnapPoints(q2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,o,r=!1){_o({event:t,app:this,selectedElements:o})&&(r||!gn.getVisibleGaps())&&gn.setVisibleGaps(j2(this.scene.getNonDeletedElements(),o,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return qe(o=>{this.maybeHandleResize(t,o)||this.maybeDragNewGenericElement(t,o)})}onKeyUpFromPointerDownHandler(t){return qe(o=>{o.key===V.ALT&&o.preventDefault(),!this.maybeHandleResize(t,o)&&this.maybeDragNewGenericElement(t,o)})}onPointerMoveFromPointerDownHandler(t){return Fm(o=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Ce(o,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.initialState.segmentMidpoint.index){let[p,u]=kt(r.x,r.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),E=this.state.selectedLinearElement.initialState.segmentMidpoint.index;if(E<0){let b=Ee.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());E=b?Ee.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,b,this.scene.getNonDeletedElementsMap()):-1}let g=Ee.moveFixedSegment(this.state.selectedLinearElement,E,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!0,segmentMidPointHoveredCoords:g.segmentMidPointHoveredCoords,initialState:g.initialState}});return}let i=this.previousPointerMoveCoords??t.origin;if(this.previousPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=Ab(eX(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(o.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(o,t))return;if(rn(this.state)){this.handleEraser(o,r);return}if(this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y),this.drawShape.handlePointerMove(r))return;let[s,l]=kt(r.x,r.y,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,o)||this.maybeHandleResize(t,o)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(p.draggedFocusPointBinding){aX(p,c,r,this.scene,this.state,this.getEffectiveGridSize(),o.altKey),this.setState({selectedLinearElement:{...p,isDragging:!1,selectedPointsIndices:[],initialState:{...p.initialState,lastClickedPoint:-1}}});return}if(Ee.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let u=Ee.addMidpoint(this.state.selectedLinearElement,r,this,!o[V.CTRL_OR_CMD],this.scene);if(!u)return;Gt(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,initialState:u.pointerDownState,selectedPointsIndices:u.selectedPointsIndices,segmentMidPointHoveredCoords:null,isDragging:!0}})});return}else{if(p.initialState.segmentMidpoint.value!==null&&!p.initialState.segmentMidpoint.added)return;if(p.initialState.lastClickedPoint>-1){let u=Ee.getElement(p.elementId,c);if(u?.isDeleted)return;if(xo(u)){let g=Br(oe(r.x,r.y),this.scene.getNonDeletedElements(),c);Ho("COMPLEX_BINDINGS")&&this.handleDelayedBindModeChange(u,g)}if(o.altKey&&!this.state.selectedLinearElement?.initialState?.arrowStartIsInside&&Ho("COMPLEX_BINDINGS")&&this.handleSkipBindMode(),p.initialState.lastClickedPoint===-1)return;let E=Ee.handlePointDragging(o,this,r.x,r.y,p);if(E){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,(E.suggestedBinding!==this.state.suggestedBinding||!kM(E.selectedLinearElement?.selectedPointsIndices??[],this.state.selectedLinearElement?.selectedPointsIndices??[])||E.selectedLinearElement?.hoverPointIndex!==this.state.selectedLinearElement?.hoverPointIndex||E.selectedLinearElement?.customLineAngle!==this.state.selectedLinearElement?.customLineAngle||this.state.selectedLinearElement.isDragging!==E.selectedLinearElement?.isDragging||this.state.selectedLinearElement?.initialState?.altFocusPoint!==E.selectedLinearElement?.initialState?.altFocusPoint)&&this.setState(E);return}}}}let d=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.selectedLinearElement?.isEditing&&o.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((d||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!m&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(g=>g.locked))return;let E=p.some(g=>St(g))?null:this.getTopLayerFrameAtSceneCoords(r,{currentFrameId:KM(p),excludeElementIds:this.state.selectedElementIds});if(this.updateFrameToHighlight(E),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.editorInterface.formFactor!=="desktop"&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let g={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},b=[...t.originalElements.values()],v=o.shiftKey;if(v){let I=Math.abs(g.x),T=Math.abs(g.y),C=v&&I<T,P=v&&I>T;C&&(g.x=0),P&&(g.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&Xn(I)&&I.crop!==null&&t.hit.element===I){let T=I.crop,C=Pi(I)&&this.imageCache.get(I.fileId)?.image;if(C&&!(C instanceof Promise)){let P=dX(I),M=uM(r.x-i.x,r.y-i.y);M[0]*=C.naturalWidth/P.width,M[1]*=C.naturalHeight/P.height;let[D,_,k,L,F,K]=DM(I,c),z=Cb(Sb(oe(D,_),oe(F,K),I.angle)),U=Cb(Sb(oe(k,_),oe(F,K),I.angle)),W=Cb(Sb(oe(D,L),oe(F,K),I.angle)),G=fM(hM(U,z)),ie=fM(hM(W,z)),me=uM(gM(M,G),gM(M,ie)),B={...T,x:fc(T.x-me[0]*Math.sign(I.scale[0]),0,C.naturalWidth-T.width),y:fc(T.y-me[1]*Math.sign(I.scale[1]),0,C.naturalHeight-T.height)};this.scene.mutateElement(I,{crop:B});return}}}this.maybeCacheVisibleGaps(o,p),this.maybeCacheReferenceSnapPoints(o,p);let{snapOffset:w,snapLines:x}=J2(b,g,this,o,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:x}),this.state.editingFrame||QK(t,p,g,this.scene,w,o[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),o.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),T=t.hit.element,C=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});T&&t.hit.wasAddedToSelection&&!C.find(z=>z.id===T.id)&&C.push(T);let P=new Map(C.map(z=>[z.id,z])),{duplicatedElements:M,duplicateElementsMap:D,elementsWithDuplicates:_,origIdToDuplicateId:k}=BM({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:P,overrides:({duplicateElement:z,origElement:U})=>({frameId:z.frameId??U.frameId,seed:$Y()})});M.forEach(z=>{t.originalElements.set(z.id,NM(z))});let L=_.map(z=>{if(P.has(z.id)){let U=t.originalElements.get(z.id);if(U)return bo(z,{x:U.x,y:U.y})}return z}),F=this.props.onDuplicate?.(L,I),K=eA(F||L,wc(M));Gt(()=>{if(t.hit.element){let z=k.get(t.hit.element.id),U=z&&D.get(z);t.hit.element=U||null}t.hit.allHitElements=t.hit.allHitElements.reduce((z,U)=>{let W=k.get(U.id),G=W&&D.get(W);return G&&z.push(G),z},[]),t.drag.origin=Ce(o,this.state),this.setState(z=>({...tA(M,this.scene.getNonDeletedElements(),z)})),this.scene.replaceAllElements(K),C.forEach(z=>{Rb(z)&&z.boundElements?.some(U=>U.type==="arrow")&&uu(z,this.scene)}),this.maybeCacheVisibleGaps(o,C,!0),this.maybeCacheReferenceSnapPoints(o,C,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,o.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},{keepSelection:o.shiftKey}),this.lassoTrail.startPath(t.origin.x,t.origin.y,o.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,o)}else if(this.state.activeTool.type==="lasso")!o.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,o.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,E=r.x-p.x,g=r.y-p.y,b=u.length>0&&u[u.length-1];if(!(b&&b[0]===E&&b[1]===g)){let w=p.simulatePressure?p.pressures:[...p.pressures,o.pressure];this.scene.mutateElement(p,{points:[...u,oe(E,g)],pressures:w},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Ht(p)&&!p.isDeleted){t.drag.hasOccurred=!0;let u=p.points;Eo(u.length>1,"Do not create linear elements with less than 2 points");let E=this.state.selectedLinearElement;(!E||E.elementId!==p.id)&&(E=new Ee(p,this.scene.getNonDeletedElementsMap())),E&&(E.initialState.lastClickedPoint<0||E.initialState.lastClickedPoint>=u.length)&&(console.warn("Last clicked point is out of bounds. Attempting to fix it."),E={...E,selectedPointsIndices:[u.length-1],initialState:{...E.initialState,prevSelectedPointsIndices:null,lastClickedPoint:u.length-1},hoverPointIndex:u.length-1}),this.setState({newElement:p,...Ee.handlePointDragging(o,this,s,l,E)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,o,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Ee.handleBoxSelection(o,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!o.shiftKey&&Ne(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(g=>Zn({...g,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),g,this)):u=!1);let E=this.state.selectionElement?hx(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1,this.state.boxSelectionMode):[];this.setState(g=>{let b={...u&&g.selectedElementIds,...E.reduce((v,w)=>(v[w.id]=!0,v),{})};return t.hit.element&&(E.length?delete b[t.hit.element.id]:b[t.hit.element.id]=!0),g=u?g:{...g,selectedGroupIds:{},editingGroupId:null},{...Zn({editingGroupId:g.editingGroupId,selectedElementIds:b},this.scene.getNonDeletedElements(),g,this),selectedLinearElement:E.length===1&&Ht(E[0])?new Ee(E[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:E.length===1&&(E[0].link||Uo(E[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,o){if(o.scrollbars.isOverHorizontal){let r=t.clientX,i=r-o.lastCoords.x;return this.viewport.translate({scrollX:this.state.scrollX-i*(kc.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.x=r,!0}if(o.scrollbars.isOverVertical){let r=t.clientY,i=r-o.lastCoords.y;return this.viewport.translate({scrollY:this.state.scrollY-i*(kc.vertical?.deltaMultiplier||1)/this.state.zoom.value}),o.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return qe(o=>{let r=this.scene.getNonDeletedElementsMap();this.removePointer(o),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush(),o.type==="pointerup"&&this.state.activeTool.type===Yn.bucketfill?this.bucketFill.handlePointerUp():this.bucketFill.cancel();let{newElement:i,resizingElement:a,croppingElementId:s,multiElement:l,activeTool:c,isResizing:d,isRotating:m,isCropping:p}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:yc(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.previousPointerMoveCoords=null,gn.setReferenceSnapPoints(null),gn.setVisibleGaps(null),this.savePointer(o.clientX,o.clientY,"up");let u=t.hit.allHitElements,E=Ce({clientX:o.clientX,clientY:o.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!u.some(x=>this.state.selectedElementIds[x.id])){let x=this.getElementAtPosition(E.x,E.y,{includeLockedElements:!0});this.isEditingTextContent()||this.store.scheduleCapture(),x?.locked?this.setState({activeLockedId:x.groupIds.length>0?x.groupIds.at(-1)||"":x.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});if(Ho("COMPLEX_BINDINGS")&&this.resetDelayedBindMode(),this.setState({selectedElementsAreBeingDragged:!1,bindMode:"orbit"}),t.drag.hasOccurred&&t.hit?.element?.id){let x=r.get(t.hit.element.id);Rb(x)&&x.boundElements?.filter(I=>I.type==="arrow").map(I=>r.get(I.id)).filter(I=>Zt(I)).forEach(I=>{I&&this.scene.mutateElement(I,{})})}if(this.state.selectedLinearElement?.isEditing&&!this.state.newElement&&this.state.selectedLinearElement.draggedFocusPointBinding===null)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId&&this.state.selectedLinearElement.draggedFocusPointBinding===null)this.actionManager.executeAction(gt);else{let x=Ee.handlePointerUp(o,this.state.selectedLinearElement,this.state,this.scene);this.actionManager.executeAction(gt,"ui",{event:o,sceneCoords:E}),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:x,suggestedBinding:null})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=Ee.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(this.state.selectedLinearElement.draggedFocusPointBinding?(cX(this.state.selectedLinearElement,this.scene),this.setState({selectedLinearElement:{...this.state.selectedLinearElement,draggedFocusPointBinding:null,initialState:{...this.state.selectedLinearElement.initialState,arrowOtherEndpointInitialBinding:null}}})):t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&(this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isDragging:!1}}),this.actionManager.executeAction(gt,"ui",{event:o,sceneCoords:E})),this.state.newElement&&this.state.multiElement&&Ht(this.state.newElement)&&this.state.selectedLinearElement){let{multiElement:x}=this.state;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,lastCommittedPoint:x.points[x.points.length-1]}})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(Q.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(Q.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(Q.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(Q.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(c,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,o),i?.type==="freedraw"){let x=Ce(o,this.state),I=i.points,T=x.x-i.x,C=x.y-i.y;T===I[0][0]&&C===I[0][1]&&(C+=1e-4,T+=1e-4);let P=i.simulatePressure?[]:[...i.pressures,o.pressure];this.scene.mutateElement(i,{points:[...I,oe(T,C)],pressures:P}),this.actionManager.executeAction(gt);return}if(Ht(i)&&this.state.activeTool.type!=="autoshape"){let x=Ce(o,this.state),I=go(oe(x.x,x.y),oe(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||I<jY)&&i&&!l)if(this.editorInterface.isTouchScreen){let T=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(i,{x:i.x-T/2,points:[oe(0,0),oe(T,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(gt)}else this.setState({multiElement:i,newElement:i});else t.drag.hasOccurred&&!l&&(this.store.scheduleCapture(),Ht(i)&&this.actionManager.executeAction(gt,"ui",{event:o,sceneCoords:E}),this.setState({suggestedBinding:null}),this.isToolLocked()?this.setState({newElement:null}):this.setState(T=>({newElement:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type}),selectedElementIds:Le({...T.selectedElementIds,[i.id]:!0},T),selectedLinearElement:new Ee(i,this.scene.getNonDeletedElementsMap())}),()=>this.cursor.reset()),this.scene.triggerUpdate());return}if($t(i)){let x=WK(Mb({fontSize:i.fontSize,fontFamily:i.fontFamily}),i.lineHeight);i.width<x&&this.scene.mutateElement(i,{autoResize:!0}),this.cursor.reset(),this.handleTextWysiwyg(i,{isExistingElement:!0})}if(c.type!=="selection"&&i&&HM(i)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),appState:{newElement:null},captureUpdate:jt.NEVER});return}if(St(i)){let x=AK(this.scene.getElementsIncludingDeleted(),i,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Gb(this.scene.getElementsMapIncludingDeleted(),x,i))}if(i&&(this.scene.mutateElement(i,xK(i),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Ce(o,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let I=this.scene.getElement(this.state.selectedLinearElement.elementId);if(I?.frameId){let T=Ub(I,r);T&&I&&(DK(I,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(I,{groupIds:[]}),MK([I],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let I=this.scene.getSelectedElements(this.state),T=this.getTopLayerFrameAtSceneCoords(x,{currentFrameId:KM(I),excludeElementIds:this.state.selectedElementIds}),C=this.scene.getElementsMapIncludingDeleted(),P=M=>{if(M.length>0){for(let D of M){let _=D.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(D,{groupIds:D.groupIds.slice(0,_)},{informMutation:!1,isDragging:!1})}C.forEach(D=>{D.groupIds.length&&Mi(C,D.groupIds[D.groupIds.length-1]).length<2&&this.scene.mutateElement(D,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(T&&!this.state.selectedElementIds[T.id]){let M=I.filter(D=>$M(D,C,this.state));this.state.editingGroupId&&P(M),C=Gb(C,M,T)}else if(!T&&this.state.editingGroupId){let M=I.filter(D=>D.frameId&&!$M(D,C,this.state));P(M)}C=ZM(C,this.state,this),this.scene.replaceAllElements(C)}}if(a&&this.store.scheduleCapture(),a&&HM(a)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==a.id),captureUpdate:jt.NEVER}),t.resize.isResizing){let x=ZM(this.scene.getElementsIncludingDeleted(),this.state,this),I=this.scene.getSelectedElements(this.state).filter(St);for(let T of I)x=kK(x,Hb(this.scene.getElementsIncludingDeleted(),T,this.state,r),T);this.scene.replaceAllElements(x)}let g=t.hit.element;this.state.selectedLinearElement?.elementId!==g?.id&&Ht(g)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Ee(g,this.scene.getNonDeletedElementsMap())}),(!s||s&&(!g&&!p||g&&g.id!==s))&&this.finishImageCropping();let b=this.lastPointerDownEvent,v=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(rn(this.state)&&b&&v){if(this.eraserTrail.endPath(),go(oe(b.clientX,b.clientY),oe(v.clientX,v.clientY))===0){let I=Ce({clientX:v.clientX,clientY:v.clientY},this.state);this.getElementsAtPosition(I.x,I.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(g&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(o.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[g.id]?ZK(this.state,g)?this.setState(x=>{let I={...x.selectedElementIds};for(let T of g.groupIds.flatMap(C=>Mi(this.scene.getNonDeletedElements(),C)))delete I[T.id];return{selectedGroupIds:{...x.selectedElementIds,...g.groupIds.map(T=>({[T]:!1})).reduce((T,C)=>({...T,...C}),{})},selectedElementIds:Le(I,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let I={...x.selectedElementIds};delete I[g.id];let T=de(this.scene.getNonDeletedElements(),{selectedElementIds:I});return{...Zn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:T.length===1&&Ht(T[0])?new Ee(T[0],this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}}):g.frameId&&this.state.selectedElementIds[g.frameId]?this.setState(x=>{let I={...x.selectedElementIds,[g.id]:!0};return delete I[g.frameId],(this.scene.getElement(g.frameId)?.groupIds??[]).flatMap(T=>Mi(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete I[T.id]}),{...Zn({editingGroupId:x.editingGroupId,selectedElementIds:I},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:g.link||Uo(g)?"info":!1}}):this.setState(x=>({selectedElementIds:Le({...x.selectedElementIds,[g.id]:!0},x)})):this.setState(x=>({...Zn({editingGroupId:x.editingGroupId,selectedElementIds:{[g.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:Ht(g)&&x.selectedLinearElement?.elementId!==g.id?new Ee(g,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(g&&Zt(g))&&!t.drag.hasOccurred&&!this.state.isResizing&&(g&&NK({point:oe(t.origin.x,t.origin.y),element:g,elementsMap:r,threshold:this.getElementHitThreshold(g),frameNameBound:St(g)?this.frameNameBoundsCache.get(g):null},r)||!g&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Ma):this.setState({selectedElementIds:Le({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),this.cursor.set(Me.AUTO);return}let w=this.getSelectedTextEditingContainerAtPosition(g,E);if(c.type===this.state.preferredSelectionTool.type&&!this.state.editingTextElement&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&!o.shiftKey&&!o[V.CTRL_OR_CMD]&&!o.altKey&&o.pointerType!=="touch"&&g&&($t(g)&&this.state.selectedElementIds[g.id]&&this.scene.getSelectedElements(this.state).length===1||w)){this.startTextEditing({sceneX:E.x,sceneY:E.y,container:w,initialCaretSceneCoords:this.lastPointerUpIsDoubleClick?void 0:E});return}if(!this.isToolLocked()&&c.type!=="freedraw"&&i&&this.setState(x=>({selectedElementIds:Le({...x.selectedElementIds,[i.id]:!0},x),showHyperlinkPopup:Uo(i)&&!i.link?"editor":x.showHyperlinkPopup})),!this.isEditingTextContent()&&(c.type!=="selection"||Ne(this.scene.getNonDeletedElements(),this.state)||!kM(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||p){let x=this.scene.getSelectedElements(this.state).filter(vc);LM(x,this.scene,this.state)}if(c.type==="laser"){this.laserTrails.endPath();return}if(c.type==="autoshape"){this.actionManager.executeAction(gt);return}!this.isToolLocked()&&c.type!=="freedraw"&&c.type!==Yn.bucketfill&&(c.type!=="lasso"||c.type==="lasso"&&c.fromSelection)?this.setState({newElement:null,suggestedBinding:null,activeTool:on(this.state,{type:this.state.preferredSelectionTool.type})},()=>this.cursor.reset()):this.setState({newElement:null,suggestedBinding:null})})}clearSelection(t){this.setState(o=>({selectedElementIds:Le({},o),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:o.editingGroupId&&t!=null&&QM(t,o.editingGroupId)?o.editingGroupId:null})),this.setState({selectedElementIds:Le({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds,selectedLinearElement:null})}getTextWysiwygSnappedToCenterPosition(t,o,r,i){if(i){let a=i.x+i.width/2,s=i.y+i.height/2,l=Ob(i,this.scene.getNonDeletedElementsMap());if(l&&(a=l.x,s=l.y),Math.hypot(t-a,o-s)<AY){let{x:m,y:p}=du({sceneX:a,sceneY:s},r);return{viewportX:m,viewportY:p,elementCenterX:a,elementCenterY:s}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:o,top:r}=t.getBoundingClientRect();return{offsetLeft:o,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=Gi.find(o=>o.code===this.props.langCode)||qn;await Yc(t),this.setAppState({})}},fX=()=>{(fA()||EA())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(xA(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};fX();var vA=$b;import{useEffect as bX,useState as xX}from"react";import{jsx as yX}from"react/jsx-runtime";var IA=e=>{let[n,t]=xX(!0);return bX(()=>{let o=async()=>{await Yc(r),t(!1)},r=Gi.find(i=>i.code===e.langCode)||qn;o()},[e.langCode]),n?yX(vp,{theme:e.theme}):e.children};import wX from"clsx";import{jsx as TA}from"react/jsx-runtime";var SA=({children:e})=>{let{FooterCenterTunnel:n}=it(),t=ye();return TA(n.In,{children:TA("div",{className:wX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},vX=SA;SA.displayName="FooterCenter";import IX from"clsx";import{MQ_MIN_WIDTH_DESKTOP as TX}from"@excalidraw/common";import{jsx as CX,jsxs as PX}from"react/jsx-runtime";var CA=({isCollaborating:e,onSelect:n,editorInterface:t,...o})=>{let r=ye(),i=t?.formFactor!=="desktop"||r.width<TX;return PX(vn,{...o,className:IX("collab-button",{active:e}),type:"button",onSelect:n,style:{position:"relative",width:i?void 0:"auto"},title:f("labels.liveCollaboration"),children:[i?c1:f("labels.share"),r.collaborators.size>0&&CX("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},SX=CA;CA.displayName="LiveCollaborationTrigger";import{jsx as Or,jsxs as kA}from"react/jsx-runtime";var kX=()=>Or("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Or("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"})}),MX=()=>kA("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Or("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)"}),Or("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)"}),Or("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)"}),Or("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)"})]}),PA=({style:e,size:n="small",withText:t})=>kA("div",{className:`ExcalidrawLogo is-${n}`,style:e,children:[Or(kX,{}),t&&Or(MX,{})]});import{Fragment as DA,jsx as dt,jsxs as nx}from"react/jsx-runtime";var ox=({icon:e,shortcut:n,children:t})=>{let o=fe();return nx(DA,{children:[dt("div",{className:"welcome-screen-menu-item__icon",children:e}),dt("div",{className:"welcome-screen-menu-item__text",children:t}),n&&o.formFactor!=="phone"&&dt("div",{className:"welcome-screen-menu-item__shortcut",children:n})]})};ox.displayName="WelcomeScreenMenuItemContent";var Ac=({onSelect:e,children:n,icon:t,shortcut:o,className:r="",...i})=>dt("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:dt(ox,{icon:t,shortcut:o,children:n})});Ac.displayName="WelcomeScreenMenuItem";var MA=({children:e,href:n,icon:t,shortcut:o,className:r="",...i})=>dt("a",{...i,className:`welcome-screen-menu-item ${r}`,href:n,target:"_blank",rel:"noopener",children:dt(ox,{icon:t,shortcut:o,children:e})});MA.displayName="WelcomeScreenMenuItemLink";var Cn=({children:e})=>{let{WelcomeScreenCenterTunnel:n}=it();return dt(n.In,{children:dt("div",{className:"welcome-screen-center",children:e||nx(DA,{children:[dt(rx,{}),dt(ix,{children:f("welcomeScreen.defaults.center_heading")}),nx(ax,{children:[dt(lx,{}),dt(sx,{})]})]})})})};Cn.displayName="Center";var rx=({children:e})=>dt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||dt(PA,{withText:!0})});rx.displayName="Logo";var ix=({children:e})=>dt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});ix.displayName="Heading";var ax=({children:e})=>dt("div",{className:"welcome-screen-menu",children:e});ax.displayName="Menu";var sx=()=>{let e=at();return dt(Ac,{onSelect:()=>e.executeAction(ni),shortcut:"?",icon:Yi,children:f("helpDialog.title")})};sx.displayName="MenuItemHelp";var lx=()=>{let e=ye(),n=at();return e.viewModeEnabled?null:dt(Ac,{onSelect:()=>n.executeAction(ma),shortcut:Je("loadScene"),icon:jc,children:f("buttons.load")})};lx.displayName="MenuItemLoadScene";var AA=({onSelect:e})=>{let{t:n}=Ae();return dt(Ac,{shortcut:null,onSelect:e,icon:qc,children:n("labels.liveCollaboration")})};AA.displayName="MenuItemLiveCollaborationTrigger";Cn.Logo=rx;Cn.Heading=ix;Cn.Menu=ax;Cn.MenuItem=Ac;Cn.MenuItemLink=MA;Cn.MenuItemHelp=sx;Cn.MenuItemLoadScene=lx;Cn.MenuItemLiveCollaborationTrigger=AA;import{jsx as ws,jsxs as cx}from"react/jsx-runtime";var Tu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:n}=it();return ws(n.In,{children:cx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Yx,ws("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};Tu.displayName="MenuHint";var Su=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:n}=it();return ws(n.In,{children:cx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ws("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),Xx]})})};Su.displayName="ToolbarHint";var Cu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:n}=it();return ws(n.In,{children:cx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ws("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Kx]})})};Cu.displayName="HelpHint";import{Fragment as LA,jsx as Dc,jsxs as DX}from"react/jsx-runtime";var Pu=e=>Dc(LA,{children:e.children||DX(LA,{children:[Dc(Cn,{}),Dc(Tu,{}),Dc(Su,{}),Dc(Cu,{})]})});Pu.displayName="WelcomeScreen";Pu.Center=Cn;Pu.Hints={MenuHint:Tu,ToolbarHint:Su,HelpHint:Cu};var AX=Pu;var LX=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLast||Object.defineProperty(Array.prototype,"findLast",{value:function(e,n){return this.slice().reverse().find((t,o)=>e.call(n,t,this.length-o-1,this))},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e,n){for(let t=0;t<this.length;t++)if(e.call(n,this[t],t,this))return t;return-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.findLastIndex||Object.defineProperty(Array.prototype,"findLastIndex",{value:function(e,n){let t=this.slice().reverse().findIndex((o,r)=>e.call(n,o,this.length-r-1,this));return t===-1?-1:this.length-t-1},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toReversed||Object.defineProperty(Array.prototype,"toReversed",{value:function(){return this.slice().reverse()},writable:!0,enumerable:!1,configurable:!0}),Array.prototype.toSorted||Object.defineProperty(Array.prototype,"toSorted",{value:function(e){return this.slice().sort(e)},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},_A=LX;import{configureGifWorkerUrl as KYe,getSceneVersion as XYe,hashElementsVersion as ZYe,hashString as $Ye,getNonDeletedElements as jYe}from"@excalidraw/element";import{getTextFromElements as JYe}from"@excalidraw/element";import{isInvisiblySmallElement as eKe}from"@excalidraw/element";import _X from"lodash.throttle";import{arrayToMap as RX,isDevEnv as RA,isTestEnv as NA}from"@excalidraw/common";import{orderByFractionalIndex as NX,syncInvalidIndices as BA,validateFractionalIndices as BX}from"@excalidraw/element";var FX=(e,n,t)=>!!(n&&(n.id===e.editingTextElement?.id||n.id===e.resizingElement?.id||n.id===e.newElement?.id||n.version>t.version||n.version===t.version&&n.versionNonce<=t.versionNonce)),OX=_X((e,n,t)=>{if(RA()||NA()||window?.DEBUG_FRACTIONAL_INDICES){let o=BA(e.map(r=>({...r})));BX(o,{shouldThrow:NA()||RA(),includeBoundTextValidation:!0,reconciliationContext:{localElements:n,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),zX=(e,n,t)=>{let o=RX(e),r=[],i=new Set;for(let s of n)if(!i.has(s.id)){let l=o.get(s.id),c=FX(t,l,s);l&&c?(r.push(l),i.add(l.id)):(r.push(s),i.add(s.id))}for(let s of e)i.has(s.id)||(r.push(s),i.add(s.id));let a=NX(r);return OX(a,e,n),BA(a),a};import{isLinearElement as dKe}from"@excalidraw/element";import{FONT_FAMILY as pKe,THEME as uKe,MIME_TYPES as hKe,ROUNDNESS as gKe,DEFAULT_LASER_COLOR as fKe,UserIdleState as EKe,normalizeLink as bKe,sceneCoordsToViewportCoords as xKe,viewportCoordsToSceneCoords as yKe,getFormFactor as wKe,throttleRAF as vKe}from"@excalidraw/common";import{mutateElement as TKe,newElementWith as SKe,bumpVersion as CKe}from"@excalidraw/element";import{CaptureUpdateAction as kKe}from"@excalidraw/element";import{getCommonBounds as FKe,getVisibleSceneBounds as OKe,convertToExcalidrawElements as zKe}from"@excalidraw/element";import{elementsOverlappingBBox as HKe}from"@excalidraw/element";import{isElementLink as VKe}from"@excalidraw/element";import{setCustomTextMetricsProvider as XKe}from"@excalidraw/element";import{jsx as Lc}from"react/jsx-runtime";_A();var HYe=({children:e})=>{let[n,t]=YX(null);return Lc(ys.Provider,{value:n,children:Lc(Iu.Provider,{value:t,children:e})})},XX=e=>{let{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:l,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p=!1,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b=qn.code,viewModeEnabled:v,viewModeOnly:w,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:M,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,onPaste:F,viewModeImageInsertBehavior:K,onViewModeImageInsertRejected:z,detectScroll:U=!0,handleKeyboardGlobally:W=!1,autoFocus:G=!1,compressImageFile:ie,generateIdForFile:me,onLinkOpen:B,generateLinkForSelection:Y,onPointerDown:pe,onPointerUp:ae,onScrollChange:xe,onUserFollow:ce,userToFollow:Oe,onDuplicate:se,imageContextMenuItems:_e,children:Re,validateEmbeddable:Se,renderEmbeddable:Mt,showDeprecatedFonts:kn,wheelZoomsOnDefault:Mn,strokeColorTopPicks:Ko,backgroundColorTopPicks:Ai,renderScrollbars:Di,viewportStatusFrame:vs,currentUserControls:yo,imageOptions:At,showDropEventDebugAlert:Is}=e,Li=e.UIOptions?.canvasActions,wo={...e.UIOptions,canvasActions:{...FA.canvasActions,...Li},tools:{image:e.UIOptions?.tools?.image??!0}};Li?.export&&(wo.canvasActions.export.saveFileToDisk=Li.export?.saveFileToDisk??FA.canvasActions.export.saveFileToDisk),wo.canvasActions.toggleTheme===null&&(P==null||r)&&(wo.canvasActions.toggleTheme=!0);let Z={maxFileSizeBytes:At?.maxFileSizeBytes??Pn.maxFileSizeBytes,maxWidthOrHeight:At?.maxWidthOrHeight??Pn.maxWidthOrHeight,gifAutoDecodeMaxFileSizeBytes:At?.gifAutoDecodeMaxFileSizeBytes??Pn.gifAutoDecodeMaxFileSizeBytes,placeholderTransitionDuration:At?.placeholderTransitionDuration??Pn.placeholderTransitionDuration},ke=UX(Iu),Dt=VX(l);Dt.current=l;let Ts=HX(ku=>{ke?.(ku),Dt.current?.(ku)},[ke]),_c=typeof x=="object"&&x!==null&&x.enabled?.browserZoom===!0&&x.enabled?.navigation!==!0;return WX(()=>{if((async()=>{await import("canvas-roundrect-polyfill")})(),_c)return;let dx=Mu=>{typeof Mu.scale=="number"&&Mu.scale!==1&&Mu.preventDefault()};return document.addEventListener("touchmove",dx,{passive:!1}),()=>{document.removeEventListener("touchmove",dx)}},[_c]),Lc(Ox,{store:bt,children:Lc(IA,{langCode:b,theme:P,children:Lc(vA,{onExport:n,className:t,onChange:o,onThemeChange:r,onIncrement:i,initialData:a,initialState:s,onExcalidrawAPI:Ts,onMount:c,onUnmount:d,onInitialize:m,isCollaborating:p,onPointerUpdate:u,renderTopLeftUI:E,renderTopRightUI:g,langCode:b,viewModeEnabled:v,viewModeOnly:w,interaction:x,ui:I,activeTool:T,gridModeEnabled:C,theme:P,renderCustomizations:M,name:D,renderCustomStats:_,editorPreferences:k,onEditorPreferencesChange:L,UIOptions:wo,onPaste:F,viewModeImageInsertBehavior:K,onViewModeImageInsertRejected:z,detectScroll:U,handleKeyboardGlobally:W,autoFocus:G,compressImageFile:ie,generateIdForFile:me,onLinkOpen:B,generateLinkForSelection:Y,onPointerDown:pe,onPointerUp:ae,onScrollChange:xe,onUserFollow:ce,userToFollow:Oe,onDuplicate:se,imageContextMenuItems:_e,validateEmbeddable:Se,renderEmbeddable:Mt,showDeprecatedFonts:kn,wheelZoomsOnDefault:Mn,strokeColorTopPicks:Ko,backgroundColorTopPicks:Ai,renderScrollbars:Di,viewportStatusFrame:vs,currentUserControls:yo,imageOptions:Z,showDropEventDebugAlert:Is,children:Re})})})},ZX=(e,n)=>{if(e.children!==n.children)return!1;let{initialData:t,UIOptions:o={},imageOptions:r,interaction:i,ui:a,activeTool:s,...l}=e,{initialData:c,UIOptions:d={},imageOptions:m,interaction:p,ui:u,activeTool:E,...g}=n;if(!(s===E||s?.type===E?.type&&(s?.type==="custom"?s.customType:null)===(E?.type==="custom"?E.customType:null))||!(i===p||typeof i=="object"&&i!==null&&typeof p=="object"&&p!==null&&!!i.enabled?.links==!!p.enabled?.links&&!!i.enabled?.embeds==!!p.enabled?.embeds&&!!i.enabled?.interactiveContent==!!p.enabled?.interactiveContent&&!!i.enabled?.navigation==!!p.enabled?.navigation&&!!i.enabled?.browserZoom==!!p.enabled?.browserZoom&&!!i.enabled?.tools?.laser==!!p.enabled?.tools?.laser&&!!i.enabled?.tools?.custom==!!p.enabled?.tools?.custom)||!(a===u||typeof a=="object"&&a!==null&&typeof u=="object"&&u!==null&&!!a.enabled?.zoom==!!u.enabled?.zoom&&!!a.enabled?.scrollBackToContent==!!u.enabled?.scrollBackToContent))return!1;let x=Object.keys(o),I=Object.keys(d);if(x.length!==I.length)return!1;let T=x.every(P=>P==="getFormFactor"?!0:P==="canvasActions"?Object.keys(o.canvasActions).every(D=>D==="export"&&o?.canvasActions?.export&&d?.canvasActions?.export?o.canvasActions.export.saveFileToDisk===d.canvasActions.export.saveFileToDisk:o?.canvasActions?.[D]===d?.canvasActions?.[D]):o[P]===d[P]),C=(r?.maxWidthOrHeight??Pn.maxWidthOrHeight)===(m?.maxWidthOrHeight??Pn.maxWidthOrHeight)&&(r?.maxFileSizeBytes??Pn.maxFileSizeBytes)===(m?.maxFileSizeBytes??Pn.maxFileSizeBytes)&&(r?.gifAutoDecodeMaxFileSizeBytes??Pn.gifAutoDecodeMaxFileSizeBytes)===(m?.gifAutoDecodeMaxFileSizeBytes??Pn.gifAutoDecodeMaxFileSizeBytes)&&(r?.placeholderTransitionDuration??Pn.placeholderTransitionDuration)===(m?.placeholderTransitionDuration??Pn.placeholderTransitionDuration);return T&&C&&KX(l,g)},$X=GX.memo(XX,ZX);$X.displayName="Excalidraw";function UYe(e){return aa(e,!1)}export{vn as Button,kKe as CaptureUpdateAction,fKe as DEFAULT_LASER_COLOR,Du as DEFAULT_OVERSCROLL,xb as DefaultSidebar,$s as Ellipsify,$X as Excalidraw,ys as ExcalidrawAPIContext,HYe as ExcalidrawAPIProvider,pKe as FONT_FAMILY,Io as Fonts,vX as Footer,SX as LiveCollaborationTrigger,hKe as MIME_TYPES,Ot as MainMenu,gKe as ROUNDNESS,_r as Sidebar,cc as Stats,uKe as THEME,_u as UnsupportedImageFileTypeError,EKe as UserIdleState,AX as WelcomeScreen,CYe as applyDarkModeFilter,CKe as bumpVersion,lg as captureDragEventData,KYe as configureGifWorkerUrl,zKe as convertToExcalidrawElements,qn as defaultLang,HKe as elementsOverlappingBBox,DP as exportToBlob,Up as exportToCanvas,wH as exportToClipboard,LP as exportToSvg,FKe as getCommonBounds,Uc as getDataURL,wKe as getFormFactor,jYe as getNonDeletedElements,XYe as getSceneVersion,PYe as getStrokeWidthByKey,JYe as getTextFromElements,OKe as getVisibleSceneBounds,ZYe as hashElementsVersion,$Ye as hashString,VKe as isElementLink,eKe as isInvisiblySmallElement,dKe as isLinearElement,Ha as isSpreadsheetValidForChartType,Gi as languages,As as loadFromBlob,TKe as mutateElement,SKe as newElementWith,bKe as normalizeLink,ur as parseDataTransferEvent,im as parseDragImageMetadata,zX as reconcileElements,Wf as renderSpreadsheet,Bi as restoreAppState,zA as restoreElement,Hr as restoreElements,xKe as sceneCoordsToViewportCoords,Ps as serializeAsJSON,XKe as setCustomTextMetricsProvider,vKe as throttleRAF,Qm as tryParseSpreadsheet,fe as useEditorInterface,Fd as useExcalidrawAPI,UYe as useExcalidrawStateValue,Ae as useI18n,$6 as useOnExcalidrawStateChange,mt as useStylesPanelMode,yKe as viewportCoordsToSceneCoords,zr as zoomToFitBounds};