@haoxin-web/excalidraw 1.0.23 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,40 +1,40 @@
1
- import{$ as G1,A as Vm,B as L1,C as P1,D as A1,E as as,F as ha,G as ls,H as ss,I as _1,J as D1,K as ga,L as R1,M as N1,N as B1,O as F1,P as cs,Q as Nn,R as O1,S as HC,T as Xm,U as GC,V as Bn,W as fa,Y as z1,_ as H1,a as C1,aa as ds,b as en,ba as U1,c as Io,ca as Km,d as S1,da as Zm,e as we,ea as ms,f as k1,fa as W1,g as J,ga as $m,h as rs,ha as Go,i as cr,ia as Y1,j as zm,ja as jm,k as Hm,ka as V1,l as _n,la as X1,m as Gm,ma as ps,n as Dn,na as qm,o as M1,oa as K1,p as Um,pa as Z1,q as dr,qa as $1,r as mr,ra as us,s as St,t as Ho,u as Rn,v as ns,w as Wm,x as ua,y as is,z as Ym}from"./chunk-TG36IG4W.js";import{a as T}from"./chunk-GANJJ4PJ.js";import{J as Om}from"./chunk-LUHP3LHA.js";import{c as I1}from"./chunk-Z3N5DIM6.js";import{b as v1,c as T1,d as I}from"./chunk-SRAX5OIU.js";import UU,{useEffect as WU}from"react";import{DEFAULT_UI_OPTIONS as _C,isShallowEqual as YU}from"@haoxin-web/excalidraw-common";import m5 from"clsx";import xH from"lodash.throttle";import zo,{useContext as Jr}from"react";import{flushSync as aa}from"react-dom";import EH from"roughjs/bin/rough";import{nanoid as yH}from"nanoid";import{clamp as p5,pointFrom as le,pointDistance as Kr,vector as u5,pointRotateRads as kf,vectorScale as wH,vectorFromPoint as Mf,vectorSubtract as h5,vectorDot as g5,vectorNormalize as f5}from"@haoxin-web/excalidraw-math";import{COLOR_PALETTE as vH,CODES as b5,shouldResizeFromCenter as x5,shouldMaintainAspectRatio as Ol,shouldRotateWithDiscreteAngle as Lf,isArrowKey as Im,KEYS as V,APP_NAME as TH,CURSOR_TYPE as Be,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as IH,DEFAULT_VERTICAL_ALIGN as E5,DRAGGING_THRESHOLD as CH,ELEMENT_SHIFT_TRANSLATE_AMOUNT as SH,ELEMENT_TRANSLATE_AMOUNT as y5,EVENT as oe,FRAME_STYLE as Zr,IMAGE_MIME_TYPES as kH,IMAGE_RENDER_TIMEOUT as MH,isBrave as LH,LINE_CONFIRM_THRESHOLD as Pf,MAX_ALLOWED_FILE_BYTES as w5,MIME_TYPES as ir,MQ_MAX_HEIGHT_LANDSCAPE as PH,MQ_MAX_WIDTH_LANDSCAPE as AH,MQ_MAX_WIDTH_PORTRAIT as _H,MQ_RIGHT_SIDEBAR_MIN_WIDTH as DH,POINTER_BUTTON as Sn,ROUNDNESS as Cm,SCROLL_TIMEOUT as RH,TAP_TWICE_TIMEOUT as NH,TEXT_TO_CENTER_SNAP_THRESHOLD as BH,THEME as Sm,THEME_FILTER as FH,TOUCH_CTX_MENU_TIMEOUT as OH,VERTICAL_ALIGN as zH,YOUTUBE_STATES as km,ZOOM_STEP as HH,POINTER_EVENTS as la,TOOL_TYPE as bt,isIOS as GH,supportsResizeObserver as v5,DEFAULT_COLLISION_THRESHOLD as T5,DEFAULT_TEXT_ALIGN as UH,ARROW_TYPE as $r,DEFAULT_REDUCED_GLOBAL_ALPHA as WH,isSafari as YH,isLocalLink as VH,normalizeLink as Af,toValidURL as XH,getGridPoint as st,getLineHeight as I5,debounce as C5,distance as sa,getFontString as _f,getNearestScrollableContainer as KH,isInputLike as S5,isToolIcon as ZH,isWritableElement as zl,sceneCoordsToViewportCoords as Mm,tupleToCoors as Df,viewportCoordsToSceneCoords as We,wrapEvent as $H,updateObject as Rf,updateActiveTool as ar,getShortcutKey as jH,isTransparent as qH,easeToValuesRAF as JH,muteFSAbortError as QH,isTestEnv as r1,isDevEnv as dC,easeOut as eG,updateStable as Hl,addEventListener as Fe,normalizeEOL as tG,getDateTime as k5,isShallowEqual as oG,arrayToMap as Lm,randomInteger as rG,CLASSES as nG,Emitter as kn,isMobile as iG,MINIMUM_ARROW_SIZE as M5,DOUBLE_TAP_POSITION_THRESHOLD as aG}from"@haoxin-web/excalidraw-common";import{getObservedAppState as lG,getCommonBounds as ca,maybeSuggestBindingsForLinearElementAtCoords as L5,getElementAbsoluteCoords as P5,bindOrUnbindLinearElements as A5,fixBindingsAfterDeletion as sG,getHoveredElementForBinding as Nf,isBindingEnabled as Bf,shouldEnableBindingForPointerEvent as cG,updateBoundElements as Ff,getSuggestedBindingsForArrows as Of,LinearElementEditor as Le,newElementWith as jr,newFrameElement as dG,newFreeDrawElement as mG,newEmbeddableElement as _5,newMagicFrameElement as D5,newIframeElement as pG,newArrowElement as uG,newElement as hG,newImageElement as gG,newLinearElement as fG,newTextElement as R5,refreshTextDimensions as bG,deepCopyElement as N5,duplicateElements as B5,hasBoundTextElement as F5,isArrowElement as zf,isBindingElement as Hf,isBindingElementType as O5,isBoundToContainer as Gf,isFrameLikeElement as Rt,isImageElement as Mn,isEmbeddableElement as lr,isInitializedImageElement as Gl,isLinearElement as ro,isLinearElementType as xG,isUsingAdaptiveRadius as EG,isIframeElement as da,isIframeLikeElement as Ul,isMagicFrameElement as Uf,isTextBindableContainer as z5,isElbowArrow as je,isFlowchartNodeElement as yG,isBindableElement as wG,isTextElement as vo,getLockedLinearCursorAlignSize as H5,getNormalizedDimensions as vG,isElementCompletelyInViewport as Wf,isElementInViewport as G5,isInvisiblySmallElement as U5,getCornerRadius as TG,isPathALoop as W5,createSrcDoc as Y5,embeddableURLValidator as Yf,maybeParseEmbedSrc as IG,getEmbedLink as Pm,getInitializedImageElements as CG,normalizeSVG as V5,updateImageCache as SG,getBoundTextElement as Vf,getContainerCenter as Xf,getContainerElement as X5,isValidTextContainer as kG,redrawTextBoundingBox as MG,shouldShowBoundingBox as LG,getFrameChildren as Kf,isCursorInFrame as K5,addElementsToFrame as Zf,replaceAllElementsInFrame as PG,removeElementsFromFrame as AG,getElementsInResizingFrame as $f,getElementsInNewFrame as _G,getContainingFrame as jf,elementOverlapsWithFrame as DG,updateFrameMembershipOfSelectedElements as Z5,isElementInFrame as $5,getFrameLikeTitle as RG,getElementsOverlappingFrame as NG,filterElementsEligibleAsFrameChildren as BG,hitElementBoundText as FG,hitElementBoundingBoxOnly as OG,hitElementItself as Wl,getVisibleSceneBounds as zG,FlowChartCreator as HG,FlowChartNavigator as GG,getLinkDirectionFromKey as j5,cropElement as UG,wrapText as WG,isElementLink as qf,parseElementLinkFromURL as YG,isMeasureTextSupported as VG,normalizeText as XG,measureText as q5,getLineHeightInPx as KG,getApproxMinLineWidth as ZG,getApproxMinLineHeight as $G,getMinTextElementWidth as jG,ShapeCache as Yl,getRenderOpacity as qG,editGroupForSelectedElement as JG,getElementsInGroup as Ln,getSelectedGroupIdForElement as QG,getSelectedGroupIds as eU,isElementInGroup as J5,isSelectedViaGroup as tU,selectGroupsForSelectedElements as no,syncInvalidIndices as mC,syncMovedIndices as Q5,excludeElementsInFramesFromSelection as oU,getSelectionStateForElements as rU,makeNextSelectedElementIds as ve,getResizeOffsetXY as nU,getResizeArrowDirection as iU,transformElements as aU,getCursorForResizingElement as eC,getElementWithTransformHandleType as tC,getTransformHandleTypeFromCoords as oC,dragNewElement as rC,dragSelectedElements as lU,getDragOffsetXY as sU,isNonDeletedElement as nC,Scene as iC,Store as cU,CaptureUpdateAction as Ct,hitElementBoundingBox as dU,isLineElement as Jf,isSimpleArrow as mU,StoreDelta as aC,positionElementsOnGrid as lC}from"@haoxin-web/excalidraw-element";import{KEYS as wp,updateActiveTool as tS}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as vp}from"@haoxin-web/excalidraw-element";import{fixBindingsAfterDeletion as oS}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as F0}from"@haoxin-web/excalidraw-element";import{newElementWith as Ks}from"@haoxin-web/excalidraw-element";import{getContainerElement as O0}from"@haoxin-web/excalidraw-element";import{isBoundToContainer as Vs,isElbowArrow as rS,isFrameLikeElement as nS}from"@haoxin-web/excalidraw-element";import{getFrameChildren as iS}from"@haoxin-web/excalidraw-element";import{getElementsInGroup as Tp,selectGroupsForSelectedElements as aS}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as Xs}from"@haoxin-web/excalidraw-element";import{isDevEnv as VC}from"@haoxin-web/excalidraw-common";import{atom as he,createStore as UC}from"jotai";import{createIsolation as WC}from"jotai-scope";var j1=WC();var{useAtom:ce,useSetAtom:pr,useAtomValue:hs,useStore:jU}=j1,q1=j1.Provider,Ve=UC();var YC=v1({"./locales/ar-SA.json":()=>import("./locales/ar-SA-G6X2FPQ2.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-76LH7QW2.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-XCXSNQG7.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-2XOGV67Q.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-6MX7JW3Y.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-2BRQDIVT.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5WZEPLOC.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-XR44H4JA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-BZB4AONW.js"),"./locales/en.json":()=>import("./locales/en-45K2M6JH.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-U4NZUMDT.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-A7QVB2H4.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-HGAKTJCU.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-Z5N7JZ37.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-RHASNOE6.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-HMX3MZ6V.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-6SHJWFNN.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-IWLTKZ5I.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-A5ZG7DT2.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-SAP4L64H.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-JPQ66NNP.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-DBVTYXUO.js"),"./locales/kaa.json":()=>import("./locales/kaa-6HZHGXH3.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-ZGHBKWFO.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-P5N5QNE5.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-HSX4SM5Z.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-MTYHY66A.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-6OUDTVRD.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-XHIRWOB4.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-5QDEKY6T.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-CRQNXWMA.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-5M5IBNSE.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-T6EIAALU.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-IS3SIHDZ.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-6E72VCQL.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-POXYY2M6.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-N4M65BXN.js"),"./locales/percentages.json":()=>import("./locales/percentages-BXMCSKIN.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-T2D74RX3.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5N22H2LF.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-UZXXM6DQ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-JPDTUUEW.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-B4JR7IUQ.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-N5RQ5JYF.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-C5VTKIMK.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-NN7IZMDC.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XGPEYMSR.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-2NMHFXQM.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HPSO5L25.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-DEFEU3FU.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-QMV73CPH.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-M7AON7JQ.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-WHMBMDLP.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-E62DVLB3.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-RAJ6MFWO.js")});var XC=85,Co={code:"en",label:"English"},On=[Co,...[{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=>I1[e.code]>=XC).sort((e,o)=>e.label>o.label?1:-1)],fs="__test__";VC()&&On.unshift({code:fs,label:"test language"},{code:`${fs}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Fn=Co,gs={},bs=async e=>{if(Fn=e,document.documentElement.dir=Fn.rtl?"rtl":"ltr",document.documentElement.lang=Fn.code,e.code.startsWith(fs))gs={};else try{gs=await YC(`./locales/${Fn.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),gs=Om}Ve.set(Q1,e.code)},Uo=()=>Fn,J1=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},h=(e,o,t)=>{if(Fn.code.startsWith(fs))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=J1(gs,r)||J1(Om,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)n=n.replace(`{{${i}}}`,String(o[i]));return n},Q1=he(Co.code),Ye=()=>{let e=hs(Q1);return{t:h,langCode:e}};import KC from"clsx";import ZC from"open-color";import nt from"react";import{THEME as $C}from"@haoxin-web/excalidraw-common";import{Fragment as Ee,jsx as g,jsxs as D}from"react/jsx-runtime";var lo=e=>"var(--icon-fill-color)",eb=e=>e===$C.LIGHT?ZC.white:"#1e1e1e",A=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:i,...a}=typeof o=="number"?{width:o}:o;return g("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:KC({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?g("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},re={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},pW=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:3,y:8,width:18,height:4,rx:1}),g("line",{x1:12,y1:8,x2:12,y2:21}),g("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),g("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),zn=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),g("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),g("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),H),tb=A(D("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),H),ob=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"1"}),g("circle",{cx:"12",cy:"19",r:"1"}),g("circle",{cx:"12",cy:"5",r:"1"})]}),H),rb=A(D("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),g("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),g("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),H),Jm=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M6.5 9.5l3.5 -3"}),g("path",{d:"M14 5.5l3 1.5"}),g("path",{d:"M18.5 10l-2.5 7"}),g("path",{d:"M13.5 17.5l-7 -5"})]}),H),tn=A(D("g",{children:[g("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"}),g("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"}),g("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:g("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"})}),g("g",{mask:"url(#UnlockedIcon)",children:g("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"})})]}),re),Hn=A(D("g",{strokeWidth:"1.25",children:[g("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"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),g("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"})]}),re),nb=A(g("g",{fill:"currentColor",children:g("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}),ib=A(D(Ee,{children:[g("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"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),g("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"}),ab=A(D(Ee,{children:[g("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"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),g("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"}),lb=A(D(Ee,{children:[g("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"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),g("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"}),uW=A(g("g",{fill:"currentColor",children:g("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"}),ba=A(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),xs=A(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[g("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"}),g("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),So=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),H),ur=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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),hr=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"})]}),H),gr=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87L13.637 3.59a1.914 1.914 0 0 0 -3.274 0z"})]}),H),fr=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3.5l2.472 4.81 5.313.773-3.843 3.746.907 5.292L12 15.9 7.151 18.12l.907-5.292L4.215 9.083l5.313-.773L12 3.5z"})]}),H),Es=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 6h12a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h-6l-4 3v-3h-2a3 3 0 0 1 -3 -3v-5a3 3 0 0 1 3 -3z"})]}),H),ys=A(D("g",{fill:"none",stroke:"currentColor",children:[g("path",{d:"M6 8 L6 16 L18 16 L18 18 L22 12 L18 6 L18 8 L6 8 Z",strokeWidth:"1.5",fill:"none"}),g("path",{d:"M7 8.5 L7 15.5 L17 15.5 L17 17 L21 12 L17 7 L17 8.5 L7 8.5 Z",strokeWidth:"0.5",opacity:"0.3",fill:"none"})]}),H),ws=A(D("g",{fill:"none",stroke:"currentColor",children:[g("path",{d:"M8 8 L8 16 L4 12 L8 8 Z",fill:"none",strokeWidth:"1.5"}),g("path",{d:"M8 10 L16 10 M8 14 L16 14",fill:"none",strokeLinecap:"round",strokeWidth:"1.5"}),g("path",{d:"M16 8 L16 16 L20 12 L16 8 Z",strokeWidth:"1.5",fill:"none"})]}),H),on=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),H),vs=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),g("line",{x1:"5",y1:"12",x2:"9",y2:"8"}),g("line",{x1:"5",y1:"12",x2:"9",y2:"16"}),g("line",{x1:"19",y1:"12",x2:"15",y2:"8"}),g("line",{x1:"19",y1:"12",x2:"15",y2:"16"})]}),H),so=A(g("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),re),sb=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),g("path",{d:"M16 7h4"}),g("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),H),Nt=A(D("g",{strokeWidth:"1.25",children:[g("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"}),g("path",{d:"m11.25 5.417 3.333 3.333"})]}),re),Ts=A(D("g",{strokeWidth:1.25,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(0,-2)",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 15l4 4l8-8l-4-4l-8 8z"}),g("path",{d:"M13 7l3 3"}),g("path",{d:"M4 16l3 3"})]}),re),Wo=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),g("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),g("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),g("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),g("polyline",{points:"5 20 11 4 13 4 20 20"})]}),H),cb=A(D("g",{strokeWidth:"1.25",children:[g("path",{d:"M12.5 6.667h.01"}),g("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"}),g("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),g("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),re),xa=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M18 13.3l-6.3 -6.3"})]}),H),Qm=A(g("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),re),ep=A(g("path",{d:"M5 10h10",strokeWidth:"1.25"}),re),db=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 21l-6 -6"}),g("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"}),g("path",{d:"M3 4v4h4"})]}),H),Bt=A(g("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"}),re),mb=A(D("g",{strokeWidth:"1.5",children:[g("polyline",{points:"12 16 18 10 12 4"}),g("polyline",{points:"8 4 2 10 8 16"})]}),re),Ea=A(D("g",{strokeWidth:"1.25",children:[g("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"}),g("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"})]}),re),ya=A(g("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"}),re),wa=A(g("g",{stroke:"currentColor",strokeLinejoin:"round",children:g("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"})}),{...re,strokeWidth:1.5}),Is=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),g("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),H),rn=A(g("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"}),re),Gn=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),pb=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),tp=A(g("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"}),re),Cs=A(g("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"}),re),ub=A(D("g",{strokeWidth:"1.25",children:[g("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"}),g("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"})]}),re),hb=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),g("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),H),gb=A(g("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),va=A(D("g",{strokeWidth:"1.25",children:[g("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"}),g("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"})]}),re),fb=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}),bb=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}),Un=A(g("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"}),re),hW=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}),xb=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"),Ss=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),g("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),g("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),H),Eb=A(g("g",{strokeWidth:1.5,children:g("path",{d:"M6 18l12 -12"})}),H),ks=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8h.01"}),g("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),g("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),g("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),g("path",{d:"M19 16v6"}),g("path",{d:"M22 19l-3 3l-3 -3"})]}),H),yb=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}),gW=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}),fW=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}),wb=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"),bW=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"),op=A(g("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"}),re),rp=A(g("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"}),re),vb=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}),Tb=A(g("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"}),re),xW=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"),EW=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}),yW=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M12 14v-11"}),g("path",{d:"M9 6l3 -3l3 3"})]}),H),wW=A(D(Ee,{children:[g("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"}),g("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}),vW=A(g("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}),Ib=D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 10l0 10"}),g("path",{d:"M12 10l4 4"}),g("path",{d:"M12 10l-4 4"}),g("path",{d:"M4 4l16 0"})]}),Cb=D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 5l0 14"}),g("path",{d:"M16 9l-4 -4"}),g("path",{d:"M8 9l4 -4"})]}),np=A(Cb,H),ip=A(Cb,{...H,style:{transform:"rotate(180deg)"}}),ap=A(Ib,H),lp=A(Ib,{...H,style:{transform:"rotate(180deg)"}}),sp=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),cp=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),dp=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),mp=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),Sb=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),kb=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),pp=A(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),g("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),re),up=A(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),g("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),re),Ms=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"9",cy:"7",r:"4"}),g("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),g("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),g("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),H),TW=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"),IW=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"),Vt=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M15 5 5 15M5 5l10 10"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),CW=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}),SW=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}),kW=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}),hp=nt.memo(({theme:e})=>A(D(Ee,{children:[g("path",{d:"M25 26H111V111H25",fill:lo(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:lo(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:lo(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:lo(e),strokeWidth:"2"}),D("g",{fill:eb(e),stroke:lo(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),gp=nt.memo(({theme:e})=>A(D(Ee,{children:[g("path",{d:"M25 26H111V111H25",fill:lo(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:lo(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:lo(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:lo(e),strokeWidth:"2"}),D("g",{fill:eb(e),stroke:lo(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),g("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Mb=A(g("g",{strokeWidth:1.25,children:g("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"})}),re),Ls=A(D(Ee,{children:[g("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"}),g("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:g("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"})}),g("g",{mask:"url(#FillHachureIcon)",children:g("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"})})]}),re),Ps=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",children:[g("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"}),g("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:g("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"})}),g("g",{mask:"url(#FillCrossHatchIcon)",children:g("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"})})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),As=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",children:g("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"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...re,fill:"currentColor"}),Wn=A(g(Ee,{children:g("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),re),Ta=A(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),re),Ia=A(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),re),MW=nt.memo(({theme:e})=>A(g("path",{d:"M6 10H34",stroke:lo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Lb=A(D("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12h2"}),g("path",{d:"M17 12h2"}),g("path",{d:"M11 12h2"})]}),H),Pb=A(D("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M8 12v.01"}),g("path",{d:"M12 12v.01"}),g("path",{d:"M16 12v.01"}),g("path",{d:"M20 12v.01"})]}),H),Ab=A(g("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"}),re),_b=A(g("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"}),re),Db=A(g("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"}),re),Rb=A(D("svg",{strokeWidth:"1.5",children:[g("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"}),g("path",{d:"M13.3333 3.33331V3.34331"}),g("path",{d:"M16.6667 3.33331V3.34331"}),g("path",{d:"M16.6667 6.66669V6.67669"}),g("path",{d:"M16.6667 10V10.01"}),g("path",{d:"M3.33334 13.3333V13.3433"}),g("path",{d:"M16.6667 13.3333V13.3433"}),g("path",{d:"M3.33334 16.6667V16.6767"}),g("path",{d:"M6.66666 16.6667V16.6767"}),g("path",{d:"M10 16.6667V16.6767"}),g("path",{d:"M13.3333 16.6667V16.6767"}),g("path",{d:"M16.6667 16.6667V16.6767"})]}),re),Nb=A(D("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),g("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),g("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),g("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),g("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),g("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),g("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),g("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),g("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),g("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),g("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),g("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),H),Bb=A(D("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[g("path",{d:"M12 12l9 0"}),g("path",{d:"M3 9l6 6"}),g("path",{d:"M3 15l6 -6"})]}),H),Fb=nt.memo(({flip:e=!1})=>A(D("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[g("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),g("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),Ob=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),zb=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[g("path",{d:"M26 10L6 10"}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Hb=nt.memo(({flip:e=!1})=>A(g("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:g("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),Gb=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),Ub=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[g("path",{d:"M6,9.5H27"}),g("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),Wb=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Yb=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Vb=nt.memo(({flip:e=!1})=>A(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Xb=nt.memo(({flip:e=!1})=>A(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),Kb=nt.memo(({flip:e=!1})=>A(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Zb=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",children:g("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"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),$b=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),jb=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),qb=A(g(Ee,{children:g("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"})}),re),nn=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 7v-2h13v2"}),g("path",{d:"M10 5v14"}),g("path",{d:"M12 19h-4"}),g("path",{d:"M15 13v-1h6v1"}),g("path",{d:"M18 12v7"}),g("path",{d:"M17 19h2"})]}),H),Jb=A(g(Ee,{children:D("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 12h10"}),g("path",{d:"M7 5v14"}),g("path",{d:"M17 5v14"}),g("path",{d:"M15 19h4"}),g("path",{d:"M15 5h4"}),g("path",{d:"M5 19h4"}),g("path",{d:"M5 5h4"})]})}),H),Ca=A(g(Ee,{children:g("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("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"})})}),re),_s=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),Ds=A(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),g("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),H),Rs=A(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),g("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),H),Ns=A(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),H),Qb=nt.memo(({theme:e})=>A(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),g("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),H)),e0=nt.memo(({theme:e})=>A(D("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),g("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),H)),t0=nt.memo(({theme:e})=>A(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),g("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),g("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),H)),Bs=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 19h-18l9 -15"}),g("path",{d:"M20.615 15.171h.015"}),g("path",{d:"M19.515 11.771h.015"}),g("path",{d:"M17.715 8.671h.015"}),g("path",{d:"M15.415 5.971h.015"})]}),H),o0=A(g("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}),LW=A(g("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"})),Fs=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),g("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),g("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),fp=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M7 11l5 5l5 -5"}),g("path",{d:"M12 4l0 12"})]}),H),Yn=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("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),r0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M9.15 14.85l8.85 -10.85"}),g("path",{d:"M6 4l8.85 10.85"})]}),H),n0=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),g("path",{d:"M12 17l0 .01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),PW=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 4v16l13 -8z"})]}),H),AW=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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),i0=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12l5 5l10 -10"})]}),H),a0=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M12 9v4"}),g("path",{d:"M12 17h.01"})]}),H),l0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11 7l6 6"}),g("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),H),s0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l-4 7h8z"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),H),Vn=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 7l16 0"}),g("path",{d:"M4 17l16 0"}),g("path",{d:"M7 4l0 16"}),g("path",{d:"M17 4l0 16"})]}),H),c0=A(g("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),Xn=A(D("g",{strokeWidth:"1.25",children:[g("path",{d:"M4.16602 10H15.8327"}),g("path",{d:"M12.5 13.3333L15.8333 10"}),g("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),re),d0=A(D("g",{strokeWidth:1.5,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{d:"M5 12h10"}),g("path",{d:"M11 8l4 4l-4 4"})]}),H),m0=A(D("g",{strokeWidth:1.5,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{d:"M5 12h14"}),g("path",{d:"M9 8l-4 4l4 4"}),g("path",{d:"M15 8l4 4l-4 4"})]}),H),Yo=A(D("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[g("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"}),g("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),p0=A(D("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[g("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"}),g("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"}),g("circle",{cx:"3",cy:"16",r:"0.8",fill:"currentColor",opacity:"0.7"}),g("circle",{cx:"5",cy:"18",r:"0.6",fill:"currentColor",opacity:"0.5"}),g("circle",{cx:"7.5",cy:"17",r:"0.8",fill:"currentColor",opacity:"0.6"}),g("circle",{cx:"10",cy:"19",r:"0.4",fill:"currentColor",opacity:"0.3"})]}),20),u0=A(D("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("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"}),g("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),_W=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("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"}),g("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),DW=A(D("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),g("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),g("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"}),g("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),g("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),g("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),h0=A(D("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),g("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),g("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),g("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),H),Kn=A(D("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),g("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),g0=A(D("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),g("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"}),g("path",{d:"M3 3l18 18"})]}),H),f0=A(D("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("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"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),b0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("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"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),Ft=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),g("path",{d:"M21 21l-6 -6"})]}),H),x0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),g("path",{d:"M12 7v5l3 3"}),g("path",{d:"M19 16l-2 3h4l-2 3"})]}),H),E0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M5 10a7 7 0 0 0 14 0"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),H),y0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 3l18 18"}),g("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"}),g("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),H),Sa=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),H),w0=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M12 20v.01"}),g("path",{d:"M16 20v.01"}),g("path",{d:"M8 20v.01"}),g("path",{d:"M4 20v.01"}),g("path",{d:"M4 16v.01"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M4 8v.01"}),g("path",{d:"M4 4v.01"}),g("path",{d:"M8 4v.01"}),g("path",{d:"M12 4v.01"}),g("path",{d:"M16 4v.01"}),g("path",{d:"M20 4v.01"}),g("path",{d:"M20 8v.01"}),g("path",{d:"M20 12v.01"}),g("path",{d:"M20 16v.01"}),g("path",{d:"M20 20v.01"})]}),H),v0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3v18"}),g("path",{d:"M19 21v-18"}),g("path",{d:"M5 7h14"}),g("path",{d:"M5 15h14"}),g("path",{d:"M8 13v4"}),g("path",{d:"M11 13v4"}),g("path",{d:"M16 13v4"}),g("path",{d:"M14 5v4"}),g("path",{d:"M11 5v4"}),g("path",{d:"M8 5v4"}),g("path",{d:"M3 21h18"})]}),H),T0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 12l18 0"}),g("path",{d:"M7 16l10 0l-10 5l0 -5"}),g("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),H),I0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l0 18"}),g("path",{d:"M16 7l0 10l5 0l-5 -10"}),g("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),H),bp=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),g("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),Os=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),g("path",{d:"M22 22l-3 -3"}),g("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),g("path",{d:"M3 11v-1"}),g("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),g("path",{d:"M10 3h1"}),g("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),H),C0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("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"}),g("path",{d:"M10 15l2 6l2 -6"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),H),S0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),g("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),g("path",{d:"M11 21v-6l3 6v-6"})]}),H),k0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M4 8l5 0"}),g("path",{d:"M15 8l4 0"})]}),H),M0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),g("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),H),L0=A(D("g",{stroke:"currentColor",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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}),RW=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M21 12h-13l3 -3"}),g("path",{d:"M11 15l-3 -3"})]}),H),P0=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M10 9l5 3l-5 3z"})]}),H),A0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 6h18"}),g("path",{d:"M3 12h18"}),g("path",{d:"M3 18h18"}),g("path",{d:"M6 3v18"}),g("path",{d:"M12 3v18"}),g("path",{d:"M18 3v18"})]}),H),_0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("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"}),g("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),H),zs=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 18l12 -12"}),g("path",{d:"M18 10v-4h-4"})]}),H),Hs=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),g("path",{d:"M18 4l3 3l-3 3"})]}),H),Gs=A(D("g",{children:[g("path",{d:"M16,12L20,9L16,6"}),g("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),Us=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 9l6 6l6 -6"})]}),H),D0=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),H),R0=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),H),xp=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),g("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),H),Ws=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 7l0 10"}),g("path",{d:"M7 5l10 0"}),g("path",{d:"M7 19l10 0"}),g("path",{d:"M19 7l0 10"})]}),H);import N0 from"clsx";import yp,{useEffect as JC,useRef as B0,useState as QC}from"react";import{isPromiseLike as eS}from"@haoxin-web/excalidraw-common";import jC from"react";import{jsx as Ep}from"react/jsx-runtime";var qC=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(jC.useRef(Date.now()).current%1600);return Ep("div",{className:`Spinner ${r}`,children:Ep("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Ep("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},it=qC;import{jsx as ka,jsxs as Ma}from"react/jsx-runtime";var z=yp.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=Xe(),a=yp.useRef(null);yp.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,m]=QC(!1),c=B0(!0),d=async u=>{let f="onClick"in r&&r.onClick?.(u);if(eS(f))try{m(!0),await f}catch(b){if(b instanceof Dn)console.warn(b);else throw b}finally{c.current&&m(!1)}};JC(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=B0(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return Ma("button",{className:N0("ToolIcon_type_button",l,t,o&&!r.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!r.hidden,"ToolIcon--selected":r.selected,"ToolIcon--plain":r.type==="icon"}),style:r.style,"data-testid":r["data-testid"],hidden:r.hidden,title:r.title,"aria-label":r["aria-label"],type:u,onClick:d,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&Ma("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&ka("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&ka(it,{})]}),r.showAriaLabel&&Ma("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&ka(it,{})]}),r.children]})}return Ma("label",{className:N0("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[ka("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:r.name,"aria-label":r["aria-label"],"aria-keyshortcuts":r["aria-keyshortcuts"],"data-testid":r["data-testid"],id:`${i}-${r.id}`,onChange:()=>{r.onChange?.({pointerType:p.current})},checked:r.checked,ref:a}),Ma("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&ka("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});z.displayName="ToolButton";var Ys=[],F=e=>(Ys=Ys.concat(e),e);import{jsx as sS}from"react/jsx-runtime";var lS=(e,o,t)=>{let r=new Set(J(e.filter(c=>nS(c)),o).map(c=>c.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let c of r){let d=iS(e,c);for(let p of d)if(!a.has(p.id)){if(Vs(p)){let u=O0(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(c=>{if(o.selectedElementIds[c.id]){let d=Vs(c)?O0(c,i):null;return c.frameId&&r.has(c.frameId)?(l=!1,n[c.id]=!0,c):d?.frameId&&r.has(d?.frameId)?c:(c.boundElements&&c.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&rS(u)&&t.scene.mutateElement(u,{startBinding:c.id===u.startBinding?.elementId?null:u.startBinding,endBinding:c.id===u.endBinding?.elementId?null:u.endBinding})}),Ks(c,{isDeleted:!0}))}return c.frameId&&r.has(c.frameId)?(l=!1,Vs(c)||(n[c.id]=!0),Ks(c,{frameId:null})):Vs(c)&&o.selectedElementIds[c.containerId]?Ks(c,{isDeleted:!0}):c}),m=o.editingGroupId;if(l&&o.editingGroupId){let c=Tp(s,o.editingGroupId).filter(d=>!d.isDeleted);if(c.length>1)c[0]&&(n[c[0].id]=!0);else{m=null,c[0]&&(n[c[0].id]=!0);let d=c[0];if(d){let p=d.groupIds.findIndex(f=>f===o.editingGroupId),u=d.groupIds[p+1];if(u){let f=Tp(s,u).filter(b=>!b.isDeleted);f.length>1&&(m=u,f.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...aS({selectedElementIds:n,editingGroupId:m},s,o,null)}}},z0=(e,o)=>{if(e.editingGroupId){let t=Tp(vp(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},La=F({name:"deleteSelectedElements",label:"labels.delete",icon:Bt,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:m}=o.selectedLinearElement,c=r.scene.getNonDeletedElementsMap(),d=F0.getElement(a,c);if(!d||l==null)return!1;if(l.length>=d.points.length){let u=e.map(b=>b.id===d.id?Ks(b,{isDeleted:!0}):b),f=z0(o,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:Xs.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:m};return F0.deletePoints(d,r,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:Xs.IMMEDIATELY}}let{elements:n,appState:i}=lS(e,o,r);return oS(n,n.filter(a=>a.isDeleted)),i=z0(i,n),{elements:n,appState:{...i,activeTool:tS(o,{type:r.defaultSelectionTool}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:we(vp(e),o)?Xs.IMMEDIATELY:Xs.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===wp.BACKSPACE||e.key===wp.DELETE)&&!e[wp.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>sS(z,{type:"button",icon:Bt,title:h("labels.delete"),"aria-label":h("labels.delete"),onClick:()=>t(null),visible:we(vp(e),o)})});import{KEYS as Zn,CODES as $n,getShortcutKey as jn,isDarwin as Zs}from"@haoxin-web/excalidraw-common";import{moveOneLeft as cS,moveOneRight as dS,moveAllLeft as mS,moveAllRight as pS}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as $s}from"@haoxin-web/excalidraw-element";import{jsx as js}from"react/jsx-runtime";var Ip=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:ip,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:cS(e,o,r.scene),appState:o,captureUpdate:$s.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Zn.CTRL_OR_CMD]&&!e.shiftKey&&e.code===$n.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.sendBackward")} \u2014 ${jn("CtrlOrCmd+[")}`,children:ip})}),Cp=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:np,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:dS(e,o,r.scene),appState:o,captureUpdate:$s.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Zn.CTRL_OR_CMD]&&!e.shiftKey&&e.code===$n.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.bringForward")} \u2014 ${jn("CtrlOrCmd+]")}`,children:np})}),Sp=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:lp,trackEvent:{category:"element"},perform:(e,o)=>({elements:mS(e,o),appState:o,captureUpdate:$s.IMMEDIATELY}),keyTest:e=>Zs?e[Zn.CTRL_OR_CMD]&&e.altKey&&e.code===$n.BRACKET_LEFT:e[Zn.CTRL_OR_CMD]&&e.shiftKey&&e.code===$n.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.sendToBack")} \u2014 ${Zs?jn("CtrlOrCmd+Alt+["):jn("CtrlOrCmd+Shift+[")}`,children:lp})}),kp=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:ap,trackEvent:{category:"element"},perform:(e,o)=>({elements:pS(e,o),appState:o,captureUpdate:$s.IMMEDIATELY}),keyTest:e=>Zs?e[Zn.CTRL_OR_CMD]&&e.altKey&&e.code===$n.BRACKET_RIGHT:e[Zn.CTRL_OR_CMD]&&e.shiftKey&&e.code===$n.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${h("labels.bringToFront")} \u2014 ${Zs?jn("CtrlOrCmd+Alt+]"):jn("CtrlOrCmd+Shift+]")}`,children:ap})});import{getNonDeletedElements as uS}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as hS}from"@haoxin-web/excalidraw-element";import{isLinearElement as gS,isTextElement as fS}from"@haoxin-web/excalidraw-element";import{arrayToMap as bS,KEYS as H0}from"@haoxin-web/excalidraw-common";import{selectGroupsForSelectedElements as xS}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as ES}from"@haoxin-web/excalidraw-element";var Mp=F({name:"selectAll",label:"labels.selectAll",icon:w0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing)return!1;let n=e.filter(i=>!i.isDeleted&&!(fS(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...xS({editingGroupId:null,selectedElementIds:n},uS(e),o,r),selectedLinearElement:Object.keys(n).length===1&&gS(e[0])?new hS(e[0],bS(e)):null},captureUpdate:ES.IMMEDIATELY}},keyTest:e=>e[H0.CTRL_OR_CMD]&&e.key===H0.A});import{DEFAULT_GRID_SIZE as G0,KEYS as U0,arrayToMap as W0,getShortcutKey as yS}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as Y0}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as wS}from"@haoxin-web/excalidraw-element";import{getSelectedElements as vS,getSelectionStateForElements as TS}from"@haoxin-web/excalidraw-element";import{syncMovedIndices as IS}from"@haoxin-web/excalidraw-element";import{duplicateElements as CS}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as V0}from"@haoxin-web/excalidraw-element";import{jsx as SS}from"react/jsx-runtime";var Lp=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Ea,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=wS.duplicateSelectedPoints(o,r.scene);return{elements:e,appState:a,captureUpdate:V0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:i}=CS({type:"in-place",elements:e,idsOfElementsToDuplicate:W0(vS(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+G0/2,y:a.y+G0/2,frameId:s??a.frameId}}});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:IS(i,W0(n)),appState:{...o,...TS(n,Y0(i),o)},captureUpdate:V0.IMMEDIATELY}},keyTest:e=>e[U0.CTRL_OR_CMD]&&e.key===U0.D,PanelComponent:({elements:e,appState:o,updateData:t})=>SS(z,{type:"button",icon:Ea,title:`${h("labels.duplicateSelection")} \u2014 ${yS("CtrlOrCmd+D")}`,"aria-label":h("labels.duplicateSelection"),onClick:()=>t(null),visible:we(Y0(e),o)})});import{pointFrom as kk}from"@haoxin-web/excalidraw-math";import{useEffect as qp,useMemo as Mk,useRef as Jp,useState as Lk}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Pk,DEFAULT_ELEMENT_BACKGROUND_PICKS as Ak,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as _k,DEFAULT_ELEMENT_STROKE_PICKS as Dk,ARROW_TYPE as Xo,DEFAULT_FONT_FAMILY as Rk,DEFAULT_FONT_SIZE as Nk,FONT_FAMILY as Bk,ROUNDNESS as uc,STROKE_WIDTH as Qp,VERTICAL_ALIGN as pc,KEYS as li,randomInteger as Fk,arrayToMap as ou,getFontFamilyString as Ok,getShortcutKey as zk,getLineHeight as Hk,isTransparent as Gk,reduceToCommonValue as Uk}from"@haoxin-web/excalidraw-common";import{canBecomePolygon as Wk,getNonDeletedElements as _x}from"@haoxin-web/excalidraw-element";import{bindLinearElement as Mx,calculateFixedPointForElbowArrowBinding as Lx,updateBoundElements as Yk}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as eu}from"@haoxin-web/excalidraw-element";import{newElementWith as Qe}from"@haoxin-web/excalidraw-element";import{getBoundTextElement as Cr,redrawTextBoundingBox as Oa}from"@haoxin-web/excalidraw-element";import{isArrowElement as hc,isBoundToContainer as Vk,isElbowArrow as Dx,isLinearElement as tu,isLineElement as Px,isTextElement as kt,isUsingAdaptiveRadius as Xk}from"@haoxin-web/excalidraw-element";import{hasStrokeColor as Kk}from"@haoxin-web/excalidraw-element";import{updateElbowArrowPoints as Zk,CaptureUpdateAction as et,toggleLinePolygonState as $k}from"@haoxin-web/excalidraw-element";import{isDevEnv as kS}from"@haoxin-web/excalidraw-common";var MS=new Set(["command_palette","export"]),ae=(e,o,t,r)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!MS.has(e)||kS())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import _S from"clsx";import LS from"clsx";import{forwardRef as PS}from"react";import{jsx as AS}from"react/jsx-runtime";var qn=PS((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return AS("button",{type:"button",ref:o,title:t,"data-testid":n,className:LS(r,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as RS,jsx as Pp,jsxs as DS}from"react/jsx-runtime";var Xt=e=>Pp(RS,{children:e.options.map(o=>e.type==="button"?Pp(qn,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):DS("label",{className:_S({active:e.value===o.value}),title:o.text,children:[Pp("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as rc from"@radix-ui/react-popover";import D6 from"clsx";import{useRef as R6}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as N6,COLOR_PALETTE as dx,isTransparent as B6}from"@haoxin-web/excalidraw-common";import{jsx as NS}from"react/jsx-runtime";var qs=()=>NS("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as HS,useRef as GS}from"react";import{createPortal as US}from"react-dom";import{EVENT as xr,KEYS as WS,rgbToHex as YS}from"@haoxin-web/excalidraw-common";import X0 from"react";var Ap=X0.createContext(null),xe=()=>X0.useContext(Ap);import{useState as BS,useLayoutEffect as K0}from"react";import{THEME as FS}from"@haoxin-web/excalidraw-common";var Js=e=>{let[o,t]=BS(null),r=pe(),{theme:n}=xe(),{container:i}=Xe();return K0(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",r.editor.isMobile),o.classList.toggle("theme--dark",n===FS.DARK))},[o,n,r.editor.isMobile,e?.className]),K0(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as OS}from"react";import{EVENT as Qs}from"@haoxin-web/excalidraw-common";function Jn(e,o,t){OS(()=>{function r(n){let i=n;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(Qs.POINTER_DOWN,r),document.addEventListener(Qs.TOUCH_START,r),()=>{document.removeEventListener(Qs.POINTER_DOWN,r),document.removeEventListener(Qs.TOUCH_START,r)}},[e,o,t])}import{useRef as zS}from"react";var br=e=>{let o=zS(e);return Object.assign(o.current,e),o.current};import{jsx as VS}from"react/jsx-runtime";var Er=he(null),Z0=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=Js({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=xe(),a=yr(),l=Oe(),s=J(a,i),m=br({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:c}=Xe();HS(()=>{let p=d.current;if(!p||!l.canvas||!n)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:S,clientY:P})=>{let M=f.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(P-i.offsetTop)*window.devicePixelRatio,1,1).data;return YS(M[0],M[1],M[2])},x=({clientX:S,clientY:P,altKey:M})=>{p.style.top=`${P+20}px`,p.style.left=`${S+20}px`;let R=b({clientX:S,clientY:P});u&&m.onChange(r,R,m.selectedElements,{altKey:M}),p.style.background=R},w=()=>{m.onCancel()},E=(S,P)=>{m.onSelect(S,P)},y=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,c?.focus(),S.stopImmediatePropagation(),S.preventDefault(),E(b(S),S)},C=S=>{S.key===WS.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),w())};return n.tabIndex=-1,n.focus(),x({clientX:m.app.lastViewportPosition.x,clientY:m.app.lastViewportPosition.y,altKey:!1}),n.addEventListener(xr.KEYDOWN,C),n.addEventListener(xr.POINTER_DOWN,y),n.addEventListener(xr.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(xr.BLUR,w),()=>{u=!1,n.removeEventListener(xr.KEYDOWN,C),n.removeEventListener(xr.POINTER_DOWN,y),n.removeEventListener(xr.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(xr.BLUR,w)}},[m,l.canvas,n,r,c,i.offsetLeft,i.offsetTop]);let d=GS(null);return Jn(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?US(VS("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import*as Qn from"@radix-ui/react-popover";import $S from"clsx";import jS from"react";import{isInteractive as qS}from"@haoxin-web/excalidraw-common";import XS from"react";import KS from"clsx";import{jsx as ZS}from"react/jsx-runtime";var De=XS.forwardRef(({children:e,padding:o,className:t,style:r},n)=>ZS("div",{className:KS("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as _p,jsxs as JS}from"react/jsx-runtime";var ec=jS.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},m)=>{let c=pe();return _p(Qn.Portal,{container:o,children:JS(Qn.Content,{ref:m,className:$S("focus-visible-none",e),"data-prevent-outside-click":!0,side:c.editor.isMobile&&!c.viewport.isLandscape?"bottom":"right",align:c.editor.isMobile&&!c.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onCloseAutoFocus:d=>{d.stopPropagation(),d.preventDefault(),o&&!qS(document.activeElement)&&o.focus(),n()},children:[_p(De,{padding:3,style:r,children:t}),_p(Qn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import e6 from"clsx";import{useCallback as t6,useEffect as Rp,useRef as q0,useState as o6}from"react";import{KEYS as Np,getShortcutKey as r6}from"@haoxin-web/excalidraw-common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as QS}from"@haoxin-web/excalidraw-common";var wr=({palette:e,color:o})=>{if(!o)return null;for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},Pa=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Dp=({color:e,palette:o})=>!Object.values(o).flat().includes(e),j0=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return Dp({color:l,palette:t})}),i=new Map;return n.forEach(a=>{let l=a[r[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,QS)},Kt=he(null),$0=(e,o,t)=>(e*299+o*587+t*114)/1e3,ei=(e,o=160)=>{if(!e)return!0;if(e==="transparent")return!1;if(!e.startsWith("#")){let i=document.createElement("div");if(i.style.color=e,i.style.color){i.style.position="absolute",i.style.visibility="hidden",i.style.width="0",i.style.height="0",document.body.appendChild(i);let a=getComputedStyle(i).color;document.body.removeChild(i);let l=a.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(l[0]),m=parseInt(l[1]),c=parseInt(l[2]);return $0(s,m,c)<o}return!0}let t=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return $0(t,r,n)<o};import{Fragment as n6,jsx as tc,jsxs as J0}from"react/jsx-runtime";var Q0=({color:e,onChange:o,label:t,colorPickerType:r,placeholder:n})=>{let i=pe(),[a,l]=o6(e),[s,m]=ce(Kt);Rp(()=>{l(e)},[e]);let c=t6(b=>{let x=b.toLowerCase(),w=ex(x);w&&o(w),l(x)},[o]),d=q0(null),p=q0(null);Rp(()=>{d.current&&d.current.focus()},[s]);let[u,f]=ce(Er);return Rp(()=>()=>{f(null)},[f]),J0("div",{className:"color-picker__input-label",children:[tc("div",{className:"color-picker__input-hash",children:"#"}),tc("input",{ref:s==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{c(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:b=>{b.key!==Np.TAB&&(b.key===Np.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:n}),!i.editor.isMobile&&J0(n6,{children:[tc("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),tc("div",{ref:p,className:e6("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:r}),title:`${h("labels.eyeDropper")} \u2014 ${Np.I.toLocaleUpperCase()} or ${r6("Alt")} `,children:l0})]})]})};import zp,{useEffect as Hp,useImperativeHandle as T6,useState as I6}from"react";import{EVENT as ax}from"@haoxin-web/excalidraw-common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as C6,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as S6,KEYS as k6}from"@haoxin-web/excalidraw-common";import l6 from"clsx";import{useEffect as s6,useRef as c6}from"react";import{jsxs as a6}from"react/jsx-runtime";var i6=({color:e,keyLabel:o,isShade:t=!1})=>a6("div",{className:"color-picker__button__hotkey-label",style:{color:ei(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),ti=i6;import{jsx as Bp,jsxs as d6}from"react/jsx-runtime";var tx=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=ce(Kt),a=c6(null);return s6(()=>{a.current&&a.current.focus()},[o,n]),Bp("div",{className:"color-picker-content--default",children:e.map((l,s)=>d6("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:l6("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[Bp("div",{className:"color-picker__button-outline"}),Bp(ti,{color:l,keyLabel:s+1})]},s))})};import m6 from"clsx";import{useEffect as p6,useRef as u6}from"react";import{jsx as Fp,jsxs as g6}from"react/jsx-runtime";var h6=({palette:e,color:o,onChange:t,activeShade:r})=>{let n=wr({color:o,palette:e}),[i,a]=ce(Kt),l=u6(null);return p6(()=>{l.current&&i==="baseColors"&&l.current.focus()},[n?.colorName,i]),Fp("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,m],c)=>{let d=(Array.isArray(m)?m[r]:m)||"transparent",p=Pa[c],u=h(`colors.${s.replace(/\d+/,"")}`,null,"");return g6("button",{ref:n?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:m6("color-picker__button color-picker__button--large has-outline",{active:n?.colorName===s,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),a("baseColors")},title:`${u}${d.startsWith("#")?` ${d}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${s}`,children:[Fp("div",{className:"color-picker__button-outline"}),Fp(ti,{color:d,keyLabel:p})]},s)})})},ox=h6;import{jsx as b6}from"react/jsx-runtime";var f6=({children:e})=>b6("div",{className:"color-picker__heading",children:e}),oi=f6;import x6 from"clsx";import{useEffect as E6,useRef as y6}from"react";import{jsx as Aa,jsxs as rx}from"react/jsx-runtime";var nx=({color:e,onChange:o,palette:t})=>{let r=wr({color:e||"transparent",palette:t}),[n,i]=ce(Kt),a=y6(null);if(E6(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,m=t[l];if(Array.isArray(m))return Aa("div",{className:"color-picker-content--default shades",children:m.map((c,d)=>rx("button",{ref:d===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:x6("color-picker__button color-picker__button--large has-outline",{active:d===s}),"aria-label":"Shade",title:`${l} - ${d+1}`,style:c?{"--swatch-color":c}:void 0,onClick:()=>{o(c),i("shades")},children:[Aa("div",{className:"color-picker__button-outline"}),Aa(ti,{color:c,keyLabel:d+1,isShade:!0})]},d))})}return rx("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Aa("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Aa("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:h("colorPicker.noShades")})]})};import{COLORS_PER_ROW as ri,COLOR_PALETTE as w6,KEYS as _a}from"@haoxin-web/excalidraw-common";var Op=(e,o,t)=>{let r=Math.ceil(t/ri);switch(o=o??-1,e){case"ArrowLeft":{let n=o-1;return n<0?t-1:n}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let n=o+ri;return n>=t?o%ri:n}case"ArrowUp":{let n=o-ri,i=n<0?ri*r+n:n;return i>=t?void 0:i}}},v6=({e,colorObj:o,onChange:t,palette:r,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(r[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return t(n[Number(e.key)-1]),i("custom"),!0;if(Pa.includes(e.key)){let l=Pa.indexOf(e.key),s=Object.keys(r)[l],m=r[s],c=Array.isArray(m)?m[a]:m;return t(c),i("baseColors"),!0}return!1},ix=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:m,onEscape:c})=>{if(e[_a.CTRL_OR_CMD])return!1;if(e.key===_a.ESCAPE)return c(e),!0;if(e.key===_a.ALT)return m(!0),!0;if(e.key===_a.I)return m(),!0;let d=wr({color:r,palette:t});if(e.key===_a.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[y,v])=>(v&&E.push(y),E),[]),f=u.indexOf(o),b=e.shiftKey?-1:1,x=f+b>u.length-1?0:f+b<0?u.length-1:f+b,w=u[x];return w&&a(w),w==="custom"?n(i[0]):w==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(w6.black)),e.preventDefault(),e.stopPropagation(),!0}if(v6({e,colorObj:d,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&d){let{shade:p}=d,u=Op(e.key,p,ri);if(u!==void 0)return n(t[d.colorName][u]),!0}if(o==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(t),f=u.indexOf(p),b=Op(e.key,f,u.length);if(b!==void 0){let x=u[b],w=t[x];return n(Array.isArray(w)?w[s]:w),!0}}if(o==="custom"){let p=r!=null?i.indexOf(r):0,u=Op(e.key,p,i.length);if(u!==void 0){let f=i[u];return n(f),!0}}return!1};import{jsx as an,jsxs as oc}from"react/jsx-runtime";var lx=zp.forwardRef(({color:e,onChange:o,type:t,elements:r,palette:n,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},m)=>{let[c]=zp.useState(()=>t==="canvasBackground"?[]:j0(r,t,n)),[d,p]=ce(Kt),u=wr({color:e,palette:n});Hp(()=>{if(!d){let w=!!e&&Dp({color:e,palette:n}),E=w&&!c.includes(e);p(E?null:w?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,n,p,u,c]);let[f,b]=I6(u?.shade??(t==="elementBackground"?C6:S6));Hp(()=>{u?.shade!=null&&b(u.shade);let w=E=>{E.key===k6.ALT&&l(!1)};return document.addEventListener(ax.KEYUP,w,{capture:!0}),()=>{document.removeEventListener(ax.KEYUP,w,{capture:!0})}},[u,l]);let x=zp.useRef(null);return T6(m,()=>x.current),Hp(()=>{x?.current?.focus()},[]),an("div",{role:"dialog","aria-modal":"true","aria-label":h("labels.colorPicker"),children:oc("div",{ref:x,onKeyDown:w=>{ix({event:w,activeColorPickerSection:d,palette:n,color:e,onChange:o,onEyeDropperToggle:l,customColors:c,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!c.length&&oc("div",{children:[an(oi,{children:h("colorPicker.mostUsedCustomColors")}),an(tx,{colors:c,color:e,label:h("colorPicker.mostUsedCustomColors"),onChange:o})]}),oc("div",{children:[an(oi,{children:h("colorPicker.colors")}),an(ox,{color:e,palette:n,onChange:o,activeShade:f})]}),oc("div",{children:[an(oi,{children:h("colorPicker.shades")}),an(nx,{color:e,onChange:o,palette:n})]}),a]})})});import M6 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as L6,DEFAULT_CANVAS_BACKGROUND_PICKS as P6,DEFAULT_ELEMENT_BACKGROUND_PICKS as A6,DEFAULT_ELEMENT_STROKE_PICKS as _6}from"@haoxin-web/excalidraw-common";import{jsx as Gp}from"react/jsx-runtime";var sx=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=_6),o==="elementBackground"&&(n=A6),o==="canvasBackground"&&(n=P6),r&&(n=r),n?Gp("div",{className:"color-picker__top-picks",children:n.map(i=>Gp("button",{className:M6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!ei(i,L6)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Gp("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as co,jsxs as Up}from"react/jsx-runtime";var cx=e=>{let o=new Option().style;return o.color=e,!!o.color},ex=e=>B6(e)?e:cx(`#${e}`)?`#${e}`:cx(e)?e:null,F6=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=dx,updateData:a})=>{let{container:l}=Xe(),[,s]=ce(Kt),[m,c]=ce(Er),d=Up("div",{children:[co(oi,{children:h("colorPicker.hexCode")}),co(Q0,{color:o||"",label:r,onChange:f=>{t(f)},colorPickerType:e,placeholder:h("colorPicker.color")})]}),p=R6(null),u=()=>{p.current?.focus()};return co(ec,{container:l,style:{maxWidth:"13rem"},onFocusOutside:f=>{u(),f.preventDefault()},onPointerDownOutside:f=>{m&&f.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?co(lx,{ref:p,palette:i,color:o,onChange:f=>{t(f)},onEyeDropperToggle:f=>{c(b=>f?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):f===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:f=>{m?c(null):a({openPopup:null})},type:e,elements:n,updateData:a,children:d}):d})},O6=({label:e,color:o,type:t})=>co(rc.Trigger,{type:"button",className:D6("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!ei(o,N6)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?h("labels.showStroke"):h("labels.showBackground"),children:co("div",{className:"color-picker__button-outline",children:!o&&Eb})}),vr=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=dx,topPicks:a,updateData:l,appState:s})=>co("div",{children:Up("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[co(sx,{activeColor:o,onChange:t,type:e,topPicks:a}),co(qs,{}),Up(rc.Root,{open:s.openPopup===e,onOpenChange:m=>{l({openPopup:m?e:null})},children:[co(O6,{color:o,label:r,type:e}),s.openPopup===e&&co(F6,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as yx from"@radix-ui/react-popover";import hk,{useCallback as gk,useMemo as fk}from"react";import{FONT_FAMILY as Kp}from"@haoxin-web/excalidraw-common";import nk,{useMemo as Tr,useState as ik,useRef as ak,useEffect as lk,useCallback as sk}from"react";import{arrayToList as ck,debounce as dk,FONT_FAMILY as ln,getFontFamilyString as mk}from"@haoxin-web/excalidraw-common";import z6 from"clsx";import H6 from"react";import{jsx as G6,jsxs as U6}from"react/jsx-runtime";var nc=H6.forwardRef(({className:e,placeholder:o,onChange:t},r)=>U6("div",{className:z6("QuickSearch__wrapper",e),children:[Ft,G6("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import W6 from"clsx";import{Children as Y6}from"react";import{jsx as mx}from"react/jsx-runtime";var ic=({className:e,placeholder:o,children:t})=>{let r=!Y6.count(t);return mx("div",{className:W6("ScrollableList__wrapper",e),role:"menu",children:r?mx("div",{className:"empty",children:o}):t})};import{jsx as V6,jsxs as X6}from"react/jsx-runtime";var px=({children:e,className:o="",style:t,title:r})=>X6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&V6("p",{className:"dropdown-menu-group-title",children:r}),e]}),Da=px;px.displayName="DropdownMenuGroup";import{useEffect as tk,useRef as ok}from"react";import{THEME as rk}from"@haoxin-web/excalidraw-common";import{jsx as K6}from"react/jsx-runtime";var Ra=({children:e,...o})=>K6("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as $6,jsx as ac,jsxs as j6}from"react/jsx-runtime";var Z6=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=pe();return j6($6,{children:[o&&ac("div",{className:"dropdown-menu-item__icon",children:o}),ac("div",{style:e,className:"dropdown-menu-item__text",children:ac(Ra,{children:r})}),t&&!n.editor.isMobile&&ac("div",{className:"dropdown-menu-item__shortcut",children:t})]})},lc=Z6;import q6,{useContext as J6}from"react";import{EVENT as Q6,composeEventHandlers as ek}from"@haoxin-web/excalidraw-common";var Wp=q6.createContext({}),sc=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
2
- ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),cc=(e,o)=>{let t=J6(Wp);return ek(e,r=>{let n=new CustomEvent(Q6.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as Yp}from"react/jsx-runtime";var Vp=({icon:e,value:o,order:t,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:m,onClick:c,...d})=>{let p=cc(c,m),u=ok(null);return tk(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),Yp("button",{...d,ref:u,value:o,onClick:p,className:sc(i,l,a),title:d.title??d["aria-label"],children:Yp(lc,{textStyle:s,icon:e,shortcut:n,children:r})})};Vp.displayName="DropdownMenuItem";var ni={GREEN:"green",RED:"red",BLUE:"blue"},dc=({type:e=ni.BLUE,children:o})=>{let{theme:t}=ko(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===rk.LIGHT?"1.5px solid white":"none"};switch(e){case ni.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ni.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case ni.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Yp("div",{className:"DropDownMenuItemBadge",style:r,children:o})};dc.displayName="DropdownMenuItemBadge";Vp.Badge=dc;var xt=Vp;import{KEYS as ii}from"@haoxin-web/excalidraw-common";var ux=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[ii.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===ii.F)return o.current?.focus(),!0;if(e.key===ii.ESCAPE)return n(),!0;if(e.key===ii.ENTER)return t?.value&&i(t.value),!0;if(e.key===ii.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===ii.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as Na,jsxs as hx}from"react/jsx-runtime";var pk=e=>{switch(e){case ln.Excalifont:case ln.Virgil:return Nt;case ln.Nunito:case ln.Helvetica:return Ca;case ln["Lilita One"]:return Jb;case ln["Comic Shanns"]:case ln.Cascadia:return _s;default:return Ca}},gx=nk.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=Xe(),{fonts:s}=Oe(),{showDeprecatedFonts:m}=Mo(),[c,d]=ik(""),p=ak(null),u=Tr(()=>Array.from(dr.registered.entries()).filter(([M,{metadata:R}])=>!R.private&&!R.fallback).map(([M,{metadata:R,fontFaces:L}])=>{let k={value:M,icon:pk(M),text:L[0]?.fontFace?.family??"Unknown"};return R.deprecated&&Object.assign(k,{deprecated:R.deprecated,badge:{type:ni.RED,placeholder:h("fontList.badge.old")}}),k}).sort((M,R)=>M.text.toLowerCase()>R.text.toLowerCase()?1:-1),[]),f=Tr(()=>new Set(s.getSceneFamilies()),[e]),b=Tr(()=>u.filter(M=>f.has(M.value)),[u,f]),x=Tr(()=>u.filter(M=>!f.has(M.value)&&(m||!M.deprecated)),[u,f,m]),w=Tr(()=>ck([...b,...x].filter(M=>M.text?.toLowerCase().includes(c))),[b,x,c]),E=Tr(()=>{let M;return o?M=w.find(R=>R.value===o):e&&(M=w.find(R=>R.value===e)),!M&&c&&(w[0]?.value?r(w[0].value):n()),M},[o,e,c,w,r,n]),y=sk(M=>{ux({event:M,inputRef:p,hoveredFont:E,filteredFonts:w,onSelect:t,onHover:r,onClose:a})&&(M.preventDefault(),M.stopPropagation())},[E,w,t,r,a]);lk(()=>(i(),()=>{a()}),[]);let v=Tr(()=>w.filter(M=>f.has(M.value)),[w,f]),C=Tr(()=>w.filter(M=>!f.has(M.value)),[w,f]),S=(M,R)=>hx(xt,{icon:M.icon,value:M.value,order:R,textStyle:{fontFamily:mk({fontFamily:M.value})},hovered:M.value===E?.value,selected:M.value===e,tabIndex:M.value===e?0:-1,onClick:L=>{t(Number(L.currentTarget.value))},onMouseMove:()=>{E?.value!==M.value&&r(M.value)},children:[M.text,M.badge&&Na(dc,{type:M.badge.type,children:M.badge.placeholder})]},M.value),P=[];return v.length&&P.push(Na(Da,{title:h("fontList.sceneFonts"),children:v.map(S)},"group_1")),C.length&&P.push(Na(Da,{title:h("fontList.availableFonts"),children:C.map((M,R)=>S(M,R+v.length))},"group_2")),hx(ec,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:y,children:[Na(nc,{ref:p,placeholder:h("quickSearch.placeholder"),onChange:dk(d,20)}),Na(ic,{className:"dropdown-menu fonts manual-hover",placeholder:h("fontList.empty"),children:P.length?P:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as fx from"@radix-ui/react-popover";import{useMemo as uk}from"react";import{jsx as Xp}from"react/jsx-runtime";var bx=({selectedFontFamily:e})=>{let o=uk(()=>!!(e&&!xx(e)),[e]);return Xp(fx.Trigger,{asChild:!0,children:Xp("div",{children:Xp(qn,{standalone:!0,icon:Wo,title:h("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as Ba,jsxs as Ex}from"react/jsx-runtime";var wx=[{value:Kp.Excalifont,icon:Nt,text:h("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Kp.Nunito,icon:Ca,text:h("labels.normal"),testId:"font-family-normal"},{value:Kp["Comic Shanns"],icon:_s,text:h("labels.code"),testId:"font-family-code"}],bk=new Set(wx.map(e=>e.value)),xx=e=>e?bk.has(e):!1,vx=hk.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=fk(()=>wx,[]),s=gk(m=>{m&&r(m)},[r]);return Ex("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[Ba("div",{className:"buttonList",children:Ba(Xt,{type:"button",options:l,value:o,onClick:s})}),Ba(qs,{}),Ex(yx.Root,{open:e,onOpenChange:a,children:[Ba(bx,{selectedFontFamily:o}),e&&Ba(gx,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:s,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as ai from"@radix-ui/react-popover";import wk from"clsx";import mc,{useEffect as vk}from"react";import{isArrowKey as Tk,KEYS as Vo}from"@haoxin-web/excalidraw-common";import{jsx as xk}from"react/jsx-runtime";var Ir=({icon:e})=>xk("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:e});import{Fragment as yk,jsx as Tx,jsxs as Ix}from"react/jsx-runtime";var Ek=({label:e,open:o,openTrigger:t,children:r,className:n,showCollapsedIcon:i=!0})=>Ix(yk,{children:[Ix("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,i&&Tx(Ir,{icon:o?D0:Us})]}),o&&Tx("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),Fa=Ek;import{jsx as sn,jsxs as Zp}from"react/jsx-runtime";var Ik=he(!1);function Ck({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=pe(),l=u=>{let f=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&f)r(f.value),u.preventDefault();else if(u.key===Vo.TAB){let b=e.findIndex(w=>w.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;r(e[x].value)}else if(Tk(u.key)){let b=Uo().rtl,x=e.findIndex(w=>w.value===o);if(x!==-1){let w=e.length,E=x;switch(u.key){case(b?Vo.ARROW_LEFT:Vo.ARROW_RIGHT):E=(x+1)%w;break;case(b?Vo.ARROW_RIGHT:Vo.ARROW_LEFT):E=(w+x-1)%w;break;case Vo.ARROW_DOWN:{E=(x+(i??1))%w;break}case Vo.ARROW_UP:{E=(w+x-(i??1))%w;break}}r(e[E].value)}u.preventDefault()}else(u.key===Vo.ESCAPE||u.key===Vo.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,m]=ce(Ik),c=mc.useMemo(()=>e.slice(0,i),[e,i]),d=mc.useMemo(()=>e.slice(i),[e,i]);vk(()=>{c.some(u=>u.value===o)||m(!0)},[o,c,m]);let p=u=>sn("div",{className:"picker-content",children:u.map((f,b)=>Zp("button",{type:"button",className:wk("picker-option",{active:o===f.value}),onClick:x=>{r(f.value)},title:`${f.text} ${f.keyBinding&&`\u2014 ${f.keyBinding.toUpperCase()}`}`,"aria-label":f.text||"none","aria-keyshortcuts":f.keyBinding||void 0,ref:x=>{o===f.value&&setTimeout(()=>{x?.focus()},0)},children:[f.icon,f.keyBinding&&sn("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return sn(ai.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:Zp("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(c),d.length>0&&sn(Fa,{label:h("labels.more_options"),open:s,openTrigger:()=>{m(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function $p({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=mc.useState(!1),s=mc.useRef(null);return sn("div",{children:Zp(ai.Root,{open:a,onOpenChange:m=>l(m),children:[sn(ai.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(m=>m.value===e)?.icon}),a&&sn(Ck,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import Cx,{useEffect as Sk}from"react";import{jsx as jp,jsxs as Sx}from"react/jsx-runtime";var kx=({updateData:e,app:o,testId:t})=>{let r=Cx.useRef(null),n=Cx.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),m=i.reduce((c,d)=>(c!=null&&c!==d.opacity&&(a=!1),c==null||c>d.opacity?d.opacity:c),l?.opacity??null)??o.state.currentItemOpacity;return Sk(()=>{if(r.current&&n.current){let c=r.current,d=n.current,p=c.offsetWidth,u=15,f=m/100*(p-u)+u/2;d.style.left=`${f}px`,c.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${m}%, var(--button-bg) ${m}%, var(--button-bg) 100%)`}},[m]),Sx("label",{className:"control-label",children:[h("labels.opacity"),Sx("div",{className:"range-wrapper",children:[jp("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:r,type:"range",min:"0",max:"100",step:"10",onChange:c=>{e(+c.target.value)},value:m,className:"range-input","data-testid":t}),jp("div",{className:"value-bubble",ref:n,children:m!==0?m:null}),jp("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Nx,jsx as te,jsxs as Mt}from"react/jsx-runtime";var Rx=.1,Et=(e,o,t,r=!1)=>{let n=ou(J(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},ze=function(e,o,t,r,n){let i=o.state.editingTextElement,a=_x(e),l=null;if(i&&(l=t(i)),!l)if(we(a,o.state)){let m=o.scene.getSelectedElements(o.state),c=r===!0?m:m.filter(d=>r(d));l=Uk(c,t)??(typeof n=="function"?n(!0):n)}else l=typeof n=="function"?n(!1):n;return l},jk=(e,o,t)=>Vk(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),ru=(e,o,t,r,n)=>{let i=new Set,a=Et(e,o,l=>{if(kt(l)){let s=r(l);i.add(s);let m=Qe(l,{fontSize:s});return Oa(m,t.scene.getContainerElement(l),t.scene),m=jk(l,m,t.scene),m}return l},!0);return J(e,o,{includeBoundTextElement:!0}).forEach(l=>{kt(l)&&Yk(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:et.IMMEDIATELY}},gc=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:Et(e,o,r=>Kk(r.type)?Qe(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?et.IMMEDIATELY:et.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt(Nx,{children:[te("h3",{"aria-hidden":"true",children:h("labels.stroke")}),te(vr,{topPicks:Dk,palette:_k,type:"elementStroke",label:h("labels.stroke"),color:ze(e,r,n=>n.strokeColor,!0,n=>n?null:o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),fc=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,r)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:et.EVENTUALLY};let n,i=r.scene.getSelectedElements(o);if(!Gk(t.currentItemBackgroundColor)&&i.every(l=>Px(l)&&Wk(l.points))){let l=ou(i);n=e.map(s=>l.has(s.id)&&Px(s)?Qe(s,{backgroundColor:t.currentItemBackgroundColor,...$k(s,!0)}):s)}else n=Et(e,o,l=>Qe(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:n,appState:{...o,...t},captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt(Nx,{children:[te("h3",{"aria-hidden":"true",children:h("labels.background")}),te(vr,{topPicks:Ak,palette:Pk,type:"elementBackground",label:h("labels.background"),color:ze(e,r,n=>n.backgroundColor,!0,n=>n?null:o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),za=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(ae("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:Et(e,o,n=>Qe(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=J(e,o),i=n.length>0&&n.every(a=>a.fillStyle==="zigzag");return Mt("fieldset",{children:[te("legend",{children:h("labels.fill")}),te("div",{className:"buttonList",children:te(Xt,{type:"button",options:[{value:"hachure",text:`${i?h("labels.zigzag"):h("labels.hachure")} (${zk("Alt-Click")})`,icon:i?Mb:Ls,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:h("labels.crossHatch"),icon:Ps,testId:"fill-cross-hatch"},{value:"solid",text:h("labels.solid"),icon:As,testId:"fill-solid"}],value:ze(e,r,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&n.every(m=>m.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),Ko=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>Qe(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt("fieldset",{children:[te("legend",{children:h("labels.strokeWidth")}),te("div",{className:"buttonList",children:te(Xt,{group:"stroke-width",options:[{value:Qp.thin,text:h("labels.thin"),icon:Wn,testId:"strokeWidth-thin"},{value:Qp.bold,text:h("labels.bold"),icon:Ta,testId:"strokeWidth-bold"},{value:Qp.extraBold,text:h("labels.extraBold"),icon:Ia,testId:"strokeWidth-extraBold"}],value:ze(e,r,n=>n.strokeWidth,n=>n.hasOwnProperty("strokeWidth"),n=>n?null:o.currentItemStrokeWidth),onChange:n=>t(n)})})]})}),qk=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>Qe(r,{seed:Fk(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt("fieldset",{children:[te("legend",{children:h("labels.sloppiness")}),te("div",{className:"buttonList",children:te(Xt,{group:"sloppiness",options:[{value:0,text:h("labels.architect"),icon:Ab},{value:1,text:h("labels.artist"),icon:_b},{value:2,text:h("labels.cartoonist"),icon:Db}],value:ze(e,r,n=>n.roughness,n=>n.hasOwnProperty("roughness"),n=>n?null:o.currentItemRoughness),onChange:n=>t(n)})})]})}),kj=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>Qe(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt("fieldset",{children:[te("legend",{children:h("labels.strokeStyle")}),te("div",{className:"buttonList",children:te(Xt,{group:"strokeStyle",options:[{value:"solid",text:h("labels.strokeStyle_solid"),icon:Wn},{value:"dashed",text:h("labels.strokeStyle_dashed"),icon:Lb},{value:"dotted",text:h("labels.strokeStyle_dotted"),icon:Pb}],value:ze(e,r,n=>n.strokeStyle,n=>n.hasOwnProperty("strokeStyle"),n=>n?null:o.currentItemStrokeStyle),onChange:n=>t(n)})})]})}),Jk=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>Qe(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>te(kx,{updateData:o,app:e,testId:"opacity"})}),nu=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>ru(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt("fieldset",{children:[te("legend",{children:h("labels.fontSize")}),te("div",{className:"buttonList",children:te(Xt,{group:"font-size",options:[{value:16,text:h("labels.small"),icon:Zb,testId:"fontSize-small"},{value:20,text:h("labels.medium"),icon:$b,testId:"fontSize-medium"},{value:28,text:h("labels.large"),icon:jb,testId:"fontSize-large"},{value:36,text:h("labels.veryLarge"),icon:qb,testId:"fontSize-veryLarge"}],value:ze(e,r,n=>{if(kt(n))return n.fontSize;let i=Cr(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>kt(n)||Cr(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||Nk),onChange:n=>t(n)})})]})}),iu=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:nn,trackEvent:!1,perform:(e,o,t,r)=>ru(e,o,r,n=>Math.round(1/(1+Rx)*n.fontSize)),keyTest:e=>e[li.CTRL_OR_CMD]&&e.shiftKey&&(e.key===li.CHEVRON_LEFT||e.key===li.COMMA)}),au=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:nn,trackEvent:!1,perform:(e,o,t,r)=>ru(e,o,r,n=>Math.round(n.fontSize*(1+Rx))),keyTest:e=>e[li.CTRL_OR_CMD]&&e.shiftKey&&(e.key===li.CHEVRON_RIGHT||e.key===li.PERIOD)}),Qk=F({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,r)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:Et(e,o,b=>{let x=n?.get(b.id);return x?Qe(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:et.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:m}=t,c=et.EVENTUALLY,d,p=!1;if(s)d=s,c=et.IMMEDIATELY;else if(m){d=m,c=et.EVENTUALLY;let f=J(e,o,{includeBoundTextElement:!0}).filter(b=>kt(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let w=f[b];x+=w?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:c};if(d&&!p){let f=new Map,b=new Set,x=!1,w=Array.from(dr.loadedFontsCache.values()),E=Object.entries(Bk).find(([C,S])=>S===d)?.[0];m&&E&&w.some(C=>C.startsWith(E))&&(x=!0),Object.assign(u,{elements:Et(e,o,C=>{if(kt(C)&&(C.fontFamily!==d||s)){let S=Qe(C,{fontFamily:d,lineHeight:Hk(d)}),P=n?.get(C.containerId||"")||{},M=r.scene.getContainerElement(C);return a&&M&&P&&r.scene.mutateElement(M,{...P}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,M),S}return C},!0)});let y=`10px ${Ok({fontFamily:d})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,S]of f)Oa(C,S,r.scene);else window.document.fonts.load(y,v).then(C=>{for(let[S,P]of f){let M=r.scene.getElement(S.id),R=P?r.scene.getElement(P.id):null;M&&Oa(M,R,r.scene)}r.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=Jp(new Map),i=Jp(null),[a,l]=Lk({}),s=Jp(!0),m=Mk(()=>{let c=(d,p)=>ze(d,t,u=>{if(kt(u))return u.fontFamily;let f=Cr(u,p);return f?f.fontFamily:null},u=>kt(u)||Cr(u,p)!==null,u=>u?null:o.currentItemFontFamily||Rk);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?c(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&o.openPopup!=="fontFamily"?c(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return qp(()=>{i.current=m},[m]),qp(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),qp(()=>(s.current=!1,()=>{s.current=!0}),[]),Mt("fieldset",{children:[te("legend",{children:h("labels.fontFamily")}),te(vx,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:o.currentHoveredFontFamily,onSelect:c=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:c}),n.current.clear()},onHover:c=>{l({currentHoveredFontFamily:c,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:c=>{if(c){n.current.clear();let{editingTextElement:d}=o;if(d?.type==="text"){let p=t.scene.getElement(d.id);n.current.set(d.id,Qe(p||d,{},!0))}else{let p=J(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,Qe(u,{},!0))}l({openPopup:"fontFamily"})}else{let d={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};s.current?r({...a,...d}):l(d),n.current.clear()}}})]})}}),Ha=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:Et(e,o,n=>{if(kt(n)){let i=Qe(n,{textAlign:t});return Oa(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return Mt("fieldset",{children:[te("legend",{children:h("labels.textAlign")}),te("div",{className:"buttonList",children:te(Xt,{group:"text-align",options:[{value:"left",text:h("labels.left"),icon:Ds,testId:"align-left"},{value:"center",text:h("labels.center"),icon:Rs,testId:"align-horizontal-center"},{value:"right",text:h("labels.right"),icon:Ns,testId:"align-right"}],value:ze(e,r,i=>{if(kt(i))return i.textAlign;let a=Cr(i,n);return a?a.textAlign:null},i=>kt(i)||Cr(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})})]})}}),e4=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Et(e,o,n=>{if(kt(n)){let i=Qe(n,{verticalAlign:t});return Oa(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>te("fieldset",{children:te("div",{className:"buttonList",children:te(Xt,{group:"text-align",options:[{value:pc.TOP,text:h("labels.alignTop"),icon:te(Qb,{theme:o.theme}),testId:"align-top"},{value:pc.MIDDLE,text:h("labels.centerVertically"),icon:te(t0,{theme:o.theme}),testId:"align-middle"},{value:pc.BOTTOM,text:h("labels.alignBottom"),icon:te(e0,{theme:o.theme}),testId:"align-bottom"}],value:ze(e,r,n=>{if(kt(n)&&n.containerId)return n.verticalAlign;let i=Cr(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>kt(n)||Cr(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:pc.MIDDLE),onChange:n=>t(n)})})})}),Mj=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>Dx(r)?r:Qe(r,{roundness:t==="round"?{type:Xk(r.type)?uc.ADAPTIVE_RADIUS:uc.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,renderAction:n})=>{let a=rs(_x(e),o).some(l=>l.roundness?.type===uc.LEGACY);return Mt("fieldset",{children:[te("legend",{children:h("labels.edges")}),Mt("div",{className:"buttonList",children:[te(Xt,{group:"edges",options:[{value:"sharp",text:h("labels.sharp"),icon:Rb},{value:"round",text:h("labels.round"),icon:Nb}],value:ze(e,r,l=>a?null:l.roundness?"round":"sharp",l=>!hc(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),n("togglePolygon")]})]})}}),Ax=e=>[{value:null,text:h("labels.arrowhead_none"),keyBinding:"q",icon:Bb},{value:"arrow",text:h("labels.arrowhead_arrow"),keyBinding:"w",icon:te(Fb,{flip:e})},{value:"triangle",text:h("labels.arrowhead_triangle"),icon:te(Gb,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:h("labels.arrowhead_triangle_outline"),icon:te(Ub,{flip:e}),keyBinding:"r"},{value:"circle",text:h("labels.arrowhead_circle"),keyBinding:"a",icon:te(Ob,{flip:e})},{value:"circle_outline",text:h("labels.arrowhead_circle_outline"),keyBinding:"s",icon:te(zb,{flip:e})},{value:"diamond",text:h("labels.arrowhead_diamond"),icon:te(Wb,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:h("labels.arrowhead_diamond_outline"),icon:te(Yb,{flip:e}),keyBinding:"f"},{value:"bar",text:h("labels.arrowhead_bar"),keyBinding:"z",icon:te(Hb,{flip:e})},{value:"crowfoot_one",text:h("labels.arrowhead_crowfoot_one"),icon:te(Xb,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:h("labels.arrowhead_crowfoot_many"),icon:te(Vb,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:h("labels.arrowhead_crowfoot_one_or_many"),icon:te(Kb,{flip:e}),keyBinding:"v"}],Lj=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>{if(tu(r)){let{position:n,type:i}=t;if(n==="start")return Qe(r,{startArrowhead:i});if(n==="end")return Qe(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Uo().rtl;return Mt("fieldset",{children:[te("legend",{children:h("labels.arrowheads")}),Mt("div",{className:"iconSelectList buttonList",children:[te($p,{label:"arrowhead_start",options:Ax(!n),value:ze(e,r,i=>tu(i)&&_n(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),te($p,{label:"arrowhead_end",group:"arrowheads",options:Ax(!!n),value:ze(e,r,i=>tu(i)&&_n(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),Pj=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=Et(e,o,l=>{if(!hc(l))return l;let s=Qe(l,{roundness:t===Xo.round?{type:uc.PROPORTIONAL_RADIUS}:null,elbowed:t===Xo.elbow,points:t===Xo.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(Dx(s)){s.fixedSegments=null;let m=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let c=eu.getPointAtIndexGlobalCoordinates(s,0,m),d=eu.getPointAtIndexGlobalCoordinates(s,-1,m),p=s.startBinding&&m.get(s.startBinding.elementId),u=s.endBinding&&m.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...Lx(s,p,"start",m)}:null,b=u&&s.endBinding?{...s.endBinding,...Lx(s,u,"end",m)}:null;s={...s,startBinding:f,endBinding:b,...Zk(s,m,{points:[c,d].map(x=>kk(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let m=r.scene.getNonDeletedElementsMap();if(s.startBinding){let c=m.get(s.startBinding.elementId);c&&Mx(s,c,"start",r.scene)}if(s.endBinding){let c=m.get(s.endBinding.elementId);c&&Mx(s,c,"end",r.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new eu(l,ou(e)))}return{elements:n,appState:i,captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt("fieldset",{children:[te("legend",{children:h("labels.arrowtypes")}),te("div",{className:"buttonList",children:te(Xt,{group:"arrowtypes",options:[{value:Xo.sharp,text:h("labels.arrowtype_sharp"),icon:zs,testId:"sharp-arrow"},{value:Xo.round,text:h("labels.arrowtype_round"),icon:Gs,testId:"round-arrow"},{value:Xo.elbow,text:h("labels.arrowtype_elbowed"),icon:Hs,testId:"elbow-arrow"}],value:ze(e,r,n=>hc(n)?n.elbowed?Xo.elbow:n.roundness?Xo.round:Xo.sharp:null,n=>hc(n),n=>n?null:o.currentItemArrowType),onChange:n=>t(n)})})]})});import{clamp as mu,roundToStep as l4}from"@haoxin-web/excalidraw-math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as s4,CURSOR_TYPE as Hx,MAX_ZOOM as Gx,MIN_ZOOM as Ux,THEME as Ga,ZOOM_STEP as pu,getShortcutKey as Wx,updateActiveTool as ci,CODES as Po,KEYS as $o}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as c4}from"@haoxin-web/excalidraw-element";import{newElementWith as d4}from"@haoxin-web/excalidraw-element";import{getCommonBounds as m4}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as po}from"@haoxin-web/excalidraw-element";import{useEffect as t4}from"react";import{jsx as r4}from"react/jsx-runtime";var si=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},lu=(e,o,t="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-r.width/2;l<0?l=a:l+r.width>=n&&(l=n-r.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+r.height>=i&&(s=o.top-r.height-a)):(s=o.top-r.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},o4=(e,o,t,r)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=r?"50ch":"10ch",o.style.maxWidth=r?"50ch":"15ch",o.textContent=t;let n=e.getBoundingClientRect();lu(o,n)},mo=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(t4(()=>()=>si().classList.remove("excalidraw-tooltip--visible"),[]),n?null:r4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>o4(i.currentTarget,si(),o,t),onPointerLeave:()=>si().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import bc from"open-color";import{CURSOR_TYPE as su,MIME_TYPES as cu,THEME as Fx}from"@haoxin-web/excalidraw-common";var Ox='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',n4='<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"/>',zx='<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"/>',i4=`data:${cu.svg},${encodeURIComponent(`${Ox}${zx}</svg>`)}`,a4=`data:${cu.svg},${encodeURIComponent(`${Ox}${n4}${zx}</svg>`)}`,Zt=e=>{e&&(e.style.cursor="")},ye=(e,o)=>{e&&(e.style.cursor=o)},Lo,Bx,du=(e,o)=>{let r=()=>{let n=o===Fx.DARK;Lo=document.createElement("canvas"),Lo.theme=o,Lo.height=20,Lo.width=20;let i=Lo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Lo.width/2,Lo.height/2,5,0,2*Math.PI),i.fillStyle=n?bc.black:bc.white,i.fill(),i.strokeStyle=n?bc.white:bc.black,i.stroke(),Bx=Lo.toDataURL(cu.svg)};(!Lo||Lo.theme!==o)&&r(),ye(e,`url(${Bx}) ${20/2} ${20/2}, auto`)},Ot=(e,o)=>{if(e)if(o.activeTool.type==="selection")Zt(e);else if(Ho(o))e.style.cursor=su.GRAB;else if(St(o))du(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===Fx.LIGHT?i4:a4;e.style.cursor=`url(${t}), auto`}else if(o.activeTool.type==="laserTrail"){let t=`url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18"><circle cx="9" cy="9" r="5" fill="orange" opacity="0.5"/><circle cx="9" cy="9" r="3" fill="red" opacity="0.8"/><circle cx="9" cy="9" r="1.5" fill="white"/></svg>') 9 9, auto`;e.style.cursor=t}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=su.AUTO):e.style.cursor=su.CROSSHAIR};var Zo=({viewportX:e,viewportY:o,nextZoom:t},r)=>{let n=e-r.offsetLeft,i=o-r.offsetTop,a=r.zoom.value,l=r.scrollX+(n-n/a),s=r.scrollY+(i-i/a),m=-(n-n/t),c=-(i-i/t);return{scrollX:l+m,scrollY:s+c,zoom:{value:t}}};import{jsx as vc,jsxs as h4}from"react/jsx-runtime";var xc=F({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?po.IMMEDIATELY:po.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>vc(vr,{palette:null,topPicks:s4,label:h("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:n=>t({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),jo=F({name:"clearCanvas",label:"labels.clearCanvas",icon:Bt,trackEvent:{category:"canvas"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,r)=>(r.imageCache.clear(),{elements:e.map(n=>d4(n,{isDeleted:!0})),appState:{...mr(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:r.defaultSelectionTool}:o.activeTool},captureUpdate:po.IMMEDIATELY})}),Ec=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Qm,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>({appState:{...o,...Zo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:Io(o.zoom.value+pu)},o),userToFollow:null},captureUpdate:po.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>vc(z,{type:"button",className:"zoom-in-button zoom-button",icon:Qm,title:`${h("buttons.zoomIn")} \u2014 ${Wx("CtrlOrCmd++")}`,"aria-label":h("buttons.zoomIn"),disabled:o.zoom.value>=Gx,onClick:()=>{e(null)}}),keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&(e.code===Po.EQUAL||e.code===Po.NUM_ADD)&&(e[$o.CTRL_OR_CMD]||e.shiftKey)}),yc=F({name:"zoomOut",label:"buttons.zoomOut",icon:ep,viewMode:!0,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>({appState:{...o,...Zo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:Io(o.zoom.value-pu)},o),userToFollow:null},captureUpdate:po.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>vc(z,{type:"button",className:"zoom-out-button zoom-button",icon:ep,title:`${h("buttons.zoomOut")} \u2014 ${Wx("CtrlOrCmd+-")}`,"aria-label":h("buttons.zoomOut"),disabled:o.zoom.value<=Ux,onClick:()=>{e(null)}}),keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&(e.code===Po.MINUS||e.code===Po.NUM_SUBTRACT)&&(e[$o.CTRL_OR_CMD]||e.shiftKey)}),wc=F({name:"resetZoom",label:"buttons.resetZoom",icon:db,viewMode:!0,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>({appState:{...o,...Zo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:Io(1)},o),userToFollow:null},captureUpdate:po.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>vc(mo,{label:h("buttons.resetZoom"),style:{height:"100%"},children:h4(z,{type:"button",className:"reset-zoom-button zoom-button",title:h("buttons.resetZoom"),"aria-label":h("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&(e.code===Po.ZERO||e.code===Po.NUM_ZERO)&&(e[$o.CTRL_OR_CMD]||e.shiftKey)}),p4=(e,o,t=1)=>{let[r,n,i,a]=e,l=i-r,s=o.width/l,m=a-n,c=o.height/m,p=Math.min(s,c)*mu(t,.1,1);return Math.min(p,1)},Yx=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=mu(n,Ux,Gx);let[l,s,m,c]=e,d=(l+m)/2,p=(s+c)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,w=o.width-u-b,E=o.height-f-x,y;if(r){let S=m-l,P=c-s;y=Math.min(w/S,E/P)*n}else y=p4(e,{width:w,height:E},n);let v=Io(mu(l4(y,pu,"floor"),i,a)),C=C1({scenePoint:{x:d,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:C.scrollX,scrollY:C.scrollY,zoom:{value:v}},captureUpdate:po.EVENTUALLY}},di=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=m4(c4(o));return Yx({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},pq=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Os,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return di({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&e.code===Po.TWO&&e.shiftKey&&!e.altKey&&!e[$o.CTRL_OR_CMD]}),uq=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Os,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return di({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&e.code===Po.THREE&&e.shiftKey&&!e.altKey&&!e[$o.CTRL_OR_CMD]}),u4=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Os,viewMode:!0,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>di({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&e.code===Po.ONE&&e.shiftKey&&!e.altKey&&!e[$o.CTRL_OR_CMD]}),cn=F({name:"toggleTheme",label:(e,o)=>o.theme===Ga.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===Ga.LIGHT?ya:wa,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===Ga.LIGHT?Ga.DARK:Ga.LIGHT)},captureUpdate:po.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===Po.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),hq=F({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return St(o)?n=ci(o,{...o.activeTool.lastActiveTool||{type:r.defaultSelectionTool},lastActiveToolBeforeEraser:null}):n=ci(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:po.IMMEDIATELY}},keyTest:e=>e.key===$o.E}),gq=F({name:"toggleLassoTool",label:"toolBar.lasso",icon:xs,trackEvent:{category:"toolbar"},predicate:(e,o,t,r)=>r.defaultSelectionTool!=="lasso",perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=ci(o,{type:"lasso",fromSelection:!1}),ye(r.interactiveCanvas,Hx.CROSSHAIR)):n=ci(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:po.NEVER}}}),Vx=F({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Fs,viewMode:!1,predicate:(e,o,t)=>t.showPanActions!==!1,perform:(e,o,t,r)=>{let n;return Ho(o)?n=ci(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=ci(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),ye(r.interactiveCanvas,Hx.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:po.IMMEDIATELY}},keyTest:(e,o,t,r)=>r.props.showPanActions!==!1&&!e.altKey&&!e[$o.CTRL_OR_CMD]&&e.key===$o.H});import{updateActiveTool as Xx}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as g4}from"@haoxin-web/excalidraw-element";var f4=F({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=Xx(o,{type:"embeddable"});return Ot(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Xx(o,{type:"embeddable"})},captureUpdate:g4.EVENTUALLY}}});import{pointFrom as b4}from"@haoxin-web/excalidraw-math";import{maybeBindLinearElement as x4,bindOrUnbindLinearElement as Kx,isBindingEnabled as E4}from"@haoxin-web/excalidraw-element/binding";import{isValidPolygon as Zx,LinearElementEditor as Ua,newElementWith as uu}from"@haoxin-web/excalidraw-element";import{isBindingElement as Tc,isFreeDrawElement as $x,isLinearElement as jx,isLineElement as Ic}from"@haoxin-web/excalidraw-element";import{KEYS as hu,arrayToMap as gu,tupleToCoors as y4,updateActiveTool as qx}from"@haoxin-web/excalidraw-common";import{isPathALoop as w4}from"@haoxin-web/excalidraw-element";import{isInvisiblySmallElement as fu}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as bu}from"@haoxin-web/excalidraw-element";import{jsx as v4}from"react/jsx-runtime";var zt=F({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,{event:l,sceneCoords:s}=t??{},m=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=Ua.handlePointerUp(l,o.selectedLinearElement,o,r.scene),{startBindingElement:f,endBindingElement:b}=u,x=r.scene.getElement(u.elementId);if(Tc(x)&&Kx(x,f,b,r.scene),u!==o.selectedLinearElement){let w=e;return x&&fu(x)&&(w=w.map(E=>E.id===x.id?uu(E,{isDeleted:!0}):E)),{elements:w,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:bu.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=Ua.getElement(u,m);if(x)return Tc(x)&&Kx(x,f,b,a),Ic(x)&&!Zx(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||fu(x)?e.map(w=>w.id===x.id?uu(w,{isDeleted:!0}):w):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new Ua(x,gu(m),!1)},captureUpdate:bu.IMMEDIATELY}}let c=e;window.document.activeElement instanceof HTMLElement&&i();let d=null;if(o.multiElement)d=o.multiElement;else if(o.newElement?.type==="freedraw"||Tc(o.newElement))d=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let u=m.get(Object.keys(o.selectedElementIds)[0]);u&&(d=u)}if(d){if(o.multiElement&&d.type!=="freedraw"){let{points:u,lastCommittedPoint:f}=d;(!f||u[u.length-1]!==f)&&a.mutateElement(d,{points:d.points.slice(0,-1)})}if(d&&fu(d)&&(c=c.map(u=>u.id===d?.id?uu(u,{isDeleted:!0}):u)),jx(d)||$x(d)){let u=w4(d.points,o.zoom.value);if(u&&(Ic(d)||$x(d))){let f=d.points,b=f[0],x=f.map((w,E)=>E===f.length-1?b4(b[0],b[1]):w);Ic(d)?a.mutateElement(d,{points:x,polygon:!0}):a.mutateElement(d,{points:x})}if(Ic(d)&&!Zx(d.points)&&a.mutateElement(d,{polygon:!1}),Tc(d)&&!u&&d.points.length>1&&E4(o)){let f=s??y4(Ua.getPointAtIndexGlobalCoordinates(d,-1,gu(e)));x4(d,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!d)&&Zt(n);let p;return o.activeTool.type==="eraser"?p=qx(o,{...o.activeTool.lastActiveTool||{type:r.defaultSelectionTool},lastActiveToolBeforeEraser:null}):p=qx(o,{type:r.defaultSelectionTool}),{elements:c,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw"||o.activeTool.type==="line"||o.activeTool.type==="arrow")&&d?o.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:d&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[d.id]:!0}:o.selectedElementIds,selectedLinearElement:d&&jx(d)?new Ua(d,gu(c)):o.selectedLinearElement},captureUpdate:bu.IMMEDIATELY}},keyTest:(e,o)=>e.key===hu.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===hu.ESCAPE||e.key===hu.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>v4(z,{type:"button",icon:wb,title:h("buttons.done"),"aria-label":h("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as ui,DEFAULT_EXPORT_PADDING as pM,EXPORT_SCALES as uM,THEME as yu}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as hM}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as fo}from"@haoxin-web/excalidraw-element";import T4 from"clsx";import{jsx as Jx,jsxs as I4}from"react/jsx-runtime";var Wa=({children:e,checked:o,onChange:t,className:r})=>I4("div",{className:T4("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[Jx("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:gb}),Jx("div",{className:"Checkbox-label",children:e})]});import{THEME as Ya}from"@haoxin-web/excalidraw-common";import{jsx as Va}from"react/jsx-runtime";var eE=e=>{let o=e.title||(e.value===Ya.DARK?h("buttons.lightMode"):h("buttons.darkMode"));return Va(z,{type:"icon",icon:e.value===Ya.LIGHT?Qx.MOON:Qx.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===Ya.DARK?Ya.LIGHT:Ya.DARK),"data-testid":"toggle-dark-mode"})},Qx={SUN:Va("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Va("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:Va("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Va("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 C4}from"react";import{focusNearestParent as S4,KEYS as k4}from"@haoxin-web/excalidraw-common";import{jsx as tE,jsxs as M4}from"react/jsx-runtime";var oE=e=>{let{id:o}=Xe(),[t,r]=C4(e.value),n=a=>{e.ignoreFocus||S4(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===k4.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return M4("div",{className:"ProjectName",children:[tE("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),tE("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as rM,DEFAULT_FILENAME as nM,IMAGE_MIME_TYPES as xE,isFirefox as iM,MIME_TYPES as aM,cloneJSON as lM,SVG_DOCUMENT_PREAMBLE as sM}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as cM}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as dM}from"@haoxin-web/excalidraw-element";import{getElementsOverlappingFrame as mM}from"@haoxin-web/excalidraw-element";import{ALLOWED_PASTE_MIME_TYPES as z4,EXPORT_DATA_TYPES as Za,MIME_TYPES as ho,arrayToMap as H4,isMemberOf as G4,isPromiseLike as U4,EVENT as kc}from"@haoxin-web/excalidraw-common";import{mutateElement as W4}from"@haoxin-web/excalidraw-element";import{deepCopyElement as Y4}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as V4,isInitializedImageElement as X4}from"@haoxin-web/excalidraw-element";import{getContainingFrame as uE}from"@haoxin-web/excalidraw-element";import{pointFrom as Sr}from"@haoxin-web/excalidraw-math";import{COLOR_PALETTE as nE,DEFAULT_CHART_COLOR_INDEX as L4,getAllColorsSpecificShade as P4,DEFAULT_FONT_FAMILY as A4,DEFAULT_FONT_SIZE as iE,VERTICAL_ALIGN as _4,randomId as aE,isDevEnv as lE}from"@haoxin-web/excalidraw-common";import{newTextElement as Cc,newLinearElement as Ka,newElement as Eu}from"@haoxin-web/excalidraw-element";var uo=32,Te=12,kr=256,sE=50,dn="NOT_SPREADSHEET",mi="VALID_SPREADSHEET",Xa=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},xu=(e,o)=>e.slice(1).every(t=>Xa(t[o])!==null),rE=e=>{let o=e[0].length;if(o>2)return{type:dn,reason:"More than 2 columns"};if(o===1){if(!xu(e,0))return{type:dn,reason:"Value is not numeric"};let s=Xa(e[0][0])===null,m=(s?e.slice(1):e).map(c=>Xa(c[0]));return m.length<2?{type:dn,reason:"Less than two rows"}:{type:mi,spreadsheet:{title:s?e[0][0]:null,labels:null,values:m}}}let t=xu(e,0),r=xu(e,1);if(!t&&!r)return{type:dn,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=Xa(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:dn,reason:"Less than 2 rows"}:{type:mi,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>Xa(s[i]))}}},D4=e=>{let o=[];for(let t=0;t<e[0].length;t++){let r=[];for(let n=0;n<e.length;n++)r.push(e[n][t]);o.push(r)}return o},cE=e=>{let o=e.trim().split(`
1
+ import{$ as U1,A as Xm,B as P1,C as A1,D as _1,E as as,F as ha,G as ls,H as ss,I as D1,J as R1,K as ga,L as N1,M as B1,N as F1,O as O1,P as cs,Q as Nn,R as z1,S as HC,T as Km,U as GC,V as Bn,W as fa,Y as H1,_ as G1,a as S1,aa as ds,b as tn,ba as W1,c as Co,ca as Zm,d as k1,da as $m,e as we,ea as ms,f as M1,fa as Y1,g as J,ga as jm,h as rs,ha as Go,i as cr,ia as V1,j as Hm,ja as qm,k as Gm,ka as X1,l as _n,la as K1,m as Um,ma as ps,n as Dn,na as Jm,o as L1,oa as Z1,p as Wm,pa as $1,q as dr,qa as j1,r as mr,ra as us,s as St,t as lo,u as Rn,v as ns,w as Ym,x as ua,y as is,z as Vm}from"./chunk-K64QT3UR.js";import{a as T}from"./chunk-2BESCJKB.js";import{J as zm}from"./chunk-LUHP3LHA.js";import{c as C1}from"./chunk-Z3N5DIM6.js";import{b as T1,c as I1,d as I}from"./chunk-SRAX5OIU.js";import UU,{useEffect as WU}from"react";import{DEFAULT_UI_OPTIONS as _C,isShallowEqual as YU}from"@haoxin-web/excalidraw-common";import m5 from"clsx";import xH from"lodash.throttle";import Ho,{useContext as Qr}from"react";import{flushSync as aa}from"react-dom";import EH from"roughjs/bin/rough";import{nanoid as yH}from"nanoid";import{clamp as p5,pointFrom as le,pointDistance as Zr,vector as u5,pointRotateRads as Mf,vectorScale as wH,vectorFromPoint as Lf,vectorSubtract as h5,vectorDot as g5,vectorNormalize as f5}from"@haoxin-web/excalidraw-math";import{COLOR_PALETTE as vH,CODES as b5,shouldResizeFromCenter as x5,shouldMaintainAspectRatio as Ol,shouldRotateWithDiscreteAngle as Pf,isArrowKey as Cm,KEYS as V,APP_NAME as TH,CURSOR_TYPE as Be,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as IH,DEFAULT_VERTICAL_ALIGN as E5,DRAGGING_THRESHOLD as CH,ELEMENT_SHIFT_TRANSLATE_AMOUNT as SH,ELEMENT_TRANSLATE_AMOUNT as y5,EVENT as oe,FRAME_STYLE as $r,IMAGE_MIME_TYPES as kH,IMAGE_RENDER_TIMEOUT as MH,isBrave as LH,LINE_CONFIRM_THRESHOLD as Af,MAX_ALLOWED_FILE_BYTES as w5,MIME_TYPES as ir,MQ_MAX_HEIGHT_LANDSCAPE as PH,MQ_MAX_WIDTH_LANDSCAPE as AH,MQ_MAX_WIDTH_PORTRAIT as _H,MQ_RIGHT_SIDEBAR_MIN_WIDTH as DH,POINTER_BUTTON as Sn,ROUNDNESS as Sm,SCROLL_TIMEOUT as RH,TAP_TWICE_TIMEOUT as NH,TEXT_TO_CENTER_SNAP_THRESHOLD as BH,THEME as km,THEME_FILTER as FH,TOUCH_CTX_MENU_TIMEOUT as OH,VERTICAL_ALIGN as zH,YOUTUBE_STATES as Mm,ZOOM_STEP as HH,POINTER_EVENTS as la,TOOL_TYPE as bt,isIOS as GH,supportsResizeObserver as v5,DEFAULT_COLLISION_THRESHOLD as T5,DEFAULT_TEXT_ALIGN as UH,ARROW_TYPE as jr,DEFAULT_REDUCED_GLOBAL_ALPHA as WH,isSafari as YH,isLocalLink as VH,normalizeLink as _f,toValidURL as XH,getGridPoint as st,getLineHeight as I5,debounce as C5,distance as sa,getFontString as Df,getNearestScrollableContainer as KH,isInputLike as S5,isToolIcon as ZH,isWritableElement as zl,sceneCoordsToViewportCoords as Lm,tupleToCoors as Rf,viewportCoordsToSceneCoords as We,wrapEvent as $H,updateObject as Nf,updateActiveTool as ar,getShortcutKey as jH,isTransparent as qH,easeToValuesRAF as JH,muteFSAbortError as QH,isTestEnv as n1,isDevEnv as dC,easeOut as eG,updateStable as Hl,addEventListener as Fe,normalizeEOL as tG,getDateTime as k5,isShallowEqual as oG,arrayToMap as Pm,randomInteger as rG,CLASSES as nG,Emitter as kn,isMobile as iG,MINIMUM_ARROW_SIZE as M5,DOUBLE_TAP_POSITION_THRESHOLD as aG}from"@haoxin-web/excalidraw-common";import{getObservedAppState as lG,getCommonBounds as ca,maybeSuggestBindingsForLinearElementAtCoords as L5,getElementAbsoluteCoords as P5,bindOrUnbindLinearElements as A5,fixBindingsAfterDeletion as sG,getHoveredElementForBinding as Bf,isBindingEnabled as Ff,shouldEnableBindingForPointerEvent as cG,updateBoundElements as Of,getSuggestedBindingsForArrows as zf,LinearElementEditor as Le,newElementWith as qr,newFrameElement as dG,newFreeDrawElement as mG,newEmbeddableElement as _5,newMagicFrameElement as D5,newIframeElement as pG,newArrowElement as uG,newElement as hG,newImageElement as gG,newLinearElement as fG,newTextElement as R5,refreshTextDimensions as bG,deepCopyElement as N5,duplicateElements as B5,hasBoundTextElement as F5,isArrowElement as Hf,isBindingElement as Gf,isBindingElementType as O5,isBoundToContainer as Uf,isFrameLikeElement as Rt,isImageElement as Mn,isEmbeddableElement as lr,isInitializedImageElement as Gl,isLinearElement as ro,isLinearElementType as xG,isUsingAdaptiveRadius as EG,isIframeElement as da,isIframeLikeElement as Ul,isMagicFrameElement as Wf,isTextBindableContainer as z5,isElbowArrow as je,isFlowchartNodeElement as yG,isBindableElement as wG,isTextElement as To,getLockedLinearCursorAlignSize as H5,getNormalizedDimensions as vG,isElementCompletelyInViewport as Yf,isElementInViewport as G5,isInvisiblySmallElement as U5,getCornerRadius as TG,isPathALoop as W5,createSrcDoc as Y5,embeddableURLValidator as Vf,maybeParseEmbedSrc as IG,getEmbedLink as Am,getInitializedImageElements as CG,normalizeSVG as V5,updateImageCache as SG,getBoundTextElement as Xf,getContainerCenter as Kf,getContainerElement as X5,isValidTextContainer as kG,redrawTextBoundingBox as MG,shouldShowBoundingBox as LG,getFrameChildren as Zf,isCursorInFrame as K5,addElementsToFrame as $f,replaceAllElementsInFrame as PG,removeElementsFromFrame as AG,getElementsInResizingFrame as jf,getElementsInNewFrame as _G,getContainingFrame as qf,elementOverlapsWithFrame as DG,updateFrameMembershipOfSelectedElements as Z5,isElementInFrame as $5,getFrameLikeTitle as RG,getElementsOverlappingFrame as NG,filterElementsEligibleAsFrameChildren as BG,hitElementBoundText as FG,hitElementBoundingBoxOnly as OG,hitElementItself as Wl,getVisibleSceneBounds as zG,FlowChartCreator as HG,FlowChartNavigator as GG,getLinkDirectionFromKey as j5,cropElement as UG,wrapText as WG,isElementLink as Jf,parseElementLinkFromURL as YG,isMeasureTextSupported as VG,normalizeText as XG,measureText as q5,getLineHeightInPx as KG,getApproxMinLineWidth as ZG,getApproxMinLineHeight as $G,getMinTextElementWidth as jG,ShapeCache as Yl,getRenderOpacity as qG,editGroupForSelectedElement as JG,getElementsInGroup as Ln,getSelectedGroupIdForElement as QG,getSelectedGroupIds as eU,isElementInGroup as J5,isSelectedViaGroup as tU,selectGroupsForSelectedElements as no,syncInvalidIndices as mC,syncMovedIndices as Q5,excludeElementsInFramesFromSelection as oU,getSelectionStateForElements as rU,makeNextSelectedElementIds as ve,getResizeOffsetXY as nU,getResizeArrowDirection as iU,transformElements as aU,getCursorForResizingElement as eC,getElementWithTransformHandleType as tC,getTransformHandleTypeFromCoords as oC,dragNewElement as rC,dragSelectedElements as lU,getDragOffsetXY as sU,isNonDeletedElement as nC,Scene as iC,Store as cU,CaptureUpdateAction as Ct,hitElementBoundingBox as dU,isLineElement as Qf,isSimpleArrow as mU,StoreDelta as aC,positionElementsOnGrid as lC}from"@haoxin-web/excalidraw-element";import{KEYS as vp,updateActiveTool as tS}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as Tp}from"@haoxin-web/excalidraw-element";import{fixBindingsAfterDeletion as oS}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as O0}from"@haoxin-web/excalidraw-element";import{newElementWith as Ks}from"@haoxin-web/excalidraw-element";import{getContainerElement as z0}from"@haoxin-web/excalidraw-element";import{isBoundToContainer as Vs,isElbowArrow as rS,isFrameLikeElement as nS}from"@haoxin-web/excalidraw-element";import{getFrameChildren as iS}from"@haoxin-web/excalidraw-element";import{getElementsInGroup as Ip,selectGroupsForSelectedElements as aS}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as Xs}from"@haoxin-web/excalidraw-element";import{isDevEnv as VC}from"@haoxin-web/excalidraw-common";import{atom as he,createStore as UC}from"jotai";import{createIsolation as WC}from"jotai-scope";var q1=WC();var{useAtom:ce,useSetAtom:pr,useAtomValue:hs,useStore:jU}=q1,J1=q1.Provider,Ve=UC();var YC=T1({"./locales/ar-SA.json":()=>import("./locales/ar-SA-G6X2FPQ2.js"),"./locales/az-AZ.json":()=>import("./locales/az-AZ-76LH7QW2.js"),"./locales/bg-BG.json":()=>import("./locales/bg-BG-XCXSNQG7.js"),"./locales/bn-BD.json":()=>import("./locales/bn-BD-2XOGV67Q.js"),"./locales/ca-ES.json":()=>import("./locales/ca-ES-6MX7JW3Y.js"),"./locales/cs-CZ.json":()=>import("./locales/cs-CZ-2BRQDIVT.js"),"./locales/da-DK.json":()=>import("./locales/da-DK-5WZEPLOC.js"),"./locales/de-DE.json":()=>import("./locales/de-DE-XR44H4JA.js"),"./locales/el-GR.json":()=>import("./locales/el-GR-BZB4AONW.js"),"./locales/en.json":()=>import("./locales/en-45K2M6JH.js"),"./locales/es-ES.json":()=>import("./locales/es-ES-U4NZUMDT.js"),"./locales/eu-ES.json":()=>import("./locales/eu-ES-A7QVB2H4.js"),"./locales/fa-IR.json":()=>import("./locales/fa-IR-HGAKTJCU.js"),"./locales/fi-FI.json":()=>import("./locales/fi-FI-Z5N7JZ37.js"),"./locales/fr-FR.json":()=>import("./locales/fr-FR-RHASNOE6.js"),"./locales/gl-ES.json":()=>import("./locales/gl-ES-HMX3MZ6V.js"),"./locales/he-IL.json":()=>import("./locales/he-IL-6SHJWFNN.js"),"./locales/hi-IN.json":()=>import("./locales/hi-IN-IWLTKZ5I.js"),"./locales/hu-HU.json":()=>import("./locales/hu-HU-A5ZG7DT2.js"),"./locales/id-ID.json":()=>import("./locales/id-ID-SAP4L64H.js"),"./locales/it-IT.json":()=>import("./locales/it-IT-JPQ66NNP.js"),"./locales/ja-JP.json":()=>import("./locales/ja-JP-DBVTYXUO.js"),"./locales/kaa.json":()=>import("./locales/kaa-6HZHGXH3.js"),"./locales/kab-KAB.json":()=>import("./locales/kab-KAB-ZGHBKWFO.js"),"./locales/kk-KZ.json":()=>import("./locales/kk-KZ-P5N5QNE5.js"),"./locales/km-KH.json":()=>import("./locales/km-KH-HSX4SM5Z.js"),"./locales/ko-KR.json":()=>import("./locales/ko-KR-MTYHY66A.js"),"./locales/ku-TR.json":()=>import("./locales/ku-TR-6OUDTVRD.js"),"./locales/lt-LT.json":()=>import("./locales/lt-LT-XHIRWOB4.js"),"./locales/lv-LV.json":()=>import("./locales/lv-LV-5QDEKY6T.js"),"./locales/mr-IN.json":()=>import("./locales/mr-IN-CRQNXWMA.js"),"./locales/my-MM.json":()=>import("./locales/my-MM-5M5IBNSE.js"),"./locales/nb-NO.json":()=>import("./locales/nb-NO-T6EIAALU.js"),"./locales/nl-NL.json":()=>import("./locales/nl-NL-IS3SIHDZ.js"),"./locales/nn-NO.json":()=>import("./locales/nn-NO-6E72VCQL.js"),"./locales/oc-FR.json":()=>import("./locales/oc-FR-POXYY2M6.js"),"./locales/pa-IN.json":()=>import("./locales/pa-IN-N4M65BXN.js"),"./locales/percentages.json":()=>import("./locales/percentages-BXMCSKIN.js"),"./locales/pl-PL.json":()=>import("./locales/pl-PL-T2D74RX3.js"),"./locales/pt-BR.json":()=>import("./locales/pt-BR-5N22H2LF.js"),"./locales/pt-PT.json":()=>import("./locales/pt-PT-UZXXM6DQ.js"),"./locales/ro-RO.json":()=>import("./locales/ro-RO-JPDTUUEW.js"),"./locales/ru-RU.json":()=>import("./locales/ru-RU-B4JR7IUQ.js"),"./locales/si-LK.json":()=>import("./locales/si-LK-N5RQ5JYF.js"),"./locales/sk-SK.json":()=>import("./locales/sk-SK-C5VTKIMK.js"),"./locales/sl-SI.json":()=>import("./locales/sl-SI-NN7IZMDC.js"),"./locales/sv-SE.json":()=>import("./locales/sv-SE-XGPEYMSR.js"),"./locales/ta-IN.json":()=>import("./locales/ta-IN-2NMHFXQM.js"),"./locales/th-TH.json":()=>import("./locales/th-TH-HPSO5L25.js"),"./locales/tr-TR.json":()=>import("./locales/tr-TR-DEFEU3FU.js"),"./locales/uk-UA.json":()=>import("./locales/uk-UA-QMV73CPH.js"),"./locales/vi-VN.json":()=>import("./locales/vi-VN-M7AON7JQ.js"),"./locales/zh-CN.json":()=>import("./locales/zh-CN-WHMBMDLP.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-E62DVLB3.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-RAJ6MFWO.js")});var XC=85,So={code:"en",label:"English"},On=[So,...[{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=>C1[e.code]>=XC).sort((e,o)=>e.label>o.label?1:-1)],fs="__test__";VC()&&On.unshift({code:fs,label:"test language"},{code:`${fs}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Fn=So,gs={},bs=async e=>{if(Fn=e,document.documentElement.dir=Fn.rtl?"rtl":"ltr",document.documentElement.lang=Fn.code,e.code.startsWith(fs))gs={};else try{gs=await YC(`./locales/${Fn.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),gs=zm}Ve.set(eb,e.code)},Uo=()=>Fn,Q1=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},h=(e,o,t)=>{if(Fn.code.startsWith(fs))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=Q1(gs,r)||Q1(zm,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)n=n.replace(`{{${i}}}`,String(o[i]));return n},eb=he(So.code),Ye=()=>{let e=hs(eb);return{t:h,langCode:e}};import KC from"clsx";import ZC from"open-color";import nt from"react";import{THEME as $C}from"@haoxin-web/excalidraw-common";import{Fragment as Ee,jsx as g,jsxs as D}from"react/jsx-runtime";var so=e=>"var(--icon-fill-color)",tb=e=>e===$C.LIGHT?ZC.white:"#1e1e1e",A=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:i,...a}=typeof o=="number"?{width:o}:o;return g("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:KC({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?g("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},re={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},pW=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:3,y:8,width:18,height:4,rx:1}),g("line",{x1:12,y1:8,x2:12,y2:21}),g("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),g("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),zn=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),g("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),g("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),g("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),H),ob=A(D("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),H),rb=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"1"}),g("circle",{cx:"12",cy:"19",r:"1"}),g("circle",{cx:"12",cy:"5",r:"1"})]}),H),nb=A(D("svg",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),g("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),g("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),H),Qm=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M6.5 9.5l3.5 -3"}),g("path",{d:"M14 5.5l3 1.5"}),g("path",{d:"M18.5 10l-2.5 7"}),g("path",{d:"M13.5 17.5l-7 -5"})]}),H),on=A(D("g",{children:[g("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"}),g("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"}),g("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:g("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"})}),g("g",{mask:"url(#UnlockedIcon)",children:g("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"})})]}),re),Hn=A(D("g",{strokeWidth:"1.25",children:[g("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"}),g("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),g("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"})]}),re),ib=A(g("g",{fill:"currentColor",children:g("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}),ab=A(D(Ee,{children:[g("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"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),g("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"}),lb=A(D(Ee,{children:[g("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"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),g("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"}),sb=A(D(Ee,{children:[g("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"}),g("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),g("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"}),uW=A(g("g",{fill:"currentColor",children:g("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"}),ba=A(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),xs=A(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[g("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"}),g("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),ko=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),H),ur=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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),hr=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"})]}),H),gr=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.363 3.591l-8.106 13.534a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636 -2.87L13.637 3.59a1.914 1.914 0 0 0 -3.274 0z"})]}),H),fr=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3.5l2.472 4.81 5.313.773-3.843 3.746.907 5.292L12 15.9 7.151 18.12l.907-5.292L4.215 9.083l5.313-.773L12 3.5z"})]}),H),Es=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 6h12a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h-6l-4 3v-3h-2a3 3 0 0 1 -3 -3v-5a3 3 0 0 1 3 -3z"})]}),H),ys=A(D("g",{fill:"none",stroke:"currentColor",children:[g("path",{d:"M6 8 L6 16 L18 16 L18 18 L22 12 L18 6 L18 8 L6 8 Z",strokeWidth:"1.5",fill:"none"}),g("path",{d:"M7 8.5 L7 15.5 L17 15.5 L17 17 L21 12 L17 7 L17 8.5 L7 8.5 Z",strokeWidth:"0.5",opacity:"0.3",fill:"none"})]}),H),ws=A(D("g",{fill:"none",stroke:"currentColor",children:[g("path",{d:"M8 8 L8 16 L4 12 L8 8 Z",fill:"none",strokeWidth:"1.5"}),g("path",{d:"M8 10 L16 10 M8 14 L16 14",fill:"none",strokeLinecap:"round",strokeWidth:"1.5"}),g("path",{d:"M16 8 L16 16 L20 12 L16 8 Z",strokeWidth:"1.5",fill:"none"})]}),H),rn=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),g("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),H),vs=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),g("line",{x1:"5",y1:"12",x2:"9",y2:"8"}),g("line",{x1:"5",y1:"12",x2:"9",y2:"16"}),g("line",{x1:"19",y1:"12",x2:"15",y2:"8"}),g("line",{x1:"19",y1:"12",x2:"15",y2:"16"})]}),H),co=A(g("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),re),cb=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),g("path",{d:"M16 7h4"}),g("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),H),Nt=A(D("g",{strokeWidth:"1.25",children:[g("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"}),g("path",{d:"m11.25 5.417 3.333 3.333"})]}),re),Ts=A(D("g",{strokeWidth:1.25,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",transform:"translate(0,-2)",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 15l4 4l8-8l-4-4l-8 8z"}),g("path",{d:"M13 7l3 3"}),g("path",{d:"M4 16l3 3"})]}),re),Wo=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),g("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),g("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),g("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),g("polyline",{points:"5 20 11 4 13 4 20 20"})]}),H),db=A(D("g",{strokeWidth:"1.25",children:[g("path",{d:"M12.5 6.667h.01"}),g("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"}),g("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),g("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),re),xa=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M18 13.3l-6.3 -6.3"})]}),H),ep=A(g("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),re),tp=A(g("path",{d:"M5 10h10",strokeWidth:"1.25"}),re),mb=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 21l-6 -6"}),g("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"}),g("path",{d:"M3 4v4h4"})]}),H),Bt=A(g("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"}),re),pb=A(D("g",{strokeWidth:"1.5",children:[g("polyline",{points:"12 16 18 10 12 4"}),g("polyline",{points:"8 4 2 10 8 16"})]}),re),Ea=A(D("g",{strokeWidth:"1.25",children:[g("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"}),g("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"})]}),re),ya=A(g("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"}),re),wa=A(g("g",{stroke:"currentColor",strokeLinejoin:"round",children:g("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"})}),{...re,strokeWidth:1.5}),Is=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),g("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),H),nn=A(g("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"}),re),Gn=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),ub=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"12",cy:"12",r:"9"}),g("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),op=A(g("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"}),re),Cs=A(g("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"}),re),hb=A(D("g",{strokeWidth:"1.25",children:[g("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"}),g("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"})]}),re),gb=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),g("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),H),fb=A(g("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),va=A(D("g",{strokeWidth:"1.25",children:[g("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"}),g("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"})]}),re),bb=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}),xb=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}),Un=A(g("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"}),re),hW=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}),Eb=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"),Ss=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),g("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),g("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),H),yb=A(g("g",{strokeWidth:1.5,children:g("path",{d:"M6 18l12 -12"})}),H),ks=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 8h.01"}),g("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),g("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),g("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),g("path",{d:"M19 16v6"}),g("path",{d:"M22 19l-3 3l-3 -3"})]}),H),wb=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}),gW=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}),fW=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}),vb=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"),bW=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"),rp=A(g("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"}),re),np=A(g("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"}),re),Tb=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}),Ib=A(g("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"}),re),xW=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"),EW=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}),yW=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M12 14v-11"}),g("path",{d:"M9 6l3 -3l3 3"})]}),H),wW=A(D(Ee,{children:[g("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"}),g("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}),vW=A(g("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}),Cb=D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 10l0 10"}),g("path",{d:"M12 10l4 4"}),g("path",{d:"M12 10l-4 4"}),g("path",{d:"M4 4l16 0"})]}),Sb=D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 5l0 14"}),g("path",{d:"M16 9l-4 -4"}),g("path",{d:"M8 9l4 -4"})]}),ip=A(Sb,H),ap=A(Sb,{...H,style:{transform:"rotate(180deg)"}}),lp=A(Cb,H),sp=A(Cb,{...H,style:{transform:"rotate(180deg)"}}),cp=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),dp=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),mp=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),pp=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),kb=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),Mb=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),up=A(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),g("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),re),hp=A(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[g("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),g("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),g("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),g("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"})]}),re),Ms=A(D("g",{strokeWidth:"1.5",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("circle",{cx:"9",cy:"7",r:"4"}),g("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),g("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),g("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),H),TW=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"),IW=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"),Vt=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M15 5 5 15M5 5l10 10"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),CW=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}),SW=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}),kW=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}),gp=nt.memo(({theme:e})=>A(D(Ee,{children:[g("path",{d:"M25 26H111V111H25",fill:so(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:so(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:so(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:so(e),strokeWidth:"2"}),D("g",{fill:tb(e),stroke:so(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),fp=nt.memo(({theme:e})=>A(D(Ee,{children:[g("path",{d:"M25 26H111V111H25",fill:so(e)}),g("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:so(e),strokeWidth:"2"}),g("path",{d:"M100 100H160V160H100",fill:so(e)}),g("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:so(e),strokeWidth:"2"}),D("g",{fill:tb(e),stroke:so(e),strokeWidth:"6",children:[g("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),g("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),g("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),g("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Lb=A(g("g",{strokeWidth:1.25,children:g("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"})}),re),Ls=A(D(Ee,{children:[g("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"}),g("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:g("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"})}),g("g",{mask:"url(#FillHachureIcon)",children:g("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"})})]}),re),Ps=A(D(Ee,{children:[D("g",{clipPath:"url(#a)",children:[g("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"}),g("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:g("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"})}),g("g",{mask:"url(#FillCrossHatchIcon)",children:g("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"})})]}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),As=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",children:g("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"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...re,fill:"currentColor"}),Wn=A(g(Ee,{children:g("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),re),Ta=A(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),re),Ia=A(g("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),re),MW=nt.memo(({theme:e})=>A(g("path",{d:"M6 10H34",stroke:so(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Pb=A(D("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12h2"}),g("path",{d:"M17 12h2"}),g("path",{d:"M11 12h2"})]}),H),Ab=A(D("g",{strokeWidth:"2",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M8 12v.01"}),g("path",{d:"M12 12v.01"}),g("path",{d:"M16 12v.01"}),g("path",{d:"M20 12v.01"})]}),H),_b=A(g("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"}),re),Db=A(g("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"}),re),Rb=A(g("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"}),re),Nb=A(D("svg",{strokeWidth:"1.5",children:[g("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"}),g("path",{d:"M13.3333 3.33331V3.34331"}),g("path",{d:"M16.6667 3.33331V3.34331"}),g("path",{d:"M16.6667 6.66669V6.67669"}),g("path",{d:"M16.6667 10V10.01"}),g("path",{d:"M3.33334 13.3333V13.3433"}),g("path",{d:"M16.6667 13.3333V13.3433"}),g("path",{d:"M3.33334 16.6667V16.6767"}),g("path",{d:"M6.66666 16.6667V16.6767"}),g("path",{d:"M10 16.6667V16.6767"}),g("path",{d:"M13.3333 16.6667V16.6767"}),g("path",{d:"M16.6667 16.6667V16.6767"})]}),re),Bb=A(D("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),g("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),g("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),g("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),g("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),g("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),g("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),g("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),g("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),g("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),g("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),g("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),H),Fb=A(D("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[g("path",{d:"M12 12l9 0"}),g("path",{d:"M3 9l6 6"}),g("path",{d:"M3 15l6 -6"})]}),H),Ob=nt.memo(({flip:e=!1})=>A(D("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[g("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),g("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),zb=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Hb=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[g("path",{d:"M26 10L6 10"}),g("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Gb=nt.memo(({flip:e=!1})=>A(g("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:g("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),Ub=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[g("path",{d:"M32 10L6 10",strokeWidth:2}),g("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),Wb=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[g("path",{d:"M6,9.5H27"}),g("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),Yb=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Vb=nt.memo(({flip:e=!1})=>A(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{d:"M6,9.5H20"}),g("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Xb=nt.memo(({flip:e=!1})=>A(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Kb=nt.memo(({flip:e=!1})=>A(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),Zb=nt.memo(({flip:e=!1})=>A(g("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:g("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),$b=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",children:g("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"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),jb=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),qb=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",children:g("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),Jb=A(g(Ee,{children:g("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"})}),re),an=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 7v-2h13v2"}),g("path",{d:"M10 5v14"}),g("path",{d:"M12 19h-4"}),g("path",{d:"M15 13v-1h6v1"}),g("path",{d:"M18 12v7"}),g("path",{d:"M17 19h2"})]}),H),Qb=A(g(Ee,{children:D("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 12h10"}),g("path",{d:"M7 5v14"}),g("path",{d:"M17 5v14"}),g("path",{d:"M15 19h4"}),g("path",{d:"M15 5h4"}),g("path",{d:"M5 19h4"}),g("path",{d:"M5 5h4"})]})}),H),Ca=A(g(Ee,{children:g("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("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"})})}),re),_s=A(D(Ee,{children:[g("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:g("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),g("defs",{children:g("clipPath",{id:"a",children:g("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),Ds=A(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),g("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),H),Rs=A(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),g("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),H),Ns=A(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),g("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),g("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),H),e0=nt.memo(({theme:e})=>A(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),g("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),H)),t0=nt.memo(({theme:e})=>A(D("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),g("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),H)),o0=nt.memo(({theme:e})=>A(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),g("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),g("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),H)),Bs=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M21 19h-18l9 -15"}),g("path",{d:"M20.615 15.171h.015"}),g("path",{d:"M19.515 11.771h.015"}),g("path",{d:"M17.715 8.671h.015"}),g("path",{d:"M15.415 5.971h.015"})]}),H),r0=A(g("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}),LW=A(g("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"})),Fs=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),g("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),g("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),g("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),bp=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),g("path",{d:"M7 11l5 5l5 -5"}),g("path",{d:"M12 4l0 12"})]}),H),Yn=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("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),n0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M9.15 14.85l8.85 -10.85"}),g("path",{d:"M6 4l8.85 10.85"})]}),H),i0=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),g("path",{d:"M12 17l0 .01"}),g("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),PW=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M7 4v16l13 -8z"})]}),H),AW=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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),a0=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 12l5 5l10 -10"})]}),H),l0=A(D(Ee,{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M12 9v4"}),g("path",{d:"M12 17h.01"})]}),H),s0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11 7l6 6"}),g("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),H),c0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l-4 7h8z"}),g("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),g("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),H),Vn=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 7l16 0"}),g("path",{d:"M4 17l16 0"}),g("path",{d:"M7 4l0 16"}),g("path",{d:"M17 4l0 16"})]}),H),d0=A(g("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),Xn=A(D("g",{strokeWidth:"1.25",children:[g("path",{d:"M4.16602 10H15.8327"}),g("path",{d:"M12.5 13.3333L15.8333 10"}),g("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),re),m0=A(D("g",{strokeWidth:1.5,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{d:"M5 12h10"}),g("path",{d:"M11 8l4 4l-4 4"})]}),H),p0=A(D("g",{strokeWidth:1.5,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[g("path",{d:"M5 12h14"}),g("path",{d:"M9 8l-4 4l4 4"}),g("path",{d:"M15 8l4 4l-4 4"})]}),H),Yo=A(D("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[g("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"}),g("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),u0=A(D("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[g("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"}),g("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"}),g("circle",{cx:"3",cy:"16",r:"0.8",fill:"currentColor",opacity:"0.7"}),g("circle",{cx:"5",cy:"18",r:"0.6",fill:"currentColor",opacity:"0.5"}),g("circle",{cx:"7.5",cy:"17",r:"0.8",fill:"currentColor",opacity:"0.6"}),g("circle",{cx:"10",cy:"19",r:"0.4",fill:"currentColor",opacity:"0.3"})]}),20),h0=A(D("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("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"}),g("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),_W=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z"}),g("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),g("path",{d:"M15 6l3 3"}),g("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"}),g("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),DW=A(D("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),g("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),g("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"}),g("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),g("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),g("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),g0=A(D("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),g("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),g("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),g("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),H),Kn=A(D("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),g("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),f0=A(D("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),g("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"}),g("path",{d:"M3 3l18 18"})]}),H),b0=A(D("g",{stroke:"currentColor",fill:"none",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("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"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),x0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("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"}),g("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),g("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),g("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),g("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),Ft=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),g("path",{d:"M21 21l-6 -6"})]}),H),E0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),g("path",{d:"M12 7v5l3 3"}),g("path",{d:"M19 16l-2 3h4l-2 3"})]}),H),y0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M5 10a7 7 0 0 0 14 0"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),H),w0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 3l18 18"}),g("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"}),g("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),g("path",{d:"M8 21l8 0"}),g("path",{d:"M12 17l0 4"})]}),H),Sa=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),H),v0=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M12 20v.01"}),g("path",{d:"M16 20v.01"}),g("path",{d:"M8 20v.01"}),g("path",{d:"M4 20v.01"}),g("path",{d:"M4 16v.01"}),g("path",{d:"M4 12v.01"}),g("path",{d:"M4 8v.01"}),g("path",{d:"M4 4v.01"}),g("path",{d:"M8 4v.01"}),g("path",{d:"M12 4v.01"}),g("path",{d:"M16 4v.01"}),g("path",{d:"M20 4v.01"}),g("path",{d:"M20 8v.01"}),g("path",{d:"M20 12v.01"}),g("path",{d:"M20 16v.01"}),g("path",{d:"M20 20v.01"})]}),H),T0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 3v18"}),g("path",{d:"M19 21v-18"}),g("path",{d:"M5 7h14"}),g("path",{d:"M5 15h14"}),g("path",{d:"M8 13v4"}),g("path",{d:"M11 13v4"}),g("path",{d:"M16 13v4"}),g("path",{d:"M14 5v4"}),g("path",{d:"M11 5v4"}),g("path",{d:"M8 5v4"}),g("path",{d:"M3 21h18"})]}),H),I0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 12l18 0"}),g("path",{d:"M7 16l10 0l-10 5l0 -5"}),g("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),H),C0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M12 3l0 18"}),g("path",{d:"M16 7l0 10l5 0l-5 -10"}),g("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),H),xp=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),g("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),Os=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),g("path",{d:"M22 22l-3 -3"}),g("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),g("path",{d:"M3 11v-1"}),g("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),g("path",{d:"M10 3h1"}),g("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),H),S0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("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"}),g("path",{d:"M10 15l2 6l2 -6"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),H),k0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),g("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),g("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),g("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),g("path",{d:"M11 21v-6l3 6v-6"})]}),H),M0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M4 8l5 0"}),g("path",{d:"M15 8l4 0"})]}),H),L0=A(D("g",{strokeWidth:1.25,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),g("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),g("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),H),P0=A(D("g",{stroke:"currentColor",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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}),RW=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M21 12h-13l3 -3"}),g("path",{d:"M11 15l-3 -3"})]}),H),A0=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("path",{d:"M10 9l5 3l-5 3z"})]}),H),_0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M3 6h18"}),g("path",{d:"M3 12h18"}),g("path",{d:"M3 18h18"}),g("path",{d:"M6 3v18"}),g("path",{d:"M12 3v18"}),g("path",{d:"M18 3v18"})]}),H),D0=A(D("g",{strokeWidth:1.5,children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("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"}),g("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"}),g("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),H),zs=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 18l12 -12"}),g("path",{d:"M18 10v-4h-4"})]}),H),Hs=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),g("path",{d:"M18 4l3 3l-3 3"})]}),H),Gs=A(D("g",{children:[g("path",{d:"M16,12L20,9L16,6"}),g("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),Us=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 9l6 6l6 -6"})]}),H),R0=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),H),N0=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M6 15l6 -6l6 6"})]}),H),Ep=A(D("g",{strokeWidth:"1.25",children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),g("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),H),Ws=A(D("g",{children:[g("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),g("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),g("path",{d:"M5 7l0 10"}),g("path",{d:"M7 5l10 0"}),g("path",{d:"M7 19l10 0"}),g("path",{d:"M19 7l0 10"})]}),H);import B0 from"clsx";import wp,{useEffect as JC,useRef as F0,useState as QC}from"react";import{isPromiseLike as eS}from"@haoxin-web/excalidraw-common";import jC from"react";import{jsx as yp}from"react/jsx-runtime";var qC=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(jC.useRef(Date.now()).current%1600);return yp("div",{className:`Spinner ${r}`,children:yp("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:yp("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},it=qC;import{jsx as ka,jsxs as Ma}from"react/jsx-runtime";var z=wp.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=Xe(),a=wp.useRef(null);wp.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,m]=QC(!1),c=F0(!0),d=async u=>{let f="onClick"in r&&r.onClick?.(u);if(eS(f))try{m(!0),await f}catch(b){if(b instanceof Dn)console.warn(b);else throw b}finally{c.current&&m(!1)}};JC(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=F0(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return Ma("button",{className:B0("ToolIcon_type_button",l,t,o&&!r.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!r.hidden,"ToolIcon--selected":r.selected,"ToolIcon--plain":r.type==="icon"}),style:r.style,"data-testid":r["data-testid"],hidden:r.hidden,title:r.title,"aria-label":r["aria-label"],type:u,onClick:d,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&Ma("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&ka("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&ka(it,{})]}),r.showAriaLabel&&Ma("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&ka(it,{})]}),r.children]})}return Ma("label",{className:B0("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[ka("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:r.name,"aria-label":r["aria-label"],"aria-keyshortcuts":r["aria-keyshortcuts"],"data-testid":r["data-testid"],id:`${i}-${r.id}`,onChange:()=>{r.onChange?.({pointerType:p.current})},checked:r.checked,ref:a}),Ma("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&ka("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});z.displayName="ToolButton";var Ys=[],F=e=>(Ys=Ys.concat(e),e);import{jsx as sS}from"react/jsx-runtime";var lS=(e,o,t)=>{let r=new Set(J(e.filter(c=>nS(c)),o).map(c=>c.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let c of r){let d=iS(e,c);for(let p of d)if(!a.has(p.id)){if(Vs(p)){let u=z0(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(c=>{if(o.selectedElementIds[c.id]){let d=Vs(c)?z0(c,i):null;return c.frameId&&r.has(c.frameId)?(l=!1,n[c.id]=!0,c):d?.frameId&&r.has(d?.frameId)?c:(c.boundElements&&c.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&rS(u)&&t.scene.mutateElement(u,{startBinding:c.id===u.startBinding?.elementId?null:u.startBinding,endBinding:c.id===u.endBinding?.elementId?null:u.endBinding})}),Ks(c,{isDeleted:!0}))}return c.frameId&&r.has(c.frameId)?(l=!1,Vs(c)||(n[c.id]=!0),Ks(c,{frameId:null})):Vs(c)&&o.selectedElementIds[c.containerId]?Ks(c,{isDeleted:!0}):c}),m=o.editingGroupId;if(l&&o.editingGroupId){let c=Ip(s,o.editingGroupId).filter(d=>!d.isDeleted);if(c.length>1)c[0]&&(n[c[0].id]=!0);else{m=null,c[0]&&(n[c[0].id]=!0);let d=c[0];if(d){let p=d.groupIds.findIndex(f=>f===o.editingGroupId),u=d.groupIds[p+1];if(u){let f=Ip(s,u).filter(b=>!b.isDeleted);f.length>1&&(m=u,f.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...aS({selectedElementIds:n,editingGroupId:m},s,o,null)}}},H0=(e,o)=>{if(e.editingGroupId){let t=Ip(Tp(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},La=F({name:"deleteSelectedElements",label:"labels.delete",icon:Bt,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:m}=o.selectedLinearElement,c=r.scene.getNonDeletedElementsMap(),d=O0.getElement(a,c);if(!d||l==null)return!1;if(l.length>=d.points.length){let u=e.map(b=>b.id===d.id?Ks(b,{isDeleted:!0}):b),f=H0(o,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:Xs.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:m};return O0.deletePoints(d,r,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:Xs.IMMEDIATELY}}let{elements:n,appState:i}=lS(e,o,r);return oS(n,n.filter(a=>a.isDeleted)),i=H0(i,n),{elements:n,appState:{...i,activeTool:tS(o,{type:r.defaultSelectionTool}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:we(Tp(e),o)?Xs.IMMEDIATELY:Xs.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===vp.BACKSPACE||e.key===vp.DELETE)&&!e[vp.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>sS(z,{type:"button",icon:Bt,title:h("labels.delete"),"aria-label":h("labels.delete"),onClick:()=>t(null),visible:we(Tp(e),o)})});import{KEYS as Zn,CODES as $n,getShortcutKey as jn,isDarwin as Zs}from"@haoxin-web/excalidraw-common";import{moveOneLeft as cS,moveOneRight as dS,moveAllLeft as mS,moveAllRight as pS}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as $s}from"@haoxin-web/excalidraw-element";import{jsx as js}from"react/jsx-runtime";var Cp=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:ap,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:cS(e,o,r.scene),appState:o,captureUpdate:$s.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Zn.CTRL_OR_CMD]&&!e.shiftKey&&e.code===$n.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.sendBackward")} \u2014 ${jn("CtrlOrCmd+[")}`,children:ap})}),Sp=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:ip,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:dS(e,o,r.scene),appState:o,captureUpdate:$s.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Zn.CTRL_OR_CMD]&&!e.shiftKey&&e.code===$n.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.bringForward")} \u2014 ${jn("CtrlOrCmd+]")}`,children:ip})}),kp=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:sp,trackEvent:{category:"element"},perform:(e,o)=>({elements:mS(e,o),appState:o,captureUpdate:$s.IMMEDIATELY}),keyTest:e=>Zs?e[Zn.CTRL_OR_CMD]&&e.altKey&&e.code===$n.BRACKET_LEFT:e[Zn.CTRL_OR_CMD]&&e.shiftKey&&e.code===$n.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${h("labels.sendToBack")} \u2014 ${Zs?jn("CtrlOrCmd+Alt+["):jn("CtrlOrCmd+Shift+[")}`,children:sp})}),Mp=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:lp,trackEvent:{category:"element"},perform:(e,o)=>({elements:pS(e,o),appState:o,captureUpdate:$s.IMMEDIATELY}),keyTest:e=>Zs?e[Zn.CTRL_OR_CMD]&&e.altKey&&e.code===$n.BRACKET_RIGHT:e[Zn.CTRL_OR_CMD]&&e.shiftKey&&e.code===$n.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>js("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${h("labels.bringToFront")} \u2014 ${Zs?jn("CtrlOrCmd+Alt+]"):jn("CtrlOrCmd+Shift+]")}`,children:lp})});import{getNonDeletedElements as uS}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as hS}from"@haoxin-web/excalidraw-element";import{isLinearElement as gS,isTextElement as fS}from"@haoxin-web/excalidraw-element";import{arrayToMap as bS,KEYS as G0}from"@haoxin-web/excalidraw-common";import{selectGroupsForSelectedElements as xS}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as ES}from"@haoxin-web/excalidraw-element";var Lp=F({name:"selectAll",label:"labels.selectAll",icon:v0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing)return!1;let n=e.filter(i=>!i.isDeleted&&!(fS(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...xS({editingGroupId:null,selectedElementIds:n},uS(e),o,r),selectedLinearElement:Object.keys(n).length===1&&gS(e[0])?new hS(e[0],bS(e)):null},captureUpdate:ES.IMMEDIATELY}},keyTest:e=>e[G0.CTRL_OR_CMD]&&e.key===G0.A});import{DEFAULT_GRID_SIZE as U0,KEYS as W0,arrayToMap as Y0,getShortcutKey as yS}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as V0}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as wS}from"@haoxin-web/excalidraw-element";import{getSelectedElements as vS,getSelectionStateForElements as TS}from"@haoxin-web/excalidraw-element";import{syncMovedIndices as IS}from"@haoxin-web/excalidraw-element";import{duplicateElements as CS}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as X0}from"@haoxin-web/excalidraw-element";import{jsx as SS}from"react/jsx-runtime";var Pp=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Ea,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=wS.duplicateSelectedPoints(o,r.scene);return{elements:e,appState:a,captureUpdate:X0.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:i}=CS({type:"in-place",elements:e,idsOfElementsToDuplicate:Y0(vS(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+U0/2,y:a.y+U0/2,frameId:s??a.frameId}}});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:IS(i,Y0(n)),appState:{...o,...TS(n,V0(i),o)},captureUpdate:X0.IMMEDIATELY}},keyTest:e=>e[W0.CTRL_OR_CMD]&&e.key===W0.D,PanelComponent:({elements:e,appState:o,updateData:t})=>SS(z,{type:"button",icon:Ea,title:`${h("labels.duplicateSelection")} \u2014 ${yS("CtrlOrCmd+D")}`,"aria-label":h("labels.duplicateSelection"),onClick:()=>t(null),visible:we(V0(e),o)})});import{pointFrom as kk}from"@haoxin-web/excalidraw-math";import{useEffect as Jp,useMemo as Mk,useRef as Qp,useState as Lk}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as Pk,DEFAULT_ELEMENT_BACKGROUND_PICKS as Ak,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as _k,DEFAULT_ELEMENT_STROKE_PICKS as Dk,ARROW_TYPE as Xo,DEFAULT_FONT_FAMILY as Rk,DEFAULT_FONT_SIZE as Nk,FONT_FAMILY as Bk,ROUNDNESS as uc,STROKE_WIDTH as eu,VERTICAL_ALIGN as pc,KEYS as li,randomInteger as Fk,arrayToMap as ru,getFontFamilyString as Ok,getShortcutKey as zk,getLineHeight as Hk,isTransparent as Gk,reduceToCommonValue as Uk}from"@haoxin-web/excalidraw-common";import{canBecomePolygon as Wk,getNonDeletedElements as Dx}from"@haoxin-web/excalidraw-element";import{bindLinearElement as Lx,calculateFixedPointForElbowArrowBinding as Px,updateBoundElements as Yk}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as tu}from"@haoxin-web/excalidraw-element";import{newElementWith as Qe}from"@haoxin-web/excalidraw-element";import{getBoundTextElement as Cr,redrawTextBoundingBox as Oa}from"@haoxin-web/excalidraw-element";import{isArrowElement as hc,isBoundToContainer as Vk,isElbowArrow as Rx,isLinearElement as ou,isLineElement as Ax,isTextElement as kt,isUsingAdaptiveRadius as Xk}from"@haoxin-web/excalidraw-element";import{hasStrokeColor as Kk}from"@haoxin-web/excalidraw-element";import{updateElbowArrowPoints as Zk,CaptureUpdateAction as et,toggleLinePolygonState as $k}from"@haoxin-web/excalidraw-element";import{isDevEnv as kS}from"@haoxin-web/excalidraw-common";var MS=new Set(["command_palette","export"]),ae=(e,o,t,r)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!MS.has(e)||kS())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import _S from"clsx";import LS from"clsx";import{forwardRef as PS}from"react";import{jsx as AS}from"react/jsx-runtime";var qn=PS((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return AS("button",{type:"button",ref:o,title:t,"data-testid":n,className:LS(r,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as RS,jsx as Ap,jsxs as DS}from"react/jsx-runtime";var Xt=e=>Ap(RS,{children:e.options.map(o=>e.type==="button"?Ap(qn,{icon:o.icon,title:o.text,testId:o.testId,active:o.active??e.value===o.value,onClick:t=>e.onClick(o.value,t)},o.text):DS("label",{className:_S({active:e.value===o.value}),title:o.text,children:[Ap("input",{type:"radio",name:e.group,onChange:()=>e.onChange(o.value),checked:e.value===o.value,"data-testid":o.testId}),o.icon]},o.text))});import*as rc from"@radix-ui/react-popover";import D6 from"clsx";import{useRef as R6}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as N6,COLOR_PALETTE as mx,isTransparent as B6}from"@haoxin-web/excalidraw-common";import{jsx as NS}from"react/jsx-runtime";var qs=()=>NS("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as HS,useRef as GS}from"react";import{createPortal as US}from"react-dom";import{EVENT as xr,KEYS as WS,rgbToHex as YS}from"@haoxin-web/excalidraw-common";import K0 from"react";var _p=K0.createContext(null),xe=()=>K0.useContext(_p);import{useState as BS,useLayoutEffect as Z0}from"react";import{THEME as FS}from"@haoxin-web/excalidraw-common";var Js=e=>{let[o,t]=BS(null),r=pe(),{theme:n}=xe(),{container:i}=Xe();return Z0(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",r.editor.isMobile),o.classList.toggle("theme--dark",n===FS.DARK))},[o,n,r.editor.isMobile,e?.className]),Z0(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),t(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),o};import{useEffect as OS}from"react";import{EVENT as Qs}from"@haoxin-web/excalidraw-common";function Jn(e,o,t){OS(()=>{function r(n){let i=n;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(Qs.POINTER_DOWN,r),document.addEventListener(Qs.TOUCH_START,r),()=>{document.removeEventListener(Qs.POINTER_DOWN,r),document.removeEventListener(Qs.TOUCH_START,r)}},[e,o,t])}import{useRef as zS}from"react";var br=e=>{let o=zS(e);return Object.assign(o.current,e),o.current};import{jsx as VS}from"react/jsx-runtime";var Er=he(null),$0=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=Js({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=xe(),a=yr(),l=Oe(),s=J(a,i),m=br({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:c}=Xe();HS(()=>{let p=d.current;if(!p||!l.canvas||!n)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:S,clientY:P})=>{let M=f.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(P-i.offsetTop)*window.devicePixelRatio,1,1).data;return YS(M[0],M[1],M[2])},x=({clientX:S,clientY:P,altKey:M})=>{p.style.top=`${P+20}px`,p.style.left=`${S+20}px`;let R=b({clientX:S,clientY:P});u&&m.onChange(r,R,m.selectedElements,{altKey:M}),p.style.background=R},w=()=>{m.onCancel()},E=(S,P)=>{m.onSelect(S,P)},y=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,c?.focus(),S.stopImmediatePropagation(),S.preventDefault(),E(b(S),S)},C=S=>{S.key===WS.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),w())};return n.tabIndex=-1,n.focus(),x({clientX:m.app.lastViewportPosition.x,clientY:m.app.lastViewportPosition.y,altKey:!1}),n.addEventListener(xr.KEYDOWN,C),n.addEventListener(xr.POINTER_DOWN,y),n.addEventListener(xr.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(xr.BLUR,w),()=>{u=!1,n.removeEventListener(xr.KEYDOWN,C),n.removeEventListener(xr.POINTER_DOWN,y),n.removeEventListener(xr.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(xr.BLUR,w)}},[m,l.canvas,n,r,c,i.offsetLeft,i.offsetTop]);let d=GS(null);return Jn(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?US(VS("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import*as Qn from"@radix-ui/react-popover";import $S from"clsx";import jS from"react";import{isInteractive as qS}from"@haoxin-web/excalidraw-common";import XS from"react";import KS from"clsx";import{jsx as ZS}from"react/jsx-runtime";var De=XS.forwardRef(({children:e,padding:o,className:t,style:r},n)=>ZS("div",{className:KS("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as Dp,jsxs as JS}from"react/jsx-runtime";var ec=jS.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},m)=>{let c=pe();return Dp(Qn.Portal,{container:o,children:JS(Qn.Content,{ref:m,className:$S("focus-visible-none",e),"data-prevent-outside-click":!0,side:c.editor.isMobile&&!c.viewport.isLandscape?"bottom":"right",align:c.editor.isMobile&&!c.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onCloseAutoFocus:d=>{d.stopPropagation(),d.preventDefault(),o&&!qS(document.activeElement)&&o.focus(),n()},children:[Dp(De,{padding:3,style:r,children:t}),Dp(Qn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import e6 from"clsx";import{useCallback as t6,useEffect as Np,useRef as J0,useState as o6}from"react";import{KEYS as Bp,getShortcutKey as r6}from"@haoxin-web/excalidraw-common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as QS}from"@haoxin-web/excalidraw-common";var wr=({palette:e,color:o})=>{if(!o)return null;for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},Pa=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Rp=({color:e,palette:o})=>!Object.values(o).flat().includes(e),q0=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return Rp({color:l,palette:t})}),i=new Map;return n.forEach(a=>{let l=a[r[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,QS)},Kt=he(null),j0=(e,o,t)=>(e*299+o*587+t*114)/1e3,ei=(e,o=160)=>{if(!e)return!0;if(e==="transparent")return!1;if(!e.startsWith("#")){let i=document.createElement("div");if(i.style.color=e,i.style.color){i.style.position="absolute",i.style.visibility="hidden",i.style.width="0",i.style.height="0",document.body.appendChild(i);let a=getComputedStyle(i).color;document.body.removeChild(i);let l=a.replace(/^(rgb|rgba)\(/,"").replace(/\)$/,"").replace(/\s/g,"").split(","),s=parseInt(l[0]),m=parseInt(l[1]),c=parseInt(l[2]);return j0(s,m,c)<o}return!0}let t=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),n=parseInt(e.slice(5,7),16);return j0(t,r,n)<o};import{Fragment as n6,jsx as tc,jsxs as Q0}from"react/jsx-runtime";var ex=({color:e,onChange:o,label:t,colorPickerType:r,placeholder:n})=>{let i=pe(),[a,l]=o6(e),[s,m]=ce(Kt);Np(()=>{l(e)},[e]);let c=t6(b=>{let x=b.toLowerCase(),w=tx(x);w&&o(w),l(x)},[o]),d=J0(null),p=J0(null);Np(()=>{d.current&&d.current.focus()},[s]);let[u,f]=ce(Er);return Np(()=>()=>{f(null)},[f]),Q0("div",{className:"color-picker__input-label",children:[tc("div",{className:"color-picker__input-hash",children:"#"}),tc("input",{ref:s==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{c(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>m("hex"),onKeyDown:b=>{b.key!==Bp.TAB&&(b.key===Bp.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:n}),!i.editor.isMobile&&Q0(n6,{children:[tc("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),tc("div",{ref:p,className:e6("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:r}),title:`${h("labels.eyeDropper")} \u2014 ${Bp.I.toLocaleUpperCase()} or ${r6("Alt")} `,children:s0})]})]})};import Hp,{useEffect as Gp,useImperativeHandle as T6,useState as I6}from"react";import{EVENT as lx}from"@haoxin-web/excalidraw-common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as C6,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as S6,KEYS as k6}from"@haoxin-web/excalidraw-common";import l6 from"clsx";import{useEffect as s6,useRef as c6}from"react";import{jsxs as a6}from"react/jsx-runtime";var i6=({color:e,keyLabel:o,isShade:t=!1})=>a6("div",{className:"color-picker__button__hotkey-label",style:{color:ei(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),ti=i6;import{jsx as Fp,jsxs as d6}from"react/jsx-runtime";var ox=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=ce(Kt),a=c6(null);return s6(()=>{a.current&&a.current.focus()},[o,n]),Fp("div",{className:"color-picker-content--default",children:e.map((l,s)=>d6("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:l6("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":r,style:{"--swatch-color":l},children:[Fp("div",{className:"color-picker__button-outline"}),Fp(ti,{color:l,keyLabel:s+1})]},s))})};import m6 from"clsx";import{useEffect as p6,useRef as u6}from"react";import{jsx as Op,jsxs as g6}from"react/jsx-runtime";var h6=({palette:e,color:o,onChange:t,activeShade:r})=>{let n=wr({color:o,palette:e}),[i,a]=ce(Kt),l=u6(null);return p6(()=>{l.current&&i==="baseColors"&&l.current.focus()},[n?.colorName,i]),Op("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,m],c)=>{let d=(Array.isArray(m)?m[r]:m)||"transparent",p=Pa[c],u=h(`colors.${s.replace(/\d+/,"")}`,null,"");return g6("button",{ref:n?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:m6("color-picker__button color-picker__button--large has-outline",{active:n?.colorName===s,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),a("baseColors")},title:`${u}${d.startsWith("#")?` ${d}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${s}`,children:[Op("div",{className:"color-picker__button-outline"}),Op(ti,{color:d,keyLabel:p})]},s)})})},rx=h6;import{jsx as b6}from"react/jsx-runtime";var f6=({children:e})=>b6("div",{className:"color-picker__heading",children:e}),oi=f6;import x6 from"clsx";import{useEffect as E6,useRef as y6}from"react";import{jsx as Aa,jsxs as nx}from"react/jsx-runtime";var ix=({color:e,onChange:o,palette:t})=>{let r=wr({color:e||"transparent",palette:t}),[n,i]=ce(Kt),a=y6(null);if(E6(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,m=t[l];if(Array.isArray(m))return Aa("div",{className:"color-picker-content--default shades",children:m.map((c,d)=>nx("button",{ref:d===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:x6("color-picker__button color-picker__button--large has-outline",{active:d===s}),"aria-label":"Shade",title:`${l} - ${d+1}`,style:c?{"--swatch-color":c}:void 0,onClick:()=>{o(c),i("shades")},children:[Aa("div",{className:"color-picker__button-outline"}),Aa(ti,{color:c,keyLabel:d+1,isShade:!0})]},d))})}return nx("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Aa("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Aa("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:h("colorPicker.noShades")})]})};import{COLORS_PER_ROW as ri,COLOR_PALETTE as w6,KEYS as _a}from"@haoxin-web/excalidraw-common";var zp=(e,o,t)=>{let r=Math.ceil(t/ri);switch(o=o??-1,e){case"ArrowLeft":{let n=o-1;return n<0?t-1:n}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let n=o+ri;return n>=t?o%ri:n}case"ArrowUp":{let n=o-ri,i=n<0?ri*r+n:n;return i>=t?void 0:i}}},v6=({e,colorObj:o,onChange:t,palette:r,customColors:n,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(r[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&n[Number(e.key)-1])return t(n[Number(e.key)-1]),i("custom"),!0;if(Pa.includes(e.key)){let l=Pa.indexOf(e.key),s=Object.keys(r)[l],m=r[s],c=Array.isArray(m)?m[a]:m;return t(c),i("baseColors"),!0}return!1},ax=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:m,onEscape:c})=>{if(e[_a.CTRL_OR_CMD])return!1;if(e.key===_a.ESCAPE)return c(e),!0;if(e.key===_a.ALT)return m(!0),!0;if(e.key===_a.I)return m(),!0;let d=wr({color:r,palette:t});if(e.key===_a.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[y,v])=>(v&&E.push(y),E),[]),f=u.indexOf(o),b=e.shiftKey?-1:1,x=f+b>u.length-1?0:f+b<0?u.length-1:f+b,w=u[x];return w&&a(w),w==="custom"?n(i[0]):w==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(w6.black)),e.preventDefault(),e.stopPropagation(),!0}if(v6({e,colorObj:d,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&d){let{shade:p}=d,u=zp(e.key,p,ri);if(u!==void 0)return n(t[d.colorName][u]),!0}if(o==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(t),f=u.indexOf(p),b=zp(e.key,f,u.length);if(b!==void 0){let x=u[b],w=t[x];return n(Array.isArray(w)?w[s]:w),!0}}if(o==="custom"){let p=r!=null?i.indexOf(r):0,u=zp(e.key,p,i.length);if(u!==void 0){let f=i[u];return n(f),!0}}return!1};import{jsx as ln,jsxs as oc}from"react/jsx-runtime";var sx=Hp.forwardRef(({color:e,onChange:o,type:t,elements:r,palette:n,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},m)=>{let[c]=Hp.useState(()=>t==="canvasBackground"?[]:q0(r,t,n)),[d,p]=ce(Kt),u=wr({color:e,palette:n});Gp(()=>{if(!d){let w=!!e&&Rp({color:e,palette:n}),E=w&&!c.includes(e);p(E?null:w?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,n,p,u,c]);let[f,b]=I6(u?.shade??(t==="elementBackground"?C6:S6));Gp(()=>{u?.shade!=null&&b(u.shade);let w=E=>{E.key===k6.ALT&&l(!1)};return document.addEventListener(lx.KEYUP,w,{capture:!0}),()=>{document.removeEventListener(lx.KEYUP,w,{capture:!0})}},[u,l]);let x=Hp.useRef(null);return T6(m,()=>x.current),Gp(()=>{x?.current?.focus()},[]),ln("div",{role:"dialog","aria-modal":"true","aria-label":h("labels.colorPicker"),children:oc("div",{ref:x,onKeyDown:w=>{ax({event:w,activeColorPickerSection:d,palette:n,color:e,onChange:o,onEyeDropperToggle:l,customColors:c,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!c.length&&oc("div",{children:[ln(oi,{children:h("colorPicker.mostUsedCustomColors")}),ln(ox,{colors:c,color:e,label:h("colorPicker.mostUsedCustomColors"),onChange:o})]}),oc("div",{children:[ln(oi,{children:h("colorPicker.colors")}),ln(rx,{color:e,palette:n,onChange:o,activeShade:f})]}),oc("div",{children:[ln(oi,{children:h("colorPicker.shades")}),ln(ix,{color:e,onChange:o,palette:n})]}),a]})})});import M6 from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as L6,DEFAULT_CANVAS_BACKGROUND_PICKS as P6,DEFAULT_ELEMENT_BACKGROUND_PICKS as A6,DEFAULT_ELEMENT_STROKE_PICKS as _6}from"@haoxin-web/excalidraw-common";import{jsx as Up}from"react/jsx-runtime";var cx=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=_6),o==="elementBackground"&&(n=A6),o==="canvasBackground"&&(n=P6),r&&(n=r),n?Up("div",{className:"color-picker__top-picks",children:n.map(i=>Up("button",{className:M6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!ei(i,L6)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Up("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as mo,jsxs as Wp}from"react/jsx-runtime";var dx=e=>{let o=new Option().style;return o.color=e,!!o.color},tx=e=>B6(e)?e:dx(`#${e}`)?`#${e}`:dx(e)?e:null,F6=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=mx,updateData:a})=>{let{container:l}=Xe(),[,s]=ce(Kt),[m,c]=ce(Er),d=Wp("div",{children:[mo(oi,{children:h("colorPicker.hexCode")}),mo(ex,{color:o||"",label:r,onChange:f=>{t(f)},colorPickerType:e,placeholder:h("colorPicker.color")})]}),p=R6(null),u=()=>{p.current?.focus()};return mo(ec,{container:l,style:{maxWidth:"13rem"},onFocusOutside:f=>{u(),f.preventDefault()},onPointerDownOutside:f=>{m&&f.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?mo(sx,{ref:p,palette:i,color:o,onChange:f=>{t(f)},onEyeDropperToggle:f=>{c(b=>f?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):f===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:f=>{m?c(null):a({openPopup:null})},type:e,elements:n,updateData:a,children:d}):d})},O6=({label:e,color:o,type:t})=>mo(rc.Trigger,{type:"button",className:D6("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!ei(o,N6)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?h("labels.showStroke"):h("labels.showBackground"),children:mo("div",{className:"color-picker__button-outline",children:!o&&yb})}),vr=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=mx,topPicks:a,updateData:l,appState:s})=>mo("div",{children:Wp("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[mo(cx,{activeColor:o,onChange:t,type:e,topPicks:a}),mo(qs,{}),Wp(rc.Root,{open:s.openPopup===e,onOpenChange:m=>{l({openPopup:m?e:null})},children:[mo(O6,{color:o,label:r,type:e}),s.openPopup===e&&mo(F6,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as wx from"@radix-ui/react-popover";import hk,{useCallback as gk,useMemo as fk}from"react";import{FONT_FAMILY as Zp}from"@haoxin-web/excalidraw-common";import nk,{useMemo as Tr,useState as ik,useRef as ak,useEffect as lk,useCallback as sk}from"react";import{arrayToList as ck,debounce as dk,FONT_FAMILY as sn,getFontFamilyString as mk}from"@haoxin-web/excalidraw-common";import z6 from"clsx";import H6 from"react";import{jsx as G6,jsxs as U6}from"react/jsx-runtime";var nc=H6.forwardRef(({className:e,placeholder:o,onChange:t},r)=>U6("div",{className:z6("QuickSearch__wrapper",e),children:[Ft,G6("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import W6 from"clsx";import{Children as Y6}from"react";import{jsx as px}from"react/jsx-runtime";var ic=({className:e,placeholder:o,children:t})=>{let r=!Y6.count(t);return px("div",{className:W6("ScrollableList__wrapper",e),role:"menu",children:r?px("div",{className:"empty",children:o}):t})};import{jsx as V6,jsxs as X6}from"react/jsx-runtime";var ux=({children:e,className:o="",style:t,title:r})=>X6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&V6("p",{className:"dropdown-menu-group-title",children:r}),e]}),Da=ux;ux.displayName="DropdownMenuGroup";import{useEffect as tk,useRef as ok}from"react";import{THEME as rk}from"@haoxin-web/excalidraw-common";import{jsx as K6}from"react/jsx-runtime";var Ra=({children:e,...o})=>K6("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as $6,jsx as ac,jsxs as j6}from"react/jsx-runtime";var Z6=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=pe();return j6($6,{children:[o&&ac("div",{className:"dropdown-menu-item__icon",children:o}),ac("div",{style:e,className:"dropdown-menu-item__text",children:ac(Ra,{children:r})}),t&&!n.editor.isMobile&&ac("div",{className:"dropdown-menu-item__shortcut",children:t})]})},lc=Z6;import q6,{useContext as J6}from"react";import{EVENT as Q6,composeEventHandlers as ek}from"@haoxin-web/excalidraw-common";var Yp=q6.createContext({}),sc=(e="",o=!1,t=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
2
+ ${o?"dropdown-menu-item--selected":""} ${t?"dropdown-menu-item--hovered":""}`.trim(),cc=(e,o)=>{let t=J6(Yp);return ek(e,r=>{let n=new CustomEvent(Q6.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as Vp}from"react/jsx-runtime";var Xp=({icon:e,value:o,order:t,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:m,onClick:c,...d})=>{let p=cc(c,m),u=ok(null);return tk(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),Vp("button",{...d,ref:u,value:o,onClick:p,className:sc(i,l,a),title:d.title??d["aria-label"],children:Vp(lc,{textStyle:s,icon:e,shortcut:n,children:r})})};Xp.displayName="DropdownMenuItem";var ni={GREEN:"green",RED:"red",BLUE:"blue"},dc=({type:e=ni.BLUE,children:o})=>{let{theme:t}=Mo(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===rk.LIGHT?"1.5px solid white":"none"};switch(e){case ni.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ni.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case ni.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Vp("div",{className:"DropDownMenuItemBadge",style:r,children:o})};dc.displayName="DropdownMenuItemBadge";Xp.Badge=dc;var xt=Xp;import{KEYS as ii}from"@haoxin-web/excalidraw-common";var hx=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[ii.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===ii.F)return o.current?.focus(),!0;if(e.key===ii.ESCAPE)return n(),!0;if(e.key===ii.ENTER)return t?.value&&i(t.value),!0;if(e.key===ii.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===ii.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as Na,jsxs as gx}from"react/jsx-runtime";var pk=e=>{switch(e){case sn.Excalifont:case sn.Virgil:return Nt;case sn.Nunito:case sn.Helvetica:return Ca;case sn["Lilita One"]:return Qb;case sn["Comic Shanns"]:case sn.Cascadia:return _s;default:return Ca}},fx=nk.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=Xe(),{fonts:s}=Oe(),{showDeprecatedFonts:m}=Lo(),[c,d]=ik(""),p=ak(null),u=Tr(()=>Array.from(dr.registered.entries()).filter(([M,{metadata:R}])=>!R.private&&!R.fallback).map(([M,{metadata:R,fontFaces:L}])=>{let k={value:M,icon:pk(M),text:L[0]?.fontFace?.family??"Unknown"};return R.deprecated&&Object.assign(k,{deprecated:R.deprecated,badge:{type:ni.RED,placeholder:h("fontList.badge.old")}}),k}).sort((M,R)=>M.text.toLowerCase()>R.text.toLowerCase()?1:-1),[]),f=Tr(()=>new Set(s.getSceneFamilies()),[e]),b=Tr(()=>u.filter(M=>f.has(M.value)),[u,f]),x=Tr(()=>u.filter(M=>!f.has(M.value)&&(m||!M.deprecated)),[u,f,m]),w=Tr(()=>ck([...b,...x].filter(M=>M.text?.toLowerCase().includes(c))),[b,x,c]),E=Tr(()=>{let M;return o?M=w.find(R=>R.value===o):e&&(M=w.find(R=>R.value===e)),!M&&c&&(w[0]?.value?r(w[0].value):n()),M},[o,e,c,w,r,n]),y=sk(M=>{hx({event:M,inputRef:p,hoveredFont:E,filteredFonts:w,onSelect:t,onHover:r,onClose:a})&&(M.preventDefault(),M.stopPropagation())},[E,w,t,r,a]);lk(()=>(i(),()=>{a()}),[]);let v=Tr(()=>w.filter(M=>f.has(M.value)),[w,f]),C=Tr(()=>w.filter(M=>!f.has(M.value)),[w,f]),S=(M,R)=>gx(xt,{icon:M.icon,value:M.value,order:R,textStyle:{fontFamily:mk({fontFamily:M.value})},hovered:M.value===E?.value,selected:M.value===e,tabIndex:M.value===e?0:-1,onClick:L=>{t(Number(L.currentTarget.value))},onMouseMove:()=>{E?.value!==M.value&&r(M.value)},children:[M.text,M.badge&&Na(dc,{type:M.badge.type,children:M.badge.placeholder})]},M.value),P=[];return v.length&&P.push(Na(Da,{title:h("fontList.sceneFonts"),children:v.map(S)},"group_1")),C.length&&P.push(Na(Da,{title:h("fontList.availableFonts"),children:C.map((M,R)=>S(M,R+v.length))},"group_2")),gx(ec,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:y,children:[Na(nc,{ref:p,placeholder:h("quickSearch.placeholder"),onChange:dk(d,20)}),Na(ic,{className:"dropdown-menu fonts manual-hover",placeholder:h("fontList.empty"),children:P.length?P:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as bx from"@radix-ui/react-popover";import{useMemo as uk}from"react";import{jsx as Kp}from"react/jsx-runtime";var xx=({selectedFontFamily:e})=>{let o=uk(()=>!!(e&&!Ex(e)),[e]);return Kp(bx.Trigger,{asChild:!0,children:Kp("div",{children:Kp(qn,{standalone:!0,icon:Wo,title:h("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as Ba,jsxs as yx}from"react/jsx-runtime";var vx=[{value:Zp.Excalifont,icon:Nt,text:h("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Zp.Nunito,icon:Ca,text:h("labels.normal"),testId:"font-family-normal"},{value:Zp["Comic Shanns"],icon:_s,text:h("labels.code"),testId:"font-family-code"}],bk=new Set(vx.map(e=>e.value)),Ex=e=>e?bk.has(e):!1,Tx=hk.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=fk(()=>vx,[]),s=gk(m=>{m&&r(m)},[r]);return yx("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[Ba("div",{className:"buttonList",children:Ba(Xt,{type:"button",options:l,value:o,onClick:s})}),Ba(qs,{}),yx(wx.Root,{open:e,onOpenChange:a,children:[Ba(xx,{selectedFontFamily:o}),e&&Ba(fx,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:s,onHover:n,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as ai from"@radix-ui/react-popover";import wk from"clsx";import mc,{useEffect as vk}from"react";import{isArrowKey as Tk,KEYS as Vo}from"@haoxin-web/excalidraw-common";import{jsx as xk}from"react/jsx-runtime";var Ir=({icon:e})=>xk("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle",flex:"0 0 auto"},children:e});import{Fragment as yk,jsx as Ix,jsxs as Cx}from"react/jsx-runtime";var Ek=({label:e,open:o,openTrigger:t,children:r,className:n,showCollapsedIcon:i=!0})=>Cx(yk,{children:[Cx("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,i&&Ix(Ir,{icon:o?R0:Us})]}),o&&Ix("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),Fa=Ek;import{jsx as cn,jsxs as $p}from"react/jsx-runtime";var Ik=he(!1);function Ck({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=pe(),l=u=>{let f=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&f)r(f.value),u.preventDefault();else if(u.key===Vo.TAB){let b=e.findIndex(w=>w.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;r(e[x].value)}else if(Tk(u.key)){let b=Uo().rtl,x=e.findIndex(w=>w.value===o);if(x!==-1){let w=e.length,E=x;switch(u.key){case(b?Vo.ARROW_LEFT:Vo.ARROW_RIGHT):E=(x+1)%w;break;case(b?Vo.ARROW_RIGHT:Vo.ARROW_LEFT):E=(w+x-1)%w;break;case Vo.ARROW_DOWN:{E=(x+(i??1))%w;break}case Vo.ARROW_UP:{E=(w+x-(i??1))%w;break}}r(e[E].value)}u.preventDefault()}else(u.key===Vo.ESCAPE||u.key===Vo.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,m]=ce(Ik),c=mc.useMemo(()=>e.slice(0,i),[e,i]),d=mc.useMemo(()=>e.slice(i),[e,i]);vk(()=>{c.some(u=>u.value===o)||m(!0)},[o,c,m]);let p=u=>cn("div",{className:"picker-content",children:u.map((f,b)=>$p("button",{type:"button",className:wk("picker-option",{active:o===f.value}),onClick:x=>{r(f.value)},title:`${f.text} ${f.keyBinding&&`\u2014 ${f.keyBinding.toUpperCase()}`}`,"aria-label":f.text||"none","aria-keyshortcuts":f.keyBinding||void 0,ref:x=>{o===f.value&&setTimeout(()=>{x?.focus()},0)},children:[f.icon,f.keyBinding&&cn("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return cn(ai.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:$p("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(c),d.length>0&&cn(Fa,{label:h("labels.more_options"),open:s,openTrigger:()=>{m(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function jp({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=mc.useState(!1),s=mc.useRef(null);return cn("div",{children:$p(ai.Root,{open:a,onOpenChange:m=>l(m),children:[cn(ai.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(m=>m.value===e)?.icon}),a&&cn(Ck,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import Sx,{useEffect as Sk}from"react";import{jsx as qp,jsxs as kx}from"react/jsx-runtime";var Mx=({updateData:e,app:o,testId:t})=>{let r=Sx.useRef(null),n=Sx.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),m=i.reduce((c,d)=>(c!=null&&c!==d.opacity&&(a=!1),c==null||c>d.opacity?d.opacity:c),l?.opacity??null)??o.state.currentItemOpacity;return Sk(()=>{if(r.current&&n.current){let c=r.current,d=n.current,p=c.offsetWidth,u=15,f=m/100*(p-u)+u/2;d.style.left=`${f}px`,c.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${m}%, var(--button-bg) ${m}%, var(--button-bg) 100%)`}},[m]),kx("label",{className:"control-label",children:[h("labels.opacity"),kx("div",{className:"range-wrapper",children:[qp("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:r,type:"range",min:"0",max:"100",step:"10",onChange:c=>{e(+c.target.value)},value:m,className:"range-input","data-testid":t}),qp("div",{className:"value-bubble",ref:n,children:m!==0?m:null}),qp("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Bx,jsx as te,jsxs as Mt}from"react/jsx-runtime";var Nx=.1,Et=(e,o,t,r=!1)=>{let n=ru(J(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},ze=function(e,o,t,r,n){let i=o.state.editingTextElement,a=Dx(e),l=null;if(i&&(l=t(i)),!l)if(we(a,o.state)){let m=o.scene.getSelectedElements(o.state),c=r===!0?m:m.filter(d=>r(d));l=Uk(c,t)??(typeof n=="function"?n(!0):n)}else l=typeof n=="function"?n(!1):n;return l},jk=(e,o,t)=>Vk(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),nu=(e,o,t,r,n)=>{let i=new Set,a=Et(e,o,l=>{if(kt(l)){let s=r(l);i.add(s);let m=Qe(l,{fontSize:s});return Oa(m,t.scene.getContainerElement(l),t.scene),m=jk(l,m,t.scene),m}return l},!0);return J(e,o,{includeBoundTextElement:!0}).forEach(l=>{kt(l)&&Yk(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:et.IMMEDIATELY}},gc=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:Et(e,o,r=>Kk(r.type)?Qe(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?et.IMMEDIATELY:et.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt(Bx,{children:[te("h3",{"aria-hidden":"true",children:h("labels.stroke")}),te(vr,{topPicks:Dk,palette:_k,type:"elementStroke",label:h("labels.stroke"),color:ze(e,r,n=>n.strokeColor,!0,n=>n?null:o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),fc=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,r)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:et.EVENTUALLY};let n,i=r.scene.getSelectedElements(o);if(!Gk(t.currentItemBackgroundColor)&&i.every(l=>Ax(l)&&Wk(l.points))){let l=ru(i);n=e.map(s=>l.has(s.id)&&Ax(s)?Qe(s,{backgroundColor:t.currentItemBackgroundColor,...$k(s,!0)}):s)}else n=Et(e,o,l=>Qe(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:n,appState:{...o,...t},captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt(Bx,{children:[te("h3",{"aria-hidden":"true",children:h("labels.background")}),te(vr,{topPicks:Ak,palette:Pk,type:"elementBackground",label:h("labels.background"),color:ze(e,r,n=>n.backgroundColor,!0,n=>n?null:o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),za=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(ae("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:Et(e,o,n=>Qe(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=J(e,o),i=n.length>0&&n.every(a=>a.fillStyle==="zigzag");return Mt("fieldset",{children:[te("legend",{children:h("labels.fill")}),te("div",{className:"buttonList",children:te(Xt,{type:"button",options:[{value:"hachure",text:`${i?h("labels.zigzag"):h("labels.hachure")} (${zk("Alt-Click")})`,icon:i?Lb:Ls,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:h("labels.crossHatch"),icon:Ps,testId:"fill-cross-hatch"},{value:"solid",text:h("labels.solid"),icon:As,testId:"fill-solid"}],value:ze(e,r,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&n.every(m=>m.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),Ko=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>Qe(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt("fieldset",{children:[te("legend",{children:h("labels.strokeWidth")}),te("div",{className:"buttonList",children:te(Xt,{group:"stroke-width",options:[{value:eu.thin,text:h("labels.thin"),icon:Wn,testId:"strokeWidth-thin"},{value:eu.bold,text:h("labels.bold"),icon:Ta,testId:"strokeWidth-bold"},{value:eu.extraBold,text:h("labels.extraBold"),icon:Ia,testId:"strokeWidth-extraBold"}],value:ze(e,r,n=>n.strokeWidth,n=>n.hasOwnProperty("strokeWidth"),n=>n?null:o.currentItemStrokeWidth),onChange:n=>t(n)})})]})}),qk=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>Qe(r,{seed:Fk(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt("fieldset",{children:[te("legend",{children:h("labels.sloppiness")}),te("div",{className:"buttonList",children:te(Xt,{group:"sloppiness",options:[{value:0,text:h("labels.architect"),icon:_b},{value:1,text:h("labels.artist"),icon:Db},{value:2,text:h("labels.cartoonist"),icon:Rb}],value:ze(e,r,n=>n.roughness,n=>n.hasOwnProperty("roughness"),n=>n?null:o.currentItemRoughness),onChange:n=>t(n)})})]})}),kj=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>Qe(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt("fieldset",{children:[te("legend",{children:h("labels.strokeStyle")}),te("div",{className:"buttonList",children:te(Xt,{group:"strokeStyle",options:[{value:"solid",text:h("labels.strokeStyle_solid"),icon:Wn},{value:"dashed",text:h("labels.strokeStyle_dashed"),icon:Pb},{value:"dotted",text:h("labels.strokeStyle_dotted"),icon:Ab}],value:ze(e,r,n=>n.strokeStyle,n=>n.hasOwnProperty("strokeStyle"),n=>n?null:o.currentItemStrokeStyle),onChange:n=>t(n)})})]})}),Jk=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>Qe(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>te(Mx,{updateData:o,app:e,testId:"opacity"})}),iu=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>nu(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt("fieldset",{children:[te("legend",{children:h("labels.fontSize")}),te("div",{className:"buttonList",children:te(Xt,{group:"font-size",options:[{value:16,text:h("labels.small"),icon:$b,testId:"fontSize-small"},{value:20,text:h("labels.medium"),icon:jb,testId:"fontSize-medium"},{value:28,text:h("labels.large"),icon:qb,testId:"fontSize-large"},{value:36,text:h("labels.veryLarge"),icon:Jb,testId:"fontSize-veryLarge"}],value:ze(e,r,n=>{if(kt(n))return n.fontSize;let i=Cr(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>kt(n)||Cr(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||Nk),onChange:n=>t(n)})})]})}),au=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:an,trackEvent:!1,perform:(e,o,t,r)=>nu(e,o,r,n=>Math.round(1/(1+Nx)*n.fontSize)),keyTest:e=>e[li.CTRL_OR_CMD]&&e.shiftKey&&(e.key===li.CHEVRON_LEFT||e.key===li.COMMA)}),lu=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:an,trackEvent:!1,perform:(e,o,t,r)=>nu(e,o,r,n=>Math.round(n.fontSize*(1+Nx))),keyTest:e=>e[li.CTRL_OR_CMD]&&e.shiftKey&&(e.key===li.CHEVRON_RIGHT||e.key===li.PERIOD)}),Qk=F({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,r)=>{let{cachedElements:n,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:Et(e,o,b=>{let x=n?.get(b.id);return x?Qe(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:et.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:m}=t,c=et.EVENTUALLY,d,p=!1;if(s)d=s,c=et.IMMEDIATELY;else if(m){d=m,c=et.EVENTUALLY;let f=J(e,o,{includeBoundTextElement:!0}).filter(b=>kt(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let w=f[b];x+=w?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:c};if(d&&!p){let f=new Map,b=new Set,x=!1,w=Array.from(dr.loadedFontsCache.values()),E=Object.entries(Bk).find(([C,S])=>S===d)?.[0];m&&E&&w.some(C=>C.startsWith(E))&&(x=!0),Object.assign(u,{elements:Et(e,o,C=>{if(kt(C)&&(C.fontFamily!==d||s)){let S=Qe(C,{fontFamily:d,lineHeight:Hk(d)}),P=n?.get(C.containerId||"")||{},M=r.scene.getContainerElement(C);return a&&M&&P&&r.scene.mutateElement(M,{...P}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,M),S}return C},!0)});let y=`10px ${Ok({fontFamily:d})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,S]of f)Oa(C,S,r.scene);else window.document.fonts.load(y,v).then(C=>{for(let[S,P]of f){let M=r.scene.getElement(S.id),R=P?r.scene.getElement(P.id):null;M&&Oa(M,R,r.scene)}r.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=Qp(new Map),i=Qp(null),[a,l]=Lk({}),s=Qp(!0),m=Mk(()=>{let c=(d,p)=>ze(d,t,u=>{if(kt(u))return u.fontFamily;let f=Cr(u,p);return f?f.fontFamily:null},u=>kt(u)||Cr(u,p)!==null,u=>u?null:o.currentItemFontFamily||Rk);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?c(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&o.openPopup!=="fontFamily"?c(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return Jp(()=>{i.current=m},[m]),Jp(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),Jp(()=>(s.current=!1,()=>{s.current=!0}),[]),Mt("fieldset",{children:[te("legend",{children:h("labels.fontFamily")}),te(Tx,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:m,hoveredFontFamily:o.currentHoveredFontFamily,onSelect:c=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:c}),n.current.clear()},onHover:c=>{l({currentHoveredFontFamily:c,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:c=>{if(c){n.current.clear();let{editingTextElement:d}=o;if(d?.type==="text"){let p=t.scene.getElement(d.id);n.current.set(d.id,Qe(p||d,{},!0))}else{let p=J(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,Qe(u,{},!0))}l({openPopup:"fontFamily"})}else{let d={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};s.current?r({...a,...d}):l(d),n.current.clear()}}})]})}}),Ha=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:Et(e,o,n=>{if(kt(n)){let i=Qe(n,{textAlign:t});return Oa(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return Mt("fieldset",{children:[te("legend",{children:h("labels.textAlign")}),te("div",{className:"buttonList",children:te(Xt,{group:"text-align",options:[{value:"left",text:h("labels.left"),icon:Ds,testId:"align-left"},{value:"center",text:h("labels.center"),icon:Rs,testId:"align-horizontal-center"},{value:"right",text:h("labels.right"),icon:Ns,testId:"align-right"}],value:ze(e,r,i=>{if(kt(i))return i.textAlign;let a=Cr(i,n);return a?a.textAlign:null},i=>kt(i)||Cr(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})})]})}}),e4=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Et(e,o,n=>{if(kt(n)){let i=Qe(n,{verticalAlign:t});return Oa(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>te("fieldset",{children:te("div",{className:"buttonList",children:te(Xt,{group:"text-align",options:[{value:pc.TOP,text:h("labels.alignTop"),icon:te(e0,{theme:o.theme}),testId:"align-top"},{value:pc.MIDDLE,text:h("labels.centerVertically"),icon:te(o0,{theme:o.theme}),testId:"align-middle"},{value:pc.BOTTOM,text:h("labels.alignBottom"),icon:te(t0,{theme:o.theme}),testId:"align-bottom"}],value:ze(e,r,n=>{if(kt(n)&&n.containerId)return n.verticalAlign;let i=Cr(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>kt(n)||Cr(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:pc.MIDDLE),onChange:n=>t(n)})})})}),Mj=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>Rx(r)?r:Qe(r,{roundness:t==="round"?{type:Xk(r.type)?uc.ADAPTIVE_RADIUS:uc.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,renderAction:n})=>{let a=rs(Dx(e),o).some(l=>l.roundness?.type===uc.LEGACY);return Mt("fieldset",{children:[te("legend",{children:h("labels.edges")}),Mt("div",{className:"buttonList",children:[te(Xt,{group:"edges",options:[{value:"sharp",text:h("labels.sharp"),icon:Nb},{value:"round",text:h("labels.round"),icon:Bb}],value:ze(e,r,l=>a?null:l.roundness?"round":"sharp",l=>!hc(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),n("togglePolygon")]})]})}}),_x=e=>[{value:null,text:h("labels.arrowhead_none"),keyBinding:"q",icon:Fb},{value:"arrow",text:h("labels.arrowhead_arrow"),keyBinding:"w",icon:te(Ob,{flip:e})},{value:"triangle",text:h("labels.arrowhead_triangle"),icon:te(Ub,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:h("labels.arrowhead_triangle_outline"),icon:te(Wb,{flip:e}),keyBinding:"r"},{value:"circle",text:h("labels.arrowhead_circle"),keyBinding:"a",icon:te(zb,{flip:e})},{value:"circle_outline",text:h("labels.arrowhead_circle_outline"),keyBinding:"s",icon:te(Hb,{flip:e})},{value:"diamond",text:h("labels.arrowhead_diamond"),icon:te(Yb,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:h("labels.arrowhead_diamond_outline"),icon:te(Vb,{flip:e}),keyBinding:"f"},{value:"bar",text:h("labels.arrowhead_bar"),keyBinding:"z",icon:te(Gb,{flip:e})},{value:"crowfoot_one",text:h("labels.arrowhead_crowfoot_one"),icon:te(Kb,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:h("labels.arrowhead_crowfoot_many"),icon:te(Xb,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:h("labels.arrowhead_crowfoot_one_or_many"),icon:te(Zb,{flip:e}),keyBinding:"v"}],Lj=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:Et(e,o,r=>{if(ou(r)){let{position:n,type:i}=t;if(n==="start")return Qe(r,{startArrowhead:i});if(n==="end")return Qe(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:et.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Uo().rtl;return Mt("fieldset",{children:[te("legend",{children:h("labels.arrowheads")}),Mt("div",{className:"iconSelectList buttonList",children:[te(jp,{label:"arrowhead_start",options:_x(!n),value:ze(e,r,i=>ou(i)&&_n(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),te(jp,{label:"arrowhead_end",group:"arrowheads",options:_x(!!n),value:ze(e,r,i=>ou(i)&&_n(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),Pj=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=Et(e,o,l=>{if(!hc(l))return l;let s=Qe(l,{roundness:t===Xo.round?{type:uc.PROPORTIONAL_RADIUS}:null,elbowed:t===Xo.elbow,points:t===Xo.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(Rx(s)){s.fixedSegments=null;let m=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let c=tu.getPointAtIndexGlobalCoordinates(s,0,m),d=tu.getPointAtIndexGlobalCoordinates(s,-1,m),p=s.startBinding&&m.get(s.startBinding.elementId),u=s.endBinding&&m.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...Px(s,p,"start",m)}:null,b=u&&s.endBinding?{...s.endBinding,...Px(s,u,"end",m)}:null;s={...s,startBinding:f,endBinding:b,...Zk(s,m,{points:[c,d].map(x=>kk(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let m=r.scene.getNonDeletedElementsMap();if(s.startBinding){let c=m.get(s.startBinding.elementId);c&&Lx(s,c,"start",r.scene)}if(s.endBinding){let c=m.get(s.endBinding.elementId);c&&Lx(s,c,"end",r.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new tu(l,ru(e)))}return{elements:n,appState:i,captureUpdate:et.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Mt("fieldset",{children:[te("legend",{children:h("labels.arrowtypes")}),te("div",{className:"buttonList",children:te(Xt,{group:"arrowtypes",options:[{value:Xo.sharp,text:h("labels.arrowtype_sharp"),icon:zs,testId:"sharp-arrow"},{value:Xo.round,text:h("labels.arrowtype_round"),icon:Gs,testId:"round-arrow"},{value:Xo.elbow,text:h("labels.arrowtype_elbowed"),icon:Hs,testId:"elbow-arrow"}],value:ze(e,r,n=>hc(n)?n.elbowed?Xo.elbow:n.roundness?Xo.round:Xo.sharp:null,n=>hc(n),n=>n?null:o.currentItemArrowType),onChange:n=>t(n)})})]})});import{clamp as pu,roundToStep as l4}from"@haoxin-web/excalidraw-math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as s4,CURSOR_TYPE as Gx,MAX_ZOOM as Ux,MIN_ZOOM as Wx,THEME as Ga,ZOOM_STEP as uu,getShortcutKey as Yx,updateActiveTool as ci,CODES as Ao,KEYS as $o}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as c4}from"@haoxin-web/excalidraw-element";import{newElementWith as d4}from"@haoxin-web/excalidraw-element";import{getCommonBounds as m4}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as uo}from"@haoxin-web/excalidraw-element";import{useEffect as t4}from"react";import{jsx as r4}from"react/jsx-runtime";var si=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let o=document.createElement("div");return document.body.appendChild(o),o.classList.add("excalidraw-tooltip"),o},su=(e,o,t="bottom")=>{let r=e.getBoundingClientRect(),n=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-r.width/2;l<0?l=a:l+r.width>=n&&(l=n-r.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+r.height>=i&&(s=o.top-r.height-a)):(s=o.top-r.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},o4=(e,o,t,r)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=r?"50ch":"10ch",o.style.maxWidth=r?"50ch":"15ch",o.textContent=t;let n=e.getBoundingClientRect();su(o,n)},po=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(t4(()=>()=>si().classList.remove("excalidraw-tooltip--visible"),[]),n?null:r4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>o4(i.currentTarget,si(),o,t),onPointerLeave:()=>si().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import bc from"open-color";import{CURSOR_TYPE as cu,MIME_TYPES as du,THEME as Ox}from"@haoxin-web/excalidraw-common";var zx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',n4='<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"/>',Hx='<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"/>',i4=`data:${du.svg},${encodeURIComponent(`${zx}${Hx}</svg>`)}`,a4=`data:${du.svg},${encodeURIComponent(`${zx}${n4}${Hx}</svg>`)}`,Zt=e=>{e&&(e.style.cursor="")},ye=(e,o)=>{e&&(e.style.cursor=o)},Po,Fx,mu=(e,o)=>{let r=()=>{let n=o===Ox.DARK;Po=document.createElement("canvas"),Po.theme=o,Po.height=20,Po.width=20;let i=Po.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(Po.width/2,Po.height/2,5,0,2*Math.PI),i.fillStyle=n?bc.black:bc.white,i.fill(),i.strokeStyle=n?bc.white:bc.black,i.stroke(),Fx=Po.toDataURL(du.svg)};(!Po||Po.theme!==o)&&r(),ye(e,`url(${Fx}) ${20/2} ${20/2}, auto`)},Ot=(e,o)=>{if(e)if(o.activeTool.type==="selection")Zt(e);else if(lo(o))e.style.cursor=cu.GRAB;else if(St(o))mu(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===Ox.LIGHT?i4:a4;e.style.cursor=`url(${t}), auto`}else if(o.activeTool.type==="laserTrail"){let t=`url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18"><circle cx="9" cy="9" r="5" fill="orange" opacity="0.5"/><circle cx="9" cy="9" r="3" fill="red" opacity="0.8"/><circle cx="9" cy="9" r="1.5" fill="white"/></svg>') 9 9, auto`;e.style.cursor=t}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=cu.AUTO):e.style.cursor=cu.CROSSHAIR};var Zo=({viewportX:e,viewportY:o,nextZoom:t},r)=>{let n=e-r.offsetLeft,i=o-r.offsetTop,a=r.zoom.value,l=r.scrollX+(n-n/a),s=r.scrollY+(i-i/a),m=-(n-n/t),c=-(i-i/t);return{scrollX:l+m,scrollY:s+c,zoom:{value:t}}};import{jsx as vc,jsxs as h4}from"react/jsx-runtime";var xc=F({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?uo.IMMEDIATELY:uo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>vc(vr,{palette:null,topPicks:s4,label:h("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:n=>t({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),jo=F({name:"clearCanvas",label:"labels.clearCanvas",icon:Bt,trackEvent:{category:"canvas"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,r)=>(r.imageCache.clear(),{elements:e.map(n=>d4(n,{isDeleted:!0})),appState:{...mr(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:r.defaultSelectionTool}:o.activeTool},captureUpdate:uo.IMMEDIATELY})}),Ec=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:ep,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>({appState:{...o,...Zo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:Co(o.zoom.value+uu)},o),userToFollow:null},captureUpdate:uo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>vc(z,{type:"button",className:"zoom-in-button zoom-button",icon:ep,title:`${h("buttons.zoomIn")} \u2014 ${Yx("CtrlOrCmd++")}`,"aria-label":h("buttons.zoomIn"),disabled:o.zoom.value>=Ux,onClick:()=>{e(null)}}),keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&(e.code===Ao.EQUAL||e.code===Ao.NUM_ADD)&&(e[$o.CTRL_OR_CMD]||e.shiftKey)}),yc=F({name:"zoomOut",label:"buttons.zoomOut",icon:tp,viewMode:!0,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>({appState:{...o,...Zo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:Co(o.zoom.value-uu)},o),userToFollow:null},captureUpdate:uo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>vc(z,{type:"button",className:"zoom-out-button zoom-button",icon:tp,title:`${h("buttons.zoomOut")} \u2014 ${Yx("CtrlOrCmd+-")}`,"aria-label":h("buttons.zoomOut"),disabled:o.zoom.value<=Wx,onClick:()=>{e(null)}}),keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&(e.code===Ao.MINUS||e.code===Ao.NUM_SUBTRACT)&&(e[$o.CTRL_OR_CMD]||e.shiftKey)}),wc=F({name:"resetZoom",label:"buttons.resetZoom",icon:mb,viewMode:!0,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>({appState:{...o,...Zo({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:Co(1)},o),userToFollow:null},captureUpdate:uo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>vc(po,{label:h("buttons.resetZoom"),style:{height:"100%"},children:h4(z,{type:"button",className:"reset-zoom-button zoom-button",title:h("buttons.resetZoom"),"aria-label":h("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&(e.code===Ao.ZERO||e.code===Ao.NUM_ZERO)&&(e[$o.CTRL_OR_CMD]||e.shiftKey)}),p4=(e,o,t=1)=>{let[r,n,i,a]=e,l=i-r,s=o.width/l,m=a-n,c=o.height/m,p=Math.min(s,c)*pu(t,.1,1);return Math.min(p,1)},Vx=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=pu(n,Wx,Ux);let[l,s,m,c]=e,d=(l+m)/2,p=(s+c)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,w=o.width-u-b,E=o.height-f-x,y;if(r){let S=m-l,P=c-s;y=Math.min(w/S,E/P)*n}else y=p4(e,{width:w,height:E},n);let v=Co(pu(l4(y,uu,"floor"),i,a)),C=S1({scenePoint:{x:d,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:C.scrollX,scrollY:C.scrollY,zoom:{value:v}},captureUpdate:uo.EVENTUALLY}},di=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=m4(c4(o));return Vx({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},pq=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Os,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return di({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&e.code===Ao.TWO&&e.shiftKey&&!e.altKey&&!e[$o.CTRL_OR_CMD]}),uq=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Os,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return di({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&e.code===Ao.THREE&&e.shiftKey&&!e.altKey&&!e[$o.CTRL_OR_CMD]}),u4=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Os,viewMode:!0,trackEvent:{category:"canvas"},predicate:(e,o,t)=>t.showZoomActions!==!1,perform:(e,o,t,r)=>di({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:(e,o,t,r)=>r.props.showZoomActions!==!1&&e.code===Ao.ONE&&e.shiftKey&&!e.altKey&&!e[$o.CTRL_OR_CMD]}),dn=F({name:"toggleTheme",label:(e,o)=>o.theme===Ga.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===Ga.LIGHT?ya:wa,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===Ga.LIGHT?Ga.DARK:Ga.LIGHT)},captureUpdate:uo.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===Ao.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),hq=F({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return St(o)?n=ci(o,{...o.activeTool.lastActiveTool||{type:r.defaultSelectionTool},lastActiveToolBeforeEraser:null}):n=ci(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:uo.IMMEDIATELY}},keyTest:e=>e.key===$o.E}),gq=F({name:"toggleLassoTool",label:"toolBar.lasso",icon:xs,trackEvent:{category:"toolbar"},predicate:(e,o,t,r)=>r.defaultSelectionTool!=="lasso",perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=ci(o,{type:"lasso",fromSelection:!1}),ye(r.interactiveCanvas,Gx.CROSSHAIR)):n=ci(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:uo.NEVER}}}),Xx=F({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Fs,viewMode:!1,predicate:(e,o,t)=>t.showPanActions!==!1,perform:(e,o,t,r)=>{let n;return lo(o)?n=ci(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=ci(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),ye(r.interactiveCanvas,Gx.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:uo.IMMEDIATELY}},keyTest:(e,o,t,r)=>r.props.showPanActions!==!1&&!e.altKey&&!e[$o.CTRL_OR_CMD]&&e.key===$o.H});import{updateActiveTool as Kx}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as g4}from"@haoxin-web/excalidraw-element";var f4=F({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=Kx(o,{type:"embeddable"});return Ot(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Kx(o,{type:"embeddable"})},captureUpdate:g4.EVENTUALLY}}});import{pointFrom as b4}from"@haoxin-web/excalidraw-math";import{maybeBindLinearElement as x4,bindOrUnbindLinearElement as Zx,isBindingEnabled as E4}from"@haoxin-web/excalidraw-element/binding";import{isValidPolygon as $x,LinearElementEditor as Ua,newElementWith as hu}from"@haoxin-web/excalidraw-element";import{isBindingElement as Tc,isFreeDrawElement as jx,isLinearElement as qx,isLineElement as Ic}from"@haoxin-web/excalidraw-element";import{KEYS as gu,arrayToMap as fu,tupleToCoors as y4,updateActiveTool as Jx}from"@haoxin-web/excalidraw-common";import{isPathALoop as w4}from"@haoxin-web/excalidraw-element";import{isInvisiblySmallElement as bu}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as xu}from"@haoxin-web/excalidraw-element";import{jsx as v4}from"react/jsx-runtime";var zt=F({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,{event:l,sceneCoords:s}=t??{},m=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=Ua.handlePointerUp(l,o.selectedLinearElement,o,r.scene),{startBindingElement:f,endBindingElement:b}=u,x=r.scene.getElement(u.elementId);if(Tc(x)&&Zx(x,f,b,r.scene),u!==o.selectedLinearElement){let w=e;return x&&bu(x)&&(w=w.map(E=>E.id===x.id?hu(E,{isDeleted:!0}):E)),{elements:w,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:xu.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=Ua.getElement(u,m);if(x)return Tc(x)&&Zx(x,f,b,a),Ic(x)&&!$x(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||bu(x)?e.map(w=>w.id===x.id?hu(w,{isDeleted:!0}):w):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new Ua(x,fu(m),!1)},captureUpdate:xu.IMMEDIATELY}}let c=e;window.document.activeElement instanceof HTMLElement&&i();let d=null;if(o.multiElement)d=o.multiElement;else if(o.newElement?.type==="freedraw"||Tc(o.newElement))d=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let u=m.get(Object.keys(o.selectedElementIds)[0]);u&&(d=u)}if(d){if(o.multiElement&&d.type!=="freedraw"){let{points:u,lastCommittedPoint:f}=d;(!f||u[u.length-1]!==f)&&a.mutateElement(d,{points:d.points.slice(0,-1)})}if(d&&bu(d)&&(c=c.map(u=>u.id===d?.id?hu(u,{isDeleted:!0}):u)),qx(d)||jx(d)){let u=w4(d.points,o.zoom.value);if(u&&(Ic(d)||jx(d))){let f=d.points,b=f[0],x=f.map((w,E)=>E===f.length-1?b4(b[0],b[1]):w);Ic(d)?a.mutateElement(d,{points:x,polygon:!0}):a.mutateElement(d,{points:x})}if(Ic(d)&&!$x(d.points)&&a.mutateElement(d,{polygon:!1}),Tc(d)&&!u&&d.points.length>1&&E4(o)){let f=s??y4(Ua.getPointAtIndexGlobalCoordinates(d,-1,fu(e)));x4(d,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!d)&&Zt(n);let p;return o.activeTool.type==="eraser"?p=Jx(o,{...o.activeTool.lastActiveTool||{type:r.defaultSelectionTool},lastActiveToolBeforeEraser:null}):p=Jx(o,{type:r.defaultSelectionTool}),{elements:c,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw"||o.activeTool.type==="line"||o.activeTool.type==="arrow")&&d?o.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:d&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[d.id]:!0}:o.selectedElementIds,selectedLinearElement:d&&qx(d)?new Ua(d,fu(c)):o.selectedLinearElement},captureUpdate:xu.IMMEDIATELY}},keyTest:(e,o)=>e.key===gu.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===gu.ESCAPE||e.key===gu.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>v4(z,{type:"button",icon:vb,title:h("buttons.done"),"aria-label":h("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as ui,DEFAULT_EXPORT_PADDING as pM,EXPORT_SCALES as uM,THEME as wu}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as hM}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as bo}from"@haoxin-web/excalidraw-element";import T4 from"clsx";import{jsx as Qx,jsxs as I4}from"react/jsx-runtime";var Wa=({children:e,checked:o,onChange:t,className:r})=>I4("div",{className:T4("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[Qx("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:fb}),Qx("div",{className:"Checkbox-label",children:e})]});import{THEME as Ya}from"@haoxin-web/excalidraw-common";import{jsx as Va}from"react/jsx-runtime";var tE=e=>{let o=e.title||(e.value===Ya.DARK?h("buttons.lightMode"):h("buttons.darkMode"));return Va(z,{type:"icon",icon:e.value===Ya.LIGHT?eE.MOON:eE.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===Ya.DARK?Ya.LIGHT:Ya.DARK),"data-testid":"toggle-dark-mode"})},eE={SUN:Va("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Va("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:Va("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Va("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 C4}from"react";import{focusNearestParent as S4,KEYS as k4}from"@haoxin-web/excalidraw-common";import{jsx as oE,jsxs as M4}from"react/jsx-runtime";var rE=e=>{let{id:o}=Xe(),[t,r]=C4(e.value),n=a=>{e.ignoreFocus||S4(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===k4.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return M4("div",{className:"ProjectName",children:[oE("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),oE("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as rM,DEFAULT_FILENAME as nM,IMAGE_MIME_TYPES as EE,isFirefox as iM,MIME_TYPES as aM,cloneJSON as lM,SVG_DOCUMENT_PREAMBLE as sM}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as cM}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as dM}from"@haoxin-web/excalidraw-element";import{getElementsOverlappingFrame as mM}from"@haoxin-web/excalidraw-element";import{ALLOWED_PASTE_MIME_TYPES as z4,EXPORT_DATA_TYPES as Za,MIME_TYPES as go,arrayToMap as H4,isMemberOf as G4,isPromiseLike as U4,EVENT as kc}from"@haoxin-web/excalidraw-common";import{mutateElement as W4}from"@haoxin-web/excalidraw-element";import{deepCopyElement as Y4}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as V4,isInitializedImageElement as X4}from"@haoxin-web/excalidraw-element";import{getContainingFrame as hE}from"@haoxin-web/excalidraw-element";import{pointFrom as Sr}from"@haoxin-web/excalidraw-math";import{COLOR_PALETTE as iE,DEFAULT_CHART_COLOR_INDEX as L4,getAllColorsSpecificShade as P4,DEFAULT_FONT_FAMILY as A4,DEFAULT_FONT_SIZE as aE,VERTICAL_ALIGN as _4,randomId as lE,isDevEnv as sE}from"@haoxin-web/excalidraw-common";import{newTextElement as Cc,newLinearElement as Ka,newElement as yu}from"@haoxin-web/excalidraw-element";var ho=32,Te=12,kr=256,cE=50,mn="NOT_SPREADSHEET",mi="VALID_SPREADSHEET",Xa=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},Eu=(e,o)=>e.slice(1).every(t=>Xa(t[o])!==null),nE=e=>{let o=e[0].length;if(o>2)return{type:mn,reason:"More than 2 columns"};if(o===1){if(!Eu(e,0))return{type:mn,reason:"Value is not numeric"};let s=Xa(e[0][0])===null,m=(s?e.slice(1):e).map(c=>Xa(c[0]));return m.length<2?{type:mn,reason:"Less than two rows"}:{type:mi,spreadsheet:{title:s?e[0][0]:null,labels:null,values:m}}}let t=Eu(e,0),r=Eu(e,1);if(!t&&!r)return{type:mn,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=Xa(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:mn,reason:"Less than 2 rows"}:{type:mi,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>Xa(s[i]))}}},D4=e=>{let o=[];for(let t=0;t<e[0].length;t++){let r=[];for(let n=0;n<e.length;n++)r.push(e[n][t]);o.push(r)}return o},dE=e=>{let o=e.trim().split(`
3
3
  `).map(i=>i.trim().split(" "));if(o.length&&o[0].length!==2&&(o=e.trim().split(`
4
- `).map(i=>i.trim().split(","))),o.length===0)return{type:dn,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:dn,reason:"All rows don't have same number of columns"};let n=rE(o);if(n.type!==mi){let i=rE(D4(o));if(i.type===mi)return i}return n},Sc=P4(L4),$t={fillStyle:"hachure",fontFamily:A4,fontSize:iE,opacity:100,roughness:1,strokeColor:nE.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:_4.MIDDLE,locked:!1},dE=e=>{let o=(uo+Te)*e.values.length+Te,t=kr+Te*2;return{chartWidth:o,chartHeight:t}},R4=(e,o,t,r,n)=>e.labels?.map((i,a)=>Cc({groupIds:[r],backgroundColor:n,...$t,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(uo+Te)+Te*2,y:t+Te/2,width:uo,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],N4=(e,o,t,r,n)=>{let i=Cc({groupIds:[r],backgroundColor:n,...$t,x:o-Te,y:t-Te,text:"0",textAlign:"right"}),a=Cc({groupIds:[r],backgroundColor:n,...$t,x:o-Te,y:t-kr-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},B4=(e,o,t,r,n)=>{let{chartWidth:i,chartHeight:a}=dE(e),l=Ka({backgroundColor:n,groupIds:[r],...$t,type:"line",x:o,y:t,width:i,points:[Sr(0,0),Sr(i,0)]}),s=Ka({backgroundColor:n,groupIds:[r],...$t,type:"line",x:o,y:t,height:a,points:[Sr(0,0),Sr(0,-a)]}),m=Ka({backgroundColor:n,groupIds:[r],...$t,type:"line",x:o,y:t-kr-Te,strokeStyle:"dotted",width:i,opacity:sE,points:[Sr(0,0),Sr(i,0)]});return[l,s,m]},mE=(e,o,t,r,n,i)=>{let{chartWidth:a,chartHeight:l}=dE(e),s=e.title?Cc({backgroundColor:n,groupIds:[r],...$t,text:e.title,x:o+a/2,y:t-kr-Te*2-iE,roundness:null,textAlign:"center"}):null,m=i?Eu({backgroundColor:n,groupIds:[r],...$t,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:nE.black,fillStyle:"solid",opacity:6}):null;return[...m?[m]:[],...s?[s]:[],...R4(e,o,t,r,n),...N4(e,o,t,r,n),...B4(e,o,t,r,n)]},F4=(e,o,t)=>{let r=Math.max(...e.values),n=aE(),i=Sc[Math.floor(Math.random()*Sc.length)];return[...e.values.map((l,s)=>{let m=l/r*kr;return Eu({backgroundColor:i,groupIds:[n],...$t,type:"rectangle",x:o+s*(uo+Te)+Te,y:t-m-Te,width:uo,height:m})}),...mE(e,o,t,n,i,lE())]},O4=(e,o,t)=>{let r=Math.max(...e.values),n=aE(),i=Sc[Math.floor(Math.random()*Sc.length)],a=0,l=[];for(let b of e.values){let x=a*(uo+Te),w=-(b/r)*kr;l.push([x,w]),a++}let s=Math.max(...l.map(b=>b[0])),m=Math.max(...l.map(b=>b[1])),c=Math.min(...l.map(b=>b[0])),d=Math.min(...l.map(b=>b[1])),p=Ka({backgroundColor:i,groupIds:[n],...$t,type:"line",x:o+Te+uo/2,y:t-Te,height:m-d,width:s-c,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let w=x*(uo+Te)+Te/2,E=-(b/r)*kr+Te/2;return Eu({backgroundColor:i,groupIds:[n],...$t,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+w+uo/2,y:t+E-Te*2,width:Te,height:Te})}),f=e.values.map((b,x)=>{let w=x*(uo+Te)+Te/2,E=b/r*kr+Te/2+Te;return Ka({backgroundColor:i,groupIds:[n],...$t,type:"line",x:o+w+uo/2+Te/2,y:t-E,height:E,strokeStyle:"dotted",opacity:sE,points:[Sr(0,0),Sr(0,E)]})});return[...mE(e,o,t,n,i,lE()),p,...f,...u]},pE=(e,o,t,r)=>e==="line"?O4(o,t,r):F4(o,t,r);var MJ="clipboard"in navigator&&"readText"in navigator.clipboard,Mc="clipboard"in navigator&&"writeText"in navigator.clipboard,pi="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,K4=e=>!!([Za.excalidraw,Za.excalidrawClipboard,Za.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),hE=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(kc.PASTE,{clipboardData:new DataTransfer});if(e)for(let[r,n]of Object.entries(e)){if(typeof n!="string"){o=o||[],o.push(n),t.clipboardData?.items.add(n);continue}try{if(t.clipboardData?.items.add(n,r),t.clipboardData?.getData(r)!==n)throw new Error(`Failed to set "${r}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let r=-1;for(let n of o){r++;try{if(t.clipboardData?.items.add(n),t.clipboardData?.files[r]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},Z4=({elements:e,files:o})=>{let t=H4(e),r=new Set(e.filter(l=>V4(l))),n=!1,i=e.reduce((l,s)=>(X4(s)&&(n=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});n&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Za.excalidrawClipboard,elements:e.map(l=>{if(uE(l,t)&&!r.has(uE(l,t))){let s=Y4(l);return W4(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},Lc=async(e,o,t)=>{await go(Z4({elements:e,files:o}),t)},$4=e=>{let o=cE(e);return o.type===mi?{spreadsheet:o.spreadsheet}:null};function gE(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let r=t.textContent?.trim();r&&o.push({type:"text",value:r})}else if(t instanceof HTMLImageElement){let r=t.getAttribute("src");r&&r.startsWith("http")&&o.push({type:"imageUrl",value:r})}else o=o.concat(gE(t));return o}var j4=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,ho.html),r=gE(t.body);if(r.length)return{type:"mixedContent",value:r}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},fE=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let r=await navigator.clipboard?.readText();if(r)return{[ho.text]:r}}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else{if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}}throw t}for(let t of o)for(let r of t.types)if(G4(z4,r))try{if(r===ho.text||r===ho.html)e[r]=await(await t.getType(r)).text();else if(U1(r)){let n=await t.getType(r),i=$1(n,r,void 0);e[r]=i}else throw new Um(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof Um?n.message:`Cannot retrieve ${r} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},q4=async(e,o=!1)=>{try{let t=e.findByType(ho.html),r=!o&&t&&j4(t);return r?r.value.every(n=>n.type==="text")?{type:"text",value:e.getData(ho.text)??r.value.map(n=>n.value).join(`
5
- `).trim()}:r:{type:"text",value:(e.getData(ho.text)||"").trim()}}catch{return{type:"text",value:""}}},J4=function(e){return this.find(o=>o.type===e)||null},Q4=function(e){return this.find(t=>t.type===e)?.value??null},eM=function(){return this.filter(e=>e.kind==="file")},$a=async e=>{let o;oM(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=(await Promise.all(Array.from(o||[]).map(async r=>{if(r.kind==="file"){let n=r.getAsFile();if(n){let i=await Z1(r);return{type:n.type,kind:"file",file:await us(n),fileHandle:i}}}else if(r.kind==="string"){let{type:n}=r,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(n):i=await new Promise(a=>{r.getAsString(l=>a(l))}),{type:n,kind:"string",value:i}}return null}))).filter(r=>r!=null);return Object.assign(t,{findByType:J4,getData:Q4,getFiles:eM})},bE=async(e,o=!1)=>{let t=await q4(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&$4(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===Za.excalidrawClipboardWithAPI;if(K4(r))return{elements:r.elements,files:r.files,text:o?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:t.value}},Pc=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[ho.png]:e})])}catch(o){if(U4(e))await navigator.clipboard.write([new window.ClipboardItem({[ho.png]:await e})]);else throw o}},go=async(e,o)=>{if(Mc)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(ho.text,e||""),o.clipboardData?.getData(ho.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!tM(e))throw new Error("Error copying to clipboard.")},tM=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let r=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${r}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let n=!1;try{t.select(),t.setSelectionRange(0,t.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),n},oM=e=>e.type===kc.PASTE||e.type===kc.COPY||e.type===kc.CUT;var mn=(e,{selectedElementIds:o},t)=>{e=cM(e);let r=t&&we(e,{selectedElementIds:o}),n=null,i=r?J(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(i.length===1&&dM(i[0])?(n=i[0],i=mM(e,n)):i.length>1&&(i=J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:lM(i)}},pn=async(e,o,t,r,{exportBackground:n,exportPadding:i=rM,viewBackgroundColor:a,name:l=t.name||nM,fileHandle:s=null,exportingFrame:m=null})=>{if(o.length===0)throw new Error(h("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let d=Nn(o,{exportBackground:n,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},r,{exportingFrame:m});if(e==="svg")return Wm(d.then(p=>new Blob([sM+p.outerHTML],{type:aM.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[xE.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await d.then(u=>u.outerHTML);try{await go(p)}catch{throw new Error(h("errors.copyToSystemClipboardFailed"))}return}}let c=cs(o,t,r,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:m});if(e==="png"){let d=Go(c);return t.exportEmbedScene&&(d=d.then(p=>import("./data/image-ERM7RAOD.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:ua(o,t,r,"local")})))),Wm(d,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[xE.png],fileHandle:s})}else if(e==="clipboard")try{let d=Go(c);await Pc(d)}catch(d){throw console.warn(d),d.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):iM&&d.name==="TypeError"?new Error(`${h("alerts.couldNotCopyToClipboard")}
4
+ `).map(i=>i.trim().split(","))),o.length===0)return{type:mn,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:mn,reason:"All rows don't have same number of columns"};let n=nE(o);if(n.type!==mi){let i=nE(D4(o));if(i.type===mi)return i}return n},Sc=P4(L4),$t={fillStyle:"hachure",fontFamily:A4,fontSize:aE,opacity:100,roughness:1,strokeColor:iE.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:_4.MIDDLE,locked:!1},mE=e=>{let o=(ho+Te)*e.values.length+Te,t=kr+Te*2;return{chartWidth:o,chartHeight:t}},R4=(e,o,t,r,n)=>e.labels?.map((i,a)=>Cc({groupIds:[r],backgroundColor:n,...$t,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(ho+Te)+Te*2,y:t+Te/2,width:ho,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],N4=(e,o,t,r,n)=>{let i=Cc({groupIds:[r],backgroundColor:n,...$t,x:o-Te,y:t-Te,text:"0",textAlign:"right"}),a=Cc({groupIds:[r],backgroundColor:n,...$t,x:o-Te,y:t-kr-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},B4=(e,o,t,r,n)=>{let{chartWidth:i,chartHeight:a}=mE(e),l=Ka({backgroundColor:n,groupIds:[r],...$t,type:"line",x:o,y:t,width:i,points:[Sr(0,0),Sr(i,0)]}),s=Ka({backgroundColor:n,groupIds:[r],...$t,type:"line",x:o,y:t,height:a,points:[Sr(0,0),Sr(0,-a)]}),m=Ka({backgroundColor:n,groupIds:[r],...$t,type:"line",x:o,y:t-kr-Te,strokeStyle:"dotted",width:i,opacity:cE,points:[Sr(0,0),Sr(i,0)]});return[l,s,m]},pE=(e,o,t,r,n,i)=>{let{chartWidth:a,chartHeight:l}=mE(e),s=e.title?Cc({backgroundColor:n,groupIds:[r],...$t,text:e.title,x:o+a/2,y:t-kr-Te*2-aE,roundness:null,textAlign:"center"}):null,m=i?yu({backgroundColor:n,groupIds:[r],...$t,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:iE.black,fillStyle:"solid",opacity:6}):null;return[...m?[m]:[],...s?[s]:[],...R4(e,o,t,r,n),...N4(e,o,t,r,n),...B4(e,o,t,r,n)]},F4=(e,o,t)=>{let r=Math.max(...e.values),n=lE(),i=Sc[Math.floor(Math.random()*Sc.length)];return[...e.values.map((l,s)=>{let m=l/r*kr;return yu({backgroundColor:i,groupIds:[n],...$t,type:"rectangle",x:o+s*(ho+Te)+Te,y:t-m-Te,width:ho,height:m})}),...pE(e,o,t,n,i,sE())]},O4=(e,o,t)=>{let r=Math.max(...e.values),n=lE(),i=Sc[Math.floor(Math.random()*Sc.length)],a=0,l=[];for(let b of e.values){let x=a*(ho+Te),w=-(b/r)*kr;l.push([x,w]),a++}let s=Math.max(...l.map(b=>b[0])),m=Math.max(...l.map(b=>b[1])),c=Math.min(...l.map(b=>b[0])),d=Math.min(...l.map(b=>b[1])),p=Ka({backgroundColor:i,groupIds:[n],...$t,type:"line",x:o+Te+ho/2,y:t-Te,height:m-d,width:s-c,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let w=x*(ho+Te)+Te/2,E=-(b/r)*kr+Te/2;return yu({backgroundColor:i,groupIds:[n],...$t,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+w+ho/2,y:t+E-Te*2,width:Te,height:Te})}),f=e.values.map((b,x)=>{let w=x*(ho+Te)+Te/2,E=b/r*kr+Te/2+Te;return Ka({backgroundColor:i,groupIds:[n],...$t,type:"line",x:o+w+ho/2+Te/2,y:t-E,height:E,strokeStyle:"dotted",opacity:cE,points:[Sr(0,0),Sr(0,E)]})});return[...pE(e,o,t,n,i,sE()),p,...f,...u]},uE=(e,o,t,r)=>e==="line"?O4(o,t,r):F4(o,t,r);var MJ="clipboard"in navigator&&"readText"in navigator.clipboard,Mc="clipboard"in navigator&&"writeText"in navigator.clipboard,pi="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,K4=e=>!!([Za.excalidraw,Za.excalidrawClipboard,Za.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),gE=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent(kc.PASTE,{clipboardData:new DataTransfer});if(e)for(let[r,n]of Object.entries(e)){if(typeof n!="string"){o=o||[],o.push(n),t.clipboardData?.items.add(n);continue}try{if(t.clipboardData?.items.add(n,r),t.clipboardData?.getData(r)!==n)throw new Error(`Failed to set "${r}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let r=-1;for(let n of o){r++;try{if(t.clipboardData?.items.add(n),t.clipboardData?.files[r]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},Z4=({elements:e,files:o})=>{let t=H4(e),r=new Set(e.filter(l=>V4(l))),n=!1,i=e.reduce((l,s)=>(X4(s)&&(n=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});n&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Za.excalidrawClipboard,elements:e.map(l=>{if(hE(l,t)&&!r.has(hE(l,t))){let s=Y4(l);return W4(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},Lc=async(e,o,t)=>{await fo(Z4({elements:e,files:o}),t)},$4=e=>{let o=dE(e);return o.type===mi?{spreadsheet:o.spreadsheet}:null};function fE(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let r=t.textContent?.trim();r&&o.push({type:"text",value:r})}else if(t instanceof HTMLImageElement){let r=t.getAttribute("src");r&&r.startsWith("http")&&o.push({type:"imageUrl",value:r})}else o=o.concat(fE(t));return o}var j4=e=>{let o=e.value;try{let t=new DOMParser().parseFromString(o,go.html),r=fE(t.body);if(r.length)return{type:"mixedContent",value:r}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},bE=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let r=await navigator.clipboard?.readText();if(r)return{[go.text]:r}}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else{if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}}throw t}for(let t of o)for(let r of t.types)if(G4(z4,r))try{if(r===go.text||r===go.html)e[r]=await(await t.getType(r)).text();else if(W1(r)){let n=await t.getType(r),i=j1(n,r,void 0);e[r]=i}else throw new Wm(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof Wm?n.message:`Cannot retrieve ${r} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},q4=async(e,o=!1)=>{try{let t=e.findByType(go.html),r=!o&&t&&j4(t);return r?r.value.every(n=>n.type==="text")?{type:"text",value:e.getData(go.text)??r.value.map(n=>n.value).join(`
5
+ `).trim()}:r:{type:"text",value:(e.getData(go.text)||"").trim()}}catch{return{type:"text",value:""}}},J4=function(e){return this.find(o=>o.type===e)||null},Q4=function(e){return this.find(t=>t.type===e)?.value??null},eM=function(){return this.filter(e=>e.kind==="file")},$a=async e=>{let o;oM(e)?o=e.clipboardData?.items:o=e.dataTransfer?.items;let t=(await Promise.all(Array.from(o||[]).map(async r=>{if(r.kind==="file"){let n=r.getAsFile();if(n){let i=await $1(r);return{type:n.type,kind:"file",file:await us(n),fileHandle:i}}}else if(r.kind==="string"){let{type:n}=r,i;return"clipboardData"in e&&e.clipboardData?i=e.clipboardData?.getData(n):i=await new Promise(a=>{r.getAsString(l=>a(l))}),{type:n,kind:"string",value:i}}return null}))).filter(r=>r!=null);return Object.assign(t,{findByType:J4,getData:Q4,getFiles:eM})},xE=async(e,o=!1)=>{let t=await q4(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&$4(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===Za.excalidrawClipboardWithAPI;if(K4(r))return{elements:r.elements,files:r.files,text:o?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:t.value}},Pc=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[go.png]:e})])}catch(o){if(U4(e))await navigator.clipboard.write([new window.ClipboardItem({[go.png]:await e})]);else throw o}},fo=async(e,o)=>{if(Mc)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(go.text,e||""),o.clipboardData?.getData(go.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!tM(e))throw new Error("Error copying to clipboard.")},tM=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let r=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${r}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let n=!1;try{t.select(),t.setSelectionRange(0,t.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),n},oM=e=>e.type===kc.PASTE||e.type===kc.COPY||e.type===kc.CUT;var pn=(e,{selectedElementIds:o},t)=>{e=cM(e);let r=t&&we(e,{selectedElementIds:o}),n=null,i=r?J(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(i.length===1&&dM(i[0])?(n=i[0],i=mM(e,n)):i.length>1&&(i=J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:lM(i)}},un=async(e,o,t,r,{exportBackground:n,exportPadding:i=rM,viewBackgroundColor:a,name:l=t.name||nM,fileHandle:s=null,exportingFrame:m=null})=>{if(o.length===0)throw new Error(h("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let d=Nn(o,{exportBackground:n,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},r,{exportingFrame:m});if(e==="svg")return Ym(d.then(p=>new Blob([sM+p.outerHTML],{type:aM.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[EE.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await d.then(u=>u.outerHTML);try{await fo(p)}catch{throw new Error(h("errors.copyToSystemClipboardFailed"))}return}}let c=cs(o,t,r,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:m});if(e==="png"){let d=Go(c);return t.exportEmbedScene&&(d=d.then(p=>import("./data/image-B72PYFWW.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:ua(o,t,r,"local")})))),Ym(d,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[EE.png],fileHandle:s})}else if(e==="clipboard")try{let d=Go(c);await Pc(d)}catch(d){throw console.warn(d),d.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):iM&&d.name==="TypeError"?new Error(`${h("alerts.couldNotCopyToClipboard")}
6
6
 
7
- ${h("hints.firefox_clipboard_write")}`):new Error(h("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var EE=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=H1(a);if(!a||!G1(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:m}=mn(e,o,!1);return await pn(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:m}),{fileHandle:a}};import{Fragment as gM,jsx as qo,jsxs as fM}from"react/jsx-runtime";var wu=F({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:fo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:r,app:n})=>qo(oE,{label:h("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),yE=F({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:fo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=hM(e),i=we(r,o)?J(r,o):r;return qo(gM,{children:uM.map(a=>{let[l,s]=O1(i,pM,a),m=`${h("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return qo(z,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:m,"aria-label":m,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),vu=F({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:fo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>qo(Wa,{checked:e.exportBackground,onChange:t=>o(t),children:h("imageExportDialog.label.withBackground")})}),Ac=F({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:fo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>fM(Wa,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[h("imageExportDialog.label.embedScene"),qo(mo,{label:h("imageExportDialog.tooltip.embedScene"),long:!0,children:qo("div",{className:"excalidraw-tooltip-icon",children:vb})})]})}),un=F({name:"saveToActiveFile",label:"buttons.save",icon:rn,trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{let n=!!o.fileHandle;try{let{fileHandle:i}=ds(o.fileHandle)?await EE(e,o,r.files,r.getName()):await is(e,o,r.files,r.getName());return{captureUpdate:fo.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?h("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):h("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:fo.EVENTUALLY}}},keyTest:e=>e.key===ui.S&&e[ui.CTRL_OR_CMD]&&!e.shiftKey}),ja=F({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:rn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await is(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:fo.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:h("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:fo.EVENTUALLY}}},keyTest:e=>e.key===ui.S&&e.shiftKey&&e[ui.CTRL_OR_CMD],PanelComponent:({updateData:e})=>qo(z,{type:"button",icon:bb,title:h("buttons.saveAs"),"aria-label":h("buttons.saveAs"),showAriaLabel:pe().editor.isMobile,hidden:!Rn,onClick:()=>e(null),"data-testid":"save-as-button"})}),hi=F({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{try{let{elements:n,appState:i,files:a}=await Ym(o,e);return{elements:n,appState:i,files:a,captureUpdate:fo.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:fo.EVENTUALLY}}},keyTest:e=>e[ui.CTRL_OR_CMD]&&e.key===ui.O}),wE=F({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:fo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>qo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:qo(eE,{value:e.exportWithDarkMode?yu.DARK:yu.LIGHT,onChange:t=>{o(t===yu.DARK)},title:h("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as bM,DEFAULT_FONT_FAMILY as xM,DEFAULT_TEXT_ALIGN as EM,CODES as vE,KEYS as TE,getLineHeight as yM}from"@haoxin-web/excalidraw-common";import{newElementWith as _c}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as wM,canApplyRoundnessTypeToElement as vM,getDefaultRoundnessTypeForElement as TM,isFrameLikeElement as IM,isArrowElement as CM,isExcalidrawElement as SM,isTextElement as Tu}from"@haoxin-web/excalidraw-element";import{getBoundTextElement as kM,redrawTextBoundingBox as MM}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as Iu}from"@haoxin-web/excalidraw-element";var IE="{}",Cu=F({name:"copyStyles",label:"labels.copyStyles",icon:bp,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&wM(i)){let a=kM(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(IE=JSON.stringify(n)),{appState:{...o,toast:{message:h("toast.copyStyles")}},captureUpdate:Iu.EVENTUALLY}},keyTest:e=>e[TE.CTRL_OR_CMD]&&e.altKey&&e.code===vE.C}),Su=F({name:"pasteStyles",label:"labels.pasteStyles",icon:bp,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(IE),i=n[0],a=n[1];if(!SM(i))return{elements:e,captureUpdate:Iu.EVENTUALLY};let l=J(e,o,{includeBoundTextElement:!0}),s=l.map(m=>m.id);return{elements:e.map(m=>{if(s.includes(m.id)){let c=i;if(Tu(m)&&m.containerId&&(c=a),!c)return m;let d=_c(m,{backgroundColor:c?.backgroundColor,strokeWidth:c?.strokeWidth,strokeColor:c?.strokeColor,strokeStyle:c?.strokeStyle,fillStyle:c?.fillStyle,opacity:c?.opacity,roughness:c?.roughness,roundness:c.roundness?vM(c.roundness.type,m)?c.roundness:TM(m):null});if(Tu(d)){let p=c.fontSize||bM,u=c.fontFamily||xM;d=_c(d,{fontSize:p,fontFamily:u,textAlign:c.textAlign||EM,lineHeight:c.lineHeight||yM(u)});let f=null;d.containerId&&(f=l.find(b=>Tu(d)&&b.id===d.containerId)||null),MM(d,f,r.scene)}return d.type==="arrow"&&CM(c)&&(d=_c(d,{startArrowhead:c.startArrowhead,endArrowhead:c.endArrowhead})),IM(m)&&(d=_c(d,{roundness:null,backgroundColor:"transparent"})),d}return m}),captureUpdate:Iu.IMMEDIATELY}},keyTest:e=>e[TE.CTRL_OR_CMD]&&e.altKey&&e.code===vE.V});import{KEYS as LM}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as PM}from"@haoxin-web/excalidraw-element";import{showSelectedShapeActions as AM}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as ku}from"@haoxin-web/excalidraw-element";import{jsx as CE}from"react/jsx-runtime";var _M=F({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:ku.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>CE(z,{type:"button",icon:Is,"aria-label":h("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),DM=F({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:ku.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>CE(z,{visible:AM(o,PM(e)),type:"button",icon:xb,"aria-label":h("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),hn=F({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:pb,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:r})=>(o.openDialog?.name==="help"&&r(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:ku.EVENTUALLY}),keyTest:e=>e.key===LM.QUESTION_MARK});import{getNonDeletedElements as Rc}from"@haoxin-web/excalidraw-element";import{newElementWith as ME}from"@haoxin-web/excalidraw-element";import{isBoundToContainer as RM}from"@haoxin-web/excalidraw-element";import{frameAndChildrenSelectedTogether as NM,getElementsInResizingFrame as BM,getFrameLikeElements as FM,getRootElements as OM,groupByFrameLikes as zM,removeElementsFromFrame as HM,replaceAllElementsInFrame as GM}from"@haoxin-web/excalidraw-element";import{KEYS as Nc,randomId as UM,arrayToMap as Mu,getShortcutKey as LE}from"@haoxin-web/excalidraw-common";import{getSelectedGroupIds as Dc,selectGroup as WM,selectGroupsForSelectedElements as YM,getElementsInGroup as SE,addToGroup as VM,removeFromSelectedGroups as XM,isElementInGroup as PE}from"@haoxin-web/excalidraw-element";import{syncMovedIndices as KM}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as qa}from"@haoxin-web/excalidraw-element";import{jsx as gi}from"react/jsx-runtime";var ZM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&PE(n,t),!0))return!0}return!1},kE=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!ZM(r)&&!NM(r)},Lu=F({name:"group",label:"labels.group",icon:e=>gi(hp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=OM(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:qa.EVENTUALLY};let i=Dc(o);if(i.length===1){let x=i[0],w=new Set(SE(e,x).map(v=>v.id)),E=new Set(n.map(v=>v.id));if(new Set([...Array.from(w),...Array.from(E)]).size===w.size)return{appState:o,elements:e,captureUpdate:qa.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&zM(n).forEach((w,E)=>{HM(w,r.scene.getNonDeletedElementsMap())});let s=UM(),m=Mu(n);a=a.map(x=>m.get(x.id)?ME(x,{groupIds:VM(x.groupIds,s,o.editingGroupId)}):x);let c=SE(a,s),d=c[c.length-1],p=a.lastIndexOf(d),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!PE(x,s)),b=KM([...f,...c,...u],Mu(c));return{appState:{...o,...WM(s,{...o,selectedGroupIds:{}},Rc(a))},elements:b,captureUpdate:qa.IMMEDIATELY}},predicate:(e,o,t,r)=>kE(e,o,r),keyTest:e=>!e.shiftKey&&e[Nc.CTRL_OR_CMD]&&e.key===Nc.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>gi(z,{hidden:!kE(e,o,r),type:"button",icon:gi(hp,{theme:o.theme}),onClick:()=>t(null),title:`${h("labels.group")} \u2014 ${LE("CtrlOrCmd+G")}`,"aria-label":h("labels.group"),visible:we(Rc(e),o)})}),Pu=F({name:"ungroup",label:"labels.ungroup",icon:e=>gi(gp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Dc(o),i=Mu(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:qa.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{RM(p)&&l.push(p.id);let u=XM(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:ME(p,{groupIds:u})});let s=YM(o,Rc(a),o,null),m=r.scene.getSelectedElements(o),c=new Set(m.filter(p=>p.frameId).map(p=>p.frameId));return FM(e).filter(p=>c.has(p.id)).forEach(p=>{p&&(a=GM(a,BM(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:qa.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Nc.CTRL_OR_CMD]&&e.key===Nc.G.toUpperCase(),predicate:(e,o)=>Dc(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>gi(z,{type:"button",hidden:Dc(o).length===0,icon:gi(gp,{theme:o.theme}),onClick:()=>t(null),title:`${h("labels.ungroup")} \u2014 ${LE("CtrlOrCmd+Shift+G")}`,"aria-label":h("labels.ungroup"),visible:we(Rc(e),o)})});import tL from"clsx";import{CaptureUpdateAction as NE}from"@haoxin-web/excalidraw-element";import{COLOR_CHARCOAL_BLACK as $M,COLOR_VOICE_CALL as jM,COLOR_WHITE as Fc,THEME as qM,UserIdleState as AE}from"@haoxin-web/excalidraw-common";var Bc=(e,o,t,r,n,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+r-i,t),e.quadraticCurveTo(o+r,t,o+r,t+i),e.lineTo(o+r,t+n-i),e.quadraticCurveTo(o+r,t+n,o+r-i,t+n),e.lineTo(o+i,t+n),e.quadraticCurveTo(o,t+n,o,t+n-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function JM(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);o=(o<<5)-o+r}return o}var gn=(e,o)=>`hsl(${Math.abs(JM(o?.id||e))%37*10}, 100%, 83%)`,_E=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},DE=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,m=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let c=11,d=14,p=l<0||l>r-c||s<0||s>n-d;l=Math.max(l,0),l=Math.min(l,r-c),s=Math.max(s,0),s=Math.min(s,n-d);let u=gn(i,m);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===AE.IDLE||f===AE.AWAY;b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===qM.DARK?"#2f6330":jM,w=m?.isSpeaking;w&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Fc,e.strokeStyle=Fc,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let E=o.remotePointerUsernames.get(i)||"";if(!p&&E){e.font="600 12px sans-serif";let y=(w?l+0:l)+c/2,v=(w?s+0:s)+d+2,C=5,S=3,P=e.measureText(E),M=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,R=Math.max(M,12),L=y-1,k=v-1,N=P.width+2+C*2+2,O=R+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(L,k,N,O,8),e.fillStyle=u,e.fill(),e.strokeStyle=Fc,e.stroke(),w&&(e.beginPath(),e.roundRect(L-2,k-2,N+4,O+4,8),e.strokeStyle=x,e.stroke())):Bc(e,L,k,N,O,8,Fc),e.fillStyle=$M,e.fillText(E,y+C+1,v+S+P.actualBoundingBoxAscent+Math.floor((R-M)/2)+2),w){e.fillStyle=x;let G=8,_=8,B=5;e.fillRect(L+N+_,k+(O/2-G/2),2,G),e.fillRect(L+N+_+B,k+(O/2-G*2/2),2,G*2),e.fillRect(L+N+_+B*2,k+(O/2-G/2),2,G)}}e.restore(),e.closePath()}};import QM from"clsx";import{useState as eL}from"react";import{jsx as RE}from"react/jsx-runtime";var Au=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=_E(t),[a,l]=eL(!1),s=!a&&r,m=s?void 0:{background:e};return RE("div",{className:QM("Avatar",n),style:m,onClick:o,children:s?RE("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as Ao,jsxs as Oc}from"react/jsx-runtime";var oL=F({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:NE.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:NE.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=o,l=gn(r,n),s=tL({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),m=n.isInCall?n.isSpeaking?Oc("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:h("userList.hint.isSpeaking"),children:[Ao("div",{}),Ao("div",{}),Ao("div",{})]}):n.isMuted?Ao("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:h("userList.hint.micMuted"),children:y0}):Ao("div",{title:h("userList.hint.inCall"),children:E0}):null;return i?Oc("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[Ao(Au,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),Ao("div",{className:"UserList__collaborator-name",children:n.username}),Oc("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Ao("div",{className:"UserList__collaborator-status-icon-is-followed",title:h("userList.hint.followStatus"),children:Kn}),m]})]}):Oc("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[Ao(Au,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),m&&Ao("div",{className:"UserList__collaborator-status-icon",children:m})]})}});import{LIBRARY_DISABLED_TYPES as rL,randomId as nL}from"@haoxin-web/excalidraw-common";import{deepCopyElement as iL}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as _u}from"@haoxin-web/excalidraw-element";var Du=F({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of rL)if(n.some(a=>a.type===i))return{captureUpdate:_u.EVENTUALLY,appState:{...o,errorMessage:h(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:nL(),status:"unpublished",elements:n.map(iL),created:Date.now()},...i])).then(()=>({captureUpdate:_u.EVENTUALLY,appState:{...o,toast:{message:h("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:_u.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as fi}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as aL}from"@haoxin-web/excalidraw-element";import{updateFrameMembershipOfSelectedElements as lL}from"@haoxin-web/excalidraw-element";import{KEYS as Mr,arrayToMap as sL,getShortcutKey as zc}from"@haoxin-web/excalidraw-common";import{alignElements as cL}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as bi}from"@haoxin-web/excalidraw-element";import{getSelectedElementsByGroup as dL}from"@haoxin-web/excalidraw-element";import{jsx as Ei}from"react/jsx-runtime";var Lt=(e,o)=>{let t=o.scene.getSelectedElements(e);return dL(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(r=>aL(r))},xi=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=cL(n,r,t.scene,o),a=sL(i);return lL(e.map(l=>a.get(l.id)||l),o,t)},mL=F({name:"alignTop",label:"labels.alignTop",icon:sp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"start",axis:"y"}),captureUpdate:bi.IMMEDIATELY}),keyTest:e=>e[Mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mr.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:sp,onClick:()=>t(null),title:`${h("labels.alignTop")} \u2014 ${zc("CtrlOrCmd+Shift+Up")}`,"aria-label":h("labels.alignTop"),visible:we(fi(e),o)})}),pL=F({name:"alignBottom",label:"labels.alignBottom",icon:cp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"end",axis:"y"}),captureUpdate:bi.IMMEDIATELY}),keyTest:e=>e[Mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mr.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:cp,onClick:()=>t(null),title:`${h("labels.alignBottom")} \u2014 ${zc("CtrlOrCmd+Shift+Down")}`,"aria-label":h("labels.alignBottom"),visible:we(fi(e),o)})}),uL=F({name:"alignLeft",label:"labels.alignLeft",icon:dp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"start",axis:"x"}),captureUpdate:bi.IMMEDIATELY}),keyTest:e=>e[Mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mr.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:dp,onClick:()=>t(null),title:`${h("labels.alignLeft")} \u2014 ${zc("CtrlOrCmd+Shift+Left")}`,"aria-label":h("labels.alignLeft"),visible:we(fi(e),o)})}),hL=F({name:"alignRight",label:"labels.alignRight",icon:mp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"end",axis:"x"}),captureUpdate:bi.IMMEDIATELY}),keyTest:e=>e[Mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mr.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:mp,onClick:()=>t(null),title:`${h("labels.alignRight")} \u2014 ${zc("CtrlOrCmd+Shift+Right")}`,"aria-label":h("labels.alignRight"),visible:we(fi(e),o)})}),gL=F({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:pp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"center",axis:"y"}),captureUpdate:bi.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:pp,onClick:()=>t(null),title:h("labels.centerVertically"),"aria-label":h("labels.centerVertically"),visible:we(fi(e),o)})}),fL=F({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:up,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"center",axis:"x"}),captureUpdate:bi.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:up,onClick:()=>t(null),title:h("labels.centerHorizontally"),"aria-label":h("labels.centerHorizontally"),visible:we(fi(e),o)})});import{getNonDeletedElements as BE}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as bL}from"@haoxin-web/excalidraw-element";import{CODES as FE,KEYS as OE,arrayToMap as xL,getShortcutKey as zE}from"@haoxin-web/excalidraw-common";import{updateFrameMembershipOfSelectedElements as EL}from"@haoxin-web/excalidraw-element";import{distributeElements as yL}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as HE}from"@haoxin-web/excalidraw-element";import{getSelectedElementsByGroup as wL}from"@haoxin-web/excalidraw-element";import{jsx as WE}from"react/jsx-runtime";var GE=(e,o)=>{let t=o.scene.getSelectedElements(e);return wL(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(r=>bL(r))},UE=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=yL(n,t.scene.getNonDeletedElementsMap(),r,o),a=xL(i);return EL(e.map(l=>a.get(l.id)||l),o,t)},vL=F({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:UE(e,o,r,{space:"between",axis:"x"}),captureUpdate:HE.IMMEDIATELY}),keyTest:e=>!e[OE.CTRL_OR_CMD]&&e.altKey&&e.code===FE.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>WE(z,{hidden:!GE(o,r),type:"button",icon:Sb,onClick:()=>t(null),title:`${h("labels.distributeHorizontally")} \u2014 ${zE("Alt+H")}`,"aria-label":h("labels.distributeHorizontally"),visible:we(BE(e),o)})}),TL=F({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:UE(e,o,r,{space:"between",axis:"y"}),captureUpdate:HE.IMMEDIATELY}),keyTest:e=>!e[OE.CTRL_OR_CMD]&&e.altKey&&e.code===FE.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>WE(z,{hidden:!GE(o,r),type:"button",icon:kb,onClick:()=>t(null),title:`${h("labels.distributeVertically")} \u2014 ${zE("Alt+V")}`,"aria-label":h("labels.distributeVertically"),visible:we(BE(e),o)})});import{getNonDeletedElements as IL}from"@haoxin-web/excalidraw-element";import{bindOrUnbindLinearElements as CL,isBindingEnabled as SL}from"@haoxin-web/excalidraw-element";import{getCommonBoundingBox as YE}from"@haoxin-web/excalidraw-element";import{newElementWith as kL}from"@haoxin-web/excalidraw-element";import{deepCopyElement as ML}from"@haoxin-web/excalidraw-element";import{resizeMultipleElements as LL}from"@haoxin-web/excalidraw-element";import{isArrowElement as PL,isElbowArrow as AL,isLinearElement as _L}from"@haoxin-web/excalidraw-element";import{updateFrameMembershipOfSelectedElements as VE}from"@haoxin-web/excalidraw-element";import{CODES as XE,KEYS as DL,arrayToMap as RL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as KE}from"@haoxin-web/excalidraw-element";var Ru=F({name:"flipHorizontal",label:"labels.flipHorizontal",icon:I0,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:VE(ZE(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:KE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===XE.H}),Nu=F({name:"flipVertical",label:"labels.flipVertical",icon:T0,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:VE(ZE(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:KE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===XE.V&&!e[DL.CTRL_OR_CMD]}),ZE=(e,o,t,r,n)=>{let i=J(IL(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=NL(i,o,t,r,n),l=RL(a);return e.map(s=>l.get(s.id)||s)},NL=(e,o,t,r,n)=>{if(e.every(u=>PL(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return kL(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=YE(e);LL(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,ML(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),CL(e.filter(_L),SL(t),[],n.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>AL(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:m,midY:c}=YE(e),[d,p]=[i-m,a-c];return s.forEach(u=>n.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),l.forEach(u=>n.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),e};import{isTextElement as BL}from"@haoxin-web/excalidraw-element";import{getTextFromElements as FL}from"@haoxin-web/excalidraw-element";import{CODES as OL,KEYS as $E,isFirefox as zL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as Ht}from"@haoxin-web/excalidraw-element";var yi=F({name:"copy",label:"labels.copy",icon:Ea,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Lc(n,r.files,t)}catch(i){return{captureUpdate:Ht.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Ht.EVENTUALLY}},keyTest:void 0}),Bu=F({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await fE()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),zL?{captureUpdate:Ht.EVENTUALLY,appState:{...o,errorMessage:h("hints.firefox_clipboard_write")}}:{captureUpdate:Ht.EVENTUALLY,appState:{...o,errorMessage:h("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(hE({types:n}))}catch(i){return console.error(i),{captureUpdate:Ht.EVENTUALLY,appState:{...o,errorMessage:h("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Ht.EVENTUALLY}},keyTest:void 0}),Hc=F({name:"cut",label:"labels.cut",icon:r0,trackEvent:{category:"element"},perform:(e,o,t,r)=>(yi.perform(e,o,t,r),La.perform(e,o,null,r)),keyTest:e=>e[$E.CTRL_OR_CMD]&&e.key===$E.X}),Gc=F({name:"copyAsSvg",label:"labels.copyAsSvg",icon:C0,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:Ht.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=mn(e,o,!0);try{await pn("clipboard-svg",n,o,r.files,{...o,exportingFrame:i,name:r.getName()});let a=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:h("toast.copyToClipboardAsSvg",{exportSelection:a.length?h("toast.selection"):h("toast.canvas"),exportColorScheme:o.exportWithDarkMode?h("buttons.darkMode"):h("buttons.lightMode")})}},captureUpdate:Ht.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Ht.EVENTUALLY}}},predicate:e=>Mc&&e.length>0,keywords:["svg","clipboard","copy"]}),Uc=F({name:"copyAsPng",label:"labels.copyAsPng",icon:S0,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:Ht.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=mn(e,o,!0);try{return await pn("clipboard",i,o,r.files,{...o,exportingFrame:a,name:r.getName()}),{appState:{...o,toast:{message:h("toast.copyToClipboardAsPng",{exportSelection:n.length?h("toast.selection"):h("toast.canvas"),exportColorScheme:o.exportWithDarkMode?h("buttons.darkMode"):h("buttons.lightMode")})}},captureUpdate:Ht.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Ht.EVENTUALLY}}},predicate:e=>pi&&e.length>0,keyTest:e=>e.code===OL.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Wc=F({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{go(FL(n))}catch{throw new Error(h("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Ht.EVENTUALLY}},predicate:(e,o,t,r)=>Mc&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(BL),keywords:["text","clipboard","copy"]});import{CODES as HL,KEYS as GL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as UL}from"@haoxin-web/excalidraw-element";var Yc=F({name:"gridMode",icon:A0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:UL.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[GL.CTRL_OR_CMD]&&e.code===HL.QUOTE});import{CODES as WL,KEYS as YL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as VL}from"@haoxin-web/excalidraw-element";var wi=F({name:"zenMode",label:"buttons.zenMode",icon:M0,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:VL.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[YL.CTRL_OR_CMD]&&e.altKey&&e.code===WL.Z});import{CODES as XL,KEYS as KL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as ZL}from"@haoxin-web/excalidraw-element";var Fu=F({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:k0,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:ZL.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[KL.CTRL_OR_CMD]&&e.altKey&&e.code===XL.S});import{CODES as $L,KEYS as jL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as qL}from"@haoxin-web/excalidraw-element";var vi=F({name:"stats",label:"stats.fullTitle",icon:v0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:qL.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[jL.CTRL_OR_CMD]&&e.altKey&&e.code===$L.SLASH});import{BOUND_TEXT_PADDING as jE,ROUNDNESS as qE,TEXT_ALIGN as QE,VERTICAL_ALIGN as ey,arrayToMap as ty,getFontString as JL}from"@haoxin-web/excalidraw-common";import{getOriginalContainerHeightFromCache as QL,resetOriginalContainerCache as eP,updateOriginalContainerCache as tP}from"@haoxin-web/excalidraw-element";import{computeBoundTextPosition as oP,computeContainerDimensionForBoundText as JE,getBoundTextElement as oy,redrawTextBoundingBox as ry}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as rP,isArrowElement as nP,isTextBindableContainer as Ou,isTextElement as Ja,isUsingAdaptiveRadius as iP}from"@haoxin-web/excalidraw-element";import{measureText as aP}from"@haoxin-web/excalidraw-element";import{syncMovedIndices as ny}from"@haoxin-web/excalidraw-element";import{newElement as lP}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as zu}from"@haoxin-web/excalidraw-element";var Hu=F({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>rP(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=oy(a,i);if(l){let{width:s,height:m}=aP(l.originalText,JL(l),l.lineHeight),c=QL(a.id);eP(a.id);let{x:d,y:p}=oP(a,l,i);r.scene.mutateElement(l,{containerId:null,width:s,height:m,text:l.originalText,x:d,y:p}),r.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:c||a.height})}}),{elements:e,appState:o,captureUpdate:zu.IMMEDIATELY}}}),Gu=F({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);if(n.length===2){let i=Ja(n[0])||Ja(n[1]),a;if(Ou(n[0])?a=n[0]:Ou(n[1])&&(a=n[1]),i&&a&&oy(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;Ja(n[0])&&Ou(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),r.scene.mutateElement(i,{containerId:a.id,verticalAlign:ey.MIDDLE,textAlign:QE.CENTER,autoResize:!0,angle:nP(a)?0:a?.angle??0}),r.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return ry(i,a,r.scene),tP(a.id,l),{elements:sP(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:zu.IMMEDIATELY}}}),sP=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===t.id);r.splice(n,1);let i=r.findIndex(a=>a.id===o.id);return r.splice(i+1,0,t),ny(r,ty([o,t])),r},cP=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===o.id);r.splice(n,1);let i=r.findIndex(a=>a.id===t.id);return r.splice(i,0,o),ny(r,ty([o,t])),r},iy=F({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>Ja(a));return n.length>0&&i},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of n)if(Ja(l)){let s=lP({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:iP("rectangle")?qE.ADAPTIVE_RADIUS:qE.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-jE,y:l.y-jE,width:JE(l.width,"rectangle"),height:JE(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let m=l.boundElements.filter(d=>d.type==="arrow").map(d=>d.id);i.filter(d=>m.includes(d.id)).forEach(d=>{let p=d.startBinding,u=d.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&r.scene.mutateElement(d,{startBinding:p,endBinding:u})})}r.scene.mutateElement(l,{containerId:s.id,verticalAlign:ey.MIDDLE,boundElements:null,textAlign:QE.CENTER,autoResize:!0}),ry(l,s,r.scene),i=cP([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:zu.IMMEDIATELY}}});import{isEmbeddableElement as SP}from"@haoxin-web/excalidraw-element";import{KEYS as gy,getShortcutKey as kP}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as MP}from"@haoxin-web/excalidraw-element";import{pointFrom as cy}from"@haoxin-web/excalidraw-math";import dP from"clsx";import{useCallback as ay,useEffect as ly,useLayoutEffect as mP,useRef as pP,useState as uP}from"react";import{EVENT as Uu,HYPERLINK_TOOLTIP_DELAY as hP,KEYS as Vc}from"@haoxin-web/excalidraw-common";import{getElementAbsoluteCoords as Ku}from"@haoxin-web/excalidraw-element";import{hitElementBoundingBox as gP}from"@haoxin-web/excalidraw-element";import{isElementLink as fP}from"@haoxin-web/excalidraw-element";import{getEmbedLink as bP,embeddableURLValidator as xP}from"@haoxin-web/excalidraw-element";import{sceneCoordsToViewportCoords as dy,viewportCoordsToSceneCoords as EP,wrapEvent as yP,isLocalLink as wP,normalizeLink as Wu}from"@haoxin-web/excalidraw-common";import{isEmbeddableElement as Yu}from"@haoxin-web/excalidraw-element";import{jsx as Ti,jsxs as sy}from"react/jsx-runtime";var Zu=380,vP=42,Vu=5,my=85,TP=500,Xu=!1,Xc=new Map,py=({element:e,scene:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=ko(),s=Mo(),m=pe(),c=e.link||"",[d,p]=uP(c),u=pP(null),f=l.showHyperlinkPopup==="editor",b=ay(()=>{if(!u.current)return;let v=Wu(u.current.value)||null;if(!e.link&&v&&ae("hyperlink","create"),Yu(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!xP(v,s.validateEmbeddable))v&&n({message:h("toast.unableToEmbed"),closable:!0}),e.link&&Xc.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:C,height:S}=e,P=bP(v);P?.error instanceof URIError&&n({message:h("toast.unrecognizedLinkFormat"),closable:!0});let M=P?P.intrinsicSize.w/P.intrinsicSize.h:1,R=Xc.get(e.id)!==e.link;o.mutateElement(e,{...R?{width:P?.type==="video"?C>S?C:S*M:C,height:P?.type==="video"&&C>S?C/M:S}:{},link:v}),i(e,!0),Xc.has(e.id)&&Xc.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,n,s.validateEmbeddable,l.activeEmbeddable,t,i]);mP(()=>()=>{b()},[b]),ly(()=>{f&&u?.current&&!(m.viewport.isMobile||m.isTouchScreen)&&u.current.select()},[f,m.viewport.isMobile,m.isTouchScreen]),ly(()=>{let v=null,C=S=>{if(f)return;v&&clearTimeout(v),CP(e,a,l,cy(S.clientX,S.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},TP))};return window.addEventListener(Uu.POINTER_MOVE,C,!1),()=>{window.removeEventListener(Uu.POINTER_MOVE,C,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=ay(()=>{ae("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),w=()=>{ae("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y}=uy(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:sy("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${E}px`,width:Zu,padding:Vu},children:[f?Ti("input",{className:dP("excalidraw-hyperlinkContainer-input"),placeholder:h("labels.link.hint"),ref:u,value:d,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[Vc.CTRL_OR_CMD]&&v.key===Vc.K&&v.preventDefault(),(v.key===Vc.ENTER||v.key===Vc.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?Ti("a",{href:Wu(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:wP(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&r){let C=yP(Uu.EXCALIDRAW_LINK,v.nativeEvent);r({...e,link:Wu(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Ti("div",{className:"excalidraw-hyperlinkContainer-link",children:h("labels.link.empty")}),sy("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&Ti(z,{type:"button",title:h("buttons.edit"),"aria-label":h("buttons.edit"),label:h("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:Nt}),Ti(z,{type:"button",title:h("labels.linkToElement"),"aria-label":h("labels.linkToElement"),label:h("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Ws}),c&&!Yu(e)&&Ti(z,{type:"button",title:h("buttons.remove"),"aria-label":h("buttons.remove"),label:h("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:Bt})]})]})},uy=(e,o,t)=>{let[r,n]=Ku(e,t),{x:i,y:a}=dy({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-Zu/2,s=a-o.offsetTop-my;return{x:l,y:s}},$u=(e,o)=>{let t=J(e,o);return Yu(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Qa=null,hy=(e,o,t)=>{Qa&&clearTimeout(Qa),Qa=window.setTimeout(()=>IP(e,o,t),hP)},IP=(e,o,t)=>{if(!e.link)return;let r=si();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=fP(e.link)?h("labels.link.goToElement"):e.link;let[n,i,a,l]=Ku(e,t),[s,m,c,d]=P1([n,i,a,l],e.angle,o),p=dy({sceneX:s,sceneY:m},o);lu(r,{left:p.x,top:p.y,width:c,height:d},"top"),ae("hyperlink","tooltip","link-icon"),Xu=!0},ju=()=>{Qa&&clearTimeout(Qa),Xu&&(Xu=!1,si().classList.remove("excalidraw-tooltip--visible"))},CP=(e,o,t,[r,n])=>{let{x:i,y:a}=EP({clientX:r,clientY:n},t),l=15/t.zoom.value;if(gP(cy(i,a),e,o))return!1;let[s,m,c]=Ku(e,o);if(i>=s&&i<=c&&a>=m-my&&a<=m)return!1;let{x:d,y:p}=uy(e,t,o);return!(r>=d-l&&r<=d+Zu+Vu*2+l&&n>=p-l&&n<=p+l+Vu*2+vP)};import{jsx as LP}from"react/jsx-runtime";var el=F({name:"hyperlink",label:(e,o)=>$u(e,o),icon:va,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:MP.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[gy.CTRL_OR_CMD]&&e.key===gy.K,predicate:(e,o)=>J(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=J(e,o);return LP(z,{type:"button",icon:va,"aria-label":h($u(e,o)),title:`${SP(e[0])?h("labels.link.labelEmbed"):h("labels.link.label")} - ${kP("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});import{KEYS as fy,arrayToMap as Ju,randomId as PP}from"@haoxin-web/excalidraw-common";import{elementsAreInSameGroup as AP,newElementWith as by,selectGroupsFromGivenElements as xy}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as Ey}from"@haoxin-web/excalidraw-element";var qu=e=>e.every(o=>!o.locked),tl=F({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return qu(r)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=J(o,e);return qu(t)?Hn:tn},trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=qu(n),a=Ju(n),l=n.length>1&&AP(n),m=n.length===1||l?null:PP(),c={...o.lockedMultiSelections};if(i)c={...o.lockedMultiSelections,...m?{[m]:!0}:{}};else if(l){let w=n[0].groupIds.at(-1);delete c[w]}let d=e.map(w=>{if(!a.has(w.id))return w;let E=w.groupIds;return i?m&&(E=[...E,m]):E=E.filter(y=>!o.lockedMultiSelections[y]),by(w,{locked:i,groupIds:E.length!==w.groupIds.length?E:w.groupIds})}),p=Ju(d),u=i?{}:Object.fromEntries(n.map(w=>[w.id,!0])),f=n.map(w=>p.get(w.id)||w),b=i?{}:xy(f,o),x=i?m||(l?n[0].groupIds.at(-1):n[0].id):null;return{elements:d,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:c,activeLockedId:x},captureUpdate:Ey.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===fy.L&&e[fy.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),yy=F({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:tn,predicate:(e,o)=>J(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),r=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return by(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),n=Ju(r),i=t.map(a=>n.get(a.id)||a);return{elements:r,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:xy(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:Ey.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as K_,isLinearElement as Z_,isLineElement as Ui}from"@haoxin-web/excalidraw-element";import{arrayToMap as $_,invariant as tg}from"@haoxin-web/excalidraw-common";import{toggleLinePolygonState as j_,CaptureUpdateAction as v2}from"@haoxin-web/excalidraw-element";import Kw from"clsx";import U7 from"fuzzy";import{useEffect as fd,useRef as W7,useState as gd}from"react";import{DEFAULT_SIDEBAR as Vw,EVENT as xd,KEYS as xo,capitalizeString as Y7,getShortcutKey as V7,isWritableElement as X7}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as uA}from"@haoxin-web/excalidraw-element";import{useEffect as nl,useMemo as wy,useRef as oh,useState as _P}from"react";import{getLinearElementSubType as Si,updateElbowArrowPoints as DP}from"@haoxin-web/excalidraw-element";import{pointFrom as Zc,pointRotateRads as RP}from"@haoxin-web/excalidraw-math";import{hasBoundTextElement as NP,isArrowBoundToElement as BP,isArrowElement as FP,isElbowArrow as OP,isLinearElement as ah,isUsingAdaptiveRadius as zP}from"@haoxin-web/excalidraw-element";import{getCommonBoundingBox as HP,getElementAbsoluteCoords as GP}from"@haoxin-web/excalidraw-element";import{getBoundTextElement as Sy,getBoundTextMaxHeight as UP,getBoundTextMaxWidth as WP,redrawTextBoundingBox as YP}from"@haoxin-web/excalidraw-element";import{wrapText as VP}from"@haoxin-web/excalidraw-element";import{assertNever as XP,CLASSES as KP,getFontString as Qu,isProdEnv as ZP,mapFind as $P,reduceToCommonValue as jP,updateActiveTool as vy}from"@haoxin-web/excalidraw-common";import{measureText as Ty}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as qP}from"@haoxin-web/excalidraw-element";import{newArrowElement as eh,newElement as JP,newLinearElement as QP}from"@haoxin-web/excalidraw-element";import{ShapeCache as eA}from"@haoxin-web/excalidraw-element";import{updateBindings as tA}from"@haoxin-web/excalidraw-element";import{jsx as ih}from"react/jsx-runtime";var oA=8,rA=10,ol=["rectangle","diamond","ellipse","triangle","pentagon"],rl=["line","sharpArrow","curvedArrow","elbowArrow"],nA=new Set(ol),iA=new Set(rl),ki=e=>nA.has(e),jc=e=>e==="arrow"||iA.has(e),bo=he(null),il=new Map,al=new Map,aA=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=oh(null);return nl(()=>{if(o.length===0){e.updateEditorAtom(bo,null);return}let r=Mi(o);r&&!t.current?t.current=r:(t.current&&!r||t.current&&r!==t.current)&&(e.updateEditorAtom(bo,null),t.current=null)},[o,e]),nl(()=>()=>{il.clear(),al.clear()},[]),ih(lA,{app:e,elements:o})},lA=({app:e,elements:o})=>{let t=Mi(o),r=wy(()=>t==="generic"?My(o):[],[t,o]),n=wy(()=>t==="linear"?nh(o):[],[t,o]),i=t==="generic"?r.every(d=>d.type===r[0].type):t==="linear"?n.every(d=>Si(d)===Si(n[0])):!1,[a,l]=_P({x:0,y:0}),s=oh(""),m=oh(null);nl(()=>{let d=[...r,...n].sort((x,w)=>x.id.localeCompare(w.id)),p=`
8
- ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${d.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(d.length===1){let[x,,,w,E,y]=GP(d[0],e.scene.getNonDeletedElementsMap());u=RP(Zc(x,w),Zc(E,y),d[0].angle)}else{let{minX:x,maxY:w}=HP(d);u=Zc(x,w)}let{x:f,y:b}=Py({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[r,n,e.scene,e.state]),nl(()=>{for(let d of n){let p=rh(d.id,pA(d));al.has(p)||al.set(p,d)}},[n]),nl(()=>{for(let d of r)if(!il.has(d.id)){let p=Sy(d,e.scene.getNonDeletedElementsMap());p&&il.set(d.id,{fontSize:p.fontSize})}},[r,e.scene]);let c=t==="linear"?[["line",so],["sharpArrow",zs],["curvedArrow",Gs],["elbowArrow",Hs]]:t==="generic"?[["rectangle",So],["diamond",ur],["ellipse",hr],["triangle",gr],["pentagon",fr]]:[];return ih("div",{ref:m,tabIndex:-1,style:{position:"absolute",top:`${a.y+(rA+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-oA}px`,zIndex:2},className:KP.CONVERT_ELEMENT_TYPE_POPUP,children:c.map(([d,p])=>{let u=i&&(t==="generic"&&r[0].type===d||t==="linear"&&Si(n[0])===d);return ih(z,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:d,keyBindingLabel:"","aria-label":d,"data-testid":`toolbar-${d}`,onChange:()=>{e.state.activeTool.type!==d&&ae("convertElementType",d,"ui"),lh(e,{conversionType:t,nextType:d}),m.current?.focus()}},`${o[0].id}${o[0].version}_${d}`)})})},sA=(e,o,t)=>{let r=WP(e,o),n=UP(e,o),i=VP(o.text,Qu(o),r),a=Ty(i,Qu(o),o.lineHeight),l=o.fontSize;for(;(a.width>r||a.height>n)&&l>0;){l-=1;let s={...o,fontSize:l};a=Ty(o.text,Qu(s),o.lineHeight)}qc(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),YP(o,e,t)},lh=(e,{conversionType:o,nextType:t,direction:r="right"})=>{if(!o)return!1;let n=e.scene.getSelectedElements(e.state),i=n.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=r==="right"?1:-1;if(o==="generic"){let l=My(n),m=l.every(c=>c.type===l[0].type)?ol.indexOf(l[0].type):-1;if(t=t??ol[(m+ol.length+a)%ol.length],t&&ki(t)){let c={};for(let p of l){let u=Cy(p,t,e);c[u.id]=u}let d=[];for(let p of e.scene.getElementsIncludingDeleted())c[p.id]?d.push(c[p.id]):d.push(p);e.scene.replaceAllElements(d);for(let p of Object.values(c)){let u=Sy(p,e.scene.getNonDeletedElementsMap());u&&(il.get(p.id)&&qc(u,e.scene.getNonDeletedElementsMap(),{fontSize:il.get(p.id)?.fontSize??u.fontSize}),sA(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:vy(p,{type:"selection"})}))}}if(o==="linear"){let l=nh(n);if(!t){let m=jP(l,Si),c=m?rl.indexOf(m):-1;t=rl[(c+rl.length+a)%rl.length]}if(jc(t)){let m=[],c=e.scene.getElementsMapIncludingDeleted();for(let d of l){let p=al.get(rh(d.id,t));if(p&&Si(p)===t)c.set(p.id,p),m.push(p);else{let u=Cy(d,t,e);c.set(u.id,u),m.push(u)}}e.scene.replaceAllElements(c);for(let d of m)if(ah(d))if(OP(d)){let p=cA(d);if(p.length<2)continue;let u=[];for(let b=1;b<p.length-2;b++)u.push({start:p[b],end:p[b+1],index:b+1});let f=DP(d,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});qc(d,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=$P(["line","sharpArrow","curvedArrow"],u=>al.get(rh(d.id,u)));if(p){let u=p.points;e.scene.mutateElement(d,{points:u})}}}let s=nh(e.scene.getSelectedElements(e.state));e.setState(m=>({selectedElementIds:i,selectedLinearElement:s.length===1?new qP(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:vy(m,{type:"selection"})}))}return!0},Mi=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(ki(t.type))return"generic";ky(t)&&(o=!0)}return o?"linear":null},ky=e=>ah(e)&&(!FP(e)||!BP(e)&&!NP(e)),rh=(e,o)=>`${e}:${o}`,My=e=>e.filter(o=>ki(o.type)),nh=e=>e.filter(o=>ky(o)),Kc=20,Ii=(e,o)=>e[0]===o[0],th=(e,o)=>e[1]===o[1],Iy=(e,o)=>Ii(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),cA=e=>{let o=[e.points[0]],t=dA(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<Kc?l[0]=a[0]:Math.abs(l[1]-a[1])<Kc&&(l[1]=a[1]),Ii(a,l)||th(a,l)||o.push(Zc(a[0],l[1])),o.push(l)}let r=[o[0]];for(let i=1;i<o.length-1;++i)Ii(o[i-1],o[i])&&Ii(o[i],o[i+1])||th(o[i-1],o[i])&&th(o[i],o[i+1])||r.push(o[i]);r.push(o[o.length-1]);let n=[r[0]];for(let i=1;i<r.length-1;++i){let a=n[n.length-1],l=r[i],s=r[i+1],m=Ii(a,l),c=Ii(l,s);if(m!==c){let d=Iy(a,l),p=Iy(l,s);if(d<Kc||p<Kc){if(p<d)m?s[0]=a[0]:s[1]=a[1];else if(c)for(let u=n.length-1;u>=0&&n[u][0]===a[0];--u)n[u][0]=l[0];else for(let u=n.length-1;u>=0&&n[u][1]===a[1];--u)n[u][1]=l[1];continue}}n.push(l)}return n.push(r[r.length-1]),n},dA=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[r,n]=o[o.length-1],[i,a]=e[t];(r!==i||n!==a)&&o.push(e[t])}return o},Cy=(e,o,t)=>{if(!mA(e.type,o)){if(!ZP())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(eA.delete(e),ki(o)){let r=Ci(JP({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:zP(o)?$c.ADAPTIVE_RADIUS:$c.PROPORTIONAL_RADIUS}:e.roundness}));return tA(r,t.scene),r}if(jc(o))switch(o){case"line":return Ci(QP({...e,type:"line"}));case"sharpArrow":return Ci(eh({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Ci(eh({...e,type:"arrow",elbowed:!1,roundness:{type:$c.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Ci(eh({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return XP(o,`unhandled conversion type: ${o}`),e},mA=(e,o)=>!!(ki(e)&&ki(o)||jc(e)&&jc(o)),pA=e=>ah(e)?Si(e):e.type,Ly=aA;var Ay=F({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,r){return Ve.set(bo,{type:"panel"}),{captureUpdate:uA.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>Mi(e)!==null});import{canCreateLinkFromElements as sh,defaultGetElementLinkFromSelection as hA,getLinkIdAndTypeFromSelection as gA}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as ll}from"@haoxin-web/excalidraw-element";var Jc=F({name:"copyElementLink",label:"labels.copyElementLink",icon:Yn,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=J(e,o);try{if(window.location){let i=gA(n,o);return i?(await go(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):hA(i.id,i.type)),{appState:{toast:{message:h("toast.elementLinkCopied"),closable:!0}},captureUpdate:ll.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:ll.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:ll.EVENTUALLY}},predicate:(e,o)=>sh(J(e,o))}),_y=F({name:"linkToElement",label:"labels.linkToElement",icon:Ws,perform:(e,o,t,r)=>{let n=J(e,o);return n.length!==1||!sh(n)?{elements:e,appState:o,app:r,captureUpdate:ll.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:J(e,o)[0].id}},captureUpdate:ll.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=J(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&sh(n)},trackEvent:!1});import{isDarwin as Dy,getShortcutKey as ne}from"@haoxin-web/excalidraw-common";var fA={toggleTheme:[ne("Shift+Alt+D")],saveScene:[ne("CtrlOrCmd+S")],loadScene:[ne("CtrlOrCmd+O")],clearCanvas:[ne("CtrlOrCmd+Delete")],imageExport:[ne("CtrlOrCmd+Shift+E")],commandPalette:[ne("CtrlOrCmd+/"),ne("CtrlOrCmd+Shift+P")],cut:[ne("CtrlOrCmd+X")],copy:[ne("CtrlOrCmd+C")],paste:[ne("CtrlOrCmd+V")],copyStyles:[ne("CtrlOrCmd+Alt+C")],pasteStyles:[ne("CtrlOrCmd+Alt+V")],selectAll:[ne("CtrlOrCmd+A")],deleteSelectedElements:[ne("Delete")],duplicateSelection:[ne("CtrlOrCmd+D"),ne(`Alt+${h("helpDialog.drag")}`)],sendBackward:[ne("CtrlOrCmd+[")],bringForward:[ne("CtrlOrCmd+]")],sendToBack:[Dy?ne("CtrlOrCmd+Alt+["):ne("CtrlOrCmd+Shift+[")],bringToFront:[Dy?ne("CtrlOrCmd+Alt+]"):ne("CtrlOrCmd+Shift+]")],copyAsPng:[ne("Shift+Alt+C")],group:[ne("CtrlOrCmd+G")],ungroup:[ne("CtrlOrCmd+Shift+G")],gridMode:[ne("CtrlOrCmd+'")],zenMode:[ne("Alt+Z")],objectsSnapMode:[ne("Alt+S")],stats:[ne("Alt+/")],addToLibrary:[],flipHorizontal:[ne("Shift+H")],flipVertical:[ne("Shift+V")],viewMode:[ne("Alt+R")],hyperlink:[ne("CtrlOrCmd+K")],toggleElementLock:[ne("CtrlOrCmd+Shift+L")],resetZoom:[ne("CtrlOrCmd+0")],zoomOut:[ne("CtrlOrCmd+-")],zoomIn:[ne("CtrlOrCmd++")],zoomToFitSelection:[ne("Shift+3")],zoomToFit:[ne("Shift+1")],zoomToFitSelectionInViewport:[ne("Shift+2")],toggleEraserTool:[ne("E")],toggleHandTool:[ne("H")],setFrameAsActiveTool:[ne("F")],saveFileToDisk:[ne("CtrlOrCmd+S")],saveToActiveFile:[ne("CtrlOrCmd+S")],toggleShortcuts:[ne("?")],searchMenu:[ne("CtrlOrCmd+F")],wrapSelectionInFrame:[]},He=(e,o=0)=>{let t=fA[e];return t&&t.length>0?t[o]||t[0]:""};var bA="\\u0300-\\u036f",xA="\\ufe20-\\ufe2f",EA="\\u20d0-\\u20ff",yA=bA+xA+EA,wA=`[${yA}]`,vA=RegExp(wA,"g"),TA=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,IA={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},ch=e=>e.replace(TA,o=>IA[o]||o).replace(vA,"");import u7 from"clsx";import{useEffect as h7,useState as g7}from"react";import{KEYS as f7,queryFocusableElements as Aw}from"@haoxin-web/excalidraw-common";import{useCallback as CA,useState as SA}from"react";var Ry=()=>{let[e,o]=SA(null),t=CA(r=>o(r),[]);return[e,t]};import{useState as Cw,useCallback as Ch,useMemo as Sw,useEffect as vw,memo as kw,useRef as o7}from"react";import{LIBRARY_DISABLED_TYPES as r7,randomId as n7,isShallowEqual as i7}from"@haoxin-web/excalidraw-common";import{useEffect as Oy,useRef as zy}from"react";import{URL_HASH_KEYS as ph,URL_QUERY_KEYS as uh,APP_NAME as Hy,EVENT as ed,DEFAULT_SIDEBAR as AA,LIBRARY_SIDEBAR_TAB as _A,arrayToMap as hh,cloneJSON as DA,preventUnload as RA,promiseTry as Gy,resolvablePromise as NA,toValidURL as BA,Queue as FA,Emitter as OA}from"@haoxin-web/excalidraw-common";import{hashElementsVersion as zA,hashString as HA}from"@haoxin-web/excalidraw-element";import{getCommonBoundingBox as mh}from"@haoxin-web/excalidraw-element";import{MIME_TYPES as fn}from"@haoxin-web/excalidraw-common";var Lr=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=Bn({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),{exportBackground:m,viewBackgroundColor:c}=s;return cs(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:m,exportPadding:i,viewBackgroundColor:c,exportingFrame:a},(d,p)=>{let u=document.createElement("canvas");if(r){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(d,p),x=r<b?r/b:o?.exportScale??1;return u.width=d*x,u.height=p*x,{canvas:u,scale:x}}let f=n?.(d,p)||{width:d,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},Ny=async e=>{let{mimeType:o=fn.png,quality:t}=e;o===fn.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${fn.png}" mimeType`),o==="image/jpg"&&(o=fn.jpg),o===fn.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${fn.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await Lr(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((n,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===fn.png&&e.appState?.exportEmbedScene&&(a=await z1({blob:a,metadata:ua(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},Li=async({elements:e,appState:o=mr(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:m}=Bn({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),c={...m,exportPadding:r};return Nn(s,c,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},kA=async e=>{if(e.type==="svg"){let o=await Li(e);await go(o.outerHTML)}else if(e.type==="png")await Pc(Ny(e));else if(e.type==="json")await Lc(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as MA,useState as LA}from"react";import{COLOR_PALETTE as PA}from"@haoxin-web/excalidraw-common";var dh=he(new Map),By=async e=>await Li({elements:e,appState:{exportBackground:!1,viewBackgroundColor:PA.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),Fy=(e,o,t)=>{let[r,n]=LA();return MA(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await By(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await By(o);n(i)})()},[e,o,t,n]),r},Qc=()=>{let[e]=ce(dh);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var GA=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],Wy=new OA,bn=he({status:"loaded",isInitialized:!1,libraryItems:[]}),sl=e=>DA(e),UA=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((r,n)=>r.id===o.elements[n].id&&r.versionNonce===o.elements[n].versionNonce)),Yy=(e,o)=>{let t=[];for(let r of o)UA(e,r)&&t.push(r);return[...t,...e]},Vy=(e,o)=>{let t=hh(o),r={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||r.deletedItems.set(i.id,i);let n=hh(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},gh=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",sl(this.currLibraryItems));I(this,"app");I(this,"updateQueue",[]);I(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);I(this,"notifyListeners",()=>{if(this.updateQueue.length>0)Ve.set(bn,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{Ve.set(bn,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=sl(this.currLibraryItems);let t=sl(this.currLibraryItems);this.app.props.onLibraryChange?.(t),Wy.trigger(Vy(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],Ve.set(dh,new Map)});I(this,"resetLibrary",()=>this.setLibrary([]));I(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(sl(t))}catch{return o(this.currLibraryItems)}}));I(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:AA.name,tab:_A}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),m;s instanceof Blob?m=await $m(s,i):m=fa(s,i),!t||window.confirm(h("alerts.confirmAddLibrary",{numShapes:m.length}))?(t&&this.app.focusContainer(),a(r?Yy(this.currLibraryItems,m):m)):l(new Dn)}catch(s){l(s)}}))));I(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=sl(await o),r(this.currLibraryItems)}catch(i){n(i)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},Xy=gh,rd=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:w}=mh(x.elements);return Math.max(b,w)},0),i=u=>{let f=0,b=0,x=0;for(let w of e){if(f%t===0&&(b=0),b===u){let{width:E}=mh(w.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,m=0,c=0,d=0,p=0;for(let u of e){c&&c%t===0&&(l+=s+50,a=0,d=0,p++),d===0&&(s=n(p)),m=i(d);let{minX:f,minY:b,width:x,height:w}=mh(u.elements),E=(m-x)/2,y=(s-w)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+y-b}))),a+=m+50,c++,d++}return r},WA=(e,o=GA)=>{if(typeof o=="function"?o(e):o.some(t=>{let r=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:n,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${r.hostname}$`).test(n)&&new RegExp(`^${r.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},fh=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(ph.addLibrary)||new URLSearchParams(window.location.search).get(uh.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},Pr=class Pr{constructor(o){I(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,r=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(fa(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?Pr.queue.push(n):n()}getLibraryItems(o){return Pr.getLibraryItems(this.adapter,o,!1)}};I(Pr,"queue",new FA),I(Pr,"run",async(o,t)=>{let r=new Pr(o);return Pr.queue.push(()=>t(r))});var Pi=Pr,cl=0,td=0,od=e=>HA(e.map(o=>`${o.id}:${zA(o.elements)}`).sort().join()),Uy=async(e,o)=>{try{return td++,await Pi.run(e,async t=>{let r=hh(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)r.delete(l);let n=[];for(let[l,s]of o.addedItems)r.has(l)?r.set(l,s):n.push(s);let i=n.concat(Array.from(r.values())),a=od(i);return a!==cl&&await e.save({libraryItems:i}),cl=a,i})}finally{td--}},YA=e=>{let{excalidrawAPI:o}=e,t=zy(e);t.current=e;let r=zy(!1);Oy(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let m=new Promise(async(d,p)=>{try{l=decodeURIComponent(l),l=BA(l),WA(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();d(f)}catch(u){p(u)}}),c=s!==o.id;await(c&&document.hidden?new Promise(d=>{window.addEventListener("focus",()=>d(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:m,prompt:c,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(d){throw o.updateScene({appState:{errorMessage:d.message}}),d}finally{if(window.location.hash.includes(ph.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(ph.addLibrary),window.history.replaceState({},Hy,`#${d.toString()}`)}else if(window.location.search.includes(uh.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(uh.addLibrary),window.history.replaceState({},Hy,`?${d.toString()}`)}}},i=l=>{l.preventDefault();let s=fh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=fh();if(a&&n(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,m=NA();s?m.resolve(Gy(s.load).then(async c=>{let d=null;try{if(!c)return Pi.getLibraryItems(l,"load");d=fa(c.libraryItems||[],"published");let p=await Uy(l,Vy([],d));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),d}}).catch(c=>(console.error(`error during library migration: ${c.message}`),Pi.getLibraryItems(l,"load")))):m.resolve(Gy(Pi.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:m.then(c=>{let d=c||[];return cl=od(d),d}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(ed.HASHCHANGE,i),()=>{window.removeEventListener(ed.HASHCHANGE,i)}},[o]),Oy(()=>{let n=Wy.on(async(a,l)=>{let s=r.current,m="adapter"in t.current&&t.current.adapter||null;try{m&&cl!==od(l)&&await Uy(m,a)}catch(c){console.error(`couldn't persist library update: ${c.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:h("errors.saveLibraryError")}})}}),i=a=>{td&&RA(a)};return window.addEventListener(ed.BEFORE_UNLOAD,i),()=>{window.removeEventListener(ed.BEFORE_UNLOAD,i),n(),cl=0,td=0}},[])};import ZA from"clsx";import{VERSIONS as VA}from"@haoxin-web/excalidraw-common";import{jsx as KA}from"react/jsx-runtime";var XA=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return KA("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${VA.excalidrawLibrary}`,target:"_excalidraw_libraries",children:h("labels.libraries")})},Ky=XA;import{jsx as $A,jsxs as jA}from"react/jsx-runtime";var nd=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>jA("div",{className:ZA("library-menu-control-buttons",i),style:r,children:[$A(Ky,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as Di,useEffect as Z8,useMemo as yw,useRef as $8,useState as j8}from"react";import{MIME_TYPES as q8,arrayToMap as J8}from"@haoxin-web/excalidraw-common";import{duplicateElements as Q8}from"@haoxin-web/excalidraw-element";import qA from"lodash.throttle";import{useEffect as JA}from"react";var QA=he(0),Zy=e=>{let[o,t]=ce(QA);return JA(()=>{let{current:r}=e;if(!r)return;let n=qA(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import A8 from"clsx";import{useCallback as _8,useState as yh}from"react";import{muteFSAbortError as D8}from"@haoxin-web/excalidraw-common";import{flushSync as $y}from"react-dom";import e8 from"clsx";import{jsx as id,jsxs as o8}from"react/jsx-runtime";var t8=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return o8("button",{className:e8("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&id("div",{style:a?{visibility:"hidden"}:{},children:r}),id("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&id("div",{style:{position:"absolute",inset:0},children:id(it,{})})]})},Jo=t8;import{jsx as jy,jsxs as qy}from"react/jsx-runtime";var r8=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=h("buttons.confirm"),cancelText:i=h("buttons.cancel"),className:a="",...l}=e,s=me(),m=pr(Ai),{container:c}=Xe();return qy(Ge,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,qy("div",{className:"confirm-dialog-buttons",children:[jy(Jo,{label:i,onClick:()=>{s({openMenu:null}),m(!1),$y(()=>{t()}),c?.focus()}}),jy(Jo,{label:n,onClick:()=>{s({openMenu:null}),m(!1),$y(()=>{o()}),c?.focus()},actionType:"danger"})]})]})},ad=r8;import sd from"open-color";import{useCallback as d8,useEffect as Eh,useRef as Jy,useState as bh}from"react";import{EDITOR_LS_KEYS as xh,EXPORT_DATA_TYPES as m8,MIME_TYPES as Qy,VERSIONS as p8,chunk as u8,getExportSource as h8}from"@haoxin-web/excalidraw-common";var jt=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};I(jt,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),I(jt,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import ld from"react";var n8=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,i8=/{{([\w-]+)}}/,a8=/<([\w-]+)>/,l8=/<\/([\w-]+)>/,s8=(e,o)=>{let t=[{name:"",children:[]}];return e.split(n8).filter(Boolean).forEach(r=>{let n=r.match(a8),i=r.match(l8),a=r.match(i8);if(n!==null){let l=n[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),m=ld.createElement(ld.Fragment,{},...s.children),c=o[s.name];typeof c=="function"&&t[t.length-1].children.push(c(m))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(r)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},c8=({i18nKey:e,children:o,...t})=>{let{t:r}=Ye();return ld.createElement(ld.Fragment,{},...s8(r(e),t))},yt=c8;import{jsx as de,jsxs as ct}from"react/jsx-runtime";var g8=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=u8(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(r*2)-r*2,a.height=i.length*128+(i.length+1)*(r*2)-r*2;let l=a.getContext("2d");l.fillStyle=sd.white,l.fillRect(0,0,a.width,a.height);for(let[s,m]of e.entries()){let c=await Lr({elements:m.elements,files:null,maxWidthOrHeight:128}),{width:d,height:p}=c,u=Math.floor(s/6)*(128+r*2),f=s%6*(128+r*2);l.drawImage(c,f+(128-d)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=sd.gray[4],l.strokeRect(f+r/2,u+r/2,128+r,128+r)}return await ps(new File([await Go(a)],"preview",{type:Qy.png}),{outputType:Qy.jpg,maxWidthOrHeight:5e3})},f8=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=Jy(null),a=Jy(null);return Eh(()=>{let l=i.current;l&&(async()=>{let s=await Li({elements:e.elements,appState:{...o,viewBackgroundColor:sd.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),ct("div",{className:"single-library-item",children:[e.status==="published"&&de("span",{className:"single-library-item-status",children:h("labels.statusPublished")}),de("div",{ref:i,className:"single-library-item__svg"}),de(z,{"aria-label":h("buttons.remove"),type:"button",icon:Vt,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:h("buttons.remove")}),ct("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[ct("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[ct("div",{style:{padding:"0.5em 0"},children:[de("span",{style:{fontWeight:500,color:sd.gray[6]},children:h("publishDialog.itemName")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),de("span",{className:"error",children:e.error})]})]})},b8=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=bh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[m,c]=bh(!1);Eh(()=>{let y=jt.get(xh.PUBLISH_LIBRARY);y&&s(y)},[]);let[d,p]=bh(o.slice());Eh(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},f=async y=>{y.preventDefault(),c(!0);let v=[],C=!1;if(d.forEach(k=>{let N="";k.name||(N=h("publishDialog.errors.required"),C=!0),v.push({...k,error:N})}),C){p(v),c(!1);return}let S=await g8(d),P={type:m8.excalidrawLibrary,version:p8.excalidrawLibrary,source:h8(),libraryItems:d},M=JSON.stringify(P,null,2),R=new Blob([M],{type:"application/json"}),L=new FormData;L.append("excalidrawLib",R),L.append("previewImage",S),L.append("previewImageType",S.type),L.append("title",l.name),L.append("authorName",l.authorName),L.append("githubHandle",l.githubHandle),L.append("name",l.name),L.append("description",l.description),L.append("twitterHandle",l.twitterHandle),L.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:L}).then(k=>k.ok?k.json().then(({url:N})=>{jt.delete(xh.PUBLISH_LIBRARY),r({url:N,authorName:l.authorName,items:d})}):k.json().catch(()=>{throw new Error(k.statusText||"something went wrong")}).then(N=>{throw new Error(N.message||k.statusText||"something went wrong")}),k=>{console.error(k),n(k),c(!1)}).catch(k=>{console.error(k),n(k),c(!1)})},b=()=>{let y=[];return d.forEach((v,C)=>{y.push(de("div",{className:"single-library-item-wrapper",children:de(f8,{libItem:v,appState:t,index:C,onChange:(S,P)=>{let M=d.slice();M[P].name=S,p(M)},onRemove:a})},C))}),de("div",{className:"selected-library-items",children:y})},x=d8(()=>{i(d),jt.set(xh.PUBLISH_LIBRARY,l),e()},[d,e,i,l]),w=!!o.length,E=o.some(y=>y.status==="published");return de(Ge,{onCloseRequest:x,title:h("publishDialog.title"),className:"publish-library",children:w?ct("form",{onSubmit:f,children:[de("div",{className:"publish-library-note",children:de(yt,{i18nKey:"publishDialog.noteDescription",link:y=>de("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),de("span",{className:"publish-library-note",children:de(yt,{i18nKey:"publishDialog.noteGuidelines",link:y=>de("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),de("div",{className:"publish-library-note",children:h("publishDialog.noteItems")}),E&&de("span",{className:"publish-library-note publish-library-warning",children:h("publishDialog.republishWarning")}),b(),ct("div",{className:"publish-library__fields",children:[ct("label",{children:[ct("div",{children:[de("span",{children:h("publishDialog.libraryName")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:h("publishDialog.placeholder.libraryName")})]}),ct("label",{style:{alignItems:"flex-start"},children:[ct("div",{children:[de("span",{children:h("publishDialog.libraryDesc")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:h("publishDialog.placeholder.libraryDesc")})]}),ct("label",{children:[ct("div",{children:[de("span",{children:h("publishDialog.authorName")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:h("publishDialog.placeholder.authorName")})]}),ct("label",{children:[de("span",{children:h("publishDialog.githubUsername")}),de("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:h("publishDialog.placeholder.githubHandle")})]}),ct("label",{children:[de("span",{children:h("publishDialog.twitterUsername")}),de("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:h("publishDialog.placeholder.twitterHandle")})]}),ct("label",{children:[de("span",{children:h("publishDialog.website")}),de("input",{type:"text",name:"website",pattern:"https?://.+",title:h("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:h("publishDialog.placeholder.website")})]}),de("span",{className:"publish-library-note",children:de(yt,{i18nKey:"publishDialog.noteLicense",link:y=>de("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),ct("div",{className:"publish-library__buttons",children:[de(Jo,{label:h("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),de(Jo,{type:"submit",label:h("buttons.submit"),actionType:"primary",isLoading:m})]})]}):de("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:h("publishDialog.atleastOneLibItem")})})},ew=b8;import y8 from"clsx";import{useEffect as w8,useRef as v8}from"react";import{EVENT as nw,KEYS as T8}from"@haoxin-web/excalidraw-common";import{forwardRef as tw}from"react";import ow from"clsx";import{jsx as rw}from"react/jsx-runtime";var x8=tw(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>rw("div",{className:ow("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),E8=tw(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>rw("div",{className:ow("Stack Stack_vertical",n),style:{"--gap":1,justifyItems:t,justifyContent:"flex-start",...i},ref:a,children:e})),Ue={Row:x8,Col:E8};import{jsx as cd}from"react/jsx-runtime";var iw=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=pe(),a=v8(null),l=br({onClickOutside:o});Jn(a,()=>{l.onClickOutside?.()}),w8(()=>{let m=d=>{d.key===T8.ESCAPE&&(d.stopImmediatePropagation(),l.onClickOutside?.())},c={capture:!0};return document.addEventListener(nw.KEYDOWN,m,c),()=>{document.removeEventListener(nw.KEYDOWN,m,c)}},[l]);let s=y8(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return cd(Wp.Provider,{value:{onSelect:r},children:cd("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?cd(Ue.Col,{className:"dropdown-menu-container",children:e}):cd(De,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};iw.displayName="DropdownMenuContent";var aw=iw;import{jsx as C8}from"react/jsx-runtime";var I8=({children:e,className:o="",selected:t,...r})=>C8("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),lw=I8;import{jsx as sw}from"react/jsx-runtime";var cw=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noopener",...s})=>{let m=cc(s.onClick,n);return sw("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:sc(i,a),title:s.title??s["aria-label"],onClick:m,children:sw(lc,{icon:e,shortcut:o,children:r})})},_i=cw;cw.displayName="DropdownMenuItemLink";import{jsx as S8}from"react/jsx-runtime";var dw=()=>S8("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),mw=dw;dw.displayName="DropdownMenuSeparator";import k8 from"clsx";import{jsx as M8}from"react/jsx-runtime";var pw=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=pe(),a=k8(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return M8("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},uw=pw;pw.displayName="DropdownMenuTrigger";import dd from"react";var hw=e=>{let o=dd.Children.toArray(e).find(t=>dd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},gw=e=>{let o=dd.Children.toArray(e).find(t=>dd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as L8,jsxs as P8}from"react/jsx-runtime";var Qo=({children:e,open:o})=>{let t=hw(e),r=gw(e);return P8(L8,{children:[t,o&&r]})};Qo.Trigger=uw;Qo.Content=aw;Qo.Item=xt;Qo.ItemLink=_i;Qo.ItemCustom=lw;Qo.Group=Da;Qo.Separator=mw;var Ie=Qo;Qo.displayName="DropdownMenu";import{jsx as Pt,jsxs as md}from"react/jsx-runtime";var R8=(e,o)=>e.filter(t=>o.includes(t.id)),N8=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=ce(bn),[m,c]=ce(Ai),d=()=>{let L=o.length?h("alerts.removeItemsFromsLibrary",{count:o.length}):h("alerts.resetLibrary"),k=o.length?h("confirmDialog.removeItemsFromLib"):h("confirmDialog.resetLibrary");return Pt(ad,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:k,children:Pt("p",{children:L})})},[p,u]=yh(!1),f=!!o.length,b=f?s.libraryItems.filter(L=>o.includes(L.id)):s.libraryItems,x=f?h("buttons.remove"):h("buttons.resetLibrary"),[w,E]=yh(!1),[y,v]=yh(null),C=_8(()=>md(Ge,{onCloseRequest:()=>v(null),title:h("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Pt("p",{children:Pt(yt,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:L=>Pt("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:L})})}),Pt(z,{type:"button",title:h("buttons.close"),"aria-label":h("buttons.close"),label:h("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),S=(L,k)=>{E(!1),v({url:L.url,authorName:L.authorName});let N=k.slice();N.forEach(O=>{o.includes(O.id)&&(O.status="published")}),t.setLibrary(N)},P=async()=>{try{await t.updateLibrary({libraryItems:ns({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(L){if(L?.name==="AbortError"){console.warn(L);return}e({errorMessage:h("errors.importLibraryError")})}},M=async()=>{let L=f?b:await t.getLatestLibrary();L1(L).catch(D8).catch(k=>{e({errorMessage:k.message})})},R=()=>md(Ie,{open:m,children:[Pt(Ie.Trigger,{onToggle:()=>c(!m),children:ob}),md(Ie.Content,{onClickOutside:()=>c(!1),onSelect:()=>c(!1),className:"library-menu",children:[!f&&Pt(Ie.Item,{onSelect:P,icon:Un,"data-testid":"lib-dropdown--load",children:h("buttons.load")}),!!b.length&&Pt(Ie.Item,{onSelect:M,icon:rn,"data-testid":"lib-dropdown--export",children:h("buttons.export")}),!!b.length&&Pt(Ie.Item,{onSelect:()=>u(!0),icon:Bt,children:x}),f&&Pt(Ie.Item,{icon:o0,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:h("buttons.publishLibrary")})]})]});return md("div",{className:A8("library-menu-dropdown-container",l),children:[R(),o.length>0&&Pt("div",{className:"library-actions-counter",children:o.length}),p&&d(),w&&Pt(ew,{onClose:()=>E(!1),libraryItems:R8(s.libraryItems,o),appState:a,onSuccess:L=>S(L,s.libraryItems),onError:L=>window.alert(L),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:L=>i(o.filter(k=>k!==L))}),y&&C()]})},wh=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=Oe(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=Qc(),a=xe(),l=me(),[s]=ce(bn),m=async d=>{let p=d.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:h("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return Pt(N8,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>m(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as Y8,useEffect as V8,useState as X8}from"react";import B8,{useCallback as F8}from"react";function O8(){return[!1,F8(o=>o(),[])]}var fw=B8.useTransition||O8;import bw from"clsx";import{memo as z8,useEffect as H8,useRef as G8,useState as U8}from"react";import{jsx as pd,jsxs as W8}from"react/jsx-runtime";var xw=z8(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=G8(null),m=Fy(e,o,l);H8(()=>{let f=s.current;if(f)return m&&(f.innerHTML=m.outerHTML),()=>{f.innerHTML=""}},[m]);let[c,d]=U8(!1),p=pe().editor.isMobile,u=t&&pd("div",{className:"library-unit__adder",children:tb});return W8("div",{className:bw("library-unit",{"library-unit__active":o,"library-unit--hover":o&&c,"library-unit--selected":n,"library-unit--skeleton":!m}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[pd("div",{className:bw("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):r(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}d(!1),a(e,f)}}),u,e&&o&&(c||p||n)&&pd(Wa,{checked:n,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),Ew=()=>pd("div",{className:"library-unit library-unit--skeleton"});import{Fragment as K8,jsx as ud}from"react/jsx-runtime";var vh=({children:e})=>ud("div",{className:"library-menu-items-container__grid",children:e}),hd=Y8(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=fw(),[s,m]=X8(0);return V8(()=>{s<e.length&&l(()=>{m(s+a)})},[s,e.length,l,a]),ud(K8,{children:e.map((c,d)=>d<s?ud(xw,{elements:c?.elements,isPending:!c?.id&&!!c?.elements,onClick:n,svgCache:i,id:c?.id,selected:r(c.id),onToggle:o,onDrag:t},c?.id??d):ud(Ew,{},d))})});import{Fragment as ww,jsx as At,jsxs as Ri}from"react/jsx-runtime";var e7=17,t7=64;function Th({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:m}){let c=$8(null),d=Zy(c);Z8(()=>{d>0&&c.current?.scrollTo(0,d)},[]);let{svgCache:p}=Qc(),u=yw(()=>o.filter(L=>L.status!=="published"),[o]),f=yw(()=>o.filter(L=>L.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!f.length,[w,E]=j8(null),y=Di((L,k)=>{let N=!m.includes(L),O=[...u,...f];if(N){if(k.shiftKey&&w){let G=O.findIndex(j=>j.id===w),_=O.findIndex(j=>j.id===L);if(G===-1||_===-1){s([...m,L]);return}let B=J8(m),K=O.reduce((j,X,q)=>((q>=G&&q<=_||B.has(X.id))&&j.push(X.id),j),[]);s(K)}else s([...m,L]);E(L)}else E(null),s(m.filter(G=>G!==L))},[w,s,f,m,u]),v=Di(L=>{let k;return m.includes(L)?k=o.filter(N=>m.includes(N.id)):k=o.filter(N=>N.id===L),k.map(N=>({...N,elements:Q8({type:"everything",elements:N.elements,randomizeSeed:!0}).duplicatedElements}))},[o,m]),C=Di((L,k)=>{k.dataTransfer.setData(q8.excalidrawlib,Vm(v(L)))},[v]),S=Di(L=>L?m.includes(L):!1,[m]),P=Di(()=>{t(n)},[n,t]),M=Di(L=>{L&&r(v(L))},[v,r]),R=p.size>=o.length?t7:e7;return Ri("div",{className:"library-menu-items-container",style:n.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&At(wh,{selectedItems:m,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),Ri(Ue.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:f.length>0?1:"0 1 auto",marginBottom:0},ref:c,children:[Ri(ww,{children:[!x&&At("div",{className:"library-menu-items-container__header",children:h("labels.personalLib")}),e&&At("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:At(it,{})}),!n.length&&!u.length?Ri("div",{className:"library-menu-items__no-items",children:[At("div",{className:"library-menu-items__no-items__label",children:h("library.noItems")}),At("div",{className:"library-menu-items__no-items__hint",children:f.length>0?h("library.hint_emptyPrivateLibrary"):h("library.hint_emptyLibrary")})]}):Ri(vh,{children:[n.length>0&&At(hd,{itemsRenderedPerBatch:R,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:C,onClick:P,isItemSelected:S,svgCache:p}),At(hd,{itemsRenderedPerBatch:R,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:M,isItemSelected:S,svgCache:p})]})]}),Ri(ww,{children:[(f.length>0||n.length>0||u.length>0)&&At("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:h("labels.excalidrawLib")}),f.length>0?At(vh,{children:At(hd,{itemsRenderedPerBatch:R,items:f,onItemSelectToggle:y,onItemDrag:C,onClick:M,isItemSelected:S,svgCache:p})}):u.length>0?At("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:h("library.noItems")}):null]}),b&&At(nd,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:At(wh,{selectedItems:m,onSelectItems:s})})]})]})}import{jsx as Ar,jsxs as Iw}from"react/jsx-runtime";var Ai=he(!1),Tw=({children:e})=>Ar("div",{className:"layer-ui__library",children:e}),a7=kw(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:m})=>{let[c]=ce(bn),d=Ch(f=>{(async(x,w)=>{ae("element","addToLibrary","ui");for(let y of r7)if(x.some(v=>v.type===y))return r({errorMessage:h(`errors.libraryElementTypeError.${y}`)});let E=[{status:"unpublished",elements:x,id:n7(),created:Date.now()},...w];t(),i.setLibrary(E).catch(()=>{r({errorMessage:h("alerts.errorAddingToLibrary")})})})(f,c.libraryItems)},[t,i,r,c.libraryItems]),p=Sw(()=>c.libraryItems,[c]);if(c.status==="loading"&&!c.isInitialized)return Ar(Tw,{children:Ar("div",{className:"layer-ui__library-message",children:Iw("div",{children:[Ar(it,{size:"2em"}),Ar("span",{children:h("labels.libraryLoadingMessage")})]})})});let u=c.libraryItems.length>0||o.length>0;return Iw(Tw,{children:[Ar(Th,{isLoading:c.status==="loading",libraryItems:p,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:m,selectedItems:s}),u&&Ar(nd,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Ih=(e,o)=>({elements:e,pending:J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),l7=(e,o)=>{let t=yr(),[r,n]=Cw(()=>Ih(t,e.selectedElementIds)),i=o7(new Map);return vw(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),vw(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!i7(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Ih(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let m=l.get(s)?.version;if(m&&m!==i.current.get(s))return Ih(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},Mw=kw(()=>{let e=Oe(),{onInsertElements:o}=e,t=Mo(),r=xe(),n=me(),[i,a]=Cw([]),l=Sw(()=>e.library,[e.library]),s=l7(r,e),m=Ch(d=>{o(rd(d))},[o]),c=Ch(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return Ar(a7,{pendingElements:s,onInsertLibraryItems:m,onAddToLibrary:c,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import s7 from"clsx";import{useRef as c7}from"react";import{createPortal as d7}from"react-dom";import{KEYS as m7}from"@haoxin-web/excalidraw-common";import{jsx as Lw,jsxs as p7}from"react/jsx-runtime";var Pw=e=>{let{closeOnClickOutside:o=!0}=e,t=Js({className:"excalidraw-modal-container"}),r=c7(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===m7.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return d7(p7("div",{className:s7("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[Lw("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),Lw("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as dl,jsxs as x7}from"react/jsx-runtime";function b7(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Ge=e=>{let[o,t]=Ry(),[r]=g7(document.activeElement),{id:n}=Xe(),i=pe().viewport.isMobile;h7(()=>{if(!o)return;let m=Aw(o);setTimeout(()=>{m.length>0&&e.autofocus!==!1&&(m[1]||m[0]).focus()});let c=d=>{if(d.key===f7.TAB){let p=Aw(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):f===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return o.addEventListener("keydown",c),()=>o.removeEventListener("keydown",c)},[o,e.autofocus]);let a=me(),l=pr(Ai),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return dl(Pw,{className:u7("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:b7(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:x7(De,{ref:t,children:[e.title&&dl("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:dl("span",{className:"Dialog__titleContent",children:e.title})}),i&&dl("button",{className:"Dialog__close",onClick:s,title:h("buttons.close"),"aria-label":h("buttons.close"),type:"button",children:Vt}),dl("div",{className:"Dialog__content",children:e.children})]})})};import Sh from"clsx";import{forwardRef as v7,useRef as T7,useImperativeHandle as I7,useLayoutEffect as C7,useState as S7}from"react";import E7 from"clsx";import{composeEventHandlers as y7}from"@haoxin-web/excalidraw-common";import{jsx as w7}from"react/jsx-runtime";var Gt=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>w7("button",{onClick:y7(i.onClick,a=>{o()}),type:e,className:E7("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as kh,jsxs as _w}from"react/jsx-runtime";var Ni=v7(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:m,...c},d)=>{let p=T7(null);I7(d,()=>p.current),C7(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=S7(!1);return _w("div",{className:Sh("ExcTextField",m,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&kh("div",{className:"ExcTextField__label",children:o}),_w("div",{className:Sh("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[kh("input",{className:Sh({"is-redacted":"value"in c&&c.value&&l&&!u}),readOnly:n,value:"value"in c?c.value:void 0,defaultValue:"defaultValue"in c?c.defaultValue:void 0,placeholder:r,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&kh(Gt,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?g0:Kn})]})]})});import{KEYS as Ce}from"@haoxin-web/excalidraw-common";var Dw=[{icon:ba,value:"selection",key:Ce.V,numericKey:Ce[1],fillable:!0},{icon:So,value:"rectangle",key:Ce.R,numericKey:Ce[2],fillable:!0},{icon:ur,value:"diamond",key:Ce.D,numericKey:Ce[3],fillable:!0},{icon:hr,value:"ellipse",key:Ce.O,numericKey:Ce[4],fillable:!0},{icon:gr,value:"triangle",key:null,numericKey:Ce[5],fillable:!0},{icon:fr,value:"pentagon",key:null,numericKey:Ce[6],fillable:!0},{icon:on,value:"arrow",key:Ce.A,numericKey:Ce[7],fillable:!0},{icon:so,value:"line",key:Ce.L,numericKey:Ce[8],fillable:!0},{icon:Nt,value:"freedraw",key:[Ce.P,Ce.X],numericKey:Ce[9],fillable:!1},{icon:Wo,value:"text",key:Ce.T,numericKey:null,fillable:!1},{icon:cb,value:"image",key:null,numericKey:null,fillable:!1},{icon:xa,value:"eraser",key:Ce.E,numericKey:null,fillable:!1},{icon:Yo,value:"laser",key:null,numericKey:null,fillable:!1},{icon:p0,value:"laserTrail",key:null,numericKey:null,fillable:!1}],Mh=e=>[{icon:ba,value:"selection",key:Ce.V,numericKey:null,fillable:!0},{icon:Nt,value:"freedraw",key:[Ce.P,Ce.X],numericKey:null,fillable:!1},{icon:so,value:"line",key:Ce.L,numericKey:null,fillable:!0},{icon:So,value:"rectangle",key:Ce.R,numericKey:null,fillable:!0},{icon:Wo,value:"text",key:Ce.T,numericKey:null,fillable:!1},{icon:xa,value:"eraser",key:Ce.E,numericKey:null,fillable:!1}],Rw=(e,o)=>Mh(o).find((r,n)=>r.numericKey!=null&&e===String(r.numericKey)||r.key&&(typeof r.key=="string"?r.key===e:r.key.includes(e)))?.value||null;import _h from"clsx";import{useState as L7}from"react";import{CLASSES as P7,KEYS as A7,capitalizeString as Ah,isTransparent as Bw}from"@haoxin-web/excalidraw-common";import{shouldAllowVerticalAlign as _7,suppportsHorizontalAlign as D7}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as Fw,isElbowArrow as R7,isImageElement as N7,isLinearElement as B7,isTextElement as F7}from"@haoxin-web/excalidraw-element";import{hasStrokeColor as Ow,toolIsArrow as zw}from"@haoxin-web/excalidraw-element";import{createIsolation as k7}from"jotai-scope";import Lh from"react";import _o from"tunnel-rat";var Ph=Lh.createContext(null),Se=()=>Lh.useContext(Ph),M7=k7(),Nw=()=>Lh.useMemo(()=>({MainMenuTunnel:_o(),WelcomeScreenMenuHintTunnel:_o(),WelcomeScreenToolbarHintTunnel:_o(),WelcomeScreenHelpHintTunnel:_o(),WelcomeScreenCenterTunnel:_o(),FooterCenterTunnel:_o(),DefaultSidebarTriggerTunnel:_o(),DefaultSidebarTabTriggersTunnel:_o(),OverwriteConfirmDialogTunnel:_o(),TTDDialogTriggerTunnel:_o(),tunnelsJotai:M7}),[]);import{Fragment as _r,jsx as dt,jsxs as wt}from"react/jsx-runtime";var Dh=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return Ow(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>Ow(r.type))},Rh=(e,o)=>cr(e.activeTool.type)||o.some(t=>cr(t.type)),Hw=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=rs(o,e),i=!1;n.length===2&&(Fw(n[0])||Fw(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=pe(),s=document.documentElement.getAttribute("dir")==="rtl",m=cr(e.activeTool.type)&&!Bw(e.currentItemBackgroundColor)||n.some(f=>cr(f.type)&&!Bw(f.backgroundColor)),c=n.length===1||i,d=!e.selectedLinearElement?.isEditing&&n.length===1&&B7(n[0])&&!R7(n[0]),p=!e.croppingElementId&&n.length===1&&N7(n[0]),u=!i&&Lt(e,r);return wt("div",{className:"selected-shape-actions",children:[dt("div",{children:Dh(e,n)&&t("changeStrokeColor")}),Rh(e,n)&&dt("div",{children:t("changeBackgroundColor")}),m&&t("changeFillStyle"),(zm(e.activeTool.type)||n.some(f=>zm(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(Hm(e.activeTool.type)||n.some(f=>Hm(f.type)))&&wt(_r,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Gm(e.activeTool.type)||n.some(f=>Gm(f.type)))&&dt(_r,{children:t("changeRoundness")}),(zw(e.activeTool.type)||n.some(f=>zw(f.type)))&&dt(_r,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(F7))&&wt(_r,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||D7(n,o))&&t("changeTextAlign")]}),_7(n,o)&&t("changeVerticalAlign"),(_n(e.activeTool.type)||n.some(f=>_n(f.type)))&&dt(_r,{children:t("changeArrowhead")}),t("changeOpacity"),wt("fieldset",{children:[dt("legend",{children:h("labels.layers")}),wt("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&wt("fieldset",{children:[dt("legend",{children:h("labels.align")}),wt("div",{className:"buttonList",children:[s?wt(_r,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):wt(_r,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),dt("div",{style:{flexBasis:"100%",height:0}}),wt("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),n.length>2&&t("distributeVertically")]})]})]}),!a&&n.length>0&&wt("fieldset",{children:[dt("legend",{children:h("labels.actions")}),wt("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),c&&t("hyperlink"),p&&t("cropEditor"),d&&t("toggleLinearEditor")]})]})]})},Gw=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=L7(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="laserTrail",m=e.type==="lasso"&&t.defaultSelectionTool!=="lasso",c=e.type==="embeddable",{TTDDialogTriggerTunnel:d}=Se();return wt(_r,{children:[Mh(t).map(({value:p,icon:u,key:f,numericKey:b,fillable:x},w)=>{if(r.tools?.[p]===!1)return null;let E=h(`toolBar.${p}`),y=f&&Ah(typeof f=="string"?f:f[0]),v=y?`${y} ${h("helpDialog.or")} ${b}`:`${b}`;return dt(z,{className:_h("Shape",{fillable:x}),type:"radio",icon:u,checked:e.type===p,name:"editor-current-shape",title:`${Ah(E)} \u2014 ${v}`,keyBindingLabel:b||y,"aria-label":Ah(E),"aria-keyshortcuts":v,"data-testid":`toolbar-${p}`,onPointerDown:({pointerType:C})=>{!o.penDetected&&C==="pen"&&t.togglePenMode(!0),p==="freedraw"?window.dispatchEvent(new CustomEvent("leftflyout:toggle",{detail:{group:"freedraw"}})):p==="line"?window.dispatchEvent(new CustomEvent("leftflyout:toggle",{detail:{group:"line"}})):p==="rectangle"?window.dispatchEvent(new CustomEvent("leftflyout:toggle",{detail:{group:"shapes"}})):p==="text"&&window.dispatchEvent(new CustomEvent("leftflyout:toggle",{detail:{group:"text"}})),p==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:C})=>{o.activeTool.type!==p&&ae("toolbar",p,"ui"),p==="image"?t.setActiveTool({type:p}):t.setActiveTool({type:p})}},p)}),dt("div",{className:"App-toolbar__divider"}),wt(Ie,{open:n,children:[dt(Ie.Trigger,{className:_h("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||c||m||l&&!t.props.isCollaborating}),onToggle:()=>i(!n),title:h("toolBar.extraTools"),children:a?Vn:c?mb:l&&!t.props.isCollaborating?Yo:m?xs:s0}),dt(Ie.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:dt(Ie.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:Yo,"data-testid":"toolbar-laser",selected:l,shortcut:A7.K.toLocaleUpperCase(),children:h("toolBar.laser")})})]})]})},Uw=({renderAction:e,zoom:o,visible:t=!0})=>t?dt(Ue.Col,{gap:1,className:P7.ZOOM_ACTIONS,children:wt(Ue.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}):null;var Ww=({actionManager:e,showExitZenModeBtn:o})=>dt("button",{type:"button",className:_h("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(wi),children:h("buttons.exitZenMode")});import{useRef as O7}from"react";var Nh=e=>{let o=O7({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as H7,jsxs as z7}from"react/jsx-runtime";var xn=he(null),Yw=()=>{let[e,o]=ce(xn),t=Ke();return e&&e==="clearCanvas"?H7(ad,{onConfirm:()=>{t.executeAction(jo),o(null)},onCancel:()=>o(null),title:h("clearCanvasDialog.title"),children:z7("p",{className:"clear-canvas__content",children:[" ",h("alerts.clearReset")]})}):null};var Bh={};T1(Bh,{toggleTheme:()=>G7});var G7={...cn,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(cn,"commandPalette")}};import{jsx as mt,jsxs as Do}from"react/jsx-runtime";var K7=he(null),Pe={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},Z7=e=>{switch(e){case Pe.app:return 1;case Pe.export:return 2;case Pe.editor:return 3;case Pe.tools:return 4;case Pe.elements:return 5;case Pe.links:return 6;default:return 10}},bd=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return Do("div",{className:Kw("shortcut",o),children:[r.map((n,i)=>mt("div",{className:"shortcut-wrapper",children:mt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),mt("div",{className:"shortcut-desc",children:t})]})},Zw=e=>!e.altKey&&e[xo.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===xo.P||e.key===xo.SLASH),Lde=Object.assign(e=>{let o=xe(),t=me();return fd(()=>{let r=n=>{Zw(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&ae("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(xd.KEYDOWN,r,{capture:!0}),()=>window.removeEventListener(xd.KEYDOWN,r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:mt($7,{...e})},{defaultItems:Bh});function $7({customCommandPaletteItems:e}){let o=Oe(),t=xe(),r=me(),n=Mo(),i=Ke(),[a,l]=ce(K7),[s,m]=gd(null),c=W7(null),d=br({uiAppState:t,customCommandPaletteItems:e,appProps:n});fd(()=>{let{uiAppState:S,customCommandPaletteItems:P,appProps:M}=d,R=O=>{let G="";return O.label&&(typeof O.label=="function"?G=h(O.label(o.scene.getNonDeletedElements(),S,o)):G=h(O.label)),G},L=O=>typeof O.icon=="function"?O.icon(S,o.scene.getNonDeletedElements()):O.icon,k=[],N=(O,G,_)=>{let B={label:R(O),icon:L(O),category:G,shortcut:He(O.name),keywords:O.keywords,predicate:O.predicate,viewMode:O.viewMode,perform:()=>{i.executeAction(O,"commandPalette")}};return _?_(B,O):B};if(S&&o.scene&&i){let O=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,el,Jc,_y].map(X=>N(X,Pe.elements,(q,se)=>({...q,predicate:se.predicate?se.predicate:(ie,be,ue,ao)=>J(ie,be).length>0}))),G=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(X=>N(X,Pe.tools)),_=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(X=>N(X,Pe.editor)),B=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(X=>N(X,Pe.export));k=[...O,..._,{label:R(jo),icon:L(jo),shortcut:He(jo.name),category:Pe.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Ve.set(xn,"clearCanvas")}},{label:h("buttons.exportImage"),category:Pe.export,icon:ks,shortcut:He("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...B];let K=[{label:h("toolBar.library"),category:Pe.app,icon:zn,viewMode:!1,perform:()=>{S.openSidebar?r({openSidebar:null}):r({openSidebar:{name:Vw.name,tab:Vw.defaultTab}})}},{label:h("search.title"),category:Pe.app,icon:Ft,viewMode:!0,perform:()=>{i.executeAction(ml)}},{label:h("labels.shapeSwitch"),category:Pe.elements,icon:Sa,perform:()=>{i.executeAction(Ay)}},{label:h("labels.changeStroke"),keywords:["color","outline"],category:Pe.elements,icon:Ss,viewMode:!1,predicate:(X,q)=>{let se=J(X,q);return se.length>0&&Dh(q,se)},perform:()=>{r(X=>({openMenu:X.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:h("labels.changeBackground"),keywords:["color","fill"],icon:Ss,category:Pe.elements,viewMode:!1,predicate:(X,q)=>{let se=J(X,q);return se.length>0&&Rh(q,se)},perform:()=>{r(X=>({openMenu:X.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:h("labels.canvasBackground"),keywords:["color"],icon:Ss,category:Pe.editor,viewMode:!1,perform:()=>{r(X=>({openMenu:X.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Dw.reduce((X,q)=>{let{value:se,icon:ie,key:be,numericKey:ue}=q;if(M.UIOptions.tools?.[se]===!1)return X;let To=be&&Y7(typeof be=="string"?be:be[0])||ue,es={label:h(`toolBar.${se}`),category:Pe.tools,shortcut:To||void 0,icon:ie,keywords:["toolbar"],viewMode:!1,perform:({event:Bm})=>{se==="image"?o.setActiveTool({type:se}):o.setActiveTool({type:se})}};return X.push(es),X},[]),...G,{label:h("toolBar.lock"),category:Pe.tools,icon:S.activeTool.locked?Hn:tn,shortcut:xo.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${h("labels.textToDiagram")}...`,category:Pe.tools,icon:b0,viewMode:!1,predicate:M.aiEnabled,perform:()=>{r(X=>({...X,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${h("toolBar.mermaidToExcalidraw")}...`,category:Pe.tools,icon:c0,viewMode:!1,predicate:M.aiEnabled,perform:()=>{r(X=>({...X,openDialog:{name:"ttd",tab:"mermaid"}}))}}],j=[...k,...K,...P||[]].map(X=>({...X,icon:X.icon||Sa,order:X.order??Z7(X.category),haystack:`${ch(X.label.toLocaleLowerCase())} ${X.keywords?.join(" ")||""}`}));m(j),l(j.find(X=>X.label===a?.label)??null)}},[d,o,i,m,a?.label,l,r]);let[p,u]=gd(""),[f,b]=gd(null),[x,w]=gd({}),E=S=>{r({openDialog:null},S),u("")},y=(S,P)=>{t.openDialog?.name==="commandPalette"&&(P.stopPropagation(),P.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),E(()=>{S.perform({actionManager:i,event:P}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=Nh(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,n,o):S.predicate===void 0||S.predicate),C=Nh(S=>{let P=X7(S.target)||Zw(S)||S.key===xo.ESCAPE;if(P&&S.key!==xo.ARROW_UP&&S.key!==xo.ARROW_DOWN&&S.key!==xo.ENTER)return;let M=Object.values(x).flat(),R=a&&!p&&v(a);if(S.key===xo.ARROW_UP){S.preventDefault();let L=M.findIndex(O=>O.label===f?.label);if(R){if(L===0){b(a);return}if(f===a){let O=M[M.length-1];O&&b(O);return}}let k;L===-1?k=M.length-1:k=L===0?M.length-1:(L-1)%M.length;let N=M[k];N&&b(N);return}if(S.key===xo.ARROW_DOWN){S.preventDefault();let L=M.findIndex(O=>O.label===f?.label);if(R){if(!f||L===M.length-1){b(a);return}if(f===a){let O=M[0];O&&b(O);return}}let k=(L+1)%M.length,N=M[k];N&&b(N);return}if(S.key===xo.ENTER&&f&&setTimeout(()=>{y(f,S)}),!P){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){c?.current?.focus();return}S.preventDefault()}});return fd(()=>(window.addEventListener(xd.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(xd.KEYDOWN,C,{capture:!0})),[C]),fd(()=>{if(!s)return;let S=L=>{let k={};for(let N of L)k[N.category]?k[N.category].push(N):k[N.category]=[N];return k},P=s.filter(v).sort((L,k)=>L.order-k.order),M=!p&&a&&v(a);if(!p){w(S(M?P.filter(L=>L.label!==a?.label):P)),b(M?a:P[0]||null);return}let R=ch(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));P=U7.filter(R,P,{extract:L=>L.haystack}).sort((L,k)=>k.score-L.score).map(L=>L.original),w(S(P)),b(P[0]??null)},[p,s,v,a]),Do(Ge,{onCloseRequest:()=>E(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[mt(Ni,{value:p,placeholder:h("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:c}),!o.device.viewport.isMobile&&Do("div",{className:"shortcuts-wrapper",children:[mt(bd,{shortcut:"\u2191\u2193",children:h("commandPalette.shortcuts.select")}),mt(bd,{shortcut:"\u21B5",children:h("commandPalette.shortcuts.confirm")}),mt(bd,{shortcut:V7("Esc"),children:h("commandPalette.shortcuts.close")})]}),Do("div",{className:"commands",children:[a&&!p&&Do("div",{className:"command-category",children:[Do("div",{className:"command-category-title",children:[h("commandPalette.recents"),mt("div",{className:"icon",style:{marginLeft:"6px"},children:x0})]}),mt(Xw,{command:a,isSelected:a.label===f?.label,onClick:S=>y(a,S),disabled:!v(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((S,P)=>Do("div",{className:"command-category",children:[mt("div",{className:"command-category-title",children:S}),x[S].map(M=>mt(Xw,{command:M,isSelected:M.label===f?.label,onClick:R=>y(M,R),onMouseMove:()=>b(M),showShortcut:!o.device.viewport.isMobile,appState:t},M.label))]},S)):s?Do("div",{className:"no-match",children:[mt("div",{className:"icon",children:Ft})," ",h("commandPalette.search.noMatch")]}):null]})]})}var Xw=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return Do("div",{className:Kw("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:n,onMouseMove:t?l:r,title:t?h("commandPalette.itemNotAvailable"):"",children:[Do("div",{className:"name",children:[e.icon&&mt(Ir,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),mt(Ra,{children:e.label})]}),i&&e.shortcut&&mt(bd,{shortcut:e.shortcut})]})};import{getSizeFromPoints as wbe,randomInteger as V_,getUpdatedTimestamp as X_}from"@haoxin-web/excalidraw-common";import{simplify as N_}from"points-on-curve";import{pointsOnBezierCurves as Rde}from"points-on-curve";import{invariant as Bde}from"@haoxin-web/excalidraw-common";import{curve as Ode,lineSegment as zde,pointFrom as Hde,pointDistance as Gde,pointFromArray as Ude,pointFromVector as Wde,pointRotateRads as Yde,polygon as Vde,polygonFromPoints as Xde,PRECISION as Kde,segmentsIntersectAt as Zde,vector as $de,vectorAdd as jde,vectorFromPoint as qde,vectorScale as Jde}from"@haoxin-web/excalidraw-math";import{getElementAbsoluteCoords as eme}from"@haoxin-web/excalidraw-element";var Fh=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as B_,pointDistance as x2,pointRotateRads as ibe}from"@haoxin-web/excalidraw-math";import{ROUGHNESS as F_,isTransparent as gl,assertNever as O_,COLOR_PALETTE as z_,LINE_POLYGON_POINT_MERGE_DISTANCE as lbe}from"@haoxin-web/excalidraw-common";import{RoughGenerator as H_}from"roughjs/bin/generator";import v1e from"roughjs/bin/rough";import{getStroke as M_}from"perfect-freehand";import{isRightAngleRads as C1e}from"@haoxin-web/excalidraw-math";import{BOUND_TEXT_PADDING as k1e,DEFAULT_REDUCED_GLOBAL_ALPHA as M1e,ELEMENT_READY_TO_ERASE_OPACITY as L1e,FRAME_STYLE as P1e,MIME_TYPES as h2,THEME as A1e,distance as _1e,getFontString as D1e,isRTL as R1e,getVerticalOffset as N1e}from"@haoxin-web/excalidraw-common";import Rge from"roughjs/bin/rough";import{arrayToMap as Bge,invariant as n2,rescalePoints as Fge,sizeOf as Oge}from"@haoxin-web/excalidraw-common";import{degreesToRadians as $h,lineSegment as Hge,pointDistance as Gge,pointFrom as at,pointFromArray as p_,pointRotateRads as Gi}from"@haoxin-web/excalidraw-math";import{pointsOnBezierCurves as Yge}from"points-on-curve";import{pointCenter as Jhe,pointFrom as Qhe,pointRotateRads as ege,pointsEqual as tge,pointDistance as oge,vectorFromPoint as rge,curveLength as nge,curvePointAtLength as ige}from"@haoxin-web/excalidraw-math";import{DRAGGING_THRESHOLD as sge,KEYS as cge,shouldRotateWithDiscreteAngle as dge,getGridPoint as mge,invariant as pge,tupleToCoors as uge,viewportCoordsToSceneCoords as hge}from"@haoxin-web/excalidraw-common";import{deconstructLinearOrFreeDrawElement as fge,isPathALoop as bge}from"@haoxin-web/excalidraw-element";import{KEYS as que,arrayToMap as Jue,isBindingFallthroughEnabled as Que,tupleToCoors as ehe,invariant as the,isDevEnv as ohe,isTestEnv as rhe}from"@haoxin-web/excalidraw-common";import{lineSegment as ihe,pointFrom as ahe,pointRotateRads as lhe,vectorFromPoint as she,pointDistanceSq as che,clamp as dhe,pointDistance as mhe,pointFromVector as phe,vectorScale as uhe,vectorNormalize as hhe,vectorCross as ghe,pointsEqual as fhe,lineSegmentIntersectionPoints as bhe,PRECISION as xhe}from"@haoxin-web/excalidraw-math";import{isTransparent as kpe}from"@haoxin-web/excalidraw-common";import{curveIntersectLineSegment as Lpe,isPointWithinBounds as Ppe,lineSegment as Ape,lineSegmentIntersectionPoints as _pe,pointFrom as Dpe,pointFromVector as Rpe,pointRotateRads as Npe,pointsEqual as Bpe,vectorFromPoint as Fpe,vectorNormalize as Ope,vectorScale as zpe}from"@haoxin-web/excalidraw-math";import{ellipse as Gpe,ellipseSegmentInterceptPoints as Upe}from"@haoxin-web/excalidraw-math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as j7,DEFAULT_PROPORTIONAL_RADIUS as Oh,LINE_CONFIRM_THRESHOLD as q7,ROUNDNESS as zh}from"@haoxin-web/excalidraw-common";import{curve as ime,curveCatmullRomCubicApproxPoints as ame,curveOffsetPoints as lme,lineSegment as sme,pointDistance as J7,pointFrom as cme,pointFromArray as dme,rectangle as mme}from"@haoxin-web/excalidraw-math";var Ed=(e,o=1)=>{if(e.length>=3){let[t,r]=[e[0],e[e.length-1]];return J7(t,r)<=q7/o}return!1},Bi=(e,o)=>{if(o.roundness?.type===zh.PROPORTIONAL_RADIUS||o.roundness?.type===zh.LEGACY)return e*Oh;if(o.roundness?.type===zh.ADAPTIVE_RADIUS){let t=o.roundness?.value??j7,r=t/Oh;return e<=r?e*Oh:t}return 0};import{ROUNDNESS as xme}from"@haoxin-web/excalidraw-common";import{pointsEqual as wme}from"@haoxin-web/excalidraw-math";var $w=e=>!!e&&e.type==="embeddable",jw=e=>!!e&&e.type==="iframe",Gh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),En=e=>e!=null&&e.type==="text";var yd=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var Dr=e=>e!=null&&Q7(e.type);var Fi=e=>e!=null&&e.type==="arrow",pl=e=>Fi(e)&&e.elbowed;var Q7=e=>e==="arrow"||e==="line";var Oi=e=>e!==null&&"containerId"in e&&e.containerId!==null&&En(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as jme,ARROW_LABEL_WIDTH_FRACTION as qme,BOUND_TEXT_PADDING as Jme,DEFAULT_FONT_SIZE as Qme,TEXT_ALIGN as epe,VERTICAL_ALIGN as tpe,getFontString as ope,isProdEnv as rpe,invariant as npe}from"@haoxin-web/excalidraw-common";import{pointFrom as ape,pointRotateRads as lpe}from"@haoxin-web/excalidraw-math";import{BOUND_TEXT_PADDING as kme,DEFAULT_FONT_SIZE as Mme,DEFAULT_FONT_FAMILY as Lme,getFontString as Pme,isTestEnv as Ame,normalizeEOL as _me}from"@haoxin-web/excalidraw-common";var Dme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Hme,isTestEnv as Gme}from"@haoxin-web/excalidraw-common";import{curvePointDistance as fpe,distanceToLineSegment as bpe,pointRotateRads as xpe}from"@haoxin-web/excalidraw-math";import{ellipse as ype,ellipseDistanceFromPoint as wpe}from"@haoxin-web/excalidraw-math/ellipse";import{invariant as eue,isDevEnv as tue,isTestEnv as oue}from"@haoxin-web/excalidraw-common";import{pointFrom as nue,pointFromVector as iue,pointRotateRads as aue,pointScaleFromOrigin as lue,pointsEqual as sue,triangleIncludesPoint as cue,vectorCross as due,vectorFromPoint as n_,vectorScale as mue}from"@haoxin-web/excalidraw-math";var Kh=[1,0],e2=[0,1],Zh=[-1,0],t2=[0,-1],wd=e=>{let[o,t]=e,r=Math.abs(o),n=Math.abs(t);return o>n?Kh:o<=-n?Zh:t>r?e2:t2},o2=(e,o)=>wd(n_(e,o)),vd=(e,o)=>Td(o2(e,o)),Xh=(e,o)=>e[0]===o[0]&&e[1]===o[1],Td=e=>Xh(e,Kh)||Xh(e,Zh);import{clamp as bue,pointDistance as xue,pointFrom as Eue,pointScaleFromOrigin as yue,pointsEqual as wue,pointTranslate as vue,vector as Tue,vectorCross as Iue,vectorFromPoint as Cue,vectorScale as Sue}from"@haoxin-web/excalidraw-math";import{BinaryHeap as Mue,invariant as Lue,isAnyTrue as Pue,tupleToCoors as Aue,getSizeFromPoints as _ue,isDevEnv as Due,arrayToMap as Rue}from"@haoxin-web/excalidraw-common";import{SHIFT_LOCKING_ANGLE as Dhe,viewportCoordsToSceneCoords as Rhe}from"@haoxin-web/excalidraw-common";import{normalizeRadians as Bhe,radiansBetweenAngles as Fhe,radiansDifference as Ohe}from"@haoxin-web/excalidraw-math";import{pointsEqual as Hhe}from"@haoxin-web/excalidraw-math";var Hh=e=>{let o=Math.floor(e.width/2)+1,t=0,r=e.width,n=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,r,n,i,a,0,n]},a2=e=>{let t=e.width/2,r=0,n=0,i=e.height,a=e.width,l=e.height;return[t,r,a,l,n,i]},l2=e=>{let o=e.width/2,t=e.height/2,r=Math.min(e.width,e.height)/2,n=r*.4,i=[];for(let a=0;a<10;a++){let l=(a*36-90)*(Math.PI/180),s=a%2===0?r:n,m=o+s*Math.cos(l),c=t+s*Math.sin(l);i.push(m,c)}return i};var u_=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"crowfoot_many":case"crowfoot_one":case"crowfoot_one_or_many":return 20;default:return 15}},h_=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},jh=(e,o,t,r)=>{if(o.length<1)return null;let n=Fh(o[0]);if(n.length<1)return null;let i=t==="start"?1:n.length-1,a=n[i].data;n2(a.length===6,"Op data length is not 6");let l=at(a[4],a[5]),s=at(a[2],a[3]),m=at(a[0],a[1]),c=n[i-1],d=at(0,0);if(c.op==="move"){let _=p_(c.data);n2(_!=null,"Op data is not a point"),d=_}else c.op==="bcurveTo"&&(d=at(c.data[4],c.data[5]));let p=(_,B)=>Math.pow(1-_,3)*l[B]+3*_*Math.pow(1-_,2)*s[B]+3*Math.pow(_,2)*(1-_)*m[B]+d[B]*Math.pow(_,3),[u,f]=t==="start"?d:l,[b,x]=[p(.3,0),p(.3,1)],w=Math.hypot(u-b,f-x),E=(u-b)/w,y=(f-x)/w,v=u_(r),C=0;{let[_,B]=t==="end"?e.points[e.points.length-1]:e.points[0],[K,j]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(_-K,B-j)}let P=Math.min(v,C*(r==="diamond"||r==="diamond_outline"?.25:.5)),M=u-E*P,R=f-y*P;if(r==="dot"||r==="circle"||r==="circle_outline"){let _=Math.hypot(R-f,M-u)+e.strokeWidth-2;return[u,f,_]}let L=h_(r);if(r==="crowfoot_many"||r==="crowfoot_one_or_many"){let[_,B]=Gi(at(u,f),at(M,R),$h(-L)),[K,j]=Gi(at(u,f),at(M,R),$h(L));return[M,R,_,B,K,j]}let[k,N]=Gi(at(M,R),at(u,f),-L*Math.PI/180),[O,G]=Gi(at(M,R),at(u,f),$h(L));if(r==="diamond"||r==="diamond_outline"){let _,B;if(t==="start"){let[K,j]=e.points.length>1?e.points[1]:[0,0];[_,B]=Gi(at(u+P*2,f),at(u,f),Math.atan2(j-f,K-u))}else{let[K,j]=e.points.length>1?e.points[e.points.length-2]:[0,0];[_,B]=Gi(at(u-P*2,f),at(u,f),Math.atan2(f-j,u-K))}return[u,f,k,N,_,B,O,G]}return[u,f,k,N,O,G]};import{pointFrom as nfe,pointCenter as ife,pointRotateRads as afe,vectorFromPoint as lfe,vectorNormalize as sfe,vectorSubtract as cfe,vectorAdd as dfe,vectorScale as mfe,pointFromVector as pfe,clamp as ufe,isCloseTo as hfe}from"@haoxin-web/excalidraw-math";import{arrayToMap as e1e}from"@haoxin-web/excalidraw-common";import{isPointWithinBounds as o1e,pointFrom as r1e}from"@haoxin-web/excalidraw-math";import{vectorCross as Efe,vectorFromPoint as yfe}from"@haoxin-web/excalidraw-math";import{arrayToMap as g_}from"@haoxin-web/excalidraw-common";import{getElementBounds as f_}from"@haoxin-web/excalidraw-element";import{isArrowElement as b_,isExcalidrawElement as x_,isFreeDrawElement as E_,isLinearElement as y_,isTextElement as w_}from"@haoxin-web/excalidraw-element";import{rangeIncludesValue as Id,pointFrom as er,pointRotateRads as v_,rangeInclusive as Cd}from"@haoxin-web/excalidraw-math";var T_=e=>e.type==="diamond"?[er(e.width/2,0),er(e.width,e.height/2),er(e.width/2,e.height),er(0,e.height/2)]:[er(0,0),er(0+e.width,0),er(0+e.width,e.height),er(0,e.height)],I_=e=>y_(e)||E_(e)?e.points:T_(e),s2=e=>{let o=e.reduce((t,[r,n])=>(t.minY=Math.min(t.minY,n),t.minX=Math.min(t.minX,r),t.maxX=Math.max(t.maxX,r),t.maxY=Math.max(t.maxY,n),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},c2=e=>{let o=I_(e),{cx:t,cy:r}=s2(o),n=er(t,r),i=o.map(c=>v_(c,n,e.angle)),{minX:a,minY:l,maxX:s,maxY:m}=s2(i);return[a+e.x,l+e.y,s+e.x,m+e.y]},qh=(e,o,t=!1)=>{let r=c2(e),n=o[0]<=r[0]&&o[2]>=r[2]&&o[1]<=r[1]&&o[3]>=r[3];return t?n?!0:r[0]<=o[0]&&r[2]>=o[2]&&r[1]<=o[1]&&r[3]>=o[3]:n},d2=(e,o)=>{let t=c2(e);return(Id(t[0],Cd(o[0],o[2]))||Id(o[0],Cd(t[0],t[2])))&&(Id(t[1],Cd(o[1],o[3]))||Id(o[1],Cd(t[1],t[3])))},m2=({elements:e,bounds:o,type:t,errorMargin:r=0})=>{x_(o)&&(o=f_(o,g_(e)));let n=[o[0]-r,o[1]-r,o[2]+r,o[3]+r],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?d2(a,n):t==="inside"?qh(a,n):qh(a,n,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);w_(a)&&a.containerId&&i.add(a.containerId),b_(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{arrayToMap as Bfe,isShallowEqual as S_}from"@haoxin-web/excalidraw-common";var C_=function(){let e=null,o=null,t=null,r=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let m={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let f=u.indexOf(l.editingGroupId);f>-1&&(u=u.slice(0,f))}if(u.length>0){let f=u[u.length-1];m[f]=!0}}let c={},d=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>m[b]);return f&&(p[u.id]=!0,Array.isArray(c[f])?c[f].push(u.id):c[f]=[u.id]),p},{});for(let p of Object.keys(c))c[p].length<2&&m[p]&&(m[p]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:m,selectedElementIds:Jh({...l.selectedElementIds,...d},s)},t},n=(i,a,l,s)=>{let m=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Qh(a,i);return m.length?r(m,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Jh(i.selectedElementIds,l)}};return n.clearCache=()=>{o=null,e=null,t=null},n}();var Wfe=function(){let e=null,o=null,t=null,r=(n,i)=>(t!=null&&n===e&&i.selectedElementIds===o||(t=n.some(a=>i.selectedElementIds[a.id]),e=n,o=i.selectedElementIds),t);return r.clearCache=()=>{e=null,o=null,t=null},r}(),Qh=(e,o,t)=>{let r=new Set,n=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){n.push(i),r.add(i.id);continue}if(t?.includeBoundTextElement&&Oi(i)&&o.selectedElementIds[i?.containerId]){n.push(i),r.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return n.forEach(a=>{yd(a)&&p2(e,a.id).forEach(l=>!r.has(l.id)&&i.push(l)),i.push(a)}),i}return n};var Jh=(e,o)=>S_(o.selectedElementIds,e)?o.selectedElementIds:e;var p2=(e,o)=>{let t=[];for(let r of e.values())r.frameId===o&&t.push(r);return t};var L_=typeof document<"u"?document.createElement("img"):{src:""};L_.src=`data:${h2.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;var P_=typeof document<"u"?document.createElement("img"):{src:""};P_.src=`data:${h2.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 g2=new WeakMap;var A_=new WeakMap([]);function f2(e){let o=__(e),t=new Path2D(o);return A_.set(e,t),t}function __(e){let o=e.simulatePressure?e.points:e.points.length?e.points.map(([r,n],i)=>[r,n,e.pressures[i]]):[[0,0,.5]],t={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:r=>Math.sin(r*Math.PI/2),last:!!e.lastCommittedPoint};return R_(M_(o,t))}function u2(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var D_=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function R_(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,r,n,i)=>(n===o?t.push(r,u2(r,i[0]),"L",i[0],"Z"):t.push(r,u2(r,i[n+1])),t),["M",e[0],"Q"]).join(" ").replace(D_,"$1")}var b2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="triangle"||e==="pentagon"||e==="image";var ut=class ut{};I(ut,"rg",new H_),I(ut,"cache",new WeakMap),I(ut,"get",o=>ut.cache.get(o)),I(ut,"set",(o,t)=>ut.cache.set(o,t)),I(ut,"delete",o=>ut.cache.delete(o)),I(ut,"destroy",()=>{ut.cache=new WeakMap}),I(ut,"generateElementShape",(o,t)=>{let r=t?.isExporting?void 0:ut.get(o);if(r!==void 0)return r;g2.delete(o);let n=W_(o,ut.rg,t||{isExporting:!1,canvasBackgroundColor:z_.white,embedsValidationStatus:null});return ut.cache.set(o,n),n});var Hi=ut,G_=e=>[8,8+e],y2=e=>[1.5,6+e];function U_(e){let o=e.roughness,t=Math.max(e.width,e.height),r=Math.min(e.width,e.height);return r>=20&&t>=50||r>=15&&e.roundness&&b2(e.type)||Dr(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var pt=(e,o=!1)=>{let t={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?G_(e.strokeWidth):e.strokeStyle==="dotted"?y2(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:U_(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<F_.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"triangle":case"pentagon":case"callout":case"ellipse":return t.fillStyle=e.fillStyle,t.fill=gl(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(t.curveFitting=1),t;case"hollow_arrow":case"hollow_double_arrow":return t.fill=void 0,t.fillStyle=void 0,t;case"line":case"freedraw":return Ed(e.points)&&(t.fillStyle=e.fillStyle,t.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),t;case"arrow":return t;default:throw new Error(`Unimplemented type ${e.type}`)}},eg=(e,o,t)=>Gh(e)&&(o||$w(e)&&t?.get(e.id)!==!0)&&gl(e.backgroundColor)&&gl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:jw(e)?{...e,strokeColor:gl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:gl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,E2=(e,o,t,r,n,i,a)=>{let l=jh(e,o,t,r);if(l===null)return[];let s=(m,c)=>{if(m===null)return[];let[,,d,p,u,f]=m;return[n.line(d,p,u,f,c)]};switch(r){case"dot":case"circle":case"circle_outline":{let[m,c,d]=l;return delete i.strokeLineDash,[n.circle(m,c,d,{...i,fill:r==="circle_outline"?void 0:e.strokeColor,fillStyle:r==="circle_outline"?void 0:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[m,c,d,p,u,f]=l;return delete i.strokeLineDash,[n.polygon([[m,c],[d,p],[u,f],[m,c]],{...i,fill:r==="triangle_outline"?void 0:e.strokeColor,fillStyle:r==="triangle_outline"?void 0:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[m,c,d,p,u,f,b,x]=l;return delete i.strokeLineDash,[n.polygon([[m,c],[d,p],[u,f],[b,x],[m,c]],{...i,fill:r==="diamond_outline"?void 0:e.strokeColor,fillStyle:r==="diamond_outline"?void 0:"solid",roughness:Math.min(1,i.roughness||0)})]}case"crowfoot_one":return s(l,i);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[m,c,d,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=y2(e.strokeWidth-1);i.strokeLineDash=[b[0],b[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(d,p,m,c,i),n.line(u,f,m,c,i),...r==="crowfoot_one_or_many"?s(jh(e,o,t,"crowfoot_one"),i):[]]}}};var W_=(e,o,{isExporting:t,canvasBackgroundColor:r,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"callout":{let i;if(e.roundness){let a=e.width,l=e.height,s=Bi(Math.min(a,l),e);i=o.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,pt(eg(e,t,n),!0))}else if(e.type==="callout"){let a=e.width,l=e.height,s=a*.34,m=a*.22,c=a*.12,d=l+l*.18,p=pt(eg(e,t,n),!1);p.disableMultiStroke=!0,p.disableMultiStrokeFill=!0;let u=`M 0 0 L ${a} 0 L ${a} ${l} L ${s} ${l} L ${c} ${d} L ${m} ${l} L 0 ${l} L 0 0 Z`;i=o.path(u,p)}else i=o.rectangle(0,0,e.width,e.height,pt(eg(e,t,n),!1));return i}case"diamond":{let i,[a,l,s,m,c,d,p,u]=Hh(e);if(e.roundness){let f=Bi(Math.abs(a-p),e),b=Bi(Math.abs(m-l),e);i=o.path(`M ${a+f} ${l+b} L ${s-f} ${m-b}
7
+ ${h("hints.firefox_clipboard_write")}`):new Error(h("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var yE=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=G1(a);if(!a||!U1(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:m}=pn(e,o,!1);return await un(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:m}),{fileHandle:a}};import{Fragment as gM,jsx as qo,jsxs as fM}from"react/jsx-runtime";var vu=F({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:bo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:r,app:n})=>qo(rE,{label:h("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),wE=F({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:bo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=hM(e),i=we(r,o)?J(r,o):r;return qo(gM,{children:uM.map(a=>{let[l,s]=z1(i,pM,a),m=`${h("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return qo(z,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:m,"aria-label":m,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),Tu=F({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:bo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>qo(Wa,{checked:e.exportBackground,onChange:t=>o(t),children:h("imageExportDialog.label.withBackground")})}),Ac=F({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:bo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>fM(Wa,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[h("imageExportDialog.label.embedScene"),qo(po,{label:h("imageExportDialog.tooltip.embedScene"),long:!0,children:qo("div",{className:"excalidraw-tooltip-icon",children:Tb})})]})}),hn=F({name:"saveToActiveFile",label:"buttons.save",icon:nn,trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{let n=!!o.fileHandle;try{let{fileHandle:i}=ds(o.fileHandle)?await yE(e,o,r.files,r.getName()):await is(e,o,r.files,r.getName());return{captureUpdate:bo.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?h("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):h("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:bo.EVENTUALLY}}},keyTest:e=>e.key===ui.S&&e[ui.CTRL_OR_CMD]&&!e.shiftKey}),ja=F({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:nn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await is(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:bo.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:h("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:bo.EVENTUALLY}}},keyTest:e=>e.key===ui.S&&e.shiftKey&&e[ui.CTRL_OR_CMD],PanelComponent:({updateData:e})=>qo(z,{type:"button",icon:xb,title:h("buttons.saveAs"),"aria-label":h("buttons.saveAs"),showAriaLabel:pe().editor.isMobile,hidden:!Rn,onClick:()=>e(null),"data-testid":"save-as-button"})}),hi=F({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,r)=>{try{let{elements:n,appState:i,files:a}=await Vm(o,e);return{elements:n,appState:i,files:a,captureUpdate:bo.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:bo.EVENTUALLY}}},keyTest:e=>e[ui.CTRL_OR_CMD]&&e.key===ui.O}),vE=F({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:bo.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>qo("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:qo(tE,{value:e.exportWithDarkMode?wu.DARK:wu.LIGHT,onChange:t=>{o(t===wu.DARK)},title:h("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as bM,DEFAULT_FONT_FAMILY as xM,DEFAULT_TEXT_ALIGN as EM,CODES as TE,KEYS as IE,getLineHeight as yM}from"@haoxin-web/excalidraw-common";import{newElementWith as _c}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as wM,canApplyRoundnessTypeToElement as vM,getDefaultRoundnessTypeForElement as TM,isFrameLikeElement as IM,isArrowElement as CM,isExcalidrawElement as SM,isTextElement as Iu}from"@haoxin-web/excalidraw-element";import{getBoundTextElement as kM,redrawTextBoundingBox as MM}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as Cu}from"@haoxin-web/excalidraw-element";var CE="{}",Su=F({name:"copyStyles",label:"labels.copyStyles",icon:xp,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&wM(i)){let a=kM(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(CE=JSON.stringify(n)),{appState:{...o,toast:{message:h("toast.copyStyles")}},captureUpdate:Cu.EVENTUALLY}},keyTest:e=>e[IE.CTRL_OR_CMD]&&e.altKey&&e.code===TE.C}),ku=F({name:"pasteStyles",label:"labels.pasteStyles",icon:xp,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(CE),i=n[0],a=n[1];if(!SM(i))return{elements:e,captureUpdate:Cu.EVENTUALLY};let l=J(e,o,{includeBoundTextElement:!0}),s=l.map(m=>m.id);return{elements:e.map(m=>{if(s.includes(m.id)){let c=i;if(Iu(m)&&m.containerId&&(c=a),!c)return m;let d=_c(m,{backgroundColor:c?.backgroundColor,strokeWidth:c?.strokeWidth,strokeColor:c?.strokeColor,strokeStyle:c?.strokeStyle,fillStyle:c?.fillStyle,opacity:c?.opacity,roughness:c?.roughness,roundness:c.roundness?vM(c.roundness.type,m)?c.roundness:TM(m):null});if(Iu(d)){let p=c.fontSize||bM,u=c.fontFamily||xM;d=_c(d,{fontSize:p,fontFamily:u,textAlign:c.textAlign||EM,lineHeight:c.lineHeight||yM(u)});let f=null;d.containerId&&(f=l.find(b=>Iu(d)&&b.id===d.containerId)||null),MM(d,f,r.scene)}return d.type==="arrow"&&CM(c)&&(d=_c(d,{startArrowhead:c.startArrowhead,endArrowhead:c.endArrowhead})),IM(m)&&(d=_c(d,{roundness:null,backgroundColor:"transparent"})),d}return m}),captureUpdate:Cu.IMMEDIATELY}},keyTest:e=>e[IE.CTRL_OR_CMD]&&e.altKey&&e.code===TE.V});import{KEYS as LM}from"@haoxin-web/excalidraw-common";import{getNonDeletedElements as PM}from"@haoxin-web/excalidraw-element";import{showSelectedShapeActions as AM}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as Mu}from"@haoxin-web/excalidraw-element";import{jsx as SE}from"react/jsx-runtime";var _M=F({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:Mu.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>SE(z,{type:"button",icon:Is,"aria-label":h("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),DM=F({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:Mu.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>SE(z,{visible:AM(o,PM(e)),type:"button",icon:Eb,"aria-label":h("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),gn=F({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:ub,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:r})=>(o.openDialog?.name==="help"&&r(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:Mu.EVENTUALLY}),keyTest:e=>e.key===LM.QUESTION_MARK});import{getNonDeletedElements as Rc}from"@haoxin-web/excalidraw-element";import{newElementWith as LE}from"@haoxin-web/excalidraw-element";import{isBoundToContainer as RM}from"@haoxin-web/excalidraw-element";import{frameAndChildrenSelectedTogether as NM,getElementsInResizingFrame as BM,getFrameLikeElements as FM,getRootElements as OM,groupByFrameLikes as zM,removeElementsFromFrame as HM,replaceAllElementsInFrame as GM}from"@haoxin-web/excalidraw-element";import{KEYS as Nc,randomId as UM,arrayToMap as Lu,getShortcutKey as PE}from"@haoxin-web/excalidraw-common";import{getSelectedGroupIds as Dc,selectGroup as WM,selectGroupsForSelectedElements as YM,getElementsInGroup as kE,addToGroup as VM,removeFromSelectedGroups as XM,isElementInGroup as AE}from"@haoxin-web/excalidraw-element";import{syncMovedIndices as KM}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as qa}from"@haoxin-web/excalidraw-element";import{jsx as gi}from"react/jsx-runtime";var ZM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&AE(n,t),!0))return!0}return!1},ME=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!ZM(r)&&!NM(r)},Pu=F({name:"group",label:"labels.group",icon:e=>gi(gp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=OM(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:qa.EVENTUALLY};let i=Dc(o);if(i.length===1){let x=i[0],w=new Set(kE(e,x).map(v=>v.id)),E=new Set(n.map(v=>v.id));if(new Set([...Array.from(w),...Array.from(E)]).size===w.size)return{appState:o,elements:e,captureUpdate:qa.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&zM(n).forEach((w,E)=>{HM(w,r.scene.getNonDeletedElementsMap())});let s=UM(),m=Lu(n);a=a.map(x=>m.get(x.id)?LE(x,{groupIds:VM(x.groupIds,s,o.editingGroupId)}):x);let c=kE(a,s),d=c[c.length-1],p=a.lastIndexOf(d),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!AE(x,s)),b=KM([...f,...c,...u],Lu(c));return{appState:{...o,...WM(s,{...o,selectedGroupIds:{}},Rc(a))},elements:b,captureUpdate:qa.IMMEDIATELY}},predicate:(e,o,t,r)=>ME(e,o,r),keyTest:e=>!e.shiftKey&&e[Nc.CTRL_OR_CMD]&&e.key===Nc.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>gi(z,{hidden:!ME(e,o,r),type:"button",icon:gi(gp,{theme:o.theme}),onClick:()=>t(null),title:`${h("labels.group")} \u2014 ${PE("CtrlOrCmd+G")}`,"aria-label":h("labels.group"),visible:we(Rc(e),o)})}),Au=F({name:"ungroup",label:"labels.ungroup",icon:e=>gi(fp,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Dc(o),i=Lu(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:qa.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{RM(p)&&l.push(p.id);let u=XM(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:LE(p,{groupIds:u})});let s=YM(o,Rc(a),o,null),m=r.scene.getSelectedElements(o),c=new Set(m.filter(p=>p.frameId).map(p=>p.frameId));return FM(e).filter(p=>c.has(p.id)).forEach(p=>{p&&(a=GM(a,BM(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:qa.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[Nc.CTRL_OR_CMD]&&e.key===Nc.G.toUpperCase(),predicate:(e,o)=>Dc(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>gi(z,{type:"button",hidden:Dc(o).length===0,icon:gi(fp,{theme:o.theme}),onClick:()=>t(null),title:`${h("labels.ungroup")} \u2014 ${PE("CtrlOrCmd+Shift+G")}`,"aria-label":h("labels.ungroup"),visible:we(Rc(e),o)})});import tL from"clsx";import{CaptureUpdateAction as BE}from"@haoxin-web/excalidraw-element";import{COLOR_CHARCOAL_BLACK as $M,COLOR_VOICE_CALL as jM,COLOR_WHITE as Fc,THEME as qM,UserIdleState as _E}from"@haoxin-web/excalidraw-common";var Bc=(e,o,t,r,n,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+r-i,t),e.quadraticCurveTo(o+r,t,o+r,t+i),e.lineTo(o+r,t+n-i),e.quadraticCurveTo(o+r,t+n,o+r-i,t+n),e.lineTo(o+i,t+n),e.quadraticCurveTo(o,t+n,o,t+n-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function JM(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let r=e.charCodeAt(t);o=(o<<5)-o+r}return o}var fn=(e,o)=>`hsl(${Math.abs(JM(o?.id||e))%37*10}, 100%, 83%)`,DE=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},RE=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,m=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let c=11,d=14,p=l<0||l>r-c||s<0||s>n-d;l=Math.max(l,0),l=Math.min(l,r-c),s=Math.max(s,0),s=Math.min(s,n-d);let u=fn(i,m);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===_E.IDLE||f===_E.AWAY;b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===qM.DARK?"#2f6330":jM,w=m?.isSpeaking;w&&(e.fillStyle=x,e.strokeStyle=x,e.lineWidth=10,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill()),e.fillStyle=Fc,e.strokeStyle=Fc,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let E=o.remotePointerUsernames.get(i)||"";if(!p&&E){e.font="600 12px sans-serif";let y=(w?l+0:l)+c/2,v=(w?s+0:s)+d+2,C=5,S=3,P=e.measureText(E),M=P.actualBoundingBoxDescent+P.actualBoundingBoxAscent,R=Math.max(M,12),L=y-1,k=v-1,N=P.width+2+C*2+2,O=R+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(L,k,N,O,8),e.fillStyle=u,e.fill(),e.strokeStyle=Fc,e.stroke(),w&&(e.beginPath(),e.roundRect(L-2,k-2,N+4,O+4,8),e.strokeStyle=x,e.stroke())):Bc(e,L,k,N,O,8,Fc),e.fillStyle=$M,e.fillText(E,y+C+1,v+S+P.actualBoundingBoxAscent+Math.floor((R-M)/2)+2),w){e.fillStyle=x;let G=8,_=8,B=5;e.fillRect(L+N+_,k+(O/2-G/2),2,G),e.fillRect(L+N+_+B,k+(O/2-G*2/2),2,G*2),e.fillRect(L+N+_+B*2,k+(O/2-G/2),2,G)}}e.restore(),e.closePath()}};import QM from"clsx";import{useState as eL}from"react";import{jsx as NE}from"react/jsx-runtime";var _u=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=DE(t),[a,l]=eL(!1),s=!a&&r,m=s?void 0:{background:e};return NE("div",{className:QM("Avatar",n),style:m,onClick:o,children:s?NE("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as _o,jsxs as Oc}from"react/jsx-runtime";var oL=F({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,o,t)=>!t.socketId||o.userToFollow?.socketId===t.socketId||t.isCurrentUser?{appState:{...o,userToFollow:null},captureUpdate:BE.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:BE.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=o,l=fn(r,n),s=tL({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),m=n.isInCall?n.isSpeaking?Oc("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:h("userList.hint.isSpeaking"),children:[_o("div",{}),_o("div",{}),_o("div",{})]}):n.isMuted?_o("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:h("userList.hint.micMuted"),children:w0}):_o("div",{title:h("userList.hint.inCall"),children:y0}):null;return i?Oc("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[_o(_u,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),_o("div",{className:"UserList__collaborator-name",children:n.username}),Oc("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&_o("div",{className:"UserList__collaborator-status-icon-is-followed",title:h("userList.hint.followStatus"),children:Kn}),m]})]}):Oc("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[_o(_u,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),m&&_o("div",{className:"UserList__collaborator-status-icon",children:m})]})}});import{LIBRARY_DISABLED_TYPES as rL,randomId as nL}from"@haoxin-web/excalidraw-common";import{deepCopyElement as iL}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as Du}from"@haoxin-web/excalidraw-element";var Ru=F({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of rL)if(n.some(a=>a.type===i))return{captureUpdate:Du.EVENTUALLY,appState:{...o,errorMessage:h(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:nL(),status:"unpublished",elements:n.map(iL),created:Date.now()},...i])).then(()=>({captureUpdate:Du.EVENTUALLY,appState:{...o,toast:{message:h("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:Du.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as fi}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as aL}from"@haoxin-web/excalidraw-element";import{updateFrameMembershipOfSelectedElements as lL}from"@haoxin-web/excalidraw-element";import{KEYS as Mr,arrayToMap as sL,getShortcutKey as zc}from"@haoxin-web/excalidraw-common";import{alignElements as cL}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as bi}from"@haoxin-web/excalidraw-element";import{getSelectedElementsByGroup as dL}from"@haoxin-web/excalidraw-element";import{jsx as Ei}from"react/jsx-runtime";var Lt=(e,o)=>{let t=o.scene.getSelectedElements(e);return dL(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(r=>aL(r))},xi=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=cL(n,r,t.scene,o),a=sL(i);return lL(e.map(l=>a.get(l.id)||l),o,t)},mL=F({name:"alignTop",label:"labels.alignTop",icon:cp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"start",axis:"y"}),captureUpdate:bi.IMMEDIATELY}),keyTest:e=>e[Mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mr.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:cp,onClick:()=>t(null),title:`${h("labels.alignTop")} \u2014 ${zc("CtrlOrCmd+Shift+Up")}`,"aria-label":h("labels.alignTop"),visible:we(fi(e),o)})}),pL=F({name:"alignBottom",label:"labels.alignBottom",icon:dp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"end",axis:"y"}),captureUpdate:bi.IMMEDIATELY}),keyTest:e=>e[Mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mr.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:dp,onClick:()=>t(null),title:`${h("labels.alignBottom")} \u2014 ${zc("CtrlOrCmd+Shift+Down")}`,"aria-label":h("labels.alignBottom"),visible:we(fi(e),o)})}),uL=F({name:"alignLeft",label:"labels.alignLeft",icon:mp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"start",axis:"x"}),captureUpdate:bi.IMMEDIATELY}),keyTest:e=>e[Mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mr.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:mp,onClick:()=>t(null),title:`${h("labels.alignLeft")} \u2014 ${zc("CtrlOrCmd+Shift+Left")}`,"aria-label":h("labels.alignLeft"),visible:we(fi(e),o)})}),hL=F({name:"alignRight",label:"labels.alignRight",icon:pp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"end",axis:"x"}),captureUpdate:bi.IMMEDIATELY}),keyTest:e=>e[Mr.CTRL_OR_CMD]&&e.shiftKey&&e.key===Mr.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:pp,onClick:()=>t(null),title:`${h("labels.alignRight")} \u2014 ${zc("CtrlOrCmd+Shift+Right")}`,"aria-label":h("labels.alignRight"),visible:we(fi(e),o)})}),gL=F({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:up,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"center",axis:"y"}),captureUpdate:bi.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:up,onClick:()=>t(null),title:h("labels.centerVertically"),"aria-label":h("labels.centerVertically"),visible:we(fi(e),o)})}),fL=F({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:hp,trackEvent:{category:"element"},predicate:(e,o,t,r)=>Lt(o,r),perform:(e,o,t,r)=>({appState:o,elements:xi(e,o,r,{position:"center",axis:"x"}),captureUpdate:bi.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ei(z,{hidden:!Lt(o,r),type:"button",icon:hp,onClick:()=>t(null),title:h("labels.centerHorizontally"),"aria-label":h("labels.centerHorizontally"),visible:we(fi(e),o)})});import{getNonDeletedElements as FE}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as bL}from"@haoxin-web/excalidraw-element";import{CODES as OE,KEYS as zE,arrayToMap as xL,getShortcutKey as HE}from"@haoxin-web/excalidraw-common";import{updateFrameMembershipOfSelectedElements as EL}from"@haoxin-web/excalidraw-element";import{distributeElements as yL}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as GE}from"@haoxin-web/excalidraw-element";import{getSelectedElementsByGroup as wL}from"@haoxin-web/excalidraw-element";import{jsx as YE}from"react/jsx-runtime";var UE=(e,o)=>{let t=o.scene.getSelectedElements(e);return wL(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(r=>bL(r))},WE=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=yL(n,t.scene.getNonDeletedElementsMap(),r,o),a=xL(i);return EL(e.map(l=>a.get(l.id)||l),o,t)},vL=F({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:WE(e,o,r,{space:"between",axis:"x"}),captureUpdate:GE.IMMEDIATELY}),keyTest:e=>!e[zE.CTRL_OR_CMD]&&e.altKey&&e.code===OE.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>YE(z,{hidden:!UE(o,r),type:"button",icon:kb,onClick:()=>t(null),title:`${h("labels.distributeHorizontally")} \u2014 ${HE("Alt+H")}`,"aria-label":h("labels.distributeHorizontally"),visible:we(FE(e),o)})}),TL=F({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:WE(e,o,r,{space:"between",axis:"y"}),captureUpdate:GE.IMMEDIATELY}),keyTest:e=>!e[zE.CTRL_OR_CMD]&&e.altKey&&e.code===OE.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>YE(z,{hidden:!UE(o,r),type:"button",icon:Mb,onClick:()=>t(null),title:`${h("labels.distributeVertically")} \u2014 ${HE("Alt+V")}`,"aria-label":h("labels.distributeVertically"),visible:we(FE(e),o)})});import{getNonDeletedElements as IL}from"@haoxin-web/excalidraw-element";import{bindOrUnbindLinearElements as CL,isBindingEnabled as SL}from"@haoxin-web/excalidraw-element";import{getCommonBoundingBox as VE}from"@haoxin-web/excalidraw-element";import{newElementWith as kL}from"@haoxin-web/excalidraw-element";import{deepCopyElement as ML}from"@haoxin-web/excalidraw-element";import{resizeMultipleElements as LL}from"@haoxin-web/excalidraw-element";import{isArrowElement as PL,isElbowArrow as AL,isLinearElement as _L}from"@haoxin-web/excalidraw-element";import{updateFrameMembershipOfSelectedElements as XE}from"@haoxin-web/excalidraw-element";import{CODES as KE,KEYS as DL,arrayToMap as RL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as ZE}from"@haoxin-web/excalidraw-element";var Nu=F({name:"flipHorizontal",label:"labels.flipHorizontal",icon:C0,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:XE($E(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:ZE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===KE.H}),Bu=F({name:"flipVertical",label:"labels.flipVertical",icon:I0,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:XE($E(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:ZE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===KE.V&&!e[DL.CTRL_OR_CMD]}),$E=(e,o,t,r,n)=>{let i=J(IL(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=NL(i,o,t,r,n),l=RL(a);return e.map(s=>l.get(s.id)||s)},NL=(e,o,t,r,n)=>{if(e.every(u=>PL(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return kL(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=VE(e);LL(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,ML(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),CL(e.filter(_L),SL(t),[],n.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>AL(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:m,midY:c}=VE(e),[d,p]=[i-m,a-c];return s.forEach(u=>n.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),l.forEach(u=>n.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),e};import{isTextElement as BL}from"@haoxin-web/excalidraw-element";import{getTextFromElements as FL}from"@haoxin-web/excalidraw-element";import{CODES as OL,KEYS as jE,isFirefox as zL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as Ht}from"@haoxin-web/excalidraw-element";var yi=F({name:"copy",label:"labels.copy",icon:Ea,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Lc(n,r.files,t)}catch(i){return{captureUpdate:Ht.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Ht.EVENTUALLY}},keyTest:void 0}),Fu=F({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await bE()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),zL?{captureUpdate:Ht.EVENTUALLY,appState:{...o,errorMessage:h("hints.firefox_clipboard_write")}}:{captureUpdate:Ht.EVENTUALLY,appState:{...o,errorMessage:h("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(gE({types:n}))}catch(i){return console.error(i),{captureUpdate:Ht.EVENTUALLY,appState:{...o,errorMessage:h("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Ht.EVENTUALLY}},keyTest:void 0}),Hc=F({name:"cut",label:"labels.cut",icon:n0,trackEvent:{category:"element"},perform:(e,o,t,r)=>(yi.perform(e,o,t,r),La.perform(e,o,null,r)),keyTest:e=>e[jE.CTRL_OR_CMD]&&e.key===jE.X}),Gc=F({name:"copyAsSvg",label:"labels.copyAsSvg",icon:S0,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:Ht.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=pn(e,o,!0);try{await un("clipboard-svg",n,o,r.files,{...o,exportingFrame:i,name:r.getName()});let a=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:h("toast.copyToClipboardAsSvg",{exportSelection:a.length?h("toast.selection"):h("toast.canvas"),exportColorScheme:o.exportWithDarkMode?h("buttons.darkMode"):h("buttons.lightMode")})}},captureUpdate:Ht.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Ht.EVENTUALLY}}},predicate:e=>Mc&&e.length>0,keywords:["svg","clipboard","copy"]}),Uc=F({name:"copyAsPng",label:"labels.copyAsPng",icon:k0,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:Ht.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=pn(e,o,!0);try{return await un("clipboard",i,o,r.files,{...o,exportingFrame:a,name:r.getName()}),{appState:{...o,toast:{message:h("toast.copyToClipboardAsPng",{exportSelection:n.length?h("toast.selection"):h("toast.canvas"),exportColorScheme:o.exportWithDarkMode?h("buttons.darkMode"):h("buttons.lightMode")})}},captureUpdate:Ht.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Ht.EVENTUALLY}}},predicate:e=>pi&&e.length>0,keyTest:e=>e.code===OL.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Wc=F({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{fo(FL(n))}catch{throw new Error(h("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Ht.EVENTUALLY}},predicate:(e,o,t,r)=>Mc&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(BL),keywords:["text","clipboard","copy"]});import{CODES as HL,KEYS as GL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as UL}from"@haoxin-web/excalidraw-element";var Yc=F({name:"gridMode",icon:_0,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:UL.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[GL.CTRL_OR_CMD]&&e.code===HL.QUOTE});import{CODES as WL,KEYS as YL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as VL}from"@haoxin-web/excalidraw-element";var wi=F({name:"zenMode",label:"buttons.zenMode",icon:L0,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:VL.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[YL.CTRL_OR_CMD]&&e.altKey&&e.code===WL.Z});import{CODES as XL,KEYS as KL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as ZL}from"@haoxin-web/excalidraw-element";var Ou=F({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:M0,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:ZL.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[KL.CTRL_OR_CMD]&&e.altKey&&e.code===XL.S});import{CODES as $L,KEYS as jL}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as qL}from"@haoxin-web/excalidraw-element";var vi=F({name:"stats",label:"stats.fullTitle",icon:T0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:qL.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[jL.CTRL_OR_CMD]&&e.altKey&&e.code===$L.SLASH});import{BOUND_TEXT_PADDING as qE,ROUNDNESS as JE,TEXT_ALIGN as ey,VERTICAL_ALIGN as ty,arrayToMap as oy,getFontString as JL}from"@haoxin-web/excalidraw-common";import{getOriginalContainerHeightFromCache as QL,resetOriginalContainerCache as eP,updateOriginalContainerCache as tP}from"@haoxin-web/excalidraw-element";import{computeBoundTextPosition as oP,computeContainerDimensionForBoundText as QE,getBoundTextElement as ry,redrawTextBoundingBox as ny}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as rP,isArrowElement as nP,isTextBindableContainer as zu,isTextElement as Ja,isUsingAdaptiveRadius as iP}from"@haoxin-web/excalidraw-element";import{measureText as aP}from"@haoxin-web/excalidraw-element";import{syncMovedIndices as iy}from"@haoxin-web/excalidraw-element";import{newElement as lP}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as Hu}from"@haoxin-web/excalidraw-element";var Gu=F({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>rP(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=ry(a,i);if(l){let{width:s,height:m}=aP(l.originalText,JL(l),l.lineHeight),c=QL(a.id);eP(a.id);let{x:d,y:p}=oP(a,l,i);r.scene.mutateElement(l,{containerId:null,width:s,height:m,text:l.originalText,x:d,y:p}),r.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:c||a.height})}}),{elements:e,appState:o,captureUpdate:Hu.IMMEDIATELY}}}),Uu=F({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);if(n.length===2){let i=Ja(n[0])||Ja(n[1]),a;if(zu(n[0])?a=n[0]:zu(n[1])&&(a=n[1]),i&&a&&ry(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;Ja(n[0])&&zu(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),r.scene.mutateElement(i,{containerId:a.id,verticalAlign:ty.MIDDLE,textAlign:ey.CENTER,autoResize:!0,angle:nP(a)?0:a?.angle??0}),r.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return ny(i,a,r.scene),tP(a.id,l),{elements:sP(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:Hu.IMMEDIATELY}}}),sP=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===t.id);r.splice(n,1);let i=r.findIndex(a=>a.id===o.id);return r.splice(i+1,0,t),iy(r,oy([o,t])),r},cP=(e,o,t)=>{let r=e.slice(),n=r.findIndex(a=>a.id===o.id);r.splice(n,1);let i=r.findIndex(a=>a.id===t.id);return r.splice(i,0,o),iy(r,oy([o,t])),r},ay=F({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>Ja(a));return n.length>0&&i},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of n)if(Ja(l)){let s=lP({type:"rectangle",backgroundColor:o.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:o.currentItemFillStyle,strokeColor:o.currentItemStrokeColor,roughness:o.currentItemRoughness,strokeWidth:o.currentItemStrokeWidth,strokeStyle:o.currentItemStrokeStyle,roundness:o.currentItemRoundness==="round"?{type:iP("rectangle")?JE.ADAPTIVE_RADIUS:JE.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-qE,y:l.y-qE,width:QE(l.width,"rectangle"),height:QE(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let m=l.boundElements.filter(d=>d.type==="arrow").map(d=>d.id);i.filter(d=>m.includes(d.id)).forEach(d=>{let p=d.startBinding,u=d.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&r.scene.mutateElement(d,{startBinding:p,endBinding:u})})}r.scene.mutateElement(l,{containerId:s.id,verticalAlign:ty.MIDDLE,boundElements:null,textAlign:ey.CENTER,autoResize:!0}),ny(l,s,r.scene),i=cP([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:Hu.IMMEDIATELY}}});import{isEmbeddableElement as SP}from"@haoxin-web/excalidraw-element";import{KEYS as fy,getShortcutKey as kP}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as MP}from"@haoxin-web/excalidraw-element";import{pointFrom as dy}from"@haoxin-web/excalidraw-math";import dP from"clsx";import{useCallback as ly,useEffect as sy,useLayoutEffect as mP,useRef as pP,useState as uP}from"react";import{EVENT as Wu,HYPERLINK_TOOLTIP_DELAY as hP,KEYS as Vc}from"@haoxin-web/excalidraw-common";import{getElementAbsoluteCoords as Zu}from"@haoxin-web/excalidraw-element";import{hitElementBoundingBox as gP}from"@haoxin-web/excalidraw-element";import{isElementLink as fP}from"@haoxin-web/excalidraw-element";import{getEmbedLink as bP,embeddableURLValidator as xP}from"@haoxin-web/excalidraw-element";import{sceneCoordsToViewportCoords as my,viewportCoordsToSceneCoords as EP,wrapEvent as yP,isLocalLink as wP,normalizeLink as Yu}from"@haoxin-web/excalidraw-common";import{isEmbeddableElement as Vu}from"@haoxin-web/excalidraw-element";import{jsx as Ti,jsxs as cy}from"react/jsx-runtime";var $u=380,vP=42,Xu=5,py=85,TP=500,Ku=!1,Xc=new Map,uy=({element:e,scene:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=Mo(),s=Lo(),m=pe(),c=e.link||"",[d,p]=uP(c),u=pP(null),f=l.showHyperlinkPopup==="editor",b=ly(()=>{if(!u.current)return;let v=Yu(u.current.value)||null;if(!e.link&&v&&ae("hyperlink","create"),Vu(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!xP(v,s.validateEmbeddable))v&&n({message:h("toast.unableToEmbed"),closable:!0}),e.link&&Xc.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:C,height:S}=e,P=bP(v);P?.error instanceof URIError&&n({message:h("toast.unrecognizedLinkFormat"),closable:!0});let M=P?P.intrinsicSize.w/P.intrinsicSize.h:1,R=Xc.get(e.id)!==e.link;o.mutateElement(e,{...R?{width:P?.type==="video"?C>S?C:S*M:C,height:P?.type==="video"&&C>S?C/M:S}:{},link:v}),i(e,!0),Xc.has(e.id)&&Xc.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,n,s.validateEmbeddable,l.activeEmbeddable,t,i]);mP(()=>()=>{b()},[b]),sy(()=>{f&&u?.current&&!(m.viewport.isMobile||m.isTouchScreen)&&u.current.select()},[f,m.viewport.isMobile,m.isTouchScreen]),sy(()=>{let v=null,C=S=>{if(f)return;v&&clearTimeout(v),CP(e,a,l,dy(S.clientX,S.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},TP))};return window.addEventListener(Wu.POINTER_MOVE,C,!1),()=>{window.removeEventListener(Wu.POINTER_MOVE,C,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=ly(()=>{ae("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),w=()=>{ae("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y}=hy(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:cy("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${E}px`,width:$u,padding:Xu},children:[f?Ti("input",{className:dP("excalidraw-hyperlinkContainer-input"),placeholder:h("labels.link.hint"),ref:u,value:d,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[Vc.CTRL_OR_CMD]&&v.key===Vc.K&&v.preventDefault(),(v.key===Vc.ENTER||v.key===Vc.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?Ti("a",{href:Yu(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:wP(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&r){let C=yP(Wu.EXCALIDRAW_LINK,v.nativeEvent);r({...e,link:Yu(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Ti("div",{className:"excalidraw-hyperlinkContainer-link",children:h("labels.link.empty")}),cy("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&Ti(z,{type:"button",title:h("buttons.edit"),"aria-label":h("buttons.edit"),label:h("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:Nt}),Ti(z,{type:"button",title:h("labels.linkToElement"),"aria-label":h("labels.linkToElement"),label:h("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Ws}),c&&!Vu(e)&&Ti(z,{type:"button",title:h("buttons.remove"),"aria-label":h("buttons.remove"),label:h("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:Bt})]})]})},hy=(e,o,t)=>{let[r,n]=Zu(e,t),{x:i,y:a}=my({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-$u/2,s=a-o.offsetTop-py;return{x:l,y:s}},ju=(e,o)=>{let t=J(e,o);return Vu(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Qa=null,gy=(e,o,t)=>{Qa&&clearTimeout(Qa),Qa=window.setTimeout(()=>IP(e,o,t),hP)},IP=(e,o,t)=>{if(!e.link)return;let r=si();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=fP(e.link)?h("labels.link.goToElement"):e.link;let[n,i,a,l]=Zu(e,t),[s,m,c,d]=A1([n,i,a,l],e.angle,o),p=my({sceneX:s,sceneY:m},o);su(r,{left:p.x,top:p.y,width:c,height:d},"top"),ae("hyperlink","tooltip","link-icon"),Ku=!0},qu=()=>{Qa&&clearTimeout(Qa),Ku&&(Ku=!1,si().classList.remove("excalidraw-tooltip--visible"))},CP=(e,o,t,[r,n])=>{let{x:i,y:a}=EP({clientX:r,clientY:n},t),l=15/t.zoom.value;if(gP(dy(i,a),e,o))return!1;let[s,m,c]=Zu(e,o);if(i>=s&&i<=c&&a>=m-py&&a<=m)return!1;let{x:d,y:p}=hy(e,t,o);return!(r>=d-l&&r<=d+$u+Xu*2+l&&n>=p-l&&n<=p+l+Xu*2+vP)};import{jsx as LP}from"react/jsx-runtime";var el=F({name:"hyperlink",label:(e,o)=>ju(e,o),icon:va,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:MP.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[fy.CTRL_OR_CMD]&&e.key===fy.K,predicate:(e,o)=>J(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=J(e,o);return LP(z,{type:"button",icon:va,"aria-label":h(ju(e,o)),title:`${SP(e[0])?h("labels.link.labelEmbed"):h("labels.link.label")} - ${kP("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});import{KEYS as by,arrayToMap as Qu,randomId as PP}from"@haoxin-web/excalidraw-common";import{elementsAreInSameGroup as AP,newElementWith as xy,selectGroupsFromGivenElements as Ey}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as yy}from"@haoxin-web/excalidraw-element";var Ju=e=>e.every(o=>!o.locked),tl=F({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return Ju(r)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=J(o,e);return Ju(t)?Hn:on},trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return n.length>0&&!n.some(i=>i.locked&&i.frameId)},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!n.length)return!1;let i=Ju(n),a=Qu(n),l=n.length>1&&AP(n),m=n.length===1||l?null:PP(),c={...o.lockedMultiSelections};if(i)c={...o.lockedMultiSelections,...m?{[m]:!0}:{}};else if(l){let w=n[0].groupIds.at(-1);delete c[w]}let d=e.map(w=>{if(!a.has(w.id))return w;let E=w.groupIds;return i?m&&(E=[...E,m]):E=E.filter(y=>!o.lockedMultiSelections[y]),xy(w,{locked:i,groupIds:E.length!==w.groupIds.length?E:w.groupIds})}),p=Qu(d),u=i?{}:Object.fromEntries(n.map(w=>[w.id,!0])),f=n.map(w=>p.get(w.id)||w),b=i?{}:Ey(f,o),x=i?m||(l?n[0].groupIds.at(-1):n[0].id):null;return{elements:d,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:c,activeLockedId:x},captureUpdate:yy.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===by.L&&e[by.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),wy=F({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:on,predicate:(e,o)=>J(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),r=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return xy(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),n=Qu(r),i=t.map(a=>n.get(a.id)||a);return{elements:r,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:Ey(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:yy.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as K_,isLinearElement as Z_,isLineElement as Ui}from"@haoxin-web/excalidraw-element";import{arrayToMap as $_,invariant as og}from"@haoxin-web/excalidraw-common";import{toggleLinePolygonState as j_,CaptureUpdateAction as T2}from"@haoxin-web/excalidraw-element";import Zw from"clsx";import U7 from"fuzzy";import{useEffect as fd,useRef as W7,useState as gd}from"react";import{DEFAULT_SIDEBAR as Xw,EVENT as xd,KEYS as Eo,capitalizeString as Y7,getShortcutKey as V7,isWritableElement as X7}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as uA}from"@haoxin-web/excalidraw-element";import{useEffect as nl,useMemo as vy,useRef as rh,useState as _P}from"react";import{getLinearElementSubType as Si,updateElbowArrowPoints as DP}from"@haoxin-web/excalidraw-element";import{pointFrom as Zc,pointRotateRads as RP}from"@haoxin-web/excalidraw-math";import{hasBoundTextElement as NP,isArrowBoundToElement as BP,isArrowElement as FP,isElbowArrow as OP,isLinearElement as lh,isUsingAdaptiveRadius as zP}from"@haoxin-web/excalidraw-element";import{getCommonBoundingBox as HP,getElementAbsoluteCoords as GP}from"@haoxin-web/excalidraw-element";import{getBoundTextElement as ky,getBoundTextMaxHeight as UP,getBoundTextMaxWidth as WP,redrawTextBoundingBox as YP}from"@haoxin-web/excalidraw-element";import{wrapText as VP}from"@haoxin-web/excalidraw-element";import{assertNever as XP,CLASSES as KP,getFontString as eh,isProdEnv as ZP,mapFind as $P,reduceToCommonValue as jP,updateActiveTool as Ty}from"@haoxin-web/excalidraw-common";import{measureText as Iy}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as qP}from"@haoxin-web/excalidraw-element";import{newArrowElement as th,newElement as JP,newLinearElement as QP}from"@haoxin-web/excalidraw-element";import{ShapeCache as eA}from"@haoxin-web/excalidraw-element";import{updateBindings as tA}from"@haoxin-web/excalidraw-element";import{jsx as ah}from"react/jsx-runtime";var oA=8,rA=10,ol=["rectangle","diamond","ellipse","triangle","pentagon"],rl=["line","sharpArrow","curvedArrow","elbowArrow"],nA=new Set(ol),iA=new Set(rl),ki=e=>nA.has(e),jc=e=>e==="arrow"||iA.has(e),xo=he(null),il=new Map,al=new Map,aA=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=rh(null);return nl(()=>{if(o.length===0){e.updateEditorAtom(xo,null);return}let r=Mi(o);r&&!t.current?t.current=r:(t.current&&!r||t.current&&r!==t.current)&&(e.updateEditorAtom(xo,null),t.current=null)},[o,e]),nl(()=>()=>{il.clear(),al.clear()},[]),ah(lA,{app:e,elements:o})},lA=({app:e,elements:o})=>{let t=Mi(o),r=vy(()=>t==="generic"?Ly(o):[],[t,o]),n=vy(()=>t==="linear"?ih(o):[],[t,o]),i=t==="generic"?r.every(d=>d.type===r[0].type):t==="linear"?n.every(d=>Si(d)===Si(n[0])):!1,[a,l]=_P({x:0,y:0}),s=rh(""),m=rh(null);nl(()=>{let d=[...r,...n].sort((x,w)=>x.id.localeCompare(w.id)),p=`
8
+ ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${d.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(d.length===1){let[x,,,w,E,y]=GP(d[0],e.scene.getNonDeletedElementsMap());u=RP(Zc(x,w),Zc(E,y),d[0].angle)}else{let{minX:x,maxY:w}=HP(d);u=Zc(x,w)}let{x:f,y:b}=Ay({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[r,n,e.scene,e.state]),nl(()=>{for(let d of n){let p=nh(d.id,pA(d));al.has(p)||al.set(p,d)}},[n]),nl(()=>{for(let d of r)if(!il.has(d.id)){let p=ky(d,e.scene.getNonDeletedElementsMap());p&&il.set(d.id,{fontSize:p.fontSize})}},[r,e.scene]);let c=t==="linear"?[["line",co],["sharpArrow",zs],["curvedArrow",Gs],["elbowArrow",Hs]]:t==="generic"?[["rectangle",ko],["diamond",ur],["ellipse",hr],["triangle",gr],["pentagon",fr]]:[];return ah("div",{ref:m,tabIndex:-1,style:{position:"absolute",top:`${a.y+(rA+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-oA}px`,zIndex:2},className:KP.CONVERT_ELEMENT_TYPE_POPUP,children:c.map(([d,p])=>{let u=i&&(t==="generic"&&r[0].type===d||t==="linear"&&Si(n[0])===d);return ah(z,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:d,keyBindingLabel:"","aria-label":d,"data-testid":`toolbar-${d}`,onChange:()=>{e.state.activeTool.type!==d&&ae("convertElementType",d,"ui"),sh(e,{conversionType:t,nextType:d}),m.current?.focus()}},`${o[0].id}${o[0].version}_${d}`)})})},sA=(e,o,t)=>{let r=WP(e,o),n=UP(e,o),i=VP(o.text,eh(o),r),a=Iy(i,eh(o),o.lineHeight),l=o.fontSize;for(;(a.width>r||a.height>n)&&l>0;){l-=1;let s={...o,fontSize:l};a=Iy(o.text,eh(s),o.lineHeight)}qc(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),YP(o,e,t)},sh=(e,{conversionType:o,nextType:t,direction:r="right"})=>{if(!o)return!1;let n=e.scene.getSelectedElements(e.state),i=n.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=r==="right"?1:-1;if(o==="generic"){let l=Ly(n),m=l.every(c=>c.type===l[0].type)?ol.indexOf(l[0].type):-1;if(t=t??ol[(m+ol.length+a)%ol.length],t&&ki(t)){let c={};for(let p of l){let u=Sy(p,t,e);c[u.id]=u}let d=[];for(let p of e.scene.getElementsIncludingDeleted())c[p.id]?d.push(c[p.id]):d.push(p);e.scene.replaceAllElements(d);for(let p of Object.values(c)){let u=ky(p,e.scene.getNonDeletedElementsMap());u&&(il.get(p.id)&&qc(u,e.scene.getNonDeletedElementsMap(),{fontSize:il.get(p.id)?.fontSize??u.fontSize}),sA(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:Ty(p,{type:"selection"})}))}}if(o==="linear"){let l=ih(n);if(!t){let m=jP(l,Si),c=m?rl.indexOf(m):-1;t=rl[(c+rl.length+a)%rl.length]}if(jc(t)){let m=[],c=e.scene.getElementsMapIncludingDeleted();for(let d of l){let p=al.get(nh(d.id,t));if(p&&Si(p)===t)c.set(p.id,p),m.push(p);else{let u=Sy(d,t,e);c.set(u.id,u),m.push(u)}}e.scene.replaceAllElements(c);for(let d of m)if(lh(d))if(OP(d)){let p=cA(d);if(p.length<2)continue;let u=[];for(let b=1;b<p.length-2;b++)u.push({start:p[b],end:p[b+1],index:b+1});let f=DP(d,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});qc(d,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=$P(["line","sharpArrow","curvedArrow"],u=>al.get(nh(d.id,u)));if(p){let u=p.points;e.scene.mutateElement(d,{points:u})}}}let s=ih(e.scene.getSelectedElements(e.state));e.setState(m=>({selectedElementIds:i,selectedLinearElement:s.length===1?new qP(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:Ty(m,{type:"selection"})}))}return!0},Mi=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(ki(t.type))return"generic";My(t)&&(o=!0)}return o?"linear":null},My=e=>lh(e)&&(!FP(e)||!BP(e)&&!NP(e)),nh=(e,o)=>`${e}:${o}`,Ly=e=>e.filter(o=>ki(o.type)),ih=e=>e.filter(o=>My(o)),Kc=20,Ii=(e,o)=>e[0]===o[0],oh=(e,o)=>e[1]===o[1],Cy=(e,o)=>Ii(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),cA=e=>{let o=[e.points[0]],t=dA(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<Kc?l[0]=a[0]:Math.abs(l[1]-a[1])<Kc&&(l[1]=a[1]),Ii(a,l)||oh(a,l)||o.push(Zc(a[0],l[1])),o.push(l)}let r=[o[0]];for(let i=1;i<o.length-1;++i)Ii(o[i-1],o[i])&&Ii(o[i],o[i+1])||oh(o[i-1],o[i])&&oh(o[i],o[i+1])||r.push(o[i]);r.push(o[o.length-1]);let n=[r[0]];for(let i=1;i<r.length-1;++i){let a=n[n.length-1],l=r[i],s=r[i+1],m=Ii(a,l),c=Ii(l,s);if(m!==c){let d=Cy(a,l),p=Cy(l,s);if(d<Kc||p<Kc){if(p<d)m?s[0]=a[0]:s[1]=a[1];else if(c)for(let u=n.length-1;u>=0&&n[u][0]===a[0];--u)n[u][0]=l[0];else for(let u=n.length-1;u>=0&&n[u][1]===a[1];--u)n[u][1]=l[1];continue}}n.push(l)}return n.push(r[r.length-1]),n},dA=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[r,n]=o[o.length-1],[i,a]=e[t];(r!==i||n!==a)&&o.push(e[t])}return o},Sy=(e,o,t)=>{if(!mA(e.type,o)){if(!ZP())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(eA.delete(e),ki(o)){let r=Ci(JP({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:zP(o)?$c.ADAPTIVE_RADIUS:$c.PROPORTIONAL_RADIUS}:e.roundness}));return tA(r,t.scene),r}if(jc(o))switch(o){case"line":return Ci(QP({...e,type:"line"}));case"sharpArrow":return Ci(th({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Ci(th({...e,type:"arrow",elbowed:!1,roundness:{type:$c.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Ci(th({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return XP(o,`unhandled conversion type: ${o}`),e},mA=(e,o)=>!!(ki(e)&&ki(o)||jc(e)&&jc(o)),pA=e=>lh(e)?Si(e):e.type,Py=aA;var _y=F({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,r){return Ve.set(xo,{type:"panel"}),{captureUpdate:uA.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>Mi(e)!==null});import{canCreateLinkFromElements as ch,defaultGetElementLinkFromSelection as hA,getLinkIdAndTypeFromSelection as gA}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as ll}from"@haoxin-web/excalidraw-element";var Jc=F({name:"copyElementLink",label:"labels.copyElementLink",icon:Yn,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=J(e,o);try{if(window.location){let i=gA(n,o);return i?(await fo(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):hA(i.id,i.type)),{appState:{toast:{message:h("toast.elementLinkCopied"),closable:!0}},captureUpdate:ll.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:ll.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:ll.EVENTUALLY}},predicate:(e,o)=>ch(J(e,o))}),Dy=F({name:"linkToElement",label:"labels.linkToElement",icon:Ws,perform:(e,o,t,r)=>{let n=J(e,o);return n.length!==1||!ch(n)?{elements:e,appState:o,app:r,captureUpdate:ll.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:J(e,o)[0].id}},captureUpdate:ll.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=J(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&ch(n)},trackEvent:!1});import{isDarwin as Ry,getShortcutKey as ne}from"@haoxin-web/excalidraw-common";var fA={toggleTheme:[ne("Shift+Alt+D")],saveScene:[ne("CtrlOrCmd+S")],loadScene:[ne("CtrlOrCmd+O")],clearCanvas:[ne("CtrlOrCmd+Delete")],imageExport:[ne("CtrlOrCmd+Shift+E")],commandPalette:[ne("CtrlOrCmd+/"),ne("CtrlOrCmd+Shift+P")],cut:[ne("CtrlOrCmd+X")],copy:[ne("CtrlOrCmd+C")],paste:[ne("CtrlOrCmd+V")],copyStyles:[ne("CtrlOrCmd+Alt+C")],pasteStyles:[ne("CtrlOrCmd+Alt+V")],selectAll:[ne("CtrlOrCmd+A")],deleteSelectedElements:[ne("Delete")],duplicateSelection:[ne("CtrlOrCmd+D"),ne(`Alt+${h("helpDialog.drag")}`)],sendBackward:[ne("CtrlOrCmd+[")],bringForward:[ne("CtrlOrCmd+]")],sendToBack:[Ry?ne("CtrlOrCmd+Alt+["):ne("CtrlOrCmd+Shift+[")],bringToFront:[Ry?ne("CtrlOrCmd+Alt+]"):ne("CtrlOrCmd+Shift+]")],copyAsPng:[ne("Shift+Alt+C")],group:[ne("CtrlOrCmd+G")],ungroup:[ne("CtrlOrCmd+Shift+G")],gridMode:[ne("CtrlOrCmd+'")],zenMode:[ne("Alt+Z")],objectsSnapMode:[ne("Alt+S")],stats:[ne("Alt+/")],addToLibrary:[],flipHorizontal:[ne("Shift+H")],flipVertical:[ne("Shift+V")],viewMode:[ne("Alt+R")],hyperlink:[ne("CtrlOrCmd+K")],toggleElementLock:[ne("CtrlOrCmd+Shift+L")],resetZoom:[ne("CtrlOrCmd+0")],zoomOut:[ne("CtrlOrCmd+-")],zoomIn:[ne("CtrlOrCmd++")],zoomToFitSelection:[ne("Shift+3")],zoomToFit:[ne("Shift+1")],zoomToFitSelectionInViewport:[ne("Shift+2")],toggleEraserTool:[ne("E")],toggleHandTool:[ne("H")],setFrameAsActiveTool:[ne("F")],saveFileToDisk:[ne("CtrlOrCmd+S")],saveToActiveFile:[ne("CtrlOrCmd+S")],toggleShortcuts:[ne("?")],searchMenu:[ne("CtrlOrCmd+F")],wrapSelectionInFrame:[]},He=(e,o=0)=>{let t=fA[e];return t&&t.length>0?t[o]||t[0]:""};var bA="\\u0300-\\u036f",xA="\\ufe20-\\ufe2f",EA="\\u20d0-\\u20ff",yA=bA+xA+EA,wA=`[${yA}]`,vA=RegExp(wA,"g"),TA=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,IA={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"E",\u00E6:"e",\u00DE:"T",\u00FE:"t",\u00DF:"s",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"I",\u0133:"i",\u0152:"E",\u0153:"e",\u0149:"n",\u017F:"s"},dh=e=>e.replace(TA,o=>IA[o]||o).replace(vA,"");import u7 from"clsx";import{useEffect as h7,useState as g7}from"react";import{KEYS as f7,queryFocusableElements as _w}from"@haoxin-web/excalidraw-common";import{useCallback as CA,useState as SA}from"react";var Ny=()=>{let[e,o]=SA(null),t=CA(r=>o(r),[]);return[e,t]};import{useState as Sw,useCallback as Sh,useMemo as kw,useEffect as Tw,memo as Mw,useRef as o7}from"react";import{LIBRARY_DISABLED_TYPES as r7,randomId as n7,isShallowEqual as i7}from"@haoxin-web/excalidraw-common";import{useEffect as zy,useRef as Hy}from"react";import{URL_HASH_KEYS as uh,URL_QUERY_KEYS as hh,APP_NAME as Gy,EVENT as ed,DEFAULT_SIDEBAR as AA,LIBRARY_SIDEBAR_TAB as _A,arrayToMap as gh,cloneJSON as DA,preventUnload as RA,promiseTry as Uy,resolvablePromise as NA,toValidURL as BA,Queue as FA,Emitter as OA}from"@haoxin-web/excalidraw-common";import{hashElementsVersion as zA,hashString as HA}from"@haoxin-web/excalidraw-element";import{getCommonBoundingBox as ph}from"@haoxin-web/excalidraw-element";import{MIME_TYPES as bn}from"@haoxin-web/excalidraw-common";var Lr=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=Bn({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),{exportBackground:m,viewBackgroundColor:c}=s;return cs(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:m,exportPadding:i,viewBackgroundColor:c,exportingFrame:a},(d,p)=>{let u=document.createElement("canvas");if(r){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(d,p),x=r<b?r/b:o?.exportScale??1;return u.width=d*x,u.height=p*x,{canvas:u,scale:x}}let f=n?.(d,p)||{width:d,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},By=async e=>{let{mimeType:o=bn.png,quality:t}=e;o===bn.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${bn.png}" mimeType`),o==="image/jpg"&&(o=bn.jpg),o===bn.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${bn.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await Lr(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((n,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===bn.png&&e.appState?.exportEmbedScene&&(a=await H1({blob:a,metadata:ua(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},Li=async({elements:e,appState:o=mr(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:m}=Bn({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),c={...m,exportPadding:r};return Nn(s,c,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},kA=async e=>{if(e.type==="svg"){let o=await Li(e);await fo(o.outerHTML)}else if(e.type==="png")await Pc(By(e));else if(e.type==="json")await Lc(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as MA,useState as LA}from"react";import{COLOR_PALETTE as PA}from"@haoxin-web/excalidraw-common";var mh=he(new Map),Fy=async e=>await Li({elements:e,appState:{exportBackground:!1,viewBackgroundColor:PA.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),Oy=(e,o,t)=>{let[r,n]=LA();return MA(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await Fy(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await Fy(o);n(i)})()},[e,o,t,n]),r},Qc=()=>{let[e]=ce(mh);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var GA=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],Yy=new OA,xn=he({status:"loaded",isInitialized:!1,libraryItems:[]}),sl=e=>DA(e),UA=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((r,n)=>r.id===o.elements[n].id&&r.versionNonce===o.elements[n].versionNonce)),Vy=(e,o)=>{let t=[];for(let r of o)UA(e,r)&&t.push(r);return[...t,...e]},Xy=(e,o)=>{let t=gh(o),r={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||r.deletedItems.set(i.id,i);let n=gh(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},fh=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",sl(this.currLibraryItems));I(this,"app");I(this,"updateQueue",[]);I(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);I(this,"notifyListeners",()=>{if(this.updateQueue.length>0)Ve.set(xn,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{Ve.set(xn,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=sl(this.currLibraryItems);let t=sl(this.currLibraryItems);this.app.props.onLibraryChange?.(t),Yy.trigger(Xy(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],Ve.set(mh,new Map)});I(this,"resetLibrary",()=>this.setLibrary([]));I(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(sl(t))}catch{return o(this.currLibraryItems)}}));I(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:AA.name,tab:_A}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),m;s instanceof Blob?m=await jm(s,i):m=fa(s,i),!t||window.confirm(h("alerts.confirmAddLibrary",{numShapes:m.length}))?(t&&this.app.focusContainer(),a(r?Vy(this.currLibraryItems,m):m)):l(new Dn)}catch(s){l(s)}}))));I(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=sl(await o),r(this.currLibraryItems)}catch(i){n(i)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},Ky=fh,rd=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:w}=ph(x.elements);return Math.max(b,w)},0),i=u=>{let f=0,b=0,x=0;for(let w of e){if(f%t===0&&(b=0),b===u){let{width:E}=ph(w.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,m=0,c=0,d=0,p=0;for(let u of e){c&&c%t===0&&(l+=s+50,a=0,d=0,p++),d===0&&(s=n(p)),m=i(d);let{minX:f,minY:b,width:x,height:w}=ph(u.elements),E=(m-x)/2,y=(s-w)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+y-b}))),a+=m+50,c++,d++}return r},WA=(e,o=GA)=>{if(typeof o=="function"?o(e):o.some(t=>{let r=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:n,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${r.hostname}$`).test(n)&&new RegExp(`^${r.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},bh=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(uh.addLibrary)||new URLSearchParams(window.location.search).get(hh.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},Pr=class Pr{constructor(o){I(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,r=!0){let n=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(fa(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?Pr.queue.push(n):n()}getLibraryItems(o){return Pr.getLibraryItems(this.adapter,o,!1)}};I(Pr,"queue",new FA),I(Pr,"run",async(o,t)=>{let r=new Pr(o);return Pr.queue.push(()=>t(r))});var Pi=Pr,cl=0,td=0,od=e=>HA(e.map(o=>`${o.id}:${zA(o.elements)}`).sort().join()),Wy=async(e,o)=>{try{return td++,await Pi.run(e,async t=>{let r=gh(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)r.delete(l);let n=[];for(let[l,s]of o.addedItems)r.has(l)?r.set(l,s):n.push(s);let i=n.concat(Array.from(r.values())),a=od(i);return a!==cl&&await e.save({libraryItems:i}),cl=a,i})}finally{td--}},YA=e=>{let{excalidrawAPI:o}=e,t=Hy(e);t.current=e;let r=Hy(!1);zy(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let m=new Promise(async(d,p)=>{try{l=decodeURIComponent(l),l=BA(l),WA(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();d(f)}catch(u){p(u)}}),c=s!==o.id;await(c&&document.hidden?new Promise(d=>{window.addEventListener("focus",()=>d(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:m,prompt:c,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(d){throw o.updateScene({appState:{errorMessage:d.message}}),d}finally{if(window.location.hash.includes(uh.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(uh.addLibrary),window.history.replaceState({},Gy,`#${d.toString()}`)}else if(window.location.search.includes(hh.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(hh.addLibrary),window.history.replaceState({},Gy,`?${d.toString()}`)}}},i=l=>{l.preventDefault();let s=bh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=bh();if(a&&n(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,m=NA();s?m.resolve(Uy(s.load).then(async c=>{let d=null;try{if(!c)return Pi.getLibraryItems(l,"load");d=fa(c.libraryItems||[],"published");let p=await Wy(l,Xy([],d));try{await s.clear()}catch(u){console.error(`couldn't delete legacy library data: ${u.message}`)}return p}catch(p){return console.error(`couldn't migrate legacy library data: ${p.message}`),d}}).catch(c=>(console.error(`error during library migration: ${c.message}`),Pi.getLibraryItems(l,"load")))):m.resolve(Uy(Pi.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:m.then(c=>{let d=c||[];return cl=od(d),d}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(ed.HASHCHANGE,i),()=>{window.removeEventListener(ed.HASHCHANGE,i)}},[o]),zy(()=>{let n=Yy.on(async(a,l)=>{let s=r.current,m="adapter"in t.current&&t.current.adapter||null;try{m&&cl!==od(l)&&await Wy(m,a)}catch(c){console.error(`couldn't persist library update: ${c.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:h("errors.saveLibraryError")}})}}),i=a=>{td&&RA(a)};return window.addEventListener(ed.BEFORE_UNLOAD,i),()=>{window.removeEventListener(ed.BEFORE_UNLOAD,i),n(),cl=0,td=0}},[])};import ZA from"clsx";import{VERSIONS as VA}from"@haoxin-web/excalidraw-common";import{jsx as KA}from"react/jsx-runtime";var XA=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return KA("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${VA.excalidrawLibrary}`,target:"_excalidraw_libraries",children:h("labels.libraries")})},Zy=XA;import{jsx as $A,jsxs as jA}from"react/jsx-runtime";var nd=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>jA("div",{className:ZA("library-menu-control-buttons",i),style:r,children:[$A(Zy,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as Di,useEffect as Z8,useMemo as ww,useRef as $8,useState as j8}from"react";import{MIME_TYPES as q8,arrayToMap as J8}from"@haoxin-web/excalidraw-common";import{duplicateElements as Q8}from"@haoxin-web/excalidraw-element";import qA from"lodash.throttle";import{useEffect as JA}from"react";var QA=he(0),$y=e=>{let[o,t]=ce(QA);return JA(()=>{let{current:r}=e;if(!r)return;let n=qA(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import A8 from"clsx";import{useCallback as _8,useState as wh}from"react";import{muteFSAbortError as D8}from"@haoxin-web/excalidraw-common";import{flushSync as jy}from"react-dom";import e8 from"clsx";import{jsx as id,jsxs as o8}from"react/jsx-runtime";var t8=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return o8("button",{className:e8("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&id("div",{style:a?{visibility:"hidden"}:{},children:r}),id("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&id("div",{style:{position:"absolute",inset:0},children:id(it,{})})]})},Jo=t8;import{jsx as qy,jsxs as Jy}from"react/jsx-runtime";var r8=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=h("buttons.confirm"),cancelText:i=h("buttons.cancel"),className:a="",...l}=e,s=me(),m=pr(Ai),{container:c}=Xe();return Jy(Ge,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,Jy("div",{className:"confirm-dialog-buttons",children:[qy(Jo,{label:i,onClick:()=>{s({openMenu:null}),m(!1),jy(()=>{t()}),c?.focus()}}),qy(Jo,{label:n,onClick:()=>{s({openMenu:null}),m(!1),jy(()=>{o()}),c?.focus()},actionType:"danger"})]})]})},ad=r8;import sd from"open-color";import{useCallback as d8,useEffect as yh,useRef as Qy,useState as xh}from"react";import{EDITOR_LS_KEYS as Eh,EXPORT_DATA_TYPES as m8,MIME_TYPES as ew,VERSIONS as p8,chunk as u8,getExportSource as h8}from"@haoxin-web/excalidraw-common";var jt=class{static has(o){try{return!!window.localStorage.getItem(o)}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),!1}}static get(o){try{let t=window.localStorage.getItem(o);return t?JSON.parse(t):null}catch(t){return console.warn(`localStorage.getItem error: ${t.message}`),null}}};I(jt,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),I(jt,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import ld from"react";var n8=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,i8=/{{([\w-]+)}}/,a8=/<([\w-]+)>/,l8=/<\/([\w-]+)>/,s8=(e,o)=>{let t=[{name:"",children:[]}];return e.split(n8).filter(Boolean).forEach(r=>{let n=r.match(a8),i=r.match(l8),a=r.match(i8);if(n!==null){let l=n[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),m=ld.createElement(ld.Fragment,{},...s.children),c=o[s.name];typeof c=="function"&&t[t.length-1].children.push(c(m))}else console.warn(`Trans: unexpected end tag ${r} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(r)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},c8=({i18nKey:e,children:o,...t})=>{let{t:r}=Ye();return ld.createElement(ld.Fragment,{},...s8(r(e),t))},yt=c8;import{jsx as de,jsxs as ct}from"react/jsx-runtime";var g8=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=u8(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(r*2)-r*2,a.height=i.length*128+(i.length+1)*(r*2)-r*2;let l=a.getContext("2d");l.fillStyle=sd.white,l.fillRect(0,0,a.width,a.height);for(let[s,m]of e.entries()){let c=await Lr({elements:m.elements,files:null,maxWidthOrHeight:128}),{width:d,height:p}=c,u=Math.floor(s/6)*(128+r*2),f=s%6*(128+r*2);l.drawImage(c,f+(128-d)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=sd.gray[4],l.strokeRect(f+r/2,u+r/2,128+r,128+r)}return await ps(new File([await Go(a)],"preview",{type:ew.png}),{outputType:ew.jpg,maxWidthOrHeight:5e3})},f8=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=Qy(null),a=Qy(null);return yh(()=>{let l=i.current;l&&(async()=>{let s=await Li({elements:e.elements,appState:{...o,viewBackgroundColor:sd.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),ct("div",{className:"single-library-item",children:[e.status==="published"&&de("span",{className:"single-library-item-status",children:h("labels.statusPublished")}),de("div",{ref:i,className:"single-library-item__svg"}),de(z,{"aria-label":h("buttons.remove"),type:"button",icon:Vt,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:h("buttons.remove")}),ct("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[ct("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[ct("div",{style:{padding:"0.5em 0"},children:[de("span",{style:{fontWeight:500,color:sd.gray[6]},children:h("publishDialog.itemName")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),de("span",{className:"error",children:e.error})]})]})},b8=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=xh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[m,c]=xh(!1);yh(()=>{let y=jt.get(Eh.PUBLISH_LIBRARY);y&&s(y)},[]);let[d,p]=xh(o.slice());yh(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},f=async y=>{y.preventDefault(),c(!0);let v=[],C=!1;if(d.forEach(k=>{let N="";k.name||(N=h("publishDialog.errors.required"),C=!0),v.push({...k,error:N})}),C){p(v),c(!1);return}let S=await g8(d),P={type:m8.excalidrawLibrary,version:p8.excalidrawLibrary,source:h8(),libraryItems:d},M=JSON.stringify(P,null,2),R=new Blob([M],{type:"application/json"}),L=new FormData;L.append("excalidrawLib",R),L.append("previewImage",S),L.append("previewImageType",S.type),L.append("title",l.name),L.append("authorName",l.authorName),L.append("githubHandle",l.githubHandle),L.append("name",l.name),L.append("description",l.description),L.append("twitterHandle",l.twitterHandle),L.append("website",l.website),fetch(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:L}).then(k=>k.ok?k.json().then(({url:N})=>{jt.delete(Eh.PUBLISH_LIBRARY),r({url:N,authorName:l.authorName,items:d})}):k.json().catch(()=>{throw new Error(k.statusText||"something went wrong")}).then(N=>{throw new Error(N.message||k.statusText||"something went wrong")}),k=>{console.error(k),n(k),c(!1)}).catch(k=>{console.error(k),n(k),c(!1)})},b=()=>{let y=[];return d.forEach((v,C)=>{y.push(de("div",{className:"single-library-item-wrapper",children:de(f8,{libItem:v,appState:t,index:C,onChange:(S,P)=>{let M=d.slice();M[P].name=S,p(M)},onRemove:a})},C))}),de("div",{className:"selected-library-items",children:y})},x=d8(()=>{i(d),jt.set(Eh.PUBLISH_LIBRARY,l),e()},[d,e,i,l]),w=!!o.length,E=o.some(y=>y.status==="published");return de(Ge,{onCloseRequest:x,title:h("publishDialog.title"),className:"publish-library",children:w?ct("form",{onSubmit:f,children:[de("div",{className:"publish-library-note",children:de(yt,{i18nKey:"publishDialog.noteDescription",link:y=>de("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),de("span",{className:"publish-library-note",children:de(yt,{i18nKey:"publishDialog.noteGuidelines",link:y=>de("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),de("div",{className:"publish-library-note",children:h("publishDialog.noteItems")}),E&&de("span",{className:"publish-library-note publish-library-warning",children:h("publishDialog.republishWarning")}),b(),ct("div",{className:"publish-library__fields",children:[ct("label",{children:[ct("div",{children:[de("span",{children:h("publishDialog.libraryName")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:h("publishDialog.placeholder.libraryName")})]}),ct("label",{style:{alignItems:"flex-start"},children:[ct("div",{children:[de("span",{children:h("publishDialog.libraryDesc")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:h("publishDialog.placeholder.libraryDesc")})]}),ct("label",{children:[ct("div",{children:[de("span",{children:h("publishDialog.authorName")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:h("publishDialog.placeholder.authorName")})]}),ct("label",{children:[de("span",{children:h("publishDialog.githubUsername")}),de("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:h("publishDialog.placeholder.githubHandle")})]}),ct("label",{children:[de("span",{children:h("publishDialog.twitterUsername")}),de("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:h("publishDialog.placeholder.twitterHandle")})]}),ct("label",{children:[de("span",{children:h("publishDialog.website")}),de("input",{type:"text",name:"website",pattern:"https?://.+",title:h("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:h("publishDialog.placeholder.website")})]}),de("span",{className:"publish-library-note",children:de(yt,{i18nKey:"publishDialog.noteLicense",link:y=>de("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),ct("div",{className:"publish-library__buttons",children:[de(Jo,{label:h("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),de(Jo,{type:"submit",label:h("buttons.submit"),actionType:"primary",isLoading:m})]})]}):de("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:h("publishDialog.atleastOneLibItem")})})},tw=b8;import y8 from"clsx";import{useEffect as w8,useRef as v8}from"react";import{EVENT as iw,KEYS as T8}from"@haoxin-web/excalidraw-common";import{forwardRef as ow}from"react";import rw from"clsx";import{jsx as nw}from"react/jsx-runtime";var x8=ow(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>nw("div",{className:rw("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),E8=ow(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>nw("div",{className:rw("Stack Stack_vertical",n),style:{"--gap":1,justifyItems:t,justifyContent:"flex-start",...i},ref:a,children:e})),Ue={Row:x8,Col:E8};import{jsx as cd}from"react/jsx-runtime";var aw=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=pe(),a=v8(null),l=br({onClickOutside:o});Jn(a,()=>{l.onClickOutside?.()}),w8(()=>{let m=d=>{d.key===T8.ESCAPE&&(d.stopImmediatePropagation(),l.onClickOutside?.())},c={capture:!0};return document.addEventListener(iw.KEYDOWN,m,c),()=>{document.removeEventListener(iw.KEYDOWN,m,c)}},[l]);let s=y8(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return cd(Yp.Provider,{value:{onSelect:r},children:cd("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?cd(Ue.Col,{className:"dropdown-menu-container",children:e}):cd(De,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};aw.displayName="DropdownMenuContent";var lw=aw;import{jsx as C8}from"react/jsx-runtime";var I8=({children:e,className:o="",selected:t,...r})=>C8("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),sw=I8;import{jsx as cw}from"react/jsx-runtime";var dw=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noopener",...s})=>{let m=cc(s.onClick,n);return cw("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:sc(i,a),title:s.title??s["aria-label"],onClick:m,children:cw(lc,{icon:e,shortcut:o,children:r})})},_i=dw;dw.displayName="DropdownMenuItemLink";import{jsx as S8}from"react/jsx-runtime";var mw=()=>S8("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),pw=mw;mw.displayName="DropdownMenuSeparator";import k8 from"clsx";import{jsx as M8}from"react/jsx-runtime";var uw=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=pe(),a=k8(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return M8("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},hw=uw;uw.displayName="DropdownMenuTrigger";import dd from"react";var gw=e=>{let o=dd.Children.toArray(e).find(t=>dd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},fw=e=>{let o=dd.Children.toArray(e).find(t=>dd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as L8,jsxs as P8}from"react/jsx-runtime";var Qo=({children:e,open:o})=>{let t=gw(e),r=fw(e);return P8(L8,{children:[t,o&&r]})};Qo.Trigger=hw;Qo.Content=lw;Qo.Item=xt;Qo.ItemLink=_i;Qo.ItemCustom=sw;Qo.Group=Da;Qo.Separator=pw;var Ie=Qo;Qo.displayName="DropdownMenu";import{jsx as Pt,jsxs as md}from"react/jsx-runtime";var R8=(e,o)=>e.filter(t=>o.includes(t.id)),N8=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=ce(xn),[m,c]=ce(Ai),d=()=>{let L=o.length?h("alerts.removeItemsFromsLibrary",{count:o.length}):h("alerts.resetLibrary"),k=o.length?h("confirmDialog.removeItemsFromLib"):h("confirmDialog.resetLibrary");return Pt(ad,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:k,children:Pt("p",{children:L})})},[p,u]=wh(!1),f=!!o.length,b=f?s.libraryItems.filter(L=>o.includes(L.id)):s.libraryItems,x=f?h("buttons.remove"):h("buttons.resetLibrary"),[w,E]=wh(!1),[y,v]=wh(null),C=_8(()=>md(Ge,{onCloseRequest:()=>v(null),title:h("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Pt("p",{children:Pt(yt,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:L=>Pt("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:L})})}),Pt(z,{type:"button",title:h("buttons.close"),"aria-label":h("buttons.close"),label:h("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),S=(L,k)=>{E(!1),v({url:L.url,authorName:L.authorName});let N=k.slice();N.forEach(O=>{o.includes(O.id)&&(O.status="published")}),t.setLibrary(N)},P=async()=>{try{await t.updateLibrary({libraryItems:ns({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(L){if(L?.name==="AbortError"){console.warn(L);return}e({errorMessage:h("errors.importLibraryError")})}},M=async()=>{let L=f?b:await t.getLatestLibrary();P1(L).catch(D8).catch(k=>{e({errorMessage:k.message})})},R=()=>md(Ie,{open:m,children:[Pt(Ie.Trigger,{onToggle:()=>c(!m),children:rb}),md(Ie.Content,{onClickOutside:()=>c(!1),onSelect:()=>c(!1),className:"library-menu",children:[!f&&Pt(Ie.Item,{onSelect:P,icon:Un,"data-testid":"lib-dropdown--load",children:h("buttons.load")}),!!b.length&&Pt(Ie.Item,{onSelect:M,icon:nn,"data-testid":"lib-dropdown--export",children:h("buttons.export")}),!!b.length&&Pt(Ie.Item,{onSelect:()=>u(!0),icon:Bt,children:x}),f&&Pt(Ie.Item,{icon:r0,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:h("buttons.publishLibrary")})]})]});return md("div",{className:A8("library-menu-dropdown-container",l),children:[R(),o.length>0&&Pt("div",{className:"library-actions-counter",children:o.length}),p&&d(),w&&Pt(tw,{onClose:()=>E(!1),libraryItems:R8(s.libraryItems,o),appState:a,onSuccess:L=>S(L,s.libraryItems),onError:L=>window.alert(L),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:L=>i(o.filter(k=>k!==L))}),y&&C()]})},vh=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=Oe(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=Qc(),a=xe(),l=me(),[s]=ce(xn),m=async d=>{let p=d.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:h("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return Pt(N8,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>m(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as Y8,useEffect as V8,useState as X8}from"react";import B8,{useCallback as F8}from"react";function O8(){return[!1,F8(o=>o(),[])]}var bw=B8.useTransition||O8;import xw from"clsx";import{memo as z8,useEffect as H8,useRef as G8,useState as U8}from"react";import{jsx as pd,jsxs as W8}from"react/jsx-runtime";var Ew=z8(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=G8(null),m=Oy(e,o,l);H8(()=>{let f=s.current;if(f)return m&&(f.innerHTML=m.outerHTML),()=>{f.innerHTML=""}},[m]);let[c,d]=U8(!1),p=pe().editor.isMobile,u=t&&pd("div",{className:"library-unit__adder",children:ob});return W8("div",{className:xw("library-unit",{"library-unit__active":o,"library-unit--hover":o&&c,"library-unit--selected":n,"library-unit--skeleton":!m}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[pd("div",{className:xw("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):r(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}d(!1),a(e,f)}}),u,e&&o&&(c||p||n)&&pd(Wa,{checked:n,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),yw=()=>pd("div",{className:"library-unit library-unit--skeleton"});import{Fragment as K8,jsx as ud}from"react/jsx-runtime";var Th=({children:e})=>ud("div",{className:"library-menu-items-container__grid",children:e}),hd=Y8(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=bw(),[s,m]=X8(0);return V8(()=>{s<e.length&&l(()=>{m(s+a)})},[s,e.length,l,a]),ud(K8,{children:e.map((c,d)=>d<s?ud(Ew,{elements:c?.elements,isPending:!c?.id&&!!c?.elements,onClick:n,svgCache:i,id:c?.id,selected:r(c.id),onToggle:o,onDrag:t},c?.id??d):ud(yw,{},d))})});import{Fragment as vw,jsx as At,jsxs as Ri}from"react/jsx-runtime";var e7=17,t7=64;function Ih({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:m}){let c=$8(null),d=$y(c);Z8(()=>{d>0&&c.current?.scrollTo(0,d)},[]);let{svgCache:p}=Qc(),u=ww(()=>o.filter(L=>L.status!=="published"),[o]),f=ww(()=>o.filter(L=>L.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!f.length,[w,E]=j8(null),y=Di((L,k)=>{let N=!m.includes(L),O=[...u,...f];if(N){if(k.shiftKey&&w){let G=O.findIndex(j=>j.id===w),_=O.findIndex(j=>j.id===L);if(G===-1||_===-1){s([...m,L]);return}let B=J8(m),K=O.reduce((j,X,q)=>((q>=G&&q<=_||B.has(X.id))&&j.push(X.id),j),[]);s(K)}else s([...m,L]);E(L)}else E(null),s(m.filter(G=>G!==L))},[w,s,f,m,u]),v=Di(L=>{let k;return m.includes(L)?k=o.filter(N=>m.includes(N.id)):k=o.filter(N=>N.id===L),k.map(N=>({...N,elements:Q8({type:"everything",elements:N.elements,randomizeSeed:!0}).duplicatedElements}))},[o,m]),C=Di((L,k)=>{k.dataTransfer.setData(q8.excalidrawlib,Xm(v(L)))},[v]),S=Di(L=>L?m.includes(L):!1,[m]),P=Di(()=>{t(n)},[n,t]),M=Di(L=>{L&&r(v(L))},[v,r]),R=p.size>=o.length?t7:e7;return Ri("div",{className:"library-menu-items-container",style:n.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&At(vh,{selectedItems:m,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),Ri(Ue.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:f.length>0?1:"0 1 auto",marginBottom:0},ref:c,children:[Ri(vw,{children:[!x&&At("div",{className:"library-menu-items-container__header",children:h("labels.personalLib")}),e&&At("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:At(it,{})}),!n.length&&!u.length?Ri("div",{className:"library-menu-items__no-items",children:[At("div",{className:"library-menu-items__no-items__label",children:h("library.noItems")}),At("div",{className:"library-menu-items__no-items__hint",children:f.length>0?h("library.hint_emptyPrivateLibrary"):h("library.hint_emptyLibrary")})]}):Ri(Th,{children:[n.length>0&&At(hd,{itemsRenderedPerBatch:R,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:C,onClick:P,isItemSelected:S,svgCache:p}),At(hd,{itemsRenderedPerBatch:R,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:M,isItemSelected:S,svgCache:p})]})]}),Ri(vw,{children:[(f.length>0||n.length>0||u.length>0)&&At("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:h("labels.excalidrawLib")}),f.length>0?At(Th,{children:At(hd,{itemsRenderedPerBatch:R,items:f,onItemSelectToggle:y,onItemDrag:C,onClick:M,isItemSelected:S,svgCache:p})}):u.length>0?At("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:h("library.noItems")}):null]}),b&&At(nd,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:At(vh,{selectedItems:m,onSelectItems:s})})]})]})}import{jsx as Ar,jsxs as Cw}from"react/jsx-runtime";var Ai=he(!1),Iw=({children:e})=>Ar("div",{className:"layer-ui__library",children:e}),a7=Mw(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:m})=>{let[c]=ce(xn),d=Sh(f=>{(async(x,w)=>{ae("element","addToLibrary","ui");for(let y of r7)if(x.some(v=>v.type===y))return r({errorMessage:h(`errors.libraryElementTypeError.${y}`)});let E=[{status:"unpublished",elements:x,id:n7(),created:Date.now()},...w];t(),i.setLibrary(E).catch(()=>{r({errorMessage:h("alerts.errorAddingToLibrary")})})})(f,c.libraryItems)},[t,i,r,c.libraryItems]),p=kw(()=>c.libraryItems,[c]);if(c.status==="loading"&&!c.isInitialized)return Ar(Iw,{children:Ar("div",{className:"layer-ui__library-message",children:Cw("div",{children:[Ar(it,{size:"2em"}),Ar("span",{children:h("labels.libraryLoadingMessage")})]})})});let u=c.libraryItems.length>0||o.length>0;return Cw(Iw,{children:[Ar(Ih,{isLoading:c.status==="loading",libraryItems:p,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:m,selectedItems:s}),u&&Ar(nd,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Ch=(e,o)=>({elements:e,pending:J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),l7=(e,o)=>{let t=yr(),[r,n]=Sw(()=>Ch(t,e.selectedElementIds)),i=o7(new Map);return Tw(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),Tw(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!i7(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Ch(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let m=l.get(s)?.version;if(m&&m!==i.current.get(s))return Ch(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},Lw=Mw(()=>{let e=Oe(),{onInsertElements:o}=e,t=Lo(),r=xe(),n=me(),[i,a]=Sw([]),l=kw(()=>e.library,[e.library]),s=l7(r,e),m=Sh(d=>{o(rd(d))},[o]),c=Sh(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return Ar(a7,{pendingElements:s,onInsertLibraryItems:m,onAddToLibrary:c,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import s7 from"clsx";import{useRef as c7}from"react";import{createPortal as d7}from"react-dom";import{KEYS as m7}from"@haoxin-web/excalidraw-common";import{jsx as Pw,jsxs as p7}from"react/jsx-runtime";var Aw=e=>{let{closeOnClickOutside:o=!0}=e,t=Js({className:"excalidraw-modal-container"}),r=c7(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===m7.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return d7(p7("div",{className:s7("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[Pw("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),Pw("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as dl,jsxs as x7}from"react/jsx-runtime";function b7(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Ge=e=>{let[o,t]=Ny(),[r]=g7(document.activeElement),{id:n}=Xe(),i=pe().viewport.isMobile;h7(()=>{if(!o)return;let m=_w(o);setTimeout(()=>{m.length>0&&e.autofocus!==!1&&(m[1]||m[0]).focus()});let c=d=>{if(d.key===f7.TAB){let p=_w(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):f===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return o.addEventListener("keydown",c),()=>o.removeEventListener("keydown",c)},[o,e.autofocus]);let a=me(),l=pr(Ai),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return dl(Aw,{className:u7("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:b7(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:x7(De,{ref:t,children:[e.title&&dl("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:dl("span",{className:"Dialog__titleContent",children:e.title})}),i&&dl("button",{className:"Dialog__close",onClick:s,title:h("buttons.close"),"aria-label":h("buttons.close"),type:"button",children:Vt}),dl("div",{className:"Dialog__content",children:e.children})]})})};import kh from"clsx";import{forwardRef as v7,useRef as T7,useImperativeHandle as I7,useLayoutEffect as C7,useState as S7}from"react";import E7 from"clsx";import{composeEventHandlers as y7}from"@haoxin-web/excalidraw-common";import{jsx as w7}from"react/jsx-runtime";var Gt=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>w7("button",{onClick:y7(i.onClick,a=>{o()}),type:e,className:E7("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as Mh,jsxs as Dw}from"react/jsx-runtime";var Ni=v7(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:m,...c},d)=>{let p=T7(null);I7(d,()=>p.current),C7(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=S7(!1);return Dw("div",{className:kh("ExcTextField",m,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&Mh("div",{className:"ExcTextField__label",children:o}),Dw("div",{className:kh("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[Mh("input",{className:kh({"is-redacted":"value"in c&&c.value&&l&&!u}),readOnly:n,value:"value"in c?c.value:void 0,defaultValue:"defaultValue"in c?c.defaultValue:void 0,placeholder:r,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&Mh(Gt,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?f0:Kn})]})]})});import{KEYS as Ce}from"@haoxin-web/excalidraw-common";var Rw=[{icon:ba,value:"selection",key:Ce.V,numericKey:Ce[1],fillable:!0},{icon:ko,value:"rectangle",key:Ce.R,numericKey:Ce[2],fillable:!0},{icon:ur,value:"diamond",key:Ce.D,numericKey:Ce[3],fillable:!0},{icon:hr,value:"ellipse",key:Ce.O,numericKey:Ce[4],fillable:!0},{icon:gr,value:"triangle",key:null,numericKey:Ce[5],fillable:!0},{icon:fr,value:"pentagon",key:null,numericKey:Ce[6],fillable:!0},{icon:rn,value:"arrow",key:Ce.A,numericKey:Ce[7],fillable:!0},{icon:co,value:"line",key:Ce.L,numericKey:Ce[8],fillable:!0},{icon:Nt,value:"freedraw",key:[Ce.P,Ce.X],numericKey:Ce[9],fillable:!1},{icon:Wo,value:"text",key:Ce.T,numericKey:null,fillable:!1},{icon:db,value:"image",key:null,numericKey:null,fillable:!1},{icon:xa,value:"eraser",key:Ce.E,numericKey:null,fillable:!1},{icon:Yo,value:"laser",key:null,numericKey:null,fillable:!1},{icon:u0,value:"laserTrail",key:null,numericKey:null,fillable:!1}],Lh=e=>[{icon:ba,value:"selection",key:Ce.V,numericKey:null,fillable:!0},{icon:Nt,value:"freedraw",key:[Ce.P,Ce.X],numericKey:null,fillable:!1},{icon:co,value:"line",key:Ce.L,numericKey:null,fillable:!0},{icon:ko,value:"rectangle",key:Ce.R,numericKey:null,fillable:!0},{icon:Wo,value:"text",key:Ce.T,numericKey:null,fillable:!1},{icon:xa,value:"eraser",key:Ce.E,numericKey:null,fillable:!1}],Nw=(e,o)=>Lh(o).find((r,n)=>r.numericKey!=null&&e===String(r.numericKey)||r.key&&(typeof r.key=="string"?r.key===e:r.key.includes(e)))?.value||null;import Dh from"clsx";import{useState as L7}from"react";import{CLASSES as P7,KEYS as A7,capitalizeString as _h,isTransparent as Fw}from"@haoxin-web/excalidraw-common";import{shouldAllowVerticalAlign as _7,suppportsHorizontalAlign as D7}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as Ow,isElbowArrow as R7,isImageElement as N7,isLinearElement as B7,isTextElement as F7}from"@haoxin-web/excalidraw-element";import{hasStrokeColor as zw,toolIsArrow as Hw}from"@haoxin-web/excalidraw-element";import{createIsolation as k7}from"jotai-scope";import Ph from"react";import Do from"tunnel-rat";var Ah=Ph.createContext(null),Se=()=>Ph.useContext(Ah),M7=k7(),Bw=()=>Ph.useMemo(()=>({MainMenuTunnel:Do(),WelcomeScreenMenuHintTunnel:Do(),WelcomeScreenToolbarHintTunnel:Do(),WelcomeScreenHelpHintTunnel:Do(),WelcomeScreenCenterTunnel:Do(),FooterCenterTunnel:Do(),DefaultSidebarTriggerTunnel:Do(),DefaultSidebarTabTriggersTunnel:Do(),OverwriteConfirmDialogTunnel:Do(),TTDDialogTriggerTunnel:Do(),tunnelsJotai:M7}),[]);import{Fragment as _r,jsx as dt,jsxs as wt}from"react/jsx-runtime";var Rh=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return zw(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>zw(r.type))},Nh=(e,o)=>cr(e.activeTool.type)||o.some(t=>cr(t.type)),Gw=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=rs(o,e),i=!1;n.length===2&&(Ow(n[0])||Ow(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=pe(),s=document.documentElement.getAttribute("dir")==="rtl",m=cr(e.activeTool.type)&&!Fw(e.currentItemBackgroundColor)||n.some(f=>cr(f.type)&&!Fw(f.backgroundColor)),c=n.length===1||i,d=!e.selectedLinearElement?.isEditing&&n.length===1&&B7(n[0])&&!R7(n[0]),p=!e.croppingElementId&&n.length===1&&N7(n[0]),u=!i&&Lt(e,r);return wt("div",{className:"selected-shape-actions",children:[dt("div",{children:Rh(e,n)&&t("changeStrokeColor")}),Nh(e,n)&&dt("div",{children:t("changeBackgroundColor")}),m&&t("changeFillStyle"),(Hm(e.activeTool.type)||n.some(f=>Hm(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(Gm(e.activeTool.type)||n.some(f=>Gm(f.type)))&&wt(_r,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Um(e.activeTool.type)||n.some(f=>Um(f.type)))&&dt(_r,{children:t("changeRoundness")}),(Hw(e.activeTool.type)||n.some(f=>Hw(f.type)))&&dt(_r,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(F7))&&wt(_r,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||D7(n,o))&&t("changeTextAlign")]}),_7(n,o)&&t("changeVerticalAlign"),(_n(e.activeTool.type)||n.some(f=>_n(f.type)))&&dt(_r,{children:t("changeArrowhead")}),t("changeOpacity"),wt("fieldset",{children:[dt("legend",{children:h("labels.layers")}),wt("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&wt("fieldset",{children:[dt("legend",{children:h("labels.align")}),wt("div",{className:"buttonList",children:[s?wt(_r,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):wt(_r,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),dt("div",{style:{flexBasis:"100%",height:0}}),wt("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),n.length>2&&t("distributeVertically")]})]})]}),!a&&n.length>0&&wt("fieldset",{children:[dt("legend",{children:h("labels.actions")}),wt("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),c&&t("hyperlink"),p&&t("cropEditor"),d&&t("toggleLinearEditor")]})]})]})},Uw=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=L7(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="laserTrail",m=e.type==="lasso"&&t.defaultSelectionTool!=="lasso",c=e.type==="embeddable",{TTDDialogTriggerTunnel:d}=Se();return wt(_r,{children:[Lh(t).map(({value:p,icon:u,key:f,numericKey:b,fillable:x},w)=>{if(r.tools?.[p]===!1)return null;let E=h(`toolBar.${p}`),y=f&&_h(typeof f=="string"?f:f[0]),v=y?`${y} ${h("helpDialog.or")} ${b}`:`${b}`;return dt(z,{className:Dh("Shape",{fillable:x}),type:"radio",icon:u,checked:e.type===p,name:"editor-current-shape",title:`${_h(E)} \u2014 ${v}`,keyBindingLabel:b||y,"aria-label":_h(E),"aria-keyshortcuts":v,"data-testid":`toolbar-${p}`,onPointerDown:({pointerType:C})=>{!o.penDetected&&C==="pen"&&t.togglePenMode(!0),p==="freedraw"?window.dispatchEvent(new CustomEvent("leftflyout:toggle",{detail:{group:"freedraw"}})):p==="line"?window.dispatchEvent(new CustomEvent("leftflyout:toggle",{detail:{group:"line"}})):p==="rectangle"?window.dispatchEvent(new CustomEvent("leftflyout:toggle",{detail:{group:"shapes"}})):p==="text"&&window.dispatchEvent(new CustomEvent("leftflyout:toggle",{detail:{group:"text"}})),p==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:C})=>{o.activeTool.type!==p&&ae("toolbar",p,"ui"),p==="image"?t.setActiveTool({type:p}):t.setActiveTool({type:p})}},p)}),dt("div",{className:"App-toolbar__divider"}),wt(Ie,{open:n,children:[dt(Ie.Trigger,{className:Dh("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||c||m||l&&!t.props.isCollaborating}),onToggle:()=>i(!n),title:h("toolBar.extraTools"),children:a?Vn:c?pb:l&&!t.props.isCollaborating?Yo:m?xs:c0}),dt(Ie.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:dt(Ie.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:Yo,"data-testid":"toolbar-laser",selected:l,shortcut:A7.K.toLocaleUpperCase(),children:h("toolBar.laser")})})]})]})},Ww=({renderAction:e,zoom:o,visible:t=!0})=>t?dt(Ue.Col,{gap:1,className:P7.ZOOM_ACTIONS,children:wt(Ue.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}):null;var Yw=({actionManager:e,showExitZenModeBtn:o})=>dt("button",{type:"button",className:Dh("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(wi),children:h("buttons.exitZenMode")});import{useRef as O7}from"react";var Bh=e=>{let o=O7({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as H7,jsxs as z7}from"react/jsx-runtime";var En=he(null),Vw=()=>{let[e,o]=ce(En),t=Ke();return e&&e==="clearCanvas"?H7(ad,{onConfirm:()=>{t.executeAction(jo),o(null)},onCancel:()=>o(null),title:h("clearCanvasDialog.title"),children:z7("p",{className:"clear-canvas__content",children:[" ",h("alerts.clearReset")]})}):null};var Fh={};I1(Fh,{toggleTheme:()=>G7});var G7={...dn,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(dn,"commandPalette")}};import{jsx as mt,jsxs as Ro}from"react/jsx-runtime";var K7=he(null),Pe={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},Z7=e=>{switch(e){case Pe.app:return 1;case Pe.export:return 2;case Pe.editor:return 3;case Pe.tools:return 4;case Pe.elements:return 5;case Pe.links:return 6;default:return 10}},bd=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return Ro("div",{className:Zw("shortcut",o),children:[r.map((n,i)=>mt("div",{className:"shortcut-wrapper",children:mt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),mt("div",{className:"shortcut-desc",children:t})]})},$w=e=>!e.altKey&&e[Eo.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===Eo.P||e.key===Eo.SLASH),Lde=Object.assign(e=>{let o=xe(),t=me();return fd(()=>{let r=n=>{$w(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&ae("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(xd.KEYDOWN,r,{capture:!0}),()=>window.removeEventListener(xd.KEYDOWN,r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:mt($7,{...e})},{defaultItems:Fh});function $7({customCommandPaletteItems:e}){let o=Oe(),t=xe(),r=me(),n=Lo(),i=Ke(),[a,l]=ce(K7),[s,m]=gd(null),c=W7(null),d=br({uiAppState:t,customCommandPaletteItems:e,appProps:n});fd(()=>{let{uiAppState:S,customCommandPaletteItems:P,appProps:M}=d,R=O=>{let G="";return O.label&&(typeof O.label=="function"?G=h(O.label(o.scene.getNonDeletedElements(),S,o)):G=h(O.label)),G},L=O=>typeof O.icon=="function"?O.icon(S,o.scene.getNonDeletedElements()):O.icon,k=[],N=(O,G,_)=>{let B={label:R(O),icon:L(O),category:G,shortcut:He(O.name),keywords:O.keywords,predicate:O.predicate,viewMode:O.viewMode,perform:()=>{i.executeAction(O,"commandPalette")}};return _?_(B,O):B};if(S&&o.scene&&i){let O=[i.actions.group,i.actions.ungroup,i.actions.cut,i.actions.copy,i.actions.deleteSelectedElements,i.actions.wrapSelectionInFrame,i.actions.copyStyles,i.actions.pasteStyles,i.actions.bringToFront,i.actions.bringForward,i.actions.sendBackward,i.actions.sendToBack,i.actions.alignTop,i.actions.alignBottom,i.actions.alignLeft,i.actions.alignRight,i.actions.alignVerticallyCentered,i.actions.alignHorizontallyCentered,i.actions.duplicateSelection,i.actions.flipHorizontal,i.actions.flipVertical,i.actions.zoomToFitSelection,i.actions.zoomToFitSelectionInViewport,i.actions.increaseFontSize,i.actions.decreaseFontSize,i.actions.toggleLinearEditor,i.actions.cropEditor,i.actions.togglePolygon,el,Jc,Dy].map(X=>N(X,Pe.elements,(q,se)=>({...q,predicate:se.predicate?se.predicate:(ie,be,ue,ao)=>J(ie,be).length>0}))),G=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(X=>N(X,Pe.tools)),_=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map(X=>N(X,Pe.editor)),B=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(X=>N(X,Pe.export));k=[...O,..._,{label:R(jo),icon:L(jo),shortcut:He(jo.name),category:Pe.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{Ve.set(En,"clearCanvas")}},{label:h("buttons.exportImage"),category:Pe.export,icon:ks,shortcut:He("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...B];let K=[{label:h("toolBar.library"),category:Pe.app,icon:zn,viewMode:!1,perform:()=>{S.openSidebar?r({openSidebar:null}):r({openSidebar:{name:Xw.name,tab:Xw.defaultTab}})}},{label:h("search.title"),category:Pe.app,icon:Ft,viewMode:!0,perform:()=>{i.executeAction(ml)}},{label:h("labels.shapeSwitch"),category:Pe.elements,icon:Sa,perform:()=>{i.executeAction(_y)}},{label:h("labels.changeStroke"),keywords:["color","outline"],category:Pe.elements,icon:Ss,viewMode:!1,predicate:(X,q)=>{let se=J(X,q);return se.length>0&&Rh(q,se)},perform:()=>{r(X=>({openMenu:X.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:h("labels.changeBackground"),keywords:["color","fill"],icon:Ss,category:Pe.elements,viewMode:!1,predicate:(X,q)=>{let se=J(X,q);return se.length>0&&Nh(q,se)},perform:()=>{r(X=>({openMenu:X.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:h("labels.canvasBackground"),keywords:["color"],icon:Ss,category:Pe.editor,viewMode:!1,perform:()=>{r(X=>({openMenu:X.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Rw.reduce((X,q)=>{let{value:se,icon:ie,key:be,numericKey:ue}=q;if(M.UIOptions.tools?.[se]===!1)return X;let Io=be&&Y7(typeof be=="string"?be:be[0])||ue,es={label:h(`toolBar.${se}`),category:Pe.tools,shortcut:Io||void 0,icon:ie,keywords:["toolbar"],viewMode:!1,perform:({event:Fm})=>{se==="image"?o.setActiveTool({type:se}):o.setActiveTool({type:se})}};return X.push(es),X},[]),...G,{label:h("toolBar.lock"),category:Pe.tools,icon:S.activeTool.locked?Hn:on,shortcut:Eo.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${h("labels.textToDiagram")}...`,category:Pe.tools,icon:x0,viewMode:!1,predicate:M.aiEnabled,perform:()=>{r(X=>({...X,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${h("toolBar.mermaidToExcalidraw")}...`,category:Pe.tools,icon:d0,viewMode:!1,predicate:M.aiEnabled,perform:()=>{r(X=>({...X,openDialog:{name:"ttd",tab:"mermaid"}}))}}],j=[...k,...K,...P||[]].map(X=>({...X,icon:X.icon||Sa,order:X.order??Z7(X.category),haystack:`${dh(X.label.toLocaleLowerCase())} ${X.keywords?.join(" ")||""}`}));m(j),l(j.find(X=>X.label===a?.label)??null)}},[d,o,i,m,a?.label,l,r]);let[p,u]=gd(""),[f,b]=gd(null),[x,w]=gd({}),E=S=>{r({openDialog:null},S),u("")},y=(S,P)=>{t.openDialog?.name==="commandPalette"&&(P.stopPropagation(),P.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),E(()=>{S.perform({actionManager:i,event:P}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=Bh(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,n,o):S.predicate===void 0||S.predicate),C=Bh(S=>{let P=X7(S.target)||$w(S)||S.key===Eo.ESCAPE;if(P&&S.key!==Eo.ARROW_UP&&S.key!==Eo.ARROW_DOWN&&S.key!==Eo.ENTER)return;let M=Object.values(x).flat(),R=a&&!p&&v(a);if(S.key===Eo.ARROW_UP){S.preventDefault();let L=M.findIndex(O=>O.label===f?.label);if(R){if(L===0){b(a);return}if(f===a){let O=M[M.length-1];O&&b(O);return}}let k;L===-1?k=M.length-1:k=L===0?M.length-1:(L-1)%M.length;let N=M[k];N&&b(N);return}if(S.key===Eo.ARROW_DOWN){S.preventDefault();let L=M.findIndex(O=>O.label===f?.label);if(R){if(!f||L===M.length-1){b(a);return}if(f===a){let O=M[0];O&&b(O);return}}let k=(L+1)%M.length,N=M[k];N&&b(N);return}if(S.key===Eo.ENTER&&f&&setTimeout(()=>{y(f,S)}),!P){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){c?.current?.focus();return}S.preventDefault()}});return fd(()=>(window.addEventListener(xd.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(xd.KEYDOWN,C,{capture:!0})),[C]),fd(()=>{if(!s)return;let S=L=>{let k={};for(let N of L)k[N.category]?k[N.category].push(N):k[N.category]=[N];return k},P=s.filter(v).sort((L,k)=>L.order-k.order),M=!p&&a&&v(a);if(!p){w(S(M?P.filter(L=>L.label!==a?.label):P)),b(M?a:P[0]||null);return}let R=dh(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));P=U7.filter(R,P,{extract:L=>L.haystack}).sort((L,k)=>k.score-L.score).map(L=>L.original),w(S(P)),b(P[0]??null)},[p,s,v,a]),Ro(Ge,{onCloseRequest:()=>E(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[mt(Ni,{value:p,placeholder:h("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:c}),!o.device.viewport.isMobile&&Ro("div",{className:"shortcuts-wrapper",children:[mt(bd,{shortcut:"\u2191\u2193",children:h("commandPalette.shortcuts.select")}),mt(bd,{shortcut:"\u21B5",children:h("commandPalette.shortcuts.confirm")}),mt(bd,{shortcut:V7("Esc"),children:h("commandPalette.shortcuts.close")})]}),Ro("div",{className:"commands",children:[a&&!p&&Ro("div",{className:"command-category",children:[Ro("div",{className:"command-category-title",children:[h("commandPalette.recents"),mt("div",{className:"icon",style:{marginLeft:"6px"},children:E0})]}),mt(Kw,{command:a,isSelected:a.label===f?.label,onClick:S=>y(a,S),disabled:!v(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((S,P)=>Ro("div",{className:"command-category",children:[mt("div",{className:"command-category-title",children:S}),x[S].map(M=>mt(Kw,{command:M,isSelected:M.label===f?.label,onClick:R=>y(M,R),onMouseMove:()=>b(M),showShortcut:!o.device.viewport.isMobile,appState:t},M.label))]},S)):s?Ro("div",{className:"no-match",children:[mt("div",{className:"icon",children:Ft})," ",h("commandPalette.search.noMatch")]}):null]})]})}var Kw=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return Ro("div",{className:Zw("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:n,onMouseMove:t?l:r,title:t?h("commandPalette.itemNotAvailable"):"",children:[Ro("div",{className:"name",children:[e.icon&&mt(Ir,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),mt(Ra,{children:e.label})]}),i&&e.shortcut&&mt(bd,{shortcut:e.shortcut})]})};import{getSizeFromPoints as wbe,randomInteger as V_,getUpdatedTimestamp as X_}from"@haoxin-web/excalidraw-common";import{simplify as N_}from"points-on-curve";import{pointsOnBezierCurves as Rde}from"points-on-curve";import{invariant as Bde}from"@haoxin-web/excalidraw-common";import{curve as Ode,lineSegment as zde,pointFrom as Hde,pointDistance as Gde,pointFromArray as Ude,pointFromVector as Wde,pointRotateRads as Yde,polygon as Vde,polygonFromPoints as Xde,PRECISION as Kde,segmentsIntersectAt as Zde,vector as $de,vectorAdd as jde,vectorFromPoint as qde,vectorScale as Jde}from"@haoxin-web/excalidraw-math";import{getElementAbsoluteCoords as eme}from"@haoxin-web/excalidraw-element";var Oh=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as B_,pointDistance as E2,pointRotateRads as ibe}from"@haoxin-web/excalidraw-math";import{ROUGHNESS as F_,isTransparent as gl,assertNever as O_,COLOR_PALETTE as z_,LINE_POLYGON_POINT_MERGE_DISTANCE as lbe}from"@haoxin-web/excalidraw-common";import{RoughGenerator as H_}from"roughjs/bin/generator";import v1e from"roughjs/bin/rough";import{getStroke as M_}from"perfect-freehand";import{isRightAngleRads as C1e}from"@haoxin-web/excalidraw-math";import{BOUND_TEXT_PADDING as k1e,DEFAULT_REDUCED_GLOBAL_ALPHA as M1e,ELEMENT_READY_TO_ERASE_OPACITY as L1e,FRAME_STYLE as P1e,MIME_TYPES as g2,THEME as A1e,distance as _1e,getFontString as D1e,isRTL as R1e,getVerticalOffset as N1e}from"@haoxin-web/excalidraw-common";import Rge from"roughjs/bin/rough";import{arrayToMap as Bge,invariant as i2,rescalePoints as Fge,sizeOf as Oge}from"@haoxin-web/excalidraw-common";import{degreesToRadians as jh,lineSegment as Hge,pointDistance as Gge,pointFrom as at,pointFromArray as p_,pointRotateRads as Gi}from"@haoxin-web/excalidraw-math";import{pointsOnBezierCurves as Yge}from"points-on-curve";import{pointCenter as Jhe,pointFrom as Qhe,pointRotateRads as ege,pointsEqual as tge,pointDistance as oge,vectorFromPoint as rge,curveLength as nge,curvePointAtLength as ige}from"@haoxin-web/excalidraw-math";import{DRAGGING_THRESHOLD as sge,KEYS as cge,shouldRotateWithDiscreteAngle as dge,getGridPoint as mge,invariant as pge,tupleToCoors as uge,viewportCoordsToSceneCoords as hge}from"@haoxin-web/excalidraw-common";import{deconstructLinearOrFreeDrawElement as fge,isPathALoop as bge}from"@haoxin-web/excalidraw-element";import{KEYS as que,arrayToMap as Jue,isBindingFallthroughEnabled as Que,tupleToCoors as ehe,invariant as the,isDevEnv as ohe,isTestEnv as rhe}from"@haoxin-web/excalidraw-common";import{lineSegment as ihe,pointFrom as ahe,pointRotateRads as lhe,vectorFromPoint as she,pointDistanceSq as che,clamp as dhe,pointDistance as mhe,pointFromVector as phe,vectorScale as uhe,vectorNormalize as hhe,vectorCross as ghe,pointsEqual as fhe,lineSegmentIntersectionPoints as bhe,PRECISION as xhe}from"@haoxin-web/excalidraw-math";import{isTransparent as kpe}from"@haoxin-web/excalidraw-common";import{curveIntersectLineSegment as Lpe,isPointWithinBounds as Ppe,lineSegment as Ape,lineSegmentIntersectionPoints as _pe,pointFrom as Dpe,pointFromVector as Rpe,pointRotateRads as Npe,pointsEqual as Bpe,vectorFromPoint as Fpe,vectorNormalize as Ope,vectorScale as zpe}from"@haoxin-web/excalidraw-math";import{ellipse as Gpe,ellipseSegmentInterceptPoints as Upe}from"@haoxin-web/excalidraw-math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as j7,DEFAULT_PROPORTIONAL_RADIUS as zh,LINE_CONFIRM_THRESHOLD as q7,ROUNDNESS as Hh}from"@haoxin-web/excalidraw-common";import{curve as ime,curveCatmullRomCubicApproxPoints as ame,curveOffsetPoints as lme,lineSegment as sme,pointDistance as J7,pointFrom as cme,pointFromArray as dme,rectangle as mme}from"@haoxin-web/excalidraw-math";var Ed=(e,o=1)=>{if(e.length>=3){let[t,r]=[e[0],e[e.length-1]];return J7(t,r)<=q7/o}return!1},Bi=(e,o)=>{if(o.roundness?.type===Hh.PROPORTIONAL_RADIUS||o.roundness?.type===Hh.LEGACY)return e*zh;if(o.roundness?.type===Hh.ADAPTIVE_RADIUS){let t=o.roundness?.value??j7,r=t/zh;return e<=r?e*zh:t}return 0};import{ROUNDNESS as xme}from"@haoxin-web/excalidraw-common";import{pointsEqual as wme}from"@haoxin-web/excalidraw-math";var jw=e=>!!e&&e.type==="embeddable",qw=e=>!!e&&e.type==="iframe",Uh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),yn=e=>e!=null&&e.type==="text";var yd=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var Dr=e=>e!=null&&Q7(e.type);var Fi=e=>e!=null&&e.type==="arrow",pl=e=>Fi(e)&&e.elbowed;var Q7=e=>e==="arrow"||e==="line";var Oi=e=>e!==null&&"containerId"in e&&e.containerId!==null&&yn(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as jme,ARROW_LABEL_WIDTH_FRACTION as qme,BOUND_TEXT_PADDING as Jme,DEFAULT_FONT_SIZE as Qme,TEXT_ALIGN as epe,VERTICAL_ALIGN as tpe,getFontString as ope,isProdEnv as rpe,invariant as npe}from"@haoxin-web/excalidraw-common";import{pointFrom as ape,pointRotateRads as lpe}from"@haoxin-web/excalidraw-math";import{BOUND_TEXT_PADDING as kme,DEFAULT_FONT_SIZE as Mme,DEFAULT_FONT_FAMILY as Lme,getFontString as Pme,isTestEnv as Ame,normalizeEOL as _me}from"@haoxin-web/excalidraw-common";var Dme="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as Hme,isTestEnv as Gme}from"@haoxin-web/excalidraw-common";import{curvePointDistance as fpe,distanceToLineSegment as bpe,pointRotateRads as xpe}from"@haoxin-web/excalidraw-math";import{ellipse as ype,ellipseDistanceFromPoint as wpe}from"@haoxin-web/excalidraw-math/ellipse";import{invariant as eue,isDevEnv as tue,isTestEnv as oue}from"@haoxin-web/excalidraw-common";import{pointFrom as nue,pointFromVector as iue,pointRotateRads as aue,pointScaleFromOrigin as lue,pointsEqual as sue,triangleIncludesPoint as cue,vectorCross as due,vectorFromPoint as n_,vectorScale as mue}from"@haoxin-web/excalidraw-math";var Zh=[1,0],t2=[0,1],$h=[-1,0],o2=[0,-1],wd=e=>{let[o,t]=e,r=Math.abs(o),n=Math.abs(t);return o>n?Zh:o<=-n?$h:t>r?t2:o2},r2=(e,o)=>wd(n_(e,o)),vd=(e,o)=>Td(r2(e,o)),Kh=(e,o)=>e[0]===o[0]&&e[1]===o[1],Td=e=>Kh(e,Zh)||Kh(e,$h);import{clamp as bue,pointDistance as xue,pointFrom as Eue,pointScaleFromOrigin as yue,pointsEqual as wue,pointTranslate as vue,vector as Tue,vectorCross as Iue,vectorFromPoint as Cue,vectorScale as Sue}from"@haoxin-web/excalidraw-math";import{BinaryHeap as Mue,invariant as Lue,isAnyTrue as Pue,tupleToCoors as Aue,getSizeFromPoints as _ue,isDevEnv as Due,arrayToMap as Rue}from"@haoxin-web/excalidraw-common";import{SHIFT_LOCKING_ANGLE as Dhe,viewportCoordsToSceneCoords as Rhe}from"@haoxin-web/excalidraw-common";import{normalizeRadians as Bhe,radiansBetweenAngles as Fhe,radiansDifference as Ohe}from"@haoxin-web/excalidraw-math";import{pointsEqual as Hhe}from"@haoxin-web/excalidraw-math";var Gh=e=>{let o=Math.floor(e.width/2)+1,t=0,r=e.width,n=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,r,n,i,a,0,n]},l2=e=>{let t=e.width/2,r=0,n=0,i=e.height,a=e.width,l=e.height;return[t,r,a,l,n,i]},s2=e=>{let o=e.width/2,t=e.height/2,r=Math.min(e.width,e.height)/2,n=r*.4,i=[];for(let a=0;a<10;a++){let l=(a*36-90)*(Math.PI/180),s=a%2===0?r:n,m=o+s*Math.cos(l),c=t+s*Math.sin(l);i.push(m,c)}return i};var u_=e=>{switch(e){case"arrow":return 25;case"diamond":case"diamond_outline":return 12;case"crowfoot_many":case"crowfoot_one":case"crowfoot_one_or_many":return 20;default:return 15}},h_=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},qh=(e,o,t,r)=>{if(o.length<1)return null;let n=Oh(o[0]);if(n.length<1)return null;let i=t==="start"?1:n.length-1,a=n[i].data;i2(a.length===6,"Op data length is not 6");let l=at(a[4],a[5]),s=at(a[2],a[3]),m=at(a[0],a[1]),c=n[i-1],d=at(0,0);if(c.op==="move"){let _=p_(c.data);i2(_!=null,"Op data is not a point"),d=_}else c.op==="bcurveTo"&&(d=at(c.data[4],c.data[5]));let p=(_,B)=>Math.pow(1-_,3)*l[B]+3*_*Math.pow(1-_,2)*s[B]+3*Math.pow(_,2)*(1-_)*m[B]+d[B]*Math.pow(_,3),[u,f]=t==="start"?d:l,[b,x]=[p(.3,0),p(.3,1)],w=Math.hypot(u-b,f-x),E=(u-b)/w,y=(f-x)/w,v=u_(r),C=0;{let[_,B]=t==="end"?e.points[e.points.length-1]:e.points[0],[K,j]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(_-K,B-j)}let P=Math.min(v,C*(r==="diamond"||r==="diamond_outline"?.25:.5)),M=u-E*P,R=f-y*P;if(r==="dot"||r==="circle"||r==="circle_outline"){let _=Math.hypot(R-f,M-u)+e.strokeWidth-2;return[u,f,_]}let L=h_(r);if(r==="crowfoot_many"||r==="crowfoot_one_or_many"){let[_,B]=Gi(at(u,f),at(M,R),jh(-L)),[K,j]=Gi(at(u,f),at(M,R),jh(L));return[M,R,_,B,K,j]}let[k,N]=Gi(at(M,R),at(u,f),-L*Math.PI/180),[O,G]=Gi(at(M,R),at(u,f),jh(L));if(r==="diamond"||r==="diamond_outline"){let _,B;if(t==="start"){let[K,j]=e.points.length>1?e.points[1]:[0,0];[_,B]=Gi(at(u+P*2,f),at(u,f),Math.atan2(j-f,K-u))}else{let[K,j]=e.points.length>1?e.points[e.points.length-2]:[0,0];[_,B]=Gi(at(u-P*2,f),at(u,f),Math.atan2(f-j,u-K))}return[u,f,k,N,_,B,O,G]}return[u,f,k,N,O,G]};import{pointFrom as nfe,pointCenter as ife,pointRotateRads as afe,vectorFromPoint as lfe,vectorNormalize as sfe,vectorSubtract as cfe,vectorAdd as dfe,vectorScale as mfe,pointFromVector as pfe,clamp as ufe,isCloseTo as hfe}from"@haoxin-web/excalidraw-math";import{arrayToMap as e1e}from"@haoxin-web/excalidraw-common";import{isPointWithinBounds as o1e,pointFrom as r1e}from"@haoxin-web/excalidraw-math";import{vectorCross as Efe,vectorFromPoint as yfe}from"@haoxin-web/excalidraw-math";import{arrayToMap as g_}from"@haoxin-web/excalidraw-common";import{getElementBounds as f_}from"@haoxin-web/excalidraw-element";import{isArrowElement as b_,isExcalidrawElement as x_,isFreeDrawElement as E_,isLinearElement as y_,isTextElement as w_}from"@haoxin-web/excalidraw-element";import{rangeIncludesValue as Id,pointFrom as er,pointRotateRads as v_,rangeInclusive as Cd}from"@haoxin-web/excalidraw-math";var T_=e=>e.type==="diamond"?[er(e.width/2,0),er(e.width,e.height/2),er(e.width/2,e.height),er(0,e.height/2)]:[er(0,0),er(0+e.width,0),er(0+e.width,e.height),er(0,e.height)],I_=e=>y_(e)||E_(e)?e.points:T_(e),c2=e=>{let o=e.reduce((t,[r,n])=>(t.minY=Math.min(t.minY,n),t.minX=Math.min(t.minX,r),t.maxX=Math.max(t.maxX,r),t.maxY=Math.max(t.maxY,n),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},d2=e=>{let o=I_(e),{cx:t,cy:r}=c2(o),n=er(t,r),i=o.map(c=>v_(c,n,e.angle)),{minX:a,minY:l,maxX:s,maxY:m}=c2(i);return[a+e.x,l+e.y,s+e.x,m+e.y]},Jh=(e,o,t=!1)=>{let r=d2(e),n=o[0]<=r[0]&&o[2]>=r[2]&&o[1]<=r[1]&&o[3]>=r[3];return t?n?!0:r[0]<=o[0]&&r[2]>=o[2]&&r[1]<=o[1]&&r[3]>=o[3]:n},m2=(e,o)=>{let t=d2(e);return(Id(t[0],Cd(o[0],o[2]))||Id(o[0],Cd(t[0],t[2])))&&(Id(t[1],Cd(o[1],o[3]))||Id(o[1],Cd(t[1],t[3])))},p2=({elements:e,bounds:o,type:t,errorMargin:r=0})=>{x_(o)&&(o=f_(o,g_(e)));let n=[o[0]-r,o[1]-r,o[2]+r,o[3]+r],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?m2(a,n):t==="inside"?Jh(a,n):Jh(a,n,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);w_(a)&&a.containerId&&i.add(a.containerId),b_(a)&&(a.startBinding&&i.add(a.startBinding.elementId),a.endBinding&&i.add(a.endBinding?.elementId))}}return e.filter(a=>i.has(a.id))};import{arrayToMap as Bfe,isShallowEqual as S_}from"@haoxin-web/excalidraw-common";var C_=function(){let e=null,o=null,t=null,r=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let m={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let f=u.indexOf(l.editingGroupId);f>-1&&(u=u.slice(0,f))}if(u.length>0){let f=u[u.length-1];m[f]=!0}}let c={},d=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>m[b]);return f&&(p[u.id]=!0,Array.isArray(c[f])?c[f].push(u.id):c[f]=[u.id]),p},{});for(let p of Object.keys(c))c[p].length<2&&m[p]&&(m[p]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:m,selectedElementIds:Qh({...l.selectedElementIds,...d},s)},t},n=(i,a,l,s)=>{let m=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):eg(a,i);return m.length?r(m,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:Qh(i.selectedElementIds,l)}};return n.clearCache=()=>{o=null,e=null,t=null},n}();var Wfe=function(){let e=null,o=null,t=null,r=(n,i)=>(t!=null&&n===e&&i.selectedElementIds===o||(t=n.some(a=>i.selectedElementIds[a.id]),e=n,o=i.selectedElementIds),t);return r.clearCache=()=>{e=null,o=null,t=null},r}(),eg=(e,o,t)=>{let r=new Set,n=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){n.push(i),r.add(i.id);continue}if(t?.includeBoundTextElement&&Oi(i)&&o.selectedElementIds[i?.containerId]){n.push(i),r.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return n.forEach(a=>{yd(a)&&u2(e,a.id).forEach(l=>!r.has(l.id)&&i.push(l)),i.push(a)}),i}return n};var Qh=(e,o)=>S_(o.selectedElementIds,e)?o.selectedElementIds:e;var u2=(e,o)=>{let t=[];for(let r of e.values())r.frameId===o&&t.push(r);return t};var L_=typeof document<"u"?document.createElement("img"):{src:""};L_.src=`data:${g2.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;var P_=typeof document<"u"?document.createElement("img"):{src:""};P_.src=`data:${g2.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 f2=new WeakMap;var A_=new WeakMap([]);function b2(e){let o=__(e),t=new Path2D(o);return A_.set(e,t),t}function __(e){let o=e.simulatePressure?e.points:e.points.length?e.points.map(([r,n],i)=>[r,n,e.pressures[i]]):[[0,0,.5]],t={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:r=>Math.sin(r*Math.PI/2),last:!!e.lastCommittedPoint};return R_(M_(o,t))}function h2(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var D_=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function R_(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,r,n,i)=>(n===o?t.push(r,h2(r,i[0]),"L",i[0],"Z"):t.push(r,h2(r,i[n+1])),t),["M",e[0],"Q"]).join(" ").replace(D_,"$1")}var x2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="triangle"||e==="pentagon"||e==="image";var ut=class ut{};I(ut,"rg",new H_),I(ut,"cache",new WeakMap),I(ut,"get",o=>ut.cache.get(o)),I(ut,"set",(o,t)=>ut.cache.set(o,t)),I(ut,"delete",o=>ut.cache.delete(o)),I(ut,"destroy",()=>{ut.cache=new WeakMap}),I(ut,"generateElementShape",(o,t)=>{let r=t?.isExporting?void 0:ut.get(o);if(r!==void 0)return r;f2.delete(o);let n=W_(o,ut.rg,t||{isExporting:!1,canvasBackgroundColor:z_.white,embedsValidationStatus:null});return ut.cache.set(o,n),n});var Hi=ut,G_=e=>[8,8+e],w2=e=>[1.5,6+e];function U_(e){let o=e.roughness,t=Math.max(e.width,e.height),r=Math.min(e.width,e.height);return r>=20&&t>=50||r>=15&&e.roundness&&x2(e.type)||Dr(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var pt=(e,o=!1)=>{let t={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?G_(e.strokeWidth):e.strokeStyle==="dotted"?w2(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:U_(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<F_.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"triangle":case"pentagon":case"callout":case"ellipse":return t.fillStyle=e.fillStyle,t.fill=gl(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(t.curveFitting=1),t;case"hollow_arrow":case"hollow_double_arrow":return t.fill=void 0,t.fillStyle=void 0,t;case"line":case"freedraw":return Ed(e.points)&&(t.fillStyle=e.fillStyle,t.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),t;case"arrow":return t;default:throw new Error(`Unimplemented type ${e.type}`)}},tg=(e,o,t)=>Uh(e)&&(o||jw(e)&&t?.get(e.id)!==!0)&&gl(e.backgroundColor)&&gl(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:qw(e)?{...e,strokeColor:gl(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:gl(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,y2=(e,o,t,r,n,i,a)=>{let l=qh(e,o,t,r);if(l===null)return[];let s=(m,c)=>{if(m===null)return[];let[,,d,p,u,f]=m;return[n.line(d,p,u,f,c)]};switch(r){case"dot":case"circle":case"circle_outline":{let[m,c,d]=l;return delete i.strokeLineDash,[n.circle(m,c,d,{...i,fill:r==="circle_outline"?void 0:e.strokeColor,fillStyle:r==="circle_outline"?void 0:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[m,c,d,p,u,f]=l;return delete i.strokeLineDash,[n.polygon([[m,c],[d,p],[u,f],[m,c]],{...i,fill:r==="triangle_outline"?void 0:e.strokeColor,fillStyle:r==="triangle_outline"?void 0:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[m,c,d,p,u,f,b,x]=l;return delete i.strokeLineDash,[n.polygon([[m,c],[d,p],[u,f],[b,x],[m,c]],{...i,fill:r==="diamond_outline"?void 0:e.strokeColor,fillStyle:r==="diamond_outline"?void 0:"solid",roughness:Math.min(1,i.roughness||0)})]}case"crowfoot_one":return s(l,i);case"bar":case"arrow":case"crowfoot_many":case"crowfoot_one_or_many":default:{let[m,c,d,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=w2(e.strokeWidth-1);i.strokeLineDash=[b[0],b[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(d,p,m,c,i),n.line(u,f,m,c,i),...r==="crowfoot_one_or_many"?s(qh(e,o,t,"crowfoot_one"),i):[]]}}};var W_=(e,o,{isExporting:t,canvasBackgroundColor:r,embedsValidationStatus:n})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":case"callout":{let i;if(e.roundness){let a=e.width,l=e.height,s=Bi(Math.min(a,l),e);i=o.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,pt(tg(e,t,n),!0))}else if(e.type==="callout"){let a=e.width,l=e.height,s=a*.34,m=a*.22,c=a*.12,d=l+l*.18,p=pt(tg(e,t,n),!1);p.disableMultiStroke=!0,p.disableMultiStrokeFill=!0;let u=`M 0 0 L ${a} 0 L ${a} ${l} L ${s} ${l} L ${c} ${d} L ${m} ${l} L 0 ${l} L 0 0 Z`;i=o.path(u,p)}else i=o.rectangle(0,0,e.width,e.height,pt(tg(e,t,n),!1));return i}case"diamond":{let i,[a,l,s,m,c,d,p,u]=Gh(e);if(e.roundness){let f=Bi(Math.abs(a-p),e),b=Bi(Math.abs(m-l),e);i=o.path(`M ${a+f} ${l+b} L ${s-f} ${m-b}
9
9
  C ${s} ${m}, ${s} ${m}, ${s-f} ${m+b}
10
10
  L ${c+f} ${d-b}
11
11
  C ${c} ${d}, ${c} ${d}, ${c-f} ${d-b}
12
12
  L ${p+f} ${u+b}
13
13
  C ${p} ${u}, ${p} ${u}, ${p+f} ${u-b}
14
14
  L ${a-f} ${l+b}
15
- C ${a} ${l}, ${a} ${l}, ${a+f} ${l+b}`,pt(e,!0))}else i=o.polygon([[a,l],[s,m],[c,d],[p,u]],pt(e));return i}case"triangle":{let i,[a,l,s,m,c,d]=a2(e);if(e.roundness){let p=Bi(Math.min(e.width,e.height),e);i=o.path(`M ${a+p*.5} ${l+p}
15
+ C ${a} ${l}, ${a} ${l}, ${a+f} ${l+b}`,pt(e,!0))}else i=o.polygon([[a,l],[s,m],[c,d],[p,u]],pt(e));return i}case"triangle":{let i,[a,l,s,m,c,d]=l2(e);if(e.roundness){let p=Bi(Math.min(e.width,e.height),e);i=o.path(`M ${a+p*.5} ${l+p}
16
16
  L ${s-p} ${m-p}
17
17
  Q ${s} ${m} ${s-p} ${m}
18
18
  L ${c+p} ${d}
19
19
  Q ${c} ${d} ${c+p} ${d-p}
20
20
  L ${a-p*.5} ${l+p}
21
21
  Q ${a} ${l} ${a+p*.5} ${l+p}
22
- Z`,pt(e,!0))}else i=o.polygon([[a,l],[s,m],[c,d]],pt(e));return i}case"pentagon":{let i,a=l2(e),l=[];for(let s=0;s<a.length;s+=2)l.push([a[s],a[s+1]]);return e.roundness,i=o.polygon(l,pt(e)),i}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,pt(e));case"hollow_arrow":{let i=e.width,a=e.height,l=Math.max(i*.25,20),s=Math.max(a*.3,8),m=Math.min(s,a*.6),c=[[0,a/2-m/2],[i-l,a/2-m/2],[i-l,0],[i,a/2],[i-l,a],[i-l,a/2+m/2],[0,a/2+m/2]];return o.polygon(c,pt(e))}case"hollow_double_arrow":{let i=e.width,a=e.height,l=Math.max(i*.2,15),s=Math.max(a*.3,8),m=Math.min(s,a*.6),c=Math.min(l,i*.4),d=[[c,0],[0,a/2],[c,a],[c,a/2+m/2],[i-c,a/2+m/2],[i-c,a],[i,a/2],[i-c,0],[i-c,a/2-m/2],[c,a/2-m/2]];return o.polygon(d,pt(e))}case"line":case"arrow":{let i,a=pt(e),l=e.points.length?e.points:[B_(0,0)];if(pl(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(Y_(l,16),pt(e,!0))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(l)),i=[]):e.roundness?i=[o.curve(l,a)]:a.fill?i=[o.polygon(l,a)]:i=[o.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:m="arrow"}=e;if(s!==null){let c=E2(e,i,"start",s,o,a,r);i.push(...c)}if(m!==null){let c=E2(e,i,"end",m,o,a,r);i.push(...c)}}return i}case"freedraw":{let i;if(f2(e),Ed(e.points)){let a=N_(e.points,.75);i=o.curve(a,{...pt(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return O_(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},Y_=(e,o)=>{let t=[];for(let n=1;n<e.length-1;n+=1){let i=e[n-1],a=e[n+1],l=e[n],s=vd(l,i),m=vd(a,l),c=Math.min(o,x2(e[n],a)/2,x2(e[n],i)/2);s?i[0]<l[0]?t.push([e[n][0]-c,e[n][1]]):t.push([e[n][0]+c,e[n][1]]):i[1]<l[1]?t.push([e[n][0],e[n][1]-c]):t.push([e[n][0],e[n][1]+c]),t.push(e[n]),m?a[0]<l[0]?t.push([e[n][0]-c,e[n][1]]):t.push([e[n][0]+c,e[n][1]]):a[1]<l[1]?t.push([e[n][0],e[n][1]-c]):t.push([e[n][0],e[n][1]+c])}let r=[`M ${e[0][0]} ${e[0][1]}`];for(let n=0;n<t.length;n+=3)r.push(`L ${t[n][0]} ${t[n][1]}`),r.push(`Q ${t[n+1][0]} ${t[n+1][1]}, ${t[n+2][0]} ${t[n+2][1]}`);return r.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),r.join(" ")};var w2=(e,o,t=!1)=>{let r=!1;for(let n in o){let i=o[n];if(typeof i<"u"){if(e[n]===i&&(typeof i!="object"||i===null))continue;r=!0}}return!r&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??V_(),updated:X_()}};import{jsx as T2}from"react/jsx-runtime";var Wi=F({name:"toggleLinearEditor",category:Pe.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&n.length===1&&Z_(n[0])&&!K_(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];tg(n,"No selected element found"),tg(o.selectedLinearElement,"No selected linear element found"),tg(n.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:v2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=h(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return T2(z,{type:"button",icon:_0,title:n,"aria-label":n,onClick:()=>o(null)})}}),Fbe=F({name:"togglePolygon",category:Pe.elements,icon:Jm,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!Ui(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return n.length>0&&n.every(i=>Ui(i)&&i.points.length>=4)},perform(e,o,t,r){let n=r.scene.getSelectedElements(o);if(n.some(s=>!Ui(s)))return!1;let i=n,a=i.some(s=>!s.polygon),l=$_(i);return{elements:e.map(s=>!l.has(s.id)||!Ui(s)?s:w2(s,{backgroundColor:a?s.backgroundColor:"transparent",...j_(s,a)})),appState:o,captureUpdate:v2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(a=>!Ui(a)||!a.polygon||a.points.length<3))return null;let n=r.every(a=>Ui(a)&&a.polygon),i=h(n?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return T2(qn,{icon:Jm,title:i,"aria-label":i,active:n,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as I2,CANVAS_SEARCH_TAB as C2,CLASSES as q_,DEFAULT_SIDEBAR as S2}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as J_}from"@haoxin-web/excalidraw-element";var ml=F({name:"searchMenu",icon:Ft,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openDialog)return!1;if(o.openSidebar?.name===S2.name&&o.openSidebar.tab===C2){let n=r.excalidrawContainerValue.container?.querySelector(`.${q_.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...o,openSidebar:{name:S2.name,tab:C2},openDialog:null},captureUpdate:J_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[I2.CTRL_OR_CMD]&&e.key===I2.F});import{isImageElement as Q_}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as eD}from"@haoxin-web/excalidraw-element";import{jsx as tD}from"react/jsx-runtime";var og=F({name:"cropEditor",label:"helpDialog.cropStart",icon:xp,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:n.id},captureUpdate:eD.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&Q_(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=h("helpDialog.cropStart");return tD(z,{type:"button",icon:xp,title:r,"aria-label":r,onClick:()=>o(null)})}});import{getNonDeletedElements as oD}from"@haoxin-web/excalidraw-element";import{mutateElement as rD}from"@haoxin-web/excalidraw-element";import{newFrameElement as nD}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as Sd}from"@haoxin-web/excalidraw-element";import{addElementsToFrame as iD,removeAllElementsFromFrame as aD}from"@haoxin-web/excalidraw-element";import{getFrameChildren as lD}from"@haoxin-web/excalidraw-element";import{KEYS as k2,updateActiveTool as M2}from"@haoxin-web/excalidraw-common";import{getElementsInGroup as sD}from"@haoxin-web/excalidraw-element";import{getCommonBounds as cD}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as yn}from"@haoxin-web/excalidraw-element";var L2=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&Sd(t[0])},P2=F({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(Sd(n)){let i=lD(oD(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:yn.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:yn.EVENTUALLY}},predicate:(e,o,t,r)=>L2(o,r)}),A2=F({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return Sd(n)?{elements:aD(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:yn.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:yn.EVENTUALLY}},predicate:(e,o,t,r)=>L2(o,r)}),X0e=F({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:yn.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),K0e=F({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Vn,viewMode:!1,perform:(e,o,t,r)=>{let n=M2(o,{type:"frame"});return Ot(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:M2(o,{type:"frame"})},captureUpdate:yn.EVENTUALLY}},keyTest:e=>!e[k2.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===k2.F}),_2=F({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=J(e,o);return n.length>0&&!n.some(i=>Sd(i))},perform:(e,o,t,r)=>{let n=J(e,o),i=r.scene.getNonDeletedElementsMap(),[a,l,s,m]=cD(n,i),c=16,d=nD({x:a-c,y:l-c,width:s-a+c*2,height:m-l+c*2});if(o.editingGroupId){let u=sD(n,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);rD(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:iD([...r.scene.getElementsIncludingDeleted(),d],n,d,o),appState:{selectedElementIds:{[d.id]:!0}},captureUpdate:yn.IMMEDIATELY}}});import{isWindows as fD,KEYS as bl,matchKey as ig,arrayToMap as D2}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as ng}from"@haoxin-web/excalidraw-element";import{orderByFractionalIndex as bD}from"@haoxin-web/excalidraw-element";import{Emitter as dD}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as mD,StoreChange as pD,StoreDelta as uD}from"@haoxin-web/excalidraw-element";var Yi=class extends uD{applyTo(o,t,r){let[n,i]=this.elements.applyTo(o,r.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,n);return[n,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,r,n){return super.applyLatestChanges(o,t,r,n)}},wn=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},fl=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new dD);I(this,"undoStack",[]);I(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof Yi)return;let t=Yi.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new wn(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r))}perform(o,t,r,n){try{let i=r();if(i===null)return;let a=mD.IMMEDIATELY,l=this.store.snapshot,s=o,m=t,c=!1;for(;i;){try{[s,m,c]=i.applyTo(s,m,l);let d=l.elements,p=l.maybeClone(a,s,m),u=pD.create(l,p),f=Yi.applyLatestChanges(i,d,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{n(i)}if(c)break;i=r()}return[s,m]}finally{this.onHistoryChangedEmitter.trigger(new wn(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let r=Yi.inverse(t);return o.push(r)}};import{useEffect as hD,useState as gD}from"react";var rg=(e,o)=>{let[t,r]=gD(o);return hD(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as F2}from"react/jsx-runtime";var R2=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:ng.EVENTUALLY};let[n,i]=r,a=bD(Array.from(n.values()));return{appState:i,elements:a,captureUpdate:ng.NEVER}}return{captureUpdate:ng.EVENTUALLY}},N2=e=>({name:"undo",label:"buttons.undo",icon:op,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>R2(n,t,()=>e.undo(D2(o),t)),keyTest:o=>o[bl.CTRL_OR_CMD]&&ig(o,bl.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:r}=rg(e.onHistoryChangedEmitter,new wn(e.isUndoStackEmpty,e.isRedoStackEmpty));return F2(z,{type:"button",icon:op,"aria-label":h("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-undo"})}}),B2=e=>({name:"redo",label:"buttons.redo",icon:rp,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>R2(n,t,()=>e.redo(D2(o),t)),keyTest:o=>o[bl.CTRL_OR_CMD]&&o.shiftKey&&ig(o,bl.Z)||fD&&o.ctrlKey&&!o.shiftKey&&ig(o,bl.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:r}=rg(e.onHistoryChangedEmitter,new wn(e.isUndoStackEmpty,e.isRedoStackEmpty));return F2(z,{type:"button",icon:rp,"aria-label":h("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-redo"})}});import{getFontString as xD}from"@haoxin-web/excalidraw-common";import{newElementWith as ED}from"@haoxin-web/excalidraw-element";import{measureText as yD}from"@haoxin-web/excalidraw-element";import{isTextElement as O2}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as wD}from"@haoxin-web/excalidraw-element";var z2=F({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=J(e,o);return n.length===1&&O2(n[0])&&!n[0].autoResize},perform:(e,o,t,r)=>{let n=J(e,o);return{appState:o,elements:e.map(i=>{if(i.id===n[0].id&&O2(i)){let a=yD(i.originalText,xD(i),i.lineHeight);return ED(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:wD.IMMEDIATELY}}});import{CODES as vD,KEYS as TD}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as ID}from"@haoxin-web/excalidraw-element";var ag=F({name:"viewMode",label:"labels.viewMode",icon:Kn,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:ID.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[TD.CTRL_OR_CMD]&&e.altKey&&e.code===vD.R});import{isPromiseLike as CD}from"@haoxin-web/excalidraw-common";import{jsx as SD}from"react/jsx-runtime";var lg=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&ae(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},kd=class{constructor(o,t,r,n){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"renderAction",(o,t)=>{let r=this.app.props.UIOptions.canvasActions,n=this.getElementsIncludingDeleted(),i=this.getAppState(),a=this.actions[o];if(a&&"PanelComponent"in a&&(!(o in r)||r[o])&&(!a.predicate||a.predicate(n,i,this.app.props,this.app))){let l=a.PanelComponent;l.displayName="PanelComponent";let s=m=>{lg(a,"ui",i,n,this.app,m),this.updater(a.perform(this.getElementsIncludingDeleted(),this.getAppState(),m,this.app))};return SD(l,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=i=>{if(CD(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=r,this.app=n}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,r=this.getElementsIncludingDeleted(),n=this.getAppState(),i=this.app.props,a=Object.values(this.actions).sort((m,c)=>(c.keyPriority||0)-(m.keyPriority||0)).filter(m=>(m.name in t?t[m.name]:!0)&&m.keyTest&&(!m.predicate||m.predicate(r,n,i,this.app))&&m.keyTest(o,n,r,this.app));if(a.length!==1)return a.length>1&&console.warn("Canceling as multiple actions match this shortcut",a),!1;let l=a[0];if(n.viewModeEnabled&&l.viewMode!==!0)return!1;let s=null;return lg(l,"keyboard",n,r,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(a[0].perform(r,n,s,this.app)),!0}executeAction(o,t="api",r=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();lg(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var Md=class{constructor(){I(this,"targets",new WeakMap);I(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let r=this.targets.get(o);if(!r)return;let n=this.onFrame(r,t);!r.stopped&&!n?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var sg=e=>{let o=Array.from(e.values());return{x:H2(o,t=>t.x)/o.length,y:H2(o,t=>t.y)/o.length}},cg=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),H2=(e,o)=>e.reduce((t,r)=>t+o(r),0);import{pointFrom as W,pointRotateRads as Rr,rangeInclusive as qt,rangeIntersection as Ld,rangesOverlap as Pd}from"@haoxin-web/excalidraw-math";import{TOOL_TYPE as vn,KEYS as G2}from"@haoxin-web/excalidraw-common";import{getCommonBounds as dg,getDraggedElementsBounds as mg,getElementAbsoluteCoords as kD}from"@haoxin-web/excalidraw-element";import{isBoundToContainer as V2}from"@haoxin-web/excalidraw-element";import{getMaximumGroups as X2}from"@haoxin-web/excalidraw-element";import{getSelectedElements as MD,getVisibleAndNonSelectedElements as K2}from"@haoxin-web/excalidraw-element";var LD=8,U2=99999,Ad=e=>LD/e,vt=class vt{};I(vt,"referenceSnapPoints",null),I(vt,"visibleGaps",null),I(vt,"setReferenceSnapPoints",o=>{vt.referenceSnapPoints=o}),I(vt,"getReferenceSnapPoints",()=>vt.referenceSnapPoints),I(vt,"setVisibleGaps",o=>{vt.visibleGaps=o}),I(vt,"getVisibleGaps",()=>vt.visibleGaps),I(vt,"destroy",()=>{vt.referenceSnapPoints=null,vt.visibleGaps=null});var Jt=vt,Nr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,tr=({event:e,app:o,selectedElements:t})=>{if(e){let r=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||r)&&(o.state.objectsSnapModeEnabled&&!e[G2.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[G2.CTRL_OR_CMD]&&!Nr(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},PD=(e,o,t=.01)=>Math.abs(e-o)<=t,xl=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,m,c,d,p]=kD(a,o);n&&(l+=n.x,m+=n.x,d+=n.x,s+=n.y,c+=n.y,p+=n.y);let u=(m-l)/2,f=(c-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=Rr(W(l,s+f),W(d,p),a.angle),x=Rr(W(l+u,s),W(d,p),a.angle),w=Rr(W(m,s+f),W(d,p),a.angle),E=Rr(W(l+u,c),W(d,p),a.angle),y=W(d,p);i=t?[b,x,w,E]:[b,x,w,E,y]}else{let b=Rr(W(l,s),W(d,p),a.angle),x=Rr(W(m,s),W(d,p),a.angle),w=Rr(W(l,c),W(d,p),a.angle),E=Rr(W(m,c),W(d,p),a.angle),y=W(d,p);i=t?[b,x,w,E]:[b,x,w,E,y]}}else if(e.length>1){let[a,l,s,m]=mg(e,n??{x:0,y:0}),c=s-a,d=m-l,p=W(a,l),u=W(s,l),f=W(a,m),b=W(s,m),x=W(a+c/2,l+d/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>W(Re(a[0]),Re(a[1])))},Z2=(e,o,t,r)=>K2(e,o,t,r),$2=(e,o,t,r)=>{let n=Z2(e,o,t,r),i=X2(n,r).filter(d=>!(d.length===1&&V2(d[0]))).map(d=>dg(d).map(p=>Re(p))),a=i.sort((d,p)=>d[0]-p[0]),l=[],s=0;e:for(let d=0;d<a.length;d++){let p=a[d];for(let u=d+1;u<a.length;u++){if(++s>U2)break e;let f=a[u],[,b,x,w]=p,[E,y,,v]=f;x<E&&Pd(qt(b,w),qt(y,v))&&l.push({startBounds:p,endBounds:f,startSide:[W(x,b),W(x,w)],endSide:[W(E,y),W(E,v)],length:E-x,overlap:Ld(qt(b,w),qt(y,v))})}}let m=i.sort((d,p)=>d[1]-p[1]),c=[];s=0;e:for(let d=0;d<m.length;d++){let p=m[d];for(let u=d+1;u<m.length;u++){if(++s>U2)break e;let f=m[u],[b,,x,w]=p,[E,y,v]=f;w<y&&Pd(qt(b,x),qt(E,v))&&c.push({startBounds:p,endBounds:f,startSide:[W(b,w),W(x,w)],endSide:[W(E,y),W(v,y)],length:y-w,overlap:Ld(qt(b,x),qt(E,v))})}}return{horizontalGaps:l,verticalGaps:c}},W2=(e,o,t,r,n,i,a)=>{if(!tr({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=Jt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:m}=l,[c,d,p,u]=mg(e,o).map(x=>Re(x)),f=(c+p)/2,b=(d+u)/2;for(let x of s){if(!Pd(qt(d,u),x.overlap))continue;let w=x.startSide[0][0]+x.length/2,E=Re(w-f);if(x.length>p-c&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(n.length=0),a.x=Math.abs(E);let L={type:"gap",direction:"center_horizontal",gap:x,offset:E};n.push(L);continue}let[,,v]=x.endBounds,C=c-v,S=Re(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(n.length=0),a.x=Math.abs(S);let L={type:"gap",direction:"side_right",gap:x,offset:S};n.push(L);continue}let[P,,,]=x.startBounds,M=P-p,R=Re(M-x.length);if(Math.abs(R)<=a.x){Math.abs(R)<a.x&&(n.length=0),a.x=Math.abs(R);let L={type:"gap",direction:"side_left",gap:x,offset:R};n.push(L);continue}}for(let x of m){if(!Pd(qt(c,p),x.overlap))continue;let w=x.startSide[0][1]+x.length/2,E=Re(w-b);if(x.length>u-d&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let L={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(L);continue}let[,v,,]=x.startBounds,C=v-u,S=Re(C-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let L={type:"gap",direction:"side_top",gap:x,offset:S};i.push(L);continue}let[,,,P]=x.endBounds,M=Re(d-P),R=x.length-M;if(Math.abs(R)<=a.y){Math.abs(R)<a.y&&(i.length=0),a.y=Math.abs(R);let L={type:"gap",direction:"side_bottom",gap:x,offset:R};i.push(L);continue}}}},j2=(e,o,t,r)=>{let n=Z2(e,o,t,r);return X2(n,r).filter(i=>!(i.length===1&&V2(i[0]))).flatMap(i=>xl(i,r))},Vi=(e,o,t,r,n,i,a)=>{if(!tr({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Jt.getReferenceSnapPoints();if(l)for(let s of o)for(let m of l){let c=m[0]-s[0],d=m[1]-s[1];Math.abs(c)<=a.x&&(Math.abs(c)<a.x&&(n.length=0),n.push({type:"point",points:[s,m],offset:c}),a.x=Math.abs(c)),Math.abs(d)<=a.y&&(Math.abs(d)<a.y&&(i.length=0),i.push({type:"point",points:[s,m],offset:d}),a.y=Math.abs(d))}},q2=(e,o,t,r,n)=>{let i=t.state,a=MD(e,i);if(!tr({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Re(o.x),o.y=Re(o.y);let l=[],s=[],m=Ad(i.zoom.value),c={x:m,y:m},d=xl(a,n,{dragOffset:o});Vi(a,d,t,r,l,s,c),W2(a,o,t,r,l,s,c);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};c.x=0,c.y=0,l.length=0,s.length=0;let u={x:Re(o.x+p.x),y:Re(o.y+p.y)};Vi(a,xl(a,n,{dragOffset:u}),t,r,l,s,c),W2(a,u,t,r,l,s,c);let f=pg(l,s),b=_D(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Re=e=>Math.round(e*10**6)/10**6,Y2=e=>{let o=new Map;for(let t of e){let r=t.join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},pg=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=Re(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>W(Re(a[0]),Re(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=Re(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>W(Re(a[0]),Re(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:Y2(i.map(a=>W(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:Y2(i.map(a=>W(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},AD=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[Re(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},_D=(e,o,t)=>{let[r,n,i,a]=mg(e,o),l=[];for(let s of t){let[m,c,d,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,w=Ld(qt(n,a),s.gap.overlap),E=Ld(qt(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[W(s.gap.startSide[0][0],y),W(r,y)]},{type:"gap",direction:"horizontal",points:[W(i,y),W(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[W(y,s.gap.startSide[0][1]),W(y,n)]},{type:"gap",direction:"vertical",points:[W(y,a),W(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[W(d,y),W(u,y)]},{type:"gap",direction:"horizontal",points:[W(b,y),W(r,y)]})}break}case"side_left":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[W(i,y),W(m,y)]},{type:"gap",direction:"horizontal",points:[W(d,y),W(u,y)]})}break}case"side_top":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[W(y,a),W(y,c)]},{type:"gap",direction:"vertical",points:[W(y,p),W(y,f)]})}break}case"side_bottom":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[W(y,p),W(y,f)]},{type:"gap",direction:"vertical",points:[W(y,x),W(y,n)]})}break}}}return AD(l.map(s=>({...s,points:s.points.map(m=>W(Re(m[0]),Re(m[1])))})))},ug=(e,o,t,r,n,i)=>{if(!tr({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!PD(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,m]=dg(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(m+=n.y));let c=[];if(i)switch(i){case"e":{c.push(W(s,l),W(s,m));break}case"w":{c.push(W(a,l),W(a,m));break}case"n":{c.push(W(a,l),W(s,l));break}case"s":{c.push(W(a,m),W(s,m));break}case"ne":{c.push(W(s,l));break}case"nw":{c.push(W(a,l));break}case"se":{c.push(W(s,m));break}case"sw":{c.push(W(a,m));break}}let d=Ad(t.state.zoom.value),p={x:d,y:d},u=[],f=[];Vi(o,c,t,r,u,f,p);let b={x:u[0]?.offset??0,y:f[0]?.offset??0};p.x=0,p.y=0,u.length=0,f.length=0;let[x,w,E,y]=dg(e).map(S=>Re(S)),v=[W(x,w),W(x,y),W(E,w),W(E,y)];Vi(e,v,t,r,u,f,p);let C=pg(u,f);return{snapOffset:b,snapLines:C}},J2=(e,o,t,r,n,i)=>{if(!tr({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[W(r.x+n.x,r.y+n.y)],l=Ad(o.state.zoom.value),s={x:l,y:l},m=[],c=[];Vi([e],a,o,t,m,c,s);let d={x:m[0]?.offset??0,y:c[0]?.offset??0};s.x=0,s.y=0,m.length=0,c.length=0;let p=xl([e],i,{boundingBoxCorners:!0,omitCenter:!0});Vi([e],p,o,t,m,c,s);let u=pg(m,c);return{snapOffset:d,snapLines:u}},Q2=(e,o,t,r,n)=>{if(!tr({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=K2(e,[],o.state,n),a=Ad(o.state.zoom.value),l={x:a,y:a},s=[],m=[];for(let c of i){let d=xl([c],n);for(let p of d){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(m.length=0),m.push({type:"pointer",points:[p,W(p[0],t.y)],direction:"vertical"}),l.x=u);let f=p[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,W(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:m.length>0?m[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...m,...s]}},ev=e=>e===vn.rectangle||e===vn.ellipse||e===vn.diamond||e===vn.frame||e===vn.magicframe||e===vn.image||e===vn.text;import{pointFrom as _d}from"@haoxin-web/excalidraw-math";import{DEFAULT_FONT_FAMILY as DD,DEFAULT_FONT_SIZE as RD,TEXT_ALIGN as ND,VERTICAL_ALIGN as BD,getSizeFromPoints as FD,randomId as OD,arrayToMap as zD,assertNever as tv,cloneJSON as nv,getFontString as HD,isDevEnv as GD,toBrandedType as UD,getLineHeight as WD}from"@haoxin-web/excalidraw-common";import{bindLinearElement as ov}from"@haoxin-web/excalidraw-element";import{newArrowElement as YD,newElement as El,newFrameElement as VD,newImageElement as XD,newLinearElement as KD,newMagicFrameElement as ZD,newTextElement as Rd}from"@haoxin-web/excalidraw-element";import{measureText as $D,normalizeText as jD}from"@haoxin-web/excalidraw-element";import{isArrowElement as qD}from"@haoxin-web/excalidraw-element";import{syncInvalidIndices as JD}from"@haoxin-web/excalidraw-element";import{redrawTextBoundingBox as QD}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as eR}from"@haoxin-web/excalidraw-element";import{getCommonBounds as tR}from"@haoxin-web/excalidraw-element";import{Scene as oR}from"@haoxin-web/excalidraw-element";var Dd={width:100,height:0},Qt=100,rR=(e,o,t)=>{let r=Rd({x:0,y:0,textAlign:ND.CENTER,verticalAlign:BD.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),QD(r,e,t),[e,r]},rv=(e,o,t,r,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let c=o?.width??Qt,d=o?.height??Qt,p;o.id&&(p=r.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-c,f=o.y||e.y-d/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=Rd({x:u,y:f,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=El({x:u,y:f,width:c,height:d,...p,...o,type:b});break}default:tv(e,`Unhandled element start type "${o.type}"`,!0)}ov(e,i,"start",n)}}if(t){let c=t?.height??Qt,d=t?.width??Qt,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,f=t.y||e.y-c/2,b=p?p.type:t.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=Rd({x:u,y:f,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=El({x:u,y:f,width:d,height:c,...p,...t,type:b});break}default:tv(e,`Unhandled element end type "${b}"`,!0)}ov(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,m=nv(e.points);return e.points[l][0]>e.points[l-1][0]&&(m[0][0]=s,m[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(m[0][0]=-s,m[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(m[0][1]=s,m[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(m[0][1]=-s,m[l][1]+=s),Object.assign(e,eR.getNormalizeElementPointsAndCoords({...e,points:m})),{linearElement:e,startBoundElement:i,endBoundElement:a}},hg=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>JD(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>UD(zD(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Xi=(e,o)=>{if(!e)return[];let t=nv(e),r=new hg,n=new Map,i=new Map;for(let s of t){let m,c=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:OD()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||Qt,u=s?.label?.text&&s.height===void 0?0:s?.height||Qt;m=El({...s,width:p,height:u});break}case"line":{let p=s.width||Dd.width,u=s.height||Dd.height;m=KD({width:p,height:u,points:[_d(0,0),_d(p,u)],...s});break}case"arrow":{let p=s.width||Dd.width,u=s.height||Dd.height;m=YD({width:p,height:u,endArrowhead:"arrow",points:[_d(0,0),_d(p,u)],...s,type:"arrow"}),Object.assign(m,FD(m.points));break}case"text":{let p=s?.fontFamily||DD,u=s?.fontSize||RD,f=s?.lineHeight||WD(p),b=s.text??"",x=jD(b),w=$D(x,HD({fontFamily:p,fontSize:u}),f);m=Rd({width:w.width,height:w.height,fontFamily:p,fontSize:u,...s});break}case"image":{m=XD({width:s?.width||Qt,height:s?.height||Qt,...s});break}case"frame":{m=VD({x:0,y:0,...s});break}case"magicframe":{m=ZD({x:0,y:0,...s});break}case"triangle":{m=El({width:s?.width||Qt,height:s?.height||Qt,...s,type:"triangle"});break}case"pentagon":{m=El({width:s?.width||Qt,height:s?.height||Qt,...s,type:"pentagon"});break}case"freedraw":case"iframe":case"embeddable":{m=s;break}default:continue}r.getElement(m.id)?console.error(`Duplicate id found for ${m.id}`):(r.add(m),n.set(m.id,s),c&&i.set(c,m.id))}let a=r.getElementsMap(),l=new oR(a);for(let[s,m]of n){let c=r.getElement(s);switch(m.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(m.label?.text){let[d,p]=rR(c,m?.label,l);if(r.add(d),r.add(p),qD(d)){let u=m.type==="arrow"?m?.start:void 0,f=m.type==="arrow"?m?.end:void 0;if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}if(f&&f.id){let E=i.get(f.id);E&&Object.assign(f,{id:E})}let{linearElement:b,startBoundElement:x,endBoundElement:w}=rv(d,u,f,r,l);d=b,r.add(b),r.add(x),r.add(w)}}else switch(m.type){case"arrow":{let{start:d,end:p}=m;if(d&&d.id){let x=i.get(d.id);Object.assign(d,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=rv(c,d,p,r,l);r.add(u),r.add(f),r.add(b);break}}break}}}for(let[s,m]of n){if(m.type!=="frame"&&m.type!=="magicframe")continue;let c=r.getElement(s);if(!c)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let d=[];m.children.forEach(C=>{let S=i.get(C);if(!S)throw new Error(`Element with ${C} wasn't mapped correctly`);let P=r.getElement(S);if(!P)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(P,{frameId:c.id}),P?.boundElements?.forEach(M=>{let R=r.getElement(M.id);if(!R)throw new Error(`Bound element with id ${M.id} doesn't exist`);Object.assign(R,{frameId:c.id}),d.push(R)}),d.push(P)});let[p,u,f,b]=tR(d),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let w=c?.x||p,E=c?.y||u,y=c?.width||f-p,v=c?.height||b-u;Object.assign(c,{x:w,y:E,width:y,height:v}),GD()&&m.children.length&&(c?.x||c?.y||c?.width||c?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return r.getElements()};import{isElementInViewport as DR}from"@haoxin-web/excalidraw-element";import{memoize as RR,toBrandedType as NR}from"@haoxin-web/excalidraw-common";import{pointFrom as mR,pointsEqual as pR}from"@haoxin-web/excalidraw-math";import Bd from"open-color";import{arrayToMap as uR,DEFAULT_TRANSFORM_HANDLE_SPACING as vg,FRAME_STYLE as mv,invariant as pv,THEME as hR,throttleRAF as gR}from"@haoxin-web/excalidraw-common";import{FIXED_BINDING_DISTANCE as fg,maxBindingGap as xv}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as Br}from"@haoxin-web/excalidraw-element";import{getOmitSidesForDevice as bg,getTransformHandles as fR,getTransformHandlesFromCoords as bR,shouldShowBoundingBox as xR}from"@haoxin-web/excalidraw-element";import{isElbowArrow as yl,isFrameLikeElement as uv,isImageElement as hv,isLinearElement as ER,isLineElement as yR,isTextElement as gv}from"@haoxin-web/excalidraw-element";import{renderSelectionElement as wR}from"@haoxin-web/excalidraw-element";import{getElementsInGroup as yg,getSelectedGroupIds as vR,isSelectedViaGroup as TR,selectGroupsFromGivenElements as IR}from"@haoxin-web/excalidraw-element";import{getCommonBounds as wg,getElementAbsoluteCoords as wl}from"@haoxin-web/excalidraw-element";import{pointFrom as ht}from"@haoxin-web/excalidraw-math";import{THEME as nR}from"@haoxin-web/excalidraw-common";var iR="#ff6b6b",aR="#ff0000",iv=1,av=2,lv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===nR.LIGHT||o.zenModeEnabled?iR:aR,r=(o.zenModeEnabled?iv*1.5:iv)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let n of o.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=t,sR(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,cR(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,lR(n,e,o));e.restore()},lR=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];eo(r,n,o)}for(let r of e.points)sv(r,t,o)},sR=(e,o,t)=>{sv(e.points[0],t,o),t.zenModeEnabled||eo(e.points[0],e.points[1],o)},sv=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?av*1.5:av)/t.zoom.value;r.beginPath(),r.moveTo(e-n,o-n),r.lineTo(e+n,o+n),r.moveTo(e+n,o-n),r.lineTo(e-n,o+n),r.stroke(),r.restore()},eo=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},cR=(e,o,t,r,n)=>{let i=8/r.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];r.zenModeEnabled||eo(ht(e[0],e[1]-i),ht(e[0],e[1]+i),n),eo(ht(s[0]-l,s[1]-a),ht(s[0]-l,s[1]+a),n),eo(ht(s[0]+l,s[1]-a),ht(s[0]+l,s[1]+a),n),r.zenModeEnabled||(eo(ht(o[0],o[1]-i),ht(o[0],o[1]+i),n),eo(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||eo(ht(e[0]-i,e[1]),ht(e[0]+i,e[1]),n),eo(ht(s[0]-a,s[1]-l),ht(s[0]+a,s[1]-l),n),eo(ht(s[0]-a,s[1]+l),ht(s[0]+a,s[1]+l),n),r.zenModeEnabled||(eo(ht(o[0]-i,o[1]),ht(o[0]+i,o[1]),n),eo(e,o,n))}};import{getGlobalCSSVariable as Nd}from"@haoxin-web/excalidraw-common";import{getCommonBounds as dR}from"@haoxin-web/excalidraw-element";var Ro=4,Ut=6,cv="rgba(0,0,0,0.3)",dv=(e,o,t,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,i,a,l]=dR(e),s=o/r.zoom.value,m=t/r.zoom.value,c={top:parseInt(Nd("sat"))||0,bottom:parseInt(Nd("sab"))||0,left:parseInt(Nd("sal"))||0,right:parseInt(Nd("sar"))||0},d=Uo().rtl,p=-r.scrollX+c.left,u=-r.scrollY+c.top,f=p+s-c.right,b=u+m-c.bottom,x=Math.min(n,p),w=Math.min(i,u),E=Math.max(a,f),y=Math.max(l,b),v=a-n,C=l-i,S=E-x,P=y-w,M=Math.max(Ro*2,c.left+c.right)+Ut*2,R=o*(s/S)-M,L=Math.max(Ro*2,c.top+c.bottom)+Ut*2,k=t*(m/P)-L,N=S>v?S*r.zoom.value/(R+M):o/(R+M),O=P>C?P*r.zoom.value/(k+L):t/(k+L);return{horizontal:p===x&&f===E?null:{x:Math.max(c.left,Ro)+Ut+(p-x)/S*o,y:t-Ut-Math.max(Ro,c.bottom),width:R,height:Ut,deltaMultiplier:N},vertical:u===w&&b===y?null:{x:d?Math.max(c.left,Ro):o-Ut-Math.max(c.right,Ro),y:Math.max(c.top,Ro)+Ut+(u-w)/P*t,width:Ut,height:k,deltaMultiplier:O}}},gg=(e,o,t)=>{let[r,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var CR=(e,o)=>{pv(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;pv(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Ev(t,e,o),e.restore()},SR=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(n))return;let i=Br.getElement(r,t);if(!i)return;let a=Br.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),Ev(a,e,o),e.restore()},Ev=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",ha(o,e[0],e[1],Br.POINT_HANDLE_SIZE/t.zoom.value,!1)},xg=(e,o,t,r,n,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),ha(e,t[0],t[1],(a?r*(o.selectedLinearElement?.isEditing?1.5:2):r)/o.zoom.value,!i,!a||n)},kR=(e,o,t,r)=>{let n=xv(o,o.width,o.height,r);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":_1(e,o,t,n);break;case"diamond":R1(e,n,o,t);break;case"ellipse":{let[i,a,l,s]=wl(o,t),m=l-i,c=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=n-fg,D1(e,m+n+fg,c+n+fg,i+m/2,a+c/2,o.angle);break}}},MR=(e,o,t,r)=>{let[n,i,a]=o,l=xv(a,a.width,a.height,r);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(m=>{let[c,d]=Br.getPointAtIndexGlobalCoordinates(n,m,t);ha(e,c,d,l,!0)})},yv=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:m,cy:c,dashed:d,activeEmbeddable:p}=t,u=a-n,f=l-i,x=(t.padding??vg*2)/o.zoom.value,w=8/o.zoom.value,E=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],d&&e.setLineDash([w,E+(w+E)*(y-1)]),e.lineDashOffset=(w+E)*v,ga(e,n-x,i-x,u+x*2,f+x*2,m,c,r);e.restore()},LR=(e,o,t,r)=>{let n=Array.isArray(t)?MR:kR;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},PR=(e,o,t,r)=>{let[n,i,a,l]=wl(t,r),s=a-n,m=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=mv.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),ga(e,n,i,s,m,n+s/2,i+m/2,t.angle,!1,mv.radius/o.zoom.value),e.restore()},fv=(e,o,t,r)=>{let{colors:n=["rgb(0,118,255)"],dashed:i=!1}=r||{},a=t.filter(c=>c.groupIds.length===0),l=t.filter(c=>c.groupIds.length>0),s=c=>{let[d,p,u,f]=wg(c);return{angle:0,x1:d,x2:u,y1:p,y2:f,selectionColors:n,dashed:i,cx:d+(u-d)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},m=c=>{let d=yg(t,c);return s(d)};Object.entries(IR(l,o)).filter(([c,d])=>d).map(([c,d])=>c).map(c=>m(c)).concat(a.map(c=>s([c]))).forEach(c=>yv(e,o,c))},Eg=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=Br.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=Br,a=o.selectedLinearElement?.isEditing?i:i/2,l=yl(t),s=yR(t);if(n.forEach((m,c)=>{if(l&&c!==0&&c!==n.length-1)return;let d=c>0&&(c!==n.length-1||!s||!t.polygon)&&pR(m,c===n.length-1?n[0]:n[c-1],2/o.zoom.value),p=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(c);s&&t.polygon&&!p&&c===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),xg(e,o,m,a,p,!1,d)}),yl(t)){let m=t.fixedSegments?.map(c=>c.index)||[];n.slice(0,-1).forEach((c,d)=>{Br.isSegmentTooShort(t,n[d+1],n[d],d,o.zoom)||xg(e,o,mR((c[0]+n[d+1][0])/2,(c[1]+n[d+1][1])/2),i/2,!1,!m.includes(d+1),!1)})}else Br.getEditorMidPoints(t,r,o).filter((c,d,p)=>c!==null&&!(yl(t)&&(d===0||d===p.length-1))).forEach(c=>{(o.selectedLinearElement?.isEditing||n.length===2)&&xg(e,o,c,i/2,!1,!0,!1)});e.restore()},bv=(e,o,t,r,n)=>{Object.keys(r).forEach(i=>{let a=r[i];if(a!==void 0){let[l,s,m,c]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?ha(e,l+m/2,s+c/2,m/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,m,c,2/t.zoom.value),e.fill(),e.stroke()):ga(e,l,s,m,c,l+m/2,s+c/2,n,!0),e.restore()}})},AR=(e,o,t,r,n)=>{let[i,a,,,l,s]=wl(r,n),m=3,c=20,d=m/t.zoom.value,p=d/2,u=l-i+d,f=s-a+d,b=Math.min(c/t.zoom.value,u),x=Math.min(c/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=d,[[[-u,-f],[0,p],[b,p],[p,0],[p,x]],[[u-p,-f],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,f],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,f],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(E=>{let[[y,v],[C,S],[P,M],[R,L],[k,N]]=E;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+C,v+S),e.lineTo(y+P,v+M),e.stroke(),e.beginPath(),e.moveTo(y+R,v+L),e.lineTo(y+k,v+N),e.stroke(),e.restore()}),e.restore()},_R=(e,o,t,r)=>{o.save();let n=vg*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,m=-(i/2+n),c=-(a/2+n);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=r,o.strokeRect(m,c,i,a),o.restore()},wv=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:r,allElementsMap:n,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[m,c]=ls(e,i),d=ss({canvas:e,scale:i,normalizedWidth:m,normalizedHeight:c});d.save(),d.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===b.id&&b&&(p=b)}),p&&Eg(d,a,p,o),a.selectionElement&&!a.isCropping)try{wR(a.selectionElement,d,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&gv(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&_R(b,d,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{LR(d,a,b,o)}),a.frameToHighlight&&PR(d,a,a.frameToHighlight,o),a.elementsToHighlight&&fv(d,a,a.elementsToHighlight),a.activeLockedId){let b=n.get(a.activeLockedId),x=b?[b]:yg(n,a.activeLockedId);fv(d,a,x,{colors:["#ced4da"],dashed:!0})}let u=r.some(b=>uv(b));if(r.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===r[0].id&&Eg(d,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(w=>w.id===b.elementId);b.segmentMidPointHoveredCoords?CR(d,a):(yl(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&SR(d,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=xR(r,a),x=r.length===1&&ER(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Eg(d,a,r[0],o);let w=l.selectionColor||Bd.black;if(b){let E=uR(r),y=[];for(let C of o.values()){let S=[],P=l.remoteSelectedElementIds.get(C.id);if(x&&yl(C)&&(C.startBinding||C.endBinding)||(E.has(C.id)&&!TR(a,C)&&S.push(w),P&&S.push(...P.map(M=>gn(M,a.collaborators.get(M))))),S.length){let[M,R,L,k,N,O]=wl(C,o,!0);y.push({angle:C.angle,x1:M,y1:R,x2:L,y2:k,selectionColors:C.locked?["#ced4da"]:S,dashed:!!P||C.locked,cx:N,cy:O,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||hv(C)?0:void 0})}}let v=C=>{let S=yg(o,C),[P,M,R,L]=wg(S);y.push({angle:0,x1:P,x2:R,y1:M,y2:L,selectionColors:S.some(k=>k.locked)?["#ced4da"]:[Bd.black],dashed:!0,cx:P+(R-P)/2,cy:M+(L-M)/2,activeEmbeddable:!1})};for(let C of vR(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>yv(d,a,C))}if(d.save(),d.translate(a.scrollX,a.scrollY),r.length===1){d.fillStyle=Bd.white;let E=fR(r[0],a.zoom,o,"mouse",bg(s));if(!a.viewModeEnabled&&b&&!gv(a.editingTextElement)&&!a.croppingElementId&&bv(d,l,a,E,r[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&hv(y)&&AR(d,l,a,y,o)}}else if(r.length>1&&!a.isRotating&&!r.some(E=>E.locked)){let E=vg*2/a.zoom.value;d.fillStyle=Bd.white;let[y,v,C,S]=wg(r,o),P=d.getLineDash();d.setLineDash([2/a.zoom.value]);let M=d.lineWidth;d.lineWidth=1/a.zoom.value,d.strokeStyle=w,ga(d,y-E,v-E,C-y+E*2,S-v+E*2,(y+C)/2,(v+S)/2,0),d.lineWidth=M,d.setLineDash(P);let R=bR([y,v,C,S,(y+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...bg(s),rotation:!0}:bg(s));r.some(L=>!L.locked)&&bv(d,l,a,R,0)}d.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:w})=>{let E=o.get(b);if(E){let[y,v,,,C,S]=wl(E,o,!0);d.save(),a.theme===hR.LIGHT?x?d.fillStyle="rgba(255, 124, 0, 0.4)":d.fillStyle="rgba(255, 226, 0, 0.4)":x?d.fillStyle="rgba(229, 82, 0, 0.4)":d.fillStyle="rgba(99, 52, 0, 0.4)";let P=uv(E)?a.zoom.value:1;d.translate(a.scrollX,a.scrollY),d.translate(C,S),d.rotate(E.angle),w.forEach(M=>{(M.showOnCanvas||x)&&d.fillRect(y+M.offsetX/P-C,v+M.offsetY/P-S,M.width/P,M.height/P)}),d.restore()}}),lv(d,a),d.restore(),DE({context:d,renderConfig:l,appState:a,normalizedWidth:m,normalizedHeight:c});let f;return l.renderScrollbars&&(f=dv(o,m,c,a),d.save(),d.fillStyle=cv,d.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&Bc(d,b.x,b.y,b.width,b.height,Ut/2)}),d.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},Tg=gR(e=>{let o=wv(e);e.callback?.(o)},{trailing:!0}),vv=(e,o)=>{if(o){Tg(e);return}let t=wv(e);return e.callback(t),t};var vl=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:m,width:c})=>{let d=[];for(let p of r.values())DR(p,c,m,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&d.push(p);return d},t=({elements:r,editingTextElement:n,newElementId:i})=>{let a=NR(new Map);for(let l of r)i!==l.id&&(!n||n.type!=="text"||l.id!==n.id)&&a.set(l.id,l);return a};return RR(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m,editingTextElement:c,newElementId:d,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:c,newElementId:d}),b=o({elementsMap:f,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){Tg.cancel(),B1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as BR}from"@haoxin-web/excalidraw-common";import{getElementAbsoluteCoords as FR}from"@haoxin-web/excalidraw-element";import{jsx as HR}from"react/jsx-runtime";var OR=5,zR=(e,o,t)=>{let[r,n]=FR(e,t),{x:i,y:a}=BR({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},Ig=({children:e,element:o,elementsMap:t})=>{let r=ko();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=zR(o,r,t);return HR("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:OR},children:e})};import{DEFAULT_LASER_COLOR as YR,easeOut as Iv}from"@haoxin-web/excalidraw-common";import{LaserPointer as GR}from"@excalidraw/laser-pointer";import{SVG_NS as Tv,getSvgPathFromStroke as UR,sceneCoordsToViewportCoords as WR}from"@haoxin-web/excalidraw-common";var or=class{constructor(o,t,r){this.animationFrameHandler=o;this.app=t;this.options=r;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Tv,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Tv,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===o&&this.currentTrail.originalPoints[r-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new GR(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=WR({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return UR(n,!0)}};var Fd=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");I(this,"localColor",YR);I(this,"setLocalColor",o=>{this.localColor=o});this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new or(o,t,{...this.getTrailOptions(),fill:()=>this.localColor})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let n=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(Iv(i),Iv(n))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(o)?r=this.collabTrails.get(o):(r=new or(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||gn(o,t)}),r.start(this.container),this.collabTrails.set(o,r)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!r.hasCurrentTrail&&r.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(t.pointer.x,t.pointer.y)&&r.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(t.pointer.x,t.pointer.y),r.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as VR}from"react";import{unstable_batchedUpdates as Cv}from"react-dom";import{throttleRAF as XR}from"@haoxin-web/excalidraw-common";var Ae=e=>o=>{Cv(e,o)},Od=e=>XR(o=>{Cv(e,o)}),Ki=(()=>{let e;try{let t=VR.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as Cg,KEYS as Tl,CLASSES as Sv,POINTER_BUTTON as KR,isWritableElement as ZR,getFontString as kv,getFontFamilyString as Mv,isTestEnv as Lv,MIME_TYPES as $R}from"@haoxin-web/excalidraw-common";import{originalContainerCache as jR,updateOriginalContainerCache as Pv}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as qR}from"@haoxin-web/excalidraw-element";import{bumpVersion as JR}from"@haoxin-web/excalidraw-element";import{getBoundTextElementId as QR,getContainerElement as Sg,getTextElementAngle as e9,redrawTextBoundingBox as t9,getBoundTextMaxHeight as o9,getBoundTextMaxWidth as Av,computeContainerDimensionForBoundText as _v,computeBoundTextPosition as r9,getBoundTextElement as n9}from"@haoxin-web/excalidraw-element";import{getTextWidth as i9}from"@haoxin-web/excalidraw-element";import{normalizeText as Dv}from"@haoxin-web/excalidraw-element";import{wrapText as a9}from"@haoxin-web/excalidraw-element";import{isArrowElement as zd,isBoundToContainer as l9,isTextElement as Rv}from"@haoxin-web/excalidraw-element";var s9=(e,o,t,r,n,i)=>{let{zoom:a}=r,l=180*t/Math.PI,s=e*(a.value-1)/2,m=o*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),o>i&&a.value!==1&&(m=i*(a.value-1)/2),`translate(${s}px, ${m}px) scale(${a.value}) rotate(${l}deg)`},Nv=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let m=(_,B)=>{if(!B.style.fontFamily||!B.style.fontSize)return!1;let K=B.style.fontFamily.replace(/"/g,"");return Mv({fontFamily:_.fontFamily})!==K||`${_.fontSize}px`!==B.style.fontSize},c=()=>{let _=l.state,B=l.scene.getElement(e);if(!B)return;let{textAlign:K,verticalAlign:j}=B,X=l.scene.getNonDeletedElementsMap();if(B&&Rv(B)){let q=B.x,se=B.y,ie=Sg(B,l.scene.getNonDeletedElementsMap()),be=B.width,ue=B.height,ao=B.width,To=B.height;if(ie&&B.containerId){if(zd(ie)){let sr=qR.getBoundTextElementPosition(ie,B,X);q=sr.x,se=sr.y}let os=m(B,d),pa;if(os?pa=Pv(ie.id,ie.height):(pa=jR[ie.id],pa||(pa=Pv(ie.id,ie.height))),ao=Av(ie,B),To=o9(ie,B),!zd(ie)&&ue>To){let sr=_v(ue,ie.type);l.scene.mutateElement(ie,{height:sr});return}else if(!zd(ie)&&ie.height>pa.height&&ue<To){let sr=_v(ue,ie.type);l.scene.mutateElement(ie,{height:sr})}else{let{x:sr,y:zC}=r9(ie,B,X);q=sr,se=zC}}let[es,Bm]=r(q,se),DC=d.selectionStart,Fm=d.selectionEnd,y1=d.value.length;if(DC===Fm&&Fm!==y1){let os=y1-Fm;d.selectionStart=d.value.length-os,d.selectionEnd=d.value.length-os}ie?be+=.5:(ao=(_.width-8-es)/_.zoom.value,be=Math.min(be,ao)),ue*=1.05;let RC=kv(B),w1=(_.height-Bm)/_.zoom.value;Object.assign(d.style,{font:RC,lineHeight:B.lineHeight,width:`${be}px`,height:`${ue}px`,left:`${es}px`,top:`${Bm}px`,transform:s9(be,ue,e9(B,ie),_,ao,w1),textAlign:K,verticalAlign:j,color:B.strokeColor,opacity:B.opacity/100,filter:"var(--theme-filter)",maxHeight:`${w1}px`});let ts=B.customData?.textStyle||{},NC=!!(ts.bold??l.state.currentTextBold),BC=!!(ts.italic??l.state.currentTextItalic),FC=!!(ts.underline??l.state.currentTextUnderline),OC=!!(ts.strikethrough??l.state.currentTextStrikethrough);d.style.fontWeight=NC?"700":"400",d.style.fontStyle=BC?"italic":"normal",d.style.textDecoration=[FC?"underline":"",OC?"line-through":""].filter(Boolean).join(" ")||"none",d.scrollTop=0,Lv()&&(d.style.fontFamily=Mv(B)),l.scene.mutateElement(B,{x:q,y:se})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(l9(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=n.originalText,c(),o&&(d.onpaste=async _=>{let B=(await $a(_)).findByType($R.text);if(!B)return;let K=Dv(B.value);if(!K)return;let j=Sg(n,l.scene.getNonDeletedElementsMap()),X=kv({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(j){let q=n9(j,l.scene.getNonDeletedElementsMap()),se=a9(`${d.value}${K}`,X,Av(j,q)),ie=i9(se,X);d.style.width=`${ie}px`}},d.oninput=()=>{let _=Dv(d.value);if(d.value!==_){let B=d.selectionStart;d.value=_,d.selectionStart=B,d.selectionEnd=B}o(d.value)}),d.onkeydown=_=>{if(!_.shiftKey&&Ec.keyTest(_,l.state,Object.values(l.scene.getNonDeletedElementsMap()),l))_.preventDefault(),l.actionManager.executeAction(Ec),c();else if(!_.shiftKey&&yc.keyTest(_,l.state,Object.values(l.scene.getNonDeletedElementsMap()),l))_.preventDefault(),l.actionManager.executeAction(yc),c();else if(!_.shiftKey&&wc.keyTest(_,l.state,Object.values(l.scene.getNonDeletedElementsMap()),l))_.preventDefault(),l.actionManager.executeAction(wc),c();else if(iu.keyTest(_))l.actionManager.executeAction(iu);else if(au.keyTest(_))l.actionManager.executeAction(au);else if(_.key===Tl.ESCAPE)_.preventDefault(),C=!0,S();else if(un.keyTest(_))_.preventDefault(),S(),l.actionManager.executeAction(un);else if(_.key===Tl.ENTER&&_[Tl.CTRL_OR_CMD]){if(_.preventDefault(),_.isComposing||_.keyCode===229)return;C=!0,S()}else if(_.key===Tl.TAB||_[Tl.CTRL_OR_CMD]&&(_.code===Cg.BRACKET_LEFT||_.code===Cg.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===Cg.BRACKET_LEFT?E():w(),d.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),w=()=>{let{selectionStart:_,selectionEnd:B}=d,K=y(),j=d.value;K.forEach(X=>{let q=j.slice(0,X),se=j.slice(X);j=`${q}${b}${se}`}),d.value=j,d.selectionStart=_+f,d.selectionEnd=B+f*K.length},E=()=>{let{selectionStart:_,selectionEnd:B}=d,K=y(),j=[],X=d.value;K.forEach(q=>{let se=X.slice(q,q+f).match(x);if(se){let ie=X.slice(0,q),be=X.slice(q+se[0].length);X=`${ie}${be}`,j.push(q)}}),d.value=X,j.length&&(_>j[j.length-1]?d.selectionStart=Math.max(_-f,j[j.length-1]):d.selectionStart=_,d.selectionEnd=Math.max(d.selectionStart,B-f*j.length))},y=()=>{let{selectionStart:_,selectionEnd:B,value:K}=d,j=K.slice(0,_).match(/[^\n]*$/)[0].length;return _=_-j,K.slice(_,B).split(`
23
- `).reduce((q,se,ie,be)=>q.concat(ie?q[ie-1]+be[ie-1].length+1:_),[]).reverse()},v=_=>{_.target instanceof HTMLCanvasElement&&(_.preventDefault(),_.stopPropagation())},C=!1,S=()=>{if(O)return;O=!0,P();let _=l.scene.getElement(n.id);if(!_)return;let B=Sg(_,l.scene.getNonDeletedElementsMap());if(B){if(d.value.trim()){let K=QR(B);!K||K!==n.id?l.scene.mutateElement(B,{boundElements:(B.boundElements||[]).concat({type:"text",id:n.id})}):zd(B)&&JR(B)}else l.scene.mutateElement(B,{boundElements:B.boundElements?.filter(K=>!Rv(K))});t9(_,B,l.scene)}t({viaKeyboard:C,nextOriginalText:d.value})},P=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,G&&G.disconnect(),window.removeEventListener("resize",c),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",L),window.removeEventListener("pointerup",M),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),k(),N(),d.remove()},M=_=>{window.removeEventListener("pointerup",M);let B=_?.target,K=B instanceof HTMLElement&&B.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=S,K||d.focus()})},R=()=>{d.onblur=null,window.addEventListener("pointerup",M),window.addEventListener("blur",S)},L=_=>{let B=_?.target;if(_.button===KR.WHEEL){B instanceof HTMLTextAreaElement&&(_.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(_)),R();return}let K=B instanceof HTMLElement&&B.classList.contains("properties-trigger");(_.target instanceof HTMLElement||_.target instanceof SVGElement)&&_.target.closest(`.${Sv.SHAPE_ACTIONS_MENU}, .${Sv.ZOOM_ACTIONS}`)&&!ZR(_.target)||K?R():_.target instanceof HTMLCanvasElement&&!Lv()&&requestAnimationFrame(()=>{S()})},k=l.scene.onUpdate(()=>{c(),!!document.activeElement?.closest(".properties-content")||d.focus()}),N=l.onScrollChangeEmitter.on(()=>{c()}),O=!1;s&&d.select(),M();let G=null;return i&&"ResizeObserver"in window?(G=new window.ResizeObserver(()=>{c()}),G.observe(i)):window.addEventListener("resize",c),d.onpointerdown=_=>_.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",L,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d),S};var Bv=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as x9}from"@haoxin-web/excalidraw-math";import{getElementLineSegments as E9}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as y9}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as w9,isLinearElement as v9,isTextElement as T9}from"@haoxin-web/excalidraw-element";import{getFrameChildren as I9}from"@haoxin-web/excalidraw-element";import{selectGroupsForSelectedElements as C9}from"@haoxin-web/excalidraw-element";import{getContainerElement as S9}from"@haoxin-web/excalidraw-element";import{arrayToMap as k9,easeOut as Hv,isShallowEqual as M9}from"@haoxin-web/excalidraw-common";import{simplify as c9}from"points-on-curve";import{polygonFromPoints as d9,lineSegment as Fv,polygonIncludesPointNonZero as m9}from"@haoxin-web/excalidraw-math";import{computeBoundTextPosition as p9,doBoundsIntersect as u9,getBoundTextElement as h9,getElementBounds as g9,intersectElementWithLineSegment as Ov}from"@haoxin-web/excalidraw-element";var zv=e=>{let{lassoPath:o,elements:t,elementsMap:r,elementsSegments:n,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=c9(o,l));let m=t.filter(p=>!p.locked);a.clear(),i.clear();let c=o.reduce((p,u)=>[Math.min(p[0],u[0]),Math.min(p[1],u[1]),Math.max(p[2],u[0]),Math.max(p[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let p of m){let u=g9(p,r);u9(c,u)&&!i.has(p.id)&&!a.has(p.id)&&(f9(s,p,n)?a.add(p.id):b9(s,p,r)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},f9=(e,o,t)=>{let r=d9(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>m9(a,r))):!1},b9=(e,o,t)=>{let r=e.slice(1).map((i,a)=>Fv(e[a],i)).concat([Fv(e[e.length-1],e[0])]),n=h9(o,t);return r.some(i=>Ov(o,t,i,0,!0).length>0||!!n&&Ov({...n,...p9(o,n,t)},t,i,0,!0).length>0)};var Hd=class extends or{constructor(t,r){super(t,r,{animateTrail:!0,streamline:.4,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/(1/0)),s=(5e3-Math.min(5e3,n.totalLength-n.currentIndex))/5e3;return Math.min(Hv(s),Hv(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,m)=>(s[m]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let m=this.app.scene.getNonDeletedElement(s);if(m&&T9(m)){let c=S9(m,this.app.scene.getNonDeletedElementsMap());c&&(n[c.id]=!0,delete n[m.id])}}for(let[s]of Object.entries(n)){let m=this.app.scene.getNonDeletedElement(s);if(m&&w9(m)){let c=I9(this.app.scene.getNonDeletedElementsMap(),m.id);for(let d of c)delete n[d.id]}}let i=C9({editingGroupId:r.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),r,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&v9(this.app.scene.getNonDeletedElement(a[0]))?new y9(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(n=>x9(n[0],n[1])),r={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!M9(r,this.canvasTranslate??{})){this.canvasTranslate=r,this.elementsSegments=new Map;let n=k9(this.app.visibleElements);for(let i of this.app.visibleElements){let a=E9(i,n);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:n}=zv({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(n)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,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 L9,easeOut as Gv,THEME as P9}from"@haoxin-web/excalidraw-common";import{computeBoundTextPosition as A9,getBoundTextElement as _9,intersectElementWithLineSegment as Uv,isPointInElement as D9}from"@haoxin-web/excalidraw-element";import{lineSegment as R9,pointFrom as N9}from"@haoxin-web/excalidraw-math";import{getElementsInGroup as Wv}from"@haoxin-web/excalidraw-element";import{shouldTestInside as B9}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as Yv,isBoundToContainer as Vv}from"@haoxin-web/excalidraw-element";import{getBoundTextElementId as Xv}from"@haoxin-web/excalidraw-element";var Gd=class extends or{constructor(t,r){super(t,r,{streamline:.2,size:5,keepHead:!0,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/200),s=(10-Math.min(10,n.totalLength-n.currentIndex))/10;return Math.min(Gv(s),Gv(l))},fill:()=>r.state.theme===P9.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set)}startPath(t,r){this.endPath(),super.startPath(t,r),this.elementsToErase.clear()}addPointToPath(t,r,n=!1){return super.addPointToPath(t,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(t){let r=super.getCurrentTrail()?.originalPoints?.map(l=>N9(l[0],l[1]))||[];if(r.length<2)return[];let n=R9(r[r.length-1],r[r.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=L9(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(Kv(n,l,a)){let m=l.groupIds.at(-1);if(this.groupsToErase.has(m)){let c=Wv(this.app.scene.getNonDeletedElementsMap(),m);for(let d of c)this.elementsToErase.delete(d.id);this.groupsToErase.delete(m)}if(Vv(l)&&this.elementsToErase.delete(l.containerId),Yv(l)){let c=Xv(l);c&&this.elementsToErase.delete(c)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&Kv(n,l,a)){let m=l.groupIds.at(-1);if(!this.groupsToErase.has(m)){let c=Wv(this.app.scene.getNonDeletedElementsMap(),m);for(let d of c)this.elementsToErase.add(d.id);this.groupsToErase.add(m)}if(Yv(l)){let c=Xv(l);c&&this.elementsToErase.add(c)}Vv(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},Kv=(e,o,t)=>{let r=e[1];if(B9(o)&&D9(r,o,t))return!0;let n=_9(o,t);return Uv(o,t,e,0,!0).length>0||!!n&&Uv({...n,...A9(o,n,t)},t,e,0,!0).length>0};import{jsx as to,jsxs as Zv}from"react/jsx-runtime";var F9=()=>Zv("div",{"data-testid":"brave-measure-text-error",children:[to("p",{children:to(yt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>to("span",{style:{fontWeight:600},children:e})})}),to("p",{children:to(yt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>to("span",{style:{fontWeight:600},children:e})})}),to("p",{children:to(yt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>to("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),to("p",{children:to(yt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>to("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>Zv("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),$v=F9;import W9 from"clsx";import Y9 from"react";import{useLayoutEffect as O9,useRef as jv,useEffect as qv}from"react";import{unstable_batchedUpdates as z9}from"react-dom";import{KEYS as H9,queryFocusableElements as G9}from"@haoxin-web/excalidraw-common";import{jsx as U9}from"react/jsx-runtime";var Jv=({children:e,left:o,top:t,onCloseRequest:r,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let m=jv(null);qv(()=>{let d=m.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=u=>{if(u.key===H9.TAB){let f=G9(d),{activeElement:b}=document,x=f.findIndex(w=>w===b);b===d?(u.shiftKey?f[f.length-1]?.focus():f[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(f[f.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===f.length-1&&!u.shiftKey&&(f[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let c=jv(null);return O9(()=>{if(n&&m.current&&t!=null&&o!=null){let d=m.current,{width:p,height:u}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===o)return;c.current={top:t,left:o},p>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):o+p-i>l?d.style.left=`${l-p-10}px`:d.style.left=`${o}px`,u>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+u-a>s?d.style.top=`${s-u}px`:d.style.top=`${t}px`}},[t,o,n,l,s,i,a]),qv(()=>{if(r){let d=p=>{m.current?.contains(p.target)||z9(()=>r(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),U9("div",{className:"popover",ref:m,tabIndex:-1,children:e})};import{jsx as Zi,jsxs as V9}from"react/jsx-runtime";var Ze="separator",Qv=Y9.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=ko(),a=yr();console.log(o);let l=["cut","copy","paste","separator","duplicateSelection","toggleElementLock"],s=[];l.forEach(c=>{if(c==="separator"){s.push("separator");return}let d=o.find(p=>p.name===c);d&&s.push(d)}),o=s;let m=o.reduce((c,d)=>(d&&(d===Ze||!d.predicate||d.predicate(a,i,e.app.props,e.app))&&c.push(d),c),[]);return Zi(Jv,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Zi("ul",{className:"context-menu",onContextMenu:c=>c.preventDefault(),children:m.map((c,d)=>{if(c===Ze)return!m[d-1]||m[d-1]===Ze?null:Zi("hr",{className:"context-menu-item-separator"},d);let p=c.name,u="";return c.label&&(typeof c.label=="function"?u=h(c.label(a,i,e.app)):u=h(c.label)),Zi("li",{"data-testid":p,onClick:()=>{n(()=>{e.executeAction(c,"contextMenu")})},children:V9("button",{type:"button",className:W9("context-menu-item",{dangerous:p==="deleteSelectedElements",checkmark:c.checked?.(i)}),children:[Zi("div",{className:"context-menu-item__label",children:u}),Zi("kbd",{className:"context-menu-item__shortcut",children:p?He(p):""})]})},d)})})})});import{jsx as kg,jsxs as e3}from"react/jsx-runtime";var X9=({height:e,width:o,userToFollow:t,onDisconnect:r})=>kg("div",{className:"follow-mode",style:{width:o,height:e},children:e3("div",{className:"follow-mode__badge",children:[e3("div",{className:"follow-mode__badge__label",children:["Following"," ",kg("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),kg("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:Vt})]})}),t3=X9;import VI from"clsx";import Iz from"react";import{DEFAULT_SIDEBAR as If,TOOL_TYPE as XI,arrayToMap as Cz,capitalizeString as Sz,isShallowEqual as vm}from"@haoxin-web/excalidraw-common";import{mutateElement as kz}from"@haoxin-web/excalidraw-element";import{ShapeCache as Mz}from"@haoxin-web/excalidraw-element";import{TOOL_TYPE as $e}from"@haoxin-web/excalidraw-common";import{jsx as Tn,jsxs as Z9}from"react/jsx-runtime";var K9=({appState:e,app:o,visible:t=!0})=>{if(!t)return null;let r=e.activeTool.type,n=so,i=So;if(r===$e.arrow){let s=e.currentItemStartArrowhead,m=e.currentItemEndArrowhead,c=s==="arrow"&&m==="arrow",d=(s==null||s===null)&&m==="arrow",p=s==="triangle_outline"&&m==="triangle_outline",u=(s==null||s===null)&&m==="triangle_outline";p?n=m0:u?n=d0:c?n=vs:d?n=on:n=on}else r===$e.line?n=so:n=so;switch(r){case $e.rectangle:i=So;break;case $e.ellipse:i=hr;break;case $e.diamond:i=ur;break;case"triangle":i=gr;break;case"pentagon":i=fr;break;case"callout":i=Es;break;case"hollow_arrow":i=ys;break;case"hollow_double_arrow":i=ws;break;default:break}let a=(e.currentItemOpacity??100)<100,l=s=>{try{window.dispatchEvent(new CustomEvent("leftflyout:toggle",{detail:{group:s}}))}catch{}};return Tn(De,{className:"App-toolbar App-toolbar--vertical",children:Z9(Ue.Col,{align:"center",gap:1,style:{padding:"4px 0"},children:[Tn(z,{"aria-label":"selection",type:"radio",icon:ba,checked:r===$e.selection,name:"left-main-toolbar",title:h("toolBar.selection"),onChange:()=>o.setActiveTool({type:$e.selection})}),Tn(z,{"aria-label":"freedraw",type:"radio",icon:a?Ts:Nt,checked:r===$e.freedraw,name:"left-main-toolbar",title:h("toolBar.freedraw"),onPointerDown:()=>l("freedraw"),onChange:()=>o.setActiveTool({type:$e.freedraw})}),Tn(z,{"aria-label":"line",type:"radio",icon:n,checked:r===$e.line||r===$e.arrow,name:"left-main-toolbar",title:h("toolBar.line"),onPointerDown:()=>l("line"),onChange:()=>o.setActiveTool({type:$e.line})}),Tn(z,{"aria-label":"shapes",type:"radio",icon:i,checked:r===$e.rectangle||r===$e.ellipse||r===$e.diamond||r==="triangle"||r==="pentagon"||r==="callout"||r==="hollow_arrow"||r==="hollow_double_arrow",name:"left-main-toolbar",title:h("headings.shapes"),onPointerDown:()=>l("shapes"),onChange:()=>o.setActiveTool({type:$e.rectangle})}),Tn(z,{"aria-label":"text",type:"radio",icon:Wo,checked:r===$e.text,name:"left-main-toolbar",title:h("toolBar.text"),onPointerDown:()=>l("text"),onChange:()=>o.setActiveTool({type:$e.text})}),Tn(z,{"aria-label":"eraser",type:"radio",icon:xa,checked:r===$e.eraser,name:"left-main-toolbar",title:h("toolBar.eraser"),onChange:()=>o.setActiveTool({type:$e.eraser})})]})})},o3=K9;import $9 from"clsx";import{useState as j9,useEffect as q9}from"react";import{THEME as J9}from"@haoxin-web/excalidraw-common";import{jsx as Mg,jsxs as Q9}from"react/jsx-runtime";var Ud=({delay:e,theme:o})=>{let[t,r]=j9(!!e);return q9(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:Q9("div",{className:$9("LoadingMessage",{"LoadingMessage--dark":o===J9.DARK}),children:[Mg("div",{children:Mg(it,{})}),Mg("div",{className:"LoadingMessage-text",children:h("labels.loadingScene")})]})};import{useEffect as yN}from"react";import{showSelectedShapeActions as wN}from"@haoxin-web/excalidraw-element";import eN from"clsx";import{jsx as tN}from"react/jsx-runtime";var Il=({children:e,side:o,className:t})=>tN("div",{className:eN("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import oN from"clsx";import{KEYS as r3}from"@haoxin-web/excalidraw-common";import{jsx as rN}from"react/jsx-runtime";var n3=e=>e.visible===!1?null:rN(z,{className:oN("Shape",{fillable:!1}),type:"radio",icon:Fs,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:r3.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":r3.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{CANVAS_SEARCH_TAB as nN,DEFAULT_SIDEBAR as iN}from"@haoxin-web/excalidraw-common";import{isFlowchartNodeElement as aN,isImageElement as i3,isLinearElement as a3,isLineElement as lN,isTextBindableContainer as sN,isTextElement as cN}from"@haoxin-web/excalidraw-element";import{getShortcutKey as Lg}from"@haoxin-web/excalidraw-common";import{isNodeInFlowchart as dN}from"@haoxin-web/excalidraw-element";import{jsx as l3}from"react/jsx-runtime";var mN=({appState:e,isMobile:o,device:t,app:r})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===iN.name&&e.openSidebar.tab===nN&&e.searchMatches?.matches.length)return h("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(St(e))return h("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?h("hints.linearElementMulti"):n.type==="arrow"?h("hints.arrowTool",{arrowShortcut:Lg("A")}):h("hints.linearElement");if(n.type==="freedraw")return h("hints.freeDraw");if(n.type==="text")return h("hints.text");if(n.type==="embeddable")return h("hints.embeddable");let m=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&m.length===1){let c=m[0];return a3(c)&&c.points.length===2?h("hints.lockAngle"):i3(c)?h("hints.resizeImage"):h("hints.resize")}if(a&&l==="mouse")return h("hints.rotate");if(m.length===1&&cN(m[0]))return h("hints.text_selected");if(e.editingTextElement)return h("hints.text_editing");if(e.croppingElementId)return h("hints.leaveCropEditor");if(m.length===1&&i3(m[0]))return h("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!m.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[h("hints.deepBoxSelect")];if(Nr(r)&&e.selectedElementsAreBeingDragged)return h("hints.disableSnapping");if(!m.length&&!o)return[h("hints.canvasPanning")];if(m.length===1){if(a3(m[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?h("hints.lineEditor_pointSelected"):h("hints.lineEditor_nothingSelected"):lN(m[0])?h("hints.lineEditor_line_info"):h("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&sN(m[0]))return aN(m[0])?dN(m[0],r.scene.getNonDeletedElementsMap())?[h("hints.bindTextToElement"),h("hints.createFlowchart")]:[h("hints.bindTextToElement"),h("hints.createFlowchart")]:h("hints.bindTextToElement")}}return null},s3=({appState:e,isMobile:o,device:t,app:r})=>{let n=mN({appState:e,isMobile:o,device:t,app:r});if(!n)return null;let i=Array.isArray(n)?n.map(a=>Lg(a).replace(/\. ?$/,"")).join(". "):Lg(n);return l3("div",{className:"HintViewer",children:l3("span",{children:i})})};import pN from"clsx";import{jsx as d3,jsxs as hN}from"react/jsx-runtime";var uN="medium",c3={CHECKED:Hn,UNCHECKED:tn},m3=e=>hN("label",{className:pN("ToolIcon ToolIcon__lock",`ToolIcon_size_${uN}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[d3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),d3("div",{className:"ToolIcon__icon",children:e.checked?c3.CHECKED:c3.UNCHECKED})]});import gN from"clsx";import{jsx as p3,jsxs as bN}from"react/jsx-runtime";var fN="medium",u3=e=>e.penDetected?bN("label",{className:gN("ToolIcon ToolIcon__penMode",`ToolIcon_size_${fN}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[p3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),p3("div",{className:"ToolIcon__icon",children:sb})]}):null;import{Fragment as xN,jsx as h3,jsxs as EN}from"react/jsx-runtime";var In=({heading:e,children:o,...t})=>{let{id:r}=Xe(),n=h3("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:h(`headings.${e}`)});return h3("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):EN(xN,{children:[n,o]})})};import{Fragment as vN,jsx as gt,jsxs as No}from"react/jsx-runtime";var g3=({appState:e,elements:o,actionManager:t,setAppState:r,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:m,device:c,renderWelcomeScreen:d,UIOptions:p,app:u,showPanActions:f})=>{let{WelcomeScreenCenterTunnel:b,MainMenuTunnel:x,DefaultSidebarTriggerTunnel:w}=Se();yN(()=>{e.viewModeEnabled&&e.openMenu&&r({openMenu:null})},[e.viewModeEnabled,e.openMenu,r]);let E=()=>No(Il,{side:"bottom",className:"App-bottom-bar-mobile",children:[d&&gt(b.Out,{}),gt(In,{heading:"shapes",children:v=>gt(Ue.Col,{gap:4,align:"center",children:No(Ue.Row,{gap:1,className:"App-toolbar-container",children:[No(De,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[v,No(Ue.Row,{gap:1,children:[gt(n3,{checked:Ho(e),onChange:()=>i(),title:h("toolBar.hand"),isMobile:!0,visible:f!==!1}),gt(Gw,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})]})]}),l&&l(!0,e),No("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&gt(w.Out,{}),gt(u3,{checked:e.penMode,onChange:()=>a(null),title:h("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),gt(m3,{checked:e.activeTool.locked,onChange:n,title:h("toolBar.lock"),isMobile:!0})]})]})})}),gt(s3,{appState:e,isMobile:!0,device:c,app:u})]}),y=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?gt("div",{className:"App-toolbar-content",children:gt(x.Out,{})}):No("div",{className:"App-toolbar-content",children:[gt(x.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),No("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return No(vN,{children:[m(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&E(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&gt("div",{className:"App-bottom-bar",style:{marginLeft:Ut+Ro*2,marginRight:Ut+Ro*2},children:No(De,{padding:0,children:[e.openMenu==="shape"&&wN(e,o)?gt(In,{className:"App-mobile-menu",heading:"selectedShapeActions",children:gt(Hw,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,No("footer",{className:"App-toolbar",children:[y(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&gt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(v=>({...en(o,v)}))},children:h("buttons.scrollBackToContent")})]})]})})]})};import TN from"open-color";import IN,{useLayoutEffect as CN,useRef as SN,useState as kN}from"react";import{jsx as Cl,jsxs as MN}from"react/jsx-runtime";var f3=e=>{let o=SN(null),[t,r]=kN(null);return CN(()=>{if(!e.spreadsheet)return;let n=pE(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await Nn(n,{exportBackground:!1,viewBackgroundColor:TN.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),Cl("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:Cl("div",{ref:o})})},b3=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=Oe(),n=IN.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),ae("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Cl(Ge,{size:"small",onCloseRequest:n,title:h("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:MN("div",{className:"container",children:[Cl(f3,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),Cl(f3,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as Fr from"@radix-ui/react-popover";import x3 from"clsx";import Wd,{useLayoutEffect as LN}from"react";import{supportsResizeObserver as PN,isShallowEqual as AN}from"@haoxin-web/excalidraw-common";import{Fragment as BN,jsx as Bo,jsxs as Yd}from"react/jsx-runtime";var _N=4,DN=8,RN=({shouldWrap:e,children:o,username:t})=>e?Bo(mo,{label:t||"Unknown user",children:o}):Bo(BN,{children:o}),Pg=({actionManager:e,collaborator:o,socketId:t,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:r,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Bo(RN,{username:o.username,shouldWrap:n,children:l},t)},NN=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Sl=Wd.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=Ke(),i=new Map;t.forEach((b,x)=>{let w=b.id||x;i.set(w,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=Wd.useState(""),m=a.filter(b=>b.username?.toLowerCase().includes(l)),c=Wd.useRef(null);LN(()=>{if(c.current){let b=w=>{let E=Math.max(1,Math.min(8,Math.floor(w/38)));p(E)};if(b(c.current.clientWidth),!PN)return;let x=new ResizeObserver(w=>{for(let E of w){let{width:y}=E.contentRect;b(y)}});return x.observe(c.current),()=>{x.disconnect()}}},[]);let[d,p]=Wd.useState(_N),f=a.slice(0,d-1).map(b=>Pg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?Bo("div",{className:x3("UserList UserList_mobile",e),children:a.map(b=>Pg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):Bo("div",{className:"UserList__wrapper",ref:c,children:Yd("div",{className:x3("UserList",e),style:{"--max-avatars":d},children:[f,a.length>d-1&&Yd(Fr.Root,{children:[Yd(Fr.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),Bo(Fr.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Yd(De,{padding:2,children:[a.length>=DN&&Bo(nc,{placeholder:h("quickSearch.placeholder"),onChange:s}),Bo(ic,{className:"dropdown-menu UserList__collaborators",placeholder:h("userList.empty"),children:m.length>0?[Bo("div",{className:"hint",children:h("userList.hint.text")}),m.map(b=>Pg({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),Bo(Fr.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[r,n]of e.collaborators){let i=o.collaborators.get(r);if(!i||r!==t.next().value||!AN(n,i,NN))return!1}return!0});import y3 from"clsx";import{jsx as FN}from"react/jsx-runtime";var E3=e=>FN("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${h("helpDialog.title")} \u2014 ?`,"aria-label":h("helpDialog.title"),children:Gn});import{jsx as rr,jsxs as w3}from"react/jsx-runtime";var v3=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r,showZoomActions:n})=>{let i=n!==!1,{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:l}=Se();return w3("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[i&&rr("div",{className:y3("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:rr(Ue.Col,{gap:2,children:rr(In,{heading:"canvasActions",children:rr(Uw,{renderAction:o.renderAction,zoom:e.zoom,visible:i})})})}),rr(a.Out,{}),rr("div",{className:y3("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),style:{display:"none"},children:w3("div",{style:{position:"relative"},children:[r&&rr(l.Out,{}),rr(E3,{onClick:()=>o.executeAction(hn)})]})}),rr(Ww,{actionManager:o,showExitZenModeBtn:t})]})},T3=v3;v3.displayName="Footer";import VN from"clsx";import{useEffect as R3,useLayoutEffect as N3,useRef as zg,useState as XN,forwardRef as B3,useImperativeHandle as KN,useCallback as A3}from"react";import{EVENT as _3,isDevEnv as ZN,KEYS as $N,updateObject as jN}from"@haoxin-web/excalidraw-common";import zN from"clsx";import{useContext as HN}from"react";import ON from"react";var Vd=ON.createContext({});import{jsx as Ag,jsxs as I3}from"react/jsx-runtime";var _g=({children:e,className:o})=>{let t=pe(),r=HN(Vd),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return I3("div",{className:zN("sidebar__header",o),"data-testid":"sidebar-header",children:[e,I3("div",{className:"sidebar__header__buttons",children:[n&&Ag(mo,{label:h("labels.sidebarLock"),children:Ag(Gt,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":h("labels.sidebarLock"),children:rb})}),Ag(Gt,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":h("buttons.close"),children:Vt})]})]})};_g.displayName="SidebarHeader";import*as S3 from"@radix-ui/react-tabs";import{jsx as C3}from"react/jsx-runtime";var Dg=({children:e,tab:o,onSelect:t,...r})=>C3(S3.Trigger,{value:o,asChild:!0,onSelect:t,children:C3("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});Dg.displayName="SidebarTabTrigger";import*as k3 from"@radix-ui/react-tabs";import{jsx as GN}from"react/jsx-runtime";var Rg=({children:e,...o})=>GN(k3.List,{className:"sidebar-triggers",...o,children:e});Rg.displayName="SidebarTabTriggers";import UN from"clsx";import{jsx as Ng,jsxs as M3}from"react/jsx-runtime";var Bg=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=me(),m=xe();return M3("label",{title:r,className:"sidebar-trigger__label-element",children:[Ng("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:c=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let d=c.target.checked;s({openSidebar:d?{name:e,tab:o}:null}),i?.(d)},checked:m.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),M3("div",{className:UN("sidebar-trigger",a),style:l,children:[t&&Ng("div",{children:t}),n&&Ng("div",{className:"sidebar-trigger__label",children:n})]})]})};Bg.displayName="SidebarTrigger";import*as L3 from"@radix-ui/react-tabs";import{jsx as WN}from"react/jsx-runtime";var Fg=({children:e,...o})=>{let t=xe(),r=me();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return WN(L3.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};Fg.displayName="SidebarTabs";import*as P3 from"@radix-ui/react-tabs";import{jsx as YN}from"react/jsx-runtime";var Og=({tab:e,children:o,...t})=>YN(P3.Content,{...t,value:e,"data-testid":e,children:o});Og.displayName="SidebarTab";import{jsx as D3}from"react/jsx-runtime";import{createElement as qN}from"react";var kl=he(!1),F3=B3(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{ZN()&&t&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=me(),s=pr(kl);N3(()=>(s(!!r),()=>{s(!1)}),[s,r]);let m=zg({});m.current.onCloseRequest=()=>{l({openSidebar:null})},m.current.onDock=u=>t?.(u),m.current=jN(m.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let c=zg(null);KN(a,()=>c.current);let d=pe(),p=A3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Jn(c,A3(u=>{u.target.closest(".sidebar-trigger")||(!r||!d.editor.canFitSidebar)&&p()},[p,r,d.editor.canFitSidebar])),R3(()=>{let u=f=>{f.key===$N.ESCAPE&&(!r||!d.editor.canFitSidebar)&&p()};return document.addEventListener(_3.KEYDOWN,u),()=>{document.removeEventListener(_3.KEYDOWN,u)}},[p,r,d.editor.canFitSidebar]),D3(De,{...i,className:VN("sidebar",{"sidebar--docked":r},n),ref:c,children:D3(Vd.Provider,{value:m.current,children:o})})});F3.displayName="SidebarInner";var oo=Object.assign(B3((e,o)=>{let t=xe(),{onStateChange:r}=e,n=zg(t.openSidebar);R3(()=>{(!t.openSidebar&&n?.current?.name===e.name||t.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&t.openSidebar!==n.current&&r?.(t.openSidebar?.name!==e.name?null:t.openSidebar),n.current=t.openSidebar},[t.openSidebar,r,e.name]);let[i,a]=XN(!1);return N3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?qN(F3,{...e,ref:o,key:e.name}):null}),{Header:_g,TabTriggers:Rg,TabTrigger:Dg,Tabs:Fg,Tab:Og,Trigger:Bg});oo.displayName="Sidebar";import{composeEventHandlers as aB}from"@haoxin-web/excalidraw-common";import{useLayoutEffect as JN,useRef as QN}from"react";import{jsx as eB}from"react/jsx-runtime";var nr=(e,o)=>{let t=he(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=Se(),[,a]=i(t),l=QN({preferHost:!1,counter:0});return JN(()=>{let s=l.current;return a(m=>{let c=m+1;return s.counter=c,c}),()=>{a(m=>{let c=m-1;return s.counter=c,c||(s.preferHost=!1),c})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:eB(o,{...n})};return r.displayName=e,r};var Ug={};T1(Ug,{ChangeCanvasBackground:()=>q3,ClearCanvas:()=>$3,CommandPalette:()=>X3,Export:()=>J3,Help:()=>Z3,LiveCollaborationTrigger:()=>eT,LoadScene:()=>W3,SaveAsImage:()=>V3,SaveToActiveFile:()=>Y3,SearchMenu:()=>K3,Socials:()=>Q3,ToggleTheme:()=>j3});import nB from"clsx";import{THEME as Or}from"@haoxin-web/excalidraw-common";var Hg=he({active:!1});async function O3({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{Ve.set(Hg,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import tB from"clsx";import{jsx as z3,jsxs as oB}from"react/jsx-runtime";var Xd=function({onChange:e,value:o,choices:t,name:r}){return z3("div",{className:"RadioGroup",children:t.map(n=>oB("div",{className:tB("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[z3("input",{name:r,type:"radio",checked:n.value===o,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as rB,jsx as Gg,jsxs as H3}from"react/jsx-runtime";var G3=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=pe();return H3(rB,{children:[H3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Gg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),Gg(Xd,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&Gg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};G3.displayName="DropdownMenuItemContentRadio";var U3=G3;import{Fragment as iB,jsx as tt,jsxs as tT}from"react/jsx-runtime";var W3=()=>{let{t:e}=Ye(),o=Ke(),t=yr();return o.isActionEnabled(hi)?tt(xt,{icon:Un,onSelect:async()=>{(!t.length||await O3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:tt(yt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>tt("strong",{children:n}),br:()=>tt("br",{})})}))&&o.executeAction(hi)},"data-testid":"load-button",shortcut:He("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};W3.displayName="LoadScene";var Y3=()=>{let{t:e}=Ye(),o=Ke();return o.isActionEnabled(un)?tt(xt,{shortcut:He("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(un),icon:fb,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};Y3.displayName="SaveToActiveFile";var V3=()=>{let e=me(),{t:o}=Ye();return tt(xt,{icon:ks,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:He("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};V3.displayName="SaveAsImage";var X3=e=>{let o=me(),{t}=Ye();return tt(xt,{icon:Sa,"data-testid":"command-palette-button",onSelect:()=>{ae("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:He("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};X3.displayName="CommandPalette";var K3=e=>{let{t:o}=Ye(),t=Ke();return tt(xt,{icon:Ft,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(ml)},shortcut:He("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};K3.displayName="SearchMenu";var Z3=()=>{let{t:e}=Ye(),o=Ke();return tt(xt,{"data-testid":"help-menu-item",icon:Gn,onSelect:()=>o.executeAction(hn),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};Z3.displayName="Help";var $3=()=>{let{t:e}=Ye(),o=pr(xn);return Ke().isActionEnabled(jo)?tt(xt,{icon:Bt,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};$3.displayName="ClearCanvas";var j3=e=>{let{t:o}=Ye(),t=xe(),r=Ke(),n=He("toggleTheme");return r.isActionEnabled(cn)?e?.allowSystemTheme?tt(U3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:Or.LIGHT,label:wa,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:Or.DARK,label:ya,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:L0,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):tt(xt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===Or.DARK?Or.LIGHT:Or.DARK);else return r.executeAction(cn)},icon:t.theme===Or.DARK?wa:ya,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===Or.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===Or.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};j3.displayName="ToggleTheme";var q3=()=>{let{t:e}=Ye(),o=xe(),t=Ke(),r=Mo();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:tT("div",{style:{marginTop:"0.5rem"},children:[tt("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),tt("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};q3.displayName="ChangeCanvasBackground";var J3=()=>{let{t:e}=Ye(),o=me();return tt(xt,{icon:rn,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};J3.displayName="Export";var Q3=()=>{let{t:e}=Ye();return tT(iB,{children:[tt(_i,{icon:Cs,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),tt(_i,{icon:hb,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),tt(_i,{icon:ub,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};Q3.displayName="Socials";var eT=({onSelect:e,isCollaborating:o})=>{let{t}=Ye();return tt(xt,{"data-testid":"collab-button",icon:Ms,className:nB({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};eT.displayName="LiveCollaborationTrigger";import{jsx as Kd,jsxs as Wg}from"react/jsx-runtime";var lB=Object.assign(nr("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Se(),r=pe(),n=xe(),i=me(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return Kd(t.In,{children:Wg(Ie,{open:n.openMenu==="canvas",children:[Kd(Ie.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Is}),Wg(Ie.Content,{onClickOutside:a,onSelect:aB(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&Wg("fieldset",{className:"UserList-Wrapper",children:[Kd("legend",{children:h("labels.collaborators")}),Kd(Sl,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Ie.Trigger,Item:Ie.Item,ItemLink:Ie.ItemLink,ItemCustom:Ie.ItemCustom,Group:Ie.Group,Separator:Ie.Separator,DefaultItems:Ug}),ft=lB;import{useEffect as $i,useRef as oT,useState as sB}from"react";import rT from"clsx";import{isTextElement as cB}from"@haoxin-web/excalidraw-element";import{getBoundTextElement as dB,getContainerElement as mB,redrawTextBoundingBox as pB,newElementWith as uB}from"@haoxin-web/excalidraw-element";import{DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as hB,STROKE_WIDTH as Tt}from"@haoxin-web/excalidraw-common";import{jsx as $,jsxs as Wt}from"react/jsx-runtime";var gB=({appState:e,app:o,actionManager:t,elements:r,showToolBar:n=!0})=>{if(!n)return null;let i=e.activeTool.type,a=ze(r,o,k=>k.strokeWidth,k=>k.hasOwnProperty("strokeWidth"),k=>k?null:e.currentItemStrokeWidth),l=oT(!1),[s,m]=sB(null),c=oT("");if($i(()=>{l.current=!1},[e.activeTool]),$i(()=>{e.viewModeEnabled&&s&&m(null)},[e.viewModeEnabled,s]),$i(()=>{let k=N=>{let G=N.detail?.group??null;l.current=!1,m(_=>_===G?null:G)};return window.addEventListener("leftflyout:toggle",k),()=>window.removeEventListener("leftflyout:toggle",k)},[]),$i(()=>{o.state.cursorButton==="down"&&(l.current=!0,m(null))},[o.state.cursorButton]),$i(()=>{let k=e.selectedElementIds||{},N=Object.keys(k).filter(_=>k[_]).sort().join("|");if(N===c.current||(c.current=N,!N))return;let O=r.find(_=>k[_.id]);if(!O)return;let G=null;switch(O.type){case"text":G="text";break;case"freedraw":G="freedraw";break;case"line":case"arrow":G="line";break;case"rectangle":case"diamond":case"ellipse":case"triangle":case"pentagon":case"callout":case"hollow_arrow":case"hollow_double_arrow":G="shapes";break;default:G=null}G&&(l.current=!1,m(G))},[e.selectedElementIds,r]),$i(()=>{let k=e.selectedElementIds||{},O=r.filter(ue=>k[ue.id]).filter(ue=>ue.type==="text");if(O.length===0)return;let G=O[0],_=ue=>O.every(ao=>ue(ao)===ue(G)),B=ue=>ue.customData?.textStyle||{},K=_(ue=>!!B(ue).bold)?!!B(G).bold:void 0,j=_(ue=>!!B(ue).italic)?!!B(G).italic:void 0,X=_(ue=>!!B(ue).underline)?!!B(G).underline:void 0,q=_(ue=>!!B(ue).strikethrough)?!!B(G).strikethrough:void 0,se=_(ue=>ue.fontSize)?G.fontSize:void 0,ie=_(ue=>ue.textAlign)?G.textAlign:void 0,be={};K!==void 0&&(be.currentTextBold=K),j!==void 0&&(be.currentTextItalic=j),X!==void 0&&(be.currentTextUnderline=X),q!==void 0&&(be.currentTextStrikethrough=q),se!==void 0&&(be.currentItemFontSize=se),ie!==void 0&&(be.currentItemTextAlign=ie),Object.keys(be).length&&o.setState(be)},[e.selectedElementIds,r]),o.state.cursorButton==="down"||l.current)return null;let d=e.selectedElementIds||{},u=r.find(k=>d[k.id])?.type,f=s==="line"&&(i==="line"||i==="arrow"||u==="line"||u==="arrow"),b=s==="shapes"&&["rectangle","diamond","ellipse","triangle","pentagon","callout","hollow_arrow","hollow_double_arrow"].includes(i)||s==="shapes"&&["rectangle","diamond","ellipse","triangle","pentagon","callout","hollow_arrow","hollow_double_arrow"].includes(u),x=s==="text"&&(i==="text"||u==="text"),w=s==="freedraw"&&(i==="freedraw"||u==="freedraw"),E=(e.currentItemOpacity??100)<100,y=()=>{let k=document.querySelector("textarea.excalidraw-wysiwyg");if(!k)return;let N=!!o.state.currentTextBold,O=!!o.state.currentTextItalic,G=!!o.state.currentTextUnderline,_=!!o.state.currentTextStrikethrough,B=[];G&&B.push("underline"),_&&B.push("line-through"),k.style.fontWeight=N?"700":"400",k.style.fontStyle=O?"italic":"normal",k.style.textDecoration=B.join(" ")||"none"},v=k=>{let N=o.scene.getSelectedElements(o.state),O=o.scene.getElementsMapIncludingDeleted(),G=_=>{let B=_.customData?.textStyle||{},K=uB(_,{customData:{..._.customData||{},textStyle:{...B,...k.bold!==void 0?{bold:k.bold}:{},...k.italic!==void 0?{italic:k.italic}:{},...k.underline!==void 0?{underline:k.underline}:{},...k.strikethrough!==void 0?{strikethrough:k.strikethrough}:{}}}});O.set(K.id,K);let j=mB(K,o.scene.getNonDeletedElementsMap());pB(K,j,o.scene)};for(let _ of N)if(cB(_))G(_);else{let B=dB(_,o.scene.getNonDeletedElementsMap());B&&G(B)}o.scene.replaceAllElements(O),o.store?.scheduleCapture?.(),o.refresh?.()},C=k=>{let N={};k.bold!==void 0&&(N.currentTextBold=k.bold),k.italic!==void 0&&(N.currentTextItalic=k.italic),k.underline!==void 0&&(N.currentTextUnderline=k.underline),k.strikethrough!==void 0&&(N.currentTextStrikethrough=k.strikethrough),o.setState(N)},S=k=>{k==="line"?o.setActiveTool({type:"line",locked:!0}):k==="arrow"?(o.setActiveTool({type:"arrow",locked:!0}),o.setState({currentItemStartArrowhead:null,currentItemEndArrowhead:"arrow"})):(o.setActiveTool({type:"arrow",locked:!0}),o.setState({currentItemStartArrowhead:"arrow",currentItemEndArrowhead:"arrow"}))},P=k=>{k==="arrow"?(o.setActiveTool({type:"arrow",locked:!0}),o.setState({currentItemStartArrowhead:null,currentItemEndArrowhead:"triangle_outline"})):(o.setActiveTool({type:"arrow",locked:!0}),o.setState({currentItemStartArrowhead:"triangle_outline",currentItemEndArrowhead:"triangle_outline"}))},M=()=>{let k=ze(r,o,N=>N.strokeColor,!0,N=>N?null:e.currentItemStrokeColor);return $(vr,{type:"elementStroke",label:h("labels.stroke"),color:k??e.currentItemStrokeColor,onChange:N=>t.executeAction(gc,"ui",{currentItemStrokeColor:N}),elements:r,appState:e,palette:hB,updateData:N=>t.executeAction(gc,"ui",N)})},R=k=>{t.executeAction(Ko,"ui",k)},L=k=>{o.setState({currentItemOpacity:k?50:100})};return Wt("div",{className:"LeftToolFlyouts",children:[f&&$(De,{className:"left-flyout left-flyout--line",children:Wt(Ue.Col,{gap:2,align:"start",children:[Wt("div",{className:"arrow-row",children:[$(z,{type:"radio","aria-label":h("toolBar.line"),icon:so,checked:i==="line",name:"left-flyout-line",title:h("toolBar.line"),onChange:()=>S("line")}),$(z,{type:"radio","aria-label":h("toolBar.arrow"),icon:on,checked:i==="arrow"&&e.currentItemStartArrowhead===null&&e.currentItemEndArrowhead==="arrow",name:"left-flyout-line",title:h("toolBar.arrow"),onChange:()=>S("arrow")}),$(z,{type:"radio","aria-label":h("labels.arrowtypes"),icon:vs,checked:i==="arrow"&&e.currentItemStartArrowhead==="arrow"&&e.currentItemEndArrowhead==="arrow",name:"left-flyout-line",title:h("labels.arrowtypes"),onChange:()=>S("double")})]}),$("div",{className:"left-flyout__separator"}),$("div",{className:"left-flyout__title",children:h("labels.strokeWidth")}),Wt("div",{className:"buttonList",style:{display:"flex",gap:6,justifyContent:"flex-start"},children:[$(z,{type:"icon","aria-label":h("labels.thin"),icon:Wn,selected:a===Tt.thin,name:"left-flyout-line-strokeWidth",title:h("labels.thin"),onClick:()=>t.executeAction(Ko,"ui",Tt.thin)}),$(z,{type:"icon","aria-label":h("labels.bold"),icon:Ta,selected:a===Tt.bold,name:"left-flyout-line-strokeWidth",title:h("labels.bold"),onClick:()=>t.executeAction(Ko,"ui",Tt.bold)}),$(z,{type:"icon","aria-label":h("labels.extraBold"),icon:Ia,selected:a===Tt.extraBold,name:"left-flyout-line-strokeWidth",title:h("labels.extraBold"),onClick:()=>t.executeAction(Ko,"ui",Tt.extraBold)})]}),$("div",{className:"left-flyout__title",children:"\u989C\u8272"}),M()]})}),b&&Wt(De,{className:"left-flyout left-flyout--shapes",children:[(()=>{let k=ze(r,o,G=>G.strokeWidth,G=>G.hasOwnProperty("strokeWidth"),G=>G?null:e.currentItemStrokeWidth),N=ze(r,o,G=>G.strokeStyle,G=>G.hasOwnProperty("strokeStyle"),G=>G?null:e.currentItemStrokeStyle),O=ze(r,o,G=>G.roughness,G=>G.hasOwnProperty("roughness"),G=>G?null:e.currentItemRoughness);return globalThis.__leftShapesFormCache={strokeWidthValue:k,strokeStyleValue:N,roughnessValue:O},null})(),Wt("div",{className:"shapes-grid",style:{gridTemplateColumns:"repeat(5, 1fr)"},children:[$(z,{type:"radio","aria-label":h("toolBar.rectangle"),icon:So,checked:i==="rectangle",name:"left-flyout-shapes",title:h("toolBar.rectangle"),onChange:()=>o.setActiveTool({type:"rectangle",locked:!0})}),$(z,{type:"radio","aria-label":h("toolBar.ellipse"),icon:hr,checked:i==="ellipse",name:"left-flyout-shapes",title:h("toolBar.ellipse"),onChange:()=>o.setActiveTool({type:"ellipse",locked:!0})}),$(z,{type:"radio","aria-label":h("toolBar.diamond"),icon:ur,checked:i==="diamond",name:"left-flyout-shapes",title:h("toolBar.diamond"),onChange:()=>o.setActiveTool({type:"diamond",locked:!0})}),$(z,{type:"radio","aria-label":h("toolBar.triangle"),icon:gr,checked:i==="triangle",name:"left-flyout-shapes",title:h("toolBar.triangle"),onChange:()=>o.setActiveTool({type:"triangle",locked:!0})}),$(z,{type:"radio","aria-label":h("toolBar.pentagon"),icon:fr,checked:i==="pentagon",name:"left-flyout-shapes",title:h("toolBar.pentagon"),onChange:()=>o.setActiveTool({type:"pentagon",locked:!0})}),$(z,{type:"radio","aria-label":h("toolBar.callout"),icon:Es,checked:i==="callout",name:"left-flyout-shapes",title:h("toolBar.callout"),onChange:()=>o.setActiveTool({type:"callout"})}),$(z,{type:"radio","aria-label":h("toolBar.hollowArrow"),icon:ys,checked:i==="hollow_arrow",name:"left-flyout-shapes",title:h("toolBar.hollowArrow"),onChange:()=>o.setActiveTool({type:"hollow_arrow"})}),$(z,{type:"radio","aria-label":h("toolBar.hollowDoubleArrow"),icon:ws,checked:i==="hollow_double_arrow",name:"left-flyout-shapes",title:h("toolBar.hollowDoubleArrow"),onChange:()=>o.setActiveTool({type:"hollow_double_arrow"})})]}),$("div",{className:"left-flyout__separator"}),$("div",{className:"left-flyout__title",style:{marginTop:8},children:h("labels.stroke")}),M(),$("div",{className:"left-flyout__title",style:{marginTop:8},children:h("labels.background")}),$(vr,{type:"elementBackground",label:h("labels.background"),color:ze(r,o,k=>k.backgroundColor,!0,k=>k?null:e.currentItemBackgroundColor),onChange:k=>t.executeAction(fc,"ui",{currentItemBackgroundColor:k}),elements:r,appState:e,updateData:k=>t.executeAction(fc,"ui",k)}),$("div",{className:"left-flyout__title",style:{marginTop:6},children:h("labels.fill")}),(()=>{let k=ze(r,o,N=>N.fillStyle,N=>N.hasOwnProperty("fillStyle"),N=>N?null:e.currentItemFillStyle);return globalThis.__leftShapesFormCache={...globalThis.__leftShapesFormCache||{},fillStyleValue:k},null})(),Wt("div",{className:"buttonList",style:{display:"flex",gap:6,justifyContent:"flex-start"},children:[$(z,{type:"icon","aria-label":h("labels.hachure"),icon:Ls,selected:globalThis.__leftShapesFormCache?.fillStyleValue==="hachure",name:"left-flyout-fillStyle",title:h("labels.hachure"),onClick:()=>t.executeAction(za,"ui","hachure")}),$(z,{type:"icon","aria-label":h("labels.crossHatch"),icon:Ps,selected:globalThis.__leftShapesFormCache?.fillStyleValue==="cross-hatch",name:"left-flyout-fillStyle",title:h("labels.crossHatch"),onClick:()=>t.executeAction(za,"ui","cross-hatch")}),$(z,{type:"icon","aria-label":h("labels.solid"),icon:As,selected:globalThis.__leftShapesFormCache?.fillStyleValue==="solid",name:"left-flyout-fillStyle",title:h("labels.solid"),onClick:()=>t.executeAction(za,"ui","solid")})]}),$("div",{className:"left-flyout__title",children:h("labels.strokeWidth")}),Wt("div",{className:"buttonList",style:{display:"flex",gap:6,justifyContent:"flex-start"},children:[$(z,{type:"icon","aria-label":h("labels.thin"),icon:Wn,selected:a===Tt.thin,name:"left-flyout-strokeWidth",title:h("labels.thin"),onClick:()=>t.executeAction(Ko,"ui",Tt.thin)}),$(z,{type:"icon","aria-label":h("labels.bold"),icon:Ta,selected:a===Tt.bold,name:"left-flyout-strokeWidth",title:h("labels.bold"),onClick:()=>t.executeAction(Ko,"ui",Tt.bold)}),$(z,{type:"icon","aria-label":h("labels.extraBold"),icon:Ia,selected:a===Tt.extraBold,name:"left-flyout-strokeWidth",title:h("labels.extraBold"),onClick:()=>t.executeAction(Ko,"ui",Tt.extraBold)})]})]}),x&&$(De,{className:"left-flyout left-flyout--text",children:Wt(Ue.Col,{gap:2,align:"start",children:[$("div",{className:"left-flyout__title",children:"\u6837\u5F0F"}),Wt("div",{className:"text-style-row",style:{display:"flex",gap:8},children:[$(z,{type:"icon","aria-label":"Bold",title:"Bold",icon:$("span",{style:{fontWeight:700},children:"B"}),selected:!!e.currentTextBold,onClick:()=>{let k=!e.currentTextBold;o.setState({currentTextBold:k}),y(),v({bold:!e.currentTextBold}),C({bold:k})}}),$(z,{type:"icon","aria-label":"Italic",title:"Italic",icon:$("span",{style:{fontStyle:"italic"},children:"I"}),selected:!!e.currentTextItalic,onClick:()=>{let k=!e.currentTextItalic;o.setState({currentTextItalic:k}),y(),v({italic:!e.currentTextItalic}),C({italic:k})}}),$(z,{type:"icon","aria-label":"Strikethrough",title:"Strikethrough",icon:$("span",{style:{textDecoration:"line-through"},children:"S"}),selected:!!e.currentTextStrikethrough,onClick:()=>{let k=!e.currentTextStrikethrough;o.setState({currentTextStrikethrough:k}),y(),v({strikethrough:k}),C({strikethrough:k})}}),$(z,{type:"icon","aria-label":"Underline",title:"Underline",icon:$("span",{style:{textDecoration:"underline"},children:"U"}),selected:!!e.currentTextUnderline,onClick:()=>{let k=!e.currentTextUnderline;o.setState({currentTextUnderline:k}),y(),v({underline:k}),C({underline:k})}})]}),$("div",{className:"left-flyout__title",children:"\u5B57\u53F7"}),$("div",{className:"text-size-row",style:{display:"flex",gap:6,alignItems:"center",justifyContent:"flex-start"},children:[10,12,16,24,36].map(k=>{let N=e.currentItemFontSize===k;return $("button",{className:rT("text-size-chip",{selected:N}),style:{minWidth:32,height:28,padding:"0 10px",borderRadius:8,background:N?"#2178ff":"transparent",color:N?"#fff":"var(--text-primary-color)",border:N?"1px solid #2178ff":"1px solid var(--button-border-color)",transition:"background 0.12s ease"},onMouseEnter:O=>{N&&(O.currentTarget.style.background="rgba(33,120,255,0.85)")},onMouseLeave:O=>{N&&(O.currentTarget.style.background="#2178ff")},onClick:()=>{t.executeAction(nu,"ui",k)},children:$("span",{style:{fontSize:12},children:k})},k)})}),$("div",{className:"left-flyout__title",children:"\u5BF9\u9F50\u65B9\u5F0F"}),Wt("div",{className:"text-align-row",style:{display:"flex",gap:6,justifyContent:"flex-start"},children:[$(z,{type:"radio","aria-label":h("labels.left"),name:"text-align",title:h("labels.left"),icon:Ds,checked:e.currentItemTextAlign==="left",onChange:()=>{t.executeAction(Ha,"ui","left")}}),$(z,{type:"radio","aria-label":h("labels.center"),name:"text-align",title:h("labels.center"),icon:Rs,checked:e.currentItemTextAlign==="center",onChange:()=>{t.executeAction(Ha,"ui","center")}}),$(z,{type:"radio","aria-label":h("labels.right"),name:"text-align",title:h("labels.right"),icon:Ns,checked:e.currentItemTextAlign==="right",onChange:()=>{t.executeAction(Ha,"ui","right")}})]}),$("div",{className:"left-flyout__separator"}),M()]})}),w&&$(De,{className:"left-flyout left-flyout--freedraw",children:Wt(Ue.Col,{gap:2,align:"start",children:[Wt("div",{className:"freedraw-pen-toggle",children:[$(z,{type:"radio","aria-label":h("toolBar.freedraw"),icon:Nt,checked:!E,name:"freedraw-pen-type",title:h("toolBar.freedraw"),onChange:()=>L(!1)}),$(z,{type:"radio","aria-label":h("toolBar.highlighter"),icon:Ts,checked:E,name:"freedraw-pen-type",title:h("toolBar.highlighter"),onChange:()=>L(!0)})]}),$("div",{className:"left-flyout__title",children:h("labels.strokeWidth")}),$("div",{className:"width-choices",children:[Tt.thin,Tt.bold,Tt.extraBold,6].map(k=>$("button",{className:rT("stroke-width-preview",{selected:e.currentItemStrokeWidth===k}),title:`${h("labels.strokeWidth")} ${k}`,onClick:()=>R(k),children:$("svg",{width:"24",height:"16",viewBox:"0 0 24 16","aria-hidden":"true",children:$("path",{d:"M2 12 C 6 2, 14 14, 22 6",fill:"none",stroke:"currentColor",strokeWidth:Math.max(1,Number(k)),strokeLinecap:"round"})})},String(k)))}),$("div",{className:"left-flyout__separator"}),$("div",{className:"left-flyout__title",children:h("colorPicker.color")}),$("div",{className:"color-section",children:M()})]})})]})},nT=gB;import fB from"clsx";import{forwardRef as bB,useState as xB}from"react";import{isPromiseLike as EB}from"@haoxin-web/excalidraw-common";import{jsx as Zd,jsxs as yB}from"react/jsx-runtime";var zr=bB(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:m},c)=>{let[d,p]=xB(!1),u=async b=>{let x=t?.(b);if(EB(x)){let w=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof Dn)console.warn(E);else throw E}finally{clearTimeout(w),p(!1)}}},f=d?"loading":m;return i=f==="success"?"success":i,Zd("button",{className:fB("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:c,disabled:f==="loading"||f==="success",children:yB("div",{className:"ExcButton__contents",children:[f==="loading"?Zd(it,{className:"ExcButton__statusIcon"}):f==="success"&&Zd("div",{className:"ExcButton__statusIcon",children:i0}),o&&Zd("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as ji,jsxs as TB}from"react/jsx-runtime";var $d=({title:e,children:o,actionLabel:t,onClick:r})=>TB("div",{className:"OverwriteConfirm__Actions__Action",children:[ji("h4",{children:e}),ji("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),ji(zr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),wB=()=>{let{t:e}=Ye(),o=Ke(),t=me();return ji($d,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Ac,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},vB=()=>{let{t:e}=Ye(),o=Ke();return ji($d,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(ja,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Yg=Object.assign(({children:e})=>ji("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:wB,SaveToDisk:vB});import{jsx as Hr,jsxs as iT}from"react/jsx-runtime";var jd=Object.assign(nr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Se(),[t,r]=ce(Hg);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return Hr(o.In,{children:Hr(Ge,{onCloseRequest:n,title:!1,size:916,children:iT("div",{className:"OverwriteConfirm",children:[Hr("h3",{children:t.title}),iT("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Hr("div",{className:"OverwriteConfirm__Description__icon",children:a0}),Hr("div",{children:t.description}),Hr("div",{className:"OverwriteConfirm__Description__spacer"}),Hr(zr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Hr(Yg,{children:e})]})})})}),{Actions:Yg,Action:$d});import VB from"clsx";import{CANVAS_SEARCH_TAB as $g,DEFAULT_SIDEBAR as XB,LIBRARY_SIDEBAR_TAB as gT,composeEventHandlers as KB}from"@haoxin-web/excalidraw-common";import{round as IB}from"@haoxin-web/excalidraw-math";import CB from"clsx";import SB from"lodash.debounce";import{Fragment as kB,memo as MB,useEffect as Ml,useMemo as aT,useRef as Vg,useState as lT}from"react";import{CLASSES as LB,EVENT as PB,FONT_FAMILY as Xg,FRAME_STYLE as Kg,getLineHeight as AB}from"@haoxin-web/excalidraw-common";import{isElementCompletelyInViewport as _B}from"@haoxin-web/excalidraw-element";import{measureText as Ll}from"@haoxin-web/excalidraw-element";import{KEYS as qi,randomInteger as sT,addEventListener as DB,getFontString as qd}from"@haoxin-web/excalidraw-common";import{newTextElement as RB}from"@haoxin-web/excalidraw-element";import{isTextElement as pT,isFrameLikeElement as Jd}from"@haoxin-web/excalidraw-element";import{getDefaultFrameName as uT}from"@haoxin-web/excalidraw-element/frame";import{Fragment as YB,jsx as ot,jsxs as Fo}from"react/jsx-runtime";var NB=he(""),Zg=he(null),BB=350,hT=()=>{let e=Oe(),o=me(),t=Vg(null),[r,n]=ce(NB),i=r.trim(),[a,l]=lT(!1),[s,m]=lT({nonce:null,items:[]}),c=Vg(null),d=Vg(void 0),[p,u]=ce(Zg),f=e.scene.getNonDeletedElementsMap();Ml(()=>{a||(i!==c.current||e.scene.getSceneNonce()!==d.current)&&(c.current=null,mT(i,e,(y,v)=>{m({nonce:sT(),items:y}),c.current=i,d.current=e.scene.getSceneNonce(),o({searchMatches:y.length?{focusedId:null,matches:y.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null})}))},[a,i,f,e,o,u,d]);let b=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},x=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};Ml(()=>{o(y=>y.searchMatches?{searchMatches:{focusedId:p!==null&&y.searchMatches?.matches[p]?.id||null,matches:y.searchMatches.matches.map((C,S)=>S===p?{...C,focus:!0}:{...C,focus:!1})}}:null)},[p,o]),Ml(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=RB({text:y.searchQuery,x:y.element.x+(y.matchedLines[0]?.offsetX??0),y:y.element.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:Jd(y.element)?Kg.nameFontSize:y.element.fontSize,fontFamily:Jd(y.element)?Xg.Assistant:y.element.fontFamily}),S=14,P=C.fontSize,M=P*v<S;if(!_B([C],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||M){let R;M?P>=S?R={fitToContent:!0}:R={fitToViewport:!0,maxZoom:IB(S/P,1)}:R={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...R,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),Ml(()=>()=>{u(null),c.current=null,d.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let w=br({goToNextItem:b,goToPreviousItem:x,searchMatches:s});Ml(()=>{let y=v=>{if(v.key===qi.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[qi.CTRL_OR_CMD]&&v.key===qi.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(v.key===qi.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===qi.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===qi.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return DB(window,PB.KEYDOWN,y,{capture:!0,passive:!1})},[o,w,e]);let E=`${s.items.length} ${s.items.length===1?h("search.singleResult"):h("search.multipleResults")}`;return Fo("div",{className:"layer-ui__search",children:[ot("div",{className:"layer-ui__search-header",children:ot(Ni,{className:LB.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:h("search.placeholder"),icon:Ft,onChange:y=>{n(y),l(!0);let v=y.trim();mT(v,e,(C,S)=>{m({nonce:sT(),items:C}),u(S),c.current=v,d.current=e.scene.getSceneNonce(),o({searchMatches:C.length?{focusedId:null,matches:C.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),Fo("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Fo(YB,{children:[p!==null&&p>-1?Fo("div",{children:[p+1," / ",E]}):ot("div",{children:E}),Fo("div",{className:"result-nav",children:[ot(Gt,{onSelect:()=>{b()},className:"result-nav-btn",children:Us}),ot(Gt,{onSelect:()=>{x()},className:"result-nav-btn",children:R0})]})]}),s.items.length===0&&i&&c.current&&ot("div",{style:{margin:"1rem auto"},children:h("search.noMatch")})]}),ot(zB,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},cT=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return ot("div",{tabIndex:-1,className:CB("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ot("div",{className:"preview-text",children:o.flatMap((t,r)=>ot(kB,{children:r===2?ot("b",{children:t}):t},r))})})},FB=e=>{let o=aT(()=>e.matches.items.filter(r=>Jd(r.element)),[e.matches]),t=aT(()=>e.matches.items.filter(r=>pT(r.element)),[e.matches]);return Fo("div",{children:[o.length>0&&Fo("div",{className:"layer-ui__search-result-container",children:[Fo("div",{className:"layer-ui__search-result-title",children:[ot("div",{className:"title-icon",children:Vn}),ot("div",{children:h("search.frames")})]}),o.map((r,n)=>ot(cT,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.index)),t.length>0&&ot("div",{className:"layer-ui__divider"})]}),t.length>0&&Fo("div",{className:"layer-ui__search-result-container",children:[Fo("div",{className:"layer-ui__search-result-title",children:[ot("div",{className:"title-icon",children:Wo}),ot("div",{children:h("search.texts")})]}),t.map((r,n)=>ot(cT,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+o.length===e.focusIndex,onClick:()=>e.onItemClick(n+o.length)},r.element.id+r.index))]})]})},OB=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,zB=MB(FB,OB),dT=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),m=a.slice(s<=0?0:s).join(" ")+(l?" ":""),c=20;m=m.length>c?m.slice(-c):m;let d=e.slice(o+t.length),p=d.split(/\s+/),u=!d.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:m.length,previewText:m+t+b,moreBefore:s>0,moreAfter:p.length>f}},HB=(e,o)=>{let t=e.split(`
22
+ Z`,pt(e,!0))}else i=o.polygon([[a,l],[s,m],[c,d]],pt(e));return i}case"pentagon":{let i,a=s2(e),l=[];for(let s=0;s<a.length;s+=2)l.push([a[s],a[s+1]]);return e.roundness,i=o.polygon(l,pt(e)),i}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,pt(e));case"hollow_arrow":{let i=e.width,a=e.height,l=Math.max(i*.25,20),s=Math.max(a*.3,8),m=Math.min(s,a*.6),c=[[0,a/2-m/2],[i-l,a/2-m/2],[i-l,0],[i,a/2],[i-l,a],[i-l,a/2+m/2],[0,a/2+m/2]];return o.polygon(c,pt(e))}case"hollow_double_arrow":{let i=e.width,a=e.height,l=Math.max(i*.2,15),s=Math.max(a*.3,8),m=Math.min(s,a*.6),c=Math.min(l,i*.4),d=[[c,0],[0,a/2],[c,a],[c,a/2+m/2],[i-c,a/2+m/2],[i-c,a],[i,a/2],[i-c,0],[i-c,a/2-m/2],[c,a/2-m/2]];return o.polygon(d,pt(e))}case"line":case"arrow":{let i,a=pt(e),l=e.points.length?e.points:[B_(0,0)];if(pl(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(Y_(l,16),pt(e,!0))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(l)),i=[]):e.roundness?i=[o.curve(l,a)]:a.fill?i=[o.polygon(l,a)]:i=[o.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:m="arrow"}=e;if(s!==null){let c=y2(e,i,"start",s,o,a,r);i.push(...c)}if(m!==null){let c=y2(e,i,"end",m,o,a,r);i.push(...c)}}return i}case"freedraw":{let i;if(b2(e),Ed(e.points)){let a=N_(e.points,.75);i=o.curve(a,{...pt(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return O_(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},Y_=(e,o)=>{let t=[];for(let n=1;n<e.length-1;n+=1){let i=e[n-1],a=e[n+1],l=e[n],s=vd(l,i),m=vd(a,l),c=Math.min(o,E2(e[n],a)/2,E2(e[n],i)/2);s?i[0]<l[0]?t.push([e[n][0]-c,e[n][1]]):t.push([e[n][0]+c,e[n][1]]):i[1]<l[1]?t.push([e[n][0],e[n][1]-c]):t.push([e[n][0],e[n][1]+c]),t.push(e[n]),m?a[0]<l[0]?t.push([e[n][0]-c,e[n][1]]):t.push([e[n][0]+c,e[n][1]]):a[1]<l[1]?t.push([e[n][0],e[n][1]-c]):t.push([e[n][0],e[n][1]+c])}let r=[`M ${e[0][0]} ${e[0][1]}`];for(let n=0;n<t.length;n+=3)r.push(`L ${t[n][0]} ${t[n][1]}`),r.push(`Q ${t[n+1][0]} ${t[n+1][1]}, ${t[n+2][0]} ${t[n+2][1]}`);return r.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),r.join(" ")};var v2=(e,o,t=!1)=>{let r=!1;for(let n in o){let i=o[n];if(typeof i<"u"){if(e[n]===i&&(typeof i!="object"||i===null))continue;r=!0}}return!r&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??V_(),updated:X_()}};import{jsx as I2}from"react/jsx-runtime";var Wi=F({name:"toggleLinearEditor",category:Pe.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&n.length===1&&Z_(n[0])&&!K_(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];og(n,"No selected element found"),og(o.selectedLinearElement,"No selected linear element found"),og(n.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:T2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=h(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return I2(z,{type:"button",icon:D0,title:n,"aria-label":n,onClick:()=>o(null)})}}),Fbe=F({name:"togglePolygon",category:Pe.elements,icon:Qm,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!Ui(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return n.length>0&&n.every(i=>Ui(i)&&i.points.length>=4)},perform(e,o,t,r){let n=r.scene.getSelectedElements(o);if(n.some(s=>!Ui(s)))return!1;let i=n,a=i.some(s=>!s.polygon),l=$_(i);return{elements:e.map(s=>!l.has(s.id)||!Ui(s)?s:v2(s,{backgroundColor:a?s.backgroundColor:"transparent",...j_(s,a)})),appState:o,captureUpdate:T2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(a=>!Ui(a)||!a.polygon||a.points.length<3))return null;let n=r.every(a=>Ui(a)&&a.polygon),i=h(n?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return I2(qn,{icon:Qm,title:i,"aria-label":i,active:n,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as C2,CANVAS_SEARCH_TAB as S2,CLASSES as q_,DEFAULT_SIDEBAR as k2}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as J_}from"@haoxin-web/excalidraw-element";var ml=F({name:"searchMenu",icon:Ft,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openDialog)return!1;if(o.openSidebar?.name===k2.name&&o.openSidebar.tab===S2){let n=r.excalidrawContainerValue.container?.querySelector(`.${q_.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...o,openSidebar:{name:k2.name,tab:S2},openDialog:null},captureUpdate:J_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[C2.CTRL_OR_CMD]&&e.key===C2.F});import{isImageElement as Q_}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as eD}from"@haoxin-web/excalidraw-element";import{jsx as tD}from"react/jsx-runtime";var rg=F({name:"cropEditor",label:"helpDialog.cropStart",icon:Ep,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:n.id},captureUpdate:eD.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&Q_(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=h("helpDialog.cropStart");return tD(z,{type:"button",icon:Ep,title:r,"aria-label":r,onClick:()=>o(null)})}});import{getNonDeletedElements as oD}from"@haoxin-web/excalidraw-element";import{mutateElement as rD}from"@haoxin-web/excalidraw-element";import{newFrameElement as nD}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as Sd}from"@haoxin-web/excalidraw-element";import{addElementsToFrame as iD,removeAllElementsFromFrame as aD}from"@haoxin-web/excalidraw-element";import{getFrameChildren as lD}from"@haoxin-web/excalidraw-element";import{KEYS as M2,updateActiveTool as L2}from"@haoxin-web/excalidraw-common";import{getElementsInGroup as sD}from"@haoxin-web/excalidraw-element";import{getCommonBounds as cD}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as wn}from"@haoxin-web/excalidraw-element";var P2=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&Sd(t[0])},A2=F({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(Sd(n)){let i=lD(oD(e),n.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:wn.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:wn.EVENTUALLY}},predicate:(e,o,t,r)=>P2(o,r)}),_2=F({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return Sd(n)?{elements:aD(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:wn.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:wn.EVENTUALLY}},predicate:(e,o,t,r)=>P2(o,r)}),X0e=F({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o)=>({elements:e,appState:{...o,frameRendering:{...o.frameRendering,enabled:!o.frameRendering.enabled}},captureUpdate:wn.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),K0e=F({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Vn,viewMode:!1,perform:(e,o,t,r)=>{let n=L2(o,{type:"frame"});return Ot(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:L2(o,{type:"frame"})},captureUpdate:wn.EVENTUALLY}},keyTest:e=>!e[M2.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===M2.F}),D2=F({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=J(e,o);return n.length>0&&!n.some(i=>Sd(i))},perform:(e,o,t,r)=>{let n=J(e,o),i=r.scene.getNonDeletedElementsMap(),[a,l,s,m]=cD(n,i),c=16,d=nD({x:a-c,y:l-c,width:s-a+c*2,height:m-l+c*2});if(o.editingGroupId){let u=sD(n,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);rD(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:iD([...r.scene.getElementsIncludingDeleted(),d],n,d,o),appState:{selectedElementIds:{[d.id]:!0}},captureUpdate:wn.IMMEDIATELY}}});import{isWindows as fD,KEYS as bl,matchKey as ag,arrayToMap as R2}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as ig}from"@haoxin-web/excalidraw-element";import{orderByFractionalIndex as bD}from"@haoxin-web/excalidraw-element";import{Emitter as dD}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as mD,StoreChange as pD,StoreDelta as uD}from"@haoxin-web/excalidraw-element";var Yi=class extends uD{applyTo(o,t,r){let[n,i]=this.elements.applyTo(o,r.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,n);return[n,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,r,n){return super.applyLatestChanges(o,t,r,n)}},vn=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},fl=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new dD);I(this,"undoStack",[]);I(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof Yi)return;let t=Yi.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new vn(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r))}perform(o,t,r,n){try{let i=r();if(i===null)return;let a=mD.IMMEDIATELY,l=this.store.snapshot,s=o,m=t,c=!1;for(;i;){try{[s,m,c]=i.applyTo(s,m,l);let d=l.elements,p=l.maybeClone(a,s,m),u=pD.create(l,p),f=Yi.applyLatestChanges(i,d,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{n(i)}if(c)break;i=r()}return[s,m]}finally{this.onHistoryChangedEmitter.trigger(new vn(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let r=Yi.inverse(t);return o.push(r)}};import{useEffect as hD,useState as gD}from"react";var ng=(e,o)=>{let[t,r]=gD(o);return hD(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as O2}from"react/jsx-runtime";var N2=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:ig.EVENTUALLY};let[n,i]=r,a=bD(Array.from(n.values()));return{appState:i,elements:a,captureUpdate:ig.NEVER}}return{captureUpdate:ig.EVENTUALLY}},B2=e=>({name:"undo",label:"buttons.undo",icon:rp,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>N2(n,t,()=>e.undo(R2(o),t)),keyTest:o=>o[bl.CTRL_OR_CMD]&&ag(o,bl.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:r}=ng(e.onHistoryChangedEmitter,new vn(e.isUndoStackEmpty,e.isRedoStackEmpty));return O2(z,{type:"button",icon:rp,"aria-label":h("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-undo"})}}),F2=e=>({name:"redo",label:"buttons.redo",icon:np,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>N2(n,t,()=>e.redo(R2(o),t)),keyTest:o=>o[bl.CTRL_OR_CMD]&&o.shiftKey&&ag(o,bl.Z)||fD&&o.ctrlKey&&!o.shiftKey&&ag(o,bl.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:r}=ng(e.onHistoryChangedEmitter,new vn(e.isUndoStackEmpty,e.isRedoStackEmpty));return O2(z,{type:"button",icon:np,"aria-label":h("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-redo"})}});import{getFontString as xD}from"@haoxin-web/excalidraw-common";import{newElementWith as ED}from"@haoxin-web/excalidraw-element";import{measureText as yD}from"@haoxin-web/excalidraw-element";import{isTextElement as z2}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as wD}from"@haoxin-web/excalidraw-element";var H2=F({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=J(e,o);return n.length===1&&z2(n[0])&&!n[0].autoResize},perform:(e,o,t,r)=>{let n=J(e,o);return{appState:o,elements:e.map(i=>{if(i.id===n[0].id&&z2(i)){let a=yD(i.originalText,xD(i),i.lineHeight);return ED(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:wD.IMMEDIATELY}}});import{CODES as vD,KEYS as TD}from"@haoxin-web/excalidraw-common";import{CaptureUpdateAction as ID}from"@haoxin-web/excalidraw-element";var lg=F({name:"viewMode",label:"labels.viewMode",icon:Kn,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:ID.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[TD.CTRL_OR_CMD]&&e.altKey&&e.code===vD.R});import{isPromiseLike as CD}from"@haoxin-web/excalidraw-common";import{jsx as SD}from"react/jsx-runtime";var sg=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&ae(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},kd=class{constructor(o,t,r,n){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"renderAction",(o,t)=>{let r=this.app.props.UIOptions.canvasActions,n=this.getElementsIncludingDeleted(),i=this.getAppState(),a=this.actions[o];if(a&&"PanelComponent"in a&&(!(o in r)||r[o])&&(!a.predicate||a.predicate(n,i,this.app.props,this.app))){let l=a.PanelComponent;l.displayName="PanelComponent";let s=m=>{sg(a,"ui",i,n,this.app,m),this.updater(a.perform(this.getElementsIncludingDeleted(),this.getAppState(),m,this.app))};return SD(l,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=i=>{if(CD(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=r,this.app=n}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,r=this.getElementsIncludingDeleted(),n=this.getAppState(),i=this.app.props,a=Object.values(this.actions).sort((m,c)=>(c.keyPriority||0)-(m.keyPriority||0)).filter(m=>(m.name in t?t[m.name]:!0)&&m.keyTest&&(!m.predicate||m.predicate(r,n,i,this.app))&&m.keyTest(o,n,r,this.app));if(a.length!==1)return a.length>1&&console.warn("Canceling as multiple actions match this shortcut",a),!1;let l=a[0];if(n.viewModeEnabled&&l.viewMode!==!0)return!1;let s=null;return sg(l,"keyboard",n,r,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(a[0].perform(r,n,s,this.app)),!0}executeAction(o,t="api",r=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();sg(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var Md=class{constructor(){I(this,"targets",new WeakMap);I(this,"rafIds",new WeakMap)}register(o,t){this.targets.set(o,{callback:t,stopped:!0})}start(o){let t=this.targets.get(o);t&&(this.rafIds.has(o)||(this.targets.set(o,{...t,stopped:!1}),this.scheduleFrame(o)))}stop(o){let t=this.targets.get(o);t&&!t.stopped&&this.targets.set(o,{...t,stopped:!0}),this.cancelFrame(o)}constructFrame(o){return t=>{let r=this.targets.get(o);if(!r)return;let n=this.onFrame(r,t);!r.stopped&&!n?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var cg=e=>{let o=Array.from(e.values());return{x:G2(o,t=>t.x)/o.length,y:G2(o,t=>t.y)/o.length}},dg=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),G2=(e,o)=>e.reduce((t,r)=>t+o(r),0);import{pointFrom as W,pointRotateRads as Rr,rangeInclusive as qt,rangeIntersection as Ld,rangesOverlap as Pd}from"@haoxin-web/excalidraw-math";import{TOOL_TYPE as Tn,KEYS as U2}from"@haoxin-web/excalidraw-common";import{getCommonBounds as mg,getDraggedElementsBounds as pg,getElementAbsoluteCoords as kD}from"@haoxin-web/excalidraw-element";import{isBoundToContainer as X2}from"@haoxin-web/excalidraw-element";import{getMaximumGroups as K2}from"@haoxin-web/excalidraw-element";import{getSelectedElements as MD,getVisibleAndNonSelectedElements as Z2}from"@haoxin-web/excalidraw-element";var LD=8,W2=99999,Ad=e=>LD/e,vt=class vt{};I(vt,"referenceSnapPoints",null),I(vt,"visibleGaps",null),I(vt,"setReferenceSnapPoints",o=>{vt.referenceSnapPoints=o}),I(vt,"getReferenceSnapPoints",()=>vt.referenceSnapPoints),I(vt,"setVisibleGaps",o=>{vt.visibleGaps=o}),I(vt,"getVisibleGaps",()=>vt.visibleGaps),I(vt,"destroy",()=>{vt.referenceSnapPoints=null,vt.visibleGaps=null});var Jt=vt,Nr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,tr=({event:e,app:o,selectedElements:t})=>{if(e){let r=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||r)&&(o.state.objectsSnapModeEnabled&&!e[U2.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[U2.CTRL_OR_CMD]&&!Nr(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},PD=(e,o,t=.01)=>Math.abs(e-o)<=t,xl=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,m,c,d,p]=kD(a,o);n&&(l+=n.x,m+=n.x,d+=n.x,s+=n.y,c+=n.y,p+=n.y);let u=(m-l)/2,f=(c-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=Rr(W(l,s+f),W(d,p),a.angle),x=Rr(W(l+u,s),W(d,p),a.angle),w=Rr(W(m,s+f),W(d,p),a.angle),E=Rr(W(l+u,c),W(d,p),a.angle),y=W(d,p);i=t?[b,x,w,E]:[b,x,w,E,y]}else{let b=Rr(W(l,s),W(d,p),a.angle),x=Rr(W(m,s),W(d,p),a.angle),w=Rr(W(l,c),W(d,p),a.angle),E=Rr(W(m,c),W(d,p),a.angle),y=W(d,p);i=t?[b,x,w,E]:[b,x,w,E,y]}}else if(e.length>1){let[a,l,s,m]=pg(e,n??{x:0,y:0}),c=s-a,d=m-l,p=W(a,l),u=W(s,l),f=W(a,m),b=W(s,m),x=W(a+c/2,l+d/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>W(Re(a[0]),Re(a[1])))},$2=(e,o,t,r)=>Z2(e,o,t,r),j2=(e,o,t,r)=>{let n=$2(e,o,t,r),i=K2(n,r).filter(d=>!(d.length===1&&X2(d[0]))).map(d=>mg(d).map(p=>Re(p))),a=i.sort((d,p)=>d[0]-p[0]),l=[],s=0;e:for(let d=0;d<a.length;d++){let p=a[d];for(let u=d+1;u<a.length;u++){if(++s>W2)break e;let f=a[u],[,b,x,w]=p,[E,y,,v]=f;x<E&&Pd(qt(b,w),qt(y,v))&&l.push({startBounds:p,endBounds:f,startSide:[W(x,b),W(x,w)],endSide:[W(E,y),W(E,v)],length:E-x,overlap:Ld(qt(b,w),qt(y,v))})}}let m=i.sort((d,p)=>d[1]-p[1]),c=[];s=0;e:for(let d=0;d<m.length;d++){let p=m[d];for(let u=d+1;u<m.length;u++){if(++s>W2)break e;let f=m[u],[b,,x,w]=p,[E,y,v]=f;w<y&&Pd(qt(b,x),qt(E,v))&&c.push({startBounds:p,endBounds:f,startSide:[W(b,w),W(x,w)],endSide:[W(E,y),W(v,y)],length:y-w,overlap:Ld(qt(b,x),qt(E,v))})}}return{horizontalGaps:l,verticalGaps:c}},Y2=(e,o,t,r,n,i,a)=>{if(!tr({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=Jt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:m}=l,[c,d,p,u]=pg(e,o).map(x=>Re(x)),f=(c+p)/2,b=(d+u)/2;for(let x of s){if(!Pd(qt(d,u),x.overlap))continue;let w=x.startSide[0][0]+x.length/2,E=Re(w-f);if(x.length>p-c&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(n.length=0),a.x=Math.abs(E);let L={type:"gap",direction:"center_horizontal",gap:x,offset:E};n.push(L);continue}let[,,v]=x.endBounds,C=c-v,S=Re(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(n.length=0),a.x=Math.abs(S);let L={type:"gap",direction:"side_right",gap:x,offset:S};n.push(L);continue}let[P,,,]=x.startBounds,M=P-p,R=Re(M-x.length);if(Math.abs(R)<=a.x){Math.abs(R)<a.x&&(n.length=0),a.x=Math.abs(R);let L={type:"gap",direction:"side_left",gap:x,offset:R};n.push(L);continue}}for(let x of m){if(!Pd(qt(c,p),x.overlap))continue;let w=x.startSide[0][1]+x.length/2,E=Re(w-b);if(x.length>u-d&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let L={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(L);continue}let[,v,,]=x.startBounds,C=v-u,S=Re(C-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let L={type:"gap",direction:"side_top",gap:x,offset:S};i.push(L);continue}let[,,,P]=x.endBounds,M=Re(d-P),R=x.length-M;if(Math.abs(R)<=a.y){Math.abs(R)<a.y&&(i.length=0),a.y=Math.abs(R);let L={type:"gap",direction:"side_bottom",gap:x,offset:R};i.push(L);continue}}}},q2=(e,o,t,r)=>{let n=$2(e,o,t,r);return K2(n,r).filter(i=>!(i.length===1&&X2(i[0]))).flatMap(i=>xl(i,r))},Vi=(e,o,t,r,n,i,a)=>{if(!tr({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Jt.getReferenceSnapPoints();if(l)for(let s of o)for(let m of l){let c=m[0]-s[0],d=m[1]-s[1];Math.abs(c)<=a.x&&(Math.abs(c)<a.x&&(n.length=0),n.push({type:"point",points:[s,m],offset:c}),a.x=Math.abs(c)),Math.abs(d)<=a.y&&(Math.abs(d)<a.y&&(i.length=0),i.push({type:"point",points:[s,m],offset:d}),a.y=Math.abs(d))}},J2=(e,o,t,r,n)=>{let i=t.state,a=MD(e,i);if(!tr({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Re(o.x),o.y=Re(o.y);let l=[],s=[],m=Ad(i.zoom.value),c={x:m,y:m},d=xl(a,n,{dragOffset:o});Vi(a,d,t,r,l,s,c),Y2(a,o,t,r,l,s,c);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};c.x=0,c.y=0,l.length=0,s.length=0;let u={x:Re(o.x+p.x),y:Re(o.y+p.y)};Vi(a,xl(a,n,{dragOffset:u}),t,r,l,s,c),Y2(a,u,t,r,l,s,c);let f=ug(l,s),b=_D(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Re=e=>Math.round(e*10**6)/10**6,V2=e=>{let o=new Map;for(let t of e){let r=t.join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},ug=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=Re(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>W(Re(a[0]),Re(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=Re(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>W(Re(a[0]),Re(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:V2(i.map(a=>W(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:V2(i.map(a=>W(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},AD=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[Re(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},_D=(e,o,t)=>{let[r,n,i,a]=pg(e,o),l=[];for(let s of t){let[m,c,d,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,w=Ld(qt(n,a),s.gap.overlap),E=Ld(qt(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[W(s.gap.startSide[0][0],y),W(r,y)]},{type:"gap",direction:"horizontal",points:[W(i,y),W(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[W(y,s.gap.startSide[0][1]),W(y,n)]},{type:"gap",direction:"vertical",points:[W(y,a),W(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[W(d,y),W(u,y)]},{type:"gap",direction:"horizontal",points:[W(b,y),W(r,y)]})}break}case"side_left":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[W(i,y),W(m,y)]},{type:"gap",direction:"horizontal",points:[W(d,y),W(u,y)]})}break}case"side_top":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[W(y,a),W(y,c)]},{type:"gap",direction:"vertical",points:[W(y,p),W(y,f)]})}break}case"side_bottom":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[W(y,p),W(y,f)]},{type:"gap",direction:"vertical",points:[W(y,x),W(y,n)]})}break}}}return AD(l.map(s=>({...s,points:s.points.map(m=>W(Re(m[0]),Re(m[1])))})))},hg=(e,o,t,r,n,i)=>{if(!tr({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!PD(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,m]=mg(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(m+=n.y));let c=[];if(i)switch(i){case"e":{c.push(W(s,l),W(s,m));break}case"w":{c.push(W(a,l),W(a,m));break}case"n":{c.push(W(a,l),W(s,l));break}case"s":{c.push(W(a,m),W(s,m));break}case"ne":{c.push(W(s,l));break}case"nw":{c.push(W(a,l));break}case"se":{c.push(W(s,m));break}case"sw":{c.push(W(a,m));break}}let d=Ad(t.state.zoom.value),p={x:d,y:d},u=[],f=[];Vi(o,c,t,r,u,f,p);let b={x:u[0]?.offset??0,y:f[0]?.offset??0};p.x=0,p.y=0,u.length=0,f.length=0;let[x,w,E,y]=mg(e).map(S=>Re(S)),v=[W(x,w),W(x,y),W(E,w),W(E,y)];Vi(e,v,t,r,u,f,p);let C=ug(u,f);return{snapOffset:b,snapLines:C}},Q2=(e,o,t,r,n,i)=>{if(!tr({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[W(r.x+n.x,r.y+n.y)],l=Ad(o.state.zoom.value),s={x:l,y:l},m=[],c=[];Vi([e],a,o,t,m,c,s);let d={x:m[0]?.offset??0,y:c[0]?.offset??0};s.x=0,s.y=0,m.length=0,c.length=0;let p=xl([e],i,{boundingBoxCorners:!0,omitCenter:!0});Vi([e],p,o,t,m,c,s);let u=ug(m,c);return{snapOffset:d,snapLines:u}},ev=(e,o,t,r,n)=>{if(!tr({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Z2(e,[],o.state,n),a=Ad(o.state.zoom.value),l={x:a,y:a},s=[],m=[];for(let c of i){let d=xl([c],n);for(let p of d){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(m.length=0),m.push({type:"pointer",points:[p,W(p[0],t.y)],direction:"vertical"}),l.x=u);let f=p[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,W(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:m.length>0?m[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...m,...s]}},tv=e=>e===Tn.rectangle||e===Tn.ellipse||e===Tn.diamond||e===Tn.frame||e===Tn.magicframe||e===Tn.image||e===Tn.text;import{pointFrom as _d}from"@haoxin-web/excalidraw-math";import{DEFAULT_FONT_FAMILY as DD,DEFAULT_FONT_SIZE as RD,TEXT_ALIGN as ND,VERTICAL_ALIGN as BD,getSizeFromPoints as FD,randomId as OD,arrayToMap as zD,assertNever as ov,cloneJSON as iv,getFontString as HD,isDevEnv as GD,toBrandedType as UD,getLineHeight as WD}from"@haoxin-web/excalidraw-common";import{bindLinearElement as rv}from"@haoxin-web/excalidraw-element";import{newArrowElement as YD,newElement as El,newFrameElement as VD,newImageElement as XD,newLinearElement as KD,newMagicFrameElement as ZD,newTextElement as Rd}from"@haoxin-web/excalidraw-element";import{measureText as $D,normalizeText as jD}from"@haoxin-web/excalidraw-element";import{isArrowElement as qD}from"@haoxin-web/excalidraw-element";import{syncInvalidIndices as JD}from"@haoxin-web/excalidraw-element";import{redrawTextBoundingBox as QD}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as eR}from"@haoxin-web/excalidraw-element";import{getCommonBounds as tR}from"@haoxin-web/excalidraw-element";import{Scene as oR}from"@haoxin-web/excalidraw-element";var Dd={width:100,height:0},Qt=100,rR=(e,o,t)=>{let r=Rd({x:0,y:0,textAlign:ND.CENTER,verticalAlign:BD.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),QD(r,e,t),[e,r]},nv=(e,o,t,r,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let c=o?.width??Qt,d=o?.height??Qt,p;o.id&&(p=r.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-c,f=o.y||e.y-d/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=Rd({x:u,y:f,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=El({x:u,y:f,width:c,height:d,...p,...o,type:b});break}default:ov(e,`Unhandled element start type "${o.type}"`,!0)}rv(e,i,"start",n)}}if(t){let c=t?.height??Qt,d=t?.width??Qt,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,f=t.y||e.y-c/2,b=p?p.type:t.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=Rd({x:u,y:f,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=El({x:u,y:f,width:d,height:c,...p,...t,type:b});break}default:ov(e,`Unhandled element end type "${b}"`,!0)}rv(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,m=iv(e.points);return e.points[l][0]>e.points[l-1][0]&&(m[0][0]=s,m[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(m[0][0]=-s,m[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(m[0][1]=s,m[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(m[0][1]=-s,m[l][1]+=s),Object.assign(e,eR.getNormalizeElementPointsAndCoords({...e,points:m})),{linearElement:e,startBoundElement:i,endBoundElement:a}},gg=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>JD(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>UD(zD(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Xi=(e,o)=>{if(!e)return[];let t=iv(e),r=new gg,n=new Map,i=new Map;for(let s of t){let m,c=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:OD()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||Qt,u=s?.label?.text&&s.height===void 0?0:s?.height||Qt;m=El({...s,width:p,height:u});break}case"line":{let p=s.width||Dd.width,u=s.height||Dd.height;m=KD({width:p,height:u,points:[_d(0,0),_d(p,u)],...s});break}case"arrow":{let p=s.width||Dd.width,u=s.height||Dd.height;m=YD({width:p,height:u,endArrowhead:"arrow",points:[_d(0,0),_d(p,u)],...s,type:"arrow"}),Object.assign(m,FD(m.points));break}case"text":{let p=s?.fontFamily||DD,u=s?.fontSize||RD,f=s?.lineHeight||WD(p),b=s.text??"",x=jD(b),w=$D(x,HD({fontFamily:p,fontSize:u}),f);m=Rd({width:w.width,height:w.height,fontFamily:p,fontSize:u,...s});break}case"image":{m=XD({width:s?.width||Qt,height:s?.height||Qt,...s});break}case"frame":{m=VD({x:0,y:0,...s});break}case"magicframe":{m=ZD({x:0,y:0,...s});break}case"triangle":{m=El({width:s?.width||Qt,height:s?.height||Qt,...s,type:"triangle"});break}case"pentagon":{m=El({width:s?.width||Qt,height:s?.height||Qt,...s,type:"pentagon"});break}case"freedraw":case"iframe":case"embeddable":{m=s;break}default:continue}r.getElement(m.id)?console.error(`Duplicate id found for ${m.id}`):(r.add(m),n.set(m.id,s),c&&i.set(c,m.id))}let a=r.getElementsMap(),l=new oR(a);for(let[s,m]of n){let c=r.getElement(s);switch(m.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(m.label?.text){let[d,p]=rR(c,m?.label,l);if(r.add(d),r.add(p),qD(d)){let u=m.type==="arrow"?m?.start:void 0,f=m.type==="arrow"?m?.end:void 0;if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}if(f&&f.id){let E=i.get(f.id);E&&Object.assign(f,{id:E})}let{linearElement:b,startBoundElement:x,endBoundElement:w}=nv(d,u,f,r,l);d=b,r.add(b),r.add(x),r.add(w)}}else switch(m.type){case"arrow":{let{start:d,end:p}=m;if(d&&d.id){let x=i.get(d.id);Object.assign(d,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=nv(c,d,p,r,l);r.add(u),r.add(f),r.add(b);break}}break}}}for(let[s,m]of n){if(m.type!=="frame"&&m.type!=="magicframe")continue;let c=r.getElement(s);if(!c)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let d=[];m.children.forEach(C=>{let S=i.get(C);if(!S)throw new Error(`Element with ${C} wasn't mapped correctly`);let P=r.getElement(S);if(!P)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(P,{frameId:c.id}),P?.boundElements?.forEach(M=>{let R=r.getElement(M.id);if(!R)throw new Error(`Bound element with id ${M.id} doesn't exist`);Object.assign(R,{frameId:c.id}),d.push(R)}),d.push(P)});let[p,u,f,b]=tR(d),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let w=c?.x||p,E=c?.y||u,y=c?.width||f-p,v=c?.height||b-u;Object.assign(c,{x:w,y:E,width:y,height:v}),GD()&&m.children.length&&(c?.x||c?.y||c?.width||c?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return r.getElements()};import{isElementInViewport as DR}from"@haoxin-web/excalidraw-element";import{memoize as RR,toBrandedType as NR}from"@haoxin-web/excalidraw-common";import{pointFrom as mR,pointsEqual as pR}from"@haoxin-web/excalidraw-math";import Bd from"open-color";import{arrayToMap as uR,DEFAULT_TRANSFORM_HANDLE_SPACING as Tg,FRAME_STYLE as pv,invariant as uv,THEME as hR,throttleRAF as gR}from"@haoxin-web/excalidraw-common";import{FIXED_BINDING_DISTANCE as bg,maxBindingGap as Ev}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as Br}from"@haoxin-web/excalidraw-element";import{getOmitSidesForDevice as xg,getTransformHandles as fR,getTransformHandlesFromCoords as bR,shouldShowBoundingBox as xR}from"@haoxin-web/excalidraw-element";import{isElbowArrow as yl,isFrameLikeElement as hv,isImageElement as gv,isLinearElement as ER,isLineElement as yR,isTextElement as fv}from"@haoxin-web/excalidraw-element";import{renderSelectionElement as wR}from"@haoxin-web/excalidraw-element";import{getElementsInGroup as wg,getSelectedGroupIds as vR,isSelectedViaGroup as TR,selectGroupsFromGivenElements as IR}from"@haoxin-web/excalidraw-element";import{getCommonBounds as vg,getElementAbsoluteCoords as wl}from"@haoxin-web/excalidraw-element";import{pointFrom as ht}from"@haoxin-web/excalidraw-math";import{THEME as nR}from"@haoxin-web/excalidraw-common";var iR="#ff6b6b",aR="#ff0000",av=1,lv=2,sv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===nR.LIGHT||o.zenModeEnabled?iR:aR,r=(o.zenModeEnabled?av*1.5:av)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let n of o.snapLines)n.type==="pointer"?(e.lineWidth=r,e.strokeStyle=t,sR(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,cR(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,lR(n,e,o));e.restore()},lR=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];eo(r,n,o)}for(let r of e.points)cv(r,t,o)},sR=(e,o,t)=>{cv(e.points[0],t,o),t.zenModeEnabled||eo(e.points[0],e.points[1],o)},cv=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?lv*1.5:lv)/t.zoom.value;r.beginPath(),r.moveTo(e-n,o-n),r.lineTo(e+n,o+n),r.moveTo(e+n,o-n),r.lineTo(e-n,o+n),r.stroke(),r.restore()},eo=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},cR=(e,o,t,r,n)=>{let i=8/r.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];r.zenModeEnabled||eo(ht(e[0],e[1]-i),ht(e[0],e[1]+i),n),eo(ht(s[0]-l,s[1]-a),ht(s[0]-l,s[1]+a),n),eo(ht(s[0]+l,s[1]-a),ht(s[0]+l,s[1]+a),n),r.zenModeEnabled||(eo(ht(o[0],o[1]-i),ht(o[0],o[1]+i),n),eo(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||eo(ht(e[0]-i,e[1]),ht(e[0]+i,e[1]),n),eo(ht(s[0]-a,s[1]-l),ht(s[0]+a,s[1]-l),n),eo(ht(s[0]-a,s[1]+l),ht(s[0]+a,s[1]+l),n),r.zenModeEnabled||(eo(ht(o[0]-i,o[1]),ht(o[0]+i,o[1]),n),eo(e,o,n))}};import{getGlobalCSSVariable as Nd}from"@haoxin-web/excalidraw-common";import{getCommonBounds as dR}from"@haoxin-web/excalidraw-element";var No=4,Ut=6,dv="rgba(0,0,0,0.3)",mv=(e,o,t,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,i,a,l]=dR(e),s=o/r.zoom.value,m=t/r.zoom.value,c={top:parseInt(Nd("sat"))||0,bottom:parseInt(Nd("sab"))||0,left:parseInt(Nd("sal"))||0,right:parseInt(Nd("sar"))||0},d=Uo().rtl,p=-r.scrollX+c.left,u=-r.scrollY+c.top,f=p+s-c.right,b=u+m-c.bottom,x=Math.min(n,p),w=Math.min(i,u),E=Math.max(a,f),y=Math.max(l,b),v=a-n,C=l-i,S=E-x,P=y-w,M=Math.max(No*2,c.left+c.right)+Ut*2,R=o*(s/S)-M,L=Math.max(No*2,c.top+c.bottom)+Ut*2,k=t*(m/P)-L,N=S>v?S*r.zoom.value/(R+M):o/(R+M),O=P>C?P*r.zoom.value/(k+L):t/(k+L);return{horizontal:p===x&&f===E?null:{x:Math.max(c.left,No)+Ut+(p-x)/S*o,y:t-Ut-Math.max(No,c.bottom),width:R,height:Ut,deltaMultiplier:N},vertical:u===w&&b===y?null:{x:d?Math.max(c.left,No):o-Ut-Math.max(c.right,No),y:Math.max(c.top,No)+Ut+(u-w)/P*t,width:Ut,height:k,deltaMultiplier:O}}},fg=(e,o,t)=>{let[r,n]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:r||n,isOverHorizontal:r,isOverVertical:n}};var CR=(e,o)=>{uv(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;uv(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),yv(t,e,o),e.restore()},SR=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(n))return;let i=Br.getElement(r,t);if(!i)return;let a=Br.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),yv(a,e,o),e.restore()},yv=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",ha(o,e[0],e[1],Br.POINT_HANDLE_SIZE/t.zoom.value,!1)},Eg=(e,o,t,r,n,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),ha(e,t[0],t[1],(a?r*(o.selectedLinearElement?.isEditing?1.5:2):r)/o.zoom.value,!i,!a||n)},kR=(e,o,t,r)=>{let n=Ev(o,o.width,o.height,r);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":D1(e,o,t,n);break;case"diamond":N1(e,n,o,t);break;case"ellipse":{let[i,a,l,s]=wl(o,t),m=l-i,c=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=n-bg,R1(e,m+n+bg,c+n+bg,i+m/2,a+c/2,o.angle);break}}},MR=(e,o,t,r)=>{let[n,i,a]=o,l=Ev(a,a.width,a.height,r);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(m=>{let[c,d]=Br.getPointAtIndexGlobalCoordinates(n,m,t);ha(e,c,d,l,!0)})},wv=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:m,cy:c,dashed:d,activeEmbeddable:p}=t,u=a-n,f=l-i,x=(t.padding??Tg*2)/o.zoom.value,w=8/o.zoom.value,E=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],d&&e.setLineDash([w,E+(w+E)*(y-1)]),e.lineDashOffset=(w+E)*v,ga(e,n-x,i-x,u+x*2,f+x*2,m,c,r);e.restore()},LR=(e,o,t,r)=>{let n=Array.isArray(t)?MR:kR;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},PR=(e,o,t,r)=>{let[n,i,a,l]=wl(t,r),s=a-n,m=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=pv.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),ga(e,n,i,s,m,n+s/2,i+m/2,t.angle,!1,pv.radius/o.zoom.value),e.restore()},bv=(e,o,t,r)=>{let{colors:n=["rgb(0,118,255)"],dashed:i=!1}=r||{},a=t.filter(c=>c.groupIds.length===0),l=t.filter(c=>c.groupIds.length>0),s=c=>{let[d,p,u,f]=vg(c);return{angle:0,x1:d,x2:u,y1:p,y2:f,selectionColors:n,dashed:i,cx:d+(u-d)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},m=c=>{let d=wg(t,c);return s(d)};Object.entries(IR(l,o)).filter(([c,d])=>d).map(([c,d])=>c).map(c=>m(c)).concat(a.map(c=>s([c]))).forEach(c=>wv(e,o,c))},yg=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=Br.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=Br,a=o.selectedLinearElement?.isEditing?i:i/2,l=yl(t),s=yR(t);if(n.forEach((m,c)=>{if(l&&c!==0&&c!==n.length-1)return;let d=c>0&&(c!==n.length-1||!s||!t.polygon)&&pR(m,c===n.length-1?n[0]:n[c-1],2/o.zoom.value),p=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(c);s&&t.polygon&&!p&&c===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Eg(e,o,m,a,p,!1,d)}),yl(t)){let m=t.fixedSegments?.map(c=>c.index)||[];n.slice(0,-1).forEach((c,d)=>{Br.isSegmentTooShort(t,n[d+1],n[d],d,o.zoom)||Eg(e,o,mR((c[0]+n[d+1][0])/2,(c[1]+n[d+1][1])/2),i/2,!1,!m.includes(d+1),!1)})}else Br.getEditorMidPoints(t,r,o).filter((c,d,p)=>c!==null&&!(yl(t)&&(d===0||d===p.length-1))).forEach(c=>{(o.selectedLinearElement?.isEditing||n.length===2)&&Eg(e,o,c,i/2,!1,!0,!1)});e.restore()},xv=(e,o,t,r,n)=>{Object.keys(r).forEach(i=>{let a=r[i];if(a!==void 0){let[l,s,m,c]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?ha(e,l+m/2,s+c/2,m/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,m,c,2/t.zoom.value),e.fill(),e.stroke()):ga(e,l,s,m,c,l+m/2,s+c/2,n,!0),e.restore()}})},AR=(e,o,t,r,n)=>{let[i,a,,,l,s]=wl(r,n),m=3,c=20,d=m/t.zoom.value,p=d/2,u=l-i+d,f=s-a+d,b=Math.min(c/t.zoom.value,u),x=Math.min(c/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=d,[[[-u,-f],[0,p],[b,p],[p,0],[p,x]],[[u-p,-f],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,f],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,f],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(E=>{let[[y,v],[C,S],[P,M],[R,L],[k,N]]=E;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+C,v+S),e.lineTo(y+P,v+M),e.stroke(),e.beginPath(),e.moveTo(y+R,v+L),e.lineTo(y+k,v+N),e.stroke(),e.restore()}),e.restore()},_R=(e,o,t,r)=>{o.save();let n=Tg*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,m=-(i/2+n),c=-(a/2+n);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=r,o.strokeRect(m,c,i,a),o.restore()},vv=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:r,allElementsMap:n,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[m,c]=ls(e,i),d=ss({canvas:e,scale:i,normalizedWidth:m,normalizedHeight:c});d.save(),d.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===b.id&&b&&(p=b)}),p&&yg(d,a,p,o),a.selectionElement&&!a.isCropping)try{wR(a.selectionElement,d,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&fv(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&_R(b,d,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{LR(d,a,b,o)}),a.frameToHighlight&&PR(d,a,a.frameToHighlight,o),a.elementsToHighlight&&bv(d,a,a.elementsToHighlight),a.activeLockedId){let b=n.get(a.activeLockedId),x=b?[b]:wg(n,a.activeLockedId);bv(d,a,x,{colors:["#ced4da"],dashed:!0})}let u=r.some(b=>hv(b));if(r.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===r[0].id&&yg(d,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(w=>w.id===b.elementId);b.segmentMidPointHoveredCoords?CR(d,a):(yl(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&SR(d,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=xR(r,a),x=r.length===1&&ER(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&yg(d,a,r[0],o);let w=l.selectionColor||Bd.black;if(b){let E=uR(r),y=[];for(let C of o.values()){let S=[],P=l.remoteSelectedElementIds.get(C.id);if(x&&yl(C)&&(C.startBinding||C.endBinding)||(E.has(C.id)&&!TR(a,C)&&S.push(w),P&&S.push(...P.map(M=>fn(M,a.collaborators.get(M))))),S.length){let[M,R,L,k,N,O]=wl(C,o,!0);y.push({angle:C.angle,x1:M,y1:R,x2:L,y2:k,selectionColors:C.locked?["#ced4da"]:S,dashed:!!P||C.locked,cx:N,cy:O,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||gv(C)?0:void 0})}}let v=C=>{let S=wg(o,C),[P,M,R,L]=vg(S);y.push({angle:0,x1:P,x2:R,y1:M,y2:L,selectionColors:S.some(k=>k.locked)?["#ced4da"]:[Bd.black],dashed:!0,cx:P+(R-P)/2,cy:M+(L-M)/2,activeEmbeddable:!1})};for(let C of vR(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>wv(d,a,C))}if(d.save(),d.translate(a.scrollX,a.scrollY),r.length===1){d.fillStyle=Bd.white;let E=fR(r[0],a.zoom,o,"mouse",xg(s));if(!a.viewModeEnabled&&b&&!fv(a.editingTextElement)&&!a.croppingElementId&&xv(d,l,a,E,r[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&gv(y)&&AR(d,l,a,y,o)}}else if(r.length>1&&!a.isRotating&&!r.some(E=>E.locked)){let E=Tg*2/a.zoom.value;d.fillStyle=Bd.white;let[y,v,C,S]=vg(r,o),P=d.getLineDash();d.setLineDash([2/a.zoom.value]);let M=d.lineWidth;d.lineWidth=1/a.zoom.value,d.strokeStyle=w,ga(d,y-E,v-E,C-y+E*2,S-v+E*2,(y+C)/2,(v+S)/2,0),d.lineWidth=M,d.setLineDash(P);let R=bR([y,v,C,S,(y+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...xg(s),rotation:!0}:xg(s));r.some(L=>!L.locked)&&xv(d,l,a,R,0)}d.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:w})=>{let E=o.get(b);if(E){let[y,v,,,C,S]=wl(E,o,!0);d.save(),a.theme===hR.LIGHT?x?d.fillStyle="rgba(255, 124, 0, 0.4)":d.fillStyle="rgba(255, 226, 0, 0.4)":x?d.fillStyle="rgba(229, 82, 0, 0.4)":d.fillStyle="rgba(99, 52, 0, 0.4)";let P=hv(E)?a.zoom.value:1;d.translate(a.scrollX,a.scrollY),d.translate(C,S),d.rotate(E.angle),w.forEach(M=>{(M.showOnCanvas||x)&&d.fillRect(y+M.offsetX/P-C,v+M.offsetY/P-S,M.width/P,M.height/P)}),d.restore()}}),sv(d,a),d.restore(),RE({context:d,renderConfig:l,appState:a,normalizedWidth:m,normalizedHeight:c});let f;return l.renderScrollbars&&(f=mv(o,m,c,a),d.save(),d.fillStyle=dv,d.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&Bc(d,b.x,b.y,b.width,b.height,Ut/2)}),d.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},Ig=gR(e=>{let o=vv(e);e.callback?.(o)},{trailing:!0}),Tv=(e,o)=>{if(o){Ig(e);return}let t=vv(e);return e.callback(t),t};var vl=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:m,width:c})=>{let d=[];for(let p of r.values())DR(p,c,m,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&d.push(p);return d},t=({elements:r,editingTextElement:n,newElementId:i})=>{let a=NR(new Map);for(let l of r)i!==l.id&&(!n||n.type!=="text"||l.id!==n.id)&&a.set(l.id,l);return a};return RR(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m,editingTextElement:c,newElementId:d,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:c,newElementId:d}),b=o({elementsMap:f,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:m});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){Ig.cancel(),F1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as BR}from"@haoxin-web/excalidraw-common";import{getElementAbsoluteCoords as FR}from"@haoxin-web/excalidraw-element";import{jsx as HR}from"react/jsx-runtime";var OR=5,zR=(e,o,t)=>{let[r,n]=FR(e,t),{x:i,y:a}=BR({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},Cg=({children:e,element:o,elementsMap:t})=>{let r=Mo();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=zR(o,r,t);return HR("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:OR},children:e})};import{DEFAULT_LASER_COLOR as YR,easeOut as Cv}from"@haoxin-web/excalidraw-common";import{LaserPointer as GR}from"@excalidraw/laser-pointer";import{SVG_NS as Iv,getSvgPathFromStroke as UR,sceneCoordsToViewportCoords as WR}from"@haoxin-web/excalidraw-common";var or=class{constructor(o,t,r){this.animationFrameHandler=o;this.app=t;this.options=r;I(this,"currentTrail");I(this,"pastTrails",[]);I(this,"container");I(this,"trailElement");I(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(Iv,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Iv,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let r=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[r-1][0]===o&&this.currentTrail.originalPoints[r-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new GR(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=WR({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return UR(n,!0)}};var Fd=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");I(this,"localColor",YR);I(this,"setLocalColor",o=>{this.localColor=o});this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new or(o,t,{...this.getTrailOptions(),fill:()=>this.localColor})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let n=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(Cv(i),Cv(n))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let r;this.collabTrails.has(o)?r=this.collabTrails.get(o):(r=new or(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||fn(o,t)}),r.start(this.container),this.collabTrails.set(o,r)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!r.hasCurrentTrail&&r.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&r.hasCurrentTrail&&!r.hasLastPoint(t.pointer.x,t.pointer.y)&&r.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&r.hasCurrentTrail&&(r.addPointToPath(t.pointer.x,t.pointer.y),r.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as VR}from"react";import{unstable_batchedUpdates as Sv}from"react-dom";import{throttleRAF as XR}from"@haoxin-web/excalidraw-common";var Ae=e=>o=>{Sv(e,o)},Od=e=>XR(o=>{Sv(e,o)}),Ki=(()=>{let e;try{let t=VR.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as Sg,KEYS as Tl,CLASSES as kv,POINTER_BUTTON as KR,isWritableElement as ZR,getFontString as Mv,getFontFamilyString as Lv,isTestEnv as Pv,MIME_TYPES as $R}from"@haoxin-web/excalidraw-common";import{originalContainerCache as jR,updateOriginalContainerCache as Av}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as qR}from"@haoxin-web/excalidraw-element";import{bumpVersion as JR}from"@haoxin-web/excalidraw-element";import{getBoundTextElementId as QR,getContainerElement as kg,getTextElementAngle as e9,redrawTextBoundingBox as t9,getBoundTextMaxHeight as o9,getBoundTextMaxWidth as _v,computeContainerDimensionForBoundText as Dv,computeBoundTextPosition as r9,getBoundTextElement as n9}from"@haoxin-web/excalidraw-element";import{getTextWidth as i9}from"@haoxin-web/excalidraw-element";import{normalizeText as Rv}from"@haoxin-web/excalidraw-element";import{wrapText as a9}from"@haoxin-web/excalidraw-element";import{isArrowElement as zd,isBoundToContainer as l9,isTextElement as Nv}from"@haoxin-web/excalidraw-element";var s9=(e,o,t,r,n,i)=>{let{zoom:a}=r,l=180*t/Math.PI,s=e*(a.value-1)/2,m=o*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),o>i&&a.value!==1&&(m=i*(a.value-1)/2),`translate(${s}px, ${m}px) scale(${a.value}) rotate(${l}deg)`},Bv=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let m=(_,B)=>{if(!B.style.fontFamily||!B.style.fontSize)return!1;let K=B.style.fontFamily.replace(/"/g,"");return Lv({fontFamily:_.fontFamily})!==K||`${_.fontSize}px`!==B.style.fontSize},c=()=>{let _=l.state,B=l.scene.getElement(e);if(!B)return;let{textAlign:K,verticalAlign:j}=B,X=l.scene.getNonDeletedElementsMap();if(B&&Nv(B)){let q=B.x,se=B.y,ie=kg(B,l.scene.getNonDeletedElementsMap()),be=B.width,ue=B.height,ao=B.width,Io=B.height;if(ie&&B.containerId){if(zd(ie)){let sr=qR.getBoundTextElementPosition(ie,B,X);q=sr.x,se=sr.y}let os=m(B,d),pa;if(os?pa=Av(ie.id,ie.height):(pa=jR[ie.id],pa||(pa=Av(ie.id,ie.height))),ao=_v(ie,B),Io=o9(ie,B),!zd(ie)&&ue>Io){let sr=Dv(ue,ie.type);l.scene.mutateElement(ie,{height:sr});return}else if(!zd(ie)&&ie.height>pa.height&&ue<Io){let sr=Dv(ue,ie.type);l.scene.mutateElement(ie,{height:sr})}else{let{x:sr,y:zC}=r9(ie,B,X);q=sr,se=zC}}let[es,Fm]=r(q,se),DC=d.selectionStart,Om=d.selectionEnd,w1=d.value.length;if(DC===Om&&Om!==w1){let os=w1-Om;d.selectionStart=d.value.length-os,d.selectionEnd=d.value.length-os}ie?be+=.5:(ao=(_.width-8-es)/_.zoom.value,be=Math.min(be,ao)),ue*=1.05;let RC=Mv(B),v1=(_.height-Fm)/_.zoom.value;Object.assign(d.style,{font:RC,lineHeight:B.lineHeight,width:`${be}px`,height:`${ue}px`,left:`${es}px`,top:`${Fm}px`,transform:s9(be,ue,e9(B,ie),_,ao,v1),textAlign:K,verticalAlign:j,color:B.strokeColor,opacity:B.opacity/100,filter:"var(--theme-filter)",maxHeight:`${v1}px`});let ts=B.customData?.textStyle||{},NC=!!(ts.bold??l.state.currentTextBold),BC=!!(ts.italic??l.state.currentTextItalic),FC=!!(ts.underline??l.state.currentTextUnderline),OC=!!(ts.strikethrough??l.state.currentTextStrikethrough);d.style.fontWeight=NC?"700":"400",d.style.fontStyle=BC?"italic":"normal",d.style.textDecoration=[FC?"underline":"",OC?"line-through":""].filter(Boolean).join(" ")||"none",d.scrollTop=0,Pv()&&(d.style.fontFamily=Lv(B)),l.scene.mutateElement(B,{x:q,y:se})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(l9(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=n.originalText,c(),o&&(d.onpaste=async _=>{let B=(await $a(_)).findByType($R.text);if(!B)return;let K=Rv(B.value);if(!K)return;let j=kg(n,l.scene.getNonDeletedElementsMap()),X=Mv({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(j){let q=n9(j,l.scene.getNonDeletedElementsMap()),se=a9(`${d.value}${K}`,X,_v(j,q)),ie=i9(se,X);d.style.width=`${ie}px`}},d.oninput=()=>{let _=Rv(d.value);if(d.value!==_){let B=d.selectionStart;d.value=_,d.selectionStart=B,d.selectionEnd=B}o(d.value)}),d.onkeydown=_=>{if(!_.shiftKey&&Ec.keyTest(_,l.state,Object.values(l.scene.getNonDeletedElementsMap()),l))_.preventDefault(),l.actionManager.executeAction(Ec),c();else if(!_.shiftKey&&yc.keyTest(_,l.state,Object.values(l.scene.getNonDeletedElementsMap()),l))_.preventDefault(),l.actionManager.executeAction(yc),c();else if(!_.shiftKey&&wc.keyTest(_,l.state,Object.values(l.scene.getNonDeletedElementsMap()),l))_.preventDefault(),l.actionManager.executeAction(wc),c();else if(au.keyTest(_))l.actionManager.executeAction(au);else if(lu.keyTest(_))l.actionManager.executeAction(lu);else if(_.key===Tl.ESCAPE)_.preventDefault(),C=!0,S();else if(hn.keyTest(_))_.preventDefault(),S(),l.actionManager.executeAction(hn);else if(_.key===Tl.ENTER&&_[Tl.CTRL_OR_CMD]){if(_.preventDefault(),_.isComposing||_.keyCode===229)return;C=!0,S()}else if(_.key===Tl.TAB||_[Tl.CTRL_OR_CMD]&&(_.code===Sg.BRACKET_LEFT||_.code===Sg.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===Sg.BRACKET_LEFT?E():w(),d.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),w=()=>{let{selectionStart:_,selectionEnd:B}=d,K=y(),j=d.value;K.forEach(X=>{let q=j.slice(0,X),se=j.slice(X);j=`${q}${b}${se}`}),d.value=j,d.selectionStart=_+f,d.selectionEnd=B+f*K.length},E=()=>{let{selectionStart:_,selectionEnd:B}=d,K=y(),j=[],X=d.value;K.forEach(q=>{let se=X.slice(q,q+f).match(x);if(se){let ie=X.slice(0,q),be=X.slice(q+se[0].length);X=`${ie}${be}`,j.push(q)}}),d.value=X,j.length&&(_>j[j.length-1]?d.selectionStart=Math.max(_-f,j[j.length-1]):d.selectionStart=_,d.selectionEnd=Math.max(d.selectionStart,B-f*j.length))},y=()=>{let{selectionStart:_,selectionEnd:B,value:K}=d,j=K.slice(0,_).match(/[^\n]*$/)[0].length;return _=_-j,K.slice(_,B).split(`
23
+ `).reduce((q,se,ie,be)=>q.concat(ie?q[ie-1]+be[ie-1].length+1:_),[]).reverse()},v=_=>{_.target instanceof HTMLCanvasElement&&(_.preventDefault(),_.stopPropagation())},C=!1,S=()=>{if(O)return;O=!0,P();let _=l.scene.getElement(n.id);if(!_)return;let B=kg(_,l.scene.getNonDeletedElementsMap());if(B){if(d.value.trim()){let K=QR(B);!K||K!==n.id?l.scene.mutateElement(B,{boundElements:(B.boundElements||[]).concat({type:"text",id:n.id})}):zd(B)&&JR(B)}else l.scene.mutateElement(B,{boundElements:B.boundElements?.filter(K=>!Nv(K))});t9(_,B,l.scene)}t({viaKeyboard:C,nextOriginalText:d.value})},P=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,G&&G.disconnect(),window.removeEventListener("resize",c),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",L),window.removeEventListener("pointerup",M),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),k(),N(),d.remove()},M=_=>{window.removeEventListener("pointerup",M);let B=_?.target,K=B instanceof HTMLElement&&B.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=S,K||d.focus()})},R=()=>{d.onblur=null,window.addEventListener("pointerup",M),window.addEventListener("blur",S)},L=_=>{let B=_?.target;if(_.button===KR.WHEEL){B instanceof HTMLTextAreaElement&&(_.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(_)),R();return}let K=B instanceof HTMLElement&&B.classList.contains("properties-trigger");(_.target instanceof HTMLElement||_.target instanceof SVGElement)&&_.target.closest(`.${kv.SHAPE_ACTIONS_MENU}, .${kv.ZOOM_ACTIONS}`)&&!ZR(_.target)||K?R():_.target instanceof HTMLCanvasElement&&!Pv()&&requestAnimationFrame(()=>{S()})},k=l.scene.onUpdate(()=>{c(),!!document.activeElement?.closest(".properties-content")||d.focus()}),N=l.onScrollChangeEmitter.on(()=>{c()}),O=!1;s&&d.select(),M();let G=null;return i&&"ResizeObserver"in window?(G=new window.ResizeObserver(()=>{c()}),G.observe(i)):window.addEventListener("resize",c),d.onpointerdown=_=>_.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",L,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d),S};var Fv=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as x9}from"@haoxin-web/excalidraw-math";import{getElementLineSegments as E9}from"@haoxin-web/excalidraw-element";import{LinearElementEditor as y9}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as w9,isLinearElement as v9,isTextElement as T9}from"@haoxin-web/excalidraw-element";import{getFrameChildren as I9}from"@haoxin-web/excalidraw-element";import{selectGroupsForSelectedElements as C9}from"@haoxin-web/excalidraw-element";import{getContainerElement as S9}from"@haoxin-web/excalidraw-element";import{arrayToMap as k9,easeOut as Gv,isShallowEqual as M9}from"@haoxin-web/excalidraw-common";import{simplify as c9}from"points-on-curve";import{polygonFromPoints as d9,lineSegment as Ov,polygonIncludesPointNonZero as m9}from"@haoxin-web/excalidraw-math";import{computeBoundTextPosition as p9,doBoundsIntersect as u9,getBoundTextElement as h9,getElementBounds as g9,intersectElementWithLineSegment as zv}from"@haoxin-web/excalidraw-element";var Hv=e=>{let{lassoPath:o,elements:t,elementsMap:r,elementsSegments:n,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=c9(o,l));let m=t.filter(p=>!p.locked);a.clear(),i.clear();let c=o.reduce((p,u)=>[Math.min(p[0],u[0]),Math.min(p[1],u[1]),Math.max(p[2],u[0]),Math.max(p[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let p of m){let u=g9(p,r);u9(c,u)&&!i.has(p.id)&&!a.has(p.id)&&(f9(s,p,n)?a.add(p.id):b9(s,p,r)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},f9=(e,o,t)=>{let r=d9(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>m9(a,r))):!1},b9=(e,o,t)=>{let r=e.slice(1).map((i,a)=>Ov(e[a],i)).concat([Ov(e[e.length-1],e[0])]),n=h9(o,t);return r.some(i=>zv(o,t,i,0,!0).length>0||!!n&&zv({...n,...p9(o,n,t)},t,i,0,!0).length>0)};var Hd=class extends or{constructor(t,r){super(t,r,{animateTrail:!0,streamline:.4,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/(1/0)),s=(5e3-Math.min(5e3,n.totalLength-n.currentIndex))/5e3;return Math.min(Gv(s),Gv(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,m)=>(s[m]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let m=this.app.scene.getNonDeletedElement(s);if(m&&T9(m)){let c=S9(m,this.app.scene.getNonDeletedElementsMap());c&&(n[c.id]=!0,delete n[m.id])}}for(let[s]of Object.entries(n)){let m=this.app.scene.getNonDeletedElement(s);if(m&&w9(m)){let c=I9(this.app.scene.getNonDeletedElementsMap(),m.id);for(let d of c)delete n[d.id]}}let i=C9({editingGroupId:r.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),r,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&v9(this.app.scene.getNonDeletedElement(a[0]))?new y9(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(n=>x9(n[0],n[1])),r={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!M9(r,this.canvasTranslate??{})){this.canvasTranslate=r,this.elementsSegments=new Map;let n=k9(this.app.visibleElements);for(let i of this.app.visibleElements){let a=E9(i,n);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:n}=Hv({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(n)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,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 L9,easeOut as Uv,THEME as P9}from"@haoxin-web/excalidraw-common";import{computeBoundTextPosition as A9,getBoundTextElement as _9,intersectElementWithLineSegment as Wv,isPointInElement as D9}from"@haoxin-web/excalidraw-element";import{lineSegment as R9,pointFrom as N9}from"@haoxin-web/excalidraw-math";import{getElementsInGroup as Yv}from"@haoxin-web/excalidraw-element";import{shouldTestInside as B9}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as Vv,isBoundToContainer as Xv}from"@haoxin-web/excalidraw-element";import{getBoundTextElementId as Kv}from"@haoxin-web/excalidraw-element";var Gd=class extends or{constructor(t,r){super(t,r,{streamline:.2,size:5,keepHead:!0,sizeMapping:n=>{let l=Math.max(0,1-(performance.now()-n.pressure)/200),s=(10-Math.min(10,n.totalLength-n.currentIndex))/10;return Math.min(Uv(s),Uv(l))},fill:()=>r.state.theme===P9.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set)}startPath(t,r){this.endPath(),super.startPath(t,r),this.elementsToErase.clear()}addPointToPath(t,r,n=!1){return super.addPointToPath(t,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(t){let r=super.getCurrentTrail()?.originalPoints?.map(l=>N9(l[0],l[1]))||[];if(r.length<2)return[];let n=R9(r[r.length-1],r[r.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=L9(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(Zv(n,l,a)){let m=l.groupIds.at(-1);if(this.groupsToErase.has(m)){let c=Yv(this.app.scene.getNonDeletedElementsMap(),m);for(let d of c)this.elementsToErase.delete(d.id);this.groupsToErase.delete(m)}if(Xv(l)&&this.elementsToErase.delete(l.containerId),Vv(l)){let c=Kv(l);c&&this.elementsToErase.delete(c)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&Zv(n,l,a)){let m=l.groupIds.at(-1);if(!this.groupsToErase.has(m)){let c=Yv(this.app.scene.getNonDeletedElementsMap(),m);for(let d of c)this.elementsToErase.add(d.id);this.groupsToErase.add(m)}if(Vv(l)){let c=Kv(l);c&&this.elementsToErase.add(c)}Xv(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},Zv=(e,o,t)=>{let r=e[1];if(B9(o)&&D9(r,o,t))return!0;let n=_9(o,t);return Wv(o,t,e,0,!0).length>0||!!n&&Wv({...n,...A9(o,n,t)},t,e,0,!0).length>0};import{jsx as to,jsxs as $v}from"react/jsx-runtime";var F9=()=>$v("div",{"data-testid":"brave-measure-text-error",children:[to("p",{children:to(yt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>to("span",{style:{fontWeight:600},children:e})})}),to("p",{children:to(yt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>to("span",{style:{fontWeight:600},children:e})})}),to("p",{children:to(yt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>to("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),to("p",{children:to(yt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>to("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>$v("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),jv=F9;import W9 from"clsx";import Y9 from"react";import{useLayoutEffect as O9,useRef as qv,useEffect as Jv}from"react";import{unstable_batchedUpdates as z9}from"react-dom";import{KEYS as H9,queryFocusableElements as G9}from"@haoxin-web/excalidraw-common";import{jsx as U9}from"react/jsx-runtime";var Qv=({children:e,left:o,top:t,onCloseRequest:r,fitInViewport:n=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let m=qv(null);Jv(()=>{let d=m.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=u=>{if(u.key===H9.TAB){let f=G9(d),{activeElement:b}=document,x=f.findIndex(w=>w===b);b===d?(u.shiftKey?f[f.length-1]?.focus():f[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(f[f.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===f.length-1&&!u.shiftKey&&(f[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let c=qv(null);return O9(()=>{if(n&&m.current&&t!=null&&o!=null){let d=m.current,{width:p,height:u}=d.getBoundingClientRect();if(c.current?.top===t&&c.current?.left===o)return;c.current={top:t,left:o},p>=l?(d.style.width=`${l}px`,d.style.left="0px",d.style.overflowX="scroll"):o+p-i>l?d.style.left=`${l-p-10}px`:d.style.left=`${o}px`,u>=s?(d.style.height=`${s-20}px`,d.style.top="10px",d.style.overflowY="scroll"):t+u-a>s?d.style.top=`${s-u}px`:d.style.top=`${t}px`}},[t,o,n,l,s,i,a]),Jv(()=>{if(r){let d=p=>{m.current?.contains(p.target)||z9(()=>r(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),U9("div",{className:"popover",ref:m,tabIndex:-1,children:e})};import{jsx as Zi,jsxs as V9}from"react/jsx-runtime";var Ze="separator",e3=Y9.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=Mo(),a=yr();console.log(o);let l=["cut","copy","paste","separator","duplicateSelection","toggleElementLock"],s=[];l.forEach(c=>{if(c==="separator"){s.push("separator");return}let d=o.find(p=>p.name===c);d&&s.push(d)}),o=s;let m=o.reduce((c,d)=>(d&&(d===Ze||!d.predicate||d.predicate(a,i,e.app.props,e.app))&&c.push(d),c),[]);return Zi(Qv,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Zi("ul",{className:"context-menu",onContextMenu:c=>c.preventDefault(),children:m.map((c,d)=>{if(c===Ze)return!m[d-1]||m[d-1]===Ze?null:Zi("hr",{className:"context-menu-item-separator"},d);let p=c.name,u="";return c.label&&(typeof c.label=="function"?u=h(c.label(a,i,e.app)):u=h(c.label)),Zi("li",{"data-testid":p,onClick:()=>{n(()=>{e.executeAction(c,"contextMenu")})},children:V9("button",{type:"button",className:W9("context-menu-item",{dangerous:p==="deleteSelectedElements",checkmark:c.checked?.(i)}),children:[Zi("div",{className:"context-menu-item__label",children:u}),Zi("kbd",{className:"context-menu-item__shortcut",children:p?He(p):""})]})},d)})})})});import{jsx as Mg,jsxs as t3}from"react/jsx-runtime";var X9=({height:e,width:o,userToFollow:t,onDisconnect:r})=>Mg("div",{className:"follow-mode",style:{width:o,height:e},children:t3("div",{className:"follow-mode__badge",children:[t3("div",{className:"follow-mode__badge__label",children:["Following"," ",Mg("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),Mg("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:Vt})]})}),o3=X9;import VI from"clsx";import Iz from"react";import{DEFAULT_SIDEBAR as Cf,TOOL_TYPE as XI,arrayToMap as Cz,capitalizeString as Sz,isShallowEqual as Tm}from"@haoxin-web/excalidraw-common";import{mutateElement as kz}from"@haoxin-web/excalidraw-element";import{ShapeCache as Mz}from"@haoxin-web/excalidraw-element";import K9 from"clsx";import{KEYS as r3}from"@haoxin-web/excalidraw-common";import{jsx as Z9}from"react/jsx-runtime";var Ud=e=>{if(e.visible===!1)return null;let o=e.showKeyShortcut!==!1,t=e.title??h("toolBar.hand"),r=o?`${t} \u2014 H`:t;return Z9(z,{className:K9("Shape",{fillable:!1}),type:"radio",icon:Fs,name:"editor-current-shape",checked:e.checked,title:r,keyBindingLabel:o&&!e.isMobile?r3.H.toLocaleUpperCase():void 0,"aria-label":r,"aria-keyshortcuts":o?r3.H:void 0,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()})};import{TOOL_TYPE as $e}from"@haoxin-web/excalidraw-common";import{jsx as Fr,jsxs as j9}from"react/jsx-runtime";var $9=({appState:e,app:o,visible:t=!0,onHandToolToggle:r,showPanActions:n})=>{if(!t)return null;let i=e.activeTool.type,a=co,l=ko;if(i===$e.arrow){let c=e.currentItemStartArrowhead,d=e.currentItemEndArrowhead,p=c==="arrow"&&d==="arrow",u=(c==null||c===null)&&d==="arrow",f=c==="triangle_outline"&&d==="triangle_outline",b=(c==null||c===null)&&d==="triangle_outline";f?a=p0:b?a=m0:p?a=vs:u?a=rn:a=rn}else i===$e.line?a=co:a=co;switch(i){case $e.rectangle:l=ko;break;case $e.ellipse:l=hr;break;case $e.diamond:l=ur;break;case"triangle":l=gr;break;case"pentagon":l=fr;break;case"callout":l=Es;break;case"hollow_arrow":l=ys;break;case"hollow_double_arrow":l=ws;break;default:break}let s=(e.currentItemOpacity??100)<100,m=c=>{try{window.dispatchEvent(new CustomEvent("leftflyout:toggle",{detail:{group:c}}))}catch{}};return Fr(De,{className:"App-toolbar App-toolbar--vertical",children:j9(Ue.Col,{align:"center",gap:1,style:{padding:"4px 0"},children:[Fr(z,{"aria-label":"selection",type:"radio",icon:ba,checked:i===$e.selection,name:"left-main-toolbar",title:h("toolBar.selection"),onChange:()=>o.setActiveTool({type:$e.selection})}),Fr(Ud,{checked:lo(e),onChange:()=>r?.(),title:h("toolBar.hand"),isMobile:!0,showKeyShortcut:!1,visible:n!==!1}),Fr(z,{"aria-label":"freedraw",type:"radio",icon:s?Ts:Nt,checked:i===$e.freedraw,name:"left-main-toolbar",title:h("toolBar.freedraw"),onPointerDown:()=>m("freedraw"),onChange:()=>o.setActiveTool({type:$e.freedraw})}),Fr(z,{"aria-label":"line",type:"radio",icon:a,checked:i===$e.line||i===$e.arrow,name:"left-main-toolbar",title:h("toolBar.line"),onPointerDown:()=>m("line"),onChange:()=>o.setActiveTool({type:$e.line})}),Fr(z,{"aria-label":"shapes",type:"radio",icon:l,checked:i===$e.rectangle||i===$e.ellipse||i===$e.diamond||i==="triangle"||i==="pentagon"||i==="callout"||i==="hollow_arrow"||i==="hollow_double_arrow",name:"left-main-toolbar",title:h("headings.shapes"),onPointerDown:()=>m("shapes"),onChange:()=>o.setActiveTool({type:$e.rectangle})}),Fr(z,{"aria-label":"text",type:"radio",icon:Wo,checked:i===$e.text,name:"left-main-toolbar",title:h("toolBar.text"),onPointerDown:()=>m("text"),onChange:()=>o.setActiveTool({type:$e.text})}),Fr(z,{"aria-label":"eraser",type:"radio",icon:xa,checked:i===$e.eraser,name:"left-main-toolbar",title:h("toolBar.eraser"),onChange:()=>o.setActiveTool({type:$e.eraser})})]})})},n3=$9;import q9 from"clsx";import{useState as J9,useEffect as Q9}from"react";import{THEME as eN}from"@haoxin-web/excalidraw-common";import{jsx as Lg,jsxs as tN}from"react/jsx-runtime";var Wd=({delay:e,theme:o})=>{let[t,r]=J9(!!e);return Q9(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:tN("div",{className:q9("LoadingMessage",{"LoadingMessage--dark":o===eN.DARK}),children:[Lg("div",{children:Lg(it,{})}),Lg("div",{className:"LoadingMessage-text",children:h("labels.loadingScene")})]})};import{useEffect as yN}from"react";import{showSelectedShapeActions as wN}from"@haoxin-web/excalidraw-element";import oN from"clsx";import{jsx as rN}from"react/jsx-runtime";var Il=({children:e,side:o,className:t})=>rN("div",{className:oN("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import{CANVAS_SEARCH_TAB as nN,DEFAULT_SIDEBAR as iN}from"@haoxin-web/excalidraw-common";import{isFlowchartNodeElement as aN,isImageElement as i3,isLinearElement as a3,isLineElement as lN,isTextBindableContainer as sN,isTextElement as cN}from"@haoxin-web/excalidraw-element";import{getShortcutKey as Pg}from"@haoxin-web/excalidraw-common";import{isNodeInFlowchart as dN}from"@haoxin-web/excalidraw-element";import{jsx as l3}from"react/jsx-runtime";var mN=({appState:e,isMobile:o,device:t,app:r})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===iN.name&&e.openSidebar.tab===nN&&e.searchMatches?.matches.length)return h("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(St(e))return h("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?h("hints.linearElementMulti"):n.type==="arrow"?h("hints.arrowTool",{arrowShortcut:Pg("A")}):h("hints.linearElement");if(n.type==="freedraw")return h("hints.freeDraw");if(n.type==="text")return h("hints.text");if(n.type==="embeddable")return h("hints.embeddable");let m=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&m.length===1){let c=m[0];return a3(c)&&c.points.length===2?h("hints.lockAngle"):i3(c)?h("hints.resizeImage"):h("hints.resize")}if(a&&l==="mouse")return h("hints.rotate");if(m.length===1&&cN(m[0]))return h("hints.text_selected");if(e.editingTextElement)return h("hints.text_editing");if(e.croppingElementId)return h("hints.leaveCropEditor");if(m.length===1&&i3(m[0]))return h("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!m.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[h("hints.deepBoxSelect")];if(Nr(r)&&e.selectedElementsAreBeingDragged)return h("hints.disableSnapping");if(!m.length&&!o)return[h("hints.canvasPanning")];if(m.length===1){if(a3(m[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?h("hints.lineEditor_pointSelected"):h("hints.lineEditor_nothingSelected"):lN(m[0])?h("hints.lineEditor_line_info"):h("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&sN(m[0]))return aN(m[0])?dN(m[0],r.scene.getNonDeletedElementsMap())?[h("hints.bindTextToElement"),h("hints.createFlowchart")]:[h("hints.bindTextToElement"),h("hints.createFlowchart")]:h("hints.bindTextToElement")}}return null},s3=({appState:e,isMobile:o,device:t,app:r})=>{let n=mN({appState:e,isMobile:o,device:t,app:r});if(!n)return null;let i=Array.isArray(n)?n.map(a=>Pg(a).replace(/\. ?$/,"")).join(". "):Pg(n);return l3("div",{className:"HintViewer",children:l3("span",{children:i})})};import pN from"clsx";import{jsx as d3,jsxs as hN}from"react/jsx-runtime";var uN="medium",c3={CHECKED:Hn,UNCHECKED:on},m3=e=>hN("label",{className:pN("ToolIcon ToolIcon__lock",`ToolIcon_size_${uN}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[d3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),d3("div",{className:"ToolIcon__icon",children:e.checked?c3.CHECKED:c3.UNCHECKED})]});import gN from"clsx";import{jsx as p3,jsxs as bN}from"react/jsx-runtime";var fN="medium",u3=e=>e.penDetected?bN("label",{className:gN("ToolIcon ToolIcon__penMode",`ToolIcon_size_${fN}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[p3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),p3("div",{className:"ToolIcon__icon",children:cb})]}):null;import{Fragment as xN,jsx as h3,jsxs as EN}from"react/jsx-runtime";var In=({heading:e,children:o,...t})=>{let{id:r}=Xe(),n=h3("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:h(`headings.${e}`)});return h3("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):EN(xN,{children:[n,o]})})};import{Fragment as vN,jsx as gt,jsxs as Bo}from"react/jsx-runtime";var g3=({appState:e,elements:o,actionManager:t,setAppState:r,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:m,device:c,renderWelcomeScreen:d,UIOptions:p,app:u,showPanActions:f})=>{let{WelcomeScreenCenterTunnel:b,MainMenuTunnel:x,DefaultSidebarTriggerTunnel:w}=Se();yN(()=>{e.viewModeEnabled&&e.openMenu&&r({openMenu:null})},[e.viewModeEnabled,e.openMenu,r]);let E=()=>Bo(Il,{side:"bottom",className:"App-bottom-bar-mobile",children:[d&&gt(b.Out,{}),gt(In,{heading:"shapes",children:v=>gt(Ue.Col,{gap:4,align:"center",children:Bo(Ue.Row,{gap:1,className:"App-toolbar-container",children:[Bo(De,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[v,Bo(Ue.Row,{gap:1,children:[gt(Ud,{checked:lo(e),onChange:()=>i(),title:h("toolBar.hand"),isMobile:!0,visible:f!==!1}),gt(Uw,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})]})]}),l&&l(!0,e),Bo("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&gt(w.Out,{}),gt(u3,{checked:e.penMode,onChange:()=>a(null),title:h("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),gt(m3,{checked:e.activeTool.locked,onChange:n,title:h("toolBar.lock"),isMobile:!0})]})]})})}),gt(s3,{appState:e,isMobile:!0,device:c,app:u})]}),y=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?gt("div",{className:"App-toolbar-content",children:gt(x.Out,{})}):Bo("div",{className:"App-toolbar-content",children:[gt(x.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),Bo("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return Bo(vN,{children:[m(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&E(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&gt("div",{className:"App-bottom-bar",style:{marginLeft:Ut+No*2,marginRight:Ut+No*2},children:Bo(De,{padding:0,children:[e.openMenu==="shape"&&wN(e,o)?gt(In,{className:"App-mobile-menu",heading:"selectedShapeActions",children:gt(Gw,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,Bo("footer",{className:"App-toolbar",children:[y(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&gt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(v=>({...tn(o,v)}))},children:h("buttons.scrollBackToContent")})]})]})})]})};import TN from"open-color";import IN,{useLayoutEffect as CN,useRef as SN,useState as kN}from"react";import{jsx as Cl,jsxs as MN}from"react/jsx-runtime";var f3=e=>{let o=SN(null),[t,r]=kN(null);return CN(()=>{if(!e.spreadsheet)return;let n=uE(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await Nn(n,{exportBackground:!1,viewBackgroundColor:TN.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),Cl("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:Cl("div",{ref:o})})},b3=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=Oe(),n=IN.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),ae("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Cl(Ge,{size:"small",onCloseRequest:n,title:h("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:MN("div",{className:"container",children:[Cl(f3,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),Cl(f3,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as Or from"@radix-ui/react-popover";import x3 from"clsx";import Yd,{useLayoutEffect as LN}from"react";import{supportsResizeObserver as PN,isShallowEqual as AN}from"@haoxin-web/excalidraw-common";import{Fragment as BN,jsx as Fo,jsxs as Vd}from"react/jsx-runtime";var _N=4,DN=8,RN=({shouldWrap:e,children:o,username:t})=>e?Fo(po,{label:t||"Unknown user",children:o}):Fo(BN,{children:o}),Ag=({actionManager:e,collaborator:o,socketId:t,withName:r=!1,shouldWrapWithTooltip:n=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:r,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return Fo(RN,{username:o.username,shouldWrap:n,children:l},t)},NN=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Sl=Yd.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=Ke(),i=new Map;t.forEach((b,x)=>{let w=b.id||x;i.set(w,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=Yd.useState(""),m=a.filter(b=>b.username?.toLowerCase().includes(l)),c=Yd.useRef(null);LN(()=>{if(c.current){let b=w=>{let E=Math.max(1,Math.min(8,Math.floor(w/38)));p(E)};if(b(c.current.clientWidth),!PN)return;let x=new ResizeObserver(w=>{for(let E of w){let{width:y}=E.contentRect;b(y)}});return x.observe(c.current),()=>{x.disconnect()}}},[]);let[d,p]=Yd.useState(_N),f=a.slice(0,d-1).map(b=>Ag({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?Fo("div",{className:x3("UserList UserList_mobile",e),children:a.map(b=>Ag({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):Fo("div",{className:"UserList__wrapper",ref:c,children:Vd("div",{className:x3("UserList",e),style:{"--max-avatars":d},children:[f,a.length>d-1&&Vd(Or.Root,{children:[Vd(Or.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),Fo(Or.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Vd(De,{padding:2,children:[a.length>=DN&&Fo(nc,{placeholder:h("quickSearch.placeholder"),onChange:s}),Fo(ic,{className:"dropdown-menu UserList__collaborators",placeholder:h("userList.empty"),children:m.length>0?[Fo("div",{className:"hint",children:h("userList.hint.text")}),m.map(b=>Ag({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),Fo(Or.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[r,n]of e.collaborators){let i=o.collaborators.get(r);if(!i||r!==t.next().value||!AN(n,i,NN))return!1}return!0});import y3 from"clsx";import{jsx as FN}from"react/jsx-runtime";var E3=e=>FN("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${h("helpDialog.title")} \u2014 ?`,"aria-label":h("helpDialog.title"),children:Gn});import{jsx as rr,jsxs as w3}from"react/jsx-runtime";var v3=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r,showZoomActions:n})=>{let i=n!==!1,{FooterCenterTunnel:a,WelcomeScreenHelpHintTunnel:l}=Se();return w3("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[i&&rr("div",{className:y3("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:rr(Ue.Col,{gap:2,children:rr(In,{heading:"canvasActions",children:rr(Ww,{renderAction:o.renderAction,zoom:e.zoom,visible:i})})})}),rr(a.Out,{}),rr("div",{className:y3("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),style:{display:"none"},children:w3("div",{style:{position:"relative"},children:[r&&rr(l.Out,{}),rr(E3,{onClick:()=>o.executeAction(gn)})]})}),rr(Yw,{actionManager:o,showExitZenModeBtn:t})]})},T3=v3;v3.displayName="Footer";import VN from"clsx";import{useEffect as R3,useLayoutEffect as N3,useRef as Hg,useState as XN,forwardRef as B3,useImperativeHandle as KN,useCallback as A3}from"react";import{EVENT as _3,isDevEnv as ZN,KEYS as $N,updateObject as jN}from"@haoxin-web/excalidraw-common";import zN from"clsx";import{useContext as HN}from"react";import ON from"react";var Xd=ON.createContext({});import{jsx as _g,jsxs as I3}from"react/jsx-runtime";var Dg=({children:e,className:o})=>{let t=pe(),r=HN(Xd),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return I3("div",{className:zN("sidebar__header",o),"data-testid":"sidebar-header",children:[e,I3("div",{className:"sidebar__header__buttons",children:[n&&_g(po,{label:h("labels.sidebarLock"),children:_g(Gt,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":h("labels.sidebarLock"),children:nb})}),_g(Gt,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":h("buttons.close"),children:Vt})]})]})};Dg.displayName="SidebarHeader";import*as S3 from"@radix-ui/react-tabs";import{jsx as C3}from"react/jsx-runtime";var Rg=({children:e,tab:o,onSelect:t,...r})=>C3(S3.Trigger,{value:o,asChild:!0,onSelect:t,children:C3("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});Rg.displayName="SidebarTabTrigger";import*as k3 from"@radix-ui/react-tabs";import{jsx as GN}from"react/jsx-runtime";var Ng=({children:e,...o})=>GN(k3.List,{className:"sidebar-triggers",...o,children:e});Ng.displayName="SidebarTabTriggers";import UN from"clsx";import{jsx as Bg,jsxs as M3}from"react/jsx-runtime";var Fg=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=me(),m=xe();return M3("label",{title:r,className:"sidebar-trigger__label-element",children:[Bg("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:c=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let d=c.target.checked;s({openSidebar:d?{name:e,tab:o}:null}),i?.(d)},checked:m.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),M3("div",{className:UN("sidebar-trigger",a),style:l,children:[t&&Bg("div",{children:t}),n&&Bg("div",{className:"sidebar-trigger__label",children:n})]})]})};Fg.displayName="SidebarTrigger";import*as L3 from"@radix-ui/react-tabs";import{jsx as WN}from"react/jsx-runtime";var Og=({children:e,...o})=>{let t=xe(),r=me();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return WN(L3.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};Og.displayName="SidebarTabs";import*as P3 from"@radix-ui/react-tabs";import{jsx as YN}from"react/jsx-runtime";var zg=({tab:e,children:o,...t})=>YN(P3.Content,{...t,value:e,"data-testid":e,children:o});zg.displayName="SidebarTab";import{jsx as D3}from"react/jsx-runtime";import{createElement as qN}from"react";var kl=he(!1),F3=B3(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{ZN()&&t&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=me(),s=pr(kl);N3(()=>(s(!!r),()=>{s(!1)}),[s,r]);let m=Hg({});m.current.onCloseRequest=()=>{l({openSidebar:null})},m.current.onDock=u=>t?.(u),m.current=jN(m.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let c=Hg(null);KN(a,()=>c.current);let d=pe(),p=A3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Jn(c,A3(u=>{u.target.closest(".sidebar-trigger")||(!r||!d.editor.canFitSidebar)&&p()},[p,r,d.editor.canFitSidebar])),R3(()=>{let u=f=>{f.key===$N.ESCAPE&&(!r||!d.editor.canFitSidebar)&&p()};return document.addEventListener(_3.KEYDOWN,u),()=>{document.removeEventListener(_3.KEYDOWN,u)}},[p,r,d.editor.canFitSidebar]),D3(De,{...i,className:VN("sidebar",{"sidebar--docked":r},n),ref:c,children:D3(Xd.Provider,{value:m.current,children:o})})});F3.displayName="SidebarInner";var oo=Object.assign(B3((e,o)=>{let t=xe(),{onStateChange:r}=e,n=Hg(t.openSidebar);R3(()=>{(!t.openSidebar&&n?.current?.name===e.name||t.openSidebar?.name===e.name&&n?.current?.name!==e.name||n.current?.name===e.name)&&t.openSidebar!==n.current&&r?.(t.openSidebar?.name!==e.name?null:t.openSidebar),n.current=t.openSidebar},[t.openSidebar,r,e.name]);let[i,a]=XN(!1);return N3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?qN(F3,{...e,ref:o,key:e.name}):null}),{Header:Dg,TabTriggers:Ng,TabTrigger:Rg,Tabs:Og,Tab:zg,Trigger:Fg});oo.displayName="Sidebar";import{composeEventHandlers as aB}from"@haoxin-web/excalidraw-common";import{useLayoutEffect as JN,useRef as QN}from"react";import{jsx as eB}from"react/jsx-runtime";var nr=(e,o)=>{let t=he(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=Se(),[,a]=i(t),l=QN({preferHost:!1,counter:0});return JN(()=>{let s=l.current;return a(m=>{let c=m+1;return s.counter=c,c}),()=>{a(m=>{let c=m-1;return s.counter=c,c||(s.preferHost=!1),c})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:eB(o,{...n})};return r.displayName=e,r};var Wg={};I1(Wg,{ChangeCanvasBackground:()=>q3,ClearCanvas:()=>$3,CommandPalette:()=>X3,Export:()=>J3,Help:()=>Z3,LiveCollaborationTrigger:()=>eT,LoadScene:()=>W3,SaveAsImage:()=>V3,SaveToActiveFile:()=>Y3,SearchMenu:()=>K3,Socials:()=>Q3,ToggleTheme:()=>j3});import nB from"clsx";import{THEME as zr}from"@haoxin-web/excalidraw-common";var Gg=he({active:!1});async function O3({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{Ve.set(Gg,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import tB from"clsx";import{jsx as z3,jsxs as oB}from"react/jsx-runtime";var Kd=function({onChange:e,value:o,choices:t,name:r}){return z3("div",{className:"RadioGroup",children:t.map(n=>oB("div",{className:tB("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[z3("input",{name:r,type:"radio",checked:n.value===o,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as rB,jsx as Ug,jsxs as H3}from"react/jsx-runtime";var G3=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=pe();return H3(rB,{children:[H3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Ug("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),Ug(Kd,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&Ug("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};G3.displayName="DropdownMenuItemContentRadio";var U3=G3;import{Fragment as iB,jsx as tt,jsxs as tT}from"react/jsx-runtime";var W3=()=>{let{t:e}=Ye(),o=Ke(),t=yr();return o.isActionEnabled(hi)?tt(xt,{icon:Un,onSelect:async()=>{(!t.length||await O3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:tt(yt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>tt("strong",{children:n}),br:()=>tt("br",{})})}))&&o.executeAction(hi)},"data-testid":"load-button",shortcut:He("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};W3.displayName="LoadScene";var Y3=()=>{let{t:e}=Ye(),o=Ke();return o.isActionEnabled(hn)?tt(xt,{shortcut:He("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(hn),icon:bb,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};Y3.displayName="SaveToActiveFile";var V3=()=>{let e=me(),{t:o}=Ye();return tt(xt,{icon:ks,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:He("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};V3.displayName="SaveAsImage";var X3=e=>{let o=me(),{t}=Ye();return tt(xt,{icon:Sa,"data-testid":"command-palette-button",onSelect:()=>{ae("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:He("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};X3.displayName="CommandPalette";var K3=e=>{let{t:o}=Ye(),t=Ke();return tt(xt,{icon:Ft,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(ml)},shortcut:He("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};K3.displayName="SearchMenu";var Z3=()=>{let{t:e}=Ye(),o=Ke();return tt(xt,{"data-testid":"help-menu-item",icon:Gn,onSelect:()=>o.executeAction(gn),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};Z3.displayName="Help";var $3=()=>{let{t:e}=Ye(),o=pr(En);return Ke().isActionEnabled(jo)?tt(xt,{icon:Bt,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};$3.displayName="ClearCanvas";var j3=e=>{let{t:o}=Ye(),t=xe(),r=Ke(),n=He("toggleTheme");return r.isActionEnabled(dn)?e?.allowSystemTheme?tt(U3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:zr.LIGHT,label:wa,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:zr.DARK,label:ya,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:P0,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):tt(xt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===zr.DARK?zr.LIGHT:zr.DARK);else return r.executeAction(dn)},icon:t.theme===zr.DARK?wa:ya,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===zr.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===zr.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};j3.displayName="ToggleTheme";var q3=()=>{let{t:e}=Ye(),o=xe(),t=Ke(),r=Lo();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:tT("div",{style:{marginTop:"0.5rem"},children:[tt("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),tt("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};q3.displayName="ChangeCanvasBackground";var J3=()=>{let{t:e}=Ye(),o=me();return tt(xt,{icon:nn,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};J3.displayName="Export";var Q3=()=>{let{t:e}=Ye();return tT(iB,{children:[tt(_i,{icon:Cs,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),tt(_i,{icon:gb,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),tt(_i,{icon:hb,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};Q3.displayName="Socials";var eT=({onSelect:e,isCollaborating:o})=>{let{t}=Ye();return tt(xt,{"data-testid":"collab-button",icon:Ms,className:nB({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};eT.displayName="LiveCollaborationTrigger";import{jsx as Zd,jsxs as Yg}from"react/jsx-runtime";var lB=Object.assign(nr("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Se(),r=pe(),n=xe(),i=me(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return Zd(t.In,{children:Yg(Ie,{open:n.openMenu==="canvas",children:[Zd(Ie.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Is}),Yg(Ie.Content,{onClickOutside:a,onSelect:aB(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&Yg("fieldset",{className:"UserList-Wrapper",children:[Zd("legend",{children:h("labels.collaborators")}),Zd(Sl,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Ie.Trigger,Item:Ie.Item,ItemLink:Ie.ItemLink,ItemCustom:Ie.ItemCustom,Group:Ie.Group,Separator:Ie.Separator,DefaultItems:Wg}),ft=lB;import{useEffect as $i,useRef as oT,useState as sB}from"react";import rT from"clsx";import{isTextElement as cB}from"@haoxin-web/excalidraw-element";import{getBoundTextElement as dB,getContainerElement as mB,redrawTextBoundingBox as pB,newElementWith as uB}from"@haoxin-web/excalidraw-element";import{DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as hB,STROKE_WIDTH as Tt}from"@haoxin-web/excalidraw-common";import{jsx as $,jsxs as Wt}from"react/jsx-runtime";var gB=({appState:e,app:o,actionManager:t,elements:r,showToolBar:n=!0})=>{if(!n)return null;let i=e.activeTool.type,a=ze(r,o,k=>k.strokeWidth,k=>k.hasOwnProperty("strokeWidth"),k=>k?null:e.currentItemStrokeWidth),l=oT(!1),[s,m]=sB(null),c=oT("");if($i(()=>{l.current=!1},[e.activeTool]),$i(()=>{e.viewModeEnabled&&s&&m(null)},[e.viewModeEnabled,s]),$i(()=>{let k=N=>{let G=N.detail?.group??null;l.current=!1,m(_=>_===G?null:G)};return window.addEventListener("leftflyout:toggle",k),()=>window.removeEventListener("leftflyout:toggle",k)},[]),$i(()=>{o.state.cursorButton==="down"&&(l.current=!0,m(null))},[o.state.cursorButton]),$i(()=>{let k=e.selectedElementIds||{},N=Object.keys(k).filter(_=>k[_]).sort().join("|");if(N===c.current||(c.current=N,!N))return;let O=r.find(_=>k[_.id]);if(!O)return;let G=null;switch(O.type){case"text":G="text";break;case"freedraw":G="freedraw";break;case"line":case"arrow":G="line";break;case"rectangle":case"diamond":case"ellipse":case"triangle":case"pentagon":case"callout":case"hollow_arrow":case"hollow_double_arrow":G="shapes";break;default:G=null}G&&(l.current=!1,m(G))},[e.selectedElementIds,r]),$i(()=>{let k=e.selectedElementIds||{},O=r.filter(ue=>k[ue.id]).filter(ue=>ue.type==="text");if(O.length===0)return;let G=O[0],_=ue=>O.every(ao=>ue(ao)===ue(G)),B=ue=>ue.customData?.textStyle||{},K=_(ue=>!!B(ue).bold)?!!B(G).bold:void 0,j=_(ue=>!!B(ue).italic)?!!B(G).italic:void 0,X=_(ue=>!!B(ue).underline)?!!B(G).underline:void 0,q=_(ue=>!!B(ue).strikethrough)?!!B(G).strikethrough:void 0,se=_(ue=>ue.fontSize)?G.fontSize:void 0,ie=_(ue=>ue.textAlign)?G.textAlign:void 0,be={};K!==void 0&&(be.currentTextBold=K),j!==void 0&&(be.currentTextItalic=j),X!==void 0&&(be.currentTextUnderline=X),q!==void 0&&(be.currentTextStrikethrough=q),se!==void 0&&(be.currentItemFontSize=se),ie!==void 0&&(be.currentItemTextAlign=ie),Object.keys(be).length&&o.setState(be)},[e.selectedElementIds,r]),o.state.cursorButton==="down"||l.current)return null;let d=e.selectedElementIds||{},u=r.find(k=>d[k.id])?.type,f=s==="line"&&(i==="line"||i==="arrow"||u==="line"||u==="arrow"),b=s==="shapes"&&["rectangle","diamond","ellipse","triangle","pentagon","callout","hollow_arrow","hollow_double_arrow"].includes(i)||s==="shapes"&&["rectangle","diamond","ellipse","triangle","pentagon","callout","hollow_arrow","hollow_double_arrow"].includes(u),x=s==="text"&&(i==="text"||u==="text"),w=s==="freedraw"&&(i==="freedraw"||u==="freedraw"),E=(e.currentItemOpacity??100)<100,y=()=>{let k=document.querySelector("textarea.excalidraw-wysiwyg");if(!k)return;let N=!!o.state.currentTextBold,O=!!o.state.currentTextItalic,G=!!o.state.currentTextUnderline,_=!!o.state.currentTextStrikethrough,B=[];G&&B.push("underline"),_&&B.push("line-through"),k.style.fontWeight=N?"700":"400",k.style.fontStyle=O?"italic":"normal",k.style.textDecoration=B.join(" ")||"none"},v=k=>{let N=o.scene.getSelectedElements(o.state),O=o.scene.getElementsMapIncludingDeleted(),G=_=>{let B=_.customData?.textStyle||{},K=uB(_,{customData:{..._.customData||{},textStyle:{...B,...k.bold!==void 0?{bold:k.bold}:{},...k.italic!==void 0?{italic:k.italic}:{},...k.underline!==void 0?{underline:k.underline}:{},...k.strikethrough!==void 0?{strikethrough:k.strikethrough}:{}}}});O.set(K.id,K);let j=mB(K,o.scene.getNonDeletedElementsMap());pB(K,j,o.scene)};for(let _ of N)if(cB(_))G(_);else{let B=dB(_,o.scene.getNonDeletedElementsMap());B&&G(B)}o.scene.replaceAllElements(O),o.store?.scheduleCapture?.(),o.refresh?.()},C=k=>{let N={};k.bold!==void 0&&(N.currentTextBold=k.bold),k.italic!==void 0&&(N.currentTextItalic=k.italic),k.underline!==void 0&&(N.currentTextUnderline=k.underline),k.strikethrough!==void 0&&(N.currentTextStrikethrough=k.strikethrough),o.setState(N)},S=k=>{k==="line"?o.setActiveTool({type:"line",locked:!0}):k==="arrow"?(o.setActiveTool({type:"arrow",locked:!0}),o.setState({currentItemStartArrowhead:null,currentItemEndArrowhead:"arrow"})):(o.setActiveTool({type:"arrow",locked:!0}),o.setState({currentItemStartArrowhead:"arrow",currentItemEndArrowhead:"arrow"}))},P=k=>{k==="arrow"?(o.setActiveTool({type:"arrow",locked:!0}),o.setState({currentItemStartArrowhead:null,currentItemEndArrowhead:"triangle_outline"})):(o.setActiveTool({type:"arrow",locked:!0}),o.setState({currentItemStartArrowhead:"triangle_outline",currentItemEndArrowhead:"triangle_outline"}))},M=()=>{let k=ze(r,o,N=>N.strokeColor,!0,N=>N?null:e.currentItemStrokeColor);return $(vr,{type:"elementStroke",label:h("labels.stroke"),color:k??e.currentItemStrokeColor,onChange:N=>t.executeAction(gc,"ui",{currentItemStrokeColor:N}),elements:r,appState:e,palette:hB,updateData:N=>t.executeAction(gc,"ui",N)})},R=k=>{t.executeAction(Ko,"ui",k)},L=k=>{o.setState({currentItemOpacity:k?50:100})};return Wt("div",{className:"LeftToolFlyouts",children:[f&&$(De,{className:"left-flyout left-flyout--line",children:Wt(Ue.Col,{gap:2,align:"start",children:[Wt("div",{className:"arrow-row",children:[$(z,{type:"radio","aria-label":h("toolBar.line"),icon:co,checked:i==="line",name:"left-flyout-line",title:h("toolBar.line"),onChange:()=>S("line")}),$(z,{type:"radio","aria-label":h("toolBar.arrow"),icon:rn,checked:i==="arrow"&&e.currentItemStartArrowhead===null&&e.currentItemEndArrowhead==="arrow",name:"left-flyout-line",title:h("toolBar.arrow"),onChange:()=>S("arrow")}),$(z,{type:"radio","aria-label":h("labels.arrowtypes"),icon:vs,checked:i==="arrow"&&e.currentItemStartArrowhead==="arrow"&&e.currentItemEndArrowhead==="arrow",name:"left-flyout-line",title:h("labels.arrowtypes"),onChange:()=>S("double")})]}),$("div",{className:"left-flyout__separator"}),$("div",{className:"left-flyout__title",children:h("labels.strokeWidth")}),Wt("div",{className:"buttonList",style:{display:"flex",gap:6,justifyContent:"flex-start"},children:[$(z,{type:"icon","aria-label":h("labels.thin"),icon:Wn,selected:a===Tt.thin,name:"left-flyout-line-strokeWidth",title:h("labels.thin"),onClick:()=>t.executeAction(Ko,"ui",Tt.thin)}),$(z,{type:"icon","aria-label":h("labels.bold"),icon:Ta,selected:a===Tt.bold,name:"left-flyout-line-strokeWidth",title:h("labels.bold"),onClick:()=>t.executeAction(Ko,"ui",Tt.bold)}),$(z,{type:"icon","aria-label":h("labels.extraBold"),icon:Ia,selected:a===Tt.extraBold,name:"left-flyout-line-strokeWidth",title:h("labels.extraBold"),onClick:()=>t.executeAction(Ko,"ui",Tt.extraBold)})]}),$("div",{className:"left-flyout__title",children:"\u989C\u8272"}),M()]})}),b&&Wt(De,{className:"left-flyout left-flyout--shapes",children:[(()=>{let k=ze(r,o,G=>G.strokeWidth,G=>G.hasOwnProperty("strokeWidth"),G=>G?null:e.currentItemStrokeWidth),N=ze(r,o,G=>G.strokeStyle,G=>G.hasOwnProperty("strokeStyle"),G=>G?null:e.currentItemStrokeStyle),O=ze(r,o,G=>G.roughness,G=>G.hasOwnProperty("roughness"),G=>G?null:e.currentItemRoughness);return globalThis.__leftShapesFormCache={strokeWidthValue:k,strokeStyleValue:N,roughnessValue:O},null})(),Wt("div",{className:"shapes-grid",style:{gridTemplateColumns:"repeat(5, 1fr)"},children:[$(z,{type:"radio","aria-label":h("toolBar.rectangle"),icon:ko,checked:i==="rectangle",name:"left-flyout-shapes",title:h("toolBar.rectangle"),onChange:()=>o.setActiveTool({type:"rectangle",locked:!0})}),$(z,{type:"radio","aria-label":h("toolBar.ellipse"),icon:hr,checked:i==="ellipse",name:"left-flyout-shapes",title:h("toolBar.ellipse"),onChange:()=>o.setActiveTool({type:"ellipse",locked:!0})}),$(z,{type:"radio","aria-label":h("toolBar.diamond"),icon:ur,checked:i==="diamond",name:"left-flyout-shapes",title:h("toolBar.diamond"),onChange:()=>o.setActiveTool({type:"diamond",locked:!0})}),$(z,{type:"radio","aria-label":h("toolBar.triangle"),icon:gr,checked:i==="triangle",name:"left-flyout-shapes",title:h("toolBar.triangle"),onChange:()=>o.setActiveTool({type:"triangle",locked:!0})}),$(z,{type:"radio","aria-label":h("toolBar.pentagon"),icon:fr,checked:i==="pentagon",name:"left-flyout-shapes",title:h("toolBar.pentagon"),onChange:()=>o.setActiveTool({type:"pentagon",locked:!0})}),$(z,{type:"radio","aria-label":h("toolBar.callout"),icon:Es,checked:i==="callout",name:"left-flyout-shapes",title:h("toolBar.callout"),onChange:()=>o.setActiveTool({type:"callout"})}),$(z,{type:"radio","aria-label":h("toolBar.hollowArrow"),icon:ys,checked:i==="hollow_arrow",name:"left-flyout-shapes",title:h("toolBar.hollowArrow"),onChange:()=>o.setActiveTool({type:"hollow_arrow"})}),$(z,{type:"radio","aria-label":h("toolBar.hollowDoubleArrow"),icon:ws,checked:i==="hollow_double_arrow",name:"left-flyout-shapes",title:h("toolBar.hollowDoubleArrow"),onChange:()=>o.setActiveTool({type:"hollow_double_arrow"})})]}),$("div",{className:"left-flyout__separator"}),$("div",{className:"left-flyout__title",style:{marginTop:8},children:h("labels.stroke")}),M(),$("div",{className:"left-flyout__title",style:{marginTop:8},children:h("labels.background")}),$(vr,{type:"elementBackground",label:h("labels.background"),color:ze(r,o,k=>k.backgroundColor,!0,k=>k?null:e.currentItemBackgroundColor),onChange:k=>t.executeAction(fc,"ui",{currentItemBackgroundColor:k}),elements:r,appState:e,updateData:k=>t.executeAction(fc,"ui",k)}),$("div",{className:"left-flyout__title",style:{marginTop:6},children:h("labels.fill")}),(()=>{let k=ze(r,o,N=>N.fillStyle,N=>N.hasOwnProperty("fillStyle"),N=>N?null:e.currentItemFillStyle);return globalThis.__leftShapesFormCache={...globalThis.__leftShapesFormCache||{},fillStyleValue:k},null})(),Wt("div",{className:"buttonList",style:{display:"flex",gap:6,justifyContent:"flex-start"},children:[$(z,{type:"icon","aria-label":h("labels.hachure"),icon:Ls,selected:globalThis.__leftShapesFormCache?.fillStyleValue==="hachure",name:"left-flyout-fillStyle",title:h("labels.hachure"),onClick:()=>t.executeAction(za,"ui","hachure")}),$(z,{type:"icon","aria-label":h("labels.crossHatch"),icon:Ps,selected:globalThis.__leftShapesFormCache?.fillStyleValue==="cross-hatch",name:"left-flyout-fillStyle",title:h("labels.crossHatch"),onClick:()=>t.executeAction(za,"ui","cross-hatch")}),$(z,{type:"icon","aria-label":h("labels.solid"),icon:As,selected:globalThis.__leftShapesFormCache?.fillStyleValue==="solid",name:"left-flyout-fillStyle",title:h("labels.solid"),onClick:()=>t.executeAction(za,"ui","solid")})]}),$("div",{className:"left-flyout__title",children:h("labels.strokeWidth")}),Wt("div",{className:"buttonList",style:{display:"flex",gap:6,justifyContent:"flex-start"},children:[$(z,{type:"icon","aria-label":h("labels.thin"),icon:Wn,selected:a===Tt.thin,name:"left-flyout-strokeWidth",title:h("labels.thin"),onClick:()=>t.executeAction(Ko,"ui",Tt.thin)}),$(z,{type:"icon","aria-label":h("labels.bold"),icon:Ta,selected:a===Tt.bold,name:"left-flyout-strokeWidth",title:h("labels.bold"),onClick:()=>t.executeAction(Ko,"ui",Tt.bold)}),$(z,{type:"icon","aria-label":h("labels.extraBold"),icon:Ia,selected:a===Tt.extraBold,name:"left-flyout-strokeWidth",title:h("labels.extraBold"),onClick:()=>t.executeAction(Ko,"ui",Tt.extraBold)})]})]}),x&&$(De,{className:"left-flyout left-flyout--text",children:Wt(Ue.Col,{gap:2,align:"start",children:[$("div",{className:"left-flyout__title",children:"\u6837\u5F0F"}),Wt("div",{className:"text-style-row",style:{display:"flex",gap:8},children:[$(z,{type:"icon","aria-label":"Bold",title:"Bold",icon:$("span",{style:{fontWeight:700},children:"B"}),selected:!!e.currentTextBold,onClick:()=>{let k=!e.currentTextBold;o.setState({currentTextBold:k}),y(),v({bold:!e.currentTextBold}),C({bold:k})}}),$(z,{type:"icon","aria-label":"Italic",title:"Italic",icon:$("span",{style:{fontStyle:"italic"},children:"I"}),selected:!!e.currentTextItalic,onClick:()=>{let k=!e.currentTextItalic;o.setState({currentTextItalic:k}),y(),v({italic:!e.currentTextItalic}),C({italic:k})}}),$(z,{type:"icon","aria-label":"Strikethrough",title:"Strikethrough",icon:$("span",{style:{textDecoration:"line-through"},children:"S"}),selected:!!e.currentTextStrikethrough,onClick:()=>{let k=!e.currentTextStrikethrough;o.setState({currentTextStrikethrough:k}),y(),v({strikethrough:k}),C({strikethrough:k})}}),$(z,{type:"icon","aria-label":"Underline",title:"Underline",icon:$("span",{style:{textDecoration:"underline"},children:"U"}),selected:!!e.currentTextUnderline,onClick:()=>{let k=!e.currentTextUnderline;o.setState({currentTextUnderline:k}),y(),v({underline:k}),C({underline:k})}})]}),$("div",{className:"left-flyout__title",children:"\u5B57\u53F7"}),$("div",{className:"text-size-row",style:{display:"flex",gap:6,alignItems:"center",justifyContent:"flex-start"},children:[10,12,16,24,36].map(k=>{let N=e.currentItemFontSize===k;return $("button",{className:rT("text-size-chip",{selected:N}),style:{minWidth:32,height:28,padding:"0 10px",borderRadius:8,background:N?"#2178ff":"transparent",color:N?"#fff":"var(--text-primary-color)",border:N?"1px solid #2178ff":"1px solid var(--button-border-color)",transition:"background 0.12s ease"},onMouseEnter:O=>{N&&(O.currentTarget.style.background="rgba(33,120,255,0.85)")},onMouseLeave:O=>{N&&(O.currentTarget.style.background="#2178ff")},onClick:()=>{t.executeAction(iu,"ui",k)},children:$("span",{style:{fontSize:12},children:k})},k)})}),$("div",{className:"left-flyout__title",children:"\u5BF9\u9F50\u65B9\u5F0F"}),Wt("div",{className:"text-align-row",style:{display:"flex",gap:6,justifyContent:"flex-start"},children:[$(z,{type:"radio","aria-label":h("labels.left"),name:"text-align",title:h("labels.left"),icon:Ds,checked:e.currentItemTextAlign==="left",onChange:()=>{t.executeAction(Ha,"ui","left")}}),$(z,{type:"radio","aria-label":h("labels.center"),name:"text-align",title:h("labels.center"),icon:Rs,checked:e.currentItemTextAlign==="center",onChange:()=>{t.executeAction(Ha,"ui","center")}}),$(z,{type:"radio","aria-label":h("labels.right"),name:"text-align",title:h("labels.right"),icon:Ns,checked:e.currentItemTextAlign==="right",onChange:()=>{t.executeAction(Ha,"ui","right")}})]}),$("div",{className:"left-flyout__separator"}),M()]})}),w&&$(De,{className:"left-flyout left-flyout--freedraw",children:Wt(Ue.Col,{gap:2,align:"start",children:[Wt("div",{className:"freedraw-pen-toggle",children:[$(z,{type:"radio","aria-label":h("toolBar.freedraw"),icon:Nt,checked:!E,name:"freedraw-pen-type",title:h("toolBar.freedraw"),onChange:()=>L(!1)}),$(z,{type:"radio","aria-label":h("toolBar.highlighter"),icon:Ts,checked:E,name:"freedraw-pen-type",title:h("toolBar.highlighter"),onChange:()=>L(!0)})]}),$("div",{className:"left-flyout__title",children:h("labels.strokeWidth")}),$("div",{className:"width-choices",children:[Tt.thin,Tt.bold,Tt.extraBold,6].map(k=>$("button",{className:rT("stroke-width-preview",{selected:e.currentItemStrokeWidth===k}),title:`${h("labels.strokeWidth")} ${k}`,onClick:()=>R(k),children:$("svg",{width:"24",height:"16",viewBox:"0 0 24 16","aria-hidden":"true",children:$("path",{d:"M2 12 C 6 2, 14 14, 22 6",fill:"none",stroke:"currentColor",strokeWidth:Math.max(1,Number(k)),strokeLinecap:"round"})})},String(k)))}),$("div",{className:"left-flyout__separator"}),$("div",{className:"left-flyout__title",children:h("colorPicker.color")}),$("div",{className:"color-section",children:M()})]})})]})},nT=gB;import fB from"clsx";import{forwardRef as bB,useState as xB}from"react";import{isPromiseLike as EB}from"@haoxin-web/excalidraw-common";import{jsx as $d,jsxs as yB}from"react/jsx-runtime";var Hr=bB(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:m},c)=>{let[d,p]=xB(!1),u=async b=>{let x=t?.(b);if(EB(x)){let w=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof Dn)console.warn(E);else throw E}finally{clearTimeout(w),p(!1)}}},f=d?"loading":m;return i=f==="success"?"success":i,$d("button",{className:fB("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:c,disabled:f==="loading"||f==="success",children:yB("div",{className:"ExcButton__contents",children:[f==="loading"?$d(it,{className:"ExcButton__statusIcon"}):f==="success"&&$d("div",{className:"ExcButton__statusIcon",children:a0}),o&&$d("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as ji,jsxs as TB}from"react/jsx-runtime";var jd=({title:e,children:o,actionLabel:t,onClick:r})=>TB("div",{className:"OverwriteConfirm__Actions__Action",children:[ji("h4",{children:e}),ji("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),ji(Hr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),wB=()=>{let{t:e}=Ye(),o=Ke(),t=me();return ji(jd,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Ac,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},vB=()=>{let{t:e}=Ye(),o=Ke();return ji(jd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(ja,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Vg=Object.assign(({children:e})=>ji("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:wB,SaveToDisk:vB});import{jsx as Gr,jsxs as iT}from"react/jsx-runtime";var qd=Object.assign(nr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Se(),[t,r]=ce(Gg);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return Gr(o.In,{children:Gr(Ge,{onCloseRequest:n,title:!1,size:916,children:iT("div",{className:"OverwriteConfirm",children:[Gr("h3",{children:t.title}),iT("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Gr("div",{className:"OverwriteConfirm__Description__icon",children:l0}),Gr("div",{children:t.description}),Gr("div",{className:"OverwriteConfirm__Description__spacer"}),Gr(Hr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Gr(Vg,{children:e})]})})})}),{Actions:Vg,Action:jd});import VB from"clsx";import{CANVAS_SEARCH_TAB as jg,DEFAULT_SIDEBAR as XB,LIBRARY_SIDEBAR_TAB as gT,composeEventHandlers as KB}from"@haoxin-web/excalidraw-common";import{round as IB}from"@haoxin-web/excalidraw-math";import CB from"clsx";import SB from"lodash.debounce";import{Fragment as kB,memo as MB,useEffect as Ml,useMemo as aT,useRef as Xg,useState as lT}from"react";import{CLASSES as LB,EVENT as PB,FONT_FAMILY as Kg,FRAME_STYLE as Zg,getLineHeight as AB}from"@haoxin-web/excalidraw-common";import{isElementCompletelyInViewport as _B}from"@haoxin-web/excalidraw-element";import{measureText as Ll}from"@haoxin-web/excalidraw-element";import{KEYS as qi,randomInteger as sT,addEventListener as DB,getFontString as Jd}from"@haoxin-web/excalidraw-common";import{newTextElement as RB}from"@haoxin-web/excalidraw-element";import{isTextElement as pT,isFrameLikeElement as Qd}from"@haoxin-web/excalidraw-element";import{getDefaultFrameName as uT}from"@haoxin-web/excalidraw-element/frame";import{Fragment as YB,jsx as ot,jsxs as Oo}from"react/jsx-runtime";var NB=he(""),$g=he(null),BB=350,hT=()=>{let e=Oe(),o=me(),t=Xg(null),[r,n]=ce(NB),i=r.trim(),[a,l]=lT(!1),[s,m]=lT({nonce:null,items:[]}),c=Xg(null),d=Xg(void 0),[p,u]=ce($g),f=e.scene.getNonDeletedElementsMap();Ml(()=>{a||(i!==c.current||e.scene.getSceneNonce()!==d.current)&&(c.current=null,mT(i,e,(y,v)=>{m({nonce:sT(),items:y}),c.current=i,d.current=e.scene.getSceneNonce(),o({searchMatches:y.length?{focusedId:null,matches:y.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null})}))},[a,i,f,e,o,u,d]);let b=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},x=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};Ml(()=>{o(y=>y.searchMatches?{searchMatches:{focusedId:p!==null&&y.searchMatches?.matches[p]?.id||null,matches:y.searchMatches.matches.map((C,S)=>S===p?{...C,focus:!0}:{...C,focus:!1})}}:null)},[p,o]),Ml(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=RB({text:y.searchQuery,x:y.element.x+(y.matchedLines[0]?.offsetX??0),y:y.element.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:Qd(y.element)?Zg.nameFontSize:y.element.fontSize,fontFamily:Qd(y.element)?Kg.Assistant:y.element.fontFamily}),S=14,P=C.fontSize,M=P*v<S;if(!_B([C],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||M){let R;M?P>=S?R={fitToContent:!0}:R={fitToViewport:!0,maxZoom:IB(S/P,1)}:R={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...R,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),Ml(()=>()=>{u(null),c.current=null,d.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let w=br({goToNextItem:b,goToPreviousItem:x,searchMatches:s});Ml(()=>{let y=v=>{if(v.key===qi.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[qi.CTRL_OR_CMD]&&v.key===qi.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(v.key===qi.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===qi.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===qi.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return DB(window,PB.KEYDOWN,y,{capture:!0,passive:!1})},[o,w,e]);let E=`${s.items.length} ${s.items.length===1?h("search.singleResult"):h("search.multipleResults")}`;return Oo("div",{className:"layer-ui__search",children:[ot("div",{className:"layer-ui__search-header",children:ot(Ni,{className:LB.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:h("search.placeholder"),icon:Ft,onChange:y=>{n(y),l(!0);let v=y.trim();mT(v,e,(C,S)=>{m({nonce:sT(),items:C}),u(S),c.current=v,d.current=e.scene.getSceneNonce(),o({searchMatches:C.length?{focusedId:null,matches:C.map(P=>({id:P.element.id,focus:!1,matchedLines:P.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),Oo("div",{className:"layer-ui__search-count",children:[s.items.length>0&&Oo(YB,{children:[p!==null&&p>-1?Oo("div",{children:[p+1," / ",E]}):ot("div",{children:E}),Oo("div",{className:"result-nav",children:[ot(Gt,{onSelect:()=>{b()},className:"result-nav-btn",children:Us}),ot(Gt,{onSelect:()=>{x()},className:"result-nav-btn",children:N0})]})]}),s.items.length===0&&i&&c.current&&ot("div",{style:{margin:"1rem auto"},children:h("search.noMatch")})]}),ot(zB,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},cT=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return ot("div",{tabIndex:-1,className:CB("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:ot("div",{className:"preview-text",children:o.flatMap((t,r)=>ot(kB,{children:r===2?ot("b",{children:t}):t},r))})})},FB=e=>{let o=aT(()=>e.matches.items.filter(r=>Qd(r.element)),[e.matches]),t=aT(()=>e.matches.items.filter(r=>pT(r.element)),[e.matches]);return Oo("div",{children:[o.length>0&&Oo("div",{className:"layer-ui__search-result-container",children:[Oo("div",{className:"layer-ui__search-result-title",children:[ot("div",{className:"title-icon",children:Vn}),ot("div",{children:h("search.frames")})]}),o.map((r,n)=>ot(cT,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.index)),t.length>0&&ot("div",{className:"layer-ui__divider"})]}),t.length>0&&Oo("div",{className:"layer-ui__search-result-container",children:[Oo("div",{className:"layer-ui__search-result-title",children:[ot("div",{className:"title-icon",children:Wo}),ot("div",{children:h("search.texts")})]}),t.map((r,n)=>ot(cT,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+o.length===e.focusIndex,onClick:()=>e.onItemClick(n+o.length)},r.element.id+r.index))]})]})},OB=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,zB=MB(FB,OB),dT=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),m=a.slice(s<=0?0:s).join(" ")+(l?" ":""),c=20;m=m.length>c?m.slice(-c):m;let d=e.slice(o+t.length),p=d.split(/\s+/),u=!d.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:m.length,previewText:m+t+b,moreBefore:s>0,moreAfter:p.length>f}},HB=(e,o)=>{let t=e.split(`
24
24
  `),r=[],n=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=o.indexOf(l,n);if(s>a.length+n){let m=s-(a.length+n);for(;m>0;)a+=" ",m--}}r.push(a),n=n+a.length}return r.join(`
25
25
  `)},GB=(e,o,t)=>{let n=HB(e.text,e.originalText).split(`
26
- `),i=[],a=0,l=0;for(let d of n){let p=a,u=p+d.length-1;i.push({line:d,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,m=e.originalText.slice(t,t+o.length),c=[];for(let d of i){if(m==="")break;if(s>=d.startIndex&&s<=d.endIndex){let p=d.endIndex+1-s,u=d.line.slice(0,s-d.startIndex),f=m.slice(0,p);m=m.slice(p);let b=Ll(u,qd(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&d.line.length>0){let v=Ll(d.line,qd(e),e.lineHeight),C=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=C}let{width:x,height:w}=Ll(f,qd(e),e.lineHeight),E=b.width,y=d.lineNumber*b.height;c.push({offsetX:E,offsetY:y,width:x,height:w,showOnCanvas:!0}),s+=p}}return c},UB=(e,o,t,r)=>{let n=e.name??uT(e),i=n.slice(t,t+o.length),a=n.slice(0,t),l=qd({fontSize:Kg.nameFontSize,fontFamily:Xg.Assistant}),s=AB(Xg.Assistant),m=Ll(a,l,s);a===""&&(m.width=0);let c=Ll(i,l,s),d=m.width,p=-m.height-Kg.strokeWidth,u=c.width;return[{offsetX:d,offsetY:p,width:u,height:c.height,showOnCanvas:d+u<=e.width*r}]},WB=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),mT=SB((e,o,t)=>{if(!e||e===""){t([],null);return}let r=o.scene.getNonDeletedElements(),n=r.filter(p=>pT(p)),i=r.filter(p=>Jd(p));n.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(WB(e),"gi");for(let p of n){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=dT(f,u.index,e),x=GB(p,e,u.index);x.length>0&&a.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let s=[];for(let p of i){let u=null,f=p.name??uT(p);for(;(u=l.exec(f))!==null;){let b=dT(f,u.index,e),x=UB(p,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let m=new Set(o.visibleElements.map(p=>p.id)),c=[...s,...a],d=c.findIndex(p=>m.has(p.element.id))??null;t(c,d)},BB);import{jsx as Eo,jsxs as fT}from"react/jsx-runtime";import{createElement as ZB}from"react";var bT=nr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Se();return Eo(o.In,{children:Eo(oo.Trigger,{...e,className:"default-sidebar-trigger",name:XB.name})})});bT.displayName="DefaultSidebarTrigger";var xT=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Se();return Eo(o.In,{children:e})};xT.displayName="DefaultTabTriggers";var Qd=Object.assign(nr("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let i=xe(),a=me(),{DefaultSidebarTabTriggersTunnel:l}=Se(),s=i.openSidebar?.tab===$g;return ZB(oo,{...n,name:"default",key:"default",className:VB("default-sidebar",o),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:KB(t,m=>{a({defaultSidebarDockedPreference:m})})},fT(oo.Tabs,{children:[Eo(oo.Header,{children:fT(oo.TabTriggers,{children:[Eo(oo.TabTrigger,{tab:$g,children:Ft}),Eo(oo.TabTrigger,{tab:gT,children:zn}),Eo(l.Out,{})]})}),Eo(oo.Tab,{tab:gT,children:Eo(Mw,{})}),Eo(oo.Tab,{tab:$g,children:Eo(hT,{})}),e]}))}),{Trigger:bT,TabTriggers:xT});import{useEffect as hF,useRef as Jg,useState as cm}from"react";import{isFiniteNumber as HT}from"@haoxin-web/excalidraw-math";import{useState as ST,useRef as kT,useEffect as MT,useDeferredValue as rF}from"react";import{EDITOR_LS_KEYS as nF,debounce as iF,isDevEnv as aF}from"@haoxin-web/excalidraw-common";import{useEffect as $B,useRef as ET}from"react";import{EVENT as yT,KEYS as wT}from"@haoxin-web/excalidraw-common";import{jsx as jB}from"react/jsx-runtime";var em=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=ET(null),i=ET(r);return i.current=r,$B(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[wT.CTRL_OR_CMD]&&s.key===wT.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(yT.KEYDOWN,l),()=>{a.removeEventListener(yT.KEYDOWN,l)}}},[]),jB("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:n})};import{jsx as tm,jsxs as vT}from"react/jsx-runtime";var qB=({error:e})=>vT("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",tm("p",{children:e})]}),om=({error:e,canvasRef:o,loaded:t})=>vT("div",{className:"ttd-dialog-output-wrapper",children:[e&&tm(qB,{error:e.message}),t?tm("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):tm(it,{size:"2rem"})]});import TT from"clsx";import{jsx as jg,jsxs as Pl}from"react/jsx-runtime";var Ji=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>Pl("div",{className:"ttd-dialog-panel",children:[Pl("div",{className:"ttd-dialog-panel__header",children:[jg("label",{children:e}),i?.()]}),o,Pl("div",{className:TT("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[Pl(Gt,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[Pl("div",{className:TT({invisible:n}),children:[t?.label,t?.icon&&jg("span",{children:t.icon})]}),n&&jg(it,{})]}),!r&&!n&&a?.(),l?.()]})]});import{jsx as JB}from"react/jsx-runtime";var rm=({children:e})=>JB("div",{className:"ttd-dialog-panels",children:e});import{getShortcutKey as IT}from"@haoxin-web/excalidraw-common";import{jsx as CT,jsxs as QB}from"react/jsx-runtime";var nm=()=>QB("div",{className:"ttd-dialog-submit-shortcut",children:[CT("div",{className:"ttd-dialog-submit-shortcut__key",children:IT("CtrlOrCmd")}),CT("div",{className:"ttd-dialog-submit-shortcut__key",children:IT("Enter")})]});import{DEFAULT_EXPORT_PADDING as eF,EDITOR_LS_KEYS as tF}from"@haoxin-web/excalidraw-common";var oF=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},im=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){oF({canvasRef:e,setError:r});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:m,files:c}=s;r(null),n.current={elements:Xi(m,{regenerateIds:!0}),files:c};let d=await Lr({elements:n.current.elements,files:n.current.files,exportPadding:eF,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Go(d)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(d)}catch(l){throw a.style.background="var(--default-bg-color)",t&&r(l),l}}},Al=e=>{jt.set(tF.MERMAID_TO_EXCALIDRAW,e)},am=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:r})=>{let{elements:n,files:i}=o.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),r&&t&&Al(t))};import{Fragment as cF,jsx as Oo,jsxs as PT}from"react/jsx-runtime";var lF=`flowchart TD
26
+ `),i=[],a=0,l=0;for(let d of n){let p=a,u=p+d.length-1;i.push({line:d,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,m=e.originalText.slice(t,t+o.length),c=[];for(let d of i){if(m==="")break;if(s>=d.startIndex&&s<=d.endIndex){let p=d.endIndex+1-s,u=d.line.slice(0,s-d.startIndex),f=m.slice(0,p);m=m.slice(p);let b=Ll(u,Jd(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&d.line.length>0){let v=Ll(d.line,Jd(e),e.lineHeight),C=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=C}let{width:x,height:w}=Ll(f,Jd(e),e.lineHeight),E=b.width,y=d.lineNumber*b.height;c.push({offsetX:E,offsetY:y,width:x,height:w,showOnCanvas:!0}),s+=p}}return c},UB=(e,o,t,r)=>{let n=e.name??uT(e),i=n.slice(t,t+o.length),a=n.slice(0,t),l=Jd({fontSize:Zg.nameFontSize,fontFamily:Kg.Assistant}),s=AB(Kg.Assistant),m=Ll(a,l,s);a===""&&(m.width=0);let c=Ll(i,l,s),d=m.width,p=-m.height-Zg.strokeWidth,u=c.width;return[{offsetX:d,offsetY:p,width:u,height:c.height,showOnCanvas:d+u<=e.width*r}]},WB=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),mT=SB((e,o,t)=>{if(!e||e===""){t([],null);return}let r=o.scene.getNonDeletedElements(),n=r.filter(p=>pT(p)),i=r.filter(p=>Qd(p));n.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(WB(e),"gi");for(let p of n){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=dT(f,u.index,e),x=GB(p,e,u.index);x.length>0&&a.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let s=[];for(let p of i){let u=null,f=p.name??uT(p);for(;(u=l.exec(f))!==null;){let b=dT(f,u.index,e),x=UB(p,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let m=new Set(o.visibleElements.map(p=>p.id)),c=[...s,...a],d=c.findIndex(p=>m.has(p.element.id))??null;t(c,d)},BB);import{jsx as yo,jsxs as fT}from"react/jsx-runtime";import{createElement as ZB}from"react";var bT=nr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Se();return yo(o.In,{children:yo(oo.Trigger,{...e,className:"default-sidebar-trigger",name:XB.name})})});bT.displayName="DefaultSidebarTrigger";var xT=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Se();return yo(o.In,{children:e})};xT.displayName="DefaultTabTriggers";var em=Object.assign(nr("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let i=xe(),a=me(),{DefaultSidebarTabTriggersTunnel:l}=Se(),s=i.openSidebar?.tab===jg;return ZB(oo,{...n,name:"default",key:"default",className:VB("default-sidebar",o),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:KB(t,m=>{a({defaultSidebarDockedPreference:m})})},fT(oo.Tabs,{children:[yo(oo.Header,{children:fT(oo.TabTriggers,{children:[yo(oo.TabTrigger,{tab:jg,children:Ft}),yo(oo.TabTrigger,{tab:gT,children:zn}),yo(l.Out,{})]})}),yo(oo.Tab,{tab:gT,children:yo(Lw,{})}),yo(oo.Tab,{tab:jg,children:yo(hT,{})}),e]}))}),{Trigger:bT,TabTriggers:xT});import{useEffect as hF,useRef as Qg,useState as dm}from"react";import{isFiniteNumber as HT}from"@haoxin-web/excalidraw-math";import{useState as ST,useRef as kT,useEffect as MT,useDeferredValue as rF}from"react";import{EDITOR_LS_KEYS as nF,debounce as iF,isDevEnv as aF}from"@haoxin-web/excalidraw-common";import{useEffect as $B,useRef as ET}from"react";import{EVENT as yT,KEYS as wT}from"@haoxin-web/excalidraw-common";import{jsx as jB}from"react/jsx-runtime";var tm=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=ET(null),i=ET(r);return i.current=r,$B(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[wT.CTRL_OR_CMD]&&s.key===wT.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(yT.KEYDOWN,l),()=>{a.removeEventListener(yT.KEYDOWN,l)}}},[]),jB("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:n})};import{jsx as om,jsxs as vT}from"react/jsx-runtime";var qB=({error:e})=>vT("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",om("p",{children:e})]}),rm=({error:e,canvasRef:o,loaded:t})=>vT("div",{className:"ttd-dialog-output-wrapper",children:[e&&om(qB,{error:e.message}),t?om("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):om(it,{size:"2rem"})]});import TT from"clsx";import{jsx as qg,jsxs as Pl}from"react/jsx-runtime";var Ji=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>Pl("div",{className:"ttd-dialog-panel",children:[Pl("div",{className:"ttd-dialog-panel__header",children:[qg("label",{children:e}),i?.()]}),o,Pl("div",{className:TT("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[Pl(Gt,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[Pl("div",{className:TT({invisible:n}),children:[t?.label,t?.icon&&qg("span",{children:t.icon})]}),n&&qg(it,{})]}),!r&&!n&&a?.(),l?.()]})]});import{jsx as JB}from"react/jsx-runtime";var nm=({children:e})=>JB("div",{className:"ttd-dialog-panels",children:e});import{getShortcutKey as IT}from"@haoxin-web/excalidraw-common";import{jsx as CT,jsxs as QB}from"react/jsx-runtime";var im=()=>QB("div",{className:"ttd-dialog-submit-shortcut",children:[CT("div",{className:"ttd-dialog-submit-shortcut__key",children:IT("CtrlOrCmd")}),CT("div",{className:"ttd-dialog-submit-shortcut__key",children:IT("Enter")})]});import{DEFAULT_EXPORT_PADDING as eF,EDITOR_LS_KEYS as tF}from"@haoxin-web/excalidraw-common";var oF=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},am=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){oF({canvasRef:e,setError:r});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:m,files:c}=s;r(null),n.current={elements:Xi(m,{regenerateIds:!0}),files:c};let d=await Lr({elements:n.current.elements,files:n.current.files,exportPadding:eF,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Go(d)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(d)}catch(l){throw a.style.background="var(--default-bg-color)",t&&r(l),l}}},Al=e=>{jt.set(tF.MERMAID_TO_EXCALIDRAW,e)},lm=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:r})=>{let{elements:n,files:i}=o.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),r&&t&&Al(t))};import{Fragment as cF,jsx as zo,jsxs as PT}from"react/jsx-runtime";var lF=`flowchart TD
27
27
  A[Christmas] -->|Get money| B(Go shopping)
28
28
  B --> C{Let me think}
29
29
  C -->|One| D[Laptop]
30
30
  C -->|Two| E[iPhone]
31
- C -->|Three| F[Car]`,LT=iF(Al,300),sF=({mermaidToExcalidrawLib:e})=>{let[o,t]=ST(()=>jt.get(nF.MERMAID_TO_EXCALIDRAW)||lF),r=rF(o.trim()),[n,i]=ST(null),a=kT(null),l=kT({elements:[],files:null}),s=Oe();MT(()=>{im({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:r}).catch(c=>{aF()&&console.error("Failed to parse mermaid definition",c)}),LT(r)},[r,e]),MT(()=>()=>{LT.flush()},[]);let m=()=>{am({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return PT(cF,{children:[Oo("div",{className:"ttd-dialog-desc",children:Oo(yt,{i18nKey:"mermaid.description",flowchartLink:c=>Oo("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:c}),sequenceLink:c=>Oo("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:c}),classLink:c=>Oo("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:c})})}),PT(rm,{children:[Oo(Ji,{label:h("mermaid.syntax"),children:Oo(em,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:c=>t(c.target.value),onKeyboardSubmit:()=>{m()}})}),Oo(Ji,{label:h("mermaid.preview"),panelAction:{action:()=>{m()},label:h("mermaid.button"),icon:Xn},renderSubmitShortcut:()=>Oo(nm,{}),children:Oo(om,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},AT=sF;import*as DT from"@radix-ui/react-tabs";import{useRef as _T}from"react";import{isMemberOf as dF}from"@haoxin-web/excalidraw-common";import{jsx as mF}from"react/jsx-runtime";var RT=e=>{let o=me(),t=_T(null),r=_T(0);return mF(DT.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>r.current&&(r.current=a,i.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="ttd"&&dF(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};RT.displayName="TTDDialogTabs";var NT=RT;import*as BT from"@radix-ui/react-tabs";import{jsx as pF}from"react/jsx-runtime";var qg=({children:e,...o})=>pF(BT.List,{className:"ttd-dialog-triggers",...o,children:e});qg.displayName="TTDDialogTabTriggers";import*as OT from"@radix-ui/react-tabs";import{jsx as FT}from"react/jsx-runtime";var lm=({children:e,tab:o,onSelect:t,...r})=>FT(OT.Trigger,{value:o,asChild:!0,onSelect:t,children:FT("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});lm.displayName="TTDDialogTabTrigger";import*as zT from"@radix-ui/react-tabs";import{jsx as uF}from"react/jsx-runtime";var sm=({tab:e,children:o,...t})=>uF(zT.Content,{...t,value:e,children:o});sm.displayName="TTDDialogTab";import{jsx as It,jsxs as Gr}from"react/jsx-runtime";var Qg=3,Qi=1e3,gF=he(null),fF=he(null),ef=e=>{let o=xe();return o.openDialog?.name!=="ttd"?null:It(bF,{...e,tab:o.openDialog.tab})},bF=nr("TTDDialogBase",({tab:e,...o})=>{let t=Oe(),r=me(),n=Jg(null),[i,a]=ce(fF),[l,s]=cm(i?.prompt??""),m=l.trim(),c=S=>{s(S.target.value),a(P=>({generatedResponse:P?.generatedResponse??null,prompt:S.target.value}))},[d,p]=cm(!1),[u,f]=ce(gF),b=async()=>{if(m.length>Qi||m.length<Qg||d||u?.rateLimitRemaining===0||"__fallback"in o){m.length<Qg&&C(new Error(`Prompt is too short (min ${Qg} characters)`)),m.length>Qi&&C(new Error(`Prompt is too long (max ${Qi} characters)`));return}try{p(!0),ae("ai","generate","ttd");let{generatedResponse:S,error:P,rateLimit:M,rateLimitRemaining:R}=await o.onTextSubmit(m);if(typeof S=="string"&&a(L=>({generatedResponse:S,prompt:L?.prompt??null})),HT(M)&&HT(R)&&f({rateLimit:M,rateLimitRemaining:R}),P){C(P);return}if(!S){C(new Error("Generation failed"));return}try{await im({canvasRef:n,data:y,mermaidToExcalidrawLib:w,setError:C,mermaidDefinition:S}),ae("ai","mermaid parse success","ttd")}catch(L){console.info(`%cTTD mermaid render errror: ${L.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
32
- TTD mermaid definition render errror: ${L.message}`,"color: yellow"),ae("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let P=S.message;(!P||P==="Failed to fetch")&&(P="Request failed"),C(new Error(P))}finally{p(!1)}},x=Jg(b);x.current=b;let[w,E]=cm({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});hF(()=>{(async()=>{await w.api,E(P=>({...P,loaded:!0}))})()},[w.api]);let y=Jg({elements:[],files:null}),[v,C]=cm(null);return It(Ge,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Gr(NT,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?It("p",{className:"dialog-mermaid-title",children:h("mermaid.title")}):Gr(qg,{children:[It(lm,{tab:"text-to-diagram",children:Gr("div",{style:{display:"flex",alignItems:"center"},children:[h("labels.textToDiagram"),It("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"AI Beta"})]})}),It(lm,{tab:"mermaid",children:"Mermaid"})]}),It(sm,{className:"ttd-dialog-content",tab:"mermaid",children:It(AT,{mermaidToExcalidrawLib:w})}),!("__fallback"in o)&&Gr(sm,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[It("div",{className:"ttd-dialog-desc",children:"Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar."}),Gr(rm,{children:[It(Ji,{label:h("labels.prompt"),panelAction:{action:b,label:"Generate",icon:Xn},onTextSubmitInProgess:d,panelActionDisabled:m.length>Qi||u?.rateLimitRemaining===0,renderTopRight:()=>u?Gr("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>It(nm,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Gr("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(Al(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",It(Ir,{icon:Xn})]});let S=m.length/Qi;return S>.8?Gr("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",m.length,"/",Qi]}):null},children:It(em,{onChange:c,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),It(Ji,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),am({app:t,data:y})},label:"Insert",icon:Xn},children:It(om,{canvasRef:n,error:v,loaded:w.loaded})})]})]})]})})});import{round as CI}from"@haoxin-web/excalidraw-math";import PO from"clsx";import AO from"lodash.throttle";import{useEffect as SI,useMemo as gf,useState as _O,memo as DO}from"react";import{STATS_PANELS as bm}from"@haoxin-web/excalidraw-common";import{getCommonBounds as RO}from"@haoxin-web/excalidraw-element";import{getUncroppedWidthAndHeight as NO}from"@haoxin-web/excalidraw-element";import{isElbowArrow as BO,isImageElement as ff}from"@haoxin-web/excalidraw-element";import{frameAndChildrenSelectedTogether as FO}from"@haoxin-web/excalidraw-element";import{elementsAreInSameGroup as OO}from"@haoxin-web/excalidraw-element";import{degreesToRadians as XT,radiansToDegrees as jT}from"@haoxin-web/excalidraw-math";import{getBoundTextElement as KT}from"@haoxin-web/excalidraw-element";import{isArrowElement as ZT,isElbowArrow as LF}from"@haoxin-web/excalidraw-element";import{updateBindings as $T}from"@haoxin-web/excalidraw-element";import TF from"clsx";import{useEffect as YT,useRef as mm,useState as IF}from"react";import{EVENT as oa,KEYS as CF,cloneJSON as tf}from"@haoxin-web/excalidraw-common";import{deepCopyElement as SF}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as VT}from"@haoxin-web/excalidraw-element";import{pointFrom as Ur,pointRotateRads as dm}from"@haoxin-web/excalidraw-math";import{getBoundTextElement as xF}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as UT}from"@haoxin-web/excalidraw-element";import{getSelectedGroupIds as EF,getElementsInGroup as yF,isInGroup as wF}from"@haoxin-web/excalidraw-element";import{getFrameChildren as vF}from"@haoxin-web/excalidraw-element";import{updateBindings as GT}from"@haoxin-web/excalidraw-element";var WT=.01,_l=10,_t=(e,o)=>!(o==="angle"&&UT(e)),_e=(e,o)=>{let t=e+o/2;return t-t%o},ea=(e,o,t)=>Object.keys(e).map(r=>({original:(t??o).get(r),latest:o.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var Cn=(e,o,t,r,n,i=!0)=>{let a=r.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,m]=[t.x+t.width/2,t.y+t.height/2],[c,d]=dm(Ur(t.x,t.y),Ur(s,m),t.angle),p=e-c,u=o-d,[f,b]=dm(Ur(e,o),Ur(s+p,m+u),-t.angle);r.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),GT(l,r);let x=xF(t,n);if(x){let w=a.get(x.id);w&&r.mutateElement(w,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(UT(t)){let w=vF(n,t.id);w.forEach(E=>{let y=a.get(E.id);if(!y)return;let[v,C]=[E.x+E.width/2,E.y+E.height/2],[S,P]=dm(Ur(E.x,E.y),Ur(v,C),E.angle),M=Math.round(S+p),R=Math.round(P+u),[L,k]=dm(Ur(M,R),Ur(v+p,C+u),-E.angle);r.mutateElement(y,{x:L,y:k},{informMutation:i,isDragging:!1}),GT(y,r,{simultaneouslyUpdated:w})})}},ta=(e,o)=>{let r=EF(o).map(n=>yF(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!wF(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as of,jsxs as MF}from"react/jsx-runtime";var kF=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:m,sensitivity:c=1,dragFinishedCallback:d})=>{let p=Oe(),u=me(),f=mm(null),b=mm(null),[x,w]=IF(r.toString()),E=mm(null);E.current||(E.current={originalAppState:tf(m),originalElements:n,lastUpdatedValue:x,updatePending:!1}),YT(()=>{let C=r.toString();w(C),E.current.lastUpdatedValue=C},[r]);let y=(C,S,P)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let M=Number(C);if(isNaN(M)){w(r.toString());return}let R=Number(M.toFixed(2)),L=Number(r);(isNaN(L)||Math.abs(R-L)>=WT)&&(E.current.lastUpdatedValue=C,t({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:R,property:l,originalAppState:P,setInputValue:k=>w(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:VT.IMMEDIATELY}))},v=mm({});return v.current.handleInputValue=y,YT(()=>{let C=f.current,S=v.current;return()=>{let P=C?.value;P&&S.handleInputValue?.(P,E.current.originalElements,E.current.originalAppState),window.removeEventListener(oa.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(oa.POINTER_UP,S.onPointerUp,!1)}},[i]),i?MF("div",{className:TF("drag-input-container",!i&&"disabled"),"data-testid":e,children:[of("div",{className:"drag-input-label",ref:b,onPointerDown:C=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let S=Number(f.current.value);isNaN(S)&&(S=0);let P=null,M=p.scene.getNonDeletedElements().reduce((_,B)=>(_.set(B.id,SF(B)),_),new Map),R=n.map(_=>M.get(_.id)),L=tf(m),k=0,N=0,O=_=>{if(P&&M!==null&&R!==null){let B=_.clientX-P.x;B!==0&&(N+=B,Math.abs(N)>=c&&(N=Math.sign(N)*Math.floor(Math.abs(N)/c),k+=N,t({accumulatedChange:k,instantChange:N,originalElements:R,originalElementsMap:M,shouldKeepAspectRatio:a,shouldChangeByStepSize:_.shiftKey,property:l,scene:s,originalAppState:L,setInputValue:K=>w(String(K)),app:p,setAppState:u}),N=0))}P={x:_.clientX,y:_.clientY}},G=()=>{window.removeEventListener(oa.POINTER_MOVE,O,!1),p.syncActionResult({captureUpdate:VT.IMMEDIATELY}),d?.({app:p,setAppState:u,originalElements:R,originalAppState:L}),P=null,k=0,N=0,R=null,M=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(oa.POINTER_UP,G,!1)};v.current.onPointerMove=O,v.current.onPointerUp=G,window.addEventListener(oa.POINTER_MOVE,O,!1),window.addEventListener(oa.POINTER_UP,G,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?of(Ir,{icon:o}):e}),of("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(i){let S=C.target;S instanceof HTMLInputElement&&C.key===CF.ENTER&&(y(S.value,n,m),p.focusContainer())}},ref:f,value:x,onChange:C=>{E.current.updatePending=!0,w(C.target.value)},onFocus:C=>{C.target.select(),E.current.originalElements=n,E.current.originalAppState=tf(m)},onBlur:C=>{x?i&&y(C.target.value,E.current.originalElements,E.current.originalAppState):w(r.toString())},disabled:!i})]}):null},rt=kF;import{jsx as DF}from"react/jsx-runtime";var PF=15,AF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a&&!LF(a)){let l=i.get(a.id);if(!l)return;if(r!==void 0){let u=XT(r);n.mutateElement(l,{angle:u}),$T(l,n);let f=KT(l,i);f&&!ZT(l)&&n.mutateElement(f,{angle:u});return}let s=Math.round(jT(a.angle)*100)/100,m=Math.round(e),c=(s+m)%360;t&&(c=_e(c,PF)),c=c<0?c+360:c;let d=XT(c);n.mutateElement(l,{angle:d}),$T(l,n);let p=KT(l,i);p&&!ZT(l)&&n.mutateElement(p,{angle:d})}},_F=({element:e,scene:o,appState:t,property:r})=>DF(rt,{label:"A",icon:Bs,value:Math.round(jT(e.angle)%360*100)/100,elements:[e],dragInputCallback:AF,editable:_t(e,"angle"),scene:o,appState:t,property:r}),qT=_F;import{jsx as NF}from"react/jsx-runtime";var JT=5,RF=({property:e,scene:o,appState:t,setAppState:r})=>NF(rt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{r(s=>{let m;return n?m=n:i&&(m=a?_e(s.gridStep+JT*Math.sign(i),JT):s.gridStep+i),m?(m=S1(m),l(m),{gridStep:m}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),QT=RF;import{clamp as pm,round as rf}from"@haoxin-web/excalidraw-math";import{MIN_WIDTH_OR_HEIGHT as um}from"@haoxin-web/excalidraw-common";import{MINIMAL_CROP_SIZE as eI,getUncroppedWidthAndHeight as rI}from"@haoxin-web/excalidraw-element";import{resizeSingleElement as tI}from"@haoxin-web/excalidraw-element";import{isImageElement as nI}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as nf}from"@haoxin-web/excalidraw-element";import{getElementsInResizingFrame as af}from"@haoxin-web/excalidraw-element";import{replaceAllElementsInFrame as iI}from"@haoxin-web/excalidraw-element";import{jsx as HF}from"react/jsx-runtime";var oI=10,BF=e=>e.type==="image",FF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:m,app:c,setAppState:d})=>{let p=m.getNonDeletedElementsMap(),u=o[0],f=p.get(u.id);if(u&&f){let b=r||BF(u),x=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!nI(w)||!w.crop)return;let E=w.crop,y={...E},v=w.scale[0]===-1,C=w.scale[1]===-1,{width:S,height:P}=rI(w),M=E.naturalWidth/S,R=E.naturalHeight/P,L=v?E.width+E.x:E.naturalWidth-E.x,k=C?E.height+E.y:E.naturalHeight-E.y,N=eI*M,O=eI*R;if(i!==void 0){if(a==="width"){let j=i*M,X=pm(j,N,L);y={...y,width:X,x:v?E.x+E.width-X:E.x}}else if(a==="height"){let j=i*R,X=pm(j,O,k);y={...y,height:X,y:C?E.y+E.height-X:E.y}}m.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/P)});return}let G=a==="width"?s:0,_=a==="height"?s:0,B=pm(E.width+G,N,L),K=pm(E.height+_,N,k);y={...E,x:v?E.x+E.width-B:E.x,y:C?E.y+E.height-K:E.y,width:B,height:K},m.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/P)});return}if(i!==void 0){let w=Math.max(a==="width"?i:b?i*x:u.width,um),E=Math.max(a==="height"?i:b?i/x:u.height,um);if(tI(w,E,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),nf(f)){let y=af(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap()),v=iI(m.getElementsIncludingDeleted(),y,f,c);m.replaceAllElements(v)}return}{let w=a==="width"?e:0,E=a==="height"?e:0,y=Math.max(0,u.width+w);a==="width"&&(n?y=_e(y,oI):y=Math.round(y));let v=Math.max(0,u.height+E);if(a==="height"&&(n?v=_e(v,oI):v=Math.round(v)),b&&(a==="width"?v=Math.round(y/x*100)/100:y=Math.round(v*x*100)/100),v=Math.max(um,v),y=Math.max(um,y),tI(y,v,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),nf(f)){let C=af(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap());d({elementsToHighlight:C})}}}},OF=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&nf(a)){let l=af(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=iI(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},zF=({property:e,element:o,scene:t,appState:r})=>{let n=rf(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&nI(o)&&o.crop){let{width:i,height:a}=rI(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=rf(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=rf(o.crop.height*l,2)}}return HF(rt,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:FF,value:n,editable:_t(o,e),scene:t,appState:r,property:e,dragFinishedCallback:OF})},lf=zF;import{getBoundTextElement as GF,redrawTextBoundingBox as UF}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as WF,isTextElement as lI}from"@haoxin-web/excalidraw-element";import{jsx as KF}from"react/jsx-runtime";var aI=4,YF=4,VF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!lI(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),aI);else if(a.type==="text"){let m=Math.round(a.fontSize),c=Math.round(e);s=Math.max(m+c,aI),t&&(s=_e(s,YF))}s&&(n.mutateElement(l,{fontSize:s}),UF(l,n.getContainerElement(l),n))}},XF=({element:e,scene:o,appState:t,property:r})=>{let n=lI(e)?e:WF(e)?GF(e,o.getNonDeletedElementsMap()):null;return n?KF(rt,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:VF,icon:nn,appState:t,scene:o,property:r}):null},sI=XF;import{degreesToRadians as cI,radiansToDegrees as pI}from"@haoxin-web/excalidraw-math";import{getBoundTextElement as dI}from"@haoxin-web/excalidraw-element";import{isArrowElement as mI}from"@haoxin-web/excalidraw-element";import{isInGroup as sf}from"@haoxin-web/excalidraw-element";import{jsx as qF}from"react/jsx-runtime";var ZF=15,$F=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(m=>a.get(m.id)).filter(m=>m&&!sf(m)&&_t(m,n)),s=o.filter(m=>!sf(m)&&_t(m,n));if(r!==void 0){let m=cI(r);for(let c of l){if(!c)continue;i.mutateElement(c,{angle:m});let d=dI(c,a);d&&!mI(c)&&i.mutateElement(d,{angle:m})}i.triggerUpdate();return}for(let m=0;m<l.length;m++){let c=l[m];if(!c)continue;let d=s[m],p=Math.round(pI(d.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=_e(f,ZF)),f=f<0?f+360:f;let b=cI(f);i.mutateElement(c,{angle:b});let x=dI(c,a);x&&!mI(c)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},jF=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!sf(s)&&_t(s,"angle")),i=n.map(s=>Math.round(pI(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>_t(s,"angle"));return qF(rt,{label:"A",icon:Bs,value:a,elements:e,dragInputCallback:$F,editable:l,appState:t,scene:o,property:r})},uI=jF;import{pointFrom as hI}from"@haoxin-web/excalidraw-math";import{useMemo as JF}from"react";import{MIN_WIDTH_OR_HEIGHT as Wr}from"@haoxin-web/excalidraw-common";import{getElementsInResizingFrame as cf,isFrameLikeElement as df,replaceAllElementsInFrame as bI,updateBoundElements as QF}from"@haoxin-web/excalidraw-element";import{rescalePointsInElement as eO,resizeSingleElement as gI}from"@haoxin-web/excalidraw-element";import{getBoundTextElement as tO,handleBindTextResize as oO}from"@haoxin-web/excalidraw-element";import{isTextElement as xI}from"@haoxin-web/excalidraw-element";import{getCommonBounds as hm}from"@haoxin-web/excalidraw-element";import{jsx as sO}from"react/jsx-runtime";var ra=10,rO=(e,o,t,r)=>{let n=r.x-e,i=r.y-o,a=r.width*t,l=r.height*t,s=e+n*t,m=o+i*t;return{width:a,height:l,x:s,y:m,...eO(r,a,l,!1),...xI(r)?{fontSize:r.fontSize*t}:{}}},nO=(e,o,t,r,n,i,a,l)=>{let s=l.getNonDeletedElementsMap(),m=rO(e,o,r,i);l.mutateElement(n,m);let c=tO(i,a);if(c){let d=c.fontSize*r;QF(n,l,{newSize:{width:m.width,height:m.height}});let p=s.get(c.id);p&&xI(p)&&(l.mutateElement(p,{fontSize:d}),oO(n,l,t==="width"?"e":"s",!0))}},fI=(e,o,t,r,n,i,a,l,s,m)=>{i==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let c=o/t;for(let d=0;d<l.length;d++){let p=l[d],u=a[d];nO(n[0],n[1],i,c,u,p,s,m)}},iO=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l,setAppState:s,app:m})=>{let c=a.getNonDeletedElementsMap(),d=ta(o,r);if(i!==void 0){for(let b of d){let x=ea(b,c,t);if(x.length>1){let w=x.map(N=>N.latest),E=x.map(N=>N.original),[y,v,C,S]=hm(E),P=C-y,M=S-v,R=P/M,L=Math.max(Wr,l==="width"?Math.max(0,i):P),k=Math.max(Wr,l==="height"?Math.max(0,i):M);fI(L,k,M,R,hI(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&_t(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(n?v=_e(v,ra):v=Math.round(v));let C=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(n?C=_e(C,ra):C=Math.round(C)),v=Math.max(Wr,v),C=Math.max(Wr,C),gI(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),df(E)){let S=cf(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap()),P=bI(a.getElementsIncludingDeleted(),S,E,m);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,f=[];for(let b of d){let x=ea(b,c,t);if(x.length>1){let w=x.map(N=>N.latest),E=x.map(N=>N.original),[y,v,C,S]=hm(E),P=C-y,M=S-v,R=P/M,L=Math.max(0,P+p);l==="width"&&(n?L=_e(L,ra):L=Math.round(L));let k=Math.max(0,M+u);l==="height"&&(n?k=_e(k,ra):k=Math.round(k)),L=Math.max(Wr,L),k=Math.max(Wr,k),fI(L,k,M,R,hI(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&_t(E,l)){let v=Math.max(0,y.width+p);l==="width"&&(n?v=_e(v,ra):v=Math.round(v));let C=Math.max(0,y.height+u);if(l==="height"&&(n?C=_e(C,ra):C=Math.round(C)),v=Math.max(Wr,v),C=Math.max(Wr,C),gI(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),df(E)){let S=cf(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap());f.push(...S)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},aO=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&df(a)){let l=cf(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=bI(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},lO=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=JF(()=>r.map(m=>{let c=ea(m,t);if(c.length>1){let[p,u,f,b]=hm(c.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[d]=c;return Math.round((e==="width"?d.latest.width:d.latest.height)*100)/100}),[t,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return sO(rt,{label:e==="width"?"W":"H",elements:o,dragInputCallback:iO,value:l,editable:s,appState:i,property:e,scene:n,dragFinishedCallback:aO})},mf=lO;import{getBoundTextElement as cO,redrawTextBoundingBox as EI}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as dO,isTextElement as mO}from"@haoxin-web/excalidraw-element";import{isInGroup as pO}from"@haoxin-web/excalidraw-element";import{jsx as bO}from"react/jsx-runtime";var yI=4,uO=4,hO=(e,o)=>e.reduce((t,r)=>{if(!r||pO(r))return t;if(mO(r))return t.push(r),t;if(dO(r)){let n=cO(r,o);if(n)return t.push(n),t}return t},[]),gO=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(r){l=Math.max(Math.round(r),yI);for(let s of a)n.mutateElement(s,{fontSize:l}),EI(s,n.getContainerElement(s),n);n.triggerUpdate()}else{let s=o;for(let m=0;m<a.length;m++){let c=a[m],d=s[m],p=Math.round(d.fontSize),u=Math.round(e),f=Math.max(p+u,yI);t&&(f=_e(f,uO)),n.mutateElement(c,{fontSize:f}),EI(c,n.getContainerElement(c),n)}n.triggerUpdate()}},fO=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=hO(e,n);if(!i.length)return null;let a=i.map(m=>Math.round(m.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return bO(rt,{label:"F",icon:nn,elements:i,dragInputCallback:gO,value:l,editable:s,scene:o,property:r,appState:t})},wI=fO;import{pointFrom as Yr,pointRotateRads as gm}from"@haoxin-web/excalidraw-math";import{useMemo as xO}from"react";import{isTextElement as EO}from"@haoxin-web/excalidraw-element";import{getCommonBounds as pf}from"@haoxin-web/excalidraw-element";import{jsx as IO}from"react/jsx-runtime";var yO=(e,o,t,r,n,i)=>{for(let a=0;a<r.length;a++){let l=r[a],[s,m]=[l.x+l.width/2,l.y+l.height/2],[c,d]=gm(Yr(l.x,l.y),Yr(s,m),l.angle),p=e==="x"?Math.round(c+o):c,u=e==="y"?Math.round(d+t):d;Cn(p,u,l,i,n,!1)}},wO=(e,o,t,r,n)=>{let i=n.getNonDeletedElementsMap(),[a,l,,]=pf(t),s=e-a,m=o-l;for(let c=0;c<t.length;c++){let d=t[c],p=i.get(d.id);if(p&&(!EO(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=gm(Yr(p.x,p.y),Yr(u,f),p.angle);Cn(b+s,x+m,d,n,r,!1)}}},vO=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(n!==void 0){for(let p of ta(o,l)){let u=ea(p,s,t);if(u.length>1){let[f,b,,]=pf(u.map(E=>E.latest));wO(i==="x"?n:f,i==="y"?n:b,u.map(E=>E.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&_t(b,i)){let[x,w]=[f.x+f.width/2,f.y+f.height/2],[E,y]=gm(Yr(f.x,f.y),Yr(x,w),f.angle);Cn(i==="x"?n:E,i==="y"?n:y,f,a,t,!1)}}}a.triggerUpdate();return}let m=r?_e(e,_l):e;yO(i,i==="x"?m:0,i==="y"?m:0,o,t,a),a.triggerUpdate()},TO=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=xO(()=>r.map(s=>{let m=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(m.length>1){let[b,x]=pf(m);return Math.round((e==="x"?b:x)*100)/100}let[c]=m,[d,p]=[c.x+c.width/2,c.y+c.height/2],[u,f]=gm(Yr(c.x,c.y),Yr(d,p),c.angle);return Math.round((e==="x"?u:f)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return IO(rt,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:vO,value:l,property:e,scene:n,appState:i})},uf=TO;import{clamp as Dl,pointFrom as fm,pointRotateRads as TI,round as vI}from"@haoxin-web/excalidraw-math";import{getFlipAdjustedCropPosition as CO,getUncroppedWidthAndHeight as SO}from"@haoxin-web/excalidraw-element";import{isImageElement as II}from"@haoxin-web/excalidraw-element";import{jsx as LO}from"react/jsx-runtime";var kO=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let m=l.getNonDeletedElementsMap(),c=t[0],[d,p]=[c.x+c.width/2,c.y+c.height/2],[u,f]=TI(fm(c.x,c.y),fm(d,p),c.angle);if(s.croppingElementId===c.id){let y=m.get(c.id);if(!y||!II(y)||!y.crop)return;let v=y.crop,C=v,S=y.scale[0]===-1,P=y.scale[1]===-1,{width:M,height:R}=SO(y);if(i!==void 0){if(a==="x"){let N=i*(v.naturalWidth/M);S?C={...v,x:Dl(v.naturalWidth-N-v.width,0,v.naturalWidth-v.width)}:C={...v,x:Dl(i*(v.naturalWidth/M),0,v.naturalWidth-v.width)}}a==="y"&&(C={...v,y:Dl(i*(v.naturalHeight/R),0,v.naturalHeight-v.height)}),l.mutateElement(y,{crop:C});return}let L=(a==="x"?o:0)*(S?-1:1),k=(a==="y"?o:0)*(P?-1:1);C={...v,x:Dl(v.x+L,0,v.naturalWidth-v.width),y:Dl(v.y+k,0,v.naturalHeight-v.height)},l.mutateElement(y,{crop:C});return}if(i!==void 0){Cn(a==="x"?i:u,a==="y"?i:f,c,l,r);return}let b=a==="x"?e:0,x=a==="y"?e:0,w=a==="x"?Math.round(n?_e(c.x+b,_l):u+b):u,E=a==="y"?Math.round(n?_e(c.y+x,_l):f+x):f;Cn(w,E,c,l,r)},MO=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=TI(fm(o.x,o.y),fm(o.x+o.width/2,o.y+o.height/2),o.angle),l=vI(e==="x"?i:a,2);if(n.croppingElementId===o.id&&II(o)&&o.crop){let s=CO(o);s&&(l=vI(e==="x"?s.x:s.y,2))}return LO(rt,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:kO,scene:r,value:l,property:e,appState:n})},hf=MO;import{Fragment as bf,jsx as Q,jsxs as Dt}from"react/jsx-runtime";var zO=50,Rl=e=>{let o=ko(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=Nr(e.app);return Q(HO,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},ke=({children:e,columns:o=1,heading:t,style:r,...n})=>Q("div",{className:PO("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});ke.displayName="StatsRow";var xm=({children:e,order:o,style:t,...r})=>Q("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});xm.displayName="StatsRows";Rl.StatsRow=ke;Rl.StatsRows=xm;var HO=DO(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),m=l.getNonDeletedElementsMap(),c=me(),d=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&ff(d),f=u?NO(d):null,[b,x]=_O({width:0,height:0}),w=gf(()=>AO(v=>{let C=RO(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},zO),[]);SI(()=>{w(s)},[i,s,w]),SI(()=>()=>w.cancel(),[w]);let E=gf(()=>ta(r,n),[r,n]),y=gf(()=>FO(r),[r]);return Q("div",{className:"exc-stats",children:Dt(De,{padding:3,children:[Dt("div",{className:"title",children:[Q("h2",{children:h("stats.title")}),Q("div",{className:"close",onClick:o,children:Vt})]}),Dt(Fa,{label:Q("h3",{children:h("stats.generalStats")}),open:!!(n.stats.panels&bm.generalStats),openTrigger:()=>c(v=>({stats:{open:!0,panels:v.stats.panels^bm.generalStats}})),children:[Dt(xm,{children:[Q(ke,{heading:!0,children:h("stats.scene")}),Dt(ke,{columns:2,children:[Q("div",{children:h("stats.shapes")}),Q("div",{children:s.length})]}),Dt(ke,{columns:2,children:[Q("div",{children:h("stats.width")}),Q("div",{children:b.width})]}),Dt(ke,{columns:2,children:[Q("div",{children:h("stats.height")}),Q("div",{children:b.height})]}),a&&Dt(bf,{children:[Q(ke,{heading:!0,children:"Canvas"}),Q(ke,{children:Q(QT,{property:"gridStep",scene:l,appState:n,setAppState:c})})]})]}),t?.(s,n)]}),!y&&r.length>0&&Q("div",{id:"elementStats",style:{marginTop:12},children:Q(Fa,{label:Q("h3",{children:h("stats.elementProperties")}),open:!!(n.stats.panels&bm.elementProperties),openTrigger:()=>c(v=>({stats:{open:!0,panels:v.stats.panels^bm.elementProperties}})),children:Dt(xm,{children:[d&&Dt(bf,{children:[u&&Q(ke,{heading:!0,children:h("labels.unCroppedDimension")}),n.croppingElementId&&ff(d)&&f&&Dt(ke,{columns:2,children:[Q("div",{children:h("stats.width")}),Q("div",{children:CI(f.width,2)})]}),n.croppingElementId&&ff(d)&&f&&Dt(ke,{columns:2,children:[Q("div",{children:h("stats.height")}),Q("div",{children:CI(f.height,2)})]}),Q(ke,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?h("labels.imageCropping"):String(d.type)}),Q(ke,{children:Q(hf,{element:d,property:"x",elementsMap:m,scene:l,appState:n})}),Q(ke,{children:Q(hf,{element:d,property:"y",elementsMap:m,scene:l,appState:n})}),Q(ke,{children:Q(lf,{property:"width",element:d,scene:l,appState:n})}),Q(ke,{children:Q(lf,{property:"height",element:d,scene:l,appState:n})}),!BO(d)&&Q(ke,{children:Q(qT,{property:"angle",element:d,scene:l,appState:n})}),Q(ke,{children:Q(sI,{property:"fontSize",element:d,scene:l,appState:n})})]}),p&&Dt(bf,{children:[OO(p)&&Q(ke,{heading:!0,children:h("element.group")}),Dt(ke,{columns:2,style:{margin:"0.3125rem 0"},children:[Q("div",{children:h("stats.shapes")}),Q("div",{children:r.length})]}),Q(ke,{children:Q(uf,{property:"x",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),Q(ke,{children:Q(uf,{property:"y",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),Q(ke,{children:Q(mf,{property:"width",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),Q(ke,{children:Q(mf,{property:"height",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),Q(ke,{children:Q(uI,{property:"angle",elements:p,scene:l,appState:n})}),Q(ke,{children:Q(wI,{property:"fontSize",elements:p,scene:l,appState:n,elementsMap:m})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as GO,useEffect as kI,useState as MI}from"react";import{normalizeLink as UO,KEYS as xf}from"@haoxin-web/excalidraw-common";import{defaultGetElementLinkFromSelection as WO,getLinkIdAndTypeFromSelection as YO}from"@haoxin-web/excalidraw-element";import{jsx as na,jsxs as Em}from"react/jsx-runtime";var VO=({sourceElementId:e,onClose:o,appState:t,scene:r,generateLinkForSelection:n=WO})=>{let i=r.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=MI(a),[m,c]=MI(!1);kI(()=>{let p=J(i,t),u=a;if(p.length>0&&n){let f=YO(p,t);f&&(u=UO(n(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,n]);let d=GO(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&r.mutateElement(p,{link:l})}if(!l&&m&&e){let p=i.get(e);p&&r.mutateElement(p,{link:null})}o?.()},[e,l,i,m,r,o]);return kI(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===xf.ENTER&&d(),t.openDialog?.name==="elementLinkSelector"&&u.key===xf.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,d]),Em("div",{className:"ElementLinkDialog",children:[Em("div",{className:"ElementLinkDialog__header",children:[na("h2",{children:h("elementLink.title")}),na("p",{children:h("elementLink.desc")})]}),Em("div",{className:"ElementLinkDialog__input",children:[na(Ni,{value:l??"",onChange:p=>{m||c(!0),s(p)},onKeyDown:p=>{p.key===xf.ENTER&&d()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&na(z,{type:"button",title:h("buttons.remove"),"aria-label":h("buttons.remove"),label:h("buttons.remove"),onClick:()=>{s(null),c(!0)},className:"ElementLinkDialog__remove",icon:Bt})]}),Em("div",{className:"ElementLinkDialog__actions",children:[na(Jo,{label:h("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),na(Jo,{label:h("buttons.confirm"),onClick:d,actionType:"primary"})]})]})},LI=VO;import XO,{useState as KO}from"react";import{Fragment as ZO,jsx as Ef}from"react/jsx-runtime";var PI=({children:e,onClose:o})=>{let[t,r]=KO(!!e),{container:n}=Xe(),i=XO.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return Ef(ZO,{children:t&&Ef(Ge,{size:"small",onCloseRequest:i,title:h("errorDialog.title"),children:Ef("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import $O from"react";import{isDarwin as AI,isFirefox as _I,isWindows as jO}from"@haoxin-web/excalidraw-common";import{KEYS as Ne,getShortcutKey as Z}from"@haoxin-web/excalidraw-common";import{Fragment as RI,jsx as U,jsxs as Yt}from"react/jsx-runtime";var qO=()=>Yt("div",{className:"HelpDialog__header",children:[Yt("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[U("div",{className:"HelpDialog__link-icon",children:tp}),h("helpDialog.documentation")]}),Yt("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[U("div",{className:"HelpDialog__link-icon",children:tp}),h("helpDialog.blog")]}),Yt("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[U("div",{className:"HelpDialog__link-icon",children:Cs}),h("helpDialog.github")]}),Yt("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[U("div",{className:"HelpDialog__link-icon",children:P0}),"YouTube"]})]}),JO=e=>Yt(RI,{children:[U("h3",{children:e.title}),U("div",{className:"HelpDialog__islands-container",children:e.children})]}),yf=e=>Yt("div",{className:`HelpDialog__island ${e.className}`,children:[U("h4",{className:"HelpDialog__island-title",children:e.caption}),U("div",{className:"HelpDialog__island-content",children:e.children})]});function*QO(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var ez=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),Y=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>U(tz,{children:ez(a)},a)));return Yt("div",{className:"HelpDialog__shortcut",children:[U("div",{children:e}),U("div",{className:"HelpDialog__key-container",children:[...QO(r,t?h("helpDialog.or"):null)]})]})},tz=e=>U("kbd",{className:"HelpDialog__key",...e}),DI=({onClose:e})=>{let o=$O.useCallback(()=>{e&&e()},[e]);return U(RI,{children:Yt(Ge,{onCloseRequest:o,title:h("helpDialog.title"),className:"HelpDialog",children:[U(qO,{}),Yt(JO,{title:h("helpDialog.shortcuts"),children:[Yt(yf,{className:"HelpDialog__island--tools",caption:h("helpDialog.tools"),children:[U(Y,{label:h("toolBar.hand"),shortcuts:[Ne.H]}),U(Y,{label:h("toolBar.selection"),shortcuts:[Ne.V,Ne[1]]}),U(Y,{label:h("toolBar.rectangle"),shortcuts:[Ne.R,Ne[2]]}),U(Y,{label:h("toolBar.diamond"),shortcuts:[Ne.D,Ne[3]]}),U(Y,{label:h("toolBar.ellipse"),shortcuts:[Ne.O,Ne[4]]}),U(Y,{label:h("toolBar.arrow"),shortcuts:[Ne.A,Ne[5]]}),U(Y,{label:h("toolBar.line"),shortcuts:[Ne.L,Ne[6]]}),U(Y,{label:h("toolBar.freedraw"),shortcuts:[Ne.P,Ne[7]]}),U(Y,{label:h("toolBar.text"),shortcuts:[Ne.T,Ne[8]]}),U(Y,{label:h("toolBar.image"),shortcuts:[Ne[9]]}),U(Y,{label:h("toolBar.eraser"),shortcuts:[Ne.E,Ne[0]]}),U(Y,{label:h("toolBar.frame"),shortcuts:[Ne.F]}),U(Y,{label:h("toolBar.laser"),shortcuts:[Ne.K]}),U(Y,{label:h("labels.eyeDropper"),shortcuts:[Ne.I,"Shift+S","Shift+G"]}),U(Y,{label:h("helpDialog.editLineArrowPoints"),shortcuts:[Z("CtrlOrCmd+Enter")]}),U(Y,{label:h("helpDialog.editText"),shortcuts:[Z("Enter")]}),U(Y,{label:h("helpDialog.textNewLine"),shortcuts:[Z("Enter"),Z("Shift+Enter")]}),U(Y,{label:h("helpDialog.textFinish"),shortcuts:[Z("Esc"),Z("CtrlOrCmd+Enter")]}),U(Y,{label:h("helpDialog.curvedArrow"),shortcuts:["A",h("helpDialog.click"),h("helpDialog.click"),h("helpDialog.click")],isOr:!1}),U(Y,{label:h("helpDialog.curvedLine"),shortcuts:["L",h("helpDialog.click"),h("helpDialog.click"),h("helpDialog.click")],isOr:!1}),U(Y,{label:h("helpDialog.cropStart"),shortcuts:[h("helpDialog.doubleClick"),Z("Enter")],isOr:!0}),U(Y,{label:h("helpDialog.cropFinish"),shortcuts:[Z("Enter"),Z("Escape")],isOr:!0}),U(Y,{label:h("toolBar.lock"),shortcuts:[Ne.Q]}),U(Y,{label:h("helpDialog.preventBinding"),shortcuts:[Z("CtrlOrCmd")]}),U(Y,{label:h("toolBar.link"),shortcuts:[Z("CtrlOrCmd+K")]}),U(Y,{label:h("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Yt(yf,{className:"HelpDialog__island--view",caption:h("helpDialog.view"),children:[U(Y,{label:h("buttons.zoomIn"),shortcuts:[Z("CtrlOrCmd++")]}),U(Y,{label:h("buttons.zoomOut"),shortcuts:[Z("CtrlOrCmd+-")]}),U(Y,{label:h("buttons.resetZoom"),shortcuts:[Z("CtrlOrCmd+0")]}),U(Y,{label:h("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),U(Y,{label:h("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),U(Y,{label:h("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),U(Y,{label:h("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),U(Y,{label:h("buttons.zenMode"),shortcuts:[Z("Alt+Z")]}),U(Y,{label:h("buttons.objectsSnapMode"),shortcuts:[Z("Alt+S")]}),U(Y,{label:h("labels.toggleGrid"),shortcuts:[Z("CtrlOrCmd+'")]}),U(Y,{label:h("labels.viewMode"),shortcuts:[Z("Alt+R")]}),U(Y,{label:h("labels.toggleTheme"),shortcuts:[Z("Alt+Shift+D")]}),U(Y,{label:h("stats.fullTitle"),shortcuts:[Z("Alt+/")]}),U(Y,{label:h("search.title"),shortcuts:[He("searchMenu")]}),U(Y,{label:h("commandPalette.title"),shortcuts:_I?[He("commandPalette")]:[He("commandPalette"),He("commandPalette",1)]})]}),Yt(yf,{className:"HelpDialog__island--editor",caption:h("helpDialog.editor"),children:[U(Y,{label:h("helpDialog.createFlowchart"),shortcuts:[Z("CtrlOrCmd+Arrow Key")],isOr:!0}),U(Y,{label:h("helpDialog.navigateFlowchart"),shortcuts:[Z("Alt+Arrow Key")],isOr:!0}),U(Y,{label:h("labels.moveCanvas"),shortcuts:[Z(`Space+${h("helpDialog.drag")}`),Z(`Wheel+${h("helpDialog.drag")}`)],isOr:!0}),U(Y,{label:h("buttons.clearReset"),shortcuts:[Z("CtrlOrCmd+Delete")]}),U(Y,{label:h("labels.delete"),shortcuts:[Z("Delete")]}),U(Y,{label:h("labels.cut"),shortcuts:[Z("CtrlOrCmd+X")]}),U(Y,{label:h("labels.copy"),shortcuts:[Z("CtrlOrCmd+C")]}),U(Y,{label:h("labels.paste"),shortcuts:[Z("CtrlOrCmd+V")]}),U(Y,{label:h("labels.pasteAsPlaintext"),shortcuts:[Z("CtrlOrCmd+Shift+V")]}),U(Y,{label:h("labels.selectAll"),shortcuts:[Z("CtrlOrCmd+A")]}),U(Y,{label:h("labels.multiSelect"),shortcuts:[Z(`Shift+${h("helpDialog.click")}`)]}),U(Y,{label:h("helpDialog.deepSelect"),shortcuts:[Z(`CtrlOrCmd+${h("helpDialog.click")}`)]}),U(Y,{label:h("helpDialog.deepBoxSelect"),shortcuts:[Z(`CtrlOrCmd+${h("helpDialog.drag")}`)]}),(pi||_I)&&U(Y,{label:h("labels.copyAsPng"),shortcuts:[Z("Shift+Alt+C")]}),U(Y,{label:h("labels.copyStyles"),shortcuts:[Z("CtrlOrCmd+Alt+C")]}),U(Y,{label:h("labels.pasteStyles"),shortcuts:[Z("CtrlOrCmd+Alt+V")]}),U(Y,{label:h("labels.sendToBack"),shortcuts:[AI?Z("CtrlOrCmd+Alt+["):Z("CtrlOrCmd+Shift+[")]}),U(Y,{label:h("labels.bringToFront"),shortcuts:[AI?Z("CtrlOrCmd+Alt+]"):Z("CtrlOrCmd+Shift+]")]}),U(Y,{label:h("labels.sendBackward"),shortcuts:[Z("CtrlOrCmd+[")]}),U(Y,{label:h("labels.bringForward"),shortcuts:[Z("CtrlOrCmd+]")]}),U(Y,{label:h("labels.alignTop"),shortcuts:[Z("CtrlOrCmd+Shift+Up")]}),U(Y,{label:h("labels.alignBottom"),shortcuts:[Z("CtrlOrCmd+Shift+Down")]}),U(Y,{label:h("labels.alignLeft"),shortcuts:[Z("CtrlOrCmd+Shift+Left")]}),U(Y,{label:h("labels.alignRight"),shortcuts:[Z("CtrlOrCmd+Shift+Right")]}),U(Y,{label:h("labels.duplicateSelection"),shortcuts:[Z("CtrlOrCmd+D"),Z(`Alt+${h("helpDialog.drag")}`)]}),U(Y,{label:h("helpDialog.toggleElementLock"),shortcuts:[Z("CtrlOrCmd+Shift+L")]}),U(Y,{label:h("buttons.undo"),shortcuts:[Z("CtrlOrCmd+Z")]}),U(Y,{label:h("buttons.redo"),shortcuts:jO?[Z("CtrlOrCmd+Y"),Z("CtrlOrCmd+Shift+Z")]:[Z("CtrlOrCmd+Shift+Z")]}),U(Y,{label:h("labels.group"),shortcuts:[Z("CtrlOrCmd+G")]}),U(Y,{label:h("labels.ungroup"),shortcuts:[Z("CtrlOrCmd+Shift+G")]}),U(Y,{label:h("labels.flipHorizontal"),shortcuts:[Z("Shift+H")]}),U(Y,{label:h("labels.flipVertical"),shortcuts:[Z("Shift+V")]}),U(Y,{label:h("labels.showStroke"),shortcuts:[Z("S")]}),U(Y,{label:h("labels.showBackground"),shortcuts:[Z("G")]}),U(Y,{label:h("labels.showFonts"),shortcuts:[Z("Shift+F")]}),U(Y,{label:h("labels.decreaseFontSize"),shortcuts:[Z("CtrlOrCmd+Shift+<")]}),U(Y,{label:h("labels.increaseFontSize"),shortcuts:[Z("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as FI,useRef as lz,useState as Vr}from"react";import{DEFAULT_EXPORT_PADDING as sz,EXPORT_IMAGE_TYPES as wf,isFirefox as cz,EXPORT_SCALES as dz,cloneJSON as OI}from"@haoxin-web/excalidraw-common";import{useCallback as oz,useRef as rz,useState as nz}from"react";var iz=2e3,NI=()=>{let[e,o]=nz(null),t=rz(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},iz)},n=oz(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import az from"clsx";import{jsx as BI}from"react/jsx-runtime";var Nl=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>BI("div",{className:az("Switch",{toggled:t,disabled:n}),children:BI("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:n,onChange:()=>r(!t),onKeyDown:i=>{i.key===" "&&r(!t)}})});import{jsx as Me,jsxs as Xr}from"react/jsx-runtime";var mz="filter"in document.createElement("canvas").getContext("2d"),pz=()=>Xr("div",{children:[Me("h3",{children:h("canvasError.cannotShowPreview")}),Me("p",{children:Me("span",{children:h("canvasError.canvasTooBig")})}),Xr("em",{children:["(",h("canvasError.canvasTooBigTip"),")"]})]}),uz=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=we(o,e),[l,s]=Vr(i),[m,c]=Vr(a),[d,p]=Vr(e.exportBackground),[u,f]=Vr(e.exportWithDarkMode),[b,x]=Vr(e.exportEmbedScene),[w,E]=Vr(e.exportScale),y=lz(null),[v,C]=Vr(null),{onCopy:S,copyStatus:P,resetCopyStatus:M}=NI();FI(()=>{M()},[l,d,u,w,b,M]);let{exportedElements:R,exportingFrame:L}=mn(o,e,m);return FI(()=>{let k=y.current;if(!k)return;let N=k.offsetWidth,O=k.offsetHeight;N&&Lr({elements:R,appState:{...e,name:l,exportBackground:d,exportWithDarkMode:u,exportScale:w,exportEmbedScene:b},files:t,exportPadding:sz,maxWidthOrHeight:Math.max(N,O),exportingFrame:L}).then(G=>(C(null),Go(G).then(()=>{k.replaceChildren(G)}).catch(_=>{throw _.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):_}))).catch(G=>{console.error(G),C(G)})},[e,t,R,L,l,d,u,w,b]),Xr("div",{className:"ImageExportModal",children:[Me("h3",{children:h("imageExportDialog.header")}),Xr("div",{className:"ImageExportModal__preview",children:[Me("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Me(pz,{})}),Me("div",{className:"ImageExportModal__preview__filename",children:!Rn&&Me("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{s(k.target.value),r.executeAction(wu,"ui",k.target.value)}})})]}),Xr("div",{className:"ImageExportModal__settings",children:[Me("h3",{children:h("imageExportDialog.header")}),a&&Me(Bl,{label:h("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Me(Nl,{name:"exportOnlySelected",checked:m,onChange:k=>{c(k)}})}),Me(Bl,{label:h("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Me(Nl,{name:"exportBackgroundSwitch",checked:d,onChange:k=>{p(k),r.executeAction(vu,"ui",k)}})}),mz&&Me(Bl,{label:h("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Me(Nl,{name:"exportDarkModeSwitch",checked:u,onChange:k=>{f(k),r.executeAction(wE,"ui",k)}})}),Me(Bl,{label:h("imageExportDialog.label.embedScene"),tooltip:h("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Me(Nl,{name:"exportEmbedSwitch",checked:b,onChange:k=>{x(k),r.executeAction(Ac,"ui",k)}})}),Me(Bl,{label:h("imageExportDialog.label.scale"),name:"exportScale",children:Me(Xd,{name:"exportScale",value:w,onChange:k=>{E(k),r.executeAction(yE,"ui",k)},choices:dz.map(k=>({value:k,label:`${k}\xD7`}))})}),Xr("div",{className:"ImageExportModal__settings__buttons",children:[Me(zr,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.exportToPng"),onClick:()=>n(wf.png,R,{exportingFrame:L}),icon:fp,children:h("imageExportDialog.button.exportToPng")}),Me(zr,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.exportToSvg"),onClick:()=>n(wf.svg,R,{exportingFrame:L}),icon:fp,children:h("imageExportDialog.button.exportToSvg")}),(pi||cz)&&Me(zr,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await n(wf.clipboard,R,{exportingFrame:L}),S()},icon:Yn,children:h("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Bl=({label:e,children:o,tooltip:t,name:r})=>Xr("div",{className:"ImageExportModal__settings__setting",title:e,children:[Xr("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Me(mo,{label:t,long:!0,children:n0})]}),Me("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),zI=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Vr(()=>({appStateSnapshot:OI(o),elementsSnapshot:OI(e)}));return Me(Ge,{onCloseRequest:i,size:"wide",title:!1,children:Me(uz,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import gz from"react";import{getFrame as fz}from"@haoxin-web/excalidraw-common";import vf from"open-color";import{jsx as hz}from"react/jsx-runtime";var Tf=({children:e,color:o})=>hz("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":vf[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":vf[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":vf[o][9]},children:e});import{Fragment as xz,jsx as yo,jsxs as ym}from"react/jsx-runtime";var bz=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return yo("div",{className:"ExportDialog ExportDialog--json",children:ym("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&ym(Tf,{color:"lime",children:[yo("div",{className:"Card-icon",children:yb}),yo("h2",{children:h("exportDialog.disk_title")}),ym("div",{className:"Card-details",children:[h("exportDialog.disk_details"),!Rn&&n.renderAction("changeProjectName")]}),yo(z,{className:"Card-button",type:"button",title:h("exportDialog.disk_button"),"aria-label":h("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(ja,"ui")}})]}),s&&ym(Tf,{color:"pink",children:[yo("div",{className:"Card-icon",children:va}),yo("h2",{children:h("exportDialog.link_title")}),yo("div",{className:"Card-details",children:h("exportDialog.link_details")}),yo(z,{className:"Card-button",type:"button",title:h("exportDialog.link_button"),"aria-label":h("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ae("export","link",`ui (${fz()})`),await s(e,o,r),l()}catch(m){t({errorMessage:m.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},HI=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=gz.useCallback(()=>{a({openDialog:null})},[a]);return yo(xz,{children:o.openDialog?.name==="jsonExport"&&yo(Ge,{onCloseRequest:l,title:h("buttons.export"),children:yo(bz,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import Ez from"clsx";import{jsx as GI,jsxs as wz}from"react/jsx-runtime";var yz="small",UI=e=>wz("label",{className:Ez("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${yz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[GI("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),GI("div",{className:"ToolIcon__icon",children:Yo})]});import{useState as ia,useRef as WI,useEffect as Fl}from"react";import{Palette as vz}from"lucide-react";import{jsx as lt,jsxs as wm}from"react/jsx-runtime";var Tz=[{value:"transparent",label:"\u767D\u8272\u80CC\u666F",color:"#ffffff",isTransparent:!0},{value:"#000000",label:"\u9ED1\u8272\u80CC\u666F",color:"#000000"},{value:"#22c55e",label:"\u7EFF\u8272\u80CC\u666F",color:"#22c55e"},{value:"#3b82f6",label:"\u84DD\u8272\u80CC\u666F",color:"#3b82f6"},{value:"#f59e0b",label:"\u6A59\u8272\u80CC\u666F",color:"#f59e0b"},{value:"#ef4444",label:"\u7EA2\u8272\u80CC\u666F",color:"#ef4444"}],YI=({appState:e,setAppState:o,actionManager:t,canvas:r})=>{let[n,i]=ia(!1),a=WI(null),[l,s]=ia(!1),[m,c]=ia(!1),[d,p]=ia([]),[u,f]=ia(null),b=WI(null),[x,w]=ia("#ff3b30");Fl(()=>{let L=localStorage.getItem("excalidraw-background-color");L&&L!==e.viewBackgroundColor&&t.executeAction(xc,"ui",{viewBackgroundColor:L}),w("#ff3b30")},[]);let E=L=>{localStorage.setItem("excalidraw-background-color",L)},y=L=>{let k=L==="transparent"?"#ffffff":L;t.executeAction(xc,"ui",{viewBackgroundColor:k}),E(k),i(!1)},v=()=>e.viewBackgroundColor||"transparent",C=()=>{p([])},S=(L,k)=>{let N={id:`trail-${Date.now()}-${Math.random()}`,x:L,y:k,timestamp:Date.now()};p(O=>[...O,N]),setTimeout(()=>{p(O=>O.filter(G=>G.id!==N.id))},3e3)},P=L=>{if(!r)return;let k=r.getBoundingClientRect(),N=L.clientX-k.left,O=L.clientY-k.top;f({x:N,y:O}),m&&S(N,O)},M=()=>{let L=!l;s(L),c(!1),L&&f(null),L?(o(k=>({...k,activeTool:{...k.activeTool,type:"laser",customType:null},cursorButton:"up"})),r&&(r.style.cursor="none")):(o(k=>({...k,activeTool:{...k.activeTool,type:"selection",customType:null}})),r&&(r.style.cursor="default"))},R=()=>{let L=!m;c(L),s(!1),L&&f(null),L?(o(k=>({...k,activeTool:{...k.activeTool,type:"laserTrail",customType:null,color:"transparent",backgroundColor:"transparent"},cursorButton:"up"})),r&&(r.style.cursor="none")):(o(k=>({...k,activeTool:{...k.activeTool,type:"selection",customType:null}})),r&&(r.style.cursor="default"))};return Fl(()=>{if((l||m)&&r)return r.addEventListener("mousemove",P),()=>{r.removeEventListener("mousemove",P)}},[l,m,r]),Fl(()=>{let L=e?.activeTool?.type;L!=="laser"&&L!=="laserTrail"&&(l||m)&&(s(!1),c(!1),r&&(r.style.cursor="default"))},[e?.activeTool?.type,l,m,r]),Fl(()=>()=>{b.current&&clearTimeout(b.current)},[]),Fl(()=>{if(!n)return;let L=k=>{let N=k.target;a.current&&N&&!a.current.contains(N)&&i(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[n]),wm("div",{className:"top-left-toolbar",children:[lt("div",{className:"top-left-toolbar__section",ref:a,children:wm("div",{className:"top-left-toolbar__group",style:{position:"relative"},children:[lt("button",{className:`top-left-toolbar__button ${n?"top-left-toolbar__button--active":""}`,onClick:()=>i(!n),title:"\u80CC\u666F\u8C03\u8272\u677F",children:lt(vz,{size:16})}),n&&lt("div",{className:"top-left-toolbar__palette",children:lt("div",{className:"top-left-toolbar__palette-grid",children:Tz.map(L=>lt("button",{className:`top-left-toolbar__color-button ${v()===L.value?"top-left-toolbar__color-button--active":""}`,onClick:()=>y(L.value),title:L.label,style:{backgroundColor:L.isTransparent?"#ffffff":L.color,border:L.isTransparent?"2px solid #e0e0e0":`2px solid ${L.color}`},children:L.isTransparent&&lt("div",{className:"top-left-toolbar__transparent-pattern",children:wm("svg",{width:"16",height:"16",viewBox:"0 0 16 16",children:[lt("defs",{children:wm("pattern",{id:"checkerboard",patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[lt("rect",{width:"4",height:"4",fill:"#f0f0f0"}),lt("rect",{x:"4",y:"4",width:"4",height:"4",fill:"#f0f0f0"}),lt("rect",{x:"4",y:"0",width:"4",height:"4",fill:"#ffffff"}),lt("rect",{x:"0",y:"4",width:"4",height:"4",fill:"#ffffff"})]})}),lt("rect",{width:"16",height:"16",fill:"url(#checkerboard)",rx:"2"})]})})},L.value))})}),lt("button",{className:`top-left-toolbar__button ${m?"top-left-toolbar__button--active":""}`,onClick:R,title:"\u6FC0\u5149\u7B14",children:Yo})]})}),(l||m)&&r&&u&&lt("div",{className:"top-left-toolbar__laser-dot",style:{position:"fixed",left:u.x-4,top:u.y-4,width:8,height:8,borderRadius:"50%",backgroundColor:x,pointerEvents:"none",zIndex:1e3,boxShadow:`0 0 8px ${x}99`}}),m&&d.length>0&&lt("svg",{className:"top-left-toolbar__laser-trails",style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:999},children:d.map((L,k)=>{let N=Date.now()-L.timestamp,O=Math.max(0,1-N/3e3);return lt("circle",{cx:L.x,cy:L.y,r:3,fill:x,opacity:O},L.id)})})]})};import{Fragment as ZI,jsx as ee,jsxs as wo}from"react/jsx-runtime";var Lz=({UIOptions:e})=>wo(ft,{__fallback:!0,children:[ee(ft.DefaultItems.LoadScene,{}),ee(ft.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ee(ft.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ee(ft.DefaultItems.SaveAsImage,{}),ee(ft.DefaultItems.SearchMenu,{}),ee(ft.DefaultItems.Help,{}),ee(ft.DefaultItems.ClearCanvas,{}),ee(ft.Separator,{}),ee(ft.Group,{title:"Excalidraw links",children:ee(ft.DefaultItems.Socials,{})}),ee(ft.Separator,{}),ee(ft.DefaultItems.ToggleTheme,{}),ee(ft.DefaultItems.ChangeCanvasBackground,{})]}),Pz=()=>wo(jd,{__fallback:!0,children:[ee(jd.Actions.SaveToDisk,{}),ee(jd.Actions.ExportToImage,{})]}),Az=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:m,renderTopRightUI:c,renderCustomStats:d,UIOptions:p,onExportImage:u,renderWelcomeScreen:f,children:b,app:x,isCollaborating:w,generateLinkForSelection:E,showZoomActions:y,showPanActions:v,showToolBar:C=!0,showTopLeftToolbar:S=!0})=>{let P=pe(),M=Nw(),R=M.tunnelsJotai.Provider,[L,k]=ce(Er),N=()=>p.canvasActions.export?ee(HI,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,O=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:ee(zI,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),G=()=>wo("div",{style:{position:"relative"},children:[ee(M.MainMenuTunnel.Out,{}),f&&ee(M.WelcomeScreenMenuHintTunnel.Out,{})]}),_=()=>o.viewModeEnabled||o.openDialog?.name==="elementLinkSelector"||!C?null:ee(Il,{side:"left",children:ee("div",{className:"App-menu App-menu_left",children:ee(In,{heading:"shapes",className:"shapes-section-left",children:q=>wo("div",{style:{position:"relative"},children:[f&&ee(M.WelcomeScreenToolbarHintTunnel.Out,{}),wo(Ue.Col,{gap:4,align:"center",children:[ee(o3,{appState:o,app:x,visible:C}),w&&ee(De,{style:{marginTop:8,alignSelf:"center",width:"fit-content"},children:ee(UI,{title:h("toolBar.laser"),checked:o.activeTool.type===XI.laser,onChange:()=>x.setActiveTool({type:XI.laser}),isMobile:!1})})]})]})})})}),B=()=>{let q=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return ee(Il,{side:"top",children:wo("div",{className:"App-menu App-menu_top",children:[ee(Ue.Col,{gap:6,className:VI("App-menu_top__left"),style:{display:"none"},children:G()}),wo("div",{className:VI("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),style:{display:"none"},children:[o.collaborators.size>0&&ee(Sl,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),c?.(P.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!j||o.openSidebar?.name!==If.name)&&ee(M.DefaultSidebarTriggerTunnel.Out,{}),q&&ee(Rl,{app:x,onClose:()=>{e.executeAction(vi)},renderCustomStats:d})]})]})})},K=()=>ee(Qd,{__fallback:!0,onDock:q=>{ae("sidebar",`toggleDock (${q?"dock":"undock"})`,`(${P.editor.isMobile?"mobile":"desktop"})`)}}),j=hs(kl),X=wo(ZI,{children:[b,ee(Lz,{UIOptions:p}),ee(Qd.Trigger,{__fallback:!0,icon:zn,title:Sz(h("toolBar.library")),onToggle:q=>{q&&ae("sidebar",`${If.name} (open)`,`button (${P.editor.isMobile?"mobile":"desktop"})`)},tab:If.defaultTab,children:h("toolBar.library")}),ee(Pz,{}),o.openDialog?.name==="ttd"&&ee(ef,{__fallback:!0}),o.isLoading&&ee(Ud,{delay:250}),o.errorMessage&&ee(PI,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),L&&!P.editor.isMobile&&ee(Z0,{colorPickerType:L.colorPickerType,onCancel:()=>{k(null)},onChange:(q,se,ie,{altKey:be})=>{if(!(q!=="elementBackground"&&q!=="elementStroke"))if(ie.length){for(let ue of ie)kz(ue,Cz(n),{[be&&L.swapPreviewOnAlt?q==="elementBackground"?"strokeColor":"backgroundColor":q==="elementBackground"?"backgroundColor":"strokeColor"]:se}),Mz.delete(ue);x.scene.triggerUpdate()}else r(q==="elementBackground"?{currentItemBackgroundColor:se}:{currentItemStrokeColor:se})},onSelect:(q,se)=>{k(ie=>ie?.keepOpenOnAlt&&se.altKey?ie:null),L?.onSelect?.(q,se)}}),o.openDialog?.name==="help"&&ee(DI,{onClose:()=>{r({openDialog:null})}}),ee(Yw,{}),o.openDialog?.name==="elementLinkSelector"&&ee(LI,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:E}),ee(M.OverwriteConfirmDialogTunnel.Out,{}),O(),N(),o.pasteDialog.shown&&ee(b3,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),P.editor.isMobile&&ee(g3,{app:x,appState:o,elements:n,actionManager:e,renderJSONExportDialog:N,renderImageExportDialog:O,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:c,renderCustomStats:d,renderSidebars:K,device:P,renderWelcomeScreen:f,UIOptions:p,showPanActions:v}),!P.editor.isMobile&&wo(ZI,{children:[wo("div",{className:"layer-ui__wrapper",style:o.openSidebar&&j&&P.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&ee(M.WelcomeScreenCenterTunnel.Out,{}),_(),B(),ee(T3,{appState:o,actionManager:e,showExitZenModeBtn:m,renderWelcomeScreen:f,showZoomActions:y}),o.scrolledOutside&&ee("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(q=>({...en(n,q)}))},children:h("buttons.scrollBackToContent")})]}),K()]})]});return ee(Ap.Provider,{value:o,children:ee(R,{children:wo(Ph.Provider,{value:M,children:[X,!o.viewModeEnabled&&C&&ee(nT,{appState:o,app:x,actionManager:e,elements:n,showToolBar:C}),!P.editor.isMobile&&!o.viewModeEnabled&&S&&ee(YI,{appState:o,setAppState:r,actionManager:e,canvas:i})]})})})},KI=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},_z=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return vm(KI(r),KI(a),{selectedElementIds:vm,selectedGroupIds:vm})&&vm(n,l)},$I=Iz.memo(Az,_z);import Dz from"clsx";import{jsx as jI,jsxs as Nz}from"react/jsx-runtime";var Rz="small",Tm=e=>Nz("label",{className:Dz("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${Rz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[jI("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),jI("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as Bz,useRef as Fz}from"react";import{jsx as qI}from"react/jsx-runtime";var JI=({trails:e})=>{let o=Fz(null);return Bz(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),qI("div",{className:"SVGLayer",children:qI("svg",{ref:o})})};import Oz,{useEffect as zz,useRef as Hz}from"react";import{CURSOR_TYPE as QI,isShallowEqual as Gz,sceneCoordsToViewportCoords as Uz}from"@haoxin-web/excalidraw-common";import{jsx as Vz}from"react/jsx-runtime";var Wz=e=>{let o=Hz(!1);return zz(()=>{if(!o.current){o.current=!0;return}let t=new Map,r=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,m)=>{if(s.selectedElementIds)for(let c of Object.keys(s.selectedElementIds))n.has(c)||n.set(c,[]),n.get(c).push(m);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(m,s.username),s.userState&&a.set(m,s.userState),r.set(m,Uz({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(m,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";vv({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:t,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Ki())}),Vz("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?QI.GRAB:QI.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:h("labels.drawingCanvas")})},e5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,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}),Yz=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:Gz(e5(e.appState),e5(o.appState)),Cf=Oz.memo(Wz,Yz);import Xz,{useEffect as t5,useRef as o5}from"react";import{isShallowEqual as r5}from"@haoxin-web/excalidraw-common";import{jsx as $z}from"react/jsx-runtime";var Kz=e=>{let o=o5(null),t=o5(!1);return t5(()=>{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]),t5(()=>{let r=o.current;if(!r)return;let n=e.canvas;t.current||(t.current=!0,r.replaceChildren(n),n.classList.add("excalidraw__canvas","static")),F1({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Ki())}),$z("div",{className:"excalidraw__canvas-wrapper",ref:o})},n5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId}),Zz=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:r5(n5(e.appState),n5(o.appState))&&r5(e.renderConfig,o.renderConfig),Sf=Xz.memo(Kz,Zz);import{useEffect as oH,useRef as rH}from"react";import{throttleRAF as jz}from"@haoxin-web/excalidraw-common";import{getTargetFrame as qz,isInvisiblySmallElement as Jz,renderElement as Qz,shouldApplyFrameClip as eH}from"@haoxin-web/excalidraw-element";var i5=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,m]=ls(e,i),c=ss({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:m});if(c.save(),c.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(Jz(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=qz(t,r,a);p&&eH(t,p,a,r)&&N1(p,c,l,a)}Qz(t,r,n,o,c,l,a)}else c.clearRect(0,0,s,m);c.restore()}},tH=jz(e=>{i5(e)},{trailing:!0}),a5=(e,o)=>{if(o){tH(e);return}i5(e)};import{jsx as iH}from"react/jsx-runtime";var nH=e=>{let o=rH(null);return oH(()=>{o.current&&a5({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Ki())}),iH("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},l5=nH;import{useCallback as aH,useEffect as lH,useRef as sH}from"react";import{jsx as s5,jsxs as dH}from"react/jsx-runtime";var cH=5e3,c5=({message:e,onClose:o,closable:t=!1,duration:r=cH,style:n})=>{let i=sH(0),a=r!==1/0,l=aH(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return lH(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),dH("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[s5("p",{className:"Toast__message",children:e}),t&&s5(z,{icon:Vt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as mH,getElementsInGroup as pH,selectGroupsFromGivenElements as uH}from"@haoxin-web/excalidraw-element";import{sceneCoordsToViewportCoords as hH}from"@haoxin-web/excalidraw-common";import{flushSync as gH}from"react-dom";import{jsx as bH}from"react/jsx-runtime";var fH=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),r=t?[t]:pH(e.scene.getNonDeletedElementsMap(),o);if(r.length===0)return null;let[n,i]=mH(r),{x:a,y:l}=hH({sceneX:n,sceneY:i},e.state);return bH("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{gH(()=>{let s=uH(r,e.state);e.setState({selectedElementIds:r.reduce((m,c)=>({...m,[c.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(tl)},title:h("labels.elementLock.unlock"),children:nb})},d5=fH;import{Fragment as uU,jsx as fe,jsxs as Am}from"react/jsx-runtime";var pC=zo.createContext(null),uC=zo.createContext(null),hC={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},i1=zo.createContext(hC);i1.displayName="DeviceContext";var a1=zo.createContext({container:null,id:null});a1.displayName="ExcalidrawContainerContext";var l1=zo.createContext([]);l1.displayName="ExcalidrawElementsContext";var s1=zo.createContext({...mr(),width:0,height:0,offsetLeft:0,offsetTop:0});s1.displayName="ExcalidrawAppStateContext";var c1=zo.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});c1.displayName="ExcalidrawSetAppStateContext";var d1=zo.createContext(null);d1.displayName="ExcalidrawActionManagerContext";var Oe=()=>Jr(pC),Mo=()=>Jr(uC),pe=()=>Jr(i1),Xe=()=>Jr(a1),yr=()=>Jr(l1),ko=()=>Jr(s1),me=()=>Jr(c1),Ke=()=>Jr(d1),Vl=!1,Qf=0,Xl=null,Pn=!1,Kl=!1,e1=!1,Zl={horizontal:null,vertical:null},qr=0,$l=!1,t1=new Map,o1=!1,sC=0,cC=!1,jl=null,ge={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},n1=class e extends zo.Component{constructor(t){super(t);I(this,"canvas");I(this,"interactiveCanvas",null);I(this,"rc");I(this,"unmounted",!1);I(this,"actionManager");I(this,"device",hC);I(this,"excalidrawContainerRef",zo.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"resizeObserver");I(this,"nearestScrollableContainer");I(this,"library");I(this,"libraryItemsFromStorage");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"handleToastClose",()=>{this.setToast(null)});I(this,"elementsPendingErasure",new Set);I(this,"flowChartCreator",new HG);I(this,"flowChartNavigator",new GG);I(this,"hitLinkElement");I(this,"lastPointerDownEvent",null);I(this,"lastPointerUpEvent",null);I(this,"lastPointerMoveEvent",null);I(this,"lastPointerMoveCoords",null);I(this,"lastViewportPosition",{x:0,y:0});I(this,"animationFrameHandler",new Md);I(this,"laserTrails",new Fd(this.animationFrameHandler,this));I(this,"eraserTrail",new Gd(this.animationFrameHandler,this));I(this,"lassoTrail",new Hd(this.animationFrameHandler,this));I(this,"onChangeEmitter",new kn);I(this,"onPointerDownEmitter",new kn);I(this,"onPointerUpEmitter",new kn);I(this,"onUserFollowEmitter",new kn);I(this,"onScrollChangeEmitter",new kn);I(this,"missingPointerEventCleanupEmitter",new kn);I(this,"onRemoveEventListenersEmitter",new kn);I(this,"defaultSelectionTool","selection");I(this,"updateEditorAtom",(t,...r)=>{let n=Ve.set(t,...r);return this.triggerRender(),n});I(this,"getEffectiveGridSize",()=>Nr(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),Yl.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(lr(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=Yf(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else da(n)&&t.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(this,"frameNameBoundsCache",{get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(t));if(n){let i=n.getBoundingClientRect(),a=We({clientX:i.x,clientY:i.y},this.state),l=We({clientX:i.right,clientY:i.bottom},this.state);return r={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===Sm.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&Rt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return r.map(i=>{if(!G5(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:a,y:l}=Mm({sceneX:i.x,sceneY:i.y},this.state),s=6,m,c=RG(i);if(i.id===this.state.editingFrame){let d=c;m=fe("input",{autoFocus:!0,value:d,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:this.state.viewBackgroundColor,filter:t?FH:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Zr.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:d.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else m=c;return fe("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Zr.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Zr.nameFontSize,color:t?Zr.nameColorDarkTheme:Zr.nameColorLightTheme,lineHeight:Zr.nameLineHeight,width:"max-content",maxWidth:n?.id===i.id&&n?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Be.MOVE,pointerEvents:this.state.viewModeEnabled?la.disabled:la.enabled},onPointerDown:d=>this.handleCanvasPointerDown(d),onWheel:d=>this.handleWheel(d),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:m},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,r,n)=>{ae("export",t,"ui");let i=await pn(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(QH).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&ds(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:r}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,r),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:bt.magicframe}),ae("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&Uf(t[0])&&t[0];if(!r&&t.some(i=>Rt(i)||i.frameId)){this.setActiveTool({type:bt.magicframe});return}ae("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=ca(t),m=50;n=D5({...Zr,x:i-m,y:a-m,width:l-i+m*2,height:s-a+m*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let c of t)this.scene.mutateElement(c,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});I(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(Er,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=t==="background"&&n.altKey||t==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:Ct.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:Ct.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?jr(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:Ct.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Ae(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||Sm.LIGHT,s=t?.appState?.name??this.state.name,m=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(c=>{n?.id===c.id&&n!==c&&nC(c)&&vo(c)&&(n=c)}),n?.isDeleted&&(n=null),this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:m}}),r=!0}r||this.scene.triggerUpdate()}));I(this,"onBlur",Ae(()=>{Pn=!1,this.setState({isBindingEnabled:!0})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",Ae(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...mr(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async i=>{if(!i.files.length)return;let a=i.files[0],l=await a.getFile();this.loadFileToCanvas(new File([l],l.name||"",{type:l.type}),a)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(i=>{console.error(i)})}catch(i){console.error(i),t={appState:{errorMessage:i.message||"Encountered an error during importing or restoring scene data"}}}let r=Bn(t,null,null,{repairBindings:!0,deleteInvisibleElements:!0}),n=r.appState.activeTool;r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:n.type==="image"||n.type==="lasso"||n.type==="selection"?{...n,type:this.defaultSelectionTool}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...en(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,captureUpdate:Ct.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(i=>{this.fonts.onLoaded(i)}),qf(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileOrTablet",()=>{let t="ontouchstart"in window||navigator.maxTouchPoints>0,r="matchMedia"in window&&window?.matchMedia("(pointer: coarse)")?.matches;return iG||t&&r});I(this,"isMobileBreakpoint",(t,r)=>t<_H||r<PH&&t<AH);I(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=Rf(i,{isLandscape:r>n,isMobile:this.isMobileBreakpoint(r,n)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});I(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:n}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:DH,a=this.device.editor,l=Rf(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",Ae(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Yl.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),v5||this.refreshEditorBreakpoints(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:n})=>{r&&(Zl=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",C5(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},RH));I(this,"onCut",Ae(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||zl(t.target)||(this.actionManager.executeAction(Hc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Ae(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||zl(t.target)||(this.actionManager.executeAction(yi,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(GH&&t.preventDefault(),!Vl){Vl=!0,t.touches.length===1&&(Xl={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Qf),Qf=window.setTimeout(e.resetTapTwice,NH);return}if(Vl&&t.touches.length===1&&Xl){let r=t.touches[0];Kr(le(r.clientX,r.clientY),le(Xl.x,Xl.y))<=aG&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY})),Vl=!1,clearTimeout(Qf)}t.touches.length===2&&this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ve(this.state.previousSelectedElementIds,this.state)}):ge.pointers.clear()});I(this,"pasteFromClipboard",Ae(async t=>{let r=!!o1,n=document.activeElement,i=this.excalidrawContainerRef.current?.contains(n);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||zl(n)))return;let l=await $a(t),s=l.getFiles(),m=await bE(l,r);if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(c){console.error(c)}await this.insertClipboardContent(m,s,r),this.setActiveTool({type:this.defaultSelectionTool},!0),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let r=Xm(t.elements,null,{deleteInvisibleElements:!0}),[n,i,a,l]=ca(r),s=sa(n,a)/2,m=sa(i,l)/2,c=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=We({clientX:c,clientY:d},this.state),f=p-s,b=u-m,[x,w]=st(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=B5({type:"everything",elements:r.map(M=>jr(M,{x:M.x+x-n,y:M.y+w-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...E];v=this.props.onDuplicate?.(v,y)||v,Q5(v,Lm(E));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let M=BG(E,S);Zf(v,M,S,this.state)}this.scene.replaceAllElements(v),E.forEach(M=>{if(vo(M)&&Gf(M)){let R=X5(M,this.scene.getElementsMapIncludingDeleted());MG(M,R,this.scene)}}),YH&&dr.loadElementsFonts(E).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let P=oU(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&Ve.get(kl)?this.state.openSidebar:null,...no({editingGroupId:null,selectedElementIds:P.reduce((M,R)=>(Gf(R)||(M[R.id]=!0),M),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.defaultSelectionTool},!0),t.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,r)=>{this.setState(t,r)});I(this,"removePointer",t=>{qr&&this.resetContextMenuTimer(),ge.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||ae("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...ar(this.state,r.activeTool.locked?{type:this.defaultSelectionTool}:r.activeTool),locked:!r.activeTool.locked}}))});I(this,"updateFrameRendering",t=>{this.setState(r=>{let n=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:n?.enabled??r.frameRendering.enabled,clip:n?.clip??r.frameRendering.clip,name:n?.name??r.frameRendering.name,outline:n?.outline??r.frameRendering.outline}}})});I(this,"togglePenMode",t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))});I(this,"onHandToolToggle",()=>{this.actionManager.executeAction(Vx)});I(this,"zoomCanvas",t=>{this.setState({...Zo({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:Io(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(qf(t)?s=YG(t):s=t,s){let m=this.scene.getElementsFromId(s);m?.length?this.scrollToContent(m,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):qf(t)&&this.setState({toast:{message:h("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=di({canvasOffsets:r.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor,minZoom:r?.minZoom,maxZoom:r?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=en(n,this.state);a=s.scrollX,l=s.scrollY}if(r?.animate){let s=this.state.scrollX,m=this.state.scrollY,c=this.state.zoom.value,d=JH({fromValues:{scrollX:s,scrollY:m,zoom:c},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,eG(f))},onStep:({scrollX:p,scrollY:u,zoom:f})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});I(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});I(this,"translateCanvas",(t,r)=>{if(this.props.showPanActions===!1){if(typeof t=="function"){let n=i=>{let a=t(i);return a.scrollX!==i.scrollX||a.scrollY!==i.scrollY?i:a};this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(n,r);return}else if(t.scrollX!==void 0||t.scrollY!==void 0)return}this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t,r)});I(this,"setToast",t=>{this.setState({toast:t})});I(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let n=await r.blob(),i=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,TH,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Ae(t=>{let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));I(this,"addMissingFiles",(t,r=!1)=>{let n=r?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!n[l.id]&&(i[l.id]=l,n[l.id]=l,l.mimeType===ir.svg))try{let s=V1(V5(X1(l.dataURL)),ir.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});I(this,"updateScene",Ae(t=>{let{elements:r,appState:n,collaborators:i,captureUpdate:a}=t;if(a){let l=r||void 0,s=n?lG({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}n&&this.setState(n),r&&this.scene.replaceAllElements(r),i&&this.setState({collaborators:i})}));I(this,"_currentUpdateSource","default");I(this,"updateSceneSilently",Ae(t=>{this._currentUpdateSource="updateSceneSilently";try{this.updateScene(t)}finally{this._currentUpdateSource="default"}}));I(this,"applyDeltas",(t,r)=>{let n=aC.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return aC.applyTo(n,a,i,r)});I(this,"mutateElement",(t,r,n=!0)=>this.scene.mutateElement(t,r,{informMutation:n,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:i=n?t:null;let a=i?{name:i}:null;return a&&r&&(a.tab=r),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",Ae(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));I(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,r=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Uo().rtl?{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width),0)+i,bottom:i,left:Math.max(r?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width)+i,0),bottom:i,left:Math.max(n?.right??0,0)+i}});I(this,"zoomToFit",()=>{console.log("\u{1F50D} \u8C03\u7528 zoomToFit \u65B9\u6CD5");let t=di({targetElements:this.scene.getNonDeletedElements(),appState:{...this.state,userToFollow:null},fitToViewport:!1,canvasOffsets:{}});t?(console.log("\u2705 zoomToFit \u6210\u529F\u6267\u884C\uFF0C\u66F4\u65B0\u573A\u666F"),this.updateScene(t)):console.log("\u26A0\uFE0F zoomToFit \u6CA1\u6709\u8FD4\u56DE\u7ED3\u679C\uFF0C\u53EF\u80FD\u6CA1\u6709\u5143\u7D20\u9700\u8981\u7F29\u653E")});I(this,"onKeyDown",Ae(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!S5(t.target)){if((t.key===V.ESCAPE||t.key===V.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=J(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&Mn(a[0])&&t.key===V.ENTER){this.startImageCropping(a[0]);return}if(t.key===V.ESCAPE)this.updateEditorAtom(bo,null);else if(t.key===V.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(nG.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=Mi(a);Ve.get(bo)?.type==="panel"&&lh(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(bo,{type:"panel"})}if(t.key===V.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Im(t.key);if(t[V.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=J(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&yG(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,j5(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!Wf(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let s=J(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let m=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),j5(t.key));if(m){this.setState(d=>({selectedElementIds:ve({[m]:!0},d)}));let c=this.scene.getNonDeletedElementsMap().get(m);c&&!Wf([c],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(c,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[V.CTRL_OR_CMD]&&t.key===V.P&&!t.shiftKey&&!t.altKey){this.setToast({message:h("commandPalette.shortcutHint",{shortcut:He("commandPalette")})}),t.preventDefault();return}if(t[V.CTRL_OR_CMD]&&t.key.toLowerCase()===V.V&&(o1=t.shiftKey,clearTimeout(sC),sC=window.setTimeout(()=>{o1=!1},100)),t[V.CTRL_OR_CMD]&&zl(t.target)&&(t.code===b5.MINUS||t.code===b5.EQUAL)){t.preventDefault();return}if(zl(t.target)&&t.key!==V.ESCAPE||Im(t.key)&&S5(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(t.key===V.PAGE_UP||t.key===V.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===V.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[V.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Im(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(je),s=new Set;a.filter(je).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),f=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||f}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let m=this.getEffectiveGridSize()&&(t.shiftKey?y5:this.getEffectiveGridSize())||(t.shiftKey?SH:y5),c=0,d=0;t.key===V.ARROW_LEFT?c=-m:t.key===V.ARROW_RIGHT?c=m:t.key===V.ARROW_UP?d=-m:t.key===V.ARROW_DOWN&&(d=m),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+c,y:p.y+d},{informMutation:!1,isDragging:!1}),Ff(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:Of(a.filter(p=>p.id!==l?.id||m!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===V.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[V.CTRL_OR_CMD]||Jf(l))ro(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),je(l)||this.actionManager.executeAction(Wi));else if(vo(l)||kG(l)){let s;vo(l)||(s=l);let m=Xf(l,this.state,this.scene.getNonDeletedElementsMap()),c=m.x,d=m.y;this.startTextEditing({sceneX:c,sceneY:d,container:s}),t.preventDefault();return}else Rt(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=Rw(t.key,this);a?(this.state.activeTool.type!==a&&ae("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===$r.sharp?$r.round:l.currentItemArrowType===$r.round?$r.elbow:$r.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===V.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===V.SPACE&&ge.pointers.size===0&&this.props.showPanActions!==!1&&(Pn=!0,ye(this.interactiveCanvas,Be.GRAB),t.preventDefault()),(t.key===V.G||t.key===V.S)&&!t.altKey&&!t[V.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===V.G&&(cr(this.state.activeTool.type)||a.some(l=>cr(l.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 a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>vo(l)||Vf(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===V.K&&!t.altKey&&!t[V.CTRL_OR_CMD]){this.state.activeTool.type==="laser"||this.state.activeTool.type==="laserTrail"?this.setActiveTool({type:this.defaultSelectionTool}):this.setActiveTool({type:"laser"});return}t[V.CTRL_OR_CMD]&&(t.key===V.BACKSPACE||t.key===V.DELETE)&&this.updateEditorAtom(xn,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===V.S&&t.shiftKey,i=t.key===V.I||r===V.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));I(this,"onKeyUp",Ae(t=>{if(t.key===V.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,Be.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Zt(this.interactiveCanvas):(Ot(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Pn=!1),!t[V.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Im(t.key)&&(A5(this.scene.getSelectedElements(this.state).filter(ro),Bf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:Ct.IMMEDIATELY})),!t[V.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:ve({[r.id]:!0},n)})),Wf([r],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(r,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:Ct.IMMEDIATELY})}}));I(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);I(this,"setActiveTool",(t,r=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let n=ar(this.state,t);n.type==="hand"?ye(this.interactiveCanvas,Be.GRAB):Pn||Ot(this.interactiveCanvas,{...this.state,activeTool:n}),ZH(document.activeElement)&&this.focusContainer(),xG(n.type)||this.setState({suggestedBindings:[]}),n.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return n.type==="freedraw"&&this.store.scheduleCapture(),n.type==="lasso"?{...i,activeTool:n,...r?{}:{selectedElementIds:ve({},i),selectedGroupIds:ve({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:ve({},i),selectedGroupIds:ve({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{ye(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{Zt(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>ge.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${h("labels.untitled")}-${k5()}`);I(this,"onGestureStart",Ae(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null}),ge.initialScale=this.state.zoom.value}));I(this,"onGestureChange",Ae(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=ge.initialScale;r&&this.setState(n=>({...Zo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Io(r*t.scale)},n)}))}));I(this,"onGestureEnd",Ae(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ve(this.state.previousSelectedElementIds,this.state)}),ge.initialScale=null}));I(this,"startTextEditing",({sceneX:t,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i);i&&s&&(Vf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let m=null,c=this.scene.getSelectedElements(this.state);c.length===1?vo(c[0])?m=c[0]:i?m=Vf(c[0],this.scene.getNonDeletedElementsMap()):m=this.getTextElementAtPosition(t,r):m=this.getTextElementAtPosition(t,r);let d=m?.fontFamily||this.state.currentItemFontFamily,p=m?.lineHeight||I5(d),u=this.state.currentItemFontSize;if(!m&&l&&i&&!zf(i)){let w=ZG(_f({fontSize:u,fontFamily:d}),p),E=$G(u,p),y=Math.max(i.height,E),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:y,width:v}),t=i.x+v/2,r=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=m||R5({x:s?s.elementCenterX:t,y:s?s.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:d,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?zH.MIDDLE:E5,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?zf(i)?0:i.angle:0,frameId:f?f.id:null,customData:{textStyle:{bold:this.state.currentTextBold||!1,italic:this.state.currentTextItalic||!1,underline:this.state.currentTextUnderline||!1,strikethrough:this.state.currentTextStrikethrough||!1}}});if(!m&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!m)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||m||i?this.handleTextWysiwyg(b,{isExistingElement:!!m}):this.setState({newElement:b,multiElement:null})});I(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.defaultSelectionTool)return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=We(t,this.state);if(r.length===1&&ro(r[0])){let l=r[0];if((t[V.CTRL_OR_CMD]&&mU(l)||Jf(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(Wi);return}else if(this.state.selectedLinearElement&&je(r[0])){let s=Le.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=s?Le.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(m&&m>-1){this.store.scheduleCapture(),Le.deleteFixedSegment(r[0],this.scene,m);let c=Le.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=c?Le.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:d,value:s,added:!1}},segmentMidPointHoveredCoords:c}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&Jf(l))return}if(r.length===1&&Mn(r[0])){this.startImageCropping(r[0]);return}if(Zt(this.interactiveCanvas),eU(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&QG(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(m=>({...m,...no({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),m,this)}));return}}if(Zt(this.interactiveCanvas),!t[V.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(Ul(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(F5(s)||!qH(s.backgroundColor)||Wl({point:le(n,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let m=Xf(s,this.state,this.scene.getNonDeletedElementsMap());n=m.x,i=m.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});I(this,"getElementLinkAtPosition",(t,r)=>{if(r&&r.locked)return;let n=this.scene.getNonDeletedElements(),i=-1;for(let a=n.length-1;a>=0;a--){let l=n[a];if(r&&l.id===r.id&&(i=a),l.link&&a>=i&&as(l,this.scene.getNonDeletedElementsMap(),this.state,le(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,r)=>{let n=Kr(le(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),le(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>CH)return;let i=We(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=as(this.hitLinkElement,a,this.state,le(i.x,i.y),this.device.editor.isMobile),s=We(this.lastPointerUpEvent,this.state),m=as(this.hitLinkElement,a,this.state,le(s.x,s.y),this.device.editor.isMobile);if(l&&m){ju();let c=this.hitLinkElement.link;if(c){c=Af(c);let d;if(this.props.onLinkOpen&&(d=$H(oe.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let p=VH(c)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=c)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&K5(t,i,r));return n.length?n[n.length-1]:null});I(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,ge.pointers.has(t.pointerId)&&ge.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=ge.initialScale;if(ge.pointers.size===2&&ge.lastCenter&&r&&ge.initialDistance){let f=sg(ge.pointers),b=f.x-ge.lastCenter.x,x=f.y-ge.lastCenter.y;ge.lastCenter=f;let w=cg(Array.from(ge.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/ge.initialDistance,y=E?Io(r*E):this.state.zoom.value;this.setState(v=>{let C=Zo({viewportX:f.x,viewportY:f.y,nextZoom:y},v);this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(b/y),scrollY:C.scrollY+2*(x/y),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else ge.lastCenter=ge.initialDistance=ge.initialScale=null;if(Pn||Kl||e1||Ho(this.state))return;let i=gg(Zl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Zt(this.interactiveCanvas):Ot(this.interactiveCanvas,this.state));let a=We(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&ev(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=Q2(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let w=Hl(x.snapLines,b),E=x.originSnapOffset?Hl(x.originSnapOffset,f):f;return x.snapLines===w&&x.originSnapOffset===E?null:{snapLines:w,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let f=Le.handlePointerMove(t,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&aa(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&O5(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(O5(this.state.activeTool.type)){let{newElement:f}=this.state;Hf(f,!1)?this.setState({suggestedBindings:L5(f,[a],this.scene,this.state.zoom,this.state.startBoundElement)}):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:f}=this.state,{x:b,y:x}=f,{points:w,lastCommittedPoint:E}=f,y=w[w.length-1];if(Ot(this.interactiveCanvas,this.state),y===E)Kr(le(l-b,s-x),y)>=Pf?this.scene.mutateElement(f,{points:[...w,le(l-b,s-x)]},{informMutation:!1,isDragging:!1}):ye(this.interactiveCanvas,Be.POINTER);else if(w.length>2&&E&&Kr(le(l-b,s-x),E)<Pf)ye(this.interactiveCanvas,Be.POINTER),this.scene.mutateElement(f,{points:w.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,C]=st(l,s,t[V.CTRL_OR_CMD]||je(f)?null:this.getEffectiveGridSize()),[S,P]=f?.lastCommittedPoint??[0,0],M=v-b-S,R=C-x-P;Lf(t)&&({width:M,height:R}=H5(S+b,P+x,v,C)),W5(w,this.state.zoom.value)&&ye(this.interactiveCanvas,Be.POINTER),this.scene.mutateElement(f,{points:[...w.slice(0,-1),le(S+M,P+R)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!i&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&je(d[0]))){let f=tC(c,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){ye(this.interactiveCanvas,eC(f));return}}}else if(d.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=oC(ca(d),l,s,this.state.zoom,t.pointerType,this.device);if(f){ye(this.interactiveCanvas,eC({transformHandleType:f}));return}}let p=this.getElementAtPosition(l,s,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p,this.hitLinkElement=this.getElementLinkAtPosition(a,p),!St(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(ye(this.interactiveCanvas,Be.POINTER),hy(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(ju(),u&&(u.link||lr(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?ye(this.interactiveCanvas,vo(u)?Be.TEXT:Be.CROSSHAIR):this.state.viewModeEnabled?ye(this.interactiveCanvas,Be.GRAB):this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,Be.AUTO):i?ye(this.interactiveCanvas,Be.AUTO):t[V.CTRL_OR_CMD]?ye(this.interactiveCanvas,Be.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,d))&&!u?.locked&&(u&&Ul(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(ye(this.interactiveCanvas,Be.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!je(u)||!(u.startBinding||u.endBinding))&&((this.state.activeTool.type!=="lasso"||d.length>0)&&ye(this.interactiveCanvas,Be.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}))),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s)),this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(f=>({hoveredElementIds:Hl(f.hoveredElementIds,no({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:Hl(f.hoveredElementIds,{})})))});I(this,"handleEraser",(t,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,t.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});I(this,"handleTouchMove",t=>{$l=!0});I(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(d=>({searchMatches:d.searchMatches&&{focusedId:null,matches:d.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(Zg,null)),Ve.get(bo)&&this.updateEditorAtom(bo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let d=this.state.newElement;this.updateScene({...d.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==d.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:ve(Object.keys(this.state.selectedElementIds).filter(p=>p!==d.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Ct.EVENTUALLY:Ct.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(d=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Rf(this.device,{isTouchScreen:!0})),Kl||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Sn.ERASER&&this.state.activeTool.type!==bt.eraser){this.setState({activeTool:ar(this.state,{type:bt.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let d=()=>{p(),u?.(),St(this.state)&&this.setState({activeTool:ar(this.state,{...this.state.activeTool.lastActiveTool||{type:bt.selection},lastActiveToolBeforeEraser:null})})},p=Fe(window,oe.POINTER_UP,d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(t.button!==Sn.MAIN&&t.button!==Sn.TOUCH&&t.button!==Sn.ERASER||ge.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!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 d=i.hit.element&&this.isASelectedElement(i.hit.element),p=this.isMobileOrTablet();!i.hit.hasHitCommonBoundingBoxOfSelectedElements&&!i.resize.handleType&&!d&&(this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey),i.drag.blockDragging=!p),p&&i.hit.element&&!d&&(this.setState(u=>{let f={...u.selectedElementIds,[i.hit.element.id]:!0},b=[];Object.keys(u.selectedElementIds).forEach(w=>{let E=this.scene.getElement(w);E&&b.push(E)});let x=i.hit.element;if(Rt(x))Kf(b,x.id).forEach(w=>{delete f[w.id]});else if(x.frameId)f[x.frameId]&&delete f[x.id];else{let w=x.groupIds,E=new Set(w.flatMap(y=>Ln(this.scene.getNonDeletedElements(),y)).filter(y=>Rt(y)).map(y=>y.id));E.size>0&&b.forEach(y=>{y.frameId&&E.has(y.frameId)&&(delete f[y.id],y.groupIds.flatMap(v=>Ln(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete f[v.id]}))})}return{...no({editingGroupId:u.editingGroupId,selectedElementIds:f},this.scene.getNonDeletedElements(),u,this),showHyperlinkPopup:x.link||lr(x)?"info":!1}}),i.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Ot(this.interactiveCanvas,this.state):this.state.activeTool.type===bt.frame||this.state.activeTool.type===bt.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.state.activeTool.type!=="laserTrail"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i);this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),m=this.onKeyDownFromPointerDownHandler(i),c=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(d=>s(d||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.state.activeTool.type==="laserTrail")&&(window.addEventListener(oe.POINTER_MOVE,l),window.addEventListener(oe.POINTER_UP,s),window.addEventListener(oe.KEYDOWN,m),window.addEventListener(oe.KEYUP,c),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=c,i.eventListeners.onKeyDown=m)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=We({clientX:t.clientX,clientY:t.clientY},this.state),n=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let i=this.getElementAtPosition(r.x,r.y);if(Ul(i)&&this.isIframeLikeElementCenter(i,t,r.x,r.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(r.x,r.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&Ul(this.hitLinkElement)&&!A1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,le(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&($l=!1,qr?$l=!0:qr=window.setTimeout(()=>{qr=0,$l||this.handleCanvasContextMenu(t)},OH))});I(this,"resetContextMenuTimer",()=>{clearTimeout(qr),qr=0,$l=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{jl?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(this.props.showPanActions!==!1&&ge.pointers.size<=1&&(t.button===Sn.WHEEL||t.button===Sn.MAIN&&Pn||Ho(this.state)||this.state.viewModeEnabled)))return!1;Kl=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);ye(this.interactiveCanvas,Be.GRABBING);let{clientX:i,clientY:a}=t,l=Od(m=>{let c=i-m.clientX,d=a-m.clientY;if(i=m.clientX,a=m.clientY,n&&!r&&(Math.abs(c)>1||Math.abs(d)>1)){r=!0;let p=f=>{document.body.removeEventListener(oe.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(oe.PASTE,p),window.removeEventListener(oe.POINTER_UP,u)},100)};document.body.addEventListener(oe.PASTE,p),window.addEventListener(oe.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-c/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=Ae(jl=()=>{jl=null,Kl=!1,Pn||(this.state.viewModeEnabled?ye(this.interactiveCanvas,Be.GRAB):Ot(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(oe.POINTER_MOVE,l),window.removeEventListener(oe.POINTER_UP,s),window.removeEventListener(oe.BLUR,s),l.flush()});return window.addEventListener(oe.BLUR,s),window.addEventListener(oe.POINTER_MOVE,l,{passive:!0}),window.addEventListener(oe.POINTER_UP,s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,r)=>{if(this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!je(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=tC(n,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType))}else a.length>1&&(r.resize.handleType=oC(ca(a),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=Df(nU(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&ro(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=iU(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Le.handlePointerDown(t,this,this.store,r.origin,p,this.scene);if(u.hitElement&&(r.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0}let l=this.getElementsAtPosition(r.origin.x,r.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),m=this.getElementAtPosition(r.origin.x,r.origin.y,{allHitElements:l});if((!m||m.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),m&&m.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?r.hit.element=null:r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,m),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=s;let c=r.hit.element,d=r.hit.allHitElements.some(p=>this.isASelectedElement(p));if((c===null||!d)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(c),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:ve({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(c!=null){if(t[V.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(r.origin.x,r.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[c.id]||(r.hit.wasAddedToSelection=!0),this.setState(p=>({...JG(p,c),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[c.id]||(this.state.editingGroupId&&!J5(c,this.state.editingGroupId)&&this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!d&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[c.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),Rt(c))Kf(f,c.id).forEach(b=>{delete u[b.id]});else if(c.frameId)u[c.frameId]&&delete u[c.id];else{let b=c.groupIds,x=new Set(b.flatMap(w=>Ln(this.scene.getNonDeletedElements(),w)).filter(w=>Rt(w)).map(w=>w.id));x.size>0&&f.forEach(w=>{w.frameId&&x.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(E=>Ln(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(c.groupIds.some(b=>p.selectedGroupIds[b])||(u={[c.id]:!0})),{...no({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:c.link||lr(c)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(this,"handleTextOnPointerDown",(t,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,i=r.origin.y,a=this.getElementAtPosition(n,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(n,i);F5(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Zt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:ar(this.state,{type:this.defaultSelectionTool})})});I(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=st(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),m=t.pressure===.5||t.pressure===0||typeof t.pressure>"u"||t.pointerType==="touch"&&this.device.isTouchScreen,c=mG({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:m,locked:!1,frameId:l?l.id:null,points:[le(0,0)],pressures:m?[]:[t.pressure]});this.scene.insertElement(c),this.setState(p=>{let u={...p.selectedElementIds};return delete u[c.id],{selectedElementIds:ve(u,p)}});let d=Nf(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:c,startBoundElement:d,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=st(t,r,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=pG({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:i});return this.scene.insertElement(s),s});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[i,a]=st(t,r,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=Pm(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:h("toast.unrecognizedLinkFormat"),closable:!0});let s=_5({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:n});return this.scene.insertElement(s),s});I(this,"newImagePlaceholder",({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,a]=st(t,r,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return gG({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,x:i-s/2,y:a-s/2,width:s,height:s})});I(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&W5(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(zt);return}if(je(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(zt);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Kr(le(n.origin.x-a,n.origin.y-l),s)<Pf){this.actionManager.executeAction(zt);return}this.setState(m=>({selectedElementIds:ve({...m.selectedElementIds,[i.id]:!0},m)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),ye(this.interactiveCanvas,Be.POINTER)}else{let[i,a]=st(n.origin.x,n.origin.y,t[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:m}=this.state,[c,d]=r==="arrow"?[s,m]:[null,null],p=r==="arrow"?uG({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===$r.round?{type:Cm.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:d,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===$r.elbow,fixedSegments:this.state.currentItemArrowType===$r.elbow?[]:null}):fG({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:Cm.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:ve(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,le(0,0)]});let u=Nf(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,je(p),je(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=st(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=_5({type:"embeddable",...l}):s=hG({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});I(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,i]=st(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Zr},l=r===bt.magicframe?D5(a):dG(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||Gf(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,jr(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});I(this,"initializeImage",async(t,r)=>{if(!Km(r))throw new Error(h("errors.unsupportedFileType"));let n=r.type;if(ye(this.interactiveCanvas,"wait"),n===ir.svg)try{r=qm(V5(await r.text()),r.name)}catch(s){throw console.warn(s),new Error(h("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(r)||Y1(r));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(h("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{r=await ps(r,{maxWidthOrHeight:IH})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(r.size>w5)throw new Error(h("errors.fileTooBig",{maxSize:`${Math.trunc(w5/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await jm(r);return new Promise(async(s,m)=>{try{let c=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:n,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([c]);if(p.size)throw new Error("Image cache update resulted with an error.")}let d=await this.imageCache.get(i)?.image;if(d&&this.state.newElement?.id!==c.id){c=this.getLatestInitializedImageElement(t,i);let p=this.getImageNaturalDimensions(c,d);Object.assign(c,p)}s(c)}catch(c){console.error(c),m(new Error(h("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,r)=>{let n=this.scene.getElement(t.id)??t;return jr(n,{fileId:r})});I(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,r=this.state.height/2+this.state.offsetTop,{x:n,y:i}=We({clientX:t,clientY:r},this.state),a=await ns({description:"Image",extensions:Object.keys(kH),multiple:!0});this.insertImages(a,n,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:ar(this.state,{type:this.defaultSelectionTool})},()=>{this.actionManager.executeAction(zt)})}});I(this,"getImageNaturalDimensions",(t,r)=>{let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(r.naturalHeight,i),l=a*(r.naturalWidth/r.naturalHeight),s=t.x+t.width/2-l/2,m=t.y+t.height/2-a/2;return{x:s,y:m,width:l,height:a,crop:null}});I(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await SG({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:r});return i.size&&(this.store.scheduleAction(Ct.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Gl(a)&&i.has(a.fileId)?jr(a,{status:"error"}):a))),{updatedFiles:n,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=CG(this.scene.getNonDeletedElements()),r=this.files)=>{let n=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);if(i.size)for(let a of n)i.has(a.fileId)&&Yl.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",xH(()=>{this.addNewImagesToImageCache()},MH));I(this,"updateBindingEnabledOnPointerMove",t=>{let r=cG(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});I(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=Nf(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(oe.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(oe.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(oe.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(oe.TOUCH_END,this.onTouchEnd))});I(this,"insertImages",async(t,r,n)=>{let i=50/this.state.zoom.value,a=lC(t.map(()=>this.newImagePlaceholder({sceneX:r,sceneY:n})),r,n,i);a.forEach(p=>this.scene.insertElement(p));let l=await Promise.all(a.map(async(p,u)=>{try{return await this.initializeImage(p,t[u])}catch(f){return this.setState({errorMessage:f.message||h("errors.imageInsertError")}),jr(p,{isDeleted:!0})}})),s=Lm(l),m=lC(l.filter(p=>!p.isDeleted),r,n,i),c=Lm(m),d=this.scene.getElementsIncludingDeleted().map(p=>c.get(p.id)??s.get(p.id)??p);this.updateScene({appState:{selectedElementIds:ve(Object.fromEntries(m.map(p=>[p.id,!0])),this.state)},elements:d,captureUpdate:Ct.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(zt)})});I(this,"handleAppOnDrop",async t=>{let{x:r,y:n}=We(t,this.state),i=await $a(t),a=i.getFiles();if(a.length===1){let{file:c,fileHandle:d}=a[0];if(c&&(c.type===ir.png||c.type===ir.svg))try{let p=await ms(c,this.state,this.scene.getElementsIncludingDeleted(),d);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Ct.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(h("alerts.couldNotLoadInvalidFile"))}}let l=a.map(c=>c.file).filter(c=>Km(c));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,r,n);let s=i.getData(ir.excalidrawlib);if(s&&typeof s=="string"){try{let c=W1(s);this.addElementsFromPasteOrLibrary({elements:rd(c),position:t,files:null})}catch(c){this.setState({errorMessage:c.message})}return}if(a.length>0){let{file:c,fileHandle:d}=a[0];c&&await this.loadFileToCanvas(c,d)}let m=i.findByType(ir.text);if(m){let c=m.value;if(c&&Yf(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||Pm(c)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:r,sceneY:n,link:Af(c)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,r)=>{t=await us(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await Zm(t,this.state,n,r)}catch(a){let l=a instanceof M1;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:h("errors.imageToolNotSupported")});return}let s=l?h("alerts.cannotRestoreFromImage"):h("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===ir.excalidraw?(mC(n.concat(i.data.elements)),this.store.scheduleMicroAction({action:Ct.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Ct.IMMEDIATELY})):i.type===ir.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:h("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Sn.SECONDARY)&&this.state.activeTool.type!==this.defaultSelectionTool)return;let{x:r,y:n}=We(t,this.state),i=this.getElementAtPosition(r,n,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:n},a),s=i||l?"element":"canvas",m=this.excalidrawContainerRef.current,{top:c,left:d}=m.getBoundingClientRect(),p=t.clientX-d,u=t.clientY-c;ae("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...no({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ro(i)?new Le(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){rC({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:sa(t.origin.x,a.x),height:sa(t.origin.y,a.y),shouldMaintainAspectRatio:Ol(r),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,m]=st(a.x,a.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=Gl(l)&&this.imageCache.get(l.fileId)?.image,d=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(r,[l]);let{snapOffset:p,snapLines:u}=J2(l,this,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:m-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,m+=p.y,this.setState({snapLines:u}),rC({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:m,width:sa(t.originInGrid.x,s),height:sa(t.originInGrid.y,m),shouldMaintainAspectRatio:Mn(l)?!Ol(r):Ol(r),shouldResizeFromCenter:x5(r),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:d,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===bt.frame||this.state.activeTool.type===bt.magicframe)&&this.setState({elementsToHighlight:$f(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,i=t.lastCoords,[a,l]=st(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&Mn(s)){let m=t.originalElements.get(s.id),c=Gl(s)&&this.imageCache.get(s.fileId)?.image;if(m&&Mn(m)&&c&&!(c instanceof Promise)){let[d,p]=st(i.x,i.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:f,snapLines:b}=ug([s],[m],this,r,u,n);this.scene.mutateElement(s,UG(s,this.scene.getNonDeletedElementsMap(),n,c.naturalWidth,c.naturalHeight,a+f.x,l+f.y,r.shiftKey?m.width/m.height:void 0)),Ff(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:b})}return!0}return!1});I(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(d=>Rt(d)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&je(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,m]=st(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(i.forEach(d=>{Kf(this.scene.getNonDeletedElements(),d.id).forEach(u=>{c.set(d.id+u.id,{x:u.x-d.x,y:u.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,p]=st(l.x,l.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=ug(n,J(f,this.state),this,r,u,a);s+=b.x,m+=b.y,this.setState({snapLines:x})}if(aU(t.originalElements,a,n,this.scene,Lf(r),x5(r),n.some(d=>Mn(d))?!Ol(r):Ol(r),s,m,t.resize.center.x,t.resize.center.y)){let d=Of(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{$f(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:d}),!0}return!1});I(this,"getContextMenuItems",t=>{let r=[];return r.push(Uc,Gc),t==="canvas"?this.state.viewModeEnabled?[...r,Yc,wi,ag,vi]:[Bu,Ze,Uc,Gc,Wc,Ze,Mp,yy,Ze,Yc,Fu,wi,ag,vi]:(r.push(Wc),this.state.viewModeEnabled?[yi,...r]:[Ze,Hc,yi,Bu,Ze,P2,A2,_2,Ze,og,Ze,...r,Ze,Cu,Su,Ze,Lu,z2,Hu,Gu,iy,Pu,Ze,Du,Ze,Ip,Cp,Sp,kp,Ze,Ru,Nu,Ze,Wi,Ze,el,Jc,Ze,Lp,tl,Ze,La])});I(this,"handleWheel",Ae(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[V.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Kl)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(n),a=HH*100,l=Math.abs(n),s=n;l>a&&(s=a*i);let m=this.state.zoom.value-s/100;m+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(c=>({...Zo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Io(m)},c),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey&&this.props.showPanActions!==!1){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(n||r)/i.value}));return}this.props.showPanActions!==!1&&this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-r/i.value,scrollY:l-n/i.value}))}));I(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:i,y:a}=We({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"||this.state.activeTool.type==="laserTrail"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:ge.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",C5(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:i,left:a,top:l}=r.getBoundingClientRect(),{width:s,height:m,offsetTop:c,offsetLeft:d}=this.state;if(n===s&&i===m&&a===d&&l===c){t&&t();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=mr();this.defaultSelectionTool=this.isMobileOrTablet()?"lasso":"selection";let{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:m=r.theme,name:c=`${h("labels.untitled")}-${k5()}`}=t;if(this.state={...r,theme:m,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight},this.id=yH(),this.library=new Xy(this),this.actionManager=new kd(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new iC,this.canvas=document.createElement("canvas"),this.rc=EH.canvas(this.canvas),this.renderer=new vl(this.scene),this.visibleElements=[],this.store=new cU(this),this.history=new fl(this.store),n){let d=b=>{this.setState(b)},p=(b="line")=>{if(b==="line"){this.setActiveTool({type:bt.line});return}if(this.setActiveTool({type:bt.arrow}),b==="arrow"){d({currentItemStartArrowhead:null,currentItemEndArrowhead:"arrow"});return}if(b==="doubleArrow"){d({currentItemStartArrowhead:"arrow",currentItemEndArrowhead:"arrow"});return}if(b==="outlineArrow"){d({currentItemStartArrowhead:null,currentItemEndArrowhead:"triangle_outline"});return}d({currentItemStartArrowhead:"triangle_outline",currentItemEndArrowhead:"triangle_outline"})},u={selectSelection:()=>{this.setActiveTool({type:bt.selection})},selectFreedraw:b=>{if(this.setActiveTool({type:bt.freedraw}),!b)return;let x={},w=b.variant??"pen";x.currentItemOpacity=w==="highlighter"?50:100,typeof b.strokeWidth=="number"&&(x.currentItemStrokeWidth=b.strokeWidth),typeof b.strokeColor=="string"&&(x.currentItemStrokeColor=b.strokeColor),d(x)},selectLine:b=>{let x=b?.variant??"line";if(p(x),!b)return;let w={};typeof b.strokeWidth=="number"&&(w.currentItemStrokeWidth=b.strokeWidth),typeof b.strokeColor=="string"&&(w.currentItemStrokeColor=b.strokeColor),d(w)},selectShape:(b,x)=>{let w=b??"rectangle";if(this.setActiveTool({type:w}),!x)return;let E={};typeof x.strokeWidth=="number"&&(E.currentItemStrokeWidth=x.strokeWidth),typeof x.strokeColor=="string"&&(E.currentItemStrokeColor=x.strokeColor),typeof x.backgroundColor=="string"&&(E.currentItemBackgroundColor=x.backgroundColor),x.fillStyle&&(E.currentItemFillStyle=x.fillStyle),d(E)},selectText:b=>{if(this.setActiveTool({type:bt.text}),!b)return;let x={};typeof b.fontSize=="number"&&(x.currentItemFontSize=b.fontSize),b.textAlign&&(x.currentItemTextAlign=b.textAlign),typeof b.strokeColor=="string"&&(x.currentItemStrokeColor=b.strokeColor),typeof b.bold=="boolean"&&(x.currentTextBold=b.bold),typeof b.italic=="boolean"&&(x.currentTextItalic=b.italic),typeof b.underline=="boolean"&&(x.currentTextUnderline=b.underline),typeof b.strikethrough=="boolean"&&(x.currentTextStrikethrough=b.strikethrough),d(x)},selectEraser:()=>{this.setActiveTool({type:bt.eraser})},updateStyle:b=>{d(b)},dispatch:b=>{switch(b.type){case"selectSelection":u.selectSelection();return;case"selectFreedraw":u.selectFreedraw(b.payload);return;case"selectLine":u.selectLine(b.payload);return;case"selectShape":u.selectShape(b.payload?.shape,b.payload&&{strokeWidth:b.payload.strokeWidth,strokeColor:b.payload.strokeColor,backgroundColor:b.payload.backgroundColor,fillStyle:b.payload.fillStyle});return;case"selectText":u.selectText(b.payload);return;case"selectEraser":u.selectEraser();return;case"updateStyle":u.updateStyle(b.payload);return;default:return}}},f={updateScene:this.updateScene,updateSceneSilently:this.updateSceneSilently,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,zoomToFit:this.zoomToFit,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:b=>{this.actionManager.registerAction(b)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,leftToolbar:u,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:b=>this.onChangeEmitter.on(b),onIncrement:b=>this.store.onStoreIncrementEmitter.on(b),onPointerDown:b=>this.onPointerDownEmitter.on(b),onPointerUp:b=>this.onPointerUpEmitter.on(b),onScrollChange:b=>this.onScrollChangeEmitter.on(b),onUserFollow:b=>this.onUserFollowEmitter.on(b)};typeof n=="function"?n(f):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new dr(this.scene),this.history=new fl(this.store),this.actionManager.registerAll(Ys),this.actionManager.registerAction(N2(this.history)),this.actionManager.registerAction(B2(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(n=a.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values(km).includes(i)&&t1.set(n,i)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),da(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=t1.get(t.id);switch(n||(t1.set(t.id,km.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case km.PLAYING:case km.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,n,i){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=t.x+t.width/3&&n<=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,r=this.state.width,n=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>lr(a)&&this.embedsValidationStatus.get(a.id)===!0||da(a));return fe(uU,{children:i.map(a=>{let{x:l,y:s}=Mm({sceneX:a.x,sceneY:a.y},this.state),m=G5(a,r,n,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(a.id);if(m&&!c&&this.initializedEmbeds.add(a.id),!(m||c))return null;let p;if(da(a)){p=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let x=b.html;p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(b.status==="pending")p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>Y5(`
31
+ C -->|Three| F[Car]`,LT=iF(Al,300),sF=({mermaidToExcalidrawLib:e})=>{let[o,t]=ST(()=>jt.get(nF.MERMAID_TO_EXCALIDRAW)||lF),r=rF(o.trim()),[n,i]=ST(null),a=kT(null),l=kT({elements:[],files:null}),s=Oe();MT(()=>{am({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:r}).catch(c=>{aF()&&console.error("Failed to parse mermaid definition",c)}),LT(r)},[r,e]),MT(()=>()=>{LT.flush()},[]);let m=()=>{lm({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return PT(cF,{children:[zo("div",{className:"ttd-dialog-desc",children:zo(yt,{i18nKey:"mermaid.description",flowchartLink:c=>zo("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:c}),sequenceLink:c=>zo("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:c}),classLink:c=>zo("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:c})})}),PT(nm,{children:[zo(Ji,{label:h("mermaid.syntax"),children:zo(tm,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:c=>t(c.target.value),onKeyboardSubmit:()=>{m()}})}),zo(Ji,{label:h("mermaid.preview"),panelAction:{action:()=>{m()},label:h("mermaid.button"),icon:Xn},renderSubmitShortcut:()=>zo(im,{}),children:zo(rm,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},AT=sF;import*as DT from"@radix-ui/react-tabs";import{useRef as _T}from"react";import{isMemberOf as dF}from"@haoxin-web/excalidraw-common";import{jsx as mF}from"react/jsx-runtime";var RT=e=>{let o=me(),t=_T(null),r=_T(0);return mF(DT.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>r.current&&(r.current=a,i.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="ttd"&&dF(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};RT.displayName="TTDDialogTabs";var NT=RT;import*as BT from"@radix-ui/react-tabs";import{jsx as pF}from"react/jsx-runtime";var Jg=({children:e,...o})=>pF(BT.List,{className:"ttd-dialog-triggers",...o,children:e});Jg.displayName="TTDDialogTabTriggers";import*as OT from"@radix-ui/react-tabs";import{jsx as FT}from"react/jsx-runtime";var sm=({children:e,tab:o,onSelect:t,...r})=>FT(OT.Trigger,{value:o,asChild:!0,onSelect:t,children:FT("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});sm.displayName="TTDDialogTabTrigger";import*as zT from"@radix-ui/react-tabs";import{jsx as uF}from"react/jsx-runtime";var cm=({tab:e,children:o,...t})=>uF(zT.Content,{...t,value:e,children:o});cm.displayName="TTDDialogTab";import{jsx as It,jsxs as Ur}from"react/jsx-runtime";var ef=3,Qi=1e3,gF=he(null),fF=he(null),tf=e=>{let o=xe();return o.openDialog?.name!=="ttd"?null:It(bF,{...e,tab:o.openDialog.tab})},bF=nr("TTDDialogBase",({tab:e,...o})=>{let t=Oe(),r=me(),n=Qg(null),[i,a]=ce(fF),[l,s]=dm(i?.prompt??""),m=l.trim(),c=S=>{s(S.target.value),a(P=>({generatedResponse:P?.generatedResponse??null,prompt:S.target.value}))},[d,p]=dm(!1),[u,f]=ce(gF),b=async()=>{if(m.length>Qi||m.length<ef||d||u?.rateLimitRemaining===0||"__fallback"in o){m.length<ef&&C(new Error(`Prompt is too short (min ${ef} characters)`)),m.length>Qi&&C(new Error(`Prompt is too long (max ${Qi} characters)`));return}try{p(!0),ae("ai","generate","ttd");let{generatedResponse:S,error:P,rateLimit:M,rateLimitRemaining:R}=await o.onTextSubmit(m);if(typeof S=="string"&&a(L=>({generatedResponse:S,prompt:L?.prompt??null})),HT(M)&&HT(R)&&f({rateLimit:M,rateLimitRemaining:R}),P){C(P);return}if(!S){C(new Error("Generation failed"));return}try{await am({canvasRef:n,data:y,mermaidToExcalidrawLib:w,setError:C,mermaidDefinition:S}),ae("ai","mermaid parse success","ttd")}catch(L){console.info(`%cTTD mermaid render errror: ${L.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
32
+ TTD mermaid definition render errror: ${L.message}`,"color: yellow"),ae("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let P=S.message;(!P||P==="Failed to fetch")&&(P="Request failed"),C(new Error(P))}finally{p(!1)}},x=Qg(b);x.current=b;let[w,E]=dm({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});hF(()=>{(async()=>{await w.api,E(P=>({...P,loaded:!0}))})()},[w.api]);let y=Qg({elements:[],files:null}),[v,C]=dm(null);return It(Ge,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Ur(NT,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?It("p",{className:"dialog-mermaid-title",children:h("mermaid.title")}):Ur(Jg,{children:[It(sm,{tab:"text-to-diagram",children:Ur("div",{style:{display:"flex",alignItems:"center"},children:[h("labels.textToDiagram"),It("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"1px 6px",marginLeft:"10px",fontSize:10,borderRadius:"12px",background:"var(--color-promo)",color:"var(--color-surface-lowest)"},children:"AI Beta"})]})}),It(sm,{tab:"mermaid",children:"Mermaid"})]}),It(cm,{className:"ttd-dialog-content",tab:"mermaid",children:It(AT,{mermaidToExcalidrawLib:w})}),!("__fallback"in o)&&Ur(cm,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[It("div",{className:"ttd-dialog-desc",children:"Currently we use Mermaid as a middle step, so you'll get best results if you describe a diagram, workflow, flow chart, and similar."}),Ur(nm,{children:[It(Ji,{label:h("labels.prompt"),panelAction:{action:b,label:"Generate",icon:Xn},onTextSubmitInProgess:d,panelActionDisabled:m.length>Qi||u?.rateLimitRemaining===0,renderTopRight:()=>u?Ur("div",{className:"ttd-dialog-rate-limit",style:{fontSize:12,marginLeft:"auto",color:u.rateLimitRemaining===0?"var(--color-danger)":void 0},children:[u.rateLimitRemaining," requests left today"]}):null,renderSubmitShortcut:()=>It(im,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Ur("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(Al(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",It(Ir,{icon:Xn})]});let S=m.length/Qi;return S>.8?Ur("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",m.length,"/",Qi]}):null},children:It(tm,{onChange:c,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),It(Ji,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),lm({app:t,data:y})},label:"Insert",icon:Xn},children:It(rm,{canvasRef:n,error:v,loaded:w.loaded})})]})]})]})})});import{round as CI}from"@haoxin-web/excalidraw-math";import PO from"clsx";import AO from"lodash.throttle";import{useEffect as SI,useMemo as ff,useState as _O,memo as DO}from"react";import{STATS_PANELS as xm}from"@haoxin-web/excalidraw-common";import{getCommonBounds as RO}from"@haoxin-web/excalidraw-element";import{getUncroppedWidthAndHeight as NO}from"@haoxin-web/excalidraw-element";import{isElbowArrow as BO,isImageElement as bf}from"@haoxin-web/excalidraw-element";import{frameAndChildrenSelectedTogether as FO}from"@haoxin-web/excalidraw-element";import{elementsAreInSameGroup as OO}from"@haoxin-web/excalidraw-element";import{degreesToRadians as XT,radiansToDegrees as jT}from"@haoxin-web/excalidraw-math";import{getBoundTextElement as KT}from"@haoxin-web/excalidraw-element";import{isArrowElement as ZT,isElbowArrow as LF}from"@haoxin-web/excalidraw-element";import{updateBindings as $T}from"@haoxin-web/excalidraw-element";import TF from"clsx";import{useEffect as YT,useRef as pm,useState as IF}from"react";import{EVENT as oa,KEYS as CF,cloneJSON as of}from"@haoxin-web/excalidraw-common";import{deepCopyElement as SF}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as VT}from"@haoxin-web/excalidraw-element";import{pointFrom as Wr,pointRotateRads as mm}from"@haoxin-web/excalidraw-math";import{getBoundTextElement as xF}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as UT}from"@haoxin-web/excalidraw-element";import{getSelectedGroupIds as EF,getElementsInGroup as yF,isInGroup as wF}from"@haoxin-web/excalidraw-element";import{getFrameChildren as vF}from"@haoxin-web/excalidraw-element";import{updateBindings as GT}from"@haoxin-web/excalidraw-element";var WT=.01,_l=10,_t=(e,o)=>!(o==="angle"&&UT(e)),_e=(e,o)=>{let t=e+o/2;return t-t%o},ea=(e,o,t)=>Object.keys(e).map(r=>({original:(t??o).get(r),latest:o.get(r)})).filter(r=>r.original!==void 0&&r.latest!==void 0);var Cn=(e,o,t,r,n,i=!0)=>{let a=r.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,m]=[t.x+t.width/2,t.y+t.height/2],[c,d]=mm(Wr(t.x,t.y),Wr(s,m),t.angle),p=e-c,u=o-d,[f,b]=mm(Wr(e,o),Wr(s+p,m+u),-t.angle);r.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),GT(l,r);let x=xF(t,n);if(x){let w=a.get(x.id);w&&r.mutateElement(w,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(UT(t)){let w=vF(n,t.id);w.forEach(E=>{let y=a.get(E.id);if(!y)return;let[v,C]=[E.x+E.width/2,E.y+E.height/2],[S,P]=mm(Wr(E.x,E.y),Wr(v,C),E.angle),M=Math.round(S+p),R=Math.round(P+u),[L,k]=mm(Wr(M,R),Wr(v+p,C+u),-E.angle);r.mutateElement(y,{x:L,y:k},{informMutation:i,isDragging:!1}),GT(y,r,{simultaneouslyUpdated:w})})}},ta=(e,o)=>{let r=EF(o).map(n=>yF(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!wF(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as rf,jsxs as MF}from"react/jsx-runtime";var kF=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:m,sensitivity:c=1,dragFinishedCallback:d})=>{let p=Oe(),u=me(),f=pm(null),b=pm(null),[x,w]=IF(r.toString()),E=pm(null);E.current||(E.current={originalAppState:of(m),originalElements:n,lastUpdatedValue:x,updatePending:!1}),YT(()=>{let C=r.toString();w(C),E.current.lastUpdatedValue=C},[r]);let y=(C,S,P)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let M=Number(C);if(isNaN(M)){w(r.toString());return}let R=Number(M.toFixed(2)),L=Number(r);(isNaN(L)||Math.abs(R-L)>=WT)&&(E.current.lastUpdatedValue=C,t({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:R,property:l,originalAppState:P,setInputValue:k=>w(String(k)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:VT.IMMEDIATELY}))},v=pm({});return v.current.handleInputValue=y,YT(()=>{let C=f.current,S=v.current;return()=>{let P=C?.value;P&&S.handleInputValue?.(P,E.current.originalElements,E.current.originalAppState),window.removeEventListener(oa.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(oa.POINTER_UP,S.onPointerUp,!1)}},[i]),i?MF("div",{className:TF("drag-input-container",!i&&"disabled"),"data-testid":e,children:[rf("div",{className:"drag-input-label",ref:b,onPointerDown:C=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let S=Number(f.current.value);isNaN(S)&&(S=0);let P=null,M=p.scene.getNonDeletedElements().reduce((_,B)=>(_.set(B.id,SF(B)),_),new Map),R=n.map(_=>M.get(_.id)),L=of(m),k=0,N=0,O=_=>{if(P&&M!==null&&R!==null){let B=_.clientX-P.x;B!==0&&(N+=B,Math.abs(N)>=c&&(N=Math.sign(N)*Math.floor(Math.abs(N)/c),k+=N,t({accumulatedChange:k,instantChange:N,originalElements:R,originalElementsMap:M,shouldKeepAspectRatio:a,shouldChangeByStepSize:_.shiftKey,property:l,scene:s,originalAppState:L,setInputValue:K=>w(String(K)),app:p,setAppState:u}),N=0))}P={x:_.clientX,y:_.clientY}},G=()=>{window.removeEventListener(oa.POINTER_MOVE,O,!1),p.syncActionResult({captureUpdate:VT.IMMEDIATELY}),d?.({app:p,setAppState:u,originalElements:R,originalAppState:L}),P=null,k=0,N=0,R=null,M=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(oa.POINTER_UP,G,!1)};v.current.onPointerMove=O,v.current.onPointerUp=G,window.addEventListener(oa.POINTER_MOVE,O,!1),window.addEventListener(oa.POINTER_UP,G,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?rf(Ir,{icon:o}):e}),rf("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(i){let S=C.target;S instanceof HTMLInputElement&&C.key===CF.ENTER&&(y(S.value,n,m),p.focusContainer())}},ref:f,value:x,onChange:C=>{E.current.updatePending=!0,w(C.target.value)},onFocus:C=>{C.target.select(),E.current.originalElements=n,E.current.originalAppState=of(m)},onBlur:C=>{x?i&&y(C.target.value,E.current.originalElements,E.current.originalAppState):w(r.toString())},disabled:!i})]}):null},rt=kF;import{jsx as DF}from"react/jsx-runtime";var PF=15,AF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a&&!LF(a)){let l=i.get(a.id);if(!l)return;if(r!==void 0){let u=XT(r);n.mutateElement(l,{angle:u}),$T(l,n);let f=KT(l,i);f&&!ZT(l)&&n.mutateElement(f,{angle:u});return}let s=Math.round(jT(a.angle)*100)/100,m=Math.round(e),c=(s+m)%360;t&&(c=_e(c,PF)),c=c<0?c+360:c;let d=XT(c);n.mutateElement(l,{angle:d}),$T(l,n);let p=KT(l,i);p&&!ZT(l)&&n.mutateElement(p,{angle:d})}},_F=({element:e,scene:o,appState:t,property:r})=>DF(rt,{label:"A",icon:Bs,value:Math.round(jT(e.angle)%360*100)/100,elements:[e],dragInputCallback:AF,editable:_t(e,"angle"),scene:o,appState:t,property:r}),qT=_F;import{jsx as NF}from"react/jsx-runtime";var JT=5,RF=({property:e,scene:o,appState:t,setAppState:r})=>NF(rt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{r(s=>{let m;return n?m=n:i&&(m=a?_e(s.gridStep+JT*Math.sign(i),JT):s.gridStep+i),m?(m=k1(m),l(m),{gridStep:m}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),QT=RF;import{clamp as um,round as nf}from"@haoxin-web/excalidraw-math";import{MIN_WIDTH_OR_HEIGHT as hm}from"@haoxin-web/excalidraw-common";import{MINIMAL_CROP_SIZE as eI,getUncroppedWidthAndHeight as rI}from"@haoxin-web/excalidraw-element";import{resizeSingleElement as tI}from"@haoxin-web/excalidraw-element";import{isImageElement as nI}from"@haoxin-web/excalidraw-element";import{isFrameLikeElement as af}from"@haoxin-web/excalidraw-element";import{getElementsInResizingFrame as lf}from"@haoxin-web/excalidraw-element";import{replaceAllElementsInFrame as iI}from"@haoxin-web/excalidraw-element";import{jsx as HF}from"react/jsx-runtime";var oI=10,BF=e=>e.type==="image",FF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:m,app:c,setAppState:d})=>{let p=m.getNonDeletedElementsMap(),u=o[0],f=p.get(u.id);if(u&&f){let b=r||BF(u),x=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!nI(w)||!w.crop)return;let E=w.crop,y={...E},v=w.scale[0]===-1,C=w.scale[1]===-1,{width:S,height:P}=rI(w),M=E.naturalWidth/S,R=E.naturalHeight/P,L=v?E.width+E.x:E.naturalWidth-E.x,k=C?E.height+E.y:E.naturalHeight-E.y,N=eI*M,O=eI*R;if(i!==void 0){if(a==="width"){let j=i*M,X=um(j,N,L);y={...y,width:X,x:v?E.x+E.width-X:E.x}}else if(a==="height"){let j=i*R,X=um(j,O,k);y={...y,height:X,y:C?E.y+E.height-X:E.y}}m.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/P)});return}let G=a==="width"?s:0,_=a==="height"?s:0,B=um(E.width+G,N,L),K=um(E.height+_,N,k);y={...E,x:v?E.x+E.width-B:E.x,y:C?E.y+E.height-K:E.y,width:B,height:K},m.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/P)});return}if(i!==void 0){let w=Math.max(a==="width"?i:b?i*x:u.width,hm),E=Math.max(a==="height"?i:b?i/x:u.height,hm);if(tI(w,E,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),af(f)){let y=lf(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap()),v=iI(m.getElementsIncludingDeleted(),y,f,c);m.replaceAllElements(v)}return}{let w=a==="width"?e:0,E=a==="height"?e:0,y=Math.max(0,u.width+w);a==="width"&&(n?y=_e(y,oI):y=Math.round(y));let v=Math.max(0,u.height+E);if(a==="height"&&(n?v=_e(v,oI):v=Math.round(v)),b&&(a==="width"?v=Math.round(y/x*100)/100:y=Math.round(v*x*100)/100),v=Math.max(hm,v),y=Math.max(hm,y),tI(y,v,f,u,t,m,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),af(f)){let C=lf(m.getElementsIncludingDeleted(),f,l,m.getNonDeletedElementsMap());d({elementsToHighlight:C})}}}},OF=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&af(a)){let l=lf(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=iI(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},zF=({property:e,element:o,scene:t,appState:r})=>{let n=nf(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&nI(o)&&o.crop){let{width:i,height:a}=rI(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=nf(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=nf(o.crop.height*l,2)}}return HF(rt,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:FF,value:n,editable:_t(o,e),scene:t,appState:r,property:e,dragFinishedCallback:OF})},sf=zF;import{getBoundTextElement as GF,redrawTextBoundingBox as UF}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as WF,isTextElement as lI}from"@haoxin-web/excalidraw-element";import{jsx as KF}from"react/jsx-runtime";var aI=4,YF=4,VF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!lI(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),aI);else if(a.type==="text"){let m=Math.round(a.fontSize),c=Math.round(e);s=Math.max(m+c,aI),t&&(s=_e(s,YF))}s&&(n.mutateElement(l,{fontSize:s}),UF(l,n.getContainerElement(l),n))}},XF=({element:e,scene:o,appState:t,property:r})=>{let n=lI(e)?e:WF(e)?GF(e,o.getNonDeletedElementsMap()):null;return n?KF(rt,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:VF,icon:an,appState:t,scene:o,property:r}):null},sI=XF;import{degreesToRadians as cI,radiansToDegrees as pI}from"@haoxin-web/excalidraw-math";import{getBoundTextElement as dI}from"@haoxin-web/excalidraw-element";import{isArrowElement as mI}from"@haoxin-web/excalidraw-element";import{isInGroup as cf}from"@haoxin-web/excalidraw-element";import{jsx as qF}from"react/jsx-runtime";var ZF=15,$F=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(m=>a.get(m.id)).filter(m=>m&&!cf(m)&&_t(m,n)),s=o.filter(m=>!cf(m)&&_t(m,n));if(r!==void 0){let m=cI(r);for(let c of l){if(!c)continue;i.mutateElement(c,{angle:m});let d=dI(c,a);d&&!mI(c)&&i.mutateElement(d,{angle:m})}i.triggerUpdate();return}for(let m=0;m<l.length;m++){let c=l[m];if(!c)continue;let d=s[m],p=Math.round(pI(d.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=_e(f,ZF)),f=f<0?f+360:f;let b=cI(f);i.mutateElement(c,{angle:b});let x=dI(c,a);x&&!mI(c)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},jF=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!cf(s)&&_t(s,"angle")),i=n.map(s=>Math.round(pI(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>_t(s,"angle"));return qF(rt,{label:"A",icon:Bs,value:a,elements:e,dragInputCallback:$F,editable:l,appState:t,scene:o,property:r})},uI=jF;import{pointFrom as hI}from"@haoxin-web/excalidraw-math";import{useMemo as JF}from"react";import{MIN_WIDTH_OR_HEIGHT as Yr}from"@haoxin-web/excalidraw-common";import{getElementsInResizingFrame as df,isFrameLikeElement as mf,replaceAllElementsInFrame as bI,updateBoundElements as QF}from"@haoxin-web/excalidraw-element";import{rescalePointsInElement as eO,resizeSingleElement as gI}from"@haoxin-web/excalidraw-element";import{getBoundTextElement as tO,handleBindTextResize as oO}from"@haoxin-web/excalidraw-element";import{isTextElement as xI}from"@haoxin-web/excalidraw-element";import{getCommonBounds as gm}from"@haoxin-web/excalidraw-element";import{jsx as sO}from"react/jsx-runtime";var ra=10,rO=(e,o,t,r)=>{let n=r.x-e,i=r.y-o,a=r.width*t,l=r.height*t,s=e+n*t,m=o+i*t;return{width:a,height:l,x:s,y:m,...eO(r,a,l,!1),...xI(r)?{fontSize:r.fontSize*t}:{}}},nO=(e,o,t,r,n,i,a,l)=>{let s=l.getNonDeletedElementsMap(),m=rO(e,o,r,i);l.mutateElement(n,m);let c=tO(i,a);if(c){let d=c.fontSize*r;QF(n,l,{newSize:{width:m.width,height:m.height}});let p=s.get(c.id);p&&xI(p)&&(l.mutateElement(p,{fontSize:d}),oO(n,l,t==="width"?"e":"s",!0))}},fI=(e,o,t,r,n,i,a,l,s,m)=>{i==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let c=o/t;for(let d=0;d<l.length;d++){let p=l[d],u=a[d];nO(n[0],n[1],i,c,u,p,s,m)}},iO=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l,setAppState:s,app:m})=>{let c=a.getNonDeletedElementsMap(),d=ta(o,r);if(i!==void 0){for(let b of d){let x=ea(b,c,t);if(x.length>1){let w=x.map(N=>N.latest),E=x.map(N=>N.original),[y,v,C,S]=gm(E),P=C-y,M=S-v,R=P/M,L=Math.max(Yr,l==="width"?Math.max(0,i):P),k=Math.max(Yr,l==="height"?Math.max(0,i):M);fI(L,k,M,R,hI(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&_t(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(n?v=_e(v,ra):v=Math.round(v));let C=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(n?C=_e(C,ra):C=Math.round(C)),v=Math.max(Yr,v),C=Math.max(Yr,C),gI(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),mf(E)){let S=df(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap()),P=bI(a.getElementsIncludingDeleted(),S,E,m);a.replaceAllElements(P)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,f=[];for(let b of d){let x=ea(b,c,t);if(x.length>1){let w=x.map(N=>N.latest),E=x.map(N=>N.original),[y,v,C,S]=gm(E),P=C-y,M=S-v,R=P/M,L=Math.max(0,P+p);l==="width"&&(n?L=_e(L,ra):L=Math.round(L));let k=Math.max(0,M+u);l==="height"&&(n?k=_e(k,ra):k=Math.round(k)),L=Math.max(Yr,L),k=Math.max(Yr,k),fI(L,k,M,R,hI(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&_t(E,l)){let v=Math.max(0,y.width+p);l==="width"&&(n?v=_e(v,ra):v=Math.round(v));let C=Math.max(0,y.height+u);if(l==="height"&&(n?C=_e(C,ra):C=Math.round(C)),v=Math.max(Yr,v),C=Math.max(Yr,C),gI(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),mf(E)){let S=df(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap());f.push(...S)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},aO=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&mf(a)){let l=df(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=bI(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},lO=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=JF(()=>r.map(m=>{let c=ea(m,t);if(c.length>1){let[p,u,f,b]=gm(c.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[d]=c;return Math.round((e==="width"?d.latest.width:d.latest.height)*100)/100}),[t,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return sO(rt,{label:e==="width"?"W":"H",elements:o,dragInputCallback:iO,value:l,editable:s,appState:i,property:e,scene:n,dragFinishedCallback:aO})},pf=lO;import{getBoundTextElement as cO,redrawTextBoundingBox as EI}from"@haoxin-web/excalidraw-element";import{hasBoundTextElement as dO,isTextElement as mO}from"@haoxin-web/excalidraw-element";import{isInGroup as pO}from"@haoxin-web/excalidraw-element";import{jsx as bO}from"react/jsx-runtime";var yI=4,uO=4,hO=(e,o)=>e.reduce((t,r)=>{if(!r||pO(r))return t;if(mO(r))return t.push(r),t;if(dO(r)){let n=cO(r,o);if(n)return t.push(n),t}return t},[]),gO=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(r){l=Math.max(Math.round(r),yI);for(let s of a)n.mutateElement(s,{fontSize:l}),EI(s,n.getContainerElement(s),n);n.triggerUpdate()}else{let s=o;for(let m=0;m<a.length;m++){let c=a[m],d=s[m],p=Math.round(d.fontSize),u=Math.round(e),f=Math.max(p+u,yI);t&&(f=_e(f,uO)),n.mutateElement(c,{fontSize:f}),EI(c,n.getContainerElement(c),n)}n.triggerUpdate()}},fO=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=hO(e,n);if(!i.length)return null;let a=i.map(m=>Math.round(m.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return bO(rt,{label:"F",icon:an,elements:i,dragInputCallback:gO,value:l,editable:s,scene:o,property:r,appState:t})},wI=fO;import{pointFrom as Vr,pointRotateRads as fm}from"@haoxin-web/excalidraw-math";import{useMemo as xO}from"react";import{isTextElement as EO}from"@haoxin-web/excalidraw-element";import{getCommonBounds as uf}from"@haoxin-web/excalidraw-element";import{jsx as IO}from"react/jsx-runtime";var yO=(e,o,t,r,n,i)=>{for(let a=0;a<r.length;a++){let l=r[a],[s,m]=[l.x+l.width/2,l.y+l.height/2],[c,d]=fm(Vr(l.x,l.y),Vr(s,m),l.angle),p=e==="x"?Math.round(c+o):c,u=e==="y"?Math.round(d+t):d;Cn(p,u,l,i,n,!1)}},wO=(e,o,t,r,n)=>{let i=n.getNonDeletedElementsMap(),[a,l,,]=uf(t),s=e-a,m=o-l;for(let c=0;c<t.length;c++){let d=t[c],p=i.get(d.id);if(p&&(!EO(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=fm(Vr(p.x,p.y),Vr(u,f),p.angle);Cn(b+s,x+m,d,n,r,!1)}}},vO=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(n!==void 0){for(let p of ta(o,l)){let u=ea(p,s,t);if(u.length>1){let[f,b,,]=uf(u.map(E=>E.latest));wO(i==="x"?n:f,i==="y"?n:b,u.map(E=>E.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&_t(b,i)){let[x,w]=[f.x+f.width/2,f.y+f.height/2],[E,y]=fm(Vr(f.x,f.y),Vr(x,w),f.angle);Cn(i==="x"?n:E,i==="y"?n:y,f,a,t,!1)}}}a.triggerUpdate();return}let m=r?_e(e,_l):e;yO(i,i==="x"?m:0,i==="y"?m:0,o,t,a),a.triggerUpdate()},TO=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=xO(()=>r.map(s=>{let m=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(m.length>1){let[b,x]=uf(m);return Math.round((e==="x"?b:x)*100)/100}let[c]=m,[d,p]=[c.x+c.width/2,c.y+c.height/2],[u,f]=fm(Vr(c.x,c.y),Vr(d,p),c.angle);return Math.round((e==="x"?u:f)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return IO(rt,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:vO,value:l,property:e,scene:n,appState:i})},hf=TO;import{clamp as Dl,pointFrom as bm,pointRotateRads as TI,round as vI}from"@haoxin-web/excalidraw-math";import{getFlipAdjustedCropPosition as CO,getUncroppedWidthAndHeight as SO}from"@haoxin-web/excalidraw-element";import{isImageElement as II}from"@haoxin-web/excalidraw-element";import{jsx as LO}from"react/jsx-runtime";var kO=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let m=l.getNonDeletedElementsMap(),c=t[0],[d,p]=[c.x+c.width/2,c.y+c.height/2],[u,f]=TI(bm(c.x,c.y),bm(d,p),c.angle);if(s.croppingElementId===c.id){let y=m.get(c.id);if(!y||!II(y)||!y.crop)return;let v=y.crop,C=v,S=y.scale[0]===-1,P=y.scale[1]===-1,{width:M,height:R}=SO(y);if(i!==void 0){if(a==="x"){let N=i*(v.naturalWidth/M);S?C={...v,x:Dl(v.naturalWidth-N-v.width,0,v.naturalWidth-v.width)}:C={...v,x:Dl(i*(v.naturalWidth/M),0,v.naturalWidth-v.width)}}a==="y"&&(C={...v,y:Dl(i*(v.naturalHeight/R),0,v.naturalHeight-v.height)}),l.mutateElement(y,{crop:C});return}let L=(a==="x"?o:0)*(S?-1:1),k=(a==="y"?o:0)*(P?-1:1);C={...v,x:Dl(v.x+L,0,v.naturalWidth-v.width),y:Dl(v.y+k,0,v.naturalHeight-v.height)},l.mutateElement(y,{crop:C});return}if(i!==void 0){Cn(a==="x"?i:u,a==="y"?i:f,c,l,r);return}let b=a==="x"?e:0,x=a==="y"?e:0,w=a==="x"?Math.round(n?_e(c.x+b,_l):u+b):u,E=a==="y"?Math.round(n?_e(c.y+x,_l):f+x):f;Cn(w,E,c,l,r)},MO=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=TI(bm(o.x,o.y),bm(o.x+o.width/2,o.y+o.height/2),o.angle),l=vI(e==="x"?i:a,2);if(n.croppingElementId===o.id&&II(o)&&o.crop){let s=CO(o);s&&(l=vI(e==="x"?s.x:s.y,2))}return LO(rt,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:kO,scene:r,value:l,property:e,appState:n})},gf=MO;import{Fragment as xf,jsx as Q,jsxs as Dt}from"react/jsx-runtime";var zO=50,Rl=e=>{let o=Mo(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=Nr(e.app);return Q(HO,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},ke=({children:e,columns:o=1,heading:t,style:r,...n})=>Q("div",{className:PO("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});ke.displayName="StatsRow";var Em=({children:e,order:o,style:t,...r})=>Q("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});Em.displayName="StatsRows";Rl.StatsRow=ke;Rl.StatsRows=Em;var HO=DO(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),m=l.getNonDeletedElementsMap(),c=me(),d=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&bf(d),f=u?NO(d):null,[b,x]=_O({width:0,height:0}),w=ff(()=>AO(v=>{let C=RO(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},zO),[]);SI(()=>{w(s)},[i,s,w]),SI(()=>()=>w.cancel(),[w]);let E=ff(()=>ta(r,n),[r,n]),y=ff(()=>FO(r),[r]);return Q("div",{className:"exc-stats",children:Dt(De,{padding:3,children:[Dt("div",{className:"title",children:[Q("h2",{children:h("stats.title")}),Q("div",{className:"close",onClick:o,children:Vt})]}),Dt(Fa,{label:Q("h3",{children:h("stats.generalStats")}),open:!!(n.stats.panels&xm.generalStats),openTrigger:()=>c(v=>({stats:{open:!0,panels:v.stats.panels^xm.generalStats}})),children:[Dt(Em,{children:[Q(ke,{heading:!0,children:h("stats.scene")}),Dt(ke,{columns:2,children:[Q("div",{children:h("stats.shapes")}),Q("div",{children:s.length})]}),Dt(ke,{columns:2,children:[Q("div",{children:h("stats.width")}),Q("div",{children:b.width})]}),Dt(ke,{columns:2,children:[Q("div",{children:h("stats.height")}),Q("div",{children:b.height})]}),a&&Dt(xf,{children:[Q(ke,{heading:!0,children:"Canvas"}),Q(ke,{children:Q(QT,{property:"gridStep",scene:l,appState:n,setAppState:c})})]})]}),t?.(s,n)]}),!y&&r.length>0&&Q("div",{id:"elementStats",style:{marginTop:12},children:Q(Fa,{label:Q("h3",{children:h("stats.elementProperties")}),open:!!(n.stats.panels&xm.elementProperties),openTrigger:()=>c(v=>({stats:{open:!0,panels:v.stats.panels^xm.elementProperties}})),children:Dt(Em,{children:[d&&Dt(xf,{children:[u&&Q(ke,{heading:!0,children:h("labels.unCroppedDimension")}),n.croppingElementId&&bf(d)&&f&&Dt(ke,{columns:2,children:[Q("div",{children:h("stats.width")}),Q("div",{children:CI(f.width,2)})]}),n.croppingElementId&&bf(d)&&f&&Dt(ke,{columns:2,children:[Q("div",{children:h("stats.height")}),Q("div",{children:CI(f.height,2)})]}),Q(ke,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?h("labels.imageCropping"):String(d.type)}),Q(ke,{children:Q(gf,{element:d,property:"x",elementsMap:m,scene:l,appState:n})}),Q(ke,{children:Q(gf,{element:d,property:"y",elementsMap:m,scene:l,appState:n})}),Q(ke,{children:Q(sf,{property:"width",element:d,scene:l,appState:n})}),Q(ke,{children:Q(sf,{property:"height",element:d,scene:l,appState:n})}),!BO(d)&&Q(ke,{children:Q(qT,{property:"angle",element:d,scene:l,appState:n})}),Q(ke,{children:Q(sI,{property:"fontSize",element:d,scene:l,appState:n})})]}),p&&Dt(xf,{children:[OO(p)&&Q(ke,{heading:!0,children:h("element.group")}),Dt(ke,{columns:2,style:{margin:"0.3125rem 0"},children:[Q("div",{children:h("stats.shapes")}),Q("div",{children:r.length})]}),Q(ke,{children:Q(hf,{property:"x",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),Q(ke,{children:Q(hf,{property:"y",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),Q(ke,{children:Q(pf,{property:"width",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),Q(ke,{children:Q(pf,{property:"height",elements:p,elementsMap:m,atomicUnits:E,scene:l,appState:n})}),Q(ke,{children:Q(uI,{property:"angle",elements:p,scene:l,appState:n})}),Q(ke,{children:Q(wI,{property:"fontSize",elements:p,scene:l,appState:n,elementsMap:m})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as GO,useEffect as kI,useState as MI}from"react";import{normalizeLink as UO,KEYS as Ef}from"@haoxin-web/excalidraw-common";import{defaultGetElementLinkFromSelection as WO,getLinkIdAndTypeFromSelection as YO}from"@haoxin-web/excalidraw-element";import{jsx as na,jsxs as ym}from"react/jsx-runtime";var VO=({sourceElementId:e,onClose:o,appState:t,scene:r,generateLinkForSelection:n=WO})=>{let i=r.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=MI(a),[m,c]=MI(!1);kI(()=>{let p=J(i,t),u=a;if(p.length>0&&n){let f=YO(p,t);f&&(u=UO(n(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,n]);let d=GO(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&r.mutateElement(p,{link:l})}if(!l&&m&&e){let p=i.get(e);p&&r.mutateElement(p,{link:null})}o?.()},[e,l,i,m,r,o]);return kI(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===Ef.ENTER&&d(),t.openDialog?.name==="elementLinkSelector"&&u.key===Ef.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,d]),ym("div",{className:"ElementLinkDialog",children:[ym("div",{className:"ElementLinkDialog__header",children:[na("h2",{children:h("elementLink.title")}),na("p",{children:h("elementLink.desc")})]}),ym("div",{className:"ElementLinkDialog__input",children:[na(Ni,{value:l??"",onChange:p=>{m||c(!0),s(p)},onKeyDown:p=>{p.key===Ef.ENTER&&d()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&na(z,{type:"button",title:h("buttons.remove"),"aria-label":h("buttons.remove"),label:h("buttons.remove"),onClick:()=>{s(null),c(!0)},className:"ElementLinkDialog__remove",icon:Bt})]}),ym("div",{className:"ElementLinkDialog__actions",children:[na(Jo,{label:h("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),na(Jo,{label:h("buttons.confirm"),onClick:d,actionType:"primary"})]})]})},LI=VO;import XO,{useState as KO}from"react";import{Fragment as ZO,jsx as yf}from"react/jsx-runtime";var PI=({children:e,onClose:o})=>{let[t,r]=KO(!!e),{container:n}=Xe(),i=XO.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return yf(ZO,{children:t&&yf(Ge,{size:"small",onCloseRequest:i,title:h("errorDialog.title"),children:yf("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import $O from"react";import{isDarwin as AI,isFirefox as _I,isWindows as jO}from"@haoxin-web/excalidraw-common";import{KEYS as Ne,getShortcutKey as Z}from"@haoxin-web/excalidraw-common";import{Fragment as RI,jsx as U,jsxs as Yt}from"react/jsx-runtime";var qO=()=>Yt("div",{className:"HelpDialog__header",children:[Yt("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[U("div",{className:"HelpDialog__link-icon",children:op}),h("helpDialog.documentation")]}),Yt("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[U("div",{className:"HelpDialog__link-icon",children:op}),h("helpDialog.blog")]}),Yt("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[U("div",{className:"HelpDialog__link-icon",children:Cs}),h("helpDialog.github")]}),Yt("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[U("div",{className:"HelpDialog__link-icon",children:A0}),"YouTube"]})]}),JO=e=>Yt(RI,{children:[U("h3",{children:e.title}),U("div",{className:"HelpDialog__islands-container",children:e.children})]}),wf=e=>Yt("div",{className:`HelpDialog__island ${e.className}`,children:[U("h4",{className:"HelpDialog__island-title",children:e.caption}),U("div",{className:"HelpDialog__island-content",children:e.children})]});function*QO(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var ez=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),Y=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>U(tz,{children:ez(a)},a)));return Yt("div",{className:"HelpDialog__shortcut",children:[U("div",{children:e}),U("div",{className:"HelpDialog__key-container",children:[...QO(r,t?h("helpDialog.or"):null)]})]})},tz=e=>U("kbd",{className:"HelpDialog__key",...e}),DI=({onClose:e})=>{let o=$O.useCallback(()=>{e&&e()},[e]);return U(RI,{children:Yt(Ge,{onCloseRequest:o,title:h("helpDialog.title"),className:"HelpDialog",children:[U(qO,{}),Yt(JO,{title:h("helpDialog.shortcuts"),children:[Yt(wf,{className:"HelpDialog__island--tools",caption:h("helpDialog.tools"),children:[U(Y,{label:h("toolBar.hand"),shortcuts:[Ne.H]}),U(Y,{label:h("toolBar.selection"),shortcuts:[Ne.V,Ne[1]]}),U(Y,{label:h("toolBar.rectangle"),shortcuts:[Ne.R,Ne[2]]}),U(Y,{label:h("toolBar.diamond"),shortcuts:[Ne.D,Ne[3]]}),U(Y,{label:h("toolBar.ellipse"),shortcuts:[Ne.O,Ne[4]]}),U(Y,{label:h("toolBar.arrow"),shortcuts:[Ne.A,Ne[5]]}),U(Y,{label:h("toolBar.line"),shortcuts:[Ne.L,Ne[6]]}),U(Y,{label:h("toolBar.freedraw"),shortcuts:[Ne.P,Ne[7]]}),U(Y,{label:h("toolBar.text"),shortcuts:[Ne.T,Ne[8]]}),U(Y,{label:h("toolBar.image"),shortcuts:[Ne[9]]}),U(Y,{label:h("toolBar.eraser"),shortcuts:[Ne.E,Ne[0]]}),U(Y,{label:h("toolBar.frame"),shortcuts:[Ne.F]}),U(Y,{label:h("toolBar.laser"),shortcuts:[Ne.K]}),U(Y,{label:h("labels.eyeDropper"),shortcuts:[Ne.I,"Shift+S","Shift+G"]}),U(Y,{label:h("helpDialog.editLineArrowPoints"),shortcuts:[Z("CtrlOrCmd+Enter")]}),U(Y,{label:h("helpDialog.editText"),shortcuts:[Z("Enter")]}),U(Y,{label:h("helpDialog.textNewLine"),shortcuts:[Z("Enter"),Z("Shift+Enter")]}),U(Y,{label:h("helpDialog.textFinish"),shortcuts:[Z("Esc"),Z("CtrlOrCmd+Enter")]}),U(Y,{label:h("helpDialog.curvedArrow"),shortcuts:["A",h("helpDialog.click"),h("helpDialog.click"),h("helpDialog.click")],isOr:!1}),U(Y,{label:h("helpDialog.curvedLine"),shortcuts:["L",h("helpDialog.click"),h("helpDialog.click"),h("helpDialog.click")],isOr:!1}),U(Y,{label:h("helpDialog.cropStart"),shortcuts:[h("helpDialog.doubleClick"),Z("Enter")],isOr:!0}),U(Y,{label:h("helpDialog.cropFinish"),shortcuts:[Z("Enter"),Z("Escape")],isOr:!0}),U(Y,{label:h("toolBar.lock"),shortcuts:[Ne.Q]}),U(Y,{label:h("helpDialog.preventBinding"),shortcuts:[Z("CtrlOrCmd")]}),U(Y,{label:h("toolBar.link"),shortcuts:[Z("CtrlOrCmd+K")]}),U(Y,{label:h("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Yt(wf,{className:"HelpDialog__island--view",caption:h("helpDialog.view"),children:[U(Y,{label:h("buttons.zoomIn"),shortcuts:[Z("CtrlOrCmd++")]}),U(Y,{label:h("buttons.zoomOut"),shortcuts:[Z("CtrlOrCmd+-")]}),U(Y,{label:h("buttons.resetZoom"),shortcuts:[Z("CtrlOrCmd+0")]}),U(Y,{label:h("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),U(Y,{label:h("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),U(Y,{label:h("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),U(Y,{label:h("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),U(Y,{label:h("buttons.zenMode"),shortcuts:[Z("Alt+Z")]}),U(Y,{label:h("buttons.objectsSnapMode"),shortcuts:[Z("Alt+S")]}),U(Y,{label:h("labels.toggleGrid"),shortcuts:[Z("CtrlOrCmd+'")]}),U(Y,{label:h("labels.viewMode"),shortcuts:[Z("Alt+R")]}),U(Y,{label:h("labels.toggleTheme"),shortcuts:[Z("Alt+Shift+D")]}),U(Y,{label:h("stats.fullTitle"),shortcuts:[Z("Alt+/")]}),U(Y,{label:h("search.title"),shortcuts:[He("searchMenu")]}),U(Y,{label:h("commandPalette.title"),shortcuts:_I?[He("commandPalette")]:[He("commandPalette"),He("commandPalette",1)]})]}),Yt(wf,{className:"HelpDialog__island--editor",caption:h("helpDialog.editor"),children:[U(Y,{label:h("helpDialog.createFlowchart"),shortcuts:[Z("CtrlOrCmd+Arrow Key")],isOr:!0}),U(Y,{label:h("helpDialog.navigateFlowchart"),shortcuts:[Z("Alt+Arrow Key")],isOr:!0}),U(Y,{label:h("labels.moveCanvas"),shortcuts:[Z(`Space+${h("helpDialog.drag")}`),Z(`Wheel+${h("helpDialog.drag")}`)],isOr:!0}),U(Y,{label:h("buttons.clearReset"),shortcuts:[Z("CtrlOrCmd+Delete")]}),U(Y,{label:h("labels.delete"),shortcuts:[Z("Delete")]}),U(Y,{label:h("labels.cut"),shortcuts:[Z("CtrlOrCmd+X")]}),U(Y,{label:h("labels.copy"),shortcuts:[Z("CtrlOrCmd+C")]}),U(Y,{label:h("labels.paste"),shortcuts:[Z("CtrlOrCmd+V")]}),U(Y,{label:h("labels.pasteAsPlaintext"),shortcuts:[Z("CtrlOrCmd+Shift+V")]}),U(Y,{label:h("labels.selectAll"),shortcuts:[Z("CtrlOrCmd+A")]}),U(Y,{label:h("labels.multiSelect"),shortcuts:[Z(`Shift+${h("helpDialog.click")}`)]}),U(Y,{label:h("helpDialog.deepSelect"),shortcuts:[Z(`CtrlOrCmd+${h("helpDialog.click")}`)]}),U(Y,{label:h("helpDialog.deepBoxSelect"),shortcuts:[Z(`CtrlOrCmd+${h("helpDialog.drag")}`)]}),(pi||_I)&&U(Y,{label:h("labels.copyAsPng"),shortcuts:[Z("Shift+Alt+C")]}),U(Y,{label:h("labels.copyStyles"),shortcuts:[Z("CtrlOrCmd+Alt+C")]}),U(Y,{label:h("labels.pasteStyles"),shortcuts:[Z("CtrlOrCmd+Alt+V")]}),U(Y,{label:h("labels.sendToBack"),shortcuts:[AI?Z("CtrlOrCmd+Alt+["):Z("CtrlOrCmd+Shift+[")]}),U(Y,{label:h("labels.bringToFront"),shortcuts:[AI?Z("CtrlOrCmd+Alt+]"):Z("CtrlOrCmd+Shift+]")]}),U(Y,{label:h("labels.sendBackward"),shortcuts:[Z("CtrlOrCmd+[")]}),U(Y,{label:h("labels.bringForward"),shortcuts:[Z("CtrlOrCmd+]")]}),U(Y,{label:h("labels.alignTop"),shortcuts:[Z("CtrlOrCmd+Shift+Up")]}),U(Y,{label:h("labels.alignBottom"),shortcuts:[Z("CtrlOrCmd+Shift+Down")]}),U(Y,{label:h("labels.alignLeft"),shortcuts:[Z("CtrlOrCmd+Shift+Left")]}),U(Y,{label:h("labels.alignRight"),shortcuts:[Z("CtrlOrCmd+Shift+Right")]}),U(Y,{label:h("labels.duplicateSelection"),shortcuts:[Z("CtrlOrCmd+D"),Z(`Alt+${h("helpDialog.drag")}`)]}),U(Y,{label:h("helpDialog.toggleElementLock"),shortcuts:[Z("CtrlOrCmd+Shift+L")]}),U(Y,{label:h("buttons.undo"),shortcuts:[Z("CtrlOrCmd+Z")]}),U(Y,{label:h("buttons.redo"),shortcuts:jO?[Z("CtrlOrCmd+Y"),Z("CtrlOrCmd+Shift+Z")]:[Z("CtrlOrCmd+Shift+Z")]}),U(Y,{label:h("labels.group"),shortcuts:[Z("CtrlOrCmd+G")]}),U(Y,{label:h("labels.ungroup"),shortcuts:[Z("CtrlOrCmd+Shift+G")]}),U(Y,{label:h("labels.flipHorizontal"),shortcuts:[Z("Shift+H")]}),U(Y,{label:h("labels.flipVertical"),shortcuts:[Z("Shift+V")]}),U(Y,{label:h("labels.showStroke"),shortcuts:[Z("S")]}),U(Y,{label:h("labels.showBackground"),shortcuts:[Z("G")]}),U(Y,{label:h("labels.showFonts"),shortcuts:[Z("Shift+F")]}),U(Y,{label:h("labels.decreaseFontSize"),shortcuts:[Z("CtrlOrCmd+Shift+<")]}),U(Y,{label:h("labels.increaseFontSize"),shortcuts:[Z("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as FI,useRef as lz,useState as Xr}from"react";import{DEFAULT_EXPORT_PADDING as sz,EXPORT_IMAGE_TYPES as vf,isFirefox as cz,EXPORT_SCALES as dz,cloneJSON as OI}from"@haoxin-web/excalidraw-common";import{useCallback as oz,useRef as rz,useState as nz}from"react";var iz=2e3,NI=()=>{let[e,o]=nz(null),t=rz(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},iz)},n=oz(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import az from"clsx";import{jsx as BI}from"react/jsx-runtime";var Nl=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>BI("div",{className:az("Switch",{toggled:t,disabled:n}),children:BI("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:n,onChange:()=>r(!t),onKeyDown:i=>{i.key===" "&&r(!t)}})});import{jsx as Me,jsxs as Kr}from"react/jsx-runtime";var mz="filter"in document.createElement("canvas").getContext("2d"),pz=()=>Kr("div",{children:[Me("h3",{children:h("canvasError.cannotShowPreview")}),Me("p",{children:Me("span",{children:h("canvasError.canvasTooBig")})}),Kr("em",{children:["(",h("canvasError.canvasTooBigTip"),")"]})]}),uz=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=we(o,e),[l,s]=Xr(i),[m,c]=Xr(a),[d,p]=Xr(e.exportBackground),[u,f]=Xr(e.exportWithDarkMode),[b,x]=Xr(e.exportEmbedScene),[w,E]=Xr(e.exportScale),y=lz(null),[v,C]=Xr(null),{onCopy:S,copyStatus:P,resetCopyStatus:M}=NI();FI(()=>{M()},[l,d,u,w,b,M]);let{exportedElements:R,exportingFrame:L}=pn(o,e,m);return FI(()=>{let k=y.current;if(!k)return;let N=k.offsetWidth,O=k.offsetHeight;N&&Lr({elements:R,appState:{...e,name:l,exportBackground:d,exportWithDarkMode:u,exportScale:w,exportEmbedScene:b},files:t,exportPadding:sz,maxWidthOrHeight:Math.max(N,O),exportingFrame:L}).then(G=>(C(null),Go(G).then(()=>{k.replaceChildren(G)}).catch(_=>{throw _.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(h("canvasError.canvasTooBig")):_}))).catch(G=>{console.error(G),C(G)})},[e,t,R,L,l,d,u,w,b]),Kr("div",{className:"ImageExportModal",children:[Me("h3",{children:h("imageExportDialog.header")}),Kr("div",{className:"ImageExportModal__preview",children:[Me("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Me(pz,{})}),Me("div",{className:"ImageExportModal__preview__filename",children:!Rn&&Me("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:k=>{s(k.target.value),r.executeAction(vu,"ui",k.target.value)}})})]}),Kr("div",{className:"ImageExportModal__settings",children:[Me("h3",{children:h("imageExportDialog.header")}),a&&Me(Bl,{label:h("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Me(Nl,{name:"exportOnlySelected",checked:m,onChange:k=>{c(k)}})}),Me(Bl,{label:h("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Me(Nl,{name:"exportBackgroundSwitch",checked:d,onChange:k=>{p(k),r.executeAction(Tu,"ui",k)}})}),mz&&Me(Bl,{label:h("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Me(Nl,{name:"exportDarkModeSwitch",checked:u,onChange:k=>{f(k),r.executeAction(vE,"ui",k)}})}),Me(Bl,{label:h("imageExportDialog.label.embedScene"),tooltip:h("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Me(Nl,{name:"exportEmbedSwitch",checked:b,onChange:k=>{x(k),r.executeAction(Ac,"ui",k)}})}),Me(Bl,{label:h("imageExportDialog.label.scale"),name:"exportScale",children:Me(Kd,{name:"exportScale",value:w,onChange:k=>{E(k),r.executeAction(wE,"ui",k)},choices:dz.map(k=>({value:k,label:`${k}\xD7`}))})}),Kr("div",{className:"ImageExportModal__settings__buttons",children:[Me(Hr,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.exportToPng"),onClick:()=>n(vf.png,R,{exportingFrame:L}),icon:bp,children:h("imageExportDialog.button.exportToPng")}),Me(Hr,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.exportToSvg"),onClick:()=>n(vf.svg,R,{exportingFrame:L}),icon:bp,children:h("imageExportDialog.button.exportToSvg")}),(pi||cz)&&Me(Hr,{className:"ImageExportModal__settings__buttons__button",label:h("imageExportDialog.title.copyPngToClipboard"),status:P,onClick:async()=>{await n(vf.clipboard,R,{exportingFrame:L}),S()},icon:Yn,children:h("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Bl=({label:e,children:o,tooltip:t,name:r})=>Kr("div",{className:"ImageExportModal__settings__setting",title:e,children:[Kr("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Me(po,{label:t,long:!0,children:i0})]}),Me("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),zI=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Xr(()=>({appStateSnapshot:OI(o),elementsSnapshot:OI(e)}));return Me(Ge,{onCloseRequest:i,size:"wide",title:!1,children:Me(uz,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import gz from"react";import{getFrame as fz}from"@haoxin-web/excalidraw-common";import Tf from"open-color";import{jsx as hz}from"react/jsx-runtime";var If=({children:e,color:o})=>hz("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":Tf[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":Tf[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":Tf[o][9]},children:e});import{Fragment as xz,jsx as wo,jsxs as wm}from"react/jsx-runtime";var bz=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return wo("div",{className:"ExportDialog ExportDialog--json",children:wm("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&wm(If,{color:"lime",children:[wo("div",{className:"Card-icon",children:wb}),wo("h2",{children:h("exportDialog.disk_title")}),wm("div",{className:"Card-details",children:[h("exportDialog.disk_details"),!Rn&&n.renderAction("changeProjectName")]}),wo(z,{className:"Card-button",type:"button",title:h("exportDialog.disk_button"),"aria-label":h("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(ja,"ui")}})]}),s&&wm(If,{color:"pink",children:[wo("div",{className:"Card-icon",children:va}),wo("h2",{children:h("exportDialog.link_title")}),wo("div",{className:"Card-details",children:h("exportDialog.link_details")}),wo(z,{className:"Card-button",type:"button",title:h("exportDialog.link_button"),"aria-label":h("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ae("export","link",`ui (${fz()})`),await s(e,o,r),l()}catch(m){t({errorMessage:m.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},HI=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=gz.useCallback(()=>{a({openDialog:null})},[a]);return wo(xz,{children:o.openDialog?.name==="jsonExport"&&wo(Ge,{onCloseRequest:l,title:h("buttons.export"),children:wo(bz,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import Ez from"clsx";import{jsx as GI,jsxs as wz}from"react/jsx-runtime";var yz="small",UI=e=>wz("label",{className:Ez("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${yz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[GI("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),GI("div",{className:"ToolIcon__icon",children:Yo})]});import{useState as ia,useRef as WI,useEffect as Fl}from"react";import{Palette as vz}from"lucide-react";import{jsx as lt,jsxs as vm}from"react/jsx-runtime";var Tz=[{value:"transparent",label:"\u767D\u8272\u80CC\u666F",color:"#ffffff",isTransparent:!0},{value:"#000000",label:"\u9ED1\u8272\u80CC\u666F",color:"#000000"},{value:"#22c55e",label:"\u7EFF\u8272\u80CC\u666F",color:"#22c55e"},{value:"#3b82f6",label:"\u84DD\u8272\u80CC\u666F",color:"#3b82f6"},{value:"#f59e0b",label:"\u6A59\u8272\u80CC\u666F",color:"#f59e0b"},{value:"#ef4444",label:"\u7EA2\u8272\u80CC\u666F",color:"#ef4444"}],YI=({appState:e,setAppState:o,actionManager:t,canvas:r})=>{let[n,i]=ia(!1),a=WI(null),[l,s]=ia(!1),[m,c]=ia(!1),[d,p]=ia([]),[u,f]=ia(null),b=WI(null),[x,w]=ia("#ff3b30");Fl(()=>{let L=localStorage.getItem("excalidraw-background-color");L&&L!==e.viewBackgroundColor&&t.executeAction(xc,"ui",{viewBackgroundColor:L}),w("#ff3b30")},[]);let E=L=>{localStorage.setItem("excalidraw-background-color",L)},y=L=>{let k=L==="transparent"?"#ffffff":L;t.executeAction(xc,"ui",{viewBackgroundColor:k}),E(k),i(!1)},v=()=>e.viewBackgroundColor||"transparent",C=()=>{p([])},S=(L,k)=>{let N={id:`trail-${Date.now()}-${Math.random()}`,x:L,y:k,timestamp:Date.now()};p(O=>[...O,N]),setTimeout(()=>{p(O=>O.filter(G=>G.id!==N.id))},3e3)},P=L=>{if(!r)return;let k=r.getBoundingClientRect(),N=L.clientX-k.left,O=L.clientY-k.top;f({x:N,y:O}),m&&S(N,O)},M=()=>{let L=!l;s(L),c(!1),L&&f(null),L?(o(k=>({...k,activeTool:{...k.activeTool,type:"laser",customType:null},cursorButton:"up"})),r&&(r.style.cursor="none")):(o(k=>({...k,activeTool:{...k.activeTool,type:"selection",customType:null}})),r&&(r.style.cursor="default"))},R=()=>{let L=!m;c(L),s(!1),L&&f(null),L?(o(k=>({...k,activeTool:{...k.activeTool,type:"laserTrail",customType:null,color:"transparent",backgroundColor:"transparent"},cursorButton:"up"})),r&&(r.style.cursor="none")):(o(k=>({...k,activeTool:{...k.activeTool,type:"selection",customType:null}})),r&&(r.style.cursor="default"))};return Fl(()=>{if((l||m)&&r)return r.addEventListener("mousemove",P),()=>{r.removeEventListener("mousemove",P)}},[l,m,r]),Fl(()=>{let L=e?.activeTool?.type;L!=="laser"&&L!=="laserTrail"&&(l||m)&&(s(!1),c(!1),r&&(r.style.cursor="default"))},[e?.activeTool?.type,l,m,r]),Fl(()=>()=>{b.current&&clearTimeout(b.current)},[]),Fl(()=>{if(!n)return;let L=k=>{let N=k.target;a.current&&N&&!a.current.contains(N)&&i(!1)};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[n]),vm("div",{className:"top-left-toolbar",children:[lt("div",{className:"top-left-toolbar__section",ref:a,children:vm("div",{className:"top-left-toolbar__group",style:{position:"relative"},children:[lt("button",{className:`top-left-toolbar__button ${n?"top-left-toolbar__button--active":""}`,onClick:()=>i(!n),title:"\u80CC\u666F\u8C03\u8272\u677F",children:lt(vz,{size:16})}),n&&lt("div",{className:"top-left-toolbar__palette",children:lt("div",{className:"top-left-toolbar__palette-grid",children:Tz.map(L=>lt("button",{className:`top-left-toolbar__color-button ${v()===L.value?"top-left-toolbar__color-button--active":""}`,onClick:()=>y(L.value),title:L.label,style:{backgroundColor:L.isTransparent?"#ffffff":L.color,border:L.isTransparent?"2px solid #e0e0e0":`2px solid ${L.color}`},children:L.isTransparent&&lt("div",{className:"top-left-toolbar__transparent-pattern",children:vm("svg",{width:"16",height:"16",viewBox:"0 0 16 16",children:[lt("defs",{children:vm("pattern",{id:"checkerboard",patternUnits:"userSpaceOnUse",width:"8",height:"8",children:[lt("rect",{width:"4",height:"4",fill:"#f0f0f0"}),lt("rect",{x:"4",y:"4",width:"4",height:"4",fill:"#f0f0f0"}),lt("rect",{x:"4",y:"0",width:"4",height:"4",fill:"#ffffff"}),lt("rect",{x:"0",y:"4",width:"4",height:"4",fill:"#ffffff"})]})}),lt("rect",{width:"16",height:"16",fill:"url(#checkerboard)",rx:"2"})]})})},L.value))})}),lt("button",{className:`top-left-toolbar__button ${m?"top-left-toolbar__button--active":""}`,onClick:R,title:"\u6FC0\u5149\u7B14",children:Yo})]})}),(l||m)&&r&&u&&lt("div",{className:"top-left-toolbar__laser-dot",style:{position:"fixed",left:u.x-4,top:u.y-4,width:8,height:8,borderRadius:"50%",backgroundColor:x,pointerEvents:"none",zIndex:1e3,boxShadow:`0 0 8px ${x}99`}}),m&&d.length>0&&lt("svg",{className:"top-left-toolbar__laser-trails",style:{position:"fixed",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:999},children:d.map((L,k)=>{let N=Date.now()-L.timestamp,O=Math.max(0,1-N/3e3);return lt("circle",{cx:L.x,cy:L.y,r:3,fill:x,opacity:O},L.id)})})]})};import{Fragment as ZI,jsx as ee,jsxs as vo}from"react/jsx-runtime";var Lz=({UIOptions:e})=>vo(ft,{__fallback:!0,children:[ee(ft.DefaultItems.LoadScene,{}),ee(ft.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ee(ft.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ee(ft.DefaultItems.SaveAsImage,{}),ee(ft.DefaultItems.SearchMenu,{}),ee(ft.DefaultItems.Help,{}),ee(ft.DefaultItems.ClearCanvas,{}),ee(ft.Separator,{}),ee(ft.Group,{title:"Excalidraw links",children:ee(ft.DefaultItems.Socials,{})}),ee(ft.Separator,{}),ee(ft.DefaultItems.ToggleTheme,{}),ee(ft.DefaultItems.ChangeCanvasBackground,{})]}),Pz=()=>vo(qd,{__fallback:!0,children:[ee(qd.Actions.SaveToDisk,{}),ee(qd.Actions.ExportToImage,{})]}),Az=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:m,renderTopRightUI:c,renderCustomStats:d,UIOptions:p,onExportImage:u,renderWelcomeScreen:f,children:b,app:x,isCollaborating:w,generateLinkForSelection:E,showZoomActions:y,showPanActions:v,showToolBar:C=!0,showTopLeftToolbar:S=!0})=>{let P=pe(),M=Bw(),R=M.tunnelsJotai.Provider,[L,k]=ce(Er),N=()=>p.canvasActions.export?ee(HI,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,O=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:ee(zI,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),G=()=>vo("div",{style:{position:"relative"},children:[ee(M.MainMenuTunnel.Out,{}),f&&ee(M.WelcomeScreenMenuHintTunnel.Out,{})]}),_=()=>o.viewModeEnabled||o.openDialog?.name==="elementLinkSelector"||!C?null:ee(Il,{side:"left",children:ee("div",{className:"App-menu App-menu_left",children:ee(In,{heading:"shapes",className:"shapes-section-left",children:q=>vo("div",{style:{position:"relative"},children:[f&&ee(M.WelcomeScreenToolbarHintTunnel.Out,{}),vo(Ue.Col,{gap:4,align:"center",children:[ee(n3,{appState:o,app:x,visible:C,onHandToolToggle:l,showPanActions:v}),w&&ee(De,{style:{marginTop:8,alignSelf:"center",width:"fit-content"},children:ee(UI,{title:h("toolBar.laser"),checked:o.activeTool.type===XI.laser,onChange:()=>x.setActiveTool({type:XI.laser}),isMobile:!1})})]})]})})})}),B=()=>{let q=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return ee(Il,{side:"top",children:vo("div",{className:"App-menu App-menu_top",children:[ee(Ue.Col,{gap:6,className:VI("App-menu_top__left"),style:{display:"none"},children:G()}),vo("div",{className:VI("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),style:{display:"none"},children:[o.collaborators.size>0&&ee(Sl,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),c?.(P.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!j||o.openSidebar?.name!==Cf.name)&&ee(M.DefaultSidebarTriggerTunnel.Out,{}),q&&ee(Rl,{app:x,onClose:()=>{e.executeAction(vi)},renderCustomStats:d})]})]})})},K=()=>ee(em,{__fallback:!0,onDock:q=>{ae("sidebar",`toggleDock (${q?"dock":"undock"})`,`(${P.editor.isMobile?"mobile":"desktop"})`)}}),j=hs(kl),X=vo(ZI,{children:[b,ee(Lz,{UIOptions:p}),ee(em.Trigger,{__fallback:!0,icon:zn,title:Sz(h("toolBar.library")),onToggle:q=>{q&&ae("sidebar",`${Cf.name} (open)`,`button (${P.editor.isMobile?"mobile":"desktop"})`)},tab:Cf.defaultTab,children:h("toolBar.library")}),ee(Pz,{}),o.openDialog?.name==="ttd"&&ee(tf,{__fallback:!0}),o.isLoading&&ee(Wd,{delay:250}),o.errorMessage&&ee(PI,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),L&&!P.editor.isMobile&&ee($0,{colorPickerType:L.colorPickerType,onCancel:()=>{k(null)},onChange:(q,se,ie,{altKey:be})=>{if(!(q!=="elementBackground"&&q!=="elementStroke"))if(ie.length){for(let ue of ie)kz(ue,Cz(n),{[be&&L.swapPreviewOnAlt?q==="elementBackground"?"strokeColor":"backgroundColor":q==="elementBackground"?"backgroundColor":"strokeColor"]:se}),Mz.delete(ue);x.scene.triggerUpdate()}else r(q==="elementBackground"?{currentItemBackgroundColor:se}:{currentItemStrokeColor:se})},onSelect:(q,se)=>{k(ie=>ie?.keepOpenOnAlt&&se.altKey?ie:null),L?.onSelect?.(q,se)}}),o.openDialog?.name==="help"&&ee(DI,{onClose:()=>{r({openDialog:null})}}),ee(Vw,{}),o.openDialog?.name==="elementLinkSelector"&&ee(LI,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:E}),ee(M.OverwriteConfirmDialogTunnel.Out,{}),O(),N(),o.pasteDialog.shown&&ee(b3,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),P.editor.isMobile&&ee(g3,{app:x,appState:o,elements:n,actionManager:e,renderJSONExportDialog:N,renderImageExportDialog:O,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:c,renderCustomStats:d,renderSidebars:K,device:P,renderWelcomeScreen:f,UIOptions:p,showPanActions:v}),!P.editor.isMobile&&vo(ZI,{children:[vo("div",{className:"layer-ui__wrapper",style:o.openSidebar&&j&&P.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&ee(M.WelcomeScreenCenterTunnel.Out,{}),_(),B(),ee(T3,{appState:o,actionManager:e,showExitZenModeBtn:m,renderWelcomeScreen:f,showZoomActions:y}),o.scrolledOutside&&ee("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(q=>({...tn(n,q)}))},children:h("buttons.scrollBackToContent")})]}),K()]})]});return ee(_p.Provider,{value:o,children:ee(R,{children:vo(Ah.Provider,{value:M,children:[X,!o.viewModeEnabled&&C&&ee(nT,{appState:o,app:x,actionManager:e,elements:n,showToolBar:C}),!P.editor.isMobile&&!o.viewModeEnabled&&S&&ee(YI,{appState:o,setAppState:r,actionManager:e,canvas:i})]})})})},KI=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},_z=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return Tm(KI(r),KI(a),{selectedElementIds:Tm,selectedGroupIds:Tm})&&Tm(n,l)},$I=Iz.memo(Az,_z);import Dz from"clsx";import{jsx as jI,jsxs as Nz}from"react/jsx-runtime";var Rz="small",Im=e=>Nz("label",{className:Dz("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${Rz}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[jI("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),jI("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as Bz,useRef as Fz}from"react";import{jsx as qI}from"react/jsx-runtime";var JI=({trails:e})=>{let o=Fz(null);return Bz(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),qI("div",{className:"SVGLayer",children:qI("svg",{ref:o})})};import Oz,{useEffect as zz,useRef as Hz}from"react";import{CURSOR_TYPE as QI,isShallowEqual as Gz,sceneCoordsToViewportCoords as Uz}from"@haoxin-web/excalidraw-common";import{jsx as Vz}from"react/jsx-runtime";var Wz=e=>{let o=Hz(!1);return zz(()=>{if(!o.current){o.current=!0;return}let t=new Map,r=new Map,n=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,m)=>{if(s.selectedElementIds)for(let c of Object.keys(s.selectedElementIds))n.has(c)||n.set(c,[]),n.get(c).push(m);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(m,s.username),s.userState&&a.set(m,s.userState),r.set(m,Uz({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(m,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";Tv({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:t,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Ki())}),Vz("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?QI.GRAB:QI.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:h("labels.drawingCanvas")})},e5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,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}),Yz=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:Gz(e5(e.appState),e5(o.appState)),Sf=Oz.memo(Wz,Yz);import Xz,{useEffect as t5,useRef as o5}from"react";import{isShallowEqual as r5}from"@haoxin-web/excalidraw-common";import{jsx as $z}from"react/jsx-runtime";var Kz=e=>{let o=o5(null),t=o5(!1);return t5(()=>{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]),t5(()=>{let r=o.current;if(!r)return;let n=e.canvas;t.current||(t.current=!0,r.replaceChildren(n),n.classList.add("excalidraw__canvas","static")),O1({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Ki())}),$z("div",{className:"excalidraw__canvas-wrapper",ref:o})},n5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,hoveredElementIds:e.hoveredElementIds,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,shouldCacheIgnoreZoom:e.shouldCacheIgnoreZoom,viewBackgroundColor:e.viewBackgroundColor,exportScale:e.exportScale,selectedElementsAreBeingDragged:e.selectedElementsAreBeingDragged,gridSize:e.gridSize,gridStep:e.gridStep,frameRendering:e.frameRendering,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,editingGroupId:e.editingGroupId,currentHoveredFontFamily:e.currentHoveredFontFamily,croppingElementId:e.croppingElementId}),Zz=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:r5(n5(e.appState),n5(o.appState))&&r5(e.renderConfig,o.renderConfig),kf=Xz.memo(Kz,Zz);import{useEffect as oH,useRef as rH}from"react";import{throttleRAF as jz}from"@haoxin-web/excalidraw-common";import{getTargetFrame as qz,isInvisiblySmallElement as Jz,renderElement as Qz,shouldApplyFrameClip as eH}from"@haoxin-web/excalidraw-element";var i5=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,m]=ls(e,i),c=ss({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:m});if(c.save(),c.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(Jz(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=qz(t,r,a);p&&eH(t,p,a,r)&&B1(p,c,l,a)}Qz(t,r,n,o,c,l,a)}else c.clearRect(0,0,s,m);c.restore()}},tH=jz(e=>{i5(e)},{trailing:!0}),a5=(e,o)=>{if(o){tH(e);return}i5(e)};import{jsx as iH}from"react/jsx-runtime";var nH=e=>{let o=rH(null);return oH(()=>{o.current&&a5({canvas:o.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Ki())}),iH("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},l5=nH;import{useCallback as aH,useEffect as lH,useRef as sH}from"react";import{jsx as s5,jsxs as dH}from"react/jsx-runtime";var cH=5e3,c5=({message:e,onClose:o,closable:t=!1,duration:r=cH,style:n})=>{let i=sH(0),a=r!==1/0,l=aH(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return lH(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),dH("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[s5("p",{className:"Toast__message",children:e}),t&&s5(z,{icon:Vt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as mH,getElementsInGroup as pH,selectGroupsFromGivenElements as uH}from"@haoxin-web/excalidraw-element";import{sceneCoordsToViewportCoords as hH}from"@haoxin-web/excalidraw-common";import{flushSync as gH}from"react-dom";import{jsx as bH}from"react/jsx-runtime";var fH=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),r=t?[t]:pH(e.scene.getNonDeletedElementsMap(),o);if(r.length===0)return null;let[n,i]=mH(r),{x:a,y:l}=hH({sceneX:n,sceneY:i},e.state);return bH("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{gH(()=>{let s=uH(r,e.state);e.setState({selectedElementIds:r.reduce((m,c)=>({...m,[c.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(tl)},title:h("labels.elementLock.unlock"),children:ib})},d5=fH;import{Fragment as uU,jsx as fe,jsxs as _m}from"react/jsx-runtime";var pC=Ho.createContext(null),uC=Ho.createContext(null),hC={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},a1=Ho.createContext(hC);a1.displayName="DeviceContext";var l1=Ho.createContext({container:null,id:null});l1.displayName="ExcalidrawContainerContext";var s1=Ho.createContext([]);s1.displayName="ExcalidrawElementsContext";var c1=Ho.createContext({...mr(),width:0,height:0,offsetLeft:0,offsetTop:0});c1.displayName="ExcalidrawAppStateContext";var d1=Ho.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});d1.displayName="ExcalidrawSetAppStateContext";var m1=Ho.createContext(null);m1.displayName="ExcalidrawActionManagerContext";var Oe=()=>Qr(pC),Lo=()=>Qr(uC),pe=()=>Qr(a1),Xe=()=>Qr(l1),yr=()=>Qr(s1),Mo=()=>Qr(c1),me=()=>Qr(d1),Ke=()=>Qr(m1),Vl=!1,e1=0,Xl=null,Pn=!1,Kl=!1,t1=!1,Zl={horizontal:null,vertical:null},Jr=0,$l=!1,o1=new Map,r1=!1,sC=0,cC=!1,jl=null,ge={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},i1=class e extends Ho.Component{constructor(t){super(t);I(this,"canvas");I(this,"interactiveCanvas",null);I(this,"rc");I(this,"unmounted",!1);I(this,"actionManager");I(this,"device",hC);I(this,"excalidrawContainerRef",Ho.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"resizeObserver");I(this,"nearestScrollableContainer");I(this,"library");I(this,"libraryItemsFromStorage");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"handleToastClose",()=>{this.setToast(null)});I(this,"elementsPendingErasure",new Set);I(this,"flowChartCreator",new HG);I(this,"flowChartNavigator",new GG);I(this,"hitLinkElement");I(this,"lastPointerDownEvent",null);I(this,"lastPointerUpEvent",null);I(this,"lastPointerMoveEvent",null);I(this,"lastPointerMoveCoords",null);I(this,"lastViewportPosition",{x:0,y:0});I(this,"animationFrameHandler",new Md);I(this,"laserTrails",new Fd(this.animationFrameHandler,this));I(this,"eraserTrail",new Gd(this.animationFrameHandler,this));I(this,"lassoTrail",new Hd(this.animationFrameHandler,this));I(this,"onChangeEmitter",new kn);I(this,"onPointerDownEmitter",new kn);I(this,"onPointerUpEmitter",new kn);I(this,"onUserFollowEmitter",new kn);I(this,"onScrollChangeEmitter",new kn);I(this,"missingPointerEventCleanupEmitter",new kn);I(this,"onRemoveEventListenersEmitter",new kn);I(this,"defaultSelectionTool","selection");I(this,"updateEditorAtom",(t,...r)=>{let n=Ve.set(t,...r);return this.triggerRender(),n});I(this,"getEffectiveGridSize",()=>Nr(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),Yl.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(lr(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=Vf(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else da(n)&&t.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(this,"frameNameBoundsCache",{get:t=>{let r=this.frameNameBoundsCache._cache.get(t.id);if(!r||r.zoom!==this.state.zoom.value||r.versionNonce!==t.versionNonce){let n=document.getElementById(this.getFrameNameDOMId(t));if(n){let i=n.getBoundingClientRect(),a=We({clientX:i.x,clientY:i.y},this.state),l=We({clientX:i.right,clientY:i.bottom},this.state);return r={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===km.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&Rt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return r.map(i=>{if(!G5(i,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===i.id&&this.resetEditingFrame(i),null;let{x:a,y:l}=Lm({sceneX:i.x,sceneY:i.y},this.state),s=6,m,c=RG(i);if(i.id===this.state.editingFrame){let d=c;m=fe("input",{autoFocus:!0,value:d,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:this.state.viewBackgroundColor,filter:t?FH:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${$r.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:d.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else m=c;return fe("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+$r.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:$r.nameFontSize,color:t?$r.nameColorDarkTheme:$r.nameColorLightTheme,lineHeight:$r.nameLineHeight,width:"max-content",maxWidth:n?.id===i.id&&n?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Be.MOVE,pointerEvents:this.state.viewModeEnabled?la.disabled:la.enabled},onPointerDown:d=>this.handleCanvasPointerDown(d),onWheel:d=>this.handleWheel(d),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:m},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,r,n)=>{ae("export",t,"ui");let i=await un(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(QH).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&ds(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:r}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,r),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:bt.magicframe}),ae("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&Wf(t[0])&&t[0];if(!r&&t.some(i=>Rt(i)||i.frameId)){this.setActiveTool({type:bt.magicframe});return}ae("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=ca(t),m=50;n=D5({...$r,x:i-m,y:a-m,width:l-i+m*2,height:s-a+m*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let c of t)this.scene.mutateElement(c,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});I(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(Er,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=t==="background"&&n.altKey||t==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:Ct.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:Ct.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?qr(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:Ct.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Ae(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||km.LIGHT,s=t?.appState?.name??this.state.name,m=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(c=>{n?.id===c.id&&n!==c&&nC(c)&&To(c)&&(n=c)}),n?.isDeleted&&(n=null),this.setState(c=>{let d=t.appState||{};return{...c,...d,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:m}}),r=!0}r||this.scene.triggerUpdate()}));I(this,"onBlur",Ae(()=>{Pn=!1,this.setState({isBindingEnabled:!0})}));I(this,"onUnload",()=>{this.onBlur()});I(this,"disableEvent",t=>{t.preventDefault()});I(this,"resetHistory",()=>{this.history.clear()});I(this,"resetStore",()=>{this.store.clear()});I(this,"resetScene",Ae(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...mr(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async i=>{if(!i.files.length)return;let a=i.files[0],l=await a.getFile();this.loadFileToCanvas(new File([l],l.name||"",{type:l.type}),a)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(i=>{console.error(i)})}catch(i){console.error(i),t={appState:{errorMessage:i.message||"Encountered an error during importing or restoring scene data"}}}let r=Bn(t,null,null,{repairBindings:!0,deleteInvisibleElements:!0}),n=r.appState.activeTool;r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:n.type==="image"||n.type==="lasso"||n.type==="selection"?{...n,type:this.defaultSelectionTool}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...tn(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,captureUpdate:Ct.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(i=>{this.fonts.onLoaded(i)}),Jf(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileOrTablet",()=>{let t="ontouchstart"in window||navigator.maxTouchPoints>0,r="matchMedia"in window&&window?.matchMedia("(pointer: coarse)")?.matches;return iG||t&&r});I(this,"isMobileBreakpoint",(t,r)=>t<_H||r<PH&&t<AH);I(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=Nf(i,{isLandscape:r>n,isMobile:this.isMobileBreakpoint(r,n)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});I(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:r,height:n}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:DH,a=this.device.editor,l=Nf(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",Ae(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Yl.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),v5||this.refreshEditorBreakpoints(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:n})=>{r&&(Zl=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",C5(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},RH));I(this,"onCut",Ae(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||zl(t.target)||(this.actionManager.executeAction(Hc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Ae(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||zl(t.target)||(this.actionManager.executeAction(yi,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(GH&&t.preventDefault(),!Vl){Vl=!0,t.touches.length===1&&(Xl={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(e1),e1=window.setTimeout(e.resetTapTwice,NH);return}if(Vl&&t.touches.length===1&&Xl){let r=t.touches[0];Zr(le(r.clientX,r.clientY),le(Xl.x,Xl.y))<=aG&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY})),Vl=!1,clearTimeout(e1)}t.touches.length===2&&this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ve(this.state.previousSelectedElementIds,this.state)}):ge.pointers.clear()});I(this,"pasteFromClipboard",Ae(async t=>{let r=!!r1,n=document.activeElement,i=this.excalidrawContainerRef.current?.contains(n);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||zl(n)))return;let l=await $a(t),s=l.getFiles(),m=await xE(l,r);if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(c){console.error(c)}await this.insertClipboardContent(m,s,r),this.setActiveTool({type:this.defaultSelectionTool},!0),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let r=Km(t.elements,null,{deleteInvisibleElements:!0}),[n,i,a,l]=ca(r),s=sa(n,a)/2,m=sa(i,l)/2,c=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,d=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=We({clientX:c,clientY:d},this.state),f=p-s,b=u-m,[x,w]=st(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=B5({type:"everything",elements:r.map(M=>qr(M,{x:M.x+x-n,y:M.y+w-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...E];v=this.props.onDuplicate?.(v,y)||v,Q5(v,Pm(E));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let M=BG(E,S);$f(v,M,S,this.state)}this.scene.replaceAllElements(v),E.forEach(M=>{if(To(M)&&Uf(M)){let R=X5(M,this.scene.getElementsMapIncludingDeleted());MG(M,R,this.scene)}}),YH&&dr.loadElementsFonts(E).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files);let P=oU(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&Ve.get(kl)?this.state.openSidebar:null,...no({editingGroupId:null,selectedElementIds:P.reduce((M,R)=>(Uf(R)||(M[R.id]=!0),M),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.defaultSelectionTool},!0),t.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,r)=>{this.setState(t,r)});I(this,"removePointer",t=>{Jr&&this.resetContextMenuTimer(),ge.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||ae("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...ar(this.state,r.activeTool.locked?{type:this.defaultSelectionTool}:r.activeTool),locked:!r.activeTool.locked}}))});I(this,"updateFrameRendering",t=>{this.setState(r=>{let n=typeof t=="function"?t(r.frameRendering):t;return{frameRendering:{enabled:n?.enabled??r.frameRendering.enabled,clip:n?.clip??r.frameRendering.clip,name:n?.name??r.frameRendering.name,outline:n?.outline??r.frameRendering.outline}}})});I(this,"togglePenMode",t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))});I(this,"onHandToolToggle",()=>{this.actionManager.executeAction(Xx)});I(this,"zoomCanvas",t=>{this.setState({...Zo({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:Co(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(Jf(t)?s=YG(t):s=t,s){let m=this.scene.getElementsFromId(s);m?.length?this.scrollToContent(m,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):Jf(t)&&this.setState({toast:{message:h("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=di({canvasOffsets:r.canvasOffsets,targetElements:n,appState:this.state,fitToViewport:!!r?.fitToViewport,viewportZoomFactor:r?.viewportZoomFactor,minZoom:r?.minZoom,maxZoom:r?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=tn(n,this.state);a=s.scrollX,l=s.scrollY}if(r?.animate){let s=this.state.scrollX,m=this.state.scrollY,c=this.state.zoom.value,d=JH({fromValues:{scrollX:s,scrollY:m,zoom:c},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,eG(f))},onStep:({scrollX:p,scrollY:u,zoom:f})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});I(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});I(this,"translateCanvas",(t,r)=>{if(this.props.showPanActions===!1){if(typeof t=="function"){let n=i=>{let a=t(i);return a.scrollX!==i.scrollX||a.scrollY!==i.scrollY?i:a};this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(n,r);return}else if(t.scrollX!==void 0||t.scrollY!==void 0)return}this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t,r)});I(this,"setToast",t=>{this.setState({toast:t})});I(this,"restoreFileFromShare",async()=>{try{let t=await caches.open("web-share-target"),r=await t.match("shared-file");if(r){let n=await r.blob(),i=new File([n],n.name||"",{type:n.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,TH,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Ae(t=>{let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));I(this,"addMissingFiles",(t,r=!1)=>{let n=r?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!n[l.id]&&(i[l.id]=l,n[l.id]=l,l.mimeType===ir.svg))try{let s=X1(V5(K1(l.dataURL)),ir.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});I(this,"updateScene",Ae(t=>{let{elements:r,appState:n,collaborators:i,captureUpdate:a}=t;if(a){let l=r||void 0,s=n?lG({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}n&&this.setState(n),r&&this.scene.replaceAllElements(r),i&&this.setState({collaborators:i})}));I(this,"_currentUpdateSource","default");I(this,"updateSceneSilently",Ae(t=>{this._currentUpdateSource="updateSceneSilently";try{this.updateScene(t)}finally{this._currentUpdateSource="default"}}));I(this,"applyDeltas",(t,r)=>{let n=aC.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return aC.applyTo(n,a,i,r)});I(this,"mutateElement",(t,r,n=!0)=>this.scene.mutateElement(t,r,{informMutation:n,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:i=n?t:null;let a=i?{name:i}:null;return a&&r&&(a.tab=r),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",Ae(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));I(this,"getEditorUIOffsets",()=>{let t=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,r=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Uo().rtl?{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width),0)+i,bottom:i,left:Math.max(r?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width)+i,0),bottom:i,left:Math.max(n?.right??0,0)+i}});I(this,"zoomToFit",()=>{console.log("\u{1F50D} \u8C03\u7528 zoomToFit \u65B9\u6CD5");let t=di({targetElements:this.scene.getNonDeletedElements(),appState:{...this.state,userToFollow:null},fitToViewport:!1,canvasOffsets:{}});t?(console.log("\u2705 zoomToFit \u6210\u529F\u6267\u884C\uFF0C\u66F4\u65B0\u573A\u666F"),this.updateScene(t)):console.log("\u26A0\uFE0F zoomToFit \u6CA1\u6709\u8FD4\u56DE\u7ED3\u679C\uFF0C\u53EF\u80FD\u6CA1\u6709\u5143\u7D20\u9700\u8981\u7F29\u653E")});I(this,"onKeyDown",Ae(t=>{if("Proxy"in window&&(!t.shiftKey&&/^[A-Z]$/.test(t.key)||t.shiftKey&&/^[a-z]$/.test(t.key))&&(t=new Proxy(t,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?t.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!S5(t.target)){if((t.key===V.ESCAPE||t.key===V.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=J(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&Mn(a[0])&&t.key===V.ENTER){this.startImageCropping(a[0]);return}if(t.key===V.ESCAPE)this.updateEditorAtom(xo,null);else if(t.key===V.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(nG.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=Mi(a);Ve.get(xo)?.type==="panel"&&sh(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(xo,{type:"panel"})}if(t.key===V.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Cm(t.key);if(t[V.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=J(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&yG(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,j5(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!Yf(this.flowChartCreator.pendingNodes,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(this.flowChartCreator.pendingNodes,{animate:!0,duration:300,fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()});return}if(t.altKey){let s=J(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){t.preventDefault();let m=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),j5(t.key));if(m){this.setState(d=>({selectedElementIds:ve({[m]:!0},d)}));let c=this.scene.getNonDeletedElementsMap().get(m);c&&!Yf([c],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(c,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[V.CTRL_OR_CMD]&&t.key===V.P&&!t.shiftKey&&!t.altKey){this.setToast({message:h("commandPalette.shortcutHint",{shortcut:He("commandPalette")})}),t.preventDefault();return}if(t[V.CTRL_OR_CMD]&&t.key.toLowerCase()===V.V&&(r1=t.shiftKey,clearTimeout(sC),sC=window.setTimeout(()=>{r1=!1},100)),t[V.CTRL_OR_CMD]&&zl(t.target)&&(t.code===b5.MINUS||t.code===b5.EQUAL)){t.preventDefault();return}if(zl(t.target)&&t.key!==V.ESCAPE||Cm(t.key)&&S5(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(t.key===V.PAGE_UP||t.key===V.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===V.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[V.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Cm(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(je),s=new Set;a.filter(je).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),f=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||f}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let m=this.getEffectiveGridSize()&&(t.shiftKey?y5:this.getEffectiveGridSize())||(t.shiftKey?SH:y5),c=0,d=0;t.key===V.ARROW_LEFT?c=-m:t.key===V.ARROW_RIGHT?c=m:t.key===V.ARROW_UP?d=-m:t.key===V.ARROW_DOWN&&(d=m),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+c,y:p.y+d},{informMutation:!1,isDragging:!1}),Of(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:zf(a.filter(p=>p.id!==l?.id||m!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===V.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[V.CTRL_OR_CMD]||Qf(l))ro(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),je(l)||this.actionManager.executeAction(Wi));else if(To(l)||kG(l)){let s;To(l)||(s=l);let m=Kf(l,this.state,this.scene.getNonDeletedElementsMap()),c=m.x,d=m.y;this.startTextEditing({sceneX:c,sceneY:d,container:s}),t.preventDefault();return}else Rt(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=Nw(t.key,this);a?(this.state.activeTool.type!==a&&ae("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===jr.sharp?jr.round:l.currentItemArrowType===jr.round?jr.elbow:jr.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===V.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===V.SPACE&&ge.pointers.size===0&&this.props.showPanActions!==!1&&(Pn=!0,ye(this.interactiveCanvas,Be.GRAB),t.preventDefault()),(t.key===V.G||t.key===V.S)&&!t.altKey&&!t[V.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===V.G&&(cr(this.state.activeTool.type)||a.some(l=>cr(l.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 a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>To(l)||Xf(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===V.K&&!t.altKey&&!t[V.CTRL_OR_CMD]){this.state.activeTool.type==="laser"||this.state.activeTool.type==="laserTrail"?this.setActiveTool({type:this.defaultSelectionTool}):this.setActiveTool({type:"laser"});return}t[V.CTRL_OR_CMD]&&(t.key===V.BACKSPACE||t.key===V.DELETE)&&this.updateEditorAtom(En,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===V.S&&t.shiftKey,i=t.key===V.I||r===V.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));I(this,"onKeyUp",Ae(t=>{if(t.key===V.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,Be.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Zt(this.interactiveCanvas):(Ot(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Pn=!1),!t[V.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Cm(t.key)&&(A5(this.scene.getSelectedElements(this.state).filter(ro),Ff(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:Ct.IMMEDIATELY})),!t[V.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:ve({[r.id]:!0},n)})),Yf([r],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(r,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:Ct.IMMEDIATELY})}}));I(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);I(this,"setActiveTool",(t,r=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let n=ar(this.state,t);n.type==="hand"?ye(this.interactiveCanvas,Be.GRAB):Pn||Ot(this.interactiveCanvas,{...this.state,activeTool:n}),ZH(document.activeElement)&&this.focusContainer(),xG(n.type)||this.setState({suggestedBindings:[]}),n.type==="image"&&this.onImageToolbarButtonClick(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};return n.type==="freedraw"&&this.store.scheduleCapture(),n.type==="lasso"?{...i,activeTool:n,...r?{}:{selectedElementIds:ve({},i),selectedGroupIds:ve({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:ve({},i),selectedGroupIds:ve({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{ye(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{Zt(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>ge.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${h("labels.untitled")}-${k5()}`);I(this,"onGestureStart",Ae(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null}),ge.initialScale=this.state.zoom.value}));I(this,"onGestureChange",Ae(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=ge.initialScale;r&&this.setState(n=>({...Zo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Co(r*t.scale)},n)}))}));I(this,"onGestureEnd",Ae(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ve(this.state.previousSelectedElementIds,this.state)}),ge.initialScale=null}));I(this,"startTextEditing",({sceneX:t,sceneY:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i);i&&s&&(Xf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let m=null,c=this.scene.getSelectedElements(this.state);c.length===1?To(c[0])?m=c[0]:i?m=Xf(c[0],this.scene.getNonDeletedElementsMap()):m=this.getTextElementAtPosition(t,r):m=this.getTextElementAtPosition(t,r);let d=m?.fontFamily||this.state.currentItemFontFamily,p=m?.lineHeight||I5(d),u=this.state.currentItemFontSize;if(!m&&l&&i&&!Hf(i)){let w=ZG(Df({fontSize:u,fontFamily:d}),p),E=$G(u,p),y=Math.max(i.height,E),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:y,width:v}),t=i.x+v/2,r=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=m||R5({x:s?s.elementCenterX:t,y:s?s.elementCenterY:r,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:d,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?zH.MIDDLE:E5,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?Hf(i)?0:i.angle:0,frameId:f?f.id:null,customData:{textStyle:{bold:this.state.currentTextBold||!1,italic:this.state.currentTextItalic||!1,underline:this.state.currentTextUnderline||!1,strikethrough:this.state.currentTextStrikethrough||!1}}});if(!m&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!m)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||m||i?this.handleTextWysiwyg(b,{isExistingElement:!!m}):this.setState({newElement:b,multiElement:null})});I(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.defaultSelectionTool)return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=We(t,this.state);if(r.length===1&&ro(r[0])){let l=r[0];if((t[V.CTRL_OR_CMD]&&mU(l)||Qf(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(Wi);return}else if(this.state.selectedLinearElement&&je(r[0])){let s=Le.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=s?Le.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(m&&m>-1){this.store.scheduleCapture(),Le.deleteFixedSegment(r[0],this.scene,m);let c=Le.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=c?Le.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:d,value:s,added:!1}},segmentMidPointHoveredCoords:c}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&Qf(l))return}if(r.length===1&&Mn(r[0])){this.startImageCropping(r[0]);return}if(Zt(this.interactiveCanvas),eU(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&QG(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(m=>({...m,...no({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),m,this)}));return}}if(Zt(this.interactiveCanvas),!t[V.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(Ul(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(F5(s)||!qH(s.backgroundColor)||Wl({point:le(n,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let m=Kf(s,this.state,this.scene.getNonDeletedElementsMap());n=m.x,i=m.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});I(this,"getElementLinkAtPosition",(t,r)=>{if(r&&r.locked)return;let n=this.scene.getNonDeletedElements(),i=-1;for(let a=n.length-1;a>=0;a--){let l=n[a];if(r&&l.id===r.id&&(i=a),l.link&&a>=i&&as(l,this.scene.getNonDeletedElementsMap(),this.state,le(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,r)=>{let n=Zr(le(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),le(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>CH)return;let i=We(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=as(this.hitLinkElement,a,this.state,le(i.x,i.y),this.device.editor.isMobile),s=We(this.lastPointerUpEvent,this.state),m=as(this.hitLinkElement,a,this.state,le(s.x,s.y),this.device.editor.isMobile);if(l&&m){qu();let c=this.hitLinkElement.link;if(c){c=_f(c);let d;if(this.props.onLinkOpen&&(d=$H(oe.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:c},d)),!d?.defaultPrevented){let p=VH(c)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=c)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&K5(t,i,r));return n.length?n[n.length-1]:null});I(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,ge.pointers.has(t.pointerId)&&ge.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=ge.initialScale;if(ge.pointers.size===2&&ge.lastCenter&&r&&ge.initialDistance){let f=cg(ge.pointers),b=f.x-ge.lastCenter.x,x=f.y-ge.lastCenter.y;ge.lastCenter=f;let w=dg(Array.from(ge.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/ge.initialDistance,y=E?Co(r*E):this.state.zoom.value;this.setState(v=>{let C=Zo({viewportX:f.x,viewportY:f.y,nextZoom:y},v);this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(b/y),scrollY:C.scrollY+2*(x/y),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else ge.lastCenter=ge.initialDistance=ge.initialScale=null;if(Pn||Kl||t1||lo(this.state))return;let i=fg(Zl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Zt(this.interactiveCanvas):Ot(this.interactiveCanvas,this.state));let a=We(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&tv(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=ev(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let w=Hl(x.snapLines,b),E=x.originSnapOffset?Hl(x.originSnapOffset,f):f;return x.snapLines===w&&x.originSnapOffset===E?null:{snapLines:w,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let f=Le.handlePointerMove(t,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&aa(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&O5(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(O5(this.state.activeTool.type)){let{newElement:f}=this.state;Gf(f,!1)?this.setState({suggestedBindings:L5(f,[a],this.scene,this.state.zoom,this.state.startBoundElement)}):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:f}=this.state,{x:b,y:x}=f,{points:w,lastCommittedPoint:E}=f,y=w[w.length-1];if(Ot(this.interactiveCanvas,this.state),y===E)Zr(le(l-b,s-x),y)>=Af?this.scene.mutateElement(f,{points:[...w,le(l-b,s-x)]},{informMutation:!1,isDragging:!1}):ye(this.interactiveCanvas,Be.POINTER);else if(w.length>2&&E&&Zr(le(l-b,s-x),E)<Af)ye(this.interactiveCanvas,Be.POINTER),this.scene.mutateElement(f,{points:w.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,C]=st(l,s,t[V.CTRL_OR_CMD]||je(f)?null:this.getEffectiveGridSize()),[S,P]=f?.lastCommittedPoint??[0,0],M=v-b-S,R=C-x-P;Pf(t)&&({width:M,height:R}=H5(S+b,P+x,v,C)),W5(w,this.state.zoom.value)&&ye(this.interactiveCanvas,Be.POINTER),this.scene.mutateElement(f,{points:[...w.slice(0,-1),le(S+M,P+R)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let c=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!i&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&je(d[0]))){let f=tC(c,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){ye(this.interactiveCanvas,eC(f));return}}}else if(d.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=oC(ca(d),l,s,this.state.zoom,t.pointerType,this.device);if(f){ye(this.interactiveCanvas,eC({transformHandleType:f}));return}}let p=this.getElementAtPosition(l,s,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p,this.hitLinkElement=this.getElementLinkAtPosition(a,p),!St(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(ye(this.interactiveCanvas,Be.POINTER),gy(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(qu(),u&&(u.link||lr(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?ye(this.interactiveCanvas,To(u)?Be.TEXT:Be.CROSSHAIR):this.state.viewModeEnabled?ye(this.interactiveCanvas,Be.GRAB):this.state.openDialog?.name==="elementLinkSelector"?ye(this.interactiveCanvas,Be.AUTO):i?ye(this.interactiveCanvas,Be.AUTO):t[V.CTRL_OR_CMD]?ye(this.interactiveCanvas,Be.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,d))&&!u?.locked&&(u&&Ul(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(ye(this.interactiveCanvas,Be.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!je(u)||!(u.startBinding||u.endBinding))&&((this.state.activeTool.type!=="lasso"||d.length>0)&&ye(this.interactiveCanvas,Be.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}))),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s)),this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(f=>({hoveredElementIds:Hl(f.hoveredElementIds,no({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:Hl(f.hoveredElementIds,{})})))});I(this,"handleEraser",(t,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,t.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});I(this,"handleTouchMove",t=>{$l=!0});I(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(d=>({searchMatches:d.searchMatches&&{focusedId:null,matches:d.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom($g,null)),Ve.get(xo)&&this.updateEditorAtom(xo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let d=this.state.newElement;this.updateScene({...d.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==d.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:ve(Object.keys(this.state.selectedElementIds).filter(p=>p!==d.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Ct.EVENTUALLY:Ct.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(d=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Nf(this.device,{isTouchScreen:!0})),Kl||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Sn.ERASER&&this.state.activeTool.type!==bt.eraser){this.setState({activeTool:ar(this.state,{type:bt.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let d=()=>{p(),u?.(),St(this.state)&&this.setState({activeTool:ar(this.state,{...this.state.activeTool.lastActiveTool||{type:bt.selection},lastActiveToolBeforeEraser:null})})},p=Fe(window,oe.POINTER_UP,d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(t.button!==Sn.MAIN&&t.button!==Sn.TOUCH&&t.button!==Sn.ERASER||ge.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!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 d=i.hit.element&&this.isASelectedElement(i.hit.element),p=this.isMobileOrTablet();!i.hit.hasHitCommonBoundingBoxOfSelectedElements&&!i.resize.handleType&&!d&&(this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey),i.drag.blockDragging=!p),p&&i.hit.element&&!d&&(this.setState(u=>{let f={...u.selectedElementIds,[i.hit.element.id]:!0},b=[];Object.keys(u.selectedElementIds).forEach(w=>{let E=this.scene.getElement(w);E&&b.push(E)});let x=i.hit.element;if(Rt(x))Zf(b,x.id).forEach(w=>{delete f[w.id]});else if(x.frameId)f[x.frameId]&&delete f[x.id];else{let w=x.groupIds,E=new Set(w.flatMap(y=>Ln(this.scene.getNonDeletedElements(),y)).filter(y=>Rt(y)).map(y=>y.id));E.size>0&&b.forEach(y=>{y.frameId&&E.has(y.frameId)&&(delete f[y.id],y.groupIds.flatMap(v=>Ln(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete f[v.id]}))})}return{...no({editingGroupId:u.editingGroupId,selectedElementIds:f},this.scene.getNonDeletedElements(),u,this),showHyperlinkPopup:x.link||lr(x)?"info":!1}}),i.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Ot(this.interactiveCanvas,this.state):this.state.activeTool.type===bt.frame||this.state.activeTool.type===bt.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.state.activeTool.type!=="image"&&this.state.activeTool.type!=="laserTrail"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i);this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),m=this.onKeyDownFromPointerDownHandler(i),c=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(d=>s(d||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser"||this.state.activeTool.type==="laserTrail")&&(window.addEventListener(oe.POINTER_MOVE,l),window.addEventListener(oe.POINTER_UP,s),window.addEventListener(oe.KEYDOWN,m),window.addEventListener(oe.KEYUP,c),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=c,i.eventListeners.onKeyDown=m)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=We({clientX:t.clientX,clientY:t.clientY},this.state),n=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&n<300){let i=this.getElementAtPosition(r.x,r.y);if(Ul(i)&&this.isIframeLikeElementCenter(i,t,r.x,r.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(r.x,r.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&Ul(this.hitLinkElement)&&!_1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,le(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});I(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&($l=!1,Jr?$l=!0:Jr=window.setTimeout(()=>{Jr=0,$l||this.handleCanvasContextMenu(t)},OH))});I(this,"resetContextMenuTimer",()=>{clearTimeout(Jr),Jr=0,$l=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{jl?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(this.props.showPanActions!==!1&&ge.pointers.size<=1&&(t.button===Sn.WHEEL||t.button===Sn.MAIN&&Pn||lo(this.state)||this.state.viewModeEnabled)))return!1;Kl=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);ye(this.interactiveCanvas,Be.GRABBING);let{clientX:i,clientY:a}=t,l=Od(m=>{let c=i-m.clientX,d=a-m.clientY;if(i=m.clientX,a=m.clientY,n&&!r&&(Math.abs(c)>1||Math.abs(d)>1)){r=!0;let p=f=>{document.body.removeEventListener(oe.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(oe.PASTE,p),window.removeEventListener(oe.POINTER_UP,u)},100)};document.body.addEventListener(oe.PASTE,p),window.addEventListener(oe.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-c/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=Ae(jl=()=>{jl=null,Kl=!1,Pn||(this.state.viewModeEnabled?ye(this.interactiveCanvas,Be.GRAB):Ot(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(oe.POINTER_MOVE,l),window.removeEventListener(oe.POINTER_UP,s),window.removeEventListener(oe.BLUR,s),l.flush()});return window.addEventListener(oe.BLUR,s),window.addEventListener(oe.POINTER_MOVE,l,{passive:!0}),window.addEventListener(oe.POINTER_UP,s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,r)=>{if(this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!je(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=tC(n,this.state,r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),r.resize.handleType=l.transformHandleType))}else a.length>1&&(r.resize.handleType=oC(ca(a),r.origin.x,r.origin.y,this.state.zoom,t.pointerType,this.device));if(r.resize.handleType)r.resize.isResizing=!0,r.resize.offset=Rf(nU(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&ro(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=iU(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Le.handlePointerDown(t,this,this.store,r.origin,p,this.scene);if(u.hitElement&&(r.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0}let l=this.getElementsAtPosition(r.origin.x,r.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),m=this.getElementAtPosition(r.origin.x,r.origin.y,{allHitElements:l});if((!m||m.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),m&&m.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?r.hit.element=null:r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,m),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=s;let c=r.hit.element,d=r.hit.allHitElements.some(p=>this.isASelectedElement(p));if((c===null||!d)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(c),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:ve({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(c!=null){if(t[V.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(r.origin.x,r.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[c.id]||(r.hit.wasAddedToSelection=!0),this.setState(p=>({...JG(p,c),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[c.id]||(this.state.editingGroupId&&!J5(c,this.state.editingGroupId)&&this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!d&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[c.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),Rt(c))Zf(f,c.id).forEach(b=>{delete u[b.id]});else if(c.frameId)u[c.frameId]&&delete u[c.id];else{let b=c.groupIds,x=new Set(b.flatMap(w=>Ln(this.scene.getNonDeletedElements(),w)).filter(w=>Rt(w)).map(w=>w.id));x.size>0&&f.forEach(w=>{w.frameId&&x.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(E=>Ln(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(c.groupIds.some(b=>p.selectedGroupIds[b])||(u={[c.id]:!0})),{...no({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:c.link||lr(c)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(this,"handleTextOnPointerDown",(t,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,i=r.origin.y,a=this.getElementAtPosition(n,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(n,i);F5(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Zt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:ar(this.state,{type:this.defaultSelectionTool})})});I(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=st(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),m=t.pressure===.5||t.pressure===0||typeof t.pressure>"u"||t.pointerType==="touch"&&this.device.isTouchScreen,c=mG({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:m,locked:!1,frameId:l?l.id:null,points:[le(0,0)],pressures:m?[]:[t.pressure]});this.scene.insertElement(c),this.setState(p=>{let u={...p.selectedElementIds};return delete u[c.id],{selectedElementIds:ve(u,p)}});let d=Bf(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:c,startBoundElement:d,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=st(t,r,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=pG({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:n,height:i});return this.scene.insertElement(s),s});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[i,a]=st(t,r,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=Am(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:h("toast.unrecognizedLinkFormat"),closable:!0});let s=_5({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:n});return this.scene.insertElement(s),s});I(this,"newImagePlaceholder",({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,a]=st(t,r,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null,s=100/this.state.zoom.value;return gG({type:"image",strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null,x:i-s/2,y:a-s/2,width:s,height:s})});I(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&W5(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(zt);return}if(je(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(zt);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Zr(le(n.origin.x-a,n.origin.y-l),s)<Af){this.actionManager.executeAction(zt);return}this.setState(m=>({selectedElementIds:ve({...m.selectedElementIds,[i.id]:!0},m)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),ye(this.interactiveCanvas,Be.POINTER)}else{let[i,a]=st(n.origin.x,n.origin.y,t[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:m}=this.state,[c,d]=r==="arrow"?[s,m]:[null,null],p=r==="arrow"?uG({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===jr.round?{type:Sm.PROPORTIONAL_RADIUS}:null,startArrowhead:c,endArrowhead:d,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===jr.elbow,fixedSegments:this.state.currentItemArrowType===jr.elbow?[]:null}):fG({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:Sm.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:ve(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,le(0,0)]});let u=Bf(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,je(p),je(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=st(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=_5({type:"embeddable",...l}):s=hG({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});I(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,i]=st(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...$r},l=r===bt.magicframe?D5(a):dG(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});I(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});I(this,"eraseElements",()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||Uf(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,qr(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});I(this,"initializeImage",async(t,r)=>{if(!Zm(r))throw new Error(h("errors.unsupportedFileType"));let n=r.type;if(ye(this.interactiveCanvas,"wait"),n===ir.svg)try{r=Jm(V5(await r.text()),r.name)}catch(s){throw console.warn(s),new Error(h("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(r)||V1(r));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(h("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{r=await ps(r,{maxWidthOrHeight:IH})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(r.size>w5)throw new Error(h("errors.fileTooBig",{maxSize:`${Math.trunc(w5/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await qm(r);return new Promise(async(s,m)=>{try{let c=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:n,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([c]);if(p.size)throw new Error("Image cache update resulted with an error.")}let d=await this.imageCache.get(i)?.image;if(d&&this.state.newElement?.id!==c.id){c=this.getLatestInitializedImageElement(t,i);let p=this.getImageNaturalDimensions(c,d);Object.assign(c,p)}s(c)}catch(c){console.error(c),m(new Error(h("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,r)=>{let n=this.scene.getElement(t.id)??t;return qr(n,{fileId:r})});I(this,"onImageToolbarButtonClick",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,r=this.state.height/2+this.state.offsetTop,{x:n,y:i}=We({clientX:t,clientY:r},this.state),a=await ns({description:"Image",extensions:Object.keys(kH),multiple:!0});this.insertImages(a,n,i)}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:ar(this.state,{type:this.defaultSelectionTool})},()=>{this.actionManager.executeAction(zt)})}});I(this,"getImageNaturalDimensions",(t,r)=>{let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(r.naturalHeight,i),l=a*(r.naturalWidth/r.naturalHeight),s=t.x+t.width/2-l/2,m=t.y+t.height/2-a/2;return{x:s,y:m,width:l,height:a,crop:null}});I(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await SG({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:r});return i.size&&(this.store.scheduleAction(Ct.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Gl(a)&&i.has(a.fileId)?qr(a,{status:"error"}):a))),{updatedFiles:n,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=CG(this.scene.getNonDeletedElements()),r=this.files)=>{let n=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);if(i.size)for(let a of n)i.has(a.fileId)&&Yl.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",xH(()=>{this.addNewImagesToImageCache()},MH));I(this,"updateBindingEnabledOnPointerMove",t=>{let r=cG(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});I(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=Bf(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(oe.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(oe.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(oe.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(oe.TOUCH_END,this.onTouchEnd))});I(this,"insertImages",async(t,r,n)=>{let i=50/this.state.zoom.value,a=lC(t.map(()=>this.newImagePlaceholder({sceneX:r,sceneY:n})),r,n,i);a.forEach(p=>this.scene.insertElement(p));let l=await Promise.all(a.map(async(p,u)=>{try{return await this.initializeImage(p,t[u])}catch(f){return this.setState({errorMessage:f.message||h("errors.imageInsertError")}),qr(p,{isDeleted:!0})}})),s=Pm(l),m=lC(l.filter(p=>!p.isDeleted),r,n,i),c=Pm(m),d=this.scene.getElementsIncludingDeleted().map(p=>c.get(p.id)??s.get(p.id)??p);this.updateScene({appState:{selectedElementIds:ve(Object.fromEntries(m.map(p=>[p.id,!0])),this.state)},elements:d,captureUpdate:Ct.IMMEDIATELY}),this.setState({},()=>{this.actionManager.executeAction(zt)})});I(this,"handleAppOnDrop",async t=>{let{x:r,y:n}=We(t,this.state),i=await $a(t),a=i.getFiles();if(a.length===1){let{file:c,fileHandle:d}=a[0];if(c&&(c.type===ir.png||c.type===ir.svg))try{let p=await ms(c,this.state,this.scene.getElementsIncludingDeleted(),d);this.syncActionResult({...p,appState:{...p.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Ct.IMMEDIATELY});return}catch(p){if(p.name!=="EncodingError")throw new Error(h("alerts.couldNotLoadInvalidFile"))}}let l=a.map(c=>c.file).filter(c=>Zm(c));if(l.length>0&&this.isToolSupported("image"))return this.insertImages(l,r,n);let s=i.getData(ir.excalidrawlib);if(s&&typeof s=="string"){try{let c=Y1(s);this.addElementsFromPasteOrLibrary({elements:rd(c),position:t,files:null})}catch(c){this.setState({errorMessage:c.message})}return}if(a.length>0){let{file:c,fileHandle:d}=a[0];c&&await this.loadFileToCanvas(c,d)}let m=i.findByType(ir.text);if(m){let c=m.value;if(c&&Vf(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||Am(c)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:r,sceneY:n,link:_f(c)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,r)=>{t=await us(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await $m(t,this.state,n,r)}catch(a){let l=a instanceof L1;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:h("errors.imageToolNotSupported")});return}let s=l?h("alerts.cannotRestoreFromImage"):h("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===ir.excalidraw?(mC(n.concat(i.data.elements)),this.store.scheduleMicroAction({action:Ct.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Ct.IMMEDIATELY})):i.type===ir.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:h("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Sn.SECONDARY)&&this.state.activeTool.type!==this.defaultSelectionTool)return;let{x:r,y:n}=We(t,this.state),i=this.getElementAtPosition(r,n,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:r,y:n},a),s=i||l?"element":"canvas",m=this.excalidrawContainerRef.current,{top:c,left:d}=m.getBoundingClientRect(),p=t.clientX-d,u=t.clientY-c;ae("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...no({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ro(i)?new Le(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){rC({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:sa(t.origin.x,a.x),height:sa(t.origin.y,a.y),shouldMaintainAspectRatio:Ol(r),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,m]=st(a.x,a.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=Gl(l)&&this.imageCache.get(l.fileId)?.image,d=c&&!(c instanceof Promise)?c.width/c.height:null;this.maybeCacheReferenceSnapPoints(r,[l]);let{snapOffset:p,snapLines:u}=Q2(l,this,r,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:m-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,m+=p.y,this.setState({snapLines:u}),rC({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:m,width:sa(t.originInGrid.x,s),height:sa(t.originInGrid.y,m),shouldMaintainAspectRatio:Mn(l)?!Ol(r):Ol(r),shouldResizeFromCenter:x5(r),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:d,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===bt.frame||this.state.activeTool.type===bt.magicframe)&&this.setState({elementsToHighlight:jf(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,i=t.lastCoords,[a,l]=st(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&Mn(s)){let m=t.originalElements.get(s.id),c=Gl(s)&&this.imageCache.get(s.fileId)?.image;if(m&&Mn(m)&&c&&!(c instanceof Promise)){let[d,p]=st(i.x,i.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:f,snapLines:b}=hg([s],[m],this,r,u,n);this.scene.mutateElement(s,UG(s,this.scene.getNonDeletedElementsMap(),n,c.naturalWidth,c.naturalHeight,a+f.x,l+f.y,r.shiftKey?m.width/m.height:void 0)),Of(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:b})}return!0}return!1});I(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(d=>Rt(d)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&je(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,m]=st(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),c=new Map;if(i.forEach(d=>{Zf(this.scene.getNonDeletedElements(),d.id).forEach(u=>{c.set(d.id+u.id,{x:u.x-d.x,y:u.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,p]=st(l.x,l.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=hg(n,J(f,this.state),this,r,u,a);s+=b.x,m+=b.y,this.setState({snapLines:x})}if(aU(t.originalElements,a,n,this.scene,Pf(r),x5(r),n.some(d=>Mn(d))?!Ol(r):Ol(r),s,m,t.resize.center.x,t.resize.center.y)){let d=zf(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{jf(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:d}),!0}return!1});I(this,"getContextMenuItems",t=>{let r=[];return r.push(Uc,Gc),t==="canvas"?this.state.viewModeEnabled?[...r,Yc,wi,lg,vi]:[Fu,Ze,Uc,Gc,Wc,Ze,Lp,wy,Ze,Yc,Ou,wi,lg,vi]:(r.push(Wc),this.state.viewModeEnabled?[yi,...r]:[Ze,Hc,yi,Fu,Ze,A2,_2,D2,Ze,rg,Ze,...r,Ze,Su,ku,Ze,Pu,H2,Gu,Uu,ay,Au,Ze,Ru,Ze,Cp,Sp,kp,Mp,Ze,Nu,Bu,Ze,Wi,Ze,el,Jc,Ze,Pp,tl,Ze,La])});I(this,"handleWheel",Ae(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[V.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Kl)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(n),a=HH*100,l=Math.abs(n),s=n;l>a&&(s=a*i);let m=this.state.zoom.value-s/100;m+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(c=>({...Zo({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Co(m)},c),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey&&this.props.showPanActions!==!1){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(n||r)/i.value}));return}this.props.showPanActions!==!1&&this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-r/i.value,scrollY:l-n/i.value}))}));I(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:i,y:a}=We({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"||this.state.activeTool.type==="laserTrail"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:ge.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",C5(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let r=this.excalidrawContainerRef.current,{width:n,height:i,left:a,top:l}=r.getBoundingClientRect(),{width:s,height:m,offsetTop:c,offsetLeft:d}=this.state;if(n===s&&i===m&&a===d&&l===c){t&&t();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=mr();this.defaultSelectionTool=this.isMobileOrTablet()?"lasso":"selection";let{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:m=r.theme,name:c=`${h("labels.untitled")}-${k5()}`}=t;if(this.state={...r,theme:m,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:c,width:window.innerWidth,height:window.innerHeight},this.id=yH(),this.library=new Ky(this),this.actionManager=new kd(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new iC,this.canvas=document.createElement("canvas"),this.rc=EH.canvas(this.canvas),this.renderer=new vl(this.scene),this.visibleElements=[],this.store=new cU(this),this.history=new fl(this.store),n){let d=b=>{this.setState(b)},p=(b="line")=>{if(b==="line"){this.setActiveTool({type:bt.line});return}if(this.setActiveTool({type:bt.arrow}),b==="arrow"){d({currentItemStartArrowhead:null,currentItemEndArrowhead:"arrow"});return}if(b==="doubleArrow"){d({currentItemStartArrowhead:"arrow",currentItemEndArrowhead:"arrow"});return}if(b==="outlineArrow"){d({currentItemStartArrowhead:null,currentItemEndArrowhead:"triangle_outline"});return}d({currentItemStartArrowhead:"triangle_outline",currentItemEndArrowhead:"triangle_outline"})},u={selectSelection:()=>{this.setActiveTool({type:bt.selection})},selectFreedraw:b=>{if(this.setActiveTool({type:bt.freedraw}),!b)return;let x={},w=b.variant??"pen";x.currentItemOpacity=w==="highlighter"?50:100,typeof b.strokeWidth=="number"&&(x.currentItemStrokeWidth=b.strokeWidth),typeof b.strokeColor=="string"&&(x.currentItemStrokeColor=b.strokeColor),d(x)},selectLine:b=>{let x=b?.variant??"line";if(p(x),!b)return;let w={};typeof b.strokeWidth=="number"&&(w.currentItemStrokeWidth=b.strokeWidth),typeof b.strokeColor=="string"&&(w.currentItemStrokeColor=b.strokeColor),d(w)},selectShape:(b,x)=>{let w=b??"rectangle";if(this.setActiveTool({type:w}),!x)return;let E={};typeof x.strokeWidth=="number"&&(E.currentItemStrokeWidth=x.strokeWidth),typeof x.strokeColor=="string"&&(E.currentItemStrokeColor=x.strokeColor),typeof x.backgroundColor=="string"&&(E.currentItemBackgroundColor=x.backgroundColor),x.fillStyle&&(E.currentItemFillStyle=x.fillStyle),d(E)},selectText:b=>{if(this.setActiveTool({type:bt.text}),!b)return;let x={};typeof b.fontSize=="number"&&(x.currentItemFontSize=b.fontSize),b.textAlign&&(x.currentItemTextAlign=b.textAlign),typeof b.strokeColor=="string"&&(x.currentItemStrokeColor=b.strokeColor),typeof b.bold=="boolean"&&(x.currentTextBold=b.bold),typeof b.italic=="boolean"&&(x.currentTextItalic=b.italic),typeof b.underline=="boolean"&&(x.currentTextUnderline=b.underline),typeof b.strikethrough=="boolean"&&(x.currentTextStrikethrough=b.strikethrough),d(x)},selectEraser:()=>{this.setActiveTool({type:bt.eraser})},updateStyle:b=>{d(b)},dispatch:b=>{switch(b.type){case"selectSelection":u.selectSelection();return;case"selectFreedraw":u.selectFreedraw(b.payload);return;case"selectLine":u.selectLine(b.payload);return;case"selectShape":u.selectShape(b.payload?.shape,b.payload&&{strokeWidth:b.payload.strokeWidth,strokeColor:b.payload.strokeColor,backgroundColor:b.payload.backgroundColor,fillStyle:b.payload.fillStyle});return;case"selectText":u.selectText(b.payload);return;case"selectEraser":u.selectEraser();return;case"updateStyle":u.updateStyle(b.payload);return;default:return}}},f={updateScene:this.updateScene,updateSceneSilently:this.updateSceneSilently,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,zoomToFit:this.zoomToFit,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:b=>{this.actionManager.registerAction(b)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,leftToolbar:u,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:b=>this.onChangeEmitter.on(b),onIncrement:b=>this.store.onStoreIncrementEmitter.on(b),onPointerDown:b=>this.onPointerDownEmitter.on(b),onPointerUp:b=>this.onPointerUpEmitter.on(b),onScrollChange:b=>this.onScrollChangeEmitter.on(b),onUserFollow:b=>this.onUserFollowEmitter.on(b)};typeof n=="function"?n(f):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new dr(this.scene),this.history=new fl(this.store),this.actionManager.registerAll(Ys),this.actionManager.registerAction(B2(this.history)),this.actionManager.registerAction(F2(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(n=a.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values(Mm).includes(i)&&o1.set(n,i)}break}}cacheEmbeddableRef(t,r){r&&this.iFrameRefs.set(t.id,r)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),da(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=o1.get(t.id);switch(n||(o1.set(t.id,Mm.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case Mm.PLAYING:case Mm.BUFFERING:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:r.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}r.src.includes("player.vimeo.com")&&r.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,r,n,i){return t&&!r.altKey&&!r.shiftKey&&!r.metaKey&&!r.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&n>=t.x+t.width/3&&n<=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,r=this.state.width,n=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>lr(a)&&this.embedsValidationStatus.get(a.id)===!0||da(a));return fe(uU,{children:i.map(a=>{let{x:l,y:s}=Lm({sceneX:a.x,sceneY:a.y},this.state),m=G5(a,r,n,this.state,this.scene.getNonDeletedElementsMap()),c=this.initializedEmbeds.has(a.id);if(m&&!c&&this.initializedEmbeds.add(a.id),!(m||c))return null;let p;if(da(a)){p=null;let b=(a.customData?.generationData??this.magicGenerations.get(a.id))||{status:"error",message:"No generation data",code:"ERR_NO_GENERATION_DATA"};if(b.status==="done"){let x=b.html;p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>x}}else if(b.status==="pending")p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>Y5(`
33
33
  <style>
34
34
  html, body {
35
35
  width: 100%;
36
36
  height: 100%;
37
- color: ${this.state.theme===Sm.DARK?"white":"black"};
37
+ color: ${this.state.theme===km.DARK?"white":"black"};
38
38
  }
39
39
  body {
40
40
  display: flex;
@@ -120,7 +120,7 @@ TTD mermaid definition render errror: ${L.message}`,"color: yellow"),ae("ai","me
120
120
  </style>
121
121
  <h1>Error!</h1>
122
122
  <h3>${x}</h3>
123
- `)}}}else p=Pm(XH(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return fe("div",{className:m5("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:m?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:m?"block":"none",opacity:qG(a,jf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?WH:1),"--embeddable-radius":`${TG(Math.min(a.width,a.height),a)}px`},children:Am("div",{className:"excalidraw__embeddable-container__inner",style:{width:m?`${a.width}px`:0,height:m?`${a.height}px`:0,transform:m?`rotate(${a.angle}rad)`:"none",pointerEvents:u?la.enabled:la.disabled},children:[f&&fe("div",{className:"excalidraw__embeddable-hint",children:h("buttons.embeddableInteractionButton")}),fe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(lr(a)?this.props.renderEmbeddable?.(a,this.state):null)??fe("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),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:r,renderCustomStats:n}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id});this.visibleElements=l;let s=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.activeTool.type==="laserTrail")&&this.state.cursorButton==="down",c=t[0],d=Ve.get(bo)?.type==="panel";return fe("div",{className:m5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":m?la.disabled:la.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:fe(pC.Provider,{value:this,children:fe(uC.Provider,{value:this.props,children:fe(a1.Provider,{value:this.excalidrawContainerValue,children:fe(i1.Provider,{value:this.device,children:fe(c1.Provider,{value:this.setAppState,children:fe(s1.Provider,{value:this.state,children:Am(l1.Provider,{value:this.scene.getNonDeletedElements(),children:[Am(d1.Provider,{value:this.actionManager,children:[fe($I,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Uo().code,renderTopRightUI:r,renderCustomStats:n,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.defaultSelectionTool&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,showZoomActions:this.props.showZoomActions,showPanActions:this.props.showPanActions,showToolBar:this.props.showToolBar,showTopLeftToolbar:this.props.showTopLeftToolbar,children:this.props.children}),fe("div",{className:"excalidraw-textEditorContainer"}),fe("div",{className:"excalidraw-contextMenuContainer"}),fe("div",{className:"excalidraw-eye-dropper-container"}),fe(JI,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&fe(py,{element:c,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&t.length===1&&Uf(c)&&fe(Ig,{element:c,elementsMap:a,children:fe(Tm,{title:h("labels.convertToCode"),icon:u0,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),t.length===1&&da(c)&&c.customData?.generationData?.status==="done"&&Am(Ig,{element:c,elementsMap:a,children:[fe(Tm,{title:h("labels.copySource"),icon:Yn,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),fe(Tm,{title:"Enter fullscreen",icon:h0,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(c);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&fe(c5,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&fe(Qv,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:p=>{this.setState({contextMenu:null},()=>{this.focusContainer(),p?.()})}}),fe(Sf,{canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:s,visibleElements:l,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:Nr(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&fe(l5,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:s,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),fe(Cf,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&fe(t3,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&fe(d5,{app:this,activeLockedId:this.state.activeLockedId}),d&&fe(Ly,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=NG(this.scene.getNonDeletedElements(),t).filter(l=>!Uf(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ae("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),ae("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(ae("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){ae("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(go(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let r=t??this.files;this.scene.getNonDeletedElements().forEach(n=>{Gl(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),Yl.delete(n))})}async componentDidMount(){this.unmounted=!1;try{window.excalidrawApp=this}catch{}if(this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,r1()||dC()){let n=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(n=>{this.history.record(n.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(n=>{t(n)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),r1()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),v5&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),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),LH()&&!VG()&&this.setState({errorMessage:fe($v,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new iC,this.fonts=new dr(this.scene),this.renderer=new vl(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),Yl.destroy(),Jt.destroy(),clearTimeout(qr),we.clearCache(),no.clearCache(),qr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Fe(document,oe.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Fe(this.excalidrawContainerRef.current,oe.WHEEL,this.handleWheel,{passive:!1}),Fe(window,oe.MESSAGE,this.onWindowMessage,!1),Fe(document,oe.POINTER_UP,this.removePointer,{passive:!1}),Fe(document,oe.COPY,this.onCopy,{passive:!1}),Fe(document,oe.KEYUP,this.onKeyUp,{passive:!0}),Fe(document,oe.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Fe(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),Fe(document,oe.GESTURE_START,this.onGestureStart,!1),Fe(document,oe.GESTURE_CHANGE,this.onGestureChange,!1),Fe(document,oe.GESTURE_END,this.onGestureEnd,!1),Fe(window,oe.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Fe(document,oe.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),Fe(document,oe.PASTE,this.pasteFromClipboard,{passive:!1}),Fe(document,oe.CUT,this.onCut,{passive:!1}),Fe(window,oe.RESIZE,this.onResize,!1),Fe(window,oe.UNLOAD,this.onUnload,!1),Fe(window,oe.BLUR,this.onBlur,!1),Fe(this.excalidrawContainerRef.current,oe.WHEEL,this.handleWheel,{passive:!1}),Fe(this.excalidrawContainerRef.current,oe.DRAG_OVER,this.disableEvent,!1),Fe(this.excalidrawContainerRef.current,oe.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Fe(KH(this.excalidrawContainerRef.current),oe.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();if(!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.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)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&St(this.state)&&this.setState({activeTool:ar(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&du(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),St(r)&&!St(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===Sm.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(zt)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null}),this.store.commit(i,this.state),!this.state.isLoading){let l={source:this._currentUpdateSource};this.props.onChange?.(n,this.state,this.files,l),this.onChangeEmitter.trigger(n,this.state,this.files,l)}}static resetTapTwice(){Vl=!1,Xl=null}async insertClipboardContent(t,r,n){let{x:i,y:a}=We({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(r.length===0&&!n&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:n,sceneX:i,sceneY:a});return}if(t.spreadsheet&&!n){this.setState({pasteDialog:{data:t.spreadsheet,shown:!0}});return}let l=r.map(c=>c.file);if(l.length===0&&t.text&&!n){let c=t.text.trim();c.startsWith("<svg")&&c.endsWith("</svg>")&&l.push(qm(c))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:h("errors.imageToolNotSupported")});return}if(t.elements){let c=t.programmaticAPI?Xi(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:c,files:t.files||null,position:this.isMobileOrTablet()?"center":"cursor",retainSeed:n});return}if(!t.text)return;if(!n&&Bv(t.text)){let c=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:d,files:p}=await c.parseMermaidToExcalidraw(t.text),u=Xi(d,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:p,position:this.isMobileOrTablet()?"center":"cursor"});return}catch(d){console.warn(`parsing pasted text as mermaid definition failed: ${d.message}`)}}let s=tG(t.text).split(/\n+/).map(c=>c.trim()).filter(Boolean),m=s.map(c=>IG(c)).filter(c=>Yf(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||Pm(c)?.type==="video"));if(!n&&m.length>0&&m.length===s.length){let c=[];for(let d of m){let p=c[c.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:Af(d)});u&&c.push(u)}c.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(c.map(d=>[d.id,!0]))}));return}this.addTextFromPaste(t.text,n)}async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(c=>c.type==="imageUrl").map(c=>c.value),l=await Promise.all(a.map(async c=>{try{return{file:await K1(c)}}catch(d){let p=d.message;return d.cause==="FETCH_ERROR"?p=h("errors.failedToFetchImage"):d.cause==="UNSUPPORTED"&&(p=h("errors.unsupportedFileType")),{errorMessage:p}}})),s=l.filter(c=>!!c.file).map(c=>c.file);await this.insertImages(s,n,i);let m=l.find(c=>!!c.errorMessage);m&&m.errorMessage&&this.setState({errorMessage:m.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
123
+ `)}}}else p=Am(XH(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return fe("div",{className:m5("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:m?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:m?"block":"none",opacity:qG(a,qf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?WH:1),"--embeddable-radius":`${TG(Math.min(a.width,a.height),a)}px`},children:_m("div",{className:"excalidraw__embeddable-container__inner",style:{width:m?`${a.width}px`:0,height:m?`${a.height}px`:0,transform:m?`rotate(${a.angle}rad)`:"none",pointerEvents:u?la.enabled:la.disabled},children:[f&&fe("div",{className:"excalidraw__embeddable-hint",children:h("buttons.embeddableInteractionButton")}),fe("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(lr(a)?this.props.renderEmbeddable?.(a,this.state):null)??fe("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),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:r,renderCustomStats:n}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id});this.visibleElements=l;let s=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.activeTool.type==="laserTrail")&&this.state.cursorButton==="down",c=t[0],d=Ve.get(xo)?.type==="panel";return fe("div",{className:m5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":m?la.disabled:la.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:fe(pC.Provider,{value:this,children:fe(uC.Provider,{value:this.props,children:fe(l1.Provider,{value:this.excalidrawContainerValue,children:fe(a1.Provider,{value:this.device,children:fe(d1.Provider,{value:this.setAppState,children:fe(c1.Provider,{value:this.state,children:_m(s1.Provider,{value:this.scene.getNonDeletedElements(),children:[_m(m1.Provider,{value:this.actionManager,children:[fe($I,{canvas:this.canvas,appState:this.state,files:this.files,setAppState:this.setAppState,actionManager:this.actionManager,elements:this.scene.getNonDeletedElements(),onLockToggle:this.toggleLock,onPenModeToggle:this.togglePenMode,onHandToolToggle:this.onHandToolToggle,langCode:Uo().code,renderTopRightUI:r,renderCustomStats:n,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type===this.defaultSelectionTool&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,showZoomActions:this.props.showZoomActions,showPanActions:this.props.showPanActions,showToolBar:this.props.showToolBar,showTopLeftToolbar:this.props.showTopLeftToolbar,children:this.props.children}),fe("div",{className:"excalidraw-textEditorContainer"}),fe("div",{className:"excalidraw-contextMenuContainer"}),fe("div",{className:"excalidraw-eye-dropper-container"}),fe(JI,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&fe(uy,{element:c,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},c.id),this.props.aiEnabled!==!1&&t.length===1&&Wf(c)&&fe(Cg,{element:c,elementsMap:a,children:fe(Im,{title:h("labels.convertToCode"),icon:h0,checked:!1,onChange:()=>this.onMagicFrameGenerate(c,"button")})}),t.length===1&&da(c)&&c.customData?.generationData?.status==="done"&&_m(Cg,{element:c,elementsMap:a,children:[fe(Im,{title:h("labels.copySource"),icon:Yn,checked:!1,onChange:()=>this.onIframeSrcCopy(c)}),fe(Im,{title:"Enter fullscreen",icon:g0,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(c);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:c,state:"active"},selectedElementIds:{[c.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&fe(c5,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&fe(e3,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:p=>{this.setState({contextMenu:null},()=>{this.focusContainer(),p?.()})}}),fe(kf,{canvas:this.canvas,rc:this.rc,elementsMap:a,allElementsMap:s,visibleElements:l,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:Nr(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&fe(l5,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:s,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),fe(Sf,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&fe(o3,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&fe(d5,{app:this,activeLockedId:this.state.activeLockedId}),d&&fe(Py,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=NG(this.scene.getNonDeletedElements(),t).filter(l=>!Wf(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ae("ai","generate (no-children)","d2c")):this.setActiveTool({type:"magicframe"});return}let a=this.insertIframeElement({sceneX:t.x+t.width+30,sceneY:t.y,width:t.width,height:t.height});if(a){this.updateMagicGeneration({frameElement:a,data:{status:"pending"}}),this.setState({selectedElementIds:{[a.id]:!0}}),ae("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(ae("ai","generate (success)","d2c"),!l.trim()){this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:"Nothing genereated :("}});return}let s=l.includes("<!DOCTYPE html>")&&l.includes("</html>")?l.slice(l.indexOf("<!DOCTYPE html>"),l.indexOf("</html>")+7):l;this.updateMagicGeneration({frameElement:a,data:{status:"done",html:s}})}catch(l){ae("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(fo(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let r=t??this.files;this.scene.getNonDeletedElements().forEach(n=>{Gl(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),Yl.delete(n))})}async componentDidMount(){this.unmounted=!1;try{window.excalidrawApp=this}catch{}if(this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,n1()||dC()){let n=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(n=>{this.history.record(n.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(n=>{t(n)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),n1()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),v5&&this.excalidrawContainerRef.current&&(this.resizeObserver=new ResizeObserver(()=>{this.refreshEditorBreakpoints(),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),LH()&&!VG()&&this.setState({errorMessage:fe(jv,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new iC,this.fonts=new dr(this.scene),this.renderer=new vl(this.scene),this.files={},this.imageCache.clear(),this.resizeObserver?.disconnect(),this.unmounted=!0,this.removeEventListeners(),this.library.destroy(),this.laserTrails.stop(),this.eraserTrail.stop(),this.onChangeEmitter.clear(),this.store.onStoreIncrementEmitter.clear(),this.store.onDurableIncrementEmitter.clear(),Yl.destroy(),Jt.destroy(),clearTimeout(Jr),we.clearCache(),no.clearCache(),Jr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Fe(document,oe.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Fe(this.excalidrawContainerRef.current,oe.WHEEL,this.handleWheel,{passive:!1}),Fe(window,oe.MESSAGE,this.onWindowMessage,!1),Fe(document,oe.POINTER_UP,this.removePointer,{passive:!1}),Fe(document,oe.COPY,this.onCopy,{passive:!1}),Fe(document,oe.KEYUP,this.onKeyUp,{passive:!0}),Fe(document,oe.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Fe(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),Fe(document,oe.GESTURE_START,this.onGestureStart,!1),Fe(document,oe.GESTURE_CHANGE,this.onGestureChange,!1),Fe(document,oe.GESTURE_END,this.onGestureEnd,!1),Fe(window,oe.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Fe(document,oe.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),Fe(document,oe.PASTE,this.pasteFromClipboard,{passive:!1}),Fe(document,oe.CUT,this.onCut,{passive:!1}),Fe(window,oe.RESIZE,this.onResize,!1),Fe(window,oe.UNLOAD,this.onUnload,!1),Fe(window,oe.BLUR,this.onBlur,!1),Fe(this.excalidrawContainerRef.current,oe.WHEEL,this.handleWheel,{passive:!1}),Fe(this.excalidrawContainerRef.current,oe.DRAG_OVER,this.disableEvent,!1),Fe(this.excalidrawContainerRef.current,oe.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Fe(KH(this.excalidrawContainerRef.current),oe.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();if(!this.state.showWelcomeScreen&&!n.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),r.userToFollow&&!this.state.collaborators.has(r.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(r.zoom.value!==this.state.zoom.value||r.scrollX!==this.state.scrollX||r.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)),r.userToFollow!==this.state.userToFollow&&(r.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:r.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&St(this.state)&&this.setState({activeTool:ar(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&mu(this.interactiveCanvas,this.state.theme),r.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),St(r)&&!St(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===km.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(zt)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null}),this.store.commit(i,this.state),!this.state.isLoading){let l={source:this._currentUpdateSource};this.props.onChange?.(n,this.state,this.files,l),this.onChangeEmitter.trigger(n,this.state,this.files,l)}}static resetTapTwice(){Vl=!1,Xl=null}async insertClipboardContent(t,r,n){let{x:i,y:a}=We({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state);if(t.errorMessage){this.setState({errorMessage:t.errorMessage});return}if(r.length===0&&!n&&t.mixedContent){await this.addElementsFromMixedContentPaste(t.mixedContent,{isPlainPaste:n,sceneX:i,sceneY:a});return}if(t.spreadsheet&&!n){this.setState({pasteDialog:{data:t.spreadsheet,shown:!0}});return}let l=r.map(c=>c.file);if(l.length===0&&t.text&&!n){let c=t.text.trim();c.startsWith("<svg")&&c.endsWith("</svg>")&&l.push(Jm(c))}if(l.length>0){this.isToolSupported("image")?await this.insertImages(l,i,a):this.setState({errorMessage:h("errors.imageToolNotSupported")});return}if(t.elements){let c=t.programmaticAPI?Xi(t.elements):t.elements;this.addElementsFromPasteOrLibrary({elements:c,files:t.files||null,position:this.isMobileOrTablet()?"center":"cursor",retainSeed:n});return}if(!t.text)return;if(!n&&Fv(t.text)){let c=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:d,files:p}=await c.parseMermaidToExcalidraw(t.text),u=Xi(d,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:u,files:p,position:this.isMobileOrTablet()?"center":"cursor"});return}catch(d){console.warn(`parsing pasted text as mermaid definition failed: ${d.message}`)}}let s=tG(t.text).split(/\n+/).map(c=>c.trim()).filter(Boolean),m=s.map(c=>IG(c)).filter(c=>Vf(c,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(c)||Am(c)?.type==="video"));if(!n&&m.length>0&&m.length===s.length){let c=[];for(let d of m){let p=c[c.length-1],u=this.insertEmbeddableElement({sceneX:p?p.x+p.width+20:i,sceneY:a,link:_f(d)});u&&c.push(u)}c.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(c.map(d=>[d.id,!0]))}));return}this.addTextFromPaste(t.text,n)}async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(c=>c.type==="imageUrl").map(c=>c.value),l=await Promise.all(a.map(async c=>{try{return{file:await Z1(c)}}catch(d){let p=d.message;return d.cause==="FETCH_ERROR"?p=h("errors.failedToFetchImage"):d.cause==="UNSUPPORTED"&&(p=h("errors.unsupportedFileType")),{errorMessage:p}}})),s=l.filter(c=>!!c.file).map(c=>c.file);await this.insertImages(s,n,i);let m=l.find(c=>!!c.errorMessage);m&&m.errorMessage&&this.setState({errorMessage:m.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
124
124
 
125
- `),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=We({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:UH,verticalAlign:E5,locked:!1},l=_f({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=I5(a.fontFamily),[m,,c]=zG(this.state),d=Math.max(Math.min((c-m)*.5,800),200),p=10,u=i,f=r?[t]:t.split(`
126
- `),b=f.reduce((x,w,E)=>{let y=XG(w).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),C=q5(y,l,s),S=C.width>d,P=S?WG(y,l,d):y;C=S?q5(P,l,s):C;let M=n-C.width/2,R=u-C.height/2,L=R5({...a,x:M,y:R,text:P,originalText:y,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(L),u+=L.height+p}else f[E-1]?.trim()&&(u+=KG(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:ve(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&cC===!1&&!this.device.editor.isMobile&&(this.setToast({message:h("toast.pasteAsSingleElement",{shortcut:jH("CtrlOrCmd+Shift+V")}),duration:5e3}),cC=!0))}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>{if(s.id===t.id&&vo(s)){let m=s.customData?.textStyle||{},c=(p,u)=>p===void 0?!!u:!!p,d={bold:c(m.bold,this.state.currentTextBold),italic:c(m.italic,this.state.currentTextItalic),underline:c(m.underline,this.state.currentTextUnderline),strikethrough:c(m.strikethrough,this.state.currentTextStrikethrough)};return jr(s,{originalText:a,isDeleted:l??s.isDeleted,...bG(s,X5(s,n),n,a),customData:{...s.customData||{},textStyle:d}})}return s})])};Nv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:m}=Mm({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,m-this.state.offsetTop]},onChange:Ae(a=>{i(a,!1),nC(t)&&Ff(t,this.scene)}),onSubmit:Ae(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let m=t.containerId?t.containerId:t.id;aa(()=>{this.setState(c=>({selectedElementIds:ve({...c.selectedElementIds,[m]:!0},c)}))})}s&&sG(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.scheduleCapture(),aa(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Ot(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&vo(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=[];if(n&&"allHitElements"in n?i=n?.allHitElements||[]:i=this.getElementsAtPosition(t,r,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),i.length>1){if(n?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return Wl({point:le(t,r),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Rt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n){let i=[],a=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n?.includeLockedElements||!s.locked)&&(n?.includeBoundTextElement||!(vo(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let m=jf(s,a);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?K5({x:t,y:r},m,a):!0}).filter(s=>da(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(T5/this.state.zoom.value))}hitElement(t,r,n,i=!0){return i&&this.state.selectedElementIds[n.id]&&LG([n],this.state)&&dU(le(t,r),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||FG(le(t,r),n,this.scene.getNonDeletedElementsMap())?!0:Wl({point:le(t,r),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Rt(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(t,r){let n=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return z5(i[0],!1)?i[0]:null;let a=null;for(let l=n.length-1;l>=0;--l){if(n[l].isDeleted)continue;let[s,m,c,d]=P5(n[l],this.scene.getNonDeletedElementsMap());if(zf(n[l])&&Wl({point:le(t,r),element:n[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[l])})){a=n[l];break}else if(s<t&&t<c&&m<r&&r<d){a=n[l];break}}return z5(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=Le.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;Wl({point:le(r,n),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Le.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=Le.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(je(a)?l===0||l===a.points.length-1:l>=0)||s?ye(this.interactiveCanvas,Be.POINTER):this.hitElement(r,n,a)&&(!je(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,Be.MOVE)):this.hitElement(r,n,a)&&(!je(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,Be.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),Le.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else ye(this.interactiveCanvas,Be.AUTO)}updateGestureOnPointerDown(t){ge.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ge.pointers.size===2&&(ge.lastCenter=sg(ge.pointers),ge.initialScale=this.state.zoom.value,ge.initialDistance=cg(Array.from(ge.pointers.values())))}initialPointerDownState(t){let r=We(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=ca(n),m=n.findIndex(je)===0;return{origin:r,withCmdOrCtrl:t[V.CTRL_OR_CMD],originInGrid:Df(st(r.x,r.y,t[V.CTRL_OR_CMD]||m?null:this.getEffectiveGridSize())),scrollbars:gg(Zl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((c,d)=>(c.set(d.id,N5(d)),c),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null,origin:{...r},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;e1=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=Od(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=Ae(()=>{jl=null,e1=!1,Ot(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(oe.POINTER_MOVE,n),window.removeEventListener(oe.POINTER_UP,i),n.flush()});return jl=i,window.addEventListener(oe.POINTER_MOVE,n),window.addEventListener(oe.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=Math.max(T5/this.state.zoom.value,1),[i,a,l,s]=ca(r);return t.x>i-n&&t.x<l+n&&t.y>a-n&&t.y<s+n}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:EG(t)?Cm.ADAPTIVE_RADIUS:Cm.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){tr({event:t,app:this,selectedElements:r})&&(n||!Jt.getReferenceSnapPoints())&&Jt.setReferenceSnapPoints(j2(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){tr({event:t,app:this,selectedElements:r})&&(n||!Jt.getVisibleGaps())&&Jt.setVisibleGaps($2(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ae(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return Ae(r=>{r.key===V.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return Od(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=We(r,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=st(n.x,n.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=Le.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?Le.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=Le.moveFixedSegment(this.state.selectedLinearElement,f,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=n,t.drag.offset===null&&(t.drag.offset=Df(sU(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(St(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=st(n.x,n.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Kr(le(n.x,n.y),le(t.origin.x,t.origin.y))*this.state.zoom.value<M5)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleCrop(t,r)||this.maybeHandleResize(t,r)))return!0;let m=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Le.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,m)){let f=Le.addMidpoint(this.state.selectedLinearElement,n,this,!r[V.CTRL_OR_CMD],this.scene);if(!f)return;aa(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=Le.handlePointDragging(r,this,n.x,n.y,p);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState(u);return}}let c=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),d=this.state.selectedLinearElement?.isEditing&&r.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((c||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!d&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(x=>x.locked))return;let u=p.find(x=>Rt(x)),f=this.getTopLayerFrameAtSceneCoords(n),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&aa(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.isMobileOrTablet()&&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 x={x:n.x-t.drag.origin.x,y:n.y-t.drag.origin.y},w=[...t.originalElements.values()],E=r.shiftKey;if(E){let C=Math.abs(x.x),S=Math.abs(x.y),P=E&&C<S,M=E&&C>S;P&&(x.x=0),M&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&Mn(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,P=Gl(C)&&this.imageCache.get(C.fileId)?.image;if(P&&!(P instanceof Promise)){let M=wH(u5(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[R,L,k,N,O,G]=P5(C,m),_=Mf(kf(le(R,L),le(O,G),C.angle)),B=Mf(kf(le(k,L),le(O,G),C.angle)),K=Mf(kf(le(R,N),le(O,G),C.angle)),j=f5(h5(B,_)),X=f5(h5(K,_)),q=u5(g5(M,j),g5(M,X)),se={...S,x:p5(S.x-q[0]*Math.sign(C.scale[0]),0,P.naturalWidth-S.width),y:p5(S.y-q[1]*Math.sign(C.scale[1]),0,P.naturalHeight-S.height)};this.scene.mutateElement(C,{crop:se});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=q2(w,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||lU(t,p,x,this.scene,y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!je(p[0]))&&this.setState({suggestedBindings:Of(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,P=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!P.find(B=>B.id===S.id)&&P.push(S);let M=new Map(P.map(B=>[B.id,B])),{duplicatedElements:R,duplicateElementsMap:L,elementsWithDuplicates:k,origIdToDuplicateId:N}=B5({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:M,overrides:({duplicateElement:B,origElement:K})=>({frameId:B.frameId??K.frameId,seed:rG()})});R.forEach(B=>{t.originalElements.set(B.id,N5(B))});let O=k.map(B=>{if(M.has(B.id)){let K=t.originalElements.get(B.id);if(K)return jr(B,{x:K.x,y:K.y})}return B}),G=this.props.onDuplicate?.(O,C),_=Q5(G||O,Lm(R));aa(()=>{if(t.hit.element){let B=N.get(t.hit.element.id),K=B&&L.get(B);t.hit.element=K||null}t.hit.allHitElements=t.hit.allHitElements.reduce((B,K)=>{let j=N.get(K.id),X=j&&L.get(j);return X&&B.push(X),B},[]),t.drag.origin=We(r,this.state),this.setState(B=>({...rU(R,this.scene.getNonDeletedElements(),B)})),this.scene.replaceAllElements(_),this.maybeCacheVisibleGaps(r,P,!0),this.maybeCacheReferenceSnapPoints(r,P,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,r.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,r)}else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let E=p.pressures;if(!p.simulatePressure){let y=r.pressure;y===0||typeof y!="number"||isNaN(y)?y=E.length>0?E[E.length-1]:.5:y=Math.max(.1,Math.min(1,y)),E=[...p.pressures,y]}this.scene.mutateElement(p,{points:[...u,le(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(ro(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;Lf(r)&&u.length===2&&({width:f,height:b}=H5(p.x,p.y,n.x,n.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,le(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&je(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),le(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),Hf(p,!1)&&this.setState({suggestedBindings:L5(p,[n],this.scene,this.state.zoom,this.state.startBoundElement)})}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Le.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&we(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>no({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?k1(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((w,E)=>(w[E.id]=!0,w),{})};return t.hit.element&&(f.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...no({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&ro(f[0])?new Le(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||lr(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(Zl.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(Zl.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ae(r=>{this.removePointer(r),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:n,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:m,isRotating:c,isCropping:d}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Hl(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Jt.setReferenceSnapPoints(null),Jt.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up");let p=t.hit.allHitElements,u=We({clientX:r.clientX,clientY:r.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!p.some(E=>this.state.selectedElementIds[E.id])){let E=this.getElementAtPosition(u.x,u.y,{includeLockedElements:!0});this.store.scheduleCapture(),E?.locked?this.setState({activeLockedId:E.groupIds.length>0?E.groupIds.at(-1)||"":E.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});this.setState({selectedElementsAreBeingDragged:!1});let f=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let E=f.get(t.hit.element.id);wG(E)&&E.boundElements?.filter(y=>y.type==="arrow").map(y=>f.get(y.id)).filter(y=>je(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.selectedLinearElement?.isEditing)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(zt);else{let E=Le.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene);E!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=Le.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction(zt,"ui",{event:r,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(oe.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(oe.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(oe.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(oe.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),n?.type==="freedraw"){let E=We(r,this.state),y=n.points,v=E.x-n.x,C=E.y-n.y;v===y[0][0]&&C===y[0][1]&&(C+=1e-4,v+=1e-4);let S=[];if(!n.simulatePressure){let P=r.pressure;P===0||typeof P!="number"||isNaN(P)?P=n.pressures.length>0?n.pressures[n.pressures.length-1]:.5:P=Math.max(.1,Math.min(1,P)),S=[...n.pressures,P]}this.scene.mutateElement(n,{points:[...y,le(v,C)],pressures:S,lastCommittedPoint:le(v,C)}),this.actionManager.executeAction(zt);return}if(ro(n)){n.points.length>1&&this.store.scheduleCapture();let E=We(r,this.state),y=Kr(le(E.x,E.y),le(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||y<M5)&&n&&!l)if(this.device.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(n,{x:n.x-v/2,points:[le(0,0),le(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(zt)}else{let v=E.x-n.x,C=E.y-n.y;this.scene.mutateElement(n,{points:[...n.points,le(v,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:n,newElement:n})}else t.drag.hasOccurred&&!l&&(Bf(this.state)&&Hf(n,!1)&&this.actionManager.executeAction(zt,"ui",{event:r,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(Zt(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:ar(this.state,{type:this.defaultSelectionTool}),selectedElementIds:ve({...v.selectedElementIds,[n.id]:!0},v),selectedLinearElement:new Le(n,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(vo(n)){let E=jG(_f({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<E&&this.scene.mutateElement(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&U5(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==n.id),appState:{newElement:null},captureUpdate:Ct.NEVER});return}if(Rt(n)){let E=_G(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Zf(this.scene.getElementsMapIncludingDeleted(),E,n,this.state))}if(n&&(this.scene.mutateElement(n,vG(n),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=We(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let v=jf(y,f);v&&y&&(DG(y,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),AG([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),C=this.scene.getElementsMapIncludingDeleted(),S=P=>{if(P.length>0){for(let M of P){let R=M.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(M,{groupIds:M.groupIds.slice(0,R)},{informMutation:!1,isDragging:!1})}C.forEach(M=>{M.groupIds.length&&Ln(C,M.groupIds[M.groupIds.length-1]).length<2&&this.scene.mutateElement(M,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(y&&!this.state.selectedElementIds[y.id]){let P=v.filter(M=>M.frameId!==y.id&&$5(M,C,this.state));this.state.editingGroupId&&S(P),C=Zf(C,P,y,this.state)}else if(!y&&this.state.editingGroupId){let P=v.filter(M=>M.frameId&&!$5(M,C,this.state));S(P)}C=Z5(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&U5(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:Ct.NEVER}),t.resize.isResizing){let E=Z5(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(v=>Rt(v));for(let v of y)E=PG(E,$f(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&ro(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Le(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!d||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(St(this.state)&&x&&w){if(this.eraserTrail.endPath(),Kr(le(x.clientX,x.clientY),le(w.clientX,w.clientY))===0){let y=We({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(r.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?tU(this.state,b)?this.setState(E=>{let y={...E.selectedElementIds};for(let v of b.groupIds.flatMap(C=>Ln(this.scene.getNonDeletedElements(),C)))delete y[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,C)=>({...v,...C}),{})},selectedElementIds:ve(y,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let y={...E.selectedElementIds};delete y[b.id];let v=J(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...no({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&ro(v[0])?new Le(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(E=>{let y={...E.selectedElementIds,[b.id]:!0};return delete y[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>Ln(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete y[v.id]}),{...no({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||lr(b)?"info":!1}}):this.setState(E=>({selectedElementIds:ve({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...no({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:ro(b)&&E.selectedLinearElement?.elementId!==b.id?new Le(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&je(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&OG({point:le(t.origin.x,t.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:Rt(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Wi):this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),ye(this.interactiveCanvas,Be.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(E=>({selectedElementIds:ve({...E.selectedElementIds,[n.id]:!0},E),showHyperlinkPopup:lr(n)&&!n.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||we(this.scene.getNonDeletedElements(),this.state)||!oG(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||m||c||d){let E=this.scene.getSelectedElements(this.state).filter(ro);A5(E,Bf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(Zt(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:ar(this.state,{type:this.defaultSelectionTool})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&ge.pointers.size<=1&&Ul(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(r=>({selectedElementIds:ve({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&J5(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,r,n,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Xf(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<BH){let{x:d,y:p}=Mm({sceneX:a,sceneY:l},n);return{viewportX:d,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:n}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=On.find(r=>r.code===this.props.langCode)||Co;await bs(t),this.setAppState({})}},pU=()=>{(r1()||dC())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(mC(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};pU();var gC=n1;import{useEffect as hU,useState as gU}from"react";import{jsx as fU}from"react/jsx-runtime";var fC=e=>{let[o,t]=gU(!0);return hU(()=>{let r=async()=>{await bs(n),t(!1)},n=On.find(i=>i.code===e.langCode)||Co;r()},[e.langCode]),o?fU(Ud,{theme:e.theme}):e.children};import bU from"clsx";import{jsx as bC}from"react/jsx-runtime";var xC=({children:e})=>{let{FooterCenterTunnel:o}=Se(),t=xe();return bC(o.In,{children:bC("div",{className:bU("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),style:{display:"none"},children:e})})},xU=xC;xC.displayName="FooterCenter";import EU from"clsx";import{jsx as wU,jsxs as vU}from"react/jsx-runtime";var EC=({isCollaborating:e,onSelect:o,...t})=>{let r=xe(),n=r.width<830;return vU(Gt,{...t,className:EU("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:h("labels.liveCollaboration"),children:[n?Tb:h("labels.share"),r.collaborators.size>0&&wU("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},yU=EC;EC.displayName="LiveCollaborationTrigger";import{jsx as Qr,jsxs as wC}from"react/jsx-runtime";var TU=()=>Qr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Qr("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"})}),IU=()=>wC("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Qr("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)"}),Qr("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)"}),Qr("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)"}),Qr("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)"})]}),yC=({style:e,size:o="small",withText:t})=>wC("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Qr(TU,{}),t&&Qr(IU,{})]});import{Fragment as IC,jsx as qe,jsxs as m1}from"react/jsx-runtime";var p1=({icon:e,shortcut:o,children:t})=>{let r=pe();return m1(IC,{children:[qe("div",{className:"welcome-screen-menu-item__icon",children:e}),qe("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&qe("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};p1.displayName="WelcomeScreenMenuItemContent";var ql=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>qe("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:qe(p1,{icon:t,shortcut:r,children:o})});ql.displayName="WelcomeScreenMenuItem";var vC=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>qe("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noopener",children:qe(p1,{icon:t,shortcut:r,children:e})});vC.displayName="WelcomeScreenMenuItemLink";var io=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Se();return qe(o.In,{children:qe("div",{className:"welcome-screen-center",children:e||m1(IC,{children:[qe(u1,{}),qe(h1,{children:h("welcomeScreen.defaults.center_heading")}),m1(g1,{children:[qe(b1,{}),qe(f1,{})]})]})})})};io.displayName="Center";var u1=({children:e})=>qe("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||qe(yC,{withText:!0})});u1.displayName="Logo";var h1=({children:e})=>qe("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});h1.displayName="Heading";var g1=({children:e})=>qe("div",{className:"welcome-screen-menu",children:e});g1.displayName="Menu";var f1=()=>{let e=Ke();return qe(ql,{onSelect:()=>e.executeAction(hn),shortcut:"?",icon:Gn,children:h("helpDialog.title")})};f1.displayName="MenuItemHelp";var b1=()=>{let e=xe(),o=Ke();return e.viewModeEnabled?null:qe(ql,{onSelect:()=>o.executeAction(hi),shortcut:He("loadScene"),icon:Un,children:h("buttons.load")})};b1.displayName="MenuItemLoadScene";var TC=({onSelect:e})=>{let{t:o}=Ye();return qe(ql,{shortcut:null,onSelect:e,icon:Ms,children:o("labels.liveCollaboration")})};TC.displayName="MenuItemLiveCollaborationTrigger";io.Logo=u1;io.Heading=h1;io.Menu=g1;io.MenuItem=ql;io.MenuItemLink=vC;io.MenuItemHelp=f1;io.MenuItemLoadScene=b1;io.MenuItemLiveCollaborationTrigger=TC;import{jsx as ma,jsxs as x1}from"react/jsx-runtime";var _m=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Se();return ma(o.In,{children:x1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[ib,ma("div",{className:"welcome-screen-decor-hint__label",children:e||h("welcomeScreen.defaults.menuHint")})]})})};_m.displayName="MenuHint";var Dm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Se();return ma(o.In,{children:x1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ma("div",{className:"welcome-screen-decor-hint__label",children:e||h("welcomeScreen.defaults.toolbarHint")}),lb]})})};Dm.displayName="ToolbarHint";var Rm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Se();return ma(o.In,{children:x1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ma("div",{children:e||h("welcomeScreen.defaults.helpHint")}),ab]})})};Rm.displayName="HelpHint";import{Fragment as CC,jsx as Jl,jsxs as SU}from"react/jsx-runtime";var Nm=e=>Jl(CC,{children:e.children||SU(CC,{children:[Jl(io,{}),Jl(_m,{}),Jl(Dm,{}),Jl(Rm,{})]})});Nm.displayName="WelcomeScreen";Nm.Center=io;Nm.Hints={MenuHint:_m,ToolbarHint:Dm,HelpHint:Rm};var CU=Nm;var kU=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},SC=kU;import{getSceneVersion as K_e,hashElementsVersion as Z_e,hashString as $_e,getNonDeletedElements as j_e}from"@haoxin-web/excalidraw-element";import{getTextFromElements as J_e}from"@haoxin-web/excalidraw-element";import{isInvisiblySmallElement as eDe}from"@haoxin-web/excalidraw-element";import MU from"lodash.throttle";import{arrayToMap as LU,isDevEnv as kC,isTestEnv as MC}from"@haoxin-web/excalidraw-common";import{orderByFractionalIndex as PU,syncInvalidIndices as LC,validateFractionalIndices as AU}from"@haoxin-web/excalidraw-element";var _U=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<t.versionNonce)),DU=MU((e,o,t)=>{if(kC()||MC()||window?.DEBUG_FRACTIONAL_INDICES){let r=LC(e.map(n=>({...n})));AU(r,{shouldThrow:MC()||kC(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),RU=(e,o,t)=>{let r=LU(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),m=_U(t,s,l);s&&m?(n.push(s),i.add(s.id)):(n.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(n.push(l),i.add(l.id));let a=PU(n);return DU(a,e,o),LC(a),a};import{getFreeDrawSvgPath as sDe}from"@haoxin-web/excalidraw-element";import{isLinearElement as mDe}from"@haoxin-web/excalidraw-element";import{FONT_FAMILY as uDe,THEME as hDe,MIME_TYPES as gDe,ROUNDNESS as $c,DEFAULT_LASER_COLOR as fDe,UserIdleState as bDe,normalizeLink as xDe}from"@haoxin-web/excalidraw-common";import{mutateElement as qc,newElementWith as yDe,bumpVersion as Ci}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as vDe}from"@haoxin-web/excalidraw-element";import{sceneCoordsToViewportCoords as Py,viewportCoordsToSceneCoords as CDe}from"@haoxin-web/excalidraw-common";import{useState as Ql}from"react";import{jsx as Je,jsxs as An}from"react/jsx-runtime";var NU=["rectangle","ellipse","diamond","triangle","pentagon","callout","hollow_arrow","hollow_double_arrow"],BU=["line","arrow","doubleArrow","outlineArrow","outlineDoubleArrow"],FU=["pen","highlighter"],OU=({excalidrawAPI:e,className:o,style:t})=>{let[r,n]=Ql("rectangle"),[i,a]=Ql("line"),[l,s]=Ql("pen"),[m,c]=Ql(2),[d,p]=Ql("#1f1f1f"),u=!e;return An("div",{className:o,style:{display:"flex",flexDirection:"column",gap:8,padding:10,border:"1px solid #e5e7eb",borderRadius:10,width:220,background:"#fff",...t},children:[An("div",{style:{display:"flex",gap:8},children:[Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectSelection(),children:"Selection"}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectEraser(),children:"Eraser"})]}),An("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[Je("label",{style:{minWidth:70},children:"Freedraw"}),Je("select",{value:l,onChange:f=>s(f.target.value),children:FU.map(f=>Je("option",{value:f,children:f},f))}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectFreedraw({variant:l,strokeWidth:m,strokeColor:d}),children:"Apply"})]}),An("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[Je("label",{style:{minWidth:70},children:"Line"}),Je("select",{value:i,onChange:f=>a(f.target.value),children:BU.map(f=>Je("option",{value:f,children:f},f))}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectLine({variant:i,strokeWidth:m,strokeColor:d}),children:"Apply"})]}),An("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[Je("label",{style:{minWidth:70},children:"Shape"}),Je("select",{value:r,onChange:f=>n(f.target.value),children:NU.map(f=>Je("option",{value:f,children:f},f))}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectShape(r,{strokeWidth:m,strokeColor:d}),children:"Apply"})]}),An("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[Je("label",{style:{minWidth:70},children:"Text"}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectText({strokeColor:d}),children:"Text Tool"})]}),An("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[Je("label",{style:{minWidth:70},children:"Stroke"}),Je("input",{type:"number",min:1,max:20,value:m,onChange:f=>c(Number(f.target.value||1)),style:{width:60}}),Je("input",{type:"color",value:d,onChange:f=>p(f.target.value)}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.updateStyle({currentItemStrokeWidth:m,currentItemStrokeColor:d}),children:"Sync"})]})]})};import{jsx as PC,jsxs as zU}from"react/jsx-runtime";var AC=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=Se(),r=me();return PC(t.In,{children:zU(Ie.Item,{onSelect:()=>{ae("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??f0,children:[e??h("labels.textToDiagram"),PC(Ie.Item.Badge,{children:"AI"})]})})};AC.displayName="TTDDialogTrigger";import{getCommonBounds as ODe,getVisibleSceneBounds as zDe}from"@haoxin-web/excalidraw-element";import{useLayoutEffect as HU}from"react";var GU=e=>{let o=Oe();return HU(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as YDe}from"@haoxin-web/excalidraw-element";import{setCustomTextMetricsProvider as XDe}from"@haoxin-web/excalidraw-element";import{jsx as E1}from"react/jsx-runtime";SC();var VU=e=>{console.log("\u4F7F\u7528\u4E86\u7EC4\u4EF6=====Excalidraw component initialized");let{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=Co.code,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:w=!0,handleKeyboardGlobally:E=!1,onLibraryChange:y,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:P,onPointerDown:M,onPointerUp:R,onScrollChange:L,onDuplicate:k,children:N,validateEmbeddable:O,renderEmbeddable:G,aiEnabled:_,showDeprecatedFonts:B,renderScrollbars:K,showZoomActions:j,showPanActions:X,showToolBar:q,showTopLeftToolbar:se}=e,ie=e.UIOptions?.canvasActions,be={...e.UIOptions,canvasActions:{..._C.canvasActions,...ie},tools:{image:e.UIOptions?.tools?.image??!0}};return ie?.export&&(be.canvasActions.export.saveFileToDisk=ie.export?.saveFileToDisk??_C.canvasActions.export.saveFileToDisk),be.canvasActions.toggleTheme===null&&typeof u>"u"&&(be.canvasActions.toggleTheme=!0),WU(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ao=To=>{typeof To.scale=="number"&&To.scale!==1&&To.preventDefault()};return document.addEventListener("touchmove",ao,{passive:!1}),()=>{document.removeEventListener("touchmove",ao)}},[]),E1(q1,{store:Ve,children:E1(fC,{langCode:s,theme:u,children:E1(gC,{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:be,onPaste:x,detectScroll:w,handleKeyboardGlobally:E,onLibraryChange:y,autoFocus:v,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:P,onPointerDown:M,onPointerUp:R,onScrollChange:L,onDuplicate:k,validateEmbeddable:O,renderEmbeddable:G,aiEnabled:_!==!1,showDeprecatedFonts:B,renderScrollbars:K,showZoomActions:j,showPanActions:X,showToolBar:q,showTopLeftToolbar:se,children:N})})})},XU=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:r={},...n}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(r),m=Object.keys(a);return s.length!==m.length?!1:s.every(d=>d==="canvasActions"?Object.keys(r.canvasActions).every(u=>u==="export"&&r?.canvasActions?.export&&a?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:r?.canvasActions?.[u]===a?.canvasActions?.[u]):r[d]===a[d])&&YU(n,l)},KU=UU.memo(VU,XU);KU.displayName="Excalidraw";export{Gt as Button,vDe as CaptureUpdateAction,fDe as DEFAULT_LASER_COLOR,Qd as DefaultSidebar,GU as DiagramToCodePlugin,Ra as Ellipsify,KU as Excalidraw,OU as ExternalLeftToolbar,uDe as FONT_FAMILY,xU as Footer,yU as LiveCollaborationTrigger,gDe as MIME_TYPES,ft as MainMenu,$c as ROUNDNESS,oo as Sidebar,Rl as Stats,hDe as THEME,ef as TTDDialog,AC as TTDDialogTrigger,bDe as UserIdleState,Sl as UserList,CU as WelcomeScreen,Ci as bumpVersion,Xi as convertToExcalidrawElements,Co as defaultLang,d2 as elementPartiallyOverlapsWithOrContainsBBox,m2 as elementsOverlappingBBox,Ny as exportToBlob,Lr as exportToCanvas,kA as exportToClipboard,Li as exportToSvg,ODe as getCommonBounds,jm as getDataURL,sDe as getFreeDrawSvgPath,od as getLibraryItemsHash,j_e as getNonDeletedElements,K_e as getSceneVersion,J_e as getTextFromElements,zDe as getVisibleSceneBounds,Z_e as hashElementsVersion,$_e as hashString,qh as isElementInsideBBox,YDe as isElementLink,eDe as isInvisiblySmallElement,mDe as isLinearElement,On as languages,ms as loadFromBlob,$m as loadLibraryFromBlob,Zm as loadSceneOrLibraryFromBlob,Yy as mergeLibraryItems,qc as mutateElement,yDe as newElementWith,xDe as normalizeLink,fh as parseLibraryTokensFromUrl,RU as reconcileElements,Bn as restore,GC as restoreAppState,HC as restoreElement,Xm as restoreElements,fa as restoreLibraryItems,Py as sceneCoordsToViewportCoords,ua as serializeAsJSON,Vm as serializeLibraryAsJSON,XDe as setCustomTextMetricsProvider,pe as useDevice,YA as useHandleLibrary,Ye as useI18n,CDe as viewportCoordsToSceneCoords,Yx as zoomToFitBounds};
125
+ `),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=We({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:UH,verticalAlign:E5,locked:!1},l=Df({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=I5(a.fontFamily),[m,,c]=zG(this.state),d=Math.max(Math.min((c-m)*.5,800),200),p=10,u=i,f=r?[t]:t.split(`
126
+ `),b=f.reduce((x,w,E)=>{let y=XG(w).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),C=q5(y,l,s),S=C.width>d,P=S?WG(y,l,d):y;C=S?q5(P,l,s):C;let M=n-C.width/2,R=u-C.height/2,L=R5({...a,x:M,y:R,text:P,originalText:y,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(L),u+=L.height+p}else f[E-1]?.trim()&&(u+=KG(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:ve(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&cC===!1&&!this.device.editor.isMobile&&(this.setToast({message:h("toast.pasteAsSingleElement",{shortcut:jH("CtrlOrCmd+Shift+V")}),duration:5e3}),cC=!0))}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>{if(s.id===t.id&&To(s)){let m=s.customData?.textStyle||{},c=(p,u)=>p===void 0?!!u:!!p,d={bold:c(m.bold,this.state.currentTextBold),italic:c(m.italic,this.state.currentTextItalic),underline:c(m.underline,this.state.currentTextUnderline),strikethrough:c(m.strikethrough,this.state.currentTextStrikethrough)};return qr(s,{originalText:a,isDeleted:l??s.isDeleted,...bG(s,X5(s,n),n,a),customData:{...s.customData||{},textStyle:d}})}return s})])};Bv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:m}=Lm({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,m-this.state.offsetTop]},onChange:Ae(a=>{i(a,!1),nC(t)&&Of(t,this.scene)}),onSubmit:Ae(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let m=t.containerId?t.containerId:t.id;aa(()=>{this.setState(c=>({selectedElementIds:ve({...c.selectedElementIds,[m]:!0},c)}))})}s&&sG(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.scheduleCapture(),aa(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Ot(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&To(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=[];if(n&&"allHitElements"in n?i=n?.allHitElements||[]:i=this.getElementsAtPosition(t,r,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),i.length>1){if(n?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return Wl({point:le(t,r),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Rt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n){let i=[],a=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n?.includeLockedElements||!s.locked)&&(n?.includeBoundTextElement||!(To(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let m=qf(s,a);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?K5({x:t,y:r},m,a):!0}).filter(s=>da(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(T5/this.state.zoom.value))}hitElement(t,r,n,i=!0){return i&&this.state.selectedElementIds[n.id]&&LG([n],this.state)&&dU(le(t,r),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||FG(le(t,r),n,this.scene.getNonDeletedElementsMap())?!0:Wl({point:le(t,r),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Rt(n)?this.frameNameBoundsCache.get(n):null})}getTextBindableContainerAtPosition(t,r){let n=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return z5(i[0],!1)?i[0]:null;let a=null;for(let l=n.length-1;l>=0;--l){if(n[l].isDeleted)continue;let[s,m,c,d]=P5(n[l],this.scene.getNonDeletedElementsMap());if(Hf(n[l])&&Wl({point:le(t,r),element:n[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[l])})){a=n[l];break}else if(s<t&&t<c&&m<r&&r<d){a=n[l];break}}return z5(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=Le.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;Wl({point:le(r,n),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Le.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=Le.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(je(a)?l===0||l===a.points.length-1:l>=0)||s?ye(this.interactiveCanvas,Be.POINTER):this.hitElement(r,n,a)&&(!je(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,Be.MOVE)):this.hitElement(r,n,a)&&(!je(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&ye(this.interactiveCanvas,Be.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),Le.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else ye(this.interactiveCanvas,Be.AUTO)}updateGestureOnPointerDown(t){ge.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),ge.pointers.size===2&&(ge.lastCenter=cg(ge.pointers),ge.initialScale=this.state.zoom.value,ge.initialDistance=dg(Array.from(ge.pointers.values())))}initialPointerDownState(t){let r=We(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=ca(n),m=n.findIndex(je)===0;return{origin:r,withCmdOrCtrl:t[V.CTRL_OR_CMD],originInGrid:Rf(st(r.x,r.y,t[V.CTRL_OR_CMD]||m?null:this.getEffectiveGridSize())),scrollbars:fg(Zl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((c,d)=>(c.set(d.id,N5(d)),c),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null,origin:{...r},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;t1=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=Od(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=Ae(()=>{jl=null,t1=!1,Ot(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(oe.POINTER_MOVE,n),window.removeEventListener(oe.POINTER_UP,i),n.flush()});return jl=i,window.addEventListener(oe.POINTER_MOVE,n),window.addEventListener(oe.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=Math.max(T5/this.state.zoom.value,1),[i,a,l,s]=ca(r);return t.x>i-n&&t.x<l+n&&t.y>a-n&&t.y<s+n}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:EG(t)?Sm.ADAPTIVE_RADIUS:Sm.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){tr({event:t,app:this,selectedElements:r})&&(n||!Jt.getReferenceSnapPoints())&&Jt.setReferenceSnapPoints(q2(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){tr({event:t,app:this,selectedElements:r})&&(n||!Jt.getVisibleGaps())&&Jt.setVisibleGaps(j2(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Ae(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return Ae(r=>{r.key===V.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return Od(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=We(r,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=st(n.x,n.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=Le.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?Le.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=Le.moveFixedSegment(this.state.selectedLinearElement,f,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=n,t.drag.offset===null&&(t.drag.offset=Rf(sU(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(St(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=st(n.x,n.y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Zr(le(n.x,n.y),le(t.origin.x,t.origin.y))*this.state.zoom.value<M5)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleCrop(t,r)||this.maybeHandleResize(t,r)))return!0;let m=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Le.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,m)){let f=Le.addMidpoint(this.state.selectedLinearElement,n,this,!r[V.CTRL_OR_CMD],this.scene);if(!f)return;aa(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=Le.handlePointDragging(r,this,n.x,n.y,p);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState(u);return}}let c=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),d=this.state.selectedLinearElement?.isEditing&&r.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((c||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!d&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(x=>x.locked))return;let u=p.find(x=>Rt(x)),f=this.getTopLayerFrameAtSceneCoords(n),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&aa(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.isMobileOrTablet()&&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 x={x:n.x-t.drag.origin.x,y:n.y-t.drag.origin.y},w=[...t.originalElements.values()],E=r.shiftKey;if(E){let C=Math.abs(x.x),S=Math.abs(x.y),P=E&&C<S,M=E&&C>S;P&&(x.x=0),M&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&Mn(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,P=Gl(C)&&this.imageCache.get(C.fileId)?.image;if(P&&!(P instanceof Promise)){let M=wH(u5(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[R,L,k,N,O,G]=P5(C,m),_=Lf(Mf(le(R,L),le(O,G),C.angle)),B=Lf(Mf(le(k,L),le(O,G),C.angle)),K=Lf(Mf(le(R,N),le(O,G),C.angle)),j=f5(h5(B,_)),X=f5(h5(K,_)),q=u5(g5(M,j),g5(M,X)),se={...S,x:p5(S.x-q[0]*Math.sign(C.scale[0]),0,P.naturalWidth-S.width),y:p5(S.y-q[1]*Math.sign(C.scale[1]),0,P.naturalHeight-S.height)};this.scene.mutateElement(C,{crop:se});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=J2(w,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||lU(t,p,x,this.scene,y,r[V.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!je(p[0]))&&this.setState({suggestedBindings:zf(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,P=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!P.find(B=>B.id===S.id)&&P.push(S);let M=new Map(P.map(B=>[B.id,B])),{duplicatedElements:R,duplicateElementsMap:L,elementsWithDuplicates:k,origIdToDuplicateId:N}=B5({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:M,overrides:({duplicateElement:B,origElement:K})=>({frameId:B.frameId??K.frameId,seed:rG()})});R.forEach(B=>{t.originalElements.set(B.id,N5(B))});let O=k.map(B=>{if(M.has(B.id)){let K=t.originalElements.get(B.id);if(K)return qr(B,{x:K.x,y:K.y})}return B}),G=this.props.onDuplicate?.(O,C),_=Q5(G||O,Pm(R));aa(()=>{if(t.hit.element){let B=N.get(t.hit.element.id),K=B&&L.get(B);t.hit.element=K||null}t.hit.allHitElements=t.hit.allHitElements.reduce((B,K)=>{let j=N.get(K.id),X=j&&L.get(j);return X&&B.push(X),B},[]),t.drag.origin=We(r,this.state),this.setState(B=>({...rU(R,this.scene.getNonDeletedElements(),B)})),this.scene.replaceAllElements(_),this.maybeCacheVisibleGaps(r,P,!0),this.maybeCacheReferenceSnapPoints(r,P,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,r.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,r)}else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let E=p.pressures;if(!p.simulatePressure){let y=r.pressure;y===0||typeof y!="number"||isNaN(y)?y=E.length>0?E[E.length-1]:.5:y=Math.max(.1,Math.min(1,y)),E=[...p.pressures,y]}this.scene.mutateElement(p,{points:[...u,le(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(ro(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;Pf(r)&&u.length===2&&({width:f,height:b}=H5(p.x,p.y,n.x,n.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,le(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&je(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),le(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),Gf(p,!1)&&this.setState({suggestedBindings:L5(p,[n],this.scene,this.state.zoom,this.state.startBoundElement)})}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Le.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&we(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>no({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?M1(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((w,E)=>(w[E.id]=!0,w),{})};return t.hit.element&&(f.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...no({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&ro(f[0])?new Le(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||lr(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(Zl.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(Zl.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return Ae(r=>{this.removePointer(r),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:n,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:m,isRotating:c,isCropping:d}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Hl(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Jt.setReferenceSnapPoints(null),Jt.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up");let p=t.hit.allHitElements,u=We({clientX:r.clientX,clientY:r.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!p.some(E=>this.state.selectedElementIds[E.id])){let E=this.getElementAtPosition(u.x,u.y,{includeLockedElements:!0});this.store.scheduleCapture(),E?.locked?this.setState({activeLockedId:E.groupIds.length>0?E.groupIds.at(-1)||"":E.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});this.setState({selectedElementsAreBeingDragged:!1});let f=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let E=f.get(t.hit.element.id);wG(E)&&E.boundElements?.filter(y=>y.type==="arrow").map(y=>f.get(y.id)).filter(y=>je(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.selectedLinearElement?.isEditing)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(zt);else{let E=Le.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene);E!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=Le.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction(zt,"ui",{event:r,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(oe.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(oe.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(oe.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(oe.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),n?.type==="freedraw"){let E=We(r,this.state),y=n.points,v=E.x-n.x,C=E.y-n.y;v===y[0][0]&&C===y[0][1]&&(C+=1e-4,v+=1e-4);let S=[];if(!n.simulatePressure){let P=r.pressure;P===0||typeof P!="number"||isNaN(P)?P=n.pressures.length>0?n.pressures[n.pressures.length-1]:.5:P=Math.max(.1,Math.min(1,P)),S=[...n.pressures,P]}this.scene.mutateElement(n,{points:[...y,le(v,C)],pressures:S,lastCommittedPoint:le(v,C)}),this.actionManager.executeAction(zt);return}if(ro(n)){n.points.length>1&&this.store.scheduleCapture();let E=We(r,this.state),y=Zr(le(E.x,E.y),le(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||y<M5)&&n&&!l)if(this.device.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(n,{x:n.x-v/2,points:[le(0,0),le(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(zt)}else{let v=E.x-n.x,C=E.y-n.y;this.scene.mutateElement(n,{points:[...n.points,le(v,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:n,newElement:n})}else t.drag.hasOccurred&&!l&&(Ff(this.state)&&Gf(n,!1)&&this.actionManager.executeAction(zt,"ui",{event:r,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(Zt(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:ar(this.state,{type:this.defaultSelectionTool}),selectedElementIds:ve({...v.selectedElementIds,[n.id]:!0},v),selectedLinearElement:new Le(n,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(To(n)){let E=jG(Df({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<E&&this.scene.mutateElement(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&U5(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==n.id),appState:{newElement:null},captureUpdate:Ct.NEVER});return}if(Rt(n)){let E=_G(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements($f(this.scene.getElementsMapIncludingDeleted(),E,n,this.state))}if(n&&(this.scene.mutateElement(n,vG(n),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=We(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let v=qf(y,f);v&&y&&(DG(y,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),AG([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),C=this.scene.getElementsMapIncludingDeleted(),S=P=>{if(P.length>0){for(let M of P){let R=M.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(M,{groupIds:M.groupIds.slice(0,R)},{informMutation:!1,isDragging:!1})}C.forEach(M=>{M.groupIds.length&&Ln(C,M.groupIds[M.groupIds.length-1]).length<2&&this.scene.mutateElement(M,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(y&&!this.state.selectedElementIds[y.id]){let P=v.filter(M=>M.frameId!==y.id&&$5(M,C,this.state));this.state.editingGroupId&&S(P),C=$f(C,P,y,this.state)}else if(!y&&this.state.editingGroupId){let P=v.filter(M=>M.frameId&&!$5(M,C,this.state));S(P)}C=Z5(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&U5(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:Ct.NEVER}),t.resize.isResizing){let E=Z5(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(v=>Rt(v));for(let v of y)E=PG(E,jf(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&ro(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Le(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!d||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(St(this.state)&&x&&w){if(this.eraserTrail.endPath(),Zr(le(x.clientX,x.clientY),le(w.clientX,w.clientY))===0){let y=We({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(r.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?tU(this.state,b)?this.setState(E=>{let y={...E.selectedElementIds};for(let v of b.groupIds.flatMap(C=>Ln(this.scene.getNonDeletedElements(),C)))delete y[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,C)=>({...v,...C}),{})},selectedElementIds:ve(y,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let y={...E.selectedElementIds};delete y[b.id];let v=J(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...no({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&ro(v[0])?new Le(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(E=>{let y={...E.selectedElementIds,[b.id]:!0};return delete y[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>Ln(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete y[v.id]}),{...no({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||lr(b)?"info":!1}}):this.setState(E=>({selectedElementIds:ve({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...no({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:ro(b)&&E.selectedLinearElement?.elementId!==b.id?new Le(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&je(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&OG({point:le(t.origin.x,t.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:Rt(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(Wi):this.setState({selectedElementIds:ve({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),ye(this.interactiveCanvas,Be.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(E=>({selectedElementIds:ve({...E.selectedElementIds,[n.id]:!0},E),showHyperlinkPopup:lr(n)&&!n.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||we(this.scene.getNonDeletedElements(),this.state)||!oG(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||m||c||d){let E=this.scene.getSelectedElements(this.state).filter(ro);A5(E,Ff(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(Zt(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:ar(this.state,{type:this.defaultSelectionTool})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&ge.pointers.size<=1&&Ul(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(r=>({selectedElementIds:ve({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&J5(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:ve({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,r,n,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Kf(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<BH){let{x:d,y:p}=Lm({sceneX:a,sceneY:l},n);return{viewportX:d,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:r,top:n}=t.getBoundingClientRect();return{offsetLeft:r,offsetTop:n}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=On.find(r=>r.code===this.props.langCode)||So;await bs(t),this.setAppState({})}},pU=()=>{(n1()||dC())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(mC(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};pU();var gC=i1;import{useEffect as hU,useState as gU}from"react";import{jsx as fU}from"react/jsx-runtime";var fC=e=>{let[o,t]=gU(!0);return hU(()=>{let r=async()=>{await bs(n),t(!1)},n=On.find(i=>i.code===e.langCode)||So;r()},[e.langCode]),o?fU(Wd,{theme:e.theme}):e.children};import bU from"clsx";import{jsx as bC}from"react/jsx-runtime";var xC=({children:e})=>{let{FooterCenterTunnel:o}=Se(),t=xe();return bC(o.In,{children:bC("div",{className:bU("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),style:{display:"none"},children:e})})},xU=xC;xC.displayName="FooterCenter";import EU from"clsx";import{jsx as wU,jsxs as vU}from"react/jsx-runtime";var EC=({isCollaborating:e,onSelect:o,...t})=>{let r=xe(),n=r.width<830;return vU(Gt,{...t,className:EU("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:h("labels.liveCollaboration"),children:[n?Ib:h("labels.share"),r.collaborators.size>0&&wU("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},yU=EC;EC.displayName="LiveCollaborationTrigger";import{jsx as en,jsxs as wC}from"react/jsx-runtime";var TU=()=>en("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:en("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"})}),IU=()=>wC("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[en("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)"}),en("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)"}),en("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)"}),en("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)"})]}),yC=({style:e,size:o="small",withText:t})=>wC("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[en(TU,{}),t&&en(IU,{})]});import{Fragment as IC,jsx as qe,jsxs as p1}from"react/jsx-runtime";var u1=({icon:e,shortcut:o,children:t})=>{let r=pe();return p1(IC,{children:[qe("div",{className:"welcome-screen-menu-item__icon",children:e}),qe("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&qe("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};u1.displayName="WelcomeScreenMenuItemContent";var ql=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>qe("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:qe(u1,{icon:t,shortcut:r,children:o})});ql.displayName="WelcomeScreenMenuItem";var vC=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>qe("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noopener",children:qe(u1,{icon:t,shortcut:r,children:e})});vC.displayName="WelcomeScreenMenuItemLink";var io=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Se();return qe(o.In,{children:qe("div",{className:"welcome-screen-center",children:e||p1(IC,{children:[qe(h1,{}),qe(g1,{children:h("welcomeScreen.defaults.center_heading")}),p1(f1,{children:[qe(x1,{}),qe(b1,{})]})]})})})};io.displayName="Center";var h1=({children:e})=>qe("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||qe(yC,{withText:!0})});h1.displayName="Logo";var g1=({children:e})=>qe("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});g1.displayName="Heading";var f1=({children:e})=>qe("div",{className:"welcome-screen-menu",children:e});f1.displayName="Menu";var b1=()=>{let e=Ke();return qe(ql,{onSelect:()=>e.executeAction(gn),shortcut:"?",icon:Gn,children:h("helpDialog.title")})};b1.displayName="MenuItemHelp";var x1=()=>{let e=xe(),o=Ke();return e.viewModeEnabled?null:qe(ql,{onSelect:()=>o.executeAction(hi),shortcut:He("loadScene"),icon:Un,children:h("buttons.load")})};x1.displayName="MenuItemLoadScene";var TC=({onSelect:e})=>{let{t:o}=Ye();return qe(ql,{shortcut:null,onSelect:e,icon:Ms,children:o("labels.liveCollaboration")})};TC.displayName="MenuItemLiveCollaborationTrigger";io.Logo=h1;io.Heading=g1;io.Menu=f1;io.MenuItem=ql;io.MenuItemLink=vC;io.MenuItemHelp=b1;io.MenuItemLoadScene=x1;io.MenuItemLiveCollaborationTrigger=TC;import{jsx as ma,jsxs as E1}from"react/jsx-runtime";var Dm=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Se();return ma(o.In,{children:E1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[ab,ma("div",{className:"welcome-screen-decor-hint__label",children:e||h("welcomeScreen.defaults.menuHint")})]})})};Dm.displayName="MenuHint";var Rm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Se();return ma(o.In,{children:E1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[ma("div",{className:"welcome-screen-decor-hint__label",children:e||h("welcomeScreen.defaults.toolbarHint")}),sb]})})};Rm.displayName="ToolbarHint";var Nm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Se();return ma(o.In,{children:E1("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[ma("div",{children:e||h("welcomeScreen.defaults.helpHint")}),lb]})})};Nm.displayName="HelpHint";import{Fragment as CC,jsx as Jl,jsxs as SU}from"react/jsx-runtime";var Bm=e=>Jl(CC,{children:e.children||SU(CC,{children:[Jl(io,{}),Jl(Dm,{}),Jl(Rm,{}),Jl(Nm,{})]})});Bm.displayName="WelcomeScreen";Bm.Center=io;Bm.Hints={MenuHint:Dm,ToolbarHint:Rm,HelpHint:Nm};var CU=Bm;var kU=()=>{Array.prototype.at||Object.defineProperty(Array.prototype,"at",{value:function(e){if(e=Math.trunc(e)||0,e<0&&(e+=this.length),!(e<0||e>=this.length))return this[e]},writable:!0,enumerable:!1,configurable:!0}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(...e){this.innerHTML="",this.append(...e)})},SC=kU;import{getSceneVersion as j_e,hashElementsVersion as q_e,hashString as J_e,getNonDeletedElements as Q_e}from"@haoxin-web/excalidraw-element";import{getTextFromElements as tDe}from"@haoxin-web/excalidraw-element";import{isInvisiblySmallElement as rDe}from"@haoxin-web/excalidraw-element";import MU from"lodash.throttle";import{arrayToMap as LU,isDevEnv as kC,isTestEnv as MC}from"@haoxin-web/excalidraw-common";import{orderByFractionalIndex as PU,syncInvalidIndices as LC,validateFractionalIndices as AU}from"@haoxin-web/excalidraw-element";var _U=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<t.versionNonce)),DU=MU((e,o,t)=>{if(kC()||MC()||window?.DEBUG_FRACTIONAL_INDICES){let r=LC(e.map(n=>({...n})));AU(r,{shouldThrow:MC()||kC(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),RU=(e,o,t)=>{let r=LU(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),m=_U(t,s,l);s&&m?(n.push(s),i.add(s.id)):(n.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(n.push(l),i.add(l.id));let a=PU(n);return DU(a,e,o),LC(a),a};import{getFreeDrawSvgPath as mDe}from"@haoxin-web/excalidraw-element";import{isLinearElement as hDe}from"@haoxin-web/excalidraw-element";import{FONT_FAMILY as fDe,THEME as bDe,MIME_TYPES as xDe,ROUNDNESS as $c,DEFAULT_LASER_COLOR as EDe,UserIdleState as yDe,normalizeLink as wDe}from"@haoxin-web/excalidraw-common";import{mutateElement as qc,newElementWith as TDe,bumpVersion as Ci}from"@haoxin-web/excalidraw-element";import{CaptureUpdateAction as CDe}from"@haoxin-web/excalidraw-element";import{sceneCoordsToViewportCoords as Ay,viewportCoordsToSceneCoords as MDe}from"@haoxin-web/excalidraw-common";import{useState as Ql}from"react";import{jsx as Je,jsxs as An}from"react/jsx-runtime";var NU=["rectangle","ellipse","diamond","triangle","pentagon","callout","hollow_arrow","hollow_double_arrow"],BU=["line","arrow","doubleArrow","outlineArrow","outlineDoubleArrow"],FU=["pen","highlighter"],OU=({excalidrawAPI:e,className:o,style:t})=>{let[r,n]=Ql("rectangle"),[i,a]=Ql("line"),[l,s]=Ql("pen"),[m,c]=Ql(2),[d,p]=Ql("#1f1f1f"),u=!e;return An("div",{className:o,style:{display:"flex",flexDirection:"column",gap:8,padding:10,border:"1px solid #e5e7eb",borderRadius:10,width:220,background:"#fff",...t},children:[An("div",{style:{display:"flex",gap:8},children:[Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectSelection(),children:"Selection"}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectEraser(),children:"Eraser"})]}),An("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[Je("label",{style:{minWidth:70},children:"Freedraw"}),Je("select",{value:l,onChange:f=>s(f.target.value),children:FU.map(f=>Je("option",{value:f,children:f},f))}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectFreedraw({variant:l,strokeWidth:m,strokeColor:d}),children:"Apply"})]}),An("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[Je("label",{style:{minWidth:70},children:"Line"}),Je("select",{value:i,onChange:f=>a(f.target.value),children:BU.map(f=>Je("option",{value:f,children:f},f))}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectLine({variant:i,strokeWidth:m,strokeColor:d}),children:"Apply"})]}),An("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[Je("label",{style:{minWidth:70},children:"Shape"}),Je("select",{value:r,onChange:f=>n(f.target.value),children:NU.map(f=>Je("option",{value:f,children:f},f))}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectShape(r,{strokeWidth:m,strokeColor:d}),children:"Apply"})]}),An("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[Je("label",{style:{minWidth:70},children:"Text"}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.selectText({strokeColor:d}),children:"Text Tool"})]}),An("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[Je("label",{style:{minWidth:70},children:"Stroke"}),Je("input",{type:"number",min:1,max:20,value:m,onChange:f=>c(Number(f.target.value||1)),style:{width:60}}),Je("input",{type:"color",value:d,onChange:f=>p(f.target.value)}),Je("button",{type:"button",disabled:u,onClick:()=>e?.leftToolbar.updateStyle({currentItemStrokeWidth:m,currentItemStrokeColor:d}),children:"Sync"})]})]})};import{jsx as PC,jsxs as zU}from"react/jsx-runtime";var AC=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=Se(),r=me();return PC(t.In,{children:zU(Ie.Item,{onSelect:()=>{ae("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??b0,children:[e??h("labels.textToDiagram"),PC(Ie.Item.Badge,{children:"AI"})]})})};AC.displayName="TTDDialogTrigger";import{getCommonBounds as GDe,getVisibleSceneBounds as UDe}from"@haoxin-web/excalidraw-element";import{useLayoutEffect as HU}from"react";var GU=e=>{let o=Oe();return HU(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as KDe}from"@haoxin-web/excalidraw-element";import{setCustomTextMetricsProvider as $De}from"@haoxin-web/excalidraw-element";import{jsx as y1}from"react/jsx-runtime";SC();var VU=e=>{console.log("\u4F7F\u7528\u4E86\u7EC4\u4EF6=====Excalidraw component initialized");let{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=So.code,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:w=!0,handleKeyboardGlobally:E=!1,onLibraryChange:y,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:P,onPointerDown:M,onPointerUp:R,onScrollChange:L,onDuplicate:k,children:N,validateEmbeddable:O,renderEmbeddable:G,aiEnabled:_,showDeprecatedFonts:B,renderScrollbars:K,showZoomActions:j,showPanActions:X,showToolBar:q,showTopLeftToolbar:se}=e,ie=e.UIOptions?.canvasActions,be={...e.UIOptions,canvasActions:{..._C.canvasActions,...ie},tools:{image:e.UIOptions?.tools?.image??!0}};return ie?.export&&(be.canvasActions.export.saveFileToDisk=ie.export?.saveFileToDisk??_C.canvasActions.export.saveFileToDisk),be.canvasActions.toggleTheme===null&&typeof u>"u"&&(be.canvasActions.toggleTheme=!0),WU(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let ao=Io=>{typeof Io.scale=="number"&&Io.scale!==1&&Io.preventDefault()};return document.addEventListener("touchmove",ao,{passive:!1}),()=>{document.removeEventListener("touchmove",ao)}},[]),y1(J1,{store:Ve,children:y1(fC,{langCode:s,theme:u,children:y1(gC,{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:m,zenModeEnabled:c,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:be,onPaste:x,detectScroll:w,handleKeyboardGlobally:E,onLibraryChange:y,autoFocus:v,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:P,onPointerDown:M,onPointerUp:R,onScrollChange:L,onDuplicate:k,validateEmbeddable:O,renderEmbeddable:G,aiEnabled:_!==!1,showDeprecatedFonts:B,renderScrollbars:K,showZoomActions:j,showPanActions:X,showToolBar:q,showTopLeftToolbar:se,children:N})})})},XU=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:r={},...n}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(r),m=Object.keys(a);return s.length!==m.length?!1:s.every(d=>d==="canvasActions"?Object.keys(r.canvasActions).every(u=>u==="export"&&r?.canvasActions?.export&&a?.canvasActions?.export?r.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:r?.canvasActions?.[u]===a?.canvasActions?.[u]):r[d]===a[d])&&YU(n,l)},KU=UU.memo(VU,XU);KU.displayName="Excalidraw";export{Gt as Button,CDe as CaptureUpdateAction,EDe as DEFAULT_LASER_COLOR,em as DefaultSidebar,GU as DiagramToCodePlugin,Ra as Ellipsify,KU as Excalidraw,OU as ExternalLeftToolbar,fDe as FONT_FAMILY,xU as Footer,yU as LiveCollaborationTrigger,xDe as MIME_TYPES,ft as MainMenu,$c as ROUNDNESS,oo as Sidebar,Rl as Stats,bDe as THEME,tf as TTDDialog,AC as TTDDialogTrigger,yDe as UserIdleState,Sl as UserList,CU as WelcomeScreen,Ci as bumpVersion,Xi as convertToExcalidrawElements,So as defaultLang,m2 as elementPartiallyOverlapsWithOrContainsBBox,p2 as elementsOverlappingBBox,By as exportToBlob,Lr as exportToCanvas,kA as exportToClipboard,Li as exportToSvg,GDe as getCommonBounds,qm as getDataURL,mDe as getFreeDrawSvgPath,od as getLibraryItemsHash,Q_e as getNonDeletedElements,j_e as getSceneVersion,tDe as getTextFromElements,UDe as getVisibleSceneBounds,q_e as hashElementsVersion,J_e as hashString,Jh as isElementInsideBBox,KDe as isElementLink,rDe as isInvisiblySmallElement,hDe as isLinearElement,On as languages,ms as loadFromBlob,jm as loadLibraryFromBlob,$m as loadSceneOrLibraryFromBlob,Vy as mergeLibraryItems,qc as mutateElement,TDe as newElementWith,wDe as normalizeLink,bh as parseLibraryTokensFromUrl,RU as reconcileElements,Bn as restore,GC as restoreAppState,HC as restoreElement,Km as restoreElements,fa as restoreLibraryItems,Ay as sceneCoordsToViewportCoords,ua as serializeAsJSON,Xm as serializeLibraryAsJSON,$De as setCustomTextMetricsProvider,pe as useDevice,YA as useHandleLibrary,Ye as useI18n,MDe as viewportCoordsToSceneCoords,Vx as zoomToFitBounds};