@dwelle/excalidraw 0.5.0-ddf5c00 → 0.5.0-dfd3a9a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/chunk-6AV52PJO.js +5805 -0
- package/dist/dev/chunk-6AV52PJO.js.map +7 -0
- package/dist/dev/{chunk-N4RJWLSZ.js → chunk-G5DT2A72.js} +15 -5
- package/dist/dev/chunk-G5DT2A72.js.map +7 -0
- package/dist/dev/chunk-WYHOCMLG.js +7 -0
- package/dist/dev/chunk-WYHOCMLG.js.map +7 -0
- package/dist/dev/data/{image-7TSQCOPJ.js → image-CVNOYW5X.js} +3 -3
- package/dist/dev/index.css +104 -22
- package/dist/dev/index.css.map +3 -3
- package/dist/dev/index.js +25076 -19609
- package/dist/dev/index.js.map +4 -4
- package/dist/dev/locales/{en-KO5RAUUV.js → en-KEYRB5CP.js} +2 -2
- package/dist/dev/subset-shared.chunk.js +1 -1
- package/dist/dev/subset-worker.chunk.js +1 -1
- package/dist/prod/chunk-76R4CNZA.js +12 -0
- package/dist/prod/chunk-DHNAMUY4.js +4 -0
- package/dist/prod/chunk-SS5RKRMN.js +7 -0
- package/dist/prod/data/image-YVTXQC5H.js +1 -0
- package/dist/prod/index.css +1 -1
- package/dist/prod/index.js +33 -20
- package/dist/prod/locales/{en-6574ZDO2.js → en-CQGKCVPT.js} +1 -1
- package/dist/prod/subset-shared.chunk.js +1 -1
- package/dist/prod/subset-worker.chunk.js +1 -1
- package/dist/types/common/src/constants.d.ts +20 -3
- package/dist/types/{excalidraw → common/src}/emitter.d.ts +1 -1
- package/dist/types/common/src/font-metadata.d.ts +4 -2
- package/dist/types/common/src/index.d.ts +1 -0
- package/dist/types/common/src/utility-types.d.ts +5 -0
- package/dist/types/common/src/utils.d.ts +17 -4
- package/dist/types/{excalidraw/scene → element/src}/Scene.d.ts +11 -14
- package/dist/types/element/src/align.d.ts +4 -3
- package/dist/types/element/src/binding.d.ts +26 -16
- package/dist/types/element/src/bounds.d.ts +13 -5
- package/dist/types/element/src/collision.d.ts +18 -12
- package/dist/types/element/src/cropElement.d.ts +1 -1
- package/dist/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +63 -38
- package/dist/types/element/src/distance.d.ts +2 -2
- package/dist/types/element/src/distribute.d.ts +2 -1
- package/dist/types/element/src/dragElements.d.ts +3 -2
- package/dist/types/element/src/duplicate.d.ts +10 -13
- package/dist/types/element/src/elbowArrow.d.ts +1 -1
- package/dist/types/element/src/flowchart.d.ts +3 -2
- package/dist/types/element/src/fractionalIndex.d.ts +9 -3
- package/dist/types/element/src/frame.d.ts +5 -4
- package/dist/types/element/src/groups.d.ts +1 -0
- package/dist/types/element/src/index.d.ts +43 -2
- package/dist/types/element/src/linearElementEditor.d.ts +22 -36
- package/dist/types/element/src/mutateElement.d.ts +11 -3
- package/dist/types/element/src/newElement.d.ts +4 -3
- package/dist/types/element/src/resizeElements.d.ts +5 -4
- package/dist/types/element/src/selection.d.ts +11 -5
- package/dist/types/element/src/shape.d.ts +42 -0
- package/dist/types/element/src/sizeHelpers.d.ts +2 -2
- package/dist/types/element/src/store.d.ts +232 -0
- package/dist/types/element/src/textElement.d.ts +4 -3
- package/dist/types/element/src/typeChecks.d.ts +19 -1
- package/dist/types/element/src/types.d.ts +15 -2
- package/dist/types/element/src/utils.d.ts +16 -6
- package/dist/types/element/src/zindex.d.ts +1 -1
- package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +42 -51
- package/dist/types/excalidraw/actions/actionBoundText.d.ts +28 -34
- package/dist/types/excalidraw/actions/actionCanvas.d.ts +188 -227
- package/dist/types/excalidraw/actions/actionClipboard.d.ts +81 -98
- package/dist/types/excalidraw/actions/actionCropEditor.d.ts +14 -17
- package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +37 -45
- package/dist/types/excalidraw/actions/actionElementLink.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionElementLock.d.ts +43 -50
- package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +14 -17
- package/dist/types/excalidraw/actions/actionExport.d.ts +141 -168
- package/dist/types/excalidraw/actions/actionFinalize.d.ts +71 -37
- package/dist/types/excalidraw/actions/actionFrame.d.ts +103 -115
- package/dist/types/excalidraw/actions/actionGroup.d.ts +28 -34
- package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
- package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +506 -16
- package/dist/types/excalidraw/actions/actionLink.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionMenu.d.ts +39 -48
- package/dist/types/excalidraw/actions/actionNavigate.d.ts +27 -33
- package/dist/types/excalidraw/actions/actionProperties.d.ts +203 -240
- package/dist/types/excalidraw/actions/actionSelectAll.d.ts +13 -16
- package/dist/types/excalidraw/actions/actionStyles.d.ts +14 -17
- package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +14 -17
- package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +14 -17
- package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +13 -189
- package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
- package/dist/types/excalidraw/actions/actionToggleStats.d.ts +14 -17
- package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +14 -17
- package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +14 -17
- package/dist/types/excalidraw/actions/types.d.ts +4 -3
- package/dist/types/excalidraw/appState.d.ts +20 -11
- package/dist/types/excalidraw/components/App.d.ts +31 -19
- package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
- package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
- package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -1
- package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -3
- package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -3
- package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -2
- package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
- package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
- package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
- package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +4 -3
- package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
- package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
- package/dist/types/excalidraw/components/Range.d.ts +3 -3
- package/dist/types/excalidraw/components/Stats/Angle.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
- package/dist/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/DragInput.d.ts +12 -2
- package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/Position.d.ts +1 -1
- package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -11
- package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
- package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
- package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
- package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
- package/dist/types/excalidraw/components/icons.d.ts +3 -0
- package/dist/types/excalidraw/components/shapes.d.ts +1 -1
- package/dist/types/excalidraw/data/transform.d.ts +1 -1
- package/dist/types/excalidraw/editor-jotai.d.ts +6 -6
- package/dist/types/excalidraw/eraser/index.d.ts +0 -2
- package/dist/types/excalidraw/fonts/Fonts.d.ts +1 -1
- package/dist/types/excalidraw/history.d.ts +30 -22
- package/dist/types/excalidraw/hooks/useEmitter.d.ts +1 -1
- package/dist/types/excalidraw/index.d.ts +10 -9
- package/dist/types/excalidraw/lasso/index.d.ts +1 -0
- package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
- package/dist/types/excalidraw/renderer/helpers.d.ts +6 -1
- package/dist/types/excalidraw/scene/Renderer.d.ts +1 -2
- package/dist/types/excalidraw/scene/export.d.ts +1 -1
- package/dist/types/excalidraw/scene/index.d.ts +2 -2
- package/dist/types/excalidraw/scene/scrollbars.d.ts +2 -3
- package/dist/types/excalidraw/scene/types.d.ts +2 -0
- package/dist/types/excalidraw/snapping.d.ts +2 -2
- package/dist/types/excalidraw/types.d.ts +30 -10
- package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
- package/dist/types/math/src/angle.d.ts +2 -0
- package/dist/types/math/src/constants.d.ts +3 -0
- package/dist/types/math/src/curve.d.ts +34 -0
- package/dist/types/math/src/index.d.ts +1 -0
- package/dist/types/math/src/point.d.ts +1 -1
- package/dist/types/math/src/rectangle.d.ts +2 -0
- package/dist/types/math/src/vector.d.ts +8 -2
- package/dist/types/utils/src/bbox.d.ts +1 -1
- package/dist/types/utils/src/index.d.ts +1 -1
- package/dist/types/utils/src/withinBounds.d.ts +1 -1
- package/history.ts +147 -110
- package/package.json +11 -8
- package/dist/dev/chunk-N4RJWLSZ.js.map +0 -7
- package/dist/dev/chunk-U4RZP56O.js +0 -18849
- package/dist/dev/chunk-U4RZP56O.js.map +0 -7
- package/dist/dev/chunk-XCMEWBOW.js +0 -7
- package/dist/dev/chunk-XCMEWBOW.js.map +0 -7
- package/dist/prod/chunk-3ZKFSMTS.js +0 -7
- package/dist/prod/chunk-OYRPRL6F.js +0 -12
- package/dist/prod/chunk-YO4ODNEY.js +0 -33
- package/dist/prod/data/image-TCFXBYOI.js +0 -1
- package/dist/types/element/src/Shape.d.ts +0 -17
- package/dist/types/element/src/ShapeCache.d.ts +0 -25
- package/dist/types/element/src/shapes.d.ts +0 -23
- package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
- package/dist/types/excalidraw/store.d.ts +0 -129
- package/dist/types/excalidraw/visualdebug.d.ts +0 -41
- package/dist/types/utils/src/collision.d.ts +0 -8
- /package/dist/dev/data/{image-7TSQCOPJ.js.map → image-CVNOYW5X.js.map} +0 -0
- /package/dist/dev/locales/{en-KO5RAUUV.js.map → en-KEYRB5CP.js.map} +0 -0
package/dist/prod/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{$ as lc,$a as Ct,$b as b0,$c as pt,$d as ox,$e as Au,$f as ve,$g as ed,A as Sr,Aa as Et,Ab as ht,Ac as xu,Ad as xT,Ae as ku,Af as pn,Ag as jc,Ah as ad,B as en,Ba as Xb,Bb as gu,Bc as Cl,Bd as Z0,Be as yT,Bf as j,Bg as qc,Bh as mE,C as rc,Ca as $b,Cb as ir,Cc as _r,Cd as Ji,Ce as vT,Cf as Or,Cg as hi,Ch as pE,D as Jp,Da as jb,Db as m0,Dc as io,Dd as et,De as wT,Df as _x,Dg as Xx,Dh as uE,E as tn,Ea as pc,Eb as fu,Ec as Zo,Ed as kl,Ee as cx,Ef as Dx,Eg as jx,Eh as Hl,F as Mo,Fa as qb,Fb as p0,Fc as Cc,Fd as Lc,Fe as dx,Ff as Yc,Fg as gi,Fh as Xu,G as hl,Ga as $n,Gb as ar,Gc as Ic,Gd as Ao,Ge as Nc,Gf as Pl,Gg as mr,Gh as hE,H as nc,Ha as Jb,Hb as Jn,Hc as Dr,Hd as be,He as Mu,Hf as un,Hg as qx,Hh as gE,I as _b,Ia as Qb,Ib as Je,Ic as fe,Id as _t,Ie as mx,If as Rl,Ig as Br,Ih as fE,J as Db,Ja as e0,Jb as Qn,Jc as Ht,Jd as Ac,Je as _o,Jf as _u,Jg as CT,Jh as bE,K as Qp,Ka as Mr,Kb as Wi,Kc as ri,Kd as X0,Ke as px,Kf as Du,Kg as IT,L as gl,La as uc,Lb as Ko,Lc as Xi,Ld as $0,Le as ux,Lf as Pu,Lg as ao,M as ge,Ma as hc,Mb as u0,Mc as Z,Md as j0,Me as oa,Mf as Ru,Mg as jo,N as Pb,Na as gc,Nb as h0,Nc as k0,Nd as q0,Ne as hx,Nf as ia,Ng as da,O as ic,Oa as t0,Ob as ei,Oc as Sc,Od as Qi,Oe as di,Of as Nu,Og as Jx,P as on,Pa as o0,Pb as Ue,Pc as ae,Pd as ea,Pe as gx,Pf as Px,Pg as Uu,Q as Rb,Qa as r0,Qb as R,Qc as Eu,Qd as J0,Qe as ra,Qf as pi,Qg as gn,R as Nb,Ra as n0,Rb as je,Rc as le,Rd as yu,Re as Oc,Rf as Rx,Rg as ma,S as Ob,Sa as Lr,Sb as Ft,Sc as ke,Sd as Q0,Se as fx,Sf as Nx,Sg as Jc,T as Bb,Ta as i0,Tb as wl,Tc as oe,Td as li,Te as Bc,Tf as Ox,Tg as Gu,U as zb,Ua as ue,Ub as an,Uc as M0,Ud as ex,Ue as sr,Uf as Bx,Ug as Ol,V as Ui,Va as T,Vb as vc,Vc as Pr,Vd as tx,Ve as Lu,Vf as zx,Vg as Qc,W as eu,Wa as fc,Wb as bu,Wc as L0,Wd as _c,We as bx,Wf as TT,Wg as Vu,X as tu,Xa as jn,Xb as Ar,Xc as ni,Xd as si,Xe as zc,Xf as hn,Xg as Yu,Y as Fb,Ya as au,Yb as ti,Yc as Rr,Yd as Dc,Ye as Fc,Yf as Ke,Yg as Qx,Z as Hb,Za as Gi,Zb as g0,Zc as A0,Zd as Ml,Ze as Hc,Zf as Wc,Zg as eE,_ as ac,_a as bc,_b as f0,_c as ii,_d as Xo,_e as xx,_f as Fx,_g as tE,a as Vo,aa as ou,ab as Lo,ac as x0,ad as _e,ae as mn,af as ze,ag as Kc,ah as Bl,b as Qs,ba as Ub,bb as a0,bc as E0,bd as $i,be as at,bf as Ex,bg as aa,bh as td,c as Ib,ca as Gb,cb as lu,cc as te,cd as _0,ce as vu,cf as J,cg as Dt,ch as od,d as Ir,da as Vb,db as El,dc as y0,dd as D0,de as wu,df as Uc,dg as Ou,dh as oE,e as Sb,ea as Yb,eb as Vi,ec as lr,ed as P0,ee as rx,ef as Me,eg as Hx,eh as rE,f as ec,fa as sc,fb as Yi,fc as v0,fd as ji,fe as nx,ff as yx,fg as Zc,fh as Wu,g as kb,ga as rn,gb as su,gc as mt,gd as R0,ge as Pc,gf as lt,gg as Vt,gh as ST,h as dl,ha as Wb,hb as xc,hc as Ge,hd as N0,he as ix,hf as Gc,hg as Bu,hh as zl,i as ml,ia as ru,ib as cu,ic as w0,id as O0,ie as ax,if as vx,ig as Ux,ih as Fl,j as Mb,ja as nu,jb as du,jc as wc,jd as B0,je as Ll,jf as $o,jg as la,jh as fn,k as Zn,ka as Kb,kb as l0,kc as Ki,kd as z0,ke as Al,kf as wx,kg as Nl,kh as pa,l as tc,la as cc,lb as mu,lc as T0,ld as F0,le as lx,lf as Tx,lg as Yt,lh as nE,m as Lb,ma as iu,mb as M,mc as ln,md as H0,me as Rc,mf as na,mg as Gx,n as jp,na as to,nb as de,nc as Tl,nd as Il,ne as B,nf as Fe,ng as Vx,nh as iE,o as Ab,oa as fl,ob as pu,oc as Qe,od as U0,oe as re,of as Cx,og as dr,p as pl,pa as oo,pb as qn,pc as sn,pd as G0,pe as _l,pf as Ix,pg as sa,ph as aE,q as qp,qa as dc,qb as Ec,qc as oi,qd as Sl,qe as ci,qf as Sx,qg as Xc,qh as lE,r as Se,ra as bl,rb as uu,rc as cn,rd as V0,re as Dl,rf as mi,rg as zu,rh as rd,s as nr,sa as kr,sb as yc,sc as C0,sd as Y0,se as ta,sf as kx,sg as ui,sh as sE,t as Xn,ta as At,tb as s0,tc as Tc,td as Ut,te as Tu,tf as Mx,tg as Yx,th as nd,u as ul,ua as mc,ub as c0,uc as no,ud as kc,ue as Cu,uf as cr,ug as ca,uh as Ku,v as Yo,va as it,vb as bo,vc as Zi,vd as qi,ve as sx,vf as Lx,vg as Wx,vh as id,w as zt,wa as nn,wb as yl,wc as We,wd as W0,we as ET,wf as Ax,wg as Kx,wh as cE,x as ce,xa as Zb,xb as vl,xc as I0,xd as ai,xe as Iu,xf as Vc,xg as Zx,xh as Zu,y as Wo,ya as xl,yb as d0,yc as S0,yd as K0,ye as Su,yf as Gt,yg as Fu,yh as zr,z as oc,za as ro,zb as hu,zc as dn,zd as Mc,ze as xe,zf as Nr,zg as $c,zh as dE}from"./chunk-YO4ODNEY.js";import{a as k}from"./chunk-3ZKFSMTS.js";import{J as Hu}from"./chunk-OYRPRL6F.js";import{c as $x}from"./chunk-Z3N5DIM6.js";import{b as Cb,c as Js,d as I}from"./chunk-SRAX5OIU.js";import KA,{useEffect as ZA}from"react";import J5 from"clsx";import yA from"lodash.throttle";import Cr,{useContext as Wn}from"react";import{flushSync as Fi}from"react-dom";import vA from"roughjs/bin/rough";import{nanoid as wA}from"nanoid";var kT=e=>{let o=e.slice(),t=new Set,r=i=>{let a=i[0]?.groupIds?.join(""),l=[i[0]],s=[];for(let c of i.slice(1))c.groupIds?.join("")===a?l.push(c):s.push(c);return s.length?[...l,...r(s)]:l},n=new Map;return o.forEach((i,a)=>{if(!n.has(i.id))if(i.groupIds?.length){let l=i.groupIds[i.groupIds.length-1],s=o.slice(a).filter(c=>{let m=c?.groupIds?.some(d=>d===l);return m&&n.set(c.id,!0),m});for(let c of r(s))t.add(c)}else t.add(i)}),t.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...t]},MT=e=>{let o=y0(e),t=e.slice(),r=new Set;return t.forEach((n,i)=>{n&&(n.boundElements?.length?(r.add(n),t[i]=null,n.boundElements.forEach(a=>{let l=o.get(a.id);l&&a.type==="text"&&(r.add(l[0]),t[l[1]]=null)})):n.type==="text"&&n.containerId&&o.get(n.containerId)?.[0].boundElements?.find(l=>l.id===n.id)||(r.add(n),t[i]=null))}),r.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...r]},xE=e=>MT(kT(e));var EE=(e,o,t,r,n)=>{let i=xo(t);return mt()&<(i,t.id),i.id=io(),i.updated=E0(),n&&(i.seed=_r(),_l(i)),i.groupIds=Lx(i.groupIds,e,a=>(o.has(a)||o.set(a,io()),o.get(a))),r&&(i=Object.assign(i,r)),i},bn=e=>{let{elements:o}=e,t="appState"in e?e.appState:{editingGroupId:null,selectedGroupIds:{}},r=e.type==="in-place"?e.reverseOrder:!1,n=new Map,i=new Map,a=[],l=[],s=new Map,c=new Map,m=te(o),d=e.type==="in-place"?e.idsOfElementsToDuplicate:new Map(o.map(x=>[x.id,x]));if(e.type==="in-place")for(let x of Object.keys(e.appState.selectedGroupIds))o.filter(E=>E.groupIds?.includes(x)).forEach(E=>d.set(E.id,E));o=xE(o);let p=o.slice(),u=x=>{let w=Cl(x).reduce((y,v)=>{if(n.has(v.id))return y;n.set(v.id,!0);let C=EE(t.editingGroupId,i,v,e.overrides?.(v),e.randomizeSeed);return n.set(C.id,!0),c.set(C.id,C),s.set(v.id,C.id),l.push(v),a.push(C),y.push(C),y},[]);return Array.isArray(x)?w:w[0]||null},g=(x,E)=>{if(E){if(r&&x<1){p.unshift(...Cl(E));return}if(!r&&x>p.length-1){p.push(...Cl(E));return}p.splice(x+(r?0:1),0,...Cl(E))}},b=new Set(o.filter(x=>d.has(x.id)&&ae(x)).map(x=>x.id));for(let x of o){if(n.has(x.id)||!d.has(x.id))continue;let E=vx(t,x);if(E){let w=Fe(o,E).flatMap(v=>ae(v)?[..._o(o,v.id),v]:[v]),y=r?p.findIndex(v=>v.groupIds?.includes(E)):Ar(p,v=>v.groupIds?.includes(E));g(y,u(w));continue}if(!(x.frameId&&b.has(x.frameId))){if(ae(x)){let w=x.id,y=_o(o,w),v=Ar(p,C=>C.frameId===w||C.id===w);g(v,u([...y,x]));continue}if(pt(x)){let w=be(x,m),y=Ar(p,v=>v.id===x.id||"containerId"in v&&v.containerId===x.id);w?g(y+(r?-1:0),u([x,w])):g(y,u(x));continue}if(_e(x)){let w=_t(x,m),y=Ar(p,v=>v.id===x.id||v.id===w?.id);w?g(y,u([w,x])):g(y,u(x));continue}g(Ar(p,w=>w.id===x.id),u(x))}}return rx(a,s,c),r&&nx(d,p,s),cx(p,l,s),{newElements:a,elementsWithClones:p}},$u=(e,o=0)=>{if(e==null||typeof e!="object")return e;let t=Object.prototype.toString.call(e);if(t==="[object Object]"){let r=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let n in e)if(e.hasOwnProperty(n)){if(o===0&&(n==="shape"||n==="canvas"))continue;r[n]=$u(e[n],o+1)}return r}if(Array.isArray(e)){let r=e.length,n=new Array(r);for(;r--;)n[r]=$u(e[r],o+1);return n}return k.DEV&&t!=="[object Object]"&&t!=="[object Array]"&&t.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${t}. This value will not be cloned!`),e},xo=e=>$u(e),LT=(e,o)=>{Object.defineProperty(e,$b,{value:o,writable:!1,enumerable:!1})};var yE={mouse:8,pen:16,touch:28},AT=16,wE={e:!0,s:!0,n:!0,w:!0};var vE={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},ju={e:!0,s:!0,n:!0,w:!0},Fr=(e,o,t,r,n,i,a)=>{let[l,s]=de(M(e+t/2,o+r/2),M(n,i),a);return[l-t/2,s-r/2,t,r]},ld=e=>!(e.viewport.isMobile||e.isTouchScreen&&(Ib||ec)),fi=e=>ld(e)?wE:{},Ul=([e,o,t,r,n,i],a,l,s,c={},m=4,d=tn)=>{let p=yE[s],u=p/l.value,g=p/l.value,b=p/l.value,x=p/l.value,E=t-e,w=r-o,y=m/l.value,v=(p-d*2)/(2*l.value),C={nw:c.nw?void 0:Fr(e-y-b+v,o-y-x+v,u,g,n,i,a),ne:c.ne?void 0:Fr(t+y-v,o-y-x+v,u,g,n,i,a),sw:c.sw?void 0:Fr(e-y-b+v,r+y-v,u,g,n,i,a),se:c.se?void 0:Fr(t+y-v,r+y-v,u,g,n,i,a),rotation:c.rotation?void 0:Fr(e+E/2-u/2,o-y-x+v-AT/l.value,u,g,n,i,a)},S=5*yE.mouse/l.value;return Math.abs(E)>S&&(c.n||(C.n=Fr(e+E/2-u/2,o-y-x+v,u,g,n,i,a)),c.s||(C.s=Fr(e+E/2-u/2,r+y-v,u,g,n,i,a))),Math.abs(w)>S&&(c.w||(C.w=Fr(e-y-b+v,o+w/2-g/2,u,g,n,i,a)),c.e||(C.e=Fr(t+y-v,o+w/2-g/2,u,g,n,i,a))),C},sd=(e,o,t,r="mouse",n=wE)=>{if(e.locked||oe(e))return{};if(e.type==="freedraw"||le(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?n=ju:a[0]>0&&a[1]<0?n=vE:a[0]>0&&a[1]>0?n=ju:a[0]<0&&a[1]>0?n=vE:a[0]<0&&a[1]<0&&(n=ju)}}else ae(e)&&(n={...n,rotation:!0});let i=le(e)?tn+8:fe(e)?0:tn;return Ul(Ke(e,t,!0),e.angle,o,r,n,i,fe(e)?0:void 0)},cd=(e,o)=>{if(o.editingLinearElement)return!1;if(e.length>1)return!0;let t=e[0];return oe(t)?!1:le(t)?t.points.length>2:!0};var ua=100,bi=100,Qu=e=>{switch(e){case T.ARROW_UP:return"up";case T.ARROW_DOWN:return"down";case T.ARROW_RIGHT:return"right";case T.ARROW_LEFT:return"left";default:return"right"}},TE=(e,o,t,r)=>{let n=[...t.values()].reduce((i,a)=>{let l;if(oe(a)&&(l=a[e==="predecessors"?"startBinding":"endBinding"])&&a[e==="predecessors"?"endBinding":"startBinding"]?.elementId===o.id){let s=t.get(l.elementId);if(!s)return i;cn(ni(s),"not an ExcalidrawBindableElement");let c=e==="predecessors"?a.points[a.points.length-1]:[0,0],m=U0(o,Dx(o),[c[0]+a.x,c[1]+a.y]);i.push({relative:s,heading:m})}return i},[]);switch(r){case"up":return n.filter(i=>Il(i.heading,H0)).map(i=>i.relative);case"down":return n.filter(i=>Il(i.heading,z0)).map(i=>i.relative);case"right":return n.filter(i=>Il(i.heading,B0)).map(i=>i.relative);case"left":return n.filter(i=>Il(i.heading,F0)).map(i=>i.relative)}},qu=(e,o,t)=>TE("successors",e,o,t),Ju=(e,o,t)=>TE("predecessors",e,o,t),_T=(e,o,t)=>{let r=bi+e.width;if(t==="up"||t==="down"){let l=ua+e.height,s=e.x,c=e.x+e.width;if(o.every(m=>m.x+m.width<s||m.x>c))return{x:0,y:l*(t==="up"?-1:1)}}else if(t==="right"||t==="left"){let l=e.y,s=e.y+e.height;if(o.every(c=>c.y+c.height<l||c.y>s))return{x:(bi+e.width)*(t==="left"?-1:1),y:0}}if(t==="up"||t==="down"){let l=ua+e.height,s=(o.length===0,l),c=o.length===0?0:(o.length+1)%2===0?(o.length+1)/2*r:o.length/2*r*-1;return t==="up"?{x:c,y:s*-1}:{x:c,y:s}}let n=ua+e.height,i=(o.length===0,bi+e.width),a=o.length===0?0:(o.length+1)%2===0?(o.length+1)/2*n:o.length/2*n*-1;return t==="left"?{x:i*-1,y:a}:{x:i,y:a}},DT=(e,o,t,r)=>{let n=qu(e,o,r),i=Ju(e,o,r),a=_T(e,[...n,...i],r),l=Vt({type:e.type,x:e.x+a.x,y:e.y+a.y,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});cn(ii(l),"not an ExcalidrawFlowchartNodeElement");let s=CE(e,l,o,r,t);return{nextNode:l,bindingArrow:s}},PT=(e,o,t,r,n)=>{let i=[];for(let a=0;a<n;a++){let l,s;if(r==="left"||r==="right"){let d=ua*(n-1)+n*e.height,p=e.y+e.height/2-d/2,u=bi+e.width;r==="left"&&(u*=-1),l=e.x+u;let g=(ua+e.height)*a;s=p+g}else{let d=bi*(n-1)+n*e.width,p=e.x+e.width/2-d/2,u=ua+e.height;r==="up"&&(u*=-1),s=e.y+u;let g=(bi+e.width)*a;l=p+g}let c=Vt({type:e.type,x:l,y:s,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});cn(ii(c),"not an ExcalidrawFlowchartNodeElement");let m=CE(e,c,o,r,t);i.push(c),i.push(m)}return i},CE=(e,o,t,r,n)=>{let i,a;switch(r){case"up":{i=e.x+e.width/2,a=e.y-6;break}case"down":{i=e.x+e.width/2,a=e.y+e.height+6;break}case"right":{i=e.x+e.width+6,a=e.y+e.height/2;break}case"left":{i=e.x-6,a=e.y+e.height/2;break}}let s,c;switch(r){case"up":{s=o.x+o.width/2-i,c=o.y+o.height-a+6;break}case"down":{s=o.x+o.width/2-i,c=o.y-a-6;break}case"right":{s=o.x-i-6,c=o.y-a+o.height/2;break}case"left":{s=o.x+o.width-i+6,c=o.y-a+o.height/2;break}}let m=sa({type:"arrow",x:i,y:a,startArrowhead:null,endArrowhead:n.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[M(0,0),M(s,c)],elbowed:!0});Xo(m,e,"start",t),Xo(m,o,"end",t);let d=new Map;d.set(e.id,e),d.set(o.id,o),d.set(m.id,m),j.movePoints(m,[{index:1,point:m.points[1]}]);let p=Rc(m,dn(new Map([...t.entries(),[e.id,e],[o.id,o],[m.id,m]])),{points:m.points});return{...m,...p}},dd=class{constructor(){I(this,"isExploring",!1);I(this,"sameLevelNodes",[]);I(this,"sameLevelIndex",0);I(this,"direction",null);I(this,"visitedNodes",new Set)}clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(o,t,r){if(!ni(o))return null;if(r!==this.direction&&this.clear(),this.visitedNodes.has(o.id)||this.visitedNodes.add(o.id),this.isExploring&&r===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let n=[...qu(o,t,r),...Ju(o,t,r)];if(n.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=n,this.direction=r,this.visitedNodes.add(n[0].id),n[0].id;if(r===this.direction||!this.isExploring){this.isExploring||this.visitedNodes.add(o.id);let a=["up","right","down","left"].filter(l=>l!==r).map(l=>[...qu(o,t,l),...Ju(o,t,l)]).flat().filter(l=>!this.visitedNodes.has(l.id));for(let l of a)if(!this.visitedNodes.has(l.id))return this.visitedNodes.add(l.id),this.isExploring=!0,this.direction=r,l.id}return null}},md=class{constructor(){I(this,"isCreatingChart",!1);I(this,"numberOfNodes",0);I(this,"direction","right");I(this,"pendingNodes",null)}createNodes(o,t,r,n){if(n!==this.direction){let{nextNode:i,bindingArrow:a}=DT(o,t,r,n);this.numberOfNodes=1,this.isCreatingChart=!0,this.direction=n,this.pendingNodes=[i,a]}else{this.numberOfNodes+=1;let i=PT(o,t,r,n,this.numberOfNodes);this.isCreatingChart=!0,this.direction=n,this.pendingNodes=i}if(o.frameId){let i=t.get(o.frameId);cn(i&&k0(i),"not an ExcalidrawFrameElement"),i&&this.pendingNodes.every(a=>dx([a],i,t)||Nc(a,i,t))&&(this.pendingNodes=this.pendingNodes.map(a=>B(a,{frameId:o.frameId},!1)))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0}},IE=(e,o)=>{for(let[,t]of o)if(t.type==="arrow"&&(t.startBinding?.elementId===e.id||t.endBinding?.elementId===e.id))return!0;return!1};var SE=(e,o,t,r,n,i,a,l,s,c,m,d)=>{if(t.length===1){let[p]=t;if(o==="rotation")oe(p)||(RT(p,r,n,s,c,i),at(p,r));else{if(Z(p)&&o)return NT(e,p,r,o,a,s,c),at(p,r),!0;if(o){let u=t[0].id,g=r.get(u),b=e.get(u);if(g&&b){let{nextWidth:x,nextHeight:E}=FT(g,b,r,e,o,s,c,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a});xi(x,E,g,b,r,e,o,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a})}}}return!0}else if(t.length>1){if(o==="rotation")return OT(e,t,r,n,s,c,i,m,d),!0;if(o){let{nextWidth:p,nextHeight:u,flipByX:g,flipByY:b,originalBoundingBox:x}=HT(t,e,r,o,s,c,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a});return th(t,r,o,n,e,{shouldResizeFromCenter:a,shouldMaintainAspectRatio:l,flipByX:g,flipByY:b,nextWidth:p,nextHeight:u,originalBoundingBox:x}),!0}}return!1},RT=(e,o,t,r,n,i)=>{let[a,l,s,c]=Ke(e,o),m=(a+s)/2,d=(l+c)/2,p;ae(e)?p=0:(p=5*Math.PI/2+Math.atan2(n-d,r-m),i&&(p=p+pl/2,p=p-p%pl),p=El(p));let u=Ao(e);if(B(e,{angle:p}),u){let g=t.getElement(u);g&&!ke(e)&&B(g,{angle:p})}},pd=(e,o,t,r)=>le(e)||Eu(e)?{points:hu(0,o,hu(1,t,e.points,r),r)}:{},eh=(e,o,t)=>{let r=e.width;if(_e(e)){let a=_t(e,o);a&&(r=ea(a,e))}let i=e.fontSize*(t/r);return i<oc?null:{size:i}},NT=(e,o,t,r,n,i,a)=>{let[l,s,c,m,d,p]=Ke(o,t),[u,g]=de(M(i,a),M(d,p),-o.angle),b=0,x=0;r!=="e"&&r!=="w"&&(r.includes("e")&&(b=(u-l)/(c-l)),r.includes("w")&&(b=(c-u)/(c-l)),r.includes("n")&&(x=(m-g)/(m-s)),r.includes("s")&&(x=(g-s)/(m-s)));let E=Math.max(b,x);if(E>0){let w=o.width*E,y=o.height*E,v=eh(o,t,w);if(v===null)return;let C=[l,s],S=[c,m],_=[d,p],L=M(l,s);if(["n","w","nw"].includes(r)&&(L=M(S[0]-Math.abs(w),S[1]-Math.abs(y))),r==="ne"){let H=[C[0],S[1]];L=M(H[0],H[1]-Math.abs(y))}if(r==="sw"){let H=[S[0],C[1]];L=M(H[0]-Math.abs(w),H[1])}["s","n"].includes(r)&&(L[0]=_[0]-w/2),["e","w"].includes(r)&&(L[1]=_[1]-y/2),n&&(L[0]=_[0]-Math.abs(w)/2,L[1]=_[1]-Math.abs(y)/2);let N=o.angle,P=de(L,M(d,p),N),z=M(L[0]+Math.abs(w)/2,L[1]+Math.abs(y)/2),W=de(z,M(d,p),N);L=de(P,W,-N);let[U,q]=L;B(o,{fontSize:v.size,width:w,height:y,x:U,y:q})}if(r==="e"||r==="w"){let w=e.get(o.id),[y,v,C,S]=aa(w,w.width,w.height,!0),_=M(y,v),L=M(C,S),N=pu(_,L),P=de(M(i,a),N,-w.angle),[z,,W]=aa(o,o.width,o.height,!0),U=W-z,q=L[0]-_[0],H=qi(Je({fontSize:o.fontSize,fontFamily:o.fontFamily}),o.lineHeight),V=q/U;r.includes("e")&&(V=(P[0]-_[0])/U),r.includes("w")&&(V=(L[0]-P[0])/U);let K=o.width*V<H?H:o.width*V,Q=Ji(o.originalText,Je(o),Math.abs(K)),X=Ut(Q,Je(o),o.lineHeight),ie=X.height,[he,pe,He,Bt]=aa(w,K,ie,!0),qt=He-he,Jt=Bt-pe,Qt=[..._];["n","w","nw"].includes(r)&&(Qt=[L[0]-Math.abs(qt),_[1]]);let rr=w.angle,qr=de(Qt,N,rr),eo=M(Qt[0]+Math.abs(qt)/2,Qt[1]+Math.abs(Jt)/2),Jr=de(eo,N,rr);Qt=de(qr,Jr,-rr);let fo={width:Math.abs(K),height:Math.abs(X.height),x:Qt[0],y:Qt[1],text:Q,autoResize:!1};B(o,fo)}},OT=(e,o,t,r,n,i,a,l,s)=>{let c=5*Math.PI/2+Math.atan2(i-s,n-l);a&&(c+=pl/2,c-=c%pl);for(let m of o)if(!ae(m)){let[d,p,u,g]=Ke(m,t),b=(d+u)/2,x=(p+g)/2,E=e.get(m.id)?.angle??m.angle,[w,y]=de(M(b,x),M(l,s),c+E-m.angle);oe(m)?B(m,{points:lx(m,t)}):B(m,{x:m.x+(w-b),y:m.y+(y-x),angle:El(c+E)},!1),at(m,t,{simultaneouslyUpdated:o});let v=be(m,t);v&&!ke(m)&&B(v,{x:v.x+(w-b),y:v.y+(y-x),angle:El(c+E)},!1)}r.triggerUpdate()},kE=(e,o,t,r,n)=>{let[i,a,l,s]=o.length===1?Ke(o[0],t):ve(o),c=(i+l)/2,m=(a+s)/2,d=o.length===1?o[0].angle:0;switch([r,n]=de(M(r,n),M(c,m),-d),e){case"n":return de(M(r-(i+l)/2,n-a),M(0,0),d);case"s":return de(M(r-(i+l)/2,n-s),M(0,0),d);case"w":return de(M(r-i,n-(a+s)/2),M(0,0),d);case"e":return de(M(r-l,n-(a+s)/2),M(0,0),d);case"nw":return de(M(r-i,n-a),M(0,0),d);case"ne":return de(M(r-l,n-a),M(0,0),d);case"sw":return de(M(r-i,n-s),M(0,0),d);case"se":return de(M(r-l,n-s),M(0,0),d);default:return[0,0]}},ME=(e,o)=>{let[,[t,r]]=o.points;return e==="nw"&&(t<0||r<0)||e==="ne"&&t>=0||e==="sw"&&t<=0||e==="se"&&(t>0||r>0)?"end":"origin"},BT=(e,o,t)=>{if(t)return"center";if(o)switch(e){case"n":return"south-side";case"e":return"west-side";case"s":return"north-side";case"w":return"east-side";case"ne":return"bottom-left";case"nw":return"bottom-right";case"se":return"top-left";case"sw":return"top-right"}return["e","se","s"].includes(e)?"top-left":["n","nw","w"].includes(e)?"bottom-right":e==="ne"?"bottom-left":"top-right"},zT=(e,o,t,r,n,i,a,l,s)=>{let c=BT(a,l,s),[m,d]=e;switch(c){case"top-left":return{x:m+(o-r)/2+(r-o)/2*Math.cos(i)+(t-n)/2*Math.sin(i),y:d+(t-n)/2+(r-o)/2*Math.sin(i)+(n-t)/2*Math.cos(i)};case"top-right":return{x:m+(o-r)/2*(Math.cos(i)+1)+(t-n)/2*Math.sin(i),y:d+(t-n)/2+(o-r)/2*Math.sin(i)+(n-t)/2*Math.cos(i)};case"bottom-left":return{x:m+(o-r)/2*(1-Math.cos(i))+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)+(r-o)/2*Math.sin(i)};case"bottom-right":return{x:m+(o-r)/2*(Math.cos(i)+1)+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)+(o-r)/2*Math.sin(i)};case"center":return{x:m-(r-o)/2,y:d-(n-t)/2};case"east-side":return{x:m+(o-r)/2*(Math.cos(i)+1),y:d+(o-r)/2*Math.sin(i)+(t-n)/2};case"west-side":return{x:m+(o-r)/2*(1-Math.cos(i)),y:d+(r-o)/2*Math.sin(i)+(t-n)/2};case"north-side":return{x:m+(o-r)/2+(t-n)/2*Math.sin(i),y:d+(n-t)/2*(Math.cos(i)-1)};case"south-side":return{x:m+(o-r)/2+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)}}},xi=(e,o,t,r,n,i,a,{shouldInformMutation:l=!0,shouldMaintainAspectRatio:s=!1,shouldResizeFromCenter:c=!1}={})=>{let m={},d=be(t,n);if(d){let b=i.get(d.id);if(b&&(m={fontSize:b.fontSize}),s){let x={...t,width:e,height:o},E=eh(d,n,ea(x,d));if(E===null)return;m={fontSize:E.size}}else{let x=kc(Je(d),d.lineHeight),E=Mc(d.fontSize,d.lineHeight);e=Math.max(e,x),o=Math.max(o,E)}}let p=pd(r,e,o,!0),u=M(r.x,r.y);if(le(r)){let[b,x]=Fx(r,i);u=M(b,x)}let g=zT(u,r.width,r.height,e,o,r.angle,a,s,c);if(le(r)&&p.points){let b=r.x-u[0],x=r.y-u[1];g.x+=b,g.y+=x;let E=p.points[0][0],w=p.points[0][1];g.x+=E,g.y+=w,p.points=p.points.map(y=>M(y[0]-E,y[1]-w))}if(e<0&&(g.x=g.x+e),o<0&&(g.y=g.y+o),"scale"in t&&"scale"in r&&B(t,{scale:[(Math.sign(e)||r.scale[0])*r.scale[0],(Math.sign(o)||r.scale[1])*r.scale[1]]}),ke(t)&&d&&s){let b=e/t.width*d.fontSize;if(b<oc)return;m.fontSize=b}if(e!==0&&o!==0&&Number.isFinite(g.x)&&Number.isFinite(g.y)){let b={...g,width:Math.abs(e),height:Math.abs(o),...p};B(t,b,l),at(t,n,{newSize:{width:e,height:o}}),d&&m!=null&&B(d,{fontSize:m.fontSize}),kl(t,n,a,s)}},FT=(e,o,t,r,n,i,a,{shouldMaintainAspectRatio:l=!1,shouldResizeFromCenter:s=!1}={})=>{let[c,m,d,p]=aa(o,o.width,o.height,!0),u=M(c,m),g=M(d,p),b=pu(u,g),x=de(M(i,a),b,-o.angle),[E,w,y,v]=aa(e,e.width,e.height,!0),C=y-E,S=v-w,_=g[0]-u[0],L=g[1]-u[1],N=_/C,P=L/S;n.includes("e")&&(N=(x[0]-u[0])/C),n.includes("s")&&(P=(x[1]-u[1])/S),n.includes("w")&&(N=(g[0]-x[0])/C),n.includes("n")&&(P=(g[1]-x[1])/S);let z=e.width*N,W=e.height*P;if(s&&(z=2*z-o.width,W=2*W-o.height),l){let U=Math.abs(z)/o.width,q=Math.abs(W)/o.height;if(n.length===1&&(W*=U,z*=q),n.length===2){let H=Math.max(U,q);z=o.width*H*Math.sign(z),W=o.height*H*Math.sign(W)}}return{nextWidth:z,nextHeight:W}},HT=(e,o,t,r,n,i,{shouldMaintainAspectRatio:a=!1,shouldResizeFromCenter:l=!1}={})=>{let s=e.map(U=>o.get(U.id)),c=s.reduce((U,q)=>{if(!le(q))return U;let H=Ao(q);if(!H)return U;let V=o.get(H)??null;return _e(V)?[...U,{...V,...j.getBoundTextElementPosition(q,V,t)}]:U},[]),m=Dt(s.map(U=>U).concat(c)),{minX:d,minY:p,maxX:u,maxY:g,midX:b,midY:x}=m,E=u-d,w=g-p,y={ne:[d,g],se:[d,p],sw:[u,p],nw:[u,g],e:[d,p+w/2],w:[u,p+w/2],n:[d+E/2,g],s:[d+E/2,p]},[v,C]=l?[b,x]:y[r],S=l?2:1,_=Math.max(Math.abs(n-v)/E||0,Math.abs(i-C)/w||0)*S,L=r.includes("e")||r.includes("w")?Math.abs(n-v)*S:E,N=r.includes("n")||r.includes("s")?Math.abs(i-C)*S:w;a&&(L=E*_*Math.sign(n-v),N=w*_*Math.sign(i-C));let P={ne:[n<v,i>C],se:[n<v,i<C],sw:[n>v,i<C],nw:[n>v,i>C],e:[n<v,!1],w:[n>v,!1],n:[!1,i>C],s:[!1,i<C]},[z,W]=P[r].map(U=>U);return{originalBoundingBox:m,nextWidth:L,nextHeight:N,flipByX:z,flipByY:W}},th=(e,o,t,r,n,{shouldMaintainAspectRatio:i=!1,shouldResizeFromCenter:a=!1,flipByX:l=!1,flipByY:s=!1,nextHeight:c,nextWidth:m,originalBoundingBox:d}={})=>{if(m===void 0&&c===void 0&&l===void 0&&s===void 0||c===0||m===0)return;n||(n=o);let p=e.reduce((S,_)=>{let L=n.get(_.id);return L&&S.push({orig:L,latest:_}),S},[]),u;if(d)u=d;else{let S=p.reduce((_,{orig:L})=>{if(!le(L))return _;let N=Ao(L);if(!N)return _;let P=n.get(N)??null;return _e(P)?[..._,{...P,...j.getBoundTextElementPosition(L,P,o)}]:_},[]);u=Dt(p.map(({orig:_})=>_).concat(S))}let{minX:g,minY:b,maxX:x,maxY:E,midX:w,midY:y}=u,v=x-g,C=E-b;if(m===void 0&&c===void 0&&(m=v,c=C),i&&(m===void 0?m=c*(v/C):c===void 0?c=m*(C/v):Math.abs(m/c-v/C)>.001&&(m=c*(v/C))),m&&c){let S=t.includes("e")||t.includes("w")?Math.abs(m)/v:1,_=t.includes("n")||t.includes("s")?Math.abs(c)/C:1,L;t.length===1?L=t.includes("e")||t.includes("w")?S:_:L=Math.max(Math.abs(m)/v||0,Math.abs(c)/C||0);let N={ne:[g,E],se:[g,b],sw:[x,b],nw:[x,E],e:[g,b+C/2],w:[x,b+C/2],n:[g+v/2,E],s:[g+v/2,b]},[P,z]=a?[w,y]:N[t],W=i||p.some(K=>K.latest.angle!==0||Z(K.latest)||cr(K.latest));W&&(S=L,_=L);let[U,q]=[l?-1:1,s?-1:1],H=[];for(let{orig:K,latest:Q}of p){if(Z(K)&&_e(K))continue;let X=K.width*S,ie=K.height*_,he=El(K.angle*U*q),pe=le(K)||Eu(K),He=K.x-P,Bt=K.y-z,qt=l&&!pe?X:0,Jt=s&&!pe?ie:0,Qt=P+U*(He*S+qt),rr=z+q*(Bt*_+Jt),qr=pd(K,X*U,ie*q,!1),eo={x:Qt,y:rr,width:X,height:ie,angle:he,...qr};if(oe(K)&&(K.startBinding&&(eo.startBinding={...K.startBinding,fixedPoint:[l?-K.startBinding.fixedPoint[0]+1:K.startBinding.fixedPoint[0],s?-K.startBinding.fixedPoint[1]+1:K.startBinding.fixedPoint[1]]}),K.endBinding&&(eo.endBinding={...K.endBinding,fixedPoint:[l?-K.endBinding.fixedPoint[0]+1:K.endBinding.fixedPoint[0],s?-K.endBinding.fixedPoint[1]+1:K.endBinding.fixedPoint[1]]}),K.fixedSegments&&qr.points&&(eo.fixedSegments=K.fixedSegments.map(fo=>({...fo,start:qr.points[fo.index-1],end:qr.points[fo.index]})))),fe(K)&&(eo.scale=[K.scale[0]*U,K.scale[1]*q]),Z(K)){let fo=eh(K,o,X);if(!fo)return;eo.fontSize=fo.size}let Jr=n.get(Ao(K)??"");if(Jr)if(W){let fo=Jr.fontSize*L;if(fo<oc)return;eo.boundTextFontSize=fo}else eo.boundTextFontSize=Jr.fontSize;H.push({element:Q,update:eo})}let V=H.map(({element:K})=>K);for(let{element:K,update:{boundTextFontSize:Q,...X}}of H){let{width:ie,height:he,angle:pe}=X;B(K,X,!1,{isDragging:!0}),at(K,o,{simultaneouslyUpdated:V,newSize:{width:ie,height:he}});let He=be(K,o);He&&Q&&(B(He,{fontSize:Q,angle:le(K)?void 0:pe},!1),kl(K,o,t,!0))}r.triggerUpdate()}};var rh=(e,o,t)=>o>=e[0]&&o<=e[0]+e[2]&&t>=e[1]&&t<=e[1]+e[3],UT=(e,o,t,r,n,i,a,l)=>{if(!t.selectedElementIds[e.id])return!1;let{rotation:s,...c}=sd(e,i,o,a,fi(l));if(s&&rh(s,r,n))return"rotation";let m=Object.keys(c).filter(d=>{let p=c[d];return p?rh(p,r,n):!1});if(m.length>0)return m[0];if(ld(l)){let[d,p,u,g,b,x]=Ke(e,o);if(!(le(e)&&e.points.length<=2)){let E=fe(e)?0:nc/i.value,w=nc/i.value,y=LE(M(d-E,p-E),M(u+E,g+E),M(b,x),e.angle);for(let[v,C]of Object.entries(y))if(uu(M(r,n),C,w))return v}}return!1},nh=(e,o,t,r,n,i,a,l)=>e.reduce((s,c)=>{if(s)return s;let m=UT(c,a,o,t,r,n,i,l);return m?{element:c,transformHandleType:m}:null},null),ih=([e,o,t,r],n,i,a,l,s)=>{let c=Ul([e,o,t,r,(e+t)/2,(o+r)/2],0,a,l,fi(s)),m=Object.keys(c).find(d=>{let p=c[d];return p&&rh(p,n,i)});if(m)return m;if(ld(s)){let d=(e+t)/2,p=(o+r)/2,u=nc/a.value,g=LE(M(e-u,o-u),M(t+u,r+u),M(d,p),0);for(let[b,x]of Object.entries(g))if(uu(M(n,i),x,u))return b}return!1},oh=["ns","nesw","ew","nwse"],GT=(e,o)=>{let t=oh.indexOf(e);if(t>=0){let r=Math.round(o/(Math.PI/4));e=oh[(t+r)%oh.length]}return e},ah=e=>{let{element:o,transformHandleType:t}=e,r=o&&Math.sign(o.height)*Math.sign(o.width)===-1,n=null;switch(t){case"n":case"s":n="ns";break;case"w":case"e":n="ew";break;case"nw":case"se":r?n="nesw":n="nwse";break;case"ne":case"sw":r?n="nwse":n="nesw";break;case"rotation":return"grab"}return n&&o&&(n=GT(n,o.angle)),n?`${n}-resize`:""},LE=([e,o],[t,r],n,i)=>{let a=de(M(e,o),n,i),l=de(M(t,o),n,i),s=de(M(e,r),n,i),c=de(M(t,r),n,i);return{n:[a,l],e:[l,c],s:[c,s],w:[s,a]}};var _E=(e,o,t,r,n,i)=>{if(o.length===1&&oe(o[0])&&(o[0].startBinding||o[0].endBinding))return;let a=o.filter(d=>{if(oe(d)&&d.startBinding&&d.endBinding){let p=o.find(g=>g.id===d.startBinding?.elementId),u=o.find(g=>g.id===d.endBinding?.elementId);return p&&u}return!0}),l=new Set(a),s=a.filter(d=>ae(d)).map(d=>d.id);if(s.length>0)for(let d of r.getNonDeletedElements())d.frameId!==null&&s.includes(d.frameId)&&l.add(d);let c=[];for(let d of l){let p=e.originalElements.get(d.id);if(!p)return;c.push(p)}let m=VT(ve(c),t,n,i);l.forEach(d=>{if(AE(e,d,m),!ke(d)){let p=be(d,r.getNonDeletedElementsMap());p&&AE(e,p,m),at(d,r.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(l)})}})},VT=(e,o,t,r)=>{let[n,i]=e,a=n+o.x+t.x,l=i+o.y+t.y;if(t.x===0||t.y===0){let[s,c]=ht(n+o.x,i+o.y,r);t.x===0&&(a=s),t.y===0&&(l=c)}return{x:a-n,y:l-i}},AE=(e,o,t)=>{let r=e.originalElements.get(o.id)??o,n=r.x+t.x,i=r.y+t.y;B(o,{x:n,y:i})},DE=(e,o,t)=>{let[r,n]=ve(e);return[o-r,t-n]},lh=({newElement:e,elementType:o,originX:t,originY:r,x:n,y:i,width:a,height:l,shouldMaintainAspectRatio:s,shouldResizeFromCenter:c,zoom:m,widthAspectRatio:d=null,originOffset:p=null,informMutation:u=!0})=>{s&&e.type!=="selection"&&(d?l=a/d:(Math.abs(i-r)>Math.abs(n-t)?{width:a,height:l}=Tu(o,l,n<t?-a:a):{width:a,height:l}=Tu(o,a,i<r?-l:l),l<0&&(l=-l)));let g=n<t?t-a:t,b=i<r?r-l:r;c&&(a+=a,l+=l,g=t-a/2,b=r-l/2);let x=null;if(Z(e)){l=e.height;let E=qi(Je({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);a=Math.max(a,E),Math.abs(n-t)>Mb/m&&(x={autoResize:!1}),b=r,c&&(g=t-a/2)}if(a!==0&&l!==0){let E=null;fe(e)&&(E={initialWidth:a,initialHeight:l}),B(e,{x:g+(p?.x??0),y:b+(p?.y??0),width:a,height:l,...x,...E},u)}};var nw={};Js(nw,{actionAddToLibrary:()=>Sm,actionAlignBottom:()=>D2,actionAlignHorizontallyCentered:()=>O2,actionAlignLeft:()=>P2,actionAlignRight:()=>R2,actionAlignTop:()=>_2,actionAlignVerticallyCentered:()=>N2,actionBindText:()=>_m,actionBringForward:()=>Vd,actionBringToFront:()=>Wd,actionChangeBackgroundColor:()=>Hy,actionChangeExportBackground:()=>xm,actionChangeFillStyle:()=>Uy,actionChangeFontFamily:()=>Ky,actionChangeFontSize:()=>Wy,actionChangeOpacity:()=>Yy,actionChangeProjectName:()=>bm,actionChangeSloppiness:()=>Vy,actionChangeStrokeColor:()=>Fy,actionChangeStrokeWidth:()=>Gy,actionChangeTextAlign:()=>Zy,actionChangeVerticalAlign:()=>Xy,actionChangeViewBackgroundColor:()=>Qy,actionClearCanvas:()=>fr,actionCopy:()=>Pi,actionCopyAsPng:()=>Ts,actionCopyAsSvg:()=>ws,actionCopyStyles:()=>ym,actionCut:()=>vs,actionDeleteSelected:()=>Ca,actionDuplicateSelection:()=>Xd,actionFinalize:()=>co,actionFlipHorizontal:()=>km,actionFlipVertical:()=>Mm,actionGoToCollaborator:()=>L2,actionGroup:()=>wm,actionLink:()=>Ua,actionLoadScene:()=>_i,actionPasteStyles:()=>vm,actionResetZoom:()=>fs,actionSaveFileToDisk:()=>Na,actionSaveToActiveFile:()=>An,actionSelectAll:()=>Zd,actionSendBackward:()=>Gd,actionSendToBack:()=>Yd,actionSetEmbeddableAsActiveTool:()=>r2,actionShortcuts:()=>_n,actionToggleCanvasMenu:()=>w2,actionToggleCropEditor:()=>op,actionToggleEditMenu:()=>T2,actionToggleElementLock:()=>Pm,actionToggleGridMode:()=>Is,actionToggleLinearEditor:()=>tp,actionToggleObjectsSnapMode:()=>Lm,actionToggleSearchMenu:()=>$a,actionToggleStats:()=>Ni,actionToggleTheme:()=>Mn,actionToggleZenMode:()=>Ri,actionUnbindText:()=>Am,actionUngroup:()=>Tm,actionZoomIn:()=>hs,actionZoomOut:()=>gs,actionZoomToFit:()=>t2,copyText:()=>Cs,distributeHorizontally:()=>H2,distributeVertically:()=>U2});import{atom as De,createStore as YT}from"jotai";import{createIsolation as WT}from"jotai-scope";var PE=WT();var{useAtom:we,useSetAtom:xn,useAtomValue:ud,useStore:c_}=PE,RE=PE.Provider,kt=YT();var KT=Cb({"./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-6574ZDO2.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-LNUGB5OW.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-E62DVLB3.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-RAJ6MFWO.js")});var ZT=85,pr={code:"en",label:"English"},ga=[pr,...[{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=>$x[e.code]>=ZT).sort((e,o)=>e.label>o.label?1:-1)],gd="__test__";Ge()&&ga.unshift({code:gd,label:"test language"},{code:`${gd}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var ha=pr,hd={},fd=async e=>{if(ha=e,document.documentElement.dir=ha.rtl?"rtl":"ltr",document.documentElement.lang=ha.code,e.code.startsWith(gd))hd={};else try{hd=await KT(`./locales/${ha.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),hd=Hu}kt.set(OE,e.code)},Hr=()=>ha,NE=(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},f=(e,o,t)=>{if(ha.code.startsWith(gd))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=NE(hd,r)||NE(Hu,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(k.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},OE=De(pr.code),ut=()=>{let e=ud(OE);return{t:f,langCode:e}};var rt=class e{constructor(o,t){this.deleted=o;this.inserted=t}static create(o,t,r,n){let i=r&&n!=="inserted"?r(o):o,a=r&&n!=="deleted"?r(t):t;return new e(i,a)}static calculate(o,t,r,n){if(o===t)return e.empty();let i={},a={};for(let c of this.distinctKeysIterator("full",o,t))i[c]=o[c],a[c]=t[c];let[l,s]=n?n(i,a):[i,a];return e.create(l,s,r)}static empty(){return new e({},{})}static isEmpty(o){return!Object.keys(o.deleted).length&&!Object.keys(o.inserted).length}static mergeObjects(o,t,r){let n={...o};for(let i of Object.keys(r))delete n[i];return{...n,...t}}static mergeArrays(o,t,r,n){return Object.values(e.mergeObjects(lr(o??[],n),lr(t??[],n),lr(r??[],n)))}static diffObjects(o,t,r,n){if(!(!o[r]&&!t[r])&&(typeof o[r]=="object"||typeof t[r]=="object")){let i=o[r]??{},a=t[r]??{},l=e.getLeftDifferences(i,a).reduce((c,m)=>(c[m]=n(i[m]),c),{}),s=e.getRightDifferences(i,a).reduce((c,m)=>(c[m]=n(a[m]),c),{});Object.keys(l).length||Object.keys(s).length?(Reflect.set(o,r,l),Reflect.set(t,r,s)):(Reflect.deleteProperty(o,r),Reflect.deleteProperty(t,r))}}static diffArrays(o,t,r,n){if(!(!o[r]&&!t[r])&&(Array.isArray(o[r])||Array.isArray(t[r]))){let i=Array.isArray(o[r])?o[r]:[],a=Array.isArray(t[r])?t[r]:[],l=lr(e.getLeftDifferences(lr(i,n),lr(a,n))),s=lr(e.getRightDifferences(lr(i,n),lr(a,n)));if(Object.keys(l).length||Object.keys(s).length){let c=i.filter(d=>l[n?n(d):String(d)]),m=a.filter(d=>s[n?n(d):String(d)]);Reflect.set(o,r,c),Reflect.set(t,r,m)}else Reflect.deleteProperty(o,r),Reflect.deleteProperty(t,r)}}static isLeftDifferent(o,t,r=!1){return!!this.distinctKeysIterator("left",o,t,r).next().value}static isRightDifferent(o,t,r=!1){return!!this.distinctKeysIterator("right",o,t,r).next().value}static getLeftDifferences(o,t,r=!1){return Array.from(this.distinctKeysIterator("left",o,t,r))}static getRightDifferences(o,t,r=!1){return Array.from(this.distinctKeysIterator("right",o,t,r))}static*distinctKeysIterator(o,t,r,n=!1){if(t===r)return;let i=[];o==="left"?i=Object.keys(t):o==="right"?i=Object.keys(r):o==="full"?i=Array.from(new Set([...Object.keys(t),...Object.keys(r)])):oi(o,`Unknown distinctKeysIterator's join param "${o}"`,!0);for(let a of i){let l=t[a],s=r[a];if(l!==s){if(!n&&typeof l=="object"&&typeof s=="object"&&l!==null&&s!==null&&Qe(l,s))continue;yield a}}}},Gl=class e{constructor(o){this.delta=o}static calculate(o,t){let r=rt.calculate(o,t,void 0,e.postProcess);return new e(r)}static empty(){return new e(rt.create({},{}))}inverse(){let o=rt.create(this.delta.inserted,this.delta.deleted);return new e(o)}applyTo(o,t){try{let{selectedElementIds:r={},selectedGroupIds:n={}}=this.delta.deleted,{selectedElementIds:i={},selectedGroupIds:a={},selectedLinearElementId:l,editingLinearElementId:s,...c}=this.delta.inserted,m=rt.mergeObjects(o.selectedElementIds,i,r),d=rt.mergeObjects(o.selectedGroupIds,a,n),p=l&&t.has(l)?new j(t.get(l)):null,u=s&&t.has(s)?new j(t.get(s)):null,g={...o,...c,selectedElementIds:m,selectedGroupIds:d,selectedLinearElement:typeof l<"u"?p:o.selectedLinearElement,editingLinearElement:typeof s<"u"?u:o.editingLinearElement},b=this.filterInvisibleChanges(o,g,t);return[g,b]}catch(r){if(console.error("Couldn't apply appstate change",r),mt()||Ge())throw r;return[o,!1]}}isEmpty(){return rt.isEmpty(this.delta)}static postProcess(o,t){try{rt.diffObjects(o,t,"selectedElementIds",r=>!0),rt.diffObjects(o,t,"selectedGroupIds",r=>r??!1)}catch(r){if(console.error("Couldn't postprocess appstate change deltas."),mt()||Ge())throw r}finally{return[o,t]}}filterInvisibleChanges(o,t,r){let n=Yl(o),i=Yl(t),a=rt.isRightDifferent(e.stripElementsProps(n),e.stripElementsProps(i)),l=rt.isRightDifferent(e.stripStandaloneProps(n),e.stripStandaloneProps(i));if(!a&&!l)return!1;let s={value:a};if(l){let c=rt.getRightDifferences(e.stripStandaloneProps(n),e.stripStandaloneProps(i)),m=new Set;(c.includes("editingGroupId")||c.includes("selectedGroupIds"))&&(m=kx(r));for(let d of c)switch(d){case"selectedElementIds":t[d]=e.filterSelectedElements(t[d],r,s);break;case"selectedGroupIds":t[d]=e.filterSelectedGroups(t[d],m,s);break;case"croppingElementId":{let b=t[d],x=b&&r.get(b);x&&!x.isDeleted?s.value=!0:t[d]=null;break}case"editingGroupId":let p=t[d];p?m.has(p)?s.value=!0:t[d]=null:s.value=!0;break;case"selectedLinearElementId":case"editingLinearElementId":let u=e.convertToAppStateKey(d),g=t[u];if(!g)s.value=!0;else{let b=r.get(g.elementId);b&&!b.isDeleted?s.value=!0:t[u]=null}break;default:oi(d,`Unknown ObservedElementsAppState's key "${d}"`,!0)}}return s.value}static convertToAppStateKey(o){switch(o){case"selectedLinearElementId":return"selectedLinearElement";case"editingLinearElementId":return"editingLinearElement"}}static filterSelectedElements(o,t,r){let n=Object.keys(o);if(!n.length)return r.value=!0,o;let i={...o};for(let a of n){let l=t.get(a);l&&!l.isDeleted?r.value=!0:delete i[a]}return i}static filterSelectedGroups(o,t,r){if(!Object.keys(o).length)return r.value=!0,o;let i={...o};for(let a of Object.keys(i))t.has(a)?r.value=!0:delete i[a];return i}static stripElementsProps(o){let{editingGroupId:t,selectedGroupIds:r,selectedElementIds:n,editingLinearElementId:i,selectedLinearElementId:a,croppingElementId:l,...s}=o;return s}static stripStandaloneProps(o){let{name:t,viewBackgroundColor:r,...n}=o;return n}},Pe=class Pe{constructor(o,t,r){this.added=o;this.removed=t;this.updated=r}static create(o,t,r,n={shouldRedistribute:!1}){let i;if(n.shouldRedistribute){let a=new Map,l=new Map,s=new Map,c=[...o,...t,...r];for(let[m,d]of c)this.satisfiesAddition(d)?a.set(m,d):this.satisfiesRemoval(d)?l.set(m,d):s.set(m,d);i=new Pe(a,l,s)}else i=new Pe(o,t,r);return(mt()||Ge())&&(Pe.validate(i,"added",this.satisfiesAddition),Pe.validate(i,"removed",this.satisfiesRemoval),Pe.validate(i,"updated",this.satisfiesUpdate)),i}static validate(o,t,r){for(let[n,i]of o[t].entries())if(!r(i))throw console.error(`Broken invariant for "${t}" delta, element "${n}", delta:`,i),new Error(`ElementsChange invariant broken for element "${n}".`)}static calculate(o,t){if(o===t)return Pe.empty();let r=new Map,n=new Map,i=new Map;for(let a of o.values())if(!t.get(a.id)){let s={...a,isDeleted:!1},c={isDeleted:!0},m=rt.create(s,c,Pe.stripIrrelevantProps);n.set(a.id,m)}for(let a of t.values()){let l=o.get(a.id);if(!l){let s={isDeleted:!0},c={...a,isDeleted:!1},m=rt.create(s,c,Pe.stripIrrelevantProps);r.set(a.id,m);continue}if(l.versionNonce!==a.versionNonce){let s=rt.calculate(l,a,Pe.stripIrrelevantProps,Pe.postProcess);if(typeof l.isDeleted=="boolean"&&typeof a.isDeleted=="boolean"&&l.isDeleted!==a.isDeleted){l.isDeleted&&!a.isDeleted?r.set(a.id,s):n.set(a.id,s);continue}rt.isEmpty(s)||i.set(a.id,s)}}return Pe.create(r,n,i)}static empty(){return Pe.create(new Map,new Map,new Map)}inverse(){let o=i=>{let a=new Map;for(let[l,s]of i.entries())a.set(l,rt.create(s.inserted,s.deleted));return a},t=o(this.added),r=o(this.removed),n=o(this.updated);return Pe.create(r,t,n)}isEmpty(){return this.added.size===0&&this.removed.size===0&&this.updated.size===0}applyLatestChanges(o){let t=l=>s=>{let c={};for(let m of Object.keys(s))switch(m){case"boundElements":c[m]=s[m];break;default:c[m]=l[m]}return c},r=l=>{let s=new Map;for(let[c,m]of l.entries()){let d=o.get(c);if(d){let p=rt.create(m.deleted,m.inserted,t(d),"inserted");s.set(c,p)}else s.set(c,m)}return s},n=r(this.added),i=r(this.removed),a=r(this.updated);return Pe.create(n,i,a,{shouldRedistribute:!0})}applyTo(o,t){let r=dn(new Map(o)),n,i={containsVisibleDifference:!1,containsZindexDifference:!1};try{let a=Pe.createApplier(r,t,i),l=a(this.added),s=a(this.removed),c=a(this.updated),m=this.resolveConflicts(o,r);n=new Map([...l,...s,...c,...m])}catch(a){if(console.error("Couldn't apply elements change",a),mt()||Ge())throw a;return[o,!0]}try{Pe.redrawTextBoundingBoxes(r,n),r=Pe.reorderElements(r,n,i),Pe.redrawBoundArrows(r,n)}catch(a){if(console.error("Couldn't mutate elements after applying elements change",a),mt()||Ge())throw a}finally{return[r,i.containsVisibleDifference]}}static applyDelta(o,t,r={containsVisibleDifference:!0,containsZindexDifference:!0}){let{boundElements:n,...i}=t.inserted;if(t.deleted.boundElements?.length||t.inserted.boundElements?.length){let a=rt.mergeArrays(o.boundElements,t.inserted.boundElements,t.deleted.boundElements,l=>l.id);Object.assign(i,{boundElements:a})}if(fe(o)){let a=t;(a.deleted.crop||a.inserted.crop)&&Object.assign(i,{crop:a.inserted.crop??null})}if(!r.containsVisibleDifference){let{index:a,...l}=i,s=Pe.checkForVisibleDifference(o,l);r.containsVisibleDifference=s}return r.containsZindexDifference||(r.containsZindexDifference=t.deleted.index!==t.inserted.index),re(o,i)}static checkForVisibleDifference(o,t){return o.isDeleted&&t.isDeleted!==!1?!1:o.isDeleted&&t.isDeleted===!1||o.isDeleted===!1&&t.isDeleted?!0:rt.isRightDifferent(o,t)}resolveConflicts(o,t){let r=new Map,n=(c,m)=>{let d=t.get(c.id);if(!d)return;let p;o.get(c.id)===d?p=re(d,m):p=B(d,m),r.set(p.id,p),t.set(p.id,p)};for(let[c]of this.removed)Pe.unbindAffected(o,t,c,n);for(let[c]of this.added)Pe.rebindAffected(o,t,c,n);for(let[c]of Array.from(this.updated).filter(([m,d])=>Object.keys({...d.deleted,...d.inserted}).find(p=>ax.has(p)))){let m=t.get(c);!m||m.isDeleted||Pe.rebindAffected(o,t,c,n)}let i=new Map(Array.from(o).filter(([c])=>r.has(c))),{added:a,removed:l,updated:s}=Pe.calculate(i,r);for(let[c,m]of a)this.added.set(c,m);for(let[c,m]of l)this.removed.set(c,m);for(let[c,m]of s)this.updated.set(c,m);return r}static unbindAffected(o,t,r,n){let i=()=>o.get(r),a=()=>t.get(r);Ll.unbindAffected(t,i(),n),Ll.unbindAffected(t,a(),n),Al.unbindAffected(t,i(),n),Al.unbindAffected(t,a(),n)}static rebindAffected(o,t,r,n){let i=()=>o.get(r),a=()=>t.get(r);Ll.unbindAffected(t,i(),n),Ll.rebindAffected(t,a(),n),Al.unbindAffected(t,i(),(l,s)=>{Z(l)&&n(l,s)}),Al.rebindAffected(t,a(),n)}static redrawTextBoundingBoxes(o,t){let r=new Map;for(let n of t.values()){if(_e(n)){let{containerId:i}=n,a=i?o.get(i):void 0;a&&r.set(a.id,{container:a,boundText:n})}if(pt(n)){let i=Ao(n),a=i?o.get(i):void 0;a&&r.set(n.id,{container:n,boundText:a})}}for(let{container:n,boundText:i}of r.values())n.isDeleted||i.isDeleted||et(i,n,o,!1)}static redrawBoundArrows(o,t){for(let r of t.values())!r.isDeleted&&ni(r)&&at(r,o,{changedElements:t})}static reorderElements(o,t,r){if(!r.containsZindexDifference)return o;let n=Array.from(o.values()),i=Vc([...n]),a=rt.getRightDifferences(n,i,!0).reduce((l,s)=>{let c=n[Number(s)];return c&&t.has(c.id)&&l.set(c.id,c),l},new Map);return!r.containsVisibleDifference&&a.size&&(r.containsVisibleDifference=!0),te(Gt(i,a))}static postProcess(o,t){try{rt.diffArrays(o,t,"boundElements",r=>r.id)}catch(r){if(console.error("Couldn't postprocess elements change deltas."),mt()||Ge())throw r}finally{return[o,t]}}static stripIrrelevantProps(o){let{id:t,updated:r,version:n,versionNonce:i,seed:a,...l}=o;return l}};I(Pe,"satisfiesAddition",({deleted:o,inserted:t})=>o.isDeleted===!0&&!t.isDeleted),I(Pe,"satisfiesRemoval",({deleted:o,inserted:t})=>!o.isDeleted&&t.isDeleted===!0),I(Pe,"satisfiesUpdate",({deleted:o,inserted:t})=>!!o.isDeleted==!!t.isDeleted),I(Pe,"createApplier",(o,t,r)=>{let n=Pe.createGetter(o,t,r);return i=>Array.from(i.entries()).reduce((a,[l,s])=>{let c=n(l,s.inserted);if(c){let m=Pe.applyDelta(c,s,r);o.set(m.id,m),a.set(m.id,m)}return a},new Map)}),I(Pe,"createGetter",(o,t,r)=>(n,i)=>{let a=o.get(n);return a||(a=t.get(n),a&&(r.containsZindexDifference=!0,(i.isDeleted===!1||i.isDeleted!==!0&&a.isDeleted===!1)&&(r.containsVisibleDifference=!0))),a});var Vl=Pe;var Pt=class{constructor(){I(this,"subscribers",[])}on(...o){let t=o.flat().filter(r=>typeof r=="function");return this.subscribers.push(...t),()=>this.off(t)}once(...o){let t=o.flat().filter(n=>typeof n=="function");t.push(()=>r());let r=this.on(...t);return r}off(...o){let t=o.flat();this.subscribers=this.subscribers.filter(r=>!t.includes(r))}trigger(...o){for(let t of this.subscribers)t(...o);return this}clear(){this.subscribers=[]}};var BE="__observedAppState",Yl=e=>{let o={name:e.name,editingGroupId:e.editingGroupId,viewBackgroundColor:e.viewBackgroundColor,selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,editingLinearElementId:e.editingLinearElement?.elementId||null,selectedLinearElementId:e.selectedLinearElement?.elementId||null,croppingElementId:e.croppingElementId};return Reflect.defineProperty(o,BE,{value:!0,enumerable:!1}),o},XT=e=>!!Reflect.get(e,BE),A={IMMEDIATELY:"IMMEDIATELY",NEVER:"NEVER",EVENTUALLY:"EVENTUALLY"},sh=class{constructor(o,t){this.elementsChange=o;this.appStateChange=t}},bd=class{constructor(){I(this,"onStoreIncrementEmitter",new Pt);I(this,"scheduledActions",new Set);I(this,"_snapshot",xd.empty());I(this,"shouldCaptureIncrement",()=>{this.scheduleAction(A.IMMEDIATELY)});I(this,"shouldUpdateSnapshot",()=>{this.scheduleAction(A.NEVER)});I(this,"scheduleAction",o=>{this.scheduledActions.add(o),this.satisfiesScheduledActionsInvariant()});I(this,"commit",(o,t)=>{try{this.scheduledActions.has(A.IMMEDIATELY)?this.captureIncrement(o,t):this.scheduledActions.has(A.NEVER)&&this.updateSnapshot(o,t)}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledActions=new Set}});I(this,"captureIncrement",(o,t)=>{let r=this.snapshot,n=this.snapshot.maybeClone(o,t);if(r!==n){let i=n.meta.didElementsChange?Vl.calculate(r.elements,n.elements):Vl.empty(),a=n.meta.didAppStateChange?Gl.calculate(r.appState,n.appState):Gl.empty();(!i.isEmpty()||!a.isEmpty())&&this.onStoreIncrementEmitter.trigger(new sh(i,a)),this.snapshot=n}});I(this,"updateSnapshot",(o,t)=>{let r=this.snapshot.maybeClone(o,t);this.snapshot!==r&&(this.snapshot=r)});I(this,"filterUncomittedElements",(o,t)=>{for(let[r,n]of o.entries()){if(!t.get(r))continue;let a=this.snapshot.elements.get(r);a?a.version<n.version&&t.set(r,a):t.delete(r)}return t});I(this,"clear",()=>{this.snapshot=xd.empty(),this.scheduledActions=new Set});I(this,"satisfiesScheduledActionsInvariant",()=>{if(!(this.scheduledActions.size>=0&&this.scheduledActions.size<=3)){let o=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledActions.size}".`;if(console.error(o,this.scheduledActions.values()),mt()||Ge())throw new Error(o)}})}get snapshot(){return this._snapshot}set snapshot(o){this._snapshot=o}},xd=class e{constructor(o,t,r={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=o;this.appState=t;this.meta=r}static empty(){return new e(new Map,Yl(Br()),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}isEmpty(){return this.meta.isEmpty}maybeClone(o,t){let r=this.maybeCreateElementsSnapshot(o),n=this.maybeCreateAppStateSnapshot(t),i=!1,a=!1;return this.elements!==r&&(i=!0),this.appState!==n&&(a=!0),!i&&!a?this:new e(r,n,{didElementsChange:i,didAppStateChange:a})}maybeCreateAppStateSnapshot(o){if(!o)return this.appState;let t=XT(o)?o:Yl(o);return this.detectChangedAppState(t)?t:this.appState}detectChangedAppState(o){return!Qe(this.appState,o,{selectedElementIds:Qe,selectedGroupIds:Qe})}maybeCreateElementsSnapshot(o){return o?this.detectChangedElements(o)?this.createElementsSnapshot(o):this.elements:this.elements}detectChangedElements(o){if(this.elements===o)return!1;if(this.elements.size!==o.size)return!0;let t=Array.from(o.keys());for(let r=t.length-1;r>=0;r--){let n=this.elements.get(t[r]),i=o.get(t[r]);if(!n||!i||n.id!==i.id||n.versionNonce!==i.versionNonce)return!0}return!1}createElementsSnapshot(o){let t=new Map;for(let[r,n]of this.elements.entries())o.get(r)?t.set(r,n):t.set(r,re(n,{isDeleted:!0}));for(let[r,n]of o.entries()){let i=t.get(r);(!i||i&&i.versionNonce!==n.versionNonce)&&t.set(r,xo(n))}return t}};var UE={};Js(UE,{AlignBottomIcon:()=>Ad,AlignLeftIcon:()=>_d,AlignRightIcon:()=>Dd,AlignTopIcon:()=>Ld,ArrowIcon:()=>yh,ArrowRightIcon:()=>Ci,ArrowheadArrowIcon:()=>Qh,ArrowheadBarIcon:()=>og,ArrowheadCircleIcon:()=>eg,ArrowheadCircleOutlineIcon:()=>tg,ArrowheadCrowfootIcon:()=>lg,ArrowheadCrowfootOneIcon:()=>sg,ArrowheadCrowfootOneOrManyIcon:()=>cg,ArrowheadDiamondIcon:()=>ig,ArrowheadDiamondOutlineIcon:()=>ag,ArrowheadNoneIcon:()=>Jh,ArrowheadTriangleIcon:()=>rg,ArrowheadTriangleOutlineIcon:()=>ng,BringForwardIcon:()=>Id,BringToFrontIcon:()=>kd,CenterHorizontallyIcon:()=>Rd,CenterVerticallyIcon:()=>Pd,CloseIcon:()=>Eo,DeviceDesktopIcon:()=>Vg,DiamondIcon:()=>xh,DiscordIcon:()=>kh,DistributeHorizontallyIcon:()=>Bh,DistributeVerticallyIcon:()=>zh,DotsIcon:()=>mh,DuplicateIcon:()=>ba,EdgeRoundIcon:()=>qh,EdgeSharpIcon:()=>jh,EllipseIcon:()=>Eh,EmbedIcon:()=>vd,EraserIcon:()=>Ch,ExcalLogo:()=>qT,ExportIcon:()=>yn,ExportImageIcon:()=>$l,ExternalLinkIcon:()=>wd,FillCrossHatchIcon:()=>Uh,FillHachureIcon:()=>Hh,FillSolidIcon:()=>Gh,FillZigZagIcon:()=>Fh,FontFamilyCodeIcon:()=>ql,FontFamilyHeadingIcon:()=>hg,FontFamilyNormalIcon:()=>va,FontSizeExtraLargeIcon:()=>ug,FontSizeLargeIcon:()=>pg,FontSizeMediumIcon:()=>mg,FontSizeSmallIcon:()=>dg,FreedrawIcon:()=>Ur,GithubIcon:()=>Zl,GroupIcon:()=>Nd,HamburgerMenuIcon:()=>Kl,HelpIcon:()=>vi,HelpIconThin:()=>Sh,HomeIcon:()=>ch,ImageIcon:()=>Th,LassoIcon:()=>fa,LibraryIcon:()=>Ei,LineIcon:()=>vh,LinkIcon:()=>ya,LoadIcon:()=>wi,LockedIcon:()=>yi,MagicIcon:()=>ts,MagicIconThin:()=>f6,MoonIcon:()=>xa,OpenAIIcon:()=>b6,PenModeIcon:()=>wh,PinIcon:()=>ph,PlusIcon:()=>dh,RectangleIcon:()=>bh,RedoIcon:()=>Cd,SelectionIcon:()=>fh,SendBackwardIcon:()=>Sd,SendToBackIcon:()=>Md,SloppinessArchitectIcon:()=>Zh,SloppinessArtistIcon:()=>Xh,SloppinessCartoonistIcon:()=>$h,StrokeStyleDashedIcon:()=>Wh,StrokeStyleDottedIcon:()=>Kh,StrokeStyleSolidIcon:()=>p6,StrokeWidthBaseIcon:()=>Bd,StrokeWidthBoldIcon:()=>Vh,StrokeWidthExtraBoldIcon:()=>Yh,SunIcon:()=>Ea,TextAlignBottomIcon:()=>Eg,TextAlignCenterIcon:()=>fg,TextAlignLeftIcon:()=>gg,TextAlignMiddleIcon:()=>yg,TextAlignRightIcon:()=>bg,TextAlignTopIcon:()=>xg,TextIcon:()=>Wl,TrashIcon:()=>lo,UndoIcon:()=>Td,UngroupIcon:()=>Od,UnlockedIcon:()=>En,WelcomeScreenHelpArrow:()=>hh,WelcomeScreenMenuArrow:()=>uh,WelcomeScreenTopToolbarArrow:()=>gh,XBrandIcon:()=>Mh,ZoomInIcon:()=>Ed,ZoomOutIcon:()=>yd,ZoomResetIcon:()=>Ih,abacusIcon:()=>Og,alertTriangleIcon:()=>Ig,angleIcon:()=>Jl,boltIcon:()=>os,brainIcon:()=>Ag,brainIconThin:()=>_g,bucketFillIcon:()=>Xl,checkIcon:()=>Lh,clipboard:()=>JT,clockIcon:()=>Dg,clone:()=>c6,coffeeIcon:()=>Gg,collapseDownIcon:()=>ns,collapseUpIcon:()=>jg,copyIcon:()=>Ti,createIcon:()=>D,cropIcon:()=>Hd,cutIcon:()=>wg,done:()=>Rh,downloadIcon:()=>zd,elbowArrowIcon:()=>Xg,elementLinkIcon:()=>is,eraser:()=>u6,exportToFileIcon:()=>Ph,exportToPlus:()=>n6,extraToolsIcon:()=>kg,eyeClosedIcon:()=>Lg,eyeDropperIcon:()=>Sg,eyeIcon:()=>Ii,file:()=>m6,flipHorizontal:()=>zg,flipVertical:()=>Bg,fontSizeIcon:()=>vn,frameToolIcon:()=>wa,fullscreenIcon:()=>Mg,gridIcon:()=>Wg,handIcon:()=>Ql,helpIcon:()=>Tg,iconFillColor:()=>Do,laserPointerToolIcon:()=>Ta,lineEditorIcon:()=>Kg,loginIcon:()=>x6,magnetIcon:()=>Ug,menu:()=>t6,mermaidLogoIcon:()=>es,microphoneIcon:()=>Pg,microphoneMutedIcon:()=>Rg,paintIcon:()=>Fd,palette:()=>Dh,playerPlayIcon:()=>h6,playerStopFilledIcon:()=>g6,pngIcon:()=>Hg,publishIcon:()=>vg,questionCircle:()=>Nh,resetZoom:()=>a6,roundArrowIcon:()=>$g,save:()=>Ah,saveAs:()=>_h,searchIcon:()=>so,selectAllIcon:()=>Ng,share:()=>Oh,shareIOS:()=>r6,shareWindows:()=>i6,sharpArrowIcon:()=>Zg,shield:()=>d6,start:()=>l6,stop:()=>s6,svgIcon:()=>Fg,tablerCheckIcon:()=>Cg,upIcon:()=>qg,usersIcon:()=>jl,warning:()=>o6,youtubeIcon:()=>Yg,zoomAreaIcon:()=>rs,zoomIn:()=>QT,zoomOut:()=>e6});import $T from"clsx";import jT from"open-color";import Mt from"react";import{Fragment as Oe,jsx as h,jsxs as O}from"react/jsx-runtime";var Do=e=>"var(--icon-fill-color)",zE=e=>e===ce.LIGHT?jT.white:"#1e1e1e",D=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:i,...a}=typeof o=="number"?{width:o}:o;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:$T({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},Y={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},me={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ch=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"5 12 3 12 12 3 21 12 19 12"}),h("path",{d:"M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7"}),h("path",{d:"M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6"})]}),Y),Ei=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),h("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),h("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),Y),dh=D(O("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),Y),mh=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),Y),ph=D(O("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),Y),En=D(O("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),me),yi=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),me),uh=D(O(Oe,{children:[h("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),hh=D(O(Oe,{children:[h("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),gh=D(O(Oe,{children:[h("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),qT=D(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),fh=D(O("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),fa=D(O("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),bh=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),Y),xh=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),Y),Eh=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),Y),yh=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),Y),vh=D(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),me),wh=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),Y),Ur=D(O("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),me),Wl=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),Y),Th=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),me),Ch=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),Y),Ed=D(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),me),yd=D(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),me),Ih=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),h("path",{d:"M3 4v4h4"})]}),Y),lo=D(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),me),vd=D(O("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),me),ba=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),me),xa=D(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),me),Ea=D(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...me,strokeWidth:1.5}),Kl=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),Y),yn=D(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),me),vi=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),Y),Sh=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),Y),wd=D(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),me),Zl=D(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),me),kh=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),me),Mh=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),Y),Lh=D(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),ya=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),me),Ah=D("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}),_h=D("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}),wi=D(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),me),JT=D("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}),Dh=D("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"),Xl=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),h("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"}),h("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"})]}),Y),$l=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),Y),Ph=D("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}),QT=D("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}),e6=D("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}),Rh=D("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"),t6=D("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"),Td=D(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),me),Cd=D(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),me),Nh=D("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}),Oh=D(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),me),o6=D("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"),r6=D("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}),n6=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),Y),i6=D(O(Oe,{children:[h("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),h("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),a6=D(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),FE=O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),HE=O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),Id=D(HE,Y),Sd=D(HE,{...Y,style:{transform:"rotate(180deg)"}}),kd=D(FE,Y),Md=D(FE,{...Y,style:{transform:"rotate(180deg)"}}),Ld=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Ad=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),_d=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Dd=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Bh=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),zh=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Pd=D(O("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),me),Rd=D(O("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),me),jl=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),Y),l6=D("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"),s6=D("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"),Eo=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),c6=D("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}),d6=D("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}),m6=D("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}),Nd=Mt.memo(({theme:e})=>D(O(Oe,{children:[h("path",{d:"M25 26H111V111H25",fill:Do(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Do(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Do(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Do(e),strokeWidth:"2"}),O("g",{fill:zE(e),stroke:Do(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Od=Mt.memo(({theme:e})=>D(O(Oe,{children:[h("path",{d:"M25 26H111V111H25",fill:Do(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:Do(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Do(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:Do(e),strokeWidth:"2"}),O("g",{fill:zE(e),stroke:Do(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Fh=D(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),me),Hh=D(O(Oe,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),me),Uh=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Gh=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...me,fill:"currentColor"}),Bd=D(h(Oe,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),Vh=D(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),me),Yh=D(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),me),p6=Mt.memo(({theme:e})=>D(h("path",{d:"M6 10H34",stroke:Do(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Wh=D(O("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),Y),Kh=D(O("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),Y),Zh=D(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),me),Xh=D(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),me),$h=D(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),me),jh=D(O("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),me),qh=D(O("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),Y),Jh=D(O("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[h("path",{d:"M12 12l9 0"}),h("path",{d:"M3 9l6 6"}),h("path",{d:"M3 15l6 -6"})]}),Y),Qh=Mt.memo(({flip:e=!1})=>D(O("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[h("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),h("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),eg=Mt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),tg=Mt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M26 10L6 10"}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),og=Mt.memo(({flip:e=!1})=>D(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:h("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),rg=Mt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),ng=Mt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[h("path",{d:"M6,9.5H27"}),h("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),ig=Mt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),ag=Mt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),lg=Mt.memo(({flip:e=!1})=>D(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),sg=Mt.memo(({flip:e=!1})=>D(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),cg=Mt.memo(({flip:e=!1})=>D(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),dg=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),mg=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),pg=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),ug=D(h(Oe,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),vn=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),Y),hg=D(h(Oe,{children:O("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),Y),va=D(h(Oe,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),me),ql=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("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"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),gg=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),Y),fg=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),Y),bg=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),Y),xg=Mt.memo(({theme:e})=>D(O("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),Y)),Eg=Mt.memo(({theme:e})=>D(O("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),Y)),yg=Mt.memo(({theme:e})=>D(O("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),Y)),Jl=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),Y),vg=D(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),u6=D(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Ql=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),Y),zd=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),Y),Ti=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),Y),wg=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),Y),Tg=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),Y),h6=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),Y),g6=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),Y),Cg=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),Y),Ig=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),Y),Sg=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l6 6"}),h("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"})]}),Y),kg=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l-4 7h8z"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("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"})]}),Y),wa=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),Y),es=D(h("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"})),Ci=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),me),Ta=D(O("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),h("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),ts=D(O("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),Y),f6=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),Y),b6=D(O("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),Y),Mg=D(O("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),Y),Ii=D(O("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),Y),Lg=D(O("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),h("path",{d:"M3 3l18 18"})]}),Y),Ag=D(O("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),Y),_g=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),Y),so=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),Y),Dg=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),Y),Pg=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),Y),Rg=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),Y),os=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),Y),Ng=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),Y),Og=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),Y),Bg=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),Y),zg=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),Y),Fd=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),Y),rs=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),Y),Fg=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),Y),Hg=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),Y),Ug=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),Y),Gg=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),Y),Vg=D(O("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...Y,strokeWidth:1.5}),x6=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),Y),Yg=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),Y),Wg=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),Y),Kg=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),Y),Zg=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),Y),Xg=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),Y),$g=D(O("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),Y),ns=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),Y),jg=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),Y),qg=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),Y),Hd=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),Y),is=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),Y);import GE from"clsx";import Qg,{useEffect as v6,useRef as VE,useState as w6}from"react";import E6 from"react";import{jsx as Jg}from"react/jsx-runtime";var y6=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(E6.useRef(Date.now()).current%1600);return Jg("div",{className:`Spinner ${r}`,children:Jg("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Jg("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},Lt=y6;import{jsx as as,jsxs as ls}from"react/jsx-runtime";var ee=Qg.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=gt(),a=Qg.useRef(null);Qg.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=w6(!1),m=VE(!0),d=async u=>{let g="onClick"in r&&r.onClick?.(u);if(ln(g))try{c(!0),await g}catch(b){if(b instanceof da)console.warn(b);else throw b}finally{m.current&&c(!1)}};v6(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=VE(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return ls("button",{className:GE("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)&&ls("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&as("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&as(Lt,{})]}),r.showAriaLabel&&ls("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&as(Lt,{})]}),r.children]})}return ls("label",{className:GE("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[as("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}),ls("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&as("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});ee.displayName="ToolButton";var Ud=[],F=e=>(Ud=Ud.concat(e),e);import{jsx as C6}from"react/jsx-runtime";var T6=(e,o,t)=>{let r=new Set(J(e.filter(m=>ae(m)),o).map(m=>m.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of r){let d=_o(e,m);for(let p of d)if(!a.has(p.id)){if(_e(p)){let u=_t(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let d=_e(m)?_t(m,i):null;return m.frameId&&r.has(m.frameId)?(l=!1,n[m.id]=!0,m):d?.frameId&&r.has(d?.frameId)?m:(m.boundElements&&m.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&oe(u)&&(B(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding}),B(u,{points:u.points}))}),re(m,{isDeleted:!0}))}return m.frameId&&r.has(m.frameId)?(l=!1,_e(m)||(n[m.id]=!0),re(m,{frameId:null})):_e(m)&&o.selectedElementIds[m.containerId]?re(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=Fe(s,o.editingGroupId).filter(d=>!d.isDeleted);if(m.length>1)m[0]&&(n[m[0].id]=!0);else{c=null,m[0]&&(n[m[0].id]=!0);let d=m[0];if(d){let p=d.groupIds.findIndex(g=>g===o.editingGroupId),u=d.groupIds[p+1];if(u){let g=Fe(s,u).filter(b=>!b.isDeleted);g.length>1&&(c=u,g.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...lt({selectedElementIds:n,editingGroupId:c},s,o,null)}}},YE=(e,o)=>{if(e.editingGroupId){let t=Fe(xe(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Ca=F({name:"deleteSelectedElements",label:"labels.delete",icon:lo,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.editingLinearElement){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:c}=o.editingLinearElement,m=r.scene.getNonDeletedElementsMap(),d=j.getElement(a,m);if(!d||l==null)return!1;if(d.points.length<2){let u=e.map(b=>b.id===d.id?re(b,{isDeleted:!0}):b),g=YE(o,u);return{elements:u,appState:{...g,editingLinearElement:null},captureUpdate:A.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:c};return j.deletePoints(d,l),{elements:e,appState:{...o,editingLinearElement:{...o.editingLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:A.IMMEDIATELY}}let{elements:n,appState:i}=T6(e,o,r);return Pc(n,n.filter(a=>a.isDeleted)),i=YE(i,n),{elements:n,appState:{...i,activeTool:Ue(o,{type:"selection"}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:ze(xe(e),o)?A.IMMEDIATELY:A.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===T.BACKSPACE||e.key===T.DELETE)&&!e[T.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>C6(ee,{type:"button",icon:lo,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),visible:ze(xe(e),o)})});var ef=(e,o)=>e.frameId===o||e.id===o,KE=(e,o,t)=>{let r=[],n=[],i=null,a=-1,l=te(t||J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++a<e.length;){let s=e[a];l.get(s.id)?(n.length&&(r=r.concat(n),n=[]),r.push(a),i=a+1):s.isDeleted&&i===a?(i=a+1,n.push(a)):n=[]}return r},I6=e=>{let o=0;return e.reduce((t,r,n)=>(n>0&&e[n-1]!==r-1&&(o=++o),(t[o]||(t[o]=[])).push(r),t),[])},WE=(e,o,t,r)=>{if("containerId"in e&&e.containerId){let n=r.getElement(e.containerId);if(n)return t==="left"?Math.min(o.indexOf(n),o.indexOf(e)):Math.max(o.indexOf(n),o.indexOf(e))}else{let n=e.boundElements?.find(i=>i.type!=="arrow")?.id;if(n){let i=r.getElement(n);if(i)return t==="left"?Math.min(o.indexOf(i),o.indexOf(e)):Math.max(o.indexOf(i),o.indexOf(e))}}},S6=(e,o)=>{let t=-1,r=-1;return e.forEach((n,i)=>{ef(n,o)&&(t===-1&&(t=i),r=i)}),t===-1?[]:e.slice(t,r+1)},k6=(e,o,t,r,n,i)=>{let a=o[t],l=p=>p.isDeleted?!1:n?p.frameId===n:e.editingGroupId?p.groupIds.includes(e.editingGroupId):!0,s=r==="left"?Ar(o,p=>l(p),Math.max(0,t-1)):bu(o,p=>l(p),t+1),c=o[s];if(!c)return-1;if(e.editingGroupId){if(a?.groupIds.join("")===c?.groupIds.join(""))return WE(c,o,r,i)??s;if(!c?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(c.frameId||ae(c))){let p=S6(o,c.frameId||c.id);return r==="left"?o.indexOf(p[0]):o.indexOf(p[p.length-1])}if(!c.groupIds.length)return WE(c,o,r,i)??s;let m=e.editingGroupId?c.groupIds[c.groupIds.indexOf(e.editingGroupId)-1]:c.groupIds[c.groupIds.length-1],d=Fe(o,m);return d.length?r==="left"?o.indexOf(d[0]):o.indexOf(d[d.length-1]):s},ZE=(e,o)=>o.reduce((t,r)=>{let n=e[r];return t.set(n.id,n),t},new Map),XE=(e,o,t,r)=>{let n=KE(e,o),i=ZE(e,n),a=I6(n);t==="right"&&(a=a.reverse());let l=new Set(n.filter(s=>ae(e[s])).map(s=>e[s].id));return a.forEach((s,c)=>{let m=s[0],d=s[s.length-1],p=t==="left"?m:d,u=s.some(y=>{let v=e[y];return v.frameId&&l.has(v.frameId)})?null:e[p]?.frameId,g=k6(o,e,p,t,u,r);if(g===-1||p===g)return;let b=t==="left"?e.slice(0,g):e.slice(0,m),x=e.slice(m,d+1),E=t==="left"?e.slice(g,m):e.slice(d+1,g+1),w=t==="left"?e.slice(d+1):e.slice(g+1);e=t==="left"?[...b,...x,...E,...w]:[...b,...E,...x,...w]}),Gt(e,i),e},$E=(e,o,t,r,n)=>{let i=KE(e,o,n),a=ZE(e,i),l=[],s,c;if(t==="left"){if(r)s=bu(e,g=>ef(g,r));else if(o.editingGroupId){let g=Fe(e,o.editingGroupId);if(!g.length)return e;s=e.indexOf(g[0])}else s=0;c=i[i.length-1]}else{if(r)c=Ar(e,g=>ef(g,r));else if(o.editingGroupId){let g=Fe(e,o.editingGroupId);if(!g.length)return e;c=e.indexOf(g[g.length-1])}else c=e.length-1;s=i[0]}s===-1&&(s=0);for(let g=s;g<c+1;g++)i.includes(g)||l.push(e[g]);let m=Array.from(a.values()),d=e.slice(0,s),p=e.slice(c+1),u=t==="left"?[...d,...m,...l,...p]:[...d,...l,...m,...p];return Gt(u,a),u};function jE(e,o,t,r){let n=te(J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),i={regularElements:[],frameChildren:new Map},a=new Set;for(let c of e)n.has(c.id)&&ae(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(ae(c)||c.frameId&&a.has(c.frameId))i.regularElements.push(c);else if(!c.frameId)i.regularElements.push(c);else{let m=i.frameChildren.get(c.frameId)||[];m.push(c),i.frameChildren.set(c.frameId,m)}let l=e,s=Array.from(i.frameChildren.entries());for(let[c,m]of s)l=r(e,o,t,c,m);return r(l,o,t,null,i.regularElements)}var qE=(e,o,t)=>XE(e,o,"left",t),JE=(e,o,t)=>XE(e,o,"right",t),QE=(e,o)=>jE(e,o,"left",$E),ey=(e,o)=>jE(e,o,"right",$E);import{jsx as Kd}from"react/jsx-runtime";var Gd=F({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Sd,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:qE(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ue.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Kd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${R("CtrlOrCmd+[")}`,children:Sd})}),Vd=F({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Id,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:JE(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===ue.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Kd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${R("CtrlOrCmd+]")}`,children:Id})}),Yd=F({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Md,trackEvent:{category:"element"},perform:(e,o)=>({elements:QE(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Vo?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===ue.BRACKET_LEFT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===ue.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Kd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Vo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")}`,children:Md})}),Wd=F({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:kd,trackEvent:{category:"element"},perform:(e,o)=>({elements:ey(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Vo?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===ue.BRACKET_RIGHT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===ue.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Kd("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Vo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")}`,children:kd})});var Zd=F({name:"selectAll",label:"labels.selectAll",icon:Ng,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.editingLinearElement)return!1;let n=e.filter(i=>!i.isDeleted&&!(Z(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...lt({editingGroupId:null,selectedElementIds:n},xe(e),o,r),selectedLinearElement:Object.keys(n).length===1&&le(e[0])?new j(e[0]):null},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.A});import{jsx as L6}from"react/jsx-runtime";var Xd=F({name:"duplicateSelection",label:"labels.duplicateSelection",icon:ba,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.editingLinearElement)try{let a=j.duplicateSelectedPoints(o,r.scene.getNonDeletedElementsMap());return{elements:e,appState:a,captureUpdate:A.IMMEDIATELY}}catch{return!1}let{newElements:n,elementsWithClones:i}=bn({type:"in-place",elements:e,idsOfElementsToDuplicate:te(J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:a=>({x:a.x+Qp/2,y:a.y+Qp/2}),reverseOrder:!1});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:Gt(i,te(n)),appState:{...o,...M6(n),...lt({editingGroupId:o.editingGroupId,selectedElementIds:Hc(n).reduce((a,l)=>(_e(l)||(a[l.id]=!0),a),{})},xe(i),o,null)},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.D,PanelComponent:({elements:e,appState:o,updateData:t})=>L6(ee,{type:"button",icon:ba,title:`${f("labels.duplicateSelection")} \u2014 ${R("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),visible:ze(xe(e),o)})}),M6=e=>{let o=e.filter(le);if(o.length===1){let t=o[0],r=t.boundElements?.map(i=>i.id)??[];if(e.every(i=>i.id===t.id||r.includes(i.id)))return{selectedLinearElement:new j(t)}}return{selectedLinearElement:null}};import{useEffect as yf,useMemo as rC,useRef as vf,useState as nC}from"react";var A6=new Set(["command_palette","export"]),ye=(e,o,t,r)=>{try{if(typeof window>"u"||k.VITE_WORKER_ID||k.VITE_APP_ENABLE_TRACKING!=="true"||!A6.has(e)||Ge())return;k.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 R6 from"clsx";import _6 from"clsx";import{forwardRef as D6}from"react";import{jsx as P6}from"react/jsx-runtime";var $d=D6((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return P6("button",{type:"button",ref:o,title:t,"data-testid":n,className:_6(r,{standalone:a,active:i}),onClick:s,children:l},t)});import{jsx as tf,jsxs as N6}from"react/jsx-runtime";var Po=e=>tf("div",{className:"buttonList",children:e.options.map(o=>e.type==="button"?tf($d,{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):N6("label",{className:R6({active:e.value===o.value}),title:o.text,children:[tf("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 tm from"@radix-ui/react-popover";import E4 from"clsx";import{useRef as y4}from"react";import{jsx as O6}from"react/jsx-runtime";var jd=()=>O6("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as H6,useRef as U6}from"react";import{createPortal as G6}from"react-dom";import ty from"react";var of=ty.createContext(null),Re=()=>ty.useContext(of);import{useState as B6,useLayoutEffect as oy}from"react";var qd=e=>{let[o,t]=B6(null),r=Ce(),{theme:n}=Re(),{container:i}=gt();return oy(()=>{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===ce.DARK))},[o,n,r.editor.isMobile,e?.className]),oy(()=>{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 z6}from"react";function Ia(e,o,t){z6(()=>{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("pointerdown",r),document.addEventListener("touchstart",r),()=>{document.removeEventListener("pointerdown",r),document.removeEventListener("touchstart",r)}},[e,o,t])}import{useRef as F6}from"react";var wn=e=>{let o=F6(e);return Object.assign(o.current,e),o.current};import{jsx as V6}from"react/jsx-runtime";var Tn=De(null),ry=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=qd({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Re(),a=Cn(),l=st(),s=J(a,i),c=wn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=gt();H6(()=>{let p=d.current;if(!p||!l.canvas||!n)return;let u=!1,g=l.canvas.getContext("2d"),b=({clientX:S,clientY:_})=>{let L=g.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(_-i.offsetTop)*window.devicePixelRatio,1,1).data;return n0(L[0],L[1],L[2])},x=({clientX:S,clientY:_,altKey:L})=>{p.style.top=`${_+20}px`,p.style.left=`${S+20}px`;let N=b({clientX:S,clientY:_});u&&c.onChange(r,N,c.selectedElements,{altKey:L}),p.style.background=N},E=()=>{c.onCancel()},w=(S,_)=>{c.onSelect(S,_)},y=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,m?.focus(),S.stopImmediatePropagation(),S.preventDefault(),w(b(S),S)},C=S=>{S.key===T.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),E())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",C),n.addEventListener("pointerdown",y),n.addEventListener("pointerup",v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener("blur",E),()=>{u=!1,n.removeEventListener("keydown",C),n.removeEventListener("pointerdown",y),n.removeEventListener("pointerup",v),window.removeEventListener("pointermove",x),window.removeEventListener("blur",E)}},[c,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let d=U6(null);return Ia(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?G6(V6("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import*as Sa from"@radix-ui/react-popover";import Z6 from"clsx";import X6 from"react";import Y6 from"react";import W6 from"clsx";import{jsx as K6}from"react/jsx-runtime";var yt=Y6.forwardRef(({children:e,padding:o,className:t,style:r},n)=>K6("div",{className:W6("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as rf,jsxs as $6}from"react/jsx-runtime";var Jd=X6.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},c)=>{let m=Ce();return rf(Sa.Portal,{container:o,children:$6(Sa.Content,{ref:c,className:Z6("focus-visible-none",e),"data-prevent-outside-click":!0,side:m.editor.isMobile&&!m.viewport.isLandscape?"bottom":"right",align:m.editor.isMobile&&!m.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&&!p0(document.activeElement)&&o.focus(),n()},children:[rf(yt,{padding:3,style:r,children:t}),rf(Sa.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import j6 from"clsx";import{useCallback as q6,useEffect as af,useRef as ay,useState as J6}from"react";var In=({palette:e,color:o})=>{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},ss=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),nf=({color:e,palette:o})=>!Object.values(o).flat().includes(e),iy=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return nf({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,qb)},No=De(null),ny=(e,o,t)=>(e*299+o*587+t*114)/1e3,ka=(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]),c=parseInt(l[1]),m=parseInt(l[2]);return ny(s,c,m)<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 ny(t,r,n)<o};import{Fragment as Q6,jsx as Qd,jsxs as ly}from"react/jsx-runtime";var sy=({color:e,onChange:o,label:t,colorPickerType:r})=>{let n=Ce(),[i,a]=J6(e),[l,s]=we(No);af(()=>{a(e)},[e]);let c=q6(g=>{let b=g.toLowerCase(),x=cy(b);x&&o(x),a(b)},[o]),m=ay(null),d=ay(null);af(()=>{m.current&&m.current.focus()},[l]);let[p,u]=we(Tn);return af(()=>()=>{u(null)},[u]),ly("div",{className:"color-picker__input-label",children:[Qd("div",{className:"color-picker__input-hash",children:"#"}),Qd("input",{ref:l==="hex"?m:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:g=>{c(g.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>s("hex"),onKeyDown:g=>{g.key!==T.TAB&&(g.key===T.ESCAPE&&d.current?.focus(),g.stopPropagation())}}),!n.editor.isMobile&&ly(Q6,{children:[Qd("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Qd("div",{ref:d,className:j6("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(g=>g?null:{keepOpenOnAlt:!1,onSelect:b=>o(b),colorPickerType:r}),title:`${f("labels.eyeDropper")} \u2014 ${T.I.toLocaleUpperCase()} or ${R("Alt")} `,children:Sg})]})]})};import gy,{useEffect as fy,useState as b4}from"react";import o4 from"clsx";import{useEffect as r4,useRef as n4}from"react";import{jsxs as t4}from"react/jsx-runtime";var e4=({color:e,keyLabel:o,isShade:t=!1})=>t4("div",{className:"color-picker__button__hotkey-label",style:{color:ka(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Ma=e4;import{jsx as lf,jsxs as i4}from"react/jsx-runtime";var dy=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=we(No),a=n4(null);return r4(()=>{a.current&&a.current.focus()},[o,n]),lf("div",{className:"color-picker-content--default",children:e.map((l,s)=>i4("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:o4("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:[lf("div",{className:"color-picker__button-outline"}),lf(Ma,{color:l,keyLabel:s+1})]},s))})};import a4 from"clsx";import{useEffect as l4,useRef as s4}from"react";import{jsx as sf,jsxs as d4}from"react/jsx-runtime";var c4=({palette:e,color:o,onChange:t,label:r,activeShade:n})=>{let i=In({color:o||"transparent",palette:e}),[a,l]=we(No),s=s4(null);return l4(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),sf("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],d)=>{let p=(Array.isArray(m)?m[n]:m)||"transparent",u=ss[d],g=f(`colors.${c.replace(/\d+/,"")}`,null,"");return d4("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:a4("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{t(p),l("baseColors")},title:`${g}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${g} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${c}`,children:[sf("div",{className:"color-picker__button-outline"}),sf(Ma,{color:p,keyLabel:u})]},c)})})},my=c4;import{jsx as p4}from"react/jsx-runtime";var m4=({children:e})=>p4("div",{className:"color-picker__heading",children:e}),La=m4;import u4 from"clsx";import{useEffect as h4,useRef as g4}from"react";import{jsx as cs,jsxs as py}from"react/jsx-runtime";var uy=({hex:e,onChange:o,palette:t})=>{let r=In({color:e||"transparent",palette:t}),[n,i]=we(No),a=g4(null);if(h4(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,c=t[l];if(Array.isArray(c))return cs("div",{className:"color-picker-content--default shades",children:c.map((m,d)=>py("button",{ref:d===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:u4("color-picker__button color-picker__button--large has-outline",{active:d===s}),"aria-label":"Shade",title:`${l} - ${d+1}`,style:m?{"--swatch-color":m}:void 0,onClick:()=>{o(m),i("shades")},children:[cs("div",{className:"color-picker__button-outline"}),cs(Ma,{color:m,keyLabel:d+1,isShade:!0})]},d))})}return py("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[cs("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),cs("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:f("colorPicker.noShades")})]})};var cf=(e,o,t)=>{let r=Math.ceil(t/$n);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+$n;return n>=t?o%$n:n}case"ArrowUp":{let n=o-$n,i=n<0?$n*r+n:n;return i>=t?void 0:i}}},f4=({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(ss.includes(e.key)){let l=ss.indexOf(e.key),s=Object.keys(r)[l],c=r[s],m=Array.isArray(c)?c[a]:c;return t(m),i("baseColors"),!0}return!1},hy=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[T.CTRL_OR_CMD])return!1;if(e.key===T.ESCAPE)return m(e),!0;if(e.key===T.ALT)return c(!0),!0;if(e.key===T.I)return c(),!0;let d=In({color:r,palette:t});if(e.key===T.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((w,[y,v])=>(v&&w.push(y),w),[]),g=u.indexOf(o),b=e.shiftKey?-1:1,x=g+b>u.length-1?0:g+b<0?u.length-1:g+b,E=u[x];return E&&a(E),E==="custom"?n(i[0]):E==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(Mr.charcoal)),e.preventDefault(),e.stopPropagation(),!0}if(f4({e,colorObj:d,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&d){let{shade:p}=d,u=cf(e.key,p,$n);if(u!==void 0)return n(t[d.colorName][u]),!0}if(o==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(t),g=u.indexOf(p),b=cf(e.key,g,u.length);if(b!==void 0){let x=u[b],E=t[x];return n(Array.isArray(E)?E[s]:E),!0}}if(o==="custom"){let p=i.indexOf(r),u=cf(e.key,p,i.length);if(u!==void 0){let g=i[u];return n(g),!0}}return!1};import{jsx as Si,jsxs as em}from"react/jsx-runtime";var by=({color:e,onChange:o,label:t,type:r,elements:n,palette:i,updateData:a,children:l,onEyeDropperToggle:s,onEscape:c})=>{let[m]=gy.useState(()=>r==="canvasBackground"?[]:iy(n,r,i)),[d,p]=we(No),u=In({color:e,palette:i});fy(()=>{if(!d){let E=nf({color:e,palette:i}),w=E&&!m.includes(e);p(w?"hex":E?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,i,p,u,m]);let[g,b]=b4(u?.shade??(r==="elementBackground"?e0:Qb));fy(()=>{u?.shade!=null&&b(u.shade);let E=w=>{w.key===T.ALT&&s(!1)};return document.addEventListener("keyup",E,{capture:!0}),()=>{document.removeEventListener("keyup",E,{capture:!0})}},[u,s]);let x=gy.useRef(null);return Si("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:em("div",{ref:x,onKeyDown:E=>{hy({event:E,activeColorPickerSection:d,palette:i,color:e,onChange:o,onEyeDropperToggle:s,customColors:m,setActiveColorPickerSection:p,updateData:a,activeShade:g,onEscape:c})&&(E.preventDefault(),E.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!m.length&&em("div",{children:[Si(La,{children:f("colorPicker.mostUsedCustomColors")}),Si(dy,{colors:m,color:e,label:f("colorPicker.mostUsedCustomColors"),onChange:o})]}),em("div",{children:[Si(La,{children:f("colorPicker.colors")}),Si(my,{color:e,label:t,palette:i,onChange:o,activeShade:g})]}),em("div",{children:[Si(La,{children:f("colorPicker.shades")}),Si(uy,{hex:e,onChange:o,palette:i})]}),l]})})};import x4 from"clsx";import{jsx as df}from"react/jsx-runtime";var xy=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=uc),o==="elementBackground"&&(n=hc),o==="canvasBackground"&&(n=gc),r&&(n=r),n?df("div",{className:"color-picker__top-picks",children:n.map(i=>df("button",{className:x4("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!ka(i,pc)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:df("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as qo,jsxs as mf}from"react/jsx-runtime";var Ey=e=>{let o=new Option().style;return o.color=e,!!o.color},cy=e=>ti(e)?e:Ey(`#${e}`)?`#${e}`:Ey(e)?e:null,v4=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Mr,updateData:a})=>{let{container:l}=gt(),[,s]=we(No),[c,m]=we(Tn),d=mf("div",{children:[qo(La,{children:f("colorPicker.hexCode")}),qo(sy,{color:o,label:r,onChange:g=>{t(g)},colorPickerType:e})]}),p=y4(null),u=()=>{p.current?.querySelector(".color-picker-content")?.focus()};return qo(Jd,{container:l,style:{maxWidth:"13rem"},onFocusOutside:g=>{u(),g.preventDefault()},onPointerDownOutside:g=>{c&&g.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?qo(by,{palette:i,color:o,onChange:g=>{t(g)},onEyeDropperToggle:g=>{m(b=>g?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):g===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:g=>{c?m(null):a({openPopup:null})},label:r,type:e,elements:n,updateData:a,children:d}):d})},w4=({label:e,color:o,type:t})=>qo(tm.Trigger,{type:"button",className:E4("color-picker__button active-color properties-trigger",{"is-transparent":o==="transparent"||!o,"has-outline":!ka(o,pc)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),children:qo("div",{className:"color-picker__button-outline"})}),ds=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Mr,topPicks:a,updateData:l,appState:s})=>qo("div",{children:mf("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[qo(xy,{activeColor:o,onChange:t,type:e,topPicks:a}),qo(jd,{}),mf(tm.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[qo(w4,{color:o,label:r,type:e}),s.openPopup===e&&qo(v4,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as Ly from"@radix-ui/react-popover";import W4,{useCallback as K4,useMemo as Z4}from"react";import z4,{useMemo as Sn,useState as F4,useRef as H4,useEffect as U4,useCallback as G4}from"react";import T4 from"clsx";import C4 from"react";import{jsx as I4,jsxs as S4}from"react/jsx-runtime";var om=C4.forwardRef(({className:e,placeholder:o,onChange:t},r)=>S4("div",{className:T4("QuickSearch__wrapper",e),children:[so,I4("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import k4 from"clsx";import{Children as M4}from"react";import{jsx as yy}from"react/jsx-runtime";var rm=({className:e,placeholder:o,children:t})=>{let r=!M4.count(t);return yy("div",{className:k4("ScrollableList__wrapper",e),role:"menu",children:r?yy("div",{className:"empty",children:o}):t})};import{jsx as L4,jsxs as A4}from"react/jsx-runtime";var vy=({children:e,className:o="",style:t,title:r})=>A4("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&L4("p",{className:"dropdown-menu-group-title",children:r}),e]}),ms=vy;vy.displayName="DropdownMenuGroup";import{useEffect as O4,useRef as B4}from"react";import{Fragment as D4,jsx as pf,jsxs as P4}from"react/jsx-runtime";var _4=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=Ce();return P4(D4,{children:[o&&pf("div",{className:"dropdown-menu-item__icon",children:o}),pf("div",{style:e,className:"dropdown-menu-item__text",children:r}),t&&!n.editor.isMobile&&pf("div",{className:"dropdown-menu-item__shortcut",children:t})]})},nm=_4;import R4,{useContext as N4}from"react";var uf=R4.createContext({}),im=(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(),am=(e,o)=>{let t=N4(uf);return sn(e,r=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as hf}from"react/jsx-runtime";var gf=({icon:e,value:o,order:t,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:c,onClick:m,...d})=>{let p=am(m,c),u=B4(null);return O4(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),hf("button",{...d,ref:u,value:o,onClick:p,className:im(i,l,a),title:d.title??d["aria-label"],children:hf(nm,{textStyle:s,icon:e,shortcut:n,children:r})})};gf.displayName="DropdownMenuItem";var Aa={GREEN:"green",RED:"red",BLUE:"blue"},lm=({type:e=Aa.BLUE,children:o})=>{let{theme:t}=ur(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===ce.LIGHT?"1.5px solid white":"none"};switch(e){case Aa.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Aa.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case Aa.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return hf("div",{className:"DropDownMenuItemBadge",style:r,children:o})};lm.displayName="DropdownMenuItemBadge";gf.Badge=lm;var Wt=gf;var wy=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===T.F)return o.current?.focus(),!0;if(e.key===T.ESCAPE)return n(),!0;if(e.key===T.ENTER)return t?.value&&i(t.value),!0;if(e.key===T.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===T.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as ps,jsxs as Ty}from"react/jsx-runtime";var V4=e=>{switch(e){case zt.Excalifont:case zt.Virgil:return Ur;case zt.Nunito:case zt.Helvetica:return va;case zt["Lilita One"]:return hg;case zt["Comic Shanns"]:case zt.Cascadia:return ql;default:return va}},Cy=z4.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=gt(),{fonts:s}=st(),{showDeprecatedFonts:c}=hr(),[m,d]=F4(""),p=H4(null),u=Sn(()=>Array.from(gn.registered.entries()).filter(([L,{metadata:N}])=>!N.serverSide&&!N.fallback).map(([L,{metadata:N,fontFaces:P}])=>{let z={value:L,icon:V4(L),text:P[0]?.fontFace?.family??"Unknown"};return N.deprecated&&Object.assign(z,{deprecated:N.deprecated,badge:{type:Aa.RED,placeholder:f("fontList.badge.old")}}),z}).sort((L,N)=>L.text.toLowerCase()>N.text.toLowerCase()?1:-1),[]),g=Sn(()=>new Set(s.getSceneFamilies()),[e]),b=Sn(()=>u.filter(L=>g.has(L.value)),[u,g]),x=Sn(()=>u.filter(L=>!g.has(L.value)&&(c||!L.deprecated)),[u,g,c]),E=Sn(()=>v0([...b,...x].filter(L=>L.text?.toLowerCase().includes(m))),[b,x,m]),w=Sn(()=>{let L;return o?L=E.find(N=>N.value===o):e&&(L=E.find(N=>N.value===e)),!L&&m&&(E[0]?.value?r(E[0].value):n()),L},[o,e,m,E,r,n]),y=G4(L=>{wy({event:L,inputRef:p,hoveredFont:w,filteredFonts:E,onSelect:t,onHover:r,onClose:a})&&(L.preventDefault(),L.stopPropagation())},[w,E,t,r,a]);U4(()=>(i(),()=>{a()}),[]);let v=Sn(()=>E.filter(L=>g.has(L.value)),[E,g]),C=Sn(()=>E.filter(L=>!g.has(L.value)),[E,g]),S=(L,N)=>Ty(Wt,{icon:L.icon,value:L.value,order:N,textStyle:{fontFamily:Jn({fontFamily:L.value})},hovered:L.value===w?.value,selected:L.value===e,tabIndex:L.value===e?0:-1,onClick:P=>{t(Number(P.currentTarget.value))},onMouseMove:()=>{w?.value!==L.value&&r(L.value)},children:[L.text,L.badge&&ps(lm,{type:L.badge.type,children:L.badge.placeholder})]},L.value),_=[];return v.length&&_.push(ps(ms,{title:f("fontList.sceneFonts"),children:v.map(S)},"group_1")),C.length&&_.push(ps(ms,{title:f("fontList.availableFonts"),children:C.map((L,N)=>S(L,N+v.length))},"group_2")),Ty(Jd,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:y,children:[ps(om,{ref:p,placeholder:f("quickSearch.placeholder"),onChange:Qn(d,20)}),ps(rm,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Iy from"@radix-ui/react-popover";import{useMemo as Y4}from"react";import{jsx as ff}from"react/jsx-runtime";var Sy=({selectedFontFamily:e})=>{let o=Y4(()=>!!(e&&!ky(e)),[e]);return ff(Iy.Trigger,{asChild:!0,children:ff("div",{children:ff($d,{standalone:!0,icon:Wl,title:f("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as sm,jsxs as My}from"react/jsx-runtime";var Ay=[{value:zt.Excalifont,icon:Ur,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:zt.Nunito,icon:va,text:f("labels.normal"),testId:"font-family-normal"},{value:zt["Comic Shanns"],icon:ql,text:f("labels.code"),testId:"font-family-code"}],X4=new Set(Ay.map(e=>e.value)),ky=e=>e?X4.has(e):!1,_y=W4.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=Z4(()=>Ay,[]),s=K4(c=>{c&&r(c)},[r]);return My("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[sm(Po,{type:"button",options:l,value:o,onClick:s}),sm(jd,{}),My(Ly.Root,{open:e,onOpenChange:a,children:[sm(Sy,{selectedFontFamily:o}),e&&sm(Cy,{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 _a from"@radix-ui/react-popover";import J4 from"clsx";import cm,{useEffect as Q4}from"react";import{jsx as $4}from"react/jsx-runtime";var kn=({icon:e})=>$4("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});import{Fragment as q4,jsx as Dy,jsxs as Py}from"react/jsx-runtime";var j4=({label:e,open:o,openTrigger:t,children:r,className:n})=>Py(q4,{children:[Py("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,Dy(kn,{icon:o?jg:ns})]}),o&&Dy("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),us=j4;import{jsx as ki,jsxs as bf}from"react/jsx-runtime";var eC=De(!1);function tC({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=Ce(),l=u=>{let g=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&g)r(g.value),u.preventDefault();else if(u.key===T.TAB){let b=e.findIndex(E=>E.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;r(e[x].value)}else if(jn(u.key)){let b=Hr().rtl,x=e.findIndex(E=>E.value===o);if(x!==-1){let E=e.length,w=x;switch(u.key){case(b?T.ARROW_LEFT:T.ARROW_RIGHT):w=(x+1)%E;break;case(b?T.ARROW_RIGHT:T.ARROW_LEFT):w=(E+x-1)%E;break;case T.ARROW_DOWN:{w=(x+(i??1))%E;break}case T.ARROW_UP:{w=(E+x-(i??1))%E;break}}r(e[w].value)}u.preventDefault()}else(u.key===T.ESCAPE||u.key===T.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,c]=we(eC),m=cm.useMemo(()=>e.slice(0,i),[e,i]),d=cm.useMemo(()=>e.slice(i),[e,i]);Q4(()=>{m.some(u=>u.value===o)||c(!0)},[o,m,c]);let p=u=>ki("div",{className:"picker-content",children:u.map((g,b)=>bf("button",{type:"button",className:J4("picker-option",{active:o===g.value}),onClick:x=>{r(g.value)},title:`${g.text} ${g.keyBinding&&`\u2014 ${g.keyBinding.toUpperCase()}`}`,"aria-label":g.text||"none","aria-keyshortcuts":g.keyBinding||void 0,ref:x=>{o===g.value&&setTimeout(()=>{x?.focus()},0)},children:[g.icon,g.keyBinding&&ki("span",{className:"picker-keybinding",children:g.keyBinding})]},g.text))});return ki(_a.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:bf("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(m),d.length>0&&ki(us,{label:f("labels.more_options"),open:s,openTrigger:()=>{c(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function xf({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=cm.useState(!1),s=cm.useRef(null);return ki("div",{children:bf(_a.Root,{open:a,onOpenChange:c=>l(c),children:[ki(_a.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(c=>c.value===e)?.icon}),a&&ki(tC,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import Ry,{useEffect as oC}from"react";import{jsx as Ef,jsxs as Ny}from"react/jsx-runtime";var Oy=({updateData:e,appState:o,elements:t,testId:r})=>{let n=Ry.useRef(null),i=Ry.useRef(null),a=Rt(t,o,l=>l.opacity,!0,o.currentItemOpacity);return oC(()=>{if(n.current&&i.current){let l=n.current,s=i.current,c=l.offsetWidth,m=15,d=a/100*(c-m)+m/2;s.style.left=`${d}px`,l.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${a}%, var(--button-bg) ${a}%, var(--button-bg) 100%)`}},[a]),Ny("label",{className:"control-label",children:[f("labels.opacity"),Ny("div",{className:"range-wrapper",children:[Ef("input",{ref:n,type:"range",min:"0",max:"100",step:"10",onChange:l=>{e(+l.target.value)},value:a,className:"range-input","data-testid":r}),Ef("div",{className:"value-bubble",ref:i,children:a!==0?a:null}),Ef("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as $y,jsx as Ee,jsxs as yo}from"react/jsx-runtime";var zy=.1,Kt=(e,o,t,r=!1)=>{let n=te(J(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},Rt=function(e,o,t,r,n){let i=o.editingTextElement,a=xe(e),l=null;return i&&(l=t(i)),l||(ze(a,o)?l=Ex(r===!0?a:a.filter(c=>r(c)),o,t)??(typeof n=="function"?n(!0):n):l=typeof n=="function"?n(!1):n),l},iC=(e,o)=>_e(o)||!o.autoResize?o:B(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},!1),wf=(e,o,t,r,n)=>{let i=new Set,a=Kt(e,o,s=>{if(Z(s)){let c=r(s);i.add(c);let m=re(s,{fontSize:c});return et(m,t.scene.getContainerElement(s),t.scene.getNonDeletedElementsMap()),m=iC(s,m),m}return s},!0),l=te(a);return J(e,o,{includeBoundTextElement:!0}).forEach(s=>{Z(s)&&at(s,l)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:A.IMMEDIATELY}},Fy=F({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:Kt(e,o,r=>Rl(r.type)?re(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>yo($y,{children:[Ee("h3",{"aria-hidden":"true",children:f("labels.stroke")}),Ee(ds,{topPicks:uc,palette:t0,type:"elementStroke",label:f("labels.stroke"),color:Rt(e,o,n=>n.strokeColor,!0,o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),Hy=F({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemBackgroundColor&&{elements:Kt(e,o,r=>re(r,{backgroundColor:t.currentItemBackgroundColor}))},appState:{...o,...t},captureUpdate:t.currentItemBackgroundColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>yo($y,{children:[Ee("h3",{"aria-hidden":"true",children:f("labels.background")}),Ee(ds,{topPicks:hc,palette:o0,type:"elementBackground",label:f("labels.background"),color:Rt(e,o,n=>n.backgroundColor,!0,o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),Uy=F({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(ye("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:Kt(e,o,n=>re(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=J(e,o),n=r.length>0&&r.every(i=>i.fillStyle==="zigzag");return yo("fieldset",{children:[Ee("legend",{children:f("labels.fill")}),Ee(Po,{type:"button",options:[{value:"hachure",text:`${n?f("labels.zigzag"):f("labels.hachure")} (${R("Alt-Click")})`,icon:n?Fh:Hh,active:n?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:Uh,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:Gh,testId:"fill-solid"}],value:Rt(e,o,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:o.currentItemFillStyle),onClick:(i,a)=>{let l=a.altKey&&i==="hachure"&&r.every(s=>s.fillStyle==="hachure")?"zigzag":i;t(l)}})]})}}),Gy=F({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:Kt(e,o,r=>re(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>yo("fieldset",{children:[Ee("legend",{children:f("labels.strokeWidth")}),Ee(Po,{group:"stroke-width",options:[{value:dc.thin,text:f("labels.thin"),icon:Bd,testId:"strokeWidth-thin"},{value:dc.bold,text:f("labels.bold"),icon:Vh,testId:"strokeWidth-bold"},{value:dc.extraBold,text:f("labels.extraBold"),icon:Yh,testId:"strokeWidth-extraBold"}],value:Rt(e,o,r=>r.strokeWidth,r=>r.hasOwnProperty("strokeWidth"),r=>r?null:o.currentItemStrokeWidth),onChange:r=>t(r)})]})}),Vy=F({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:Kt(e,o,r=>re(r,{seed:_r(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>yo("fieldset",{children:[Ee("legend",{children:f("labels.sloppiness")}),Ee(Po,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:Zh},{value:1,text:f("labels.artist"),icon:Xh},{value:2,text:f("labels.cartoonist"),icon:$h}],value:Rt(e,o,r=>r.roughness,r=>r.hasOwnProperty("roughness"),r=>r?null:o.currentItemRoughness),onChange:r=>t(r)})]})}),KB=F({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:Kt(e,o,r=>re(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>yo("fieldset",{children:[Ee("legend",{children:f("labels.strokeStyle")}),Ee(Po,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Bd},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:Wh},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:Kh}],value:Rt(e,o,r=>r.strokeStyle,r=>r.hasOwnProperty("strokeStyle"),r=>r?null:o.currentItemStrokeStyle),onChange:r=>t(r)})]})}),Yy=F({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:Kt(e,o,r=>re(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>Ee(Oy,{updateData:t,elements:e,appState:o,testId:"opacity"})}),Wy=F({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>wf(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yo("fieldset",{children:[Ee("legend",{children:f("labels.fontSize")}),Ee(Po,{group:"font-size",options:[{value:16,text:f("labels.small"),icon:dg,testId:"fontSize-small"},{value:20,text:f("labels.medium"),icon:mg,testId:"fontSize-medium"},{value:28,text:f("labels.large"),icon:pg,testId:"fontSize-large"},{value:36,text:f("labels.veryLarge"),icon:ug,testId:"fontSize-veryLarge"}],value:Rt(e,o,n=>{if(Z(n))return n.fontSize;let i=be(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>Z(n)||be(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||Sr),onChange:n=>t(n)})]})}),Tf=F({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:vn,trackEvent:!1,perform:(e,o,t,r)=>wf(e,o,r,n=>Math.round(1/(1+zy)*n.fontSize)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_LEFT||e.key===T.COMMA)}),Cf=F({name:"increaseFontSize",label:"labels.increaseFontSize",icon:vn,trackEvent:!1,perform:(e,o,t,r)=>wf(e,o,r,n=>Math.round(n.fontSize*(1+zy))),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_RIGHT||e.key===T.PERIOD)}),Ky=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:Kt(e,o,b=>{let x=n?.get(b.id);return x?re(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:A.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=A.EVENTUALLY,d,p=!1;if(s)d=s,m=A.IMMEDIATELY;else if(c){d=c,m=A.EVENTUALLY;let g=J(e,o,{includeBoundTextElement:!0}).filter(b=>Z(b));if(g.length>200)p=!0;else{let b=0,x=0;for(;b<g.length&&x<5e3;){let E=g[b];x+=E?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(d&&!p){let g=new Map,b=new Set,x=!1,E=Array.from(gn.loadedFontsCache.values()),w=Object.entries(zt).find(([C,S])=>S===d)?.[0];c&&w&&E.some(C=>C.startsWith(w))&&(x=!0),Object.assign(u,{elements:Kt(e,o,C=>{if(Z(C)&&(C.fontFamily!==d||s)){let S=re(C,{fontFamily:d,lineHeight:Lr(d)}),_=n?.get(C.containerId||"")||{},L=r.scene.getContainerElement(C);return a&&L&&_&&B(L,{..._},!1),x||(b=new Set([...b,...Array.from(S.originalText)])),g.set(S,L),S}return C},!0)});let y=`10px ${Jn({fontFamily:d})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,S]of g)et(C,S,r.scene.getNonDeletedElementsMap(),!1);else window.document.fonts.load(y,v).then(C=>{for(let[S,_]of g){let L=r.scene.getElement(S.id),N=_?r.scene.getElement(_.id):null;L&&et(L,N,r.scene.getNonDeletedElementsMap(),!1)}r.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=vf(new Map),i=vf(null),[a,l]=nC({}),s=vf(!0),c=rC(()=>{let m=(d,p)=>Rt(d,o,u=>{if(Z(u))return u.fontFamily;let g=be(u,p);return g?g.fontFamily:null},u=>Z(u)||be(u,p)!==null,u=>u?null:o.currentItemFontFamily||en);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?m(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&o.openPopup!=="fontFamily"?m(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t.scene]);return yf(()=>{i.current=c},[c]),yf(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),yf(()=>(s.current=!1,()=>{s.current=!0}),[]),yo("fieldset",{children:[Ee("legend",{children:f("labels.fontFamily")}),Ee(_y,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:c,hoveredFontFamily:o.currentHoveredFontFamily,onSelect:m=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:m}),n.current.clear()},onHover:m=>{l({currentHoveredFontFamily:m,cachedElements:new Map(n.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0})},onPopupChange:m=>{if(m){n.current.clear();let{editingTextElement:d}=o;if(d?.type==="text"){let p=t.scene.getElement(d.id);n.current.set(d.id,re(p||d,{},!0))}else{let p=J(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,re(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()}}})]})}}),Zy=F({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:Kt(e,o,n=>{if(Z(n)){let i=re(n,{textAlign:t});return et(i,r.scene.getContainerElement(n),r.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return yo("fieldset",{children:[Ee("legend",{children:f("labels.textAlign")}),Ee(Po,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:gg,testId:"align-left"},{value:"center",text:f("labels.center"),icon:fg,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:bg,testId:"align-right"}],value:Rt(e,o,i=>{if(Z(i))return i.textAlign;let a=be(i,n);return a?a.textAlign:null},i=>Z(i)||be(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})]})}}),Xy=F({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Kt(e,o,n=>{if(Z(n)){let i=re(n,{verticalAlign:t});return et(i,r.scene.getContainerElement(n),r.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...o},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ee("fieldset",{children:Ee(Po,{group:"text-align",options:[{value:to.TOP,text:f("labels.alignTop"),icon:Ee(xg,{theme:o.theme}),testId:"align-top"},{value:to.MIDDLE,text:f("labels.centerVertically"),icon:Ee(yg,{theme:o.theme}),testId:"align-middle"},{value:to.BOTTOM,text:f("labels.alignBottom"),icon:Ee(Eg,{theme:o.theme}),testId:"align-bottom"}],value:Rt(e,o,n=>{if(Z(n)&&n.containerId)return n.verticalAlign;let i=be(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>Z(n)||be(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:to.MIDDLE),onChange:n=>t(n)})})}),ZB=F({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:Kt(e,o,r=>oe(r)?r:re(r,{roundness:t==="round"?{type:$i(r.type)?oo.ADAPTIVE_RADIUS:oo.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=Uc(xe(e),o).some(i=>i.roundness?.type===oo.LEGACY);return yo("fieldset",{children:[Ee("legend",{children:f("labels.edges")}),Ee(Po,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:jh},{value:"round",text:f("labels.round"),icon:qh}],value:Rt(e,o,i=>n?null:i.roundness?"round":"sharp",i=>!ke(i)&&i.hasOwnProperty("roundness"),i=>i?null:o.currentItemRoundness),onChange:i=>t(i)})]})}}),By=e=>[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Jh},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:Ee(Qh,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:Ee(rg,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:Ee(ng,{flip:e}),keyBinding:"r"},{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:Ee(eg,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Ee(tg,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:Ee(ig,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:Ee(ag,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:Ee(og,{flip:e})},{value:"crowfoot_one",text:f("labels.arrowhead_crowfoot_one"),icon:Ee(sg,{flip:e}),keyBinding:"c"},{value:"crowfoot_many",text:f("labels.arrowhead_crowfoot_many"),icon:Ee(lg,{flip:e}),keyBinding:"x"},{value:"crowfoot_one_or_many",text:f("labels.arrowhead_crowfoot_one_or_many"),icon:Ee(cg,{flip:e}),keyBinding:"v"}],XB=F({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:Kt(e,o,r=>{if(le(r)){let{position:n,type:i}=t;if(n==="start")return re(r,{startArrowhead:i});if(n==="end")return re(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=Hr().rtl;return yo("fieldset",{children:[Ee("legend",{children:f("labels.arrowheads")}),yo("div",{className:"iconSelectList buttonList",children:[Ee(xf,{label:"arrowhead_start",options:By(!r),value:Rt(e,o,n=>le(n)&&ia(n.type)?n.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:n=>t({position:"start",type:n}),numberOfOptionsToAlwaysShow:4}),Ee(xf,{label:"arrowhead_end",group:"arrowheads",options:By(!!r),value:Rt(e,o,n=>le(n)&&ia(n.type)?n.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:n=>t({position:"end",type:n}),numberOfOptionsToAlwaysShow:4})]})]})}}),$B=F({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=Kt(e,o,l=>{if(!ke(l))return l;let s=re(l,{roundness:t===Et.round?{type:oo.PROPORTIONAL_RADIUS}:null,elbowed:t===Et.elbow,points:t===Et.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(oe(s)){s.fixedSegments=null;let c=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let m=j.getPointAtIndexGlobalCoordinates(s,0,c),d=j.getPointAtIndexGlobalCoordinates(s,-1,c),p=!s.startBinding&&mn(an(m),e,c,o.zoom,!1,!0),u=!s.endBinding&&mn(an(d),e,c,o.zoom,!1,!0),g=p||s.startBinding&&c.get(s.startBinding.elementId),b=u||s.endBinding&&c.get(s.endBinding.elementId),x=p?vu(s,p,"start"):m,E=u?vu(s,u,"end"):d;p&&Xo(s,p,"start",c),u&&Xo(s,u,"end",c);let w=g&&s.startBinding?{...s.startBinding,...wu(s,g,"start",c)}:null,y=b&&s.endBinding?{...s.endBinding,...wu(s,b,"end",c)}:null;s={...s,startBinding:w,endBinding:y,...Rc(s,c,{points:[x,E].map(v=>M(v[0]-s.x,v[1]-s.y)),startBinding:w,endBinding:y,fixedSegments:null})},j.updateEditorMidPointsCache(s,c,r.state)}else{let c=r.scene.getNonDeletedElementsMap();if(s.startBinding){let m=c.get(s.startBinding.elementId);m&&Xo(s,m,"start",c)}if(s.endBinding){let m=c.get(s.endBinding.elementId);m&&Xo(s,m,"end",c)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new j(l))}return{elements:n,appState:i,captureUpdate:A.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t})=>yo("fieldset",{children:[Ee("legend",{children:f("labels.arrowtypes")}),Ee(Po,{group:"arrowtypes",options:[{value:Et.sharp,text:f("labels.arrowtype_sharp"),icon:Zg,testId:"sharp-arrow"},{value:Et.round,text:f("labels.arrowtype_round"),icon:$g,testId:"round-arrow"},{value:Et.elbow,text:f("labels.arrowtype_elbowed"),icon:Xg,testId:"elbow-arrow"}],value:Rt(e,o,r=>ke(r)?r.elbowed?Et.elbow:r.roundness?Et.round:Et.sharp:null,r=>ke(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})]})});import{useEffect as aC}from"react";import{jsx as sC}from"react/jsx-runtime";var Da=()=>{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},If=(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`})},lC=(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();If(o,n)},vo=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(aC(()=>()=>Da().classList.remove("excalidraw-tooltip--visible"),[]),n?null:sC("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>lC(i.currentTarget,Da(),o,t),onPointerLeave:()=>Da().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import dm from"open-color";var qy='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',cC='<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"/>',Jy='<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"/>',dC=`data:${ge.svg},${encodeURIComponent(`${qy}${Jy}</svg>`)}`,mC=`data:${ge.svg},${encodeURIComponent(`${qy}${cC}${Jy}</svg>`)}`,wo=e=>{e&&(e.style.cursor="")},Le=(e,o)=>{e&&(e.style.cursor=o)},gr,jy,Sf=(e,o)=>{let r=()=>{let n=o===ce.DARK;gr=document.createElement("canvas"),gr.theme=o,gr.height=20,gr.width=20;let i=gr.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(gr.width/2,gr.height/2,5,0,2*Math.PI),i.fillStyle=n?dm.black:dm.white,i.fill(),i.strokeStyle=n?dm.white:dm.black,i.stroke(),jy=gr.toDataURL(ge.svg)};(!gr||gr.theme!==o)&&r(),Le(e,`url(${jy}) ${20/2} ${20/2}, auto`)},To=(e,o)=>{if(e)if(o.activeTool.type==="selection")wo(e);else if(jo(o))e.style.cursor=Se.GRAB;else if(ao(o))Sf(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===ce.LIGHT?dC:mC;e.style.cursor=`url(${t}), auto`}else if(!["image","custom"].includes(o.activeTool.type))e.style.cursor=Se.CROSSHAIR;else if(o.activeTool.type==="custom"&&o.activeTool.customType==="comment"){let t=`data:${ge.svg},${encodeURIComponent(`
|
|
1
|
+
import{$ as pE,A as Tc,B as zu,C as Gu,D as tE,E as oE,F as nE,G as Ic,H as xl,I as Cc,J as Sc,K as rE,L as iE,M as El,N as aE,O as lE,P as sE,Q as Uu,R as j4,S as yl,T as wl,U as jn,V as Fi,W as cE,Y as dE,_ as mE,a as qx,aa as kc,b as qr,ba as uE,c as Jo,ca as Mc,d as Jx,da as Yu,e as Le,ea as Lc,f as Qx,fa as gE,g as J,ga as Wu,h as wc,ha as wn,i as $n,ia as hE,j as Nu,ja as Vu,k as Bu,ka as fE,l as Ni,la as bE,m as Ou,ma as Ac,n as Bi,na as Ku,o as eE,oa as xE,p as Fu,pa as EE,q as Zn,qa as yE,r as Jr,ra as wE,s as $4,t as Z4,u as Ht,v as Do,w as Oi,x as vc,y as Hu,z as bl}from"./chunk-DHNAMUY4.js";import{a as I}from"./chunk-SS5RKRMN.js";import{J as Ru}from"./chunk-76R4CNZA.js";import{c as jx}from"./chunk-Z3N5DIM6.js";import{b as Zx,c as yc,d as S}from"./chunk-SRAX5OIU.js";import DX,{useEffect as RX}from"react";import{DEFAULT_UI_OPTIONS as V4,isShallowEqual as NX}from"@excalidraw/common";import v6 from"clsx";import oV from"lodash.throttle";import yn,{useContext as Kr}from"react";import{flushSync as Vn}from"react-dom";import nV from"roughjs/bin/rough";import{nanoid as rV}from"nanoid";import{clamp as T6,pointFrom as he,pointDistance as dl,vector as I6,pointRotateRads as ex,vectorScale as iV,vectorFromPoint as tx,vectorSubtract as C6,vectorDot as S6,vectorNormalize as k6}from"@excalidraw/math";import{COLOR_PALETTE as aV,CODES as M6,shouldResizeFromCenter as L6,shouldMaintainAspectRatio as nc,shouldRotateWithDiscreteAngle as ox,isArrowKey as wu,KEYS as W,APP_NAME as lV,CURSOR_TYPE as Ye,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as sV,DEFAULT_VERTICAL_ALIGN as A6,DRAGGING_THRESHOLD as P6,ELEMENT_SHIFT_TRANSLATE_AMOUNT as cV,ELEMENT_TRANSLATE_AMOUNT as _6,EVENT as oe,FRAME_STYLE as Gr,IMAGE_MIME_TYPES as dV,IMAGE_RENDER_TIMEOUT as mV,isBrave as pV,LINE_CONFIRM_THRESHOLD as nx,MAX_ALLOWED_FILE_BYTES as D6,MIME_TYPES as Ur,MQ_MAX_HEIGHT_LANDSCAPE as uV,MQ_MAX_WIDTH_LANDSCAPE as gV,MQ_MAX_WIDTH_PORTRAIT as hV,MQ_RIGHT_SIDEBAR_MIN_WIDTH as fV,POINTER_BUTTON as Ai,ROUNDNESS as vu,SCROLL_TIMEOUT as bV,TAP_TWICE_TIMEOUT as xV,TEXT_TO_CENTER_SNAP_THRESHOLD as EV,THEME as Tu,THEME_FILTER as yV,TOUCH_CTX_MENU_TIMEOUT as wV,VERTICAL_ALIGN as vV,YOUTUBE_STATES as Iu,ZOOM_STEP as TV,POINTER_EVENTS as ml,TOOL_TYPE as En,isIOS as IV,supportsResizeObserver as R6,DEFAULT_COLLISION_THRESHOLD as N6,DEFAULT_TEXT_ALIGN as CV,ARROW_TYPE as Yr,DEFAULT_REDUCED_GLOBAL_ALPHA as SV,isSafari as kV,isLocalLink as MV,normalizeLink as rx,toValidURL as LV,getGridPoint as Tt,getLineHeight as B6,debounce as O6,distance as pl,getFontString as ix,getNearestScrollableContainer as AV,isInputLike as F6,isToolIcon as PV,isWritableElement as rc,sceneCoordsToViewportCoords as Cu,tupleToCoors as ax,viewportCoordsToSceneCoords as qe,wrapEvent as _V,updateObject as lx,updateActiveTool as Kn,getShortcutKey as DV,isTransparent as RV,easeToValuesRAF as NV,muteFSAbortError as BV,isTestEnv as Mx,isDevEnv as y4,easeOut as OV,updateStable as ic,addEventListener as Ve,normalizeEOL as FV,getDateTime as H6,isShallowEqual as HV,arrayToMap as z6,randomInteger as zV,CLASSES as GV,Emitter as Pi,isProdEnv as UV}from"@excalidraw/common";import{getObservedAppState as YV,getCommonBounds as ul,maybeSuggestBindingsForLinearElementAtCoords as G6,getElementAbsoluteCoords as U6,bindOrUnbindLinearElements as Y6,fixBindingsAfterDeletion as WV,getHoveredElementForBinding as sx,isBindingEnabled as cx,shouldEnableBindingForPointerEvent as VV,updateBoundElements as dx,getSuggestedBindingsForArrows as mx,LinearElementEditor as De,newElementWith as _i,newFrameElement as KV,newFreeDrawElement as XV,newEmbeddableElement as W6,newMagicFrameElement as V6,newIframeElement as $V,newArrowElement as ZV,newElement as jV,newImageElement as qV,newLinearElement as JV,newTextElement as K6,refreshTextDimensions as QV,deepCopyElement as X6,duplicateElements as $6,hasBoundTextElement as Z6,isArrowElement as px,isBindingElement as ux,isBindingElementType as eK,isBoundToContainer as gx,isFrameLikeElement as Lo,isImageElement as Di,isEmbeddableElement as Wr,isInitializedImageElement as ac,isLinearElement as Ao,isLinearElementType as tK,isUsingAdaptiveRadius as oK,isIframeElement as gl,isIframeLikeElement as lc,isMagicFrameElement as hx,isTextBindableContainer as j6,isElbowArrow as at,isFlowchartNodeElement as nK,isBindableElement as rK,isTextElement as jo,getLockedLinearCursorAlignSize as q6,getNormalizedDimensions as iK,isElementCompletelyInViewport as fx,isElementInViewport as J6,isInvisiblySmallElement as Q6,getCornerRadius as aK,isPathALoop as e4,createSrcDoc as t4,embeddableURLValidator as bx,maybeParseEmbedSrc as lK,getEmbedLink as Su,getInitializedImageElements as sK,normalizeSVG as o4,updateImageCache as cK,getBoundTextElement as xx,getContainerCenter as Ex,getContainerElement as n4,isValidTextContainer as dK,redrawTextBoundingBox as mK,shouldShowBoundingBox as pK,getFrameChildren as r4,isCursorInFrame as i4,addElementsToFrame as yx,replaceAllElementsInFrame as uK,removeElementsFromFrame as gK,getElementsInResizingFrame as wx,getElementsInNewFrame as hK,getContainingFrame as vx,elementOverlapsWithFrame as fK,updateFrameMembershipOfSelectedElements as a4,isElementInFrame as l4,getFrameLikeTitle as bK,getElementsOverlappingFrame as xK,filterElementsEligibleAsFrameChildren as EK,hitElementBoundText as yK,hitElementBoundingBoxOnly as wK,hitElementItself as sc,getVisibleSceneBounds as vK,FlowChartCreator as TK,FlowChartNavigator as IK,getLinkDirectionFromKey as s4,cropElement as CK,wrapText as SK,isElementLink as Tx,parseElementLinkFromURL as kK,isMeasureTextSupported as MK,normalizeText as LK,measureText as c4,getLineHeightInPx as AK,getApproxMinLineWidth as PK,getApproxMinLineHeight as _K,getMinTextElementWidth as DK,ShapeCache as cc,clearRenderCache as RK,getRenderOpacity as NK}from"@excalidraw/element";import{editGroupForSelectedElement as BK,getElementsInGroup as dc,getSelectedGroupIdForElement as OK,getSelectedGroupIds as FK,isElementInGroup as d4,isSelectedViaGroup as HK,selectGroupsForSelectedElements as qo,syncInvalidIndices as w4,syncMovedIndices as m4,excludeElementsInFramesFromSelection as zK,getSelectionStateForElements as GK,makeNextSelectedElementIds as Ae,getResizeOffsetXY as UK,getResizeArrowDirection as YK,transformElements as WK,getCursorForResizingElement as p4,getElementWithTransformHandleType as u4,getTransformHandleTypeFromCoords as g4,dragNewElement as h4,dragSelectedElements as VK,getDragOffsetXY as KK,isNonDeletedElement as f4,Scene as b4,Store as XK,CaptureUpdateAction as Lt,hitElementBoundingBox as $K,isLineElement as Ix,isSimpleArrow as ZK}from"@excalidraw/element";var W3={};yc(W3,{actionAddToLibrary:()=>lm,actionAlignBottom:()=>Xw,actionAlignHorizontallyCentered:()=>qw,actionAlignLeft:()=>$w,actionAlignRight:()=>Zw,actionAlignTop:()=>Kw,actionAlignVerticallyCentered:()=>jw,actionBindText:()=>um,actionBringForward:()=>md,actionBringToFront:()=>ud,actionChangeBackgroundColor:()=>Py,actionChangeExportBackground:()=>$d,actionChangeFillStyle:()=>_y,actionChangeFontFamily:()=>Oy,actionChangeFontSize:()=>By,actionChangeOpacity:()=>Ny,actionChangeProjectName:()=>Xd,actionChangeSloppiness:()=>Ry,actionChangeStrokeColor:()=>Ay,actionChangeStrokeWidth:()=>Dy,actionChangeTextAlign:()=>Fy,actionChangeVerticalAlign:()=>Hy,actionChangeViewBackgroundColor:()=>$y,actionClearCanvas:()=>rn,actionCopy:()=>hi,actionCopyAsPng:()=>gs,actionCopyAsSvg:()=>us,actionCopyStyles:()=>qd,actionCut:()=>ps,actionDeleteSelected:()=>Zi,actionDuplicateSelection:()=>fd,actionFinalize:()=>Vt,actionFlipHorizontal:()=>cm,actionFlipVertical:()=>dm,actionGoToCollaborator:()=>Vw,actionGroup:()=>om,actionLink:()=>va,actionLoadScene:()=>ui,actionPasteStyles:()=>Jd,actionResetZoom:()=>ns,actionSaveFileToDisk:()=>ha,actionSaveToActiveFile:()=>ur,actionSelectAll:()=>hd,actionSendBackward:()=>dd,actionSendToBack:()=>pd,actionSetEmbeddableAsActiveTool:()=>Qy,actionShortcuts:()=>gr,actionToggleCanvasMenu:()=>_w,actionToggleCropEditor:()=>up,actionToggleEditMenu:()=>Dw,actionToggleElementLock:()=>Ta,actionToggleGridMode:()=>fs,actionToggleLinearEditor:()=>pp,actionToggleObjectsSnapMode:()=>mm,actionToggleSearchMenu:()=>Ba,actionToggleStats:()=>bi,actionToggleTheme:()=>dr,actionToggleZenMode:()=>fi,actionUnbindText:()=>pm,actionUngroup:()=>nm,actionZoomIn:()=>ts,actionZoomOut:()=>os,actionZoomToFit:()=>jy,copyText:()=>hs,distributeHorizontally:()=>i2,distributeVertically:()=>a2});import{KEYS as Dh,updateActiveTool as _k}from"@excalidraw/common";import{getNonDeletedElements as Rh}from"@excalidraw/element";import{fixBindingsAfterDeletion as Dk}from"@excalidraw/element";import{LinearElementEditor as _E}from"@excalidraw/element";import{newElementWith as ld}from"@excalidraw/element";import{getContainerElement as DE}from"@excalidraw/element";import{isBoundToContainer as id,isElbowArrow as Rk,isFrameLikeElement as Nk}from"@excalidraw/element";import{getFrameChildren as Bk}from"@excalidraw/element";import{getElementsInGroup as Nh,selectGroupsForSelectedElements as Ok}from"@excalidraw/element";import{CaptureUpdateAction as ad}from"@excalidraw/element";import{isDevEnv as ek}from"@excalidraw/common";import{atom as be,createStore as q4}from"jotai";import{createIsolation as J4}from"jotai-scope";var vE=J4();var{useAtom:ce,useSetAtom:qn,useAtomValue:Pc,useStore:GX}=vE,TE=vE.Provider,et=q4();var Q4=Zx({"./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-CQGKCVPT.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-LNUGB5OW.js"),"./locales/zh-HK.json":()=>import("./locales/zh-HK-E62DVLB3.js"),"./locales/zh-TW.json":()=>import("./locales/zh-TW-RAJ6MFWO.js")});var tk=85,Qo={code:"en",label:"English"},zi=[Qo,...[{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=>jx[e.code]>=tk).sort((e,t)=>e.label>t.label?1:-1)],Dc="__test__";ek()&&zi.unshift({code:Dc,label:"test language"},{code:`${Dc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Hi=Qo,_c={},Rc=async e=>{if(Hi=e,document.documentElement.dir=Hi.rtl?"rtl":"ltr",document.documentElement.lang=Hi.code,e.code.startsWith(Dc))_c={};else try{_c=await Q4(`./locales/${Hi.code}.json`)}catch(t){console.error(`Failed to load language ${e.code}:`,t.message),_c=Ru}et.set(CE,e.code)},vn=()=>Hi,IE=(e,t)=>{for(let o=0;o<t.length;++o){let n=t[o];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},f=(e,t,o)=>{if(Hi.code.startsWith(Dc))return`\u202A[[${t?`${e}(${JSON.stringify(t).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=IE(_c,n)||IE(Ru,n)||o;if(r===void 0){let i=`Can't find translation for ${e}`;if(I.PROD)return console.warn(i),"";throw new Error(i)}if(t)for(let i in t)r=r.replace(`{{${i}}}`,String(t[i]));return r},CE=be(Qo.code),Je=()=>{let e=Pc(CE);return{t:f,langCode:e}};var LE={};yc(LE,{AlignBottomIcon:()=>Xc,AlignLeftIcon:()=>$c,AlignRightIcon:()=>Zc,AlignTopIcon:()=>Kc,ArrowIcon:()=>og,ArrowRightIcon:()=>ii,ArrowheadArrowIcon:()=>Ng,ArrowheadBarIcon:()=>Fg,ArrowheadCircleIcon:()=>Bg,ArrowheadCircleOutlineIcon:()=>Og,ArrowheadCrowfootIcon:()=>Yg,ArrowheadCrowfootOneIcon:()=>Wg,ArrowheadCrowfootOneOrManyIcon:()=>Vg,ArrowheadDiamondIcon:()=>Gg,ArrowheadDiamondOutlineIcon:()=>Ug,ArrowheadNoneIcon:()=>Rg,ArrowheadTriangleIcon:()=>Hg,ArrowheadTriangleOutlineIcon:()=>zg,BringForwardIcon:()=>Uc,BringToFrontIcon:()=>Wc,CenterHorizontallyIcon:()=>qc,CenterVerticallyIcon:()=>jc,CloseIcon:()=>no,DeviceDesktopIcon:()=>Ch,DiamondIcon:()=>Tl,DiscordIcon:()=>sg,DistributeHorizontallyIcon:()=>Eg,DistributeVerticallyIcon:()=>yg,DotsIcon:()=>Zu,DuplicateIcon:()=>Ui,EdgeRoundIcon:()=>Dg,EdgeSharpIcon:()=>_g,EllipseIcon:()=>Il,EmbedIcon:()=>Fc,EraserIcon:()=>ig,ExcalLogo:()=>ik,ExportIcon:()=>Qn,ExportImageIcon:()=>Ll,ExternalLinkIcon:()=>Hc,FillCrossHatchIcon:()=>Tg,FillHachureIcon:()=>vg,FillSolidIcon:()=>Ig,FillZigZagIcon:()=>wg,FontFamilyCodeIcon:()=>Pl,FontFamilyHeadingIcon:()=>jg,FontFamilyNormalIcon:()=>Ki,FontSizeExtraLargeIcon:()=>Zg,FontSizeLargeIcon:()=>$g,FontSizeMediumIcon:()=>Xg,FontSizeSmallIcon:()=>Kg,FreedrawIcon:()=>Tn,GithubIcon:()=>kl,GroupIcon:()=>Jc,HamburgerMenuIcon:()=>Sl,HelpIcon:()=>oi,HelpIconThin:()=>lg,HomeIcon:()=>Xu,ImageIcon:()=>rg,LassoIcon:()=>Gi,LibraryIcon:()=>Qr,LineIcon:()=>Cl,LinkIcon:()=>Vi,LoadIcon:()=>ni,LockedIcon:()=>ei,LockedIconFilled:()=>qu,MagicIcon:()=>Nl,MagicIconThin:()=>Ik,MoonIcon:()=>Yi,OpenAIIcon:()=>Ck,PenModeIcon:()=>ng,PinIcon:()=>ju,PlusIcon:()=>$u,RectangleIcon:()=>vl,RedoIcon:()=>Gc,SelectionIcon:()=>tg,SendBackwardIcon:()=>Yc,SendToBackIcon:()=>Vc,SloppinessArchitectIcon:()=>Lg,SloppinessArtistIcon:()=>Ag,SloppinessCartoonistIcon:()=>Pg,StrokeStyleDashedIcon:()=>kg,StrokeStyleDottedIcon:()=>Mg,StrokeStyleSolidIcon:()=>yk,StrokeWidthBaseIcon:()=>ed,StrokeWidthBoldIcon:()=>Cg,StrokeWidthExtraBoldIcon:()=>Sg,SunIcon:()=>Wi,TextAlignBottomIcon:()=>th,TextAlignCenterIcon:()=>Jg,TextAlignLeftIcon:()=>qg,TextAlignMiddleIcon:()=>oh,TextAlignRightIcon:()=>Qg,TextAlignTopIcon:()=>eh,TextIcon:()=>ti,TrashIcon:()=>zt,UndoIcon:()=>zc,UngroupIcon:()=>Qc,UnlockedIcon:()=>Jn,WelcomeScreenHelpArrow:()=>Qu,WelcomeScreenMenuArrow:()=>Ju,WelcomeScreenTopToolbarArrow:()=>eg,XBrandIcon:()=>cg,ZoomInIcon:()=>Bc,ZoomOutIcon:()=>Oc,ZoomResetIcon:()=>ag,abacusIcon:()=>xh,alertTriangleIcon:()=>lh,angleIcon:()=>_l,boltIcon:()=>$i,brainIcon:()=>ph,brainIconThin:()=>uh,bucketFillIcon:()=>Ml,checkIcon:()=>dg,clipboard:()=>ak,clockIcon:()=>gh,clone:()=>bk,coffeeIcon:()=>Ih,collapseDownIcon:()=>zl,collapseUpIcon:()=>Lh,copyIcon:()=>ri,createIcon:()=>L,cropIcon:()=>nd,cutIcon:()=>rh,done:()=>fg,downloadIcon:()=>td,elbowArrowIcon:()=>Fl,elementLinkIcon:()=>Gl,eraser:()=>wk,exportToFileIcon:()=>hg,exportToPlus:()=>pk,extraToolsIcon:()=>ch,eyeClosedIcon:()=>mh,eyeDropperIcon:()=>sh,eyeIcon:()=>ai,file:()=>Ek,flipHorizontal:()=>yh,flipVertical:()=>Eh,fontSizeIcon:()=>er,frameToolIcon:()=>tr,fullscreenIcon:()=>dh,gridIcon:()=>kh,handIcon:()=>Dl,helpIcon:()=>ih,iconFillColor:()=>uo,laserPointerToolIcon:()=>Xi,lineEditorIcon:()=>Mh,loginIcon:()=>Sk,magnetIcon:()=>Th,menu:()=>ck,mermaidLogoIcon:()=>Rl,microphoneIcon:()=>hh,microphoneMutedIcon:()=>fh,paintIcon:()=>od,palette:()=>ug,playerPlayIcon:()=>vk,playerStopFilledIcon:()=>Tk,pngIcon:()=>vh,polygonIcon:()=>Nc,publishIcon:()=>nh,questionCircle:()=>bg,resetZoom:()=>gk,roundArrowIcon:()=>Hl,save:()=>mg,saveAs:()=>pg,searchIcon:()=>Gt,selectAllIcon:()=>bh,share:()=>xg,shareIOS:()=>mk,shareWindows:()=>uk,sharpArrowIcon:()=>Ol,shield:()=>xk,slashIcon:()=>gg,start:()=>hk,stop:()=>fk,svgIcon:()=>wh,tablerCheckIcon:()=>ah,upIcon:()=>Ah,usersIcon:()=>Al,warning:()=>dk,youtubeIcon:()=>Sh,zoomAreaIcon:()=>Bl,zoomIn:()=>lk,zoomOut:()=>sk});import ok from"clsx";import nk from"open-color";import Et from"react";import{THEME as rk}from"@excalidraw/common";import{Fragment as Ce,jsx as h,jsxs as D}from"react/jsx-runtime";var uo=e=>"var(--icon-fill-color)",SE=e=>e===rk.LIGHT?nk.white:"#1e1e1e",L=(e,t=512)=>{let{width:o=512,height:n=o,mirror:r,style:i,...a}=typeof t=="number"?{width:t}:t;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${o} ${n}`,className:ok({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},H={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},re={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},Xu=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("polyline",{points:"5 12 3 12 12 3 21 12 19 12"}),h("path",{d:"M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7"}),h("path",{d:"M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6"})]}),H),Qr=L(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),h("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),h("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),H),$u=L(D("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),H),Zu=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),H),ju=L(D("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),H),Nc=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M6.5 9.5l3.5 -3"}),h("path",{d:"M14 5.5l3 1.5"}),h("path",{d:"M18.5 10l-2.5 7"}),h("path",{d:"M13.5 17.5l-7 -5"})]}),H),Jn=L(D("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),re),ei=L(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),re),qu=L(h("g",{fill:"currentColor",children:h("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),Ju=L(D(Ce,{children:[h("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),Qu=L(D(Ce,{children:[h("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),eg=L(D(Ce,{children:[h("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),ik=L(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),tg=L(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Gi=L(D("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),vl=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),H),Tl=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),H),Il=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),H),og=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),H),Cl=L(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),re),ng=L(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),H),Tn=L(D("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),re),ti=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),H),rg=L(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),re),ig=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),H),Bc=L(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),re),Oc=L(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),re),ag=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),h("path",{d:"M3 4v4h4"})]}),H),zt=L(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),re),Fc=L(D("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),re),Ui=L(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),re),Yi=L(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),re),Wi=L(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...re,strokeWidth:1.5}),Sl=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),H),Qn=L(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),re),oi=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),lg=L(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),Hc=L(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),re),kl=L(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),re),sg=L(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),re),cg=L(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),H),dg=L(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Vi=L(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),re),mg=L("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}),pg=L("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}),ni=L(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),re),ak=L("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}),ug=L("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"),Ml=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),h("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"}),h("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),gg=L(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),H),Ll=L(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),H),hg=L("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}),lk=L("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}),sk=L("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}),fg=L("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"),ck=L("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"),zc=L(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),re),Gc=L(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),re),bg=L("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}),xg=L(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),re),dk=L("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"),mk=L("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}),pk=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),H),uk=L(D(Ce,{children:[h("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),h("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),gk=L(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),kE=D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),ME=D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),Uc=L(ME,H),Yc=L(ME,{...H,style:{transform:"rotate(180deg)"}}),Wc=L(kE,H),Vc=L(kE,{...H,style:{transform:"rotate(180deg)"}}),Kc=L(D(Ce,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),Xc=L(D(Ce,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),$c=L(D(Ce,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),Zc=L(D(Ce,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),Eg=L(D(Ce,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),yg=L(D(Ce,{children:[D("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),jc=L(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),re),qc=L(D("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),re),Al=L(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),H),hk=L("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"),fk=L("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"),no=L(D(Ce,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),bk=L("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}),xk=L("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}),Ek=L("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}),Jc=Et.memo(({theme:e})=>L(D(Ce,{children:[h("path",{d:"M25 26H111V111H25",fill:uo(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:uo(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:uo(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:uo(e),strokeWidth:"2"}),D("g",{fill:SE(e),stroke:uo(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),Qc=Et.memo(({theme:e})=>L(D(Ce,{children:[h("path",{d:"M25 26H111V111H25",fill:uo(e)}),h("path",{d:"M25 111C25 80.2068 25 49.4135 25 26M25 26C48.6174 26 72.2348 26 111 26H25ZM25 26C53.3671 26 81.7343 26 111 26H25ZM111 26C111 52.303 111 78.606 111 111V26ZM111 26C111 51.2947 111 76.5893 111 111V26ZM111 111C87.0792 111 63.1585 111 25 111H111ZM111 111C87.4646 111 63.9293 111 25 111H111ZM25 111C25 81.1514 25 51.3028 25 26V111Z",stroke:uo(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:uo(e)}),h("path",{d:"M100 160C100 144.106 100 128.211 100 100M100 100C117.706 100 135.412 100 160 100H100ZM100 100C114.214 100 128.428 100 160 100H100ZM160 100C160 120.184 160 140.369 160 160V100ZM160 100C160 113.219 160 126.437 160 160V100ZM160 160C145.534 160 131.068 160 100 160H160ZM160 160C143.467 160 126.934 160 100 160H160ZM100 160C100 143.661 100 127.321 100 100V160Z",stroke:uo(e),strokeWidth:"2"}),D("g",{fill:SE(e),stroke:uo(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"78.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"78.5",width:"30",height:"30"}),h("rect",{x:"105.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"102.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),wg=L(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),re),vg=L(D(Ce,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),re),Tg=L(D(Ce,{children:[D("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),Ig=L(D(Ce,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...re,fill:"currentColor"}),ed=L(h(Ce,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),re),Cg=L(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),re),Sg=L(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),re),yk=Et.memo(({theme:e})=>L(h("path",{d:"M6 10H34",stroke:uo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),kg=L(D("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),H),Mg=L(D("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),H),Lg=L(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),re),Ag=L(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),re),Pg=L(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),re),_g=L(D("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),re),Dg=L(D("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),H),Rg=L(D("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[h("path",{d:"M12 12l9 0"}),h("path",{d:"M3 9l6 6"}),h("path",{d:"M3 15l6 -6"})]}),H),Ng=Et.memo(({flip:e=!1})=>L(D("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[h("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),h("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),Bg=Et.memo(({flip:e=!1})=>L(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Og=Et.memo(({flip:e=!1})=>L(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M26 10L6 10"}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Fg=Et.memo(({flip:e=!1})=>L(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:h("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),Hg=Et.memo(({flip:e=!1})=>L(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),zg=Et.memo(({flip:e=!1})=>L(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[h("path",{d:"M6,9.5H27"}),h("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),Gg=Et.memo(({flip:e=!1})=>L(D("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Ug=Et.memo(({flip:e=!1})=>L(D("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Yg=Et.memo(({flip:e=!1})=>L(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Wg=Et.memo(({flip:e=!1})=>L(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),Vg=Et.memo(({flip:e=!1})=>L(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Kg=L(D(Ce,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),Xg=L(D(Ce,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),$g=L(D(Ce,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),Zg=L(h(Ce,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),re),er=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),H),jg=L(h(Ce,{children:D("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),H),Ki=L(h(Ce,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),re),Pl=L(D(Ce,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("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"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),re),qg=L(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),H),Jg=L(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),H),Qg=L(D("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),H),eh=Et.memo(({theme:e})=>L(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),H)),th=Et.memo(({theme:e})=>L(D("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),H)),oh=Et.memo(({theme:e})=>L(D("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),H)),_l=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),H),nh=L(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),wk=L(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Dl=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),H),td=L(D(Ce,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),H),ri=L(D(Ce,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),H),rh=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),H),ih=L(D(Ce,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),H),vk=L(D(Ce,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),H),Tk=L(D(Ce,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),H),ah=L(D(Ce,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),H),lh=L(D(Ce,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),H),sh=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l6 6"}),h("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),ch=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l-4 7h8z"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("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),tr=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),H),Rl=L(h("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"})),ii=L(D("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),re),Xi=L(D("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),h("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),Nl=L(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),H),Ik=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),H),Ck=L(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),H),dh=L(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),H),ai=L(D("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),H),mh=L(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),h("path",{d:"M3 3l18 18"})]}),H),ph=L(D("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),uh=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),H),Gt=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),H),gh=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),H),hh=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),H),fh=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),H),$i=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),H),bh=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),H),xh=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),H),Eh=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),H),yh=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),H),od=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),H),Bl=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),H),wh=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),H),vh=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),H),Th=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),H),Ih=L(D("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),H),Ch=L(D("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...H,strokeWidth:1.5}),Sk=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),H),Sh=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),H),kh=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),H),Mh=L(D("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),H),Ol=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),H),Fl=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),H),Hl=L(D("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),H),zl=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),H),Lh=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),Ah=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),H),nd=L(D("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),H),Gl=L(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),H);import AE from"clsx";import _h,{useEffect as Lk,useRef as PE,useState as Ak}from"react";import{isPromiseLike as Pk}from"@excalidraw/common";import kk from"react";import{jsx as Ph}from"react/jsx-runtime";var Mk=({size:e="1em",circleWidth:t=8,synchronized:o=!1,className:n=""})=>{let i=-(kk.useRef(Date.now()).current%1600);return Ph("div",{className:`Spinner ${n}`,children:Ph("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":o?`${i}ms`:0},children:Ph("circle",{cx:"50",cy:"50",r:50-t/2,strokeWidth:t,fill:"none",strokeMiterlimit:"10"})})})},yt=Mk;import{jsx as Ul,jsxs as Yl}from"react/jsx-runtime";var $=_h.forwardRef(({size:e="medium",visible:t=!0,className:o="",...n},r)=>{let{id:i}=tt(),a=_h.useRef(null);_h.useImperativeHandle(r,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=Ak(!1),d=PE(!0),m=async u=>{let g="onClick"in n&&n.onClick?.(u);if(Pk(g))try{c(!0),await g}catch(b){if(b instanceof Bi)console.warn(b);else throw b}finally{d.current&&c(!1)}};Lk(()=>(d.current=!0,()=>{d.current=!1}),[]);let p=PE(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return Yl("button",{className:AE("ToolIcon_type_button",l,o,t&&!n.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!n.hidden,"ToolIcon--selected":n.selected,"ToolIcon--plain":n.type==="icon"}),style:n.style,"data-testid":n["data-testid"],hidden:n.hidden,title:n.title,"aria-label":n["aria-label"],type:u,onClick:m,ref:a,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&Yl("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&Ul("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&Ul(yt,{})]}),n.showAriaLabel&&Yl("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&Ul(yt,{})]}),n.children]})}return Yl("label",{className:AE("ToolIcon",o),title:n.title,onPointerDown:u=>{p.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[Ul("input",{className:`ToolIcon_type_radio ${l}`,type:"radio",name:n.name,"aria-label":n["aria-label"],"aria-keyshortcuts":n["aria-keyshortcuts"],"data-testid":n["data-testid"],id:`${i}-${n.id}`,onChange:()=>{n.onChange?.({pointerType:p.current})},checked:n.checked,ref:a}),Yl("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&Ul("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});$.displayName="ToolButton";var rd=[],N=e=>(rd=rd.concat(e),e);import{jsx as Hk}from"react/jsx-runtime";var Fk=(e,t,o)=>{let n=new Set(J(e.filter(d=>Nk(d)),t).map(d=>d.id)),r={},i=o.scene.getNonDeletedElementsMap(),a=new Set;for(let d of n){let m=Bk(e,d);for(let p of m)if(!a.has(p.id)){if(id(p)){let u=DE(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(d=>{if(t.selectedElementIds[d.id]){let m=id(d)?DE(d,i):null;return d.frameId&&n.has(d.frameId)?(l=!1,r[d.id]=!0,d):m?.frameId&&n.has(m?.frameId)?d:(d.boundElements&&d.boundElements.forEach(p=>{let u=o.scene.getNonDeletedElementsMap().get(p.id);u&&Rk(u)&&o.scene.mutateElement(u,{startBinding:d.id===u.startBinding?.elementId?null:u.startBinding,endBinding:d.id===u.endBinding?.elementId?null:u.endBinding})}),ld(d,{isDeleted:!0}))}return d.frameId&&n.has(d.frameId)?(l=!1,id(d)||(r[d.id]=!0),ld(d,{frameId:null})):id(d)&&t.selectedElementIds[d.containerId]?ld(d,{isDeleted:!0}):d}),c=t.editingGroupId;if(l&&t.editingGroupId){let d=Nh(s,t.editingGroupId).filter(m=>!m.isDeleted);if(d.length>1)d[0]&&(r[d[0].id]=!0);else{c=null,d[0]&&(r[d[0].id]=!0);let m=d[0];if(m){let p=m.groupIds.findIndex(g=>g===t.editingGroupId),u=m.groupIds[p+1];if(u){let g=Nh(s,u).filter(b=>!b.isDeleted);g.length>1&&(c=u,g.forEach(b=>{r[b.id]=!0}))}}}}return{elements:s,appState:{...t,...Ok({selectedElementIds:r,editingGroupId:c},s,t,null)}}},RE=(e,t)=>{if(e.editingGroupId){let o=Nh(Rh(t),e.editingGroupId);if(o.length)return{...e,selectedElementIds:{[o[0].id]:!0}}}return e},Zi=N({name:"deleteSelectedElements",label:"labels.delete",icon:zt,trackEvent:{category:"element",action:"delete"},perform:(e,t,o,n)=>{if(t.editingLinearElement){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:c}=t.editingLinearElement,d=n.scene.getNonDeletedElementsMap(),m=_E.getElement(a,d);if(!m||l==null)return!1;if(m.points.length<2){let u=e.map(b=>b.id===m.id?ld(b,{isDeleted:!0}):b),g=RE(t,u);return{elements:u,appState:{...g,editingLinearElement:null},captureUpdate:ad.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(m.points.length-1)?null:c};return _E.deletePoints(m,n,l),{elements:e,appState:{...t,editingLinearElement:{...t.editingLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:ad.IMMEDIATELY}}let{elements:r,appState:i}=Fk(e,t,n);return Dk(r,r.filter(a=>a.isDeleted)),i=RE(i,r),{elements:r,appState:{...i,activeTool:_k(t,{type:"selection"}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Le(Rh(e),t)?ad.IMMEDIATELY:ad.EVENTUALLY}},keyTest:(e,t,o)=>(e.key===Dh.BACKSPACE||e.key===Dh.DELETE)&&!e[Dh.CTRL_OR_CMD],PanelComponent:({elements:e,appState:t,updateData:o})=>Hk($,{type:"button",icon:zt,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>o(null),visible:Le(Rh(e),t)})});import{KEYS as ji,CODES as qi,getShortcutKey as Ji,isDarwin as sd}from"@excalidraw/common";import{moveOneLeft as zk,moveOneRight as Gk,moveAllLeft as Uk,moveAllRight as Yk}from"@excalidraw/element";import{CaptureUpdateAction as cd}from"@excalidraw/element";import{jsx as gd}from"react/jsx-runtime";var dd=N({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Yc,trackEvent:{category:"element"},perform:(e,t,o,n)=>({elements:zk(e,t,n.scene),appState:t,captureUpdate:cd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ji.CTRL_OR_CMD]&&!e.shiftKey&&e.code===qi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>gd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${Ji("CtrlOrCmd+[")}`,children:Yc})}),md=N({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Uc,trackEvent:{category:"element"},perform:(e,t,o,n)=>({elements:Gk(e,t,n.scene),appState:t,captureUpdate:cd.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[ji.CTRL_OR_CMD]&&!e.shiftKey&&e.code===qi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>gd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${Ji("CtrlOrCmd+]")}`,children:Uc})}),pd=N({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Vc,trackEvent:{category:"element"},perform:(e,t)=>({elements:Uk(e,t),appState:t,captureUpdate:cd.IMMEDIATELY}),keyTest:e=>sd?e[ji.CTRL_OR_CMD]&&e.altKey&&e.code===qi.BRACKET_LEFT:e[ji.CTRL_OR_CMD]&&e.shiftKey&&e.code===qi.BRACKET_LEFT,PanelComponent:({updateData:e,appState:t})=>gd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${sd?Ji("CtrlOrCmd+Alt+["):Ji("CtrlOrCmd+Shift+[")}`,children:Vc})}),ud=N({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Wc,trackEvent:{category:"element"},perform:(e,t)=>({elements:Yk(e,t),appState:t,captureUpdate:cd.IMMEDIATELY}),keyTest:e=>sd?e[ji.CTRL_OR_CMD]&&e.altKey&&e.code===qi.BRACKET_RIGHT:e[ji.CTRL_OR_CMD]&&e.shiftKey&&e.code===qi.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:t})=>gd("button",{type:"button",className:"zIndexButton",onClick:o=>e(null),title:`${f("labels.bringToFront")} \u2014 ${sd?Ji("CtrlOrCmd+Alt+]"):Ji("CtrlOrCmd+Shift+]")}`,children:Wc})});import{getNonDeletedElements as Wk}from"@excalidraw/element";import{LinearElementEditor as Vk}from"@excalidraw/element";import{isLinearElement as Kk,isTextElement as Xk}from"@excalidraw/element";import{arrayToMap as $k,KEYS as NE}from"@excalidraw/common";import{selectGroupsForSelectedElements as Zk}from"@excalidraw/element";import{CaptureUpdateAction as jk}from"@excalidraw/element";var hd=N({name:"selectAll",label:"labels.selectAll",icon:bh,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,t,o,n)=>{if(t.editingLinearElement)return!1;let r=e.filter(i=>!i.isDeleted&&!(Xk(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...t,...Zk({editingGroupId:null,selectedElementIds:r},Wk(e),t,n),selectedLinearElement:Object.keys(r).length===1&&Kk(e[0])?new Vk(e[0],$k(e)):null},captureUpdate:jk.IMMEDIATELY}},keyTest:e=>e[NE.CTRL_OR_CMD]&&e.key===NE.A});import{DEFAULT_GRID_SIZE as BE,KEYS as OE,arrayToMap as FE,getShortcutKey as qk}from"@excalidraw/common";import{getNonDeletedElements as HE}from"@excalidraw/element";import{LinearElementEditor as Jk}from"@excalidraw/element";import{getSelectedElements as Qk,getSelectionStateForElements as eM}from"@excalidraw/element";import{syncMovedIndices as tM}from"@excalidraw/element";import{duplicateElements as oM}from"@excalidraw/element";import{CaptureUpdateAction as zE}from"@excalidraw/element";import{jsx as nM}from"react/jsx-runtime";var fd=N({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Ui,trackEvent:{category:"element"},perform:(e,t,o,n)=>{if(t.selectedElementsAreBeingDragged)return!1;if(t.editingLinearElement)try{let a=Jk.duplicateSelectedPoints(t,n.scene);return{elements:e,appState:a,captureUpdate:zE.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=oM({type:"in-place",elements:e,idsOfElementsToDuplicate:FE(Qk(e,t,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:t,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+BE/2,y:a.y+BE/2,frameId:s??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:tM(i,FE(r)),appState:{...t,...eM(r,HE(i),t)},captureUpdate:zE.IMMEDIATELY}},keyTest:e=>e[OE.CTRL_OR_CMD]&&e.key===OE.D,PanelComponent:({elements:e,appState:t,updateData:o})=>nM($,{type:"button",icon:Ui,title:`${f("labels.duplicateSelection")} \u2014 ${qk("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>o(null),visible:Le(HE(e),t)})});import{pointFrom as rA}from"@excalidraw/math";import{useEffect as nf,useMemo as iA,useRef as rf,useState as aA}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as lA,DEFAULT_ELEMENT_BACKGROUND_PICKS as sA,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as cA,DEFAULT_ELEMENT_STROKE_PICKS as dA,ARROW_TYPE as Cn,DEFAULT_FONT_FAMILY as mA,DEFAULT_FONT_SIZE as pA,FONT_FAMILY as uA,ROUNDNESS as Dd,STROKE_WIDTH as af,VERTICAL_ALIGN as _d,KEYS as ca,randomInteger as gA,arrayToMap as cf,getFontFamilyString as hA,getShortcutKey as fA,getLineHeight as bA,isTransparent as xA,reduceToCommonValue as EA}from"@excalidraw/common";import{canBecomePolygon as yA,getNonDeletedElements as ky}from"@excalidraw/element";import{bindLinearElement as Ty,calculateFixedPointForElbowArrowBinding as Iy,updateBoundElements as wA}from"@excalidraw/element";import{LinearElementEditor as lf}from"@excalidraw/element";import{newElementWith as ct}from"@excalidraw/element";import{getBoundTextElement as cr,redrawTextBoundingBox as Ql}from"@excalidraw/element";import{isArrowElement as Rd,isBoundToContainer as vA,isElbowArrow as My,isLinearElement as sf,isLineElement as Cy,isTextElement as Ut,isUsingAdaptiveRadius as TA}from"@excalidraw/element";import{hasStrokeColor as IA}from"@excalidraw/element";import{updateElbowArrowPoints as CA,CaptureUpdateAction as dt,toggleLinePolygonState as SA}from"@excalidraw/element";import{isDevEnv as rM}from"@excalidraw/common";var iM=new Set(["command_palette","export"]),ae=(e,t,o,n)=>{try{if(typeof window>"u"||I.VITE_WORKER_ID||I.VITE_APP_ENABLE_TRACKING!=="true"||!iM.has(e)||rM())return;I.PROD||console.info("trackEvent",{category:e,action:t,label:o,value:n}),window.sa_event&&window.sa_event(t,{category:e,label:o,value:n})}catch(r){console.error("error during analytics",r)}};import cM from"clsx";import aM from"clsx";import{forwardRef as lM}from"react";import{jsx as sM}from"react/jsx-runtime";var Qi=lM((e,t)=>{let{title:o,className:n,testId:r,active:i,standalone:a,icon:l,onClick:s}=e;return sM("button",{type:"button",ref:t,title:o,"data-testid":r,className:aM(n,{standalone:a,active:i}),onClick:s,style:e.style,children:l},o)});import{Fragment as mM,jsx as Bh,jsxs as dM}from"react/jsx-runtime";var go=e=>Bh(mM,{children:e.options.map(t=>e.type==="button"?Bh(Qi,{icon:t.icon,title:t.text,testId:t.testId,active:t.active??e.value===t.value,onClick:o=>e.onClick(t.value,o)},t.text):dM("label",{className:cM({active:e.value===t.value}),title:t.text,children:[Bh("input",{type:"radio",name:e.group,onChange:()=>e.onChange(t.value),checked:e.value===t.value,"data-testid":t.testId}),t.icon]},t.text))});import*as Td from"@radix-ui/react-popover";import dL from"clsx";import{useRef as mL}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as pL,COLOR_PALETTE as iy,isTransparent as uL}from"@excalidraw/common";import{jsx as pM}from"react/jsx-runtime";var bd=()=>pM("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as bM,useRef as xM}from"react";import{createPortal as EM}from"react-dom";import{EVENT as nr,KEYS as yM,rgbToHex as wM}from"@excalidraw/common";import GE from"react";var Oh=GE.createContext(null),Te=()=>GE.useContext(Oh);import{useState as uM,useLayoutEffect as UE}from"react";import{THEME as gM}from"@excalidraw/common";var xd=e=>{let[t,o]=uM(null),n=me(),{theme:r}=Te(),{container:i}=tt();return UE(()=>{t&&(t.className="",t.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),t.classList.toggle("excalidraw--mobile",n.editor.isMobile),t.classList.toggle("theme--dark",r===gM.DARK))},[t,r,n.editor.isMobile,e?.className]),UE(()=>{let a=e?.parentSelector?i?.querySelector(e.parentSelector):document.body;if(!a)return;let l=document.createElement("div");return a.appendChild(l),o(l),()=>{a.removeChild(l)}},[i,e?.parentSelector]),t};import{useEffect as hM}from"react";import{EVENT as Ed}from"@excalidraw/common";function ea(e,t,o){hM(()=>{function n(r){let i=r;if(!e.current)return;let a=o?.(i,e.current);if(a===!0)return;if(a===!1)return t(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]")||t(i)}return document.addEventListener(Ed.POINTER_DOWN,n),document.addEventListener(Ed.TOUCH_START,n),()=>{document.removeEventListener(Ed.POINTER_DOWN,n),document.removeEventListener(Ed.TOUCH_START,n)}},[e,t,o])}import{useRef as fM}from"react";var or=e=>{let t=fM(e);return Object.assign(t.current,e),t.current};import{jsx as vM}from"react/jsx-runtime";var rr=be(null),YE=({onCancel:e,onChange:t,onSelect:o,colorPickerType:n})=>{let r=xd({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Te(),a=ir(),l=Ke(),s=J(a,i),c=or({app:l,onCancel:e,onChange:t,onSelect:o,selectedElements:s}),{container:d}=tt();bM(()=>{let p=m.current;if(!p||!l.canvas||!r)return;let u=!1,g=l.canvas.getContext("2d"),b=({clientX:C,clientY:M})=>{let k=g.getImageData((C-i.offsetLeft)*window.devicePixelRatio,(M-i.offsetTop)*window.devicePixelRatio,1,1).data;return wM(k[0],k[1],k[2])},x=({clientX:C,clientY:M,altKey:k})=>{p.style.top=`${M+20}px`,p.style.left=`${C+20}px`;let P=b({clientX:C,clientY:M});u&&c.onChange(n,P,c.selectedElements,{altKey:k}),p.style.background=P},w=()=>{c.onCancel()},E=(C,M)=>{c.onSelect(C,M)},y=C=>{u=!0,C.stopImmediatePropagation()},T=C=>{u=!1,d?.focus(),C.stopImmediatePropagation(),C.preventDefault(),E(b(C),C)},v=C=>{C.key===yM.ESCAPE&&(C.preventDefault(),C.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(nr.KEYDOWN,v),r.addEventListener(nr.POINTER_DOWN,y),r.addEventListener(nr.POINTER_UP,T),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(nr.BLUR,w),()=>{u=!1,r.removeEventListener(nr.KEYDOWN,v),r.removeEventListener(nr.POINTER_DOWN,y),r.removeEventListener(nr.POINTER_UP,T),window.removeEventListener("pointermove",x),window.removeEventListener(nr.BLUR,w)}},[c,l.canvas,r,n,d,i.offsetLeft,i.offsetTop]);let m=xM(null);return ea(m,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?EM(vM("div",{ref:m,className:"excalidraw-eye-dropper-preview"}),r):null};import*as ta from"@radix-ui/react-popover";import SM from"clsx";import kM from"react";import{isInteractive as MM}from"@excalidraw/common";import TM from"react";import IM from"clsx";import{jsx as CM}from"react/jsx-runtime";var st=TM.forwardRef(({children:e,padding:t,className:o,style:n},r)=>CM("div",{className:IM("Island",o),style:{"--padding":t,...n},ref:r,children:e}));import{jsx as Fh,jsxs as LM}from"react/jsx-runtime";var yd=kM.forwardRef(({className:e,container:t,children:o,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},c)=>{let d=me();return Fh(ta.Portal,{container:t,children:LM(ta.Content,{ref:c,className:SM("focus-visible-none",e),"data-prevent-outside-click":!0,side:d.editor.isMobile&&!d.viewport.isLandscape?"bottom":"right",align:d.editor.isMobile&&!d.viewport.isLandscape?"center":"start",alignOffset:-16,sideOffset:20,style:{zIndex:"var(--zIndex-popup)"},onPointerLeave:l,onKeyDown:i,onFocusOutside:a,onPointerDownOutside:s,onCloseAutoFocus:m=>{m.stopPropagation(),m.preventDefault(),t&&!MM(document.activeElement)&&t.focus(),r()},children:[Fh(st,{padding:3,style:n,children:o}),Fh(ta.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import PM from"clsx";import{useCallback as _M,useEffect as zh,useRef as KE,useState as DM}from"react";import{KEYS as Gh,getShortcutKey as RM}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as AM}from"@excalidraw/common";var ar=({palette:e,color:t})=>{if(!t)return null;for(let[o,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(t);if(r>-1)return{colorName:o,shade:r}}else if(n===t)return{colorName:o,shade:null};return null},Wl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Hh=({color:e,palette:t})=>!Object.values(t).flat().includes(e),VE=(e,t,o)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[n[t]];return Hh({color:l,palette:o})}),i=new Map;return r.forEach(a=>{let l=a[n[t]];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,AM)},ho=be(null),WE=(e,t,o)=>(e*299+t*587+o*114)/1e3,oa=(e,t=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]),c=parseInt(l[1]),d=parseInt(l[2]);return WE(s,c,d)<t}return!0}let o=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return WE(o,n,r)<t};import{Fragment as NM,jsx as wd,jsxs as XE}from"react/jsx-runtime";var $E=({color:e,onChange:t,label:o,colorPickerType:n,placeholder:r})=>{let i=me(),[a,l]=DM(e),[s,c]=ce(ho);zh(()=>{l(e)},[e]);let d=_M(b=>{let x=b.toLowerCase(),w=ZE(x);w&&t(w),l(x)},[t]),m=KE(null),p=KE(null);zh(()=>{m.current&&m.current.focus()},[s]);let[u,g]=ce(rr);return zh(()=>()=>{g(null)},[g]),XE("div",{className:"color-picker__input-label",children:[wd("div",{className:"color-picker__input-hash",children:"#"}),wd("input",{ref:s==="hex"?m:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":o,onChange:b=>{d(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:b=>{b.key!==Gh.TAB&&(b.key===Gh.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:r}),!i.editor.isMobile&&XE(NM,{children:[wd("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),wd("div",{ref:p,className:PM("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>g(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>t(x),colorPickerType:n}),title:`${f("labels.eyeDropper")} \u2014 ${Gh.I.toLocaleUpperCase()} or ${RM("Alt")} `,children:sh})]})]})};import Vh,{useEffect as Kh,useImperativeHandle as eL,useState as tL}from"react";import{EVENT as ty}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as oL,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as nL,KEYS as rL}from"@excalidraw/common";import FM from"clsx";import{useEffect as HM,useRef as zM}from"react";import{jsxs as OM}from"react/jsx-runtime";var BM=({color:e,keyLabel:t,isShade:o=!1})=>OM("div",{className:"color-picker__button__hotkey-label",style:{color:oa(e)?"#fff":"#000"},children:[o&&"\u21E7",t]}),na=BM;import{jsx as Uh,jsxs as GM}from"react/jsx-runtime";var jE=({colors:e,color:t,onChange:o,label:n})=>{let[r,i]=ce(ho),a=zM(null);return HM(()=>{a.current&&a.current.focus()},[t,r]),Uh("div",{className:"color-picker-content--default",children:e.map((l,s)=>GM("button",{ref:t===l?a:void 0,tabIndex:-1,type:"button",className:FM("color-picker__button color-picker__button--large has-outline",{active:t===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{o(l),i("custom")},title:l,"aria-label":n,style:{"--swatch-color":l},children:[Uh("div",{className:"color-picker__button-outline"}),Uh(na,{color:l,keyLabel:s+1})]},s))})};import UM from"clsx";import{useEffect as YM,useRef as WM}from"react";import{jsx as Yh,jsxs as KM}from"react/jsx-runtime";var VM=({palette:e,color:t,onChange:o,activeShade:n})=>{let r=ar({color:t,palette:e}),[i,a]=ce(ho),l=WM(null);return YM(()=>{l.current&&i==="baseColors"&&l.current.focus()},[r?.colorName,i]),Yh("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,c],d)=>{let m=(Array.isArray(c)?c[n]:c)||"transparent",p=Wl[d],u=f(`colors.${s.replace(/\d+/,"")}`,null,"");return KM("button",{ref:r?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:UM("color-picker__button color-picker__button--large has-outline",{active:r?.colorName===s,"is-transparent":m==="transparent"||!m}),onClick:()=>{o(m),a("baseColors")},title:`${u}${m.startsWith("#")?` ${m}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:m?{"--swatch-color":m}:void 0,"data-testid":`color-${s}`,children:[Yh("div",{className:"color-picker__button-outline"}),Yh(na,{color:m,keyLabel:p})]},s)})})},qE=VM;import{jsx as $M}from"react/jsx-runtime";var XM=({children:e})=>$M("div",{className:"color-picker__heading",children:e}),ra=XM;import ZM from"clsx";import{useEffect as jM,useRef as qM}from"react";import{jsx as Vl,jsxs as JE}from"react/jsx-runtime";var QE=({color:e,onChange:t,palette:o})=>{let n=ar({color:e||"transparent",palette:o}),[r,i]=ce(ho),a=qM(null);if(jM(()=>{a.current&&r==="shades"&&a.current.focus()},[n,r]),n){let{colorName:l,shade:s}=n,c=o[l];if(Array.isArray(c))return Vl("div",{className:"color-picker-content--default shades",children:c.map((d,m)=>JE("button",{ref:m===s&&r==="shades"?a:void 0,tabIndex:-1,type:"button",className:ZM("color-picker__button color-picker__button--large has-outline",{active:m===s}),"aria-label":"Shade",title:`${l} - ${m+1}`,style:d?{"--swatch-color":d}:void 0,onClick:()=>{t(d),i("shades")},children:[Vl("div",{className:"color-picker__button-outline"}),Vl(na,{color:d,keyLabel:m+1,isShade:!0})]},m))})}return JE("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Vl("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Vl("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:f("colorPicker.noShades")})]})};import{COLORS_PER_ROW as ia,COLOR_PALETTE as JM,KEYS as Kl}from"@excalidraw/common";var Wh=(e,t,o)=>{let n=Math.ceil(o/ia);switch(t=t??-1,e){case"ArrowLeft":{let r=t-1;return r<0?o-1:r}case"ArrowRight":return(t+1)%o;case"ArrowDown":{let r=t+ia;return r>=o?t%ia:r}case"ArrowUp":{let r=t-ia,i=r<0?ia*n+r:r;return i>=o?void 0:i}}},QM=({e,colorObj:t,onChange:o,palette:n,customColors:r,setActiveColorPickerSection:i,activeShade:a})=>{if(t?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return o(n[t.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&r[Number(e.key)-1])return o(r[Number(e.key)-1]),i("custom"),!0;if(Wl.includes(e.key)){let l=Wl.indexOf(e.key),s=Object.keys(n)[l],c=n[s],d=Array.isArray(c)?c[a]:c;return o(d),i("baseColors"),!0}return!1},ey=({event:e,activeColorPickerSection:t,palette:o,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:d})=>{if(e[Kl.CTRL_OR_CMD])return!1;if(e.key===Kl.ESCAPE)return d(e),!0;if(e.key===Kl.ALT)return c(!0),!0;if(e.key===Kl.I)return c(),!0;let m=ar({color:n,palette:o});if(e.key===Kl.TAB){let p={custom:!!i.length,baseColors:!0,shades:m?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[y,T])=>(T&&E.push(y),E),[]),g=u.indexOf(t),b=e.shiftKey?-1:1,x=g+b>u.length-1?0:g+b<0?u.length-1:g+b,w=u[x];return w&&a(w),w==="custom"?r(i[0]):w==="baseColors"&&(Object.entries(o).find(([y,T])=>Array.isArray(T)?T.includes(n):T===n?y:null)||r(JM.charcoal)),e.preventDefault(),e.stopPropagation(),!0}if(QM({e,colorObj:m,onChange:r,palette:o,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(t==="shades"&&m){let{shade:p}=m,u=Wh(e.key,p,ia);if(u!==void 0)return r(o[m.colorName][u]),!0}if(t==="baseColors"&&m){let{colorName:p}=m,u=Object.keys(o),g=u.indexOf(p),b=Wh(e.key,g,u.length);if(b!==void 0){let x=u[b],w=o[x];return r(Array.isArray(w)?w[s]:w),!0}}if(t==="custom"){let p=n!=null?i.indexOf(n):0,u=Wh(e.key,p,i.length);if(u!==void 0){let g=i[u];return r(g),!0}}return!1};import{jsx as li,jsxs as vd}from"react/jsx-runtime";var oy=Vh.forwardRef(({color:e,onChange:t,type:o,elements:n,palette:r,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},c)=>{let[d]=Vh.useState(()=>o==="canvasBackground"?[]:VE(n,o,r)),[m,p]=ce(ho),u=ar({color:e,palette:r});Kh(()=>{if(!m){let w=!!e&&Hh({color:e,palette:r}),E=w&&!d.includes(e);p(E?null:w?"custom":u?.shade!=null?"shades":"baseColors")}},[m,e,r,p,u,d]);let[g,b]=tL(u?.shade??(o==="elementBackground"?oL:nL));Kh(()=>{u?.shade!=null&&b(u.shade);let w=E=>{E.key===rL.ALT&&l(!1)};return document.addEventListener(ty.KEYUP,w,{capture:!0}),()=>{document.removeEventListener(ty.KEYUP,w,{capture:!0})}},[u,l]);let x=Vh.useRef(null);return eL(c,()=>x.current),Kh(()=>{x?.current?.focus()},[]),li("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:vd("div",{ref:x,onKeyDown:w=>{ey({event:w,activeColorPickerSection:m,palette:r,color:e,onChange:t,onEyeDropperToggle:l,customColors:d,setActiveColorPickerSection:p,updateData:i,activeShade:g,onEscape:s})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!d.length&&vd("div",{children:[li(ra,{children:f("colorPicker.mostUsedCustomColors")}),li(jE,{colors:d,color:e,label:f("colorPicker.mostUsedCustomColors"),onChange:t})]}),vd("div",{children:[li(ra,{children:f("colorPicker.colors")}),li(qE,{color:e,palette:r,onChange:t,activeShade:g})]}),vd("div",{children:[li(ra,{children:f("colorPicker.shades")}),li(QE,{color:e,onChange:t,palette:r})]}),a]})})});import iL from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as aL,DEFAULT_CANVAS_BACKGROUND_PICKS as lL,DEFAULT_ELEMENT_BACKGROUND_PICKS as sL,DEFAULT_ELEMENT_STROKE_PICKS as cL}from"@excalidraw/common";import{jsx as Xh}from"react/jsx-runtime";var ny=({onChange:e,type:t,activeColor:o,topPicks:n})=>{let r;return t==="elementStroke"&&(r=cL),t==="elementBackground"&&(r=sL),t==="canvasBackground"&&(r=lL),n&&(r=n),r?Xh("div",{className:"color-picker__top-picks",children:r.map(i=>Xh("button",{className:iL("color-picker__button",{active:i===o,"is-transparent":i==="transparent"||!i,"has-outline":!oa(i,aL)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Xh("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Ro,jsxs as $h}from"react/jsx-runtime";var ry=e=>{let t=new Option().style;return t.color=e,!!t.color},ZE=e=>uL(e)?e:ry(`#${e}`)?`#${e}`:ry(e)?e:null,gL=({type:e,color:t,onChange:o,label:n,elements:r,palette:i=iy,updateData:a})=>{let{container:l}=tt(),[,s]=ce(ho),[c,d]=ce(rr),m=$h("div",{children:[Ro(ra,{children:f("colorPicker.hexCode")}),Ro($E,{color:t||"",label:n,onChange:g=>{o(g)},colorPickerType:e,placeholder:f("colorPicker.color")})]}),p=mL(null),u=()=>{p.current?.focus()};return Ro(yd,{container:l,style:{maxWidth:"13rem"},onFocusOutside:g=>{u(),g.preventDefault()},onPointerDownOutside:g=>{c&&g.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?Ro(oy,{ref:p,palette:i,color:t,onChange:g=>{o(g)},onEyeDropperToggle:g=>{d(b=>g?(b=b||{keepOpenOnAlt:!0,onSelect:o,colorPickerType:e},b.keepOpenOnAlt=!0,b):g===!1||b?null:{keepOpenOnAlt:!1,onSelect:o,colorPickerType:e})},onEscape:g=>{c?d(null):a({openPopup:null})},type:e,elements:r,updateData:a,children:m}):m})},hL=({label:e,color:t,type:o})=>Ro(Td.Trigger,{type:"button",className:dL("color-picker__button active-color properties-trigger",{"is-transparent":!t||t==="transparent","has-outline":!t||!oa(t,pL)}),"aria-label":e,style:t?{"--swatch-color":t}:void 0,title:o==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),children:Ro("div",{className:"color-picker__button-outline",children:!t&&gg})}),Xl=({type:e,color:t,onChange:o,label:n,elements:r,palette:i=iy,topPicks:a,updateData:l,appState:s})=>Ro("div",{children:$h("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[Ro(ny,{activeColor:t,onChange:o,type:e,topPicks:a}),Ro(bd,{}),$h(Td.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[Ro(hL,{color:t,label:n,type:e}),s.openPopup===e&&Ro(gL,{type:e,color:t,onChange:o,label:n,elements:r,palette:i,updateData:l})]})]})});import*as hy from"@radix-ui/react-popover";import VL,{useCallback as KL,useMemo as XL}from"react";import{FONT_FAMILY as Qh}from"@excalidraw/common";import NL,{useMemo as lr,useState as BL,useRef as OL,useEffect as FL,useCallback as HL}from"react";import{arrayToList as zL,debounce as GL,FONT_FAMILY as si,getFontFamilyString as UL}from"@excalidraw/common";import fL from"clsx";import bL from"react";import{jsx as xL,jsxs as EL}from"react/jsx-runtime";var Id=bL.forwardRef(({className:e,placeholder:t,onChange:o},n)=>EL("div",{className:fL("QuickSearch__wrapper",e),children:[Gt,xL("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:t,onChange:r=>o(r.target.value.trim().toLowerCase())})]}));import yL from"clsx";import{Children as wL}from"react";import{jsx as ay}from"react/jsx-runtime";var Cd=({className:e,placeholder:t,children:o})=>{let n=!wL.count(o);return ay("div",{className:yL("ScrollableList__wrapper",e),role:"menu",children:n?ay("div",{className:"empty",children:t}):o})};import{jsx as vL,jsxs as TL}from"react/jsx-runtime";var ly=({children:e,className:t="",style:o,title:n})=>TL("div",{className:`dropdown-menu-group ${t}`,style:o,children:[n&&vL("p",{className:"dropdown-menu-group-title",children:n}),e]}),$l=ly;ly.displayName="DropdownMenuGroup";import{useEffect as _L,useRef as DL}from"react";import{THEME as RL}from"@excalidraw/common";import{jsx as IL}from"react/jsx-runtime";var Zl=({children:e,...t})=>IL("span",{...t,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...t.style},children:e});import{Fragment as SL,jsx as Sd,jsxs as kL}from"react/jsx-runtime";var CL=({textStyle:e,icon:t,shortcut:o,children:n})=>{let r=me();return kL(SL,{children:[t&&Sd("div",{className:"dropdown-menu-item__icon",children:t}),Sd("div",{style:e,className:"dropdown-menu-item__text",children:Sd(Zl,{children:n})}),o&&!r.editor.isMobile&&Sd("div",{className:"dropdown-menu-item__shortcut",children:o})]})},kd=CL;import ML,{useContext as LL}from"react";import{EVENT as AL,composeEventHandlers as PL}from"@excalidraw/common";var Zh=ML.createContext({}),Md=(e="",t=!1,o=!1)=>`dropdown-menu-item dropdown-menu-item-base ${e}
|
|
2
|
+
${t?"dropdown-menu-item--selected":""} ${o?"dropdown-menu-item--hovered":""}`.trim(),Ld=(e,t)=>{let o=LL(Zh);return PL(e,n=>{let r=new CustomEvent(AL.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});t?.(r),r.defaultPrevented||o.onSelect?.(r)})};import{jsx as jh}from"react/jsx-runtime";var qh=({icon:e,value:t,order:o,children:n,shortcut:r,className:i,hovered:a,selected:l,textStyle:s,onSelect:c,onClick:d,...m})=>{let p=Ld(d,c),u=DL(null);return _L(()=>{a&&(o===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,o]),jh("button",{...m,ref:u,value:t,onClick:p,className:Md(i,l,a),title:m.title??m["aria-label"],children:jh(kd,{textStyle:s,icon:e,shortcut:r,children:n})})};qh.displayName="DropdownMenuItem";var aa={GREEN:"green",RED:"red",BLUE:"blue"},Ad=({type:e=aa.BLUE,children:t})=>{let{theme:o}=en(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:o===RL.LIGHT?"1.5px solid white":"none"};switch(e){case aa.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case aa.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case aa.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return jh("div",{className:"DropDownMenuItemBadge",style:n,children:t})};Ad.displayName="DropdownMenuItemBadge";qh.Badge=Ad;var At=qh;import{KEYS as la}from"@excalidraw/common";var sy=({event:e,inputRef:t,hoveredFont:o,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[la.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===la.F)return t.current?.focus(),!0;if(e.key===la.ESCAPE)return r(),!0;if(e.key===la.ENTER)return o?.value&&i(o.value),!0;if(e.key===la.ARROW_DOWN)return o?.next?a(o.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===la.ARROW_UP)return o?.prev?a(o.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as jl,jsxs as cy}from"react/jsx-runtime";var YL=e=>{switch(e){case si.Excalifont:case si.Virgil:return Tn;case si.Nunito:case si.Helvetica:return Ki;case si["Lilita One"]:return jg;case si["Comic Shanns"]:case si.Cascadia:return Pl;default:return Ki}},dy=NL.memo(({selectedFontFamily:e,hoveredFontFamily:t,onSelect:o,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=tt(),{fonts:s}=Ke(),{showDeprecatedFonts:c}=tn(),[d,m]=BL(""),p=OL(null),u=lr(()=>Array.from(Zn.registered.entries()).filter(([k,{metadata:P}])=>!P.private&&!P.fallback).map(([k,{metadata:P,fontFaces:A}])=>{let R={value:k,icon:YL(k),text:A[0]?.fontFace?.family??"Unknown"};return P.deprecated&&Object.assign(R,{deprecated:P.deprecated,badge:{type:aa.RED,placeholder:f("fontList.badge.old")}}),R}).sort((k,P)=>k.text.toLowerCase()>P.text.toLowerCase()?1:-1),[]),g=lr(()=>new Set(s.getSceneFamilies()),[e]),b=lr(()=>u.filter(k=>g.has(k.value)),[u,g]),x=lr(()=>u.filter(k=>!g.has(k.value)&&(c||!k.deprecated)),[u,g,c]),w=lr(()=>zL([...b,...x].filter(k=>k.text?.toLowerCase().includes(d))),[b,x,d]),E=lr(()=>{let k;return t?k=w.find(P=>P.value===t):e&&(k=w.find(P=>P.value===e)),!k&&d&&(w[0]?.value?n(w[0].value):r()),k},[t,e,d,w,n,r]),y=HL(k=>{sy({event:k,inputRef:p,hoveredFont:E,filteredFonts:w,onSelect:o,onHover:n,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[E,w,o,n,a]);FL(()=>(i(),()=>{a()}),[]);let T=lr(()=>w.filter(k=>g.has(k.value)),[w,g]),v=lr(()=>w.filter(k=>!g.has(k.value)),[w,g]),C=(k,P)=>cy(At,{icon:k.icon,value:k.value,order:P,textStyle:{fontFamily:UL({fontFamily:k.value})},hovered:k.value===E?.value,selected:k.value===e,tabIndex:k.value===e?0:-1,onClick:A=>{o(Number(A.currentTarget.value))},onMouseMove:()=>{E?.value!==k.value&&n(k.value)},children:[k.text,k.badge&&jl(Ad,{type:k.badge.type,children:k.badge.placeholder})]},k.value),M=[];return T.length&&M.push(jl($l,{title:f("fontList.sceneFonts"),children:T.map(C)},"group_1")),v.length&&M.push(jl($l,{title:f("fontList.availableFonts"),children:v.map((k,P)=>C(k,P+T.length))},"group_2")),cy(yd,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:r,onKeyDown:y,children:[jl(Id,{ref:p,placeholder:f("quickSearch.placeholder"),onChange:GL(m,20)}),jl(Cd,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:M.length?M:null})]})},(e,t)=>e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);import*as my from"@radix-ui/react-popover";import{useMemo as WL}from"react";import{jsx as Jh}from"react/jsx-runtime";var py=({selectedFontFamily:e})=>{let t=WL(()=>!!(e&&!uy(e)),[e]);return Jh(my.Trigger,{asChild:!0,children:Jh("div",{children:Jh(Qi,{standalone:!0,icon:ti,title:f("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:t,onClick:()=>{}})})})};import{jsx as ql,jsxs as gy}from"react/jsx-runtime";var fy=[{value:Qh.Excalifont,icon:Tn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Qh.Nunito,icon:Ki,text:f("labels.normal"),testId:"font-family-normal"},{value:Qh["Comic Shanns"],icon:Pl,text:f("labels.code"),testId:"font-family-code"}],$L=new Set(fy.map(e=>e.value)),uy=e=>e?$L.has(e):!1,by=VL.memo(({isOpened:e,selectedFontFamily:t,hoveredFontFamily:o,onSelect:n,onHover:r,onLeave:i,onPopupChange:a})=>{let l=XL(()=>fy,[]),s=KL(c=>{c&&n(c)},[n]);return gy("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[ql("div",{className:"buttonList",children:ql(go,{type:"button",options:l,value:t,onClick:s})}),ql(bd,{}),gy(hy.Root,{open:e,onOpenChange:a,children:[ql(py,{selectedFontFamily:t}),e&&ql(dy,{selectedFontFamily:t,hoveredFontFamily:o,onSelect:s,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,t)=>e.isOpened===t.isOpened&&e.selectedFontFamily===t.selectedFontFamily&&e.hoveredFontFamily===t.hoveredFontFamily);import*as sa from"@radix-ui/react-popover";import JL from"clsx";import Pd,{useEffect as QL}from"react";import{isArrowKey as eA,KEYS as In}from"@excalidraw/common";import{jsx as ZL}from"react/jsx-runtime";var sr=({icon:e})=>ZL("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 qL,jsx as xy,jsxs as Ey}from"react/jsx-runtime";var jL=({label:e,open:t,openTrigger:o,children:n,className:r,showCollapsedIcon:i=!0})=>Ey(qL,{children:[Ey("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:o,children:[e,i&&xy(sr,{icon:t?Lh:zl})]}),t&&xy("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),Jl=jL;import{jsx as ci,jsxs as ef}from"react/jsx-runtime";var tA=be(!1);function oA({options:e,value:t,label:o,onChange:n,onClose:r,numberOfOptionsToAlwaysShow:i=e.length}){let a=me(),l=u=>{let g=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&g)n(g.value),u.preventDefault();else if(u.key===In.TAB){let b=e.findIndex(w=>w.value===t),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;n(e[x].value)}else if(eA(u.key)){let b=vn().rtl,x=e.findIndex(w=>w.value===t);if(x!==-1){let w=e.length,E=x;switch(u.key){case(b?In.ARROW_LEFT:In.ARROW_RIGHT):E=(x+1)%w;break;case(b?In.ARROW_RIGHT:In.ARROW_LEFT):E=(w+x-1)%w;break;case In.ARROW_DOWN:{E=(x+(i??1))%w;break}case In.ARROW_UP:{E=(w+x-(i??1))%w;break}}n(e[E].value)}u.preventDefault()}else(u.key===In.ESCAPE||u.key===In.ENTER)&&(u.preventDefault(),r());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,c]=ce(tA),d=Pd.useMemo(()=>e.slice(0,i),[e,i]),m=Pd.useMemo(()=>e.slice(i),[e,i]);QL(()=>{d.some(u=>u.value===t)||c(!0)},[t,d,c]);let p=u=>ci("div",{className:"picker-content",children:u.map((g,b)=>ef("button",{type:"button",className:JL("picker-option",{active:t===g.value}),onClick:x=>{n(g.value)},title:`${g.text} ${g.keyBinding&&`\u2014 ${g.keyBinding.toUpperCase()}`}`,"aria-label":g.text||"none","aria-keyshortcuts":g.keyBinding||void 0,ref:x=>{t===g.value&&setTimeout(()=>{x?.focus()},0)},children:[g.icon,g.keyBinding&&ci("span",{className:"picker-keybinding",children:g.keyBinding})]},g.text))});return ci(sa.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:ef("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":o,children:[p(d),m.length>0&&ci(Jl,{label:f("labels.more_options"),open:s,openTrigger:()=>{c(u=>!u)},className:"picker-collapsible",children:p(m)})]})})}function tf({value:e,label:t,options:o,onChange:n,group:r="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Pd.useState(!1),s=Pd.useRef(null);return ci("div",{children:ef(sa.Root,{open:a,onOpenChange:c=>l(c),children:[ci(sa.Trigger,{name:r,type:"button","aria-label":t,onClick:()=>l(!a),ref:s,className:a?"active":"",children:o.find(c=>c.value===e)?.icon}),a&&ci(oA,{options:o,value:e,label:t,onChange:n,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import yy,{useEffect as nA}from"react";import{jsx as of,jsxs as wy}from"react/jsx-runtime";var vy=({updateData:e,app:t,testId:o})=>{let n=yy.useRef(null),r=yy.useRef(null),i=t.scene.getSelectedElements(t.state),a=!0,l=i.at(0),c=i.reduce((d,m)=>(d!=null&&d!==m.opacity&&(a=!1),d==null||d>m.opacity?m.opacity:d),l?.opacity??null)??t.state.currentItemOpacity;return nA(()=>{if(n.current&&r.current){let d=n.current,m=r.current,p=d.offsetWidth,u=15,g=c/100*(p-u)+u/2;m.style.left=`${g}px`,d.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${c}%, var(--button-bg) ${c}%, var(--button-bg) 100%)`}},[c]),wy("label",{className:"control-label",children:[f("labels.opacity"),wy("div",{className:"range-wrapper",children:[of("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:n,type:"range",min:"0",max:"100",step:"10",onChange:d=>{e(+d.target.value)},value:c,className:"range-input","data-testid":o}),of("div",{className:"value-bubble",ref:r,children:c!==0?c:null}),of("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as zy,jsx as te,jsxs as Wt}from"react/jsx-runtime";var Ly=.1,Pt=(e,t,o,n=!1)=>{let r=cf(J(e,t,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===t.editingTextElement?.id?o(i):i)},Yt=function(e,t,o,n,r){let i=t.state.editingTextElement,a=ky(e),l=null;if(i&&(l=o(i)),!l)if(Le(a,t.state)){let c=t.scene.getSelectedElements(t.state),d=n===!0?c:c.filter(m=>n(m));l=EA(d,o)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},kA=(e,t,o)=>vA(t)||!t.autoResize?t:o.mutateElement(t,{x:e.textAlign==="left"?e.x:e.x+(e.width-t.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-t.height)/2}),df=(e,t,o,n,r)=>{let i=new Set,a=Pt(e,t,l=>{if(Ut(l)){let s=n(l);i.add(s);let c=ct(l,{fontSize:s});return Ql(c,o.scene.getContainerElement(l),o.scene),c=kA(l,c,o.scene),c}return l},!0);return J(e,t,{includeBoundTextElement:!0}).forEach(l=>{Ut(l)&&wA(l,o.scene)}),{elements:a,appState:{...t,currentItemFontSize:i.size===1?[...i][0]:r??t.currentItemFontSize},captureUpdate:dt.IMMEDIATELY}},Ay=N({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,t,o)=>({...o.currentItemStrokeColor&&{elements:Pt(e,t,n=>IA(n.type)?ct(n,{strokeColor:o.currentItemStrokeColor}):n,!0)},appState:{...t,...o},captureUpdate:o.currentItemStrokeColor?dt.IMMEDIATELY:dt.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Wt(zy,{children:[te("h3",{"aria-hidden":"true",children:f("labels.stroke")}),te(Xl,{topPicks:dA,palette:cA,type:"elementStroke",label:f("labels.stroke"),color:Yt(e,n,r=>r.strokeColor,!0,r=>r?null:t.currentItemStrokeColor),onChange:r=>o({currentItemStrokeColor:r}),elements:e,appState:t,updateData:o})]})}),Py=N({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,t,o,n)=>{if(!o.currentItemBackgroundColor)return{appState:{...t,...o},captureUpdate:dt.EVENTUALLY};let r,i=n.scene.getSelectedElements(t);if(!xA(o.currentItemBackgroundColor)&&i.every(l=>Cy(l)&&yA(l.points))){let l=cf(i);r=e.map(s=>l.has(s.id)&&Cy(s)?ct(s,{backgroundColor:o.currentItemBackgroundColor,...SA(s,!0)}):s)}else r=Pt(e,t,l=>ct(l,{backgroundColor:o.currentItemBackgroundColor}));return{elements:r,appState:{...t,...o},captureUpdate:dt.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Wt(zy,{children:[te("h3",{"aria-hidden":"true",children:f("labels.background")}),te(Xl,{topPicks:sA,palette:lA,type:"elementBackground",label:f("labels.background"),color:Yt(e,n,r=>r.backgroundColor,!0,r=>r?null:t.currentItemBackgroundColor),onChange:r=>o({currentItemBackgroundColor:r}),elements:e,appState:t,updateData:o})]})}),_y=N({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,t,o,n)=>(ae("element","changeFillStyle",`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`),{elements:Pt(e,t,r=>ct(r,{fillStyle:o})),appState:{...t,currentItemFillStyle:o},captureUpdate:dt.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>{let r=J(e,t),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return Wt("fieldset",{children:[te("legend",{children:f("labels.fill")}),te("div",{className:"buttonList",children:te(go,{type:"button",options:[{value:"hachure",text:`${i?f("labels.zigzag"):f("labels.hachure")} (${fA("Alt-Click")})`,icon:i?wg:vg,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:Tg,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:Ig,testId:"fill-solid"}],value:Yt(e,n,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:t.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&r.every(c=>c.fillStyle==="hachure")?"zigzag":a;o(s)}})})]})}}),Dy=N({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,t,o)=>({elements:Pt(e,t,n=>ct(n,{strokeWidth:o})),appState:{...t,currentItemStrokeWidth:o},captureUpdate:dt.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Wt("fieldset",{children:[te("legend",{children:f("labels.strokeWidth")}),te("div",{className:"buttonList",children:te(go,{group:"stroke-width",options:[{value:af.thin,text:f("labels.thin"),icon:ed,testId:"strokeWidth-thin"},{value:af.bold,text:f("labels.bold"),icon:Cg,testId:"strokeWidth-bold"},{value:af.extraBold,text:f("labels.extraBold"),icon:Sg,testId:"strokeWidth-extraBold"}],value:Yt(e,n,r=>r.strokeWidth,r=>r.hasOwnProperty("strokeWidth"),r=>r?null:t.currentItemStrokeWidth),onChange:r=>o(r)})})]})}),Ry=N({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,t,o)=>({elements:Pt(e,t,n=>ct(n,{seed:gA(),roughness:o})),appState:{...t,currentItemRoughness:o},captureUpdate:dt.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Wt("fieldset",{children:[te("legend",{children:f("labels.sloppiness")}),te("div",{className:"buttonList",children:te(go,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:Lg},{value:1,text:f("labels.artist"),icon:Ag},{value:2,text:f("labels.cartoonist"),icon:Pg}],value:Yt(e,n,r=>r.roughness,r=>r.hasOwnProperty("roughness"),r=>r?null:t.currentItemRoughness),onChange:r=>o(r)})})]})}),$ee=N({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,t,o)=>({elements:Pt(e,t,n=>ct(n,{strokeStyle:o})),appState:{...t,currentItemStrokeStyle:o},captureUpdate:dt.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Wt("fieldset",{children:[te("legend",{children:f("labels.strokeStyle")}),te("div",{className:"buttonList",children:te(go,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:ed},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:kg},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:Mg}],value:Yt(e,n,r=>r.strokeStyle,r=>r.hasOwnProperty("strokeStyle"),r=>r?null:t.currentItemStrokeStyle),onChange:r=>o(r)})})]})}),Ny=N({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,t,o)=>({elements:Pt(e,t,n=>ct(n,{opacity:o}),!0),appState:{...t,currentItemOpacity:o},captureUpdate:dt.IMMEDIATELY}),PanelComponent:({app:e,updateData:t})=>te(vy,{updateData:t,app:e,testId:"opacity"})}),By=N({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,t,o,n)=>df(e,t,n,()=>o,o),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Wt("fieldset",{children:[te("legend",{children:f("labels.fontSize")}),te("div",{className:"buttonList",children:te(go,{group:"font-size",options:[{value:16,text:f("labels.small"),icon:Kg,testId:"fontSize-small"},{value:20,text:f("labels.medium"),icon:Xg,testId:"fontSize-medium"},{value:28,text:f("labels.large"),icon:$g,testId:"fontSize-large"},{value:36,text:f("labels.veryLarge"),icon:Zg,testId:"fontSize-veryLarge"}],value:Yt(e,n,r=>{if(Ut(r))return r.fontSize;let i=cr(r,n.scene.getNonDeletedElementsMap());return i?i.fontSize:null},r=>Ut(r)||cr(r,n.scene.getNonDeletedElementsMap())!==null,r=>r?null:t.currentItemFontSize||pA),onChange:r=>o(r)})})]})}),mf=N({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:er,trackEvent:!1,perform:(e,t,o,n)=>df(e,t,n,r=>Math.round(1/(1+Ly)*r.fontSize)),keyTest:e=>e[ca.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ca.CHEVRON_LEFT||e.key===ca.COMMA)}),pf=N({name:"increaseFontSize",label:"labels.increaseFontSize",icon:er,trackEvent:!1,perform:(e,t,o,n)=>df(e,t,n,r=>Math.round(r.fontSize*(1+Ly))),keyTest:e=>e[ca.CTRL_OR_CMD]&&e.shiftKey&&(e.key===ca.CHEVRON_RIGHT||e.key===ca.PERIOD)}),Oy=N({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,t,o,n)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...l}=o;if(i)return{elements:Pt(e,t,b=>{let x=r?.get(b.id);return x?ct(b,{...x}):b},!0),appState:{...t,...l},captureUpdate:dt.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:c}=o,d=dt.EVENTUALLY,m,p=!1;if(s)m=s,d=dt.IMMEDIATELY;else if(c){m=c,d=dt.EVENTUALLY;let g=J(e,t,{includeBoundTextElement:!0}).filter(b=>Ut(b));if(g.length>200)p=!0;else{let b=0,x=0;for(;b<g.length&&x<5e3;){let w=g[b];x+=w?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...t,...l},captureUpdate:d};if(m&&!p){let g=new Map,b=new Set,x=!1,w=Array.from(Zn.loadedFontsCache.values()),E=Object.entries(uA).find(([v,C])=>C===m)?.[0];c&&E&&w.some(v=>v.startsWith(E))&&(x=!0),Object.assign(u,{elements:Pt(e,t,v=>{if(Ut(v)&&(v.fontFamily!==m||s)){let C=ct(v,{fontFamily:m,lineHeight:bA(m)}),M=r?.get(v.containerId||"")||{},k=n.scene.getContainerElement(v);return a&&k&&M&&n.scene.mutateElement(k,{...M}),x||(b=new Set([...b,...Array.from(C.originalText)])),g.set(C,k),C}return v},!0)});let y=`10px ${hA({fontFamily:m})}`,T=Array.from(b.values()).join();if(x||window.document.fonts.check(y,T))for(let[v,C]of g)Ql(v,C,n.scene);else window.document.fonts.load(y,T).then(v=>{for(let[C,M]of g){let k=n.scene.getElement(C.id),P=M?n.scene.getElement(M.id):null;k&&Ql(k,P,n.scene)}n.fonts.onLoaded(v)})}return u},PanelComponent:({elements:e,appState:t,app:o,updateData:n})=>{let r=rf(new Map),i=rf(null),[a,l]=aA({}),s=rf(!0),c=iA(()=>{let d=(m,p)=>Yt(m,o,u=>{if(Ut(u))return u.fontFamily;let g=cr(u,p);return g?g.fontFamily:null},u=>Ut(u)||cr(u,p)!==null,u=>u?null:t.currentItemFontFamily||mA);return a.openPopup==="fontFamily"&&t.openPopup==="fontFamily"?d(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&t.openPopup!=="fontFamily"?d(e,o.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,t,e,o]);return nf(()=>{i.current=c},[c]),nf(()=>{Object.keys(a).length&&(n(a),l({}))},[a]),nf(()=>(s.current=!1,()=>{s.current=!0}),[]),Wt("fieldset",{children:[te("legend",{children:f("labels.fontFamily")}),te(by,{isOpened:t.openPopup==="fontFamily",selectedFontFamily:c,hoveredFontFamily:t.currentHoveredFontFamily,onSelect:d=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:d}),r.current.clear()},onHover:d=>{l({currentHoveredFontFamily:d,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:d=>{if(d){r.current.clear();let{editingTextElement:m}=t;if(m?.type==="text"){let p=o.scene.getElement(m.id);r.current.set(m.id,ct(p||m,{},!0))}else{let p=J(e,t,{includeBoundTextElement:!0});for(let u of p)r.current.set(u.id,ct(u,{},!0))}l({openPopup:"fontFamily"})}else{let m={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s.current?n({...a,...m}):l(m),r.current.clear()}}})]})}}),Fy=N({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,t,o,n)=>({elements:Pt(e,t,r=>{if(Ut(r)){let i=ct(r,{textAlign:o});return Ql(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...t,currentItemTextAlign:o},captureUpdate:dt.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>{let r=n.scene.getNonDeletedElementsMap();return Wt("fieldset",{children:[te("legend",{children:f("labels.textAlign")}),te("div",{className:"buttonList",children:te(go,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:qg,testId:"align-left"},{value:"center",text:f("labels.center"),icon:Jg,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:Qg,testId:"align-right"}],value:Yt(e,n,i=>{if(Ut(i))return i.textAlign;let a=cr(i,r);return a?a.textAlign:null},i=>Ut(i)||cr(i,r)!==null,i=>i?null:t.currentItemTextAlign),onChange:i=>o(i)})})]})}}),Hy=N({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,t,o,n)=>({elements:Pt(e,t,r=>{if(Ut(r)){let i=ct(r,{verticalAlign:o});return Ql(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...t},captureUpdate:dt.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>te("fieldset",{children:te("div",{className:"buttonList",children:te(go,{group:"text-align",options:[{value:_d.TOP,text:f("labels.alignTop"),icon:te(eh,{theme:t.theme}),testId:"align-top"},{value:_d.MIDDLE,text:f("labels.centerVertically"),icon:te(oh,{theme:t.theme}),testId:"align-middle"},{value:_d.BOTTOM,text:f("labels.alignBottom"),icon:te(th,{theme:t.theme}),testId:"align-bottom"}],value:Yt(e,n,r=>{if(Ut(r)&&r.containerId)return r.verticalAlign;let i=cr(r,n.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},r=>Ut(r)||cr(r,n.scene.getNonDeletedElementsMap())!==null,r=>r?null:_d.MIDDLE),onChange:r=>o(r)})})})}),Zee=N({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,t,o)=>({elements:Pt(e,t,n=>My(n)?n:ct(n,{roundness:o==="round"?{type:TA(n.type)?Dd.ADAPTIVE_RADIUS:Dd.PROPORTIONAL_RADIUS}:null})),appState:{...t,currentItemRoundness:o},captureUpdate:dt.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n,renderAction:r})=>{let a=wc(ky(e),t).some(l=>l.roundness?.type===Dd.LEGACY);return Wt("fieldset",{children:[te("legend",{children:f("labels.edges")}),Wt("div",{className:"buttonList",children:[te(go,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:_g},{value:"round",text:f("labels.round"),icon:Dg}],value:Yt(e,n,l=>a?null:l.roundness?"round":"sharp",l=>!Rd(l)&&l.hasOwnProperty("roundness"),l=>l?null:t.currentItemRoundness),onChange:l=>o(l)}),r("togglePolygon")]})]})}}),Sy=e=>[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Rg},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:te(Ng,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:te(Hg,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:te(zg,{flip:e}),keyBinding:"r"},{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:te(Bg,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:te(Og,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:te(Gg,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:te(Ug,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:te(Fg,{flip:e})},{value:"crowfoot_one",text:f("labels.arrowhead_crowfoot_one"),icon:te(Wg,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:f("labels.arrowhead_crowfoot_many"),icon:te(Yg,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:f("labels.arrowhead_crowfoot_one_or_many"),icon:te(Vg,{flip:e}),keyBinding:"v"}],jee=N({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,t,o)=>({elements:Pt(e,t,n=>{if(sf(n)){let{position:r,type:i}=o;if(r==="start")return ct(n,{startArrowhead:i});if(r==="end")return ct(n,{endArrowhead:i})}return n}),appState:{...t,[o.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:o.type},captureUpdate:dt.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>{let r=vn().rtl;return Wt("fieldset",{children:[te("legend",{children:f("labels.arrowheads")}),Wt("div",{className:"iconSelectList buttonList",children:[te(tf,{label:"arrowhead_start",options:Sy(!r),value:Yt(e,n,i=>sf(i)&&Ni(i.type)?i.startArrowhead:t.currentItemStartArrowhead,!0,t.currentItemStartArrowhead),onChange:i=>o({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),te(tf,{label:"arrowhead_end",group:"arrowheads",options:Sy(!!r),value:Yt(e,n,i=>sf(i)&&Ni(i.type)?i.endArrowhead:t.currentItemEndArrowhead,!0,t.currentItemEndArrowhead),onChange:i=>o({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),qee=N({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,t,o,n)=>{let r=Pt(e,t,l=>{if(!Rd(l))return l;let s=ct(l,{roundness:o===Cn.round?{type:Dd.PROPORTIONAL_RADIUS}:null,elbowed:o===Cn.elbow,points:o===Cn.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(My(s)){s.fixedSegments=null;let c=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let d=lf.getPointAtIndexGlobalCoordinates(s,0,c),m=lf.getPointAtIndexGlobalCoordinates(s,-1,c),p=s.startBinding&&c.get(s.startBinding.elementId),u=s.endBinding&&c.get(s.endBinding.elementId),g=p&&s.startBinding?{...s.startBinding,...Iy(s,p,"start",c)}:null,b=u&&s.endBinding?{...s.endBinding,...Iy(s,u,"end",c)}:null;s={...s,startBinding:g,endBinding:b,...CA(s,c,{points:[d,m].map(x=>rA(x[0]-s.x,x[1]-s.y)),startBinding:g,endBinding:b,fixedSegments:null})}}else{let c=n.scene.getNonDeletedElementsMap();if(s.startBinding){let d=c.get(s.startBinding.elementId);d&&Ty(s,d,"start",n.scene)}if(s.endBinding){let d=c.get(s.endBinding.elementId);d&&Ty(s,d,"end",n.scene)}}return s}),i={...t,currentItemArrowType:o},a=t.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new lf(l,cf(e)))}return{elements:r,appState:i,captureUpdate:dt.IMMEDIATELY}},PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>Wt("fieldset",{children:[te("legend",{children:f("labels.arrowtypes")}),te("div",{className:"buttonList",children:te(go,{group:"arrowtypes",options:[{value:Cn.sharp,text:f("labels.arrowtype_sharp"),icon:Ol,testId:"sharp-arrow"},{value:Cn.round,text:f("labels.arrowtype_round"),icon:Hl,testId:"round-arrow"},{value:Cn.elbow,text:f("labels.arrowtype_elbowed"),icon:Fl,testId:"elbow-arrow"}],value:Yt(e,n,r=>Rd(r)?r.elbowed?Cn.elbow:r.roundness?Cn.round:Cn.sharp:null,r=>Rd(r),r=>r?null:t.currentItemArrowType),onChange:r=>o(r)})})]})});import{clamp as bf,roundToStep as RA}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as NA,CURSOR_TYPE as Wy,MAX_ZOOM as Vy,MIN_ZOOM as Ky,THEME as es,ZOOM_STEP as xf,getShortcutKey as Xy,updateActiveTool as ma,CODES as nn,KEYS as kn}from"@excalidraw/common";import{getNonDeletedElements as BA}from"@excalidraw/element";import{newElementWith as OA}from"@excalidraw/element";import{getCommonBounds as FA}from"@excalidraw/element";import{CaptureUpdateAction as No}from"@excalidraw/element";import{useEffect as MA}from"react";import{jsx as AA}from"react/jsx-runtime";var da=()=>{let e=document.querySelector(".excalidraw-tooltip");if(e)return e;let t=document.createElement("div");return document.body.appendChild(t),t.classList.add("excalidraw-tooltip"),t},uf=(e,t,o="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,l=t.left+t.width/2-n.width/2;l<0?l=a:l+n.width>=r&&(l=r-n.width-a);let s;o==="bottom"?(s=t.top+t.height+a,s+n.height>=i&&(s=t.top-n.height-a)):(s=t.top-n.height-a,s<0&&(s=t.top+t.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},LA=(e,t,o,n)=>{t.classList.add("excalidraw-tooltip--visible"),t.style.minWidth=n?"50ch":"10ch",t.style.maxWidth=n?"50ch":"15ch",t.textContent=o;let r=e.getBoundingClientRect();uf(t,r)},ro=({children:e,label:t,long:o=!1,style:n,disabled:r})=>(MA(()=>()=>da().classList.remove("excalidraw-tooltip--visible"),[]),r?null:AA("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>LA(i.currentTarget,da(),t,o),onPointerLeave:()=>da().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import Nd from"open-color";import{CURSOR_TYPE as gf,MIME_TYPES as Bd,THEME as hf}from"@excalidraw/common";var Uy='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',PA='<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"/>',Yy='<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"/>',_A=`data:${Bd.svg},${encodeURIComponent(`${Uy}${Yy}</svg>`)}`,DA=`data:${Bd.svg},${encodeURIComponent(`${Uy}${PA}${Yy}</svg>`)}`,fo=e=>{e&&(e.style.cursor="")},Se=(e,t)=>{e&&(e.style.cursor=t)},on,Gy,ff=(e,t)=>{let n=()=>{let r=t===hf.DARK;on=document.createElement("canvas"),on.theme=t,on.height=20,on.width=20;let i=on.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(on.width/2,on.height/2,5,0,2*Math.PI),i.fillStyle=r?Nd.black:Nd.white,i.fill(),i.strokeStyle=r?Nd.white:Nd.black,i.stroke(),Gy=on.toDataURL(Bd.svg)};(!on||on.theme!==t)&&n(),Se(e,`url(${Gy}) ${20/2} ${20/2}, auto`)},io=(e,t)=>{if(e)if(t.activeTool.type==="selection")fo(e);else if(Do(t))e.style.cursor=gf.GRAB;else if(Ht(t))ff(e,t.theme);else if(t.activeTool.type==="laser"){let o=t.theme===hf.LIGHT?_A:DA;e.style.cursor=`url(${o}), auto`}else if(!["image","custom"].includes(t.activeTool.type))e.style.cursor=gf.CROSSHAIR;else if(t.activeTool.type==="custom"&&t.activeTool.customType==="comment"){let o=`data:${Bd.svg},${encodeURIComponent(`
|
|
3
3
|
<svg
|
|
4
4
|
width="24"
|
|
5
5
|
height="24"
|
|
@@ -8,30 +8,43 @@ import{$ as lc,$a as Ct,$b as b0,$c as pt,$d as ox,$e as Au,$f as ve,$g as ed,A
|
|
|
8
8
|
>
|
|
9
9
|
<path
|
|
10
10
|
d="M5.25 18A3.25 3.25 0 0 1 2 14.75v-8.5A3.25 3.25 0 0 1 5.25 3h13.5A3.25 3.25 0 0 1 22 6.25v8.5A3.25 3.25 0 0 1 18.75 18h-5.738L8 21.75a1.25 1.25 0 0 1-1.999-1V18h-.75Zm7.264-1.5h6.236a1.75 1.75 0 0 0 1.75-1.75v-8.5a1.75 1.75 0 0 0-1.75-1.75H5.25A1.75 1.75 0 0 0 3.5 6.25v8.5c0 .966.784 1.75 1.75 1.75h2.249v3.75l5.015-3.75Z"
|
|
11
|
-
fill="${
|
|
11
|
+
fill="${t.theme===hf.LIGHT?"#000":"#fff"}"
|
|
12
12
|
/>
|
|
13
13
|
</svg>
|
|
14
|
-
`)}`;e.style.cursor=`url(${t}) 5 20, auto`}else o.activeTool.type!=="image"&&(e.style.cursor=Se.AUTO)};var Gr=({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),c=-(n-n/t),m=-(i-i/t);return{scrollX:l+c,scrollY:s+m,zoom:{value:t}}};import{jsx as mm,jsxs as uC}from"react/jsx-runtime";var Qy=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?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>mm(ds,{palette:null,topPicks:gc,label:f("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:n=>t({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),fr=F({name:"clearCanvas",label:"labels.clearCanvas",icon:lo,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=>re(n,{isDeleted:!0})),appState:{...Br(),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:"selection"}:o.activeTool},captureUpdate:A.IMMEDIATELY})}),hs=F({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Ed,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Gr({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:mr(o.zoom.value+Ui)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>mm(ee,{type:"button",className:"zoom-in-button zoom-button",icon:Ed,title:`${f("buttons.zoomIn")} \u2014 ${R("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:o.zoom.value>=tu,onClick:()=>{e(null)}}),keyTest:e=>(e.code===ue.EQUAL||e.code===ue.NUM_ADD)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),gs=F({name:"zoomOut",label:"buttons.zoomOut",icon:yd,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Gr({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:mr(o.zoom.value-Ui)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>mm(ee,{type:"button",className:"zoom-out-button zoom-button",icon:yd,title:`${f("buttons.zoomOut")} \u2014 ${R("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:o.zoom.value<=eu,onClick:()=>{e(null)}}),keyTest:e=>(e.code===ue.MINUS||e.code===ue.NUM_SUBTRACT)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),fs=F({name:"resetZoom",label:"buttons.resetZoom",icon:Ih,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Gr({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:mr(1)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>mm(vo,{label:f("buttons.resetZoom"),style:{height:"100%"},children:uC(ee,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===ue.ZERO||e.code===ue.NUM_ZERO)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),pC=(e,o,t=1)=>{let[r,n,i,a]=e,l=i-r,s=o.width/l,c=a-n,m=o.height/c,p=Math.min(s,m)*Ct(t,.1,1);return Math.min(p,1)},e2=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=Ct(n,eu,tu);let[l,s,c,m]=e,d=(l+c)/2,p=(s+m)/2,u=t?.left??0,g=t?.top??0,b=t?.right??0,x=t?.bottom??0,E=o.width-u-b,w=o.height-g-x,y;if(r){let S=c-l,_=m-s;y=Math.min(E/S,w/_)*n}else y=pC(e,{width:E,height:w},n);let v=mr(Ct(a0(y,Ui,"floor"),i,a)),C=jx({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:A.EVENTUALLY}},bs=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=ve(xe(o));return e2({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},_z=F({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:rs,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return bs({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===ue.TWO&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),Dz=F({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:rs,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return bs({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===ue.THREE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),t2=F({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:rs,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>bs({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===ue.ONE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),Mn=F({name:"toggleTheme",label:(e,o)=>o.theme===ce.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===ce.LIGHT?xa:Ea,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===ce.LIGHT?ce.DARK:ce.LIGHT)},captureUpdate:A.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===ue.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),Pz=F({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o)=>{let t;return ao(o)?t=Ue(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):t=Ue(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:t},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.key===T.E}),Rz=F({name:"toggleLassoTool",label:"toolBar.lasso",icon:fa,trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=Ue(o,{type:"lasso",fromSelection:!1}),Le(r.interactiveCanvas,Se.CROSSHAIR)):n=Ue(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:A.NEVER}}}),o2=F({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Ql,viewMode:!1,perform:(e,o,t,r)=>{let n;return jo(o)?n=Ue(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=Ue(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),Le(r.interactiveCanvas,Se.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:A.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[T.CTRL_OR_CMD]&&e.key===T.H});var r2=F({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=Ue(o,{type:"embeddable"});return To(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Ue(o,{type:"embeddable"})},captureUpdate:A.EVENTUALLY}}});import{jsx as hC}from"react/jsx-runtime";var co=F({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,l=a.getNonDeletedElementsMap();if(o.editingLinearElement){let{elementId:p,startBindingElement:u,endBindingElement:g}=o.editingLinearElement,b=j.getElement(p,l);if(b)return Pr(b)&&_c(b,u,g,l,a),{elements:b.points.length<2||ci(b)?e.filter(x=>x.id!==b.id):void 0,appState:{...o,cursorButton:"up",editingLinearElement:null},captureUpdate:A.IMMEDIATELY}}let s=e,c=o.pendingImageElementId&&a.getElement(o.pendingImageElementId);c&&B(c,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&i();let m=o.multiElement?o.multiElement:o.newElement?.type==="freedraw"?o.newElement:null;if(m){if(m.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:g}=m;(!g||u[u.length-1]!==g)&&B(m,{points:m.points.slice(0,-1)})}ci(m)&&(s=s.filter(u=>u.id!==m.id));let p=Pl(m.points,o.zoom.value);if((m.type==="line"||m.type==="freedraw")&&p){let u=m.points,g=u[0];B(m,{points:u.map((b,x)=>x===u.length-1?M(g[0],g[1]):b)})}if(Pr(m)&&!p&&m.points.length>1){let[u,g]=j.getPointAtIndexGlobalCoordinates(m,-1,te(e));Ml(m,o,{x:u,y:g},l,e)}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!m)&&wo(n);let d;return o.activeTool.type==="eraser"?d=Ue(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):d=Ue(o,{type:"selection"}),{elements:s,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&m?o.activeTool:d,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:m&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[m.id]:!0}:o.selectedElementIds,selectedLinearElement:m&&le(m)?new j(m):o.selectedLinearElement,pendingImageElementId:null},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o)=>e.key===T.ESCAPE&&(o.editingLinearElement!==null||!o.newElement&&o.multiElement===null)||(e.key===T.ESCAPE||e.key===T.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>hC(ee,{type:"button",icon:Rh,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import gC from"clsx";import{jsx as n2,jsxs as fC}from"react/jsx-runtime";var xs=({children:e,checked:o,onChange:t,className:r})=>fC("div",{className:gC("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[n2("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:Lh}),n2("div",{className:"Checkbox-label",children:e})]});import{jsx as Es}from"react/jsx-runtime";var a2=e=>{let o=e.title||(e.value===ce.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return Es(ee,{type:"icon",icon:e.value===ce.LIGHT?i2.MOON:i2.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===ce.DARK?ce.LIGHT:ce.DARK),"data-testid":"toggle-dark-mode"})},i2={SUN:Es("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Es("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:Es("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Es("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 bC}from"react";import{jsx as l2,jsxs as xC}from"react/jsx-runtime";var s2=e=>{let{id:o}=gt(),[t,r]=bC(e.value),n=a=>{e.ignoreFocus||b0(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===T.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return xC("div",{className:"ProjectName",children:[l2("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),l2("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};var Jo=32,Ve=12,Ln=256,d2=50,Mi="NOT_SPREADSHEET",Pa="VALID_SPREADSHEET",ys=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},kf=(e,o)=>e.slice(1).every(t=>ys(t[o])!==null),c2=e=>{let o=e[0].length;if(o>2)return{type:Mi,reason:"More than 2 columns"};if(o===1){if(!kf(e,0))return{type:Mi,reason:"Value is not numeric"};let s=ys(e[0][0])===null,c=(s?e.slice(1):e).map(m=>ys(m[0]));return c.length<2?{type:Mi,reason:"Less than two rows"}:{type:Pa,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let t=kf(e,0),r=kf(e,1);if(!t&&!r)return{type:Mi,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=ys(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:Mi,reason:"Less than 2 rows"}:{type:Pa,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>ys(s[i]))}}},EC=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},m2=e=>{let o=e.trim().split(`
|
|
15
|
-
`).map(i=>i.trim().split(" "));if(
|
|
16
|
-
`).map(i=>i.trim().split(","))),
|
|
17
|
-
`).trim()}:
|
|
14
|
+
`)}`;e.style.cursor=`url(${o}) 5 20, auto`}else t.activeTool.type!=="image"&&(e.style.cursor=gf.AUTO)};var Sn=({viewportX:e,viewportY:t,nextZoom:o},n)=>{let r=e-n.offsetLeft,i=t-n.offsetTop,a=n.zoom.value,l=n.scrollX+(r-r/a),s=n.scrollY+(i-i/a),c=-(r-r/o),d=-(i-i/o);return{scrollX:l+c,scrollY:s+d,zoom:{value:o}}};import{jsx as Od,jsxs as zA}from"react/jsx-runtime";var $y=N({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,t,o,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!t.viewModeEnabled,perform:(e,t,o)=>({appState:{...t,...o},captureUpdate:o.viewBackgroundColor?No.IMMEDIATELY:No.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o,appProps:n})=>Od(Xl,{palette:null,topPicks:NA,label:f("labels.canvasBackground"),type:"canvasBackground",color:t.viewBackgroundColor,onChange:r=>o({viewBackgroundColor:r}),"data-testid":"canvas-background-picker",elements:e,appState:t,updateData:o})}),rn=N({name:"clearCanvas",label:"labels.clearCanvas",icon:zt,trackEvent:{category:"canvas"},predicate:(e,t,o,n)=>!!n.props.UIOptions.canvasActions.clearCanvas&&!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector",perform:(e,t,o,n)=>(n.imageCache.clear(),{elements:e.map(r=>OA(r,{isDeleted:!0})),appState:{...Jr(),files:{},theme:t.theme,penMode:t.penMode,penDetected:t.penDetected,exportBackground:t.exportBackground,exportEmbedScene:t.exportEmbedScene,gridSize:t.gridSize,gridStep:t.gridStep,gridModeEnabled:t.gridModeEnabled,stats:t.stats,pasteDialog:t.pasteDialog,activeTool:t.activeTool.type==="image"?{...t.activeTool,type:"selection"}:t.activeTool},captureUpdate:No.IMMEDIATELY})}),ts=N({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Bc,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>({appState:{...t,...Sn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Jo(t.zoom.value+xf)},t),userToFollow:null},captureUpdate:No.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>Od($,{type:"button",className:"zoom-in-button zoom-button",icon:Bc,title:`${f("buttons.zoomIn")} \u2014 ${Xy("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:t.zoom.value>=Vy,onClick:()=>{e(null)}}),keyTest:e=>(e.code===nn.EQUAL||e.code===nn.NUM_ADD)&&(e[kn.CTRL_OR_CMD]||e.shiftKey)}),os=N({name:"zoomOut",label:"buttons.zoomOut",icon:Oc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>({appState:{...t,...Sn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Jo(t.zoom.value-xf)},t),userToFollow:null},captureUpdate:No.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>Od($,{type:"button",className:"zoom-out-button zoom-button",icon:Oc,title:`${f("buttons.zoomOut")} \u2014 ${Xy("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:t.zoom.value<=Ky,onClick:()=>{e(null)}}),keyTest:e=>(e.code===nn.MINUS||e.code===nn.NUM_SUBTRACT)&&(e[kn.CTRL_OR_CMD]||e.shiftKey)}),ns=N({name:"resetZoom",label:"buttons.resetZoom",icon:ag,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>({appState:{...t,...Sn({viewportX:t.width/2+t.offsetLeft,viewportY:t.height/2+t.offsetTop,nextZoom:Jo(1)},t),userToFollow:null},captureUpdate:No.EVENTUALLY}),PanelComponent:({updateData:e,appState:t})=>Od(ro,{label:f("buttons.resetZoom"),style:{height:"100%"},children:zA($,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(t.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===nn.ZERO||e.code===nn.NUM_ZERO)&&(e[kn.CTRL_OR_CMD]||e.shiftKey)}),HA=(e,t,o=1)=>{let[n,r,i,a]=e,l=i-n,s=t.width/l,c=a-r,d=t.height/c,p=Math.min(s,d)*bf(o,.1,1);return Math.min(p,1)},Zy=({bounds:e,appState:t,canvasOffsets:o,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{r=bf(r,Ky,Vy);let[l,s,c,d]=e,m=(l+c)/2,p=(s+d)/2,u=o?.left??0,g=o?.top??0,b=o?.right??0,x=o?.bottom??0,w=t.width-u-b,E=t.height-g-x,y;if(n){let C=c-l,M=d-s;y=Math.min(w/C,E/M)*r}else y=HA(e,{width:w,height:E},r);let T=Jo(bf(RA(y,xf,"floor"),i,a)),v=qx({scenePoint:{x:m,y:p},viewportDimensions:{width:t.width,height:t.height},offsets:o,zoom:{value:T}});return{appState:{...t,scrollX:v.scrollX,scrollY:v.scrollY,zoom:{value:T}},captureUpdate:No.EVENTUALLY}},rs=({canvasOffsets:e,targetElements:t,appState:o,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})=>{let l=FA(BA(t));return Zy({canvasOffsets:e,bounds:l,appState:o,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})},Dte=N({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Bl,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);return rs({targetElements:r.length?r:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===nn.TWO&&e.shiftKey&&!e.altKey&&!e[kn.CTRL_OR_CMD]}),Rte=N({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Bl,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);return rs({targetElements:r.length?r:e,appState:{...t,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===nn.THREE&&e.shiftKey&&!e.altKey&&!e[kn.CTRL_OR_CMD]}),jy=N({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Bl,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o,n)=>rs({targetElements:e,appState:{...t,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===nn.ONE&&e.shiftKey&&!e.altKey&&!e[kn.CTRL_OR_CMD]}),dr=N({name:"toggleTheme",label:(e,t)=>t.theme===es.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===es.LIGHT?Yi:Wi,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t,o)=>({appState:{...t,theme:o||(t.theme===es.LIGHT?es.DARK:es.LIGHT)},captureUpdate:No.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===nn.D,predicate:(e,t,o,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),Nte=N({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,t)=>{let o;return Ht(t)?o=ma(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):o=ma(t,{type:"eraser",lastActiveToolBeforeEraser:t.activeTool}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:o},captureUpdate:No.IMMEDIATELY}},keyTest:e=>e.key===kn.E}),Bte=N({name:"toggleLassoTool",label:"toolBar.lasso",icon:Gi,trackEvent:{category:"toolbar"},perform:(e,t,o,n)=>{let r;return t.activeTool.type!=="lasso"?(r=ma(t,{type:"lasso",fromSelection:!1}),Se(n.interactiveCanvas,Wy.CROSSHAIR)):r=ma(t,{type:"selection"}),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:No.NEVER}}}),qy=N({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Dl,viewMode:!1,perform:(e,t,o,n)=>{let r;return Do(t)?r=ma(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=ma(t,{type:"hand",lastActiveToolBeforeEraser:t.activeTool}),Se(n.interactiveCanvas,Wy.GRAB)),{appState:{...t,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:No.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[kn.CTRL_OR_CMD]&&e.key===kn.H});import{updateActiveTool as Jy}from"@excalidraw/common";import{CaptureUpdateAction as GA}from"@excalidraw/element";var Qy=N({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,t,o,n)=>{let r=Jy(t,{type:"embeddable"});return io(n.canvas,{...t,activeTool:r}),{elements:e,appState:{...t,activeTool:Jy(t,{type:"embeddable"})},captureUpdate:GA.EVENTUALLY}}});import{pointFrom as UA}from"@excalidraw/math";import{maybeBindLinearElement as YA,bindOrUnbindLinearElement as ew,isBindingEnabled as WA}from"@excalidraw/element/binding";import{isValidPolygon as tw,LinearElementEditor as Fd}from"@excalidraw/element";import{isBindingElement as Hd,isFreeDrawElement as ow,isLinearElement as nw,isLineElement as zd}from"@excalidraw/element";import{KEYS as Ef,arrayToMap as rw,tupleToCoors as VA,updateActiveTool as iw}from"@excalidraw/common";import{isPathALoop as KA}from"@excalidraw/element";import{isInvisiblySmallElement as yf}from"@excalidraw/element";import{CaptureUpdateAction as wf}from"@excalidraw/element";import{jsx as XA}from"react/jsx-runtime";var Vt=N({name:"finalize",label:"",trackEvent:!1,perform:(e,t,o,n)=>{let{interactiveCanvas:r,focusContainer:i,scene:a}=n,{event:l,sceneCoords:s}=o??{},c=a.getNonDeletedElementsMap();if(l&&t.selectedLinearElement){let u=Fd.handlePointerUp(l,t.selectedLinearElement,t,n.scene),{startBindingElement:g,endBindingElement:b}=u,x=n.scene.getElement(u.elementId);if(Hd(x)&&ew(x,g,b,n.scene),u!==t.selectedLinearElement){let w=e;return x&&yf(x)&&(w=w.filter(E=>E.id!==x.id)),{elements:w,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:wf.IMMEDIATELY}}}if(t.editingLinearElement){let{elementId:u,startBindingElement:g,endBindingElement:b}=t.editingLinearElement,x=Fd.getElement(u,c);if(x)return Hd(x)&&ew(x,g,b,a),zd(x)&&!tw(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||yf(x)?e.filter(w=>w.id!==x.id):void 0,appState:{...t,cursorButton:"up",editingLinearElement:null},captureUpdate:wf.IMMEDIATELY}}let d=e;window.document.activeElement instanceof HTMLElement&&i();let m=null;if(t.multiElement)m=t.multiElement;else if(t.newElement?.type==="freedraw"||Hd(t.newElement))m=t.newElement;else if(Object.keys(t.selectedElementIds).length===1){let u=c.get(Object.keys(t.selectedElementIds)[0]);u&&(m=u)}if(m){if(t.multiElement&&m.type!=="freedraw"&&t.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:g}=m;(!g||u[u.length-1]!==g)&&a.mutateElement(m,{points:m.points.slice(0,-1)})}if(m&&yf(m)&&(d=d.filter(u=>u.id!==m.id)),nw(m)||ow(m)){let u=KA(m.points,t.zoom.value);if(u&&(zd(m)||ow(m))){let g=m.points,b=g[0],x=g.map((w,E)=>E===g.length-1?UA(b[0],b[1]):w);zd(m)?a.mutateElement(m,{points:x,polygon:!0}):a.mutateElement(m,{points:x})}if(zd(m)&&!tw(m.points)&&a.mutateElement(m,{polygon:!1}),Hd(m)&&!u&&m.points.length>1&&WA(t)){let g=s??VA(Fd.getPointAtIndexGlobalCoordinates(m,-1,rw(e)));YA(m,t,g,a)}}}(!t.activeTool.locked&&t.activeTool.type!=="freedraw"||!m)&&fo(r);let p;return t.activeTool.type==="eraser"?p=iw(t,{...t.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):p=iw(t,{type:"selection"}),{elements:d,appState:{...t,cursorButton:"up",activeTool:(t.activeTool.locked||t.activeTool.type==="freedraw")&&m?t.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:m&&!t.activeTool.locked&&t.activeTool.type!=="freedraw"?{...t.selectedElementIds,[m.id]:!0}:t.selectedElementIds,selectedLinearElement:m&&nw(m)?new Fd(m,rw(d)):t.selectedLinearElement},captureUpdate:wf.IMMEDIATELY}},keyTest:(e,t)=>e.key===Ef.ESCAPE&&(t.editingLinearElement!==null||!t.newElement&&t.multiElement===null)||(e.key===Ef.ESCAPE||e.key===Ef.ENTER)&&t.multiElement!==null,PanelComponent:({appState:e,updateData:t,data:o})=>XA($,{type:"button",icon:fg,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:t,visible:e.multiElement!=null,size:o?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as ga,DEFAULT_EXPORT_PADDING as DP,EXPORT_SCALES as RP,THEME as If}from"@excalidraw/common";import{getNonDeletedElements as NP}from"@excalidraw/element";import{CaptureUpdateAction as Ho}from"@excalidraw/element";import $A from"clsx";import{jsx as aw,jsxs as ZA}from"react/jsx-runtime";var is=({children:e,checked:t,onChange:o,className:n})=>ZA("div",{className:$A("Checkbox",n,{"is-checked":t}),onClick:r=>{o(!t,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[aw("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":t,children:dg}),aw("div",{className:"Checkbox-label",children:e})]});import{THEME as as}from"@excalidraw/common";import{jsx as ls}from"react/jsx-runtime";var sw=e=>{let t=e.title||(e.value===as.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return ls($,{type:"icon",icon:e.value===as.LIGHT?lw.MOON:lw.SUN,title:t,"aria-label":t,onClick:()=>e.onChange(e.value===as.DARK?as.LIGHT:as.DARK),"data-testid":"toggle-dark-mode"})},lw={SUN:ls("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ls("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:ls("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ls("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 jA}from"react";import{focusNearestParent as qA,KEYS as JA}from"@excalidraw/common";import{jsx as cw,jsxs as QA}from"react/jsx-runtime";var dw=e=>{let{id:t}=tt(),[o,n]=jA(e.value),r=a=>{e.ignoreFocus||qA(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===JA.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return QA("div",{className:"ProjectName",children:[cw("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),cw("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${t}-filename`,value:o,onChange:a=>n(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as IP,DEFAULT_FILENAME as CP,IMAGE_MIME_TYPES as Cw,isFirefox as SP,MIME_TYPES as kP,cloneJSON as MP,SVG_DOCUMENT_PREAMBLE as LP}from"@excalidraw/common";import{getNonDeletedElements as AP}from"@excalidraw/element";import{isFrameLikeElement as PP}from"@excalidraw/element";import{getElementsOverlappingFrame as _P}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as dP,EXPORT_DATA_TYPES as ds,MIME_TYPES as Oo,arrayToMap as mP,isMemberOf as pP,isPromiseLike as uP}from"@excalidraw/common";import{mutateElement as gP}from"@excalidraw/element";import{deepCopyElement as hP}from"@excalidraw/element";import{isFrameLikeElement as fP,isInitializedImageElement as bP}from"@excalidraw/element";import{getContainingFrame as ww}from"@excalidraw/element";import{pointFrom as mr}from"@excalidraw/math";import{DEFAULT_CHART_COLOR_INDEX as eP,getAllColorsSpecificShade as tP,DEFAULT_FONT_FAMILY as oP,DEFAULT_FONT_SIZE as pw,VERTICAL_ALIGN as nP,randomId as uw,isDevEnv as gw,COLOR_CHARCOAL_BLACK as hw}from"@excalidraw/common";import{newTextElement as Gd,newLinearElement as cs,newElement as Tf}from"@excalidraw/element";var Bo=32,_e=12,pr=256,fw=50,di="NOT_SPREADSHEET",pa="VALID_SPREADSHEET",ss=e=>{let t=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return t?parseFloat(`${(t[1]||t[2])+t[3]}`.replace(/,/g,"")):null},vf=(e,t)=>e.slice(1).every(o=>ss(o[t])!==null),mw=e=>{let t=e[0].length;if(t>2)return{type:di,reason:"More than 2 columns"};if(t===1){if(!vf(e,0))return{type:di,reason:"Value is not numeric"};let s=ss(e[0][0])===null,c=(s?e.slice(1):e).map(d=>ss(d[0]));return c.length<2?{type:di,reason:"Less than two rows"}:{type:pa,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let o=vf(e,0),n=vf(e,1);if(!o&&!n)return{type:di,reason:"Value is not numeric"};let[r,i]=n?[0,1]:[1,0],a=ss(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:di,reason:"Less than 2 rows"}:{type:pa,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[r]),values:l.map(s=>ss(s[i]))}}},rP=e=>{let t=[];for(let o=0;o<e[0].length;o++){let n=[];for(let r=0;r<e.length;r++)n.push(e[r][o]);t.push(n)}return t},bw=e=>{let t=e.trim().split(`
|
|
15
|
+
`).map(i=>i.trim().split(" "));if(t.length&&t[0].length!==2&&(t=e.trim().split(`
|
|
16
|
+
`).map(i=>i.trim().split(","))),t.length===0)return{type:di,reason:"No values"};let o=t[0].length;if(!t.every(i=>i.length===o))return{type:di,reason:"All rows don't have same number of columns"};let r=mw(t);if(r.type!==pa){let i=mw(rP(t));if(i.type===pa)return i}return r},Ud=tP(eP),bo={fillStyle:"hachure",fontFamily:oP,fontSize:pw,opacity:100,roughness:1,strokeColor:hw,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:nP.MIDDLE,locked:!1},xw=e=>{let t=(Bo+_e)*e.values.length+_e,o=pr+_e*2;return{chartWidth:t,chartHeight:o}},iP=(e,t,o,n,r)=>e.labels?.map((i,a)=>Gd({groupIds:[n],backgroundColor:r,...bo,text:i.length>8?`${i.slice(0,5)}...`:i,x:t+a*(Bo+_e)+_e*2,y:o+_e/2,width:Bo,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],aP=(e,t,o,n,r)=>{let i=Gd({groupIds:[n],backgroundColor:r,...bo,x:t-_e,y:o-_e,text:"0",textAlign:"right"}),a=Gd({groupIds:[n],backgroundColor:r,...bo,x:t-_e,y:o-pr-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},lP=(e,t,o,n,r)=>{let{chartWidth:i,chartHeight:a}=xw(e),l=cs({backgroundColor:r,groupIds:[n],...bo,type:"line",x:t,y:o,width:i,points:[mr(0,0),mr(i,0)]}),s=cs({backgroundColor:r,groupIds:[n],...bo,type:"line",x:t,y:o,height:a,points:[mr(0,0),mr(0,-a)]}),c=cs({backgroundColor:r,groupIds:[n],...bo,type:"line",x:t,y:o-pr-_e,strokeStyle:"dotted",width:i,opacity:fw,points:[mr(0,0),mr(i,0)]});return[l,s,c]},Ew=(e,t,o,n,r,i)=>{let{chartWidth:a,chartHeight:l}=xw(e),s=e.title?Gd({backgroundColor:r,groupIds:[n],...bo,text:e.title,x:t+a/2,y:o-pr-_e*2-pw,roundness:null,textAlign:"center"}):null,c=i?Tf({backgroundColor:r,groupIds:[n],...bo,type:"rectangle",x:t,y:o-l,width:a,height:l,strokeColor:hw,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...s?[s]:[],...iP(e,t,o,n,r),...aP(e,t,o,n,r),...lP(e,t,o,n,r)]},sP=(e,t,o)=>{let n=Math.max(...e.values),r=uw(),i=Ud[Math.floor(Math.random()*Ud.length)];return[...e.values.map((l,s)=>{let c=l/n*pr;return Tf({backgroundColor:i,groupIds:[r],...bo,type:"rectangle",x:t+s*(Bo+_e)+_e,y:o-c-_e,width:Bo,height:c})}),...Ew(e,t,o,r,i,gw())]},cP=(e,t,o)=>{let n=Math.max(...e.values),r=uw(),i=Ud[Math.floor(Math.random()*Ud.length)],a=0,l=[];for(let b of e.values){let x=a*(Bo+_e),w=-(b/n)*pr;l.push([x,w]),a++}let s=Math.max(...l.map(b=>b[0])),c=Math.max(...l.map(b=>b[1])),d=Math.min(...l.map(b=>b[0])),m=Math.min(...l.map(b=>b[1])),p=cs({backgroundColor:i,groupIds:[r],...bo,type:"line",x:t+_e+Bo/2,y:o-_e,height:c-m,width:s-d,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let w=x*(Bo+_e)+_e/2,E=-(b/n)*pr+_e/2;return Tf({backgroundColor:i,groupIds:[r],...bo,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:t+w+Bo/2,y:o+E-_e*2,width:_e,height:_e})}),g=e.values.map((b,x)=>{let w=x*(Bo+_e)+_e/2,E=b/n*pr+_e/2+_e;return cs({backgroundColor:i,groupIds:[r],...bo,type:"line",x:t+w+Bo/2+_e/2,y:o-E,height:E,strokeStyle:"dotted",opacity:fw,points:[mr(0,0),mr(0,E)]})});return[...Ew(e,t,o,r,i,gw()),p,...g,...u]},yw=(e,t,o,n)=>e==="line"?cP(t,o,n):sP(t,o,n);var Zoe="clipboard"in navigator&&"readText"in navigator.clipboard,Yd="clipboard"in navigator&&"writeText"in navigator.clipboard,ua="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,xP=e=>!!([ds.excalidraw,ds.excalidrawClipboard,ds.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),vw=({types:e,files:t})=>{!e&&!t&&console.warn("createPasteEvent: no types or files provided");let o=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){t=t||[],t.push(r);continue}try{if(o.clipboardData?.setData(n,r),o.clipboardData?.getData(n)!==r)throw new Error(`Failed to set "${n}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(t){let n=-1;for(let r of t){n++;try{if(o.clipboardData?.items.add(r),o.clipboardData?.files[n]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return o},EP=({elements:e,files:t})=>{let o=mP(e),n=new Set(e.filter(l=>fP(l))),r=!1,i=e.reduce((l,s)=>(bP(s)&&(r=!0,t&&t[s.fileId]&&(l[s.fileId]=t[s.fileId])),l),{});r&&!t&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:ds.excalidrawClipboard,elements:e.map(l=>{if(ww(l,o)&&!n.has(ww(l,o))){let s=hP(l);return gP(s,o,{frameId:null}),s}return l}),files:t?i:void 0};return JSON.stringify(a)},Wd=async(e,t,o)=>{await Fo(EP({elements:e,files:t}),o)},yP=e=>{let t=bw(e);return t.type===pa?{spreadsheet:t.spreadsheet}:null};function Tw(e){let t=[];for(let o of e.childNodes)if(o.nodeType===3){let n=o.textContent?.trim();n&&t.push({type:"text",value:n})}else if(o instanceof HTMLImageElement){let n=o.getAttribute("src");n&&n.startsWith("http")&&t.push({type:"imageUrl",value:n})}else t=t.concat(Tw(o));return t}var wP=e=>{let t=e.clipboardData?.getData(Oo.html);if(!t)return null;try{let o=new DOMParser().parseFromString(t,Oo.html),n=Tw(o.body);if(n.length)return{type:"mixedContent",value:n}}catch(o){console.error(`error in parseHTMLFromPaste: ${o.message}`)}return null},Iw=async()=>{let e={},t;try{t=await navigator.clipboard?.read()}catch(o){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${o.message}). Failling back to navigator.clipboard.read()`);let n=await navigator.clipboard?.readText();if(n)return{[Oo.text]:n}}}catch(n){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${n.message}). Failling back to navigator.clipboard.read()`);else{if(n.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${n.message}`),e;throw n}}throw o}for(let o of t)for(let n of o.types)if(pP(dP,n))try{if(n===Oo.text||n===Oo.html)e[n]=await(await o.getType(n)).text();else if(uE(n)){let r=await o.getType(n),i=yE(r,n,void 0);e[n]=i}else throw new Fu(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof Fu?r.message:`Cannot retrieve ${n} from clipboardItem: ${r.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},vP=async(e,t=!1)=>{try{let o=!t&&e&&wP(e);return o?o.value.every(r=>r.type==="text")?{type:"text",value:e.clipboardData?.getData(Oo.text)||o.value.map(r=>r.value).join(`
|
|
17
|
+
`).trim()}:o:{type:"text",value:(e.clipboardData?.getData(Oo.text)||"").trim()}}catch{return{type:"text",value:""}}},Vd=async(e,t=!1)=>{let o=await vP(e,t);if(o.type==="mixedContent")return{mixedContent:o.value};try{let n=!t&&yP(o.value);if(n)return n}catch(n){console.error(n)}try{let n=JSON.parse(o.value),r=n.type===ds.excalidrawClipboardWithAPI;if(xP(n))return{elements:n.elements,files:n.files,text:t?JSON.stringify(n.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:o.value}},Kd=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[Oo.png]:e})])}catch(t){if(uP(e))await navigator.clipboard.write([new window.ClipboardItem({[Oo.png]:await e})]);else throw t}},Fo=async(e,t)=>{if(Yd)try{await navigator.clipboard.writeText(e||"");return}catch(o){console.error(o)}try{if(t){if(t.clipboardData?.setData(Oo.text,e||""),t.clipboardData?.getData(Oo.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(o){console.error(o)}if(!TP(e))throw new Error("Error copying to clipboard.")},TP=e=>{e||(e=" ");let t=document.documentElement.getAttribute("dir")==="rtl",o=document.createElement("textarea");o.style.border="0",o.style.padding="0",o.style.margin="0",o.style.position="absolute",o.style[t?"right":"left"]="-9999px";let n=window.pageYOffset||document.documentElement.scrollTop;o.style.top=`${n}px`,o.style.fontSize="12pt",o.setAttribute("readonly",""),o.value=e,document.body.appendChild(o);let r=!1;try{o.select(),o.setSelectionRange(0,o.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return o.remove(),r};var mi=(e,{selectedElementIds:t},o)=>{e=AP(e);let n=o&&Le(e,{selectedElementIds:t}),r=null,i=n?J(e,{selectedElementIds:t},{includeBoundTextElement:!0}):e;return n&&(i.length===1&&PP(i[0])?(r=i[0],i=_P(e,r)):i.length>1&&(i=J(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:r,exportedElements:MP(i)}},pi=async({type:e,data:t,config:o})=>{let n=Object.assign({},o);if(n.padding=n.padding??IP,n.fileHandle=n.fileHandle??null,n.exportingFrame=n.exportingFrame??null,n.name=n.name||CP,t.elements.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let i=Fi({data:{elements:t.elements,appState:{exportBackground:n.exportBackground,exportWithDarkMode:t.appState.exportWithDarkMode,viewBackgroundColor:t.appState.viewBackgroundColor,exportPadding:n.padding,exportScale:t.appState.exportScale,exportEmbedScene:t.appState.exportEmbedScene&&e==="svg"},files:t.files},config:{exportingFrame:n.exportingFrame}});if(e==="svg")return Hu(i.then(a=>new Blob([LP+a.outerHTML],{type:kP.svg})),{description:"Export to SVG",name:n.name,extension:t.appState.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Cw.svg],fileHandle:n.fileHandle});if(e==="clipboard-svg"){let a=await i.then(l=>l.outerHTML);try{await Fo(a)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let r=jn({data:t,config:{canvasBackgroundColor:n.exportBackground?n.viewBackgroundColor:!1,padding:n.padding,theme:t.appState.exportWithDarkMode?"dark":"light",scale:t.appState.exportScale,fit:"none",exportingFrame:n.exportingFrame}});if(e==="png"){let i=wn(r);return t.appState.exportEmbedScene&&(i=i.then(a=>import("./data/image-YVTXQC5H.js").then(({encodePngMetadata:l})=>l({blob:a,metadata:bl(t.elements,t.appState,t.files,"local")})))),Hu(i,{description:"Export to PNG",name:n.name,extension:t.appState.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Cw.png],fileHandle:n.fileHandle})}else if(e==="clipboard")try{let i=wn(r);await Kd(i)}catch(i){throw console.warn(i),i.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):SP&&i.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
|
|
18
18
|
|
|
19
|
-
${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var x2=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=aE(a);if(!a||!lE(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=Li(e,o,!1);return await Ai({type:l,data:{elements:s,appState:o,files:t},config:{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:c}}),{fileHandle:a}};import{Fragment as _C,jsx as Vr,jsxs as DC}from"react/jsx-runtime";var bm=F({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:r,app:n})=>Vr(s2,{label:f("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),E2=F({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=xe(e),i=ze(r,o)?J(r,o):r,a=(l,s,c)=>{let[,,m,d]=nE(l).map(p=>Math.trunc(p*c));return[m+s*2,d+s*2]};return Vr(_C,{children:sc.map(l=>{let[s,c]=a(i,rn,l),m=`${f("imageExportDialog.label.scale")} ${l}x (${s}x${c})`;return Vr(ee,{size:"small",type:"radio",icon:`${l}x`,name:"export-canvas-scale",title:m,"aria-label":m,id:"export-canvas-scale",checked:l===o.exportScale,onChange:()=>t(l)},l)})})}}),xm=F({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Vr(xs,{checked:e.exportBackground,onChange:t=>o(t),children:f("imageExportDialog.label.withBackground")})}),Em=F({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>DC(xs,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[f("imageExportDialog.label.embedScene"),Vr(vo,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:Vr("div",{className:"excalidraw-tooltip-icon",children:Nh})})]})}),An=F({name:"saveToActiveFile",label:"buttons.save",icon:yn,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}=rd(o.fileHandle)?await x2(e,o,r.files,r.getName()):await Qc(e,o,r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):f("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e[T.CTRL_OR_CMD]&&!e.shiftKey}),Na=F({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:yn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await Qc(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:f("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e.shiftKey&&e[T.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Vr(ee,{type:"button",icon:_h,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:Ce().editor.isMobile,hidden:!ma,onClick:()=>e(null),"data-testid":"save-as-button"})}),_i=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 Vu(o,e);return{elements:n,appState:i,files:a,captureUpdate:A.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:A.EVENTUALLY}}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.O}),y2=F({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Vr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Vr(a2,{value:e.exportWithDarkMode?ce.DARK:ce.LIGHT,onChange:t=>{o(t===ce.DARK)},title:f("imageExportDialog.label.darkMode")})})});var v2="{}",ym=F({name:"copyStyles",label:"labels.copyStyles",icon:Fd,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&pt(i)){let a=be(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(v2=JSON.stringify(n)),{appState:{...o,toast:{message:f("toast.copyStyles")}},captureUpdate:A.EVENTUALLY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===ue.C}),vm=F({name:"pasteStyles",label:"labels.pasteStyles",icon:Fd,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(v2),i=n[0],a=n[1];if(!A0(i))return{elements:e,captureUpdate:A.EVENTUALLY};let l=J(e,o,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=i;if(Z(c)&&c.containerId&&(m=a),!m)return c;let d=re(c,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?_0(m.roundness.type,c)?m.roundness:D0(c):null});if(Z(d)){let p=m.fontSize||Sr,u=m.fontFamily||en;d=re(d,{fontSize:p,fontFamily:u,textAlign:m.textAlign||rc,lineHeight:m.lineHeight||Lr(u)});let g=null;d.containerId&&(g=l.find(b=>Z(d)&&b.id===d.containerId)||null),et(d,g,r.scene.getNonDeletedElementsMap())}return d.type==="arrow"&&ke(m)&&(d=re(d,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),ae(c)&&(d=re(d,{roundness:null,backgroundColor:"transparent"})),d}return c}),captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===ue.V});var Oa=(e,o)=>!!(!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(e.activeTool.type!=="custom"&&(e.editingTextElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="lasso"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||J(o,e).length));import{jsx as C2}from"react/jsx-runtime";var w2=F({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:A.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>C2(ee,{type:"button",icon:Kl,"aria-label":f("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),T2=F({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>C2(ee,{visible:Oa(o,xe(e)),type:"button",icon:Dh,"aria-label":f("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),_n=F({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:Sh,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:A.EVENTUALLY}),keyTest:e=>e.key===T.QUESTION_MARK});import{jsx as Ba}from"react/jsx-runtime";var PC=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&na(n,t),!0))return!0}return!1},I2=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!PC(r)&&!Fc(r)},wm=F({name:"group",label:"labels.group",icon:e=>Ba(Nd,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=ux(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let i=$o(o);if(i.length===1){let x=i[0],E=new Set(Fe(e,x).map(v=>v.id)),w=new Set(n.map(v=>v.id));if(new Set([...Array.from(E),...Array.from(w)]).size===E.size)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&mx(n).forEach((E,w)=>{Oc(E,r.scene.getNonDeletedElementsMap())});let s=io(),c=te(n);a=a.map(x=>c.get(x.id)?re(x,{groupIds:Ix(x.groupIds,s,o.editingGroupId)}):x);let m=Fe(a,s),d=m[m.length-1],p=a.lastIndexOf(d),u=a.slice(p+1),g=a.slice(0,p).filter(x=>!na(x,s)),b=Gt([...g,...m,...u],te(m));return{appState:{...o,...yx(s,{...o,selectedGroupIds:{}},xe(a))},elements:b,captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>I2(e,o,r),keyTest:e=>!e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ba(ee,{hidden:!I2(e,o,r),type:"button",icon:Ba(Nd,{theme:o.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${R("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:ze(xe(e),o)})}),Tm=F({name:"ungroup",label:"labels.ungroup",icon:e=>Ba(Od,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=$o(o),i=te(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{_e(p)&&l.push(p.id);let u=Sx(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:re(p,{groupIds:u})});let s=lt(o,xe(a),o,null),c=r.scene.getSelectedElements(o),m=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return px(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=Bc(a,oa(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,g])=>(g&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G.toUpperCase(),predicate:(e,o)=>$o(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>Ba(ee,{type:"button",hidden:$o(o).length===0,icon:Ba(Od,{theme:o.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${R("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:ze(xe(e),o)})});import BC from"clsx";var Cm=(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 RC(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 Di=(e,o)=>`hsl(${Math.abs(RC(o?.id||e))%37*10}, 100%, 83%)`,S2=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},k2=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,c=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let m=11,d=14,p=l<0||l>r-m||s<0||s>n-d;l=Math.max(l,0),l=Math.min(l,r-m),s=Math.max(s,0),s=Math.min(s,n-d);let u=Di(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let g=o.remotePointerUserStates.get(i),b=p||g==="idle"||g==="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===ce.DARK?"#2f6330":Db,E=c?.isSpeaking;E&&(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=Mo,e.strokeStyle=Mo,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 w=o.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let y=(E?l+0:l)+m/2,v=(E?s+0:s)+d+2,C=5,S=3,_=e.measureText(w),L=_.actualBoundingBoxDescent+_.actualBoundingBoxAscent,N=Math.max(L,12),P=y-1,z=v-1,W=_.width+2+C*2+2,U=N+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,z,W,U,8),e.fillStyle=u,e.fill(),e.strokeStyle=Mo,e.stroke(),E&&(e.beginPath(),e.roundRect(P-2,z-2,W+4,U+4,8),e.strokeStyle=x,e.stroke())):Cm(e,P,z,W,U,8,Mo),e.fillStyle=hl,e.fillText(w,y+C+1,v+S+_.actualBoundingBoxAscent+Math.floor((N-L)/2)+2),E){e.fillStyle=x;let q=8,H=8,V=5;e.fillRect(P+W+H,z+(U/2-q/2),2,q),e.fillRect(P+W+H+V,z+(U/2-q*2/2),2,q*2),e.fillRect(P+W+H+V*2,z+(U/2-q/2),2,q)}}e.restore(),e.closePath()}};import NC from"clsx";import{useState as OC}from"react";import{jsx as M2}from"react/jsx-runtime";var Mf=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=S2(t),[a,l]=OC(!1),s=!a&&r,c=s?void 0:{background:e};return M2("div",{className:NC("Avatar",n),style:c,onClick:o,children:s?M2("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as br,jsxs as Im}from"react/jsx-runtime";var L2=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:A.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:A.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=o,l=Di(r,n),s=BC({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),c=n.isInCall?n.isSpeaking?Im("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[br("div",{}),br("div",{}),br("div",{})]}):n.isMuted?br("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:Rg}):br("div",{title:f("userList.hint.inCall"),children:Pg}):null;return i?Im("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[br(Mf,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),br("div",{className:"UserList__collaborator-name",children:n.username}),Im("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&br("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:Ii}),c]})]}):Im("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[br(Mf,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&br("div",{className:"UserList__collaborator-status-icon",children:c})]})}});var Sm=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 mc)if(n.some(a=>a.type===i))return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:io(),status:"unpublished",elements:n.map(xo),created:Date.now()},...i])).then(()=>({captureUpdate:A.EVENTUALLY,appState:{...o,toast:{message:f("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});var A2=(e,o,t,r)=>{let n=mi(e,o),i=Dt(e);return n.flatMap(a=>{let l=zC(a,i,t);return a.map(s=>{let c=B(s,{x:s.x+l.x,y:s.y+l.y});return at(s,r.getNonDeletedElementsMap(),{simultaneouslyUpdated:a}),c})})},zC=(e,o,{axis:t,position:r})=>{let n=Dt(e),[i,a]=t==="x"?["minX","maxX"]:["minY","maxY"],l={x:0,y:0};return r==="start"?{...l,[t]:o[i]-n[i]}:r==="end"?{...l,[t]:o[a]-n[a]}:{...l,[t]:(o[i]+o[a])/2-(n[i]+n[a])/2}};import{jsx as Fa}from"react/jsx-runtime";var mo=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ae(r))},za=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=te(e),a=A2(n,i,r,t.scene),l=te(a);return sr(e.map(s=>l.get(s.id)||s),o,t)},_2=F({name:"alignTop",label:"labels.alignTop",icon:Ld,trackEvent:{category:"element"},predicate:(e,o,t,r)=>mo(o,r),perform:(e,o,t,r)=>({appState:o,elements:za(e,o,r,{position:"start",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Fa(ee,{hidden:!mo(o,r),type:"button",icon:Ld,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${R("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:ze(xe(e),o)})}),D2=F({name:"alignBottom",label:"labels.alignBottom",icon:Ad,trackEvent:{category:"element"},predicate:(e,o,t,r)=>mo(o,r),perform:(e,o,t,r)=>({appState:o,elements:za(e,o,r,{position:"end",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Fa(ee,{hidden:!mo(o,r),type:"button",icon:Ad,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${R("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:ze(xe(e),o)})}),P2=F({name:"alignLeft",label:"labels.alignLeft",icon:_d,trackEvent:{category:"element"},predicate:(e,o,t,r)=>mo(o,r),perform:(e,o,t,r)=>({appState:o,elements:za(e,o,r,{position:"start",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Fa(ee,{hidden:!mo(o,r),type:"button",icon:_d,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${R("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:ze(xe(e),o)})}),R2=F({name:"alignRight",label:"labels.alignRight",icon:Dd,trackEvent:{category:"element"},predicate:(e,o,t,r)=>mo(o,r),perform:(e,o,t,r)=>({appState:o,elements:za(e,o,r,{position:"end",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Fa(ee,{hidden:!mo(o,r),type:"button",icon:Dd,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${R("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:ze(xe(e),o)})}),N2=F({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Pd,trackEvent:{category:"element"},predicate:(e,o,t,r)=>mo(o,r),perform:(e,o,t,r)=>({appState:o,elements:za(e,o,r,{position:"center",axis:"y"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Fa(ee,{hidden:!mo(o,r),type:"button",icon:Pd,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:ze(xe(e),o)})}),O2=F({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Rd,trackEvent:{category:"element"},predicate:(e,o,t,r)=>mo(o,r),perform:(e,o,t,r)=>({appState:o,elements:za(e,o,r,{position:"center",axis:"x"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Fa(ee,{hidden:!mo(o,r),type:"button",icon:Rd,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:ze(xe(e),o)})});var B2=(e,o,t)=>{let[r,n,i,a]=t.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],l=Dt(e),s=mi(e,o).map(p=>[p,Dt(p)]).sort((p,u)=>p[1][n]-u[1][n]),c=0;for(let p of s)c+=p[1][a];let m=(l[a]-c)/(s.length-1);if(m<0){let p=s.findIndex(x=>x[1][r]===l[r]),u=s.findIndex(x=>x[1][i]===l[i]),g=(s[u][1][n]-s[p][1][n])/(s.length-1),b=s[p][1][n];return s.flatMap(([x,E],w)=>{let y={x:0,y:0};return w!==p&&w!==u&&(b+=g,y[t.axis]=b-E[n]),x.map(v=>re(v,{x:v.x+y.x,y:v.y+y.y}))})}let d=l[r];return s.flatMap(([p,u])=>{let g={x:0,y:0};return g[t.axis]=d-u[r],d+=m,d+=u[a],p.map(b=>re(b,{x:b.x+g.x,y:b.y+g.y}))})};import{jsx as G2}from"react/jsx-runtime";var z2=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ae(r))},F2=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=B2(n,t.scene.getNonDeletedElementsMap(),r),a=te(i);return sr(e.map(l=>a.get(l.id)||l),o,t)},H2=F({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:F2(e,o,r,{space:"between",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===ue.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>G2(ee,{hidden:!z2(o,r),type:"button",icon:Bh,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${R("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:ze(xe(e),o)})}),U2=F({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:F2(e,o,r,{space:"between",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===ue.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>G2(ee,{hidden:!z2(o,r),type:"button",icon:zh,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${R("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:ze(xe(e),o)})});var km=F({name:"flipHorizontal",label:"labels.flipHorizontal",icon:zg,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:sr(V2(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ue.H}),Mm=F({name:"flipVertical",label:"labels.flipVertical",icon:Bg,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:sr(V2(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===ue.V&&!e[T.CTRL_OR_CMD]}),V2=(e,o,t,r,n)=>{let i=J(xe(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=FC(i,o,t,r,n),l=te(a);return e.map(s=>l.get(s.id)||s)},FC=(e,o,t,r,n)=>{if(e.every(u=>ke(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let g=u;return re(g,{startArrowhead:g.endArrowhead,endArrowhead:g.startArrowhead})});let{midX:i,midY:a}=Dt(e);th(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,xo(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),si(e.filter(le),o,n.scene.getNonDeletedElements(),n.scene,li(t),[],t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,g)=>oe(g)?{...u,elbowArrows:u.elbowArrows.concat(g)}:{...u,otherElements:u.otherElements.concat(g)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:m}=Dt(e),[d,p]=[i-c,a-m];return s.forEach(u=>B(u,{x:u.x+d,y:u.y+p})),l.forEach(u=>B(u,{x:u.x+d,y:u.y+p})),e};var Pi=F({name:"copy",label:"labels.copy",icon:ba,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await hm(n,r.files,t)}catch(i){return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),Lf=F({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await b2()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),Ir?{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(g2({types:n}))}catch(i){return console.error(i),{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),vs=F({name:"cut",label:"labels.cut",icon:wg,trackEvent:{category:"element"},perform:(e,o,t,r)=>(Pi.perform(e,o,t,r),Ca.perform(e,o,null,r)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.X}),ws=F({name:"copyAsSvg",label:"labels.copyAsSvg",icon:Fg,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:A.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=Li(e,o,!0);try{await Ai({type:"clipboard-svg",data:{elements:n,appState:o,files:r.files},config:{...o,exportingFrame:i,name:r.getName()}});let a=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:o.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:A.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:A.EVENTUALLY}}},predicate:e=>um&&e.length>0,keywords:["svg","clipboard","copy"]}),Ts=F({name:"copyAsPng",label:"labels.copyAsPng",icon:Hg,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:A.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Li(e,o,!0);try{return await Ai({type:"clipboard",data:{elements:i,appState:o,files:r.files},config:{...o,exportingFrame:a,name:o.name||r.getName()}}),{appState:{...o,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:n.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:o.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:A.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:A.EVENTUALLY}}},predicate:e=>Ra&&e.length>0,keyTest:e=>e.code===ue.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Cs=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{Qo(yu(n))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>um&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(Z),keywords:["text","clipboard","copy"]});var Is=F({name:"gridMode",icon:Wg,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:A.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.code===ue.QUOTE});var Ri=F({name:"zenMode",label:"buttons.zenMode",icon:Gg,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:A.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===ue.Z});var Lm=F({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Ug,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:A.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===ue.S});var Ni=F({name:"stats",label:"stats.fullTitle",icon:Og,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:A.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===ue.SLASH});var Am=F({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>pt(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=be(a,i);if(l){let{width:s,height:c}=Ut(l.originalText,Je(l),l.lineHeight),m=Y0(a.id);V0(a.id);let{x:d,y:p}=Lc(a,l,i);B(l,{containerId:null,width:s,height:c,text:l.originalText,x:d,y:p}),B(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:A.IMMEDIATELY}}}),_m=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=Z(n[0])||Z(n[1]),a;if(Rr(n[0])?a=n[0]:Rr(n[1])&&(a=n[1]),i&&a&&be(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;Z(n[0])&&Rr(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),B(i,{containerId:a.id,verticalAlign:to.MIDDLE,textAlign:fl.CENTER,autoResize:!0,angle:ke(a)?0:a?.angle??0}),B(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return et(i,a,r.scene.getNonDeletedElementsMap()),Sl(a.id,l),{elements:HC(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:A.IMMEDIATELY}}}),HC=(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),Gt(r,te([o,t])),r},UC=(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),Gt(r,te([o,t])),r},Y2=F({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>Z(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(Z(l)){let s=Vt({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:$i("rectangle")?oo.ADAPTIVE_RADIUS:oo.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-iu,y:l.y-iu,width:Qi(l.width,"rectangle"),height:Qi(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(d=>d.type==="arrow").map(d=>d.id);i.filter(d=>c.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)&&B(d,{startBinding:p,endBinding:u},!1)})}B(l,{containerId:s.id,verticalAlign:to.MIDDLE,boundElements:null,textAlign:fl.CENTER,autoResize:!0},!1),et(l,s,r.scene.getNonDeletedElementsMap()),i=UC([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:A.IMMEDIATELY}}});import GC from"clsx";import{useCallback as W2,useEffect as K2,useLayoutEffect as VC,useRef as YC,useState as WC}from"react";import{jsx as Ha,jsxs as Z2}from"react/jsx-runtime";var Df=380,KC=42,Af=5,X2=85,ZC=500,_f=!1,Dm=new Map,$2=({element:e,elementsMap:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=ur(),l=hr(),s=Ce(),c=e.link||"",[m,d]=WC(c),p=YC(null),u=a.showHyperlinkPopup==="editor",g=W2(()=>{if(!p.current)return;let y=Zo(p.current.value)||null;if(!e.link&&y&&ye("hyperlink","create"),Ht(e)){if(a.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!y){B(e,{link:null}),i(e,!1);return}if(!ca(y,l.validateEmbeddable))y&&n({message:f("toast.unableToEmbed"),closable:!0}),e.link&&Dm.set(e.id,e.link),B(e,{link:y}),i(e,!1);else{let{width:v,height:C}=e,S=ui(y);S?.error instanceof URIError&&n({message:f("toast.unrecognizedLinkFormat"),closable:!0});let _=S?S.intrinsicSize.w/S.intrinsicSize.h:1,L=Dm.get(e.id)!==e.link;B(e,{...L?{width:S?.type==="video"?v>C?v:C*_:v,height:S?.type==="video"&&v>C?v/_:C}:{},link:y}),i(e,!0),Dm.has(e.id)&&Dm.delete(e.id)}}else B(e,{link:y})},[e,n,l.validateEmbeddable,a.activeEmbeddable,t,i]);VC(()=>()=>{g()},[g]),K2(()=>{u&&p?.current&&!(s.viewport.isMobile||s.isTouchScreen)&&p.current.select()},[u,s.viewport.isMobile,s.isTouchScreen]),K2(()=>{let y=null,v=C=>{if(u)return;y&&clearTimeout(y),$C(e,o,a,M(C.clientX,C.clientY))&&(y=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},ZC))};return window.addEventListener("pointermove",v,!1),()=>{window.removeEventListener("pointermove",v,!1),y&&clearTimeout(y)}},[a,e,u,t,o]);let b=W2(()=>{ye("hyperlink","delete"),B(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e]),x=()=>{ye("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y:w}=j2(e,a,o);return a.contextMenu||a.selectedElementsAreBeingDragged||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:Z2("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${w}px`,left:`${E}px`,width:Df,padding:Af},children:[u?Ha("input",{className:GC("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:p,value:m,onChange:y=>d(y.target.value),autoFocus:!0,onKeyDown:y=>{y.stopPropagation(),y[T.CTRL_OR_CMD]&&y.key===T.K&&y.preventDefault(),(y.key===T.ENTER||y.key===T.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?Ha("a",{href:Zo(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:Cc(e.link)?"_self":"_blank",onClick:y=>{if(e.link&&r){let v=wc("excalidraw-link",y.nativeEvent);r({...e,link:Zo(e.link)},v),v.defaultPrevented&&y.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Ha("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),Z2("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!u&&Ha(ee,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:x,className:"excalidraw-hyperlinkContainer--edit",icon:Ur}),Ha(ee,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:is}),c&&!Ht(e)&&Ha(ee,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:lo})]})]})},j2=(e,o,t)=>{let[r,n]=Ke(e,t),{x:i,y:a}=Ft({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-Df/2,s=a-o.offsetTop-X2;return{x:l,y:s}},Pf=(e,o)=>{let t=J(e,o);return Ht(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Ss=null,q2=(e,o,t)=>{Ss&&clearTimeout(Ss),Ss=window.setTimeout(()=>XC(e,o,t),Fb)},XC=(e,o,t)=>{if(!e.link)return;let r=Da();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=hi(e.link)?f("labels.link.goToElement"):e.link;let[n,i,a,l]=Ke(e,t),[s,c,m,d]=eE([n,i,a,l],e.angle,o),p=Ft({sceneX:s,sceneY:c},o);If(r,{left:p.x,top:p.y,width:m,height:d},"top"),ye("hyperlink","tooltip","link-icon"),_f=!0},Rf=()=>{Ss&&clearTimeout(Ss),_f&&(_f=!1,Da().classList.remove("excalidraw-tooltip--visible"))},$C=(e,o,t,[r,n])=>{let{x:i,y:a}=je({clientX:r,clientY:n},t),l=15/t.zoom.value;if(R0(i,a,e,o))return!1;let[s,c,m]=Ke(e,o);if(i>=s&&i<=m&&a>=c-X2&&a<=c)return!1;let{x:d,y:p}=j2(e,t,o);return!(r>=d-l&&r<=d+Df+Af*2+l&&n>=p-l&&n<=p+l+Af*2+KC)};import{jsx as jC}from"react/jsx-runtime";var Ua=F({name:"hyperlink",label:(e,o)=>Pf(e,o),icon:ya,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:A.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.K,predicate:(e,o)=>J(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=J(e,o);return jC(ee,{type:"button",icon:ya,"aria-label":f(Pf(e,o)),title:`${Ht(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${R("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});var Nf=e=>e.every(o=>!o.locked),Pm=F({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return r.length===1&&!ae(r[0])?r[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":Nf(r)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,o)=>{let t=J(o,e);return Nf(t)?yi:En},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=Nf(n),a=te(n);return{elements:e.map(l=>a.has(l.id)?re(l,{locked:i}):l),appState:{...o,selectedLinearElement:i?null:o.selectedLinearElement},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===T.L&&e[T.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),J2=F({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:En,predicate:(e,o)=>J(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(r=>r.locked);return{elements:e.map(r=>r.locked?re(r,{locked:!1}):r),appState:{...o,selectedElementIds:Object.fromEntries(t.map(r=>[r.id,!0]))},captureUpdate:A.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import ow from"clsx";import GS from"fuzzy";import{useEffect as Qm,useRef as VS,useState as Jm}from"react";var Rm=F({name:"copyElementLink",label:"labels.copyElementLink",icon:Ti,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=J(e,o);try{if(window.location){let i=jc(n,o);return i?(await Qo(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):$c(i.id,i.type)),{appState:{toast:{message:f("toast.elementLinkCopied"),closable:!0}},captureUpdate:A.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:A.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:A.EVENTUALLY}},predicate:(e,o)=>qc(J(e,o))}),Q2=F({name:"linkToElement",label:"labels.linkToElement",icon:is,perform:(e,o,t,r)=>{let n=J(e,o);return n.length!==1||!qc(n)?{elements:e,appState:o,app:r,captureUpdate:A.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:J(e,o)[0].id}},captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=J(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&qc(n)},trackEvent:!1});var qC={toggleTheme:[R("Shift+Alt+D")],saveScene:[R("CtrlOrCmd+S")],loadScene:[R("CtrlOrCmd+O")],clearCanvas:[R("CtrlOrCmd+Delete")],imageExport:[R("CtrlOrCmd+Shift+E")],commandPalette:[R("CtrlOrCmd+/"),R("CtrlOrCmd+Shift+P")],cut:[R("CtrlOrCmd+X")],copy:[R("CtrlOrCmd+C")],paste:[R("CtrlOrCmd+V")],copyStyles:[R("CtrlOrCmd+Alt+C")],pasteStyles:[R("CtrlOrCmd+Alt+V")],selectAll:[R("CtrlOrCmd+A")],deleteSelectedElements:[R("Delete")],duplicateSelection:[R("CtrlOrCmd+D"),R(`Alt+${f("helpDialog.drag")}`)],sendBackward:[R("CtrlOrCmd+[")],bringForward:[R("CtrlOrCmd+]")],sendToBack:[Vo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")],bringToFront:[Vo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")],copyAsPng:[R("Shift+Alt+C")],group:[R("CtrlOrCmd+G")],ungroup:[R("CtrlOrCmd+Shift+G")],gridMode:[R("CtrlOrCmd+'")],zenMode:[R("Alt+Z")],objectsSnapMode:[R("Alt+S")],stats:[R("Alt+/")],addToLibrary:[],flipHorizontal:[R("Shift+H")],flipVertical:[R("Shift+V")],viewMode:[R("Alt+R")],hyperlink:[R("CtrlOrCmd+K")],toggleElementLock:[R("CtrlOrCmd+Shift+L")],resetZoom:[R("CtrlOrCmd+0")],zoomOut:[R("CtrlOrCmd+-")],zoomIn:[R("CtrlOrCmd++")],zoomToFitSelection:[R("Shift+3")],zoomToFit:[R("Shift+1")],zoomToFitSelectionInViewport:[R("Shift+2")],toggleEraserTool:[R("E")],toggleHandTool:[R("H")],setFrameAsActiveTool:[R("F")],saveFileToDisk:[R("CtrlOrCmd+S")],saveToActiveFile:[R("CtrlOrCmd+S")],toggleShortcuts:[R("?")],searchMenu:[R("CtrlOrCmd+F")],wrapSelectionInFrame:[]},ct=(e,o=0)=>{let t=qC[e];return t&&t.length>0?t[o]||t[0]:""};var JC="\\u0300-\\u036f",QC="\\ufe20-\\ufe2f",eI="\\u20d0-\\u20ff",tI=JC+QC+eI,oI=`[${tI}]`,rI=RegExp(oI,"g"),nI=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,iI={\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"},Of=e=>e.replace(nI,o=>iI[o]||o).replace(rI,"");import TS from"clsx";import{useEffect as CS,useState as IS}from"react";import{useCallback as aI,useState as lI}from"react";var ev=()=>{let[e,o]=lI(null),t=aI(r=>o(r),[]);return[e,t]};import{useState as Uv,useCallback as Xf,useMemo as Gv,useEffect as zv,memo as Vv,useRef as fS}from"react";import{useEffect as nv,useRef as iv}from"react";var Nm=async({data:e,config:o})=>fn({data:e,config:o}),tv=async({data:e,config:o})=>{let{mimeType:t=ge.png,quality:r}=o||{};t===ge.png&&typeof r=="number"&&console.warn(`"quality" will be ignored for "${ge.png}" mimeType`),t==="image/jpg"&&(t=ge.jpg),t===ge.jpg&&o?.canvasBackgroundColor&&(console.warn(`Defaulting "exportBackground" to "true" for "${ge.jpg}" mimeType`),o={...o,canvasBackgroundColor:e.appState?.viewBackgroundColor||Mo});let n=await fn({data:e,config:o});return r=r||(/image\/jpe?g/.test(t)?.92:.8),new Promise((i,a)=>{n.toBlob(async l=>{if(!l)return a(new Error("couldn't export to blob"));l&&t===ge.png&&e.appState?.exportEmbedScene&&(l=await iE({blob:l,metadata:Ol(e.elements,e.appState,e.files||{},"local")})),i(l)},t,r)})},Ga=async({data:e,config:o})=>{let{elements:t,appState:r}=zl({...e,files:e.files||{}},null,null),n={...r,exportPadding:o?.padding},i=xe(t),a=e.files||{};return pa({data:{elements:i,appState:n,files:a},config:{exportingFrame:o?.exportingFrame,renderEmbeddables:o?.renderEmbeddables,skipInliningFonts:o?.skipInliningFonts,reuseImages:o?.reuseImages}})},sI=async({type:e,data:o,config:t})=>{if(e==="svg"){let r=await Ga({data:o,config:t});await Qo(r.outerHTML)}else if(e==="png")await fm(tv({data:o,config:t}));else if(e==="json")await hm(o.elements,o.files);else throw new Error("Invalid export type")};import{useEffect as cI,useState as dI}from"react";var Bf=De(new Map),ov=async e=>await Ga({data:{elements:e,appState:{exportBackground:!1,viewBackgroundColor:Mr.white},files:null},config:{renderEmbeddables:!1,skipInliningFonts:!0}}),rv=(e,o,t)=>{let[r,n]=dI();return cI(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await ov(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await ov(o);n(i)})()},[e,o,t,n]),r},Om=()=>{let[e]=we(Bf);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var mI=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],lv=new Pt,Pn=De({status:"loaded",isInitialized:!1,libraryItems:[]}),ks=e=>no(e),pI=(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)),sv=(e,o)=>{let t=[];for(let r of o)pI(e,r)&&t.push(r);return[...t,...e]},cv=(e,o)=>{let t=te(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=te(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},zf=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",ks(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)kt.set(Pn,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{kt.set(Pn,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=ks(this.currLibraryItems);let t=ks(this.currLibraryItems);this.app.props.onLibraryChange?.(t),lv.trigger(cv(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],kt.set(Bf,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(ks(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:At.name,tab:bl}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await Zu(s,i):c=Fl(s,i),!t||window.confirm(f("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),a(r?sv(this.currLibraryItems,c):c)):l(new da)}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=ks(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}},Hf=zf,Fm=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:E}=Dt(x.elements);return Math.max(b,E)},0),i=u=>{let g=0,b=0,x=0;for(let E of e){if(g%t===0&&(b=0),b===u){let{width:w}=Dt(E.elements);x=Math.max(x,w)}g++,b++}return x},a=0,l=0,s=0,c=0,m=0,d=0,p=0;for(let u of e){m&&m%t===0&&(l+=s+50,a=0,d=0,p++),d===0&&(s=n(p)),c=i(d);let{minX:g,minY:b,width:x,height:E}=Dt(u.elements),w=(c-x)/2,y=(s-E)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+w-g,y:v.y+l+y-b}))),a+=c+50,m++,d++}return r},uI=(e,o=mI)=>{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}"`)},Ff=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(lc.addLibrary)||new URLSearchParams(window.location.search).get(ac.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},Dn=class Dn{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(Fl(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?Dn.queue.push(n):n()}getLibraryItems(o){return Dn.getLibraryItems(this.adapter,o,!1)}};I(Dn,"queue",new i0),I(Dn,"run",async(o,t)=>{let r=new Dn(o);return Dn.queue.push(()=>t(r))});var Va=Dn,Ms=0,Bm=0,zm=e=>Su(e.map(o=>`${o.id}:${Iu(o.elements)}`).sort().join()),av=async(e,o)=>{try{return Bm++,await Va.run(e,async t=>{let r=te(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=zm(i);return a!==Ms&&await e.save({libraryItems:i}),Ms=a,i})}finally{Bm--}},hI=e=>{let{excalidrawAPI:o}=e,t=iv(e);t.current=e;let r=iv(!1);nv(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(d,p)=>{try{l=decodeURIComponent(l),l=Ic(l),uI(l,t.current.validateLibraryUrl);let g=await(await fetch(l)).blob();d(g)}catch(u){p(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(d=>{window.addEventListener("focus",()=>d(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(d){throw o.updateScene({appState:{errorMessage:d.message}}),d}finally{if(window.location.hash.includes(lc.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(lc.addLibrary),window.history.replaceState({},ml,`#${d.toString()}`)}else if(window.location.search.includes(ac.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(ac.addLibrary),window.history.replaceState({},ml,`?${d.toString()}`)}}},i=l=>{l.preventDefault();let s=Ff();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Ff();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,c=g0();s?c.resolve(xu(s.load).then(async m=>{let d=null;try{if(!m)return Va.getLibraryItems(l,"load");d=Fl(m.libraryItems||[],"published");let p=await av(l,cv([],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(m=>(console.error(`error during library migration: ${m.message}`),Va.getLibraryItems(l,"load")))):c.resolve(xu(Va.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:c.then(m=>{let d=m||[];return Ms=zm(d),d}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[o]),nv(()=>{let n=lv.on(async(a,l)=>{let s=r.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&Ms!==zm(l)&&await av(c,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:f("errors.saveLibraryError")}})}}),i=a=>{Bm&&x0(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),Ms=0,Bm=0}},[])};import bI from"clsx";import{jsx as fI}from"react/jsx-runtime";var gI=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return fI("a",{className:"library-menu-browse-button",href:`${k.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${cc.excalidrawLibrary}`,target:"_excalidraw_libraries",children:f("labels.libraries")})},dv=gI;import{jsx as xI,jsxs as EI}from"react/jsx-runtime";var Hm=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>EI("div",{className:bI("library-menu-control-buttons",i),style:r,children:[xI(dv,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as Ka,useEffect as mS,useMemo as Ov,useRef as pS,useState as uS}from"react";import yI from"lodash.throttle";import{useEffect as vI}from"react";var wI=De(0),mv=e=>{let[o,t]=we(wI);return vI(()=>{let{current:r}=e;if(!r)return;let n=yI(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import $I from"clsx";import{useCallback as jI,useState as Vf}from"react";import{flushSync as pv}from"react-dom";import TI from"clsx";import{jsx as Um,jsxs as II}from"react/jsx-runtime";var CI=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return II("button",{className:TI("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&Um("div",{style:a?{visibility:"hidden"}:{},children:r}),Um("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Um("div",{style:{position:"absolute",inset:0},children:Um(Lt,{})})]})},Yr=CI;import{jsx as uv,jsxs as hv}from"react/jsx-runtime";var SI=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=f("buttons.confirm"),cancelText:i=f("buttons.cancel"),className:a="",...l}=e,s=Ie(),c=xn(Ya),{container:m}=gt();return hv(dt,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,hv("div",{className:"confirm-dialog-buttons",children:[uv(Yr,{label:i,onClick:()=>{s({openMenu:null}),c(!1),pv(()=>{t()}),m?.focus()}}),uv(Yr,{label:n,onClick:()=>{s({openMenu:null}),c(!1),pv(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},Gm=SI;import fv from"open-color";import{useCallback as PI,useEffect as Gf,useRef as gv,useState as Uf}from"react";var Bo=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(Bo,"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(Bo,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Vm from"react";var kI=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,MI=/{{([\w-]+)}}/,LI=/<([\w-]+)>/,AI=/<\/([\w-]+)>/,_I=(e,o)=>{let t=[{name:"",children:[]}];return e.split(kI).filter(Boolean).forEach(r=>{let n=r.match(LI),i=r.match(AI),a=r.match(MI);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(),c=Vm.createElement(Vm.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(c))}else console.warn(`Trans: unexpected end tag ${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},DI=({i18nKey:e,children:o,...t})=>{let{t:r}=ut();return Vm.createElement(Vm.Fragment,{},..._I(r(e),t))},Zt=DI;import{jsx as Te,jsxs as Nt}from"react/jsx-runtime";var RI=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=h0(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=Mo,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let m=await Nm({data:{elements:c.elements,files:null},config:{maxWidthOrHeight:128}}),{width:d,height:p}=m,u=Math.floor(s/6)*(128+r*2),g=s%6*(128+r*2);l.drawImage(m,g+(128-d)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=fv.gray[4],l.strokeRect(g+r/2,u+r/2,128+r,128+r)}return await Hl(new File([await zr(a)],"preview",{type:ge.png}),{outputType:ge.jpg,maxWidthOrHeight:5e3})},NI=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=gv(null),a=gv(null);return Gf(()=>{let l=i.current;l&&(async()=>{let s=await Ga({data:{elements:e.elements,appState:{...o,viewBackgroundColor:Mo,exportBackground:!0},files:null},config:{skipInliningFonts:!0}});l.innerHTML=s.outerHTML})()},[e.elements,o]),Nt("div",{className:"single-library-item",children:[e.status==="published"&&Te("span",{className:"single-library-item-status",children:f("labels.statusPublished")}),Te("div",{ref:i,className:"single-library-item__svg"}),Te(ee,{"aria-label":f("buttons.remove"),type:"button",icon:Eo,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:f("buttons.remove")}),Nt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[Nt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[Nt("div",{style:{padding:"0.5em 0"},children:[Te("span",{style:{fontWeight:500,color:fv.gray[6]},children:f("publishDialog.itemName")}),Te("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Te("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),Te("span",{className:"error",children:e.error})]})]})},OI=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Uf({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=Uf(!1);Gf(()=>{let y=Bo.get(nn.PUBLISH_LIBRARY);y&&s(y)},[]);let[d,p]=Uf(o.slice());Gf(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},g=async y=>{y.preventDefault(),m(!0);let v=[],C=!1;if(d.forEach(z=>{let W="";z.name||(W=f("publishDialog.errors.required"),C=!0),v.push({...z,error:W})}),C){p(v),m(!1);return}let S=await RI(d),_={type:on.excalidrawLibrary,version:cc.excalidrawLibrary,source:Rb,libraryItems:d},L=JSON.stringify(_,null,2),N=new Blob([L],{type:"application/json"}),P=new FormData;P.append("excalidrawLib",N),P.append("previewImage",S),P.append("previewImageType",S.type),P.append("title",l.name),P.append("authorName",l.authorName),P.append("githubHandle",l.githubHandle),P.append("name",l.name),P.append("description",l.description),P.append("twitterHandle",l.twitterHandle),P.append("website",l.website),fetch(`${k.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(z=>z.ok?z.json().then(({url:W})=>{Bo.delete(nn.PUBLISH_LIBRARY),r({url:W,authorName:l.authorName,items:d})}):z.json().catch(()=>{throw new Error(z.statusText||"something went wrong")}).then(W=>{throw new Error(W.message||z.statusText||"something went wrong")}),z=>{console.error(z),n(z),m(!1)}).catch(z=>{console.error(z),n(z),m(!1)})},b=()=>{let y=[];return d.forEach((v,C)=>{y.push(Te("div",{className:"single-library-item-wrapper",children:Te(NI,{libItem:v,appState:t,index:C,onChange:(S,_)=>{let L=d.slice();L[_].name=S,p(L)},onRemove:a})},C))}),Te("div",{className:"selected-library-items",children:y})},x=PI(()=>{i(d),Bo.set(nn.PUBLISH_LIBRARY,l),e()},[d,e,i,l]),E=!!o.length,w=o.some(y=>y.status==="published");return Te(dt,{onCloseRequest:x,title:f("publishDialog.title"),className:"publish-library",children:E?Nt("form",{onSubmit:g,children:[Te("div",{className:"publish-library-note",children:Te(Zt,{i18nKey:"publishDialog.noteDescription",link:y=>Te("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:y})})}),Te("span",{className:"publish-library-note",children:Te(Zt,{i18nKey:"publishDialog.noteGuidelines",link:y=>Te("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),Te("div",{className:"publish-library-note",children:f("publishDialog.noteItems")}),w&&Te("span",{className:"publish-library-note publish-library-warning",children:f("publishDialog.republishWarning")}),b(),Nt("div",{className:"publish-library__fields",children:[Nt("label",{children:[Nt("div",{children:[Te("span",{children:f("publishDialog.libraryName")}),Te("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Te("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:f("publishDialog.placeholder.libraryName")})]}),Nt("label",{style:{alignItems:"flex-start"},children:[Nt("div",{children:[Te("span",{children:f("publishDialog.libraryDesc")}),Te("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Te("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:f("publishDialog.placeholder.libraryDesc")})]}),Nt("label",{children:[Nt("div",{children:[Te("span",{children:f("publishDialog.authorName")}),Te("span",{"aria-hidden":"true",className:"required",children:"*"})]}),Te("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:f("publishDialog.placeholder.authorName")})]}),Nt("label",{children:[Te("span",{children:f("publishDialog.githubUsername")}),Te("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:f("publishDialog.placeholder.githubHandle")})]}),Nt("label",{children:[Te("span",{children:f("publishDialog.twitterUsername")}),Te("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:f("publishDialog.placeholder.twitterHandle")})]}),Nt("label",{children:[Te("span",{children:f("publishDialog.website")}),Te("input",{type:"text",name:"website",pattern:"https?://.+",title:f("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:f("publishDialog.placeholder.website")})]}),Te("span",{className:"publish-library-note",children:Te(Zt,{i18nKey:"publishDialog.noteLicense",link:y=>Te("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),Nt("div",{className:"publish-library__buttons",children:[Te(Yr,{label:f("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),Te(Yr,{type:"submit",label:f("buttons.submit"),actionType:"primary",isLoading:c})]})]}):Te("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:f("publishDialog.atleastOneLibItem")})})},bv=OI;import FI from"clsx";import{useEffect as HI,useRef as UI}from"react";import{forwardRef as xv}from"react";import Ev from"clsx";import{jsx as yv}from"react/jsx-runtime";var BI=xv(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>yv("div",{className:Ev("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),zI=xv(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>yv("div",{className:Ev("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...i},ref:a,children:e})),It={Row:BI,Col:zI};import{jsx as Ym}from"react/jsx-runtime";var vv=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=Ce(),a=UI(null),l=wn({onClickOutside:o});Ia(a,()=>{l.onClickOutside?.()}),HI(()=>{let c=d=>{d.key===T.ESCAPE&&(d.stopImmediatePropagation(),l.onClickOutside?.())},m={capture:!0};return document.addEventListener("keydown",c,m),()=>{document.removeEventListener("keydown",c,m)}},[l]);let s=FI(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Ym(uf.Provider,{value:{onSelect:r},children:Ym("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Ym(It.Col,{className:"dropdown-menu-container",children:e}):Ym(yt,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};vv.displayName="DropdownMenuContent";var wv=vv;import{jsx as VI}from"react/jsx-runtime";var GI=({children:e,className:o="",selected:t,...r})=>VI("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),Tv=GI;import{jsx as Cv}from"react/jsx-runtime";var Iv=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noreferrer",...s})=>{let c=am(s.onClick,n);return Cv("a",{...s,href:t,target:"_blank",rel:"noreferrer",className:im(i,a),title:s.title??s["aria-label"],onClick:c,children:Cv(nm,{icon:e,shortcut:o,children:r})})},Wa=Iv;Iv.displayName="DropdownMenuItemLink";import{jsx as YI}from"react/jsx-runtime";var Sv=()=>YI("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),kv=Sv;Sv.displayName="DropdownMenuSeparator";import WI from"clsx";import{jsx as KI}from"react/jsx-runtime";var Mv=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=Ce(),a=WI(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return KI("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},Lv=Mv;Mv.displayName="DropdownMenuTrigger";import Wm from"react";var Av=e=>{let o=Wm.Children.toArray(e).find(t=>Wm.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},_v=e=>{let o=Wm.Children.toArray(e).find(t=>Wm.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as ZI,jsxs as XI}from"react/jsx-runtime";var Wr=({children:e,open:o})=>{let t=Av(e),r=_v(e);return XI(ZI,{children:[t,o&&r]})};Wr.Trigger=Lv;Wr.Content=wv;Wr.Item=Wt;Wr.ItemLink=Wa;Wr.ItemCustom=Tv;Wr.Group=ms;Wr.Separator=kv;var Ne=Wr;Wr.displayName="DropdownMenu";import{jsx as po,jsxs as Km}from"react/jsx-runtime";var qI=(e,o)=>e.filter(t=>o.includes(t.id)),JI=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=we(Pn),[c,m]=we(Ya),d=()=>{let P=o.length?f("alerts.removeItemsFromsLibrary",{count:o.length}):f("alerts.resetLibrary"),z=o.length?f("confirmDialog.removeItemsFromLib"):f("confirmDialog.resetLibrary");return po(Gm,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:z,children:po("p",{children:P})})},[p,u]=Vf(!1),g=!!o.length,b=g?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=g?f("buttons.remove"):f("buttons.resetLibrary"),[E,w]=Vf(!1),[y,v]=Vf(null),C=jI(()=>Km(dt,{onCloseRequest:()=>v(null),title:f("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[po("p",{children:po(Zt,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:P=>po("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),po(ee,{type:"button",title:f("buttons.close"),"aria-label":f("buttons.close"),label:f("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),S=(P,z)=>{w(!1),v({url:P.url,authorName:P.authorName});let W=z.slice();W.forEach(U=>{o.includes(U.id)&&(U.status="published")}),t.setLibrary(W)},_=async()=>{try{await t.updateLibrary({libraryItems:Jc({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:f("errors.importLibraryError")})}},L=async()=>{let P=g?b:await t.getLatestLibrary();Qx(P).catch(vc).catch(z=>{e({errorMessage:z.message})})},N=()=>Km(Ne,{open:c,children:[po(Ne.Trigger,{onToggle:()=>m(!c),children:mh}),Km(Ne.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!g&&po(Ne.Item,{onSelect:_,icon:wi,"data-testid":"lib-dropdown--load",children:f("buttons.load")}),!!b.length&&po(Ne.Item,{onSelect:L,icon:yn,"data-testid":"lib-dropdown--export",children:f("buttons.export")}),!!b.length&&po(Ne.Item,{onSelect:()=>u(!0),icon:lo,children:x}),g&&po(Ne.Item,{icon:vg,onSelect:()=>w(!0),"data-testid":"lib-dropdown--remove",children:f("buttons.publishLibrary")})]})]});return Km("div",{className:$I("library-menu-dropdown-container",l),children:[N(),o.length>0&&po("div",{className:"library-actions-counter",children:o.length}),p&&d(),E&&po(bv,{onClose:()=>w(!1),libraryItems:qI(s.libraryItems,o),appState:a,onSuccess:P=>S(P,s.libraryItems),onError:P=>window.alert(P),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:P=>i(o.filter(z=>z!==P))}),y&&C()]})},Yf=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=st(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=Om(),a=Re(),l=Ie(),[s]=we(Pn),c=async d=>{let p=d.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:f("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return po(JI,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as lS,useEffect as sS,useState as cS}from"react";import QI,{useCallback as eS}from"react";function tS(){return[!1,eS(o=>o(),[])]}var Dv=QI.useTransition||tS;import Pv from"clsx";import{memo as oS,useEffect as rS,useRef as nS,useState as iS}from"react";import{jsx as Zm,jsxs as aS}from"react/jsx-runtime";var Rv=oS(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=nS(null),c=rv(e,o,l);rS(()=>{let g=s.current;if(g)return c&&(g.innerHTML=c.outerHTML),()=>{g.innerHTML=""}},[c]);let[m,d]=iS(!1),p=Ce().editor.isMobile,u=t&&Zm("div",{className:"library-unit__adder",children:dh});return aS("div",{className:Pv("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":n,"library-unit--skeleton":!c}),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:[Zm("div",{className:Pv("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?g=>{e&&g.shiftKey?i(e,g):r(e)}:void 0,onDragStart:g=>{if(!e){g.preventDefault();return}d(!1),a(e,g)}}),u,e&&o&&(m||p||n)&&Zm(xs,{checked:n,onChange:(g,b)=>i(e,b),className:"library-unit__checkbox"})]})}),Nv=()=>Zm("div",{className:"library-unit library-unit--skeleton"});import{Fragment as dS,jsx as Xm}from"react/jsx-runtime";var Wf=({children:e})=>Xm("div",{className:"library-menu-items-container__grid",children:e}),$m=lS(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=Dv(),[s,c]=cS(0);return sS(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),Xm(dS,{children:e.map((m,d)=>d<s?Xm(Rv,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:n,svgCache:i,id:m?.id,selected:r(m.id),onToggle:o,onDrag:t},m?.id??d):Xm(Nv,{},d))})});import{Fragment as Bv,jsx as uo,jsxs as Za}from"react/jsx-runtime";var hS=17,gS=64;function Kf({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let m=pS(null),d=mv(m);mS(()=>{d>0&&m.current?.scrollTo(0,d)},[]);let{svgCache:p}=Om(),u=Ov(()=>o.filter(P=>P.status!=="published"),[o]),g=Ov(()=>o.filter(P=>P.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!g.length,[E,w]=uS(null),y=Ka((P,z)=>{let W=!c.includes(P),U=[...u,...g];if(W){if(z.shiftKey&&E){let q=U.findIndex(Q=>Q.id===E),H=U.findIndex(Q=>Q.id===P);if(q===-1||H===-1){s([...c,P]);return}let V=te(c),K=U.reduce((Q,X,ie)=>((ie>=q&&ie<=H||V.has(X.id))&&Q.push(X.id),Q),[]);s(K)}else s([...c,P]);w(P)}else w(null),s(c.filter(q=>q!==P))},[E,s,g,c,u]),v=Ka(P=>{let z;return c.includes(P)?z=o.filter(W=>c.includes(W.id)):z=o.filter(W=>W.id===P),z.map(W=>({...W,elements:bn({type:"everything",elements:W.elements,randomizeSeed:!0}).newElements}))},[o,c]),C=Ka((P,z)=>{z.dataTransfer.setData(ge.excalidrawlib,Yu(v(P)))},[v]),S=Ka(P=>P?c.includes(P):!1,[c]),_=Ka(()=>{t(n)},[n,t]),L=Ka(P=>{P&&r(v(P))},[v,r]),N=p.size>=o.length?gS:hS;return Za("div",{className:"library-menu-items-container",style:n.length||u.length||g.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&uo(Yf,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),Za(It.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:g.length>0?1:"0 1 auto",marginBottom:0},ref:m,children:[Za(Bv,{children:[!x&&uo("div",{className:"library-menu-items-container__header",children:f("labels.personalLib")}),e&&uo("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:uo(Lt,{})}),!n.length&&!u.length?Za("div",{className:"library-menu-items__no-items",children:[uo("div",{className:"library-menu-items__no-items__label",children:f("library.noItems")}),uo("div",{className:"library-menu-items__no-items__hint",children:g.length>0?f("library.hint_emptyPrivateLibrary"):f("library.hint_emptyLibrary")})]}):Za(Wf,{children:[n.length>0&&uo($m,{itemsRenderedPerBatch:N,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:C,onClick:_,isItemSelected:S,svgCache:p}),uo($m,{itemsRenderedPerBatch:N,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p})]})]}),Za(Bv,{children:[(g.length>0||n.length>0||u.length>0)&&uo("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:f("labels.excalidrawLib")}),g.length>0?uo(Wf,{children:uo($m,{itemsRenderedPerBatch:N,items:g,onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p})}):u.length>0?uo("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:f("library.noItems")}):null]}),b&&uo(Hm,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:uo(Yf,{selectedItems:c,onSelectItems:s})})]})]})}import{jsx as Rn,jsxs as Hv}from"react/jsx-runtime";var Ya=De(!1),Fv=({children:e})=>Rn("div",{className:"layer-ui__library",children:e}),bS=Vv(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=we(Pn),d=Xf(g=>{(async(x,E)=>{ye("element","addToLibrary","ui");for(let y of mc)if(x.some(v=>v.type===y))return r({errorMessage:f(`errors.libraryElementTypeError.${y}`)});let w=[{status:"unpublished",elements:x,id:io(),created:Date.now()},...E];t(),i.setLibrary(w).catch(()=>{r({errorMessage:f("alerts.errorAddingToLibrary")})})})(g,m.libraryItems)},[t,i,r,m.libraryItems]),p=Gv(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return Rn(Fv,{children:Rn("div",{className:"layer-ui__library-message",children:Hv("div",{children:[Rn(Lt,{size:"2em"}),Rn("span",{children:f("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return Hv(Fv,{children:[Rn(Kf,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),u&&Rn(Hm,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Zf=(e,o)=>({elements:e,pending:J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),xS=(e,o)=>{let t=Cn(),[r,n]=Uv(()=>Zf(t,e.selectedElementIds)),i=fS(new Map);return zv(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),zv(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!Qe(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Zf(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=l.get(s)?.version;if(c&&c!==i.current.get(s))return Zf(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},Yv=Vv(()=>{let e=st(),{onInsertElements:o}=e,t=hr(),r=Re(),n=Ie(),[i,a]=Uv([]),l=Gv(()=>e.library,[e.library]),s=xS(r,e),c=Xf(d=>{o(Fm(d))},[o]),m=Xf(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return Rn(bS,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import ES from"clsx";import{useRef as yS}from"react";import{createPortal as vS}from"react-dom";import{jsx as Wv,jsxs as wS}from"react/jsx-runtime";var Kv=e=>{let{closeOnClickOutside:o=!0}=e,t=qd({className:"excalidraw-modal-container"}),r=yS(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===T.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return vS(wS("div",{className:ES("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[Wv("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),Wv("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Ls,jsxs as kS}from"react/jsx-runtime";function SS(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var dt=e=>{let[o,t]=ev(),[r]=IS(document.activeElement),{id:n}=gt(),i=Ce().viewport.isMobile;CS(()=>{if(!o)return;let c=Tl(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=d=>{if(d.key===T.TAB){let p=Tl(o),{activeElement:u}=document,g=p.findIndex(b=>b===u);g===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):g===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=Ie(),l=xn(Ya),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return Ls(Kv,{className:TS("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:SS(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:kS(yt,{ref:t,children:[e.title&&Ls("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:Ls("span",{className:"Dialog__titleContent",children:e.title})}),i&&Ls("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:Eo}),Ls("div",{className:"Dialog__content",children:e.children})]})})};import $f from"clsx";import{forwardRef as AS,useRef as _S,useImperativeHandle as DS,useLayoutEffect as PS,useState as RS}from"react";import MS from"clsx";import{jsx as LS}from"react/jsx-runtime";var Co=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>LS("button",{onClick:sn(i.onClick,a=>{o()}),type:e,className:MS("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as jf,jsxs as Zv}from"react/jsx-runtime";var Xa=AS(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:c,...m},d)=>{let p=_S(null);DS(d,()=>p.current),PS(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,g]=RS(!1);return Zv("div",{className:$f("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&jf("div",{className:"ExcTextField__label",children:o}),Zv("div",{className:$f("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[jf("input",{className:$f({"is-redacted":"value"in m&&m.value&&l&&!u}),readOnly:n,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:r,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&jf(Co,{onSelect:()=>g(!u),style:{border:0,userSelect:"none"},children:u?Lg:Ii})]})]})});var As=[{icon:fh,value:"selection",key:T.V,numericKey:T[1],fillable:!0},{icon:bh,value:"rectangle",key:T.R,numericKey:T[2],fillable:!0},{icon:xh,value:"diamond",key:T.D,numericKey:T[3],fillable:!0},{icon:Eh,value:"ellipse",key:T.O,numericKey:T[4],fillable:!0},{icon:yh,value:"arrow",key:T.A,numericKey:T[5],fillable:!0},{icon:vh,value:"line",key:T.L,numericKey:T[6],fillable:!0},{icon:Ur,value:"freedraw",key:[T.P,T.X],numericKey:T[7],fillable:!1},{icon:Wl,value:"text",key:T.T,numericKey:T[8],fillable:!1},{icon:Th,value:"image",key:null,numericKey:T[9],fillable:!1},{icon:Ch,value:"eraser",key:T.E,numericKey:T[0],fillable:!1}],Xv=e=>As.find((t,r)=>t.numericKey!=null&&e===t.numericKey.toString()||t.key&&(typeof t.key=="string"?t.key===e:t.key.includes(e)))?.value||null;import Qf from"clsx";import{useState as BS}from"react";import{createIsolation as NS}from"jotai-scope";import qf from"react";import xr from"tunnel-rat";var Jf=qf.createContext(null),Ze=()=>qf.useContext(Jf),OS=NS(),$v=()=>qf.useMemo(()=>({MainMenuTunnel:xr(),WelcomeScreenMenuHintTunnel:xr(),WelcomeScreenToolbarHintTunnel:xr(),WelcomeScreenHelpHintTunnel:xr(),WelcomeScreenCenterTunnel:xr(),FooterCenterTunnel:xr(),DefaultSidebarTriggerTunnel:xr(),DefaultSidebarTabTriggersTunnel:xr(),OverwriteConfirmDialogTunnel:xr(),TTDDialogTriggerTunnel:xr(),tunnelsJotai:OS}),[]);import{Fragment as Kr,jsx as Ye,jsxs as vt}from"react/jsx-runtime";var e1=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return Rl(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>Rl(r.type))},t1=(e,o)=>un(e.activeTool.type)||o.some(t=>un(t.type)),jm=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=Uc(o,e),i=!1;n.length===2&&(pt(n[0])||pt(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=Ce(),s=document.documentElement.getAttribute("dir")==="rtl",c=un(e.activeTool.type)&&!ti(e.currentItemBackgroundColor)||n.some(g=>un(g.type)&&!ti(g.backgroundColor)),m=n.length===1||i,d=!e.editingLinearElement&&n.length===1&&le(n[0])&&!oe(n[0]),p=!e.croppingElementId&&n.length===1&&fe(n[0]),u=!i&&mo(e,r);return vt("div",{className:"panelColumn",children:[Ye("div",{children:e1(e,n)&&t("changeStrokeColor")}),t1(e,n)&&Ye("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(_u(e.activeTool.type)||n.some(g=>_u(g.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(g=>g.type==="freedraw"))&&t("changeStrokeShape"),(Du(e.activeTool.type)||n.some(g=>Du(g.type)))&&vt(Kr,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Pu(e.activeTool.type)||n.some(g=>Pu(g.type)))&&Ye(Kr,{children:t("changeRoundness")}),(Ru(e.activeTool.type)||n.some(g=>Ru(g.type)))&&Ye(Kr,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(Z))&&vt(Kr,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||j0(n,o))&&t("changeTextAlign")]}),$0(n,o)&&t("changeVerticalAlign"),(ia(e.activeTool.type)||n.some(g=>ia(g.type)))&&Ye(Kr,{children:t("changeArrowhead")}),t("changeOpacity"),vt("fieldset",{children:[Ye("legend",{children:f("labels.layers")}),vt("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&vt("fieldset",{children:[Ye("legend",{children:f("labels.align")}),vt("div",{className:"buttonList",children:[s?vt(Kr,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):vt(Kr,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),Ye("div",{style:{flexBasis:"100%",height:0}}),vt("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&&vt("fieldset",{children:[Ye("legend",{children:f("labels.actions")}),vt("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),p&&t("cropEditor"),d&&t("toggleLinearEditor")]})]})]})},qm=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=BS(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso",c=e.type==="embeddable",{TTDDialogTriggerTunnel:m}=Ze();return vt(Kr,{children:[As.map(({value:d,icon:p,key:u,numericKey:g,fillable:b},x)=>{if(r.tools?.[d]===!1)return null;let E=f(`toolBar.${d}`),w=u&&ir(typeof u=="string"?u:u[0]),y=w?`${w} ${f("helpDialog.or")} ${g}`:`${g}`;return Ye(ee,{className:Qf("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===d,name:"editor-current-shape",title:`${ir(E)} \u2014 ${y}`,keyBindingLabel:g||w,"aria-label":ir(E),"aria-keyshortcuts":y,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:v})=>{!o.penDetected&&v==="pen"&&t.togglePenMode(!0),d==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:v})=>{o.activeTool.type!==d&&ye("toolbar",d,"ui"),d==="image"?t.setActiveTool({type:d,insertOnCanvasDirectly:v!=="mouse"}):t.setActiveTool({type:d})}},d)}),Ye("div",{className:"App-toolbar__divider"}),vt(Ne,{open:n,children:[Ye(Ne.Trigger,{className:Qf("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||c||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!n),title:f("toolBar.extraTools"),children:a?wa:c?vd:l&&!t.props.isCollaborating?Ta:s?fa:kg}),vt(Ne.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Ye(Ne.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:wa,shortcut:T.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:f("toolBar.frame")}),Ye(Ne.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:vd,"data-testid":"toolbar-embeddable",selected:c,children:f("toolBar.embeddable")}),Ye(Ne.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:Ta,"data-testid":"toolbar-laser",selected:l,shortcut:T.K.toLocaleUpperCase(),children:f("toolBar.laser")}),Ye(Ne.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:fa,"data-testid":"toolbar-lasso",selected:s,children:f("toolBar.lasso")}),Ye("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&Ye(m.Out,{}),Ye(Ne.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:es,"data-testid":"toolbar-embeddable",children:f("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&Ye(Kr,{children:vt(Ne.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:ts,"data-testid":"toolbar-magicframe",children:[f("toolBar.magicframe"),Ye(Ne.Item.Badge,{children:"AI"})]})})]})]})]})},jv=({renderAction:e,zoom:o})=>Ye(It.Col,{gap:1,className:Yo.ZOOM_ACTIONS,children:vt(It.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),qv=({renderAction:e,className:o})=>vt("div",{className:`undo-redo-buttons ${o}`,children:[Ye("div",{className:"undo-button-container",children:Ye(vo,{label:f("buttons.undo"),children:e("undo")})}),Ye("div",{className:"redo-button-container",children:vt(vo,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),Jv=({actionManager:e,showExitZenModeBtn:o})=>Ye("button",{type:"button",className:Qf("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(Ri),children:f("buttons.exitZenMode")}),Qv=({renderAction:e,className:o})=>Ye("div",{className:`finalize-button ${o}`,children:e("finalize",{size:"small"})});import{useRef as zS}from"react";var o1=e=>{let o=zS({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as HS,jsxs as FS}from"react/jsx-runtime";var Oi=De(null),ew=()=>{let[e,o]=we(Oi),t=ft();return e&&e==="clearCanvas"?HS(Gm,{onConfirm:()=>{t.executeAction(fr),o(null)},onCancel:()=>o(null),title:f("clearCanvasDialog.title"),children:FS("p",{className:"clear-canvas__content",children:[" ",f("alerts.clearReset")]})}):null};var r1={};Js(r1,{toggleTheme:()=>US});var US={...Mn,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Mn,"commandPalette")}};import{jsx as Xt,jsxs as Er}from"react/jsx-runtime";var YS=De(null),nt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},WS=e=>{switch(e){case nt.app:return 1;case nt.export:return 2;case nt.editor:return 3;case nt.tools:return 4;case nt.elements:return 5;case nt.links:return 6;default:return 10}},ep=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return Er("div",{className:ow("shortcut",o),children:[r.map((n,i)=>Xt("div",{className:"shortcut-wrapper",children:Xt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),Xt("div",{className:"shortcut-desc",children:t})]})},rw=e=>!e.altKey&&e[T.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===T.P||e.key===T.SLASH),KS=Object.assign(e=>{let o=Re(),t=Ie();return Qm(()=>{let r=n=>{rw(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&ye("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener("keydown",r,{capture:!0}),()=>window.removeEventListener("keydown",r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:Xt(ZS,{...e})},{defaultItems:r1});function ZS({customCommandPaletteItems:e}){let o=st(),t=Re(),r=Ie(),n=hr(),i=ft(),[a,l]=we(YS),[s,c]=Jm(null),m=VS(null),d=wn({uiAppState:t,customCommandPaletteItems:e,appProps:n});Qm(()=>{let{uiAppState:S,customCommandPaletteItems:_,appProps:L}=d,N=U=>{let q="";return U.label&&(typeof U.label=="function"?q=f(U.label(o.scene.getNonDeletedElements(),S,o)):q=f(U.label)),q},P=U=>typeof U.icon=="function"?U.icon(S,o.scene.getNonDeletedElements()):U.icon,z=[],W=(U,q,H)=>{let V={label:N(U),icon:P(U),category:q,shortcut:ct(U.name),keywords:U.keywords,predicate:U.predicate,viewMode:U.viewMode,perform:()=>{i.executeAction(U,"commandPalette")}};return H?H(V,U):V};if(S&&o.scene&&i){let U=[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,Ua,Rm,Q2].map(X=>W(X,nt.elements,(ie,he)=>({...ie,predicate:he.predicate?he.predicate:(pe,He,Bt,qt)=>J(pe,He).length>0}))),q=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(X=>W(X,nt.tools)),H=[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=>W(X,nt.editor)),V=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(X=>W(X,nt.export));z=[...U,...H,{label:N(fr),icon:P(fr),shortcut:ct(fr.name),category:nt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{kt.set(Oi,"clearCanvas")}},{label:f("buttons.exportImage"),category:nt.export,icon:$l,shortcut:ct("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...V];let K=[{label:f("toolBar.library"),category:nt.app,icon:Ei,viewMode:!1,perform:()=>{S.openSidebar?r({openSidebar:null}):r({openSidebar:{name:At.name,tab:At.defaultTab}})}},{label:f("search.title"),category:nt.app,icon:so,viewMode:!0,perform:()=>{i.executeAction($a)}},{label:f("labels.changeStroke"),keywords:["color","outline"],category:nt.elements,icon:Xl,viewMode:!1,predicate:(X,ie)=>{let he=J(X,ie);return he.length>0&&e1(ie,he)},perform:()=>{r(X=>({openMenu:X.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:f("labels.changeBackground"),keywords:["color","fill"],icon:Xl,category:nt.elements,viewMode:!1,predicate:(X,ie)=>{let he=J(X,ie);return he.length>0&&t1(ie,he)},perform:()=>{r(X=>({openMenu:X.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:f("labels.canvasBackground"),keywords:["color"],icon:Xl,category:nt.editor,viewMode:!1,perform:()=>{r(X=>({openMenu:X.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...As.reduce((X,ie)=>{let{value:he,icon:pe,key:He,numericKey:Bt}=ie;if(L.UIOptions.tools?.[he]===!1)return X;let Jt=He&&ir(typeof He=="string"?He:He[0])||Bt,Qt={label:f(`toolBar.${he}`),category:nt.tools,shortcut:Jt,icon:pe,keywords:["toolbar"],viewMode:!1,perform:({event:rr})=>{he==="image"?o.setActiveTool({type:he,insertOnCanvasDirectly:rr.type==="keydown"}):o.setActiveTool({type:he})}};return X.push(Qt),X},[]),...q,{label:f("toolBar.lock"),category:nt.tools,icon:S.activeTool.locked?yi:En,shortcut:T.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${f("labels.textToDiagram")}...`,category:nt.tools,icon:_g,viewMode:!1,predicate:L.aiEnabled,perform:()=>{r(X=>({...X,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${f("toolBar.mermaidToExcalidraw")}...`,category:nt.tools,icon:es,viewMode:!1,predicate:L.aiEnabled,perform:()=>{r(X=>({...X,openDialog:{name:"ttd",tab:"mermaid"}}))}}],Q=[...z,...K,..._||[]].map(X=>({...X,icon:X.icon||os,order:X.order??WS(X.category),haystack:`${Of(X.label.toLocaleLowerCase())} ${X.keywords?.join(" ")||""}`}));c(Q),l(Q.find(X=>X.label===a?.label)??null)}},[d,o,i,c,a?.label,l,r]);let[p,u]=Jm(""),[g,b]=Jm(null),[x,E]=Jm({}),w=S=>{r({openDialog:null},S),u("")},y=(S,_)=>{t.openDialog?.name==="commandPalette"&&(_.stopPropagation(),_.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{S.perform({actionManager:i,event:_}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=o1(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=o1(S=>{let _=ar(S.target)||rw(S)||S.key===T.ESCAPE;if(_&&S.key!==T.ARROW_UP&&S.key!==T.ARROW_DOWN&&S.key!==T.ENTER)return;let L=Object.values(x).flat(),N=a&&!p&&v(a);if(S.key===T.ARROW_UP){S.preventDefault();let P=L.findIndex(U=>U.label===g?.label);if(N){if(P===0){b(a);return}if(g===a){let U=L[L.length-1];U&&b(U);return}}let z;P===-1?z=L.length-1:z=P===0?L.length-1:(P-1)%L.length;let W=L[z];W&&b(W);return}if(S.key===T.ARROW_DOWN){S.preventDefault();let P=L.findIndex(U=>U.label===g?.label);if(N){if(!g||P===L.length-1){b(a);return}if(g===a){let U=L[0];U&&b(U);return}}let z=(P+1)%L.length,W=L[z];W&&b(W);return}if(S.key===T.ENTER&&g&&setTimeout(()=>{y(g,S)}),!_){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){m?.current?.focus();return}S.preventDefault()}});return Qm(()=>(window.addEventListener("keydown",C,{capture:!0}),()=>window.removeEventListener("keydown",C,{capture:!0})),[C]),Qm(()=>{if(!s)return;let S=P=>{let z={};for(let W of P)z[W.category]?z[W.category].push(W):z[W.category]=[W];return z},_=s.filter(v).sort((P,z)=>P.order-z.order),L=!p&&a&&v(a);if(!p){E(S(L?_.filter(P=>P.label!==a?.label):_)),b(L?a:_[0]||null);return}let N=Of(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));_=GS.filter(N,_,{extract:P=>P.haystack}).sort((P,z)=>z.score-P.score).map(P=>P.original),E(S(_)),b(_[0]??null)},[p,s,v,a]),Er(dt,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Xt(Xa,{value:p,placeholder:f("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:m}),!o.device.viewport.isMobile&&Er("div",{className:"shortcuts-wrapper",children:[Xt(ep,{shortcut:"\u2191\u2193",children:f("commandPalette.shortcuts.select")}),Xt(ep,{shortcut:"\u21B5",children:f("commandPalette.shortcuts.confirm")}),Xt(ep,{shortcut:R("Esc"),children:f("commandPalette.shortcuts.close")})]}),Er("div",{className:"commands",children:[a&&!p&&Er("div",{className:"command-category",children:[Er("div",{className:"command-category-title",children:[f("commandPalette.recents"),Xt("div",{className:"icon",style:{marginLeft:"6px"},children:Dg})]}),Xt(tw,{command:a,isSelected:a.label===g?.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,_)=>Er("div",{className:"command-category",children:[Xt("div",{className:"command-category-title",children:S}),x[S].map(L=>Xt(tw,{command:L,isSelected:L.label===g?.label,onClick:N=>y(L,N),onMouseMove:()=>b(L),showShortcut:!o.device.viewport.isMobile,appState:t},L.label))]},S)):s?Er("div",{className:"no-match",children:[Xt("div",{className:"icon",children:so})," ",f("commandPalette.search.noMatch")]}):null]})]})}var tw=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return Er("div",{className:ow("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?f("commandPalette.itemNotAvailable"):"",children:[Er("div",{className:"name",children:[e.icon&&Xt(kn,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&Xt(ep,{shortcut:e.shortcut})]})};import{jsx as XS}from"react/jsx-runtime";var tp=F({name:"toggleLinearEditor",category:nt.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.editingLinearElement&&n.length===1&&le(n[0])&&!oe(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0],i=o.editingLinearElement?.elementId===n.id?null:new j(n);return{appState:{...o,editingLinearElement:i},captureUpdate:A.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=f(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return XS(ee,{type:"button",icon:Kg,title:n,"aria-label":n,onClick:()=>o(null)})}});var $a=F({name:"searchMenu",icon:so,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.openSidebar?.name===At.name&&o.openSidebar.tab===kr){let n=r.excalidrawContainerValue.container?.querySelector(`.${Yo.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.matches(":focus")?{appState:{...o,openSidebar:null},captureUpdate:A.EVENTUALLY}:(n?.focus(),n?.select(),!1)}return{appState:{...o,openSidebar:{name:At.name,tab:kr},openDialog:null},captureUpdate:A.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.F});import{jsx as $S}from"react/jsx-runtime";var op=F({name:"cropEditor",label:"helpDialog.cropStart",icon:Hd,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:A.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&fe(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=f("helpDialog.cropStart");return $S(ee,{type:"button",icon:Hd,title:r,"aria-label":r,onClick:()=>o(null)})}});var iw=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&ae(t[0])},aw=F({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(ae(n)){let i=_o(xe(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:A.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>iw(o,r)}),lw=F({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return ae(n)?{elements:fx(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:A.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>iw(o,r)}),jJ=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:A.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),qJ=F({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:wa,viewMode:!1,perform:(e,o,t,r)=>{let n=Ue(o,{type:"frame"});return To(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Ue(o,{type:"frame"})},captureUpdate:A.EVENTUALLY}},keyTest:e=>!e[T.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===T.F}),sw=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=>ae(i))},perform:(e,o,t,r)=>{let n=J(e,o),[i,a,l,s]=ve(n,r.scene.getNonDeletedElementsMap()),c=16,m=la({x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2});if(o.editingGroupId){let p=Fe(n,o.editingGroupId);for(let u of p){let g=u.groupIds.indexOf(o.editingGroupId);B(u,{groupIds:u.groupIds.slice(0,g)},!1)}}return{elements:ra([...r.scene.getElementsIncludingDeleted(),m],n,m,o),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:A.IMMEDIATELY}}});var Bi=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},ja=class e{constructor(){I(this,"onHistoryChangedEmitter",new Pt);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,t){let r=n1.create(t,o);r.isEmpty()||(this.undoStack.push(r.inverse()),r.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Bi(this.isUndoStackEmpty,this.isRedoStackEmpty)))}undo(o,t,r){return this.perform(o,t,r,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n,o))}redo(o,t,r){return this.perform(o,t,r,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n,o))}perform(o,t,r,n,i){try{let a=n();if(a===null)return;let l=o,s=t,c=!1;for(;a;){try{[l,s,c]=a.applyTo(l,s,r)}finally{i(a)}if(c)break;a=n()}return[l,s]}finally{this.onHistoryChangedEmitter.trigger(new Bi(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,r){let n=t.inverse().applyLatestChanges(r);return o.push(n)}},n1=class e{constructor(o,t){this.appStateChange=o;this.elementsChange=t}static create(o,t){return new e(o,t)}inverse(){return new e(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(o,t,r){let[n,i]=this.elementsChange.applyTo(o,r.elements),[a,l]=this.appStateChange.applyTo(t,n);return[n,a,i||l]}applyLatestChanges(o){let t=this.elementsChange.applyLatestChanges(o);return e.create(this.appStateChange,t)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}};import{useEffect as jS,useState as qS}from"react";var i1=(e,o)=>{let[t,r]=qS(o);return jS(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as pw}from"react/jsx-runtime";var cw=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:A.EVENTUALLY};let[n,i]=r,a=Array.from(n.values());return{appState:i,elements:a,captureUpdate:A.NEVER}}return{captureUpdate:A.EVENTUALLY}},dw=(e,o)=>({name:"undo",label:"buttons.undo",icon:Td,trackEvent:{category:"history"},viewMode:!1,perform:(t,r,n,i)=>cw(i,r,()=>e.undo(te(t),r,o.snapshot)),keyTest:t=>t[T.CTRL_OR_CMD]&&fc(t,T.Z)&&!t.shiftKey,PanelComponent:({updateData:t,data:r})=>{let{isUndoStackEmpty:n}=i1(e.onHistoryChangedEmitter,new Bi(e.isUndoStackEmpty,e.isRedoStackEmpty));return pw(ee,{type:"button",icon:Td,"aria-label":f("buttons.undo"),onClick:t,size:r?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),mw=(e,o)=>({name:"redo",label:"buttons.redo",icon:Cd,trackEvent:{category:"history"},viewMode:!1,perform:(t,r,n,i)=>cw(i,r,()=>e.redo(te(t),r,o.snapshot)),keyTest:t=>t[T.CTRL_OR_CMD]&&t.shiftKey&&fc(t,T.Z)||Qs&&t.ctrlKey&&!t.shiftKey&&fc(t,T.Y),PanelComponent:({updateData:t,data:r})=>{let{isRedoStackEmpty:n}=i1(e.onHistoryChangedEmitter,new Bi(e.isUndoStackEmpty,e.isRedoStackEmpty));return pw(ee,{type:"button",icon:Cd,"aria-label":f("buttons.redo"),onClick:t,size:r?.size||"medium",disabled:n,"data-testid":"button-redo"})}});var uw=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&&Z(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&&Z(i)){let a=Ut(i.originalText,Je(i),i.lineHeight);return re(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:A.IMMEDIATELY}}});var a1=F({name:"viewMode",label:"labels.viewMode",icon:Ii,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:A.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===ue.R});import{jsx as JS}from"react/jsx-runtime";var l1=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&ye(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},_s=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;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in r)||r[o])){let n=this.actions[o],i=n.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{l1(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return JS(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t})}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(ln(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=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(r.length!==1)return r.length>1&&console.warn("Canceling as multiple actions match this shortcut",r),!1;let n=r[0];if(this.getAppState().viewModeEnabled&&n.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return l1(n,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(r[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",r=null){let n=this.getElementsIncludingDeleted(),i=this.getAppState();l1(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var rp=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 s1=e=>{let o=Array.from(e.values());return{x:hw(o,t=>t.x)/o.length,y:hw(o,t=>t.y)/o.length}},c1=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),hw=(e,o)=>e.reduce((t,r)=>t+o(r),0);var QS=8,gw=99999,np=e=>QS/e,$t=class $t{};I($t,"referenceSnapPoints",null),I($t,"visibleGaps",null),I($t,"setReferenceSnapPoints",o=>{$t.referenceSnapPoints=o}),I($t,"getReferenceSnapPoints",()=>$t.referenceSnapPoints),I($t,"setVisibleGaps",o=>{$t.visibleGaps=o}),I($t,"getVisibleGaps",()=>$t.visibleGaps),I($t,"destroy",()=>{$t.referenceSnapPoints=null,$t.visibleGaps=null});var zo=$t,Nn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Zr=({event:e,app:o,selectedElements:t})=>e?o.state.objectsSnapModeEnabled&&!e[T.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[T.CTRL_OR_CMD]&&!Nn(o):t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled,ek=(e,o,t=.01)=>Math.abs(e-o)<=t,Ds=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,m,d,p]=Ke(a,o);n&&(l+=n.x,c+=n.x,d+=n.x,s+=n.y,m+=n.y,p+=n.y);let u=(c-l)/2,g=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=de(M(l,s+g),M(d,p),a.angle),x=de(M(l+u,s),M(d,p),a.angle),E=de(M(c,s+g),M(d,p),a.angle),w=de(M(l+u,m),M(d,p),a.angle),y=M(d,p);i=t?[b,x,E,w]:[b,x,E,w,y]}else{let b=de(M(l,s),M(d,p),a.angle),x=de(M(c,s),M(d,p),a.angle),E=de(M(l,m),M(d,p),a.angle),w=de(M(c,m),M(d,p),a.angle),y=M(d,p);i=t?[b,x,E,w]:[b,x,E,w,y]}}else if(e.length>1){let[a,l,s,c]=Kc(e,n??{x:0,y:0}),m=s-a,d=c-l,p=M(a,l),u=M(s,l),g=M(a,c),b=M(s,c),x=M(a+m/2,l+d/2);i=t?[p,u,g,b]:[p,u,g,b,x]}return i.map(a=>M(tt(a[0]),tt(a[1])))},xw=(e,o,t,r)=>{let n=o.filter(i=>ae(i)).map(i=>i.id);return Au(e,o,t,r).filter(i=>!(i.frameId&&n.includes(i.frameId)))},Ew=(e,o,t,r)=>{let n=xw(e,o,t,r),i=mi(n,r).filter(d=>!(d.length===1&&_e(d[0]))).map(d=>ve(d).map(p=>tt(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>gw)break e;let g=a[u],[,b,x,E]=p,[w,y,,v]=g;x<w&&yl(bo(b,E),bo(y,v))&&l.push({startBounds:p,endBounds:g,startSide:[M(x,b),M(x,E)],endSide:[M(w,y),M(w,v)],length:w-x,overlap:vl(bo(b,E),bo(y,v))})}}let c=i.sort((d,p)=>d[1]-p[1]),m=[];s=0;e:for(let d=0;d<c.length;d++){let p=c[d];for(let u=d+1;u<c.length;u++){if(++s>gw)break e;let g=c[u],[b,,x,E]=p,[w,y,v]=g;E<y&&yl(bo(b,x),bo(w,v))&&m.push({startBounds:p,endBounds:g,startSide:[M(b,E),M(x,E)],endSide:[M(w,y),M(v,y)],length:y-E,overlap:vl(bo(b,x),bo(w,v))})}}return{horizontalGaps:l,verticalGaps:m}},fw=(e,o,t,r,n,i,a)=>{if(!Zr({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=zo.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[m,d,p,u]=Kc(e,o).map(x=>tt(x)),g=(m+p)/2,b=(d+u)/2;for(let x of s){if(!yl(bo(d,u),x.overlap))continue;let E=x.startSide[0][0]+x.length/2,w=tt(E-g);if(x.length>p-m&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(n.length=0),a.x=Math.abs(w);let P={type:"gap",direction:"center_horizontal",gap:x,offset:w};n.push(P);continue}let[,,v]=x.endBounds,C=m-v,S=tt(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(n.length=0),a.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};n.push(P);continue}let[_,,,]=x.startBounds,L=_-p,N=tt(L-x.length);if(Math.abs(N)<=a.x){Math.abs(N)<a.x&&(n.length=0),a.x=Math.abs(N);let P={type:"gap",direction:"side_left",gap:x,offset:N};n.push(P);continue}}for(let x of c){if(!yl(bo(m,p),x.overlap))continue;let E=x.startSide[0][1]+x.length/2,w=tt(E-b);if(x.length>u-d&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let P={type:"gap",direction:"center_vertical",gap:x,offset:w};i.push(P);continue}let[,v,,]=x.startBounds,C=v-u,S=tt(C-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let P={type:"gap",direction:"side_top",gap:x,offset:S};i.push(P);continue}let[,,,_]=x.endBounds,L=tt(d-_),N=x.length-L;if(Math.abs(N)<=a.y){Math.abs(N)<a.y&&(i.length=0),a.y=Math.abs(N);let P={type:"gap",direction:"side_bottom",gap:x,offset:N};i.push(P);continue}}}},yw=(e,o,t,r)=>{let n=xw(e,o,t,r);return mi(n,r).filter(i=>!(i.length===1&&_e(i[0]))).flatMap(i=>Ds(i,r))},qa=(e,o,t,r,n,i,a)=>{if(!Zr({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=zo.getReferenceSnapPoints();if(l)for(let s of o)for(let c of l){let m=c[0]-s[0],d=c[1]-s[1];Math.abs(m)<=a.x&&(Math.abs(m)<a.x&&(n.length=0),n.push({type:"point",points:[s,c],offset:m}),a.x=Math.abs(m)),Math.abs(d)<=a.y&&(Math.abs(d)<a.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:d}),a.y=Math.abs(d))}},vw=(e,o,t,r,n)=>{let i=t.state,a=J(e,i);if(!Zr({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=tt(o.x),o.y=tt(o.y);let l=[],s=[],c=np(i.zoom.value),m={x:c,y:c},d=Ds(a,n,{dragOffset:o});qa(a,d,t,r,l,s,m),fw(a,o,t,r,l,s,m);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};m.x=0,m.y=0,l.length=0,s.length=0;let u={x:tt(o.x+p.x),y:tt(o.y+p.y)};qa(a,Ds(a,n,{dragOffset:u}),t,r,l,s,m),fw(a,u,t,r,l,s,m);let g=d1(l,s),b=ok(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...g,...b]}},tt=e=>Math.round(e*10**6)/10**6,bw=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())},d1=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=tt(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>M(tt(a[0]),tt(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=tt(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>M(tt(a[0]),tt(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:bw(i.map(a=>M(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:bw(i.map(a=>M(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},tk=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[tt(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},ok=(e,o,t)=>{let[r,n,i,a]=Kc(e,o),l=[];for(let s of t){let[c,m,d,p]=s.gap.startBounds,[u,g,b,x]=s.gap.endBounds,E=vl(bo(n,a),s.gap.overlap),w=vl(bo(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(s.gap.startSide[0][0],y),M(r,y)]},{type:"gap",direction:"horizontal",points:[M(i,y),M(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,s.gap.startSide[0][1]),M(y,n)]},{type:"gap",direction:"vertical",points:[M(y,a),M(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(d,y),M(u,y)]},{type:"gap",direction:"horizontal",points:[M(b,y),M(r,y)]})}break}case"side_left":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(i,y),M(c,y)]},{type:"gap",direction:"horizontal",points:[M(d,y),M(u,y)]})}break}case"side_top":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,a),M(y,m)]},{type:"gap",direction:"vertical",points:[M(y,p),M(y,g)]})}break}case"side_bottom":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,p),M(y,g)]},{type:"gap",direction:"vertical",points:[M(y,x),M(y,n)]})}break}}}return tk(l.map(s=>({...s,points:s.points.map(c=>M(tt(c[0]),tt(c[1])))})))},m1=(e,o,t,r,n,i)=>{if(!Zr({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!ek(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=ve(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(c+=n.y));let m=[];if(i)switch(i){case"e":{m.push(M(s,l),M(s,c));break}case"w":{m.push(M(a,l),M(a,c));break}case"n":{m.push(M(a,l),M(s,l));break}case"s":{m.push(M(a,c),M(s,c));break}case"ne":{m.push(M(s,l));break}case"nw":{m.push(M(a,l));break}case"se":{m.push(M(s,c));break}case"sw":{m.push(M(a,c));break}}let d=np(t.state.zoom.value),p={x:d,y:d},u=[],g=[];qa(o,m,t,r,u,g,p);let b={x:u[0]?.offset??0,y:g[0]?.offset??0};p.x=0,p.y=0,u.length=0,g.length=0;let[x,E,w,y]=ve(e).map(S=>tt(S)),v=[M(x,E),M(x,y),M(w,E),M(w,y)];qa(e,v,t,r,u,g,p);let C=d1(u,g);return{snapOffset:b,snapLines:C}},ww=(e,o,t,r,n,i)=>{if(!Zr({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[M(r.x+n.x,r.y+n.y)],l=np(o.state.zoom.value),s={x:l,y:l},c=[],m=[];qa([e],a,o,t,c,m,s);let d={x:c[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,c.length=0,m.length=0;let p=Ds([e],i,{boundingBoxCorners:!0,omitCenter:!0});qa([e],p,o,t,c,m,s);let u=d1(c,m);return{snapOffset:d,snapLines:u}},Tw=(e,o,t,r,n)=>{if(!Zr({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Au(e,[],o.state,n),a=np(o.state.zoom.value),l={x:a,y:a},s=[],c=[];for(let m of i){let d=Ds([m],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)&&(c.length=0),c.push({type:"pointer",points:[p,M(p[0],t.y)],direction:"vertical"}),l.x=u);let g=p[1]-t.y;Math.abs(g)<=Math.abs(l.y)&&(Math.abs(g)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,M(t.x,p[1])],direction:"horizontal"}),l.y=g)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},Cw=e=>e===it.rectangle||e===it.ellipse||e===it.diamond||e===it.frame||e===it.magicframe||e===it.image||e===it.text;var ip={width:100,height:0},On=100,rk=(e,o,t)=>{let r=Yt({x:0,y:0,textAlign:fl.CENTER,verticalAlign:to.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),et(r,e,t),[e,r]},Iw=(e,o,t,r,n)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let m=o?.width??On,d=o?.height??On,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-m,g=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=Yt({x:u,y:g,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=Vt({x:u,y:g,width:m,height:d,...p,...o,type:b});break}default:oi(e,`Unhandled element start type "${o.type}"`,!0)}Xo(e,i,"start",n)}}if(t){let m=t?.height??On,d=t?.width??On,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,g=t.y||e.y-m/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=Yt({x:u,y:g,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=Vt({x:u,y:g,width:d,height:m,...p,...t,type:b});break}default:oi(e,`Unhandled element end type "${b}"`,!0)}Xo(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,c=no(e.points);return e.points[l][0]>e.points[l-1][0]&&(c[0][0]=s,c[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(c[0][0]=-s,c[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(c[0][1]=s,c[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(c[0][1]=-s,c[l][1]+=s),Object.assign(e,j.getNormalizedPoints({...e,points:c})),{linearElement:e,startBoundElement:i,endBoundElement:a}},p1=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>Nr(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>dn(te(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Ja=(e,o)=>{if(!e)return[];let t=no(e),r=new p1,n=new Map,i=new Map;for(let l of t){let s,c=l.id;switch(o?.regenerateIds!==!1&&Object.assign(l,{id:io()}),l.type){case"rectangle":case"ellipse":case"diamond":{let d=l?.label?.text&&l.width===void 0?0:l?.width||On,p=l?.label?.text&&l.height===void 0?0:l?.height||On;s=Vt({...l,width:d,height:p});break}case"line":{let d=l.width||ip.width,p=l.height||ip.height;s=dr({width:d,height:p,points:[M(0,0),M(d,p)],...l});break}case"arrow":{let d=l.width||ip.width,p=l.height||ip.height;s=sa({width:d,height:p,endArrowhead:"arrow",points:[M(0,0),M(d,p)],...l,type:"arrow"}),Object.assign(s,d0(s.points));break}case"text":{let d=l?.fontFamily||en,p=l?.fontSize||Sr,u=l?.lineHeight||Lr(d),g=l.text??"",b=ai(g),x=Ut(b,Je({fontFamily:d,fontSize:p}),u);s=Yt({width:x.width,height:x.height,fontFamily:d,fontSize:p,...l});break}case"image":{s=Xc({width:l?.width||On,height:l?.height||On,...l});break}case"frame":{s=la({x:0,y:0,...l});break}case"magicframe":{s=Nl({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{s=l;break}default:s=l,oi(l,`Unhandled element type "${l.type}"`,!0)}r.getElement(s.id)?console.error(`Duplicate id found for ${s.id}`):(r.add(s),n.set(s.id,l),c&&i.set(c,s.id))}let a=r.getElementsMap();for(let[l,s]of n){let c=r.getElement(l);switch(s.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(s.label?.text){let[m,d]=rk(c,s?.label,a);if(r.add(m),r.add(d),ke(m)){let p=s.type==="arrow"?s?.start:void 0,u=s.type==="arrow"?s?.end:void 0;if(p&&p.id){let E=i.get(p.id);E&&Object.assign(p,{id:E})}if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}let{linearElement:g,startBoundElement:b,endBoundElement:x}=Iw(m,p,u,r,a);m=g,r.add(g),r.add(b),r.add(x)}}else switch(s.type){case"arrow":{let{start:m,end:d}=s;if(m&&m.id){let b=i.get(m.id);Object.assign(m,{id:b})}if(d&&d.id){let b=i.get(d.id);Object.assign(d,{id:b})}let{linearElement:p,startBoundElement:u,endBoundElement:g}=Iw(c,m,d,r,a);r.add(p),r.add(u),r.add(g);break}}break}}}for(let[l,s]of n){if(s.type!=="frame"&&s.type!=="magicframe")continue;let c=r.getElement(l);if(!c)throw new Error(`Excalidraw element with id ${l} doesn't exist`);let m=[];s.children.forEach(v=>{let C=i.get(v);if(!C)throw new Error(`Element with ${v} wasn't mapped correctly`);let S=r.getElement(C);if(!S)throw new Error(`Frame element with id ${C} doesn't exist`);Object.assign(S,{frameId:c.id}),S?.boundElements?.forEach(_=>{let L=r.getElement(_.id);if(!L)throw new Error(`Bound element with id ${_.id} doesn't exist`);Object.assign(L,{frameId:c.id}),m.push(L)}),m.push(S)});let[d,p,u,g]=ve(m),b=10;d=d-b,p=p-b,u=u+b,g=g+b;let x=c?.x||d,E=c?.y||p,w=c?.width||u-d,y=c?.height||g-p;Object.assign(c,{x,y:E,width:w,height:y}),Ge()&&s.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 ap from"open-color";var nk="#ff6b6b",ik="#ff0000",Sw=1,kw=2,Mw=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===ce.LIGHT||o.zenModeEnabled?nk:ik,r=(o.zenModeEnabled?Sw*1.5:Sw)/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,lk(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,sk(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,ak(n,e,o));e.restore()},ak=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];Fo(r,n,o)}for(let r of e.points)Lw(r,t,o)},lk=(e,o,t)=>{Lw(e.points[0],t,o),t.zenModeEnabled||Fo(e.points[0],e.points[1],o)},Lw=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?kw*1.5:kw)/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()},Fo=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},sk=(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||Fo(M(e[0],e[1]-i),M(e[0],e[1]+i),n),Fo(M(s[0]-l,s[1]-a),M(s[0]-l,s[1]+a),n),Fo(M(s[0]+l,s[1]-a),M(s[0]+l,s[1]+a),n),r.zenModeEnabled||(Fo(M(o[0],o[1]-i),M(o[0],o[1]+i),n),Fo(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||Fo(M(e[0]-i,e[1]),M(e[0]+i,e[1]),n),Fo(M(s[0]-a,s[1]-l),M(s[0]+a,s[1]-l),n),Fo(M(s[0]-a,s[1]+l),M(s[0]+a,s[1]+l),n),r.zenModeEnabled||(Fo(M(o[0]-i,o[1]),M(o[0]+i,o[1]),n),Fo(e,o,n))}};var er=4,yr=6,Aw="rgba(0,0,0,0.3)",_w=(e,o,t,r)=>{if(!e.length)return{horizontal:null,vertical:null};let[n,i,a,l]=ve(e),s=o/r.zoom.value,c=t/r.zoom.value,m=o-s,d=t-c,p={top:parseInt(wl("sat"))||0,bottom:parseInt(wl("sab"))||0,left:parseInt(wl("sal"))||0,right:parseInt(wl("sar"))||0},u=Hr().rtl,g=-r.scrollX+m/2+p.left,b=-r.scrollY+d/2+p.top,x=g+s-p.right,E=b+c-p.bottom,w=Math.min(n,g),y=Math.min(i,b),v=Math.max(a,x),C=Math.max(l,E);return{horizontal:g===w&&x===v?null:{x:Math.max(p.left,er)+(g-w)/(v-w)*o,y:t-yr-Math.max(er,p.bottom),width:(x-g)/(v-w)*o-Math.max(er*2,p.left+p.right),height:yr},vertical:b===y&&E===C?null:{x:u?Math.max(p.left,er):o-yr-Math.max(p.right,er),y:(b-y)/(C-y)*t+Math.max(p.top,er),width:yr,height:(E-b)/(C-y)*t-Math.max(er*2,p.top+p.bottom)}}},u1=(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 ck=(e,o)=>{cn(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;cn(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Pw(t,e,o),e.restore()},dk=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=j.getElement(r,t);if(!i)return;let a=j.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),Pw(a,e,o),e.restore()},Pw=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Bl(o,e[0],e[1],j.POINT_HANDLE_SIZE/t.zoom.value,!1)},Ps=(e,o,t,r,n,i,a,l,s=!1,c=0)=>{e.save(),e.translate(i,a),e.rotate(l),s&&e.fillRect(o-i,t-a,r,n),c&&e.roundRect?(e.beginPath(),e.roundRect(o-i,t-a,r,n,c),e.stroke(),e.closePath()):e.strokeRect(o-i,t-a,r,n),e.restore()},mk=(e,o,t,r,n,i)=>{e.save(),e.translate(r,n),e.rotate(i),e.beginPath(),e.moveTo(0,t/2),e.lineTo(o/2,0),e.lineTo(0,-t/2),e.lineTo(-o/2,0),e.closePath(),e.stroke(),e.restore()},h1=(e,o,t,r,n,i=!1)=>{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)"),Bl(e,t[0],t[1],r/o.zoom.value,!i)},pk=(e,o,t,r,n,i)=>{e.beginPath(),e.ellipse(r,n,o/2,t/2,i,0,Math.PI*2),e.stroke()},uk=(e,o,t,r)=>{let[n,i,a,l]=Ke(o,t),s=a-n,c=l-i;e.strokeStyle="rgba(0,0,0,.05)";let m=r.value<1?r.value:1;e.lineWidth=ex/m;let d=e.lineWidth/2+tx,p=Yc(Math.min(o.width,o.height),o);switch(o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":Ps(e,n-d,i-d,s+d*2,c+d*2,n+s/2,i+c/2,o.angle,void 0,p);break;case"diamond":let u=Math.hypot(s,c),g=d*u/c,b=d*u/s;mk(e,s+g*2,c+b*2,n+s/2,i+c/2,o.angle);break;case"ellipse":pk(e,s+d*2,c+d*2,n+s/2,i+c/2,o.angle);break}},hk=(e,o,t,r)=>{let[n,i,a]=o,l=ix(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(c=>{let[m,d]=j.getPointAtIndexGlobalCoordinates(n,c,t);Bl(e,m,d,l)})},Rw=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:m,dashed:d,activeEmbeddable:p}=t,u=a-n,g=l-i,x=(t.padding??tn*2)/o.zoom.value,E=8/o.zoom.value,w=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([E,w+(E+w)*(y-1)]),e.lineDashOffset=(E+w)*v,Ps(e,n-x,i-x,u+x*2,g+x*2,c,m,r);e.restore()},gk=(e,o,t,r)=>{let n=Array.isArray(t)?hk:uk;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},fk=(e,o,t,r)=>{let[n,i,a,l]=Ke(t,r),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Wo.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Ps(e,n,i,s,c,n+s/2,i+c/2,t.angle,!1,Wo.radius/o.zoom.value),e.restore()},bk=(e,o,t)=>{let r=t.filter(l=>l.groupIds.length===0),n=t.filter(l=>l.groupIds.length>0),i=l=>{let[s,c,m,d]=ve(l);return{angle:0,x1:s,x2:m,y1:c,y2:d,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:s+(m-s)/2,cy:c+(d-c)/2,activeEmbeddable:!1}},a=l=>{let s=Fe(t,l);return i(s)};Object.entries(wx(n,o)).filter(([l,s])=>s).map(([l,s])=>l).map(l=>a(l)).concat(r.map(l=>i([l]))).forEach(l=>Rw(e,o,l))},g1=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=j.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=j,a=o.editingLinearElement?i:i/2;if(n.forEach((l,s)=>{if(oe(t)&&s!==0&&s!==n.length-1)return;let c=!!o.editingLinearElement?.selectedPointsIndices?.includes(s);h1(e,o,l,a,c)}),oe(t)){let l=t.fixedSegments?.map(s=>s.index)||[];n.slice(0,-1).forEach((s,c)=>{j.isSegmentTooShort(t,n[c+1],n[c],c,o.zoom)||h1(e,o,M((s[0]+n[c+1][0])/2,(s[1]+n[c+1][1])/2),i/2,!1,!l.includes(c+1))})}else j.getEditorMidPoints(t,r,o).filter((s,c,m)=>s!==null&&!(oe(t)&&(c===0||c===m.length-1))).forEach(s=>{(o.editingLinearElement||n.length===2)&&h1(e,o,s,i/2,!1,!0)});e.restore()},Dw=(e,o,t,r,n)=>{Object.keys(r).forEach(i=>{let a=r[i];if(a!==void 0){let[l,s,c,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Bl(e,l+c/2,s+m/2,c/2):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,m,2/t.zoom.value),e.fill(),e.stroke()):Ps(e,l,s,c,m,l+c/2,s+m/2,n,!0),e.restore()}})},xk=(e,o,t,r,n)=>{let[i,a,,,l,s]=Ke(r,n),c=3,m=20,d=c/t.zoom.value,p=d/2,u=l-i+d,g=s-a+d,b=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,g);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=d,[[[-u,-g],[0,p],[b,p],[p,0],[p,x]],[[u-p,-g],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,g],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,g],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(w=>{let[[y,v],[C,S],[_,L],[N,P],[z,W]]=w;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+C,v+S),e.lineTo(y+_,v+L),e.stroke(),e.beginPath(),e.moveTo(y+N,v+P),e.lineTo(y+z,v+W),e.stroke(),e.restore()}),e.restore()},Ek=(e,o,t,r)=>{o.save();let n=tn*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,c=-(i/2+n),m=-(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(c,m,i,a),o.restore()},Nw=({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[c,m]=td(e,i),d=od({canvas:e,scale:i,normalizedWidth:c,normalizedHeight:m});d.save(),d.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.editingLinearElement?.elementId===b.id&&b&&(p=b)}),p&&g1(d,a,p,o),a.selectionElement&&!a.isCropping)try{Bx(a.selectionElement,d,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Z(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&Ek(b,d,a,l.selectionColor)}a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{gk(d,a,b,o)}),a.frameToHighlight&&fk(d,a,a.frameToHighlight,o),a.elementsToHighlight&&bk(d,a,a.elementsToHighlight);let u=r.some(b=>ae(b));if(r.length===1&&a.editingLinearElement?.elementId===r[0].id&&g1(d,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(E=>E.id===b.elementId);b.segmentMidPointHoveredCoords?ck(d,a):(oe(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&dk(d,a,o)}if(!a.multiElement&&!a.editingLinearElement){let b=cd(r,a),x=r.length===1&&le(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&g1(d,a,r[0],o);let E=l.selectionColor||ap.black;if(b){let w=te(r),y=[];for(let C of o.values()){let S=[],_=l.remoteSelectedElementIds.get(C.id);if(x&&oe(C)&&(C.startBinding||C.endBinding)||(w.has(C.id)&&!Gc(a,C)&&S.push(E),_&&S.push(..._.map(L=>Di(L,a.collaborators.get(L))))),S.length){let[L,N,P,z,W,U]=Ke(C,o,!0);y.push({angle:C.angle,x1:L,y1:N,x2:P,y2:z,selectionColors:S,dashed:!!_,cx:W,cy:U,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||fe(C)?0:void 0})}}let v=C=>{let S=Fe(o,C),[_,L,N,P]=ve(S);y.push({angle:0,x1:_,x2:N,y1:L,y2:P,selectionColors:[ap.black],dashed:!0,cx:_+(N-_)/2,cy:L+(P-L)/2,activeEmbeddable:!1})};for(let C of $o(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>Rw(d,a,C))}if(d.save(),d.translate(a.scrollX,a.scrollY),r.length===1){d.fillStyle=ap.white;let w=sd(r[0],a.zoom,o,"mouse",fi(s));if(!a.viewModeEnabled&&b&&!Z(a.editingTextElement)&&!a.croppingElementId&&Dw(d,l,a,w,r[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&fe(y)&&xk(d,l,a,y,o)}}else if(r.length>1&&!a.isRotating){let w=tn*2/a.zoom.value;d.fillStyle=ap.white;let[y,v,C,S]=ve(r,o),_=d.getLineDash();d.setLineDash([2/a.zoom.value]);let L=d.lineWidth;d.lineWidth=1/a.zoom.value,d.strokeStyle=E,Ps(d,y-w,v-w,C-y+w*2,S-v+w*2,(y+C)/2,(v+S)/2,0),d.lineWidth=L,d.setLineDash(_);let N=Ul([y,v,C,S,(y+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...fi(s),rotation:!0}:fi(s));r.some(P=>!P.locked)&&Dw(d,l,a,N,0)}d.restore()}a.searchMatches.forEach(({id:b,focus:x,matchedLines:E})=>{let w=o.get(b);if(w&&Z(w)){let[y,v,,,C,S]=Ke(w,o,!0);d.save(),a.theme===ce.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)",d.translate(a.scrollX,a.scrollY),d.translate(C,S),d.rotate(w.angle),E.forEach(_=>{d.fillRect(y+_.offsetX-C,v+_.offsetY-S,_.width,_.height)}),d.restore()}}),Mw(d,a),d.restore(),k2({context:d,renderConfig:l,appState:a,normalizedWidth:c,normalizedHeight:m});let g;return l.renderScrollbars&&(g=_w(t,c,m,a),d.save(),d.fillStyle=Aw,d.strokeStyle="rgba(255,255,255,0.8)",[g.horizontal,g.vertical].forEach(b=>{b&&Cm(d,b.x,b.y,b.width,b.height,yr/2)}),d.restore()),{scrollBars:g,atLeastOneVisibleElement:t.length>0,elementsMap:o}},f1=Wi(e=>{let o=Nw(e);e.callback?.(o)},{trailing:!0}),Ow=(e,o)=>{if(o){f1(e);return}let t=Nw(e);return e.callback(t),t};var Rs=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:m})=>{let d=[];for(let p of r.values())Dl(p,m,c,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&d.push(p);return d},t=({elements:r,editingTextElement:n,newElementId:i,pendingImageElementId:a})=>{let l=dn(new Map);for(let s of r)fe(s)&&a===s.id||i!==s.id&&(!n||n.type!=="text"||s.id!==n.id)&&l.set(s.id,s);return l};return C0(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingTextElement:m,newElementId:d,pendingImageElementId:p,sceneNonce:u})=>{let g=this.scene.getNonDeletedElements(),b=t({elements:g,editingTextElement:m,newElementId:d,pendingImageElementId:p}),x=o({elementsMap:b,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:b,visibleElements:x}})})());this.scene=o}destroy(){f1.cancel(),oE.cancel(),this.getRenderableElements.clear()}};import{jsx as wk}from"react/jsx-runtime";var yk=5,vk=(e,o,t)=>{let[r,n]=Ke(e,t),{x:i,y:a}=Ft({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},b1=({children:e,element:o,elementsMap:t})=>{let r=ur();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=vk(o,r,t);return wk("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:yk},children:e})};import{LaserPointer as Tk}from"@excalidraw/laser-pointer";var Xr=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(nu,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(nu,"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 Tk(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.pastTrails=[],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=Ft({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return I0(n,!0)}};var lp=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;I(this,"localTrail");I(this,"collabTrails",new Map);I(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Xr(o,t,{...this.getTrailOptions(),fill:()=>qp})}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(Ko(i),Ko(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 Xr(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||Di(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 Ck}from"react";import{unstable_batchedUpdates as Bw}from"react-dom";var ot=e=>o=>{Bw(e,o)},sp=e=>Wi(o=>{Bw(e,o)}),Qa=(()=>{let e;try{let t=Ck.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})();var Ik=(e,o,t,r,n,i)=>{let{zoom:a}=r,l=180*t/Math.PI,s=e*(a.value-1)/2,c=o*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(a.value-1)/2),o>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},zw=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let c=(H,V)=>{if(!V.style.fontFamily||!V.style.fontSize)return!1;let K=V.style.fontFamily.replace(/"/g,"");return Jn({fontFamily:H.fontFamily})!==K||`${H.fontSize}px`!==V.style.fontSize},m=()=>{let H=l.state,V=pn.getScene(n)?.getElement(e);if(!V)return;let{textAlign:K,verticalAlign:Q}=V,X=l.scene.getNonDeletedElementsMap();if(V&&Z(V)){let ie=V.x,he=V.y,pe=_t(V,l.scene.getNonDeletedElementsMap()),He=V.width,Bt=V.height,qt=V.width,Jt=V.height;if(pe&&V.containerId){if(ke(pe)){let Qr=j.getBoundTextElementPosition(pe,V,X);ie=Qr.x,he=Qr.y}let qs=c(V,d),cl;if(qs?cl=Sl(pe.id,pe.height):(cl=G0[pe.id],cl||(cl=Sl(pe.id,pe.height))),qt=ea(pe,V),Jt=J0(pe,V),!ke(pe)&&Bt>Jt){let Qr=Qi(Bt,pe.type);B(pe,{height:Qr});return}else if(!ke(pe)&&pe.height>cl.height&&Bt<Jt){let Qr=Qi(Bt,pe.type);B(pe,{height:Qr})}else{let{y:Qr}=Lc(pe,V,X);he=Qr}}let[Qt,rr]=r(ie,he),qr=d.selectionStart,eo=d.selectionEnd,Jr=d.value.length;if(qr===eo&&eo!==Jr){let qs=Jr-eo;d.selectionStart=d.value.length-qs,d.selectionEnd=d.value.length-qs}pe?He+=.5:(qt=(H.width-8-Qt)/H.zoom.value,He=Math.min(He,qt)),Bt*=1.05;let fo=Je(V),Tb=(H.height-rr)/H.zoom.value;Object.assign(d.style,{font:fo,lineHeight:V.lineHeight,width:`${He}px`,height:`${Bt}px`,left:`${Qt}px`,top:`${rr}px`,transform:Ik(He,Bt,X0(V,pe),H,qt,Tb),textAlign:K,verticalAlign:Q,color:V.strokeColor,opacity:V.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Tb}px`}),d.scrollTop=0,mt()&&(d.style.fontFamily=Jn(V)),B(V,{x:ie,y:he})}},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";(_e(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,m(),o&&(d.onpaste=async H=>{let V=await gm(H,!0);if(!V.text)return;let K=ai(V.text);if(!K)return;let Q=_t(n,l.scene.getNonDeletedElementsMap()),X=Je({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Q){let ie=be(Q,l.scene.getNonDeletedElementsMap()),he=Ji(`${d.value}${K}`,X,ea(Q,ie)),pe=Z0(he,X);d.style.width=`${pe}px`}},d.oninput=()=>{let H=ai(d.value);if(d.value!==H){let V=d.selectionStart;d.value=H,d.selectionStart=V,d.selectionEnd=V}o(d.value)}),d.onkeydown=H=>{if(!H.shiftKey&&hs.keyTest(H))H.preventDefault(),l.actionManager.executeAction(hs),m();else if(!H.shiftKey&&gs.keyTest(H))H.preventDefault(),l.actionManager.executeAction(gs),m();else if(!H.shiftKey&&fs.keyTest(H))H.preventDefault(),l.actionManager.executeAction(fs),m();else if(Tf.keyTest(H))l.actionManager.executeAction(Tf);else if(Cf.keyTest(H))l.actionManager.executeAction(Cf);else if(H.key===T.ESCAPE)H.preventDefault(),C=!0,S();else if(An.keyTest(H))H.preventDefault(),S(),l.actionManager.executeAction(An);else if(H.key===T.ENTER&&H[T.CTRL_OR_CMD]){if(H.preventDefault(),H.isComposing||H.keyCode===229)return;C=!0,S()}else if(H.key===T.TAB||H[T.CTRL_OR_CMD]&&(H.code===ue.BRACKET_LEFT||H.code===ue.BRACKET_RIGHT)){if(H.preventDefault(),H.isComposing)return;H.shiftKey||H.code===ue.BRACKET_LEFT?w():E(),d.dispatchEvent(new Event("input"))}};let g=4,b=" ".repeat(g),x=new RegExp(`^ {1,${g}}`),E=()=>{let{selectionStart:H,selectionEnd:V}=d,K=y(),Q=d.value;K.forEach(X=>{let ie=Q.slice(0,X),he=Q.slice(X);Q=`${ie}${b}${he}`}),d.value=Q,d.selectionStart=H+g,d.selectionEnd=V+g*K.length},w=()=>{let{selectionStart:H,selectionEnd:V}=d,K=y(),Q=[],X=d.value;K.forEach(ie=>{let he=X.slice(ie,ie+g).match(x);if(he){let pe=X.slice(0,ie),He=X.slice(ie+he[0].length);X=`${pe}${He}`,Q.push(ie)}}),d.value=X,Q.length&&(H>Q[Q.length-1]?d.selectionStart=Math.max(H-g,Q[Q.length-1]):d.selectionStart=H,d.selectionEnd=Math.max(d.selectionStart,V-g*Q.length))},y=()=>{let{selectionStart:H,selectionEnd:V,value:K}=d,Q=K.slice(0,H).match(/[^\n]*$/)[0].length;return H=H-Q,K.slice(H,V).split(`
|
|
20
|
-
`).reduce((ie,he,pe,He)=>ie.concat(pe?ie[pe-1]+He[pe-1].length+1:H),[]).reverse()},v=H=>{H.target instanceof HTMLCanvasElement&&(H.preventDefault(),H.stopPropagation())},C=!1,S=()=>{if(U)return;U=!0,_();let H=pn.getScene(n)?.getElement(n.id);if(!H)return;let V=_t(H,l.scene.getNonDeletedElementsMap());if(V){if(d.value.trim()){let K=Ao(V);!K||K!==n.id?B(V,{boundElements:(V.boundElements||[]).concat({type:"text",id:n.id})}):ke(V)&&_l(V)}else B(V,{boundElements:V.boundElements?.filter(K=>!Z(K))});et(H,V,l.scene.getNonDeletedElementsMap())}t({viaKeyboard:C,nextOriginalText:d.value})},_=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,q&&q.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",L),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),z(),W(),d.remove()},L=H=>{window.removeEventListener("pointerup",L);let V=H?.target,K=V instanceof HTMLElement&&V.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=S,K||d.focus()})},N=()=>{d.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",S)},P=H=>{let V=H?.target;if(H.button===nr.WHEEL){V instanceof HTMLTextAreaElement&&(H.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(H)),N();return}let K=V instanceof HTMLElement&&V.classList.contains("properties-trigger");(H.target instanceof HTMLElement||H.target instanceof SVGElement)&&H.target.closest(`.${Yo.SHAPE_ACTIONS_MENU}, .${Yo.ZOOM_ACTIONS}`)&&!ar(H.target)||K?N():H.target instanceof HTMLCanvasElement&&!mt()&&requestAnimationFrame(()=>{S()})},z=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||d.focus()}),W=l.onScrollChangeEmitter.on(()=>{m()}),U=!1;s&&d.select(),L();let q=null;i&&"ResizeObserver"in window?(q=new window.ResizeObserver(()=>{m()}),q.observe(i)):window.addEventListener("resize",m),d.onpointerdown=H=>H.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",P,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d)};var Fw=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{simplify as Sk}from"points-on-curve";var Hw=e=>{let{lassoPath:o,elements:t,elementsSegments:r,intersectedElements:n,enclosedElements:i,simplifyDistance:a}=e,l=o;a&&(l=Sk(o,a)),i.clear();for(let c of t)!n.has(c.id)&&!i.has(c.id)&&(kk(l,c,r)?i.add(c.id):Mk(l,c,r)&&n.add(c.id));return{selectedElementIds:[...n,...i]}},kk=(e,o,t)=>{let r=s0(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>c0(a,r))):!1},Mk=(e,o,t)=>{let r=t.get(o.id);return r?e.reduce((i,a,l)=>(l===0||i.push(Ec(e[l-1],a)),i),[]).some(i=>r.some(a=>yc(i,a,1)!==null)):!1};var cp=class extends Xr{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(Ko(s),Ko(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,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&Z(c)){let m=_t(c,this.app.scene.getNonDeletedElementsMap());m&&(n[m.id]=!0,delete n[c.id])}}for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&ae(c)){let m=_o(this.app.scene.getNonDeletedElementsMap(),c.id);for(let d of m)delete n[d.id]}}let i=lt({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&&le(this.app.scene.getNonDeletedElement(a[0]))?new j(this.app.scene.getNonDeletedElement(a[0])):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(r=>M(r[0],r[1]));if(!this.elementsSegments){this.elementsSegments=new Map;let r=te(this.app.visibleElements);for(let n of this.app.visibleElements){let i=Wc(n,r);this.elementsSegments.set(n.id,i)}}if(t){let{selectedElementIds:r}=Hw({lassoPath:t,elements:this.app.visibleElements,elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}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}};var Lk=2,dp=class extends Xr{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(Ko(s),Ko(l))},fill:()=>r.state.theme===ce.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set);I(this,"segmentsCache",new Map);I(this,"geometricShapesCache",new Map)}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=>M(l[0],l[1]))||[];r=r?.slice(r.length-Lk);let n=this.app.visibleElements.filter(l=>!l.locked),i=te(n),a=r.reduce((l,s,c)=>(c===0||l.push(Ec(r[c-1],s)),l),[]);if(a.length===0)return[];for(let l of n)if(t&&this.elementsToErase.has(l.id)){if(Uw(a,l,this.segmentsCache,this.geometricShapesCache,i,this.app)){let c=l.groupIds.at(-1);if(this.groupsToErase.has(c)){let m=Fe(this.app.scene.getNonDeletedElementsMap(),c);for(let d of m)this.elementsToErase.delete(d.id);this.groupsToErase.delete(c)}if(_e(l)&&this.elementsToErase.delete(l.containerId),pt(l)){let m=Ao(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&Uw(a,l,this.segmentsCache,this.geometricShapesCache,i,this.app)){let c=l.groupIds.at(-1);if(!this.groupsToErase.has(c)){let m=Fe(this.app.scene.getNonDeletedElementsMap(),c);for(let d of m)this.elementsToErase.add(d.id);this.groupsToErase.add(c)}if(pt(l)){let m=Ao(l);m&&this.elementsToErase.add(m)}_e(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(),this.segmentsCache.clear()}},Uw=(e,o,t,r,n,i)=>{let a=r.get(o.id);a||(a=Or(o,n),r.set(o.id,a));let l=e[e.length-1][1];if(P0(o)&&Zc(l,a))return!0;let s=t.get(o.id);return s||(s=Wc(o,n),t.set(o.id,s)),e.some(c=>s?.some(m=>yc(c,m,i.getElementHitThreshold())!==null))};import{jsx as Ho,jsxs as Gw}from"react/jsx-runtime";var Ak=()=>Gw("div",{"data-testid":"brave-measure-text-error",children:[Ho("p",{children:Ho(Zt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Ho("span",{style:{fontWeight:600},children:e})})}),Ho("p",{children:Ho(Zt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Ho("span",{style:{fontWeight:600},children:e})})}),Ho("p",{children:Ho(Zt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Ho("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Ho("p",{children:Ho(Zt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Ho("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>Gw("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Vw=Ak;import Rk from"clsx";import Nk from"react";import{useLayoutEffect as _k,useRef as Yw,useEffect as Ww}from"react";import{unstable_batchedUpdates as Dk}from"react-dom";import{jsx as Pk}from"react/jsx-runtime";var Kw=({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 c=Yw(null);Ww(()=>{let d=c.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=u=>{if(u.key===T.TAB){let g=Tl(d),{activeElement:b}=document,x=g.findIndex(E=>E===b);b===d?(u.shiftKey?g[g.length-1]?.focus():g[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(g[g.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===g.length-1&&!u.shiftKey&&(g[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let m=Yw(null);return _k(()=>{if(n&&c.current&&t!=null&&o!=null){let d=c.current,{width:p,height:u}=d.getBoundingClientRect();if(m.current?.top===t&&m.current?.left===o)return;m.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]),Ww(()=>{if(r){let d=p=>{c.current?.contains(p.target)||Dk(()=>r(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),Pk("div",{className:"popover",ref:c,tabIndex:-1,children:e})};import{jsx as el,jsxs as Ok}from"react/jsx-runtime";var bt="separator",Zw=Nk.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=ur(),a=Cn(),l=o.reduce((s,c)=>(c&&(c===bt||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return el(Kw,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:el("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===bt)return!l[c-1]||l[c-1]===bt?null:el("hr",{className:"context-menu-item-separator"},c);let m=s.name,d="";return s.label&&(typeof s.label=="function"?d=f(s.label(a,i,e.app)):d=f(s.label)),el("li",{"data-testid":m,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:Ok("button",{type:"button",className:Rk("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[el("div",{className:"context-menu-item__label",children:d}),el("kbd",{className:"context-menu-item__shortcut",children:m?ct(m):""})]})},c)})})})});import{jsx as x1,jsxs as Xw}from"react/jsx-runtime";var Bk=({height:e,width:o,userToFollow:t,onDisconnect:r})=>x1("div",{className:"follow-mode",style:{width:o,height:e},children:Xw("div",{className:"follow-mode__badge",children:[Xw("div",{className:"follow-mode__badge__label",children:["Following"," ",x1("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),x1("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:Eo})]})}),$w=Bk;import Ys from"clsx";import V7 from"react";import zk from"clsx";import{useState as Fk,useEffect as Hk}from"react";import{jsx as E1,jsxs as Uk}from"react/jsx-runtime";var mp=({delay:e,theme:o})=>{let[t,r]=Fk(!!e);return Hk(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:Uk("div",{className:zk("LoadingMessage",{"LoadingMessage--dark":o===ce.DARK}),children:[E1("div",{children:E1(Lt,{})}),E1("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import Gk from"clsx";import{jsx as qw,jsxs as Yk}from"react/jsx-runtime";var Vk="medium",jw={CHECKED:yi,UNCHECKED:En},pp=e=>Yk("label",{className:Gk("ToolIcon ToolIcon__lock",`ToolIcon_size_${Vk}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[qw("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),qw("div",{className:"ToolIcon__icon",children:e.checked?jw.CHECKED:jw.UNCHECKED})]});import Wk from"clsx";import{jsx as Kk}from"react/jsx-runtime";var up=({children:e,side:o,className:t})=>Kk("div",{className:Wk("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import Zk from"clsx";import{jsx as Xk}from"react/jsx-runtime";var hp=e=>Xk(ee,{className:Zk("Shape",{fillable:!1}),type:"radio",icon:Ql,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:T.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":T.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{jsx as Jw}from"react/jsx-runtime";var $k=({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===At.name&&e.openSidebar.tab===kr&&e.searchMatches?.length)return f("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(ao(e))return f("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?f("hints.linearElementMulti"):n.type==="arrow"?f("hints.arrowTool",{arrowShortcut:R("A")}):f("hints.linearElement");if(n.type==="freedraw")return f("hints.freeDraw");if(n.type==="text")return f("hints.text");if(n.type==="embeddable")return f("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return f("hints.placeImage");let c=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let m=c[0];return le(m)&&m.points.length===2?f("hints.lockAngle"):fe(m)?f("hints.resizeImage"):f("hints.resize")}if(a&&l==="mouse")return f("hints.rotate");if(c.length===1&&Z(c[0]))return f("hints.text_selected");if(e.editingTextElement)return f("hints.text_editing");if(e.croppingElementId)return f("hints.leaveCropEditor");if(c.length===1&&fe(c[0]))return f("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.editingLinearElement)return[f("hints.deepBoxSelect")];if(Nn(r)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping");if(!c.length&&!o)return[f("hints.canvasPanning")];if(c.length===1){if(le(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected"):f("hints.lineEditor_nothingSelected"):f("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&Rr(c[0]))return ii(c[0])?IE(c[0],r.scene.getNonDeletedElementsMap())?[f("hints.bindTextToElement"),f("hints.createFlowchart")]:[f("hints.bindTextToElement"),f("hints.createFlowchart")]:f("hints.bindTextToElement")}}return null},gp=({appState:e,isMobile:o,device:t,app:r})=>{let n=$k({appState:e,isMobile:o,device:t,app:r});if(!n)return null;let i=Array.isArray(n)?n.map(a=>R(a).replace(/\. ?$/,"")).join(". "):R(n);return Jw("div",{className:"HintViewer",children:Jw("span",{children:i})})};import jk from"clsx";import{jsx as Qw,jsxs as Jk}from"react/jsx-runtime";var qk="medium",fp=e=>e.penDetected?Jk("label",{className:jk("ToolIcon ToolIcon__penMode",`ToolIcon_size_${qk}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Qw("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Qw("div",{className:"ToolIcon__icon",children:wh})]}):null;import{Fragment as Qk,jsx as e3,jsxs as eM}from"react/jsx-runtime";var Bn=({heading:e,children:o,...t})=>{let{id:r}=gt(),n=e3("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:f(`headings.${e}`)});return e3("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):eM(Qk,{children:[n,o]})})};import{jsx as y1}from"react/jsx-runtime";var t3=({onHomeButtonClick:e})=>y1("label",{title:`${ir(f("toolBar.library"))} \u2014 0`,children:y1("div",{className:"library-button",onClick:e,children:y1("div",{children:ch})})});import{Fragment as tM,jsx as wt,jsxs as $r}from"react/jsx-runtime";var o3=({appState:e,elements:o,actionManager:t,setAppState:r,onLockToggle:n,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:c,device:m,renderWelcomeScreen:d,UIOptions:p,app:u,onHomeButtonClick:g})=>{let{WelcomeScreenCenterTunnel:b,MainMenuTunnel:x,DefaultSidebarTriggerTunnel:E}=Ze(),w=()=>$r(up,{side:"top",className:"App-top-bar",children:[d&&wt(b.Out,{}),wt(Bn,{heading:"shapes",children:v=>wt(It.Col,{gap:4,align:"center",children:$r(It.Row,{gap:1,className:"App-toolbar-container",children:[$r(yt,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[v,wt(It.Row,{gap:1,children:wt(qm,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),$r("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&wt(E.Out,{}),wt(fp,{checked:e.penMode,onChange:()=>a(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),wt(pp,{checked:e.activeTool.locked,onChange:n,title:f("toolBar.lock"),isMobile:!0}),wt(hp,{checked:jo(e),onChange:()=>i(),title:f("toolBar.hand"),isMobile:!0})]}),wt("div",{className:"mobile-misc-tools-container-left",children:wt(t3,{onHomeButtonClick:g})})]})})}),wt(gp,{appState:e,isMobile:!0,device:m,app:u})]}),y=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?wt("div",{className:"App-toolbar-content",children:wt(x.Out,{})}):$r("div",{className:"App-toolbar-content",children:[wt(x.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),$r("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return $r(tM,{children:[c(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&w(),wt("div",{className:"App-bottom-bar",style:{marginBottom:yr+er*2,marginLeft:yr+er*2,marginRight:yr+er*2},children:$r(yt,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Oa(e,o)?wt(Bn,{className:"App-mobile-menu",heading:"selectedShapeActions",children:wt(jm,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,$r("footer",{className:"App-toolbar",children:[y(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&wt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(v=>({...gi(o,v)}))},children:f("buttons.scrollBackToContent")})]})]})})]})};import oM,{useLayoutEffect as rM,useRef as nM,useState as iM}from"react";import{jsx as Ns,jsxs as aM}from"react/jsx-runtime";var r3=e=>{let o=nM(null),[t,r]=iM(null);return rM(()=>{if(!e.spreadsheet)return;let n=h2(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await pa({data:{elements:n,appState:{exportBackground:!1,viewBackgroundColor:Mo},files:null},config:{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]),Ns("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:Ns("div",{ref:o})})},n3=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=st(),n=oM.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),ye("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Ns(dt,{size:"small",onCloseRequest:n,title:f("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:aM("div",{className:"container",children:[Ns(r3,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),Ns(r3,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as zn from"@radix-ui/react-popover";import i3 from"clsx";import bp,{useLayoutEffect as lM}from"react";import{Fragment as pM,jsx as vr,jsxs as xp}from"react/jsx-runtime";var sM=4,cM=8,dM=({shouldWrap:e,children:o,username:t})=>e?vr(vo,{label:t||"Unknown user",children:o}):vr(pM,{children:o}),v1=({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 vr(dM,{username:o.username,shouldWrap:n,children:l},t)},mM=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Ep=bp.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=ft(),i=new Map;t.forEach((b,x)=>{let E=b.id||x;i.set(E,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=bp.useState(""),c=a.filter(b=>b.username?.toLowerCase().includes(l)),m=bp.useRef(null);lM(()=>{if(m.current){let b=E=>{let w=Math.max(1,Math.min(8,Math.floor(E/38)));p(w)};if(b(m.current.clientWidth),!dl)return;let x=new ResizeObserver(E=>{for(let w of E){let{width:y}=w.contentRect;b(y)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[d,p]=bp.useState(sM),g=a.slice(0,d-1).map(b=>v1({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?vr("div",{className:i3("UserList UserList_mobile",e),children:a.map(b=>v1({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):vr("div",{className:"UserList__wrapper",ref:m,children:xp("div",{className:i3("UserList",e),style:{"--max-avatars":d},children:[g,a.length>d-1&&xp(zn.Root,{children:[xp(zn.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),vr(zn.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:xp(yt,{padding:2,children:[a.length>=cM&&vr(om,{placeholder:f("quickSearch.placeholder"),onChange:s}),vr(rm,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:c.length>0?[vr("div",{className:"hint",children:f("userList.hint.text")}),c.map(b=>v1({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),vr(zn.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||!Qe(n,i,mM))return!1}return!0});import yp from"clsx";import{jsx as uM}from"react/jsx-runtime";var a3=e=>uM("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${f("helpDialog.title")} \u2014 ?`,"aria-label":f("helpDialog.title"),children:vi});import{jsx as wr,jsxs as w1}from"react/jsx-runtime";var l3=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=Ze(),a=Ce(),l=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return w1("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[wr("div",{className:yp("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:wr(It.Col,{gap:2,children:w1(Bn,{heading:"canvasActions",children:[wr(jv,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&wr(qv,{renderAction:o.renderAction,className:yp("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),l&&wr(Qv,{renderAction:o.renderAction,className:yp("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),wr(n.Out,{}),wr("div",{className:yp("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:w1("div",{style:{position:"relative"},children:[r&&wr(i.Out,{}),wr(a3,{onClick:()=>o.executeAction(_n)})]})}),wr(Jv,{actionManager:o,showExitZenModeBtn:t})]})},s3=l3;l3.displayName="Footer";import vM from"clsx";import{useEffect as x3,useLayoutEffect as E3,useRef as _1,useState as wM,forwardRef as y3,useImperativeHandle as TM,useCallback as f3}from"react";import gM from"clsx";import{useContext as fM}from"react";import hM from"react";var vp=hM.createContext({});import{jsx as T1,jsxs as c3}from"react/jsx-runtime";var C1=({children:e,className:o})=>{let t=Ce(),r=fM(vp),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return c3("div",{className:gM("sidebar__header",o),"data-testid":"sidebar-header",children:[e,c3("div",{className:"sidebar__header__buttons",children:[n&&T1(vo,{label:f("labels.sidebarLock"),children:T1(Co,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:ph})}),T1(Co,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":f("buttons.close"),children:Eo})]})]})};C1.displayName="SidebarHeader";import*as m3 from"@radix-ui/react-tabs";import{jsx as d3}from"react/jsx-runtime";var I1=({children:e,tab:o,onSelect:t,...r})=>d3(m3.Trigger,{value:o,asChild:!0,onSelect:t,children:d3("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});I1.displayName="SidebarTabTrigger";import*as p3 from"@radix-ui/react-tabs";import{jsx as bM}from"react/jsx-runtime";var S1=({children:e,...o})=>bM(p3.List,{className:"sidebar-triggers",...o,children:e});S1.displayName="SidebarTabTriggers";import xM from"clsx";import{jsx as k1,jsxs as u3}from"react/jsx-runtime";var M1=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=Ie(),c=Re();return u3("label",{title:r,className:"sidebar-trigger__label-element",children:[k1("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let d=m.target.checked;s({openSidebar:d?{name:e,tab:o}:null}),i?.(d)},checked:c.openSidebar?.name===e,"aria-label":r,"aria-keyshortcuts":"0"}),u3("div",{className:xM("sidebar-trigger",a),style:l,children:[t&&k1("div",{children:t}),n&&k1("div",{className:"sidebar-trigger__label",children:n})]})]})};M1.displayName="SidebarTrigger";import*as h3 from"@radix-ui/react-tabs";import{jsx as EM}from"react/jsx-runtime";var L1=({children:e,...o})=>{let t=Re(),r=Ie();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return EM(h3.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};L1.displayName="SidebarTabs";import*as g3 from"@radix-ui/react-tabs";import{jsx as yM}from"react/jsx-runtime";var A1=({tab:e,children:o,...t})=>yM(g3.Content,{...t,value:e,"data-testid":e,children:o});A1.displayName="SidebarTab";import{jsx as b3}from"react/jsx-runtime";import{createElement as CM}from"react";var Os=De(!1),v3=y3(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{Ge()&&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=Ie(),s=xn(Os);E3(()=>(s(!!r),()=>{s(!1)}),[s,r]);let c=_1({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=Ki(c.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let m=_1(null);TM(a,()=>m.current);let d=Ce(),p=f3(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Ia(m,f3(u=>{u.target.closest(".sidebar-trigger")||(!r||!d.editor.canFitSidebar)&&p()},[p,r,d.editor.canFitSidebar])),x3(()=>{let u=g=>{g.key===T.ESCAPE&&(!r||!d.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,r,d.editor.canFitSidebar]),b3(yt,{...i,className:vM("sidebar",{"sidebar--docked":r},n),ref:m,children:b3(vp.Provider,{value:c.current,children:o})})});v3.displayName="SidebarInner";var Uo=Object.assign(y3((e,o)=>{let t=Re(),{onStateChange:r}=e,n=_1(t.openSidebar);x3(()=>{(!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]=wM(!1);return E3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?CM(v3,{...e,ref:o,key:e.name}):null}),{Header:C1,TabTriggers:S1,TabTrigger:I1,Tabs:L1,Tab:A1,Trigger:M1});Uo.displayName="Sidebar";import{useLayoutEffect as IM,useRef as SM}from"react";import{jsx as kM}from"react/jsx-runtime";var jr=(e,o)=>{let t=De(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=Ze(),[,a]=i(t),l=SM({preferHost:!1,counter:0});return IM(()=>{let s=l.current;return a(c=>{let m=c+1;return s.counter=m,m}),()=>{a(c=>{let m=c-1;return s.counter=m,m||(s.preferHost=!1),m})}},[a]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:kM(o,{...n})};return r.displayName=e,r};var R1={};Js(R1,{ChangeCanvasBackground:()=>N3,ClearCanvas:()=>P3,CommandPalette:()=>A3,Export:()=>O3,Help:()=>D3,LiveCollaborationTrigger:()=>z3,LoadScene:()=>k3,SaveAsImage:()=>L3,SaveToActiveFile:()=>M3,SearchMenu:()=>_3,Socials:()=>B3,ToggleTheme:()=>R3});import _M from"clsx";var D1=De({active:!1});async function w3({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{kt.set(D1,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import MM from"clsx";import{jsx as T3,jsxs as LM}from"react/jsx-runtime";var wp=function({onChange:e,value:o,choices:t,name:r}){return T3("div",{className:"RadioGroup",children:t.map(n=>LM("div",{className:MM("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[T3("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 AM,jsx as P1,jsxs as C3}from"react/jsx-runtime";var I3=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=Ce();return C3(AM,{children:[C3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[P1("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),P1(wp,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&P1("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};I3.displayName="DropdownMenuItemContentRadio";var S3=I3;import{Fragment as DM,jsx as Tt,jsxs as F3}from"react/jsx-runtime";var k3=()=>{let{t:e}=ut(),o=ft(),t=Cn();return o.isActionEnabled(_i)?Tt(Wt,{icon:wi,onSelect:async()=>{(!t.length||await w3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:Tt(Zt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>Tt("strong",{children:n}),br:()=>Tt("br",{})})}))&&o.executeAction(_i)},"data-testid":"load-button",shortcut:ct("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};k3.displayName="LoadScene";var M3=()=>{let{t:e}=ut(),o=ft();return o.isActionEnabled(An)?Tt(Wt,{shortcut:ct("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(An),icon:Ah,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};M3.displayName="SaveToActiveFile";var L3=()=>{let e=Ie(),{t:o}=ut();return Tt(Wt,{icon:$l,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:ct("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};L3.displayName="SaveAsImage";var A3=e=>{let o=Ie(),{t}=ut();return Tt(Wt,{icon:os,"data-testid":"command-palette-button",onSelect:()=>{ye("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:ct("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};A3.displayName="CommandPalette";var _3=e=>{let{t:o}=ut(),t=ft();return Tt(Wt,{icon:so,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction($a)},shortcut:ct("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};_3.displayName="SearchMenu";var D3=()=>{let{t:e}=ut(),o=ft();return Tt(Wt,{"data-testid":"help-menu-item",icon:vi,onSelect:()=>o.executeAction(_n),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};D3.displayName="Help";var P3=()=>{let{t:e}=ut(),o=xn(Oi);return ft().isActionEnabled(fr)?Tt(Wt,{icon:lo,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};P3.displayName="ClearCanvas";var R3=e=>{let{t:o}=ut(),t=Re(),r=ft(),n=ct("toggleTheme");return r.isActionEnabled(Mn)?e?.allowSystemTheme?Tt(S3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:ce.LIGHT,label:Ea,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:ce.DARK,label:xa,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:Vg,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):Tt(Wt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===ce.DARK?ce.LIGHT:ce.DARK);else return r.executeAction(Mn)},icon:t.theme===ce.DARK?Ea:xa,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===ce.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===ce.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};R3.displayName="ToggleTheme";var N3=()=>{let{t:e}=ut(),o=Re(),t=ft(),r=hr();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:F3("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")})]})};N3.displayName="ChangeCanvasBackground";var O3=()=>{let{t:e}=ut(),o=Ie();return Tt(Wt,{icon:yn,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};O3.displayName="Export";var B3=()=>{let{t:e}=ut();return F3(DM,{children:[Tt(Wa,{icon:Zl,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),Tt(Wa,{icon:Mh,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),Tt(Wa,{icon:kh,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};B3.displayName="Socials";var z3=({onSelect:e,isCollaborating:o})=>{let{t}=ut();return Tt(Wt,{"data-testid":"collab-button",icon:jl,className:_M({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};z3.displayName="LiveCollaborationTrigger";import{jsx as Tp,jsxs as N1}from"react/jsx-runtime";var PM=Object.assign(jr("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ze(),r=Ce(),n=Re(),i=Ie(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return Tp(t.In,{children:N1(Ne,{open:n.openMenu==="canvas",children:[Tp(Ne.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Kl}),N1(Ne.Content,{onClickOutside:a,onSelect:sn(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&N1("fieldset",{className:"UserList-Wrapper",children:[Tp("legend",{children:f("labels.collaborators")}),Tp(Ep,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Ne.Trigger,Item:Ne.Item,ItemLink:Ne.ItemLink,ItemCustom:Ne.ItemCustom,Group:Ne.Group,Separator:Ne.Separator,DefaultItems:R1}),Ot=PM;import RM from"clsx";import{forwardRef as NM,useState as OM}from"react";import{jsx as Cp,jsxs as BM}from"react/jsx-runtime";var Fn=NM(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:c},m)=>{let[d,p]=OM(!1),u=async b=>{let x=t?.(b);if(ln(x)){let E=window.setTimeout(()=>{p(!0)},50);try{await x}catch(w){if(w instanceof da)console.warn(w);else throw w}finally{clearTimeout(E),p(!1)}}},g=d?"loading":c;return i=g==="success"?"success":i,Cp("button",{className:RM("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:m,disabled:g==="loading"||g==="success",children:BM("div",{className:"ExcButton__contents",children:[g==="loading"?Cp(Lt,{className:"ExcButton__statusIcon"}):g==="success"&&Cp("div",{className:"ExcButton__statusIcon",children:Cg}),o&&Cp("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as tl,jsxs as HM}from"react/jsx-runtime";var Ip=({title:e,children:o,actionLabel:t,onClick:r})=>HM("div",{className:"OverwriteConfirm__Actions__Action",children:[tl("h4",{children:e}),tl("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),tl(Fn,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),zM=()=>{let{t:e}=ut(),o=ft(),t=Ie();return tl(Ip,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Em,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},FM=()=>{let{t:e}=ut(),o=ft();return tl(Ip,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Na,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},O1=Object.assign(({children:e})=>tl("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:zM,SaveToDisk:FM});import{jsx as Hn,jsxs as H3}from"react/jsx-runtime";var Sp=Object.assign(jr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ze(),[t,r]=we(D1);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return Hn(o.In,{children:Hn(dt,{onCloseRequest:n,title:!1,size:916,children:H3("div",{className:"OverwriteConfirm",children:[Hn("h3",{children:t.title}),H3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Hn("div",{className:"OverwriteConfirm__Description__icon",children:Ig}),Hn("div",{children:t.description}),Hn("div",{className:"OverwriteConfirm__Description__spacer"}),Hn(Fn,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Hn(O1,{children:e})]})})})}),{Actions:O1,Action:Ip});import oL from"clsx";import UM from"clsx";import GM from"lodash.debounce";import{Fragment as VM,memo as YM,useEffect as Bs,useRef as B1,useState as U3}from"react";import{Fragment as tL,jsx as Io,jsxs as zs}from"react/jsx-runtime";var WM=De(""),z1=De(null),KM=350,V3=()=>{let e=st(),o=Ie(),t=B1(null),[r,n]=we(WM),i=r.trim(),[a,l]=U3(!1),[s,c]=U3({nonce:null,items:[]}),m=B1(null),d=B1(void 0),[p,u]=we(z1),g=e.scene.getNonDeletedElementsMap();Bs(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==d.current)&&(m.current=null,G3(i,e,(y,v)=>{c({nonce:_r(),items:y}),m.current=i,d.current=e.scene.getSceneNonce(),o({searchMatches:y.map(C=>({id:C.textElement.id,focus:!1,matchedLines:C.matchedLines}))})}))},[a,i,g,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)};Bs(()=>{o(y=>({searchMatches:y.searchMatches.map((v,C)=>C===p?{...v,focus:!0}:{...v,focus:!1})}))},[p,o]),Bs(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=Yt({text:y.searchQuery,x:y.textElement.x+(y.matchedLines[0]?.offsetX??0),y:y.textElement.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:y.textElement.fontSize,fontFamily:y.textElement.fontFamily}),S=14,_=y.textElement.fontSize,L=_*v<S;if(!ta([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())||L){let N;L?_>=S?N={fitToContent:!0}:N={fitToViewport:!0,maxZoom:Lo(S/_,1)}:N={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...N,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),Bs(()=>()=>{u(null),m.current=null,d.current=void 0,o({searchMatches:[]}),l(!1)},[o,u]);let E=wn({goToNextItem:b,goToPreviousItem:x,searchMatches:s});Bs(()=>{let y=v=>{if(v.key===T.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}v[T.CTRL_OR_CMD]&&v.key===T.F&&(v.preventDefault(),v.stopPropagation(),t.current?.matches(":focus")?o({openSidebar:null}):(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())),v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&E.searchMatches.items.length&&(v.key===T.ENTER&&(v.stopPropagation(),E.goToNextItem()),v.key===T.ARROW_UP?(v.stopPropagation(),E.goToPreviousItem()):v.key===T.ARROW_DOWN&&(v.stopPropagation(),E.goToNextItem()))};return We(window,"keydown",y,{capture:!0,passive:!1})},[o,E,e]);let w=`${s.items.length} ${s.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return zs("div",{className:"layer-ui__search",children:[Io("div",{className:"layer-ui__search-header",children:Io(Xa,{className:Yo.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:f("search.placeholder"),icon:so,onChange:y=>{n(y),l(!0);let v=y.trim();G3(v,e,(C,S)=>{c({nonce:_r(),items:C}),u(S),m.current=v,d.current=e.scene.getSceneNonce(),o({searchMatches:C.map(_=>({id:_.textElement.id,focus:!1,matchedLines:_.matchedLines}))}),l(!1)})},selectOnRender:!0})}),zs("div",{className:"layer-ui__search-count",children:[s.items.length>0&&zs(tL,{children:[p!==null&&p>-1?zs("div",{children:[p+1," / ",w]}):Io("div",{children:w}),zs("div",{className:"result-nav",children:[Io(Co,{onSelect:()=>{b()},className:"result-nav-btn",children:ns}),Io(Co,{onSelect:()=>{x()},className:"result-nav-btn",children:qg})]})]}),s.items.length===0&&i&&m.current&&Io("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),Io(jM,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},ZM=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 Io("div",{tabIndex:-1,className:UM("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Io("div",{className:"preview-text",children:o.flatMap((t,r)=>Io(VM,{children:r===2?Io("b",{children:t}):t},r))})})},XM=e=>Io("div",{className:"layer-ui__search-result-container",children:e.matches.items.map((o,t)=>Io(ZM,{searchQuery:e.searchQuery,preview:o.preview,highlighted:t===e.focusIndex,onClick:()=>e.onItemClick(t)},o.textElement.id+o.index))}),$M=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,jM=YM(XM,$M),qM=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),c=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;c=c.length>m?c.slice(-m):c;let d=e.slice(o+t.length),p=d.split(/\s+/),u=!d.startsWith(" "),g=u?6:5,b=(u?"":" ")+p.slice(0,g).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+b,moreBefore:s>0,moreAfter:p.length>g}},JM=(e,o)=>{let t=e.split(`
|
|
21
|
-
`)
|
|
22
|
-
`)
|
|
23
|
-
`)
|
|
19
|
+
${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Sw=async(e,t,o,n)=>{let{exportBackground:r,viewBackgroundColor:i,fileHandle:a}=t,l=mE(a);if(!a||!pE(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");t={...t,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:c}=mi(e,t,!1);return await pi({type:l,data:{elements:s,appState:t,files:o},config:{exportBackground:r,viewBackgroundColor:i,name:n,fileHandle:a,exportingFrame:c}}),{fileHandle:a}};import{Fragment as BP,jsx as Mn,jsxs as OP}from"react/jsx-runtime";var Xd=N({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,t,o)=>({appState:{...t,name:o},captureUpdate:Ho.EVENTUALLY}),PanelComponent:({appState:e,updateData:t,appProps:o,data:n,app:r})=>Mn(dw,{label:f("labels.fileTitle"),value:r.getName(),onChange:i=>t(i),ignoreFocus:n?.ignoreFocus??!1})}),kw=N({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,t,o)=>({appState:{...t,exportScale:o},captureUpdate:Ho.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o})=>{let n=NP(e),i=Le(n,t)?J(n,t):n,a=(l,s,c)=>{let[,,d,m]=cE(l).map(p=>Math.trunc(p*c));return[d+s*2,m+s*2]};return Mn(BP,{children:RP.map(l=>{let[s,c]=a(i,DP,l),d=`${f("imageExportDialog.label.scale")} ${l}x (${s}x${c})`;return Mn($,{size:"small",type:"radio",icon:`${l}x`,name:"export-canvas-scale",title:d,"aria-label":d,id:"export-canvas-scale",checked:l===t.exportScale,onChange:()=>o(l)},l)})})}}),$d=N({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,t,o)=>({appState:{...t,exportBackground:o},captureUpdate:Ho.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>Mn(is,{checked:e.exportBackground,onChange:o=>t(o),children:f("imageExportDialog.label.withBackground")})}),Zd=N({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,t,o)=>({appState:{...t,exportEmbedScene:o},captureUpdate:Ho.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>OP(is,{checked:e.exportEmbedScene,onChange:o=>t(o),children:[f("imageExportDialog.label.embedScene"),Mn(ro,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:Mn("div",{className:"excalidraw-tooltip-icon",children:bg})})]})}),ur=N({name:"saveToActiveFile",label:"buttons.save",icon:Qn,trackEvent:{category:"export"},predicate:(e,t,o,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!t.fileHandle&&!t.viewModeEnabled,perform:async(e,t,o,n)=>{let r=!!t.fileHandle;try{let{fileHandle:i}=kc(t.fileHandle)?await Sw(e,t,n.files,n.getName()):await Tc(e,t,n.files,n.getName());return{captureUpdate:Ho.EVENTUALLY,appState:{...t,fileHandle:i,toast:r?{message:i?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):f("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:Ho.EVENTUALLY}}},keyTest:e=>e.key===ga.S&&e[ga.CTRL_OR_CMD]&&!e.shiftKey}),ha=N({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Qn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,t,o,n)=>{try{let{fileHandle:r}=await Tc(e,{...t,fileHandle:null},n.files,n.getName());return{captureUpdate:Ho.EVENTUALLY,appState:{...t,openDialog:null,fileHandle:r,toast:{message:f("toast.fileSaved")}}}}catch(r){return r?.name!=="AbortError"?console.error(r):console.warn(r),{captureUpdate:Ho.EVENTUALLY}}},keyTest:e=>e.key===ga.S&&e.shiftKey&&e[ga.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Mn($,{type:"button",icon:pg,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:me().editor.isMobile,hidden:!Oi,onClick:()=>e(null),"data-testid":"save-as-button"})}),ui=N({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,t,o,n)=>!!n.props.UIOptions.canvasActions.loadScene&&!t.viewModeEnabled,perform:async(e,t,o,n)=>{try{let{elements:r,appState:i,files:a}=await zu(t,e);return{elements:r,appState:i,files:a,captureUpdate:Ho.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...t,errorMessage:r.message},files:n.files,captureUpdate:Ho.EVENTUALLY}}},keyTest:e=>e[ga.CTRL_OR_CMD]&&e.key===ga.O}),Mw=N({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,t,o)=>({appState:{...t,exportWithDarkMode:o},captureUpdate:Ho.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>Mn("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Mn(sw,{value:e.exportWithDarkMode?If.DARK:If.LIGHT,onChange:o=>{t(o===If.DARK)},title:f("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as FP,DEFAULT_FONT_FAMILY as HP,DEFAULT_TEXT_ALIGN as zP,CODES as Lw,KEYS as Aw,getLineHeight as GP}from"@excalidraw/common";import{newElementWith as jd}from"@excalidraw/element";import{hasBoundTextElement as UP,canApplyRoundnessTypeToElement as YP,getDefaultRoundnessTypeForElement as WP,isFrameLikeElement as VP,isArrowElement as KP,isExcalidrawElement as XP,isTextElement as Cf}from"@excalidraw/element";import{getBoundTextElement as $P,redrawTextBoundingBox as ZP}from"@excalidraw/element";import{CaptureUpdateAction as Sf}from"@excalidraw/element";var Pw="{}",qd=N({name:"copyStyles",label:"labels.copyStyles",icon:od,trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=[],i=e.find(a=>t.selectedElementIds[a.id]);if(r.push(i),i&&UP(i)){let a=$P(i,n.scene.getNonDeletedElementsMap());r.push(a)}return i&&(Pw=JSON.stringify(r)),{appState:{...t,toast:{message:f("toast.copyStyles")}},captureUpdate:Sf.EVENTUALLY}},keyTest:e=>e[Aw.CTRL_OR_CMD]&&e.altKey&&e.code===Lw.C}),Jd=N({name:"pasteStyles",label:"labels.pasteStyles",icon:od,trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=JSON.parse(Pw),i=r[0],a=r[1];if(!XP(i))return{elements:e,captureUpdate:Sf.EVENTUALLY};let l=J(e,t,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let d=i;if(Cf(c)&&c.containerId&&(d=a),!d)return c;let m=jd(c,{backgroundColor:d?.backgroundColor,strokeWidth:d?.strokeWidth,strokeColor:d?.strokeColor,strokeStyle:d?.strokeStyle,fillStyle:d?.fillStyle,opacity:d?.opacity,roughness:d?.roughness,roundness:d.roundness?YP(d.roundness.type,c)?d.roundness:WP(c):null});if(Cf(m)){let p=d.fontSize||FP,u=d.fontFamily||HP;m=jd(m,{fontSize:p,fontFamily:u,textAlign:d.textAlign||zP,lineHeight:d.lineHeight||GP(u)});let g=null;m.containerId&&(g=l.find(b=>Cf(m)&&b.id===m.containerId)||null),ZP(m,g,n.scene)}return m.type==="arrow"&&KP(d)&&(m=jd(m,{startArrowhead:d.startArrowhead,endArrowhead:d.endArrowhead})),VP(c)&&(m=jd(m,{roundness:null,backgroundColor:"transparent"})),m}return c}),captureUpdate:Sf.IMMEDIATELY}},keyTest:e=>e[Aw.CTRL_OR_CMD]&&e.altKey&&e.code===Lw.V});import{KEYS as jP}from"@excalidraw/common";import{getNonDeletedElements as qP}from"@excalidraw/element";import{showSelectedShapeActions as JP}from"@excalidraw/element";import{CaptureUpdateAction as kf}from"@excalidraw/element";import{jsx as Rw}from"react/jsx-runtime";var _w=N({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="canvas"?null:"canvas"},captureUpdate:kf.EVENTUALLY}),PanelComponent:({appState:e,updateData:t})=>Rw($,{type:"button",icon:Sl,"aria-label":f("buttons.menu"),onClick:t,selected:e.openMenu==="canvas"})}),Dw=N({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,t)=>({appState:{...t,openMenu:t.openMenu==="shape"?null:"shape"},captureUpdate:kf.EVENTUALLY}),PanelComponent:({elements:e,appState:t,updateData:o})=>Rw($,{visible:JP(t,qP(e)),type:"button",icon:ug,"aria-label":f("buttons.edit"),onClick:o,selected:t.openMenu==="shape"})}),gr=N({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:lg,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,t,o,{focusContainer:n})=>(t.openDialog?.name==="help"&&n(),{appState:{...t,openDialog:t.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:kf.EVENTUALLY}),keyTest:e=>e.key===jP.QUESTION_MARK});import{getNonDeletedElements as em}from"@excalidraw/element";import{newElementWith as Ow}from"@excalidraw/element";import{isBoundToContainer as QP}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as e_,getElementsInResizingFrame as t_,getFrameLikeElements as o_,getRootElements as n_,groupByFrameLikes as r_,removeElementsFromFrame as i_,replaceAllElementsInFrame as a_}from"@excalidraw/element";import{KEYS as tm,randomId as l_,arrayToMap as Mf,getShortcutKey as Fw}from"@excalidraw/common";import{getSelectedGroupIds as Qd,selectGroup as s_,selectGroupsForSelectedElements as c_,getElementsInGroup as Nw,addToGroup as d_,removeFromSelectedGroups as m_,isElementInGroup as Hw}from"@excalidraw/element";import{syncMovedIndices as p_}from"@excalidraw/element";import{CaptureUpdateAction as ms}from"@excalidraw/element";import{jsx as fa}from"react/jsx-runtime";var u_=e=>{if(e.length>=2){let t=e[0].groupIds;for(let o of t)if(e.reduce((n,r)=>n&&Hw(r,o),!0))return!0}return!1},Bw=(e,t,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!u_(n)&&!e_(n)},om=N({name:"group",label:"labels.group",icon:e=>fa(Jc,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=n_(n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:t,elements:e,captureUpdate:ms.EVENTUALLY};let i=Qd(t);if(i.length===1){let x=i[0],w=new Set(Nw(e,x).map(T=>T.id)),E=new Set(r.map(T=>T.id));if(new Set([...Array.from(w),...Array.from(E)]).size===w.size)return{appState:t,elements:e,captureUpdate:ms.EVENTUALLY}}let a=[...e];new Set(r.map(x=>x.frameId)).size>1&&r_(r).forEach((w,E)=>{i_(w,n.scene.getNonDeletedElementsMap())});let s=l_(),c=Mf(r);a=a.map(x=>c.get(x.id)?Ow(x,{groupIds:d_(x.groupIds,s,t.editingGroupId)}):x);let d=Nw(a,s),m=d[d.length-1],p=a.lastIndexOf(m),u=a.slice(p+1),g=a.slice(0,p).filter(x=>!Hw(x,s)),b=p_([...g,...d,...u],Mf(d));return{appState:{...t,...s_(s,{...t,selectedGroupIds:{}},em(a))},elements:b,captureUpdate:ms.IMMEDIATELY}},predicate:(e,t,o,n)=>Bw(e,t,n),keyTest:e=>!e.shiftKey&&e[tm.CTRL_OR_CMD]&&e.key===tm.G,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>fa($,{hidden:!Bw(e,t,n),type:"button",icon:fa(Jc,{theme:t.theme}),onClick:()=>o(null),title:`${f("labels.group")} \u2014 ${Fw("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:Le(em(e),t)})}),nm=N({name:"ungroup",label:"labels.ungroup",icon:e=>fa(Qc,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=Qd(t),i=Mf(e);if(r.length===0)return{appState:t,elements:e,captureUpdate:ms.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{QP(p)&&l.push(p.id);let u=m_(p.groupIds,t.selectedGroupIds);return u.length===p.groupIds.length?p:Ow(p,{groupIds:u})});let s=c_(t,em(a),t,null),c=n.scene.getSelectedElements(t),d=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return o_(e).filter(p=>d.has(p.id)).forEach(p=>{p&&(a=a_(a,t_(a,p,t,i),p,n))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,g])=>(g&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...t,...s},elements:a,captureUpdate:ms.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[tm.CTRL_OR_CMD]&&e.key===tm.G.toUpperCase(),predicate:(e,t)=>Qd(t).length>0,PanelComponent:({elements:e,appState:t,updateData:o})=>fa($,{type:"button",hidden:Qd(t).length===0,icon:fa(Qc,{theme:t.theme}),onClick:()=>o(null),title:`${f("labels.ungroup")} \u2014 ${Fw("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:Le(em(e),t)})});import y_ from"clsx";import{CaptureUpdateAction as Ww}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as g_,COLOR_VOICE_CALL as h_,COLOR_WHITE as im,THEME as f_,UserIdleState as zw}from"@excalidraw/common";var rm=(e,t,o,n,r,i,a)=>{e.beginPath(),e.moveTo(t+i,o),e.lineTo(t+n-i,o),e.quadraticCurveTo(t+n,o,t+n,o+i),e.lineTo(t+n,o+r-i),e.quadraticCurveTo(t+n,o+r,t+n-i,o+r),e.lineTo(t+i,o+r),e.quadraticCurveTo(t,o+r,t,o+r-i),e.lineTo(t,o+i),e.quadraticCurveTo(t,o,t+i,o),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function b_(e){let t=0;if(e.length===0)return t;for(let o=0;o<e.length;o++){let n=e.charCodeAt(o);t=(t<<5)-t+n}return t}var gi=(e,t)=>`hsl(${Math.abs(b_(t?.id||e))%37*10}, 100%, 83%)`,Gw=e=>{let t=e?.trim()?.codePointAt(0);return(t?String.fromCodePoint(t):"?").toUpperCase()},Uw=({context:e,renderConfig:t,appState:o,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,a]of t.remotePointerViewportCoords){let{x:l,y:s}=a,c=o.collaborators.get(i);l-=o.offsetLeft,s-=o.offsetTop;let d=11,m=14,p=l<0||l>n-d||s<0||s>r-m;l=Math.max(l,0),l=Math.min(l,n-d),s=Math.max(s,0),s=Math.min(s,r-m);let u=gi(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let g=t.remotePointerUserStates.get(i),b=p||g===zw.IDLE||g===zw.AWAY;b&&(e.globalAlpha=.3),t.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=o.theme===f_.DARK?"#2f6330":h_,w=c?.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=im,e.strokeStyle=im,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=t.remotePointerUsernames.get(i)||"";if(!p&&E){e.font="600 12px sans-serif";let y=(w?l+0:l)+d/2,T=(w?s+0:s)+m+2,v=5,C=3,M=e.measureText(E),k=M.actualBoundingBoxDescent+M.actualBoundingBoxAscent,P=Math.max(k,12),A=y-1,R=T-1,O=M.width+2+v*2+2,U=P+2+C*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(A,R,O,U,8),e.fillStyle=u,e.fill(),e.strokeStyle=im,e.stroke(),w&&(e.beginPath(),e.roundRect(A-2,R-2,O+4,U+4,8),e.strokeStyle=x,e.stroke())):rm(e,A,R,O,U,8,im),e.fillStyle=g_,e.fillText(E,y+v+1,T+C+M.actualBoundingBoxAscent+Math.floor((P-k)/2)+2),w){e.fillStyle=x;let ee=8,_=8,B=5;e.fillRect(A+O+_,R+(U/2-ee/2),2,ee),e.fillRect(A+O+_+B,R+(U/2-ee*2/2),2,ee*2),e.fillRect(A+O+_+B*2,R+(U/2-ee/2),2,ee)}}e.restore(),e.closePath()}};import x_ from"clsx";import{useState as E_}from"react";import{jsx as Yw}from"react/jsx-runtime";var Lf=({color:e,onClick:t,name:o,src:n,className:r})=>{let i=Gw(o),[a,l]=E_(!1),s=!a&&n,c=s?void 0:{background:e};return Yw("div",{className:x_("Avatar",r),style:c,onClick:t,children:s?Yw("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as an,jsxs as am}from"react/jsx-runtime";var Vw=N({name:"goToCollaborator",label:"Go to a collaborator",viewMode:!0,trackEvent:{category:"collab"},perform:(e,t,o)=>!o.socketId||t.userToFollow?.socketId===o.socketId||o.isCurrentUser?{appState:{...t,userToFollow:null},captureUpdate:Ww.EVENTUALLY}:{appState:{...t,userToFollow:{socketId:o.socketId,username:o.username||""},openMenu:t.openMenu==="canvas"?null:t.openMenu},captureUpdate:Ww.EVENTUALLY},PanelComponent:({updateData:e,data:t,appState:o})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:a}=t,l=gi(n,r),s=y_({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),c=r.isInCall?r.isSpeaking?am("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[an("div",{}),an("div",{}),an("div",{})]}):r.isMuted?an("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:fh}):an("div",{title:f("userList.hint.inCall"),children:hh}):null;return i?am("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[an(Lf,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),an("div",{className:"UserList__collaborator-name",children:r.username}),am("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&an("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:ai}),c]})]}):am("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[an(Lf,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),c&&an("div",{className:"UserList__collaborator-status-icon",children:c})]})}});import{LIBRARY_DISABLED_TYPES as w_,randomId as v_}from"@excalidraw/common";import{deepCopyElement as T_}from"@excalidraw/element";import{CaptureUpdateAction as Af}from"@excalidraw/element";var lm=N({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of w_)if(r.some(a=>a.type===i))return{captureUpdate:Af.EVENTUALLY,appState:{...t,errorMessage:f(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:v_(),status:"unpublished",elements:r.map(T_),created:Date.now()},...i])).then(()=>({captureUpdate:Af.EVENTUALLY,appState:{...t,toast:{message:f("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:Af.EVENTUALLY,appState:{...t,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as ba}from"@excalidraw/element";import{isFrameLikeElement as I_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as C_}from"@excalidraw/element";import{KEYS as hr,arrayToMap as S_,getShortcutKey as sm}from"@excalidraw/common";import{alignElements as k_}from"@excalidraw/element";import{CaptureUpdateAction as xa}from"@excalidraw/element";import{getSelectedElementsByGroup as M_}from"@excalidraw/element";import{jsx as ya}from"react/jsx-runtime";var Kt=(e,t)=>{let o=t.scene.getSelectedElements(e);return M_(o,t.scene.getNonDeletedElementsMap(),e).length>1&&!o.some(n=>I_(n))},Ea=(e,t,o,n)=>{let r=o.scene.getSelectedElements(t),i=k_(r,n,o.scene,t),a=S_(i);return C_(e.map(l=>a.get(l.id)||l),t,o)},Kw=N({name:"alignTop",label:"labels.alignTop",icon:Kc,trackEvent:{category:"element"},predicate:(e,t,o,n)=>Kt(t,n),perform:(e,t,o,n)=>({appState:t,elements:Ea(e,t,n,{position:"start",axis:"y"}),captureUpdate:xa.IMMEDIATELY}),keyTest:e=>e[hr.CTRL_OR_CMD]&&e.shiftKey&&e.key===hr.ARROW_UP,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>ya($,{hidden:!Kt(t,n),type:"button",icon:Kc,onClick:()=>o(null),title:`${f("labels.alignTop")} \u2014 ${sm("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:Le(ba(e),t)})}),Xw=N({name:"alignBottom",label:"labels.alignBottom",icon:Xc,trackEvent:{category:"element"},predicate:(e,t,o,n)=>Kt(t,n),perform:(e,t,o,n)=>({appState:t,elements:Ea(e,t,n,{position:"end",axis:"y"}),captureUpdate:xa.IMMEDIATELY}),keyTest:e=>e[hr.CTRL_OR_CMD]&&e.shiftKey&&e.key===hr.ARROW_DOWN,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>ya($,{hidden:!Kt(t,n),type:"button",icon:Xc,onClick:()=>o(null),title:`${f("labels.alignBottom")} \u2014 ${sm("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:Le(ba(e),t)})}),$w=N({name:"alignLeft",label:"labels.alignLeft",icon:$c,trackEvent:{category:"element"},predicate:(e,t,o,n)=>Kt(t,n),perform:(e,t,o,n)=>({appState:t,elements:Ea(e,t,n,{position:"start",axis:"x"}),captureUpdate:xa.IMMEDIATELY}),keyTest:e=>e[hr.CTRL_OR_CMD]&&e.shiftKey&&e.key===hr.ARROW_LEFT,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>ya($,{hidden:!Kt(t,n),type:"button",icon:$c,onClick:()=>o(null),title:`${f("labels.alignLeft")} \u2014 ${sm("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:Le(ba(e),t)})}),Zw=N({name:"alignRight",label:"labels.alignRight",icon:Zc,trackEvent:{category:"element"},predicate:(e,t,o,n)=>Kt(t,n),perform:(e,t,o,n)=>({appState:t,elements:Ea(e,t,n,{position:"end",axis:"x"}),captureUpdate:xa.IMMEDIATELY}),keyTest:e=>e[hr.CTRL_OR_CMD]&&e.shiftKey&&e.key===hr.ARROW_RIGHT,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>ya($,{hidden:!Kt(t,n),type:"button",icon:Zc,onClick:()=>o(null),title:`${f("labels.alignRight")} \u2014 ${sm("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:Le(ba(e),t)})}),jw=N({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:jc,trackEvent:{category:"element"},predicate:(e,t,o,n)=>Kt(t,n),perform:(e,t,o,n)=>({appState:t,elements:Ea(e,t,n,{position:"center",axis:"y"}),captureUpdate:xa.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>ya($,{hidden:!Kt(t,n),type:"button",icon:jc,onClick:()=>o(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:Le(ba(e),t)})}),qw=N({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:qc,trackEvent:{category:"element"},predicate:(e,t,o,n)=>Kt(t,n),perform:(e,t,o,n)=>({appState:t,elements:Ea(e,t,n,{position:"center",axis:"x"}),captureUpdate:xa.IMMEDIATELY}),PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>ya($,{hidden:!Kt(t,n),type:"button",icon:qc,onClick:()=>o(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:Le(ba(e),t)})});import{getNonDeletedElements as Jw}from"@excalidraw/element";import{isFrameLikeElement as L_}from"@excalidraw/element";import{CODES as Qw,KEYS as e2,arrayToMap as A_,getShortcutKey as t2}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as P_}from"@excalidraw/element";import{distributeElements as __}from"@excalidraw/element";import{CaptureUpdateAction as o2}from"@excalidraw/element";import{getSelectedElementsByGroup as D_}from"@excalidraw/element";import{jsx as l2}from"react/jsx-runtime";var n2=(e,t)=>{let o=t.scene.getSelectedElements(e);return D_(o,t.scene.getNonDeletedElementsMap(),e).length>2&&!o.some(n=>L_(n))},r2=(e,t,o,n)=>{let r=o.scene.getSelectedElements(t),i=__(r,o.scene.getNonDeletedElementsMap(),n,t),a=A_(i);return P_(e.map(l=>a.get(l.id)||l),t,o)},i2=N({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,t,o,n)=>({appState:t,elements:r2(e,t,n,{space:"between",axis:"x"}),captureUpdate:o2.IMMEDIATELY}),keyTest:e=>!e[e2.CTRL_OR_CMD]&&e.altKey&&e.code===Qw.H,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>l2($,{hidden:!n2(t,n),type:"button",icon:Eg,onClick:()=>o(null),title:`${f("labels.distributeHorizontally")} \u2014 ${t2("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:Le(Jw(e),t)})}),a2=N({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,t,o,n)=>({appState:t,elements:r2(e,t,n,{space:"between",axis:"y"}),captureUpdate:o2.IMMEDIATELY}),keyTest:e=>!e[e2.CTRL_OR_CMD]&&e.altKey&&e.code===Qw.V,PanelComponent:({elements:e,appState:t,updateData:o,app:n})=>l2($,{hidden:!n2(t,n),type:"button",icon:yg,onClick:()=>o(null),title:`${f("labels.distributeVertically")} \u2014 ${t2("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:Le(Jw(e),t)})});import{getNonDeletedElements as R_}from"@excalidraw/element";import{bindOrUnbindLinearElements as N_,isBindingEnabled as B_}from"@excalidraw/element";import{getCommonBoundingBox as s2}from"@excalidraw/element";import{newElementWith as O_}from"@excalidraw/element";import{deepCopyElement as F_}from"@excalidraw/element";import{resizeMultipleElements as H_}from"@excalidraw/element";import{isArrowElement as z_,isElbowArrow as G_,isLinearElement as U_}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as c2}from"@excalidraw/element";import{CODES as d2,KEYS as Y_,arrayToMap as W_}from"@excalidraw/common";import{CaptureUpdateAction as m2}from"@excalidraw/element";var cm=N({name:"flipHorizontal",label:"labels.flipHorizontal",icon:yh,trackEvent:{category:"element"},perform:(e,t,o,n)=>({elements:c2(p2(e,n.scene.getNonDeletedElementsMap(),t,"horizontal",n),t,n),appState:t,captureUpdate:m2.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===d2.H}),dm=N({name:"flipVertical",label:"labels.flipVertical",icon:Eh,trackEvent:{category:"element"},perform:(e,t,o,n)=>({elements:c2(p2(e,n.scene.getNonDeletedElementsMap(),t,"vertical",n),t,n),appState:t,captureUpdate:m2.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===d2.V&&!e[Y_.CTRL_OR_CMD]}),p2=(e,t,o,n,r)=>{let i=J(R_(e),o,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=V_(i,t,o,n,r),l=W_(a);return e.map(s=>l.get(s.id)||s)},V_=(e,t,o,n,r)=>{if(e.every(u=>z_(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let g=u;return O_(g,{startArrowhead:g.endArrowhead,endArrowhead:g.startArrowhead})});let{midX:i,midY:a}=s2(e);H_(e,t,"nw",r.scene,new Map(Array.from(t.values()).map(u=>[u.id,F_(u)])),{flipByX:n==="horizontal",flipByY:n==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),N_(e.filter(U_),B_(o),[],r.scene,o.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,g)=>G_(g)?{...u,elbowArrows:u.elbowArrows.concat(g)}:{...u,otherElements:u.otherElements.concat(g)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:d}=s2(e),[m,p]=[i-c,a-d];return s.forEach(u=>r.scene.mutateElement(u,{x:u.x+m,y:u.y+p})),l.forEach(u=>r.scene.mutateElement(u,{x:u.x+m,y:u.y+p})),e};import{isTextElement as K_}from"@excalidraw/element";import{getTextFromElements as X_}from"@excalidraw/element";import{CODES as $_,KEYS as u2,isFirefox as Z_}from"@excalidraw/common";import{CaptureUpdateAction as ao}from"@excalidraw/element";var hi=N({name:"copy",label:"labels.copy",icon:Ui,trackEvent:{category:"element"},perform:async(e,t,o,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Wd(r,n.files,o)}catch(i){return{captureUpdate:ao.EVENTUALLY,appState:{...t,errorMessage:i.message}}}return{captureUpdate:ao.EVENTUALLY}},keyTest:void 0}),Pf=N({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,t,o,n)=>{let r;try{r=await Iw()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),Z_?{captureUpdate:ao.EVENTUALLY,appState:{...t,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:ao.EVENTUALLY,appState:{...t,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(vw({types:r}))}catch(i){return console.error(i),{captureUpdate:ao.EVENTUALLY,appState:{...t,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:ao.EVENTUALLY}},keyTest:void 0}),ps=N({name:"cut",label:"labels.cut",icon:rh,trackEvent:{category:"element"},perform:(e,t,o,n)=>(hi.perform(e,t,o,n),Zi.perform(e,t,null,n)),keyTest:e=>e[u2.CTRL_OR_CMD]&&e.key===u2.X}),us=N({name:"copyAsSvg",label:"labels.copyAsSvg",icon:wh,trackEvent:{category:"element"},perform:async(e,t,o,n)=>{if(!n.canvas)return{captureUpdate:ao.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=mi(e,t,!0);try{await pi({type:"clipboard-svg",data:{elements:r,appState:t,files:n.files},config:{...t,exportingFrame:i,name:n.getName()}});let a=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:t.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:ao.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:ao.EVENTUALLY}}},predicate:e=>Yd&&e.length>0,keywords:["svg","clipboard","copy"]}),gs=N({name:"copyAsPng",label:"labels.copyAsPng",icon:vh,trackEvent:{category:"element"},perform:async(e,t,o,n)=>{if(!n.canvas)return{captureUpdate:ao.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=mi(e,t,!0);try{return await pi({type:"clipboard",data:{elements:i,appState:t,files:n.files},config:{...t,exportingFrame:a,name:t.name||n.getName()}}),{appState:{...t,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:r.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:t.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:ao.EVENTUALLY}}catch(l){return console.error(l),{appState:{...t,errorMessage:l.message},captureUpdate:ao.EVENTUALLY}}},predicate:e=>ua&&e.length>0,keyTest:e=>e.code===$_.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),hs=N({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0});try{Fo(X_(r))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:ao.EVENTUALLY}},predicate:(e,t,o,n)=>Yd&&n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0}).some(K_),keywords:["text","clipboard","copy"]});import{CODES as j_,KEYS as q_}from"@excalidraw/common";import{CaptureUpdateAction as J_}from"@excalidraw/element";var fs=N({name:"gridMode",icon:kh,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,t){return{appState:{...t,gridModeEnabled:!this.checked(t),objectsSnapModeEnabled:!1},captureUpdate:J_.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>o.gridModeEnabled===void 0,keyTest:e=>e[q_.CTRL_OR_CMD]&&e.code===j_.QUOTE});import{CODES as Q_,KEYS as e8}from"@excalidraw/common";import{CaptureUpdateAction as t8}from"@excalidraw/element";var fi=N({name:"zenMode",label:"buttons.zenMode",icon:Ih,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,t){return{appState:{...t,zenModeEnabled:!this.checked(t)},captureUpdate:t8.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,t,o)=>typeof o.zenModeEnabled>"u",keyTest:e=>!e[e8.CTRL_OR_CMD]&&e.altKey&&e.code===Q_.Z});import{CODES as o8,KEYS as n8}from"@excalidraw/common";import{CaptureUpdateAction as r8}from"@excalidraw/element";var mm=N({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:Th,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,t){return{appState:{...t,objectsSnapModeEnabled:!this.checked(t),gridModeEnabled:!1},captureUpdate:r8.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,t,o)=>typeof o.objectsSnapModeEnabled>"u",keyTest:e=>!e[n8.CTRL_OR_CMD]&&e.altKey&&e.code===o8.S});import{CODES as i8,KEYS as a8}from"@excalidraw/common";import{CaptureUpdateAction as l8}from"@excalidraw/element";var bi=N({name:"stats",label:"stats.fullTitle",icon:xh,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,t){return{appState:{...t,stats:{...t.stats,open:!this.checked(t)}},captureUpdate:l8.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[a8.CTRL_OR_CMD]&&e.altKey&&e.code===i8.SLASH});import{BOUND_TEXT_PADDING as g2,ROUNDNESS as h2,TEXT_ALIGN as b2,VERTICAL_ALIGN as x2,arrayToMap as E2,getFontString as s8}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as c8,resetOriginalContainerCache as d8,updateOriginalContainerCache as m8}from"@excalidraw/element";import{computeBoundTextPosition as p8,computeContainerDimensionForBoundText as f2,getBoundTextElement as y2,redrawTextBoundingBox as w2}from"@excalidraw/element";import{hasBoundTextElement as u8,isArrowElement as g8,isTextBindableContainer as _f,isTextElement as bs,isUsingAdaptiveRadius as h8}from"@excalidraw/element";import{measureText as f8}from"@excalidraw/element";import{syncMovedIndices as v2}from"@excalidraw/element";import{newElement as b8}from"@excalidraw/element";import{CaptureUpdateAction as Df}from"@excalidraw/element";var pm=N({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,t,o,n)=>n.scene.getSelectedElements(t).some(i=>u8(i)),perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t),i=n.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=y2(a,i);if(l){let{width:s,height:c}=f8(l.originalText,s8(l),l.lineHeight),d=c8(a.id);d8(a.id);let{x:m,y:p}=p8(a,l,i);n.scene.mutateElement(l,{containerId:null,width:s,height:c,text:l.originalText,x:m,y:p}),n.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:d||a.height})}}),{elements:e,appState:t,captureUpdate:Df.IMMEDIATELY}}}),um=N({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);if(r.length===2){let i=bs(r[0])||bs(r[1]),a;if(_f(r[0])?a=r[0]:_f(r[1])&&(a=r[1]),i&&a&&y2(a,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t),i,a;bs(r[0])&&_f(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),n.scene.mutateElement(i,{containerId:a.id,verticalAlign:x2.MIDDLE,textAlign:b2.CENTER,autoResize:!0,angle:g8(a)?0:a?.angle??0}),n.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return w2(i,a,n.scene),m8(a.id,l),{elements:x8(e,a,i),appState:{...t,selectedElementIds:{[a.id]:!0}},captureUpdate:Df.IMMEDIATELY}}}),x8=(e,t,o)=>{let n=e.slice(),r=n.findIndex(a=>a.id===o.id);n.splice(r,1);let i=n.findIndex(a=>a.id===t.id);return n.splice(i+1,0,o),v2(n,E2([t,o])),n},E8=(e,t,o)=>{let n=e.slice(),r=n.findIndex(a=>a.id===t.id);n.splice(r,1);let i=n.findIndex(a=>a.id===o.id);return n.splice(i,0,t),v2(n,E2([t,o])),n},T2=N({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t),i=r.some(a=>bs(a));return r.length>0&&i},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t),i=e.slice(),a={};for(let l of r)if(bs(l)){let s=b8({type:"rectangle",backgroundColor:t.currentItemBackgroundColor,boundElements:[...l.boundElements||[],{id:l.id,type:"text"}],angle:l.angle,fillStyle:t.currentItemFillStyle,strokeColor:t.currentItemStrokeColor,roughness:t.currentItemRoughness,strokeWidth:t.currentItemStrokeWidth,strokeStyle:t.currentItemStrokeStyle,roundness:t.currentItemRoundness==="round"?{type:h8("rectangle")?h2.ADAPTIVE_RADIUS:h2.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-g2,y:l.y-g2,width:f2(l.width,"rectangle"),height:f2(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(m=>m.type==="arrow").map(m=>m.id);i.filter(m=>c.includes(m.id)).forEach(m=>{let p=m.startBinding,u=m.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&n.scene.mutateElement(m,{startBinding:p,endBinding:u})})}n.scene.mutateElement(l,{containerId:s.id,verticalAlign:x2.MIDDLE,boundElements:null,textAlign:b2.CENTER,autoResize:!0}),w2(l,s,n.scene),i=E8([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...t,selectedElementIds:a},captureUpdate:Df.IMMEDIATELY}}});import{isEmbeddableElement as B8}from"@excalidraw/element";import{KEYS as D2,getShortcutKey as O8}from"@excalidraw/common";import{CaptureUpdateAction as F8}from"@excalidraw/element";import{pointFrom as k2}from"@excalidraw/math";import y8 from"clsx";import{useCallback as I2,useEffect as C2,useLayoutEffect as w8,useRef as v8,useState as T8}from"react";import{EVENT as Rf,HYPERLINK_TOOLTIP_DELAY as I8,KEYS as gm}from"@excalidraw/common";import{getElementAbsoluteCoords as Hf}from"@excalidraw/element";import{hitElementBoundingBox as C8}from"@excalidraw/element";import{isElementLink as S8}from"@excalidraw/element";import{getEmbedLink as k8,embeddableURLValidator as M8}from"@excalidraw/element";import{sceneCoordsToViewportCoords as M2,viewportCoordsToSceneCoords as L8,wrapEvent as A8,isLocalLink as P8,normalizeLink as Nf}from"@excalidraw/common";import{isEmbeddableElement as Bf}from"@excalidraw/element";import{jsx as wa,jsxs as S2}from"react/jsx-runtime";var zf=380,_8=42,Of=5,L2=85,D8=500,Ff=!1,hm=new Map,A2=({element:e,scene:t,setAppState:o,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let a=t.getNonDeletedElementsMap(),l=en(),s=tn(),c=me(),d=e.link||"",[m,p]=T8(d),u=v8(null),g=l.showHyperlinkPopup==="editor",b=I2(()=>{if(!u.current)return;let T=Nf(u.current.value)||null;if(!e.link&&T&&ae("hyperlink","create"),Bf(e)){if(l.activeEmbeddable?.element===e&&o({activeEmbeddable:null}),!T){t.mutateElement(e,{link:null}),i(e,!1);return}if(!M8(T,s.validateEmbeddable))T&&r({message:f("toast.unableToEmbed"),closable:!0}),e.link&&hm.set(e.id,e.link),t.mutateElement(e,{link:T}),i(e,!1);else{let{width:v,height:C}=e,M=k8(T);M?.error instanceof URIError&&r({message:f("toast.unrecognizedLinkFormat"),closable:!0});let k=M?M.intrinsicSize.w/M.intrinsicSize.h:1,P=hm.get(e.id)!==e.link;t.mutateElement(e,{...P?{width:M?.type==="video"?v>C?v:C*k:v,height:M?.type==="video"&&v>C?v/k:C}:{},link:T}),i(e,!0),hm.has(e.id)&&hm.delete(e.id)}}else t.mutateElement(e,{link:T})},[e,t,r,s.validateEmbeddable,l.activeEmbeddable,o,i]);w8(()=>()=>{b()},[b]),C2(()=>{g&&u?.current&&!(c.viewport.isMobile||c.isTouchScreen)&&u.current.select()},[g,c.viewport.isMobile,c.isTouchScreen]),C2(()=>{let T=null,v=C=>{if(g)return;T&&clearTimeout(T),N8(e,a,l,k2(C.clientX,C.clientY))&&(T=window.setTimeout(()=>{o({showHyperlinkPopup:!1})},D8))};return window.addEventListener(Rf.POINTER_MOVE,v,!1),()=>{window.removeEventListener(Rf.POINTER_MOVE,v,!1),T&&clearTimeout(T)}},[l,e,g,o,a]);let x=I2(()=>{ae("hyperlink","delete"),t.mutateElement(e,{link:null}),o({showHyperlinkPopup:!1})},[o,e,t]),w=()=>{ae("hyperlink","edit","popup-ui"),o({showHyperlinkPopup:"editor"})},{x:E,y}=P2(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:S2("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${E}px`,width:zf,padding:Of},children:[g?wa("input",{className:y8("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:u,value:m,onChange:T=>p(T.target.value),autoFocus:!0,onKeyDown:T=>{T.stopPropagation(),T[gm.CTRL_OR_CMD]&&T.key===gm.K&&T.preventDefault(),(T.key===gm.ENTER||T.key===gm.ESCAPE)&&(b(),o({showHyperlinkPopup:"info"}))}}):e.link?wa("a",{href:Nf(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:P8(e.link)?"_self":"_blank",onClick:T=>{if(e.link&&n){let v=A8(Rf.EXCALIDRAW_LINK,T.nativeEvent);n({...e,link:Nf(e.link)},v),v.defaultPrevented&&T.preventDefault()}},rel:"noopener noreferrer",children:e.link}):wa("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),S2("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!g&&wa($,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:Tn}),wa($,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{o({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Gl}),d&&!Bf(e)&&wa($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:zt})]})]})},P2=(e,t,o)=>{let[n,r]=Hf(e,o),{x:i,y:a}=M2({sceneX:n+e.width/2,sceneY:r},t),l=i-t.offsetLeft-zf/2,s=a-t.offsetTop-L2;return{x:l,y:s}},Gf=(e,t)=>{let o=J(e,t);return Bf(o[0])?"labels.link.editEmbed":o[0]?.link?"labels.link.edit":"labels.link.create"},xs=null,_2=(e,t,o)=>{xs&&clearTimeout(xs),xs=window.setTimeout(()=>R8(e,t,o),I8)},R8=(e,t,o)=>{if(!e.link)return;let n=da();n.classList.add("excalidraw-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=S8(e.link)?f("labels.link.goToElement"):e.link;let[r,i,a,l]=Hf(e,o),[s,c,d,m]=oE([r,i,a,l],e.angle,t),p=M2({sceneX:s,sceneY:c},t);uf(n,{left:p.x,top:p.y,width:d,height:m},"top"),ae("hyperlink","tooltip","link-icon"),Ff=!0},Uf=()=>{xs&&clearTimeout(xs),Ff&&(Ff=!1,da().classList.remove("excalidraw-tooltip--visible"))},N8=(e,t,o,[n,r])=>{let{x:i,y:a}=L8({clientX:n,clientY:r},o),l=15/o.zoom.value;if(C8(k2(i,a),e,t))return!1;let[s,c,d]=Hf(e,t);if(i>=s&&i<=d&&a>=c-L2&&a<=c)return!1;let{x:m,y:p}=P2(e,o,t);return!(n>=m-l&&n<=m+zf+Of*2+l&&r>=p-l&&r<=p+l+Of*2+_8)};import{jsx as H8}from"react/jsx-runtime";var va=N({name:"hyperlink",label:(e,t)=>Gf(e,t),icon:Vi,perform:(e,t)=>t.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...t,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:F8.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[D2.CTRL_OR_CMD]&&e.key===D2.K,predicate:(e,t)=>J(e,t).length===1,PanelComponent:({elements:e,appState:t,updateData:o})=>{let n=J(e,t);return H8($,{type:"button",icon:Vi,"aria-label":f(Gf(e,t)),title:`${B8(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${O8("CtrlOrCmd+K")}`,onClick:()=>o(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as R2,arrayToMap as Wf,randomId as z8}from"@excalidraw/common";import{elementsAreInSameGroup as G8,newElementWith as N2,selectGroupsFromGivenElements as B2}from"@excalidraw/element";import{CaptureUpdateAction as O2}from"@excalidraw/element";var Yf=e=>e.every(t=>!t.locked),Ta=N({name:"toggleElementLock",label:(e,t,o)=>{let n=o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1});return Yf(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,t)=>{let o=J(t,e);return Yf(o)?ei:Jn},trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=Yf(r),a=Wf(r),l=r.length>1&&G8(r),c=r.length===1||l?null:z8(),d={...t.lockedMultiSelections};if(i)d={...t.lockedMultiSelections,...c?{[c]:!0}:{}};else if(l){let w=r[0].groupIds.at(-1);delete d[w]}let m=e.map(w=>{if(!a.has(w.id))return w;let E=w.groupIds;return i?c&&(E=[...E,c]):E=E.filter(y=>!t.lockedMultiSelections[y]),N2(w,{locked:i,groupIds:E.length!==w.groupIds.length?E:w.groupIds})}),p=Wf(m),u=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),g=r.map(w=>p.get(w.id)||w),b=i?{}:B2(g,t),x=i?c||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:m,appState:{...t,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:t.selectedLinearElement,lockedMultiSelections:d,activeLockedId:x},captureUpdate:O2.IMMEDIATELY}},keyTest:(e,t,o,n)=>e.key.toLocaleLowerCase()===R2.L&&e[R2.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}).length>0}),F2=N({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Jn,predicate:(e,t)=>J(e,t).length===0&&e.some(n=>n.locked),perform:(e,t)=>{let o=e.filter(a=>a.locked),n=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!t.lockedMultiSelections[s]);return N2(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),r=Wf(n),i=o.map(a=>r.get(a.id)||a);return{elements:n,appState:{...t,selectedElementIds:Object.fromEntries(o.map(a=>[a.id,!0])),selectedGroupIds:B2(i,t),lockedMultiSelections:{},activeLockedId:null},captureUpdate:O2.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{LinearElementEditor as PB}from"@excalidraw/element";import{isElbowArrow as _B,isLinearElement as DB,isLineElement as $a}from"@excalidraw/element";import{arrayToMap as F3}from"@excalidraw/common";import{toggleLinePolygonState as RB,CaptureUpdateAction as H3}from"@excalidraw/element";import uT from"clsx";import JR from"fuzzy";import{useEffect as Gm,useRef as QR,useState as zm}from"react";import{DEFAULT_SIDEBAR as mT,EVENT as Ym,KEYS as Go,capitalizeString as e9,getShortcutKey as t9,isWritableElement as o9}from"@excalidraw/common";import{CaptureUpdateAction as TD}from"@excalidraw/element";import{useEffect as ws,useMemo as H2,useRef as $f,useState as U8}from"react";import{getLinearElementSubType as Sa,updateElbowArrowPoints as Y8}from"@excalidraw/element";import{pointFrom as bm,pointRotateRads as W8}from"@excalidraw/math";import{hasBoundTextElement as V8,isArrowBoundToElement as K8,isArrowElement as X8,isElbowArrow as $8,isLinearElement as Jf,isUsingAdaptiveRadius as Z8}from"@excalidraw/element";import{getCommonBoundingBox as j8,getElementAbsoluteCoords as q8}from"@excalidraw/element";import{getBoundTextElement as W2,getBoundTextMaxHeight as J8,getBoundTextMaxWidth as Q8,redrawTextBoundingBox as eD}from"@excalidraw/element";import{wrapText as tD}from"@excalidraw/element";import{assertNever as oD,CLASSES as nD,getFontString as Vf,isProdEnv as rD,mapFind as iD,reduceToCommonValue as aD,updateActiveTool as z2}from"@excalidraw/common";import{measureText as G2}from"@excalidraw/element";import{LinearElementEditor as lD}from"@excalidraw/element";import{newArrowElement as Kf,newElement as sD,newLinearElement as cD}from"@excalidraw/element";import{ShapeCache as dD}from"@excalidraw/element";import{updateBindings as mD}from"@excalidraw/element";import{jsx as qf}from"react/jsx-runtime";var pD=8,uD=10,Es=["rectangle","diamond","ellipse"],ys=["line","sharpArrow","curvedArrow","elbowArrow"],gD=new Set(Es),hD=new Set(ys),ka=e=>gD.has(e),Em=e=>e==="arrow"||hD.has(e),zo=be(null),vs=new Map,Ts=new Map,fD=({app:e})=>{let t=e.scene.getSelectedElements(e.state),o=$f(null);return ws(()=>{if(t.length===0){e.updateEditorAtom(zo,null);return}let n=Ma(t);n&&!o.current?o.current=n:(o.current&&!n||o.current&&n!==o.current)&&(e.updateEditorAtom(zo,null),o.current=null)},[t,e]),ws(()=>()=>{vs.clear(),Ts.clear()},[]),qf(bD,{app:e,elements:t})},bD=({app:e,elements:t})=>{let o=Ma(t),n=H2(()=>o==="generic"?K2(t):[],[o,t]),r=H2(()=>o==="linear"?jf(t):[],[o,t]),i=o==="generic"?n.every(m=>m.type===n[0].type):o==="linear"?r.every(m=>Sa(m)===Sa(r[0])):!1,[a,l]=U8({x:0,y:0}),s=$f(""),c=$f(null);ws(()=>{let m=[...n,...r].sort((x,w)=>x.id.localeCompare(w.id)),p=`
|
|
20
|
+
${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${m.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(m.length===1){let[x,,,w,E,y]=q8(m[0],e.scene.getNonDeletedElementsMap());u=W8(bm(x,w),bm(E,y),m[0].angle)}else{let{minX:x,maxY:w}=j8(m);u=bm(x,w)}let{x:g,y:b}=$2({sceneX:u[0],sceneY:u[1]},e.state);l({x:g,y:b})},[n,r,e.scene,e.state]),ws(()=>{for(let m of r){let p=Zf(m.id,vD(m));Ts.has(p)||Ts.set(p,m)}},[r]),ws(()=>{for(let m of n)if(!vs.has(m.id)){let p=W2(m,e.scene.getNonDeletedElementsMap());p&&vs.set(m.id,{fontSize:p.fontSize})}},[n,e.scene]);let d=o==="linear"?[["line",Cl],["sharpArrow",Ol],["curvedArrow",Hl],["elbowArrow",Fl]]:o==="generic"?[["rectangle",vl],["diamond",Tl],["ellipse",Il]]:[];return qf("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(uD+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-pD}px`,zIndex:2},className:nD.CONVERT_ELEMENT_TYPE_POPUP,children:d.map(([m,p])=>{let u=i&&(o==="generic"&&n[0].type===m||o==="linear"&&Sa(r[0])===m);return qf($,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:m,keyBindingLabel:"","aria-label":m,"data-testid":`toolbar-${m}`,onChange:()=>{e.state.activeTool.type!==m&&ae("convertElementType",m,"ui"),Qf(e,{conversionType:o,nextType:m}),c.current?.focus()}},`${t[0].id}${t[0].version}_${m}`)})})},xD=(e,t,o)=>{let n=Q8(e,t),r=J8(e,t),i=tD(t.text,Vf(t),n),a=G2(i,Vf(t),t.lineHeight),l=t.fontSize;for(;(a.width>n||a.height>r)&&l>0;){l-=1;let s={...t,fontSize:l};a=G2(t.text,Vf(s),t.lineHeight)}ym(t,o.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),eD(t,e,o)},Qf=(e,{conversionType:t,nextType:o,direction:n="right"})=>{if(!t)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=n==="right"?1:-1;if(t==="generic"){let l=K2(r),c=l.every(d=>d.type===l[0].type)?Es.indexOf(l[0].type):-1;if(o=o??Es[(c+Es.length+a)%Es.length],o&&ka(o)){let d={};for(let p of l){let u=Y2(p,o,e);d[u.id]=u}let m=[];for(let p of e.scene.getElementsIncludingDeleted())d[p.id]?m.push(d[p.id]):m.push(p);e.scene.replaceAllElements(m);for(let p of Object.values(d)){let u=W2(p,e.scene.getNonDeletedElementsMap());u&&(vs.get(p.id)&&ym(u,e.scene.getNonDeletedElementsMap(),{fontSize:vs.get(p.id)?.fontSize??u.fontSize}),xD(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:z2(p,{type:"selection"})}))}}if(t==="linear"){let l=jf(r);if(!o){let c=aD(l,Sa),d=c?ys.indexOf(c):-1;o=ys[(d+ys.length+a)%ys.length]}if(Em(o)){let c=[],d=e.scene.getElementsMapIncludingDeleted();for(let m of l){let p=Ts.get(Zf(m.id,o));if(p&&Sa(p)===o)d.set(p.id,p),c.push(p);else{let u=Y2(m,o,e);d.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(d);for(let m of c)if(Jf(m))if($8(m)){let p=ED(m);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 g=Y8(m,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});ym(m,e.scene.getNonDeletedElementsMap(),{...g,endArrowhead:"arrow"})}else{let p=iD(["line","sharpArrow","curvedArrow"],u=>Ts.get(Zf(m.id,u)));if(p){let u=p.points;e.scene.mutateElement(m,{points:u})}}}let s=jf(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:s.length===1?new lD(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:z2(c,{type:"selection"})}))}return!0},Ma=e=>{if(e.length===0)return null;let t=!1;for(let o of e){if(ka(o.type))return"generic";V2(o)&&(t=!0)}return t?"linear":null},V2=e=>Jf(e)&&(!X8(e)||!K8(e)&&!V8(e)),Zf=(e,t)=>`${e}:${t}`,K2=e=>e.filter(t=>ka(t.type)),jf=e=>e.filter(t=>V2(t)),fm=20,Ia=(e,t)=>e[0]===t[0],Xf=(e,t)=>e[1]===t[1],U2=(e,t)=>Ia(e,t)?Math.abs(e[1]-t[1]):Math.abs(e[0]-t[0]),ED=e=>{let t=[e.points[0]],o=yD(e.points);for(let i=1;i<o.length;++i){let a=t[t.length-1],l=[...o[i]];Math.abs(l[0]-a[0])<fm?l[0]=a[0]:Math.abs(l[1]-a[1])<fm&&(l[1]=a[1]),Ia(a,l)||Xf(a,l)||t.push(bm(a[0],l[1])),t.push(l)}let n=[t[0]];for(let i=1;i<t.length-1;++i)Ia(t[i-1],t[i])&&Ia(t[i],t[i+1])||Xf(t[i-1],t[i])&&Xf(t[i],t[i+1])||n.push(t[i]);n.push(t[t.length-1]);let r=[n[0]];for(let i=1;i<n.length-1;++i){let a=r[r.length-1],l=n[i],s=n[i+1],c=Ia(a,l),d=Ia(l,s);if(c!==d){let m=U2(a,l),p=U2(l,s);if(m<fm||p<fm){if(p<m)c?s[0]=a[0]:s[1]=a[1];else if(d)for(let u=r.length-1;u>=0&&r[u][0]===a[0];--u)r[u][0]=l[0];else for(let u=r.length-1;u>=0&&r[u][1]===a[1];--u)r[u][1]=l[1];continue}}r.push(l)}return r.push(n[n.length-1]),r},yD=e=>{if(e.length===0)return[];let t=[e[0]];for(let o=1;o<e.length;o++){let[n,r]=t[t.length-1],[i,a]=e[o];(n!==i||r!==a)&&t.push(e[o])}return t},Y2=(e,t,o)=>{if(!wD(e.type,t)){if(!rD())throw Error(`Invalid conversion from ${e.type} to ${t}.`);return e}if(e.type===t)return e;if(dD.delete(e),ka(t)){let n=Ca(sD({...e,type:t,roundness:t==="diamond"&&e.roundness?{type:Z8(t)?xm.ADAPTIVE_RADIUS:xm.PROPORTIONAL_RADIUS}:e.roundness}));return mD(n,o.scene),n}if(Em(t))switch(t){case"line":return Ca(cD({...e,type:"line"}));case"sharpArrow":return Ca(Kf({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:o.state.currentItemStartArrowhead,endArrowhead:o.state.currentItemEndArrowhead}));case"curvedArrow":return Ca(Kf({...e,type:"arrow",elbowed:!1,roundness:{type:xm.PROPORTIONAL_RADIUS},startArrowhead:o.state.currentItemStartArrowhead,endArrowhead:o.state.currentItemEndArrowhead}));case"elbowArrow":return Ca(Kf({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return oD(t,`unhandled conversion type: ${t}`),e},wD=(e,t)=>!!(ka(e)&&ka(t)||Em(e)&&Em(t)),vD=e=>Jf(e)?Sa(e):e.type,X2=fD;var Z2=N({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,t,o,n){return et.set(zo,{type:"panel"}),{captureUpdate:TD.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>Ma(e)!==null});import{canCreateLinkFromElements as e1,defaultGetElementLinkFromSelection as ID,getLinkIdAndTypeFromSelection as CD}from"@excalidraw/element";import{CaptureUpdateAction as Is}from"@excalidraw/element";var wm=N({name:"copyElementLink",label:"labels.copyElementLink",icon:ri,trackEvent:{category:"element"},perform:async(e,t,o,n)=>{let r=J(e,t);try{if(window.location){let i=CD(r,t);return i?(await Fo(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):ID(i.id,i.type)),{appState:{toast:{message:f("toast.elementLinkCopied"),closable:!0}},captureUpdate:Is.EVENTUALLY}):{appState:t,elements:e,app:n,captureUpdate:Is.EVENTUALLY}}}catch(i){console.error(i)}return{appState:t,elements:e,app:n,captureUpdate:Is.EVENTUALLY}},predicate:(e,t)=>e1(J(e,t))}),j2=N({name:"linkToElement",label:"labels.linkToElement",icon:Gl,perform:(e,t,o,n)=>{let r=J(e,t);return r.length!==1||!e1(r)?{elements:e,appState:t,app:n,captureUpdate:Is.EVENTUALLY}:{appState:{...t,openDialog:{name:"elementLinkSelector",sourceElementId:J(e,t)[0].id}},captureUpdate:Is.IMMEDIATELY}},predicate:(e,t,o,n)=>{let r=J(e,t);return t.openDialog?.name!=="elementLinkSelector"&&r.length===1&&e1(r)},trackEvent:!1});import{isDarwin as q2,getShortcutKey as ie}from"@excalidraw/common";var SD={toggleTheme:[ie("Shift+Alt+D")],saveScene:[ie("CtrlOrCmd+S")],loadScene:[ie("CtrlOrCmd+O")],clearCanvas:[ie("CtrlOrCmd+Delete")],imageExport:[ie("CtrlOrCmd+Shift+E")],commandPalette:[ie("CtrlOrCmd+/"),ie("CtrlOrCmd+Shift+P")],cut:[ie("CtrlOrCmd+X")],copy:[ie("CtrlOrCmd+C")],paste:[ie("CtrlOrCmd+V")],copyStyles:[ie("CtrlOrCmd+Alt+C")],pasteStyles:[ie("CtrlOrCmd+Alt+V")],selectAll:[ie("CtrlOrCmd+A")],deleteSelectedElements:[ie("Delete")],duplicateSelection:[ie("CtrlOrCmd+D"),ie(`Alt+${f("helpDialog.drag")}`)],sendBackward:[ie("CtrlOrCmd+[")],bringForward:[ie("CtrlOrCmd+]")],sendToBack:[q2?ie("CtrlOrCmd+Alt+["):ie("CtrlOrCmd+Shift+[")],bringToFront:[q2?ie("CtrlOrCmd+Alt+]"):ie("CtrlOrCmd+Shift+]")],copyAsPng:[ie("Shift+Alt+C")],group:[ie("CtrlOrCmd+G")],ungroup:[ie("CtrlOrCmd+Shift+G")],gridMode:[ie("CtrlOrCmd+'")],zenMode:[ie("Alt+Z")],objectsSnapMode:[ie("Alt+S")],stats:[ie("Alt+/")],addToLibrary:[],flipHorizontal:[ie("Shift+H")],flipVertical:[ie("Shift+V")],viewMode:[ie("Alt+R")],hyperlink:[ie("CtrlOrCmd+K")],toggleElementLock:[ie("CtrlOrCmd+Shift+L")],resetZoom:[ie("CtrlOrCmd+0")],zoomOut:[ie("CtrlOrCmd+-")],zoomIn:[ie("CtrlOrCmd++")],zoomToFitSelection:[ie("Shift+3")],zoomToFit:[ie("Shift+1")],zoomToFitSelectionInViewport:[ie("Shift+2")],toggleEraserTool:[ie("E")],toggleHandTool:[ie("H")],setFrameAsActiveTool:[ie("F")],saveFileToDisk:[ie("CtrlOrCmd+S")],saveToActiveFile:[ie("CtrlOrCmd+S")],toggleShortcuts:[ie("?")],searchMenu:[ie("CtrlOrCmd+F")],wrapSelectionInFrame:[]},Xe=(e,t=0)=>{let o=SD[e];return o&&o.length>0?o[t]||o[0]:""};var kD="\\u0300-\\u036f",MD="\\ufe20-\\ufe2f",LD="\\u20d0-\\u20ff",AD=kD+MD+LD,PD=`[${AD}]`,_D=RegExp(PD,"g"),DD=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,RD={\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"},t1=e=>e.replace(DD,t=>RD[t]||t).replace(_D,"");import IR from"clsx";import{useEffect as CR,useState as SR}from"react";import{KEYS as kR,queryFocusableElements as qv}from"@excalidraw/common";import{useCallback as ND,useState as BD}from"react";var J2=()=>{let[e,t]=BD(null),o=ND(n=>t(n),[]);return[e,o]};import{useState as Vv,useCallback as x1,useMemo as Kv,useEffect as Uv,memo as Xv,useRef as uR}from"react";import{LIBRARY_DISABLED_TYPES as gR,randomId as hR,isShallowEqual as fR}from"@excalidraw/common";import{useEffect as nv,useRef as rv}from"react";import{URL_HASH_KEYS as r1,URL_QUERY_KEYS as i1,APP_NAME as iv,EVENT as Im,DEFAULT_SIDEBAR as UD,LIBRARY_SIDEBAR_TAB as YD,arrayToMap as a1,cloneJSON as WD,preventUnload as VD,promiseTry as av,resolvablePromise as KD,toValidURL as XD,Queue as $D,Emitter as ZD}from"@excalidraw/common";import{hashElementsVersion as jD,hashString as qD}from"@excalidraw/element";import{getCommonBoundingBox as n1}from"@excalidraw/element";import{COLOR_WHITE as OD,MIME_TYPES as xi}from"@excalidraw/common";var vm=async({data:e,config:t})=>jn({data:e,config:t}),Q2=async({data:e,config:t})=>{let{mimeType:o=xi.png,quality:n}=t||{};o===xi.png&&typeof n=="number"&&console.warn(`"quality" will be ignored for "${xi.png}" mimeType`),o==="image/jpg"&&(o=xi.jpg),o===xi.jpg&&t?.canvasBackgroundColor&&(console.warn(`Defaulting "exportBackground" to "true" for "${xi.jpg}" mimeType`),t={...t,canvasBackgroundColor:e.appState?.viewBackgroundColor||OD});let r=await jn({data:e,config:t});return n=n||(/image\/jpe?g/.test(o)?.92:.8),new Promise((i,a)=>{r.toBlob(async l=>{if(!l)return a(new Error("couldn't export to blob"));l&&o===xi.png&&e.appState?.exportEmbedScene&&(l=await dE({blob:l,metadata:bl(e.elements,e.appState,e.files||{},"local")})),i(l)},o,n)})},La=async({data:e,config:t})=>{let{elements:o,appState:n}=yl({...e,files:e.files||{}},null,null),r={...n,exportPadding:t?.padding},i=ev(o),a=e.files||{};return Fi({data:{elements:i,appState:r,files:a},config:{exportingFrame:t?.exportingFrame,renderEmbeddables:t?.renderEmbeddables,skipInliningFonts:t?.skipInliningFonts,reuseImages:t?.reuseImages}})},FD=async({type:e,data:t,config:o})=>{if(e==="svg"){let n=await La({data:t,config:o});await Fo(n.outerHTML)}else if(e==="png")await Kd(Q2({data:t,config:o}));else if(e==="json")await Wd(t.elements,t.files);else throw new Error("Invalid export type")};import{useEffect as HD,useState as zD}from"react";import{COLOR_PALETTE as GD}from"@excalidraw/common";var o1=be(new Map),tv=async e=>await La({data:{elements:e,appState:{exportBackground:!1,viewBackgroundColor:GD.white},files:null},config:{renderEmbeddables:!1,skipInliningFonts:!0}}),ov=(e,t,o)=>{let[n,r]=zD();return HD(()=>{if(t)if(e){let i=o.get(e);i?r(i):(async()=>{let a=await tv(t);a.querySelector(".style-fonts")?.remove(),a&&(o.set(e,a),r(a))})()}else(async()=>{let i=await tv(t);r(i)})()},[e,t,o,r]),n},Tm=()=>{let[e]=ce(o1);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var JD=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],sv=new ZD,br=be({status:"loaded",isInitialized:!1,libraryItems:[]}),Cs=e=>WD(e),QD=(e,t)=>!e.find(o=>o.elements.length!==t.elements.length?!1:o.elements.every((n,r)=>n.id===t.elements[r].id&&n.versionNonce===t.elements[r].versionNonce)),cv=(e,t)=>{let o=[];for(let n of t)QD(e,n)&&o.push(n);return[...o,...e]},dv=(e,t)=>{let o=a1(t),n={deletedItems:new Map,addedItems:new Map};for(let i of e)o.has(i.id)||n.deletedItems.set(i.id,i);let r=a1(e);for(let i of t)r.has(i.id)||n.addedItems.set(i.id,i);return n},l1=class{constructor(t){S(this,"currLibraryItems",[]);S(this,"prevLibraryItems",Cs(this.currLibraryItems));S(this,"app");S(this,"updateQueue",[]);S(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);S(this,"notifyListeners",()=>{if(this.updateQueue.length>0)et.set(br,t=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:t.isInitialized}));else{et.set(br,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let t=this.prevLibraryItems;this.prevLibraryItems=Cs(this.currLibraryItems);let o=Cs(this.currLibraryItems);this.app.props.onLibraryChange?.(o),sv.trigger(dv(t,o),o)}catch(t){console.error(t)}}});S(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],et.set(o1,new Map)});S(this,"resetLibrary",()=>this.setLibrary([]));S(this,"getLatestLibrary",()=>new Promise(async t=>{try{let o=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?t(this.getLatestLibrary()):t(Cs(o))}catch{return t(this.currLibraryItems)}}));S(this,"updateLibrary",async({libraryItems:t,prompt:o=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:UD.name,tab:YD}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof t=="function"&&!(t instanceof Blob)?t(this.currLibraryItems):t),c;s instanceof Blob?c=await Wu(s,i):c=wl(s,i),!o||window.confirm(f("alerts.confirmAddLibrary",{numShapes:c.length}))?(o&&this.app.focusContainer(),a(n?cv(this.currLibraryItems,c):c)):l(new Bi)}catch(s){l(s)}}))));S(this,"setLibrary",t=>{let o=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof t=="function"&&(t=t(this.currLibraryItems)),this.currLibraryItems=Cs(await t),n(this.currLibraryItems)}catch(i){r(i)}}).catch(n=>{if(n.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw n}).finally(()=>{this.updateQueue=this.updateQueue.filter(n=>n!==o),this.notifyListeners()});return this.updateQueue.push(o),this.notifyListeners(),o});this.app=t}},c1=l1,km=e=>{let o=Math.ceil(Math.sqrt(e.length)),n=[],r=u=>e.slice(u*o,u*o+o).reduce((b,x)=>{let{height:w}=n1(x.elements);return Math.max(b,w)},0),i=u=>{let g=0,b=0,x=0;for(let w of e){if(g%o===0&&(b=0),b===u){let{width:E}=n1(w.elements);x=Math.max(x,E)}g++,b++}return x},a=0,l=0,s=0,c=0,d=0,m=0,p=0;for(let u of e){d&&d%o===0&&(l+=s+50,a=0,m=0,p++),m===0&&(s=r(p)),c=i(m);let{minX:g,minY:b,width:x,height:w}=n1(u.elements),E=(c-x)/2,y=(s-w)/2;n.push(...u.elements.map(T=>({...T,x:T.x+a+E-g,y:T.y+l+y-b}))),a+=c+50,d++,m++}return n},e7=(e,t=JD)=>{if(typeof t=="function"?t(e):t.some(o=>{let n=new URL(`https://${o.replace(/^https?:\/\//,"")}`),{hostname:r,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${n.hostname}$`).test(r)&&new RegExp(`^${n.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},s1=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(r1.addLibrary)||new URLSearchParams(window.location.search).get(i1.addLibrary),t=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:t}:null},fr=class fr{constructor(t){S(this,"adapter");this.adapter=t}static async getLibraryItems(t,o,n=!0){let r=()=>new Promise(async(i,a)=>{try{let l=await t.load({source:o});i(wl(l?.libraryItems||[],"published"))}catch(l){a(l)}});return n?fr.queue.push(r):r()}getLibraryItems(t){return fr.getLibraryItems(this.adapter,t,!1)}};S(fr,"queue",new $D),S(fr,"run",async(t,o)=>{let n=new fr(t);return fr.queue.push(()=>o(n))});var Aa=fr,Ss=0,Cm=0,Sm=e=>qD(e.map(t=>`${t.id}:${jD(t.elements)}`).sort().join()),lv=async(e,t)=>{try{return Cm++,await Aa.run(e,async o=>{let n=a1(await o.getLibraryItems("save"));for(let[l]of t.deletedItems)n.delete(l);let r=[];for(let[l,s]of t.addedItems)n.has(l)?n.set(l,s):r.push(s);let i=r.concat(Array.from(n.values())),a=Sm(i);return a!==Ss&&await e.save({libraryItems:i}),Ss=a,i})}finally{Cm--}},t7=e=>{let{excalidrawAPI:t}=e,o=rv(e);o.current=e;let n=rv(!1);nv(()=>{if(!t)return;n.current=!1;let r=async({libraryUrl:l,idToken:s})=>{let c=new Promise(async(m,p)=>{try{l=decodeURIComponent(l),l=XD(l),e7(l,o.current.validateLibraryUrl);let g=await(await fetch(l)).blob();m(g)}catch(u){p(u)}}),d=s!==t.id;await(d&&document.hidden?new Promise(m=>{window.addEventListener("focus",()=>m(),{once:!0})}):null);try{await t.updateLibrary({libraryItems:c,prompt:d,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(m){throw t.updateScene({appState:{errorMessage:m.message}}),m}finally{if(window.location.hash.includes(r1.addLibrary)){let m=new URLSearchParams(window.location.hash.slice(1));m.delete(r1.addLibrary),window.history.replaceState({},iv,`#${m.toString()}`)}else if(window.location.search.includes(i1.addLibrary)){let m=new URLSearchParams(window.location.search);m.delete(i1.addLibrary),window.history.replaceState({},iv,`?${m.toString()}`)}}},i=l=>{l.preventDefault();let s=s1();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),r(s))},a=s1();if(a&&r(a),"getInitialLibraryItems"in o.current&&o.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(o.current.getInitialLibraryItems()).then(l=>{t.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in o.current&&o.current.adapter){let l=o.current.adapter,s=o.current.migrationAdapter,c=KD();s?c.resolve(av(s.load).then(async d=>{let m=null;try{if(!d)return Aa.getLibraryItems(l,"load");m=wl(d.libraryItems||[],"published");let p=await lv(l,dv([],m));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}`),m}}).catch(d=>(console.error(`error during library migration: ${d.message}`),Aa.getLibraryItems(l,"load")))):c.resolve(av(Aa.getLibraryItems,l,"load")),t.updateLibrary({libraryItems:c.then(d=>{let m=d||[];return Ss=Sm(m),m}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(Im.HASHCHANGE,i),()=>{window.removeEventListener(Im.HASHCHANGE,i)}},[t]),nv(()=>{let r=sv.on(async(a,l)=>{let s=n.current,c="adapter"in o.current&&o.current.adapter||null;try{c&&Ss!==Sm(l)&&await lv(c,a)}catch(d){console.error(`couldn't persist library update: ${d.message}`,a),s&&o.current.excalidrawAPI&&o.current.excalidrawAPI.updateScene({appState:{errorMessage:f("errors.saveLibraryError")}})}}),i=a=>{Cm&&VD(a)};return window.addEventListener(Im.BEFORE_UNLOAD,i),()=>{window.removeEventListener(Im.BEFORE_UNLOAD,i),r(),Ss=0,Cm=0}},[])};import i7 from"clsx";import{VERSIONS as o7}from"@excalidraw/common";import{jsx as r7}from"react/jsx-runtime";var n7=({theme:e,id:t,libraryReturnUrl:o})=>{let n=o||window.location.origin+window.location.pathname;return r7("a",{className:"library-menu-browse-button",href:`${I.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${n}&useHash=true&token=${t}&theme=${e}&version=${o7.excalidrawLibrary}`,target:"_excalidraw_libraries",children:f("labels.libraries")})},mv=n7;import{jsx as a7,jsxs as l7}from"react/jsx-runtime";var Mm=({libraryReturnUrl:e,theme:t,id:o,style:n,children:r,className:i})=>l7("div",{className:i7("library-menu-control-buttons",i),style:n,children:[a7(mv,{id:o,libraryReturnUrl:e,theme:t}),r]});import{useCallback as Da,useEffect as iR,useMemo as zv,useRef as aR,useState as lR}from"react";import{MIME_TYPES as sR,arrayToMap as cR}from"@excalidraw/common";import{duplicateElements as dR}from"@excalidraw/element";import s7 from"lodash.throttle";import{useEffect as c7}from"react";var d7=be(0),pv=e=>{let[t,o]=ce(d7);return c7(()=>{let{current:n}=e;if(!n)return;let r=s7(()=>{let{scrollTop:i}=n;o(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,o]),t};import U7 from"clsx";import{useCallback as Y7,useState as u1}from"react";import{muteFSAbortError as W7}from"@excalidraw/common";import{flushSync as uv}from"react-dom";import m7 from"clsx";import{jsx as Lm,jsxs as u7}from"react/jsx-runtime";var p7=({label:e,onClick:t,className:o,children:n,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return u7("button",{className:m7("Dialog__action-button",s,o),type:i,"aria-label":e,onClick:t,...l,children:[n&&Lm("div",{style:a?{visibility:"hidden"}:{},children:n}),Lm("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&Lm("div",{style:{position:"absolute",inset:0},children:Lm(yt,{})})]})},Ln=p7;import{jsx as gv,jsxs as hv}from"react/jsx-runtime";var g7=e=>{let{onConfirm:t,onCancel:o,children:n,confirmText:r=f("buttons.confirm"),cancelText:i=f("buttons.cancel"),className:a="",...l}=e,s=pe(),c=qn(Pa),{container:d}=tt();return hv($e,{onCloseRequest:o,size:"small",...l,className:`confirm-dialog ${a}`,children:[n,hv("div",{className:"confirm-dialog-buttons",children:[gv(Ln,{label:i,onClick:()=>{s({openMenu:null}),c(!1),uv(()=>{o()}),d?.focus()}}),gv(Ln,{label:r,onClick:()=>{s({openMenu:null}),c(!1),uv(()=>{t()}),d?.focus()},actionType:"danger"})]})]})},Am=g7;import xv from"open-color";import{useCallback as w7,useEffect as p1,useRef as fv,useState as d1}from"react";import{COLOR_WHITE as Ev,EDITOR_LS_KEYS as m1,EXPORT_DATA_TYPES as v7,MIME_TYPES as bv,VERSIONS as T7,chunk as I7,getExportSource as C7}from"@excalidraw/common";var xo=class{static has(t){try{return!!window.localStorage.getItem(t)}catch(o){return console.warn(`localStorage.getItem error: ${o.message}`),!1}}static get(t){try{let o=window.localStorage.getItem(t);return o?JSON.parse(o):null}catch(o){return console.warn(`localStorage.getItem error: ${o.message}`),null}}};S(xo,"set",(t,o)=>{try{return window.localStorage.setItem(t,JSON.stringify(o)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),S(xo,"delete",t=>{try{window.localStorage.removeItem(t)}catch(o){console.warn(`localStorage.removeItem error: ${o.message}`)}});import Pm from"react";var h7=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,f7=/{{([\w-]+)}}/,b7=/<([\w-]+)>/,x7=/<\/([\w-]+)>/,E7=(e,t)=>{let o=[{name:"",children:[]}];return e.split(h7).filter(Boolean).forEach(n=>{let r=n.match(b7),i=n.match(x7),a=n.match(f7);if(r!==null){let l=r[1];t.hasOwnProperty(l)?o.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===o[o.length-1].name){let s=o.pop(),c=Pm.createElement(Pm.Fragment,{},...s.children),d=t[s.name];typeof d=="function"&&o[o.length-1].children.push(d(c))}else console.warn(`Trans: unexpected end tag ${n} for interpolating ${e}`);else if(a!==null){let l=a[1];t.hasOwnProperty(l)?o[o.length-1].children.push(t[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else o[o.length-1].children.push(n)}),o.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),o[0].children},y7=({i18nKey:e,children:t,...o})=>{let{t:n}=Je();return Pm.createElement(Pm.Fragment,{},...E7(n(e),o))},_t=y7;import{jsx as de,jsxs as It}from"react/jsx-runtime";var S7=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=I7(e,6),a=document.createElement("canvas");a.width=i[0].length*128+(i[0].length+1)*(n*2)-n*2,a.height=i.length*128+(i.length+1)*(n*2)-n*2;let l=a.getContext("2d");l.fillStyle=Ev,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let d=await vm({data:{elements:c.elements,files:null},config:{maxWidthOrHeight:128}}),{width:m,height:p}=d,u=Math.floor(s/6)*(128+n*2),g=s%6*(128+n*2);l.drawImage(d,g+(128-m)/2+n,u+(128-p)/2+n),l.lineWidth=r,l.strokeStyle=xv.gray[4],l.strokeRect(g+n/2,u+n/2,128+n,128+n)}return await Ac(new File([await wn(a)],"preview",{type:bv.png}),{outputType:bv.jpg,maxWidthOrHeight:5e3})},k7=({libItem:e,appState:t,index:o,onChange:n,onRemove:r})=>{let i=fv(null),a=fv(null);return p1(()=>{let l=i.current;l&&(async()=>{let s=await La({data:{elements:e.elements,appState:{...t,viewBackgroundColor:Ev,exportBackground:!0},files:null},config:{skipInliningFonts:!0}});l.innerHTML=s.outerHTML})()},[e.elements,t]),It("div",{className:"single-library-item",children:[e.status==="published"&&de("span",{className:"single-library-item-status",children:f("labels.statusPublished")}),de("div",{ref:i,className:"single-library-item__svg"}),de($,{"aria-label":f("buttons.remove"),type:"button",icon:no,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:f("buttons.remove")}),It("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[It("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[It("div",{style:{padding:"0.5em 0"},children:[de("span",{style:{fontWeight:500,color:xv.gray[6]},children:f("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=>{n(l.target.value,o)}})]}),de("span",{className:"error",children:e.error})]})]})},M7=({onClose:e,libraryItems:t,appState:o,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=d1({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,d]=d1(!1);p1(()=>{let y=xo.get(m1.PUBLISH_LIBRARY);y&&s(y)},[]);let[m,p]=d1(t.slice());p1(()=>{p(t.slice())},[t]);let u=y=>{s({...l,[y.target.name]:y.target.value})},g=async y=>{y.preventDefault(),d(!0);let T=[],v=!1;if(m.forEach(R=>{let O="";R.name||(O=f("publishDialog.errors.required"),v=!0),T.push({...R,error:O})}),v){p(T),d(!1);return}let C=await S7(m),M={type:v7.excalidrawLibrary,version:T7.excalidrawLibrary,source:C7(),libraryItems:m},k=JSON.stringify(M,null,2),P=new Blob([k],{type:"application/json"}),A=new FormData;A.append("excalidrawLib",P),A.append("previewImage",C),A.append("previewImageType",C.type),A.append("title",l.name),A.append("authorName",l.authorName),A.append("githubHandle",l.githubHandle),A.append("name",l.name),A.append("description",l.description),A.append("twitterHandle",l.twitterHandle),A.append("website",l.website),fetch(`${I.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:A}).then(R=>R.ok?R.json().then(({url:O})=>{xo.delete(m1.PUBLISH_LIBRARY),n({url:O,authorName:l.authorName,items:m})}):R.json().catch(()=>{throw new Error(R.statusText||"something went wrong")}).then(O=>{throw new Error(O.message||R.statusText||"something went wrong")}),R=>{console.error(R),r(R),d(!1)}).catch(R=>{console.error(R),r(R),d(!1)})},b=()=>{let y=[];return m.forEach((T,v)=>{y.push(de("div",{className:"single-library-item-wrapper",children:de(k7,{libItem:T,appState:o,index:v,onChange:(C,M)=>{let k=m.slice();k[M].name=C,p(k)},onRemove:a})},v))}),de("div",{className:"selected-library-items",children:y})},x=w7(()=>{i(m),xo.set(m1.PUBLISH_LIBRARY,l),e()},[m,e,i,l]),w=!!t.length,E=t.some(y=>y.status==="published");return de($e,{onCloseRequest:x,title:f("publishDialog.title"),className:"publish-library",children:w?It("form",{onSubmit:g,children:[de("div",{className:"publish-library-note",children:de(_t,{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(_t,{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:f("publishDialog.noteItems")}),E&&de("span",{className:"publish-library-note publish-library-warning",children:f("publishDialog.republishWarning")}),b(),It("div",{className:"publish-library__fields",children:[It("label",{children:[It("div",{children:[de("span",{children:f("publishDialog.libraryName")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:f("publishDialog.placeholder.libraryName")})]}),It("label",{style:{alignItems:"flex-start"},children:[It("div",{children:[de("span",{children:f("publishDialog.libraryDesc")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:f("publishDialog.placeholder.libraryDesc")})]}),It("label",{children:[It("div",{children:[de("span",{children:f("publishDialog.authorName")}),de("span",{"aria-hidden":"true",className:"required",children:"*"})]}),de("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:f("publishDialog.placeholder.authorName")})]}),It("label",{children:[de("span",{children:f("publishDialog.githubUsername")}),de("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:f("publishDialog.placeholder.githubHandle")})]}),It("label",{children:[de("span",{children:f("publishDialog.twitterUsername")}),de("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:f("publishDialog.placeholder.twitterHandle")})]}),It("label",{children:[de("span",{children:f("publishDialog.website")}),de("input",{type:"text",name:"website",pattern:"https?://.+",title:f("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:f("publishDialog.placeholder.website")})]}),de("span",{className:"publish-library-note",children:de(_t,{i18nKey:"publishDialog.noteLicense",link:y=>de("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),It("div",{className:"publish-library__buttons",children:[de(Ln,{label:f("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),de(Ln,{type:"submit",label:f("buttons.submit"),actionType:"primary",isLoading:c})]})]}):de("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:f("publishDialog.atleastOneLibItem")})})},yv=M7;import P7 from"clsx";import{useEffect as _7,useRef as D7}from"react";import{EVENT as Iv,KEYS as R7}from"@excalidraw/common";import{forwardRef as wv}from"react";import vv from"clsx";import{jsx as Tv}from"react/jsx-runtime";var L7=wv(({children:e,gap:t,align:o,justifyContent:n,className:r,style:i},a)=>Tv("div",{className:vv("Stack Stack_horizontal",r),style:{"--gap":t,alignItems:o,justifyContent:n,...i},ref:a,children:e})),A7=wv(({children:e,gap:t,align:o,justifyContent:n,className:r,style:i},a)=>Tv("div",{className:vv("Stack Stack_vertical",r),style:{"--gap":t,justifyItems:o,justifyContent:n,...i},ref:a,children:e})),ht={Row:L7,Col:A7};import{jsx as _m}from"react/jsx-runtime";var Cv=({children:e,onClickOutside:t,className:o="",onSelect:n,style:r})=>{let i=me(),a=D7(null),l=or({onClickOutside:t});ea(a,()=>{l.onClickOutside?.()}),_7(()=>{let c=m=>{m.key===R7.ESCAPE&&(m.stopImmediatePropagation(),l.onClickOutside?.())},d={capture:!0};return document.addEventListener(Iv.KEYDOWN,c,d),()=>{document.removeEventListener(Iv.KEYDOWN,c,d)}},[l]);let s=P7(`dropdown-menu ${o}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return _m(Zh.Provider,{value:{onSelect:n},children:_m("div",{ref:a,className:s,style:r,"data-testid":"dropdown-menu",children:i.editor.isMobile?_m(ht.Col,{className:"dropdown-menu-container",children:e}):_m(st,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};Cv.displayName="DropdownMenuContent";var Sv=Cv;import{jsx as B7}from"react/jsx-runtime";var N7=({children:e,className:t="",selected:o,...n})=>B7("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${t} ${o?"dropdown-menu-item--selected":""}`.trim(),children:e}),kv=N7;import{jsx as Mv}from"react/jsx-runtime";var Lv=({icon:e,shortcut:t,href:o,children:n,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let c=Ld(s.onClick,r);return Mv("a",{...s,href:o,target:"_blank",rel:l||"noopener",className:Md(i,a),title:s.title??s["aria-label"],onClick:c,children:Mv(kd,{icon:e,shortcut:t,children:n})})},_a=Lv;Lv.displayName="DropdownMenuItemLink";import{jsx as O7}from"react/jsx-runtime";var Av=()=>O7("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),Pv=Av;Av.displayName="DropdownMenuSeparator";import F7 from"clsx";import{jsx as H7}from"react/jsx-runtime";var _v=({className:e="",children:t,onToggle:o,title:n,...r})=>{let i=me(),a=F7(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return H7("button",{"data-prevent-outside-click":!0,className:a,onClick:o,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:t})},Dv=_v;_v.displayName="DropdownMenuTrigger";import Dm from"react";var Rv=e=>{let t=Dm.Children.toArray(e).find(o=>Dm.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName==="DropdownMenuTrigger");return t||null},Nv=e=>{let t=Dm.Children.toArray(e).find(o=>Dm.isValidElement(o)&&typeof o.type!="string"&&o?.type.displayName&&o.type.displayName==="DropdownMenuContent");return t||null};import{Fragment as z7,jsxs as G7}from"react/jsx-runtime";var An=({children:e,open:t})=>{let o=Rv(e),n=Nv(e);return G7(z7,{children:[o,t&&n]})};An.Trigger=Dv;An.Content=Sv;An.Item=At;An.ItemLink=_a;An.ItemCustom=kv;An.Group=$l;An.Separator=Pv;var Ie=An;An.displayName="DropdownMenu";import{jsx as Xt,jsxs as Rm}from"react/jsx-runtime";var V7=(e,t)=>e.filter(o=>t.includes(o.id)),K7=({setAppState:e,selectedItems:t,library:o,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:a,className:l})=>{let[s]=ce(br),[c,d]=ce(Pa),m=()=>{let A=t.length?f("alerts.removeItemsFromsLibrary",{count:t.length}):f("alerts.resetLibrary"),R=t.length?f("confirmDialog.removeItemsFromLib"):f("confirmDialog.resetLibrary");return Xt(Am,{onConfirm:()=>{t.length?n():r(),u(!1)},onCancel:()=>{u(!1)},title:R,children:Xt("p",{children:A})})},[p,u]=u1(!1),g=!!t.length,b=g?s.libraryItems.filter(A=>t.includes(A.id)):s.libraryItems,x=g?f("buttons.remove"):f("buttons.resetLibrary"),[w,E]=u1(!1),[y,T]=u1(null),v=Y7(()=>Rm($e,{onCloseRequest:()=>T(null),title:f("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Xt("p",{children:Xt(_t,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:A=>Xt("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:A})})}),Xt($,{type:"button",title:f("buttons.close"),"aria-label":f("buttons.close"),label:f("buttons.close"),onClick:()=>T(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[T,y]),C=(A,R)=>{E(!1),T({url:A.url,authorName:A.authorName});let O=R.slice();O.forEach(U=>{t.includes(U.id)&&(U.status="published")}),o.setLibrary(O)},M=async()=>{try{await o.updateLibrary({libraryItems:vc({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(A){if(A?.name==="AbortError"){console.warn(A);return}e({errorMessage:f("errors.importLibraryError")})}},k=async()=>{let A=g?b:await o.getLatestLibrary();tE(A).catch(W7).catch(R=>{e({errorMessage:R.message})})},P=()=>Rm(Ie,{open:c,children:[Xt(Ie.Trigger,{onToggle:()=>d(!c),children:Zu}),Rm(Ie.Content,{onClickOutside:()=>d(!1),onSelect:()=>d(!1),className:"library-menu",children:[!g&&Xt(Ie.Item,{onSelect:M,icon:ni,"data-testid":"lib-dropdown--load",children:f("buttons.load")}),!!b.length&&Xt(Ie.Item,{onSelect:k,icon:Qn,"data-testid":"lib-dropdown--export",children:f("buttons.export")}),!!b.length&&Xt(Ie.Item,{onSelect:()=>u(!0),icon:zt,children:x}),g&&Xt(Ie.Item,{icon:nh,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:f("buttons.publishLibrary")})]})]});return Rm("div",{className:U7("library-menu-dropdown-container",l),children:[P(),t.length>0&&Xt("div",{className:"library-actions-counter",children:t.length}),p&&m(),w&&Xt(yv,{onClose:()=>E(!1),libraryItems:V7(s.libraryItems,t),appState:a,onSuccess:A=>C(A,s.libraryItems),onError:A=>window.alert(A),updateItemsInStorage:()=>o.setLibrary(s.libraryItems),onRemove:A=>i(t.filter(R=>R!==A))}),y&&v()]})},g1=({selectedItems:e,onSelectItems:t,className:o})=>{let{library:n}=Ke(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=Tm(),a=Te(),l=pe(),[s]=ce(br),c=async m=>{let p=m.filter(u=>!e.includes(u.id));n.setLibrary(p).catch(()=>{l({errorMessage:f("alerts.errorRemovingFromLibrary")})}),i(e),t([])};return Xt(K7,{appState:a,setAppState:l,selectedItems:e,onSelectItems:t,library:n,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:o})};import{memo as tR,useEffect as oR,useState as nR}from"react";import X7,{useCallback as $7}from"react";function Z7(){return[!1,$7(t=>t(),[])]}var Bv=X7.useTransition||Z7;import Ov from"clsx";import{memo as j7,useEffect as q7,useRef as J7,useState as Q7}from"react";import{jsx as Nm,jsxs as eR}from"react/jsx-runtime";var Fv=j7(({id:e,elements:t,isPending:o,onClick:n,selected:r,onToggle:i,onDrag:a,svgCache:l})=>{let s=J7(null),c=ov(e,t,l);q7(()=>{let g=s.current;if(g)return c&&(g.innerHTML=c.outerHTML),()=>{g.innerHTML=""}},[c]);let[d,m]=Q7(!1),p=me().editor.isMobile,u=o&&Nm("div",{className:"library-unit__adder",children:$u});return eR("div",{className:Ov("library-unit",{"library-unit__active":t,"library-unit--hover":t&&d,"library-unit--selected":r,"library-unit--skeleton":!c}),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[Nm("div",{className:Ov("library-unit__dragger",{"library-unit__pulse":!!o}),ref:s,draggable:!!t,onClick:t||o?g=>{e&&g.shiftKey?i(e,g):n(e)}:void 0,onDragStart:g=>{if(!e){g.preventDefault();return}m(!1),a(e,g)}}),u,e&&t&&(d||p||r)&&Nm(is,{checked:r,onChange:(g,b)=>i(e,b),className:"library-unit__checkbox"})]})}),Hv=()=>Nm("div",{className:"library-unit library-unit--skeleton"});import{Fragment as rR,jsx as Bm}from"react/jsx-runtime";var h1=({children:e})=>Bm("div",{className:"library-menu-items-container__grid",children:e}),Om=tR(({items:e,onItemSelectToggle:t,onItemDrag:o,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=Bv(),[s,c]=nR(0);return oR(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),Bm(rR,{children:e.map((d,m)=>m<s?Bm(Fv,{elements:d?.elements,isPending:!d?.id&&!!d?.elements,onClick:r,svgCache:i,id:d?.id,selected:n(d.id),onToggle:t,onDrag:o},d?.id??m):Bm(Hv,{},m))})});import{Fragment as Gv,jsx as $t,jsxs as Ra}from"react/jsx-runtime";var mR=17,pR=64;function f1({isLoading:e,libraryItems:t,onAddToLibrary:o,onInsertLibraryItems:n,pendingElements:r,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let d=aR(null),m=pv(d);iR(()=>{m>0&&d.current?.scrollTo(0,m)},[]);let{svgCache:p}=Tm(),u=zv(()=>t.filter(A=>A.status!=="published"),[t]),g=zv(()=>t.filter(A=>A.status==="published"),[t]),b=!t.length&&!r.length,x=!r.length&&!u.length&&!g.length,[w,E]=lR(null),y=Da((A,R)=>{let O=!c.includes(A),U=[...u,...g];if(O){if(R.shiftKey&&w){let ee=U.findIndex(V=>V.id===w),_=U.findIndex(V=>V.id===A);if(ee===-1||_===-1){s([...c,A]);return}let B=cR(c),j=U.reduce((V,Y,le)=>((le>=ee&&le<=_||B.has(Y.id))&&V.push(Y.id),V),[]);s(j)}else s([...c,A]);E(A)}else E(null),s(c.filter(ee=>ee!==A))},[w,s,g,c,u]),T=Da(A=>{let R;return c.includes(A)?R=t.filter(O=>c.includes(O.id)):R=t.filter(O=>O.id===A),R.map(O=>({...O,elements:dR({type:"everything",elements:O.elements,randomizeSeed:!0}).duplicatedElements}))},[t,c]),v=Da((A,R)=>{R.dataTransfer.setData(sR.excalidrawlib,Gu(T(A)))},[T]),C=Da(A=>A?c.includes(A):!1,[c]),M=Da(()=>{o(r)},[r,o]),k=Da(A=>{A&&n(T(A))},[T,n]),P=p.size>=t.length?pR:mR;return Ra("div",{className:"library-menu-items-container",style:r.length||u.length||g.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&$t(g1,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),Ra(ht.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:g.length>0?1:"0 1 auto",marginBottom:0},ref:d,children:[Ra(Gv,{children:[!x&&$t("div",{className:"library-menu-items-container__header",children:f("labels.personalLib")}),e&&$t("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:$t(yt,{})}),!r.length&&!u.length?Ra("div",{className:"library-menu-items__no-items",children:[$t("div",{className:"library-menu-items__no-items__label",children:f("library.noItems")}),$t("div",{className:"library-menu-items__no-items__hint",children:g.length>0?f("library.hint_emptyPrivateLibrary"):f("library.hint_emptyLibrary")})]}):Ra(h1,{children:[r.length>0&&$t(Om,{itemsRenderedPerBatch:P,items:[{id:null,elements:r}],onItemSelectToggle:y,onItemDrag:v,onClick:M,isItemSelected:C,svgCache:p}),$t(Om,{itemsRenderedPerBatch:P,items:u,onItemSelectToggle:y,onItemDrag:v,onClick:k,isItemSelected:C,svgCache:p})]})]}),Ra(Gv,{children:[(g.length>0||r.length>0||u.length>0)&&$t("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:f("labels.excalidrawLib")}),g.length>0?$t(h1,{children:$t(Om,{itemsRenderedPerBatch:P,items:g,onItemSelectToggle:y,onItemDrag:v,onClick:k,isItemSelected:C,svgCache:p})}):u.length>0?$t("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:f("library.noItems")}):null]}),b&&$t(Mm,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:$t(g1,{selectedItems:c,onSelectItems:s})})]})]})}import{jsx as xr,jsxs as Wv}from"react/jsx-runtime";var Pa=be(!1),Yv=({children:e})=>xr("div",{className:"layer-ui__library",children:e}),bR=Xv(({onInsertLibraryItems:e,pendingElements:t,onAddToLibrary:o,setAppState:n,libraryReturnUrl:r,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[d]=ce(br),m=x1(g=>{(async(x,w)=>{ae("element","addToLibrary","ui");for(let y of gR)if(x.some(T=>T.type===y))return n({errorMessage:f(`errors.libraryElementTypeError.${y}`)});let E=[{status:"unpublished",elements:x,id:hR(),created:Date.now()},...w];o(),i.setLibrary(E).catch(()=>{n({errorMessage:f("alerts.errorAddingToLibrary")})})})(g,d.libraryItems)},[o,i,n,d.libraryItems]),p=Kv(()=>d.libraryItems,[d]);if(d.status==="loading"&&!d.isInitialized)return xr(Yv,{children:xr("div",{className:"layer-ui__library-message",children:Wv("div",{children:[xr(yt,{size:"2em"}),xr("span",{children:f("labels.libraryLoadingMessage")})]})})});let u=d.libraryItems.length>0||t.length>0;return Wv(Yv,{children:[xr(f1,{isLoading:d.status==="loading",libraryItems:p,onAddToLibrary:m,onInsertLibraryItems:e,pendingElements:t,id:a,libraryReturnUrl:r,theme:l,onSelectItems:c,selectedItems:s}),u&&xr(Mm,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:r,theme:l})]})}),b1=(e,t)=>({elements:e,pending:J(e,{selectedElementIds:t},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:t}),xR=(e,t)=>{let o=ir(),[n,r]=Vv(()=>b1(o,e.selectedElementIds)),i=uR(new Map);return Uv(()=>{for(let a of n.pending)i.current.set(a.id,a.version)},[n.pending]),Uv(()=>{t.state.cursorButton==="up"&&t.state.activeTool.type==="selection"&&r(a=>{if(!fR(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),b1(o,e.selectedElementIds);let l=t.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let c=l.get(s)?.version;if(c&&c!==i.current.get(s))return b1(o,e.selectedElementIds)}return a})},[t,t.state.cursorButton,t.state.activeTool.type,e.selectedElementIds,o]),n.pending},$v=Xv(()=>{let e=Ke(),{onInsertElements:t}=e,o=tn(),n=Te(),r=pe(),[i,a]=Vv([]),l=Kv(()=>e.library,[e.library]),s=xR(n,e),c=x1(m=>{t(km(m))},[t]),d=x1(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return xr(bR,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:d,setAppState:r,libraryReturnUrl:o.libraryReturnUrl,library:l,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:a})});import ER from"clsx";import{useRef as yR}from"react";import{createPortal as wR}from"react-dom";import{KEYS as vR}from"@excalidraw/common";import{jsx as Zv,jsxs as TR}from"react/jsx-runtime";var jv=e=>{let{closeOnClickOutside:t=!0}=e,o=xd({className:"excalidraw-modal-container"}),n=yR(document.body.classList.contains("excalidraw-animations-disabled"));if(!o)return null;let r=i=>{i.key===vR.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return wR(TR("div",{className:ER("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[Zv("div",{className:"Modal__background",onClick:t?e.onCloseRequest:void 0}),Zv("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),o)};import{jsx as ks,jsxs as LR}from"react/jsx-runtime";function MR(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var $e=e=>{let[t,o]=J2(),[n]=SR(document.activeElement),{id:r}=tt(),i=me().viewport.isMobile;CR(()=>{if(!t)return;let c=qv(t);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let d=m=>{if(m.key===kR.TAB){let p=qv(t),{activeElement:u}=document,g=p.findIndex(b=>b===u);g===0&&m.shiftKey?(p[p.length-1].focus(),m.preventDefault()):g===p.length-1&&!m.shiftKey&&(p[0].focus(),m.preventDefault())}};return t.addEventListener("keydown",d),()=>t.removeEventListener("keydown",d)},[t,e.autofocus]);let a=pe(),l=qn(Pa),s=()=>{a({openMenu:null}),l(!1),n.focus(),e.onCloseRequest()};return ks(jv,{className:IR("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:MR(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:LR(st,{ref:o,children:[e.title&&ks("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:ks("span",{className:"Dialog__titleContent",children:e.title})}),i&&ks("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:no}),ks("div",{className:"Dialog__content",children:e.children})]})})};import E1 from"clsx";import{forwardRef as DR,useRef as RR,useImperativeHandle as NR,useLayoutEffect as BR,useState as OR}from"react";import AR from"clsx";import{composeEventHandlers as PR}from"@excalidraw/common";import{jsx as _R}from"react/jsx-runtime";var lo=({type:e="button",onSelect:t,selected:o,children:n,className:r="",...i})=>_R("button",{onClick:PR(i.onClick,a=>{t()}),type:e,className:AR("excalidraw-button",r,{selected:o}),...i,children:n});import{jsx as y1,jsxs as Jv}from"react/jsx-runtime";var Na=DR(({onChange:e,label:t,fullWidth:o,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:c,...d},m)=>{let p=RR(null);NR(m,()=>p.current),BR(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,g]=OR(!1);return Jv("div",{className:E1("ExcTextField",c,{"ExcTextField--fullWidth":o,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,t&&y1("div",{className:"ExcTextField__label",children:t}),Jv("div",{className:E1("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[y1("input",{className:E1({"is-redacted":"value"in d&&d.value&&l&&!u}),readOnly:r,value:"value"in d?d.value:void 0,defaultValue:"defaultValue"in d?d.defaultValue:void 0,placeholder:n,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&y1(lo,{onSelect:()=>g(!u),style:{border:0,userSelect:"none"},children:u?mh:ai})]})]})});import{KEYS as ot}from"@excalidraw/common";var Ms=[{icon:tg,value:"selection",key:ot.V,numericKey:ot[1],fillable:!0},{icon:vl,value:"rectangle",key:ot.R,numericKey:ot[2],fillable:!0},{icon:Tl,value:"diamond",key:ot.D,numericKey:ot[3],fillable:!0},{icon:Il,value:"ellipse",key:ot.O,numericKey:ot[4],fillable:!0},{icon:og,value:"arrow",key:ot.A,numericKey:ot[5],fillable:!0},{icon:Cl,value:"line",key:ot.L,numericKey:ot[6],fillable:!0},{icon:Tn,value:"freedraw",key:[ot.P,ot.X],numericKey:ot[7],fillable:!1},{icon:ti,value:"text",key:ot.T,numericKey:ot[8],fillable:!1},{icon:rg,value:"image",key:null,numericKey:ot[9],fillable:!1},{icon:ig,value:"eraser",key:ot.E,numericKey:ot[0],fillable:!1}],Qv=e=>Ms.find((o,n)=>o.numericKey!=null&&e===o.numericKey.toString()||o.key&&(typeof o.key=="string"?o.key===e:o.key.includes(e)))?.value||null;import I1 from"clsx";import{useState as zR}from"react";import{CLASSES as GR,KEYS as tT,capitalizeString as T1,isTransparent as oT}from"@excalidraw/common";import{shouldAllowVerticalAlign as UR,suppportsHorizontalAlign as YR}from"@excalidraw/element";import{hasBoundTextElement as nT,isElbowArrow as WR,isImageElement as VR,isLinearElement as KR,isTextElement as XR}from"@excalidraw/element";import{hasStrokeColor as rT,toolIsArrow as iT}from"@excalidraw/element";import{createIsolation as FR}from"jotai-scope";import w1 from"react";import ln from"tunnel-rat";var v1=w1.createContext(null),Ne=()=>w1.useContext(v1),HR=FR(),eT=()=>w1.useMemo(()=>({MainMenuTunnel:ln(),WelcomeScreenMenuHintTunnel:ln(),WelcomeScreenToolbarHintTunnel:ln(),WelcomeScreenHelpHintTunnel:ln(),WelcomeScreenCenterTunnel:ln(),FooterCenterTunnel:ln(),DefaultSidebarTriggerTunnel:ln(),DefaultSidebarTabTriggersTunnel:ln(),OverwriteConfirmDialogTunnel:ln(),TTDDialogTriggerTunnel:ln(),tunnelsJotai:HR}),[]);import{Fragment as Pn,jsx as Re,jsxs as mt}from"react/jsx-runtime";var C1=(e,t)=>{let o=t[0]?.type||null;for(let n of t)if(n.type!==o){o=null;break}return rT(e.activeTool.type)&&o!=="image"&&o!=="frame"&&o!=="magicframe"||t.some(n=>rT(n.type))},S1=(e,t)=>$n(e.activeTool.type)||t.some(o=>$n(o.type)),Fm=({appState:e,elementsMap:t,renderAction:o,app:n})=>{let r=wc(t,e),i=!1;r.length===2&&(nT(r[0])||nT(r[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=me(),s=document.documentElement.getAttribute("dir")==="rtl",c=$n(e.activeTool.type)&&!oT(e.currentItemBackgroundColor)||r.some(g=>$n(g.type)&&!oT(g.backgroundColor)),d=r.length===1||i,m=!e.editingLinearElement&&r.length===1&&KR(r[0])&&!WR(r[0]),p=!e.croppingElementId&&r.length===1&&VR(r[0]),u=!i&&Kt(e,n);return mt("div",{className:"selected-shape-actions",children:[Re("div",{children:C1(e,r)&&o("changeStrokeColor")}),S1(e,r)&&Re("div",{children:o("changeBackgroundColor")}),c&&o("changeFillStyle"),(Nu(e.activeTool.type)||r.some(g=>Nu(g.type)))&&o("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(g=>g.type==="freedraw"))&&o("changeStrokeShape"),(Bu(e.activeTool.type)||r.some(g=>Bu(g.type)))&&mt(Pn,{children:[o("changeStrokeStyle"),o("changeSloppiness")]}),(Ou(e.activeTool.type)||r.some(g=>Ou(g.type)))&&Re(Pn,{children:o("changeRoundness")}),(iT(e.activeTool.type)||r.some(g=>iT(g.type)))&&Re(Pn,{children:o("changeArrowType")}),(e.activeTool.type==="text"||r.some(XR))&&mt(Pn,{children:[o("changeFontFamily"),o("changeFontSize"),(e.activeTool.type==="text"||YR(r,t))&&o("changeTextAlign")]}),UR(r,t)&&o("changeVerticalAlign"),(Ni(e.activeTool.type)||r.some(g=>Ni(g.type)))&&Re(Pn,{children:o("changeArrowhead")}),o("changeOpacity"),mt("fieldset",{children:[Re("legend",{children:f("labels.layers")}),mt("div",{className:"buttonList",children:[o("sendToBack"),o("sendBackward"),o("bringForward"),o("bringToFront")]})]}),u&&!i&&mt("fieldset",{children:[Re("legend",{children:f("labels.align")}),mt("div",{className:"buttonList",children:[s?mt(Pn,{children:[o("alignRight"),o("alignHorizontallyCentered"),o("alignLeft")]}):mt(Pn,{children:[o("alignLeft"),o("alignHorizontallyCentered"),o("alignRight")]}),r.length>2&&o("distributeHorizontally"),Re("div",{style:{flexBasis:"100%",height:0}}),mt("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[o("alignTop"),o("alignVerticallyCentered"),o("alignBottom"),r.length>2&&o("distributeVertically")]})]})]}),!a&&r.length>0&&mt("fieldset",{children:[Re("legend",{children:f("labels.actions")}),mt("div",{className:"buttonList",children:[!l.editor.isMobile&&o("duplicateSelection"),!l.editor.isMobile&&o("deleteSelectedElements"),o("group"),o("ungroup"),d&&o("hyperlink"),p&&o("cropEditor"),m&&o("toggleLinearEditor")]})]})]})},Hm=({activeTool:e,appState:t,app:o,UIOptions:n})=>{let[r,i]=zR(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso",c=e.type==="embeddable",{TTDDialogTriggerTunnel:d}=Ne();return mt(Pn,{children:[Ms.map(({value:m,icon:p,key:u,numericKey:g,fillable:b},x)=>{if(n.tools?.[m]===!1)return null;let w=f(`toolBar.${m}`),E=u&&T1(typeof u=="string"?u:u[0]),y=E?`${E} ${f("helpDialog.or")} ${g}`:`${g}`;return Re($,{className:I1("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===m,name:"editor-current-shape",title:`${T1(w)} \u2014 ${y}`,keyBindingLabel:g||E,"aria-label":T1(w),"aria-keyshortcuts":y,"data-testid":`toolbar-${m}`,onPointerDown:({pointerType:T})=>{!t.penDetected&&T==="pen"&&o.togglePenMode(!0),m==="selection"&&(t.activeTool.type==="selection"?o.setActiveTool({type:"lasso"}):o.setActiveTool({type:"selection"}))},onChange:({pointerType:T})=>{t.activeTool.type!==m&&ae("toolbar",m,"ui"),m==="image"?o.setActiveTool({type:m}):o.setActiveTool({type:m})}},m)}),Re("div",{className:"App-toolbar__divider"}),mt(Ie,{open:r,children:[Re(Ie.Trigger,{className:I1("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||c||s||l&&!o.props.isCollaborating}),onToggle:()=>i(!r),title:f("toolBar.extraTools"),children:a?tr:c?Fc:l&&!o.props.isCollaborating?Xi:s?Gi:ch}),mt(Ie.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Re(Ie.Item,{onSelect:()=>o.setActiveTool({type:"frame"}),icon:tr,shortcut:tT.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:f("toolBar.frame")}),Re(Ie.Item,{onSelect:()=>o.setActiveTool({type:"embeddable"}),icon:Fc,"data-testid":"toolbar-embeddable",selected:c,children:f("toolBar.embeddable")}),Re(Ie.Item,{onSelect:()=>o.setActiveTool({type:"laser"}),icon:Xi,"data-testid":"toolbar-laser",selected:l,shortcut:tT.K.toLocaleUpperCase(),children:f("toolBar.laser")}),Re(Ie.Item,{onSelect:()=>o.setActiveTool({type:"lasso"}),icon:Gi,"data-testid":"toolbar-lasso",selected:s,children:f("toolBar.lasso")}),Re("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),o.props.aiEnabled!==!1&&Re(d.Out,{}),Re(Ie.Item,{onSelect:()=>o.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Rl,"data-testid":"toolbar-embeddable",children:f("toolBar.mermaidToExcalidraw")}),o.props.aiEnabled!==!1&&o.plugins.diagramToCode&&Re(Pn,{children:mt(Ie.Item,{onSelect:()=>o.onMagicframeToolSelect(),icon:Nl,"data-testid":"toolbar-magicframe",children:[f("toolBar.magicframe"),Re(Ie.Item.Badge,{children:"AI"})]})})]})]})]})},aT=({renderAction:e,zoom:t})=>Re(ht.Col,{gap:1,className:GR.ZOOM_ACTIONS,children:mt(ht.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),lT=({renderAction:e,className:t})=>mt("div",{className:`undo-redo-buttons ${t}`,children:[Re("div",{className:"undo-button-container",children:Re(ro,{label:f("buttons.undo"),children:e("undo")})}),Re("div",{className:"redo-button-container",children:mt(ro,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),sT=({actionManager:e,showExitZenModeBtn:t})=>Re("button",{type:"button",className:I1("disable-zen-mode",{"disable-zen-mode--visible":t}),onClick:()=>e.executeAction(fi),children:f("buttons.exitZenMode")}),cT=({renderAction:e,className:t})=>Re("div",{className:`finalize-button ${t}`,children:e("finalize",{size:"small"})});import{useRef as $R}from"react";var k1=e=>{let t=$R({userFn:e});return t.current.userFn=e,t.current.stableFn||(t.current.stableFn=(...o)=>t.current.userFn(...o)),t.current.stableFn};import{jsx as jR,jsxs as ZR}from"react/jsx-runtime";var Ei=be(null),dT=()=>{let[e,t]=ce(Ei),o=nt();return e&&e==="clearCanvas"?jR(Am,{onConfirm:()=>{o.executeAction(rn),t(null)},onCancel:()=>t(null),title:f("clearCanvasDialog.title"),children:ZR("p",{className:"clear-canvas__content",children:[" ",f("alerts.clearReset")]})}):null};var M1={};yc(M1,{toggleTheme:()=>qR});var qR={...dr,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(dr,"commandPalette")}};import{jsx as Ct,jsxs as sn}from"react/jsx-runtime";var n9=be(null),Fe={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},r9=e=>{switch(e){case Fe.app:return 1;case Fe.export:return 2;case Fe.editor:return 3;case Fe.tools:return 4;case Fe.elements:return 5;case Fe.links:return 6;default:return 10}},Um=({shortcut:e,className:t,children:o})=>{let n=e.replace("++","+$").split("+");return sn("div",{className:uT("shortcut",t),children:[n.map((r,i)=>Ct("div",{className:"shortcut-wrapper",children:Ct("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),Ct("div",{className:"shortcut-desc",children:o})]})},gT=e=>!e.altKey&&e[Go.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===Go.P||e.key===Go.SLASH),i9=Object.assign(e=>{let t=Te(),o=pe();return Gm(()=>{let n=r=>{gT(r)&&(r.preventDefault(),r.stopPropagation(),o(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&ae("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(Ym.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(Ym.KEYDOWN,n,{capture:!0})},[o]),t.openDialog?.name!=="commandPalette"?null:Ct(a9,{...e})},{defaultItems:M1});function a9({customCommandPaletteItems:e}){let t=Ke(),o=Te(),n=pe(),r=tn(),i=nt(),[a,l]=ce(n9),[s,c]=zm(null),d=QR(null),m=or({uiAppState:o,customCommandPaletteItems:e,appProps:r});Gm(()=>{let{uiAppState:C,customCommandPaletteItems:M,appProps:k}=m,P=U=>{let ee="";return U.label&&(typeof U.label=="function"?ee=f(U.label(t.scene.getNonDeletedElements(),C,t)):ee=f(U.label)),ee},A=U=>typeof U.icon=="function"?U.icon(C,t.scene.getNonDeletedElements()):U.icon,R=[],O=(U,ee,_)=>{let B={label:P(U),icon:A(U),category:ee,shortcut:Xe(U.name),keywords:U.keywords,predicate:U.predicate,viewMode:U.viewMode,perform:()=>{i.executeAction(U,"commandPalette")}};return _?_(B,U):B};if(C&&t.scene&&i){let U=[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,va,wm,j2].map(Y=>O(Y,Fe.elements,(le,xe)=>({...le,predicate:xe.predicate?xe.predicate:(ue,gt,Ft,_o)=>J(ue,gt).length>0}))),ee=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(Y=>O(Y,Fe.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(Y=>O(Y,Fe.editor)),B=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(Y=>O(Y,Fe.export));R=[...U,..._,{label:P(rn),icon:A(rn),shortcut:Xe(rn.name),category:Fe.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{et.set(Ei,"clearCanvas")}},{label:f("buttons.exportImage"),category:Fe.export,icon:Ll,shortcut:Xe("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...B];let j=[{label:f("toolBar.library"),category:Fe.app,icon:Qr,viewMode:!1,perform:()=>{C.openSidebar?n({openSidebar:null}):n({openSidebar:{name:mT.name,tab:mT.defaultTab}})}},{label:f("search.title"),category:Fe.app,icon:Gt,viewMode:!0,perform:()=>{i.executeAction(Ba)}},{label:f("labels.shapeSwitch"),category:Fe.elements,icon:$i,perform:()=>{i.executeAction(Z2)}},{label:f("labels.changeStroke"),keywords:["color","outline"],category:Fe.elements,icon:Ml,viewMode:!1,predicate:(Y,le)=>{let xe=J(Y,le);return xe.length>0&&C1(le,xe)},perform:()=>{n(Y=>({openMenu:Y.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:f("labels.changeBackground"),keywords:["color","fill"],icon:Ml,category:Fe.elements,viewMode:!1,predicate:(Y,le)=>{let xe=J(Y,le);return xe.length>0&&S1(le,xe)},perform:()=>{n(Y=>({openMenu:Y.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:f("labels.canvasBackground"),keywords:["color"],icon:Ml,category:Fe.editor,viewMode:!1,perform:()=>{n(Y=>({openMenu:Y.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Ms.reduce((Y,le)=>{let{value:xe,icon:ue,key:gt,numericKey:Ft}=le;if(k.UIOptions.tools?.[xe]===!1)return Y;let $r=gt&&e9(typeof gt=="string"?gt:gt[0])||Ft,Zr={label:f(`toolBar.${xe}`),category:Fe.tools,shortcut:$r,icon:ue,keywords:["toolbar"],viewMode:!1,perform:({event:jr})=>{xe==="image"?t.setActiveTool({type:xe}):t.setActiveTool({type:xe})}};return Y.push(Zr),Y},[]),...ee,{label:f("toolBar.lock"),category:Fe.tools,icon:C.activeTool.locked?ei:Jn,shortcut:Go.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{t.toggleLock()}},{label:`${f("labels.textToDiagram")}...`,category:Fe.tools,icon:uh,viewMode:!1,predicate:k.aiEnabled,perform:()=>{n(Y=>({...Y,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${f("toolBar.mermaidToExcalidraw")}...`,category:Fe.tools,icon:Rl,viewMode:!1,predicate:k.aiEnabled,perform:()=>{n(Y=>({...Y,openDialog:{name:"ttd",tab:"mermaid"}}))}}],V=[...R,...j,...M||[]].map(Y=>({...Y,icon:Y.icon||$i,order:Y.order??r9(Y.category),haystack:`${t1(Y.label.toLocaleLowerCase())} ${Y.keywords?.join(" ")||""}`}));c(V),l(V.find(Y=>Y.label===a?.label)??null)}},[m,t,i,c,a?.label,l,n]);let[p,u]=zm(""),[g,b]=zm(null),[x,w]=zm({}),E=C=>{n({openDialog:null},C),u("")},y=(C,M)=>{o.openDialog?.name==="commandPalette"&&(M.stopPropagation(),M.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),E(()=>{C.perform({actionManager:i,event:M}),l(C),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},T=k1(C=>C.viewMode===!1&&o.viewModeEnabled?!1:typeof C.predicate=="function"?C.predicate(t.scene.getNonDeletedElements(),o,r,t):C.predicate===void 0||C.predicate),v=k1(C=>{let M=o9(C.target)||gT(C)||C.key===Go.ESCAPE;if(M&&C.key!==Go.ARROW_UP&&C.key!==Go.ARROW_DOWN&&C.key!==Go.ENTER)return;let k=Object.values(x).flat(),P=a&&!p&&T(a);if(C.key===Go.ARROW_UP){C.preventDefault();let A=k.findIndex(U=>U.label===g?.label);if(P){if(A===0){b(a);return}if(g===a){let U=k[k.length-1];U&&b(U);return}}let R;A===-1?R=k.length-1:R=A===0?k.length-1:(A-1)%k.length;let O=k[R];O&&b(O);return}if(C.key===Go.ARROW_DOWN){C.preventDefault();let A=k.findIndex(U=>U.label===g?.label);if(P){if(!g||A===k.length-1){b(a);return}if(g===a){let U=k[0];U&&b(U);return}}let R=(A+1)%k.length,O=k[R];O&&b(O);return}if(C.key===Go.ENTER&&g&&setTimeout(()=>{y(g,C)}),!M){if(C.stopPropagation(),/^[a-zA-Z0-9]$/.test(C.key)){d?.current?.focus();return}C.preventDefault()}});return Gm(()=>(window.addEventListener(Ym.KEYDOWN,v,{capture:!0}),()=>window.removeEventListener(Ym.KEYDOWN,v,{capture:!0})),[v]),Gm(()=>{if(!s)return;let C=A=>{let R={};for(let O of A)R[O.category]?R[O.category].push(O):R[O.category]=[O];return R},M=s.filter(T).sort((A,R)=>A.order-R.order),k=!p&&a&&T(a);if(!p){w(C(k?M.filter(A=>A.label!==a?.label):M)),b(k?a:M[0]||null);return}let P=t1(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));M=JR.filter(P,M,{extract:A=>A.haystack}).sort((A,R)=>R.score-A.score).map(A=>A.original),w(C(M)),b(M[0]??null)},[p,s,T,a]),sn($e,{onCloseRequest:()=>E(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Ct(Na,{value:p,placeholder:f("commandPalette.search.placeholder"),onChange:C=>{u(C)},selectOnRender:!0,ref:d}),!t.device.viewport.isMobile&&sn("div",{className:"shortcuts-wrapper",children:[Ct(Um,{shortcut:"\u2191\u2193",children:f("commandPalette.shortcuts.select")}),Ct(Um,{shortcut:"\u21B5",children:f("commandPalette.shortcuts.confirm")}),Ct(Um,{shortcut:t9("Esc"),children:f("commandPalette.shortcuts.close")})]}),sn("div",{className:"commands",children:[a&&!p&&sn("div",{className:"command-category",children:[sn("div",{className:"command-category-title",children:[f("commandPalette.recents"),Ct("div",{className:"icon",style:{marginLeft:"6px"},children:gh})]}),Ct(pT,{command:a,isSelected:a.label===g?.label,onClick:C=>y(a,C),disabled:!T(a),onMouseMove:()=>b(a),showShortcut:!t.device.viewport.isMobile,appState:o})]}),Object.keys(x).length>0?Object.keys(x).map((C,M)=>sn("div",{className:"command-category",children:[Ct("div",{className:"command-category-title",children:C}),x[C].map(k=>Ct(pT,{command:k,isSelected:k.label===g?.label,onClick:P=>y(k,P),onMouseMove:()=>b(k),showShortcut:!t.device.viewport.isMobile,appState:o},k.label))]},C)):s?sn("div",{className:"no-match",children:[Ct("div",{className:"icon",children:Gt})," ",f("commandPalette.search.noMatch")]}):null]})]})}var pT=({command:e,isSelected:t,disabled:o,onMouseMove:n,onClick:r,showShortcut:i,appState:a})=>{let l=()=>{};return sn("div",{className:uT("command-item",{"item-selected":t,"item-disabled":o}),ref:s=>{t&&!o&&s?.scrollIntoView?.({block:"nearest"})},onClick:o?l:r,onMouseMove:o?l:n,title:o?f("commandPalette.itemNotAvailable"):"",children:[sn("div",{className:"name",children:[e.icon&&Ct(sr,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),Ct(Zl,{children:e.label})]}),i&&e.shortcut&&Ct(Um,{shortcut:e.shortcut})]})};import{getSizeFromPoints as AB,randomInteger as v0,getUpdatedTimestamp as T0}from"@excalidraw/common";import{simplify as _3}from"points-on-curve";import{pointsOnBezierCurves as Qge}from"points-on-curve";import{invariant as the}from"@excalidraw/common";import{curve as nhe,lineSegment as rhe,pointFrom as ihe,pointDistance as ahe,pointFromArray as lhe,pointFromVector as she,pointRotateRads as che,polygon as dhe,polygonFromPoints as mhe,PRECISION as phe,segmentsIntersectAt as uhe,vector as ghe,vectorAdd as hhe,vectorFromPoint as fhe,vectorScale as bhe}from"@excalidraw/math";import{getElementAbsoluteCoords as Ehe}from"@excalidraw/element";var Oa=e=>{if(!e)return[];for(let t of e.sets)if(t.type==="path")return t.ops;return e.sets[0].ops};import{pointFrom as ft,pointDistance as L3,pointRotateRads as zn}from"@excalidraw/math";import{ROUGHNESS as TB,isTransparent as Os,assertNever as IB,COLOR_PALETTE as CB,LINE_POLYGON_POINT_MERGE_DISTANCE as SB}from"@excalidraw/common";import{RoughGenerator as D3}from"roughjs/bin/generator";import fbe from"roughjs/bin/rough";import{getStroke as fB}from"perfect-freehand";import{isRightAngleRads as Ebe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as wbe,DEFAULT_REDUCED_GLOBAL_ALPHA as vbe,ELEMENT_READY_TO_ERASE_OPACITY as Tbe,FRAME_STYLE as Ibe,MIME_TYPES as C3,THEME as Cbe,distance as Sbe,getFontString as kbe,isRTL as Mbe,getVerticalOffset as Lbe}from"@excalidraw/common";import g3 from"roughjs/bin/rough";import{arrayToMap as B1e,invariant as h0,rescalePoints as O1e,sizeOf as F1e}from"@excalidraw/common";import{degreesToRadians as g0,lineSegment as z1e,pointDistance as G1e,pointFrom as ne,pointFromArray as h3,pointRotateRads as Qe}from"@excalidraw/math";import{pointsOnBezierCurves as W1e}from"points-on-curve";import{pointCenter as a3,pointFrom as q,pointRotateRads as Nt,pointsEqual as l3,pointDistance as Ka,vectorFromPoint as YN,curveLength as WN,curvePointAtLength as VN}from"@excalidraw/math";import{DRAGGING_THRESHOLD as KN,KEYS as Xa,shouldRotateWithDiscreteAngle as s3,getGridPoint as c3,invariant as Fn,tupleToCoors as m0,viewportCoordsToSceneCoords as XN}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as d3,isPathALoop as $N}from"@excalidraw/element";import{KEYS as Xfe,arrayToMap as yN,isBindingFallthroughEnabled as sp,tupleToCoors as $fe,invariant as wN,isDevEnv as vN,isTestEnv as TN}from"@excalidraw/common";import{lineSegment as wo,pointFrom as ge,pointRotateRads as We,vectorFromPoint as Ii,pointDistanceSq as Wa,clamp as $T,pointDistance as Ti,pointFromVector as a0,vectorScale as l0,vectorNormalize as s0,vectorCross as IN,pointsEqual as CN,lineSegmentIntersectionPoints as ZT,PRECISION as SN}from"@excalidraw/math";import{isTransparent as ufe}from"@excalidraw/common";import{curveIntersectLineSegment as DT,isPointWithinBounds as hfe,lineSegment as V1,lineSegmentIntersectionPoints as RT,pointFrom as ffe,pointFromVector as bfe,pointRotateRads as Rn,pointsEqual as xfe,vectorFromPoint as Efe,vectorNormalize as yfe,vectorScale as wfe}from"@excalidraw/math";import{ellipse as K9,ellipseSegmentInterceptPoints as X9}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as l9,DEFAULT_PROPORTIONAL_RADIUS as L1,LINE_CONFIRM_THRESHOLD as s9,ROUNDNESS as A1}from"@excalidraw/common";import{curve as _n,curveCatmullRomCubicApproxPoints as hT,curveOffsetPoints as fT,lineSegment as so,pointDistance as c9,pointFrom as fe,pointFromArray as d9,rectangle as m9}from"@excalidraw/math";var Ls=new WeakMap,P1=(e,t)=>{let o=Ls.get(e);if(!o)return;let{version:n,shapes:r}=o;if(n!==e.version){Ls.delete(e);return}return r.get(t)},_1=(e,t,o)=>{let n=Ls.get(e);if(!n){Ls.set(e,{version:e.version,shapes:new Map([[o,t]])});return}let{version:r,shapes:i}=n;if(r!==e.version){Ls.set(e,{version:e.version,shapes:new Map([[o,t]])});return}i.set(o,t)};function Wm(e){let t=P1(e,0);if(t)return t;let o=bT(e),n=[],r=[];for(let a=0;a<o.length;a+=1){let l=o[a],s=o[a-1]&&d9(o[a-1].data.slice(-2));switch(l.op){case"move":continue;case"lineTo":if(!s)throw new Error("prevPoint is undefined");n.push(so(fe(e.x+s[0],e.y+s[1]),fe(e.x+l.data[0],e.y+l.data[1])));continue;case"bcurveTo":if(!s)throw new Error("prevPoint is undefined");r.push(_n(fe(e.x+s[0],e.y+s[1]),fe(e.x+l.data[0],e.y+l.data[1]),fe(e.x+l.data[2],e.y+l.data[3]),fe(e.x+l.data[4],e.y+l.data[5])));continue;default:console.error("Unknown op type",l.op)}}let i=[n,r];return _1(e,i,0),i}function As(e,t=0){let o=P1(e,t);if(o)return o;let n=Er(Math.min(e.width,e.height),e);n===0&&(n=.01);let r=m9(fe(e.x,e.y),fe(e.x+e.width,e.y+e.height)),i=so(fe(r[0][0]+n,r[0][1]),fe(r[1][0]-n,r[0][1])),a=so(fe(r[1][0],r[0][1]+n),fe(r[1][0],r[1][1]-n)),l=so(fe(r[0][0]+n,r[1][1]),fe(r[1][0]-n,r[1][1])),s=so(fe(r[0][0],r[1][1]-n),fe(r[0][0],r[0][1]+n)),c=[_n(s[1],fe(s[1][0]+2/3*(r[0][0]-s[1][0]),s[1][1]+2/3*(r[0][1]-s[1][1])),fe(i[0][0]+2/3*(r[0][0]-i[0][0]),i[0][1]+2/3*(r[0][1]-i[0][1])),i[0]),_n(i[1],fe(i[1][0]+2/3*(r[1][0]-i[1][0]),i[1][1]+2/3*(r[0][1]-i[1][1])),fe(a[0][0]+2/3*(r[1][0]-a[0][0]),a[0][1]+2/3*(r[0][1]-a[0][1])),a[0]),_n(a[1],fe(a[1][0]+2/3*(r[1][0]-a[1][0]),a[1][1]+2/3*(r[1][1]-a[1][1])),fe(l[1][0]+2/3*(r[1][0]-l[1][0]),l[1][1]+2/3*(r[1][1]-l[1][1])),l[1]),_n(l[0],fe(l[0][0]+2/3*(r[0][0]-l[0][0]),l[0][1]+2/3*(r[1][1]-l[0][1])),fe(s[0][0]+2/3*(r[0][0]-s[0][0]),s[0][1]+2/3*(r[1][1]-s[0][1])),s[0])],d=t>0?c.map(u=>hT(fT(u,t))):[[c[0]],[c[1]],[c[2]],[c[3]]],p=[[so(d[0][d[0].length-1][3],d[1][0][0]),so(d[1][d[1].length-1][3],d[2][0][0]),so(d[2][d[2].length-1][3],d[3][0][0]),so(d[3][d[3].length-1][3],d[0][0][0])],d.flat()];return _1(e,p,t),p}function Ps(e,t=0){let o=P1(e,t);if(o)return o;let[n,r,i,a,l,s,c,d]=Km(e),m=e.roundness?Er(Math.abs(n-c),e):(n-c)*.01,p=e.roundness?Er(Math.abs(a-r),e):(a-r)*.01,[u,g,b,x]=[fe(e.x+n,e.y+r),fe(e.x+i,e.y+a),fe(e.x+l,e.y+s),fe(e.x+c,e.y+d)],w=[_n(fe(g[0]-m,g[1]-p),g,g,fe(g[0]-m,g[1]+p)),_n(fe(b[0]+m,b[1]-p),b,b,fe(b[0]-m,b[1]-p)),_n(fe(x[0]+m,x[1]+p),x,x,fe(x[0]+m,x[1]-p)),_n(fe(u[0]-m,u[1]+p),u,u,fe(u[0]+m,u[1]+p))],E=t>0?w.map(v=>hT(fT(v,t))):[[w[0]],[w[1]],[w[2]],[w[3]]],T=[[so(E[0][E[0].length-1][3],E[1][0][0]),so(E[1][E[1].length-1][3],E[2][0][0]),so(E[2][E[2].length-1][3],E[3][0][0]),so(E[3][E[3].length-1][3],E[0][0][0])],E.flat()];return _1(e,T,t),T}var Vm=(e,t=1)=>{if(e.length>=3){let[o,n]=[e[0],e[e.length-1]];return c9(o,n)<=s9/t}return!1},Er=(e,t)=>{if(t.roundness?.type===A1.PROPORTIONAL_RADIUS||t.roundness?.type===A1.LEGACY)return e*L1;if(t.roundness?.type===A1.ADAPTIVE_RADIUS){let o=t.roundness?.value??l9,n=o/L1;return e<=n?e*L1:o}return 0};import{ROUNDNESS as Lhe,assertNever as Ahe}from"@excalidraw/common";import{pointsEqual as p9}from"@excalidraw/math";var xT=e=>!!e&&e.type==="embeddable",ET=e=>!!e&&e.type==="iframe",D1=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),yr=e=>e!=null&&e.type==="text";var Uo=e=>e!=null&&(e.type==="frame"||e.type==="magicframe"),Fa=e=>e!=null&&u9(e.type),u9=e=>e==="freedraw",cn=e=>e!=null&&g9(e.type),_s=e=>e!=null&&e.type==="line",Zt=e=>e!=null&&e.type==="arrow",Ee=e=>Zt(e)&&e.elbowed;var g9=e=>e==="arrow"||e==="line",R1=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&h9(e.type),h9=e=>e==="arrow",Ds=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId),yT=e=>e!=null&&(e.type==="rectangle"||e.type==="diamond"||e.type==="image"||e.type==="iframe"||e.type==="embeddable"||e.type==="frame"||e.type==="magicframe"||e.type==="text"&&!e.containerId);var f9=(e,t=!0)=>e!=null&&(!e.locked||t===!0)&&(e.type==="rectangle"||e.type==="diamond"||e.type==="ellipse"||Zt(e));var Xm=e=>f9(e)&&!!e.boundElements?.some(({type:t})=>t==="text"),Dn=e=>e!==null&&"containerId"in e&&e.containerId!==null&&yr(e);var $m=e=>Object.hasOwn(e,"fixedPoint")&&e.fixedPoint!=null;var wT=e=>e.length>3||e.length===3&&!p9(e[0],e[e.length-1]);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as R9,ARROW_LABEL_WIDTH_FRACTION as N9,BOUND_TEXT_PADDING as dn,DEFAULT_FONT_SIZE as B9,TEXT_ALIGN as MT,VERTICAL_ALIGN as LT,getFontString as AT,isProdEnv as qhe,invariant as Jhe}from"@excalidraw/common";var vT={};var TT=e=>{vT[e]&&delete vT[e]};import{BOUND_TEXT_PADDING as Ohe,DEFAULT_FONT_SIZE as Fhe,DEFAULT_FONT_FAMILY as Hhe,getFontString as zhe,isTestEnv as b9,normalizeEOL as x9}from"@excalidraw/common";var IT=(e,t,o)=>{let n=e.split(`
|
|
21
|
+
`).map(l=>l||" ").join(`
|
|
22
|
+
`),r=parseFloat(t),i=w9(n,r,o);return{width:y9(n,t),height:i}},Ghe="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();var E9=e=>x9(e).replace(/\t/g," "),CT=e=>E9(e).split(`
|
|
23
|
+
`);var ST=(e,t)=>e*t;var N1;var B1=class{constructor(){S(this,"canvas");this.canvas=document.createElement("canvas")}getLineWidth(t,o){let n=this.canvas.getContext("2d");n.font=o;let i=n.measureText(t).width;return b9()?i*10:i}},wr=(e,t)=>(N1||(N1=new B1),N1.getLineWidth(e,t)),y9=(e,t)=>{let o=CT(e),n=0;return o.forEach(r=>{n=Math.max(n,wr(r,t))}),n},w9=(e,t,o)=>{let n=CT(e).length;return ST(t,o)*n},Zm=(()=>{let e={};return{calculate:(r,i)=>{let a=r.charCodeAt(0);if(e[i]||(e[i]=[]),!e[i][a]){let l=wr(r,i);e[i][a]=l}return e[i][a]},getCache:r=>e[r],clearCache:r=>{e[r]=[]}}})();import{isDevEnv as v9,isTestEnv as T9}from"@excalidraw/common";var jm,O1;var I9=()=>{if(!jm)try{jm=S9()}catch{jm=C9()}return jm},F1=()=>(O1||(O1=k9()),O1),Eo={WHITESPACE:/\s/u,HYPHEN:/-/u,OPENING:/<\(\[\{/u,CLOSING:/>\)\]\}.,:;!\?…\//u},vr={CHAR:/\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}`'^〃〰〆#&*+-ー/\=|¦〒¬ ̄/u,OPENING:/([{〈《⦅「「『【〖〔〘〚<〝/u,CLOSING:/)]}〉》⦆」」』】〗〕〙〛>。.,、〟‥?!:;・〜〞/u,CURRENCY:/¥₩£¢$/u},yi={FLAG:/\p{RI}\p{RI}/u,JOINER:/(?:\p{Emoji_Modifier}|\uFE0F\u20E3?|[\u{E0020}-\u{E007E}]+\u{E007F})?/u,ZWJ:/\u200D/u,ANY:/[\p{Emoji}]/u,MOST:/[\p{Extended_Pictographic}\p{Emoji_Presentation}]/u},C9=()=>ke.or(F1(),Ze.On(Eo.HYPHEN,Eo.WHITESPACE,vr.CHAR)),S9=()=>ke.or(F1(),Ze.Before(Eo.WHITESPACE).Build(),Ze.After(Eo.WHITESPACE,Eo.HYPHEN).Build(),Ze.Before(vr.CHAR,vr.CURRENCY).NotPrecededBy(Eo.OPENING,vr.OPENING).Build(),Ze.After(vr.CHAR).NotFollowedBy(Eo.HYPHEN,Eo.CLOSING,vr.CLOSING).Build(),Ze.BeforeMany(vr.OPENING).NotPrecededBy(Eo.OPENING).Build(),Ze.AfterMany(vr.CLOSING).NotFollowedBy(Eo.CLOSING).Build(),Ze.AfterMany(Eo.CLOSING).FollowedBy(Eo.OPENING).Build()),k9=()=>ke.group(ke.or(yi.FLAG,ke.and(yi.MOST,yi.JOINER,ke.build(`(?:${yi.ZWJ.source}(?:${yi.FLAG.source}|${yi.ANY.source}${yi.JOINER.source}))*`)))),ke={build:e=>new RegExp(e,"u"),join:(...e)=>e.map(t=>t.source).join(""),and:(...e)=>ke.build(ke.join(...e)),or:(...e)=>ke.build(e.map(t=>t.source).join("|")),group:(...e)=>ke.build(`(${ke.join(...e)})`),class:(...e)=>ke.build(`[${ke.join(...e)}]`)},Ze={On:(...e)=>{let t=ke.join(...e);return ke.build(`([${t}])`)},Before:(...e)=>{let t=ke.join(...e),o=()=>ke.build(`(?=[${t}])`);return Ze.Chain(o)},After:(...e)=>{let t=ke.join(...e),o=()=>ke.build(`(?<=[${t}])`);return Ze.Chain(o)},BeforeMany:(...e)=>{let t=ke.join(...e),o=()=>ke.build(`(?<![${t}])(?=[${t}])`);return Ze.Chain(o)},AfterMany:(...e)=>{let t=ke.join(...e),o=()=>ke.build(`(?<=[${t}])(?![${t}])`);return Ze.Chain(o)},NotBefore:(...e)=>{let t=ke.join(...e),o=()=>ke.build(`(?![${t}])`);return Ze.Chain(o)},NotAfter:(...e)=>{let t=ke.join(...e),o=()=>ke.build(`(?<![${t}])`);return Ze.Chain(o)},Chain:e=>({Build:e,PreceededBy:(...t)=>{let o=e(),n=Ze.After(...t).Build(),r=()=>ke.and(n,o);return Ze.Chain(r)},FollowedBy:(...t)=>{let o=e(),n=Ze.Before(...t).Build(),r=()=>ke.and(o,n);return Ze.Chain(r)},NotPrecededBy:(...t)=>{let o=e(),n=Ze.NotAfter(...t).Build(),r=()=>ke.and(n,o);return Ze.Chain(r)},NotFollowedBy:(...t)=>{let o=e(),n=Ze.NotBefore(...t).Build(),r=()=>ke.and(o,n);return Ze.Chain(r)}})},M9=e=>{let t=I9();return e.normalize("NFC").split(t).filter(Boolean)},kT=(e,t,o)=>{if(!Number.isFinite(o)||o<0)return e;let n=[],r=e.split(`
|
|
24
|
+
`);for(let i of r){if(wr(i,t)<=o){n.push(i);continue}let l=L9(i,t,o);n.push(...l)}return n.join(`
|
|
25
|
+
`)},L9=(e,t,o)=>{let n=[],i=M9(e)[Symbol.iterator](),a="",l=0,s=i.next();for(;!s.done;){let c=s.value,d=a+c,m=_9(c)?l+Zm.calculate(c,t):wr(d,t);if(/\s/.test(c)||m<=o){a=d,l=m,s=i.next();continue}if(a)n.push(a.trimEnd()),a="",l=0;else{let p=A9(c,t,o),u=p[p.length-1]??"",g=p.slice(0,-1);n.push(...g),a=u,l=wr(u,t),s=i.next()}}if(a){let c=P9(a,t,o);n.push(c)}return n},A9=(e,t,o)=>{if(F1().test(e))return[e];D9(e);let n=[],r=Array.from(e),i="",a=0;for(let l of r){let s=Zm.calculate(l,t),c=a+s;if(c<=o){i=i+l,a=c;continue}i&&n.push(i),i=l,a=s}return i&&n.push(i),n},P9=(e,t,o)=>{if(!(wr(e,t)>o))return e;let[,r,i]=e.match(/^(.+?)(\s+)$/)??[e,e.trimEnd(),""],a=wr(r,t);for(let l of Array.from(i)){let s=Zm.calculate(l,t),c=a+s;if(c>o)break;r=r+l,a=c}return r},_9=e=>e.codePointAt(0)!==void 0&&e.codePointAt(1)===void 0,D9=e=>{if((T9()||v9())&&/\s/.test(e))throw new Error("Word should not contain any whitespaces!")};var H1=(e,t,o,n=!1)=>{let r=t.getNonDeletedElementsMap();if(!PT(e))return;TT(e.id);let a=jt(e,r);if(a&&a.text){if(!e)return;let l=a.text,s=a.height,c=a.width,d=z1(e,a),m=G1(e,a),p=e.height;if(n||o!=="n"&&o!=="s"){l&&(l=kT(a.originalText,AT(a),d));let u=IT(l,AT(a),a.lineHeight);s=u.height,c=u.width}if(s>m){p=F9(s,e.type);let u=p-e.height,g=!Zt(e)&&(o==="ne"||o==="nw"||o==="n")?e.y-u:e.y;t.mutateElement(e,{height:p,y:g})}t.mutateElement(a,{text:l,width:c,height:s}),Zt(e)||t.mutateElement(a,O9(e,a,r))}},O9=(e,t,o)=>{if(Zt(e))return Dt.getBoundTextElementPosition(e,t,o);let n=_T(e),r=G1(e,t),i=z1(e,t),a,l;return t.verticalAlign===LT.TOP?l=n.y:t.verticalAlign===LT.BOTTOM?l=n.y+(r-t.height):l=n.y+(r/2-t.height/2),t.textAlign===MT.LEFT?a=n.x:t.textAlign===MT.RIGHT?a=n.x+(i-t.width):a=n.x+(i/2-t.width/2),{x:a,y:l}},PT=e=>e?.boundElements?.length&&e?.boundElements?.find(t=>t.type==="text")?.id||null,jt=(e,t)=>{if(!e)return null;let o=PT(e);return o&&t.get(o)||null},Ha=(e,t)=>e&&e.containerId&&t.get(e.containerId)||null;var _T=e=>{let t=dn,o=dn;return e.type==="ellipse"&&(t+=e.width/2*(1-Math.sqrt(2)/2),o+=e.height/2*(1-Math.sqrt(2)/2)),e.type==="diamond"&&(t+=e.width/4,o+=e.height/4),{x:e.x+t,y:e.y+o}};var F9=(e,t)=>{e=Math.ceil(e);let o=dn*2;return t==="ellipse"?Math.round((e+o)/Math.sqrt(2)*2):t==="arrow"?e+o*8:t==="diamond"?2*(e+o):e+o},z1=(e,t)=>{let{width:o}=e;if(Zt(e)){let n=(t?.fontSize??B9)*R9;return Math.max(N9*o,n)}return e.type==="ellipse"?Math.round(o/2*Math.sqrt(2))-dn*2:e.type==="diamond"?Math.round(o/2)-dn*2:o-dn*2},G1=(e,t)=>{let{height:o}=e;return Zt(e)?o-dn*8*2<=0?t.height:o:e.type==="ellipse"?Math.round(o/2*Math.sqrt(2))-dn*2:e.type==="diamond"?Math.round(o/2)-dn*2:o-dn*2};import{curvePointDistance as U1,distanceToLineSegment as Y1,pointRotateRads as W1}from"@excalidraw/math";import{ellipse as H9,ellipseDistanceFromPoint as z9}from"@excalidraw/math/ellipse";var wi=(e,t,o)=>{switch(e.type){case"selection":case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"magicframe":return G9(e,t,o);case"diamond":return U9(e,t,o);case"ellipse":return Y9(e,t,o);case"line":case"arrow":case"freedraw":return W9(e,o)}},G9=(e,t,o)=>{let n=wt(e,t),r=W1(o,n,-e.angle),[i,a]=As(e);return Math.min(...i.map(l=>Y1(r,l)),...a.map(l=>U1(l,r)).filter(l=>l!==null))},U9=(e,t,o)=>{let n=wt(e,t),r=W1(o,n,-e.angle),[i,a]=Ps(e);return Math.min(...i.map(l=>Y1(r,l)),...a.map(l=>U1(l,r)).filter(l=>l!==null))},Y9=(e,t,o)=>{let n=wt(e,t);return z9(W1(o,n,-e.angle),H9(n,e.width/2,e.height/2))},W9=(e,t)=>{let[o,n]=Wm(e);return Math.min(...o.map(r=>Y1(t,r)),...n.map(r=>U1(r,t)))};var qm=(e,t,o,n=0,r=!1)=>{let i=[Math.min(o[0][0]-n,o[1][0]-n),Math.min(o[0][1]-n,o[1][1]-n),Math.max(o[0][0]+n,o[1][0]+n),Math.max(o[0][1]+n,o[1][1]+n)],a=vi(e,t);if(!za(i,a))return[];switch(e.type){case"rectangle":case"image":case"text":case"iframe":case"embeddable":case"frame":case"selection":case"magicframe":return Z9(e,t,o,n,r);case"diamond":return j9(e,t,o,n,r);case"ellipse":return q9(e,t,o,n);case"line":case"freedraw":case"arrow":return $9(e,o,r)}},NT=(e,t,o,n,r,i=!1)=>{for(let a of e){let l=Jm(a[0],a[1],a[2],a[3]),s=[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])];if(!za(l,s))continue;let c=DT(a,t);if(c.length>0){for(let d of c)o.push(Rn(d,n,r));if(i)return o}}return o},BT=(e,t,o,n,r,i=!1)=>{for(let a of e){let l=RT(a,t);if(l&&(o.push(Rn(l,n,r)),i))return o}return o},$9=(e,t,o=!1)=>{let[n,r]=Wm(e),i=[];for(let a of n){let l=RT(a,t);if(l&&(i.push(l),o))return i}for(let a of r){let l=Jm(a[0],a[1],a[2],a[3]),s=[Math.min(t[0][0],t[1][0]),Math.min(t[0][1],t[1][1]),Math.max(t[0][0],t[1][0]),Math.max(t[0][1],t[1][1])];if(!za(l,s))continue;let c=DT(a,t);if(c.length>0&&(i.push(...c),o))return i}return i},Z9=(e,t,o,n=0,r=!1)=>{let i=wt(e,t),a=Rn(o[0],i,-e.angle),l=Rn(o[1],i,-e.angle),s=V1(a,l),[c,d]=As(e,n),m=[];return BT(c,s,m,i,e.angle,r),r&&m.length>0||NT(d,s,m,i,e.angle,r),m},j9=(e,t,o,n=0,r=!1)=>{let i=wt(e,t),a=Rn(o[0],i,-e.angle),l=Rn(o[1],i,-e.angle),s=V1(a,l),[c,d]=Ps(e,n),m=[];return BT(c,s,m,i,e.angle,r),r&&m.length>0||NT(d,s,m,i,e.angle,r),m},q9=(e,t,o,n=0)=>{let r=wt(e,t),i=Rn(o[0],r,-e.angle),a=Rn(o[1],r,-e.angle);return X9(K9(r,e.width/2+n,e.height/2+n),V1(i,a)).map(l=>Rn(l,r,e.angle))};import{invariant as OT,isDevEnv as J9,isTestEnv as Q9}from"@excalidraw/common";import{pointFrom as Tr,pointFromVector as Qm,pointRotateRads as ep,pointScaleFromOrigin as tp,pointsEqual as eN,triangleIncludesPoint as K1,vectorCross as qt,vectorFromPoint as ye,vectorScale as op}from"@excalidraw/math";var rt=[1,0],Rt=[0,1],yo=[-1,0],Yo=[0,-1],Bn=e=>{let[t,o]=e,n=Math.abs(t),r=Math.abs(o);return t>r?rt:t<=-r?yo:o>n?Rt:Yo},Jt=(e,t)=>Bn(ye(e,t)),Wo=(e,t)=>co(Jt(e,t)),vt=(e,t)=>e[0]===t[0]&&e[1]===t[1],co=e=>vt(e,rt)||vt(e,yo);var tN=(e,t,o)=>{let n=Nn(t);(J9()||Q9())&&(OT(e.width>0&&e.height>0,"Diamond element has no width or height"),OT(!eN(n,o),"The point is too close to the element mid point to determine heading"));let r=.95,i=Qm(op(ye(ep(Tr(e.x+e.width/2,e.y),n,e.angle),n),r),n),a=Qm(op(ye(ep(Tr(e.x+e.width,e.y+e.height/2),n,e.angle),n),r),n),l=Qm(op(ye(ep(Tr(e.x+e.width/2,e.y+e.height),n,e.angle),n),r),n),s=Qm(op(ye(ep(Tr(e.x,e.y+e.height/2),n,e.angle),n),r),n);if(qt(ye(o,i),ye(i,a))<=0&&qt(ye(o,i),ye(i,s))>0)return Jt(i,n);if(qt(ye(o,a),ye(a,l))<=0&&qt(ye(o,a),ye(a,i))>0)return Jt(a,n);if(qt(ye(o,l),ye(l,s))<=0&&qt(ye(o,l),ye(l,a))>0)return Jt(l,n);if(qt(ye(o,s),ye(s,i))<=0&&qt(ye(o,s),ye(s,l))>0)return Jt(s,n);if(qt(ye(o,n),ye(i,n))<=0&&qt(ye(o,n),ye(a,n))>0){let d=e.width>e.height?i:a;return Jt(d,n)}else if(qt(ye(o,n),ye(a,n))<=0&&qt(ye(o,n),ye(l,n))>0){let d=e.width>e.height?l:a;return Jt(d,n)}else if(qt(ye(o,n),ye(l,n))<=0&&qt(ye(o,n),ye(s,n))>0){let d=e.width>e.height?l:s;return Jt(d,n)}let c=e.width>e.height?i:s;return Jt(c,n)},X1=(e,t,o)=>{let r=Nn(t);if(e.type==="diamond")return tN(e,t,o);let i=tp(Tr(t[0],t[1]),r,2),a=tp(Tr(t[2],t[1]),r,2),l=tp(Tr(t[0],t[3]),r,2),s=tp(Tr(t[2],t[3]),r,2);return K1([i,a,r],o)?Yo:K1([a,s,r],o)?rt:K1([s,l,r],o)?Rt:yo},$1=e=>[e[0]===0?0:e[0]>0?-1:1,e[1]===0?0:e[1]>0?-1:1];import{clamp as np,pointDistance as q1,pointFrom as se,pointScaleFromOrigin as oN,pointsEqual as Ns,pointTranslate as j1,vector as mn,vectorCross as rp,vectorFromPoint as J1,vectorScale as nN}from"@excalidraw/math";import{BinaryHeap as rN,invariant as Ga,isAnyTrue as iN,tupleToCoors as aN,getSizeFromPoints as FT,isDevEnv as lN,arrayToMap as sN}from"@excalidraw/common";var Q1=1,Me=40,cN=(e,t)=>{let o=e.fixedSegments?e.fixedSegments.slice():null;if(o){let n=[];e.points.map(a=>se(e.x+a[0],e.y+a[1])).forEach((a,l,s)=>{if(l<2)return n.push(a);let c=Jt(a,s[l-1]),d=Jt(s[l-1],s[l-2]);if(vt(c,d)){let m=o?.findIndex(u=>u.index===l-1)??-1,p=o?.findIndex(u=>u.index===l)??-1;p!==-1&&(o[p].start=se(s[l-2][0]-e.x,s[l-2][1]-e.y)),m!==-1&&o.splice(m,1),n.splice(-1,1),o.forEach(u=>{u.index>l-1&&(u.index-=1)})}return n.push(a)});let r=[];n.forEach((a,l,s)=>{if(l<3)return r.push(a);if(q1(s[l-2],s[l-1])<Q1){let c=o?.findIndex(p=>p.index===l-2)??-1,d=o?.findIndex(p=>p.index===l-1)??-1;d!==-1&&o.splice(d,1),c!==-1&&o.splice(c,1),r.splice(-2,2),o.forEach(p=>{p.index>l-2&&(p.index-=2)});let m=Wo(a,s[l-1]);return r.push(se(m?a[0]:s[l-2][0],m?s[l-2][1]:a[1]))}r.push(a)});let i=o.filter(a=>a.index!==1&&a.index!==r.length-1);return i.length===0?On(o0(n0(t0(e,e0(e,t,r.map(a=>se(a[0]-e.x,a[1]-e.y))))??[])),i,null,null):(lN()&&Ga(VT(r),"Invalid elbow points with fixed segments"),On(r,i,e.startIsSpecial,e.endIsSpecial))}return{x:e.x,y:e.y,points:e.points,fixedSegments:e.fixedSegments,startIsSpecial:e.startIsSpecial,endIsSpecial:e.endIsSpecial}},dN=(e,t,o)=>{let n=t.map(P=>P.index),i=(e.fixedSegments?.map(P=>P.index)??[]).findIndex(P=>!n.includes(P));if(i===-1||!e.fixedSegments?.[i])return{points:e.points};let a=e.fixedSegments[i].index,l=e.fixedSegments[i-1],s=e.fixedSegments[i+1],c=e.x+(l?l.end[0]:0),d=e.y+(l?l.end[1]:0),m=l?null:e.startBinding,p=s?null:e.endBinding,{startHeading:u,endHeading:g,startGlobalPoint:b,endGlobalPoint:x,hoveredStartElement:w,hoveredEndElement:E,...y}=e0({x:c,y:d,startBinding:m,endBinding:p,startArrowhead:null,endArrowhead:null,points:e.points},o,[se(0,0),se(e.x+(s?.start[0]??e.points[e.points.length-1][0])-c,e.y+(s?.start[1]??e.points[e.points.length-1][1])-d)],{isDragging:!1}),{points:T}=On(o0(n0(t0(e,{startHeading:u,endHeading:g,startGlobalPoint:b,endGlobalPoint:x,hoveredStartElement:w,hoveredEndElement:E,...y})??[])),t,null,null),v=[];if(l)for(let P=0;P<l.index;P++)v.push(se(e.x+e.points[P][0],e.y+e.points[P][1]));if(T.forEach(P=>{v.push(se(e.x+(l?l.end[0]:0)+P[0],e.y+(l?l.end[1]:0)+P[1]))}),s)for(let P=s.index;P<e.points.length;P++)v.push(se(e.x+e.points[P][0],e.y+e.points[P][1]));let C=(s?.index??e.points.length)-(l?.index??0)-1,M=t.map(P=>P.index>a?{...P,index:P.index-C+(T.length-1)}:P),k=v.flatMap((P,A)=>{let R=v[A-1],O=v[A+1];if(R&&O){let U=Jt(P,R),ee=Jt(O,P);if(vt(U,ee))return M.forEach(_=>{_.index>A&&(_.index-=1)}),[];if(vt(U,$1(ee)))return M.forEach(_=>{_.index>A&&(_.index+=1)}),[P,P]}return[P]});return On(k,M,!1,!1)},mN=(e,t,o,n,r,i)=>{let a=t.map((v,C)=>e.fixedSegments==null||e.fixedSegments[C]===void 0||e.fixedSegments[C].index!==v.index||(v.start[0]!==e.fixedSegments[C].start[0]&&v.end[0]!==e.fixedSegments[C].end[0])!=(v.start[1]!==e.fixedSegments[C].start[1]&&v.end[1]!==e.fixedSegments[C].end[1])?C:null).filter(v=>v!==null).shift();if(a==null)return{points:e.points};let l=e.fixedSegments?.findIndex(v=>v.index===1)??-1,s=e.fixedSegments?.findIndex(v=>v.index===e.points.length-1)??-1,c=q1(t[a].start,t[a].end),d=c<Me+5;if(l===-1&&t[a].index===1&&r){let v=co(o),M=(v?vt(o,rt):vt(o,Rt))?d?c/2:Me:d?-c/2:-Me;t[a].start=se(t[a].start[0]+(v?M:0),t[a].start[1]+(v?0:M))}if(s===-1&&t[a].index===e.points.length-1&&i){let v=co(n),M=(v?vt(n,rt):vt(n,Rt))?d?c/2:Me:d?-c/2:-Me;t[a].end=se(t[a].end[0]+(v?M:0),t[a].end[1]+(v?0:M))}let m=t.map(v=>({...v,start:se(e.x+v.start[0],e.y+v.start[1]),end:se(e.x+v.end[0],e.y+v.end[1])})),p=e.points.map((v,C)=>se(e.x+v[0],e.y+v[1])),u=m[a].index-1,g=m[a].index,b=m[a].start,x=m[a].end,w=p[u-1]&&!Ns(p[u],p[u-1])?Wo(p[u-1],p[u]):void 0,E=p[g+1]&&!Ns(p[g],p[g+1])?Wo(p[g+1],p[g]):void 0;if(w!==void 0){let v=w?1:0;p[u-1][v]=b[v]}if(p[u]=b,p[g]=x,E!==void 0){let v=E?1:0;p[g+1][v]=x[v]}let y=m.findIndex(v=>v.index===u);if(y!==-1){let v=Wo(m[y].end,m[y].start)?1:0;m[y].start[v]=b[v],m[y].end=b}let T=m.findIndex(v=>v.index===g+1);if(T!==-1){let v=Wo(m[T].end,m[T].start)?1:0;m[T].end[v]=x[v],m[T].start=x}if(l===-1&&u===0){let v=r?co(o):Wo(p[1],p[0]);p.unshift(se(v?b[0]:e.x+e.points[0][0],v?e.y+e.points[0][1]:b[1])),r&&p.unshift(se(e.x+e.points[0][0],e.y+e.points[0][1]));for(let C of m)C.index+=r?2:1}if(s===-1&&g===e.points.length-1){let v=co(n);p.push(se(v?x[0]:e.x+e.points[e.points.length-1][0],v?e.y+e.points[e.points.length-1][1]:x[1])),i&&p.push(se(e.x+e.points[e.points.length-1][0],e.y+e.points[e.points.length-1][1]))}return On(p,m.map(v=>({...v,start:se(v.start[0]-e.x,v.start[1]-e.y),end:se(v.end[0]-e.x,v.end[1]-e.y)})),!1,!1)},pN=(e,t,o,n,r,i,a,l,s)=>{let c=e.startIsSpecial??null,d=e.endIsSpecial??null,m=t.map((x,w)=>w===0?se(e.x+x[0],e.y+x[1]):w===t.length-1?se(e.x+x[0],e.y+x[1]):se(e.x+e.points[w][0],e.y+e.points[w][1])),p=o.map(x=>({...x,start:se(e.x+(x.start[0]-t[0][0]),e.y+(x.start[1]-t[0][1])),end:se(e.x+(x.end[0]-t[0][0]),e.y+(x.end[1]-t[0][1]))})),u=[],g=2+(c?1:0),b=2+(d?1:0);for(;u.length+g<m.length-b;)u.push(m[u.length+g]);{let x=m[c?2:1],w=m[c?3:2],E=co(n),y=co(Bn(J1(x,w)));if(l&&E===y){let T=E?vt(n,rt):vt(n,Rt);if(u.unshift(se(y?i[0]+(T?Me:-Me):w[0],y?w[1]:i[1]+(T?Me:-Me))),u.unshift(se(E?i[0]+(T?Me:-Me):i[0],E?i[1]:i[1]+(T?Me:-Me))),!c){c=!0;for(let v of p)v.index>1&&(v.index+=1)}}else if(u.unshift(se(y?i[0]:x[0],y?x[1]:i[1])),c){c=!1;for(let T of p)T.index>1&&(T.index-=1)}u.unshift(i)}{let x=m[m.length-(d?3:2)],w=m[m.length-(d?4:3)],E=co(r),y=Wo(w,x);if(s&&E===y){let T=E?vt(r,rt):vt(r,Rt);u.push(se(y?a[0]+(T?Me:-Me):w[0],y?w[1]:a[1]+(T?Me:-Me))),u.push(se(E?a[0]+(T?Me:-Me):a[0],E?a[1]:a[1]+(T?Me:-Me))),d||(d=!0)}else u.push(se(y?a[0]:x[0],y?x[1]:a[1])),d&&(d=!1)}return u.push(a),On(u,p.map(({index:x})=>({index:x,start:u[x-1],end:u[x]})).map(x=>({...x,start:se(x.start[0]-i[0],x.start[1]-i[1]),end:se(x.end[0]-i[0],x.end[1]-i[1])})),c,d)},Ir=1e6,lp=(e,t,o,n)=>{if(e.points.length<2)return{points:o.points??e.points};I.PROD||(Ga(!o.points||o.points.length>=2,"Updated point array length must match the arrow point length, contain exactly the new start and end points or not be specified at all (i.e. you can't add new points between start and end manually to elbow arrows)"),Ga(!e.fixedSegments||e.fixedSegments.map(v=>v.start[0]===v.end[0]||v.start[1]===v.end[1]).every(Boolean),"Fixed segments must be either horizontal or vertical"),Ga(!o.fixedSegments||o.fixedSegments.map(v=>v.start[0]===v.end[0]||v.start[1]===v.end[1]).every(Boolean),"Updates to fixed segments must be either horizontal or vertical"),Ga(e.points.slice(1).map((v,C)=>v[0]===e.points[C][0]||v[1]===e.points[C][1]),"Elbow arrow segments must be either horizontal or vertical"),Ga(o.fixedSegments?.find(v=>v.index===1&&Ns(v.start,(o.points??e.points)[0]))==null&&o.fixedSegments?.find(v=>v.index===(o.points??e.points).length-1&&Ns(v.end,(o.points??e.points)[(o.points??e.points).length-1]))==null,"The first and last segments cannot be fixed"));let r=o.fixedSegments??e.fixedSegments??[],i=o.points?o.points&&o.points.length===2?e.points.map((v,C)=>C===0?o.points[0]:C===e.points.length-1?o.points[1]:v):o.points.slice():e.points.slice(),{startBinding:a,endBinding:l,...s}=o,c=typeof a<"u"?a:e.startBinding,d=typeof l<"u"?l:e.endBinding,m=c&&ap(c.elementId,t),p=d&&ap(d.elementId,t),u=VT(i);if(c&&!m&&u||d&&!p&&u||t.size===0&&u||Object.keys(s).length===0&&(m?.id!==c?.elementId||p?.id!==d?.elementId))return On(i.map(v=>se(e.x+v[0],e.y+v[1])),e.fixedSegments,e.startIsSpecial,e.endIsSpecial);let{startHeading:g,endHeading:b,startGlobalPoint:x,endGlobalPoint:w,hoveredStartElement:E,hoveredEndElement:y,...T}=e0({x:e.x,y:e.y,startBinding:c,endBinding:d,startArrowhead:e.startArrowhead,endArrowhead:e.endArrowhead,points:e.points},t,i,n);return t.size===0&&u?On(i.map(v=>se(e.x+v[0],e.y+v[1])),e.fixedSegments,e.startIsSpecial,e.endIsSpecial):!o.points&&!o.fixedSegments&&!o.startBinding&&!o.endBinding?cN(e,t):o.startBinding===e.startBinding&&o.endBinding===e.endBinding&&(o.points??[]).every((v,C)=>Ns(v,e.points[C]??se(1/0,1/0)))&&u?{}:r.length===0?On(o0(n0(t0(e,{startHeading:g,endHeading:b,startGlobalPoint:x,endGlobalPoint:w,hoveredStartElement:E,hoveredEndElement:y,...T})??[])),r,null,null):(e.fixedSegments?.length??0)>r.length?dN(e,r,t):o.points?o.points&&o.fixedSegments?o:pN(e,i,r,g,b,x,w,E,y):mN(e,r,g,b,E,y)},e0=(e,t,o,n)=>{let r=j1(o[0],mn(e.x,e.y)),i=j1(o[o.length-1],mn(e.x,e.y)),a=null,l=null;if(n?.isDragging){let v=Array.from(t.values());a=UT(r,t,v,n?.zoom)||null,l=UT(i,t,v,n?.zoom)||null}else a=e.startBinding&&ap(e.startBinding.elementId,t)||null,l=e.endBinding&&ap(e.endBinding.elementId,t)||null;let s=zT({...e,type:"arrow",elbowed:!0,points:o},"start",e.startBinding?.fixedPoint,r,a,t,n?.isDragging),c=zT({...e,type:"arrow",elbowed:!0,points:o},"end",e.endBinding?.fixedPoint,i,l,t,n?.isDragging),d=GT(s,c,a,r,t),m=GT(c,s,l,i,t),p=[s[0]-2,s[1]-2,s[0]+2,s[1]+2],u=[c[0]-2,c[1]-2,c[0]+2,c[1]+2],g=a?pn(a,t,Cr(d,e.startArrowhead?Pe*6:Pe*2,1)):p,b=l?pn(l,t,Cr(m,e.endArrowhead?Pe*6:Pe*2,1)):u,x=Ua(s,l?pn(l,t,Cr(m,Me,Me)):u)||Ua(c,a?pn(a,t,Cr(d,Me,Me)):p),w=WT(x?[p,u]:[g,b]),E=hN(x?p:g,x?u:b,w,x?Cr(d,!a&&!l?0:Me,0):Cr(d,!a&&!l?0:Me-(e.startArrowhead?Pe*6:Pe*2),Me),x?Cr(m,!a&&!l?0:Me,0):Cr(m,!a&&!l?0:Me-(e.endArrowhead?Pe*6:Pe*2),Me),x,a&&pn(a,t),l&&pn(l,t)),y=HT(E[0],d,s),T=HT(E[1],m,c);return{dynamicAABBs:E,startDonglePosition:y,startGlobalPoint:s,startHeading:d,endDonglePosition:T,endGlobalPoint:c,endHeading:m,commonBounds:w,hoveredStartElement:a,hoveredEndElement:l,boundsOverlap:x,startElementBounds:g,endElementBounds:b}},t0=(e,t)=>{let{dynamicAABBs:o,startDonglePosition:n,startGlobalPoint:r,startHeading:i,endDonglePosition:a,endGlobalPoint:l,endHeading:s,commonBounds:c,hoveredEndElement:d}=t,m=fN(o,n||r,i,a||l,s,c),p=n&&ip(n,m),u=a&&ip(a,m),g=ip(l,m);g&&d&&(g.closed=!0);let b=ip(r,m);b&&e.startBinding&&(b.closed=!0);let x=p&&u&&(Ua(p.pos,o[1])||Ua(u.pos,o[0])),w=uN(p||b,u||g,m,i||rt,s||rt,x?[]:o);if(w){let E=w.map(y=>[y.pos[0],y.pos[1]]);return p&&E.unshift(r),u&&E.push(l),E}return null},Cr=(e,t,o)=>{switch(e){case Yo:return[t,o,o,o];case rt:return[o,t,o,o];case Rt:return[o,o,t,o]}return[o,o,o,t]},uN=(e,t,o,n,r,i)=>{let a=Z1(e.pos,t.pos),l=new rN(s=>s.f);for(l.push(e);l.size()>0;){let s=l.pop();if(!s||s.closed)continue;if(s===t)return gN(e,s);s.closed=!0;let c=xN(s.addr,o);for(let d=0;d<4;d++){let m=c[d];if(!m||m.closed)continue;let p=oN(m.pos,s.pos,.5);if(iN(...i.map(T=>Ua(p,T))))continue;let u=EN(d),g=s.parent?Bn(J1(s.pos,s.parent.pos)):n,b=$1(g);if(vt(b,u)||YT(e.addr,m.addr)&&vt(u,n)||YT(t.addr,m.addr)&&vt(u,r))continue;let w=g!==u,E=s.g+Z1(m.pos,s.pos)+(w?Math.pow(a,3):0),y=m.visited;if(!y||E<m.g){let T=bN(m,t,u,r);m.visited=!0,m.parent=s,m.h=Z1(t.pos,m.pos)+T*Math.pow(a,2),m.g=E,m.f=m.g+m.h,y?l.rescoreElement(m):l.push(m)}}}return null},gN=(e,t)=>{let o=t,n=[];for(;o.parent;)n.unshift(o),o=o.parent;return n.unshift(e),n},Z1=(e,t)=>Math.abs(e[0]-t[0])+Math.abs(e[1]-t[1]),hN=(e,t,o,n,r,i,a,l)=>{let s=a??e,c=l??t,[d,m,p,u]=n??[0,0,0,0],[g,b,x,w]=r??[0,0,0,0],E=[e[0]>t[2]?e[1]>t[3]||e[3]<t[1]?Math.min((s[0]+c[2])/2,e[0]-u):(s[0]+c[2])/2:e[0]>t[0]?e[0]-u:o[0]-u,e[1]>t[3]?e[0]>t[2]||e[2]<t[0]?Math.min((s[1]+c[3])/2,e[1]-d):(s[1]+c[3])/2:e[1]>t[1]?e[1]-d:o[1]-d,e[2]<t[0]?e[1]>t[3]||e[3]<t[1]?Math.max((s[2]+c[0])/2,e[2]+m):(s[2]+c[0])/2:e[2]<t[2]?e[2]+m:o[2]+m,e[3]<t[1]?e[0]>t[2]||e[2]<t[0]?Math.max((s[3]+c[1])/2,e[3]+p):(s[3]+c[1])/2:e[3]<t[3]?e[3]+p:o[3]+p],y=[t[0]>e[2]?t[1]>e[3]||t[3]<e[1]?Math.min((c[0]+s[2])/2,t[0]-w):(c[0]+s[2])/2:t[0]>e[0]?t[0]-w:o[0]-w,t[1]>e[3]?t[0]>e[2]||t[2]<e[0]?Math.min((c[1]+s[3])/2,t[1]-g):(c[1]+s[3])/2:t[1]>e[1]?t[1]-g:o[1]-g,t[2]<e[0]?t[1]>e[3]||t[3]<e[1]?Math.max((c[2]+s[0])/2,t[2]+b):(c[2]+s[0])/2:t[2]<e[2]?t[2]+b:o[2]+b,t[3]<e[1]?t[0]>e[2]||t[2]<e[0]?Math.max((c[3]+s[1])/2,t[3]+x):(c[3]+s[1])/2:t[3]<e[3]?t[3]+x:o[3]+x],T=WT([E,y]);if(!i&&E[2]-E[0]+y[2]-y[0]>T[2]-T[0]+1e-11&&E[3]-E[1]+y[3]-y[1]>T[3]-T[1]+1e-11){let[v,C]=[(y[0]+y[2])/2,(y[1]+y[3])/2];if(t[0]>e[2]&&e[1]>t[3]){let M=E[2]+(y[0]-E[2])/2,k=y[3]+(E[1]-y[3])/2;return rp(mn(e[2]-v,e[1]-C),mn(e[0]-v,e[3]-C))>0?[[E[0],E[1],M,E[3]],[M,y[1],y[2],y[3]]]:[[E[0],k,E[2],E[3]],[y[0],y[1],y[2],k]]}else if(e[2]<t[0]&&e[3]<t[1]){let M=E[2]+(y[0]-E[2])/2,k=E[3]+(y[1]-E[3])/2;return rp(mn(e[0]-v,e[1]-C),mn(e[2]-v,e[3]-C))>0?[[E[0],E[1],E[2],k],[y[0],k,y[2],y[3]]]:[[E[0],E[1],M,E[3]],[M,y[1],y[2],y[3]]]}else if(e[0]>t[2]&&e[3]<t[1]){let M=y[2]+(E[0]-y[2])/2,k=E[3]+(y[1]-E[3])/2;return rp(mn(e[2]-v,e[1]-C),mn(e[0]-v,e[3]-C))>0?[[M,E[1],E[2],E[3]],[y[0],y[1],M,y[3]]]:[[E[0],E[1],E[2],k],[y[0],k,y[2],y[3]]]}else if(e[0]>t[2]&&e[1]>t[3]){let M=y[2]+(E[0]-y[2])/2,k=y[3]+(E[1]-y[3])/2;return rp(mn(e[0]-v,e[1]-C),mn(e[2]-v,e[3]-C))>0?[[M,E[1],E[2],E[3]],[y[0],y[1],M,y[3]]]:[[E[0],k,E[2],E[3]],[y[0],y[1],y[2],k]]}}return[E,y]},fN=(e,t,o,n,r,i)=>{let a=new Set,l=new Set;o===yo||o===rt?l.add(t[1]):a.add(t[0]),r===yo||r===rt?l.add(n[1]):a.add(n[0]),e.forEach(d=>{a.add(d[0]),a.add(d[2]),l.add(d[1]),l.add(d[3])}),a.add(i[0]),a.add(i[2]),l.add(i[1]),l.add(i[3]);let s=Array.from(l).sort((d,m)=>d-m),c=Array.from(a).sort((d,m)=>d-m);return{row:s.length,col:c.length,data:s.flatMap((d,m)=>c.map((p,u)=>({f:0,g:0,h:0,closed:!1,visited:!1,parent:null,addr:[u,m],pos:[p,d]})))}},HT=(e,t,o)=>{switch(t){case Yo:return se(o[0],e[1]);case rt:return se(e[2],o[1]);case Rt:return se(o[0],e[3])}return se(e[0],o[1])},bN=(e,t,o,n)=>{if(n===rt)switch(o){case rt:return e.pos[0]>=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2;case Yo:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Rt:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case yo:return e.pos[1]===t.pos[1]?4:2}else if(n===yo)switch(o){case rt:return e.pos[1]===t.pos[1]?4:2;case Yo:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case Rt:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3;case yo:return e.pos[0]<=t.pos[0]?4:e.pos[1]===t.pos[1]?0:2}else if(n===Yo)switch(o){case rt:return e.pos[1]>t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Yo:return e.pos[1]>=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case Rt:return e.pos[0]===t.pos[0]?4:2;case yo:return e.pos[1]>t.pos[1]&&e.pos[0]>t.pos[0]?1:3}else if(n===Rt)switch(o){case rt:return e.pos[1]<t.pos[1]&&e.pos[0]<t.pos[0]?1:3;case Yo:return e.pos[0]===t.pos[0]?4:2;case Rt:return e.pos[1]<=t.pos[1]?4:e.pos[0]===t.pos[0]?0:2;case yo:return e.pos[1]<t.pos[1]&&e.pos[0]>t.pos[0]?1:3}return 0},xN=([e,t],o)=>[Rs([e,t-1],o),Rs([e+1,t],o),Rs([e,t+1],o),Rs([e-1,t],o)],Rs=([e,t],o)=>e<0||e>=o.col||t<0||t>=o.row?null:o.data[t*o.col+e]??null,ip=(e,t)=>{for(let o=0;o<t.col;o++)for(let n=0;n<t.row;n++){let r=Rs([o,n],t);if(r&&e[0]===r.pos[0]&&e[1]===r.pos[1])return r}return null},WT=e=>[Math.min(...e.map(t=>t[0])),Math.min(...e.map(t=>t[1])),Math.max(...e.map(t=>t[2])),Math.max(...e.map(t=>t[3]))],ap=(e,t)=>{let o=t.get(e);return o&&Ds(o)?o:null},On=(e,t,o,n)=>{let r=e[0][0],i=e[0][1],a=e.map(l=>j1(l,nN(J1(e[0]),-1)));return(r<-Ir||r>Ir||i<-Ir||i>Ir||r+a[a.length-1][0]<-Ir||i+a[a.length-1][0]>Ir||r+a[a.length-1][1]<-Ir||i+a[a.length-1][1]>Ir)&&console.error("Elbow arrow normalization is outside reasonable bounds (> 1e6)",{x:r,y:i,points:a,...FT(a)}),a=a.map(([l,s])=>se(np(l,-1e6,1e6),np(s,-1e6,1e6))),{points:a,x:np(r,-1e6,1e6),y:np(i,-1e6,1e6),fixedSegments:(t?.length??0)>0?t:null,...FT(a),startIsSpecial:o,endIsSpecial:n}},o0=e=>{if(e.length>1){let t=Math.abs(e[0][1]-e[1][1])<Math.abs(e[0][0]-e[1][0]);return e.filter((o,n)=>{if(n===0||n===e.length-1)return!0;let r=e[n+1],i=Math.abs(o[1]-r[1])<Math.abs(o[0]-r[0]);return t===i?(t=i,!1):(t=i,!0)})}return e},n0=e=>e.length>=4?e.filter((t,o)=>{if(o===0||o===e.length-1)return!0;let n=e[o-1];return q1(n,t)>Q1}):e,EN=e=>{switch(e){case 0:return Yo;case 1:return rt;case 2:return Rt}return yo},zT=(e,t,o,n,r,i,a)=>a?r&&i?r0(e,r,t,i):n:r?XT(o||[0,0],r,i??sN([r])):n,GT=(e,t,o,n,r)=>KT(e,t,o,o&&pn(o,r,Array(4).fill(wi(o,r,e))),n,r),UT=(e,t,o,n)=>Ya(aN(e),o,t,n,!0,!0),YT=(e,t)=>e[0]===t[0]&&e[1]===t[1],VT=(e,t=Q1)=>e.slice(1).map((o,n)=>Math.abs(o[0]-e[n][0])<t||Math.abs(o[1]-e[n][1])<t).every(Boolean);var c0=e=>e.isBindingEnabled,Pe=5,kN=10,MN=(e,t)=>{let o=[];return t.forEach(n=>{let r=e.getNonDeletedElement(n);r!=null&&o.push(r)}),o},JT=(e,t,o,n)=>{let r=n.getNonDeletedElementsMap(),i=new Set,a=new Set;jT(e,t,o,"start",i,a,n,r),jT(e,o,t,"end",i,a,n,r);let l=Array.from(a).filter(s=>!i.has(s));MN(n,l).forEach(s=>{n.mutateElement(s,{boundElements:s.boundElements?.filter(c=>c.type!=="arrow"||c.id!==e.id)})})},jT=(e,t,o,n,r,i,a,l)=>{if(t!=="keep"){if(t===null){let s=PN(e,n,a);s!=null&&i.add(s);return}t3(e)?(o==null||(o==="keep"?!AN(e,t,n):n==="start"||o.id!==t.id))&&(qT(e,t,n,a),r.add(t.id)):(qT(e,t,n,a),r.add(t.id))}};var QT=(e,t,o,n,r)=>Array.from(t.reduce((i,a)=>{let l=Ya(a,o.getNonDeletedElements(),o.getNonDeletedElementsMap(),n,Ee(e),Ee(e));return l!=null&&!e3(e,r?.id,l)&&i.add(l),i},new Set));var LN=(e,t)=>({...e,gap:Math.min(e.gap,d0(t,t.width,t.height))}),qT=(e,t,o,n)=>{if(!Zt(e))return;let r={elementId:t.id,...LN(RN(e,t,o,n.getNonDeletedElementsMap()),t)};Ee(e)&&(r={...r,...FN(e,t,o,n.getNonDeletedElementsMap())}),n.mutateElement(e,{[o==="start"?"startBinding":"endBinding"]:r}),yN(t.boundElements||[]).has(e.id)||n.mutateElement(t,{boundElements:(t.boundElements||[]).concat({id:e.id,type:"arrow"})})},AN=(e,t,o)=>{let n=e[o==="start"?"endBinding":"startBinding"];return e3(e,n?.elementId,t)},e3=(e,t,o)=>t===o.id&&t3(e),t3=e=>e.points.length<3&&!Ee(e),PN=(e,t,o)=>{let n=t==="start"?"startBinding":"endBinding",r=e[n];return r==null?null:(o.mutateElement(e,{[n]:null}),r.elementId)},Ya=(e,t,o,n,r,i)=>{if(i){let l=!1,s=DN(t,d=>Ds(d,!1)&&i0(d,e,o,n,(r||!sp(d))&&!Uo(d))).filter(d=>l?!1:(sp(d)||(l=!0),!0));if(!s||s.length===0)return null;if(s.length===1)return s[0];let c=s.filter(d=>i0(d,e,o,n,!1));return c.length===1?c[0]:s.sort((d,m)=>m.width**2+m.height**2-(d.width**2+d.height**2)).pop()}return _N(t,l=>Ds(l,!1)&&i0(l,e,o,n,(r||!sp(l))&&!Uo(l)))},_N=(e,t)=>{let o=null;for(let n=e.length-1;n>=0;--n){let r=e[n];if(!r.isDeleted&&t(r)){o=r;break}}return o},DN=(e,t)=>{let o=[];for(let n=e.length-1;n>=0;--n){let r=e[n];r.isDeleted||t(r)&&o.push(r)}return o},RN=(e,t,o,n)=>{let r=o==="start"?-1:1,i=r===-1?0:e.points.length-1,a=i-r,l=Dt.getPointAtIndexGlobalCoordinates(e,i,n),s=Dt.getPointAtIndexGlobalCoordinates(e,a,n);return{focus:HN(t,n,s,l),gap:Math.max(1,wi(t,n,l))}};var KT=(e,t,o,n,r,i,a)=>{let l=Bn(Ii(t,e));return!o||!n?l:NN(r,o,i,a)?X1(o,n,e):Bn(Ii(e,wt(o,i)))},NN=(e,t,o,n)=>{let r=wi(t,o,e),i=d0(t,t.width,t.height,n);return r>i?null:r},r0=(e,t,o,n)=>{(vN()||TN())&&wN(e.points.length>1,"Arrow should have at least 2 points");let r=pn(t,n),i=e.points[o==="start"?0:e.points.length-1],a=ge(e.x+i[0],e.y+i[1]),l=yT(t)?BN(t,n,a):a,s=Ee(e),c=Nn(r),d=o==="start"?1:e.points.length-2,m=We(ge(e.x+e.points[d][0],e.y+e.points[d][1]),c,e.angle??0),p=null;if(s){let u=co(X1(t,r,a)),g=ON(t,n,l),b=ge(u?c[0]:g[0],u?g[1]:c[1]),x=wo(b,a0(l0(s0(Ii(g,b)),Math.max(t.width,t.height)*2),b));p=qm(t,n,x,Pe).sort(Wa)[0]}else p=qm(t,n,wo(m,a0(l0(s0(Ii(l,m)),Ti(l,m)+Math.max(t.width,t.height)*2),m)),Pe).sort((u,g)=>Wa(u,m)-Wa(g,m))[0];return!p||Wa(l,p)<SN?l:s?p:l},BN=(e,t,o)=>{let n=wt(e,t),r=We(o,n,-e.angle);return r[0]<e.x&&r[1]<e.y?r[1]-e.y>-Pe?We(ge(e.x-Pe,e.y),n,e.angle):We(ge(e.x,e.y-Pe),n,e.angle):r[0]<e.x&&r[1]>e.y+e.height?r[0]-e.x>-Pe?We(ge(e.x,e.y+e.height+Pe),n,e.angle):We(ge(e.x-Pe,e.y+e.height),n,e.angle):r[0]>e.x+e.width&&r[1]>e.y+e.height?r[0]-e.x<e.width+Pe?We(ge(e.x+e.width,e.y+e.height+Pe),n,e.angle):We(ge(e.x+e.width+Pe,e.y+e.height),n,e.angle):r[0]>e.x+e.width&&r[1]<e.y?r[0]-e.x<e.width+Pe?We(ge(e.x+e.width,e.y-Pe),n,e.angle):We(ge(e.x+e.width+Pe,e.y),n,e.angle):o},ON=(e,t,o,n=.05)=>{let{x:r,y:i,width:a,height:l,angle:s}=e,c=wt(e,t,-.1,-.1),d=We(o,c,-s),m=$T(n*l,5,80),p=$T(n*a,5,80);if(d[0]<=r+a/2&&d[1]>c[1]-m&&d[1]<c[1]+m)return We(ge(r-Pe,c[1]),c,s);if(d[1]<=i+l/2&&d[0]>c[0]-p&&d[0]<c[0]+p)return We(ge(c[0],i-Pe),c,s);if(d[0]>=r+a/2&&d[1]>c[1]-m&&d[1]<c[1]+m)return We(ge(r+a+Pe,c[1]),c,s);if(d[1]>=i+l/2&&d[0]>c[0]-p&&d[0]<c[0]+p)return We(ge(c[0],i+l+Pe),c,s);if(e.type==="diamond"){let u=Pe,g=ge(r+a/4-u,i+l/4-u),b=ge(r+3*a/4+u,i+l/4-u),x=ge(r+a/4-u,i+3*l/4+u),w=ge(r+3*a/4+u,i+3*l/4+u);if(Ti(g,d)<Math.max(p,m))return We(g,c,s);if(Ti(b,d)<Math.max(p,m))return We(b,c,s);if(Ti(x,d)<Math.max(p,m))return We(x,c,s);if(Ti(w,d)<Math.max(p,m))return We(w,c,s)}return o};var FN=(e,t,o,n)=>{let r=[t.x,t.y,t.x+t.width,t.y+t.height],i=r0(e,t,o,n),a=ge(r[0]+(r[2]-r[0])/2,r[1]+(r[3]-r[1])/2),l=We(i,a,-t.angle);return{fixedPoint:n3([(l[0]-t.x)/t.width,(l[1]-t.y)/t.height])}};var o3=(e,t,o)=>{for(let n of e){if("boundElements"in n&&n.boundElements&&Object.assign(n,{boundElements:n.boundElements.reduce((r,i)=>{let a=t.get(i.id);return a&&r.push({...i,id:a}),r},[])}),"containerId"in n&&n.containerId&&Object.assign(n,{containerId:t.get(n.containerId)??null}),"endBinding"in n&&n.endBinding){let r=t.get(n.endBinding.elementId);Object.assign(n,{endBinding:r?{...n.endBinding,elementId:r}:null})}if("startBinding"in n&&n.startBinding){let r=t.get(n.startBinding.elementId);Object.assign(n,{startBinding:r?{...n.startBinding,elementId:r}:null})}Ee(n)&&Object.assign(n,lp(n,o,{points:[n.points[0],n.points[n.points.length-1]]}))}};var i0=(e,{x:t,y:o},n,r,i)=>{let a=ge(t,o),l=d0(e,e.width,e.height,r),s=(i||!sp(e))&&!Uo(e),c=[t-l,o-l,t+l,o+l],d=vi(e,n);if(!za(c,d))return!1;let m=qm(e,n,wo(wt(e,n),a)),p=wi(e,n,a);return s?m.length===0||p<=l:m.length>0&&p<=l},d0=(e,t,o,n)=>{let r=n?.value&&n.value<1?n.value:1,a=(e.type==="diamond"?1/Math.sqrt(2):1)*Math.min(t,o);return Math.max(16,Math.min(.25*a,32),kN/r+Pe)},HN=(e,t,o,n)=>{let r=wt(e,t);if(CN(o,n))return 0;let i=We(o,r,-e.angle),a=We(n,r,-e.angle),l=Math.sign(IN(Ii(a,o),Ii(a,r)))*-1,s=wo(a,a0(l0(s0(Ii(a,i)),Math.max(e.width*2,e.height*2)),a)),c=e.type==="diamond"?[wo(ge(e.x+e.width/2,e.y),ge(e.x+e.width/2,e.y+e.height)),wo(ge(e.x,e.y+e.height/2),ge(e.x+e.width,e.y+e.height/2))]:[wo(ge(e.x,e.y),ge(e.x+e.width,e.y+e.height)),wo(ge(e.x+e.width,e.y),ge(e.x,e.y+e.height))],d=e.type==="diamond"?[wo(ge(e.x+e.width/2,e.y-e.height),ge(e.x+e.width/2,e.y+e.height*2)),wo(ge(e.x-e.width,e.y+e.height/2),ge(e.x+e.width*2,e.y+e.height/2))]:[wo(ge(e.x-e.width,e.y-e.height),ge(e.x+e.width*2,e.y+e.height*2)),wo(ge(e.x+e.width*2,e.y-e.height),ge(e.x-e.width,e.y+e.height*2))];return[ZT(s,d[0]),ZT(s,d[1])].filter(u=>u!==null).sort((u,g)=>Wa(u,n)-Wa(g,n)).map((u,g)=>l*Ti(r,u)/(e.type==="diamond"?Ti(c[g][0],c[g][1])/2:Math.sqrt(e.width**2+e.height**2)/2)).sort((u,g)=>Math.abs(u)-Math.abs(g))[0]??0};var XT=(e,t,o)=>{let[n,r]=n3(e);return We(ge(t.x+t.width*n,t.y+t.height*r),wt(t,o),t.angle)};var n3=e=>e&&(Math.abs(e[0]-.5)<1e-4||Math.abs(e[1]-.5)<1e-4)?e.map(t=>Math.abs(t-.5)<1e-4?.5001:t):e;import{SHIFT_LOCKING_ANGLE as Ci,viewportCoordsToSceneCoords as d1e}from"@excalidraw/common";import{normalizeRadians as r3,radiansBetweenAngles as zN,radiansDifference as GN}from"@excalidraw/math";import{pointsEqual as u1e}from"@excalidraw/math";var i3=(e,t,o,n,r)=>{let i=o-e,a=n-t,l=Math.atan2(a,i),s=Math.round(l/Ci)*Ci;if(r){let c=Math.floor(r/Ci)*Ci;zN(l,c,c+Ci)&&(GN(l,r)<Ci/6?s=r:r3(l)>r3(r)?s=c+Ci:s=c)}if(s===0)a=0;else if(s===Math.PI/2)i=0;else{let c=Math.tan(s),d=-1,m=t-c*e,p=-1/c,u=-1,g=n-p*o,b=(d*g-u*m)/(c*u-p*d),x=(m*p-g*c)/(c*u-p*d);i=b-e,a=x-t}return{width:i,height:a}};var p0=({points:e})=>{let t=e[0][0],o=e[0][1];return{points:e.map(n=>q(n[0]-t,n[1]-o)),offsetX:t,offsetY:o}},K=class K{constructor(t,o){S(this,"elementId");S(this,"selectedPointsIndices");S(this,"pointerDownState");S(this,"isDragging");S(this,"lastUncommittedPoint");S(this,"pointerOffset");S(this,"startBindingElement");S(this,"endBindingElement");S(this,"hoverPointIndex");S(this,"segmentMidPointHoveredCoords");S(this,"elbowed");S(this,"customLineAngle");this.elementId=t.id,l3(t.points[0],q(0,0))||(console.error("Linear element is not normalized",Error().stack),Va(t,o,K.getNormalizeElementPointsAndCoords(t))),this.selectedPointsIndices=null,this.lastUncommittedPoint=null,this.isDragging=!1,this.pointerOffset={x:0,y:0},this.startBindingElement="keep",this.endBindingElement="keep",this.pointerDownState={prevSelectedPointsIndices:null,lastClickedPoint:-1,lastClickedIsEndPoint:!1,origin:null,segmentMidpoint:{value:null,index:null,added:!1}},this.hoverPointIndex=-1,this.segmentMidPointHoveredCoords=null,this.elbowed=Ee(t)&&t.elbowed,this.customLineAngle=null}static getElement(t,o){let n=o.get(t);return n||null}static handleBoxSelection(t,o,n,r){if(!o.editingLinearElement||!o.selectionElement)return!1;let{editingLinearElement:i}=o,{selectedPointsIndices:a,elementId:l}=i,s=K.getElement(l,r);if(!s)return!1;let[c,d,m,p]=Qt(o.selectionElement,r),g=K.getPointsGlobalCoordinates(s,r).reduce((b,x,w)=>((x[0]>=c&&x[0]<=m&&x[1]>=d&&x[1]<=p||t.shiftKey&&a?.includes(w))&&b.push(w),b),[]).filter(b=>!(Ee(s)&&b!==0&&b!==s.points.length-1));n({editingLinearElement:{...i,selectedPointsIndices:g.length?g:null}})}static handlePointDragging(t,o,n,r,i){if(!i)return null;let{elementId:a}=i,l=o.scene.getNonDeletedElementsMap(),s=K.getElement(a,l),c=i.customLineAngle;if(!s||Ee(s)&&!i.pointerDownState.lastClickedIsEndPoint&&i.pointerDownState.lastClickedPoint!==0)return null;let d=Ee(s)?[i.selectedPointsIndices?.includes(0)?0:void 0,i.selectedPointsIndices?.find(u=>u>0)?s.points.length-1:void 0].filter(u=>u!==void 0):i.selectedPointsIndices,m=Ee(s)?i.pointerDownState.lastClickedPoint>0?s.points.length-1:0:i.pointerDownState.lastClickedPoint,p=s.points[m];if(d&&p){if(s3(t)&&d.length===1&&s.points.length>1){let x=d[0],w=s.points[x===0?1:x-1];c=i.customLineAngle??Math.atan2(s.points[x][1]-w[1],s.points[x][0]-w[0]);let[E,y]=K._getShiftLockedDelta(s,l,w,q(n,r),t[Xa.CTRL_OR_CMD]?null:o.getEffectiveGridSize(),c);K.movePoints(s,o.scene,new Map([[x,{point:q(E+w[0],y+w[1]),isDragging:x===m}]]))}else{let x=K.createPointAt(s,l,n-i.pointerOffset.x,r-i.pointerOffset.y,t[Xa.CTRL_OR_CMD]?null:o.getEffectiveGridSize()),w=x[0]-p[0],E=x[1]-p[1];K.movePoints(s,o.scene,new Map(d.map(y=>{let T=y===m?K.createPointAt(s,l,n-i.pointerOffset.x,r-i.pointerOffset.y,t[Xa.CTRL_OR_CMD]?null:o.getEffectiveGridSize()):q(s.points[y][0]+w,s.points[y][1]+E);return[y,{point:T,isDragging:y===m}]})))}jt(s,l)&&H1(s,o.scene,!1);let g=[];if(R1(s,!1)){let x=d[0]===0,w=d[d.length-1]===s.points.length-1,E=[];!x!=!w?E.push({x:n,y:r}):(x&&E.push(m0(K.getPointGlobalCoordinates(s,s.points[0],l))),w&&E.push(m0(K.getPointGlobalCoordinates(s,s.points[d[d.length-1]],l)))),E.length&&(g=QT(s,E,o.scene,o.state.zoom))}let b={...i,selectedPointsIndices:d,segmentMidPointHoveredCoords:m!==0&&m!==s.points.length-1?this.getPointGlobalCoordinates(s,p,l):null,hoverPointIndex:m===0||m===s.points.length-1?m:-1,isDragging:!0,customLineAngle:c};return{...o.state,editingLinearElement:o.state.editingLinearElement?b:null,selectedLinearElement:b,suggestedBindings:g}}return null}static handlePointerUp(t,o,n,r){let i=r.getNonDeletedElementsMap(),a=r.getNonDeletedElements(),l=XN(t,n),{elementId:s,selectedPointsIndices:c,isDragging:d,pointerDownState:m}=o,p=K.getElement(s,i);if(!p)return o;let u={};if(d&&c){for(let g of c)if(g===0||g===p.points.length-1){$N(p.points,n.zoom.value)&&(_s(p)&&r.mutateElement(p,{...m3(p,!0)},{informMutation:!1,isDragging:!1}),K.movePoints(p,r,new Map([[g,{point:g===0?p.points[p.points.length-1]:p.points[0]}]])));let b=c0(n)?Ya((c?.length??0)>1?m0(K.getPointAtIndexGlobalCoordinates(p,g,i)):l,a,i,n.zoom,Ee(p),Ee(p)):null;u[g===0?"startBindingElement":"endBindingElement"]=b}}return{...o,...u,segmentMidPointHoveredCoords:null,hoverPointIndex:-1,selectedPointsIndices:d||t.shiftKey?!d&&t.shiftKey&&m.prevSelectedPointsIndices?.includes(m.lastClickedPoint)?c&&c.filter(g=>g!==m.lastClickedPoint):c:c?.includes(m.lastClickedPoint)?[m.lastClickedPoint]:c,isDragging:!1,pointerOffset:{x:0,y:0},customLineAngle:null}}static isSegmentTooShort(t,o,n,r,i){if(Ee(t))return r>=0&&r<t.points.length?Ka(o,n)*i.value<K.POINT_HANDLE_SIZE/2:!1;let a=Ka(o,n);if(t.points.length>2&&t.roundness){let[l,s]=d3(t);Fn(l.length===0&&s.length>0,"Only linears built out of curves are supported"),Fn(l.length+s.length>=r,"Invalid segment index while calculating mid point"),a=WN(s[r])}return a*i.value<K.POINT_HANDLE_SIZE*4}static getSegmentMidPoint(t,o){if(Ee(t)){Fn(t.points.length>=o,"Invalid segment index while calculating elbow arrow mid point");let i=a3(t.points[o-1],t.points[o]);return q(t.x+i[0],t.y+i[1])}let[n,r]=d3(t);if(Fn(n.length===0&&r.length>0||n.length>0&&r.length===0,"Only linears built out of either segments or curves are supported"),Fn(n.length+r.length>=o,"Invalid segment index while calculating mid point"),n.length){let i=n[o-1];return a3(i[0],i[1])}if(r.length){let i=r[o-1];return VN(i,.5)}Fn(!1,"Invalid segment type while calculating mid point")}static getSegmentMidPointIndex(t,o,n,r){let i=K.getElement(t.elementId,r);if(!i)return-1;let a=K.getEditorMidPoints(i,r,o),l=0;for(;l<a.length;){if(K.arePointsEqual(n,a[l]))return l+1;l++}return-1}static handlePointerDown(t,o,n,r,i,a){let l=o.state,s=a.getNonDeletedElementsMap(),c=a.getNonDeletedElements(),d={didAddPoint:!1,hitElement:null,linearElementEditor:null};if(!i)return d;let{elementId:m}=i,p=K.getElement(m,s);if(!p)return d;let u=K.getSegmentMidpointHitCoords(i,r,l,s),g=null;if(u)g=K.getSegmentMidPointIndex(i,l,u,s);else if(t.altKey&&l.editingLinearElement)return i.lastUncommittedPoint==null&&(a.mutateElement(p,{points:[...p.points,K.createPointAt(p,s,r.x,r.y,t[Xa.CTRL_OR_CMD]?null:o.getEffectiveGridSize())]}),d.didAddPoint=!0),n.scheduleCapture(),d.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:-1,lastClickedIsEndPoint:!1,origin:{x:r.x,y:r.y},segmentMidpoint:{value:u,index:g,added:!1}},selectedPointsIndices:[p.points.length-1],lastUncommittedPoint:null,endBindingElement:Ya(r,c,s,o.state.zoom,i.elbowed)},d.didAddPoint=!0,d;let b=K.getPointIndexUnderCursor(p,s,l.zoom,r.x,r.y);if(b>=0||u)d.hitElement=p;else{let{startBindingElement:k,endBindingElement:P}=i;c0(l)&&R1(p)&&JT(p,k,P,a)}let[x,w,E,y]=Qt(p,s),T=(x+E)/2,v=(w+y)/2,C=b>-1&&Nt(q(p.x+p.points[b][0],p.y+p.points[b][1]),q(T,v),p.angle),M=b>-1||t.shiftKey?t.shiftKey||i.selectedPointsIndices?.includes(b)?ZN([...i.selectedPointsIndices||[],b]):[b]:null;return d.linearElementEditor={...i,pointerDownState:{prevSelectedPointsIndices:i.selectedPointsIndices,lastClickedPoint:b,lastClickedIsEndPoint:b===p.points.length-1,origin:{x:r.x,y:r.y},segmentMidpoint:{value:u,index:g,added:!1}},selectedPointsIndices:M,pointerOffset:C?{x:r.x-C[0],y:r.y-C[1]}:{x:0,y:0}},d}static arePointsEqual(t,o){return!t&&!o?!0:!t||!o?!1:l3(t,o)}static handlePointerMove(t,o,n,r){let i=r.state;if(!i.editingLinearElement)return null;let{elementId:a,lastUncommittedPoint:l}=i.editingLinearElement,s=r.scene.getNonDeletedElementsMap(),c=K.getElement(a,s);if(!c)return i.editingLinearElement;let{points:d}=c,m=d[d.length-1];if(!t.altKey)return m===l&&K.deletePoints(c,r,[d.length-1]),{...i.editingLinearElement,lastUncommittedPoint:null};let p;if(s3(t)&&d.length>=2){let u=d[d.length-2],[g,b]=K._getShiftLockedDelta(c,s,u,q(o,n),t[Xa.CTRL_OR_CMD]?null:r.getEffectiveGridSize());p=q(g+u[0],b+u[1])}else p=K.createPointAt(c,s,o-i.editingLinearElement.pointerOffset.x,n-i.editingLinearElement.pointerOffset.y,t[Xa.CTRL_OR_CMD]||Ee(c)?null:r.getEffectiveGridSize());return m===l?K.movePoints(c,r.scene,new Map([[c.points.length-1,{point:p}]])):K.addPoints(c,r.scene,[p]),{...i.editingLinearElement,lastUncommittedPoint:c.points[c.points.length-1]}}static getPointGlobalCoordinates(t,o,n){let[r,i,a,l]=Qt(t,n),s=(r+a)/2,c=(i+l)/2,{x:d,y:m}=t;return Nt(q(d+o[0],m+o[1]),q(s,c),t.angle)}static getPointsGlobalCoordinates(t,o){let[n,r,i,a]=Qt(t,o),l=(n+i)/2,s=(r+a)/2;return t.points.map(c=>{let{x:d,y:m}=t;return Nt(q(d+c[0],m+c[1]),q(l,s),t.angle)})}static getPointAtIndexGlobalCoordinates(t,o,n){let r=o<0?t.points.length+o:o,[i,a,l,s]=Qt(t,n),c=(i+l)/2,d=(a+s)/2,m=t.points[r],{x:p,y:u}=t;return m?Nt(q(p+m[0],u+m[1]),q(c,d),t.angle):Nt(q(p,u),q(c,d),t.angle)}static pointFromAbsoluteCoords(t,o,n){if(Ee(t))return q(o[0]-t.x,o[1]-t.y);let[r,i,a,l]=Qt(t,n),s=(r+a)/2,c=(i+l)/2,[d,m]=Nt(q(o[0],o[1]),q(s,c),-t.angle);return q(d-t.x,m-t.y)}static getPointIndexUnderCursor(t,o,n,r,i){let a=K.getPointsGlobalCoordinates(t,o),l=a.length;for(;--l>-1;){let s=a[l];if(Ka(q(r,i),q(s[0],s[1]))*n.value<K.POINT_HANDLE_SIZE+1)return l}return-1}static createPointAt(t,o,n,r,i){let a=c3(n,r,i),[l,s,c,d]=Qt(t,o),m=(l+c)/2,p=(s+d)/2,[u,g]=Nt(q(a[0],a[1]),q(m,p),-t.angle);return q(u-t.x,g-t.y)}static getNormalizeElementPointsAndCoords(t){let{points:o,offsetX:n,offsetY:r}=p0(t);return{points:o,x:t.x+n,y:t.y+r}}static duplicateSelectedPoints(t,o){Fn(t.editingLinearElement,"Not currently editing a linear element");let n=o.getNonDeletedElementsMap(),{selectedPointsIndices:r,elementId:i}=t.editingLinearElement,a=K.getElement(i,n);Fn(a,"The linear element does not exist in the provided Scene"),Fn(r!=null,"There are no selected points to duplicate");let{points:l}=a,s=[],c=!1,d=-1,m=l.reduce((p,u,g)=>{if(++d,p.push(u),r.includes(g)){let x=l[g+1];x||(c=!0),p.push(x?q((u[0]+x[0])/2,(u[1]+x[1])/2):q(u[0],u[1])),s.push(d+1),++d}return p},[]);if(o.mutateElement(a,{points:m}),c){let p=a.points[a.points.length-1];K.movePoints(a,o,new Map([[a.points.length-1,{point:q(p[0]+30,p[1]+30)}]]))}return{...t,editingLinearElement:{...t.editingLinearElement,selectedPointsIndices:s}}}static deletePoints(t,o,n){let r=o.state.editingLinearElement?.lastUncommittedPoint===t.points[t.points.length-1],i=t.points.filter((d,m)=>!n.includes(m));_s(t)&&t.polygon&&(r||n.includes(0)||n.includes(t.points.length-1))&&(i[0]=q(i[i.length-1][0],i[i.length-1][1]));let{points:l,offsetX:s,offsetY:c}=p0({points:i});K._updatePoints(t,o.scene,l,s,c)}static addPoints(t,o,n){let r=[...t.points,...n];_s(t)&&t.polygon&&(r[0]=q(r[r.length-1][0],r[r.length-1][1]));let{points:i,offsetX:a,offsetY:l}=p0({points:r});K._updatePoints(t,o,i,a,l)}static movePoints(t,o,n,r){let{points:i}=t;if(_s(t)&&t.polygon){let d=n.get(0),m=n.get(i.length-1);d?n.set(i.length-1,{point:q(d.point[0],d.point[1]),isDragging:d.isDragging}):m&&n.set(0,{point:q(m.point[0],m.point[1]),isDragging:m.isDragging})}let a=n.get(0)?.point??q(0,0),[l,s]=a,c=Ee(t)?[n.get(0)?.point??i[0],n.get(i.length-1)?.point??i[i.length-1]]:i.map((d,m)=>{let p=n.get(m)?.point??d;return q(p[0]-l,p[1]-s)});K._updatePoints(t,o,c,l,s,r,{isDragging:Array.from(n.values()).some(d=>d.isDragging)})}static shouldAddMidpoint(t,o,n,r){let i=K.getElement(t.elementId,r);if(i&&Ee(i)||!i)return!1;let{segmentMidpoint:a}=t.pointerDownState;if(a.added||a.value===null||a.index===null||t.pointerDownState.origin===null)return!1;let l=t.pointerDownState.origin,s=Ka(q(l.x,l.y),q(o.x,o.y));return!(!n.editingLinearElement&&s<KN/n.zoom.value)}static addMidpoint(t,o,n,r,i){let a=i.getNonDeletedElementsMap(),l=K.getElement(t.elementId,a);if(!l)return;let{segmentMidpoint:s}=t.pointerDownState,c={pointerDownState:t.pointerDownState,selectedPointsIndices:t.selectedPointsIndices},d=K.createPointAt(l,a,o.x,o.y,r&&!Ee(l)?n.getEffectiveGridSize():null),m=[...l.points.slice(0,s.index),d,...l.points.slice(s.index)];return i.mutateElement(l,{points:m}),c.pointerDownState={...t.pointerDownState,segmentMidpoint:{...t.pointerDownState.segmentMidpoint,added:!0},lastClickedPoint:s.index},c.selectedPointsIndices=[s.index],c}static _updatePoints(t,o,n,r,i,a,l){if(Ee(t)){let s={};a?.startBinding!==void 0&&(s.startBinding=a.startBinding!==null&&$m(a.startBinding)?a.startBinding:null),a?.endBinding!==void 0&&(s.endBinding=a.endBinding!==null&&$m(a.endBinding)?a.endBinding:null),s.points=Array.from(n),o.mutateElement(t,s,{informMutation:!0,isDragging:l?.isDragging??!1})}else{let s=u0(t,n),c=u0(t,t.points),d=(s[0]+s[2])/2,m=(s[1]+s[3])/2,p=(c[0]+c[2])/2,u=(c[1]+c[3])/2,g=p-d,b=u-m,x=Nt(q(r,i),q(g,b),t.angle);o.mutateElement(t,{...a,points:n,x:t.x+x[0],y:t.y+x[1]})}}static _getShiftLockedDelta(t,o,n,r,i,a){let l=K.getPointGlobalCoordinates(t,n,o);if(Ee(t))return[r[0]-l[0],r[1]-l[1]];let[s,c]=c3(r[0],r[1],i),{width:d,height:m}=i3(l[0],l[1],s,c,a);return Nt(q(d,m),q(0,0),-t.angle)}static moveFixedSegment(t,o,n,r,i){let a=i.getNonDeletedElementsMap(),l=K.getElement(t.elementId,a);if(!l||!Ee(l))return t;if(o&&o>0&&o<l.points.length){let s=co(Bn(YN(l.points[o],l.points[o-1]))),c=(l.fixedSegments??[]).reduce((u,g)=>(u[g.index]=g,u),{});c[o]={index:o,start:q(s?l.points[o-1][0]:n-l.x,s?r-l.y:l.points[o-1][1]),end:q(s?l.points[o][0]:n-l.x,s?r-l.y:l.points[o][1])};let d=Object.values(c).sort((u,g)=>u.index-g.index),m=d.map(u=>u.index).reduce((u,g)=>g<o?u+1:u,0);i.mutateElement(l,{fixedSegments:d});let p=q(l.x+(l.fixedSegments[m].start[0]+l.fixedSegments[m].end[0])/2,l.y+(l.fixedSegments[m].start[1]+l.fixedSegments[m].end[1])/2);return{...t,segmentMidPointHoveredCoords:p,pointerDownState:{...t.pointerDownState,segmentMidpoint:{added:!1,index:l.fixedSegments[m].index,value:p}}}}return t}static deleteFixedSegment(t,o,n){o.mutateElement(t,{fixedSegments:t.fixedSegments?.filter(r=>r.index!==n)})}};S(K,"POINT_HANDLE_SIZE",10),S(K,"getEditorMidPoints",(t,o,n)=>{let r=jt(t,o);if(!Ee(t)&&!n.editingLinearElement&&t.points.length>2&&!r)return[];let i=K.getPointsGlobalCoordinates(t,o),a=0,l=[];for(;a<i.length-1;){if(K.isSegmentTooShort(t,t.points[a],t.points[a+1],a,n.zoom)){l.push(null),a++;continue}let s=K.getSegmentMidPoint(t,a+1);l.push(s),a++}return l}),S(K,"getSegmentMidpointHitCoords",(t,o,n,r)=>{let{elementId:i}=t,a=K.getElement(i,r);if(!a)return null;let l=K.getPointIndexUnderCursor(a,r,n.zoom,o.x,o.y);if(!Ee(a)&&l>=0||K.getPointsGlobalCoordinates(a,r).length>=3&&!n.editingLinearElement&&!Ee(a))return null;let c=(K.POINT_HANDLE_SIZE+1)/n.zoom.value,d=t.segmentMidPointHoveredCoords;if(d&&Ka(q(d[0],d[1]),q(o.x,o.y))<=c)return d;let m=0,p=K.getEditorMidPoints(a,r,n);for(;m<p.length;){if(p[m]!==null&&Ka(p[m],q(o.x,o.y))<=c)return p[m];m++}return null}),S(K,"getBoundTextElementPosition",(t,o,n)=>{K.getPointsGlobalCoordinates(t,n).length<2&&Va(o,n,{isDeleted:!0});let i=0,a=0;if(t.points.length%2===1){let l=Math.floor(t.points.length/2),s=K.getPointGlobalCoordinates(t,t.points[l],n);i=s[0]-o.width/2,a=s[1]-o.height/2}else{let l=t.points.length/2-1,s=K.getSegmentMidPoint(t,l+1);i=s[0]-o.width/2,a=s[1]-o.height/2}return{x:i,y:a}}),S(K,"getMinMaxXYWithBoundText",(t,o,n,r)=>{let[i,a,l,s]=n,c=(i+l)/2,d=(a+s)/2,{x:m,y:p}=K.getBoundTextElementPosition(t,r,o),u=m+r.width,g=p+r.height,b=q(c,d),x=Nt(q(i,a),b,t.angle),w=Nt(q(l,a),b,t.angle),E=Nt(q(m,p),b,-t.angle),y=Nt(q(u,p),b,-t.angle),T=Nt(q(m,g),b,-t.angle),v=Nt(q(u,g),b,-t.angle);return x[0]<w[0]&&x[1]>=w[1]?(i=Math.min(i,T[0]),l=Math.max(l,Math.max(y[0],v[0])),a=Math.min(a,E[1]),s=Math.max(s,v[1])):x[0]>=w[0]&&x[1]>w[1]?(i=Math.min(i,v[0]),l=Math.max(l,Math.max(E[0],y[0])),a=Math.min(a,T[1]),s=Math.max(s,y[1])):x[0]>=w[0]?(i=Math.min(i,y[0]),l=Math.max(l,T[0]),a=Math.min(a,v[1]),s=Math.max(s,E[1])):x[1]<=w[1]&&(i=Math.min(i,Math.min(y[0],E[0])),l=Math.max(l,v[0]),a=Math.min(a,y[1]),s=Math.max(s,T[1])),[i,a,l,s,c,d]}),S(K,"getElementAbsoluteCoords",(t,o,n=!1)=>{let r,i,a,l,s;if(t.points.length<2||!un.get(t)){let{minX:p,minY:u,maxX:g,maxY:b}=t.points.reduce((x,[w,E])=>(x.minY=Math.min(x.minY,E),x.minX=Math.min(x.minX,w),x.maxX=Math.max(x.maxX,w),x.maxY=Math.max(x.maxY,E),x),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});i=p+t.x,a=u+t.y,l=g+t.x,s=b+t.y}else{let p=un.generateElementShape(t,null),u=Oa(p[0]),[g,b,x,w]=cp(u);i=g+t.x,a=b+t.y,l=x+t.x,s=w+t.y}let c=(i+l)/2,d=(a+s)/2;if(r=[i,a,l,s,c,d],!n)return r;let m=jt(t,o);return m&&(r=K.getMinMaxXYWithBoundText(t,o,[i,a,l,s],m)),r});var Dt=K,ZN=e=>{let t=[...new Set(e.filter(o=>o!==null&&o!==-1))];return t=t.sort((o,n)=>o-n),t.length?t:null};var gn=class gn{static getBounds(t,o,n=!1){let r=n&&t.angle!==0?gn.nonRotatedBoundsCache.get(t):gn.boundsCache.get(t);if(r?.version&&r.version===t.version&&!Dn(t))return r.bounds;if(n&&t.angle!==0){let a=gn.calculateBounds({...t,angle:0},o);return gn.nonRotatedBoundsCache.set(t,{version:t.version,bounds:a}),a}let i=gn.calculateBounds(t,o);return gn.boundsCache.set(t,{version:t.version,bounds:i}),i}static calculateBounds(t,o){let n,[r,i,a,l,s,c]=Qt(t,o);if(Fa(t)){let[d,m,p,u]=f3(t.points.map(([g,b])=>Qe(ne(g,b),ne(s-t.x,c-t.y),t.angle)));return[d+t.x,m+t.y,p+t.x,u+t.y]}else if(cn(t))n=eB(t,s,c,o);else if(t.type==="diamond"){let[d,m]=Qe(ne(s,i),ne(s,c),t.angle),[p,u]=Qe(ne(s,l),ne(s,c),t.angle),[g,b]=Qe(ne(r,c),ne(s,c),t.angle),[x,w]=Qe(ne(a,c),ne(s,c),t.angle),E=Math.min(d,p,g,x),y=Math.min(m,u,b,w),T=Math.max(d,p,g,x),v=Math.max(m,u,b,w);n=[E,y,T,v]}else if(t.type==="ellipse"){let d=(a-r)/2,m=(l-i)/2,p=Math.cos(t.angle),u=Math.sin(t.angle),g=Math.hypot(d*p,m*u),b=Math.hypot(m*p,d*u);n=[s-g,c-b,s+g,c+b]}else{let[d,m]=Qe(ne(r,i),ne(s,c),t.angle),[p,u]=Qe(ne(r,l),ne(s,c),t.angle),[g,b]=Qe(ne(a,l),ne(s,c),t.angle),[x,w]=Qe(ne(a,i),ne(s,c),t.angle),E=Math.min(d,p,g,x),y=Math.min(m,u,b,w),T=Math.max(d,p,g,x),v=Math.max(m,u,b,w);n=[E,y,T,v]}return n}};S(gn,"boundsCache",new WeakMap),S(gn,"nonRotatedBoundsCache",new WeakMap);var f0=gn,Qt=(e,t,o=!1)=>{if(Fa(e))return jN(e);if(cn(e))return Dt.getElementAbsoluteCoords(e,t,o);if(yr(e)){let n=t?Ha(e,t):null;if(Zt(n)){let{x:r,y:i}=Dt.getBoundTextElementPosition(n,e,t);return[r,i,r+e.width,i+e.height,r+e.width/2,i+e.height/2]}}return[e.x,e.y,e.x+e.width,e.y+e.height,e.x+e.width/2,e.y+e.height/2]};var Km=e=>{let t=Math.floor(e.width/2)+1,o=0,n=e.width,r=Math.floor(e.height/2)+1,i=t,a=e.height;return[t,o,n,r,i,a,0,r]},p3=(e,t,o,n,r)=>{let i=1-e;return Math.pow(i,3)*t+3*Math.pow(i,2)*e*o+3*i*Math.pow(e,2)*n+Math.pow(e,3)*r},u3=(e,t,o,n)=>{let r=t-e,i=o-t,a=n-o,l=3*r-6*i+3*a,s=6*i-6*r,c=3*r,d=s*s-4*l*c;if(!(d>=0))return!1;let p=null,u=null,g=1/0,b=1/0;return l===0?g=b=-c/s:(g=(-s+Math.sqrt(d))/(2*l),b=(-s-Math.sqrt(d))/(2*l)),g>=0&&g<=1&&(p=p3(g,e,t,o,n)),b>=0&&b<=1&&(u=p3(b,e,t,o,n)),[p,u]},Jm=(e,t,o,n)=>{let r=u3(e[0],t[0],o[0],n[0]),i=u3(e[1],t[1],o[1],n[1]),a=Math.min(e[0],n[0]),l=Math.max(e[0],n[0]);if(r){let d=r.filter(m=>m!==null);a=Math.min(a,...d),l=Math.max(l,...d)}let s=Math.min(e[1],n[1]),c=Math.max(e[1],n[1]);if(i){let d=i.filter(m=>m!==null);s=Math.min(s,...d),c=Math.max(c,...d)}return[a,s,l,c]},cp=(e,t)=>{let o=ne(0,0),{minX:n,minY:r,maxX:i,maxY:a}=e.reduce((l,{op:s,data:c})=>{if(s==="move"){let d=h3(c);h0(d!=null,"Op data is not a point"),o=d}else if(s==="bcurveTo"){let d=ne(c[0],c[1]),m=ne(c[2],c[3]),p=ne(c[4],c[5]),u=t?t(d):d,g=t?t(m):m,b=t?t(p):p,x=t?t(o):o;o=p;let[w,E,y,T]=Jm(x,u,g,b);l.minX=Math.min(l.minX,w),l.minY=Math.min(l.minY,E),l.maxX=Math.max(l.maxX,y),l.maxY=Math.max(l.maxY,T)}return l},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return[n,r,i,a]},f3=e=>{let t=1/0,o=1/0,n=-1/0,r=-1/0;for(let[i,a]of e)t=Math.min(t,i),o=Math.min(o,a),n=Math.max(n,i),r=Math.max(r,a);return[t,o,n,r]},jN=e=>{let[t,o,n,r]=f3(e.points),i=t+e.x,a=o+e.y,l=n+e.x,s=r+e.y;return[i,a,l,s,(i+l)/2,(a+s)/2]},qN=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}},JN=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},b0=(e,t,o,n)=>{if(t.length<1)return null;let r=Oa(t[0]);if(r.length<1)return null;let i=o==="start"?1:r.length-1,a=r[i].data;h0(a.length===6,"Op data length is not 6");let l=ne(a[4],a[5]),s=ne(a[2],a[3]),c=ne(a[0],a[1]),d=r[i-1],m=ne(0,0);if(d.op==="move"){let _=h3(d.data);h0(_!=null,"Op data is not a point"),m=_}else d.op==="bcurveTo"&&(m=ne(d.data[4],d.data[5]));let p=(_,B)=>Math.pow(1-_,3)*l[B]+3*_*Math.pow(1-_,2)*s[B]+3*Math.pow(_,2)*(1-_)*c[B]+m[B]*Math.pow(_,3),[u,g]=o==="start"?m:l,[b,x]=[p(.3,0),p(.3,1)],w=Math.hypot(u-b,g-x),E=(u-b)/w,y=(g-x)/w,T=qN(n),v=0;{let[_,B]=o==="end"?e.points[e.points.length-1]:e.points[0],[j,V]=e.points.length>1?o==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];v=Math.hypot(_-j,B-V)}let M=Math.min(T,v*(n==="diamond"||n==="diamond_outline"?.25:.5)),k=u-E*M,P=g-y*M;if(n==="dot"||n==="circle"||n==="circle_outline"){let _=Math.hypot(P-g,k-u)+e.strokeWidth-2;return[u,g,_]}let A=JN(n);if(n==="crowfoot_many"||n==="crowfoot_one_or_many"){let[_,B]=Qe(ne(u,g),ne(k,P),g0(-A)),[j,V]=Qe(ne(u,g),ne(k,P),g0(A));return[k,P,_,B,j,V]}let[R,O]=Qe(ne(k,P),ne(u,g),-A*Math.PI/180),[U,ee]=Qe(ne(k,P),ne(u,g),g0(A));if(n==="diamond"||n==="diamond_outline"){let _,B;if(o==="start"){let[j,V]=e.points.length>1?e.points[1]:[0,0];[_,B]=Qe(ne(u+M*2,g),ne(u,g),Math.atan2(V-g,j-u))}else{let[j,V]=e.points.length>1?e.points[e.points.length-2]:[0,0];[_,B]=Qe(ne(u-M*2,g),ne(u,g),Math.atan2(g-V,u-j))}return[u,g,R,O,_,B,U,ee]}return[u,g,R,O,U,ee]},QN=e=>{let t=g3.generator(),o=vo(e),n=e.roundness?"curve":o.fill?"polygon":"linearPath";return t[n](e.points,o)},eB=(e,t,o,n)=>{let r=jt(e,n);if(e.points.length<2){let[m,p]=e.points[0],[u,g]=Qe(ne(e.x+m,e.y+p),ne(t,o),e.angle),b=[u,g,u,g];if(r){let x=Dt.getMinMaxXYWithBoundText(e,n,[u,g,u,g],r);b=[x[0],x[1],x[2],x[3]]}return b}let a=un.get(e)?.[0]??QN(e),l=Oa(a),c=cp(l,([m,p])=>Qe(ne(e.x+m,e.y+p),ne(t,o),e.angle)),d=[c[0],c[1],c[2],c[3]];if(r){let m=Dt.getMinMaxXYWithBoundText(e,n,d,r);d=[m[0],m[1],m[2],m[3]]}return d},vi=(e,t,o=!1)=>f0.getBounds(e,t,o);var u0=(e,t)=>{let o=g3.generator(),n=e.roundness==null?o.linearPath(t,vo(e)):o.curve(t,vo(e)),r=Oa(n),[i,a,l,s]=cp(r);return[i+e.x,a+e.y,l+e.x,s+e.y]};var Nn=e=>ne(e[0]+(e[2]-e[0])/2,e[1]+(e[3]-e[1])/2),pn=(e,t,o)=>{let n={minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height,midX:e.x+e.width/2,midY:e.y+e.height/2},r=wt(e,t),[i,a]=Qe(ne(n.minX,n.minY),r,e.angle),[l,s]=Qe(ne(n.maxX,n.minY),r,e.angle),[c,d]=Qe(ne(n.maxX,n.maxY),r,e.angle),[m,p]=Qe(ne(n.minX,n.maxY),r,e.angle),u=[Math.min(i,l,c,m),Math.min(a,s,d,p),Math.max(i,l,c,m),Math.max(a,s,d,p)];if(o){let[g,b,x,w]=o;return[u[0]-w,u[1]-g,u[2]+b,u[3]+x]}return u},Ua=(e,t)=>e[0]>t[0]&&e[0]<t[2]&&e[1]>t[1]&&e[1]<t[3],za=(e,t)=>{if(e==null||t==null)return!1;let[o,n,r,i]=e,[a,l,s,c]=t;return o<s&&r>a&&n<c&&i>l},wt=(e,t,o=0,n=0)=>{let[r,i]=Nn(vi(e,t));return ne(r+o,i+n)};import{pointFrom as r0e,pointCenter as i0e,pointRotateRads as a0e,vectorFromPoint as l0e,vectorNormalize as s0e,vectorSubtract as c0e,vectorAdd as d0e,vectorScale as m0e,pointFromVector as p0e,clamp as u0e,isCloseTo as g0e}from"@excalidraw/math";import{arrayToMap as hB}from"@excalidraw/common";import{isPointWithinBounds as ebe,pointFrom as tbe}from"@excalidraw/math";import{vectorCross as E0e,vectorFromPoint as y0e}from"@excalidraw/math";import{arrayToMap as tB}from"@excalidraw/common";import{getElementBounds as oB}from"@excalidraw/element";import{isArrowElement as nB,isExcalidrawElement as rB,isFreeDrawElement as iB,isLinearElement as aB,isTextElement as lB}from"@excalidraw/element";import{rangeIncludesValue as dp,pointFrom as Hn,pointRotateRads as sB,rangeInclusive as mp}from"@excalidraw/math";var cB=e=>e.type==="diamond"?[Hn(e.width/2,0),Hn(e.width,e.height/2),Hn(e.width/2,e.height),Hn(0,e.height/2)]:[Hn(0,0),Hn(0+e.width,0),Hn(0+e.width,e.height),Hn(0,e.height)],dB=e=>aB(e)||iB(e)?e.points:cB(e),b3=e=>{let t=e.reduce((o,[n,r])=>(o.minY=Math.min(o.minY,r),o.minX=Math.min(o.minX,n),o.maxX=Math.max(o.maxX,n),o.maxY=Math.max(o.maxY,r),o),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return t.cx=(t.maxX+t.minX)/2,t.cy=(t.maxY+t.minY)/2,t},x3=e=>{let t=dB(e),{cx:o,cy:n}=b3(t),r=Hn(o,n),i=t.map(d=>sB(d,r,e.angle)),{minX:a,minY:l,maxX:s,maxY:c}=b3(i);return[a+e.x,l+e.y,s+e.x,c+e.y]},x0=(e,t,o=!1)=>{let n=x3(e),r=t[0]<=n[0]&&t[2]>=n[2]&&t[1]<=n[1]&&t[3]>=n[3];return o?r?!0:n[0]<=t[0]&&n[2]>=t[2]&&n[1]<=t[1]&&n[3]>=t[3]:r},E3=(e,t)=>{let o=x3(e);return(dp(o[0],mp(t[0],t[2]))||dp(t[0],mp(o[0],o[2])))&&(dp(o[1],mp(t[1],t[3]))||dp(t[1],mp(o[1],o[3])))},y3=({elements:e,bounds:t,type:o,errorMargin:n=0})=>{rB(t)&&(t=oB(t,tB(e)));let r=[t[0]-n,t[1]-n,t[2]+n,t[3]+n],i=new Set;for(let a of e){if(i.has(a.id))continue;if(o==="overlap"?E3(a,r):o==="inside"?x0(a,r):x0(a,r,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);lB(a)&&a.containerId&&i.add(a.containerId),nB(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 B0e,isShallowEqual as uB}from"@excalidraw/common";var mB=function(){let e=null,t=null,o=null,n=(i,a,l,s)=>{if(o!==void 0&&a===t&&i===e&&l.editingGroupId===o?.editingGroupId)return o;let c={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let g=u.indexOf(l.editingGroupId);g>-1&&(u=u.slice(0,g))}if(u.length>0){let g=u[u.length-1];c[g]=!0}}let d={},m=a.reduce((p,u)=>{if(u.isDeleted)return p;let g=u.groupIds.find(b=>c[b]);return g&&(p[u.id]=!0,Array.isArray(d[g])?d[g].push(u.id):d[g]=[u.id]),p},{});for(let p of Object.keys(d))d[p].length<2&&c[p]&&(c[p]=!1);return t=a,e=i,o={editingGroupId:l.editingGroupId,selectedGroupIds:c,selectedElementIds:E0({...l.selectedElementIds,...m},s)},o},r=(i,a,l,s)=>{let c=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):w0(a,i);return c.length?n(c,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:E0(i.selectedElementIds,l)}};return r.clearCache=()=>{t=null,e=null,o=null},r}();var w3=(e,t)=>t.groupIds.filter(o=>o!==e.editingGroupId).find(o=>e.selectedGroupIds[o]);var pB=(e,t)=>e.groupIds.includes(t),y0=(e,t)=>{let o=[];for(let n of e.values())pB(n,t)&&o.push(n);return o};var v3=(e,t,o)=>{let n=[...e],r=t?e.indexOf(t):-1,i=r>-1?r:e.length;for(let a=0;a<i;a++)n[a]=o(n[a]);return n};var Y0e=function(){let e=null,t=null,o=null,n=(r,i)=>(o!=null&&r===e&&i.selectedElementIds===t||(o=r.some(a=>i.selectedElementIds[a.id]),e=r,t=i.selectedElementIds),o);return n.clearCache=()=>{e=null,t=null,o=null},n}(),w0=(e,t,o)=>{let n=new Set,r=[];for(let i of e.values()){if(t.selectedElementIds[i.id]){r.push(i),n.add(i.id);continue}if(o?.includeBoundTextElement&&Dn(i)&&t.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(o?.includeElementsInFrames){let i=[];return r.forEach(a=>{Uo(a)&&Bs(e,a.id).forEach(l=>!n.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var E0=(e,t)=>uB(t.selectedElementIds,e)?t.selectedElementIds:e;var T3=(e,t,o)=>{let n=hB(e);for(let r of t)if(r.frameId){let i=o.get(r.id),a=o.get(r.frameId),l=i&&n.get(i);l&&Va(l,n,{frameId:a??null})}};var Bs=(e,t)=>{let o=[];for(let n of e.values())n.frameId===t&&o.push(n);return o};var bB=typeof document<"u"?document.createElement("img"):{src:""};bB.src=`data:${C3.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 xB=typeof document<"u"?document.createElement("img"):{src:""};xB.src=`data:${C3.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 S3=new WeakMap;var EB=new WeakMap([]);function k3(e){let t=yB(e),o=new Path2D(t);return EB.set(e,o),o}function yB(e){let t=e.simulatePressure?e.points:e.points.length?e.points.map(([n,r],i)=>[n,r,e.pressures[i]]):[[0,0,.5]],o={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:n=>Math.sin(n*Math.PI/2),last:!!e.lastCommittedPoint};return vB(fB(t,o))}function I3(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}var wB=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function vB(e){if(!e.length)return"";let t=e.length-1;return e.reduce((o,n,r,i)=>(r===t?o.push(n,I3(n,i[0]),"L",i[0],"Z"):o.push(n,I3(n,i[r+1])),o),["M",e[0],"Q"]).join(" ").replace(wB,"$1")}var M3=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var St=class St{};S(St,"rg",new D3),S(St,"cache",new WeakMap),S(St,"get",t=>St.cache.get(t)),S(St,"set",(t,o)=>St.cache.set(t,o)),S(St,"delete",t=>St.cache.delete(t)),S(St,"destroy",()=>{St.cache=new WeakMap}),S(St,"generateElementShape",(t,o)=>{let n=o?.isExporting?void 0:St.get(t);if(n!==void 0)return n;S3.delete(t);let r=LB(t,St.rg,o||{isExporting:!1,canvasBackgroundColor:CB.white,embedsValidationStatus:null});return St.cache.set(t,r),r});var un=St,kB=e=>[8,8+e],R3=e=>[1.5,6+e];function MB(e){let t=e.roughness,o=Math.max(e.width,e.height),n=Math.min(e.width,e.height);return n>=20&&o>=50||n>=15&&e.roundness&&M3(e.type)||cn(e)&&o>=50?t:Math.min(t/(o<10?3:2),2.5)}var vo=(e,t=!1)=>{let o={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?kB(e.strokeWidth):e.strokeStyle==="dotted"?R3(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:MB(e),stroke:e.strokeColor,preserveVertices:t||e.roughness<TB.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return o.fillStyle=e.fillStyle,o.fill=Os(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(o.curveFitting=1),o;case"line":case"freedraw":return Vm(e.points)&&(o.fillStyle=e.fillStyle,o.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),o;case"arrow":return o;default:throw new Error(`Unimplemented type ${e.type}`)}},A3=(e,t,o)=>D1(e)&&(t||xT(e)&&o?.get(e.id)!==!0)&&Os(e.backgroundColor)&&Os(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:ET(e)?{...e,strokeColor:Os(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Os(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,P3=(e,t,o,n,r,i,a)=>{a=a||"transparent";let l=b0(e,t,o,n);if(l===null)return[];let s=(c,d)=>{if(c===null)return[];let[,,m,p,u,g]=c;return[r.line(m,p,u,g,d)]};switch(n){case"dot":case"circle":case"circle_outline":{let[c,d,m]=l;return delete i.strokeLineDash,[r.circle(c,d,m,{...i,fill:n==="circle_outline"?a:e.strokeColor,fillStyle:"solid",stroke:e.strokeColor,roughness:Math.min(.5,i.roughness||0)})]}case"triangle":case"triangle_outline":{let[c,d,m,p,u,g]=l;return delete i.strokeLineDash,[r.polygon([[c,d],[m,p],[u,g],[c,d]],{...i,fill:n==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[c,d,m,p,u,g,b,x]=l;return delete i.strokeLineDash,[r.polygon([[c,d],[m,p],[u,g],[b,x],[c,d]],{...i,fill:n==="diamond_outline"?a:e.strokeColor,fillStyle:"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[c,d,m,p,u,g]=l;if(e.strokeStyle==="dotted"){let b=R3(e.strokeWidth-1);i.strokeLineDash=[b[0],b[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[r.line(m,p,c,d,i),r.line(u,g,c,d,i),...n==="crowfoot_one_or_many"?s(b0(e,t,o,"crowfoot_one"),i):[]]}}},bT=e=>{let t=new D3,o={seed:e.seed,disableMultiStroke:!0,disableMultiStrokeFill:!0,roughness:0,preserveVertices:!0},n=Nn(e.points.reduce((r,i)=>[Math.min(e.x+i[0],r[0]),Math.min(e.y+i[1],r[1]),Math.max(e.x+i[0],r[2]),Math.max(e.y+i[1],r[3])],[1/0,1/0,-1/0,-1/0]));switch(e.type){case"line":case"arrow":{let r=e.points.length?e.points:[ft(0,0)];return Ee(e)?t.path(N3(r,16),o).sets[0].ops:e.roundness?t.curve(r,o).sets[0].ops.slice(0,e.points.length).map((i,a)=>{if(a===0){let l=zn(ft(e.x+i.data[0],e.y+i.data[1]),n,e.angle);return{op:"move",data:ft(l[0]-e.x,l[1]-e.y)}}return{op:"bcurveTo",data:[zn(ft(e.x+i.data[0],e.y+i.data[1]),n,e.angle),zn(ft(e.x+i.data[2],e.y+i.data[3]),n,e.angle),zn(ft(e.x+i.data[4],e.y+i.data[5]),n,e.angle)].map(l=>ft(l[0]-e.x,l[1]-e.y)).flat()}}):r.map((i,a)=>{let l=zn(ft(e.x+i[0],e.y+i[1]),n,e.angle);return{op:a===0?"move":"lineTo",data:ft(l[0]-e.x,l[1]-e.y)}})}case"freedraw":{if(e.points.length<2)return[];let r=_3(e.points,.75);return t.curve(r,o).sets[0].ops.slice(0,e.points.length).map((i,a)=>{if(a===0){let l=zn(ft(e.x+i.data[0],e.y+i.data[1]),n,e.angle);return{op:"move",data:ft(l[0]-e.x,l[1]-e.y)}}return{op:"bcurveTo",data:[zn(ft(e.x+i.data[0],e.y+i.data[1]),n,e.angle),zn(ft(e.x+i.data[2],e.y+i.data[3]),n,e.angle),zn(ft(e.x+i.data[4],e.y+i.data[5]),n,e.angle)].map(l=>ft(l[0]-e.x,l[1]-e.y)).flat()}})}}},LB=(e,t,{isExporting:o,canvasBackgroundColor:n,embedsValidationStatus:r})=>{switch(e.type){case"rectangle":case"iframe":case"embeddable":{let i;if(e.roundness){let a=e.width,l=e.height,s=Er(Math.min(a,l),e);i=t.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`,vo(A3(e,o,r),!0))}else i=t.rectangle(0,0,e.width,e.height,vo(A3(e,o,r),!1));return i}case"diamond":{let i,[a,l,s,c,d,m,p,u]=Km(e);if(e.roundness){let g=Er(Math.abs(a-p),e),b=Er(Math.abs(c-l),e);i=t.path(`M ${a+g} ${l+b} L ${s-g} ${c-b}
|
|
26
|
+
C ${s} ${c}, ${s} ${c}, ${s-g} ${c+b}
|
|
27
|
+
L ${d+g} ${m-b}
|
|
28
|
+
C ${d} ${m}, ${d} ${m}, ${d-g} ${m-b}
|
|
29
|
+
L ${p+g} ${u+b}
|
|
30
|
+
C ${p} ${u}, ${p} ${u}, ${p+g} ${u-b}
|
|
31
|
+
L ${a-g} ${l+b}
|
|
32
|
+
C ${a} ${l}, ${a} ${l}, ${a+g} ${l+b}`,vo(e,!0))}else i=t.polygon([[a,l],[s,c],[d,m],[p,u]],vo(e));return i}case"ellipse":return t.ellipse(e.width/2,e.height/2,e.width,e.height,vo(e));case"line":case"arrow":{let i,a=vo(e),l=e.points.length?e.points:[ft(0,0)];if(Ee(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[t.path(N3(l,16),vo(e,!0))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(l)),i=[]):e.roundness?i=[t.curve(l,a)]:a.fill?i=[t.polygon(l,a)]:i=[t.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:c="arrow"}=e;if(s!==null){let d=P3(e,i,"start",s,t,a,n);i.push(...d)}if(c!==null){let d=P3(e,i,"end",c,t,a,n);i.push(...d)}}return i}case"freedraw":{let i;if(k3(e),Vm(e.points)){let a=_3(e.points,.75);i=t.curve(a,{...vo(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return IB(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},N3=(e,t)=>{let o=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],l=e[r],s=Wo(l,i),c=Wo(a,l),d=Math.min(t,L3(e[r],a)/2,L3(e[r],i)/2);s?i[0]<l[0]?o.push([e[r][0]-d,e[r][1]]):o.push([e[r][0]+d,e[r][1]]):i[1]<l[1]?o.push([e[r][0],e[r][1]-d]):o.push([e[r][0],e[r][1]+d]),o.push(e[r]),c?a[0]<l[0]?o.push([e[r][0]-d,e[r][1]]):o.push([e[r][0]+d,e[r][1]]):a[1]<l[1]?o.push([e[r][0],e[r][1]-d]):o.push([e[r][0],e[r][1]+d])}let n=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<o.length;r+=3)n.push(`L ${o[r][0]} ${o[r][1]}`),n.push(`Q ${o[r+1][0]} ${o[r+1][1]}, ${o[r+2][0]} ${o[r+2][1]}`);return n.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),n.join(" ")};var m3=(e,t)=>{let o=[...e.points];if(t){if(!wT(e.points))return null;let r=o[0],i=o[o.length-1];Math.hypot(r[0]-i[0],r[1]-i[1])>SB||o.length<4?o.push(ft(r[0],r[1])):o[o.length-1]=ft(r[0],r[1])}return{polygon:t,points:o}};var Va=(e,t,o,n)=>{let r=!1,{points:i,fixedSegments:a,startBinding:l,endBinding:s,fileId:c}=o;Ee(e)&&(Object.keys(o).length===0||typeof i<"u"||typeof a<"u"||typeof l<"u"||typeof s<"u")?o={...o,angle:0,...lp({...e,x:o.x||e.x,y:o.y||e.y},t,o,n)}:typeof i<"u"&&(o={...AB(i),...o});for(let d in o){let m=o[d];if(typeof m<"u"){if(e[d]===m&&(typeof m!="object"||m===null||d==="groupIds"||d==="scale"))continue;if(d==="scale"){let p=e[d],u=m;if(p[0]===u[0]&&p[1]===u[1])continue}else if(d==="points"){let p=e[d],u=m;if(p.length===u.length){let g=!1,b=p.length;for(;--b;){let x=p[b],w=u[b];if(x[0]!==w[0]||x[1]!==w[1]){g=!0;break}}if(!g)continue}}e[d]=m,r=!0}}return r&&((typeof o.height<"u"||typeof o.width<"u"||typeof c<"u"||typeof i<"u")&&un.delete(e),e.version=o.version??e.version+1,e.versionNonce=o.versionNonce??v0(),e.updated=T0()),e},B3=(e,t,o=!1)=>{let n=!1;for(let r in t){let i=t[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return!n&&!o?e:{...e,...t,version:t.version??e.version+1,versionNonce:t.versionNonce??v0(),updated:T0()}},O3=(e,t)=>(e.version=(t??e.version)+1,e.versionNonce=v0(),e.updated=T0(),e);import{jsx as z3}from"react/jsx-runtime";var pp=N({name:"toggleLinearEditor",category:Fe.elements,label:(e,t,o)=>o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);return!!(!t.editingLinearElement&&r.length===1&&DB(r[0])&&!_B(r[0]))},perform(e,t,o,n){let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0],i=t.editingLinearElement?.elementId===r.id?null:new PB(r,F3(e));return{appState:{...t,editingLinearElement:i},captureUpdate:H3.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:o})=>{let n=o.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],r=f(n.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return z3($,{type:"button",icon:Mh,title:r,"aria-label":r,onClick:()=>t(null)})}}),Mxe=N({name:"togglePolygon",category:Fe.elements,icon:Nc,keywords:["loop"],label:(e,t,o)=>!o.scene.getSelectedElements({selectedElementIds:t.selectedElementIds}).some(i=>!$a(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds});return r.length>0&&r.every(i=>$a(i)&&i.points.length>=4)},perform(e,t,o,n){let r=n.scene.getSelectedElements(t);if(r.some(s=>!$a(s)))return!1;let i=r,a=i.some(s=>!s.polygon),l=F3(i);return{elements:e.map(s=>!l.has(s.id)||!$a(s)?s:B3(s,{backgroundColor:a?s.backgroundColor:"transparent",...RB(s,a)})),appState:t,captureUpdate:H3.IMMEDIATELY}},PanelComponent:({appState:e,updateData:t,app:o})=>{let n=o.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(n.length===0||n.some(a=>!$a(a)||!a.polygon||a.points.length<3))return null;let r=n.every(a=>$a(a)&&a.polygon),i=f(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return z3(Qi,{icon:Nc,title:i,"aria-label":i,active:r,onClick:()=>t(null),style:{marginLeft:"auto"}})}});import{KEYS as G3,CANVAS_SEARCH_TAB as U3,CLASSES as NB,DEFAULT_SIDEBAR as Y3}from"@excalidraw/common";import{CaptureUpdateAction as BB}from"@excalidraw/element";var Ba=N({name:"searchMenu",icon:Gt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,t,o,n){if(t.openDialog)return!1;if(t.openSidebar?.name===Y3.name&&t.openSidebar.tab===U3){let r=n.excalidrawContainerValue.container?.querySelector(`.${NB.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...t,openSidebar:{name:Y3.name,tab:U3},openDialog:null},captureUpdate:BB.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,t,o)=>o.gridModeEnabled===void 0,keyTest:e=>e[G3.CTRL_OR_CMD]&&e.key===G3.F});import{isImageElement as OB}from"@excalidraw/element";import{CaptureUpdateAction as FB}from"@excalidraw/element";import{jsx as HB}from"react/jsx-runtime";var up=N({name:"cropEditor",label:"helpDialog.cropStart",icon:nd,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,t,o,n){let r=n.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...t,isCropping:!1,croppingElementId:r.id},captureUpdate:FB.IMMEDIATELY}},predicate:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t);return!!(!t.croppingElementId&&r.length===1&&OB(r[0]))},PanelComponent:({appState:e,updateData:t,app:o})=>{let n=f("helpDialog.cropStart");return HB($,{type:"button",icon:nd,title:n,"aria-label":n,onClick:()=>t(null)})}});import{getNonDeletedElements as zB}from"@excalidraw/element";import{mutateElement as GB}from"@excalidraw/element";import{newFrameElement as UB}from"@excalidraw/element";import{isFrameLikeElement as gp}from"@excalidraw/element";import{addElementsToFrame as YB,removeAllElementsFromFrame as WB}from"@excalidraw/element";import{getFrameChildren as VB}from"@excalidraw/element";import{KEYS as V3,updateActiveTool as K3}from"@excalidraw/common";import{getElementsInGroup as KB}from"@excalidraw/element";import{getCommonBounds as XB}from"@excalidraw/element";import{CaptureUpdateAction as Si}from"@excalidraw/element";var X3=(e,t)=>{let o=t.scene.getSelectedElements(e);return o.length===1&&gp(o[0])},$3=N({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t).at(0)||null;if(gp(r)){let i=VB(zB(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...t,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:Si.IMMEDIATELY}}return{elements:e,appState:t,captureUpdate:Si.EVENTUALLY}},predicate:(e,t,o,n)=>X3(t,n)}),Z3=N({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,t,o,n)=>{let r=n.scene.getSelectedElements(t).at(0)||null;return gp(r)?{elements:WB(e,r),appState:{...t,selectedElementIds:{[r.id]:!0}},captureUpdate:Si.IMMEDIATELY}:{elements:e,appState:t,captureUpdate:Si.EVENTUALLY}},predicate:(e,t,o,n)=>X3(t,n)}),BEe=N({name:"updateFrameRendering",label:"labels.updateFrameRendering",viewMode:!0,trackEvent:{category:"canvas"},perform:(e,t)=>({elements:e,appState:{...t,frameRendering:{...t.frameRendering,enabled:!t.frameRendering.enabled}},captureUpdate:Si.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),OEe=N({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:tr,viewMode:!1,perform:(e,t,o,n)=>{let r=K3(t,{type:"frame"});return io(n.interactiveCanvas,{...t,activeTool:r}),{elements:e,appState:{...t,activeTool:K3(t,{type:"frame"})},captureUpdate:Si.EVENTUALLY}},keyTest:e=>!e[V3.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===V3.F}),j3=N({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=J(e,t);return r.length>0&&!r.some(i=>gp(i))},perform:(e,t,o,n)=>{let r=J(e,t),i=n.scene.getNonDeletedElementsMap(),[a,l,s,c]=XB(r,i),d=16,m=UB({x:a-d,y:l-d,width:s-a+d*2,height:c-l+d*2});if(t.editingGroupId){let u=KB(r,t.editingGroupId);for(let g of u){let b=g.groupIds.indexOf(t.editingGroupId);GB(g,i,{groupIds:g.groupIds.slice(0,b)})}}return{elements:YB([...n.scene.getElementsIncludingDeleted(),m],r,m,t),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:Si.IMMEDIATELY}}});import{isWindows as eO,KEYS as Fs,matchKey as S0,arrayToMap as q3}from"@excalidraw/common";import{CaptureUpdateAction as C0}from"@excalidraw/element";import{orderByFractionalIndex as tO}from"@excalidraw/element";import{Emitter as $B}from"@excalidraw/common";import{CaptureUpdateAction as ZB,StoreChange as jB,StoreDelta as qB}from"@excalidraw/element";var Za=class extends qB{applyTo(t,o,n){let[r,i]=this.elements.applyTo(t,n.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(o,r);return[r,a,i||l]}static calculate(t,o){return super.calculate(t,o)}static inverse(t){return super.inverse(t)}static applyLatestChanges(t,o,n,r){return super.applyLatestChanges(t,o,n,r)}},ki=class{constructor(t=!0,o=!0){this.isUndoStackEmpty=t;this.isRedoStackEmpty=o}},ja=class e{constructor(t){this.store=t;S(this,"onHistoryChangedEmitter",new $B);S(this,"undoStack",[]);S(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(t){if(t.isEmpty()||t instanceof Za)return;let o=Za.inverse(t);this.undoStack.push(o),o.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new ki(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(t,o){return this.perform(t,o,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n))}redo(t,o){return this.perform(t,o,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n))}perform(t,o,n,r){try{let i=n();if(i===null)return;let a=ZB.IMMEDIATELY,l=this.store.snapshot,s=t,c=o,d=!1;for(;i;){try{[s,c,d]=i.applyTo(s,c,l);let m=l.elements,p=l.maybeClone(a,s,c),u=jB.create(l,p),g=Za.applyLatestChanges(i,m,s);g.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:g}),i=g),l=p}finally{r(i)}if(d)break;i=n()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new ki(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(t){if(!t.length)return null;let o=t.pop();return o!==void 0?o:null}static push(t,o){let n=Za.inverse(o);return t.push(n)}};import{useEffect as JB,useState as QB}from"react";var I0=(e,t)=>{let[o,n]=QB(t);return JB(()=>{let r=e.on(i=>{n(i)});return()=>{r()}},[e]),o};import{jsx as tI}from"react/jsx-runtime";var J3=(e,t,o)=>{if(!t.multiElement&&!t.resizingElement&&!t.editingTextElement&&!t.newElement&&!t.selectedElementsAreBeingDragged&&!t.selectionElement&&!e.flowChartCreator.isCreatingChart){let n=o();if(!n)return{captureUpdate:C0.EVENTUALLY};let[r,i]=n,a=tO(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:C0.NEVER}}return{captureUpdate:C0.EVENTUALLY}},Q3=e=>({name:"undo",label:"buttons.undo",icon:zc,trackEvent:{category:"history"},viewMode:!1,perform:(t,o,n,r)=>J3(r,o,()=>e.undo(q3(t),o)),keyTest:t=>t[Fs.CTRL_OR_CMD]&&S0(t,Fs.Z)&&!t.shiftKey,PanelComponent:({updateData:t,data:o})=>{let{isUndoStackEmpty:n}=I0(e.onHistoryChangedEmitter,new ki(e.isUndoStackEmpty,e.isRedoStackEmpty));return tI($,{type:"button",icon:zc,"aria-label":f("buttons.undo"),onClick:t,size:o?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),eI=e=>({name:"redo",label:"buttons.redo",icon:Gc,trackEvent:{category:"history"},viewMode:!1,perform:(t,o,n,r)=>J3(r,o,()=>e.redo(q3(t),o)),keyTest:t=>t[Fs.CTRL_OR_CMD]&&t.shiftKey&&S0(t,Fs.Z)||eO&&t.ctrlKey&&!t.shiftKey&&S0(t,Fs.Y),PanelComponent:({updateData:t,data:o})=>{let{isRedoStackEmpty:n}=I0(e.onHistoryChangedEmitter,new ki(e.isUndoStackEmpty,e.isRedoStackEmpty));return tI($,{type:"button",icon:Gc,"aria-label":f("buttons.redo"),onClick:t,size:o?.size||"medium",disabled:n,"data-testid":"button-redo"})}});import{getFontString as oO}from"@excalidraw/common";import{newElementWith as nO}from"@excalidraw/element";import{measureText as rO}from"@excalidraw/element";import{isTextElement as oI}from"@excalidraw/element";import{CaptureUpdateAction as iO}from"@excalidraw/element";var nI=N({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,t,o,n)=>{let r=J(e,t);return r.length===1&&oI(r[0])&&!r[0].autoResize},perform:(e,t,o,n)=>{let r=J(e,t);return{appState:t,elements:e.map(i=>{if(i.id===r[0].id&&oI(i)){let a=rO(i.originalText,oO(i),i.lineHeight);return nO(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:iO.IMMEDIATELY}}});import{CODES as aO,KEYS as lO}from"@excalidraw/common";import{CaptureUpdateAction as sO}from"@excalidraw/element";var k0=N({name:"viewMode",label:"labels.viewMode",icon:ai,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,t){return{appState:{...t,viewModeEnabled:!this.checked(t)},captureUpdate:sO.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,t,o)=>typeof o.viewModeEnabled>"u",keyTest:e=>!e[lO.CTRL_OR_CMD]&&e.altKey&&e.code===aO.R});import{isPromiseLike as cO}from"@excalidraw/common";import{jsx as dO}from"react/jsx-runtime";var M0=(e,t,o,n,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(o,n,i))&&ae(e.trackEvent.category,e.trackEvent.action||e.name,`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Hs=class{constructor(t,o,n,r){S(this,"actions",{});S(this,"updater");S(this,"getAppState");S(this,"getElementsIncludingDeleted");S(this,"app");S(this,"renderAction",(t,o)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[t]&&"PanelComponent"in this.actions[t]&&(!(t in n)||n[t])){let r=this.actions[t],i=r.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=c=>{M0(r,"ui",l,a,this.app,c),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return dO(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:o,renderAction:this.renderAction})}return null});S(this,"isActionEnabled",t=>{let o=this.getElementsIncludingDeleted(),n=this.getAppState();return!t.predicate||t.predicate(o,n,this.app.props,this.app)});this.updater=i=>{if(cO(i))i.then(a=>t(a));else return t(i)},this.getAppState=o,this.getElementsIncludingDeleted=n,this.app=r}registerAction(t){this.actions[t.name]=t}registerAll(t){t.forEach(o=>this.registerAction(o))}handleKeyDown(t){let o=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((s,c)=>(c.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in o?o[s.name]:!0)&&s.keyTest&&s.keyTest(t,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn("Canceling as multiple actions match this shortcut",n),!1;let r=n[0];if(this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return M0(r,"keyboard",a,i,this.app,null),t.preventDefault(),t.stopPropagation(),this.updater(n[0].perform(i,a,l,this.app)),!0}executeAction(t,o="api",n=null){let r=this.getElementsIncludingDeleted(),i=this.getAppState();M0(t,o,i,r,this.app,n),this.updater(t.perform(r,i,n,this.app))}};var hp=class{constructor(){S(this,"targets",new WeakMap);S(this,"rafIds",new WeakMap)}register(t,o){this.targets.set(t,{callback:o,stopped:!0})}start(t){let o=this.targets.get(t);o&&(this.rafIds.has(t)||(this.targets.set(t,{...o,stopped:!1}),this.scheduleFrame(t)))}stop(t){let o=this.targets.get(t);o&&!o.stopped&&this.targets.set(t,{...o,stopped:!0}),this.cancelFrame(t)}constructFrame(t){return o=>{let n=this.targets.get(t);if(!n)return;let r=this.onFrame(n,o);!n.stopped&&!r?this.scheduleFrame(t):this.cancelFrame(t)}}scheduleFrame(t){let o=requestAnimationFrame(this.constructFrame(t));this.rafIds.set(t,o)}cancelFrame(t){if(this.rafIds.has(t)){let o=this.rafIds.get(t);cancelAnimationFrame(o)}this.rafIds.delete(t)}onFrame(t,o){return t.callback(o)??!1}};var L0=e=>{let t=Array.from(e.values());return{x:rI(t,o=>o.x)/t.length,y:rI(t,o=>o.y)/t.length}},A0=([e,t])=>Math.hypot(e.x-t.x,e.y-t.y),rI=(e,t)=>e.reduce((o,n)=>o+t(n),0);import{pointFrom as z,pointRotateRads as Sr,rangeInclusive as To,rangeIntersection as fp,rangesOverlap as bp}from"@excalidraw/math";import{TOOL_TYPE as Mi,KEYS as iI}from"@excalidraw/common";import{getCommonBounds as P0,getDraggedElementsBounds as _0,getElementAbsoluteCoords as mO}from"@excalidraw/element";import{isBoundToContainer as cI,isFrameLikeElement as pO}from"@excalidraw/element";import{getMaximumGroups as dI}from"@excalidraw/element";import{getSelectedElements as uO,getVisibleAndNonSelectedElements as mI}from"@excalidraw/element";var gO=8,aI=99999,xp=e=>gO/e,Bt=class Bt{};S(Bt,"referenceSnapPoints",null),S(Bt,"visibleGaps",null),S(Bt,"setReferenceSnapPoints",t=>{Bt.referenceSnapPoints=t}),S(Bt,"getReferenceSnapPoints",()=>Bt.referenceSnapPoints),S(Bt,"setVisibleGaps",t=>{Bt.visibleGaps=t}),S(Bt,"getVisibleGaps",()=>Bt.visibleGaps),S(Bt,"destroy",()=>{Bt.referenceSnapPoints=null,Bt.visibleGaps=null});var Io=Bt,kr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Gn=({event:e,app:t,selectedElements:o})=>e?t.state.activeTool.type!=="lasso"&&(t.state.objectsSnapModeEnabled&&!e[iI.CTRL_OR_CMD]||!t.state.objectsSnapModeEnabled&&e[iI.CTRL_OR_CMD]&&!kr(t)):o.length===1&&o[0].type==="arrow"?!1:t.state.objectsSnapModeEnabled,hO=(e,t,o=.01)=>Math.abs(e-t)<=o,zs=(e,t,{omitCenter:o,boundingBoxCorners:n,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,c,d,m,p]=mO(a,t);r&&(l+=r.x,c+=r.x,m+=r.x,s+=r.y,d+=r.y,p+=r.y);let u=(c-l)/2,g=(d-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!n){let b=Sr(z(l,s+g),z(m,p),a.angle),x=Sr(z(l+u,s),z(m,p),a.angle),w=Sr(z(c,s+g),z(m,p),a.angle),E=Sr(z(l+u,d),z(m,p),a.angle),y=z(m,p);i=o?[b,x,w,E]:[b,x,w,E,y]}else{let b=Sr(z(l,s),z(m,p),a.angle),x=Sr(z(c,s),z(m,p),a.angle),w=Sr(z(l,d),z(m,p),a.angle),E=Sr(z(c,d),z(m,p),a.angle),y=z(m,p);i=o?[b,x,w,E]:[b,x,w,E,y]}}else if(e.length>1){let[a,l,s,c]=_0(e,r??{x:0,y:0}),d=s-a,m=c-l,p=z(a,l),u=z(s,l),g=z(a,c),b=z(s,c),x=z(a+d/2,l+m/2);i=o?[p,u,g,b]:[p,u,g,b,x]}return i.map(a=>z(ze(a[0]),ze(a[1])))},pI=(e,t,o,n)=>{let r=t.filter(i=>pO(i)).map(i=>i.id);return mI(e,t,o,n).filter(i=>!(i.frameId&&r.includes(i.frameId)))},uI=(e,t,o,n)=>{let r=pI(e,t,o,n),i=dI(r,n).filter(m=>!(m.length===1&&cI(m[0]))).map(m=>P0(m).map(p=>ze(p))),a=i.sort((m,p)=>m[0]-p[0]),l=[],s=0;e:for(let m=0;m<a.length;m++){let p=a[m];for(let u=m+1;u<a.length;u++){if(++s>aI)break e;let g=a[u],[,b,x,w]=p,[E,y,,T]=g;x<E&&bp(To(b,w),To(y,T))&&l.push({startBounds:p,endBounds:g,startSide:[z(x,b),z(x,w)],endSide:[z(E,y),z(E,T)],length:E-x,overlap:fp(To(b,w),To(y,T))})}}let c=i.sort((m,p)=>m[1]-p[1]),d=[];s=0;e:for(let m=0;m<c.length;m++){let p=c[m];for(let u=m+1;u<c.length;u++){if(++s>aI)break e;let g=c[u],[b,,x,w]=p,[E,y,T]=g;w<y&&bp(To(b,x),To(E,T))&&d.push({startBounds:p,endBounds:g,startSide:[z(b,w),z(x,w)],endSide:[z(E,y),z(T,y)],length:y-w,overlap:fp(To(b,x),To(E,T))})}}return{horizontalGaps:l,verticalGaps:d}},lI=(e,t,o,n,r,i,a)=>{if(!Gn({app:o,event:n,selectedElements:e}))return[];if(e.length===0)return[];let l=Io.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[d,m,p,u]=_0(e,t).map(x=>ze(x)),g=(d+p)/2,b=(m+u)/2;for(let x of s){if(!bp(To(m,u),x.overlap))continue;let w=x.startSide[0][0]+x.length/2,E=ze(w-g);if(x.length>p-d&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(r.length=0),a.x=Math.abs(E);let A={type:"gap",direction:"center_horizontal",gap:x,offset:E};r.push(A);continue}let[,,T]=x.endBounds,v=d-T,C=ze(x.length-v);if(Math.abs(C)<=a.x){Math.abs(C)<a.x&&(r.length=0),a.x=Math.abs(C);let A={type:"gap",direction:"side_right",gap:x,offset:C};r.push(A);continue}let[M,,,]=x.startBounds,k=M-p,P=ze(k-x.length);if(Math.abs(P)<=a.x){Math.abs(P)<a.x&&(r.length=0),a.x=Math.abs(P);let A={type:"gap",direction:"side_left",gap:x,offset:P};r.push(A);continue}}for(let x of c){if(!bp(To(d,p),x.overlap))continue;let w=x.startSide[0][1]+x.length/2,E=ze(w-b);if(x.length>u-m&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let A={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(A);continue}let[,T,,]=x.startBounds,v=T-u,C=ze(v-x.length);if(Math.abs(C)<=a.y){Math.abs(C)<a.y&&(i.length=0),a.y=Math.abs(C);let A={type:"gap",direction:"side_top",gap:x,offset:C};i.push(A);continue}let[,,,M]=x.endBounds,k=ze(m-M),P=x.length-k;if(Math.abs(P)<=a.y){Math.abs(P)<a.y&&(i.length=0),a.y=Math.abs(P);let A={type:"gap",direction:"side_bottom",gap:x,offset:P};i.push(A);continue}}}},gI=(e,t,o,n)=>{let r=pI(e,t,o,n);return dI(r,n).filter(i=>!(i.length===1&&cI(i[0]))).flatMap(i=>zs(i,n))},qa=(e,t,o,n,r,i,a)=>{if(!Gn({app:o,event:n,selectedElements:e})||e.length===0&&t.length===0)return[];let l=Io.getReferenceSnapPoints();if(l)for(let s of t)for(let c of l){let d=c[0]-s[0],m=c[1]-s[1];Math.abs(d)<=a.x&&(Math.abs(d)<a.x&&(r.length=0),r.push({type:"point",points:[s,c],offset:d}),a.x=Math.abs(d)),Math.abs(m)<=a.y&&(Math.abs(m)<a.y&&(i.length=0),i.push({type:"point",points:[s,c],offset:m}),a.y=Math.abs(m))}},hI=(e,t,o,n,r)=>{let i=o.state,a=uO(e,i);if(!Gn({app:o,event:n,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};t.x=ze(t.x),t.y=ze(t.y);let l=[],s=[],c=xp(i.zoom.value),d={x:c,y:c},m=zs(a,r,{dragOffset:t});qa(a,m,o,n,l,s,d),lI(a,t,o,n,l,s,d);let p={x:l[0]?.offset??0,y:s[0]?.offset??0};d.x=0,d.y=0,l.length=0,s.length=0;let u={x:ze(t.x+p.x),y:ze(t.y+p.y)};qa(a,zs(a,r,{dragOffset:u}),o,n,l,s,d),lI(a,u,o,n,l,s,d);let g=D0(l,s),b=bO(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...g,...b]}},ze=e=>Math.round(e*10**6)/10**6,sI=e=>{let t=new Map;for(let o of e){let n=o.join(",");t.has(n)||t.set(n,o)}return Array.from(t.values())},D0=(e,t)=>{let o={},n={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=ze(r.points[0][0]);o[i]||(o[i]=[]),o[i].push(...r.points.map(a=>z(ze(a[0]),ze(a[1]))))}}if(t.length>0){for(let r of t)if(r.type==="point"){let i=ze(r.points[0][1]);n[i]||(n[i]=[]),n[i].push(...r.points.map(a=>z(ze(a[0]),ze(a[1]))))}}return Object.entries(o).map(([r,i])=>({type:"points",points:sI(i.map(a=>z(Number(r),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(n).map(([r,i])=>({type:"points",points:sI(i.map(a=>z(a[0],Number(r))).sort((a,l)=>a[0]-l[0]))})))},fO=e=>{let t=new Map;for(let o of e){let n=o.points.flat().map(r=>[ze(r)]).join(",");t.has(n)||t.set(n,o)}return Array.from(t.values())},bO=(e,t,o)=>{let[n,r,i,a]=_0(e,t),l=[];for(let s of o){let[c,d,m,p]=s.gap.startBounds,[u,g,b,x]=s.gap.endBounds,w=fp(To(r,a),s.gap.overlap),E=fp(To(n,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:[z(s.gap.startSide[0][0],y),z(n,y)]},{type:"gap",direction:"horizontal",points:[z(i,y),z(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:[z(y,s.gap.startSide[0][1]),z(y,r)]},{type:"gap",direction:"vertical",points:[z(y,a),z(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:[z(m,y),z(u,y)]},{type:"gap",direction:"horizontal",points:[z(b,y),z(n,y)]})}break}case"side_left":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[z(i,y),z(c,y)]},{type:"gap",direction:"horizontal",points:[z(m,y),z(u,y)]})}break}case"side_top":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[z(y,a),z(y,d)]},{type:"gap",direction:"vertical",points:[z(y,p),z(y,g)]})}break}case"side_bottom":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[z(y,p),z(y,g)]},{type:"gap",direction:"vertical",points:[z(y,x),z(y,r)]})}break}}}return fO(l.map(s=>({...s,points:s.points.map(c=>z(ze(c[0]),ze(c[1])))})))},R0=(e,t,o,n,r,i)=>{if(!Gn({event:n,selectedElements:e,app:o})||e.length===0||e.length===1&&!hO(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=P0(t);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?l+=r.y:i.includes("s")&&(c+=r.y));let d=[];if(i)switch(i){case"e":{d.push(z(s,l),z(s,c));break}case"w":{d.push(z(a,l),z(a,c));break}case"n":{d.push(z(a,l),z(s,l));break}case"s":{d.push(z(a,c),z(s,c));break}case"ne":{d.push(z(s,l));break}case"nw":{d.push(z(a,l));break}case"se":{d.push(z(s,c));break}case"sw":{d.push(z(a,c));break}}let m=xp(o.state.zoom.value),p={x:m,y:m},u=[],g=[];qa(t,d,o,n,u,g,p);let b={x:u[0]?.offset??0,y:g[0]?.offset??0};p.x=0,p.y=0,u.length=0,g.length=0;let[x,w,E,y]=P0(e).map(C=>ze(C)),T=[z(x,w),z(x,y),z(E,w),z(E,y)];qa(e,T,o,n,u,g,p);let v=D0(u,g);return{snapOffset:b,snapLines:v}},fI=(e,t,o,n,r,i)=>{if(!Gn({event:o,selectedElements:[e],app:t}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[z(n.x+r.x,n.y+r.y)],l=xp(t.state.zoom.value),s={x:l,y:l},c=[],d=[];qa([e],a,t,o,c,d,s);let m={x:c[0]?.offset??0,y:d[0]?.offset??0};s.x=0,s.y=0,c.length=0,d.length=0;let p=zs([e],i,{boundingBoxCorners:!0,omitCenter:!0});qa([e],p,t,o,c,d,s);let u=D0(c,d);return{snapOffset:m,snapLines:u}},bI=(e,t,o,n,r)=>{if(!Gn({event:n,selectedElements:[],app:t}))return{originOffset:{x:0,y:0},snapLines:[]};let i=mI(e,[],t.state,r),a=xp(t.state.zoom.value),l={x:a,y:a},s=[],c=[];for(let d of i){let m=zs([d],r);for(let p of m){let u=p[0]-o.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[p,z(p[0],o.y)],direction:"vertical"}),l.x=u);let g=p[1]-o.y;Math.abs(g)<=Math.abs(l.y)&&(Math.abs(g)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,z(o.x,p[1])],direction:"horizontal"}),l.y=g)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-o.x:0,y:s.length>0?s[0].points[0][1]-o.y:0},snapLines:[...c,...s]}},xI=e=>e===Mi.rectangle||e===Mi.ellipse||e===Mi.diamond||e===Mi.frame||e===Mi.magicframe||e===Mi.image||e===Mi.text;import{pointFrom as Ep}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as xO,DEFAULT_FONT_SIZE as EO,TEXT_ALIGN as yO,VERTICAL_ALIGN as wO,getSizeFromPoints as vO,randomId as TO,arrayToMap as IO,assertNever as N0,cloneJSON as wI,getFontString as CO,isDevEnv as SO,toBrandedType as kO,getLineHeight as MO}from"@excalidraw/common";import{bindLinearElement as EI}from"@excalidraw/element";import{newArrowElement as LO,newElement as B0,newFrameElement as AO,newImageElement as PO,newLinearElement as _O,newMagicFrameElement as DO,newTextElement as wp}from"@excalidraw/element";import{measureText as RO,normalizeText as NO}from"@excalidraw/element";import{isArrowElement as BO}from"@excalidraw/element";import{syncInvalidIndices as OO}from"@excalidraw/element";import{redrawTextBoundingBox as FO}from"@excalidraw/element";import{LinearElementEditor as HO}from"@excalidraw/element";import{getCommonBounds as zO}from"@excalidraw/element";import{Scene as GO}from"@excalidraw/element";var yp={width:100,height:0},Mr=100,UO=(e,t,o)=>{let n=wp({x:0,y:0,textAlign:yO.CENTER,verticalAlign:wO.MIDDLE,...t,containerId:e.id,strokeColor:t.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:n.id})}),FO(n,e,o),[e,n]},yI=(e,t,o,n,r)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),t){let d=t?.width??Mr,m=t?.height??Mr,p;t.id&&(p=n.getElement(t.id),p||console.error(`No element for start binding with id ${t.id} found`));let u=t.x||e.x-d,g=t.y||e.y-m/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 start binding text element for ${e.id}`),i=wp({x:u,y:g,type:"text",...p,...t,text:x}),Object.assign(i,{x:t.x||e.x-i.width,y:t.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=B0({x:u,y:g,width:d,height:m,...p,...t,type:b});break}default:N0(e,`Unhandled element start type "${t.type}"`,!0)}EI(e,i,"start",r)}}if(o){let d=o?.height??Mr,m=o?.width??Mr,p;o.id&&(p=n.getElement(o.id),p||console.error(`No element for end binding with id ${o.id} found`));let u=o.x||e.x+e.width,g=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 end binding text element for ${e.id}`),a=wp({x:u,y:g,type:"text",...p,...o,text:x}),Object.assign(a,{y:o.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=B0({x:u,y:g,width:m,height:d,...p,...o,type:b});break}default:N0(e,`Unhandled element end type "${b}"`,!0)}EI(e,a,"end",r)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,c=wI(e.points);return e.points[l][0]>e.points[l-1][0]&&(c[0][0]=s,c[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(c[0][0]=-s,c[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(c[0][1]=s,c[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(c[0][1]=-s,c[l][1]+=s),Object.assign(e,HO.getNormalizeElementPointsAndCoords({...e,points:c})),{linearElement:e,startBoundElement:i,endBoundElement:a}},O0=class{constructor(){S(this,"excalidrawElements",new Map);S(this,"add",t=>{t&&this.excalidrawElements.set(t.id,t)});S(this,"getElements",()=>OO(Array.from(this.excalidrawElements.values())));S(this,"getElementsMap",()=>kO(IO(this.getElements())));S(this,"getElement",t=>this.excalidrawElements.get(t))}},Ja=(e,t)=>{if(!e)return[];let o=wI(e),n=new O0,r=new Map,i=new Map;for(let s of o){let c,d=s.id;switch(t?.regenerateIds!==!1&&Object.assign(s,{id:TO()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||Mr,u=s?.label?.text&&s.height===void 0?0:s?.height||Mr;c=B0({...s,width:p,height:u});break}case"line":{let p=s.width||yp.width,u=s.height||yp.height;c=_O({width:p,height:u,points:[Ep(0,0),Ep(p,u)],...s});break}case"arrow":{let p=s.width||yp.width,u=s.height||yp.height;c=LO({width:p,height:u,endArrowhead:"arrow",points:[Ep(0,0),Ep(p,u)],...s,type:"arrow"}),Object.assign(c,vO(c.points));break}case"text":{let p=s?.fontFamily||xO,u=s?.fontSize||EO,g=s?.lineHeight||MO(p),b=s.text??"",x=NO(b),w=RO(x,CO({fontFamily:p,fontSize:u}),g);c=wp({width:w.width,height:w.height,fontFamily:p,fontSize:u,...s});break}case"image":{c=PO({width:s?.width||Mr,height:s?.height||Mr,...s});break}case"frame":{c=AO({x:0,y:0,...s});break}case"magicframe":{c=DO({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{c=s;break}default:c=s,N0(s,`Unhandled element type "${s.type}"`,!0)}n.getElement(c.id)?console.error(`Duplicate id found for ${c.id}`):(n.add(c),r.set(c.id,s),d&&i.set(d,c.id))}let a=n.getElementsMap(),l=new GO(a);for(let[s,c]of r){let d=n.getElement(s);switch(c.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(c.label?.text){let[m,p]=UO(d,c?.label,l);if(n.add(m),n.add(p),BO(m)){let u=c.type==="arrow"?c?.start:void 0,g=c.type==="arrow"?c?.end:void 0;if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}if(g&&g.id){let E=i.get(g.id);E&&Object.assign(g,{id:E})}let{linearElement:b,startBoundElement:x,endBoundElement:w}=yI(m,u,g,n,l);m=b,n.add(b),n.add(x),n.add(w)}}else switch(c.type){case"arrow":{let{start:m,end:p}=c;if(m&&m.id){let x=i.get(m.id);Object.assign(m,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:g,endBoundElement:b}=yI(d,m,p,n,l);n.add(u),n.add(g),n.add(b);break}}break}}}for(let[s,c]of r){if(c.type!=="frame"&&c.type!=="magicframe")continue;let d=n.getElement(s);if(!d)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let m=[];c.children.forEach(v=>{let C=i.get(v);if(!C)throw new Error(`Element with ${v} wasn't mapped correctly`);let M=n.getElement(C);if(!M)throw new Error(`Frame element with id ${C} doesn't exist`);Object.assign(M,{frameId:d.id}),M?.boundElements?.forEach(k=>{let P=n.getElement(k.id);if(!P)throw new Error(`Bound element with id ${k.id} doesn't exist`);Object.assign(P,{frameId:d.id}),m.push(P)}),m.push(M)});let[p,u,g,b]=zO(m),x=10;p=p-x,u=u-x,g=g+x,b=b+x;let w=d?.x||p,E=d?.y||u,y=d?.width||g-p,T=d?.height||b-u;Object.assign(d,{x:w,y:E,width:y,height:T}),SO()&&c.children.length&&(d?.x||d?.y||d?.width||d?.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 n.getElements()};import{isElementInViewport as xF}from"@excalidraw/element";import{memoize as EF,toBrandedType as yF}from"@excalidraw/common";import{pointFrom as jO,pointsEqual as qO}from"@excalidraw/math";import Tp from"open-color";import{arrayToMap as JO,DEFAULT_TRANSFORM_HANDLE_SPACING as V0,FRAME_STYLE as MI,invariant as LI,THEME as QO,throttleRAF as eF}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as H0,maxBindingGap as NI}from"@excalidraw/element";import{LinearElementEditor as Lr}from"@excalidraw/element";import{getOmitSidesForDevice as z0,getTransformHandles as tF,getTransformHandlesFromCoords as oF,shouldShowBoundingBox as nF}from"@excalidraw/element";import{isElbowArrow as Gs,isFrameLikeElement as AI,isImageElement as PI,isLinearElement as rF,isLineElement as iF,isTextElement as _I}from"@excalidraw/element";import{renderSelectionElement as aF}from"@excalidraw/element";import{getElementsInGroup as Y0,getSelectedGroupIds as lF,isSelectedViaGroup as sF,selectGroupsFromGivenElements as cF}from"@excalidraw/element";import{getCommonBounds as W0,getElementAbsoluteCoords as Us}from"@excalidraw/element";import{pointFrom as kt}from"@excalidraw/math";import{THEME as YO}from"@excalidraw/common";var WO="#ff6b6b",VO="#ff0000",vI=1,TI=2,II=(e,t)=>{if(!t.snapLines.length)return;let o=t.theme===YO.LIGHT||t.zenModeEnabled?WO:VO,n=(t.zenModeEnabled?vI*1.5:vI)/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY);for(let r of t.snapLines)r.type==="pointer"?(e.lineWidth=n,e.strokeStyle=o,XO(r,e,t)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=o,$O(r.points[0],r.points[1],r.direction,t,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=o,KO(r,e,t));e.restore()},KO=(e,t,o)=>{if(!o.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];Co(n,r,t)}for(let n of e.points)CI(n,o,t)},XO=(e,t,o)=>{CI(e.points[0],o,t),o.zenModeEnabled||Co(e.points[0],e.points[1],t)},CI=([e,t],o,n)=>{n.save();let r=(o.zenModeEnabled?TI*1.5:TI)/o.zoom.value;n.beginPath(),n.moveTo(e-r,t-r),n.lineTo(e+r,t+r),n.moveTo(e+r,t-r),n.lineTo(e-r,t+r),n.stroke(),n.restore()},Co=(e,t,o)=>{o.beginPath(),o.lineTo(e[0],e[1]),o.lineTo(t[0],t[1]),o.stroke()},$O=(e,t,o,n,r)=>{let i=8/n.zoom.value,a=i/2,l=i/4;if(o==="horizontal"){let s=[(e[0]+t[0])/2,e[1]];n.zenModeEnabled||Co(kt(e[0],e[1]-i),kt(e[0],e[1]+i),r),Co(kt(s[0]-l,s[1]-a),kt(s[0]-l,s[1]+a),r),Co(kt(s[0]+l,s[1]-a),kt(s[0]+l,s[1]+a),r),n.zenModeEnabled||(Co(kt(t[0],t[1]-i),kt(t[0],t[1]+i),r),Co(e,t,r))}else{let s=[e[0],(e[1]+t[1])/2];n.zenModeEnabled||Co(kt(e[0]-i,e[1]),kt(e[0]+i,e[1]),r),Co(kt(s[0]-a,s[1]-l),kt(s[0]+a,s[1]-l),r),Co(kt(s[0]-a,s[1]+l),kt(s[0]+a,s[1]+l),r),n.zenModeEnabled||(Co(kt(t[0]-i,t[1]),kt(t[0]+i,t[1]),r),Co(e,t,r))}};import{getGlobalCSSVariable as vp}from"@excalidraw/common";import{getCommonBounds as ZO}from"@excalidraw/element";var Vo=4,eo=6,SI="rgba(0,0,0,0.3)",kI=(e,t,o,n)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,l]=ZO(e),s=t/n.zoom.value,c=o/n.zoom.value,d={top:parseInt(vp("sat"))||0,bottom:parseInt(vp("sab"))||0,left:parseInt(vp("sal"))||0,right:parseInt(vp("sar"))||0},m=vn().rtl,p=-n.scrollX+d.left,u=-n.scrollY+d.top,g=p+s-d.right,b=u+c-d.bottom,x=Math.min(r,p),w=Math.min(i,u),E=Math.max(a,g),y=Math.max(l,b),T=a-r,v=l-i,C=E-x,M=y-w,k=Math.max(Vo*2,d.left+d.right)+eo*2,P=t*(s/C)-k,A=Math.max(Vo*2,d.top+d.bottom)+eo*2,R=o*(c/M)-A,O=C>T?C*n.zoom.value/(P+k):t/(P+k),U=M>v?M*n.zoom.value/(R+A):o/(R+A);return{horizontal:p===x&&g===E?null:{x:Math.max(d.left,Vo)+eo+(p-x)/C*t,y:o-eo-Math.max(Vo,d.bottom),width:P,height:eo,deltaMultiplier:O},vertical:u===w&&b===y?null:{x:m?Math.max(d.left,Vo):t-eo-Math.max(d.right,Vo),y:Math.max(d.top,Vo)+eo+(u-w)/M*o,width:eo,height:R,deltaMultiplier:U}}},F0=(e,t,o)=>{let[n,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=t&&t<=a.x+a.width&&a.y<=o&&o<=a.y+a.height);return{isOverEither:n||r,isOverHorizontal:n,isOverVertical:r}};var dF=(e,t)=>{LI(t.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:o}=t.selectedLinearElement;LI(o,"midPointCoords is null"),e.save(),e.translate(t.scrollX,t.scrollY),BI(o,e,t),e.restore()},mF=(e,t,o)=>{let{elementId:n,hoverPointIndex:r}=t.selectedLinearElement;if(t.editingLinearElement?.selectedPointsIndices?.includes(r))return;let i=Lr.getElement(n,o);if(!i)return;let a=Lr.getPointAtIndexGlobalCoordinates(i,r,o);e.save(),e.translate(t.scrollX,t.scrollY),BI(a,e,t),e.restore()},BI=(e,t,o)=>{t.fillStyle="rgba(105, 101, 219, 0.4)",xl(t,e[0],e[1],Lr.POINT_HANDLE_SIZE/o.zoom.value,!1)},G0=(e,t,o,n,r,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",r?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),xl(e,o[0],o[1],(a?n*(t.editingLinearElement?1.5:2):n)/t.zoom.value,!i,!a||r)},pF=(e,t,o,n)=>{let r=NI(t,t.width,t.height,n);switch(e.fillStyle="rgba(0,0,0,.05)",t.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":rE(e,t,o,r);break;case"diamond":aE(e,r,t,o);break;case"ellipse":{let[i,a,l,s]=Us(t,o),c=l-i,d=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=r-H0,iE(e,c+r+H0,d+r+H0,i+c/2,a+d/2,t.angle);break}}},uF=(e,t,o,n)=>{let[r,i,a]=t,l=NI(a,a.width,a.height,n);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(c=>{let[d,m]=Lr.getPointAtIndexGlobalCoordinates(r,c,o);xl(e,d,m,l,!0)})},OI=(e,t,o)=>{let{angle:n,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:d,dashed:m,activeEmbeddable:p}=o,u=a-r,g=l-i,x=(o.padding??V0*2)/t.zoom.value,w=8/t.zoom.value,E=4/t.zoom.value;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=(p?4:1)/t.zoom.value;let y=s.length;for(let T=0;T<y;++T)e.strokeStyle=s[T],m&&e.setLineDash([w,E+(w+E)*(y-1)]),e.lineDashOffset=(w+E)*T,El(e,r-x,i-x,u+x*2,g+x*2,c,d,n);e.restore()},gF=(e,t,o,n)=>{let r=Array.isArray(o)?uF:pF;e.save(),e.translate(t.scrollX,t.scrollY),r(e,o,n,t.zoom),e.restore()},hF=(e,t,o,n)=>{let[r,i,a,l]=Us(o,n),s=a-r,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=MI.strokeWidth/t.zoom.value,e.save(),e.translate(t.scrollX,t.scrollY),El(e,r,i,s,c,r+s/2,i+c/2,o.angle,!1,MI.radius/t.zoom.value),e.restore()},DI=(e,t,o,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},a=o.filter(d=>d.groupIds.length===0),l=o.filter(d=>d.groupIds.length>0),s=d=>{let[m,p,u,g]=W0(d);return{angle:0,x1:m,x2:u,y1:p,y2:g,selectionColors:r,dashed:i,cx:m+(u-m)/2,cy:p+(g-p)/2,activeEmbeddable:!1}},c=d=>{let m=Y0(o,d);return s(m)};Object.entries(cF(l,t)).filter(([d,m])=>m).map(([d,m])=>d).map(d=>c(d)).concat(a.map(d=>s([d]))).forEach(d=>OI(e,t,d))},U0=(e,t,o,n)=>{if(!t.selectedLinearElement)return;e.save(),e.translate(t.scrollX,t.scrollY),e.lineWidth=1/t.zoom.value;let r=Lr.getPointsGlobalCoordinates(o,n),{POINT_HANDLE_SIZE:i}=Lr,a=t.editingLinearElement?i:i/2,l=Gs(o),s=iF(o);if(r.forEach((c,d)=>{if(l&&d!==0&&d!==r.length-1)return;let m=d>0&&(d!==r.length-1||!s||!o.polygon)&&qO(c,d===r.length-1?r[0]:r[d-1],2/t.zoom.value),p=!!t.editingLinearElement?.selectedPointsIndices?.includes(d);s&&o.polygon&&!p&&d===o.points.length-1&&t.editingLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),G0(e,t,c,a,p,!1,m)}),Gs(o)){let c=o.fixedSegments?.map(d=>d.index)||[];r.slice(0,-1).forEach((d,m)=>{Lr.isSegmentTooShort(o,r[m+1],r[m],m,t.zoom)||G0(e,t,jO((d[0]+r[m+1][0])/2,(d[1]+r[m+1][1])/2),i/2,!1,!c.includes(m+1),!1)})}else Lr.getEditorMidPoints(o,n,t).filter((d,m,p)=>d!==null&&!(Gs(o)&&(m===0||m===p.length-1))).forEach(d=>{(t.editingLinearElement||r.length===2)&&G0(e,t,d,i/2,!1,!0,!1)});e.restore()},RI=(e,t,o,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[l,s,c,d]=a;e.save(),e.lineWidth=1/o.zoom.value,t.selectionColor&&(e.strokeStyle=t.selectionColor),i==="rotation"?xl(e,l+c/2,s+d/2,c/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,c,d,2/o.zoom.value),e.fill(),e.stroke()):El(e,l,s,c,d,l+c/2,s+d/2,r,!0),e.restore()}})},fF=(e,t,o,n,r)=>{let[i,a,,,l,s]=Us(n,r),c=3,d=20,m=c/o.zoom.value,p=m/2,u=l-i+m,g=s-a+m,b=Math.min(d/o.zoom.value,u),x=Math.min(d/o.zoom.value,g);e.save(),e.fillStyle=t.selectionColor,e.strokeStyle=t.selectionColor,e.lineWidth=m,[[[-u,-g],[0,p],[b,p],[p,0],[p,x]],[[u-p,-g],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,g],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,g],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(E=>{let[[y,T],[v,C],[M,k],[P,A],[R,O]]=E;e.save(),e.translate(l,s),e.rotate(n.angle),e.beginPath(),e.moveTo(y+v,T+C),e.lineTo(y+M,T+k),e.stroke(),e.beginPath(),e.moveTo(y+P,T+A),e.lineTo(y+R,T+O),e.stroke(),e.restore()}),e.restore()},bF=(e,t,o,n)=>{t.save();let r=V0*2/o.zoom.value,i=e.width+r*2,a=e.height+r*2,l=e.x+i/2,s=e.y+a/2,c=-(i/2+r),d=-(a/2+r);t.translate(l+o.scrollX,s+o.scrollY),t.rotate(e.angle),t.lineWidth=1/o.zoom.value,t.strokeStyle=n,t.strokeRect(c,d,i,a),t.restore()},FI=({canvas:e,elementsMap:t,visibleElements:o,selectedElements:n,allElementsMap:r,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:t};let[c,d]=Cc(e,i),m=Sc({canvas:e,scale:i,normalizedWidth:c,normalizedHeight:d});m.save(),m.scale(a.zoom.value,a.zoom.value);let p;if(o.forEach(b=>{a.editingLinearElement?.elementId===b.id&&b&&(p=b)}),p&&U0(m,a,p,t),a.selectionElement&&!a.isCropping)try{aF(a.selectionElement,m,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&_I(a.editingTextElement)){let b=r.get(a.editingTextElement.id);b&&!b.autoResize&&bF(b,m,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{gF(m,a,b,t)}),a.frameToHighlight&&hF(m,a,a.frameToHighlight,t),a.elementsToHighlight&&DI(m,a,a.elementsToHighlight),a.activeLockedId){let b=r.get(a.activeLockedId),x=b?[b]:Y0(r,a.activeLockedId);DI(m,a,x,{colors:["#ced4da"],dashed:!0})}let u=n.some(b=>AI(b));if(n.length===1&&a.editingLinearElement?.elementId===n[0].id&&U0(m,a,n[0],t),a.selectedLinearElement){let b=a.selectedLinearElement,x=n.find(w=>w.id===b.elementId);b.segmentMidPointHoveredCoords?dF(m,a):(Gs(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&mF(m,a,t)}if(!a.multiElement&&!a.editingLinearElement){let b=nF(n,a),x=n.length===1&&rF(n[0]);x&&a.selectedLinearElement?.elementId===n[0].id&&!n[0].locked&&U0(m,a,n[0],t);let w=l.selectionColor||Tp.black;if(b){let E=JO(n),y=[];for(let v of t.values()){let C=[],M=l.remoteSelectedElementIds.get(v.id);if(x&&Gs(v)&&(v.startBinding||v.endBinding)||(E.has(v.id)&&!sF(a,v)&&C.push(w),M&&C.push(...M.map(k=>gi(k,a.collaborators.get(k))))),C.length){let[k,P,A,R,O,U]=Us(v,t,!0);y.push({angle:v.angle,x1:k,y1:P,x2:A,y2:R,selectionColors:v.locked?["#ced4da"]:C,dashed:!!M||v.locked,cx:O,cy:U,activeEmbeddable:a.activeEmbeddable?.element===v&&a.activeEmbeddable.state==="active",padding:v.id===a.croppingElementId||PI(v)?0:void 0})}}let T=v=>{let C=Y0(t,v),[M,k,P,A]=W0(C);y.push({angle:0,x1:M,x2:P,y1:k,y2:A,selectionColors:C.some(R=>R.locked)?["#ced4da"]:[Tp.black],dashed:!0,cx:M+(P-M)/2,cy:k+(A-k)/2,activeEmbeddable:!1})};for(let v of lF(a))T(v);a.editingGroupId&&T(a.editingGroupId),y.forEach(v=>OI(m,a,v))}if(m.save(),m.translate(a.scrollX,a.scrollY),n.length===1){m.fillStyle=Tp.white;let E=tF(n[0],a.zoom,t,"mouse",z0(s));if(!a.viewModeEnabled&&b&&!_I(a.editingTextElement)&&!a.croppingElementId&&RI(m,l,a,E,n[0].angle),a.croppingElementId&&!a.isCropping){let y=t.get(a.croppingElementId);y&&PI(y)&&fF(m,l,a,y,t)}}else if(n.length>1&&!a.isRotating&&!n.some(E=>E.locked)){let E=V0*2/a.zoom.value;m.fillStyle=Tp.white;let[y,T,v,C]=W0(n,t),M=m.getLineDash();m.setLineDash([2/a.zoom.value]);let k=m.lineWidth;m.lineWidth=1/a.zoom.value,m.strokeStyle=w,El(m,y-E,T-E,v-y+E*2,C-T+E*2,(y+v)/2,(T+C)/2,0),m.lineWidth=k,m.setLineDash(M);let P=oF([y,T,v,C,(y+v)/2,(T+C)/2],0,a.zoom,"mouse",u?{...z0(s),rotation:!0}:z0(s));n.some(A=>!A.locked)&&RI(m,l,a,P,0)}m.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:w})=>{let E=t.get(b);if(E){let[y,T,,,v,C]=Us(E,t,!0);m.save(),a.theme===QO.LIGHT?x?m.fillStyle="rgba(255, 124, 0, 0.4)":m.fillStyle="rgba(255, 226, 0, 0.4)":x?m.fillStyle="rgba(229, 82, 0, 0.4)":m.fillStyle="rgba(99, 52, 0, 0.4)";let M=AI(E)?a.zoom.value:1;m.translate(a.scrollX,a.scrollY),m.translate(v,C),m.rotate(E.angle),w.forEach(k=>{(k.showOnCanvas||x)&&m.fillRect(y+k.offsetX/M-v,T+k.offsetY/M-C,k.width/M,k.height/M)}),m.restore()}}),II(m,a),m.restore(),Uw({context:m,renderConfig:l,appState:a,normalizedWidth:c,normalizedHeight:d});let g;return l.renderScrollbars&&(g=kI(t,c,d,a),m.save(),m.fillStyle=SI,m.strokeStyle="rgba(255,255,255,0.8)",[g.horizontal,g.vertical].forEach(b=>{b&&rm(m,b.x,b.y,b.width,b.height,eo/2)}),m.restore()),{scrollBars:g,atLeastOneVisibleElement:o.length>0,elementsMap:t}},K0=eF(e=>{let t=FI(e);e.callback?.(t)},{trailing:!0}),HI=(e,t)=>{if(t){K0(e);return}let o=FI(e);return e.callback(o),o};var Ys=class{constructor(t){S(this,"scene");S(this,"getRenderableElements",(()=>{let t=({elementsMap:n,zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:c,width:d})=>{let m=[];for(let p of n.values())xF(p,d,c,{zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},n)&&m.push(p);return m},o=({elements:n,editingTextElement:r,newElementId:i})=>{let a=yF(new Map);for(let l of n)i!==l.id&&(!r||r.type!=="text"||l.id!==r.id)&&a.set(l.id,l);return a};return EF(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingTextElement:d,newElementId:m,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),g=o({elements:u,editingTextElement:d,newElementId:m}),b=t({elementsMap:g,zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:g,visibleElements:b}})})());this.scene=t}destroy(){K0.cancel(),lE.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as wF}from"@excalidraw/common";import{getElementAbsoluteCoords as vF}from"@excalidraw/element";import{jsx as CF}from"react/jsx-runtime";var TF=5,IF=(e,t,o)=>{let[n,r]=vF(e,o),{x:i,y:a}=wF({sceneX:n+e.width,sceneY:r},t),l=i-t.offsetLeft+10,s=a-t.offsetTop;return{x:l,y:s}},X0=({children:e,element:t,elementsMap:o})=>{let n=en();if(n.contextMenu||n.newElement||n.resizingElement||n.isRotating||n.openMenu||n.viewModeEnabled)return null;let{x:r,y:i}=IF(t,n,o);return CF("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${r}px`,padding:TF},children:e})};import{DEFAULT_LASER_COLOR as LF,easeOut as GI}from"@excalidraw/common";import{LaserPointer as SF}from"@excalidraw/laser-pointer";import{SVG_NS as zI,getSvgPathFromStroke as kF,sceneCoordsToViewportCoords as MF}from"@excalidraw/common";var Un=class{constructor(t,o,n){this.animationFrameHandler=t;this.app=o;this.options=n;S(this,"currentTrail");S(this,"pastTrails",[]);S(this,"container");S(this,"trailElement");S(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(zI,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(zI,"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(t,o){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===t&&this.currentTrail.originalPoints[n-1][1]===o}return!1}start(t){t&&(this.container=t),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(t,o){this.currentTrail=new SF(this.options),this.currentTrail.addPoint([t,o,performance.now()]),this.update()}addPointToPath(t,o){this.currentTrail&&(this.currentTrail.addPoint([t,o,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 t=[];for(let n of this.pastTrails)t.push(this.drawTrail(n,this.app.state));if(this.currentTrail){let n=this.drawTrail(this.currentTrail,this.app.state);t.push(n)}this.pastTrails=this.pastTrails.filter(n=>n.getStrokeOutline().length!==0),t.length===0&&this.stop();let o=t.join(" ").trim();this.trailElement.setAttribute("d",o),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(t,o){let n=t.getStrokeOutline(t.options.size/o.zoom.value).map(([i,a])=>{let l=MF({sceneX:i,sceneY:a},o);return[l.x,l.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return kF(r,!0)}};var Ip=class{constructor(t,o){this.animationFrameHandler=t;this.app=o;S(this,"localTrail");S(this,"collabTrails",new Map);S(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Un(t,o,{...this.getTrailOptions(),fill:()=>LF})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:t=>{let r=Math.max(0,1-(performance.now()-t.pressure)/1e3),i=(50-Math.min(50,t.totalLength-t.currentIndex))/50;return Math.min(GI(i),GI(r))}}}startPath(t,o){this.localTrail.startPath(t,o)}addPointToPath(t,o){this.localTrail.addPointToPath(t,o)}endPath(){this.localTrail.endPath()}start(t){this.container=t,this.animationFrameHandler.start(this),this.localTrail.start(t)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[t,o]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(t)?n=this.collabTrails.get(t):(n=new Un(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>o.pointer?.laserColor||gi(t,o)}),n.start(this.container),this.collabTrails.set(t,n)),o.pointer&&o.pointer.tool==="laser"&&(o.button==="down"&&!n.hasCurrentTrail&&n.startPath(o.pointer.x,o.pointer.y),o.button==="down"&&n.hasCurrentTrail&&!n.hasLastPoint(o.pointer.x,o.pointer.y)&&n.addPointToPath(o.pointer.x,o.pointer.y),o.button==="up"&&n.hasCurrentTrail&&(n.addPointToPath(o.pointer.x,o.pointer.y),n.endPath()))}for(let t of this.collabTrails.keys())this.app.state.collaborators.has(t)||(this.collabTrails.get(t).stop(),this.collabTrails.delete(t))}}};import{version as AF}from"react";import{unstable_batchedUpdates as UI}from"react-dom";import{throttleRAF as PF}from"@excalidraw/common";var Ge=e=>t=>{UI(e,t)},Cp=e=>PF(t=>{UI(e,t)}),Qa=(()=>{let e;try{let o=AF.split(".");e=Number(o[0])>17}catch{e=!1}let t=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(t||(t=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as $0,KEYS as Ws,CLASSES as YI,POINTER_BUTTON as _F,isWritableElement as DF,getFontString as WI,getFontFamilyString as VI,isTestEnv as KI}from"@excalidraw/common";import{originalContainerCache as RF,updateOriginalContainerCache as XI}from"@excalidraw/element";import{LinearElementEditor as NF}from"@excalidraw/element";import{bumpVersion as BF}from"@excalidraw/element";import{getBoundTextElementId as OF,getContainerElement as Z0,getTextElementAngle as FF,redrawTextBoundingBox as HF,getBoundTextMaxHeight as zF,getBoundTextMaxWidth as $I,computeContainerDimensionForBoundText as ZI,computeBoundTextPosition as GF,getBoundTextElement as UF}from"@excalidraw/element";import{getTextWidth as YF}from"@excalidraw/element";import{normalizeText as jI}from"@excalidraw/element";import{wrapText as WF}from"@excalidraw/element";import{isArrowElement as Sp,isBoundToContainer as VF,isTextElement as qI}from"@excalidraw/element";var KF=(e,t,o,n,r,i)=>{let{zoom:a}=n,l=180*o/Math.PI,s=e*(a.value-1)/2,c=t*(a.value-1)/2;return e>r&&a.value!==1&&(s=r*(a.value-1)/2),t>i&&a.value!==1&&(c=i*(a.value-1)/2),`translate(${s}px, ${c}px) scale(${a.value}) rotate(${l}deg)`},JI=({id:e,onChange:t,onSubmit:o,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let c=(_,B)=>{if(!B.style.fontFamily||!B.style.fontSize)return!1;let j=B.style.fontFamily.replace(/"/g,"");return VI({fontFamily:_.fontFamily})!==j||`${_.fontSize}px`!==B.style.fontSize},d=()=>{let _=l.state,B=l.scene.getElement(e);if(!B)return;let{textAlign:j,verticalAlign:V}=B,Y=l.scene.getNonDeletedElementsMap();if(B&&qI(B)){let le=B.x,xe=B.y,ue=Z0(B,l.scene.getNonDeletedElementsMap()),gt=B.width,Ft=B.height,_o=B.width,$r=B.height;if(ue&&B.containerId){if(Sp(ue)){let Xn=NF.getBoundTextElementPosition(ue,B,Y);le=Xn.x,xe=Xn.y}let Ec=c(B,m),fl;if(Ec?fl=XI(ue.id,ue.height):(fl=RF[ue.id],fl||(fl=XI(ue.id,ue.height))),_o=$I(ue,B),$r=zF(ue,B),!Sp(ue)&&Ft>$r){let Xn=ZI(Ft,ue.type);l.scene.mutateElement(ue,{height:Xn});return}else if(!Sp(ue)&&ue.height>fl.height&&Ft<$r){let Xn=ZI(Ft,ue.type);l.scene.mutateElement(ue,{height:Xn})}else{let{y:Xn}=GF(ue,B,Y);xe=Xn}}let[Zr,jr]=n(le,xe),K4=m.selectionStart,Du=m.selectionEnd,Xx=m.value.length;if(K4===Du&&Du!==Xx){let Ec=Xx-Du;m.selectionStart=m.value.length-Ec,m.selectionEnd=m.value.length-Ec}ue?gt+=.5:(_o=(_.width-8-Zr)/_.zoom.value,gt=Math.min(gt,_o)),Ft*=1.05;let X4=WI(B),$x=(_.height-jr)/_.zoom.value;Object.assign(m.style,{font:X4,lineHeight:B.lineHeight,width:`${gt}px`,height:`${Ft}px`,left:`${Zr}px`,top:`${jr}px`,transform:KF(gt,Ft,FF(B,ue),_,_o,$x),textAlign:j,verticalAlign:V,color:B.strokeColor,opacity:B.opacity/100,filter:"var(--theme-filter)",maxHeight:`${$x}px`}),m.scrollTop=0,KI()&&(m.style.fontFamily=VI(B)),l.scene.mutateElement(B,{x:le,y:xe})}},m=document.createElement("textarea");m.dir="auto",m.tabIndex=0,m.dataset.type="wysiwyg",m.wrap="off",m.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(VF(r)||!r.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(m.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"}),m.value=r.originalText,d(),t&&(m.onpaste=async _=>{let B=await Vd(_,!0);if(!B.text)return;let j=jI(B.text);if(!j)return;let V=Z0(r,l.scene.getNonDeletedElementsMap()),Y=WI({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(V){let le=UF(V,l.scene.getNonDeletedElementsMap()),xe=WF(`${m.value}${j}`,Y,$I(V,le)),ue=YF(xe,Y);m.style.width=`${ue}px`}},m.oninput=()=>{let _=jI(m.value);if(m.value!==_){let B=m.selectionStart;m.value=_,m.selectionStart=B,m.selectionEnd=B}t(m.value)}),m.onkeydown=_=>{if(!_.shiftKey&&ts.keyTest(_))_.preventDefault(),l.actionManager.executeAction(ts),d();else if(!_.shiftKey&&os.keyTest(_))_.preventDefault(),l.actionManager.executeAction(os),d();else if(!_.shiftKey&&ns.keyTest(_))_.preventDefault(),l.actionManager.executeAction(ns),d();else if(mf.keyTest(_))l.actionManager.executeAction(mf);else if(pf.keyTest(_))l.actionManager.executeAction(pf);else if(_.key===Ws.ESCAPE)_.preventDefault(),v=!0,C();else if(ur.keyTest(_))_.preventDefault(),C(),l.actionManager.executeAction(ur);else if(_.key===Ws.ENTER&&_[Ws.CTRL_OR_CMD]){if(_.preventDefault(),_.isComposing||_.keyCode===229)return;v=!0,C()}else if(_.key===Ws.TAB||_[Ws.CTRL_OR_CMD]&&(_.code===$0.BRACKET_LEFT||_.code===$0.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===$0.BRACKET_LEFT?E():w(),m.dispatchEvent(new Event("input"))}};let g=4,b=" ".repeat(g),x=new RegExp(`^ {1,${g}}`),w=()=>{let{selectionStart:_,selectionEnd:B}=m,j=y(),V=m.value;j.forEach(Y=>{let le=V.slice(0,Y),xe=V.slice(Y);V=`${le}${b}${xe}`}),m.value=V,m.selectionStart=_+g,m.selectionEnd=B+g*j.length},E=()=>{let{selectionStart:_,selectionEnd:B}=m,j=y(),V=[],Y=m.value;j.forEach(le=>{let xe=Y.slice(le,le+g).match(x);if(xe){let ue=Y.slice(0,le),gt=Y.slice(le+xe[0].length);Y=`${ue}${gt}`,V.push(le)}}),m.value=Y,V.length&&(_>V[V.length-1]?m.selectionStart=Math.max(_-g,V[V.length-1]):m.selectionStart=_,m.selectionEnd=Math.max(m.selectionStart,B-g*V.length))},y=()=>{let{selectionStart:_,selectionEnd:B,value:j}=m,V=j.slice(0,_).match(/[^\n]*$/)[0].length;return _=_-V,j.slice(_,B).split(`
|
|
33
|
+
`).reduce((le,xe,ue,gt)=>le.concat(ue?le[ue-1]+gt[ue-1].length+1:_),[]).reverse()},T=_=>{_.target instanceof HTMLCanvasElement&&(_.preventDefault(),_.stopPropagation())},v=!1,C=()=>{if(U)return;U=!0,M();let _=l.scene.getElement(r.id);if(!_)return;let B=Z0(_,l.scene.getNonDeletedElementsMap());if(B){if(m.value.trim()){let j=OF(B);!j||j!==r.id?l.scene.mutateElement(B,{boundElements:(B.boundElements||[]).concat({type:"text",id:r.id})}):Sp(B)&&BF(B)}else l.scene.mutateElement(B,{boundElements:B.boundElements?.filter(j=>!qI(j))});HF(_,B,l.scene)}o({viaKeyboard:v,nextOriginalText:m.value})},M=()=>{m.onblur=null,m.oninput=null,m.onkeydown=null,ee&&ee.disconnect(),window.removeEventListener("resize",d),window.removeEventListener("wheel",T,!0),window.removeEventListener("pointerdown",A),window.removeEventListener("pointerup",k),window.removeEventListener("blur",C),window.removeEventListener("beforeunload",C),R(),O(),m.remove()},k=_=>{window.removeEventListener("pointerup",k);let B=_?.target,j=B instanceof HTMLElement&&B.classList.contains("properties-trigger");setTimeout(()=>{m.onblur=C,j||m.focus()})},P=()=>{m.onblur=null,window.addEventListener("pointerup",k),window.addEventListener("blur",C)},A=_=>{let B=_?.target;if(_.button===_F.WHEEL){B instanceof HTMLTextAreaElement&&(_.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(_)),P();return}let j=B instanceof HTMLElement&&B.classList.contains("properties-trigger");(_.target instanceof HTMLElement||_.target instanceof SVGElement)&&_.target.closest(`.${YI.SHAPE_ACTIONS_MENU}, .${YI.ZOOM_ACTIONS}`)&&!DF(_.target)||j?P():_.target instanceof HTMLCanvasElement&&!KI()&&requestAnimationFrame(()=>{C()})},R=l.scene.onUpdate(()=>{d(),!!document.activeElement?.closest(".properties-content")||m.focus()}),O=l.onScrollChangeEmitter.on(()=>{d()}),U=!1;s&&m.select(),k();let ee=null;return i&&"ResizeObserver"in window?(ee=new window.ResizeObserver(()=>{d()}),ee.observe(i)):window.addEventListener("resize",d),m.onpointerdown=_=>_.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",A,{capture:!0})}),window.addEventListener("beforeunload",C),a?.querySelector(".excalidraw-textEditorContainer").appendChild(m),C};var QI=e=>{let t=["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(?:${t.map(n=>`\\s*${n}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as oH}from"@excalidraw/math";import{getElementLineSegments as nH}from"@excalidraw/element";import{LinearElementEditor as rH}from"@excalidraw/element";import{isFrameLikeElement as iH,isLinearElement as aH,isTextElement as lH}from"@excalidraw/element";import{getFrameChildren as sH}from"@excalidraw/element";import{selectGroupsForSelectedElements as cH}from"@excalidraw/element";import{getContainerElement as dH}from"@excalidraw/element";import{arrayToMap as mH,easeOut as n5,isShallowEqual as pH}from"@excalidraw/common";import{simplify as XF}from"points-on-curve";import{polygonFromPoints as $F,lineSegment as e5,polygonIncludesPointNonZero as ZF}from"@excalidraw/math";import{computeBoundTextPosition as jF,doBoundsIntersect as qF,getBoundTextElement as JF,getElementBounds as QF,intersectElementWithLineSegment as t5}from"@excalidraw/element";var o5=e=>{let{lassoPath:t,elements:o,elementsMap:n,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=t;l&&(s=XF(t,l));let c=o.filter(p=>!p.locked);a.clear(),i.clear();let d=t.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 c){let u=QF(p,n);qF(d,u)&&!i.has(p.id)&&!a.has(p.id)&&(eH(s,p,r)?a.add(p.id):tH(s,p,n)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},eH=(e,t,o)=>{let n=$F(e),r=o.get(t.id);return r?r.some(i=>i.some(a=>ZF(a,n))):!1},tH=(e,t,o)=>{let n=e.slice(1).map((i,a)=>e5(e[a],i)).concat([e5(e[e.length-1],e[0])]),r=JF(t,o);return n.some(i=>t5(t,o,i,0,!0).length>0||!!r&&t5({...r,...jF(t,r,o)},o,i,0,!0).length>0)};var kp=class extends Un{constructor(o,n){super(o,n,{animateTrail:!0,streamline:.4,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/(1/0)),s=(5e3-Math.min(5e3,r.totalLength-r.currentIndex))/5e3;return Math.min(n5(s),n5(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});S(this,"intersectedElements",new Set);S(this,"enclosedElements",new Set);S(this,"elementsSegments",null);S(this,"canvasTranslate",null);S(this,"keepPreviousSelection",!1);S(this,"selectElementsFromIds",o=>{this.app.setState(n=>{let r=o.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(n.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(s);if(c&&lH(c)){let d=dH(c,this.app.scene.getNonDeletedElementsMap());d&&(r[d.id]=!0,delete r[c.id])}}for(let[s]of Object.entries(r)){let c=this.app.scene.getNonDeletedElement(s);if(c&&iH(c)){let d=sH(this.app.scene.getNonDeletedElementsMap(),c.id);for(let m of d)delete r[m.id]}}let i=cH({editingGroupId:n.editingGroupId,selectedElementIds:r},this.app.scene.getNonDeletedElements(),n,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&aH(this.app.scene.getNonDeletedElement(a[0]))?new rH(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});S(this,"addPointToPath",(o,n,r=!1)=>{super.addPointToPath(o,n),this.keepPreviousSelection=r,this.updateSelection()});S(this,"updateSelection",()=>{let o=super.getCurrentTrail()?.originalPoints?.map(r=>oH(r[0],r[1])),n={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!pH(n,this.canvasTranslate??{})){this.canvasTranslate=n,this.elementsSegments=new Map;let r=mH(this.app.visibleElements);for(let i of this.app.visibleElements){let a=nH(i,r);this.elementsSegments.set(i.id,a)}}if(o){let{selectedElementIds:r}=o5({lassoPath:o,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}startPath(o,n,r=!1){this.endPath(),super.startPath(o,n),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as uH,easeOut as r5,THEME as gH}from"@excalidraw/common";import{computeBoundTextPosition as hH,getBoundTextElement as fH,intersectElementWithLineSegment as i5,isPointInElement as bH}from"@excalidraw/element";import{lineSegment as xH,pointFrom as EH}from"@excalidraw/math";import{getElementsInGroup as a5}from"@excalidraw/element";import{shouldTestInside as yH}from"@excalidraw/element";import{hasBoundTextElement as l5,isBoundToContainer as s5}from"@excalidraw/element";import{getBoundTextElementId as c5}from"@excalidraw/element";var Mp=class extends Un{constructor(o,n){super(o,n,{streamline:.2,size:5,keepHead:!0,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/200),s=(10-Math.min(10,r.totalLength-r.currentIndex))/10;return Math.min(r5(s),r5(l))},fill:()=>n.state.theme===gH.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});S(this,"elementsToErase",new Set);S(this,"groupsToErase",new Set)}startPath(o,n){this.endPath(),super.startPath(o,n),this.elementsToErase.clear()}addPointToPath(o,n,r=!1){return super.addPointToPath(o,n),this.updateElementsToBeErased(r)}updateElementsToBeErased(o){let n=super.getCurrentTrail()?.originalPoints?.map(l=>EH(l[0],l[1]))||[];if(n.length<2)return[];let r=xH(n[n.length-1],n[n.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=uH(i);for(let l of i)if(o&&this.elementsToErase.has(l.id)){if(d5(r,l,a)){let c=l.groupIds.at(-1);if(this.groupsToErase.has(c)){let d=a5(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.delete(m.id);this.groupsToErase.delete(c)}if(s5(l)&&this.elementsToErase.delete(l.containerId),l5(l)){let d=c5(l);d&&this.elementsToErase.delete(d)}this.elementsToErase.delete(l.id)}}else if(!o&&!this.elementsToErase.has(l.id)&&d5(r,l,a)){let c=l.groupIds.at(-1);if(!this.groupsToErase.has(c)){let d=a5(this.app.scene.getNonDeletedElementsMap(),c);for(let m of d)this.elementsToErase.add(m.id);this.groupsToErase.add(c)}if(l5(l)){let d=c5(l);d&&this.elementsToErase.add(d)}s5(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()}},d5=(e,t,o)=>{let n=e[1];if(yH(t)&&bH(n,t,o))return!0;let r=fH(t,o);return i5(t,o,e,0,!0).length>0||!!r&&i5({...r,...hH(t,r,o)},o,e,0,!0).length>0};import{jsx as So,jsxs as m5}from"react/jsx-runtime";var wH=()=>m5("div",{"data-testid":"brave-measure-text-error",children:[So("p",{children:So(_t,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>So("span",{style:{fontWeight:600},children:e})})}),So("p",{children:So(_t,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>So("span",{style:{fontWeight:600},children:e})})}),So("p",{children:So(_t,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>So("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),So("p",{children:So(_t,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>So("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>m5("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),p5=wH;import kH from"clsx";import MH from"react";import{useLayoutEffect as vH,useRef as u5,useEffect as g5}from"react";import{unstable_batchedUpdates as TH}from"react-dom";import{KEYS as IH,queryFocusableElements as CH}from"@excalidraw/common";import{jsx as SH}from"react/jsx-runtime";var h5=({children:e,left:t,top:o,onCloseRequest:n,fitInViewport:r=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let c=u5(null);g5(()=>{let m=c.current;if(!m)return;m.contains(document.activeElement)||m.focus();let p=u=>{if(u.key===IH.TAB){let g=CH(m),{activeElement:b}=document,x=g.findIndex(w=>w===b);b===m?(u.shiftKey?g[g.length-1]?.focus():g[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(g[g.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===g.length-1&&!u.shiftKey&&(g[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return m.addEventListener("keydown",p),()=>m.removeEventListener("keydown",p)},[]);let d=u5(null);return vH(()=>{if(r&&c.current&&o!=null&&t!=null){let m=c.current,{width:p,height:u}=m.getBoundingClientRect();if(d.current?.top===o&&d.current?.left===t)return;d.current={top:o,left:t},p>=l?(m.style.width=`${l}px`,m.style.left="0px",m.style.overflowX="scroll"):t+p-i>l?m.style.left=`${l-p-10}px`:m.style.left=`${t}px`,u>=s?(m.style.height=`${s-20}px`,m.style.top="10px",m.style.overflowY="scroll"):o+u-a>s?m.style.top=`${s-u}px`:m.style.top=`${o}px`}},[o,t,r,l,s,i,a]),g5(()=>{if(n){let m=p=>{c.current?.contains(p.target)||TH(()=>n(p))};return document.addEventListener("pointerdown",m,!1),()=>document.removeEventListener("pointerdown",m,!1)}},[n]),SH("div",{className:"popover",ref:c,tabIndex:-1,children:e})};import{jsx as el,jsxs as LH}from"react/jsx-runtime";var it="separator",f5=MH.memo(({actionManager:e,items:t,top:o,left:n,onClose:r})=>{let i=en(),a=ir(),l=t.reduce((s,c)=>(c&&(c===it||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return el(h5,{onCloseRequest:()=>{r()},top:o,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:el("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===it)return!l[c-1]||l[c-1]===it?null:el("hr",{className:"context-menu-item-separator"},c);let d=s.name,m="";return s.label&&(typeof s.label=="function"?m=f(s.label(a,i,e.app)):m=f(s.label)),el("li",{"data-testid":d,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:LH("button",{type:"button",className:kH("context-menu-item",{dangerous:d==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[el("div",{className:"context-menu-item__label",children:m}),el("kbd",{className:"context-menu-item__shortcut",children:d?Xe(d):""})]})},c)})})})});import{jsx as j0,jsxs as b5}from"react/jsx-runtime";var AH=({height:e,width:t,userToFollow:o,onDisconnect:n})=>j0("div",{className:"follow-mode",style:{width:t,height:e},children:b5("div",{className:"follow-mode__badge",children:[b5("div",{className:"follow-mode__badge__label",children:["Following"," ",j0("span",{className:"follow-mode__badge__username",title:o.username,children:o.username})]}),j0("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:no})]})}),x5=AH;import oc from"clsx";import sW from"react";import{CLASSES as cW,DEFAULT_SIDEBAR as qb,TOOL_TYPE as r6,arrayToMap as dW,capitalizeString as mW,isShallowEqual as Eu}from"@excalidraw/common";import{mutateElement as pW}from"@excalidraw/element";import{showSelectedShapeActions as uW}from"@excalidraw/element";import{ShapeCache as gW}from"@excalidraw/element";import PH from"clsx";import{useState as _H,useEffect as DH}from"react";import{THEME as RH}from"@excalidraw/common";import{jsx as q0,jsxs as NH}from"react/jsx-runtime";var Lp=({delay:e,theme:t})=>{let[o,n]=_H(!!e);return DH(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),o?null:NH("div",{className:PH("LoadingMessage",{"LoadingMessage--dark":t===RH.DARK}),children:[q0("div",{children:q0(yt,{})}),q0("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import BH from"clsx";import{jsx as y5,jsxs as FH}from"react/jsx-runtime";var OH="medium",E5={CHECKED:ei,UNCHECKED:Jn},Ap=e=>FH("label",{className:BH("ToolIcon ToolIcon__lock",`ToolIcon_size_${OH}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[y5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),y5("div",{className:"ToolIcon__icon",children:e.checked?E5.CHECKED:E5.UNCHECKED})]});import{showSelectedShapeActions as fz}from"@excalidraw/element";import HH from"clsx";import{jsx as zH}from"react/jsx-runtime";var Pp=({children:e,side:t,className:o})=>zH("div",{className:HH("FixedSideContainer",`FixedSideContainer_side_${t}`,o),children:e});import GH from"clsx";import{KEYS as w5}from"@excalidraw/common";import{jsx as UH}from"react/jsx-runtime";var _p=e=>UH($,{className:GH("Shape",{fillable:!1}),type:"radio",icon:Dl,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:w5.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":w5.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{CANVAS_SEARCH_TAB as YH,DEFAULT_SIDEBAR as WH}from"@excalidraw/common";import{isFlowchartNodeElement as VH,isImageElement as v5,isLinearElement as T5,isLineElement as KH,isTextBindableContainer as XH,isTextElement as $H}from"@excalidraw/element";import{getShortcutKey as J0}from"@excalidraw/common";import{isNodeInFlowchart as ZH}from"@excalidraw/element";import{jsx as I5}from"react/jsx-runtime";var jH=({appState:e,isMobile:t,device:o,app:n})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===WH.name&&e.openSidebar.tab===YH&&e.searchMatches?.matches.length)return f("hints.dismissSearch");if(e.openSidebar&&!o.editor.canFitSidebar)return null;if(Ht(e))return f("hints.eraserRevert");if(r.type==="arrow"||r.type==="line")return s?f("hints.linearElementMulti"):r.type==="arrow"?f("hints.arrowTool",{arrowShortcut:J0("A")}):f("hints.linearElement");if(r.type==="freedraw")return f("hints.freeDraw");if(r.type==="text")return f("hints.text");if(r.type==="embeddable")return f("hints.embeddable");let c=n.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let d=c[0];return T5(d)&&d.points.length===2?f("hints.lockAngle"):v5(d)?f("hints.resizeImage"):f("hints.resize")}if(a&&l==="mouse")return f("hints.rotate");if(c.length===1&&$H(c[0]))return f("hints.text_selected");if(e.editingTextElement)return f("hints.text_editing");if(e.croppingElementId)return f("hints.leaveCropEditor");if(c.length===1&&v5(c[0]))return f("hints.enterCropEditor");if(r.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.editingLinearElement)return[f("hints.deepBoxSelect")];if(kr(n)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping");if(!c.length&&!t)return[f("hints.canvasPanning")];if(c.length===1){if(T5(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected"):f("hints.lineEditor_nothingSelected"):KH(c[0])?f("hints.lineEditor_line_info"):f("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&XH(c[0]))return VH(c[0])?ZH(c[0],n.scene.getNonDeletedElementsMap())?[f("hints.bindTextToElement"),f("hints.createFlowchart")]:[f("hints.bindTextToElement"),f("hints.createFlowchart")]:f("hints.bindTextToElement")}}return null},Dp=({appState:e,isMobile:t,device:o,app:n})=>{let r=jH({appState:e,isMobile:t,device:o,app:n});if(!r)return null;let i=Array.isArray(r)?r.map(a=>J0(a).replace(/\. ?$/,"")).join(". "):J0(r);return I5("div",{className:"HintViewer",children:I5("span",{children:i})})};import qH from"clsx";import{jsx as C5,jsxs as QH}from"react/jsx-runtime";var JH="medium",Rp=e=>e.penDetected?QH("label",{className:qH("ToolIcon ToolIcon__penMode",`ToolIcon_size_${JH}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[C5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),C5("div",{className:"ToolIcon__icon",children:ng})]}):null;import{Fragment as ez,jsx as S5,jsxs as tz}from"react/jsx-runtime";var Ar=({heading:e,children:t,...o})=>{let{id:n}=tt(),r=S5("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:f(`headings.${e}`)});return S5("section",{...o,"aria-labelledby":`${n}-${e}-title`,children:typeof t=="function"?t(r):tz(ez,{children:[r,t]})})};import mz from"open-color";var Q0=/Mac|iPod|iPhone|iPad/.test(navigator.platform),PTe=/^Win/.test(navigator.platform),_Te=/\b(android)\b/i.test(navigator.userAgent),DTe=typeof window<"u"&&"netscape"in window&&navigator.userAgent.indexOf("rv:")>1&&navigator.userAgent.indexOf("Gecko")>1,oz=navigator.userAgent.indexOf("Chrome")!==-1,RTe=!oz&&navigator.userAgent.indexOf("Safari")!==-1,NTe=/iPad|iPhone/.test(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document;var BTe=typeof window<"u"&&"ResizeObserver"in window;var OTe=Math.PI/12;var nz="Xiaolai",M5="Segoe UI Emoji",ko={Virgil:1,Helvetica:2,Cascadia:3,Excalifont:5,Nunito:6,"Lilita One":7,"Comic Shanns":8,"Liberation Sans":9,Assistant:10},rz="sans-serif",iz="monospace",az={[rz]:998,[iz]:999},eb={[nz]:100,...az,[M5]:1e3};var FTe=ko.Excalifont;var lz=2;var Np="#ffffff",tb="#1e1e1e",Bp="transparent",sz=2*lz,cz=1e-5,HTe=2*sz-cz;var L5={svg:"image/svg+xml",png:"image/png",jpg:"image/jpeg",gif:"image/gif",webp:"image/webp",bmp:"image/bmp",ico:"image/x-icon",avif:"image/avif",jfif:"image/jfif"},k5={text:"text/plain",html:"text/html",json:"application/json",excalidraw:"application/vnd.excalidraw+json",excalidrawlib:"application/vnd.excalidrawlib+json","excalidraw.svg":"image/svg+xml","excalidraw.png":"image/png",binary:"application/octet-stream",...L5},zTe=[k5.text,k5.html,...Object.values(L5)];var GTe=4*1024*1024;var dz={architect:0,artist:1,cartoonist:2};var UTe={strokeColor:tb,backgroundColor:Bp,fillStyle:"solid",strokeWidth:2,strokeStyle:"solid",roughness:dz.artist,opacity:100,locked:!1};var YTe=Symbol.for("__test__originalId__");var pz=(e,t)=>t.reduce((o,n)=>(n in e&&(o[n]=e[n]),o),{});var Op=4,Fp=1,Ko=[0,2,4,6,8];var Xo=(e,t)=>t.map(o=>mz[e][o]),je={transparent:Bp,charcoal:tb,white:Np,gray:Xo("gray",Ko),red:Xo("red",Ko),pink:Xo("pink",Ko),grape:Xo("grape",Ko),violet:Xo("violet",Ko),blue:Xo("blue",Ko),cyan:Xo("cyan",Ko),teal:Xo("teal",Ko),green:Xo("green",Ko),yellow:Xo("yellow",Ko),orange:Xo("orange",Ko),bronze:["#f8f1ee","#eaddd7","#d2bab0","#a18072","#846358"]},A5=pz(je,["cyan","blue","violet","grape","pink","green","teal","yellow","orange","red"]),$Te=[je.charcoal,je.red[Op],je.green[Op],je.blue[Op],je.yellow[Op]],ZTe=[je.transparent,je.red[Fp],je.green[Fp],je.blue[Fp],je.yellow[Fp]],jTe=[je.white,"#f8f9fa","#f5faff","#fffce8","#fdf8f6"],qTe={transparent:je.transparent,white:je.white,gray:je.gray,charcoal:je.charcoal,bronze:je.bronze,...A5},JTe={transparent:je.transparent,white:je.white,gray:je.gray,charcoal:je.charcoal,bronze:je.bronze,...A5};var o3e={[ko.Excalifont]:{metrics:{unitsPerEm:1e3,ascender:886,descender:-374,lineHeight:1.25}},[ko.Nunito]:{metrics:{unitsPerEm:1e3,ascender:1011,descender:-353,lineHeight:1.25}},[ko["Lilita One"]]:{metrics:{unitsPerEm:1e3,ascender:923,descender:-220,lineHeight:1.15}},[ko["Comic Shanns"]]:{metrics:{unitsPerEm:1e3,ascender:750,descender:-250,lineHeight:1.25}},[ko.Virgil]:{metrics:{unitsPerEm:1e3,ascender:886,descender:-374,lineHeight:1.25},deprecated:!0},[ko.Helvetica]:{metrics:{unitsPerEm:2048,ascender:1577,descender:-471,lineHeight:1.15},deprecated:!0,local:!0},[ko.Cascadia]:{metrics:{unitsPerEm:2048,ascender:1900,descender:-480,lineHeight:1.2},deprecated:!0},[ko["Liberation Sans"]]:{metrics:{unitsPerEm:2048,ascender:1854,descender:-434,lineHeight:1.15},private:!0},[ko.Assistant]:{metrics:{unitsPerEm:2048,ascender:1021,descender:-287,lineHeight:1.25},private:!0},[eb.Xiaolai]:{metrics:{unitsPerEm:1e3,ascender:880,descender:-144,lineHeight:1.25},fallback:!0},[eb["Segoe UI Emoji"]]:{metrics:{unitsPerEm:1e3,ascender:886,descender:-374,lineHeight:1.25},local:!0,fallback:!0}};var P5={EQUAL:"Equal",MINUS:"Minus",NUM_ADD:"NumpadAdd",NUM_SUBTRACT:"NumpadSubtract",NUM_ZERO:"Numpad0",BRACKET_RIGHT:"BracketRight",BRACKET_LEFT:"BracketLeft",ONE:"Digit1",TWO:"Digit2",THREE:"Digit3",NINE:"Digit9",QUOTE:"Quote",ZERO:"Digit0",SLASH:"Slash",C:"KeyC",D:"KeyD",H:"KeyH",V:"KeyV",Z:"KeyZ",Y:"KeyY",R:"KeyR",S:"KeyS"},_5={ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight",ARROW_UP:"ArrowUp",PAGE_UP:"PageUp",PAGE_DOWN:"PageDown",BACKSPACE:"Backspace",ALT:"Alt",CTRL_OR_CMD:Q0?"metaKey":"ctrlKey",DELETE:"Delete",ENTER:"Enter",ESCAPE:"Escape",QUESTION_MARK:"?",SPACE:" ",TAB:"Tab",CHEVRON_LEFT:"<",CHEVRON_RIGHT:">",PERIOD:".",COMMA:",",SUBTRACT:"-",SLASH:"/",A:"a",C:"c",D:"d",E:"e",F:"f",G:"g",H:"h",I:"i",L:"l",O:"o",P:"p",Q:"q",R:"r",S:"s",T:"t",V:"v",X:"x",Y:"y",Z:"z",K:"k",W:"w",0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9"},p3e=new Map([[_5.Z,P5.Z],[_5.Y,P5.Y]]);import{pointFromPair as f3e}from"@excalidraw/math";import y3e from"es6-promise-pool";import{nanoid as N3e}from"nanoid";import{Random as hz}from"roughjs/bin/math";import{average as M3e}from"@excalidraw/math";var D5=e=>e.charAt(0).toUpperCase()+e.slice(1);var uz="A-Za-z\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u0300-\u0590\u0800-\u1FFF\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF",gz="\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC",A3e=new RegExp(`^[^${uz}]*[${gz}]`);var F3e=new hz(Date.now());import{sanitizeUrl as Y3e}from"@braintree/sanitize-url";import{jsx as ob}from"react/jsx-runtime";var R5=({onHomeButtonClick:e})=>ob("label",{title:`${D5(f("toolBar.library"))} \u2014 0`,children:ob("div",{className:"library-button",onClick:e,children:ob("div",{children:Xu})})});import{Fragment as bz,jsx as pt,jsxs as Yn}from"react/jsx-runtime";var N5=({appState:e,elements:t,actionManager:o,setAppState:n,onLockToggle:r,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:c,device:d,renderWelcomeScreen:m,UIOptions:p,app:u,onHomeButtonClick:g})=>{let{WelcomeScreenCenterTunnel:b,MainMenuTunnel:x,DefaultSidebarTriggerTunnel:w}=Ne(),E=()=>Yn(Pp,{side:"top",className:"App-top-bar",children:[m&&pt(b.Out,{}),pt(Ar,{heading:"shapes",children:T=>pt(ht.Col,{gap:4,align:"center",children:Yn(ht.Row,{gap:1,className:"App-toolbar-container",children:[Yn(st,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[T,pt(ht.Row,{gap:1,children:pt(Hm,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Yn("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&pt(w.Out,{}),pt(Rp,{checked:e.penMode,onChange:()=>a(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),pt(Ap,{checked:e.activeTool.locked,onChange:r,title:f("toolBar.lock"),isMobile:!0}),pt(_p,{checked:Do(e),onChange:()=>i(),title:f("toolBar.hand"),isMobile:!0})]}),pt("div",{className:"mobile-misc-tools-container-left",children:pt(R5,{onHomeButtonClick:g})})]})})}),pt(Dp,{appState:e,isMobile:!0,device:d,app:u})]}),y=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?pt("div",{className:"App-toolbar-content",children:pt(x.Out,{})}):Yn("div",{className:"App-toolbar-content",children:[pt(x.Out,{}),o.renderAction("toggleEditMenu"),o.renderAction(e.multiElement?"finalize":"duplicateSelection"),o.renderAction("deleteSelectedElements"),Yn("div",{children:[o.renderAction("undo"),o.renderAction("redo")]})]});return Yn(bz,{children:[c(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&E(),pt("div",{className:"App-bottom-bar",style:{marginBottom:eo+Vo*2,marginLeft:eo+Vo*2,marginRight:eo+Vo*2},children:Yn(st,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&fz(e,t)?pt(Ar,{className:"App-mobile-menu",heading:"selectedShapeActions",children:pt(Fm,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:o.renderAction,app:u})}):null,Yn("footer",{className:"App-toolbar",children:[y(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&pt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(T=>({...qr(t,T)}))},children:f("buttons.scrollBackToContent")})]})]})})]})};import xz,{useLayoutEffect as Ez,useRef as yz,useState as wz}from"react";import{jsx as Vs,jsxs as vz}from"react/jsx-runtime";var B5=e=>{let t=yz(null),[o,n]=wz(null);return Ez(()=>{if(!e.spreadsheet)return;let r=yw(e.chartType,e.spreadsheet,0,0);n(r);let i,a=t.current;return(async()=>(i=await Fi({data:{elements:r,appState:{exportBackground:!1,viewBackgroundColor:Np},files:null},config:{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]),Vs("button",{type:"button",className:"ChartPreview",onClick:()=>{o&&e.onClick(e.chartType,o)},children:Vs("div",{ref:t})})},O5=({setAppState:e,appState:t,onClose:o})=>{let{onInsertElements:n}=Ke(),r=xz.useCallback(()=>{o&&o()},[o]),i=(a,l)=>{n(l),ae("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Vs($e,{size:"small",onCloseRequest:r,title:f("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:vz("div",{className:"container",children:[Vs(B5,{chartType:"bar",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="bar",onClick:i}),Vs(B5,{chartType:"line",spreadsheet:t.pasteDialog.data,selected:t.currentChartType==="line",onClick:i})]})})};import*as Pr from"@radix-ui/react-popover";import F5 from"clsx";import Hp,{useLayoutEffect as Tz}from"react";import{supportsResizeObserver as Iz,isShallowEqual as Cz}from"@excalidraw/common";import{Fragment as Az,jsx as hn,jsxs as zp}from"react/jsx-runtime";var Sz=4,kz=8,Mz=({shouldWrap:e,children:t,username:o})=>e?hn(ro,{label:o||"Unknown user",children:t}):hn(Az,{children:t}),nb=({actionManager:e,collaborator:t,socketId:o,withName:n=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:o,collaborator:t,withName:n,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return hn(Mz,{username:t.username,shouldWrap:r,children:l},o)},Lz=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Gp=Hp.memo(({className:e,mobile:t,collaborators:o,userToFollow:n})=>{let r=nt(),i=new Map;o.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]=Hp.useState(""),c=a.filter(b=>b.username?.toLowerCase().includes(l)),d=Hp.useRef(null);Tz(()=>{if(d.current){let b=w=>{let E=Math.max(1,Math.min(8,Math.floor(w/38)));p(E)};if(b(d.current.clientWidth),!Iz)return;let x=new ResizeObserver(w=>{for(let E of w){let{width:y}=E.contentRect;b(y)}});return x.observe(d.current),()=>{x.disconnect()}}},[]);let[m,p]=Hp.useState(Sz),g=a.slice(0,m-1).map(b=>nb({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}));return t?hn("div",{className:F5("UserList UserList_mobile",e),children:a.map(b=>nb({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}))}):hn("div",{className:"UserList__wrapper",ref:d,children:zp("div",{className:F5("UserList",e),style:{"--max-avatars":m},children:[g,a.length>m-1&&zp(Pr.Root,{children:[zp(Pr.Trigger,{className:"UserList__more",children:["+",a.length-m+1]}),hn(Pr.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:zp(st,{padding:2,children:[a.length>=kz&&hn(Id,{placeholder:f("quickSearch.placeholder"),onChange:s}),hn(Cd,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:c.length>0?[hn("div",{className:"hint",children:f("userList.hint.text")}),c.map(b=>nb({actionManager:r,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===n}))]:[]}),hn(Pr.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,t)=>{if(e.collaborators.size!==t.collaborators.size||e.mobile!==t.mobile||e.className!==t.className||e.userToFollow!==t.userToFollow)return!1;let o=t.collaborators.keys();for(let[n,r]of e.collaborators){let i=t.collaborators.get(n);if(!i||n!==o.next().value||!Cz(r,i,Lz))return!1}return!0});import Up from"clsx";import{jsx as Pz}from"react/jsx-runtime";var H5=e=>Pz("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${f("helpDialog.title")} \u2014 ?`,"aria-label":f("helpDialog.title"),children:oi});import{jsx as fn,jsxs as rb}from"react/jsx-runtime";var z5=({appState:e,actionManager:t,showExitZenModeBtn:o,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i}=Ne(),a=me(),l=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return rb("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[fn("div",{className:Up("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:fn(ht.Col,{gap:2,children:rb(Ar,{heading:"canvasActions",children:[fn(aT,{renderAction:t.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&fn(lT,{renderAction:t.renderAction,className:Up("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),l&&fn(cT,{renderAction:t.renderAction,className:Up("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),fn(r.Out,{}),fn("div",{className:Up("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:rb("div",{style:{position:"relative"},children:[n&&fn(i.Out,{}),fn(H5,{onClick:()=>t.executeAction(gr)})]})}),fn(sT,{actionManager:t,showExitZenModeBtn:o})]})},G5=z5;z5.displayName="Footer";import Hz from"clsx";import{useEffect as J5,useLayoutEffect as Q5,useRef as ub,useState as zz,forwardRef as eC,useImperativeHandle as Gz,useCallback as Z5}from"react";import{EVENT as j5,isDevEnv as Uz,KEYS as Yz,updateObject as Wz}from"@excalidraw/common";import Dz from"clsx";import{useContext as Rz}from"react";import _z from"react";var Yp=_z.createContext({});import{jsx as ib,jsxs as U5}from"react/jsx-runtime";var ab=({children:e,className:t})=>{let o=me(),n=Rz(Yp),r=!!(o.editor.canFitSidebar&&n.shouldRenderDockButton);return U5("div",{className:Dz("sidebar__header",t),"data-testid":"sidebar-header",children:[e,U5("div",{className:"sidebar__header__buttons",children:[r&&ib(ro,{label:f("labels.sidebarLock"),children:ib(lo,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:ju})}),ib(lo,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":f("buttons.close"),children:no})]})]})};ab.displayName="SidebarHeader";import*as W5 from"@radix-ui/react-tabs";import{jsx as Y5}from"react/jsx-runtime";var lb=({children:e,tab:t,onSelect:o,...n})=>Y5(W5.Trigger,{value:t,asChild:!0,onSelect:o,children:Y5("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...n,children:e})});lb.displayName="SidebarTabTrigger";import*as V5 from"@radix-ui/react-tabs";import{jsx as Nz}from"react/jsx-runtime";var sb=({children:e,...t})=>Nz(V5.List,{className:"sidebar-triggers",...t,children:e});sb.displayName="SidebarTabTriggers";import Bz from"clsx";import{jsx as cb,jsxs as K5}from"react/jsx-runtime";var db=({name:e,tab:t,icon:o,title:n,children:r,onToggle:i,className:a,style:l})=>{let s=pe(),c=Te();return K5("label",{title:n,className:"sidebar-trigger__label-element",children:[cb("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:d=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let m=d.target.checked;s({openSidebar:m?{name:e,tab:t}:null}),i?.(m)},checked:c.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),K5("div",{className:Bz("sidebar-trigger",a),style:l,children:[o&&cb("div",{children:o}),r&&cb("div",{className:"sidebar-trigger__label",children:r})]})]})};db.displayName="SidebarTrigger";import*as X5 from"@radix-ui/react-tabs";import{jsx as Oz}from"react/jsx-runtime";var mb=({children:e,...t})=>{let o=Te(),n=pe();if(!o.openSidebar)return null;let{name:r}=o.openSidebar;return Oz(X5.Root,{className:"sidebar-tabs-root",value:o.openSidebar.tab,onValueChange:i=>n(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...t,children:e})};mb.displayName="SidebarTabs";import*as $5 from"@radix-ui/react-tabs";import{jsx as Fz}from"react/jsx-runtime";var pb=({tab:e,children:t,...o})=>Fz($5.Content,{...o,value:e,"data-testid":e,children:t});pb.displayName="SidebarTab";import{jsx as q5}from"react/jsx-runtime";import{createElement as Vz}from"react";var Ks=be(!1),tC=eC(({name:e,children:t,onDock:o,docked:n,className:r,...i},a)=>{Uz()&&o&&n==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=pe(),s=qn(Ks);Q5(()=>(s(!!n),()=>{s(!1)}),[s,n]);let c=ub({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>o?.(u),c.current=Wz(c.current,{docked:n,shouldRenderDockButton:!!o&&n!=null});let d=ub(null);Gz(a,()=>d.current);let m=me(),p=Z5(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return ea(d,Z5(u=>{u.target.closest(".sidebar-trigger")||(!n||!m.editor.canFitSidebar)&&p()},[p,n,m.editor.canFitSidebar])),J5(()=>{let u=g=>{g.key===Yz.ESCAPE&&(!n||!m.editor.canFitSidebar)&&p()};return document.addEventListener(j5.KEYDOWN,u),()=>{document.removeEventListener(j5.KEYDOWN,u)}},[p,n,m.editor.canFitSidebar]),q5(st,{...i,className:Hz("sidebar",{"sidebar--docked":n},r),ref:d,children:q5(Yp.Provider,{value:c.current,children:t})})});tC.displayName="SidebarInner";var Mo=Object.assign(eC((e,t)=>{let o=Te(),{onStateChange:n}=e,r=ub(o.openSidebar);J5(()=>{(!o.openSidebar&&r?.current?.name===e.name||o.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&o.openSidebar!==r.current&&n?.(o.openSidebar?.name!==e.name?null:o.openSidebar),r.current=o.openSidebar},[o.openSidebar,n,e.name]);let[i,a]=zz(!1);return Q5(()=>(a(!0),()=>a(!1)),[]),i&&o.openSidebar?.name===e.name?Vz(tC,{...e,ref:t,key:e.name}):null}),{Header:ab,TabTriggers:sb,TabTrigger:lb,Tabs:mb,Tab:pb,Trigger:db});Mo.displayName="Sidebar";import{composeEventHandlers as eG}from"@excalidraw/common";import{useLayoutEffect as Kz,useRef as Xz}from"react";import{jsx as $z}from"react/jsx-runtime";var Wn=(e,t)=>{let o=be(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=Ne(),[,a]=i(o),l=Xz({preferHost:!1,counter:0});return Kz(()=>{let s=l.current;return a(c=>{let d=c+1;return s.counter=d,d}),()=>{a(c=>{let d=c-1;return s.counter=d,d||(s.preferHost=!1),d})}},[a]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:$z(t,{...r})};return n.displayName=e,n};var fb={};yc(fb,{ChangeCanvasBackground:()=>hC,ClearCanvas:()=>uC,CommandPalette:()=>dC,Export:()=>fC,Help:()=>pC,LiveCollaborationTrigger:()=>xC,LoadScene:()=>lC,SaveAsImage:()=>cC,SaveToActiveFile:()=>sC,SearchMenu:()=>mC,Socials:()=>bC,ToggleTheme:()=>gC});import Jz from"clsx";import{THEME as _r}from"@excalidraw/common";var gb=be({active:!1});async function oC({title:e,description:t,actionLabel:o,color:n}){return new Promise(r=>{et.set(gb,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:t,actionLabel:o,color:n})})}import Zz from"clsx";import{jsx as nC,jsxs as jz}from"react/jsx-runtime";var Wp=function({onChange:e,value:t,choices:o,name:n}){return nC("div",{className:"RadioGroup",children:o.map(r=>jz("div",{className:Zz("RadioGroup__choice",{active:r.value===t}),title:r.ariaLabel,children:[nC("input",{name:n,type:"radio",checked:r.value===t,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as qz,jsx as hb,jsxs as rC}from"react/jsx-runtime";var iC=({value:e,shortcut:t,onChange:o,choices:n,children:r,name:i})=>{let a=me();return rC(qz,{children:[rC("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[hb("label",{className:"dropdown-menu-item__text",htmlFor:i,children:r}),hb(Wp,{name:i,value:e,onChange:o,choices:n})]}),t&&!a.editor.isMobile&&hb("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:t})]})};iC.displayName="DropdownMenuItemContentRadio";var aC=iC;import{Fragment as Qz,jsx as ut,jsxs as EC}from"react/jsx-runtime";var lC=()=>{let{t:e}=Je(),t=nt(),o=ir();return t.isActionEnabled(ui)?ut(At,{icon:ni,onSelect:async()=>{(!o.length||await oC({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:ut(_t,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>ut("strong",{children:r}),br:()=>ut("br",{})})}))&&t.executeAction(ui)},"data-testid":"load-button",shortcut:Xe("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};lC.displayName="LoadScene";var sC=()=>{let{t:e}=Je(),t=nt();return t.isActionEnabled(ur)?ut(At,{shortcut:Xe("saveScene"),"data-testid":"save-button",onSelect:()=>t.executeAction(ur),icon:mg,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};sC.displayName="SaveToActiveFile";var cC=()=>{let e=pe(),{t}=Je();return ut(At,{icon:Ll,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Xe("imageExport"),"aria-label":t("buttons.exportImage"),children:t("buttons.exportImage")})};cC.displayName="SaveAsImage";var dC=e=>{let t=pe(),{t:o}=Je();return ut(At,{icon:$i,"data-testid":"command-palette-button",onSelect:()=>{ae("command_palette","open","menu"),t({openDialog:{name:"commandPalette"}})},shortcut:Xe("commandPalette"),"aria-label":o("commandPalette.title"),className:e?.className,children:o("commandPalette.title")})};dC.displayName="CommandPalette";var mC=e=>{let{t}=Je(),o=nt();return ut(At,{icon:Gt,"data-testid":"search-menu-button",onSelect:()=>{o.executeAction(Ba)},shortcut:Xe("searchMenu"),"aria-label":t("search.title"),className:e?.className,children:t("search.title")})};mC.displayName="SearchMenu";var pC=()=>{let{t:e}=Je(),t=nt();return ut(At,{"data-testid":"help-menu-item",icon:oi,onSelect:()=>t.executeAction(gr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};pC.displayName="Help";var uC=()=>{let{t:e}=Je(),t=qn(Ei);return nt().isActionEnabled(rn)?ut(At,{icon:zt,onSelect:()=>t("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};uC.displayName="ClearCanvas";var gC=e=>{let{t}=Je(),o=Te(),n=nt(),r=Xe("toggleTheme");return n.isActionEnabled(dr)?e?.allowSystemTheme?ut(aC,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:_r.LIGHT,label:Wi,ariaLabel:`${t("buttons.lightMode")} - ${r}`},{value:_r.DARK,label:Yi,ariaLabel:`${t("buttons.darkMode")} - ${r}`},{value:"system",label:Ch,ariaLabel:t("buttons.systemMode")}],children:t("labels.theme")}):ut(At,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(o.theme===_r.DARK?_r.LIGHT:_r.DARK);else return n.executeAction(dr)},icon:o.theme===_r.DARK?Wi:Yi,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":o.theme===_r.DARK?t("buttons.lightMode"):t("buttons.darkMode"),children:o.theme===_r.DARK?t("buttons.lightMode"):t("buttons.darkMode")}):null};gC.displayName="ToggleTheme";var hC=()=>{let{t:e}=Je(),t=Te(),o=nt(),n=tn();return t.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:EC("div",{style:{marginTop:"0.5rem"},children:[ut("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),ut("div",{style:{padding:"0 0.625rem"},children:o.renderAction("changeViewBackgroundColor")})]})};hC.displayName="ChangeCanvasBackground";var fC=()=>{let{t:e}=Je(),t=pe();return ut(At,{icon:Qn,onSelect:()=>{t({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};fC.displayName="Export";var bC=()=>{let{t:e}=Je();return EC(Qz,{children:[ut(_a,{icon:kl,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),ut(_a,{icon:cg,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),ut(_a,{icon:sg,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};bC.displayName="Socials";var xC=({onSelect:e,isCollaborating:t})=>{let{t:o}=Je();return ut(At,{"data-testid":"collab-button",icon:Al,className:Jz({"active-collab":t}),onSelect:e,children:o("labels.liveCollaboration")})};xC.displayName="LiveCollaborationTrigger";import{jsx as Vp,jsxs as bb}from"react/jsx-runtime";var tG=Object.assign(Wn("MainMenu",({children:e,onSelect:t})=>{let{MainMenuTunnel:o}=Ne(),n=me(),r=Te(),i=pe(),a=n.editor.isMobile?void 0:()=>i({openMenu:null});return Vp(o.In,{children:bb(Ie,{open:r.openMenu==="canvas",children:[Vp(Ie.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Sl}),bb(Ie.Content,{onClickOutside:a,onSelect:eG(t,()=>{i({openMenu:null})}),children:[e,n.editor.isMobile&&r.collaborators.size>0&&bb("fieldset",{className:"UserList-Wrapper",children:[Vp("legend",{children:f("labels.collaborators")}),Vp(Gp,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Ie.Trigger,Item:Ie.Item,ItemLink:Ie.ItemLink,ItemCustom:Ie.ItemCustom,Group:Ie.Group,Separator:Ie.Separator,DefaultItems:fb}),Mt=tG;import oG from"clsx";import{forwardRef as nG,useState as rG}from"react";import{isPromiseLike as iG}from"@excalidraw/common";import{jsx as Kp,jsxs as aG}from"react/jsx-runtime";var Dr=nG(({children:e,icon:t,onClick:o,label:n,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:c},d)=>{let[m,p]=rG(!1),u=async b=>{let x=o?.(b);if(iG(x)){let w=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof Bi)console.warn(E);else throw E}finally{clearTimeout(w),p(!1)}}},g=m?"loading":c;return i=g==="success"?"success":i,Kp("button",{className:oG("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":n,ref:d,disabled:g==="loading"||g==="success",children:aG("div",{className:"ExcButton__contents",children:[g==="loading"?Kp(yt,{className:"ExcButton__statusIcon"}):g==="success"&&Kp("div",{className:"ExcButton__statusIcon",children:ah}),t&&Kp("div",{className:"ExcButton__icon","aria-hidden":!0,children:t}),r!=="icon"&&(e??n)]})})});import{jsx as tl,jsxs as cG}from"react/jsx-runtime";var Xp=({title:e,children:t,actionLabel:o,onClick:n})=>cG("div",{className:"OverwriteConfirm__Actions__Action",children:[tl("h4",{children:e}),tl("div",{className:"OverwriteConfirm__Actions__Action__content",children:t}),tl(Dr,{variant:"outlined",color:"muted",label:o,size:"large",fullWidth:!0,onClick:n})]}),lG=()=>{let{t:e}=Je(),t=nt(),o=pe();return tl(Xp,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{t.executeAction(Zd,"ui",!0),o({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},sG=()=>{let{t:e}=Je(),t=nt();return tl(Xp,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{t.executeAction(ha,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},xb=Object.assign(({children:e})=>tl("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:lG,SaveToDisk:sG});import{jsx as Rr,jsxs as yC}from"react/jsx-runtime";var $p=Object.assign(Wn("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:t}=Ne(),[o,n]=ce(gb);if(!o.active)return null;let r=()=>{o.onClose(),n(a=>({...a,active:!1}))},i=()=>{o.onConfirm(),n(a=>({...a,active:!1}))};return Rr(t.In,{children:Rr($e,{onCloseRequest:r,title:!1,size:916,children:yC("div",{className:"OverwriteConfirm",children:[Rr("h3",{children:o.title}),yC("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${o.color}`,children:[Rr("div",{className:"OverwriteConfirm__Description__icon",children:lh}),Rr("div",{children:o.description}),Rr("div",{className:"OverwriteConfirm__Description__spacer"}),Rr(Dr,{color:o.color,size:"large",label:o.actionLabel,onClick:i})]}),Rr(xb,{children:e})]})})})}),{Actions:xb,Action:Xp});import PG from"clsx";import{CANVAS_SEARCH_TAB as Tb,DEFAULT_SIDEBAR as _G,LIBRARY_SIDEBAR_TAB as AC,composeEventHandlers as DG}from"@excalidraw/common";import{round as dG}from"@excalidraw/math";import mG from"clsx";import pG from"lodash.debounce";import{Fragment as uG,memo as gG,useEffect as Xs,useMemo as wC,useRef as Eb,useState as vC}from"react";import{CLASSES as hG,EVENT as fG,FONT_FAMILY as yb,FRAME_STYLE as wb,getLineHeight as bG}from"@excalidraw/common";import{isElementCompletelyInViewport as xG}from"@excalidraw/element";import{measureText as $s}from"@excalidraw/element";import{KEYS as ol,randomInteger as TC,addEventListener as EG,getFontString as Zp}from"@excalidraw/common";import{newTextElement as yG}from"@excalidraw/element";import{isTextElement as kC,isFrameLikeElement as jp}from"@excalidraw/element";import{getDefaultFrameName as MC}from"@excalidraw/element/frame";import{Fragment as AG,jsx as bt,jsxs as bn}from"react/jsx-runtime";var wG=be(""),vb=be(null),vG=350,LC=()=>{let e=Ke(),t=pe(),o=Eb(null),[n,r]=ce(wG),i=n.trim(),[a,l]=vC(!1),[s,c]=vC({nonce:null,items:[]}),d=Eb(null),m=Eb(void 0),[p,u]=ce(vb),g=e.scene.getNonDeletedElementsMap();Xs(()=>{a||(i!==d.current||e.scene.getSceneNonce()!==m.current)&&(d.current=null,SC(i,e,(y,T)=>{c({nonce:TC(),items:y}),d.current=i,m.current=e.scene.getSceneNonce(),t({searchMatches:y.length?{focusedId:null,matches:y.map(v=>({id:v.element.id,focus:!1,matchedLines:v.matchedLines}))}:null})}))},[a,i,g,e,t,u,m]);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)};Xs(()=>{t(y=>y.searchMatches?{searchMatches:{focusedId:p!==null&&y.searchMatches?.matches[p]?.id||null,matches:y.searchMatches.matches.map((v,C)=>C===p?{...v,focus:!0}:{...v,focus:!1})}}:null)},[p,t]),Xs(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let T=e.state.zoom.value,v=yG({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:jp(y.element)?wb.nameFontSize:y.element.fontSize,fontFamily:jp(y.element)?yb.Assistant:y.element.fontFamily}),C=14,M=v.fontSize,k=M*T<C;if(!xG([v],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||k){let P;k?M>=C?P={fitToContent:!0}:P={fitToViewport:!0,maxZoom:dG(C/M,1)}:P={fitToContent:!0},e.scrollToContent(v,{animate:!0,duration:300,...P,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),Xs(()=>()=>{u(null),d.current=null,m.current=void 0,t({searchMatches:null}),l(!1)},[t,u]);let w=or({goToNextItem:b,goToPreviousItem:x,searchMatches:s});Xs(()=>{let y=T=>{if(T.key===ol.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){T.preventDefault(),T.stopPropagation(),t({openSidebar:null});return}if(T[ol.CTRL_OR_CMD]&&T.key===ol.F){if(T.preventDefault(),T.stopPropagation(),e.state.openDialog)return;o.current?.matches(":focus")||(e.state.openDialog&&t({openDialog:null}),o.current?.focus(),o.current?.select())}T.target instanceof HTMLElement&&T.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(T.key===ol.ENTER&&(T.stopPropagation(),w.goToNextItem()),T.key===ol.ARROW_UP?(T.stopPropagation(),w.goToPreviousItem()):T.key===ol.ARROW_DOWN&&(T.stopPropagation(),w.goToNextItem()))};return EG(window,fG.KEYDOWN,y,{capture:!0,passive:!1})},[t,w,e]);let E=`${s.items.length} ${s.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return bn("div",{className:"layer-ui__search",children:[bt("div",{className:"layer-ui__search-header",children:bt(Na,{className:hG.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:o,placeholder:f("search.placeholder"),icon:Gt,onChange:y=>{r(y),l(!0);let T=y.trim();SC(T,e,(v,C)=>{c({nonce:TC(),items:v}),u(C),d.current=T,m.current=e.scene.getSceneNonce(),t({searchMatches:v.length?{focusedId:null,matches:v.map(M=>({id:M.element.id,focus:!1,matchedLines:M.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),bn("div",{className:"layer-ui__search-count",children:[s.items.length>0&&bn(AG,{children:[p!==null&&p>-1?bn("div",{children:[p+1," / ",E]}):bt("div",{children:E}),bn("div",{className:"result-nav",children:[bt(lo,{onSelect:()=>{b()},className:"result-nav-btn",children:zl}),bt(lo,{onSelect:()=>{x()},className:"result-nav-btn",children:Ah})]})]}),s.items.length===0&&i&&d.current&&bt("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),bt(CG,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},IC=e=>{let t=[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 bt("div",{tabIndex:-1,className:mG("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:o=>{e.highlighted&&o?.scrollIntoView({behavior:"auto",block:"nearest"})},children:bt("div",{className:"preview-text",children:t.flatMap((o,n)=>bt(uG,{children:n===2?bt("b",{children:o}):o},n))})})},TG=e=>{let t=wC(()=>e.matches.items.filter(n=>jp(n.element)),[e.matches]),o=wC(()=>e.matches.items.filter(n=>kC(n.element)),[e.matches]);return bn("div",{children:[t.length>0&&bn("div",{className:"layer-ui__search-result-container",children:[bn("div",{className:"layer-ui__search-result-title",children:[bt("div",{className:"title-icon",children:tr}),bt("div",{children:f("search.frames")})]}),t.map((n,r)=>bt(IC,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),o.length>0&&bt("div",{className:"layer-ui__divider"})]}),o.length>0&&bn("div",{className:"layer-ui__search-result-container",children:[bn("div",{className:"layer-ui__search-result-title",children:[bt("div",{className:"title-icon",children:ti}),bt("div",{children:f("search.texts")})]}),o.map((n,r)=>bt(IC,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+t.length===e.focusIndex,onClick:()=>e.onItemClick(r+t.length)},n.element.id+n.index))]})]})},IG=(e,t)=>e.matches.nonce===t.matches.nonce&&e.focusIndex===t.focusIndex,CG=gG(TG,IG),CC=(e,t,o)=>{let i=e.slice(0,t),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),c=a.slice(s<=0?0:s).join(" ")+(l?" ":""),d=20;c=c.length>d?c.slice(-d):c;let m=e.slice(t+o.length),p=m.split(/\s+/),u=!m.startsWith(" "),g=u?6:5,b=(u?"":" ")+p.slice(0,g).join(" ");return{indexInSearchQuery:c.length,previewText:c+o+b,moreBefore:s>0,moreAfter:p.length>g}},SG=(e,t)=>{let o=e.split(`
|
|
34
|
+
`),n=[],r=0;for(let i=0;i<o.length;i++){let a=o[i],l=o[i+1];if(l){let s=t.indexOf(l,r);if(s>a.length+r){let c=s-(a.length+r);for(;c>0;)a+=" ",c--}}n.push(a),r=r+a.length}return n.join(`
|
|
35
|
+
`)},kG=(e,t,o)=>{let r=SG(e.text,e.originalText).split(`
|
|
36
|
+
`),i=[],a=0,l=0;for(let m of r){let p=a,u=p+m.length-1;i.push({line:m,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=o,c=e.originalText.slice(o,o+t.length),d=[];for(let m of i){if(c==="")break;if(s>=m.startIndex&&s<=m.endIndex){let p=m.endIndex+1-s,u=m.line.slice(0,s-m.startIndex),g=c.slice(0,p);c=c.slice(p);let b=$s(u,Zp(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&m.line.length>0){let T=$s(m.line,Zp(e),e.lineHeight),v=e.textAlign==="center"?(e.width-T.width)/2:e.width-T.width;b.width+=v}let{width:x,height:w}=$s(g,Zp(e),e.lineHeight),E=b.width,y=m.lineNumber*b.height;d.push({offsetX:E,offsetY:y,width:x,height:w,showOnCanvas:!0}),s+=p}}return d},MG=(e,t,o,n)=>{let r=e.name??MC(e),i=r.slice(o,o+t.length),a=r.slice(0,o),l=Zp({fontSize:wb.nameFontSize,fontFamily:yb.Assistant}),s=bG(yb.Assistant),c=$s(a,l,s);a===""&&(c.width=0);let d=$s(i,l,s),m=c.width,p=-c.height-wb.strokeWidth,u=d.width;return[{offsetX:m,offsetY:p,width:u,height:d.height,showOnCanvas:m+u<=e.width*n}]},LG=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),SC=pG((e,t,o)=>{if(!e||e===""){o([],null);return}let n=t.scene.getNonDeletedElements(),r=n.filter(p=>kC(p)),i=n.filter(p=>jp(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(LG(e),"gi");for(let p of r){let u=null,g=p.originalText;for(;(u=l.exec(g))!==null;){let b=CC(g,u.index,e),x=kG(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,g=p.name??MC(p);for(;(u=l.exec(g))!==null;){let b=CC(g,u.index,e),x=MG(p,e,u.index,t.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let c=new Set(t.visibleElements.map(p=>p.id)),d=[...s,...a],m=d.findIndex(p=>c.has(p.element.id))??null;o(d,m)},vG);import{jsx as $o,jsxs as PC}from"react/jsx-runtime";import{createElement as RG}from"react";var _C=Wn("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:t}=Ne();return $o(t.In,{children:$o(Mo.Trigger,{...e,className:"default-sidebar-trigger",name:_G.name})})});_C.displayName="DefaultSidebarTrigger";var DC=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:t}=Ne();return $o(t.In,{children:e})};DC.displayName="DefaultTabTriggers";var qp=Object.assign(Wn("DefaultSidebar",({children:e,className:t,onDock:o,docked:n,...r})=>{let i=Te(),a=pe(),{DefaultSidebarTabTriggersTunnel:l}=Ne(),s=i.openSidebar?.tab===Tb;return RG(Mo,{...r,name:"default",key:"default",className:PG("default-sidebar",t),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||o===!1||!o&&n!=null?void 0:DG(o,c=>{a({defaultSidebarDockedPreference:c})})},PC(Mo.Tabs,{children:[$o(Mo.Header,{children:PC(Mo.TabTriggers,{children:[$o(Mo.TabTrigger,{tab:Tb,children:Gt}),$o(Mo.TabTrigger,{tab:AC,children:Qr}),$o(l.Out,{})]})}),$o(Mo.Tab,{tab:AC,children:$o($v,{})}),$o(Mo.Tab,{tab:Tb,children:$o(LC,{})}),e]}))}),{Trigger:_C,TabTriggers:DC});import{useEffect as eU,useRef as Sb,useState as lu}from"react";import{isFiniteNumber as tS}from"@excalidraw/math";import{useState as GC,useRef as UC,useEffect as YC,useDeferredValue as YG}from"react";import{EDITOR_LS_KEYS as WG,debounce as VG,isDevEnv as KG}from"@excalidraw/common";import{useEffect as NG,useRef as RC}from"react";import{EVENT as NC,KEYS as BC}from"@excalidraw/common";import{jsx as BG}from"react/jsx-runtime";var Jp=({input:e,placeholder:t,onChange:o,onKeyboardSubmit:n})=>{let r=RC(null),i=RC(n);return i.current=n,NG(()=>{if(!i.current)return;let a=r.current;if(a){let l=s=>{s[BC.CTRL_OR_CMD]&&s.key===BC.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(NC.KEYDOWN,l),()=>{a.removeEventListener(NC.KEYDOWN,l)}}},[]),BG("textarea",{className:"ttd-dialog-input",onChange:o,value:e,placeholder:t,ref:r})};import{jsx as Qp,jsxs as OC}from"react/jsx-runtime";var OG=({error:e})=>OC("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Qp("p",{children:e})]}),eu=({error:e,canvasRef:t,loaded:o})=>OC("div",{className:"ttd-dialog-output-wrapper",children:[e&&Qp(OG,{error:e.message}),o?Qp("div",{ref:t,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Qp(yt,{size:"2rem"})]});import FC from"clsx";import{jsx as Ib,jsxs as Zs}from"react/jsx-runtime";var nl=({label:e,children:t,panelAction:o,panelActionDisabled:n=!1,onTextSubmitInProgess:r,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>Zs("div",{className:"ttd-dialog-panel",children:[Zs("div",{className:"ttd-dialog-panel__header",children:[Ib("label",{children:e}),i?.()]}),t,Zs("div",{className:FC("ttd-dialog-panel-button-container",{invisible:!o}),style:{display:"flex",alignItems:"center"},children:[Zs(lo,{className:"ttd-dialog-panel-button",onSelect:o?o.action:()=>{},disabled:n||r,children:[Zs("div",{className:FC({invisible:r}),children:[o?.label,o?.icon&&Ib("span",{children:o.icon})]}),r&&Ib(yt,{})]}),!n&&!r&&a?.(),l?.()]})]});import{jsx as FG}from"react/jsx-runtime";var tu=({children:e})=>FG("div",{className:"ttd-dialog-panels",children:e});import{getShortcutKey as HC}from"@excalidraw/common";import{jsx as zC,jsxs as HG}from"react/jsx-runtime";var ou=()=>HG("div",{className:"ttd-dialog-submit-shortcut",children:[zC("div",{className:"ttd-dialog-submit-shortcut__key",children:HC("CtrlOrCmd")}),zC("div",{className:"ttd-dialog-submit-shortcut__key",children:HC("Enter")})]});import{DEFAULT_EXPORT_PADDING as zG,EDITOR_LS_KEYS as GG}from"@excalidraw/common";var UG=({canvasRef:e,setError:t})=>{let o=e.current;if(!o)return;let n=o.parentElement;n&&(n.style.background="",t(null),o.replaceChildren())},nu=async({canvasRef:e,mermaidToExcalidrawLib:t,mermaidDefinition:o,setError:n,data:r})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!o){UG({canvasRef:e,setError:n});return}try{let l=await t.api,s;try{s=await l.parseMermaidToExcalidraw(o)}catch{s=await l.parseMermaidToExcalidraw(o.replace(/"/g,"'"))}let{elements:c,files:d}=s;n(null),r.current={elements:Ja(c,{regenerateIds:!0}),files:d};let m=await jn({data:{elements:r.current.elements,files:r.current.files},config:{padding:zG,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio}});try{await wn(m)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(m)}catch(l){throw a.style.background="var(--default-bg-color)",o&&n(l),l}}},js=e=>{xo.set(GG.MERMAID_TO_EXCALIDRAW,e)},ru=({app:e,data:t,text:o,shouldSaveMermaidDataToStorage:n})=>{let{elements:r,files:i}=t.current;r.length&&(e.addElementsFromPasteOrLibrary({elements:r,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),n&&o&&js(o))};import{Fragment as ZG,jsx as xn,jsxs as VC}from"react/jsx-runtime";var XG=`flowchart TD
|
|
24
37
|
A[Christmas] -->|Get money| B(Go shopping)
|
|
25
38
|
B --> C{Let me think}
|
|
26
39
|
C -->|One| D[Laptop]
|
|
27
40
|
C -->|Two| E[iPhone]
|
|
28
|
-
C -->|Three| F[Car]`,
|
|
29
|
-
TTD mermaid definition render errror: ${P.message}`,"color: yellow"),ye("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let _=S.message;(!_||_==="Failed to fetch")&&(_="Request failed"),C(new Error(_))}finally{p(!1)}},x=U1(b);x.current=b;let[E,w]=Bp({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});bL(()=>{(async()=>{await E.api,w(_=>({..._,loaded:!0}))})()},[E.api]);let y=U1({elements:[],files:null}),[v,C]=Bp(null);return jt(dt,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Un(a5,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?jt("p",{className:"dialog-mermaid-title",children:f("mermaid.title")}):Un(H1,{children:[jt(Np,{tab:"text-to-diagram",children:Un("div",{style:{display:"flex",alignItems:"center"},children:[f("labels.textToDiagram"),jt("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"})]})}),jt(Np,{tab:"mermaid",children:"Mermaid"})]}),jt(Op,{className:"ttd-dialog-content",tab:"mermaid",children:jt(o5,{mermaidToExcalidrawLib:E})}),!("__fallback"in o)&&Un(Op,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[jt("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."}),Un(_p,{children:[jt(ol,{label:f("labels.prompt"),panelAction:{action:b,label:"Generate",icon:Ci},onTextSubmitInProgess:d,panelActionDisabled:c.length>rl||u?.rateLimitRemaining===0,renderTopRight:()=>u?Un("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:()=>jt(Dp,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Un("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(Hs(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",jt(kn,{icon:Ci})]});let S=c.length/rl;return S>.8?Un("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",rl]}):null},children:jt(Mp,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),jt(ol,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Rp({app:t,data:y})},label:"Insert",icon:Ci},children:jt(Ap,{canvasRef:n,error:v,loaded:E.loaded})})]})]})]})})});import d7 from"clsx";import m7 from"lodash.throttle";import{useEffect as C5,useMemo as $1,useState as p7,memo as u7}from"react";import vL from"clsx";import{useEffect as p5,useRef as Fp,useState as wL}from"react";var m5=.01,ho=(e,o)=>!(o==="height"&&Z(e)||o==="width"&&Z(e)||o==="angle"&&ae(e)),qe=(e,o)=>{let t=e+o/2;return t-t%o},nl=(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 zi=(e,o,t,r,n,i,a,l=!0)=>{let s=r.get(t.id);if(!s)return;let[c,m]=[t.x+t.width/2,t.y+t.height/2],[d,p]=de(M(t.x,t.y),M(c,m),t.angle),u=e-d,g=o-p,[b,x]=de(M(e,o),M(c+u,m+g),-t.angle);B(s,{x:b,y:x},l),zp(s,r,n,i);let E=be(t,a);if(E){let w=r.get(E.id);w&&B(w,{x:E.x+u,y:E.y+g},l)}},il=(e,o)=>{let r=$o(o).map(n=>Fe(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!cr(n)).forEach(n=>{r.push({[n.id]:!0})}),r},zp=(e,o,t,r,n)=>{le(e)?si([e],o,t,r,!0,[],n?.zoom):at(e,o,n)};import{jsx as Y1,jsxs as CL}from"react/jsx-runtime";var TL=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:m=1})=>{let d=st(),p=Fp(null),u=Fp(null),[g,b]=wL(r.toString()),x=Fp(null);x.current||(x.current={originalAppState:no(c),originalElements:n,lastUpdatedValue:g,updatePending:!1}),p5(()=>{let y=r.toString();b(y),x.current.lastUpdatedValue=y},[r]);let E=(y,v,C)=>{if(!x.current.updatePending)return!1;x.current.updatePending=!1;let S=Number(y);if(isNaN(S)){b(r.toString());return}let _=Number(S.toFixed(2)),L=Number(r);(isNaN(L)||Math.abs(_-L)>=m5)&&(x.current.lastUpdatedValue=y,t({accumulatedChange:0,instantChange:0,originalElements:v,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:_,property:l,originalAppState:C,setInputValue:N=>b(String(N))}),d.syncActionResult({captureUpdate:A.IMMEDIATELY}))},w=Fp({});return w.current.handleInputValue=E,p5(()=>{let y=p.current,v=w.current;return()=>{let C=y?.value;C&&v.handleInputValue?.(C,x.current.originalElements,x.current.originalAppState),window.removeEventListener("pointermove",v.onPointerMove,!1),window.removeEventListener("pointerup",v.onPointerUp,!1)}},[i]),i?CL("div",{className:vL("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Y1("div",{className:"drag-input-label",ref:u,onPointerDown:y=>{if(p.current&&i){document.body.classList.add("excalidraw-cursor-resize");let v=Number(p.current.value);isNaN(v)&&(v=0);let C=null,S=d.scene.getNonDeletedElements().reduce((U,q)=>(U.set(q.id,xo(q)),U),new Map),_=n.map(U=>S.get(U.id)),L=no(c),N=0,P=0,z=U=>{if(C&&S!==null&&_!==null){let q=U.clientX-C.x;q!==0&&(P+=q,Math.abs(P)>=m&&(P=Math.sign(P)*Math.floor(Math.abs(P)/m),N+=P,t({accumulatedChange:N,instantChange:P,originalElements:_,originalElementsMap:S,shouldKeepAspectRatio:a,shouldChangeByStepSize:U.shiftKey,property:l,scene:s,originalAppState:L,setInputValue:H=>b(String(H))}),P=0))}C={x:U.clientX,y:U.clientY}},W=()=>{window.removeEventListener("pointermove",z,!1),d.syncActionResult({captureUpdate:A.IMMEDIATELY}),C=null,N=0,P=0,_=null,S=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener("pointerup",W,!1)};w.current.onPointerMove=z,w.current.onPointerUp=W,window.addEventListener("pointermove",z,!1),window.addEventListener("pointerup",W,!1)}},onPointerEnter:()=>{u.current&&(u.current.style.cursor="ew-resize")},children:o?Y1(kn,{icon:o}):e}),Y1("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:y=>{if(i){let v=y.target;v instanceof HTMLInputElement&&y.key===T.ENTER&&(E(v.value,n,c),d.focusContainer())}},ref:p,value:g,onChange:y=>{x.current.updatePending=!0,b(y.target.value)},onFocus:y=>{y.target.select(),x.current.originalElements=n,x.current.originalAppState=no(c)},onBlur:y=>{g?i&&E(y.target.value,x.current.originalElements,x.current.originalAppState):b(r.toString())},disabled:!i})]}):null},St=TL;import{jsx as ML}from"react/jsx-runtime";var IL=15,SL=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=n.getNonDeletedElements(),l=o[0];if(l&&!oe(l)){let s=i.get(l.id);if(!s)return;if(r!==void 0){let g=Vi(r);B(s,{angle:g}),zp(s,i,a,n);let b=be(s,i);b&&!ke(s)&&B(b,{angle:g});return}let c=Math.round(Yi(l.angle)*100)/100,m=Math.round(e),d=(c+m)%360;t&&(d=qe(d,IL)),d=d<0?d+360:d;let p=Vi(d);B(s,{angle:p}),zp(s,i,a,n);let u=be(s,i);u&&!ke(s)&&B(u,{angle:p})}},kL=({element:e,scene:o,appState:t,property:r})=>ML(St,{label:"A",icon:Jl,value:Math.round(Yi(e.angle)%360*100)/100,elements:[e],dragInputCallback:SL,editable:ho(e,"angle"),scene:o,appState:t,property:r}),u5=kL;import{jsx as AL}from"react/jsx-runtime";var h5=5,LL=({property:e,scene:o,appState:t,setAppState:r})=>AL(St,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{r(s=>{let c;return n?c=n:i&&(c=a?qe(s.gridStep+h5*Math.sign(i),h5):s.gridStep+i),c?(c=qx(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),g5=LL;import{jsx as RL}from"react/jsx-runtime";var f5=10,_L=e=>e.type==="image",DL=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:c})=>{let m=c.getNonDeletedElementsMap(),d=o[0],p=m.get(d.id);if(d&&p){let u=r||_L(d),g=d.width/d.height;if(l.croppingElementId===d.id){let y=m.get(d.id);if(!y||!fe(y)||!y.crop)return;let v=y.crop,C={...v},S=y.scale[0]===-1,_=y.scale[1]===-1,{width:L,height:N}=pi(y),P=v.naturalWidth/L,z=v.naturalHeight/N,W=S?v.width+v.x:v.naturalWidth-v.x,U=_?v.height+v.y:v.naturalHeight-v.y,q=Nu*P,H=Nu*z;if(i!==void 0){if(a==="width"){let ie=i*P,he=Ct(ie,q,W);C={...C,width:he,x:S?v.x+v.width-he:v.x}}else if(a==="height"){let ie=i*z,he=Ct(ie,H,U);C={...C,height:he,y:_?v.y+v.height-he:v.y}}B(y,{crop:C,width:C.width/(v.naturalWidth/L),height:C.height/(v.naturalHeight/N)});return}let V=a==="width"?s:0,K=a==="height"?s:0,Q=Ct(v.width+V,q,W),X=Ct(v.height+K,q,U);C={...v,x:S?v.x+v.width-Q:v.x,y:_?v.y+v.height-X:v.y,width:Q,height:X},B(y,{crop:C,width:C.width/(v.naturalWidth/L),height:C.height/(v.naturalHeight/N)});return}if(i!==void 0){let y=Math.max(a==="width"?i:u?i*g:d.width,ro),v=Math.max(a==="height"?i:u?i/g:d.height,ro);xi(y,v,p,d,m,t,a==="width"?"e":"s",{shouldMaintainAspectRatio:u});return}let b=a==="width"?e:0,x=a==="height"?e:0,E=Math.max(0,d.width+b);a==="width"&&(n?E=qe(E,f5):E=Math.round(E));let w=Math.max(0,d.height+x);a==="height"&&(n?w=qe(w,f5):w=Math.round(w)),u&&(a==="width"?w=Math.round(E/g*100)/100:E=Math.round(w*g*100)/100),w=Math.max(ro,w),E=Math.max(ro,E),xi(E,w,p,d,m,t,a==="width"?"e":"s",{shouldMaintainAspectRatio:u})}},PL=({property:e,element:o,scene:t,appState:r})=>{let n=Lo(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&fe(o)&&o.crop){let{width:i,height:a}=pi(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=Lo(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=Lo(o.crop.height*l,2)}}return RL(St,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:DL,value:n,editable:ho(o,e),scene:t,appState:r,property:e})},W1=PL;import{jsx as zL}from"react/jsx-runtime";var b5=4,NL=4,OL=({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||!Z(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),b5);else if(a.type==="text"){let c=Math.round(a.fontSize),m=Math.round(e);s=Math.max(c+m,b5),t&&(s=qe(s,NL))}s&&(B(l,{fontSize:s}),et(l,n.getContainerElement(l),n.getNonDeletedElementsMap()))}},BL=({element:e,scene:o,appState:t,property:r})=>{let n=Z(e)?e:pt(e)?be(e,o.getNonDeletedElementsMap()):null;return n?zL(St,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:OL,icon:vn,appState:t,scene:o,property:r}):null},x5=BL;import{jsx as GL}from"react/jsx-runtime";var FL=15,HL=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(c=>a.get(c.id)).filter(c=>c&&!cr(c)&&ho(c,n)),s=o.filter(c=>!cr(c)&&ho(c,n));if(r!==void 0){let c=Vi(r);for(let m of l){if(!m)continue;B(m,{angle:c},!1);let d=be(m,a);d&&!ke(m)&&B(d,{angle:c},!1)}i.triggerUpdate();return}for(let c=0;c<l.length;c++){let m=l[c];if(!m)continue;let d=s[c],p=Math.round(Yi(d.angle)*100)/100,u=Math.round(e),g=(p+u)%360;t&&(g=qe(g,FL)),g=g<0?g+360:g;let b=Vi(g);B(m,{angle:b},!1);let x=be(m,a);x&&!ke(m)&&B(x,{angle:b},!1)}i.triggerUpdate()},UL=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!cr(s)&&ho(s,"angle")),i=n.map(s=>Math.round(Yi(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>ho(s,"angle"));return GL(St,{label:"A",icon:Jl,value:a,elements:e,dragInputCallback:HL,editable:l,appState:t,scene:o,property:r})},E5=UL;import{useMemo as VL}from"react";import{jsx as XL}from"react/jsx-runtime";var al=10,YL=(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,c=o+i*t;return{width:a,height:l,x:s,y:c,...pd(r,a,l,!1),...Z(r)?{fontSize:r.fontSize*t}:{}}},WL=(e,o,t,r,n,i,a,l)=>{let s=YL(e,o,r,i);B(n,s,!1);let c=be(i,l);if(c){let m=c.fontSize*r;at(n,a,{newSize:{width:s.width,height:s.height}});let d=a.get(c.id);d&&Z(d)&&(B(d,{fontSize:m},!1),kl(n,a,t==="width"?"e":"s",!0))}},y5=(e,o,t,r,n,i,a,l,s,c)=>{i==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let m=o/t;for(let d=0;d<l.length;d++){let p=l[d],u=a[d];WL(n[0],n[1],i,m,u,p,s,c)}},KL=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l})=>{let s=a.getNonDeletedElementsMap(),c=il(o,r);if(i!==void 0){for(let p of c){let u=nl(p,s,t);if(u.length>1){let g=u.map(N=>N.latest),b=u.map(N=>N.original),[x,E,w,y]=ve(b),v=w-x,C=y-E,S=v/C,_=Math.max(ro,l==="width"?Math.max(0,i):v),L=Math.max(ro,l==="height"?Math.max(0,i):C);y5(_,L,C,S,M(x,E),l,g,b,s,t)}else{let[g]=u,b=g?.latest,x=g?.original;if(b&&x&&ho(b,l)){let E=l==="width"?Math.max(0,i):b.width;l==="width"&&(n?E=qe(E,al):E=Math.round(E));let w=l==="height"?Math.max(0,i):b.height;l==="height"&&(n?w=qe(w,al):w=Math.round(w)),E=Math.max(ro,E),w=Math.max(ro,w),xi(E,w,b,x,s,t,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate();return}let m=l==="width"?e:0,d=l==="height"?e:0;for(let p of c){let u=nl(p,s,t);if(u.length>1){let g=u.map(N=>N.latest),b=u.map(N=>N.original),[x,E,w,y]=ve(b),v=w-x,C=y-E,S=v/C,_=Math.max(0,v+m);l==="width"&&(n?_=qe(_,al):_=Math.round(_));let L=Math.max(0,C+d);l==="height"&&(n?L=qe(L,al):L=Math.round(L)),_=Math.max(ro,_),L=Math.max(ro,L),y5(_,L,C,S,M(x,E),l,g,b,s,t)}else{let[g]=u,b=g?.latest,x=g?.original;if(b&&x&&ho(b,l)){let E=Math.max(0,x.width+m);l==="width"&&(n?E=qe(E,al):E=Math.round(E));let w=Math.max(0,x.height+d);l==="height"&&(n?w=qe(w,al):w=Math.round(w)),E=Math.max(ro,E),w=Math.max(ro,w),xi(E,w,b,x,s,t,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate()},ZL=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=VL(()=>r.map(c=>{let m=nl(c,t);if(m.length>1){let[p,u,g,b]=ve(m.map(x=>x.latest));return Math.round((e==="width"?g-p:b-u)*100)/100}let[d]=m;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 XL(St,{label:e==="width"?"W":"H",elements:o,dragInputCallback:KL,value:l,editable:s,appState:i,property:e,scene:n})},K1=ZL;import{jsx as QL}from"react/jsx-runtime";var v5=4,$L=4,jL=(e,o)=>e.reduce((t,r)=>{if(!r||cr(r))return t;if(Z(r))return t.push(r),t;if(pt(r)){let n=be(r,o);if(n)return t.push(n),t}return t},[]),qL=({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),v5);for(let s of a)B(s,{fontSize:l},!1),et(s,n.getContainerElement(s),i,!1);n.triggerUpdate()}else{let s=o;for(let c=0;c<a.length;c++){let m=a[c],d=s[c],p=Math.round(d.fontSize),u=Math.round(e),g=Math.max(p+u,v5);t&&(g=qe(g,$L)),B(m,{fontSize:g},!1),et(m,n.getContainerElement(m),i,!1)}n.triggerUpdate()}},JL=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=jL(e,n);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return QL(St,{label:"F",icon:vn,elements:i,dragInputCallback:qL,value:l,editable:s,scene:o,property:r,appState:t})},w5=JL;import{useMemo as e7}from"react";import{jsx as a7}from"react/jsx-runtime";var t7=10,o7=(e,o,t,r,n,i,a,l)=>{for(let s=0;s<r.length;s++){let c=n[s],[m,d]=[c.x+c.width/2,c.y+c.height/2],[p,u]=de(M(c.x,c.y),M(m,d),c.angle),g=e==="x"?Math.round(p+o):p,b=e==="y"?Math.round(u+t):u;zi(g,b,c,i,r,l,a,!1)}},r7=(e,o,t,r,n,i,a)=>{let[l,s,,]=ve(t),c=e-l,m=o-s;for(let d=0;d<t.length;d++){let p=t[d],u=r.get(p.id);if(u&&(!Z(u)||!u.containerId)){let[g,b]=[u.x+u.width/2,u.y+u.height/2],[x,E]=de(M(u.x,u.y),M(g,b),u.angle);zi(x+c,E+m,p,r,n,a,i,!1)}}},n7=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap(),c=a.getNonDeletedElements();if(n!==void 0){for(let u of il(o,l)){let g=nl(u,s,t);if(g.length>1){let[b,x,,]=ve(g.map(y=>y.latest));r7(i==="x"?n:b,i==="y"?n:x,g.map(y=>y.original),s,c,t,a)}else{let b=g[0]?.original,x=g[0]?.latest;if(b&&x&&ho(x,i)){let[E,w]=[b.x+b.width/2,b.y+b.height/2],[y,v]=de(M(b.x,b.y),M(E,w),b.angle);zi(i==="x"?n:y,i==="y"?n:v,b,s,c,a,t,!1)}}}a.triggerUpdate();return}let m=r?qe(e,t7):e;o7(i,i==="x"?m:0,i==="y"?m:0,o,o,s,t,a),a.triggerUpdate()},i7=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=e7(()=>r.map(s=>{let c=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(c.length>1){let[b,x]=ve(c);return Math.round((e==="x"?b:x)*100)/100}let[m]=c,[d,p]=[m.x+m.width/2,m.y+m.height/2],[u,g]=de(M(m.x,m.y),M(d,p),m.angle);return Math.round((e==="x"?u:g)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return a7(St,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:n7,value:l,property:e,scene:n,appState:i})},Z1=i7;import{jsx as c7}from"react/jsx-runtime";var T5=10,l7=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let c=l.getNonDeletedElementsMap(),m=l.getNonDeletedElements(),d=t[0],[p,u]=[d.x+d.width/2,d.y+d.height/2],[g,b]=de(M(d.x,d.y),M(p,u),d.angle);if(s.croppingElementId===d.id){let v=c.get(d.id);if(!v||!fe(v)||!v.crop)return;let C=v.crop,S=C,_=v.scale[0]===-1,L=v.scale[1]===-1,{width:N,height:P}=pi(v);if(i!==void 0){if(a==="x"){let U=i*(C.naturalWidth/N);_?S={...C,x:Ct(C.naturalWidth-U-C.width,0,C.naturalWidth-C.width)}:S={...C,x:Ct(i*(C.naturalWidth/N),0,C.naturalWidth-C.width)}}a==="y"&&(S={...C,y:Ct(i*(C.naturalHeight/P),0,C.naturalHeight-C.height)}),B(v,{crop:S});return}let z=(a==="x"?o:0)*(_?-1:1),W=(a==="y"?o:0)*(L?-1:1);S={...C,x:Ct(C.x+z,0,C.naturalWidth-C.width),y:Ct(C.y+W,0,C.naturalHeight-C.height)},B(v,{crop:S});return}if(i!==void 0){zi(a==="x"?i:g,a==="y"?i:b,d,c,m,l,r);return}let x=a==="x"?e:0,E=a==="y"?e:0,w=a==="x"?Math.round(n?qe(d.x+x,T5):g+x):g,y=a==="y"?Math.round(n?qe(d.y+E,T5):b+E):b;zi(w,y,d,c,m,l,r)},s7=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=de(M(o.x,o.y),M(o.x+o.width/2,o.y+o.height/2),o.angle),l=Lo(e==="x"?i:a,2);if(n.croppingElementId===o.id&&fe(o)&&o.crop){let s=Rx(o);s&&(l=Lo(e==="x"?s.x:s.y,2))}return c7(St,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:l7,scene:r,value:l,property:e,appState:n})},X1=s7;import{Fragment as j1,jsx as se,jsxs as go}from"react/jsx-runtime";var h7=50,Us=e=>{let o=ur(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=Nn(e.app);return se(g7,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},Xe=({children:e,columns:o=1,heading:t,style:r,...n})=>se("div",{className:d7("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});Xe.displayName="StatsRow";var Hp=({children:e,order:o,style:t,...r})=>se("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});Hp.displayName="StatsRows";Us.StatsRow=Xe;Us.StatsRows=Hp;var g7=u7(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),m=Ie(),d=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&fe(d),g=u?pi(d):null,[b,x]=p7({width:0,height:0}),E=$1(()=>m7(v=>{let C=ve(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},h7),[]);C5(()=>{E(s)},[i,s,E]),C5(()=>()=>E.cancel(),[E]);let w=$1(()=>il(r,n),[r,n]),y=$1(()=>Fc(r),[r]);return se("div",{className:"exc-stats",children:go(yt,{padding:3,children:[go("div",{className:"title",children:[se("h2",{children:f("stats.title")}),se("div",{className:"close",onClick:o,children:Eo})]}),go(us,{label:se("h3",{children:f("stats.generalStats")}),open:!!(n.stats.panels&xl.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^xl.generalStats}})),children:[go(Hp,{children:[se(Xe,{heading:!0,children:f("stats.scene")}),go(Xe,{columns:2,children:[se("div",{children:f("stats.shapes")}),se("div",{children:s.length})]}),go(Xe,{columns:2,children:[se("div",{children:f("stats.width")}),se("div",{children:b.width})]}),go(Xe,{columns:2,children:[se("div",{children:f("stats.height")}),se("div",{children:b.height})]}),a&&go(j1,{children:[se(Xe,{heading:!0,children:"Canvas"}),se(Xe,{children:se(g5,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),t?.(s,n)]}),!y&&r.length>0&&se("div",{id:"elementStats",style:{marginTop:12},children:se(us,{label:se("h3",{children:f("stats.elementProperties")}),open:!!(n.stats.panels&xl.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^xl.elementProperties}})),children:go(Hp,{children:[d&&go(j1,{children:[u&&se(Xe,{heading:!0,children:f("labels.unCroppedDimension")}),n.croppingElementId&&fe(d)&&g&&go(Xe,{columns:2,children:[se("div",{children:f("stats.width")}),se("div",{children:Lo(g.width,2)})]}),n.croppingElementId&&fe(d)&&g&&go(Xe,{columns:2,children:[se("div",{children:f("stats.height")}),se("div",{children:Lo(g.height,2)})]}),se(Xe,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?f("labels.imageCropping"):f(`element.${d.type}`)}),se(Xe,{children:se(X1,{element:d,property:"x",elementsMap:c,scene:l,appState:n})}),se(Xe,{children:se(X1,{element:d,property:"y",elementsMap:c,scene:l,appState:n})}),se(Xe,{children:se(W1,{property:"width",element:d,scene:l,appState:n})}),se(Xe,{children:se(W1,{property:"height",element:d,scene:l,appState:n})}),!oe(d)&&se(Xe,{children:se(u5,{property:"angle",element:d,scene:l,appState:n})}),se(Xe,{children:se(x5,{property:"fontSize",element:d,scene:l,appState:n})})]}),p&&go(j1,{children:[Mx(p)&&se(Xe,{heading:!0,children:f("element.group")}),go(Xe,{columns:2,style:{margin:"0.3125rem 0"},children:[se("div",{children:f("stats.shapes")}),se("div",{children:r.length})]}),se(Xe,{children:se(Z1,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),se(Xe,{children:se(Z1,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),se(Xe,{children:se(K1,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),se(Xe,{children:se(K1,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),se(Xe,{children:se(E5,{property:"angle",elements:p,scene:l,appState:n})}),se(Xe,{children:se(w5,{property:"fontSize",elements:p,scene:l,appState:n,elementsMap:c})})]})]})})})]})})},(e,o)=>e.sceneNonce===o.sceneNonce&&e.selectedElements===o.selectedElements&&e.appState.stats.panels===o.appState.stats.panels&&e.gridModeEnabled===o.gridModeEnabled&&e.appState.gridStep===o.appState.gridStep&&e.appState.croppingElementId===o.appState.croppingElementId);import{useCallback as f7,useEffect as I5,useState as S5}from"react";import{jsx as ll,jsxs as Up}from"react/jsx-runtime";var b7=({sourceElementId:e,onClose:o,elementsMap:t,appState:r,generateLinkForSelection:n=$c})=>{let i=t.get(e)?.link??null,[a,l]=S5(i),[s,c]=S5(!1);I5(()=>{let d=J(t,r),p=i;if(d.length>0&&n){let u=jc(d,r);u&&(p=Zo(n(u.id,u.type)))}l(p)},[t,r,r.selectedElementIds,i,n]);let m=f7(()=>{if(a&&a!==t.get(e)?.link){let d=t.get(e);d&&B(d,{link:a})}if(!a&&s&&e){let d=t.get(e);d&&B(d,{link:null})}o?.()},[e,a,t,s,o]);return I5(()=>{let d=p=>{r.openDialog?.name==="elementLinkSelector"&&p.key===T.ENTER&&m(),r.openDialog?.name==="elementLinkSelector"&&p.key===T.ESCAPE&&o?.()};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[r,o,m]),Up("div",{className:"ElementLinkDialog",children:[Up("div",{className:"ElementLinkDialog__header",children:[ll("h2",{children:f("elementLink.title")}),ll("p",{children:f("elementLink.desc")})]}),Up("div",{className:"ElementLinkDialog__input",children:[ll(Xa,{value:a??"",onChange:d=>{s||c(!0),l(d)},onKeyDown:d=>{d.key===T.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),i&&a&&ll(ee,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),c(!0)},className:"ElementLinkDialog__remove",icon:lo})]}),Up("div",{className:"ElementLinkDialog__actions",children:[ll(Yr,{label:f("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),ll(Yr,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},k5=b7;import x7,{useState as E7}from"react";import{Fragment as y7,jsx as q1}from"react/jsx-runtime";var M5=({children:e,onClose:o})=>{let[t,r]=E7(!!e),{container:n}=gt(),i=x7.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return q1(y7,{children:t&&q1(dt,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:q1("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import v7 from"react";import{Fragment as A5,jsx as G,jsxs as So}from"react/jsx-runtime";var w7=()=>So("div",{className:"HelpDialog__header",children:[So("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[G("div",{className:"HelpDialog__link-icon",children:wd}),f("helpDialog.documentation")]}),So("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener noreferrer",children:[G("div",{className:"HelpDialog__link-icon",children:wd}),f("helpDialog.blog")]}),So("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[G("div",{className:"HelpDialog__link-icon",children:Zl}),f("helpDialog.github")]}),So("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[G("div",{className:"HelpDialog__link-icon",children:Yg}),"YouTube"]})]}),T7=e=>So(A5,{children:[G("h3",{children:e.title}),G("div",{className:"HelpDialog__islands-container",children:e.children})]}),J1=e=>So("div",{className:`HelpDialog__island ${e.className}`,children:[G("h4",{className:"HelpDialog__island-title",children:e.caption}),G("div",{className:"HelpDialog__island-content",children:e.children})]});function*C7(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var I7=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),$=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>G(S7,{children:I7(a)},a)));return So("div",{className:"HelpDialog__shortcut",children:[G("div",{children:e}),G("div",{className:"HelpDialog__key-container",children:[...C7(r,t?f("helpDialog.or"):null)]})]})},S7=e=>G("kbd",{className:"HelpDialog__key",...e}),L5=({onClose:e})=>{let o=v7.useCallback(()=>{e&&e()},[e]);return G(A5,{children:So(dt,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",children:[G(w7,{}),So(T7,{title:f("helpDialog.shortcuts"),children:[So(J1,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[G($,{label:f("toolBar.hand"),shortcuts:[T.H]}),G($,{label:f("toolBar.selection"),shortcuts:[T.V,T[1]]}),G($,{label:f("toolBar.rectangle"),shortcuts:[T.R,T[2]]}),G($,{label:f("toolBar.diamond"),shortcuts:[T.D,T[3]]}),G($,{label:f("toolBar.ellipse"),shortcuts:[T.O,T[4]]}),G($,{label:f("toolBar.arrow"),shortcuts:[T.A,T[5]]}),G($,{label:f("toolBar.line"),shortcuts:[T.L,T[6]]}),G($,{label:f("toolBar.freedraw"),shortcuts:[T.P,T[7]]}),G($,{label:f("toolBar.text"),shortcuts:[T.T,T[8]]}),G($,{label:f("toolBar.image"),shortcuts:[T[9]]}),G($,{label:f("toolBar.eraser"),shortcuts:[T.E,T[0]]}),G($,{label:f("toolBar.frame"),shortcuts:[T.F]}),G($,{label:f("toolBar.laser"),shortcuts:[T.K]}),G($,{label:f("labels.eyeDropper"),shortcuts:[T.I,"Shift+S","Shift+G"]}),G($,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[R("CtrlOrCmd+Enter")]}),G($,{label:f("helpDialog.editText"),shortcuts:[R("Enter")]}),G($,{label:f("helpDialog.textNewLine"),shortcuts:[R("Enter"),R("Shift+Enter")]}),G($,{label:f("helpDialog.textFinish"),shortcuts:[R("Esc"),R("CtrlOrCmd+Enter")]}),G($,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),G($,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),G($,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),R("Enter")],isOr:!0}),G($,{label:f("helpDialog.cropFinish"),shortcuts:[R("Enter"),R("Escape")],isOr:!0}),G($,{label:f("toolBar.lock"),shortcuts:[T.Q]}),G($,{label:f("helpDialog.preventBinding"),shortcuts:[R("CtrlOrCmd")]}),G($,{label:f("toolBar.link"),shortcuts:[R("CtrlOrCmd+K")]})]}),So(J1,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[G($,{label:f("buttons.zoomIn"),shortcuts:[R("CtrlOrCmd++")]}),G($,{label:f("buttons.zoomOut"),shortcuts:[R("CtrlOrCmd+-")]}),G($,{label:f("buttons.resetZoom"),shortcuts:[R("CtrlOrCmd+0")]}),G($,{label:f("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),G($,{label:f("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),G($,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),G($,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),G($,{label:f("buttons.zenMode"),shortcuts:[R("Alt+Z")]}),G($,{label:f("buttons.objectsSnapMode"),shortcuts:[R("Alt+S")]}),G($,{label:f("labels.toggleGrid"),shortcuts:[R("CtrlOrCmd+'")]}),G($,{label:f("labels.viewMode"),shortcuts:[R("Alt+R")]}),G($,{label:f("labels.toggleTheme"),shortcuts:[R("Alt+Shift+D")]}),G($,{label:f("stats.fullTitle"),shortcuts:[R("Alt+/")]}),G($,{label:f("search.title"),shortcuts:[ct("searchMenu")]}),G($,{label:f("commandPalette.title"),shortcuts:Ir?[ct("commandPalette")]:[ct("commandPalette"),ct("commandPalette",1)]})]}),So(J1,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[G($,{label:f("helpDialog.createFlowchart"),shortcuts:[R("CtrlOrCmd+Arrow Key")],isOr:!0}),G($,{label:f("helpDialog.navigateFlowchart"),shortcuts:[R("Alt+Arrow Key")],isOr:!0}),G($,{label:f("labels.moveCanvas"),shortcuts:[R(`Space+${f("helpDialog.drag")}`),R(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),G($,{label:f("buttons.clearReset"),shortcuts:[R("CtrlOrCmd+Delete")]}),G($,{label:f("labels.delete"),shortcuts:[R("Delete")]}),G($,{label:f("labels.cut"),shortcuts:[R("CtrlOrCmd+X")]}),G($,{label:f("labels.copy"),shortcuts:[R("CtrlOrCmd+C")]}),G($,{label:f("labels.paste"),shortcuts:[R("CtrlOrCmd+V")]}),G($,{label:f("labels.pasteAsPlaintext"),shortcuts:[R("CtrlOrCmd+Shift+V")]}),G($,{label:f("labels.selectAll"),shortcuts:[R("CtrlOrCmd+A")]}),G($,{label:f("labels.multiSelect"),shortcuts:[R(`Shift+${f("helpDialog.click")}`)]}),G($,{label:f("helpDialog.deepSelect"),shortcuts:[R(`CtrlOrCmd+${f("helpDialog.click")}`)]}),G($,{label:f("helpDialog.deepBoxSelect"),shortcuts:[R(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(Ra||Ir)&&G($,{label:f("labels.copyAsPng"),shortcuts:[R("Shift+Alt+C")]}),G($,{label:f("labels.copyStyles"),shortcuts:[R("CtrlOrCmd+Alt+C")]}),G($,{label:f("labels.pasteStyles"),shortcuts:[R("CtrlOrCmd+Alt+V")]}),G($,{label:f("labels.sendToBack"),shortcuts:[Vo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")]}),G($,{label:f("labels.bringToFront"),shortcuts:[Vo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")]}),G($,{label:f("labels.sendBackward"),shortcuts:[R("CtrlOrCmd+[")]}),G($,{label:f("labels.bringForward"),shortcuts:[R("CtrlOrCmd+]")]}),G($,{label:f("labels.alignTop"),shortcuts:[R("CtrlOrCmd+Shift+Up")]}),G($,{label:f("labels.alignBottom"),shortcuts:[R("CtrlOrCmd+Shift+Down")]}),G($,{label:f("labels.alignLeft"),shortcuts:[R("CtrlOrCmd+Shift+Left")]}),G($,{label:f("labels.alignRight"),shortcuts:[R("CtrlOrCmd+Shift+Right")]}),G($,{label:f("labels.duplicateSelection"),shortcuts:[R("CtrlOrCmd+D"),R(`Alt+${f("helpDialog.drag")}`)]}),G($,{label:f("helpDialog.toggleElementLock"),shortcuts:[R("CtrlOrCmd+Shift+L")]}),G($,{label:f("buttons.undo"),shortcuts:[R("CtrlOrCmd+Z")]}),G($,{label:f("buttons.redo"),shortcuts:Qs?[R("CtrlOrCmd+Y"),R("CtrlOrCmd+Shift+Z")]:[R("CtrlOrCmd+Shift+Z")]}),G($,{label:f("labels.group"),shortcuts:[R("CtrlOrCmd+G")]}),G($,{label:f("labels.ungroup"),shortcuts:[R("CtrlOrCmd+Shift+G")]}),G($,{label:f("labels.flipHorizontal"),shortcuts:[R("Shift+H")]}),G($,{label:f("labels.flipVertical"),shortcuts:[R("Shift+V")]}),G($,{label:f("labels.showStroke"),shortcuts:[R("S")]}),G($,{label:f("labels.showBackground"),shortcuts:[R("G")]}),G($,{label:f("labels.showFonts"),shortcuts:[R("Shift+F")]}),G($,{label:f("labels.decreaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+<")]}),G($,{label:f("labels.increaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as P5,useRef as D7,useState as Gn}from"react";import{useCallback as k7,useRef as M7,useState as L7}from"react";var A7=2e3,_5=()=>{let[e,o]=L7(null),t=M7(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},A7)},n=k7(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import _7 from"clsx";import{jsx as D5}from"react/jsx-runtime";var Gs=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>D5("div",{className:_7("Switch",{toggled:t,disabled:n}),children:D5("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 $e,jsxs as Vn}from"react/jsx-runtime";var P7="filter"in document.createElement("canvas").getContext("2d"),R7=()=>Vn("div",{children:[$e("h3",{children:f("canvasError.cannotShowPreview")}),$e("p",{children:$e("span",{children:f("canvasError.canvasTooBig")})}),Vn("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),N7=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=ze(o,e),[l,s]=Gn(i),[c,m]=Gn(a),[d,p]=Gn(e.exportBackground),[u,g]=Gn(e.exportWithDarkMode),[b,x]=Gn(e.exportEmbedScene),[E,w]=Gn(e.exportScale),y=D7(null),[v,C]=Gn(null),{onCopy:S,copyStatus:_,resetCopyStatus:L}=_5();P5(()=>{L()},[l,d,u,E,b,L]);let{exportedElements:N,exportingFrame:P}=Li(o,e,c);return P5(()=>{let z=y.current;if(!z)return;let W=z.offsetWidth,U=z.offsetHeight;W&&Nm({data:{elements:N,appState:{...e,name:l,exportEmbedScene:b},files:t},config:{canvasBackgroundColor:d?e.viewBackgroundColor:!1,padding:rn,theme:u?"dark":"light",scale:E,maxWidthOrHeight:Math.max(W,U),exportingFrame:P}}).then(q=>(C(null),zr(q).then(()=>{z.replaceChildren(q)}).catch(H=>{throw H.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):H}))).catch(q=>{console.error(q),C(q)})},[e,t,N,P,l,d,u,E,b]),Vn("div",{className:"ImageExportModal",children:[$e("h3",{children:f("imageExportDialog.header")}),Vn("div",{className:"ImageExportModal__preview",children:[$e("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&$e(R7,{})}),$e("div",{className:"ImageExportModal__preview__filename",children:!ma&&$e("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:z=>{s(z.target.value),r.executeAction(bm,"ui",z.target.value)}})})]}),Vn("div",{className:"ImageExportModal__settings",children:[$e("h3",{children:f("imageExportDialog.header")}),a&&$e(Vs,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:$e(Gs,{name:"exportOnlySelected",checked:c,onChange:z=>{m(z)}})}),$e(Vs,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:$e(Gs,{name:"exportBackgroundSwitch",checked:d,onChange:z=>{p(z),r.executeAction(xm,"ui",z)}})}),P7&&$e(Vs,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:$e(Gs,{name:"exportDarkModeSwitch",checked:u,onChange:z=>{g(z),r.executeAction(y2,"ui",z)}})}),$e(Vs,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:$e(Gs,{name:"exportEmbedSwitch",checked:b,onChange:z=>{x(z),r.executeAction(Em,"ui",z)}})}),$e(Vs,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:$e(wp,{name:"exportScale",value:E,onChange:z=>{w(z),r.executeAction(E2,"ui",z)},choices:sc.map(z=>({value:z,label:`${z}\xD7`}))})}),Vn("div",{className:"ImageExportModal__settings__buttons",children:[$e(Fn,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>n(ic.png,N,{exportingFrame:P}),icon:zd,children:f("imageExportDialog.button.exportToPng")}),$e(Fn,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>n(ic.svg,N,{exportingFrame:P}),icon:zd,children:f("imageExportDialog.button.exportToSvg")}),(Ra||Ir)&&$e(Fn,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:_,onClick:async()=>{await n(ic.clipboard,N,{exportingFrame:P}),S()},icon:Ti,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},Vs=({label:e,children:o,tooltip:t,name:r})=>Vn("div",{className:"ImageExportModal__settings__setting",title:e,children:[Vn("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&$e(vo,{label:t,long:!0,children:Tg})]}),$e("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),R5=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Gn(()=>({appStateSnapshot:no(o),elementsSnapshot:no(e)}));return $e(dt,{onCloseRequest:i,size:"wide",title:!1,children:$e(N7,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import B7 from"react";import Q1 from"open-color";import{jsx as O7}from"react/jsx-runtime";var eb=({children:e,color:o})=>O7("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":Q1[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":Q1[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":Q1[o][9]},children:e});import{Fragment as F7,jsx as or,jsxs as Gp}from"react/jsx-runtime";var z7=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return or("div",{className:"ExportDialog ExportDialog--json",children:Gp("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Gp(eb,{color:"lime",children:[or("div",{className:"Card-icon",children:Ph}),or("h2",{children:f("exportDialog.disk_title")}),Gp("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!ma&&n.renderAction("changeProjectName")]}),or(ee,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Na,"ui")}})]}),s&&Gp(eb,{color:"pink",children:[or("div",{className:"Card-icon",children:ya}),or("h2",{children:f("exportDialog.link_title")}),or("div",{className:"Card-details",children:f("exportDialog.link_details")}),or(ee,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ye("export","link",`ui (${T0()})`),await s(e,o,r),l()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},N5=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=B7.useCallback(()=>{a({openDialog:null})},[a]);return or(F7,{children:o.openDialog?.name==="jsonExport"&&or(dt,{onCloseRequest:l,title:f("buttons.export"),children:or(z7,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import H7 from"clsx";import{jsx as O5,jsxs as G7}from"react/jsx-runtime";var U7="small",B5=e=>G7("label",{className:H7("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${U7}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[O5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),O5("div",{className:"ToolIcon__icon",children:Ta})]});import{Fragment as F5,jsx as ne,jsxs as ko}from"react/jsx-runtime";var Y7=({UIOptions:e})=>ko(Ot,{__fallback:!0,children:[ne(Ot.DefaultItems.LoadScene,{}),ne(Ot.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&ne(Ot.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&ne(Ot.DefaultItems.SaveAsImage,{}),ne(Ot.DefaultItems.SearchMenu,{}),ne(Ot.DefaultItems.Help,{}),ne(Ot.DefaultItems.ClearCanvas,{}),ne(Ot.Separator,{}),ne(Ot.Group,{title:"Excalidraw links",children:ne(Ot.DefaultItems.Socials,{})}),ne(Ot.Separator,{}),ne(Ot.DefaultItems.ToggleTheme,{}),ne(Ot.DefaultItems.ChangeCanvasBackground,{})]}),W7=()=>ko(Sp,{__fallback:!0,children:[ne(Sp.Actions.SaveToDisk,{}),ne(Sp.Actions.ExportToImage,{})]}),K7=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopRightUI:m,renderCustomStats:d,UIOptions:p,onExportImage:u,renderWelcomeScreen:g,onHomeButtonClick:b,children:x,app:E,isCollaborating:w,generateLinkForSelection:y,uiDisabled:v})=>{let C=Ce(),S=$v(),_=S.tunnelsJotai.Provider,[L,N]=we(Tn),P=()=>p.canvasActions.export?ne(N5,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,z=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:ne(R5,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:E.getName()}),W=()=>ko("div",{style:{position:"relative"},children:[ne(S.MainMenuTunnel.Out,{}),g&&ne(S.WelcomeScreenMenuHintTunnel.Out,{})]}),U=()=>ne(Bn,{heading:"selectedShapeActions",className:Ys("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:ne(yt,{className:Yo.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:ne(jm,{appState:o,elementsMap:E.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:E})})}),q=()=>{let Q=Oa(o,n),X=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return ne(up,{side:"top",children:ko("div",{className:"App-menu App-menu_top",children:[ko(It.Col,{gap:6,className:Ys("App-menu_top__left"),children:[W(),Q&&U()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&ne(Bn,{heading:"shapes",className:"shapes-section",children:ie=>ko("div",{style:{position:"relative"},children:[g&&ne(S.WelcomeScreenToolbarHintTunnel.Out,{}),ne(It.Col,{gap:4,align:"start",children:ko(It.Row,{gap:1,className:Ys("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[ko(yt,{padding:1,className:Ys("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[ne(gp,{appState:o,isMobile:C.editor.isMobile,device:C,app:E}),ie,ko(It.Row,{gap:1,children:[ne(fp,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),penDetected:o.penDetected}),ne(pp,{checked:o.activeTool.locked,onChange:a,title:f("toolBar.lock")}),ne("div",{className:"App-toolbar__divider"}),ne(hp,{checked:jo(o),onChange:()=>l(),title:f("toolBar.hand"),isMobile:!0}),ne(qm,{appState:o,activeTool:o.activeTool,UIOptions:p,app:E})]})]}),w&&ne(yt,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:ne(B5,{title:f("toolBar.laser"),checked:o.activeTool.type===it.laser,onChange:()=>E.setActiveTool({type:it.laser}),isMobile:!0})})]})})]})}),ko("div",{className:Ys("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&ne(Ep,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),m?.(C.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!V||o.openSidebar?.name!==At.name)&&ne(S.DefaultSidebarTriggerTunnel.Out,{}),X&&ne(Us,{app:E,onClose:()=>{e.executeAction(Ni)},renderCustomStats:d})]})]})})},H=()=>ne(kp,{__fallback:!0,onDock:Q=>{ye("sidebar",`toggleDock (${Q?"dock":"undock"})`,`(${C.editor.isMobile?"mobile":"desktop"})`)}}),V=ud(Os);if(v)return null;let K=ko(F5,{children:[x,ne(Y7,{UIOptions:p}),ne(kp.Trigger,{__fallback:!0,icon:Ei,title:ir(f("toolBar.library")),onToggle:Q=>{Q&&ye("sidebar",`${At.name} (open)`,`button (${C.editor.isMobile?"mobile":"desktop"})`)},tab:At.defaultTab,children:f("toolBar.library")}),ne(W7,{}),o.openDialog?.name==="ttd"&&ne(V1,{__fallback:!0}),o.isLoading&&ne(mp,{delay:250}),o.errorMessage&&ne(M5,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),L&&!C.editor.isMobile&&ne(ry,{colorPickerType:L.colorPickerType,onCancel:()=>{N(null)},onChange:(Q,X,ie,{altKey:he})=>{if(!(Q!=="elementBackground"&&Q!=="elementStroke"))if(ie.length){for(let pe of ie)B(pe,{[he&&L.swapPreviewOnAlt?Q==="elementBackground"?"strokeColor":"backgroundColor":Q==="elementBackground"?"backgroundColor":"strokeColor"]:X},!1),hn.delete(pe);pn.getScene(ie[0])?.triggerUpdate()}else r(Q==="elementBackground"?{currentItemBackgroundColor:X}:{currentItemStrokeColor:X})},onSelect:(Q,X)=>{N(ie=>ie?.keepOpenOnAlt&&X.altKey?ie:null),L?.onSelect?.(Q,X)}}),o.openDialog?.name==="help"&&ne(L5,{onClose:()=>{r({openDialog:null})}}),ne(ew,{}),o.openDialog?.name==="elementLinkSelector"&&ne(k5,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},elementsMap:E.scene.getNonDeletedElementsMap(),appState:o,generateLinkForSelection:y}),ne(S.OverwriteConfirmDialogTunnel.Out,{}),z(),P(),o.pasteDialog.shown&&ne(n3,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),C.editor.isMobile&&ne(o3,{app:E,onHomeButtonClick:b,appState:o,elements:n,actionManager:e,renderJSONExportDialog:P,renderImageExportDialog:z,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:m,renderCustomStats:d,renderSidebars:H,device:C,renderWelcomeScreen:g,UIOptions:p}),!C.editor.isMobile&&ko(F5,{children:[ko("div",{className:"layer-ui__wrapper",style:o.openSidebar&&V&&C.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[g&&ne(S.WelcomeScreenCenterTunnel.Out,{}),q(),ne(s3,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:g}),o.scrolledOutside&&ne("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(Q=>({...gi(n,Q)}))},children:f("buttons.scrollBackToContent")})]}),H()]})]});return ne(of.Provider,{value:o,children:ne(_,{children:ne(Jf.Provider,{value:S,children:K})})})},z5=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},Z7=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return Qe(z5(r),z5(a),{selectedElementIds:Qe,selectedGroupIds:Qe})&&Qe(n,l)},H5=V7.memo(K7,Z7);import X7 from"clsx";import{jsx as U5,jsxs as j7}from"react/jsx-runtime";var $7="small",Vp=e=>j7("label",{className:X7("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${$7}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[U5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),U5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as q7,useRef as J7}from"react";import{jsx as G5}from"react/jsx-runtime";var V5=({trails:e})=>{let o=J7(null);return q7(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),G5("div",{className:"SVGLayer",children:G5("svg",{ref:o})})};import Q7,{useEffect as eA,useRef as tA}from"react";import{jsx as nA}from"react/jsx-runtime";var oA=e=>{let o=tA(!1);return eA(()=>{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,c)=>{if(s.selectedElementIds)for(let m of Object.keys(s.selectedElementIds))n.has(m)||n.set(m,[]),n.get(m).push(c);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(c,s.username),s.userState&&a.set(c,s.userState),r.set(c,Ft({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(c,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";Ow({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:!1},device:e.device,callback:e.renderInteractiveSceneCallback},Qa())}),nA("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Se.GRAB:Se.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:f("labels.drawingCanvas")})},Y5=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,editingLinearElement:e.editingLinearElement,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,pendingImageElementId:e.pendingImageElementId,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}),rA=(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?!1:Qe(Y5(e.appState),Y5(o.appState)),tb=Q7.memo(oA,rA);import iA,{useEffect as aA,useRef as W5}from"react";import{jsx as cA}from"react/jsx-runtime";var lA=e=>{let o=W5(null),t=W5(!1);return aA(()=>{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"));let i=`${e.appState.width}px`,a=`${e.appState.height}px`;n.style.width!==i&&(n.style.width=i),n.style.height!==a&&(n.style.height=a);let l=e.appState.width*e.scale,s=e.appState.height*e.scale;n.width!==l&&(n.width=l),n.height!==s&&(n.height=s),rE({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Qa())}),cA("div",{className:"excalidraw__canvas-wrapper",ref:o})},K5=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,pendingImageElementId:e.pendingImageElementId,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}),sA=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:Qe(K5(e.appState),K5(o.appState))&&Qe(e.renderConfig,o.renderConfig),ob=iA.memo(lA,sA);import{useEffect as mA,useRef as pA}from"react";var Z5=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=td(e,i),m=od({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"?zx(t,r,n,o,m,l,a):m.clearRect(0,0,s,c)}},dA=Wi(e=>{Z5(e)},{trailing:!0}),X5=(e,o)=>{if(o){dA(e);return}Z5(e)};import{jsx as hA}from"react/jsx-runtime";var uA=e=>{let o=pA(null);return mA(()=>{o.current&&X5({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},Qa())}),hA("canvas",{className:"excalidraw__canvas",style:{width:e.appState.width,height:e.appState.height},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:o})},$5=uA;import{useCallback as gA,useEffect as fA,useRef as bA}from"react";import{jsx as j5,jsxs as EA}from"react/jsx-runtime";var xA=5e3,q5=({message:e,onClose:o,closable:t=!1,duration:r=xA,style:n})=>{let i=bA(0),a=r!==1/0,l=gA(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return fA(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),EA("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[j5("p",{className:"Toast__message",children:e}),t&&j5(ee,{icon:Eo,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{Fragment as CA,jsx as Be,jsxs as Wp}from"react/jsx-runtime";var tT=Cr.createContext(null),oT=Cr.createContext(null),rT={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},sb=Cr.createContext(rT);sb.displayName="DeviceContext";var cb=Cr.createContext({container:null,id:null});cb.displayName="ExcalidrawContainerContext";var db=Cr.createContext([]);db.displayName="ExcalidrawElementsContext";var mb=Cr.createContext({...Br(),width:0,height:0,offsetLeft:0,offsetTop:0});mb.displayName="ExcalidrawAppStateContext";var pb=Cr.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});pb.displayName="ExcalidrawSetAppStateContext";var ub=Cr.createContext(null);ub.displayName="ExcalidrawActionManagerContext";var st=()=>Wn(tT),hr=()=>Wn(oT),Ce=()=>Wn(sb),gt=()=>Wn(cb),Cn=()=>Wn(db),ur=()=>Wn(mb),Ie=()=>Wn(pb),ft=()=>Wn(ub),Ws=!1,rb=0,Hi=!1,Ks=!1,nb=!1,ib={horizontal:null,vertical:null},Yn=0,Zs=!1,ab=new Map,Yp=!1,Q5=0,eT=!1,Xs=null,Ae={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},lb=class e extends Cr.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",rT);I(this,"excalidrawContainerRef",Cr.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,"elementsPendingErasure",new Set);I(this,"flowChartCreator",new md);I(this,"flowChartNavigator",new dd);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 rp);I(this,"laserTrails",new lp(this.animationFrameHandler,this));I(this,"eraserTrail",new dp(this.animationFrameHandler,this));I(this,"lassoTrail",new cp(this.animationFrameHandler,this));I(this,"onChangeEmitter",new Pt);I(this,"onPointerDownEmitter",new Pt);I(this,"onPointerUpEmitter",new Pt);I(this,"onUserFollowEmitter",new Pt);I(this,"onScrollChangeEmitter",new Pt);I(this,"missingPointerEventCleanupEmitter",new Pt);I(this,"onRemoveEventListenersEmitter",new Pt);I(this,"getEffectiveGridSize",()=>Nn(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),hn.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(Ht(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=ca(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else ri(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=je({clientX:i.x,clientY:i.y},this.state),l=je({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&&B(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===ce.DARK;return this.scene.getNonDeletedFramesLikes().map(r=>{if(!Dl(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()))return this.state.editingFrame===r.id&&this.resetEditingFrame(r),null;let{x:n,y:i}=Ft({sceneX:r.x,sceneY:r.y},this.state),a=6,l,s=bx(r);if(r.id===this.state.editingFrame){let c=s;l=Be("input",{autoFocus:!0,value:c,onChange:m=>{B(r,{name:m.target.value})},onFocus:m=>m.target.select(),onBlur:()=>this.resetEditingFrame(r),onKeyDown:m=>{(m.key===T.ESCAPE||m.key===T.ENTER)&&this.resetEditingFrame(r)},style:{background:this.state.viewBackgroundColor,filter:t?Hb:"none",zIndex:2,border:"none",display:"block",padding:`${a}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:`translate(-${a}px, ${a}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-n-a}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else l=s;return Be("div",{id:this.getFrameNameDOMId(r),style:{position:"absolute",bottom:`${this.state.height+Wo.nameOffsetY-i+this.state.offsetTop}px`,left:`${n-this.state.offsetLeft}px`,zIndex:2,fontSize:Wo.nameFontSize,color:t?Wo.nameColorDarkTheme:Wo.nameColorLightTheme,lineHeight:Wo.nameLineHeight,width:"max-content",maxWidth:`${r.width}px`,overflow:r.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Se.MOVE,pointerEvents:this.state.viewModeEnabled?Xn.disabled:Xn.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:r.id})},children:l},r.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());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)=>{ye("export",t,"ui");let i=await Ai({type:t,data:{elements:r,appState:this.state,files:this.files},config:{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}}).catch(vc).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&rd(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?B(t,{customData:{generationData:void 0}},!1):B(t,{customData:{generationData:r}},!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:it.magicframe}),ye("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&Sc(t[0])&&t[0];if(!r&&t.some(i=>ae(i)||i.frameId)){this.setActiveTool({type:it.magicframe});return}ye("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=ve(t),c=50;n=Nl({...Wo,x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let m of t)B(m,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});I(this,"openEyeDropper",({type:t})=>{kt.set(Tn,{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:A.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:A.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?re(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:A.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})});I(this,"syncActionResult",ot(t=>{if(this.unmounted||t===!1)return;t.captureUpdate===A.NEVER?this.store.shouldUpdateSnapshot():t.captureUpdate===A.IMMEDIATELY&&this.store.shouldCaptureIncrement();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||ce.LIGHT,s=t?.appState?.name??this.state.name,c=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(m=>{n?.id===m.id&&n!==m&&ku(m)&&Z(m)&&(n=m)}),n?.isDeleted&&(n=null),this.setState(m=>{let d=t.appState||{};return{...m,...d,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),r=!0}!r&&t.captureUpdate!==A.EVENTUALLY&&this.scene.triggerUpdate()}));I(this,"onBlur",ot(()=>{Hi=!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",ot(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...Br(),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 n=>{if(!n.files.length)return;let i=n.files[0],a=await i.getFile();this.loadFileToCanvas(new File([a],a.name||"",{type:a.type}),i)}),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(n=>{console.error(n)})}catch(n){console.error(n),t={appState:{errorMessage:n.message||"Encountered an error during importing or restoring scene data"}}}let r=zl(t,null,null,{repairBindings:!0});r.appState={...r.appState,theme:this.props.theme||r.appState.theme,openSidebar:r.appState?.openSidebar||this.state.openSidebar,activeTool:r.appState.activeTool.type==="image"?{...r.appState.activeTool,type:"selection"}:r.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(r.appState={...r.appState,...gi(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),t?.scrollX!=null&&(r.appState.scrollX=t.scrollX),t?.scrollY!=null&&(r.appState.scrollY=t.scrollY),this.resetHistory(),this.syncActionResult({...r,captureUpdate:A.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(n=>{this.fonts.onLoaded(n)}),hi(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileBreakpoint",(t,r)=>t<Ub||r<Vb&&t<Gb);I(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=Ki(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:Yb,a=this.device.editor,l=Ki(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",ot(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>hn.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),dl||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&&(ib=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",Qn(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},zb));I(this,"onCut",ot(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ar(t.target)||(this.actionManager.executeAction(vs,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",ot(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ar(t.target)||(this.actionManager.executeAction(Pi,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(ec&&t.preventDefault(),this.props.interactive!==!1){if(!Ws){Ws=!0,clearTimeout(rb),rb=window.setTimeout(e.resetTapTwice,Ob);return}if(Ws&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),Ws=!1,clearTimeout(rb)}t.touches.length===2&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null})}});I(this,"onTouchEnd",t=>{this.props.interactive!==!1&&(this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}):Ae.pointers.clear())});I(this,"pasteFromClipboard",ot(async t=>{if(this.props.interactive===!1)return;let r=!!Yp,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)||ar(n)))return;let{x:l,y:s}=je({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),c=t?.clipboardData?.files[0],m=await gm(t,r);if(!c&&!r){if(m.mixedContent)return this.addElementsFromMixedContentPaste(m.mixedContent,{isPlainPaste:r,sceneX:l,sceneY:s});if(m.text){let d=m.text.trim();d.startsWith("<svg")&&d.endsWith("</svg>")&&(c=Xu(d))}}if(nd(c)&&!m.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:l,sceneY:s});this.insertImageElement(d,c),this.initializeImageDimensions(d),this.setState({selectedElementIds:Me({[d.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(d){console.error(d)}if(m.errorMessage)this.setState({errorMessage:m.errorMessage});else if(m.spreadsheet&&!r)this.setState({pasteDialog:{data:m.spreadsheet,shown:!0}});else if(m.elements){let d=m.programmaticAPI?Ja(m.elements):m.elements;this.addElementsFromPasteOrLibrary({elements:d,files:m.files||null,position:"cursor",retainSeed:r})}else if(m.text){if(m.text&&Fw(m.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:g,files:b}=await u.parseMermaidToExcalidraw(m.text),x=Ja(g,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:x,files:b,position:"cursor"});return}catch(g){console.warn(`parsing pasted text as mermaid definition failed: ${g.message}`)}}let d=S0(m.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=d.map(u=>Yx(u)).filter(u=>ca(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||ui(u)?.type==="video"));if(!Yp&&p.length>0&&p.length===d.length){let u=[];for(let g of p){let b=u[u.length-1],x=this.insertEmbeddableElement({sceneX:b?b.x+b.width+20:l,sceneY:s,link:Zo(g)});x&&u.push(x)}u.length&&this.setState({selectedElementIds:Object.fromEntries(u.map(g=>[g.id,!0]))});return}this.addTextFromPaste(m.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let r=Wu(t.elements,null,void 0),[n,i,a,l]=ve(r),s=ei(n,a)/2,c=ei(i,l)/2,m=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}=je({clientX:m,clientY:d},this.state),g=p-s,b=u-c,[x,E]=ht(g,b,this.getEffectiveGridSize()),{newElements:w}=bn({type:"everything",elements:r.map(L=>re(L,{x:L.x+x-n,y:L.y+E-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...w];v=this.props.onDuplicate?.(v,y)||v,Gt(v,te(w));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let L=gx(w,S);ra(v,L,S,this.state)}this.scene.replaceAllElements(v),w.forEach(L=>{if(Z(L)&&_e(L)){let N=_t(L,this.scene.getElementsMapIncludingDeleted());et(L,N,this.scene.getElementsMapIncludingDeleted())}}),Sb&&gn.loadElementsFonts(w).then(L=>{this.fonts.onLoaded(L)}),t.files&&this.addMissingFiles(t.files),this.store.shouldCaptureIncrement();let _=Hc(w);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&kt.get(Os)?this.state.openSidebar:null,...lt({editingGroupId:null,selectedElementIds:_.reduce((L,N)=>(_e(N)||(L[N.id]=!0),L),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(w,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,r)=>{this.setState(t,r)});I(this,"removePointer",t=>{Yn&&this.resetContextMenuTimer(),Ae.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||ye("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Ue(this.state,r.activeTool.locked?{type:"selection"}: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(o2)});I(this,"zoomCanvas",t=>{this.setState({...Gr({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:mr(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(hi(t)?s=Xx(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):hi(t)&&this.setState({toast:{message:f("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}=bs({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=gi(n,this.state);a=s.scrollX,l=s.scrollY}if(r?.animate){let s=this.state.scrollX,c=this.state.scrollY,m=this.state.zoom.value,d=u0({fromValues:{scrollX:s,scrollY:c,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,g,b)=>{if(b==="zoom")return p*Math.pow(u/p,Ko(g))},onStep:({scrollX:p,scrollY:u,zoom:g})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:g}})},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=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});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,ml,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",ot(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===ge.svg))try{let s=mE(Fu(uE(l.dataURL)),ge.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",ot(t=>{let r=Nr(t.elements??[]);if(t.captureUpdate&&t.captureUpdate!==A.EVENTUALLY){let n=this.store.snapshot.appState,i=this.store.snapshot.elements,a=t.appState?Object.assign({},n,t.appState):n,l=t.elements?this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(),te(r)):i;t.captureUpdate===A.IMMEDIATELY?this.store.captureIncrement(l,a):t.captureUpdate===A.NEVER&&this.store.updateSnapshot(l,a)}t.appState&&this.setState(t.appState),t.elements&&this.scene.replaceAllElements(r),t.collaborators&&this.setState({collaborators:t.collaborators})}));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",ot(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 Hr().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,"onKeyDown",ot(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}})),!fu(t.target)){if((t.key===T.ESCAPE||t.key===T.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=J(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&fe(a[0])&&t.key===T.ENTER){this.startImageCropping(a[0]);return}if(t.key===T.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=jn(t.key);if(t[T.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=J(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&ii(s[0])&&this.flowChartCreator.createNodes(s[0],this.scene.getNonDeletedElementsMap(),this.state,Qu(t.key)),this.flowChartCreator.pendingNodes?.length&&!ta(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 c=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),Qu(t.key));if(c){this.setState(d=>({selectedElementIds:Me({[c]:!0},d)}));let m=this.scene.getNonDeletedElementsMap().get(c);m&&!ta([m],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(m,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[T.CTRL_OR_CMD]&&t.key===T.P&&!t.shiftKey&&!t.altKey){this.setToast({message:f("commandPalette.shortcutHint",{shortcut:ct("commandPalette")})}),t.preventDefault();return}if(t[T.CTRL_OR_CMD]&&t.key.toLowerCase()===T.V&&(Yp=t.shiftKey,clearTimeout(Q5),Q5=window.setTimeout(()=>{Yp=!1},100)),t[T.CTRL_OR_CMD]&&ar(t.target)&&(t.code===ue.MINUS||t.code===ue.EQUAL)){t.preventDefault();return}if(ar(t.target)&&t.key!==T.ESCAPE||jn(t.key)&&fu(t.target))return;if(t.key===T.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===T.E&&t.shiftKey&&t[T.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===T.PAGE_UP||t.key===T.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===T.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[T.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),jn(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(oe),s=new Set;a.filter(oe).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),g=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||g}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?jp:this.getEffectiveGridSize())||(t.shiftKey?Lb:jp),m=0,d=0;t.key===T.ARROW_LEFT?m=-c:t.key===T.ARROW_RIGHT?m=c:t.key===T.ARROW_UP?d=-c:t.key===T.ARROW_DOWN&&(d=c),a.forEach(p=>{B(p,{x:p.x+m,y:p.y+d},!1),at(p,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:Dc(a.filter(p=>p.id!==l?.id||c!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===T.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[T.CTRL_OR_CMD])le(l)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==a[0].id)&&(this.store.shouldCaptureIncrement(),oe(l)||this.setState({editingLinearElement:new j(l)}));else if(Z(l)||q0(l)){let s;Z(l)||(s=l);let c=Ac(l,this.state,this.scene.getNonDeletedElementsMap()),m=c.x,d=c.y;this.startTextEditing({sceneX:m,sceneY:d,container:s}),t.preventDefault();return}else ae(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=Xv(t.key);a?(this.state.activeTool.type!==a&&ye("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Et.sharp?Et.round:l.currentItemArrowType===Et.round?Et.elbow:Et.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===T.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===T.SPACE&&Ae.pointers.size===0&&(Hi=!0,Le(this.interactiveCanvas,Se.GRAB),t.preventDefault()),(t.key===T.G||t.key===T.S)&&!t.altKey&&!t[T.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===T.G&&(un(this.state.activeTool.type)||a.some(l=>un(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===T.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[T.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===T.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=>Z(l)||be(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===T.K&&!t.altKey&&!t[T.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[T.CTRL_OR_CMD]&&(t.key===T.BACKSPACE||t.key===T.DELETE)&&kt.set(Oi,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===T.S&&t.shiftKey,i=t.key===T.I||r===T.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));I(this,"onKeyUp",ot(t=>{if(t.key===T.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?Le(this.interactiveCanvas,Se.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?wo(this.interactiveCanvas):(To(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Hi=!1),!t[T.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),jn(t.key)&&(si(this.scene.getSelectedElements(this.state).filter(le),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,li(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:A.IMMEDIATELY})),!t[T.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:Me({[r.id]:!0},n)})),ta([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:A.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=Ue(this.state,t);m0(document.activeElement)&&this.focusContainer(),M0(n.type)||this.setState({suggestedBindings:[]}),n.type==="image"&&this.onImageAction({insertOnCanvasDirectly:(t.type==="image"&&t.insertOnCanvasDirectly)??!1}),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};n.type==="freedraw"&&this.store.shouldCaptureIncrement();let l;return n.type==="lasso"?l={...i,activeTool:n,...r?{}:{selectedElementIds:Me({},i),selectedGroupIds:Me({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?l={...i,activeTool:n,selectedElementIds:Me({},i),selectedGroupIds:Me({},i),editingGroupId:null,multiElement:null,...a}:l={...i,activeTool:n,...a},n.type==="hand"?Le(this.interactiveCanvas,Se.GRAB):Hi||To(this.interactiveCanvas,{...this.state,activeTool:n}),l})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{Le(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{wo(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>Ae.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${gu()}`);I(this,"onGestureStart",ot(t=>{if(t.preventDefault(),this.props.interactive===!1)return!1;this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null}),Ae.initialScale=this.state.zoom.value}));I(this,"onGestureChange",ot(t=>{if(t.preventDefault(),this.props.interactive===!1)return!1;if(this.isTouchScreenMultiTouchGesture())return;let r=Ae.initialScale;r&&this.setState(n=>({...Gr({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:mr(r*t.scale)},n)}))}));I(this,"onGestureEnd",ot(t=>{if(t.preventDefault(),this.props.interactive===!1)return!1;this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}),Ae.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&&(be(i,this.scene.getNonDeletedElementsMap())||(l=!0));let c=null,m=this.scene.getSelectedElements(this.state);m.length===1?Z(m[0])?c=m[0]:i?c=be(m[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(t,r):c=this.getTextElementAtPosition(t,r);let d=c?.fontFamily||this.state.currentItemFontFamily,p=c?.lineHeight||Lr(d),u=this.state.currentItemFontSize;if(!c&&l&&i&&!ke(i)){let E=kc(Je({fontSize:u,fontFamily:d}),p),w=Mc(u,p),y=Math.max(i.height,w),v=Math.max(i.width,E);B(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 g=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=c||Yt({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?to.MIDDLE:Jp,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?ke(i)?0:i.angle:0,frameId:g?g.id:null});if(!c&&l&&i&&B(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!c)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||c||i?this.handleTextWysiwyg(b,{isExistingElement:!!c}):this.setState({newElement:b,multiElement:null})});I(this,"startImageCropping",t=>{this.store.shouldCaptureIncrement(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.shouldCaptureIncrement(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=je(t,this.state);if(r.length===1&&le(r[0])){if(t[T.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)&&!oe(r[0])){this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new j(r[0])});return}else if(this.state.selectedLinearElement&&oe(r[0])){let l=j.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),s=l?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(s&&s>-1){this.store.shouldCaptureIncrement(),j.deleteFixedSegment(r[0],s);let c=j.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=c?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:c}});return}}}if(r.length===1&&fe(r[0])){this.startImageCropping(r[0]);return}if(wo(this.interactiveCanvas),$o(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&Cx(l,this.state.selectedGroupIds);if(s){this.store.shouldCaptureIncrement(),this.setState(c=>({...c,...lt({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(wo(this.interactiveCanvas),!t[T.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(Xi(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(pt(s)||!ti(s.backgroundColor)||ji({x:n,y:i,element:s,shape:Or(s,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()}))){let c=Ac(s,this.state,this.scene.getNonDeletedElementsMap());n=c.x,i=c.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}});I(this,"getElementLinkAtPosition",(t,r)=>{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&&ed(l,this.scene.getNonDeletedElementsMap(),this.state,M(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,r)=>{let n=qn(M(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),M(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>Zn)return;let i=je(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=ed(this.hitLinkElement,a,this.state,M(i.x,i.y),this.device.editor.isMobile),s=je(this.lastPointerUpEvent,this.state),c=ed(this.hitLinkElement,a,this.state,M(s.x,s.y),this.device.editor.isMobile);if(l&&c){Rf();let m=this.hitLinkElement.link;if(m){m=Zo(m);let d;if(this.props.onLinkOpen&&(d=wc("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},d)),!d?.defaultPrevented){let p=Cc(m)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=m)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>Mu(t,i,r));return n.length?n[n.length-1]:null});I(this,"handleCanvasPointerMove",t=>{if(this.props.interactive===!1)return!1;this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,Ae.pointers.has(t.pointerId)&&Ae.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=Ae.initialScale;if(Ae.pointers.size===2&&Ae.lastCenter&&r&&Ae.initialDistance){let u=s1(Ae.pointers),g=u.x-Ae.lastCenter.x,b=u.y-Ae.lastCenter.y;Ae.lastCenter=u;let x=c1(Array.from(Ae.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:x/Ae.initialDistance,w=E?mr(r*E):this.state.zoom.value;this.setState(y=>{let v=Gr({viewportX:u.x,viewportY:u.y,nextZoom:w},y);this.translateCanvas({zoom:v.zoom,scrollX:v.scrollX+2*(g/w),scrollY:v.scrollY+2*(b/w),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else Ae.lastCenter=Ae.initialDistance=Ae.initialScale=null;if(Hi||Ks||nb||jo(this.state))return;let i=u1(ib,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?wo(this.interactiveCanvas):To(this.interactiveCanvas,this.state));let a=je(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Cw(this.state.activeTool.type)){let{originOffset:u,snapLines:g}=Tw(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(b=>{let x=Zi(b.snapLines,g),E=b.originSnapOffset?Zi(b.originSnapOffset,u):u;return b.snapLines===x&&b.originSnapOffset===E?null:{snapLines:x,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(u=>u.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let u=j.handlePointerMove(t,l,s,this,this.scene.getNonDeletedElementsMap());u&&u!==this.state.editingLinearElement&&Fi(()=>{this.setState({editingLinearElement:u})}),u?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(a,u.elbowed):Fi(()=>{this.setState({suggestedBindings:[]})})}if(L0(this.state.activeTool.type)){let{newElement:u}=this.state;Pr(u,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(u,[a],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:u}=this.state,{x:g,y:b}=u,{points:x,lastCommittedPoint:E}=u,w=x[x.length-1];if(To(this.interactiveCanvas,this.state),w===E)qn(M(l-g,s-b),w)>=tc?B(u,{points:[...x,M(l-g,s-b)]},!1):Le(this.interactiveCanvas,Se.POINTER);else if(x.length>2&&E&&qn(M(l-g,s-b),E)<tc)Le(this.interactiveCanvas,Se.POINTER),B(u,{points:x.slice(0,-1)},!1);else{let[y,v]=ht(l,s,t[T.CTRL_OR_CMD]||oe(u)?null:this.getEffectiveGridSize()),[C,S]=u?.lastCommittedPoint??[0,0],_=y-g-C,L=v-b-S;bc(t)&&({width:_,height:L}=Cu(C+g,S+b,y,v)),Pl(x,this.state.zoom.value)&&Le(this.interactiveCanvas,Se.POINTER),B(u,{points:[...x.slice(0,-1),M(C+_,S+L)]},!1,{isDragging:!0}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!i&&!this.state.editingLinearElement){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&&oe(d[0]))){let u=nh(m,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(u&&u.transformHandleType){Le(this.interactiveCanvas,ah(u));return}}}else if(d.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let u=ih(ve(d),l,s,this.state.zoom,t.pointerType,this.device);if(u){Le(this.interactiveCanvas,ah({transformHandleType:u}));return}}let p=this.getElementAtPosition(a.x,a.y);this.hitLinkElement=this.getElementLinkAtPosition(a,p),!ao(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(Le(this.interactiveCanvas,Se.POINTER),q2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Rf(),p&&(p.link||Ht(p))&&this.state.selectedElementIds[p.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Le(this.interactiveCanvas,Z(p)?Se.TEXT:Se.CROSSHAIR):this.state.viewModeEnabled?Le(this.interactiveCanvas,Se.GRAB):this.state.openDialog?.name==="elementLinkSelector"?Le(this.interactiveCanvas,Se.AUTO):i?Le(this.interactiveCanvas,Se.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s):t[T.CTRL_OR_CMD]?Le(this.interactiveCanvas,Se.AUTO):(p||this.isHittingCommonBoundingBoxOfSelectedElements(a,d))&&!p?.locked&&(p&&Xi(p)&&this.isIframeLikeElementCenter(p,t,l,s)?(Le(this.interactiveCanvas,Se.POINTER),this.setState({activeEmbeddable:{element:p,state:"hover"}})):(!p||!oe(p)||!(p.startBinding||p.endBinding))&&(Le(this.interactiveCanvas,Se.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))),this.state.openDialog?.name==="elementLinkSelector"&&p?this.setState(u=>({hoveredElementIds:Zi(u.hoveredElementIds,lt({editingGroupId:u.editingGroupId,selectedElementIds:{[p.id]:!0}},this.scene.getNonDeletedElements(),u,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!p&&this.setState(u=>({hoveredElementIds:Zi(u.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=>{Zs=!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.map(p=>({...p,focus:!1}))})),kt.set(z1,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:Me(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"?A.EVENTUALLY:A.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=Ki(this.device,{isTouchScreen:!0})),Ks||(this.lastPointerDownEvent=t,this.props.interactive!==!1&&this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===nr.ERASER&&this.state.activeTool.type!==it.eraser){this.setState({activeTool:Ue(this.state,{type:it.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let d=()=>{p(),u?.(),ao(this.state)&&this.setState({activeTool:Ue(this.state,{...this.state.activeTool.lastActiveTool||{type:it.selection},lastActiveToolBeforeEraser:null})})},p=We(window,"pointerup",d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(t.button!==nr.MAIN&&t.button!==nr.TOUCH&&t.button!==nr.ERASER||Ae.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.props.interactive!==!1&&this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.props.interactive!==!1&&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")this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey);else if(this.state.activeTool.type==="text")this.handleTextOnPointerDown(t,i);else if(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i);else if(this.state.activeTool.type==="image"){Le(this.interactiveCanvas,Se.CROSSHAIR);let d=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!d)return;this.setState({newElement:d,pendingImageElementId:null,multiElement:null});let{x:p,y:u}=je(t,this.state),g=this.getTopLayerFrameAtSceneCoords({x:p,y:u});B(d,{x:p,y:u,frameId:g?g.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?To(this.interactiveCanvas,this.state):this.state.activeTool.type===it.frame||this.state.activeTool.type===it.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.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),c=this.onKeyDownFromPointerDownHandler(i),m=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(d=>s(d||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",l),window.addEventListener("pointerup",s),window.addEventListener("keydown",c),window.addEventListener("keyup",m),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=m,i.eventListeners.onKeyDown=c)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=je({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(Xi(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);this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&Xi(this.hitLinkElement)&&!tE(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,M(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"&&(Zs=!1,Yn?Zs=!0:Yn=window.setTimeout(()=>{Yn=0,Zs||this.handleCanvasContextMenu(t)},Bb))});I(this,"resetContextMenuTimer",()=>{clearTimeout(Yn),Yn=0,Zs=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{Xs?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(Ae.pointers.size<=1&&(t.button===nr.WHEEL||t.button===nr.MAIN&&Hi||jo(this.state)||this.state.viewModeEnabled)))return!1;Ks=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Le(this.interactiveCanvas,Se.GRABBING);let{clientX:i,clientY:a}=t,l=sp(c=>{let m=i-c.clientX,d=a-c.clientY;if(i=c.clientX,a=c.clientY,n&&!r&&(Math.abs(m)>1||Math.abs(d)>1)){r=!0;let p=g=>{document.body.removeEventListener("paste",p),g.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener("paste",p),window.removeEventListener("pointerup",u)},100)};document.body.addEventListener("paste",p),window.addEventListener("pointerup",u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=ot(Xs=()=>{Xs=null,Ks=!1,Hi||(this.state.viewModeEnabled?Le(this.interactiveCanvas,Se.GRAB):To(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("blur",s),l.flush()});return window.addEventListener("blur",s),window.addEventListener("pointermove",l,{passive:!0}),window.addEventListener("pointerup",s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,r)=>{if(this.state.activeTool.type==="selection"){let n=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.editingLinearElement&&!oe(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=nh(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=ih(ve(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=an(kE(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&le(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=ME(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let c=this.state.editingLinearElement||this.state.selectedLinearElement,m=j.handlePointerDown(t,this,this.store,r.origin,c,this.scene);if(m.hitElement&&(r.hit.element=m.hitElement),m.linearElementEditor&&(this.setState({selectedLinearElement:m.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:m.linearElementEditor})),m.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,r.hit.element),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=this.getElementsAtPosition(r.origin.x,r.origin.y);let l=r.hit.element,s=r.hit.allHitElements.some(c=>this.isASelectedElement(c));if((l===null||!s)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(l),this.state.editingLinearElement)this.setState({selectedElementIds:Me({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(l!=null){if(t[T.CTRL_OR_CMD])return this.state.selectedElementIds[l.id]||(r.hit.wasAddedToSelection=!0),this.setState(c=>({...Tx(c,l),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[l.id]||(this.state.editingGroupId&&!na(l,this.state.editingGroupId)&&this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!s&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(c=>{let m={...c.selectedElementIds,[l.id]:!0},d=[];if(Object.keys(c.selectedElementIds).forEach(p=>{let u=this.scene.getElement(p);u&&d.push(u)}),ae(l))_o(d,l.id).forEach(p=>{delete m[p.id]});else if(l.frameId)m[l.frameId]&&delete m[l.id];else{let p=l.groupIds,u=new Set(p.flatMap(g=>Fe(this.scene.getNonDeletedElements(),g)).filter(g=>ae(g)).map(g=>g.id));u.size>0&&d.forEach(g=>{g.frameId&&u.has(g.frameId)&&(delete m[g.id],g.groupIds.flatMap(b=>Fe(this.scene.getNonDeletedElements(),b)).forEach(b=>{delete m[b.id]}))})}return c.openDialog?.name==="elementLinkSelector"&&(l.groupIds.some(p=>c.selectedGroupIds[p])||(m={[l.id]:!0})),{...lt({editingGroupId:c.editingGroupId,selectedElementIds:m},this.scene.getNonDeletedElements(),c,this),showHyperlinkPopup:l.link||Ht(l)?"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);pt(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}),wo(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Ue(this.state,{type:"selection"})})});I(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=ht(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,c=Vx({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:s,locked:!1,frameId:l?l.id:null,points:[M(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(d=>{let p={...d.selectedElementIds};return delete p[c.id],{selectedElementIds:Me(p,d)}});let m=mn(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:c,startBoundElement:m,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=ht(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=Ux({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]=ht(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=ui(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let s=Bu({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,"createImageElement",({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,a]=ht(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null;return Xc({type:"image",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,roundness:null,opacity:this.state.currentItemOpacity,locked:!1,frameId:l?l.id:null})});I(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&Pl(i.points,this.state.zoom.value)){B(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(co);return}if(oe(i)&&i.points.length>1){B(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(co);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&qn(M(n.origin.x-a,n.origin.y-l),s)<tc){this.actionManager.executeAction(co);return}this.setState(c=>({selectedElementIds:Me({...c.selectedElementIds,[i.id]:!0},c)})),B(i,{lastCommittedPoint:i.points[i.points.length-1]}),Le(this.interactiveCanvas,Se.POINTER)}else{let[i,a]=ht(n.origin.x,n.origin.y,t[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,d]=r==="arrow"?[s,c]:[null,null],p=r==="arrow"?sa({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===Et.round?{type:oo.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:d,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Et.elbow,fixedSegments:this.state.currentItemArrowType===Et.elbow?[]:null}):dr({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:oo.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(g=>{let b={...g.selectedElementIds};return delete b[p.id],{selectedElementIds:Me(b,g)}}),B(p,{points:[...p.points,M(0,0)]});let u=mn(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,oe(p),oe(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=ht(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[T.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=Bu({type:"embeddable",...l}):s=Vt({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]=ht(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Wo},l=r===it.magicframe?Nl(a):la(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)||_e(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,re(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(r))});I(this,"initializeImage",async({imageFile:t,imageElement:r,showCursorImagePreview:n=!1})=>{if(!nd(t))throw new Error(f("errors.unsupportedFileType"));let i=t.type;if(Le(this.interactiveCanvas,"wait"),i===ge.svg)try{t=Xu(Fu(await t.text()),t.name)}catch(m){throw console.warn(m),new Error(f("errors.svgImageInsertError"))}let a=await(this.props.generateIdForFile?.(t)||dE(t));if(!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[a]?.dataURL){try{t=await Hl(t,{maxWidthOrHeight:Wb})}catch(m){console.error("Error trying to resizing image file on insertion",m)}if(t.size>ru)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(ru/1024/1024)}MB`}))}if(n){let m=this.files[a]?.dataURL,d=m&&pE(m);this.setImagePreviewCursor(d||t)}let s=this.files[a]?.dataURL||await ad(t),c=B(r,{fileId:a},!1);return new Promise(async(m,d)=>{try{this.addMissingFiles([{mimeType:i,id:a,dataURL:s,created:Date.now(),lastRetrieved:Date.now()}]);let p=this.imageCache.get(a);p||(this.addNewImagesToImageCache(),await this.updateImageCache([c])),p?.image instanceof Promise&&await p.image,this.state.pendingImageElementId!==c.id&&this.state.newElement?.id!==c.id&&this.initializeImageDimensions(c,!0),m(c)}catch(p){console.error(p),d(new Error(f("errors.imageInsertError")))}finally{n||wo(this.interactiveCanvas)}})});I(this,"insertImageElement",async(t,r,n)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:n})}catch(i){return B(t,{isDeleted:!0}),this.actionManager.executeAction(co),this.setState({errorMessage:i.message||f("errors.imageInsertError")}),null}});I(this,"setImagePreviewCursor",async t=>{let n;try{n=await Hl(t,{maxWidthOrHeight:96})}catch(a){throw a.cause==="UNSUPPORTED"?new Error(f("errors.unsupportedFileType")):a}let i=await ad(n);if(t.type===ge.svg){let a=await Wx(i),l=Math.min(a.height,96),s=l*(a.width/a.height);s>96&&(s=96,l=s*(a.height/a.width));let c=document.createElement("canvas");c.height=l,c.width=s,c.getContext("2d").drawImage(a,0,0,s,l),i=c.toDataURL(ge.svg)}this.state.pendingImageElementId&&Le(this.interactiveCanvas,`url(${i}) 4 4, auto`)});I(this,"onImageAction",async({insertOnCanvasDirectly:t})=>{try{let r=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:i,y:a}=je({clientX:r,clientY:n},this.state),l=await Jc({description:"Image",extensions:Object.keys(gl)}),s=this.createImageElement({sceneX:i,sceneY:a,addToFrameUnderCursor:!1});t?(this.insertImageElement(s,l),this.initializeImageDimensions(s),this.setState({selectedElementIds:Me({[s.id]:!0},this.state)},()=>{this.actionManager.executeAction(co)})):this.setState({pendingImageElementId:s.id},()=>{this.insertImageElement(s,l,!0)})}catch(r){r.name!=="AbortError"?console.error(r):console.warn(r),this.setState({pendingImageElementId:null,newElement:null,activeTool:Ue(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(co)})}});I(this,"initializeImageDimensions",(t,r=!1)=>{let n=Dr(t)&&this.imageCache.get(t.fileId)?.image;if(!n||n instanceof Promise){if(t.width<Zn/this.state.zoom.value&&t.height<Zn/this.state.zoom.value){let i=100/this.state.zoom.value;B(t,{x:t.x-i/2,y:t.y-i/2,width:i,height:i})}return}if(r||t.width<Zn/this.state.zoom.value&&t.height<Zn/this.state.zoom.value){let i=Math.max(this.state.height-120,160),a=Math.min(i,Math.floor(this.state.height*.5)/this.state.zoom.value),l=Math.min(n.naturalHeight,a),s=l*(n.naturalWidth/n.naturalHeight),c=t.x+t.width/2-s/2,m=t.y+t.height/2-l/2;B(t,{x:c,y:m,width:s,height:l,crop:null})}});I(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await Kx({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:r});if(n.size||i.size)for(let a of t)n.has(a.fileId)&&hn.delete(a);return i.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Dr(a)&&i.has(a.fileId)?re(a,{status:"error"}):a)),{updatedFiles:n,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=Zx(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);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",yA(()=>{this.addNewImagesToImageCache()},Nb));I(this,"updateBindingEnabledOnPointerMove",t=>{let r=Q0(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});I(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=mn(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});I(this,"maybeSuggestBindingsForLinearElementAtCoords",(t,r,n)=>{if(!r.length)return;let i=r.reduce((a,l)=>{let s=mn(l,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,oe(t),oe(t));return s!=null&&!ox(t,n?.id,s)&&a.push(s),a},[]);this.setState({suggestedBindings:i})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener("touchstart",this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener("touchend",this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener("touchstart",this.onTouchStart),this.interactiveCanvas?.removeEventListener("touchend",this.onTouchEnd))});I(this,"handleAppOnDrop",async t=>{let{file:r,fileHandle:n}=await gE(t),{x:i,y:a}=je(t,this.state);try{if(nd(r)&&this.isToolSupported("image")){if(r?.type===ge.png||r?.type===ge.svg)try{let c=await id(r,this.state,this.scene.getElementsIncludingDeleted(),n);this.syncActionResult({...c,appState:{...c.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:A.IMMEDIATELY});return}catch(c){if(c.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}let s=this.createImageElement({sceneX:i,sceneY:a});this.insertImageElement(s,r),this.initializeImageDimensions(s),this.setState({selectedElementIds:Me({[s.id]:!0},this.state)});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let l=t.dataTransfer.getData(ge.excalidrawlib);if(l&&typeof l=="string"){try{let s=cE(l);this.addElementsFromPasteOrLibrary({elements:Fm(s),position:t,files:null})}catch(s){this.setState({errorMessage:s.message})}return}if(r&&await this.loadFileToCanvas(r,n),t.dataTransfer?.types?.includes("text/plain")){let s=t.dataTransfer?.getData("text");if(s&&ca(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||ui(s)?.type==="video")){let c=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:Zo(s)});c&&this.setState({selectedElementIds:{[c.id]:!0}})}}});I(this,"loadFileToCanvas",async(t,r)=>{t=await bE(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await Ku(t,this.state,n,r)}catch(a){let l=a instanceof Jx;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let s=l?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===ge.excalidraw?(Nr(n.concat(i.data.elements)),this.store.updateSnapshot(te(n),this.state),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:A.IMMEDIATELY})):i.type===ge.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:f("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),this.props.interactive===!1||("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==nr.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:n}=je(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",c=this.excalidrawContainerRef.current,{top:m,left:d}=c.getBoundingClientRect(),p=t.clientX-d,u=t.clientY-m;ye("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...lt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:le(i)?new j(i):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"){lh({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:ei(t.origin.x,a.x),height:ei(t.origin.y,a.y),shouldMaintainAspectRatio:Gi(r),shouldResizeFromCenter:!1,zoom:this.state.zoom.value,informMutation:n});return}let l=this.state.newElement;if(!l)return;let[s,c]=ht(a.x,a.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=Dr(l)&&this.imageCache.get(l.fileId)?.image,d=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(r,[l]);let{snapOffset:p,snapLines:u}=ww(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:c-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,c+=p.y,this.setState({snapLines:u}),lh({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:ei(t.originInGrid.x,s),height:ei(t.originInGrid.y,c),shouldMaintainAspectRatio:fe(l)?!Gi(r):Gi(r),shouldResizeFromCenter:au(r),zoom:this.state.zoom.value,widthAspectRatio:d,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===it.frame||this.state.activeTool.type===it.magicframe)&&this.setState({elementsToHighlight:oa(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]=ht(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&fe(s)){let c=t.originalElements.get(s.id),m=Dr(s)&&this.imageCache.get(s.fileId)?.image;if(c&&fe(c)&&m&&!(m instanceof Promise)){let[d,p]=ht(i.x,i.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:g,snapLines:b}=m1([s],[c],this,r,u,n);B(s,Px(s,n,m.naturalWidth,m.naturalHeight,a+g.x,l+g.y,r.shiftKey?c.width/c.height:void 0)),at(s,this.scene.getNonDeletedElementsMap(),{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=>ae(d)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&oe(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=ht(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(d=>{_o(this.scene.getNonDeletedElements(),d.id).forEach(u=>{m.set(d.id+u.id,{x:u.x-d.x,y:u.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,p]=ht(l.x,l.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y},g=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=m1(n,J(g,this.state),this,r,u,a);s+=b.x,c+=b.y,this.setState({snapLines:x})}if(SE(t.originalElements,a,n,this.scene.getElementsMapIncludingDeleted(),this.scene,bc(r),au(r),n.some(d=>fe(d))?!Gi(r):Gi(r),s,c,t.resize.center.x,t.resize.center.y)){let d=Dc(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{oa(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(g=>p.add(g))}),this.setState({elementsToHighlight:[...p],suggestedBindings:d}),!0}return!1});I(this,"getContextMenuItems",t=>{let r=[];return r.push(Ts,ws),t==="canvas"?this.state.viewModeEnabled?[...r,Is,Ri,a1,Ni]:[Lf,bt,Ts,ws,Cs,bt,Zd,J2,bt,Is,Lm,Ri,a1,Ni]:(r.push(Cs),this.state.viewModeEnabled?[Pi,...r]:[bt,vs,Pi,Lf,bt,aw,lw,sw,bt,op,bt,...r,bt,ym,vm,bt,wm,uw,Am,_m,Y2,Tm,bt,Sm,bt,Gd,Vd,Yd,Wd,bt,km,Mm,bt,tp,bt,Ua,Rm,bt,Xd,Pm,bt,Ca])});I(this,"handleWheel",ot(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[T.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),Ks||this.props.interactive===!1)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(n),a=Ui*100,l=Math.abs(n),s=n;l>a&&(s=a*i);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(m=>({...Gr({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:mr(c)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(n||r)/i.value}));return}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}=je({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:Ae.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",Qn(()=>{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:c,offsetTop:m,offsetLeft:d}=this.state;if(n===s&&i===c&&a===d&&l===m){t&&t();return}this.setState({width:n,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=Br(),{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=r.theme,name:m=`${f("labels.untitled")}-${gu()}`}=t;if(this.state={...r,theme:c,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight},this.id=wA(),this.library=new Hf(this),this.actionManager=new _s(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new pn,this.canvas=document.createElement("canvas"),this.rc=vA.canvas(this.canvas),this.renderer=new Rs(this.scene),this.visibleElements=[],this.store=new bd,this.history=new ja,n){let d={updateScene:this.updateScene,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,app:this,onChange:p=>this.onChangeEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof n=="function"?n(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new gn(this.scene),this.history=new ja,this.actionManager.registerAll(Ud),this.actionManager.registerAction(dw(this.history,this.store)),this.actionManager.registerAction(mw(this.history,this.store))}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(ul).includes(i)&&ab.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),ri(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=ab.get(t.id);switch(n||(ab.set(t.id,ul.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case ul.PLAYING:case ul.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=>Ht(a)&&this.embedsValidationStatus.get(a.id)===!0||ri(a));return Be(CA,{children:i.map(a=>{let{x:l,y:s}=Ft({sceneX:a.x,sceneY:a.y},this.state),c=Dl(a,r,n,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(c&&!m&&this.initializedEmbeds.add(a.id),!(c||m))return null;let p;if(ri(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:()=>zu(`
|
|
41
|
+
C -->|Three| F[Car]`,WC=VG(js,300),$G=({mermaidToExcalidrawLib:e})=>{let[t,o]=GC(()=>xo.get(WG.MERMAID_TO_EXCALIDRAW)||XG),n=YG(t.trim()),[r,i]=GC(null),a=UC(null),l=UC({elements:[],files:null}),s=Ke();YC(()=>{nu({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:n}).catch(d=>{KG()&&console.error("Failed to parse mermaid definition",d)}),WC(n)},[n,e]),YC(()=>()=>{WC.flush()},[]);let c=()=>{ru({app:s,data:l,text:t,shouldSaveMermaidDataToStorage:!0})};return VC(ZG,{children:[xn("div",{className:"ttd-dialog-desc",children:xn(_t,{i18nKey:"mermaid.description",flowchartLink:d=>xn("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:d}),sequenceLink:d=>xn("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:d}),classLink:d=>xn("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:d})})}),VC(tu,{children:[xn(nl,{label:f("mermaid.syntax"),children:xn(Jp,{input:t,placeholder:"Write Mermaid diagram defintion here...",onChange:d=>o(d.target.value),onKeyboardSubmit:()=>{c()}})}),xn(nl,{label:f("mermaid.preview"),panelAction:{action:()=>{c()},label:f("mermaid.button"),icon:ii},renderSubmitShortcut:()=>xn(ou,{}),children:xn(eu,{canvasRef:a,loaded:e.loaded,error:r})})]})]})},KC=$G;import*as $C from"@radix-ui/react-tabs";import{useRef as XC}from"react";import{isMemberOf as jG}from"@excalidraw/common";import{jsx as qG}from"react/jsx-runtime";var ZC=e=>{let t=pe(),o=XC(null),n=XC(0);return qG($C.Root,{ref:o,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:r=>{if(!r)return;let i=o.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>n.current&&(n.current=a,i.style.minHeight=`min(${n.current}px, 100%)`)}e.dialog==="ttd"&&jG(["text-to-diagram","mermaid"],r)&&t({openDialog:{name:e.dialog,tab:r}})},children:e.children})};ZC.displayName="TTDDialogTabs";var jC=ZC;import*as qC from"@radix-ui/react-tabs";import{jsx as JG}from"react/jsx-runtime";var Cb=({children:e,...t})=>JG(qC.List,{className:"ttd-dialog-triggers",...t,children:e});Cb.displayName="TTDDialogTabTriggers";import*as QC from"@radix-ui/react-tabs";import{jsx as JC}from"react/jsx-runtime";var iu=({children:e,tab:t,onSelect:o,...n})=>JC(QC.Trigger,{value:t,asChild:!0,onSelect:o,children:JC("button",{type:"button",className:"ttd-dialog-tab-trigger",...n,children:e})});iu.displayName="TTDDialogTabTrigger";import*as eS from"@radix-ui/react-tabs";import{jsx as QG}from"react/jsx-runtime";var au=({tab:e,children:t,...o})=>QG(eS.Content,{...o,value:e,children:t});au.displayName="TTDDialogTab";import{jsx as Ot,jsxs as Nr}from"react/jsx-runtime";var kb=3,rl=1e3,tU=be(null),oU=be(null),Mb=e=>{let t=Te();return t.openDialog?.name!=="ttd"?null:Ot(nU,{...e,tab:t.openDialog.tab})},nU=Wn("TTDDialogBase",({tab:e,...t})=>{let o=Ke(),n=pe(),r=Sb(null),[i,a]=ce(oU),[l,s]=lu(i?.prompt??""),c=l.trim(),d=C=>{s(C.target.value),a(M=>({generatedResponse:M?.generatedResponse??null,prompt:C.target.value}))},[m,p]=lu(!1),[u,g]=ce(tU),b=async()=>{if(c.length>rl||c.length<kb||m||u?.rateLimitRemaining===0||"__fallback"in t){c.length<kb&&v(new Error(`Prompt is too short (min ${kb} characters)`)),c.length>rl&&v(new Error(`Prompt is too long (max ${rl} characters)`));return}try{p(!0),ae("ai","generate","ttd");let{generatedResponse:C,error:M,rateLimit:k,rateLimitRemaining:P}=await t.onTextSubmit(c);if(typeof C=="string"&&a(A=>({generatedResponse:C,prompt:A?.prompt??null})),tS(k)&&tS(P)&&g({rateLimit:k,rateLimitRemaining:P}),M){v(M);return}if(!C){v(new Error("Generation failed"));return}try{await nu({canvasRef:r,data:y,mermaidToExcalidrawLib:w,setError:v,mermaidDefinition:C}),ae("ai","mermaid parse success","ttd")}catch(A){console.info(`%cTTD mermaid render errror: ${A.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
42
|
+
TTD mermaid definition render errror: ${A.message}`,"color: yellow"),ae("ai","mermaid parse failed","ttd"),v(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(C){let M=C.message;(!M||M==="Failed to fetch")&&(M="Request failed"),v(new Error(M))}finally{p(!1)}},x=Sb(b);x.current=b;let[w,E]=lu({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});eU(()=>{(async()=>{await w.api,E(M=>({...M,loaded:!0}))})()},[w.api]);let y=Sb({elements:[],files:null}),[T,v]=lu(null);return Ot($e,{className:"ttd-dialog",onCloseRequest:()=>{o.setOpenDialog(null)},size:1200,title:!1,...t,autofocus:!1,children:Nr(jC,{dialog:"ttd",tab:e,children:["__fallback"in t&&t.__fallback?Ot("p",{className:"dialog-mermaid-title",children:f("mermaid.title")}):Nr(Cb,{children:[Ot(iu,{tab:"text-to-diagram",children:Nr("div",{style:{display:"flex",alignItems:"center"},children:[f("labels.textToDiagram"),Ot("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"})]})}),Ot(iu,{tab:"mermaid",children:"Mermaid"})]}),Ot(au,{className:"ttd-dialog-content",tab:"mermaid",children:Ot(KC,{mermaidToExcalidrawLib:w})}),!("__fallback"in t)&&Nr(au,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[Ot("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."}),Nr(tu,{children:[Ot(nl,{label:f("labels.prompt"),panelAction:{action:b,label:"Generate",icon:ii},onTextSubmitInProgess:m,panelActionDisabled:c.length>rl||u?.rateLimitRemaining===0,renderTopRight:()=>u?Nr("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:()=>Ot(ou,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Nr("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(js(i.generatedResponse),n({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",Ot(sr,{icon:ii})]});let C=c.length/rl;return C>.8?Nr("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:C>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",rl]}):null},children:Ot(Jp,{onChange:d,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),Ot(nl,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),ru({app:o,data:y})},label:"Insert",icon:ii},children:Ot(eu,{canvasRef:r,error:T,loaded:w.loaded})})]})]})]})})});import{round as zS}from"@excalidraw/math";import fY from"clsx";import bY from"lodash.throttle";import{useEffect as GS,useMemo as Ub,useState as xY,memo as EY}from"react";import{STATS_PANELS as hu}from"@excalidraw/common";import{getCommonBounds as yY}from"@excalidraw/element";import{getUncroppedWidthAndHeight as wY}from"@excalidraw/element";import{isElbowArrow as vY,isImageElement as Yb}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as TY}from"@excalidraw/element";import{elementsAreInSameGroup as IY}from"@excalidraw/element";import{degreesToRadians as lS,radiansToDegrees as mS}from"@excalidraw/math";import{getBoundTextElement as sS}from"@excalidraw/element";import{isArrowElement as cS,isElbowArrow as hU}from"@excalidraw/element";import{updateBindings as dS}from"@excalidraw/element";import cU from"clsx";import{useEffect as iS,useRef as cu,useState as dU}from"react";import{EVENT as ll,KEYS as mU,cloneJSON as Lb}from"@excalidraw/common";import{deepCopyElement as pU}from"@excalidraw/element";import{CaptureUpdateAction as aS}from"@excalidraw/element";import{pointFrom as Br,pointRotateRads as su}from"@excalidraw/math";import{getBoundTextElement as rU}from"@excalidraw/element";import{isFrameLikeElement as nS}from"@excalidraw/element";import{getSelectedGroupIds as iU,getElementsInGroup as aU,isInGroup as lU}from"@excalidraw/element";import{getFrameChildren as sU}from"@excalidraw/element";import{updateBindings as oS}from"@excalidraw/element";var rS=.01,qs=10,to=(e,t)=>!(t==="angle"&&nS(e)),He=(e,t)=>{let o=e+t/2;return o-o%t},il=(e,t,o)=>Object.keys(e).map(n=>({original:(o??t).get(n),latest:t.get(n)})).filter(n=>n.original!==void 0&&n.latest!==void 0);var Li=(e,t,o,n,r,i=!0)=>{let a=n.getNonDeletedElementsMap(),l=a.get(o.id);if(!l)return;let[s,c]=[o.x+o.width/2,o.y+o.height/2],[d,m]=su(Br(o.x,o.y),Br(s,c),o.angle),p=e-d,u=t-m,[g,b]=su(Br(e,t),Br(s+p,c+u),-o.angle);n.mutateElement(l,{x:g,y:b},{informMutation:i,isDragging:!1}),oS(l,n);let x=rU(o,r);if(x){let w=a.get(x.id);w&&n.mutateElement(w,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(nS(o)){let w=sU(r,o.id);w.forEach(E=>{let y=a.get(E.id);if(!y)return;let[T,v]=[E.x+E.width/2,E.y+E.height/2],[C,M]=su(Br(E.x,E.y),Br(T,v),E.angle),k=Math.round(C+p),P=Math.round(M+u),[A,R]=su(Br(k,P),Br(T+p,v+u),-E.angle);n.mutateElement(y,{x:A,y:R},{informMutation:i,isDragging:!1}),oS(y,n,{simultaneouslyUpdated:w})})}},al=(e,t)=>{let n=iU(t).map(r=>aU(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!lU(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as Ab,jsxs as gU}from"react/jsx-runtime";var uU=({label:e,icon:t,dragInputCallback:o,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:d=1,dragFinishedCallback:m})=>{let p=Ke(),u=pe(),g=cu(null),b=cu(null),[x,w]=dU(n.toString()),E=cu(null);E.current||(E.current={originalAppState:Lb(c),originalElements:r,lastUpdatedValue:x,updatePending:!1}),iS(()=>{let v=n.toString();w(v),E.current.lastUpdatedValue=v},[n]);let y=(v,C,M)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let k=Number(v);if(isNaN(k)){w(n.toString());return}let P=Number(k.toFixed(2)),A=Number(n);(isNaN(A)||Math.abs(P-A)>=rS)&&(E.current.lastUpdatedValue=v,o({accumulatedChange:0,instantChange:0,originalElements:C,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:P,property:l,originalAppState:M,setInputValue:R=>w(String(R)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:aS.IMMEDIATELY}))},T=cu({});return T.current.handleInputValue=y,iS(()=>{let v=g.current,C=T.current;return()=>{let M=v?.value;M&&C.handleInputValue?.(M,E.current.originalElements,E.current.originalAppState),window.removeEventListener(ll.POINTER_MOVE,C.onPointerMove,!1),window.removeEventListener(ll.POINTER_UP,C.onPointerUp,!1)}},[i]),i?gU("div",{className:cU("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Ab("div",{className:"drag-input-label",ref:b,onPointerDown:v=>{if(g.current&&i){document.body.classList.add("excalidraw-cursor-resize");let C=Number(g.current.value);isNaN(C)&&(C=0);let M=null,k=p.scene.getNonDeletedElements().reduce((_,B)=>(_.set(B.id,pU(B)),_),new Map),P=r.map(_=>k.get(_.id)),A=Lb(c),R=0,O=0,U=_=>{if(M&&k!==null&&P!==null){let B=_.clientX-M.x;B!==0&&(O+=B,Math.abs(O)>=d&&(O=Math.sign(O)*Math.floor(Math.abs(O)/d),R+=O,o({accumulatedChange:R,instantChange:O,originalElements:P,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:_.shiftKey,property:l,scene:s,originalAppState:A,setInputValue:j=>w(String(j)),app:p,setAppState:u}),O=0))}M={x:_.clientX,y:_.clientY}},ee=()=>{window.removeEventListener(ll.POINTER_MOVE,U,!1),p.syncActionResult({captureUpdate:aS.IMMEDIATELY}),m?.({app:p,setAppState:u,originalElements:P,originalAppState:A}),M=null,R=0,O=0,P=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(ll.POINTER_UP,ee,!1)};T.current.onPointerMove=U,T.current.onPointerUp=ee,window.addEventListener(ll.POINTER_MOVE,U,!1),window.addEventListener(ll.POINTER_UP,ee,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:t?Ab(sr,{icon:t}):e}),Ab("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:v=>{if(i){let C=v.target;C instanceof HTMLInputElement&&v.key===mU.ENTER&&(y(C.value,r,c),p.focusContainer())}},ref:g,value:x,onChange:v=>{E.current.updatePending=!0,w(v.target.value)},onFocus:v=>{v.target.select(),E.current.originalElements=r,E.current.originalAppState=Lb(c)},onBlur:v=>{x?i&&y(v.target.value,E.current.originalElements,E.current.originalAppState):w(n.toString())},disabled:!i})]}):null},xt=uU;import{jsx as EU}from"react/jsx-runtime";var fU=15,bU=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=t[0];if(a&&!hU(a)){let l=i.get(a.id);if(!l)return;if(n!==void 0){let u=lS(n);r.mutateElement(l,{angle:u}),dS(l,r);let g=sS(l,i);g&&!cS(l)&&r.mutateElement(g,{angle:u});return}let s=Math.round(mS(a.angle)*100)/100,c=Math.round(e),d=(s+c)%360;o&&(d=He(d,fU)),d=d<0?d+360:d;let m=lS(d);r.mutateElement(l,{angle:m}),dS(l,r);let p=sS(l,i);p&&!cS(l)&&r.mutateElement(p,{angle:m})}},xU=({element:e,scene:t,appState:o,property:n})=>EU(xt,{label:"A",icon:_l,value:Math.round(mS(e.angle)%360*100)/100,elements:[e],dragInputCallback:bU,editable:to(e,"angle"),scene:t,appState:o,property:n}),pS=xU;import{jsx as wU}from"react/jsx-runtime";var uS=5,yU=({property:e,scene:t,appState:o,setAppState:n})=>wU(xt,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{n(s=>{let c;return r?c=r:i&&(c=a?He(s.gridStep+uS*Math.sign(i),uS):s.gridStep+i),c?(c=Jx(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:t,value:o.gridStep,property:e,appState:o}),gS=yU;import{clamp as du,round as Pb}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as mu}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as hS,getUncroppedWidthAndHeight as xS}from"@excalidraw/element";import{resizeSingleElement as fS}from"@excalidraw/element";import{isImageElement as ES}from"@excalidraw/element";import{isFrameLikeElement as _b}from"@excalidraw/element";import{getElementsInResizingFrame as Db}from"@excalidraw/element";import{replaceAllElementsInFrame as yS}from"@excalidraw/element";import{jsx as SU}from"react/jsx-runtime";var bS=10,vU=e=>e.type==="image",TU=({accumulatedChange:e,originalElements:t,originalElementsMap:o,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:c,app:d,setAppState:m})=>{let p=c.getNonDeletedElementsMap(),u=t[0],g=p.get(u.id);if(u&&g){let b=n||vU(u),x=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!ES(w)||!w.crop)return;let E=w.crop,y={...E},T=w.scale[0]===-1,v=w.scale[1]===-1,{width:C,height:M}=xS(w),k=E.naturalWidth/C,P=E.naturalHeight/M,A=T?E.width+E.x:E.naturalWidth-E.x,R=v?E.height+E.y:E.naturalHeight-E.y,O=hS*k,U=hS*P;if(i!==void 0){if(a==="width"){let V=i*k,Y=du(V,O,A);y={...y,width:Y,x:T?E.x+E.width-Y:E.x}}else if(a==="height"){let V=i*P,Y=du(V,U,R);y={...y,height:Y,y:v?E.y+E.height-Y:E.y}}c.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/C),height:y.height/(E.naturalHeight/M)});return}let ee=a==="width"?s:0,_=a==="height"?s:0,B=du(E.width+ee,O,A),j=du(E.height+_,O,R);y={...E,x:T?E.x+E.width-B:E.x,y:v?E.y+E.height-j:E.y,width:B,height:j},c.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/C),height:y.height/(E.naturalHeight/M)});return}if(i!==void 0){let w=Math.max(a==="width"?i:b?i*x:u.width,mu),E=Math.max(a==="height"?i:b?i/x:u.height,mu);if(fS(w,E,g,u,o,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),_b(g)){let y=Db(c.getElementsIncludingDeleted(),g,l,c.getNonDeletedElementsMap()),T=yS(c.getElementsIncludingDeleted(),y,g,d);c.replaceAllElements(T)}return}{let w=a==="width"?e:0,E=a==="height"?e:0,y=Math.max(0,u.width+w);a==="width"&&(r?y=He(y,bS):y=Math.round(y));let T=Math.max(0,u.height+E);if(a==="height"&&(r?T=He(T,bS):T=Math.round(T)),b&&(a==="width"?T=Math.round(y/x*100)/100:y=Math.round(T*x*100)/100),T=Math.max(mu,T),y=Math.max(mu,y),fS(y,T,g,u,o,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),_b(g)){let v=Db(c.getElementsIncludingDeleted(),g,l,c.getNonDeletedElementsMap());m({elementsToHighlight:v})}}}},IU=({setAppState:e,app:t,originalElements:o,originalAppState:n})=>{let r=t.scene.getNonDeletedElementsMap(),i=o?.[0],a=i&&r.get(i.id);if(a&&_b(a)){let l=Db(t.scene.getElementsIncludingDeleted(),a,n,t.scene.getNonDeletedElementsMap()),s=yS(t.scene.getElementsIncludingDeleted(),l,a,t);t.scene.replaceAllElements(s),e({elementsToHighlight:null})}},CU=({property:e,element:t,scene:o,appState:n})=>{let r=Pb(e==="width"?t.width:t.height,2);if(n.croppingElementId&&n.croppingElementId===t.id&&ES(t)&&t.crop){let{width:i,height:a}=xS(t);if(e==="width"){let l=i/t.crop.naturalWidth;r=Pb(t.crop.width*l,2)}if(e==="height"){let l=a/t.crop.naturalHeight;r=Pb(t.crop.height*l,2)}}return SU(xt,{label:e==="width"?"W":"H",elements:[t],dragInputCallback:TU,value:r,editable:to(t,e),scene:o,appState:n,property:e,dragFinishedCallback:IU})},Rb=CU;import{getBoundTextElement as kU,redrawTextBoundingBox as MU}from"@excalidraw/element";import{hasBoundTextElement as LU,isTextElement as vS}from"@excalidraw/element";import{jsx as DU}from"react/jsx-runtime";var wS=4,AU=4,PU=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=t[0];if(a){let l=i.get(a.id);if(!l||!vS(l))return;let s;if(n!==void 0)s=Math.max(Math.round(n),wS);else if(a.type==="text"){let c=Math.round(a.fontSize),d=Math.round(e);s=Math.max(c+d,wS),o&&(s=He(s,AU))}s&&(r.mutateElement(l,{fontSize:s}),MU(l,r.getContainerElement(l),r))}},_U=({element:e,scene:t,appState:o,property:n})=>{let r=vS(e)?e:LU(e)?kU(e,t.getNonDeletedElementsMap()):null;return r?DU(xt,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:PU,icon:er,appState:o,scene:t,property:n}):null},TS=_U;import{degreesToRadians as IS,radiansToDegrees as kS}from"@excalidraw/math";import{getBoundTextElement as CS}from"@excalidraw/element";import{isArrowElement as SS}from"@excalidraw/element";import{isInGroup as Nb}from"@excalidraw/element";import{jsx as OU}from"react/jsx-runtime";var RU=15,NU=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=t.map(c=>a.get(c.id)).filter(c=>c&&!Nb(c)&&to(c,r)),s=t.filter(c=>!Nb(c)&&to(c,r));if(n!==void 0){let c=IS(n);for(let d of l){if(!d)continue;i.mutateElement(d,{angle:c});let m=CS(d,a);m&&!SS(d)&&i.mutateElement(m,{angle:c})}i.triggerUpdate();return}for(let c=0;c<l.length;c++){let d=l[c];if(!d)continue;let m=s[c],p=Math.round(kS(m.angle)*100)/100,u=Math.round(e),g=(p+u)%360;o&&(g=He(g,RU)),g=g<0?g+360:g;let b=IS(g);i.mutateElement(d,{angle:b});let x=CS(d,a);x&&!SS(d)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},BU=({elements:e,scene:t,appState:o,property:n})=>{let r=e.filter(s=>!Nb(s)&&to(s,"angle")),i=r.map(s=>Math.round(kS(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>to(s,"angle"));return OU(xt,{label:"A",icon:_l,value:a,elements:e,dragInputCallback:NU,editable:l,appState:o,scene:t,property:n})},MS=BU;import{pointFrom as LS}from"@excalidraw/math";import{useMemo as FU}from"react";import{MIN_WIDTH_OR_HEIGHT as Or}from"@excalidraw/common";import{getElementsInResizingFrame as Bb,isFrameLikeElement as Ob,replaceAllElementsInFrame as _S,updateBoundElements as HU}from"@excalidraw/element";import{rescalePointsInElement as zU,resizeSingleElement as AS}from"@excalidraw/element";import{getBoundTextElement as GU,handleBindTextResize as UU}from"@excalidraw/element";import{isTextElement as DS}from"@excalidraw/element";import{getCommonBounds as pu}from"@excalidraw/element";import{jsx as $U}from"react/jsx-runtime";var sl=10,YU=(e,t,o,n)=>{let r=n.x-e,i=n.y-t,a=n.width*o,l=n.height*o,s=e+r*o,c=t+i*o;return{width:a,height:l,x:s,y:c,...zU(n,a,l,!1),...DS(n)?{fontSize:n.fontSize*o}:{}}},WU=(e,t,o,n,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),c=YU(e,t,n,i);l.mutateElement(r,c);let d=GU(i,a);if(d){let m=d.fontSize*n;HU(r,l,{newSize:{width:c.width,height:c.height}});let p=s.get(d.id);p&&DS(p)&&(l.mutateElement(p,{fontSize:m}),UU(r,l,o==="width"?"e":"s",!0))}},PS=(e,t,o,n,r,i,a,l,s,c)=>{i==="width"?t=Math.round(e/n*100)/100:e=Math.round(t*n*100)/100;let d=t/o;for(let m=0;m<l.length;m++){let p=l[m],u=a[m];WU(r[0],r[1],i,d,u,p,s,c)}},VU=({accumulatedChange:e,originalElements:t,originalElementsMap:o,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:c})=>{let d=a.getNonDeletedElementsMap(),m=al(t,n);if(i!==void 0){for(let b of m){let x=il(b,d,o);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,T,v,C]=pu(E),M=v-y,k=C-T,P=M/k,A=Math.max(Or,l==="width"?Math.max(0,i):M),R=Math.max(Or,l==="height"?Math.max(0,i):k);PS(A,R,k,P,LS(y,T),l,w,E,o,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&to(E,l)){let T=l==="width"?Math.max(0,i):E.width;l==="width"&&(r?T=He(T,sl):T=Math.round(T));let v=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(r?v=He(v,sl):v=Math.round(v)),T=Math.max(Or,T),v=Math.max(Or,v),AS(T,v,E,y,o,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Ob(E)){let C=Bb(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap()),M=_S(a.getElementsIncludingDeleted(),C,E,c);a.replaceAllElements(M)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,g=[];for(let b of m){let x=il(b,d,o);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,T,v,C]=pu(E),M=v-y,k=C-T,P=M/k,A=Math.max(0,M+p);l==="width"&&(r?A=He(A,sl):A=Math.round(A));let R=Math.max(0,k+u);l==="height"&&(r?R=He(R,sl):R=Math.round(R)),A=Math.max(Or,A),R=Math.max(Or,R),PS(A,R,k,P,LS(y,T),l,w,E,o,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&to(E,l)){let T=Math.max(0,y.width+p);l==="width"&&(r?T=He(T,sl):T=Math.round(T));let v=Math.max(0,y.height+u);if(l==="height"&&(r?v=He(v,sl):v=Math.round(v)),T=Math.max(Or,T),v=Math.max(Or,v),AS(T,v,E,y,o,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Ob(E)){let C=Bb(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap());g.push(...C)}}}}s({elementsToHighlight:g}),a.triggerUpdate()},KU=({setAppState:e,app:t,originalElements:o,originalAppState:n})=>{let r=t.scene.getNonDeletedElementsMap(),i=o?.[0],a=i&&r.get(i.id);if(a&&Ob(a)){let l=Bb(t.scene.getElementsIncludingDeleted(),a,n,t.scene.getNonDeletedElementsMap()),s=_S(t.scene.getElementsIncludingDeleted(),l,a,t);t.scene.replaceAllElements(s),e({elementsToHighlight:null})}},XU=({property:e,elements:t,elementsMap:o,atomicUnits:n,scene:r,appState:i})=>{let a=FU(()=>n.map(c=>{let d=il(c,o);if(d.length>1){let[p,u,g,b]=pu(d.map(x=>x.latest));return Math.round((e==="width"?g-p:b-u)*100)/100}let[m]=d;return Math.round((e==="width"?m.latest.width:m.latest.height)*100)/100}),[o,n,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return $U(xt,{label:e==="width"?"W":"H",elements:t,dragInputCallback:VU,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:KU})},Fb=XU;import{getBoundTextElement as ZU,redrawTextBoundingBox as RS}from"@excalidraw/element";import{hasBoundTextElement as jU,isTextElement as qU}from"@excalidraw/element";import{isInGroup as JU}from"@excalidraw/element";import{jsx as nY}from"react/jsx-runtime";var NS=4,QU=4,eY=(e,t)=>e.reduce((o,n)=>{if(!n||JU(n))return o;if(qU(n))return o.push(n),o;if(jU(n)){let r=ZU(n,t);if(r)return o.push(r),o}return o},[]),tY=({accumulatedChange:e,originalElements:t,shouldChangeByStepSize:o,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=t.map(s=>i.get(s.id)),l;if(n){l=Math.max(Math.round(n),NS);for(let s of a)r.mutateElement(s,{fontSize:l}),RS(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=t;for(let c=0;c<a.length;c++){let d=a[c],m=s[c],p=Math.round(m.fontSize),u=Math.round(e),g=Math.max(p+u,NS);o&&(g=He(g,QU)),r.mutateElement(d,{fontSize:g}),RS(d,r.getContainerElement(d),r)}r.triggerUpdate()}},oY=({elements:e,scene:t,appState:o,property:n,elementsMap:r})=>{let i=eY(e,r);if(!i.length)return null;let a=i.map(c=>Math.round(c.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return nY(xt,{label:"F",icon:er,elements:i,dragInputCallback:tY,value:l,editable:s,scene:t,property:n,appState:o})},BS=oY;import{pointFrom as Fr,pointRotateRads as uu}from"@excalidraw/math";import{useMemo as rY}from"react";import{isTextElement as iY}from"@excalidraw/element";import{getCommonBounds as Hb}from"@excalidraw/element";import{jsx as dY}from"react/jsx-runtime";var aY=(e,t,o,n,r,i)=>{for(let a=0;a<n.length;a++){let l=n[a],[s,c]=[l.x+l.width/2,l.y+l.height/2],[d,m]=uu(Fr(l.x,l.y),Fr(s,c),l.angle),p=e==="x"?Math.round(d+t):d,u=e==="y"?Math.round(m+o):m;Li(p,u,l,i,r,!1)}},lY=(e,t,o,n,r)=>{let i=r.getNonDeletedElementsMap(),[a,l,,]=Hb(o),s=e-a,c=t-l;for(let d=0;d<o.length;d++){let m=o[d],p=i.get(m.id);if(p&&(!iY(p)||!p.containerId)){let[u,g]=[p.x+p.width/2,p.y+p.height/2],[b,x]=uu(Fr(p.x,p.y),Fr(u,g),p.angle);Li(b+s,x+c,m,r,n,!1)}}},sY=({accumulatedChange:e,originalElements:t,originalElementsMap:o,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(r!==void 0){for(let p of al(t,l)){let u=il(p,s,o);if(u.length>1){let[g,b,,]=Hb(u.map(E=>E.latest));lY(i==="x"?r:g,i==="y"?r:b,u.map(E=>E.original),o,a)}else{let g=u[0]?.original,b=u[0]?.latest;if(g&&b&&to(b,i)){let[x,w]=[g.x+g.width/2,g.y+g.height/2],[E,y]=uu(Fr(g.x,g.y),Fr(x,w),g.angle);Li(i==="x"?r:E,i==="y"?r:y,g,a,o,!1)}}}a.triggerUpdate();return}let c=n?He(e,qs):e;aY(i,i==="x"?c:0,i==="y"?c:0,t,o,a),a.triggerUpdate()},cY=({property:e,elements:t,elementsMap:o,atomicUnits:n,scene:r,appState:i})=>{let a=rY(()=>n.map(s=>{let c=Object.keys(s).map(b=>o.get(b)).filter(b=>b!==void 0);if(c.length>1){let[b,x]=Hb(c);return Math.round((e==="x"?b:x)*100)/100}let[d]=c,[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,g]=uu(Fr(d.x,d.y),Fr(m,p),d.angle);return Math.round((e==="x"?u:g)*100)/100}),[n,o,e]),l=new Set(a).size===1?a[0]:"Mixed";return dY(xt,{label:e==="x"?"X":"Y",elements:t,dragInputCallback:sY,value:l,property:e,scene:r,appState:i})},zb=cY;import{clamp as Js,pointFrom as gu,pointRotateRads as FS,round as OS}from"@excalidraw/math";import{getFlipAdjustedCropPosition as mY,getUncroppedWidthAndHeight as pY}from"@excalidraw/element";import{isImageElement as HS}from"@excalidraw/element";import{jsx as hY}from"react/jsx-runtime";var uY=({accumulatedChange:e,instantChange:t,originalElements:o,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s})=>{let c=l.getNonDeletedElementsMap(),d=o[0],[m,p]=[d.x+d.width/2,d.y+d.height/2],[u,g]=FS(gu(d.x,d.y),gu(m,p),d.angle);if(s.croppingElementId===d.id){let y=c.get(d.id);if(!y||!HS(y)||!y.crop)return;let T=y.crop,v=T,C=y.scale[0]===-1,M=y.scale[1]===-1,{width:k,height:P}=pY(y);if(i!==void 0){if(a==="x"){let O=i*(T.naturalWidth/k);C?v={...T,x:Js(T.naturalWidth-O-T.width,0,T.naturalWidth-T.width)}:v={...T,x:Js(i*(T.naturalWidth/k),0,T.naturalWidth-T.width)}}a==="y"&&(v={...T,y:Js(i*(T.naturalHeight/P),0,T.naturalHeight-T.height)}),l.mutateElement(y,{crop:v});return}let A=(a==="x"?t:0)*(C?-1:1),R=(a==="y"?t:0)*(M?-1:1);v={...T,x:Js(T.x+A,0,T.naturalWidth-T.width),y:Js(T.y+R,0,T.naturalHeight-T.height)},l.mutateElement(y,{crop:v});return}if(i!==void 0){Li(a==="x"?i:u,a==="y"?i:g,d,l,n);return}let b=a==="x"?e:0,x=a==="y"?e:0,w=a==="x"?Math.round(r?He(d.x+b,qs):u+b):u,E=a==="y"?Math.round(r?He(d.y+x,qs):g+x):g;Li(w,E,d,l,n)},gY=({property:e,element:t,elementsMap:o,scene:n,appState:r})=>{let[i,a]=FS(gu(t.x,t.y),gu(t.x+t.width/2,t.y+t.height/2),t.angle),l=OS(e==="x"?i:a,2);if(r.croppingElementId===t.id&&HS(t)&&t.crop){let s=mY(t);s&&(l=OS(e==="x"?s.x:s.y,2))}return hY(xt,{label:e==="x"?"X":"Y",elements:[t],dragInputCallback:uY,scene:n,value:l,property:e,appState:r})},Gb=gY;import{Fragment as Wb,jsx as Q,jsxs as oo}from"react/jsx-runtime";var CY=50,Qs=e=>{let t=en(),o=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:t.selectedElementIds,includeBoundTextElement:!1}),r=kr(e.app);return Q(SY,{...e,appState:t,sceneNonce:o,selectedElements:n,gridModeEnabled:r})},Be=({children:e,columns:t=1,heading:o,style:n,...r})=>Q("div",{className:fY("exc-stats__row",{"exc-stats__row--heading":o}),style:{gridTemplateColumns:`repeat(${t}, 1fr)`,...n},...r,children:e});Be.displayName="StatsRow";var fu=({children:e,order:t,style:o,...n})=>Q("div",{className:"exc-stats__rows",style:{order:t,...o},...n,children:e});fu.displayName="StatsRows";Qs.StatsRow=Be;Qs.StatsRows=fu;var SY=EY(({app:e,onClose:t,renderCustomStats:o,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),d=pe(),m=n.length===1?n[0]:null,p=n.length>1?n:null,u=r.croppingElementId&&Yb(m),g=u?wY(m):null,[b,x]=xY({width:0,height:0}),w=Ub(()=>bY(T=>{let v=yY(T);x({width:Math.round(v[2])-Math.round(v[0]),height:Math.round(v[3])-Math.round(v[1])})},CY),[]);GS(()=>{w(s)},[i,s,w]),GS(()=>()=>w.cancel(),[w]);let E=Ub(()=>al(n,r),[n,r]),y=Ub(()=>TY(n),[n]);return Q("div",{className:"exc-stats",children:oo(st,{padding:3,children:[oo("div",{className:"title",children:[Q("h2",{children:f("stats.title")}),Q("div",{className:"close",onClick:t,children:no})]}),oo(Jl,{label:Q("h3",{children:f("stats.generalStats")}),open:!!(r.stats.panels&hu.generalStats),openTrigger:()=>d(T=>({stats:{open:!0,panels:T.stats.panels^hu.generalStats}})),children:[oo(fu,{children:[Q(Be,{heading:!0,children:f("stats.scene")}),oo(Be,{columns:2,children:[Q("div",{children:f("stats.shapes")}),Q("div",{children:s.length})]}),oo(Be,{columns:2,children:[Q("div",{children:f("stats.width")}),Q("div",{children:b.width})]}),oo(Be,{columns:2,children:[Q("div",{children:f("stats.height")}),Q("div",{children:b.height})]}),a&&oo(Wb,{children:[Q(Be,{heading:!0,children:"Canvas"}),Q(Be,{children:Q(gS,{property:"gridStep",scene:l,appState:r,setAppState:d})})]})]}),o?.(s,r)]}),!y&&n.length>0&&Q("div",{id:"elementStats",style:{marginTop:12},children:Q(Jl,{label:Q("h3",{children:f("stats.elementProperties")}),open:!!(r.stats.panels&hu.elementProperties),openTrigger:()=>d(T=>({stats:{open:!0,panels:T.stats.panels^hu.elementProperties}})),children:oo(fu,{children:[m&&oo(Wb,{children:[u&&Q(Be,{heading:!0,children:f("labels.unCroppedDimension")}),r.croppingElementId&&Yb(m)&&g&&oo(Be,{columns:2,children:[Q("div",{children:f("stats.width")}),Q("div",{children:zS(g.width,2)})]}),r.croppingElementId&&Yb(m)&&g&&oo(Be,{columns:2,children:[Q("div",{children:f("stats.height")}),Q("div",{children:zS(g.height,2)})]}),Q(Be,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?f("labels.imageCropping"):f(`element.${m.type}`)}),Q(Be,{children:Q(Gb,{element:m,property:"x",elementsMap:c,scene:l,appState:r})}),Q(Be,{children:Q(Gb,{element:m,property:"y",elementsMap:c,scene:l,appState:r})}),Q(Be,{children:Q(Rb,{property:"width",element:m,scene:l,appState:r})}),Q(Be,{children:Q(Rb,{property:"height",element:m,scene:l,appState:r})}),!vY(m)&&Q(Be,{children:Q(pS,{property:"angle",element:m,scene:l,appState:r})}),Q(Be,{children:Q(TS,{property:"fontSize",element:m,scene:l,appState:r})})]}),p&&oo(Wb,{children:[IY(p)&&Q(Be,{heading:!0,children:f("element.group")}),oo(Be,{columns:2,style:{margin:"0.3125rem 0"},children:[Q("div",{children:f("stats.shapes")}),Q("div",{children:n.length})]}),Q(Be,{children:Q(zb,{property:"x",elements:p,elementsMap:c,atomicUnits:E,scene:l,appState:r})}),Q(Be,{children:Q(zb,{property:"y",elements:p,elementsMap:c,atomicUnits:E,scene:l,appState:r})}),Q(Be,{children:Q(Fb,{property:"width",elements:p,elementsMap:c,atomicUnits:E,scene:l,appState:r})}),Q(Be,{children:Q(Fb,{property:"height",elements:p,elementsMap:c,atomicUnits:E,scene:l,appState:r})}),Q(Be,{children:Q(MS,{property:"angle",elements:p,scene:l,appState:r})}),Q(Be,{children:Q(BS,{property:"fontSize",elements:p,scene:l,appState:r,elementsMap:c})})]})]})})})]})})},(e,t)=>e.sceneNonce===t.sceneNonce&&e.selectedElements===t.selectedElements&&e.appState.stats.panels===t.appState.stats.panels&&e.gridModeEnabled===t.gridModeEnabled&&e.appState.gridStep===t.appState.gridStep&&e.appState.croppingElementId===t.appState.croppingElementId);import{useCallback as kY,useEffect as US,useState as YS}from"react";import{normalizeLink as MY,KEYS as Vb}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as LY,getLinkIdAndTypeFromSelection as AY}from"@excalidraw/element";import{jsx as cl,jsxs as bu}from"react/jsx-runtime";var PY=({sourceElementId:e,onClose:t,appState:o,scene:n,generateLinkForSelection:r=LY})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=YS(a),[c,d]=YS(!1);US(()=>{let p=J(i,o),u=a;if(p.length>0&&r){let g=AY(p,o);g&&(u=MY(r(g.id,g.type)))}s(u)},[i,o,o.selectedElementIds,a,r]);let m=kY(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&n.mutateElement(p,{link:l})}if(!l&&c&&e){let p=i.get(e);p&&n.mutateElement(p,{link:null})}t?.()},[e,l,i,c,n,t]);return US(()=>{let p=u=>{o.openDialog?.name==="elementLinkSelector"&&u.key===Vb.ENTER&&m(),o.openDialog?.name==="elementLinkSelector"&&u.key===Vb.ESCAPE&&t?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[o,t,m]),bu("div",{className:"ElementLinkDialog",children:[bu("div",{className:"ElementLinkDialog__header",children:[cl("h2",{children:f("elementLink.title")}),cl("p",{children:f("elementLink.desc")})]}),bu("div",{className:"ElementLinkDialog__input",children:[cl(Na,{value:l??"",onChange:p=>{c||d(!0),s(p)},onKeyDown:p=>{p.key===Vb.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&cl($,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{s(null),d(!0)},className:"ElementLinkDialog__remove",icon:zt})]}),bu("div",{className:"ElementLinkDialog__actions",children:[cl(Ln,{label:f("buttons.cancel"),onClick:()=>{t?.()},style:{marginRight:10}}),cl(Ln,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},WS=PY;import _Y,{useState as DY}from"react";import{Fragment as RY,jsx as Kb}from"react/jsx-runtime";var VS=({children:e,onClose:t})=>{let[o,n]=DY(!!e),{container:r}=tt(),i=_Y.useCallback(()=>{n(!1),t&&t(),r?.focus()},[t,r]);return Kb(RY,{children:o&&Kb($e,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:Kb("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import NY from"react";import{isDarwin as KS,isFirefox as XS,isWindows as BY}from"@excalidraw/common";import{KEYS as Ue,getShortcutKey as X}from"@excalidraw/common";import{Fragment as ZS,jsx as F,jsxs as mo}from"react/jsx-runtime";var OY=()=>mo("div",{className:"HelpDialog__header",children:[mo("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:Hc}),f("helpDialog.documentation")]}),mo("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:Hc}),f("helpDialog.blog")]}),mo("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[F("div",{className:"HelpDialog__link-icon",children:kl}),f("helpDialog.github")]}),mo("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[F("div",{className:"HelpDialog__link-icon",children:Sh}),"YouTube"]})]}),FY=e=>mo(ZS,{children:[F("h3",{children:e.title}),F("div",{className:"HelpDialog__islands-container",children:e.children})]}),Xb=e=>mo("div",{className:`HelpDialog__island ${e.className}`,children:[F("h4",{className:"HelpDialog__island-title",children:e.caption}),F("div",{className:"HelpDialog__island-content",children:e.children})]});function*HY(e,t){let o=!0;for(let n of e)o||(yield t),o=!1,yield n}var zY=e=>e.replace(/\b[a-z]\b/,t=>t.toUpperCase()),G=({label:e,shortcuts:t,isOr:o=!0})=>{let n=t.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>F(GY,{children:zY(a)},a)));return mo("div",{className:"HelpDialog__shortcut",children:[F("div",{children:e}),F("div",{className:"HelpDialog__key-container",children:[...HY(n,o?f("helpDialog.or"):null)]})]})},GY=e=>F("kbd",{className:"HelpDialog__key",...e}),$S=({onClose:e})=>{let t=NY.useCallback(()=>{e&&e()},[e]);return F(ZS,{children:mo($e,{onCloseRequest:t,title:f("helpDialog.title"),className:"HelpDialog",children:[F(OY,{}),mo(FY,{title:f("helpDialog.shortcuts"),children:[mo(Xb,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[F(G,{label:f("toolBar.hand"),shortcuts:[Ue.H]}),F(G,{label:f("toolBar.selection"),shortcuts:[Ue.V,Ue[1]]}),F(G,{label:f("toolBar.rectangle"),shortcuts:[Ue.R,Ue[2]]}),F(G,{label:f("toolBar.diamond"),shortcuts:[Ue.D,Ue[3]]}),F(G,{label:f("toolBar.ellipse"),shortcuts:[Ue.O,Ue[4]]}),F(G,{label:f("toolBar.arrow"),shortcuts:[Ue.A,Ue[5]]}),F(G,{label:f("toolBar.line"),shortcuts:[Ue.L,Ue[6]]}),F(G,{label:f("toolBar.freedraw"),shortcuts:[Ue.P,Ue[7]]}),F(G,{label:f("toolBar.text"),shortcuts:[Ue.T,Ue[8]]}),F(G,{label:f("toolBar.image"),shortcuts:[Ue[9]]}),F(G,{label:f("toolBar.eraser"),shortcuts:[Ue.E,Ue[0]]}),F(G,{label:f("toolBar.frame"),shortcuts:[Ue.F]}),F(G,{label:f("toolBar.laser"),shortcuts:[Ue.K]}),F(G,{label:f("labels.eyeDropper"),shortcuts:[Ue.I,"Shift+S","Shift+G"]}),F(G,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[X("CtrlOrCmd+Enter")]}),F(G,{label:f("helpDialog.editText"),shortcuts:[X("Enter")]}),F(G,{label:f("helpDialog.textNewLine"),shortcuts:[X("Enter"),X("Shift+Enter")]}),F(G,{label:f("helpDialog.textFinish"),shortcuts:[X("Esc"),X("CtrlOrCmd+Enter")]}),F(G,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),F(G,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),F(G,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),X("Enter")],isOr:!0}),F(G,{label:f("helpDialog.cropFinish"),shortcuts:[X("Enter"),X("Escape")],isOr:!0}),F(G,{label:f("toolBar.lock"),shortcuts:[Ue.Q]}),F(G,{label:f("helpDialog.preventBinding"),shortcuts:[X("CtrlOrCmd")]}),F(G,{label:f("toolBar.link"),shortcuts:[X("CtrlOrCmd+K")]}),F(G,{label:f("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),mo(Xb,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[F(G,{label:f("buttons.zoomIn"),shortcuts:[X("CtrlOrCmd++")]}),F(G,{label:f("buttons.zoomOut"),shortcuts:[X("CtrlOrCmd+-")]}),F(G,{label:f("buttons.resetZoom"),shortcuts:[X("CtrlOrCmd+0")]}),F(G,{label:f("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),F(G,{label:f("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),F(G,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),F(G,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),F(G,{label:f("buttons.zenMode"),shortcuts:[X("Alt+Z")]}),F(G,{label:f("buttons.objectsSnapMode"),shortcuts:[X("Alt+S")]}),F(G,{label:f("labels.toggleGrid"),shortcuts:[X("CtrlOrCmd+'")]}),F(G,{label:f("labels.viewMode"),shortcuts:[X("Alt+R")]}),F(G,{label:f("labels.toggleTheme"),shortcuts:[X("Alt+Shift+D")]}),F(G,{label:f("stats.fullTitle"),shortcuts:[X("Alt+/")]}),F(G,{label:f("search.title"),shortcuts:[Xe("searchMenu")]}),F(G,{label:f("commandPalette.title"),shortcuts:XS?[Xe("commandPalette")]:[Xe("commandPalette"),Xe("commandPalette",1)]})]}),mo(Xb,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[F(G,{label:f("helpDialog.createFlowchart"),shortcuts:[X("CtrlOrCmd+Arrow Key")],isOr:!0}),F(G,{label:f("helpDialog.navigateFlowchart"),shortcuts:[X("Alt+Arrow Key")],isOr:!0}),F(G,{label:f("labels.moveCanvas"),shortcuts:[X(`Space+${f("helpDialog.drag")}`),X(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),F(G,{label:f("buttons.clearReset"),shortcuts:[X("CtrlOrCmd+Delete")]}),F(G,{label:f("labels.delete"),shortcuts:[X("Delete")]}),F(G,{label:f("labels.cut"),shortcuts:[X("CtrlOrCmd+X")]}),F(G,{label:f("labels.copy"),shortcuts:[X("CtrlOrCmd+C")]}),F(G,{label:f("labels.paste"),shortcuts:[X("CtrlOrCmd+V")]}),F(G,{label:f("labels.pasteAsPlaintext"),shortcuts:[X("CtrlOrCmd+Shift+V")]}),F(G,{label:f("labels.selectAll"),shortcuts:[X("CtrlOrCmd+A")]}),F(G,{label:f("labels.multiSelect"),shortcuts:[X(`Shift+${f("helpDialog.click")}`)]}),F(G,{label:f("helpDialog.deepSelect"),shortcuts:[X(`CtrlOrCmd+${f("helpDialog.click")}`)]}),F(G,{label:f("helpDialog.deepBoxSelect"),shortcuts:[X(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(ua||XS)&&F(G,{label:f("labels.copyAsPng"),shortcuts:[X("Shift+Alt+C")]}),F(G,{label:f("labels.copyStyles"),shortcuts:[X("CtrlOrCmd+Alt+C")]}),F(G,{label:f("labels.pasteStyles"),shortcuts:[X("CtrlOrCmd+Alt+V")]}),F(G,{label:f("labels.sendToBack"),shortcuts:[KS?X("CtrlOrCmd+Alt+["):X("CtrlOrCmd+Shift+[")]}),F(G,{label:f("labels.bringToFront"),shortcuts:[KS?X("CtrlOrCmd+Alt+]"):X("CtrlOrCmd+Shift+]")]}),F(G,{label:f("labels.sendBackward"),shortcuts:[X("CtrlOrCmd+[")]}),F(G,{label:f("labels.bringForward"),shortcuts:[X("CtrlOrCmd+]")]}),F(G,{label:f("labels.alignTop"),shortcuts:[X("CtrlOrCmd+Shift+Up")]}),F(G,{label:f("labels.alignBottom"),shortcuts:[X("CtrlOrCmd+Shift+Down")]}),F(G,{label:f("labels.alignLeft"),shortcuts:[X("CtrlOrCmd+Shift+Left")]}),F(G,{label:f("labels.alignRight"),shortcuts:[X("CtrlOrCmd+Shift+Right")]}),F(G,{label:f("labels.duplicateSelection"),shortcuts:[X("CtrlOrCmd+D"),X(`Alt+${f("helpDialog.drag")}`)]}),F(G,{label:f("helpDialog.toggleElementLock"),shortcuts:[X("CtrlOrCmd+Shift+L")]}),F(G,{label:f("buttons.undo"),shortcuts:[X("CtrlOrCmd+Z")]}),F(G,{label:f("buttons.redo"),shortcuts:BY?[X("CtrlOrCmd+Y"),X("CtrlOrCmd+Shift+Z")]:[X("CtrlOrCmd+Shift+Z")]}),F(G,{label:f("labels.group"),shortcuts:[X("CtrlOrCmd+G")]}),F(G,{label:f("labels.ungroup"),shortcuts:[X("CtrlOrCmd+Shift+G")]}),F(G,{label:f("labels.flipHorizontal"),shortcuts:[X("Shift+H")]}),F(G,{label:f("labels.flipVertical"),shortcuts:[X("Shift+V")]}),F(G,{label:f("labels.showStroke"),shortcuts:[X("S")]}),F(G,{label:f("labels.showBackground"),shortcuts:[X("G")]}),F(G,{label:f("labels.showFonts"),shortcuts:[X("Shift+F")]}),F(G,{label:f("labels.decreaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+<")]}),F(G,{label:f("labels.increaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as JS,useRef as XY,useState as Hr}from"react";import{DEFAULT_EXPORT_PADDING as $Y,EXPORT_IMAGE_TYPES as $b,isFirefox as ZY,EXPORT_SCALES as jY,cloneJSON as QS}from"@excalidraw/common";import{useCallback as UY,useRef as YY,useState as WY}from"react";var VY=2e3,jS=()=>{let[e,t]=WY(null),o=YY(0),n=()=>{clearTimeout(o.current),t("success"),o.current=window.setTimeout(()=>{t(null)},VY)},r=UY(()=>{t(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import KY from"clsx";import{jsx as qS}from"react/jsx-runtime";var ec=({title:e,name:t,checked:o,onChange:n,disabled:r=!1})=>qS("div",{className:KY("Switch",{toggled:o,disabled:r}),children:qS("input",{name:t,id:t,title:e,type:"checkbox",checked:o,disabled:r,onChange:()=>n(!o),onKeyDown:i=>{i.key===" "&&n(!o)}})});import{jsx as Oe,jsxs as zr}from"react/jsx-runtime";var qY="filter"in document.createElement("canvas").getContext("2d"),JY=()=>zr("div",{children:[Oe("h3",{children:f("canvasError.cannotShowPreview")}),Oe("p",{children:Oe("span",{children:f("canvasError.canvasTooBig")})}),zr("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),QY=({appStateSnapshot:e,elementsSnapshot:t,files:o,actionManager:n,onExportImage:r,name:i})=>{let a=Le(t,e),[l,s]=Hr(i),[c,d]=Hr(a),[m,p]=Hr(e.exportBackground),[u,g]=Hr(e.exportWithDarkMode),[b,x]=Hr(e.exportEmbedScene),[w,E]=Hr(e.exportScale),y=XY(null),[T,v]=Hr(null),{onCopy:C,copyStatus:M,resetCopyStatus:k}=jS();JS(()=>{k()},[l,m,u,w,b,k]);let{exportedElements:P,exportingFrame:A}=mi(t,e,c);return JS(()=>{let R=y.current;if(!R)return;let O=R.offsetWidth,U=R.offsetHeight;O&&vm({data:{elements:P,appState:{...e,name:l,exportEmbedScene:b},files:o},config:{canvasBackgroundColor:m?e.viewBackgroundColor:!1,padding:$Y,theme:u?"dark":"light",scale:w,maxWidthOrHeight:Math.max(O,U),exportingFrame:A}}).then(ee=>(v(null),wn(ee).then(()=>{R.replaceChildren(ee)}).catch(_=>{throw _.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):_}))).catch(ee=>{console.error(ee),v(ee)})},[e,o,P,A,l,m,u,w,b]),zr("div",{className:"ImageExportModal",children:[Oe("h3",{children:f("imageExportDialog.header")}),zr("div",{className:"ImageExportModal__preview",children:[Oe("div",{className:"ImageExportModal__preview__canvas",ref:y,children:T&&Oe(JY,{})}),Oe("div",{className:"ImageExportModal__preview__filename",children:!Oi&&Oe("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:R=>{s(R.target.value),n.executeAction(Xd,"ui",R.target.value)}})})]}),zr("div",{className:"ImageExportModal__settings",children:[Oe("h3",{children:f("imageExportDialog.header")}),a&&Oe(tc,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Oe(ec,{name:"exportOnlySelected",checked:c,onChange:R=>{d(R)}})}),Oe(tc,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Oe(ec,{name:"exportBackgroundSwitch",checked:m,onChange:R=>{p(R),n.executeAction($d,"ui",R)}})}),qY&&Oe(tc,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Oe(ec,{name:"exportDarkModeSwitch",checked:u,onChange:R=>{g(R),n.executeAction(Mw,"ui",R)}})}),Oe(tc,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Oe(ec,{name:"exportEmbedSwitch",checked:b,onChange:R=>{x(R),n.executeAction(Zd,"ui",R)}})}),Oe(tc,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Oe(Wp,{name:"exportScale",value:w,onChange:R=>{E(R),n.executeAction(kw,"ui",R)},choices:jY.map(R=>({value:R,label:`${R}\xD7`}))})}),zr("div",{className:"ImageExportModal__settings__buttons",children:[Oe(Dr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>r($b.png,P,{exportingFrame:A}),icon:td,children:f("imageExportDialog.button.exportToPng")}),Oe(Dr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>r($b.svg,P,{exportingFrame:A}),icon:td,children:f("imageExportDialog.button.exportToSvg")}),(ua||ZY)&&Oe(Dr,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:M,onClick:async()=>{await r($b.clipboard,P,{exportingFrame:A}),C()},icon:ri,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},tc=({label:e,children:t,tooltip:o,name:n})=>zr("div",{className:"ImageExportModal__settings__setting",title:e,children:[zr("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,o&&Oe(ro,{label:o,long:!0,children:ih})]}),Oe("div",{className:"ImageExportModal__settings__setting__content",children:t})]}),e6=({elements:e,appState:t,files:o,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Hr(()=>({appStateSnapshot:QS(t),elementsSnapshot:QS(e)}));return Oe($e,{onCloseRequest:i,size:"wide",title:!1,children:Oe(QY,{elementsSnapshot:s,appStateSnapshot:l,files:o,actionManager:n,onExportImage:r,name:a})})};import tW from"react";import{getFrame as oW}from"@excalidraw/common";import Zb from"open-color";import{jsx as eW}from"react/jsx-runtime";var jb=({children:e,color:t})=>eW("div",{className:"Card",style:{"--card-color":t==="primary"?"var(--color-primary)":Zb[t][7],"--card-color-darker":t==="primary"?"var(--color-primary-darker)":Zb[t][8],"--card-color-darkest":t==="primary"?"var(--color-primary-darkest)":Zb[t][9]},children:e});import{Fragment as rW,jsx as Zo,jsxs as xu}from"react/jsx-runtime";var nW=({elements:e,appState:t,setAppState:o,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return Zo("div",{className:"ExportDialog ExportDialog--json",children:xu("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&xu(jb,{color:"lime",children:[Zo("div",{className:"Card-icon",children:hg}),Zo("h2",{children:f("exportDialog.disk_title")}),xu("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Oi&&r.renderAction("changeProjectName")]}),Zo($,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(ha,"ui")}})]}),s&&xu(jb,{color:"pink",children:[Zo("div",{className:"Card-icon",children:Vi}),Zo("h2",{children:f("exportDialog.link_title")}),Zo("div",{className:"Card-details",children:f("exportDialog.link_details")}),Zo($,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ae("export","link",`ui (${oW()})`),await s(e,t,n),l()}catch(c){o({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,t,n,a)]})})},t6=({elements:e,appState:t,files:o,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let l=tW.useCallback(()=>{a({openDialog:null})},[a]);return Zo(rW,{children:t.openDialog?.name==="jsonExport"&&Zo($e,{onCloseRequest:l,title:f("buttons.export"),children:Zo(nW,{elements:e,appState:t,setAppState:a,files:o,actionManager:n,onCloseRequest:l,exportOpts:r,canvas:i})})})};import iW from"clsx";import{jsx as o6,jsxs as lW}from"react/jsx-runtime";var aW="small",n6=e=>lW("label",{className:iW("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${aW}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[o6("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),o6("div",{className:"ToolIcon__icon",children:Xi})]});import{Fragment as a6,jsx as Z,jsxs as po}from"react/jsx-runtime";var hW=({UIOptions:e})=>po(Mt,{__fallback:!0,children:[Z(Mt.DefaultItems.LoadScene,{}),Z(Mt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&Z(Mt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&Z(Mt.DefaultItems.SaveAsImage,{}),Z(Mt.DefaultItems.SearchMenu,{}),Z(Mt.DefaultItems.Help,{}),Z(Mt.DefaultItems.ClearCanvas,{}),Z(Mt.Separator,{}),Z(Mt.Group,{title:"Excalidraw links",children:Z(Mt.DefaultItems.Socials,{})}),Z(Mt.Separator,{}),Z(Mt.DefaultItems.ToggleTheme,{}),Z(Mt.DefaultItems.ChangeCanvasBackground,{})]}),fW=()=>po($p,{__fallback:!0,children:[Z($p.Actions.SaveToDisk,{}),Z($p.Actions.ExportToImage,{})]}),bW=({actionManager:e,appState:t,files:o,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopRightUI:d,renderCustomStats:m,UIOptions:p,onExportImage:u,renderWelcomeScreen:g,onHomeButtonClick:b,children:x,app:w,isCollaborating:E,generateLinkForSelection:y,uiDisabled:T})=>{let v=me(),C=eT(),M=C.tunnelsJotai.Provider,[k,P]=ce(rr),A=()=>p.canvasActions.export?Z(t6,{elements:r,appState:t,files:o,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:n}):null,R=()=>!p.canvasActions.saveAsImage||t.openDialog?.name!=="imageExport"?null:Z(e6,{elements:r,appState:t,files:o,actionManager:e,onExportImage:u,onCloseRequest:()=>n({openDialog:null}),name:w.getName()}),O=()=>po("div",{style:{position:"relative"},children:[Z(C.MainMenuTunnel.Out,{}),g&&Z(C.WelcomeScreenMenuHintTunnel.Out,{})]}),U=()=>Z(Ar,{heading:"selectedShapeActions",className:oc("selected-shape-actions zen-mode-transition",{"transition-left":t.zenModeEnabled}),children:Z(st,{className:cW.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${t.height-166}px`},children:Z(Fm,{appState:t,elementsMap:w.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:w})})}),ee=()=>{let V=uW(t,r),Y=t.stats.open&&!t.zenModeEnabled&&!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector";return Z(Pp,{side:"top",children:po("div",{className:"App-menu App-menu_top",children:[po(ht.Col,{gap:6,className:oc("App-menu_top__left"),children:[O(),V&&U()]}),!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector"&&Z(Ar,{heading:"shapes",className:"shapes-section",children:le=>po("div",{style:{position:"relative"},children:[g&&Z(C.WelcomeScreenToolbarHintTunnel.Out,{}),Z(ht.Col,{gap:4,align:"start",children:po(ht.Row,{gap:1,className:oc("App-toolbar-container",{"zen-mode":t.zenModeEnabled}),children:[po(st,{padding:1,className:oc("App-toolbar",{"zen-mode":t.zenModeEnabled}),children:[Z(Dp,{appState:t,isMobile:v.editor.isMobile,device:v,app:w}),le,po(ht.Row,{gap:1,children:[Z(Rp,{zenModeEnabled:t.zenModeEnabled,checked:t.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),penDetected:t.penDetected}),Z(Ap,{checked:t.activeTool.locked,onChange:a,title:f("toolBar.lock")}),Z("div",{className:"App-toolbar__divider"}),Z(_p,{checked:Do(t),onChange:()=>l(),title:f("toolBar.hand"),isMobile:!0}),Z(Hm,{appState:t,activeTool:t.activeTool,UIOptions:p,app:w})]})]}),E&&Z(st,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:Z(n6,{title:f("toolBar.laser"),checked:t.activeTool.type===r6.laser,onChange:()=>w.setActiveTool({type:r6.laser}),isMobile:!0})})]})})]})}),po("div",{className:oc("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":t.zenModeEnabled}),children:[t.collaborators.size>0&&Z(Gp,{collaborators:t.collaborators,userToFollow:t.userToFollow?.socketId||null}),d?.(v.editor.isMobile,t),!t.viewModeEnabled&&t.openDialog?.name!=="elementLinkSelector"&&(!B||t.openSidebar?.name!==qb.name)&&Z(C.DefaultSidebarTriggerTunnel.Out,{}),Y&&Z(Qs,{app:w,onClose:()=>{e.executeAction(bi)},renderCustomStats:m})]})]})})},_=()=>Z(qp,{__fallback:!0,onDock:V=>{ae("sidebar",`toggleDock (${V?"dock":"undock"})`,`(${v.editor.isMobile?"mobile":"desktop"})`)}}),B=Pc(Ks);if(T)return null;let j=po(a6,{children:[x,Z(hW,{UIOptions:p}),Z(qp.Trigger,{__fallback:!0,icon:Qr,title:mW(f("toolBar.library")),onToggle:V=>{V&&ae("sidebar",`${qb.name} (open)`,`button (${v.editor.isMobile?"mobile":"desktop"})`)},tab:qb.defaultTab,children:f("toolBar.library")}),Z(fW,{}),t.openDialog?.name==="ttd"&&Z(Mb,{__fallback:!0}),t.isLoading&&Z(Lp,{delay:250}),t.errorMessage&&Z(VS,{onClose:()=>n({errorMessage:null}),children:t.errorMessage}),k&&!v.editor.isMobile&&Z(YE,{colorPickerType:k.colorPickerType,onCancel:()=>{P(null)},onChange:(V,Y,le,{altKey:xe})=>{if(!(V!=="elementBackground"&&V!=="elementStroke"))if(le.length){for(let ue of le)pW(ue,dW(r),{[xe&&k.swapPreviewOnAlt?V==="elementBackground"?"strokeColor":"backgroundColor":V==="elementBackground"?"backgroundColor":"strokeColor"]:Y}),gW.delete(ue);w.scene.triggerUpdate()}else n(V==="elementBackground"?{currentItemBackgroundColor:Y}:{currentItemStrokeColor:Y})},onSelect:(V,Y)=>{P(le=>le?.keepOpenOnAlt&&Y.altKey?le:null),k?.onSelect?.(V,Y)}}),t.openDialog?.name==="help"&&Z($S,{onClose:()=>{n({openDialog:null})}}),Z(dT,{}),t.openDialog?.name==="elementLinkSelector"&&Z(WS,{sourceElementId:t.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:w.scene,appState:t,generateLinkForSelection:y}),Z(C.OverwriteConfirmDialogTunnel.Out,{}),R(),A(),t.pasteDialog.shown&&Z(O5,{setAppState:n,appState:t,onClose:()=>n({pasteDialog:{shown:!1,data:null}})}),v.editor.isMobile&&Z(N5,{app:w,onHomeButtonClick:b,appState:t,elements:r,actionManager:e,renderJSONExportDialog:A,renderImageExportDialog:R,setAppState:n,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:d,renderCustomStats:m,renderSidebars:_,device:v,renderWelcomeScreen:g,UIOptions:p}),!v.editor.isMobile&&po(a6,{children:[po("div",{className:"layer-ui__wrapper",style:t.openSidebar&&B&&v.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[g&&Z(C.WelcomeScreenCenterTunnel.Out,{}),ee(),Z(G5,{appState:t,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:g}),t.scrolledOutside&&Z("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(V=>({...qr(r,V)}))},children:f("buttons.scrollBackToContent")})]}),_()]})]});return Z(Oh.Provider,{value:t,children:Z(M,{children:Z(v1.Provider,{value:C,children:j})})})},i6=e=>{let{suggestedBindings:t,startBoundElement:o,cursorButton:n,scrollX:r,scrollY:i,...a}=e;return a},xW=(e,t)=>{if(e.children!==t.children)return!1;let{canvas:o,appState:n,...r}=e,{canvas:i,appState:a,...l}=t;return Eu(i6(n),i6(a),{selectedElementIds:Eu,selectedGroupIds:Eu})&&Eu(r,l)},l6=sW.memo(bW,xW);import EW from"clsx";import{jsx as s6,jsxs as wW}from"react/jsx-runtime";var yW="small",yu=e=>wW("label",{className:EW("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${yW}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[s6("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),s6("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as vW,useRef as TW}from"react";import{jsx as c6}from"react/jsx-runtime";var d6=({trails:e})=>{let t=TW(null);return vW(()=>{if(t.current)for(let o of e)o.start(t.current);return()=>{for(let o of e)o.stop()}},e),c6("div",{className:"SVGLayer",children:c6("svg",{ref:t})})};import IW,{useEffect as CW,useRef as SW}from"react";import{CURSOR_TYPE as m6,isShallowEqual as kW,sceneCoordsToViewportCoords as MW}from"@excalidraw/common";import{jsx as PW}from"react/jsx-runtime";var LW=e=>{let t=SW(!1);return CW(()=>{if(!t.current){t.current=!0;return}let o=new Map,n=new Map,r=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,c)=>{if(s.selectedElementIds)for(let d of Object.keys(s.selectedElementIds))r.has(d)||r.set(d,[]),r.get(d).push(c);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(c,s.username),s.userState&&a.set(c,s.userState),n.set(c,MW({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),o.set(c,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";HI({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:n,remotePointerButton:o,remoteSelectedElementIds:r,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Qa())}),PW("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?m6.GRAB:m6.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:f("labels.drawingCanvas")})},p6=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,editingLinearElement:e.editingLinearElement,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}),AW=(e,t)=>e.selectionNonce!==t.selectionNonce||e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements||e.selectedElements!==t.selectedElements||e.renderScrollbars!==t.renderScrollbars?!1:kW(p6(e.appState),p6(t.appState)),Jb=IW.memo(LW,AW);import _W,{useEffect as DW,useRef as u6}from"react";import{isShallowEqual as g6}from"@excalidraw/common";import{jsx as BW}from"react/jsx-runtime";var RW=e=>{let t=u6(null),o=u6(!1);return DW(()=>{let n=t.current;if(!n)return;let r=e.canvas;o.current||(o.current=!0,n.replaceChildren(r),r.classList.add("excalidraw__canvas","static"));let i=`${e.appState.width}px`,a=`${e.appState.height}px`;r.style.width!==i&&(r.style.width=i),r.style.height!==a&&(r.style.height=a);let l=e.appState.width*e.scale,s=e.appState.height*e.scale;r.width!==l&&(r.width=l),r.height!==s&&(r.height=s),sE({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Qa())}),BW("div",{className:"excalidraw__canvas-wrapper",ref:t})},h6=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}),NW=(e,t)=>e.sceneNonce!==t.sceneNonce||e.scale!==t.scale||e.elementsMap!==t.elementsMap||e.visibleElements!==t.visibleElements?!1:g6(h6(e.appState),h6(t.appState))&&g6(e.renderConfig,t.renderConfig),Qb=_W.memo(RW,NW);import{useEffect as zW,useRef as GW}from"react";import{throttleRAF as OW}from"@excalidraw/common";import{renderElement as FW}from"@excalidraw/element";var f6=({canvas:e,rc:t,newElement:o,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=Cc(e,i),d=Sc({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});d.save(),d.scale(a.zoom.value,a.zoom.value),o&&o.type!=="selection"?FW(o,n,r,t,d,l,a):d.clearRect(0,0,s,c)}},HW=OW(e=>{f6(e)},{trailing:!0}),b6=(e,t)=>{if(t){HW(e);return}f6(e)};import{jsx as YW}from"react/jsx-runtime";var UW=e=>{let t=GW(null);return zW(()=>{t.current&&b6({canvas:t.current,scale:e.scale,newElement:e.appState.newElement,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,rc:e.rc,renderConfig:e.renderConfig,appState:e.appState},Qa())}),YW("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:t})},x6=UW;import{useCallback as WW,useEffect as VW,useRef as KW}from"react";import{jsx as E6,jsxs as $W}from"react/jsx-runtime";var XW=5e3,y6=({message:e,onClose:t,closable:o=!1,duration:n=XW,style:r})=>{let i=KW(0),a=n!==1/0,l=WW(()=>{a&&(i.current=window.setTimeout(()=>t(),n))},[t,n,a]);return VW(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,n,a]),$W("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[E6("p",{className:"Toast__message",children:e}),o&&E6($,{icon:no,"aria-label":"close",type:"icon",onClick:t,className:"close"})]})};import{getCommonBounds as ZW,getElementsInGroup as jW,selectGroupsFromGivenElements as qW}from"@excalidraw/element";import{sceneCoordsToViewportCoords as JW}from"@excalidraw/common";import{flushSync as QW}from"react-dom";import{jsx as tV}from"react/jsx-runtime";var eV=({app:e,activeLockedId:t})=>{let o=e.scene.getElement(t),n=o?[o]:jW(e.scene.getNonDeletedElementsMap(),t);if(n.length===0)return null;let[r,i]=ZW(n),{x:a,y:l}=JW({sceneX:r,sceneY:i},e.state);return tV("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{QW(()=>{let s=qW(n,e.state);e.setState({selectedElementIds:n.reduce((c,d)=>({...c,[d.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(Ta)},title:f("labels.elementLock.unlock"),children:qu})},w6=eV;import{Fragment as qK,jsx as ve,jsxs as Mu}from"react/jsx-runtime";var v4=yn.createContext(null),T4=yn.createContext(null),I4={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},Ax=yn.createContext(I4);Ax.displayName="DeviceContext";var Px=yn.createContext({container:null,id:null});Px.displayName="ExcalidrawContainerContext";var _x=yn.createContext([]);_x.displayName="ExcalidrawElementsContext";var Dx=yn.createContext({...Jr(),width:0,height:0,offsetLeft:0,offsetTop:0});Dx.displayName="ExcalidrawAppStateContext";var Rx=yn.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Rx.displayName="ExcalidrawSetAppStateContext";var Nx=yn.createContext(null);Nx.displayName="ExcalidrawActionManagerContext";var Ke=()=>Kr(v4),tn=()=>Kr(T4),me=()=>Kr(Ax),tt=()=>Kr(Px),ir=()=>Kr(_x),en=()=>Kr(Dx),pe=()=>Kr(Rx),nt=()=>Kr(Nx),mc=!1,Cx=0,Ri=!1,pc=!1,Sx=!1,uc={horizontal:null,vertical:null},Vr=0,gc=!1,kx=new Map,ku=!1,x4=0,E4=!1,hc=null,we={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Lx=class e extends yn.Component{constructor(o){super(o);S(this,"canvas");S(this,"interactiveCanvas",null);S(this,"rc");S(this,"unmounted",!1);S(this,"actionManager");S(this,"device",I4);S(this,"excalidrawContainerRef",yn.createRef());S(this,"scene");S(this,"fonts");S(this,"renderer");S(this,"visibleElements");S(this,"resizeObserver");S(this,"nearestScrollableContainer");S(this,"library");S(this,"libraryItemsFromStorage");S(this,"id");S(this,"store");S(this,"history");S(this,"excalidrawContainerValue");S(this,"files",{});S(this,"imageCache",new Map);S(this,"iFrameRefs",new Map);S(this,"embedsValidationStatus",new Map);S(this,"initializedEmbeds",new Set);S(this,"handleToastClose",()=>{this.setToast(null)});S(this,"elementsPendingErasure",new Set);S(this,"flowChartCreator",new TK);S(this,"flowChartNavigator",new IK);S(this,"hitLinkElement");S(this,"lastPointerDownEvent",null);S(this,"lastPointerUpEvent",null);S(this,"lastPointerMoveEvent",null);S(this,"lastPointerMoveCoords",null);S(this,"lastViewportPosition",{x:0,y:0});S(this,"animationFrameHandler",new hp);S(this,"laserTrails",new Ip(this.animationFrameHandler,this));S(this,"eraserTrail",new Mp(this.animationFrameHandler,this));S(this,"lassoTrail",new kp(this.animationFrameHandler,this));S(this,"onChangeEmitter",new Pi);S(this,"onPointerDownEmitter",new Pi);S(this,"onPointerUpEmitter",new Pi);S(this,"onUserFollowEmitter",new Pi);S(this,"onScrollChangeEmitter",new Pi);S(this,"missingPointerEventCleanupEmitter",new Pi);S(this,"onRemoveEventListenersEmitter",new Pi);S(this,"updateEditorAtom",(o,...n)=>{let r=et.set(o,...n);return this.triggerRender(),r});S(this,"getEffectiveGridSize",()=>kr(this)?this.state.gridSize:null);S(this,"updateEmbedValidationStatus",(o,n)=>{this.embedsValidationStatus.set(o.id,n),cc.delete(o)});S(this,"updateEmbeddables",()=>{let o=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(Wr(r)){if(o.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=bx(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else gl(r)&&o.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{o.has(i)||this.iFrameRefs.delete(i)})});S(this,"getFrameNameDOMId",o=>`${this.id}-frame-name-${o.id}`);S(this,"frameNameBoundsCache",{get:o=>{let n=this.frameNameBoundsCache._cache.get(o.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==o.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(o));if(r){let i=r.getBoundingClientRect(),a=qe({clientX:i.x,clientY:i.y},this.state),l=qe({clientX:i.right,clientY:i.bottom},this.state);return n={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:o.versionNonce},this.frameNameBoundsCache._cache.set(o.id,n),n}return null}return n},_cache:new Map});S(this,"resetEditingFrame",o=>{o&&this.scene.mutateElement(o,{name:o.name?.trim()||null}),this.setState({editingFrame:null})});S(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let o=this.state.theme===Tu.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&Lo(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!J6(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}=Cu({sceneX:i.x,sceneY:i.y},this.state),s=6,c,d=bK(i);if(i.id===this.state.editingFrame){let m=d;c=ve("input",{autoFocus:!0,value:m,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===W.ESCAPE||p.key===W.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:o?yV:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Gr.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:m.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=d;return ve("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+Gr.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Gr.nameFontSize,color:o?Gr.nameColorDarkTheme:Gr.nameColorLightTheme,lineHeight:Gr.nameLineHeight,width:"max-content",maxWidth:r?.id===i.id&&r?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Ye.MOVE,pointerEvents:this.state.viewModeEnabled?ml.disabled:ml.enabled},onPointerDown:m=>this.handleCanvasPointerDown(m),onWheel:m=>this.handleWheel(m),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});S(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});S(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());S(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());S(this,"getSceneElements",()=>this.scene.getNonDeletedElements());S(this,"onInsertElements",o=>{this.addElementsFromPasteOrLibrary({elements:o,position:"center",files:null})});S(this,"onExportImage",async(o,n,r)=>{ae("export",o,"ui");let i=await pi({type:o,data:{elements:n,appState:this.state,files:this.files},config:{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}}).catch(BV).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&kc(i)&&this.setState({fileHandle:i})});S(this,"magicGenerations",new Map);S(this,"updateMagicGeneration",({frameElement:o,data:n})=>{n.status==="pending"?this.scene.mutateElement(o,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(o,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(o.id,n),this.triggerRender()});S(this,"plugins",{});S(this,"onMagicframeToolSelect",()=>{let o=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(o.length===0)this.setActiveTool({type:En.magicframe}),ae("ai","tool-select (empty-selection)","d2c");else{let n=o.length===1&&hx(o[0])&&o[0];if(!n&&o.some(i=>Lo(i)||i.frameId)){this.setActiveTool({type:En.magicframe});return}ae("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,l,s]=ul(o),c=50;r=V6({...Gr,x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let d of o)this.scene.mutateElement(d,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});S(this,"openEyeDropper",({type:o})=>{this.updateEditorAtom(rr,{swapPreviewOnAlt:!0,colorPickerType:o==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=o==="background"&&r.altKey||o==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:Lt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:Lt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?_i(l,{[i?"strokeColor":"backgroundColor"]:n}):l),captureUpdate:Lt.IMMEDIATELY})},keepOpenOnAlt:!1})});S(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})});S(this,"syncActionResult",Ge(o=>{if(this.unmounted||o===!1)return;this.store.scheduleAction(o.captureUpdate);let n=!1,r=null;if(o.elements&&(this.scene.replaceAllElements(o.elements),n=!0),o.files&&(this.addMissingFiles(o.files,o.replaceFiles),this.addNewImagesToImageCache()),o.appState||r||this.state.contextMenu){let i=o?.appState?.viewModeEnabled||!1,a=o?.appState?.zenModeEnabled||!1,l=o?.appState?.theme||this.props.theme||Tu.LIGHT,s=o?.appState?.name??this.state.name,c=o?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=o.appState?.editingTextElement||null,o.elements&&r&&o.elements.forEach(d=>{r?.id===d.id&&r!==d&&f4(d)&&jo(d)&&(r=d)}),r?.isDeleted&&(r=null),this.setState(d=>{let m=o.appState||{};return{...d,...m,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),n=!0}n||this.scene.triggerUpdate()}));S(this,"onBlur",Ge(()=>{Ri=!1,this.setState({isBindingEnabled:!0})}));S(this,"onUnload",()=>{this.onBlur()});S(this,"disableEvent",o=>{o.preventDefault()});S(this,"resetHistory",()=>{this.history.clear()});S(this,"resetStore",()=>{this.store.clear()});S(this,"resetScene",Ge(o=>{this.scene.replaceAllElements([]),this.setState(n=>({...Jr(),isLoading:o?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));S(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async r=>{if(!r.files.length)return;let i=r.files[0],a=await i.getFile();this.loadFileToCanvas(new File([a],a.name||"",{type:a.type}),i)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let o=null;try{typeof this.props.initialData=="function"?o=await this.props.initialData()||null:o=await this.props.initialData||null,o?.libraryItems&&this.library.updateLibrary({libraryItems:o.libraryItems,merge:!0}).catch(r=>{console.error(r)})}catch(r){console.error(r),o={appState:{errorMessage:r.message||"Encountered an error during importing or restoring scene data"}}}let n=yl(o,null,null,{repairBindings:!0});n.appState={...n.appState,theme:this.props.theme||n.appState.theme,openSidebar:n.appState?.openSidebar||this.state.openSidebar,activeTool:n.appState.activeTool.type==="image"?{...n.appState.activeTool,type:"selection"}:n.appState.activeTool,isLoading:!1,toast:this.state.toast},o?.scrollToContent&&(n.appState={...n.appState,...qr(n.elements,{...n.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),o?.scrollX!=null&&(n.appState.scrollX=o.scrollX),o?.scrollY!=null&&(n.appState.scrollY=o.scrollY),this.resetHistory(),this.syncActionResult({...n,captureUpdate:Lt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(r=>{this.fonts.onLoaded(r)}),Tx(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});S(this,"isMobileBreakpoint",(o,n)=>o<hV||n<uV&&o<gV);S(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:n,clientHeight:r}=document.body,i=this.device.viewport,a=lx(i,{isLandscape:n>r,isMobile:this.isMobileBreakpoint(n,r)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});S(this,"refreshEditorBreakpoints",()=>{let o=this.excalidrawContainerRef.current;if(!o)return;let{width:n,height:r}=o.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:fV,a=this.device.editor,l=lx(a,{isMobile:this.isMobileBreakpoint(n,r),canFitSidebar:n>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});S(this,"onResize",Ge(()=>{this.scene.getElementsIncludingDeleted().forEach(o=>cc.delete(o)),this.refreshViewportBreakpoints(),this.updateDOMRect(),R6||this.refreshEditorBreakpoints(),this.setState({})}));S(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});S(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:o,scrollBars:n,elementsMap:r})=>{n&&(uc=n);let i=this.state.editingTextElement?!1:!o&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});S(this,"onScroll",O6(()=>{let{offsetTop:o,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===o?null:{offsetTop:o,offsetLeft:n})},bV));S(this,"onCut",Ge(o=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||rc(o.target)||(this.actionManager.executeAction(ps,"keyboard",o),o.preventDefault(),o.stopPropagation())}));S(this,"onCopy",Ge(o=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||rc(o.target)||(this.actionManager.executeAction(hi,"keyboard",o),o.preventDefault(),o.stopPropagation())}));S(this,"onTouchStart",o=>{if(IV&&o.preventDefault(),this.props.interactive!==!1){if(!mc){mc=!0,clearTimeout(Cx),Cx=window.setTimeout(e.resetTapTwice,xV);return}if(mc&&o.touches.length===1){let n=o.touches[0];this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY}),mc=!1,clearTimeout(Cx)}o.touches.length===2&&this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null})}});S(this,"onTouchEnd",o=>{this.props.interactive!==!1&&(this.resetContextMenuTimer(),o.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ae(this.state.previousSelectedElementIds,this.state)}):we.pointers.clear())});S(this,"pasteFromClipboard",Ge(async o=>{if(this.props.interactive===!1)return;let n=!!ku,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(o&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(o&&(!(a instanceof HTMLCanvasElement)||rc(r)))return;let{x:l,y:s}=qe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),c=o?.clipboardData?.files[0],d=await Vd(o,n);if(!c&&!n){if(d.mixedContent)return this.addElementsFromMixedContentPaste(d.mixedContent,{isPlainPaste:n,sceneX:l,sceneY:s});if(d.text){let m=d.text.trim();m.startsWith("<svg")&&m.endsWith("</svg>")&&(c=Ku(m))}}if(Mc(c)&&!d.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}this.createImageElement({sceneX:l,sceneY:s,imageFile:c});return}if(this.props.onPaste)try{if(await this.props.onPaste(d,o)===!1)return}catch(m){console.error(m)}if(d.errorMessage)this.setState({errorMessage:d.errorMessage});else if(d.spreadsheet&&!n)this.setState({pasteDialog:{data:d.spreadsheet,shown:!0}});else if(d.elements){let m=d.programmaticAPI?Ja(d.elements):d.elements;this.addElementsFromPasteOrLibrary({elements:m,files:d.files||null,position:"cursor",retainSeed:n})}else if(d.text){if(d.text&&QI(d.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:g,files:b}=await u.parseMermaidToExcalidraw(d.text),x=Ja(g,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:x,files:b,position:"cursor"});return}catch(g){console.warn(`parsing pasted text as mermaid definition failed: ${g.message}`)}}let m=FV(d.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=m.map(u=>lK(u)).filter(u=>bx(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||Su(u)?.type==="video"));if(!ku&&p.length>0&&p.length===m.length){let u=[];for(let g of p){let b=u[u.length-1],x=this.insertEmbeddableElement({sceneX:b?b.x+b.width+20:l,sceneY:s,link:rx(g)});x&&u.push(x)}u.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(u.map(g=>[g.id,!0]))}));return}this.addTextFromPaste(d.text,n)}this.setActiveTool({type:"selection"}),o?.preventDefault()}));S(this,"addElementsFromPasteOrLibrary",o=>{let n=Uu(o.elements,null,void 0),[r,i,a,l]=ul(n),s=pl(r,a)/2,c=pl(i,l)/2,d=typeof o.position=="object"?o.position.clientX:o.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,m=typeof o.position=="object"?o.position.clientY:o.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=qe({clientX:d,clientY:m},this.state),g=p-s,b=u-c,[x,w]=Tt(g,b,this.getEffectiveGridSize()),{duplicatedElements:E}=$6({type:"everything",elements:n.map(k=>_i(k,{x:k.x+x-r,y:k.y+w-i})),randomizeSeed:!o.retainSeed}),y=this.scene.getElementsIncludingDeleted(),T=[...y,...E];T=this.props.onDuplicate?.(T,y)||T,m4(T,z6(E));let C=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(C){let k=EK(E,C);yx(T,k,C,this.state)}this.scene.replaceAllElements(T),E.forEach(k=>{if(jo(k)&&gx(k)){let P=n4(k,this.scene.getElementsMapIncludingDeleted());mK(k,P,this.scene)}}),kV&&Zn.loadElementsFonts(E).then(k=>{this.fonts.onLoaded(k)}),o.files&&this.addMissingFiles(o.files);let M=zK(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&et.get(Ks)?this.state.openSidebar:null,...qo({editingGroupId:null,selectedElementIds:M.reduce((k,P)=>(gx(P)||(k[P.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{o.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),o.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});S(this,"setAppState",(o,n)=>{this.setState(o,n)});S(this,"removePointer",o=>{Vr&&this.resetContextMenuTimer(),we.pointers.delete(o.pointerId)});S(this,"toggleLock",(o="ui")=>{this.state.activeTool.locked||ae("toolbar","toggleLock",`${o} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...Kn(this.state,n.activeTool.locked?{type:"selection"}:n.activeTool),locked:!n.activeTool.locked}}))});S(this,"updateFrameRendering",o=>{this.setState(n=>{let r=typeof o=="function"?o(n.frameRendering):o;return{frameRendering:{enabled:r?.enabled??n.frameRendering.enabled,clip:r?.clip??n.frameRendering.clip,name:r?.name??n.frameRendering.name,outline:r?.outline??n.frameRendering.outline}}})});S(this,"togglePenMode",o=>{this.setState(n=>({penMode:o??!n.penMode,penDetected:!0}))});S(this,"onHandToolToggle",()=>{this.actionManager.executeAction(qy)});S(this,"zoomCanvas",o=>{this.setState({...Sn({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:Jo(o)},this.state)})});S(this,"cancelInProgressAnimation",null);S(this,"scrollToContent",(o=this.scene.getNonDeletedElements(),n)=>{if(typeof o=="string"){let s;if(Tx(o)?s=kK(o):s=o,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):Tx(o)&&this.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(o)?o:[o],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:s}=rs({canvasOffsets:n.canvasOffsets,targetElements:r,appState:this.state,fitToViewport:!!n?.fitToViewport,viewportZoomFactor:n?.viewportZoomFactor,minZoom:n?.minZoom,maxZoom:n?.maxZoom});i=s.zoom,a=s.scrollX,l=s.scrollY}else{let s=qr(r,this.state);a=s.scrollX,l=s.scrollY}if(n?.animate){let s=this.state.scrollX,c=this.state.scrollY,d=this.state.zoom.value,m=NV({fromValues:{scrollX:s,scrollY:c,zoom:d},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,g,b)=>{if(b==="zoom")return p*Math.pow(u/p,OV(g))},onStep:({scrollX:p,scrollY:u,zoom:g})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:g}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:n?.duration??500});this.cancelInProgressAnimation=()=>{m(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});S(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});S(this,"translateCanvas",o=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(o)});S(this,"setToast",o=>{this.setState({toast:o})});S(this,"restoreFileFromShare",async()=>{try{let o=await caches.open("web-share-target"),n=await o.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await o.delete("shared-file"),window.history.replaceState(null,lV,window.location.pathname)}}catch(o){this.setState({errorMessage:o.message})}});S(this,"addFiles",Ge(o=>{let{addedFiles:n}=this.addMissingFiles(o);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));S(this,"addMissingFiles",(o,n=!1)=>{let r=n?{}:{...this.files},i={},a=Array.isArray(o)?o:Object.values(o);for(let l of a)if(!r[l.id]&&(i[l.id]=l,r[l.id]=l,l.mimeType===Ur.svg))try{let s=fE(o4(bE(l.dataURL)),Ur.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});S(this,"updateScene",Ge(o=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=o;if(a){let l=n||void 0,s=r?YV({...this.store.snapshot.appState,...r}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}r&&this.setState(r),n&&this.scene.replaceAllElements(n),i&&this.setState({collaborators:i})}));S(this,"mutateElement",(o,n,r=!0)=>this.scene.mutateElement(o,n,{informMutation:r,isDragging:!1}));S(this,"triggerRender",o=>{o===!0?this.scene.triggerUpdate():this.setState({})});S(this,"toggleSidebar",({name:o,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===o&&this.state.openSidebar?.tab===n?null:o:i=r?o:null;let a=i?{name:i}:null;return a&&n&&(a.tab=n),this.setState({openSidebar:a}),!!i});S(this,"updateCurrentCursorPosition",Ge(o=>{this.lastViewportPosition.x=o.clientX,this.lastViewportPosition.y=o.clientY}));S(this,"getEditorUIOffsets",()=>{let o=this.excalidrawContainerRef?.current?.querySelector(".App-toolbar")?.getBoundingClientRect()?.bottom??0,n=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),r=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return vn().rtl?{top:o+i,right:Math.max(this.state.width-(r?.left??this.state.width),0)+i,bottom:i,left:Math.max(n?.right??0,0)+i}:{top:o+i,right:Math.max(this.state.width-(n?.left??this.state.width)+i,0),bottom:i,left:Math.max(r?.right??0,0)+i}});S(this,"onKeyDown",Ge(o=>{if("Proxy"in window&&(!o.shiftKey&&/^[A-Z]$/.test(o.key)||o.shiftKey&&/^[a-z]$/.test(o.key))&&(o=new Proxy(o,{get(a,l){let s=a[l];return typeof s=="function"?s.bind(a):l==="key"?o.shiftKey?a.key.toUpperCase():a.key.toLowerCase():s}})),!F6(o.target)){if((o.key===W.ESCAPE||o.key===W.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=J(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&Di(a[0])&&o.key===W.ENTER){this.startImageCropping(a[0]);return}if(o.key===W.ESCAPE)this.updateEditorAtom(zo,null);else if(o.key===W.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(GV.CONVERT_ELEMENT_TYPE_POPUP))){o.preventDefault();let s=Ma(a);et.get(zo)?.type==="panel"&&Qf(this,{conversionType:s,direction:o.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(zo,{type:"panel"})}if(o.key===W.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=wu(o.key);if(o[W.CTRL_OR_CMD]&&l&&!o.shiftKey){o.preventDefault();let s=J(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&nK(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,s4(o.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!fx(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(o.altKey){let s=J(this.scene.getNonDeletedElementsMap(),this.state);if(s.length===1&&l){o.preventDefault();let c=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),s4(o.key));if(c){this.setState(m=>({selectedElementIds:Ae({[c]:!0},m)}));let d=this.scene.getNonDeletedElementsMap().get(c);d&&!fx([d],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(d,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(o[W.CTRL_OR_CMD]&&o.key===W.P&&!o.shiftKey&&!o.altKey){this.setToast({message:f("commandPalette.shortcutHint",{shortcut:Xe("commandPalette")})}),o.preventDefault();return}if(o[W.CTRL_OR_CMD]&&o.key.toLowerCase()===W.V&&(ku=o.shiftKey,clearTimeout(x4),x4=window.setTimeout(()=>{ku=!1},100)),o[W.CTRL_OR_CMD]&&rc(o.target)&&(o.code===M6.MINUS||o.code===M6.EQUAL)){o.preventDefault();return}if(rc(o.target)&&o.key!==W.ESCAPE||wu(o.key)&&F6(o.target))return;if(o.key===W.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(o.key.toLowerCase()===W.E&&o.shiftKey&&o[W.CTRL_OR_CMD]){o.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(o.key===W.PAGE_UP||o.key===W.PAGE_DOWN){let a=(o.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;o.key===W.PAGE_DOWN&&(a=-a),o.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(o)||this.state.viewModeEnabled)return;if(o[W.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),wu(o.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(at),s=new Set;a.filter(at).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),g=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||g}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let c=this.getEffectiveGridSize()&&(o.shiftKey?_6:this.getEffectiveGridSize())||(o.shiftKey?cV:_6),d=0,m=0;o.key===W.ARROW_LEFT?d=-c:o.key===W.ARROW_RIGHT?d=c:o.key===W.ARROW_UP?m=-c:o.key===W.ARROW_DOWN&&(m=c),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+d,y:p.y+m},{informMutation:!1,isDragging:!1}),dx(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:mx(a.filter(p=>p.id!==l?.id||c!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),o.preventDefault()}else if(o.key===W.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(o[W.CTRL_OR_CMD]||Ix(l))Ao(l)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),at(l)||this.setState({editingLinearElement:new De(l,this.scene.getNonDeletedElementsMap())}));else if(jo(l)||dK(l)){let s;jo(l)||(s=l);let c=Ex(l,this.state,this.scene.getNonDeletedElementsMap()),d=c.x,m=c.y;this.startTextEditing({sceneX:d,sceneY:m,container:s}),o.preventDefault();return}else Lo(l)&&this.setState({editingFrame:l.id})}}else if(!o.ctrlKey&&!o.altKey&&!o.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=Qv(o.key);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===Yr.sharp?Yr.round:l.currentItemArrowType===Yr.round?Yr.elbow:Yr.sharp})),this.setActiveTool({type:a}),o.stopPropagation()):o.key===W.Q&&(this.toggleLock("keyboard"),o.stopPropagation())}if(o.key===W.SPACE&&we.pointers.size===0&&(Ri=!0,Se(this.interactiveCanvas,Ye.GRAB),o.preventDefault()),(o.key===W.G||o.key===W.S)&&!o.altKey&&!o[W.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;o.key===W.G&&($n(this.state.activeTool.type)||a.some(l=>$n(l.type)))&&(this.setState({openPopup:"elementBackground"}),o.stopPropagation()),o.key===W.S&&(this.setState({openPopup:"elementStroke"}),o.stopPropagation())}if(!o[W.CTRL_OR_CMD]&&o.shiftKey&&o.key.toLowerCase()===W.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=>jo(l)||xx(l,this.scene.getNonDeletedElementsMap())))&&(o.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(o.key===W.K&&!o.altKey&&!o[W.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}o[W.CTRL_OR_CMD]&&(o.key===W.BACKSPACE||o.key===W.DELETE)&&this.updateEditorAtom(Ei,"clearCanvas");let n=o.key.toLocaleLowerCase(),r=n===W.S&&o.shiftKey,i=o.key===W.I||n===W.G&&o.shiftKey;(r||i)&&this.openEyeDropper({type:r?"stroke":"background"})}));S(this,"onKeyUp",Ge(o=>{if(o.key===W.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?Se(this.interactiveCanvas,Ye.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?fo(this.interactiveCanvas):(io(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Ri=!1),!o[W.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),wu(o.key)&&(Y6(this.scene.getSelectedElements(this.state).filter(Ao),cx(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),o.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:Lt.IMMEDIATELY})),!o[W.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:Ae({[n.id]:!0},r)})),fx([n],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())||this.scrollToContent(n,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})),this.flowChartCreator.clear(),this.syncActionResult({captureUpdate:Lt.IMMEDIATELY})}}));S(this,"isToolSupported",o=>this.props.UIOptions.tools?.[o]!==!1);S(this,"setActiveTool",(o,n=!1)=>{if(!this.isToolSupported(o.type)){console.warn(`"${o.type}" tool is disabled via "UIOptions.canvasActions.tools.${o.type}"`);return}let r=Kn(this.state,o);PV(document.activeElement)&&this.focusContainer(),tK(r.type)||this.setState({suggestedBindings:[]}),r.type==="image"&&this.onImageAction(),this.setState(i=>{let a={snapLines:i.snapLines.length?[]:i.snapLines,originSnapOffset:null,activeEmbeddable:null};r.type==="freedraw"&&this.store.scheduleCapture();let l;return r.type==="lasso"?l={...i,activeTool:r,...n?{}:{selectedElementIds:Ae({},i),selectedGroupIds:Ae({},i),editingGroupId:null,multiElement:null},...a}:r.type!=="selection"?l={...i,activeTool:r,selectedElementIds:Ae({},i),selectedGroupIds:Ae({},i),editingGroupId:null,multiElement:null,...a}:l={...i,activeTool:r,...a},r.type==="hand"?Se(this.interactiveCanvas,Ye.GRAB):Ri||io(this.interactiveCanvas,{...this.state,activeTool:r}),l})});S(this,"setOpenDialog",o=>{this.setState({openDialog:o})});S(this,"setCursor",o=>{Se(this.interactiveCanvas,o)});S(this,"resetCursor",()=>{fo(this.interactiveCanvas)});S(this,"isTouchScreenMultiTouchGesture",()=>we.pointers.size>=2);S(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${H6()}`);S(this,"onGestureStart",Ge(o=>{if(o.preventDefault(),this.props.interactive===!1)return!1;this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null}),we.initialScale=this.state.zoom.value}));S(this,"onGestureChange",Ge(o=>{if(o.preventDefault(),this.props.interactive===!1)return!1;if(this.isTouchScreenMultiTouchGesture())return;let n=we.initialScale;n&&this.setState(r=>({...Sn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Jo(n*o.scale)},r)}))}));S(this,"onGestureEnd",Ge(o=>{if(o.preventDefault(),this.props.interactive===!1)return!1;this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ae(this.state.previousSelectedElementIds,this.state)}),we.initialScale=null}));S(this,"startTextEditing",({sceneX:o,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=r&&this.getTextWysiwygSnappedToCenterPosition(o,n,this.state,i);i&&s&&(xx(i,this.scene.getNonDeletedElementsMap())||(l=!0));let c=null,d=this.scene.getSelectedElements(this.state);d.length===1?jo(d[0])?c=d[0]:i?c=xx(d[0],this.scene.getNonDeletedElementsMap()):c=this.getTextElementAtPosition(o,n):c=this.getTextElementAtPosition(o,n);let m=c?.fontFamily||this.state.currentItemFontFamily,p=c?.lineHeight||B6(m),u=this.state.currentItemFontSize;if(!c&&l&&i&&!px(i)){let w=PK(ix({fontSize:u,fontFamily:m}),p),E=_K(u,p),y=Math.max(i.height,E),T=Math.max(i.width,w);this.scene.mutateElement(i,{height:y,width:T}),o=i.x+T/2,n=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(o,n,this.state,i))}let g=this.getTopLayerFrameAtSceneCoords({x:o,y:n}),b=c||K6({x:s?s.elementCenterX:o,y:s?s.elementCenterY:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:m,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?vV.MIDDLE:A6,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?px(i)?0:i.angle:0,frameId:g?g.id:null});if(!c&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!c)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||c||i?this.handleTextWysiwyg(b,{isExistingElement:!!c}):this.setState({newElement:b,multiElement:null})});S(this,"startImageCropping",o=>{this.store.scheduleCapture(),this.setState({croppingElementId:o.id})});S(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});S(this,"handleCanvasDoubleClick",o=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=qe(o,this.state);if(n.length===1&&Ao(n[0])){let l=n[0];if((o[W.CTRL_OR_CMD]&&ZK(l)||Ix(l))&&this.state.editingLinearElement?.elementId!==l.id){this.store.scheduleCapture(),this.setState({editingLinearElement:new De(l,this.scene.getNonDeletedElementsMap())});return}else if(this.state.selectedLinearElement&&at(n[0])){let s=De.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=s?De.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(c&&c>-1){this.store.scheduleCapture(),De.deleteFixedSegment(n[0],this.scene,c);let d=De.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=d?De.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,d,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:m,value:s,added:!1}},segmentMidPointHoveredCoords:d}});return}}else if(this.state.editingLinearElement&&this.state.editingLinearElement.elementId===l.id&&Ix(l))return}if(n.length===1&&Di(n[0])){this.startImageCropping(n[0]);return}if(fo(this.interactiveCanvas),FK(this.state).length>0){let l=this.getElementAtPosition(r,i),s=l&&OK(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...qo({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(fo(this.interactiveCanvas),!o[W.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(lc(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.editingLinearElement){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(Z6(s)||!RV(s.backgroundColor)||sc({point:he(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let c=Ex(s,this.state,this.scene.getNonDeletedElementsMap());r=c.x,i=c.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!o.altKey,container:s})}}});S(this,"getElementLinkAtPosition",(o,n)=>{if(n&&n.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let l=r[a];if(n&&l.id===n.id&&(i=a),l.link&&a>=i&&Ic(l,this.scene.getNonDeletedElementsMap(),this.state,he(o.x,o.y),this.device.editor.isMobile))return l}});S(this,"redirectToLink",(o,n)=>{let r=dl(he(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),he(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>P6)return;let i=qe(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Ic(this.hitLinkElement,a,this.state,he(i.x,i.y),this.device.editor.isMobile),s=qe(this.lastPointerUpEvent,this.state),c=Ic(this.hitLinkElement,a,this.state,he(s.x,s.y),this.device.editor.isMobile);if(l&&c){Uf();let d=this.hitLinkElement.link;if(d){d=rx(d);let m;if(this.props.onLinkOpen&&(m=_V(oe.EXCALIDRAW_LINK,o.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:d},m)),!m?.defaultPrevented){let p=MV(d)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=d)}}}});S(this,"getTopLayerFrameAtSceneCoords",o=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>i4(o,i,n));return r.length?r[r.length-1]:null});S(this,"handleCanvasPointerMove",o=>{if(this.props.interactive===!1)return!1;this.savePointer(o.clientX,o.clientY,this.state.cursorButton),this.lastPointerMoveEvent=o.nativeEvent,we.pointers.has(o.pointerId)&&we.pointers.set(o.pointerId,{x:o.clientX,y:o.clientY});let n=we.initialScale;if(we.pointers.size===2&&we.lastCenter&&n&&we.initialDistance){let g=L0(we.pointers),b=g.x-we.lastCenter.x,x=g.y-we.lastCenter.y;we.lastCenter=g;let w=A0(Array.from(we.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/we.initialDistance,y=E?Jo(n*E):this.state.zoom.value;this.setState(T=>{let v=Sn({viewportX:g.x,viewportY:g.y,nextZoom:y},T);this.translateCanvas({zoom:v.zoom,scrollX:v.scrollX+2*(b/y),scrollY:v.scrollY+2*(x/y),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else we.lastCenter=we.initialDistance=we.initialScale=null;if(Ri||pc||Sx||Do(this.state))return;let i=F0(uc,o.clientX-this.state.offsetLeft,o.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?fo(this.interactiveCanvas):io(this.interactiveCanvas,this.state));let a=qe(o,this.state),{x:l,y:s}=a;if(!this.state.newElement&&xI(this.state.activeTool.type)){let{originOffset:g,snapLines:b}=bI(this.scene.getNonDeletedElements(),this,{x:l,y:s},o,this.scene.getNonDeletedElementsMap());this.setState(x=>{let w=ic(x.snapLines,b),E=x.originSnapOffset?ic(x.originSnapOffset,g):g;return x.snapLines===w&&x.originSnapOffset===E?null:{snapLines:w,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(g=>g.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let g=De.handlePointerMove(o,l,s,this);g&&g!==this.state.editingLinearElement&&Vn(()=>{this.setState({editingLinearElement:g})}),g?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(a,g.elbowed):Vn(()=>{this.setState({suggestedBindings:[]})})}if(eK(this.state.activeTool.type)){let{newElement:g}=this.state;ux(g,!1)?this.setState({suggestedBindings:G6(g,[a],this.scene,this.state.zoom,this.state.startBoundElement)}):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:g}=this.state,{x:b,y:x}=g,{points:w,lastCommittedPoint:E}=g,y=w[w.length-1];if(io(this.interactiveCanvas,this.state),y===E)dl(he(l-b,s-x),y)>=nx?this.scene.mutateElement(g,{points:[...w,he(l-b,s-x)]},{informMutation:!1,isDragging:!1}):Se(this.interactiveCanvas,Ye.POINTER);else if(w.length>2&&E&&dl(he(l-b,s-x),E)<nx)Se(this.interactiveCanvas,Ye.POINTER),this.scene.mutateElement(g,{points:w.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[T,v]=Tt(l,s,o[W.CTRL_OR_CMD]||at(g)?null:this.getEffectiveGridSize()),[C,M]=g?.lastCommittedPoint??[0,0],k=T-b-C,P=v-x-M;ox(o)&&({width:k,height:P}=q6(C+b,M+x,T,v)),e4(w,this.state.zoom.value)&&Se(this.interactiveCanvas,Ye.POINTER),this.scene.mutateElement(g,{points:[...w.slice(0,-1),he(C+k,M+P)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!o.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let d=this.scene.getNonDeletedElements(),m=this.scene.getSelectedElements(this.state);if(m.length===1&&!i&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(m.length===1&&at(m[0]))){let g=u4(d,this.state,l,s,this.state.zoom,o.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(g&&g.transformHandleType){Se(this.interactiveCanvas,p4(g));return}}}else if(m.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let g=g4(ul(m),l,s,this.state.zoom,o.pointerType,this.device);if(g){Se(this.interactiveCanvas,p4({transformHandleType:g}));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),!Ht(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(Se(this.interactiveCanvas,Ye.POINTER),_2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Uf(),u&&(u.link||Wr(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Se(this.interactiveCanvas,jo(u)?Ye.TEXT:Ye.CROSSHAIR):this.state.viewModeEnabled?Se(this.interactiveCanvas,Ye.GRAB):this.state.openDialog?.name==="elementLinkSelector"?Se(this.interactiveCanvas,Ye.AUTO):i?Se(this.interactiveCanvas,Ye.AUTO):this.state.selectedLinearElement&&u?.id===this.state.selectedLinearElement.elementId?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s):o[W.CTRL_OR_CMD]?Se(this.interactiveCanvas,Ye.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,m))&&!u?.locked&&(u&&lc(u)&&this.isIframeLikeElementCenter(u,o,l,s)?(Se(this.interactiveCanvas,Ye.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!at(u)||!(u.startBinding||u.endBinding))&&(Se(this.interactiveCanvas,Ye.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))),this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(g=>({hoveredElementIds:ic(g.hoveredElementIds,qo({editingGroupId:g.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),g,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(g=>({hoveredElementIds:ic(g.hoveredElementIds,{})})))});S(this,"handleEraser",(o,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,o.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});S(this,"handleTouchMove",o=>{gc=!0});S(this,"handleCanvasPointerDown",o=>{let n=o.target;if(n.setPointerCapture&&n.setPointerCapture(o.pointerId),this.maybeCleanupAfterMissingPointerUp(o.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(m=>({searchMatches:m.searchMatches&&{focusedId:null,matches:m.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(vb,null)),et.get(zo)&&this.updateEditorAtom(zo,null),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(o),o.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let m=this.state.newElement;this.updateScene({...m.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==m.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Ae(Object.keys(this.state.selectedElementIds).filter(p=>p!==m.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?Lt.EVENTUALLY:Lt.NEVER});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(o),!this.state.penDetected&&o.pointerType==="pen"&&this.setState(m=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(o.pointerType)&&(this.device=lx(this.device,{isTouchScreen:!0})),pc||(this.lastPointerDownEvent=o,this.props.interactive!==!1&&this.handleCanvasPanUsingWheelOrSpaceDrag(o)))return;if(this.setState({lastPointerDownWith:o.pointerType,cursorButton:"down"}),this.savePointer(o.clientX,o.clientY,"down"),o.button===Ai.ERASER&&this.state.activeTool.type!==En.eraser){this.setState({activeTool:Kn(this.state,{type:En.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(o);let m=()=>{p(),u?.(),Ht(this.state)&&this.setState({activeTool:Kn(this.state,{...this.state.activeTool.lastActiveTool||{type:En.selection},lastActiveToolBeforeEraser:null})})},p=Ve(window,oe.POINTER_UP,m,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(m)})});return}if(o.button!==Ai.MAIN&&o.button!==Ai.TOUCH&&o.button!==Ai.ERASER||we.pointers.size>1)return;let i=this.initialPointerDownState(o);if(this.setState({selectedElementsAreBeingDragged:!1}),this.props.interactive!==!1&&this.handleDraggingScrollBar(o,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(o),this.props.interactive!==!1&&this.handleSelectionOnPointerDown(o,i))||!(!this.state.penMode||o.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;this.state.activeTool.type==="lasso"?this.lassoTrail.startPath(i.origin.x,i.origin.y,o.shiftKey):this.state.activeTool.type==="text"?this.handleTextOnPointerDown(o,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(o,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(o,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?io(this.interactiveCanvas,this.state):this.state.activeTool.type===En.frame||this.state.activeTool.type===En.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.createGenericElementOnPointerDown(this.state.activeTool.type,i),this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,o),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),c=this.onKeyDownFromPointerDownHandler(i),d=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(m=>s(m||o.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(oe.POINTER_MOVE,l),window.addEventListener(oe.POINTER_UP,s),window.addEventListener(oe.KEYDOWN,c),window.addEventListener(oe.KEYUP,d),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=d,i.eventListeners.onKeyDown=c)});S(this,"handleCanvasPointerUp",o=>{this.removePointer(o),this.lastPointerUpEvent=o;let n=qe({clientX:o.clientX,clientY:o.clientY},this.state),r=o.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&r<300){let i=this.getElementAtPosition(n.x,n.y);if(lc(i)&&this.isIframeLikeElementCenter(i,o,n.x,n.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(n.x,n.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(n,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?r<300&&lc(this.hitLinkElement)&&!nE(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,he(n.x,n.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(o,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});S(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",o=>{o.pointerType==="touch"&&(gc=!1,Vr?gc=!0:Vr=window.setTimeout(()=>{Vr=0,gc||this.handleCanvasContextMenu(o)},wV))});S(this,"resetContextMenuTimer",()=>{clearTimeout(Vr),Vr=0,gc=!1});S(this,"maybeCleanupAfterMissingPointerUp",o=>{hc?.(),this.missingPointerEventCleanupEmitter.trigger(o).clear()});S(this,"handleCanvasPanUsingWheelOrSpaceDrag",o=>{if(!(we.pointers.size<=1&&(o.button===Ai.WHEEL||o.button===Ai.MAIN&&Ri||Do(this.state)||this.state.viewModeEnabled)))return!1;pc=!0,this.focusContainer(),this.state.editingTextElement||o.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Se(this.interactiveCanvas,Ye.GRABBING);let{clientX:i,clientY:a}=o,l=Cp(c=>{let d=i-c.clientX,m=a-c.clientY;if(i=c.clientX,a=c.clientY,r&&!n&&(Math.abs(d)>1||Math.abs(m)>1)){n=!0;let p=g=>{document.body.removeEventListener(oe.PASTE,p),g.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-d/this.state.zoom.value,scrollY:this.state.scrollY-m/this.state.zoom.value})}),s=Ge(hc=()=>{hc=null,pc=!1,Ri||(this.state.viewModeEnabled?Se(this.interactiveCanvas,Ye.GRAB):io(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(o.clientX,o.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});S(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});S(this,"handleSelectionOnPointerDown",(o,n)=>{if(this.state.activeTool.type==="selection"){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.editingLinearElement&&!at(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=u4(r,this.state,n.origin.x,n.origin.y,this.state.zoom,o.pointerType,this.scene.getNonDeletedElementsMap(),this.device);l!=null&&(l.transformHandleType==="rotation"?(this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType):(this.state.croppingElementId||this.setState({resizingElement:l.element}),n.resize.handleType=l.transformHandleType))}else a.length>1&&(n.resize.handleType=g4(ul(a),n.origin.x,n.origin.y,this.state.zoom,o.pointerType,this.device));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=ax(UK(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&Ao(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=YK(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.editingLinearElement||this.state.selectedLinearElement,u=De.handlePointerDown(o,this,this.store,n.origin,p,this.scene);if(u.hitElement&&(n.hit.element=u.hitElement),u.linearElementEditor&&(this.setState({selectedLinearElement:u.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:u.linearElementEditor})),u.didAddPoint)return!0}let l=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),c=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:l});if((!c||c.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),c&&c.locked&&!s.some(p=>this.state.selectedElementIds[p.id])?n.hit.element=null:n.hit.element=n.hit.element??this.getElementAtPosition(n.origin.x,n.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(n.origin,c),this.hitLinkElement)return!0;if(this.state.croppingElementId&&n.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),n.hit.element&&this.getElementLinkAtPosition({x:n.origin.x,y:n.origin.y},n.hit.element))return!1;n.hit.allHitElements=s;let d=n.hit.element,m=n.hit.allHitElements.some(p=>this.isASelectedElement(p));if((d===null||!m)&&!o.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(d),this.state.editingLinearElement)this.setState({selectedElementIds:Ae({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(d!=null){if(o[W.CTRL_OR_CMD])return o.altKey||(this.state.selectedElementIds[d.id]||(n.hit.wasAddedToSelection=!0),this.setState(p=>({...BK(p,d),previousSelectedElementIds:this.state.selectedElementIds}))),!1;this.state.selectedElementIds[d.id]||(this.state.editingGroupId&&!d4(d,this.state.editingGroupId)&&this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!m&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[d.id]:!0},g=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&g.push(x)}),Lo(d))r4(g,d.id).forEach(b=>{delete u[b.id]});else if(d.frameId)u[d.frameId]&&delete u[d.id];else{let b=d.groupIds,x=new Set(b.flatMap(w=>dc(this.scene.getNonDeletedElements(),w)).filter(w=>Lo(w)).map(w=>w.id));x.size>0&&g.forEach(w=>{w.frameId&&x.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(E=>dc(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(d.groupIds.some(b=>p.selectedGroupIds[b])||(u={[d.id]:!0})),{...qo({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:d.link||Wr(d)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});S(this,"handleTextOnPointerDown",(o,n)=>{if(this.state.editingTextElement)return;let r=n.origin.x,i=n.origin.y,a=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);Z6(a)&&(l=a,r=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!o.altKey,container:l,autoEdit:!1}),fo(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Kn(this.state,{type:"selection"})})});S(this,"handleFreeDrawElementOnPointerDown",(o,n,r)=>{let[i,a]=Tt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=o.pressure===.5,c=XV({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[he(0,0)],pressures:s?[]:[o.pressure]});this.scene.insertElement(c),this.setState(m=>{let p={...m.selectedElementIds};return delete p[c.id],{selectedElementIds:Ae(p,m)}});let d=sx(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:c,startBoundElement:d,suggestedBindings:[]})});S(this,"insertIframeElement",({sceneX:o,sceneY:n,width:r,height:i})=>{let[a,l]=Tt(o,n,this.lastPointerDownEvent?.[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=$V({type:"iframe",x:a,y:l,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("iframe"),opacity:this.state.currentItemOpacity,locked:!1,width:r,height:i});return this.scene.insertElement(s),s});S(this,"insertEmbeddableElement",({sceneX:o,sceneY:n,link:r})=>{let[i,a]=Tt(o,n,this.lastPointerDownEvent?.[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=Su(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let s=W6({type:"embeddable",x:i,y:a,strokeColor:"transparent",backgroundColor:"transparent",fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,roundness:this.getCurrentItemRoundness("embeddable"),opacity:this.state.currentItemOpacity,locked:!1,width:l.intrinsicSize.w,height:l.intrinsicSize.h,link:r});return this.scene.insertElement(s),s});S(this,"createImageElement",async({sceneX:o,sceneY:n,addToFrameUnderCursor:r=!0,imageFile:i})=>{let[a,l]=Tt(o,n,this.lastPointerDownEvent?.[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=r?this.getTopLayerFrameAtSceneCoords({x:a,y:l}):null,c=100/this.state.zoom.value,d=qV({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:s?s.id:null,x:a-c/2,y:l-c/2,width:c,height:c});return await this.insertImageElement(d,i)});S(this,"handleLinearElementOnPointerDown",(o,n,r)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&e4(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Vt);return}if(at(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(Vt);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&dl(he(r.origin.x-a,r.origin.y-l),s)<nx){this.actionManager.executeAction(Vt);return}this.setState(c=>({selectedElementIds:Ae({...c.selectedElementIds,[i.id]:!0},c)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),Se(this.interactiveCanvas,Ye.POINTER)}else{let[i,a]=Tt(r.origin.x,r.origin.y,o[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[d,m]=n==="arrow"?[s,c]:[null,null],p=n==="arrow"?ZV({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Yr.round?{type:vu.PROPORTIONAL_RADIUS}:null,startArrowhead:d,endArrowhead:m,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Yr.elbow,fixedSegments:this.state.currentItemArrowType===Yr.elbow?[]:null}):JV({type:n,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemRoundness==="round"?{type:vu.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(g=>{let b={...g.selectedElementIds};return delete b[p.id],{selectedElementIds:Ae(b,g)}}),this.scene.mutateElement(p,{points:[...p.points,he(0,0)]});let u=sx(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,at(p),at(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});S(this,"createGenericElementOnPointerDown",(o,n)=>{let[r,i]=Tt(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),l={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(o),locked:!1,frameId:a?a.id:null},s;o==="embeddable"?s=W6({type:"embeddable",...l}):s=jV({type:o,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});S(this,"createFrameElementOnPointerDown",(o,n)=>{let[r,i]=Tt(o.origin.x,o.origin.y,this.lastPointerDownEvent?.[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Gr},l=n===En.magicframe?V6(a):KV(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});S(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});S(this,"eraseElements",()=>{let o=!1,n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||gx(r)&&this.elementsPendingErasure.has(r.containerId)?(o=!0,_i(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,o&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});S(this,"initializeImage",async(o,n)=>{if(!Mc(n))throw new Error(f("errors.unsupportedFileType"));let r=n.type;if(Se(this.interactiveCanvas,"wait"),r===Ur.svg)try{n=Ku(o4(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(f("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(n)||hE(n));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{n=await Ac(n,{maxWidthOrHeight:sV})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>D6)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(D6/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await Vu(n);return new Promise(async(s,c)=>{try{let d=this.getLatestInitializedImageElement(o,i);if(this.addMissingFiles([{mimeType:r,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([d]);if(p.size)throw new Error("Image cache update resulted with an error.")}let m=await this.imageCache.get(i)?.image;if(m&&this.state.newElement?.id!==d.id){d=this.getLatestInitializedImageElement(o,i);let p=this.getImageNaturalDimensions(d,m);Object.assign(d,p)}s(d)}catch(d){console.error(d),c(new Error(f("errors.imageInsertError")))}})});S(this,"getLatestInitializedImageElement",(o,n)=>{let r=this.scene.getElement(o.id)??o;return _i(r,{fileId:n})});S(this,"insertImageElement",async(o,n)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}this.scene.insertElement(o);try{let r=await this.initializeImage(o,n),i=this.scene.getElementsIncludingDeleted().map(a=>a.id===r.id?r:a);return this.updateScene({captureUpdate:Lt.IMMEDIATELY,elements:i,appState:{selectedElementIds:Ae({[r.id]:!0},this.state)}}),r}catch(r){return this.store.scheduleAction(Lt.NEVER),this.scene.mutateElement(o,{isDeleted:!0}),this.actionManager.executeAction(Vt),this.setState({errorMessage:r.message||f("errors.imageInsertError")}),null}});S(this,"onImageAction",async()=>{try{let o=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=qe({clientX:o,clientY:n},this.state),a=await vc({description:"Image",extensions:Object.keys(dV)});await this.createImageElement({sceneX:r,sceneY:i,addToFrameUnderCursor:!1,imageFile:a}),this.setState({},()=>{this.actionManager.executeAction(Vt)})}catch(o){o.name!=="AbortError"?console.error(o):console.warn(o),this.setState({newElement:null,activeTool:Kn(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(Vt)})}});S(this,"getImageNaturalDimensions",(o,n)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(n.naturalHeight,i),l=a*(n.naturalWidth/n.naturalHeight),s=o.x+o.width/2-l/2,c=o.y+o.height/2-a/2;return{x:s,y:c,width:l,height:a,crop:null}});S(this,"updateImageCache",async(o,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await cK({imageCache:this.imageCache,fileIds:o.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(Lt.NEVER),this.scene.replaceAllElements(o.map(a=>ac(a)&&i.has(a.fileId)?_i(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});S(this,"addNewImagesToImageCache",async(o=sK(this.scene.getNonDeletedElements()),n=this.files)=>{let r=o.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,n);if(i.size)for(let a of r)i.has(a.fileId)&&cc.delete(a);i.size&&this.scene.triggerUpdate()}});S(this,"scheduleImageRefresh",oV(()=>{this.addNewImagesToImageCache()},mV));S(this,"updateBindingEnabledOnPointerMove",o=>{let n=VV(o);this.state.isBindingEnabled!==n&&this.setState({isBindingEnabled:n})});S(this,"maybeSuggestBindingAtCursor",(o,n)=>{let r=sx(o,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,n);this.setState({suggestedBindings:r!=null?[r]:[]})});S(this,"handleInteractiveCanvasRef",o=>{o!==null?(this.interactiveCanvas=o,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))});S(this,"handleAppOnDrop",async o=>{let{file:n,fileHandle:r}=await EE(o),{x:i,y:a}=qe(o,this.state);try{if(Mc(n)&&this.isToolSupported("image")){if(n?.type===Ur.png||n?.type===Ur.svg)try{let s=await Lc(n,this.state,this.scene.getElementsIncludingDeleted(),r);this.syncActionResult({...s,appState:{...s.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Lt.IMMEDIATELY});return}catch(s){if(s.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}this.createImageElement({sceneX:i,sceneY:a,imageFile:n});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let l=o.dataTransfer.getData(Ur.excalidrawlib);if(l&&typeof l=="string"){try{let s=gE(l);this.addElementsFromPasteOrLibrary({elements:km(s),position:o,files:null})}catch(s){this.setState({errorMessage:s.message})}return}if(n&&await this.loadFileToCanvas(n,r),o.dataTransfer?.types?.includes("text/plain")){let s=o.dataTransfer?.getData("text");if(s&&bx(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||Su(s)?.type==="video")){let c=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:rx(s)});c&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[c.id]:!0}}))}}});S(this,"loadFileToCanvas",async(o,n)=>{o=await wE(o);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await Yu(o,this.state,r,n)}catch(a){let l=a instanceof eE;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let s=l?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===Ur.excalidraw?(w4(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:Lt.NEVER,elements:r,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:Lt.IMMEDIATELY})):i.type===Ur.excalidrawlib&&await this.library.updateLibrary({libraryItems:o,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:f("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});S(this,"handleCanvasContextMenu",o=>{if(o.preventDefault(),this.props.interactive===!1||("pointerType"in o.nativeEvent&&o.nativeEvent.pointerType==="touch"||"pointerType"in o.nativeEvent&&o.nativeEvent.pointerType==="pen"&&o.button!==Ai.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:n,y:r}=qe(o,this.state),i=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:n,y:r},a),s=i||l?"element":"canvas",c=this.excalidrawContainerRef.current,{top:d,left:m}=c.getBoundingClientRect(),p=o.clientX-m,u=o.clientY-d;ae("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...qo({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Ao(i)?new De(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});S(this,"maybeDragNewGenericElement",(o,n,r=!0)=>{let i=this.state.selectionElement,a=o.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){h4({newElement:i,elementType:this.state.activeTool.type,originX:o.origin.x,originY:o.origin.y,x:a.x,y:a.y,width:pl(o.origin.x,a.x),height:pl(o.origin.y,a.y),shouldMaintainAspectRatio:nc(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,c]=Tt(a.x,a.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=ac(l)&&this.imageCache.get(l.fileId)?.image,m=d&&!(d instanceof Promise)?d.width/d.height:null;this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:p,snapLines:u}=fI(l,this,n,{x:o.originInGrid.x+(this.state.originSnapOffset?.x??0),y:o.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-o.originInGrid.x,y:c-o.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,c+=p.y,this.setState({snapLines:u}),h4({newElement:l,elementType:this.state.activeTool.type,originX:o.originInGrid.x,originY:o.originInGrid.y,x:s,y:c,width:pl(o.originInGrid.x,s),height:pl(o.originInGrid.y,c),shouldMaintainAspectRatio:Di(l)?!nc(n):nc(n),shouldResizeFromCenter:L6(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:m,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===En.frame||this.state.activeTool.type===En.magicframe)&&this.setState({elementsToHighlight:wx(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});S(this,"maybeHandleCrop",(o,n)=>{if(!this.state.croppingElementId)return!1;let r=o.resize.handleType,i=o.lastCoords,[a,l]=Tt(i.x-o.resize.offset.x,i.y-o.resize.offset.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&Di(s)){let c=o.originalElements.get(s.id),d=ac(s)&&this.imageCache.get(s.fileId)?.image;if(c&&Di(c)&&d&&!(d instanceof Promise)){let[m,p]=Tt(i.x,i.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-o.originInGrid.x,y:p-o.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:g,snapLines:b}=R0([s],[c],this,n,u,r);this.scene.mutateElement(s,CK(s,this.scene.getNonDeletedElementsMap(),r,d.naturalWidth,d.naturalHeight,a+g.x,l+g.y,n.shiftKey?c.width/c.height:void 0)),dx(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:r&&r!=="rotation",snapLines:b})}return!0}return!1});S(this,"maybeHandleResize",(o,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(m=>Lo(m)),a=o.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&at(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=o.lastCoords,[s,c]=Tt(l.x-o.resize.offset.x,l.y-o.resize.offset.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),d=new Map;if(i.forEach(m=>{r4(this.scene.getNonDeletedElements(),m.id).forEach(u=>{d.set(m.id+u.id,{x:u.x-m.x,y:u.y-m.y})})}),!this.state.selectedElementsAreBeingDragged){let[m,p]=Tt(l.x,l.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:m-o.originInGrid.x,y:p-o.originInGrid.y},g=[...o.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:b,snapLines:x}=R0(r,J(g,this.state),this,n,u,a);s+=b.x,c+=b.y,this.setState({snapLines:x})}if(WK(o.originalElements,a,r,this.scene,ox(n),L6(n),r.some(m=>Di(m))?!nc(n):nc(n),s,c,o.resize.center.x,o.resize.center.y)){let m=mx(r,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{wx(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(g=>p.add(g))}),this.setState({elementsToHighlight:[...p],suggestedBindings:m}),!0}return!1});S(this,"getContextMenuItems",o=>{let n=[];return n.push(gs,us),o==="canvas"?this.state.viewModeEnabled?[...n,fs,fi,k0,bi]:[Pf,it,gs,us,hs,it,hd,F2,it,fs,mm,fi,k0,bi]:(n.push(hs),this.state.viewModeEnabled?[hi,...n]:[it,ps,hi,Pf,it,$3,Z3,j3,it,up,it,...n,it,qd,Jd,it,om,nI,pm,um,T2,nm,it,lm,it,dd,md,pd,ud,it,cm,dm,it,pp,it,va,wm,it,fd,Ta,it,Zi])});S(this,"handleWheel",Ge(o=>{if(!(o.target instanceof HTMLCanvasElement||o.target instanceof HTMLTextAreaElement||o.target instanceof HTMLIFrameElement)){o[W.CTRL_OR_CMD]&&o.preventDefault();return}if(o.preventDefault(),pc||this.props.interactive===!1)return;let{deltaX:n,deltaY:r}=o;if(o.metaKey||o.ctrlKey){let i=Math.sign(r),a=TV*100,l=Math.abs(r),s=r;l>a&&(s=a*i);let c=this.state.zoom.value-s/100;c+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(d=>({...Sn({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:Jo(c)},d),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(o.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(r||n)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-n/i.value,scrollY:l-r/i.value}))}));S(this,"savePointer",(o,n,r)=>{if(!o||!n)return;let{x:i,y:a}=qe({clientX:o,clientY:n},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:r,pointersMap:we.pointers})});S(this,"resetShouldCacheIgnoreZoomDebounced",O6(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));S(this,"updateDOMRect",o=>{if(this.excalidrawContainerRef?.current){let n=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:l}=n.getBoundingClientRect(),{width:s,height:c,offsetTop:d,offsetLeft:m}=this.state;if(r===s&&i===c&&a===m&&l===d){o&&o();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{o&&o()})}});S(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let n=Jr(),{excalidrawAPI:r,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=n.theme,name:d=`${f("labels.untitled")}-${H6()}`}=o;if(this.state={...n,theme:c,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??n.gridModeEnabled,name:d,width:window.innerWidth,height:window.innerHeight},this.id=rV(),this.library=new c1(this),this.actionManager=new Hs(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new b4,this.canvas=document.createElement("canvas"),this.rc=nV.canvas(this.canvas),this.renderer=new Ys(this.scene),this.visibleElements=[],this.store=new XK(this),this.history=new ja(this.store),r){let m={updateScene:this.updateScene,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,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,app:this,onChange:p=>this.onChangeEmitter.on(p),onIncrement:p=>this.store.onStoreIncrementEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof r=="function"?r(m):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Zn(this.scene),this.history=new ja(this.store),this.actionManager.registerAll(rd),this.actionManager.registerAction(Q3(this.history)),this.actionManager.registerAction(eI(this.history))}onWindowMessage(o){if(o.origin!=="https://player.vimeo.com"&&o.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(o.data)}catch{}if(n)switch(o.origin){case"https://player.vimeo.com":if(n.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===o.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:n.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(n.event==="infoDelivery"&&n.info&&n.id&&typeof n.info.playerState=="number"){let r=n.id,i=n.info.playerState;Object.values(Iu).includes(i)&&kx.set(r,i)}break}}cacheEmbeddableRef(o,n){n&&this.iFrameRefs.set(o.id,n)}getHTMLIFrameElement(o){return this.iFrameRefs.get(o.id)}handleEmbeddableCenterClick(o){if(this.state.activeEmbeddable?.element===o&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:o,state:"active"},selectedElementIds:{[o.id]:!0},newElement:null,selectionElement:null})},100),gl(o)))return;let n=this.getHTMLIFrameElement(o);if(n?.contentWindow){if(n.src.includes("youtube")){let r=kx.get(o.id);switch(r||(kx.set(o.id,Iu.UNSTARTED),n.contentWindow.postMessage(JSON.stringify({event:"listening",id:o.id}),"*")),r){case Iu.PLAYING:case Iu.BUFFERING:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}n.src.includes("player.vimeo.com")&&n.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(o,n,r,i){return o&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==o||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=o.x+o.width/3&&r<=o.x+2*o.width/3&&i>=o.y+o.height/3&&i<=o.y+2*o.height/3}renderEmbeddables(){let o=this.state.zoom.value,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Wr(a)&&this.embedsValidationStatus.get(a.id)===!0||gl(a));return ve(qK,{children:i.map(a=>{let{x:l,y:s}=Cu({sceneX:a.x,sceneY:a.y},this.state),c=J6(a,n,r,this.state,this.scene.getNonDeletedElementsMap()),d=this.initializedEmbeds.has(a.id);if(c&&!d&&this.initializedEmbeds.add(a.id),!(c||d))return null;let p;if(gl(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:()=>t4(`
|
|
30
43
|
<style>
|
|
31
44
|
html, body {
|
|
32
45
|
width: 100%;
|
|
33
46
|
height: 100%;
|
|
34
|
-
color: ${this.state.theme===
|
|
47
|
+
color: ${this.state.theme===Tu.DARK?"white":"black"};
|
|
35
48
|
}
|
|
36
49
|
body {
|
|
37
50
|
display: flex;
|
|
@@ -98,7 +111,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),ye("ai","me
|
|
|
98
111
|
</svg>
|
|
99
112
|
</div>
|
|
100
113
|
<div>Generating...</div>
|
|
101
|
-
`)};else{let x;b.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=b.message||"Generation failed",p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>
|
|
114
|
+
`)};else{let x;b.code==="ERR_GENERATION_INTERRUPTED"?x="Generation was interrupted...":x=b.message||"Generation failed",p={intrinsicSize:{w:a.width,h:a.height},type:"document",srcdoc:()=>t4(`
|
|
102
115
|
<style>
|
|
103
116
|
html, body {
|
|
104
117
|
height: 100%;
|
|
@@ -108,7 +121,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),ye("ai","me
|
|
|
108
121
|
flex-direction: column;
|
|
109
122
|
align-items: center;
|
|
110
123
|
justify-content: center;
|
|
111
|
-
color: ${
|
|
124
|
+
color: ${aV.red[3]};
|
|
112
125
|
}
|
|
113
126
|
h1, h3 {
|
|
114
127
|
margin-top: 0;
|
|
@@ -117,7 +130,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),ye("ai","me
|
|
|
117
130
|
</style>
|
|
118
131
|
<h1>Error!</h1>
|
|
119
132
|
<h3>${x}</h3>
|
|
120
|
-
`)}}}else p=ui(Ic(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",g=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return Be("div",{className:J5("excalidraw__embeddable-container",{"is-hovered":g}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:Nx(a,di(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?Xb:1),"--embeddable-radius":`${Yc(Math.min(a.width,a.height),a)}px`},children:Wp("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?Xn.enabled:Xn.disabled},children:[g&&Be("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Be("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(Ht(a)?this.props.renderEmbeddable?.(a,this.state):null)??Be("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,pendingImageElementId:this.state.pendingImageElementId});this.visibleElements=l;let s=this.scene.getNonDeletedElementsMap(),c="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",m=t[0];return Be("div",{className:J5("excalidraw excalidraw-container",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":c?Xn.disabled:Xn.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:Be(tT.Provider,{value:this,children:Be(oT.Provider,{value:this.props,children:Be(cb.Provider,{value:this.excalidrawContainerValue,children:Be(sb.Provider,{value:this.device,children:Be(pb.Provider,{value:this.setAppState,children:Be(mb.Provider,{value:this.state,children:Wp(db.Provider,{value:this.scene.getNonDeletedElements(),children:[Wp(ub.Provider,{value:this.actionManager,children:[Be(H5,{onHomeButtonClick:this.props.onHomeButtonClick||(()=>{}),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:Hr().code,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==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,renderTopRightUI:r,uiDisabled:this.props.ui===!1,children:this.props.children}),Be("div",{className:"excalidraw-textEditorContainer"}),Be("div",{className:"excalidraw-contextMenuContainer"}),Be("div",{className:"excalidraw-eye-dropper-container"}),Be(V5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Be($2,{element:m,elementsMap:s,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.props.aiEnabled!==!1&&t.length===1&&Sc(m)&&Be(b1,{element:m,elementsMap:a,children:Be(Vp,{title:f("labels.convertToCode"),icon:ts,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),t.length===1&&ri(m)&&m.customData?.generationData?.status==="done"&&Wp(b1,{element:m,elementsMap:a,children:[Be(Vp,{title:f("labels.copySource"),icon:Ti,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),Be(Vp,{title:"Enter fullscreen",icon:Mg,checked:!1,onChange:()=>{let d=this.getHTMLIFrameElement(m);if(d)try{d.requestFullscreen(),this.setState({activeEmbeddable:{element:m,state:"active"},selectedElementIds:{[m.id]:!0},newElement:null,selectionElement:null})}catch(p){console.warn(p),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&Be(q5,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&this.props.interactive!==!1&&this.props.ui!==!1&&Be(Zw,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:d=>{this.setState({contextMenu:null},()=>{this.focusContainer(),d?.()})}}),Be(ob,{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:Nn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&Be($5,{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}}),Be(tb,{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,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&&Be($w,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),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=zc(this.scene.getNonDeletedElements(),t).filter(l=>!Sc(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ye("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}}),ye("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(ye("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){ye("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"&&(Qo(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=>{Dr(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),hn.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,mt()||Ge()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...n)=>this.setState(...n)},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.onStoreIncrementEmitter.on(r=>{this.history.record(r.elementsChange,r.appStateChange)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),mt()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),dl&&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),kb()&&!W0()&&this.setState({errorMessage:Be(Vw,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new pn,this.fonts=new gn(this.scene),this.renderer=new Rs(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(),hn.destroy(),zo.destroy(),Ox(),this.onChangeEmitter.clear(),w0()&&(this.history=new ja,this.library=new Hf(this),this.actionManager=new _s(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.canvas=null,this.interactiveCanvas=null,this.rc=null,this.excalidrawContainerRef.current=void 0,this.nearestScrollableContainer=void 0,this.excalidrawContainerValue={container:null,id:"unmounted"}),clearTimeout(Yn),ze.clearCache(),lt.clearCache(),Yn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(We(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(We(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),We(window,"message",this.onWindowMessage,!1),We(document,"pointerup",this.removePointer,{passive:!1}),We(document,"copy",this.onCopy,{passive:!1}),We(document,"keyup",this.onKeyUp,{passive:!0}),We(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),We(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),We(document,"gesturestart",this.onGestureStart,!1),We(document,"gesturechange",this.onGestureChange,!1),We(document,"gestureend",this.onGestureEnd,!1),We(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(We(document,"fullscreenchange",this.onFullscreenChange,{passive:!1}),We(document,"paste",this.pasteFromClipboard,{passive:!1}),We(document,"cut",this.onCut,{passive:!1}),We(window,"resize",this.onResize,!1),We(window,"unload",this.onUnload,!1),We(window,"blur",this.onBlur,!1),We(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),We(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),We(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(We(f0(this.excalidrawContainerRef.current),"scroll",this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted(),a=this.scene.getNonDeletedElementsMap();!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(),this.props.activeTool&&this.props.activeTool.type!==this.state.activeTool.type&&this.setActiveTool(this.props.activeTool),(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&&ao(this.state)&&this.setState({activeTool:Ue(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&Sf(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(),ao(r)&&!ao(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.props.UIOptions.canvasActions&&this.state.openMenu==="canvas"&&this.setState({openMenu:null}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===ce.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(co)}),this.state.editingTextElement?.isDeleted&&this.setState({editingTextElement:null}),this.state.selectedLinearElement&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&this.setState({selectedLinearElement:null});let{multiElement:s}=r;r.activeTool!==this.state.activeTool&&s!=null&&li(this.state)&&Pr(s,!1)&&Ml(s,this.state,an(j.getPointAtIndexGlobalCoordinates(s,-1,a)),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files,this.props.id),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){Ws=!1}async addElementsFromMixedContentPaste(t,{isPlainPaste:r,sceneX:n,sceneY:i}){if(!r&&t.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=t.filter(p=>p.type==="imageUrl").map(p=>p.value),l=await Promise.all(a.map(async p=>{try{return{file:await hE(p)}}catch(u){let g=u.message;return u.cause==="FETCH_ERROR"?g=f("errors.failedToFetchImage"):u.cause==="UNSUPPORTED"&&(g=f("errors.unsupportedFileType")),{errorMessage:g}}})),s=i,c=!1,m={};for(let p of l)if(p.file){let u=this.createImageElement({sceneX:n,sceneY:s}),g=await this.insertImageElement(u,p.file);g&&(c||(c=!0,s-=g.height/2),B(g,{y:s},!1),s=u.y+u.height+25,m[u.id]=!0)}this.setState({selectedElementIds:Me(m,this.state)});let d=l.find(p=>!!p.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
|
|
133
|
+
`)}}}else p=Su(LV(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",g=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return ve("div",{className:v6("excalidraw__embeddable-container",{"is-hovered":g}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${o})`:"none",display:c?"block":"none",opacity:NK(a,vx(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?SV:1),"--embeddable-radius":`${aK(Math.min(a.width,a.height),a)}px`},children:Mu("div",{className:"excalidraw__embeddable-container__inner",style:{width:c?`${a.width}px`:0,height:c?`${a.height}px`:0,transform:c?`rotate(${a.angle}rad)`:"none",pointerEvents:u?ml.enabled:ml.disabled},children:[g&&ve("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),ve("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(Wr(a)?this.props.renderEmbeddable?.(a,this.state):null)??ve("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(o){document.documentElement.style.overscrollBehaviorX=o.type==="pointerenter"?"none":"auto"}render(){let o=this.scene.getSelectedElements(this.state),{renderTopRightUI:n,renderCustomStats:r}=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(),c="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",d=o[0],m=et.get(zo)?.type==="panel";return ve("div",{className:v6("excalidraw excalidraw-container",this.props.className,{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile,"excalidraw--zen-mode":this.state.zenModeEnabled}),style:{"--ui-pointerEvents":c?ml.disabled:ml.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:ve(v4.Provider,{value:this,children:ve(T4.Provider,{value:this.props,children:ve(Px.Provider,{value:this.excalidrawContainerValue,children:ve(Ax.Provider,{value:this.device,children:ve(Rx.Provider,{value:this.setAppState,children:ve(Dx.Provider,{value:this.state,children:Mu(_x.Provider,{value:this.scene.getNonDeletedElements(),children:[Mu(Nx.Provider,{value:this.actionManager,children:[ve(l6,{onHomeButtonClick:this.props.onHomeButtonClick||(()=>{}),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:vn().code,renderCustomStats:r,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==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,renderTopRightUI:n,uiDisabled:this.props.ui===!1,children:this.props.children}),ve("div",{className:"excalidraw-textEditorContainer"}),ve("div",{className:"excalidraw-contextMenuContainer"}),ve("div",{className:"excalidraw-eye-dropper-container"}),ve(d6,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),o.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&ve(A2,{element:d,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},d.id),this.props.aiEnabled!==!1&&o.length===1&&hx(d)&&ve(X0,{element:d,elementsMap:a,children:ve(yu,{title:f("labels.convertToCode"),icon:Nl,checked:!1,onChange:()=>this.onMagicFrameGenerate(d,"button")})}),o.length===1&&gl(d)&&d.customData?.generationData?.status==="done"&&Mu(X0,{element:d,elementsMap:a,children:[ve(yu,{title:f("labels.copySource"),icon:ri,checked:!1,onChange:()=>this.onIframeSrcCopy(d)}),ve(yu,{title:"Enter fullscreen",icon:dh,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(d);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:d,state:"active"},selectedElementIds:{[d.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&ve(y6,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&this.props.interactive!==!1&&this.props.ui!==!1&&ve(f5,{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?.()})}}),ve(Qb,{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:kr(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&ve(x6,{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}}),ve(Jb,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:o,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&&ve(x5,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&ve(w6,{app:this,activeLockedId:this.state.activeLockedId}),m&&ve(X2,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(o){Object.assign(this.plugins,o)}async onMagicFrameGenerate(o,n){let r=this.plugins.diagramToCode?.generate;if(!r){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=xK(this.scene.getNonDeletedElements(),o).filter(l=>!hx(l));if(!i.length){n==="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:o.x+o.width+30,sceneY:o.y,width:o.width,height:o.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 r({frame:o,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(o){o.customData?.generationData?.status==="done"&&(Fo(o.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(o){let n=o??this.files;this.scene.getNonDeletedElements().forEach(r=>{ac(r)&&n[r.fileId]&&(this.imageCache.delete(r.fileId),cc.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,Mx()||y4()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(r=>{this.history.record(r.delta)});let{onIncrement:o}=this.props;o&&this.store.onStoreIncrementEmitter.on(r=>{o(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Mx()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),R6&&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),pV()&&!MK()&&this.setState({errorMessage:ve(p5,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new b4,this.fonts=new Zn(this.scene),this.renderer=new Ys(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(),cc.destroy(),Io.destroy(),RK(),this.onChangeEmitter.clear(),UV()&&(this.history=new ja(this.store),this.library=new c1(this),this.actionManager=new Hs(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.canvas=null,this.interactiveCanvas=null,this.rc=null,this.excalidrawContainerRef.current=void 0,this.nearestScrollableContainer=void 0,this.excalidrawContainerValue={container:null,id:"unmounted"}),clearTimeout(Vr),Le.clearCache(),qo.clearCache(),Vr=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Ve(document,oe.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Ve(this.excalidrawContainerRef.current,oe.WHEEL,this.handleWheel,{passive:!1}),Ve(window,oe.MESSAGE,this.onWindowMessage,!1),Ve(document,oe.POINTER_UP,this.removePointer,{passive:!1}),Ve(document,oe.COPY,this.onCopy,{passive:!1}),Ve(document,oe.KEYUP,this.onKeyUp,{passive:!0}),Ve(document,oe.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),Ve(document.fonts,"loadingdone",o=>{let n=o.fontfaces;this.fonts.onLoaded(n)},{passive:!1}),Ve(document,oe.GESTURE_START,this.onGestureStart,!1),Ve(document,oe.GESTURE_CHANGE,this.onGestureChange,!1),Ve(document,oe.GESTURE_END,this.onGestureEnd,!1),Ve(window,oe.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Ve(document,oe.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),Ve(document,oe.PASTE,this.pasteFromClipboard,{passive:!1}),Ve(document,oe.CUT,this.onCut,{passive:!1}),Ve(window,oe.RESIZE,this.onResize,!1),Ve(window,oe.UNLOAD,this.onUnload,!1),Ve(window,oe.BLUR,this.onBlur,!1),Ve(this.excalidrawContainerRef.current,oe.WHEEL,this.handleWheel,{passive:!1}),Ve(this.excalidrawContainerRef.current,oe.DRAG_OVER,this.disableEvent,!1),Ve(this.excalidrawContainerRef.current,oe.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Ve(AV(this.excalidrawContainerRef.current),oe.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(o,n){this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),o.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),n.userToFollow&&!this.state.collaborators.has(n.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),this.props.activeTool&&this.props.activeTool.type!==this.state.activeTool.type&&this.setActiveTool(this.props.activeTool),(n.zoom.value!==this.state.zoom.value||n.scrollX!==this.state.scrollX||n.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),n.userToFollow!==this.state.userToFollow&&(n.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:n.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&Ht(this.state)&&this.setState({activeTool:Kn(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&n.theme!==this.state.theme&&ff(this.interactiveCanvas,this.state.theme),n.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),o.langCode!==this.props.langCode&&this.updateLanguage(),Ht(n)&&!Ht(this.state)&&this.eraserTrail.endPath(),o.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),n.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(n.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&n.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),o.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),o.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),!this.props.UIOptions.canvasActions&&this.state.openMenu==="canvas"&&this.setState({openMenu:null}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===Tu.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(Vt)}),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||(this.props.onChange?.(r,this.state,this.files,this.props.id),this.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){mc=!1}async addElementsFromMixedContentPaste(o,{isPlainPaste:n,sceneX:r,sceneY:i}){if(!n&&o.some(a=>a.type==="imageUrl")&&this.isToolSupported("image")){let a=o.filter(p=>p.type==="imageUrl").map(p=>p.value),l=await Promise.all(a.map(async p=>{try{return{file:await xE(p)}}catch(u){let g=u.message;return u.cause==="FETCH_ERROR"?g=f("errors.failedToFetchImage"):u.cause==="UNSUPPORTED"&&(g=f("errors.unsupportedFileType")),{errorMessage:g}}})),s=i,c=!1,d={};for(let p of l)if(p.file){let u=await this.createImageElement({sceneX:r,sceneY:s,imageFile:p.file});u&&(c||(c=!0,s-=u.height/2),this.scene.mutateElement(u,{y:s},{informMutation:!1,isDragging:!1}),s=u.y+u.height+25,d[u.id]=!0)}this.setState({selectedElementIds:Ae(d,this.state)});let m=l.find(p=>!!p.errorMessage);m&&m.errorMessage&&this.setState({errorMessage:m.errorMessage})}else{let a=o.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
|
|
121
134
|
|
|
122
|
-
`),
|
|
123
|
-
`),b=g.reduce((x,E,w)=>{let y=ai(E).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),C=Ut(y,l,s),S=C.width>d,_=S?Ji(y,l,d):y;C=S?Ut(_,l,s):C;let L=n-C.width/2,N=u-C.height/2,P=Yt({...a,x:L,y:N,text:_,originalText:y,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(P),u+=P.height+p}else g[w-1]?.trim()&&(u+=K0(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.setState({selectedElementIds:Me(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&eT===!1&&!this.device.editor.isMobile&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:R("CtrlOrCmd+Shift+V")}),duration:5e3}),eT=!0),this.store.shouldCaptureIncrement())}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&Z(s)?re(s,{originalText:a,isDeleted:l??s.isDeleted,...Gx(s,_t(s,n),n,a)}):s)])};zw({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:c}=Ft({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:ot(a=>{i(a,!1),ku(t)&&at(t,this.scene.getNonDeletedElementsMap())}),onSubmit:ot(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let c=t.containerId?t.containerId:t.id;Fi(()=>{this.setState(m=>({selectedElementIds:Me({...m.selectedElementIds,[c]:!0},m)}))})}s&&Pc(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.shouldCaptureIncrement(),Fi(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&To(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:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&Z(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=this.getElementsAtPosition(t,r,n?.includeBoundTextElement,n?.includeLockedElements);if(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 ji({x:t,y:r,element:a,shape:Or(a,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()/2,frameNameBound:ae(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n=!1,i=!1){let a=[],l=this.scene.getNonDeletedElementsMap();return(n&&i?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(c=>(i||!c.locked)&&(n||!(Z(c)&&c.containerId)))).filter(c=>this.hitElement(t,r,c)).filter(c=>{let m=di(c,l);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?Mu({x:t,y:r},m,l):!0}).filter(c=>ri(c)?(a.push(c),!1):!0).concat(a)}getElementHitThreshold(){return _b/this.state.zoom.value}hitElement(t,r,n,i=!0){if(i&&this.state.selectedElementIds[n.id]&&cd([n],this.state)){let l=Hx(n,this.scene.getNonDeletedElementsMap(),fe(n)?0:this.getElementHitThreshold());if(Zc(M(t,r),l))return!0}return O0(t,r,_x(n,this.scene.getNonDeletedElementsMap()))?!0:ji({x:t,y:r,element:n,shape:Or(n,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:ae(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 Rr(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,c,m,d]=Ke(n[l],this.scene.getNonDeletedElementsMap());if(ke(n[l])&&ji({x:t,y:r,element:n[l],shape:Or(n[l],this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()})){a=n[l];break}else if(s<t&&t<m&&c<r&&r<d){a=n[l];break}}return Rr(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=j.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;ji({x:r,y:n,element:a,shape:Or(a,this.scene.getNonDeletedElementsMap())})?(l=j.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=j.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(oe(a)?l===0||l===a.points.length-1:l>=0)||s?Le(this.interactiveCanvas,Se.POINTER):this.hitElement(r,n,a)&&(!oe(a)||!(a.startBinding||a.endBinding))&&Le(this.interactiveCanvas,Se.MOVE)):this.hitElement(r,n,a)&&(!oe(a)||!(a.startBinding||a.endBinding))&&Le(this.interactiveCanvas,Se.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),j.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else Le(this.interactiveCanvas,Se.AUTO)}updateGestureOnPointerDown(t){Ae.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),Ae.pointers.size===2&&(Ae.lastCenter=s1(Ae.pointers),Ae.initialScale=this.state.zoom.value,Ae.initialDistance=c1(Array.from(Ae.pointers.values())))}initialPointerDownState(t){let r=je(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=ve(n),c=n.findIndex(oe)===0;return{origin:r,withCmdOrCtrl:t[T.CTRL_OR_CMD],originInGrid:an(ht(r.x,r.y,t[T.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:u1(ib,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((m,d)=>(m.set(d.id,xo(d)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;nb=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=sp(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=ot(()=>{Xs=null,nb=!1,To(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener("pointermove",n),window.removeEventListener("pointerup",i),n.flush()});return Xs=i,window.addEventListener("pointermove",n),window.addEventListener("pointerup",i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=this.getElementHitThreshold(),[i,a,l,s]=ve(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:$i(t)?oo.ADAPTIVE_RADIUS:oo.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){Zr({event:t,app:this,selectedElements:r})&&(n||!zo.getReferenceSnapPoints())&&zo.setReferenceSnapPoints(yw(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){Zr({event:t,app:this,selectedElements:r})&&(n||!zo.getVisibleGaps())&&zo.setVisibleGaps(Ew(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return ot(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return ot(r=>{r.key===T.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return sp(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=je(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=ht(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),g=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(g<0){let x=j.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());g=x?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=j.moveFixedSegment(this.state.selectedLinearElement,g,p,u,this.scene.getNonDeletedElementsMap());Fi(()=>{this.state.selectedLinearElement&&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=an(DE(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(ao(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=ht(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&qn(M(n.x,n.y),M(t.origin.x,t.origin.y))<Zn)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 c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.editingLinearElement||this.state.selectedLinearElement;if(j.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,c)){let g=j.addMidpoint(this.state.selectedLinearElement,n,this,!r[T.CTRL_OR_CMD],c);if(!g)return;Fi(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:g.pointerDownState,selectedPointsIndices:g.selectedPointsIndices,segmentMidPointHoveredCoords:null}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:g.pointerDownState,selectedPointsIndices:g.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=j.handlePointDragging(r,this,n.x,n.y,(g,b)=>{this.maybeSuggestBindingsForLinearElementAtCoords(g,b)},p,this.scene);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState({editingLinearElement:this.state.editingLinearElement?u:null,selectedLinearElement:u});return}}let m=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),d=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!d&&this.state.activeTool.type!=="lasso"){let p=this.scene.getSelectedElements(this.state);if(p.every(x=>x.locked))return;let u=p.find(x=>ae(x)),g=this.getTopLayerFrameAtSceneCoords(n),b=g&&!u?g:null;if(this.state.frameToHighlight!==b&&Fi(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:n.x-t.origin.x,y:n.y-t.origin.y},E=[...t.originalElements.values()],w=r.shiftKey;if(w){let C=Math.abs(x.x),S=Math.abs(x.y),_=w&&C<S,L=w&&C>S;_&&(x.x=0),L&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&fe(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,_=Dr(C)&&this.imageCache.get(C.fileId)?.image;if(_&&!(_ instanceof Promise)){let L=l0(su(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[N,P,z,W,U,q]=Ke(C,c),H=xc(de(M(N,P),M(U,q),C.angle)),V=xc(de(M(z,P),M(U,q),C.angle)),K=xc(de(M(N,W),M(U,q),C.angle)),Q=mu(du(V,H)),X=mu(du(K,H)),ie=su(cu(L,Q),cu(L,X)),he={...S,x:Ct(S.x-ie[0]*Math.sign(C.scale[0]),0,_.naturalWidth-S.width),y:Ct(S.y-ie[1]*Math.sign(C.scale[1]),0,_.naturalHeight-S.height)};B(C,{crop:he});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=vw(E,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||_E(t,p,x,this.scene,y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!oe(p[0]))&&this.setState({suggestedBindings:Dc(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,_=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!_.find(U=>U.id===S.id)&&_.push(S);let L=new Map(_.map(U=>[U.id,U])),{newElements:N,elementsWithClones:P}=bn({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:L,overrides:U=>{let q=t.originalElements.get(U.id);return q?{x:q.x,y:q.y,seed:q.seed}:{}},reverseOrder:!0});N.forEach(U=>{t.originalElements.set(U.id,U)});let z=this.props.onDuplicate?.(P,C),W=Gt(z||P,te(N)).map(U=>L.has(U.id)?re(U,{seed:_r()}):U);this.scene.replaceAllElements(W),this.maybeCacheVisibleGaps(r,_,!0),this.maybeCacheReferenceSnapPoints(r,_,!0)}return}}if(this.state.selectionElement)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})):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,g=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===g&&x[1]===b)){let w=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];B(p,{points:[...u,M(g,b)],pressures:w},!1),this.setState({newElement:p})}}else if(le(p)){t.drag.hasOccurred=!0;let u=p.points,g=l-p.x,b=s-p.y;bc(r)&&u.length===2&&({width:g,height:b}=Cu(p.x,p.y,n.x,n.y)),u.length===1?B(p,{points:[...u,M(g,b)]},!1):(u.length===2||u.length>1&&oe(p))&&B(p,{points:[...u.slice(0,-1),M(g,b)]},!1,{isDragging:!0}),this.setState({newElement:p}),Pr(p,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(p,[n],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.editingLinearElement)j.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&ze(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>lt({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let g=this.state.selectionElement?xx(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...g.reduce((E,w)=>(E[w.id]=!0,E),{})};return t.hit.element&&(g.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...lt({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:g.length===1&&le(g[0])?new j(g[0]):null,showHyperlinkPopup:g.length===1&&(g[0].link||Ht(g[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/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/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return ot(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:n,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:c,isRotating:m,isCropping:d}=this.state;this.setState(x=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:Zi(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,zo.setReferenceSnapPoints(null),zo.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1}),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r);let p=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let x=p.get(t.hit.element.id);ni(x)&&x.boundElements?.filter(E=>E.type==="arrow").map(E=>p.get(E.id)).filter(E=>oe(E)).forEach(E=>{E&&B(E,{},!0)})}if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(co);else{let x=j.handlePointerUp(r,this.state.editingLinearElement,this.state,this.scene);x!==this.state.editingLinearElement&&this.setState({editingLinearElement:x,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=j.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&B(x,{},!0)}if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let x=j.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene),{startBindingElement:E,endBindingElement:w}=x,y=this.scene.getElement(x.elementId);Pr(y)&&_c(y,E,w,p,this.scene),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...x,selectedPointsIndices:null},suggestedBindings:[]})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",t.eventListeners.onMove),window.removeEventListener("pointerup",t.eventListeners.onUp),window.removeEventListener("keydown",t.eventListeners.onKeyDown),window.removeEventListener("keyup",t.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),n?.type==="freedraw"){let x=je(r,this.state),E=n.points,w=x.x-n.x,y=x.y-n.y;w===E[0][0]&&y===E[0][1]&&(y+=1e-4,w+=1e-4);let v=n.simulatePressure?[]:[...n.pressures,r.pressure];B(n,{points:[...E,M(w,y)],pressures:v,lastCommittedPoint:M(w,y)}),this.actionManager.executeAction(co);return}if(fe(n)){let x=n;try{this.initializeImageDimensions(x),this.setState({selectedElementIds:Me({[x.id]:!0},this.state)},()=>{this.actionManager.executeAction(co)})}catch(E){console.error(E),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(w=>w.id!==x.id)),this.actionManager.executeAction(co)}return}if(le(n)){n.points.length>1&&this.store.shouldCaptureIncrement();let x=je(r,this.state);!t.drag.hasOccurred&&n&&!l?(B(n,{points:[...n.points,M(x.x-n.x,x.y-n.y)]}),this.setState({multiElement:n,newElement:n})):t.drag.hasOccurred&&!l&&(li(this.state)&&Pr(n,!1)&&Ml(n,this.state,x,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(E=>({newElement:null})):(wo(this.interactiveCanvas),this.setState(E=>({newElement:null,activeTool:Ue(this.state,{type:"selection"}),selectedElementIds:Me({...E.selectedElementIds,[n.id]:!0},E),selectedLinearElement:new j(n)}))),this.scene.triggerUpdate());return}if(Z(n)){let x=qi(Je({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<x&&B(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&ci(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==n.id),appState:{newElement:null},captureUpdate:A.NEVER});return}if(ae(n)){let x=hx(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(ra(this.scene.getElementsMapIncludingDeleted(),x,n,this.state))}if(n&&(B(n,sx(n)),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=je(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let E=this.scene.getElement(this.state.selectedLinearElement.elementId);if(E?.frameId){let w=di(E,p);w&&E&&(Nc(E,w,this.scene.getNonDeletedElementsMap())||(B(E,{groupIds:[]}),Oc([E],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let E=this.getTopLayerFrameAtSceneCoords(x),w=this.scene.getSelectedElements(this.state),y=this.scene.getElementsMapIncludingDeleted(),v=C=>{if(C.length>0){for(let S of C){let _=S.groupIds.indexOf(this.state.editingGroupId);B(S,{groupIds:S.groupIds.slice(0,_)},!1)}y.forEach(S=>{S.groupIds.length&&Fe(y,S.groupIds[S.groupIds.length-1]).length<2&&B(S,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(E&&!this.state.selectedElementIds[E.id]){let C=w.filter(S=>S.frameId!==E.id&&Lu(S,y,this.state));this.state.editingGroupId&&v(C),y=ra(y,C,E,this.state)}else if(!E&&this.state.editingGroupId){let C=w.filter(S=>S.frameId&&!Lu(S,y,this.state));v(C)}y=sr(y,this.state,this),this.scene.replaceAllElements(y)}}if(i&&this.store.shouldCaptureIncrement(),i&&ci(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),captureUpdate:A.NEVER}),t.resize.isResizing){let x=sr(this.scene.getElementsIncludingDeleted(),this.state,this),E=this.scene.getSelectedElements(this.state).filter(w=>ae(w));for(let w of E)x=Bc(x,oa(this.scene.getElementsIncludingDeleted(),w,this.state,p),w,this);this.scene.replaceAllElements(x)}let u=t.hit.element;this.state.selectedLinearElement?.elementId!==u?.id&&le(u)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new j(u)}),(!a||a&&(!u&&!d||u&&u.id!==a))&&this.finishImageCropping();let g=this.lastPointerDownEvent,b=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(ao(this.state)&&g&&b){if(this.eraserTrail.endPath(),qn(M(g.clientX,g.clientY),M(b.clientX,b.clientY))===0){let E=je({clientX:b.clientX,clientY:b.clientY},this.state);this.getElementsAtPosition(E.x,E.y).forEach(y=>this.elementsPendingErasure.add(y.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(u&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!t.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[u.id]?Gc(this.state,u)?this.setState(x=>{let E={...x.selectedElementIds};for(let w of u.groupIds.flatMap(y=>Fe(this.scene.getNonDeletedElements(),y)))delete E[w.id];return{selectedGroupIds:{...x.selectedElementIds,...u.groupIds.map(w=>({[w]:!1})).reduce((w,y)=>({...w,...y}),{})},selectedElementIds:Me(E,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let E={...x.selectedElementIds};delete E[u.id];let w=J(this.scene.getNonDeletedElements(),{selectedElementIds:E});return{...lt({editingGroupId:x.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:w.length===1&&le(w[0])?new j(w[0]):x.selectedLinearElement}}):u.frameId&&this.state.selectedElementIds[u.frameId]?this.setState(x=>{let E={...x.selectedElementIds,[u.id]:!0};return delete E[u.frameId],(this.scene.getElement(u.frameId)?.groupIds??[]).flatMap(w=>Fe(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete E[w.id]}),{...lt({editingGroupId:x.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:u.link||Ht(u)?"info":!1}}):this.setState(x=>({selectedElementIds:Me({...x.selectedElementIds,[u.id]:!0},x)})):this.setState(x=>({...lt({editingGroupId:x.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:le(u)&&x.selectedLinearElement?.elementId!==u.id?new j(u):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(u&&oe(u))&&!t.drag.hasOccurred&&!this.state.isResizing&&(u&&N0({x:t.origin.x,y:t.origin.y,element:u,shape:Or(u,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:ae(u)?this.frameNameBoundsCache.get(u):null},p)||!u&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),Le(this.interactiveCanvas,Se.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(x=>({selectedElementIds:Me({...x.selectedElementIds,[n.id]:!0},x),showHyperlinkPopup:Ht(n)&&!n.link?"editor":x.showHyperlinkPopup})),(s.type!=="selection"||ze(this.scene.getNonDeletedElements(),this.state)||!Qe(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.shouldCaptureIncrement(),t.drag.hasOccurred||c||m||d){let x=this.scene.getSelectedElements(this.state).filter(le);si(x,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,li(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(wo(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Ue(this.state,{type:"selection"})})):this.setState({newElement:null,suggestedBindings:[]}),u&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&Ae.pointers.size<=1&&Xi(u)&&this.isIframeLikeElementCenter(u,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(u)})}clearSelection(t){this.setState(r=>({selectedElementIds:Me({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&na(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Me({},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=Ac(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<Ab){let{x:d,y:p}=Ft({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=ga.find(r=>r.code===this.props.langCode)||pr;await fd(t),this.setAppState({})}},TA=()=>{(mt()||Ge())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(Nr(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};TA();var nT=lb;import{useEffect as IA,useState as SA}from"react";import{jsx as kA}from"react/jsx-runtime";var iT=e=>{let[o,t]=SA(!0);return IA(()=>{let r=async()=>{await fd(n),t(!1)},n=ga.find(i=>i.code===e.langCode)||pr;r()},[e.langCode]),o?kA(mp,{theme:e.theme}):e.children};import MA from"clsx";import{jsx as aT}from"react/jsx-runtime";var lT=({children:e})=>{let{FooterCenterTunnel:o}=Ze(),t=Re();return aT(o.In,{children:aT("div",{className:MA("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},LA=lT;lT.displayName="FooterCenter";import AA from"clsx";import{jsx as DA,jsxs as PA}from"react/jsx-runtime";var sT=({isCollaborating:e,onSelect:o,...t})=>{let r=Re(),n=r.width<830;return PA(Co,{...t,className:AA("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:f("labels.liveCollaboration"),children:[n?Oh:f("labels.share"),r.collaborators.size>0&&DA("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},_A=sT;sT.displayName="LiveCollaborationTrigger";import{jsx as Kn,jsxs as dT}from"react/jsx-runtime";var RA=()=>Kn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Kn("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),NA=()=>dT("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Kn("path",{d:"M429.27 96.74c2.47-1.39 4.78-3.02 6.83-4.95 1.43-1.35 2.73-2.86 3.81-4.51-.66.9-1.4 1.77-2.23 2.59-2.91 2.84-5.72 5.09-8.42 6.87h.01ZM343.6 69.36c.33 3.13.58 6.27.79 9.4.09 1.37.18 2.75.25 4.12-.12-4.46-.27-8.93-.5-13.39-.11-2.08-.24-4.16-.4-6.24-.06 1.79-.11 3.85-.13 6.11h-.01ZM378.47 98.34c.01-.37.07-1.13.01-6.51-.11 1.9-.22 3.81-.31 5.71-.07 1.42-.22 2.91-.16 4.35.39.03.78.07 1.17.1-.92-.85-.76-2.01-.72-3.66l.01.01ZM344.09 86.12c-.09-2.41-.22-4.83-.39-7.24v12.21c.15-.05.32-.09.47-.14.05-1.61-.03-3.23-.09-4.83h.01ZM440.69 66.79c-.22-.34-.45-.67-.69-.99-3.71-4.87-9.91-7.14-15.65-8.55-1.05-.26-2.12-.49-3.18-.71 2.29.59 4.48 1.26 6.64 2.02 7.19 2.54 10.57 5.41 12.88 8.23ZM305.09 72.46l1.2 3.6c.84 2.53 1.67 5.06 2.46 7.61.24.78.5 1.57.73 2.36.22-.04.44-.08.67-.12a776.9 776.9 0 0 1-5.01-13.57c-.02.04-.03.09-.05.13v-.01ZM345.49 90.25v.31c1.48-.42 3.05-.83 4.66-1.2-1.56.25-3.12.52-4.66.89ZM371.02 90.22c0-.57-.04-1.14-.11-1.71-.06-.02-.12-.04-.19-.05-.21-.05-.43-.08-.65-.11.42.16.74.88.95 1.87ZM398.93 54.23c-.13 0-.27-.01-.4-.02l.03.4c.11-.15.23-.27.37-.38ZM401.57 62.28v-.15c-1.22-.24-2.86-.61-3.23-1.25-.09-.15-.18-.51-.27-.98-.09.37-.2.73-.33 1.09 1.24.56 2.52.98 3.83 1.29ZM421.73 88.68c-2.97 1.65-6.28 3.12-9.69 3.68v.18c4.72-.14 11.63-3.85 16.33-8.38-2.04 1.75-4.33 3.24-6.63 4.53l-.01-.01ZM411.28 80.92c-.05-1.2-.09-2.4-.15-3.6-.21 5.66-.46 11.38-.47 14.51.24-.02.48-.04.71-.07.15-3.61.05-7.23-.09-10.83v-.01Z",transform:"translate(-144.023 -51.76)"}),Kn("path",{d:"M425.38 67.41c-3.5-1.45-7.19-2.57-14.06-3.62.09 1.97.06 4.88-.03 8.12.03.04.06.09.06.15.19 1.36.28 2.73.37 4.1.25 3.77.39 7.55.41 11.33 0 1.38-.01 2.76-.07 4.13 1.4-.25 2.78-.65 4.12-1.15 4.07-1.5 7.94-3.78 11.28-6.54 2.33-1.92 5.13-4.49 5.88-7.58.63-3.53-2.45-6.68-7.97-8.96l.01.02ZM411.35 92.53v-.06l-.34.03c.11.01.22.03.34.03ZM314.26 64.06c-.23-.59-.47-1.17-.7-1.75.57 1.62 1.11 3.25 1.6 4.9l.15.54 2.35 6.05c.32.82.66 1.64.98 2.46-1.38-4.1-2.83-8.17-4.39-12.2h.01ZM156.82 103.07c-.18.13-.38.23-.58.33 1.32-.03 2.66-.2 3.93-.34.86-.09 1.72-.22 2.58-.33-2.12.1-4.12.17-5.94.34h.01ZM210.14 68.88s.03.04.05.07c.18-.31.39-.64.58-.96-.21.3-.42.6-.64.89h.01ZM201.65 82.8c-.5.77-1.02 1.56-1.49 2.37 1.11-1.55 2.21-3.1 3.2-4.59-.23.23-.49.51-.75.79-.32.47-.65.95-.96 1.43ZM194.03 98.66c-.33-.4-.65-.84-1.05-1.17-.24-.2-.07-.49.17-.56-.23-.26-.42-.5-.63-.75 1.51-2.55 3.93-5.87 6.4-9.28-.17-.08-.29-.28-.2-.49.04-.09.09-.17.13-.26-1.21 1.78-2.42 3.55-3.61 5.33-.87 1.31-1.74 2.64-2.54 4-.29.5-.63 1.04-.87 1.61.81.65 1.63 1.27 2.47 1.88-.09-.11-.18-.21-.27-.32v.01ZM307.79 82.93c-1-3.17-2.05-6.32-3.1-9.48-1.62 4.08-3.69 9.17-6.16 15.19 3.32-1.04 6.77-1.87 10.27-2.5-.32-1.08-.67-2.15-1.01-3.21ZM149.5 80.7c.05-1.71.04-3.43 0-5.14-.1 2.26-.16 4.51-.22 6.77-.02.73-.03 1.46-.04 2.19.14-1.27.2-2.55.24-3.82h.02ZM228.98 98.3c.39 1.25.91 3.03.94 3.91.06-.03.12-.07.17-.1.08-1.29-.55-2.65-1.11-3.81ZM307.72 53.36c.81.5 1.53 1.04 2.07 1.49-.38-.8-.78-1.58-1.21-2.35-.17.03-.34.06-.51.11-.43.12-.86.26-1.29.41.35-.01.53.1.94.34ZM283.69 96.14c3.91-7.25 6.89-13.35 8.88-18.15l1.1-2.66c-1.27 2.64-2.56 5.27-3.83 7.9-1.53 3.15-3.06 6.31-4.58 9.47-.87 1.81-1.76 3.62-2.54 5.47.04.02.07.04.11.07.05.05.1.09.15.14.05-.73.27-1.48.71-2.24ZM289.92 103.23s-.04.01-.05.03c0-.02.04-.03.05-.04.05-.05.11-.1.16-.15l.21-.21c-.55 0-1.5-.27-2.55-.72.4.26.8.51 1.22.74.24.13.48.26.73.37.05.02.1.03.14.05a.27.27 0 0 1 .08-.07h.01ZM269.23 68.49c-.39-.19-.82-.48-1.33-.87-3.06-1.56-6.31-2.78-9.36-2.35-3.5.49-5.7 1.11-7.74 2.44 5.71-2.6 12.82-2.07 18.44.79l-.01-.01ZM177.87 53.69l1.06.03c-.96-.22-2-.25-2.89-.3-4.95-.26-9.99.33-14.86 1.19-2.44.43-4.88.95-7.28 1.59 9.09-1.76 15.69-2.77 23.97-2.51ZM219.85 55.51c-.18.12-.36.27-.56.45-.45.53-.86 1.11-1.26 1.66-1.91 2.61-3.71 5.31-5.57 7.95l-.12.18 8.05-10.11c-.18-.05-.36-.1-.55-.13h.01ZM510.71 54.1c.12-.15.29-.3.53-.45.69-.4 3.72-.63 5.87-.74-.36-.02-.73-.04-1.09-.05-1.84-.03-3.67.09-5.49.35.05.3.12.59.18.88v.01ZM510.76 86.02c1.37-3.07 2.49-6.27 3.57-9.46.55-1.64 1.12-3.3 1.6-4.97-1.59 4.01-3.67 9.14-6.2 15.3.24-.08.5-.14.74-.22.1-.22.19-.44.29-.65ZM566.95 75.76c.11-.02.23.03.31.11-.05-.13-.09-.26-.14-.39-.05.09-.11.18-.17.28ZM511.33 86.41c3.08-.89 6.24-1.62 9.46-2.14-1.51-3.98-2.98-7.96-4.39-11.87-.05.15-.09.31-.14.46-1.02 3.32-2.15 6.61-3.39 9.85-.48 1.25-.98 2.49-1.53 3.7h-.01ZM578.24 74.45c.11-.44.23-.87.35-1.31-.31.7-.64 1.39-.97 2.08.09.21.19.4.28.61.12-.46.23-.92.35-1.38h-.01ZM520.62 53.11c-.09 0-.18-.01-.28-.02.38.34.29 1.08.93 2.53l6.65 17.15c2.2 5.68 4.69 11.36 7.41 16.87l1.06 2.17c-2.95-7.05-5.92-14.08-8.87-21.13-1.58-3.79-3.16-7.59-4.7-11.4-.78-1.92-1.73-3.89-2.25-5.91-.03-.1 0-.19.04-.26h.01ZM578.78 77.87c1.45-5.77 3.07-10.43 3.58-13.36.05-.34.16-.88.31-1.55-.67 1.79-1.37 3.56-2.08 5.33-.12.43-.23.86-.35 1.29-.65 2.43-1.29 4.86-1.9 7.3.14.33.29.65.43 1l.01-.01ZM545.3 94.66c.02-.44.03-.83.05-1.12.02-1.01.05-2.02.11-3.02.03-6.66-.46-14.33-1.46-22.8-.13-.42-.27-1.24-.56-2.89 0-.02 0-.04-.01-.06.62 6.61.95 13.25 1.32 19.87.17 3.08.33 6.16.52 9.23.02.25.03.52.04.78l-.01.01ZM580.77 102.81c.13.2.27.38.37.49.27-.11.53-.22.8-.32-.43.09-.82.05-1.17-.16v-.01ZM530.48 104.07h.33c-.36-.13-.71-.32-1.04-.56.14.24.3.47.45.7.06-.08.14-.13.26-.13v-.01ZM542.63 58.82c.06.23.11.47.15.71.14-.33.36-.62.7-.86-.28.05-.57.11-.85.15ZM583.81 57.87c.15-.7.29-1.41.42-2.11-.14.45-.28.9-.42 1.34-.46 1.44-.89 2.89-1.31 4.34.44-1.19.88-2.37 1.31-3.57ZM523.62 91.48c-4.66 1.17-9.05 2.89-14.02 5.27 4.65-1.84 9.48-3.29 14.28-4.63-.09-.22-.17-.41-.26-.64ZM460.64 78.3c-.04-2.9-.11-5.81-.28-8.71-.1-1.68-.17-3.43-.5-5.09-.07.02-.14.03-.2.05.3 6.54.45 12.17.51 17.12.17-.07.34-.14.51-.2 0-1.06-.01-2.11-.03-3.17h-.01ZM470.63 63.24c-3.38-.26-6.81.32-10.1 1.1.41 2.01.47 4.14.57 6.18.18 3.55.25 7.11.27 10.67 3.31-1.38 6.5-3.12 9.3-5.35 1.96-1.56 3.86-3.41 5.02-5.66.73-1.41 1.19-3.22.26-4.65-1.09-1.7-3.46-2.14-5.32-2.29ZM460.29 63.68c1-.24 2.01-.46 3.04-.65-1.15.16-2.37.38-3.71.69v.13c.07-.02.15-.04.22-.05.11-.13.3-.18.45-.11v-.01ZM457.24 100.96c.43-.03.86-.07 1.29-.11.14-.49.27-.99.38-1.49-.44.7-1 1.23-1.67 1.6ZM482.88 104.98c-.18.23-.36.38-.55.47.14.09.27.19.4.28a70.76 70.76 0 0 0 4.37-4.63c.76-.89 1.52-1.81 2.19-2.77-.3-.27-.61-.53-.92-.79-.07 1.94-4.62 6.32-5.49 7.45v-.01Z",transform:"translate(-144.023 -51.76)"}),Kn("path",{d:"M474.36 63.31c-.4-.16-.84-.27-1.29-.37 1.56.42 3.08 1.22 3.76 2.74.62 1.4.32 2.95-.28 4.32.7-1.22.94-2.34.74-3.47-.24-1.33-1.19-2.54-2.93-3.21v-.01ZM477.34 89.18c-1.2-.81-2.4-1.62-3.6-2.42-.14.1-.26.19-.4.29 1.4.67 2.73 1.39 4 2.13ZM465.88 93.85c.37.25.74.5 1.1.75.46.32.92.65 1.38.97-1.57-1.2-2.01-1.61-2.49-1.72h.01ZM574.92 90.06c-2.28-5.21-4.93-11.13-5.67-12.26-.1-.15-1.57-3.01-1.63-3.08 0 0-.01.02-.02.02.4 1.37 1.09 2.69 1.65 3.99 2.14 4.95 4.36 9.86 6.67 14.73.6 1.26 1.21 2.52 1.83 3.78-.75-2.01-1.64-4.45-2.83-7.18ZM448.73 65.29c.1.2.22.38.34.57.22-.02.43-.06.65-.08v-.08c-.14-.05-.25 0-.99-.41ZM460.16 94.81c-.02.31-.06.59-.1.89-.03 1.71-.33 3.43-.79 5.07.15-.02.3-.03.45-.05.01-.04.02-.08.03-.11.09-.34.15-.69.2-1.03.17-1.07.25-2.16.33-3.24.05-.69.08-1.39.12-2.08-.27.1-.27.26-.24.57v-.02Z",transform:"translate(-144.023 -51.76)"}),Kn("path",{d:"m328.67 98.12-3.22-6.58c-1.29-2.63-2.53-5.29-3.72-7.97-.25-.85-.52-1.69-.79-2.53-.81-2.57-1.67-5.12-2.55-7.67-1.92-5.53-3.9-11.08-6.32-16.41-.72-1.58-1.46-3.44-2.63-4.79-.03-.17-.16-.29-.34-.36a.282.282 0 0 0-.23-.04c-.06-.01-.12 0-.18.01-.74.06-1.5.38-2.19.61-2.22.77-4.4 1.64-6.63 2.38-.03-.08-.06-.16-.09-.25-.15-.42-.82-.24-.67.19.03.09.07.19.1.28l-.18.06c-.36.11-.28.6 0 .68.18 1.18.63 2.36.98 3.49.03.09.06.17.08.26-.08.23-.17.46-.24.64-.37.98-.79 1.94-1.21 2.9-1.27 2.89-2.62 5.75-3.98 8.6-3.18 6.67-6.44 13.31-9.64 19.97-1.08 2.25-2.2 4.5-3.15 6.81-.13.32.24.5.5.37 1.34 1.33 2.84 2.5 4.4 3.57.65.44 1.31.87 2.01 1.24.4.22.86.48 1.33.5.24.01.35-.19.33-.37.11-.1.21-.21.28-.28.41-.41.81-.84 1.2-1.26.85-.92 1.69-1.87 2.5-2.84 6.31-2.34 12.6-4.31 18.71-5.84 2.14 5.3 3.43 8.43 3.97 9.58.55 1.05 1.15 1.88 1.82 2.52 1.32.56 6.96-.03 9.23-1.96.87-1.28 1.19-2.67.93-4.15-.09-.5-.22-.95-.4-1.33l-.01-.03Zm-20.09-45.61c.43.77.83 1.56 1.21 2.35-.54-.45-1.27-.99-2.07-1.49-.42-.24-.6-.35-.94-.34.43-.15.85-.29 1.29-.41.17-.05.34-.08.51-.11Zm-25.86 45.66c.78-1.85 1.67-3.66 2.54-5.47 1.51-3.16 3.05-6.31 4.58-9.47 1.28-2.63 2.56-5.26 3.83-7.9l-1.1 2.66c-1.99 4.79-4.97 10.9-8.88 18.15-.43.76-.66 1.51-.71 2.24-.05-.05-.1-.09-.15-.14a.259.259 0 0 0-.11-.07Zm6.24 4.71c-.42-.23-.82-.48-1.22-.74 1.05.45 2 .72 2.55.72l-.21.21c-.05.05-.11.1-.16.15-.01.01-.04.03-.05.04 0-.02.03-.02.05-.03a.27.27 0 0 0-.08.07c-.05-.02-.1-.03-.14-.05-.25-.1-.49-.24-.73-.37h-.01Zm15.73-29.43c1.05 3.15 2.1 6.31 3.1 9.48.34 1.06.69 2.13 1.01 3.21-3.5.63-6.95 1.46-10.27 2.5 2.48-6.03 4.54-11.11 6.16-15.19Zm4.79 12.57c-.23-.79-.49-1.58-.73-2.36-.79-2.54-1.63-5.08-2.46-7.61l-1.2-3.6c.02-.04.04-.09.05-.13 1.6 4.45 3.28 9 5.01 13.57l-.67.12v.01Zm5.83-18.27-.15-.54c-.49-1.64-1.03-3.28-1.6-4.9.23.58.47 1.17.7 1.75 1.56 4.03 3.01 8.1 4.39 12.2-.33-.82-.67-1.64-.98-2.46l-2.35-6.05h-.01ZM390.43 79.37c-.13-10.43-.22-17.5-.24-19.97-.24-1.6.21-2.88-.65-3.65-.14-.13-.32-.23-.52-.32h.03c.45 0 .45-.69 0-.7-1.75-.03-3.5-.04-5.25-.14-1.38-.08-2.76-.21-4.15-.31-.07 0-.12.01-.17.04-.21-.07-.47.03-.45.31l.03.45c-.11.14-.19.3-.22.5-.21 1.26-.32 13.67-.36 23.59-.32 5.79-.67 11.57-.97 17.36-.09 1.73-.29 3.54-.21 5.3-.39.02-.38.64.04.69v.12c.05.44.74.45.7 0v-.06c1.1.09 2.2.21 3.3.3 1.14.19 2.44.2 3.29.17 1.73-.05 2.92-.05 3.8-.37.45-.05.9-.11 1.35-.17.44-.06.25-.73-.19-.67h-.01c.24-.32.45-.72.62-1.25.66-1.84.41-6.36.34-11.33l-.13-9.9.02.01Zm-12.26 18.17c.09-1.91.2-3.81.31-5.71.06 5.38 0 6.14-.01 6.51-.05 1.65-.21 2.81.72 3.66-.39-.04-.78-.07-1.17-.1-.06-1.44.09-2.93.16-4.35l-.01-.01ZM588.97 53.85c-2.06-.25-3.17-.51-3.76-.6a.3.3 0 0 1 .04-.08c.22-.39-.39-.75-.6-.35-.56 1.02-.9 2.19-1.26 3.29-.61 1.88-1.17 3.78-1.72 5.68-.63 2.19-1.24 4.39-1.83 6.59-.81 2.03-1.67 4.05-2.61 6.03-1.7-3.64-3.11-6.04-4.03-7.57-2.26-3.74-2.85-5.48-3.57-6.08l.31-.09c.43-.12.25-.8-.19-.67-1.06.3-2.12.6-3.17.95-.93.32-1.85.69-2.76 1.07-.13.05-.19.16-.22.27-.04.02-.08.05-.11.07-.04-.06-.07-.12-.11-.18a.354.354 0 0 0-.48-.12c-.16.09-.22.32-.13.48l.33.54c0 .09.02.18.06.28.51 1.16.78 1.38.72 1.47-2.42 3.44-5.41 7.86-6.2 9.1-1.27 1.97-2.01 3.14-2.45 3.84l-.91-6.56-.43-4.1c-.19-1.85-.37-3.23-.53-4.13-.19-1.1-.3-2.15-.45-3.16-.2-1.36-.29-2.06-.47-2.42h.04c.45.02.45-.68 0-.7-3.43-.16-6.81.94-10.17 1.48-.24-.22-.73-.04-.58.32.24.59.33 1.25.43 1.87.17 1.06.29 2.13.4 3.2.32 3.09.53 6.2.74 9.3.44 6.75.77 13.51 1.17 20.26.11 1.95.13 3.96.46 5.89.05.3.37.31.55.14.74 1.71 2.87 1.27 6.13 1.27 1.34 0 2.39.04 2.99-.11.02.32.48.53.63.18 3.61-8.26 7.41-16.46 12.05-24.2.03-.05.04-.1.05-.15.3.73.64 1.45.94 2.16.97 2.26 1.97 4.52 2.98 6.76 2.26 5.03 4.54 10.07 7.09 14.96.47.9.94 1.79 1.47 2.65.2.32.4.67.66.96-.18.25 0 .68.34.54.91-.38 1.82-.75 2.76-1.07 1.04-.35 2.11-.65 3.17-.95.39-.11.28-.66-.07-.68.62-.4.95-.96.87-1.91-.3-3.34.72-7.47.86-8.52l2.14-11.43c1.75-10.74 3.13-17.51 3.23-20.86.02-.49.08-2.84.13-3.24.17-1.25.48-1-4.96-1.65l.03-.02Zm-46.19 5.67c-.04-.24-.09-.48-.15-.71l.85-.15c-.34.24-.56.53-.7.86Zm1.95 25.12c-.36-6.63-.7-13.26-1.32-19.87 0 .02 0 .04.01.06.29 1.65.44 2.47.56 2.89 1 8.46 1.5 16.14 1.46 22.8-.06.99-.1 2-.11 3.02-.01.29-.03.68-.05 1.12-.01-.26-.03-.53-.04-.78-.19-3.08-.35-6.16-.52-9.23l.01-.01Zm36.4 18.66c-.11-.11-.24-.29-.37-.49.35.21.74.26 1.17.16-.27.11-.53.22-.8.32v.01Zm-.89-33.72c.12-.43.23-.86.35-1.29.71-1.77 1.41-3.55 2.08-5.33-.15.68-.26 1.22-.31 1.55-.5 2.94-2.13 7.59-3.58 13.36-.15-.35-.29-.66-.43-1 .61-2.44 1.25-4.87 1.9-7.3l-.01.01Zm3.56-12.48c.14-.44.28-.89.42-1.34-.13.7-.27 1.41-.42 2.11-.43 1.19-.86 2.38-1.31 3.57.42-1.45.85-2.9 1.31-4.34Zm-5.22 16.05c-.11.44-.23.87-.35 1.31-.12.46-.23.92-.35 1.38-.1-.22-.19-.4-.28-.61.34-.69.66-1.38.97-2.08h.01Zm-11.64 2.62c.06-.1.12-.19.17-.28.05.13.09.26.14.39a.398.398 0 0 0-.31-.11Zm2.3 2.98c-.56-1.3-1.25-2.63-1.65-3.99 0 0 .01-.02.02-.02.06.08 1.52 2.93 1.63 3.08.73 1.13 3.38 7.04 5.67 12.26 1.2 2.73 2.08 5.17 2.83 7.18-.62-1.25-1.23-2.51-1.83-3.78-2.31-4.87-4.53-9.78-6.67-14.73ZM275.92 87.03c-1.06-2.18-1.13-3.45-2.44-2.93-1.52.57-2.94 1.3-4.5 2.1-1.4.72-2.68 1.44-3.92 2.12.01-.25-.24-.5-.51-.34-4.8 2.93-12.41 4.7-17.28 1.31-1.98-1.77-3.32-4.15-3.97-5.78-.29-.95-.49-1.94-.63-2.93-.14-3.34 1.58-6.53 3.9-9.12.8-.79 1.68-1.51 2.66-2.12 3.7-2.3 8.22-3.07 12.51-2.51 2.71.35 5.32 1.24 7.71 2.55.39.22.75-.39.35-.6-.18-.1-.37-.18-.55-.27.56.27 1.03.33 1.51.19l-.48.39c-.15.11-.23.3-.13.48.09.15.33.24.48.13 1.3-.97 2.46-2.09 3.45-3.37.37-.29.64-.6.65-.97v-.02c.08-.33-.03-.7-.21-1.08-.31-.87-.98-2.01-2.19-3.26-2.43-2.52-3.79-3.45-5.68-4.26-1.14-.49-3.12-1.06-4.42-1.23-3.28-.42-10.64-1.21-18.18 4.11-7.74 5.46-11.94 12.3-12.23 20.61-.08 2.06.04 3.98.34 5.71.74 4.18 2.57 8 5.44 11.34 4.26 4.99 9.76 7.52 16.34 7.52 4.85 0 9.69-1.77 14.89-4.62.23-.12.45-.23.68-.35 2.19-1.1 4.37-2.23 6.46-3.5.49-.3 1.03-.61 1.5-.98 1.47-.87 1.11-1.12.49-2.95-.39-1.14-.76-2.7-2.06-5.36l.02-.01Zm-17.38-21.76c3.05-.42 6.31.79 9.36 2.35.51.39.94.68 1.33.87-5.61-2.86-12.72-3.39-18.44-.79 2.05-1.33 4.24-1.95 7.74-2.44l.01.01ZM443.67 72.67c-.4-2.2-1.15-4.33-2.37-6.22-1.49-2.32-3.58-4.19-5.91-5.64-6.17-3.81-13.75-5.11-20.83-6.01-3.23-.41-6.47-.69-9.72-.92l-1.39-.12c-.85-.07-1.52-.1-2.05-.1-1.08-.06-2.17-.12-3.25-.17-.08 0-.14.02-.19.05-.1.05-.18.14-.16.3.27 2.55-.01 5.12-.92 7.52-.15.38.4.56.62.28 1.32.59 2.68 1.05 4.08 1.37 0 2.78-.14 7.58-.33 12.91 0 0 0 .02-.01.03-.61 3.66-.79 7.42-1 11.12-.23 4.01-.43 8.03-.44 12.05 0 .64 0 1.28.03 1.93.02.31 0 .68.15.96.06.11.14.16.24.17-.2.17-.21.54.11.59 3.83.67 7.78.71 11.68.25 2.3-.19 4.87-.65 7.65-1.56 1.85-.54 3.67-1.18 5.43-1.91 7.2-3.02 14.31-8.07 17.35-15.53.76-1.86 1.17-3.8 1.31-5.75.3-1.93.28-3.82-.09-5.58l.01-.02Zm-19.32-15.42c5.74 1.41 11.94 3.68 15.65 8.55.25.32.47.65.69.99-2.3-2.82-5.68-5.69-12.88-8.23-2.16-.76-4.35-1.43-6.64-2.02 1.06.21 2.13.45 3.18.71Zm-25.82-3.04c.13 0 .27.01.4.02-.14.1-.26.23-.37.38 0-.13-.02-.26-.03-.4Zm34.82 22.17c-.75 3.09-3.55 5.66-5.88 7.58-3.35 2.76-7.21 5.03-11.28 6.54-1.33.49-2.71.9-4.12 1.15.06-1.38.08-2.76.07-4.13-.02-3.78-.16-7.56-.41-11.33-.09-1.37-.18-2.74-.37-4.1 0-.06-.03-.11-.06-.15.09-3.25.12-6.16.03-8.12 6.86 1.05 10.56 2.17 14.06 3.62 5.52 2.28 8.59 5.44 7.97 8.96l-.01-.02Zm-22 16.15c-.12 0-.23-.02-.34-.03l.34-.03v.06Zm-.69-.7c0-3.13.26-8.84.47-14.51.06 1.2.11 2.41.15 3.6.15 3.6.25 7.23.09 10.83-.24.03-.48.05-.71.07v.01Zm-12.33-30.94c.37.63 2.01 1.01 3.23 1.25v.15c-1.31-.31-2.59-.73-3.83-1.29.12-.36.23-.72.33-1.09.08.48.18.84.27.98Zm13.7 31.65v-.18c3.41-.56 6.71-2.02 9.69-3.68 2.31-1.28 4.59-2.78 6.63-4.53-4.69 4.53-11.61 8.24-16.33 8.38l.01.01Zm24.07-.75c-2.05 1.93-4.37 3.56-6.83 4.95 2.7-1.78 5.52-4.03 8.42-6.87.82-.82 1.56-1.69 2.23-2.59-1.08 1.65-2.38 3.16-3.81 4.51h-.01ZM187.16 92.14c-.79-2.47-2.1-7.12-3.1-6.87-.19-.01-2.09.77-4.08 1.54-3.06 1.18-5.91 2.13-10.09 2.82-2.74.42-5.87 1.01-10.61 1.06.04-3.34.05-6.01.05-7.99 7.97-.65 12.33-2.11 16.37-3.55 1.11-.39 2.69-1.01 2.63-1.8-.08-.35-.55-1.39-1.17-2.61-.47-1.16-.98-2.31-1.61-3.38-.42-.71-1.04-1.69-1.86-2.06-.11-.08-.22-.13-.29-.12-.02 0-.04 0-.07.01-.19-.04-.39-.05-.6-.01-.17.03-.24.15-.25.28-.04.02-.09.04-.14.05-4.33 1.48-8.85 2.33-13.24 3.61a499.1 499.1 0 0 0-.31-8.19c4.51-.99 8.88-1.38 13.11-1.82 3.68-.38 6.28.12 7.47.34.59.11.9.16 1.16.18h.1c-.1.37.44.66.62.28.02-.04.03-.08.05-.13.15.2.53.22.62-.1.17-.58.19-1.21.21-1.81v-.36c.03-.15.05-.3.07-.45.52-2.47.33-5.09-.64-7.44-.11-.27-.44-.28-.6-.14-.08-.21-.15-.42-.24-.62-.19-.41-.79-.05-.6.35.03.07.05.15.09.22-.98-.42-2.15-.54-3.17-.63-2.17-.19-4.37-.14-6.54 0-5.7.35-11.4 1.3-16.91 2.79-2.08.56-4.13 1.22-6.14 2-4.54 1.05-3.79 1.51-2.17 6.07.18.51.46 1.68.54 1.94.82 2.47 1.08 2.13 3.1 2.13s0 .05 0 .08h.52c-.48 2.66-.51 5.45-.62 8.13-.15 3.48-.22 6.96-.28 10.45 0 .41-.01.82-.02 1.23-.16.29-.33.57-.51.85-.05.38-.09.77-.14 1.18-.42 3.52-.59 6.48-.52 8.8v.34c.02.47.05.76.06.87.16 1.57-.26 3.47 1.35 3.79 1.61.32 3.5.55 4.85.55.11 0 .22-.02.33-.02 1.79.24 3.67.05 5.45-.12 2.85-.28 5.69-.7 8.51-1.19 3.03-.53 6.05-1.14 9.04-1.86 2.4-.58 4.82-1.19 7.13-2.06.51-.19 1.73-.57 2.46-1.14 1.81-.68 2.18-1 1.57-2.67-.23-.62-.48-1.49-.91-2.78l-.03-.02Zm-11.12-38.71c.89.05 1.93.08 2.89.3-.33 0-.68-.02-1.06-.03-8.28-.26-14.88.75-23.97 2.51 2.41-.64 4.85-1.16 7.28-1.59 4.87-.86 9.91-1.45 14.86-1.19Zm-26.53 22.13c.03 1.71.04 3.43 0 5.14-.04 1.27-.11 2.55-.24 3.82 0-.73.02-1.46.04-2.19.05-2.26.12-4.51.22-6.77h-.02Zm6.73 27.85c.2-.1.4-.21.58-.33 1.82-.17 3.82-.24 5.94-.34-.86.11-1.72.24-2.58.33-1.27.14-2.61.31-3.93.34h-.01ZM534.48 85.44c-3.52-8.38-7.07-16.75-10.5-25.17-.63-1.54-1.25-3.09-1.86-4.65-.31-.8-.65-1.6-.87-2.43-.04-.17-.17-.24-.31-.25.1-.2 0-.51-.29-.53-1.59-.08-3.18-.22-4.78-.25-1.96-.03-3.91.13-5.84.42-.31.05-.31.38-.13.56-.03.06-.05.14-.04.22.23 1.54.63 3.06 1.16 4.53.13.35.27.7.41 1.06l-2.68 6.18c-.11.03-.2.09-.25.22-.67 1.9-1.52 3.73-2.34 5.56a536.85 536.85 0 0 1-3.9 8.45c-2.64 5.64-5.34 11.25-7.91 16.93-.44.97-.88 1.94-1.29 2.93-.2.48-.47 1-.55 1.52v.05c-.02.12.02.26.16.34 1.19.73 2.41 1.41 3.66 2.05 1.2.62 2.45 1.25 3.76 1.61.43.12.62-.55.19-.67-1.13-.31-2.2-.83-3.24-1.36 1.09.36 2.1.69 2.75.93 2.82 1.01 2.38 1.1 4.3-3.75 2.1-1.09 4.34-1.96 6.53-2.79 4.35-1.64 8.8-3.03 13.27-4.29.82 2.01 1.77 3.97 2.72 5.92.35.83.62 1.45.79 1.82.22.42.45.8.69 1.15.17.33.33.67.5 1 .42.8.84 1.63 1.4 2.35.23.29.6 0 .55-.31 1.53-.02 3.06-.07 4.58-.27.92-.12 1.82-.32 2.71-.54 1.39-.27 3.85-1.11 3.74-1.42-.67-1.96-1.55-3.87-2.34-5.78-1.57-3.78-3.16-7.56-4.75-11.33v-.01Zm-11.65-26.16c1.54 3.81 3.12 7.6 4.7 11.4 2.94 7.05 5.91 14.09 8.87 21.13l-1.06-2.17c-2.71-5.51-5.2-11.19-7.41-16.87l-6.65-17.15c-.65-1.45-.55-2.19-.93-2.53.09 0 .18.01.28.02a.29.29 0 0 0-.04.26c.52 2.02 1.47 3.98 2.25 5.91h-.01Zm-6.58 13.58c.05-.15.09-.31.14-.46 1.41 3.92 2.88 7.9 4.39 11.87-3.22.52-6.38 1.25-9.46 2.14.55-1.22 1.05-2.46 1.53-3.7 1.24-3.24 2.37-6.53 3.39-9.85h.01Zm-.23-20c.36 0 .73.03 1.09.05-2.15.1-5.18.33-5.87.74-.24.15-.41.3-.53.45-.06-.29-.13-.58-.18-.88 1.82-.26 3.65-.39 5.49-.35v-.01Zm-.09 18.72c-.49 1.67-1.05 3.33-1.6 4.97-1.07 3.19-2.19 6.38-3.57 9.46-.09.21-.19.43-.29.65-.25.07-.5.14-.74.22 2.53-6.16 4.61-11.29 6.2-15.3Zm-6.34 25.16c4.97-2.38 9.37-4.1 14.02-5.27l.26.64c-4.8 1.35-9.63 2.8-14.28 4.63Zm20.17 6.76c.33.23.68.42 1.04.56h-.33c-.12 0-.21.06-.26.13-.15-.23-.31-.45-.45-.7v.01ZM226.57 91.75c-3.55-4.74-6.68-9.11-9.31-12.99 9.2-15.25 10.05-17.81 10.35-18.38.17-.34 1.09-2.27.64-2.53-1.13-.65-1.03-.65-2.97-1.71-1.19-.65-3.04-1.61-4.53-2.12-1.71-.59-1.24-.36-3 2.77-.06.1-.11.2-.17.3-.75 1.02-1.48 2.05-2.2 3.09-1.88 2.71-3.73 5.45-5.69 8.1-3.68-4.91-6.88-8.76-9.51-11.43-.15-.15-.3-.29-.46-.42-1.27-1.28-7.24 3.53-7.93 5.58-.09.09-.19.16-.28.25-.27.26.03.64.33.58.19.65.5 1.29.94 1.91 3.85 5.06 7.19 9.76 9.94 14-1.23 2.61-3.06 5-4.67 7.38l-2.28 3.33c-.5.66-.93 1.23-1.29 1.69-.67.93-2.09 2.61-2.3 3.87-.51.85-1.16 1.84-1.29 2.83-.06.44.61.63.67.19.01-.08.04-.15.06-.22 1.36 1.08 2.76 2.11 4.19 3.11 1.3.91 2.62 1.85 4.04 2.56.21.1.4 0 .48-.17.24.07.48.14.72.2.44.1.62-.57.19-.67-2.02-.48-3.77-1.57-5.23-3.02-.47-.46-.9-.96-1.32-1.46 1.74 1.35 4.2 2.89 5.89 4.14 1.39 1.03 2.85-2.27 4.22-4.2 1.86-2.64 3.96-5.86 5.52-8.29l10.39 14.51c.67.81 1.14 1.21 1.57 1.36-.05.24.12.51.41.4 1.53-.58 3.05-1.19 4.54-1.87 1.52-.69 3.06-1.45 4.36-2.5a.28.28 0 0 0 .12-.23c1.66-1.1.81-1.74-1.41-4.91-1.13-1.58-1.71-2.36-3.7-5.01l-.03-.02Zm2.41 6.54c.56 1.15 1.19 2.52 1.11 3.81-.06.04-.12.07-.17.1-.03-.88-.55-2.66-.94-3.91Zm-16.51-32.73c1.86-2.65 3.65-5.35 5.57-7.95.4-.55.81-1.13 1.26-1.66.19-.18.38-.33.56-.45.18.03.36.08.55.13l-8.05 10.11.12-.18h-.01ZM192.7 95.48c.79-1.37 1.66-2.69 2.54-4 1.19-1.79 2.4-3.56 3.61-5.33-.04.09-.09.17-.13.26-.1.22.03.41.2.49-2.47 3.42-4.89 6.73-6.4 9.28.21.24.4.48.63.75-.24.07-.4.36-.17.56.4.33.72.77 1.05 1.17.09.11.18.21.27.32-.84-.61-1.66-1.24-2.47-1.88.24-.57.58-1.11.87-1.61v-.01Zm7.46-10.32c.47-.81.98-1.59 1.49-2.37.31-.48.64-.95.96-1.43.26-.29.52-.56.75-.79-.99 1.48-2.09 3.03-3.2 4.59Zm10.03-16.22s-.03-.05-.05-.07c.22-.29.43-.59.64-.89-.2.32-.4.65-.58.96h-.01ZM371.54 87.96c-.01-.08-.01-.16-.03-.23-.06-.38-.58-.29-.66.03-.3-.05-.6-.08-.81-.11-1.14-.15-2.29-.19-3.44-.2 1.04-.09 2.09-.18 3.14-.23.45-.02.45-.72 0-.7-6.57.35-13.14 1.23-19.65 2.11-1.53.21-3.05.42-4.57.68-.01 0-.02.01-.04.01-.04-3.33-.13-6.66-.24-9.99-.19-5.7-.4-11.41-.88-17.1-.13-1.51-.23-3.07-.49-4.58 0-.25 0-.48-.02-.68-.06-1.19-.04-2.61-.68-2.78-.16-.07-.72-.16-1.5-.24.22-.17.16-.62-.2-.63-1.19-.04-2.39.09-3.57.23-1.2.14-2.41.32-3.59.6-.16-.1-.41-.06-.5.12-.06.02-.13.03-.19.05-.35.1-.29.55-.03.66-.26.6-.19 2.27-.21 3-.02.66-.66 33.73-.9 40.3-.03.65.06 1.12.04 1.45-.16 3.05.87 4.96 6.34 3.93 1.09-.08 2.75-.77 5.36-1.43 4.13-1.04 5.78-1.52 6.2-1.65 6.43-1.69 6.78-1.97 11.72-2.43.55-.05 4.8-.38 6.03-.3.64.04 1.19.07 1.65.1.09 0 .16-.03.24-.05.1.27.56.33.66-.02.39-1.32.61-2.71.78-4.08.2-1.61.29-3.24.15-4.86.24.03.52-.23.38-.53-.09-.2-.27-.33-.49-.43v-.02Zm-.63.56c.07.57.11 1.14.11 1.71-.21-.99-.53-1.71-.95-1.87.22.03.44.06.65.11.06.01.12.04.19.05Zm-25.41 1.73c1.54-.36 3.1-.64 4.66-.89-1.61.37-3.18.77-4.66 1.2v-.31Zm-.86-7.37c-.07-1.37-.16-2.75-.25-4.12-.21-3.13-.45-6.27-.79-9.4.02-2.25.08-4.31.13-6.11.16 2.08.29 4.16.4 6.24.23 4.46.38 8.93.5 13.39h.01Zm-.94-4c.16 2.41.29 4.83.39 7.24.06 1.6.14 3.22.09 4.83-.15.05-.32.09-.47.14V78.88h-.01ZM483.72 92.83c-3.05-2.28-6.22-4.4-9.38-6.51 8.86-6.49 13.49-12.95 13.73-19.23.04-.76 0-1.5-.13-2.2-.67-3.82-3.5-6.68-8.39-8.48.13.04.27.08.4.13 3.92 1.39 7.74 4.23 8.5 8.56.34 1.95-.05 3.96-.98 5.69-.21.4.39.75.6.35 1.86-3.46 1.46-7.55-.97-10.63-3.53-4.47-9.76-5.88-15.16-6.16-2.32-.12-4.64-.04-6.95.19-6 .32-12.71 1.68-17.63 3.21-.37.11-.67.23-.92.35-.2-.17-.62.02-.57.37v.03c-.64.68-.18 1.64.48 3.21.38.91.67 1.89 1.15 2.58.32.76.68 1.51 1.13 2.19.14.21.38.19.53.07.19-.02.38-.05.57-.08v1.57c-.06.06-.1.13-.11.23-.27 4.18-.34 8.38-.48 12.57l-.3 9.03c-.24 3.91-.44 6.77-.46 7.26-.05.88-.11 1.95.07 2.81-.01.22-.02.43-.04.65 0 .11-.02.23-.03.35 0 .05-.03.27-.01.16-.05.4.5.59.64.28.05.04.12.08.2.08 1.75.13 3.5.28 5.25.3 1.69.02 3.38-.12 5.06-.32.08.23.36.39.55.15.06-.08.11-.17.16-.26.18-.09.24-.32.18-.48.05-.2.1-.4.13-.6.16-.86.25-1.74.33-2.62.11-1.17.17-2.34.23-3.51.15-.01.32-.03.52-.04.36-.03 1.73-.15 2.06-.15.39 0 .7-.02.95-.04 1.76 1.11 3.45 2.35 5.14 3.55 2.83 2.01 5.64 4.04 8.47 6.04 1.42 1 2.85 2 4.29 2.97.1.06.19.07.27.04.08 0 .17-.02.25-.1 1.61-1.56 3.15-3.18 4.6-4.88.75-.88 1.49-1.78 2.15-2.73.01.01.03.02.04.03.34.3.83-.2.49-.49-2.16-1.9-4.34-3.76-6.64-5.48l.03-.01Zm-6.38-3.65a55.72 55.72 0 0 0-4-2.13c.14-.1.26-.19.4-.29 1.2.81 2.4 1.61 3.6 2.42Zm-20.1 11.78c.67-.37 1.23-.91 1.67-1.6-.11.5-.24 1-.38 1.49-.43.04-.86.08-1.29.11Zm2.38-37.24c1.34-.31 2.56-.52 3.71-.69-1.03.19-2.04.41-3.04.65-.14-.07-.34-.02-.45.11-.07.02-.15.04-.22.05v-.13.01Zm.04.84c.07-.02.14-.03.2-.05.34 1.66.41 3.41.5 5.09.17 2.9.24 5.81.28 8.71l.03 3.17c-.17.07-.34.14-.51.2-.06-4.96-.21-10.58-.51-17.12h.01Zm16.04 5.62c-1.16 2.25-3.06 4.1-5.02 5.66-2.8 2.23-5.99 3.97-9.3 5.35-.01-3.56-.09-7.12-.27-10.67-.1-2.04-.16-4.16-.57-6.18 3.3-.78 6.72-1.36 10.1-1.1 1.85.14 4.23.59 5.32 2.29.92 1.43.46 3.24-.26 4.65Zm.85-.18c.6-1.37.9-2.92.28-4.32-.67-1.52-2.2-2.32-3.76-2.74.46.1.89.21 1.29.37 1.74.67 2.69 1.88 2.93 3.21.2 1.13-.05 2.25-.74 3.47V70Zm-27.47-4.14c-.12-.19-.23-.38-.34-.57.74.42.85.36.99.41v.08c-.22.03-.43.06-.65.08Zm11.21 30.46c-.08 1.08-.16 2.17-.33 3.24-.05.35-.11.69-.2 1.03 0 .04-.02.07-.03.11-.15.02-.3.04-.45.05.45-1.64.76-3.36.79-5.07.03-.29.08-.57.1-.89-.03-.31-.03-.47.24-.57-.04.69-.07 1.39-.12 2.08v.02Zm5.6-2.47c.48.11.92.52 2.49 1.72-.46-.32-.92-.65-1.38-.97-.37-.25-.73-.5-1.1-.75h-.01Zm21.23 7.24a70.76 70.76 0 0 1-4.37 4.63c-.14-.09-.27-.19-.4-.28.19-.09.37-.24.55-.47.87-1.14 5.43-5.51 5.49-7.45.31.26.62.53.92.79-.67.97-1.42 1.88-2.19 2.77v.01Z",fill:"currentColor",transform:"translate(-144.023 -51.76)"})]}),cT=({style:e,size:o="small",withText:t})=>dT("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Kn(RA,{}),t&&Kn(NA,{})]});import{Fragment as uT,jsx as xt,jsxs as hb}from"react/jsx-runtime";var gb=({icon:e,shortcut:o,children:t})=>{let r=Ce();return hb(uT,{children:[xt("div",{className:"welcome-screen-menu-item__icon",children:e}),xt("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&xt("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};gb.displayName="WelcomeScreenMenuItemContent";var $s=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>xt("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:xt(gb,{icon:t,shortcut:r,children:o})});$s.displayName="WelcomeScreenMenuItem";var mT=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>xt("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noreferrer",children:xt(gb,{icon:t,shortcut:r,children:e})});mT.displayName="WelcomeScreenMenuItemLink";var Go=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Ze();return xt(o.In,{children:xt("div",{className:"welcome-screen-center",children:e||hb(uT,{children:[xt(fb,{}),xt(bb,{children:f("welcomeScreen.defaults.center_heading")}),hb(xb,{children:[xt(yb,{}),xt(Eb,{})]})]})})})};Go.displayName="Center";var fb=({children:e})=>xt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||xt(cT,{withText:!0})});fb.displayName="Logo";var bb=({children:e})=>xt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});bb.displayName="Heading";var xb=({children:e})=>xt("div",{className:"welcome-screen-menu",children:e});xb.displayName="Menu";var Eb=()=>{let e=ft();return xt($s,{onSelect:()=>e.executeAction(_n),shortcut:"?",icon:vi,children:f("helpDialog.title")})};Eb.displayName="MenuItemHelp";var yb=()=>{let e=Re(),o=ft();return e.viewModeEnabled?null:xt($s,{onSelect:()=>o.executeAction(_i),shortcut:ct("loadScene"),icon:wi,children:f("buttons.load")})};yb.displayName="MenuItemLoadScene";var pT=({onSelect:e})=>{let{t:o}=ut();return xt($s,{shortcut:null,onSelect:e,icon:jl,children:o("labels.liveCollaboration")})};pT.displayName="MenuItemLiveCollaborationTrigger";Go.Logo=fb;Go.Heading=bb;Go.Menu=xb;Go.MenuItem=$s;Go.MenuItemLink=mT;Go.MenuItemHelp=Eb;Go.MenuItemLoadScene=yb;Go.MenuItemLiveCollaborationTrigger=pT;import{jsx as sl,jsxs as vb}from"react/jsx-runtime";var Kp=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Ze();return sl(o.In,{children:vb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[uh,sl("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};Kp.displayName="MenuHint";var Zp=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Ze();return sl(o.In,{children:vb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[sl("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),gh]})})};Zp.displayName="ToolbarHint";var Xp=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Ze();return sl(o.In,{children:vb("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[sl("div",{children:e||f("welcomeScreen.defaults.helpHint")}),hh]})})};Xp.displayName="HelpHint";import{Fragment as hT,jsx as js,jsxs as BA}from"react/jsx-runtime";var $p=e=>js(hT,{children:e.children||BA(hT,{children:[js(Go,{}),js(Kp,{}),js(Zp,{}),js(Xp,{})]})});$p.displayName="WelcomeScreen";$p.Center=Go;$p.Hints={MenuHint:Kp,ToolbarHint:Zp,HelpHint:Xp};var OA=$p;var zA=()=>{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)})},gT=zA;import FA from"lodash.throttle";var HA=(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)),UA=FA((e,o,t)=>{if(Ge()||mt()||window?.DEBUG_FRACTIONAL_INDICES){let r=Nr(e.map(n=>({...n})));Ax(r,{shouldThrow:mt()||Ge(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),GA=(e,o,t)=>{let r=te(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),c=HA(t,s,l);s&&c?(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=Vc(n);return UA(a,e,o),Nr(a),a};import{jsx as fT,jsxs as VA}from"react/jsx-runtime";var bT=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=Ze(),r=Ie();return fT(t.In,{children:VA(Ne.Item,{onSelect:()=>{ye("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??Ag,children:[e??f("labels.textToDiagram"),fT(Ne.Item.Badge,{children:"AI"})]})})};bT.displayName="TTDDialogTrigger";import{useLayoutEffect as YA}from"react";var WA=e=>{let o=st();return YA(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{parseMermaidToExcalidraw as TEe}from"@excalidraw/mermaid-to-excalidraw";import{jsx as wb}from"react/jsx-runtime";gT();var XA=e=>{let{className:o,onChange:t,initialData:r,excalidrawAPI:n,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=pr.code,viewModeEnabled:c,zenModeEnabled:m,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:g,renderCustomStats:b,onPaste:x,detectScroll:E=!0,handleKeyboardGlobally:w=!1,onLibraryChange:y,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:_,onPointerDown:L,onPointerUp:N,onScrollChange:P,onDuplicate:z,id:W,onHomeButtonClick:U,children:q,validateEmbeddable:H,renderEmbeddable:V,aiEnabled:K,showDeprecatedFonts:Q,ui:X,interactive:ie,activeTool:he}=e,pe=e.UIOptions?.canvasActions,He={...e.UIOptions,canvasActions:{...ou.canvasActions,...pe},tools:{image:e.UIOptions?.tools?.image??!0}};return pe?.export&&(He.canvasActions.export.saveFileToDisk=pe.export?.saveFileToDisk??ou.canvasActions.export.saveFileToDisk),He.canvasActions.toggleTheme===null&&typeof u>"u"&&(He.canvasActions.toggleTheme=!0),ZA(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let qt=Jt=>{typeof Jt.scale=="number"&&Jt.scale!==1&&Jt.preventDefault()};return document.addEventListener("touchmove",qt,{passive:!1}),()=>{document.removeEventListener("touchmove",qt)}},[]),wb(RE,{store:kt,children:wb(iT,{langCode:s,theme:u,children:wb(nT,{id:W,className:o,onChange:t,initialData:r,excalidrawAPI:n,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:ie===!1?!0:c,zenModeEnabled:m,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:g,renderCustomStats:b,UIOptions:He,onPaste:x,detectScroll:E,handleKeyboardGlobally:w,onLibraryChange:y,autoFocus:v,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:_,onPointerDown:L,onPointerUp:N,onScrollChange:P,onDuplicate:z,validateEmbeddable:H,renderEmbeddable:V,aiEnabled:K!==!1,showDeprecatedFonts:Q,onHomeButtonClick:U,ui:X,interactive:ie,activeTool:he,children:q})})})},$A=(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),c=Object.keys(a);return s.length!==c.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])&&Qe(n,l)},jA=KA.memo(XA,$A);jA.displayName="Excalidraw";export{Co as Button,A as CaptureUpdateAction,KS as CommandPalette,qp as DEFAULT_LASER_COLOR,kp as DefaultSidebar,WA as DiagramToCodePlugin,jA as Excalidraw,zt as FONT_FAMILY,LA as Footer,_A as LiveCollaborationTrigger,ge as MIME_TYPES,Ot as MainMenu,oo as ROUNDNESS,Uo as Sidebar,Us as Stats,ce as THEME,V1 as TTDDialog,bT as TTDDialogTrigger,jb as UserIdleState,OA as WelcomeScreen,nw as actions,_l as bumpVersion,IT as cleanAppStateForExport,CT as clearAppStateForLocalStorage,Ja as convertToExcalidrawElements,pr as defaultLang,EE as duplicateElement,bn as duplicateElements,vT as elementPartiallyOverlapsWithOrContainsBBox,wT as elementsOverlappingBBox,tv as exportToBlob,fn as exportToCanvas,sI as exportToClipboard,Ga as exportToSvg,ve as getCommonBounds,ad as getDataURL,Br as getDefaultAppState,TT as getFreeDrawSvgPath,zm as getLibraryItemsHash,xe as getNonDeletedElements,ET as getSceneVersion,yu as getTextFromElements,Ou as getVisibleSceneBounds,Iu as hashElementsVersion,Su as hashString,UE as icons,yT as isElementInsideBBox,hi as isElementLink,ci as isInvisiblySmallElement,le as isLinearElement,ga as languages,Pn as libraryItemsAtom,id as loadFromBlob,Zu as loadLibraryFromBlob,Ku as loadSceneOrLibraryFromBlob,sv as mergeLibraryItems,B as mutateElement,re as newElementWith,Zo as normalizeLink,Ff as parseLibraryTokensFromUrl,TEe as parseMermaidToExcalidraw,GA as reconcileElements,zl as restore,ST as restoreAppState,Wu as restoreElements,Fl as restoreLibraryItems,Ft as sceneCoordsToViewportCoords,Ol as serializeAsJSON,Yu as serializeLibraryAsJSON,xT as setCustomTextMetricsProvider,Ce as useDevice,hI as useHandleLibrary,ut as useI18n,je as viewportCoordsToSceneCoords,e2 as zoomToFitBounds};
|
|
135
|
+
`),n)}}addTextFromPaste(o,n=!1){let{x:r,y:i}=qe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:o,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:CV,verticalAlign:A6,locked:!1},l=ix({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=B6(a.fontFamily),[c,,d]=vK(this.state),m=Math.max(Math.min((d-c)*.5,800),200),p=10,u=i,g=n?[o]:o.split(`
|
|
136
|
+
`),b=g.reduce((x,w,E)=>{let y=LK(w).trim();if(y.length){let T=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),v=c4(y,l,s),C=v.width>m,M=C?SK(y,l,m):y;v=C?c4(M,l,s):v;let k=r-v.width/2,P=u-v.height/2,A=K6({...a,x:k,y:P,text:M,originalText:y,lineHeight:s,autoResize:!C,frameId:T?T.id:null});x.push(A),u+=A.height+p}else g[E-1]?.trim()&&(u+=AK(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:Ae(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!n&&b.length>1&&E4===!1&&!this.device.editor.isMobile&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:DV("CtrlOrCmd+Shift+V")}),duration:5e3}),E4=!0))}handleTextWysiwyg(o,{isExistingElement:n=!1}){let r=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===o.id&&jo(s)?_i(s,{originalText:a,isDeleted:l??s.isDeleted,...QV(s,n4(s,r),r,a)}):s)])};JI({id:o.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:c}=Cu({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:Ge(a=>{i(a,!1),f4(o)&&dx(o,this.scene)}),onSubmit:Ge(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(s&&!n?this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(c=>c.id!==o.id)):i(l,s),!s&&a){let c=o.containerId?o.containerId:o.id;Vn(()=>{this.setState(d=>({selectedElementIds:Ae({...d.selectedElementIds,[c]:!0},d)}))})}s&&WV(this.scene.getNonDeletedElements(),[o]),this.store.scheduleCapture(),Vn(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&io(this.interactiveCanvas,this.state),this.focusContainer()}),element:o,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(o.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(o,n){let r=this.getElementAtPosition(o,n,{includeBoundTextElement:!0});return r&&jo(r)&&!r.isDeleted?r:null}getElementAtPosition(o,n,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(o,n,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return sc({point:he(o,n),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Lo(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(o,n,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(r?.includeLockedElements||!s.locked)&&(r?.includeBoundTextElement||!(jo(s)&&s.containerId)))).filter(s=>this.hitElement(o,n,s)).filter(s=>{let c=vx(s,a);return c&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?i4({x:o,y:n},c,a):!0}).filter(s=>gl(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(o){return Math.max(o.strokeWidth/2+.1,.85*(N6/this.state.zoom.value))}hitElement(o,n,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&pK([r],this.state)&&$K(he(o,n),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||yK(he(o,n),r,this.scene.getNonDeletedElementsMap())?!0:sc({point:he(o,n),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Lo(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(o,n){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return j6(i[0],!1)?i[0]:null;let a=null;for(let l=r.length-1;l>=0;--l){if(r[l].isDeleted)continue;let[s,c,d,m]=U6(r[l],this.scene.getNonDeletedElementsMap());if(px(r[l])&&sc({point:he(o,n),element:r[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[l])})){a=r[l];break}else if(s<o&&o<d&&c<n&&n<m){a=r[l];break}}return j6(a,!1)?a:null}handleHoverSelectedLinearElement(o,n,r){let i=this.scene.getNonDeletedElementsMap(),a=De.getElement(o.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;sc({point:he(n,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=De.getPointIndexUnderCursor(a,i,this.state.zoom,n,r),s=De.getSegmentMidpointHitCoords(o,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),(at(a)?l===0||l===a.points.length-1:l>=0)||s?Se(this.interactiveCanvas,Ye.POINTER):this.hitElement(n,r,a)&&(!at(a)||!(a.startBinding||a.endBinding))&&Se(this.interactiveCanvas,Ye.MOVE)):this.hitElement(n,r,a)&&(!at(a)||!(a.startBinding||a.endBinding))&&Se(this.interactiveCanvas,Ye.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),De.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else Se(this.interactiveCanvas,Ye.AUTO)}updateGestureOnPointerDown(o){we.pointers.set(o.pointerId,{x:o.clientX,y:o.clientY}),we.pointers.size===2&&(we.lastCenter=L0(we.pointers),we.initialScale=this.state.zoom.value,we.initialDistance=A0(Array.from(we.pointers.values())))}initialPointerDownState(o){let n=qe(o,this.state),r=this.scene.getSelectedElements(this.state),[i,a,l,s]=ul(r),c=r.findIndex(at)===0;return{origin:n,withCmdOrCtrl:o[W.CTRL_OR_CMD],originInGrid:ax(Tt(n.x,n.y,o[W.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:F0(uc,o.clientX-this.state.offsetLeft,o.clientY-this.state.offsetTop),lastCoords:{...n},originalElements:this.scene.getNonDeletedElements().reduce((d,m)=>(d.set(m.id,X6(m)),d),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(n,r)},drag:{hasOccurred:!1,offset:null,origin:{...n}},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(o,n){if(!(n.scrollbars.isOverEither&&!this.state.multiElement))return!1;Sx=!0,n.lastCoords.x=o.clientX,n.lastCoords.y=o.clientY;let r=Cp(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,n)}),i=Ge(()=>{hc=null,Sx=!1,io(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(o.clientX,o.clientY,"up"),window.removeEventListener(oe.POINTER_MOVE,r),window.removeEventListener(oe.POINTER_UP,i),r.flush()});return hc=i,window.addEventListener(oe.POINTER_MOVE,r),window.addEventListener(oe.POINTER_UP,i),!0}isASelectedElement(o){return o!=null&&this.state.selectedElementIds[o.id]}isHittingCommonBoundingBoxOfSelectedElements(o,n){if(n.length<2)return!1;let r=Math.max(N6/this.state.zoom.value,1),[i,a,l,s]=ul(n);return o.x>i-r&&o.x<l+r&&o.y>a-r&&o.y<s+r}getCurrentItemRoundness(o){return this.state.currentItemRoundness==="round"?{type:oK(o)?vu.ADAPTIVE_RADIUS:vu.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(o,n,r=!1){Gn({event:o,app:this,selectedElements:n})&&(r||!Io.getReferenceSnapPoints())&&Io.setReferenceSnapPoints(gI(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(o,n,r=!1){Gn({event:o,app:this,selectedElements:n})&&(r||!Io.getVisibleGaps())&&Io.setVisibleGaps(uI(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(o){return Ge(n=>{this.maybeHandleResize(o,n)||this.maybeDragNewGenericElement(o,n)})}onKeyUpFromPointerDownHandler(o){return Ge(n=>{n.key===W.ALT&&n.preventDefault(),!this.maybeHandleResize(o,n)&&this.maybeDragNewGenericElement(o,n)})}onPointerMoveFromPointerDownHandler(o){return Cp(n=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=qe(n,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]=Tt(r.x,r.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),g=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(g<0){let x=De.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());g=x?De.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=De.moveFixedSegment(this.state.selectedLinearElement,g,p,u,this.scene);Vn(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}})});return}let i=this.lastPointerMoveCoords??o.origin;if(this.lastPointerMoveCoords=r,o.drag.offset===null&&(o.drag.offset=ax(KK(this.scene.getSelectedElements(this.state),o.origin.x,o.origin.y))),!(n.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(n,o))return;if(Ht(this.state)){this.handleEraser(n,r);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y);let[l,s]=Tt(r.x,r.y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!o.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&dl(he(r.x,r.y),he(o.origin.x,o.origin.y))<P6)return;if(o.resize.isResizing&&(o.lastCoords.x=r.x,o.lastCoords.y=r.y,this.maybeHandleCrop(o,n)||this.maybeHandleResize(o,n)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.editingLinearElement||this.state.selectedLinearElement;if(De.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,c)){let g=De.addMidpoint(this.state.selectedLinearElement,r,this,!n[W.CTRL_OR_CMD],this.scene);if(!g)return;Vn(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:g.pointerDownState,selectedPointsIndices:g.selectedPointsIndices,segmentMidPointHoveredCoords:null}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:g.pointerDownState,selectedPointsIndices:g.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=De.handlePointDragging(n,this,r.x,r.y,p);if(u){o.lastCoords.x=r.x,o.lastCoords.y=r.y,o.drag.hasOccurred=!0,this.setState(u);return}}let d=o.hit.allHitElements.some(p=>this.isASelectedElement(p)),m=this.state.editingLinearElement&&n.shiftKey&&this.state.editingLinearElement.elementId===o.hit.element?.id;if((d||o.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!m&&this.state.activeTool.type!=="lasso"){let p=this.scene.getSelectedElements(this.state);if(p.every(x=>x.locked))return;let u=p.find(x=>Lo(x)),g=this.getTopLayerFrameAtSceneCoords(r),b=g&&!u?g:null;if(this.state.frameToHighlight!==b&&Vn(()=>{this.setState({frameToHighlight:b})}),o.drag.hasOccurred=!0,p.length>0&&!o.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:r.x-o.drag.origin.x,y:r.y-o.drag.origin.y},w=[...o.originalElements.values()],E=n.shiftKey;if(E){let v=Math.abs(x.x),C=Math.abs(x.y),M=E&&v<C,k=E&&v>C;M&&(x.x=0),k&&(x.y=0)}if(this.state.croppingElementId){let v=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(v&&Di(v)&&v.crop!==null&&o.hit.element===v){let C=v.crop,M=ac(v)&&this.imageCache.get(v.fileId)?.image;if(M&&!(M instanceof Promise)){let k=iV(I6(r.x-i.x,r.y-i.y),Math.max(this.state.zoom.value,2)),[P,A,R,O,U,ee]=U6(v,c),_=tx(ex(he(P,A),he(U,ee),v.angle)),B=tx(ex(he(R,A),he(U,ee),v.angle)),j=tx(ex(he(P,O),he(U,ee),v.angle)),V=k6(C6(B,_)),Y=k6(C6(j,_)),le=I6(S6(k,V),S6(k,Y)),xe={...C,x:T6(C.x-le[0]*Math.sign(v.scale[0]),0,M.naturalWidth-C.width),y:T6(C.y-le[1]*Math.sign(v.scale[1]),0,M.naturalHeight-C.height)};this.scene.mutateElement(v,{crop:xe});return}}}this.maybeCacheVisibleGaps(n,p),this.maybeCacheReferenceSnapPoints(n,p);let{snapOffset:y,snapLines:T}=hI(w,x,this,n,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:T}),this.state.editingFrame||VK(o,p,x,this.scene,y,n[W.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!at(p[0]))&&this.setState({suggestedBindings:mx(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),n.altKey&&!o.hit.hasBeenDuplicated){o.hit.hasBeenDuplicated=!0;let v=this.scene.getElementsIncludingDeleted(),C=o.hit.element,M=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});C&&o.hit.wasAddedToSelection&&!M.find(B=>B.id===C.id)&&M.push(C);let k=new Map(M.map(B=>[B.id,B])),{duplicatedElements:P,duplicateElementsMap:A,elementsWithDuplicates:R,origIdToDuplicateId:O}=$6({type:"in-place",elements:v,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:B,origElement:j})=>({frameId:B.frameId??j.frameId,seed:zV()})});P.forEach(B=>{o.originalElements.set(B.id,X6(B))});let U=R.map(B=>{if(k.has(B.id)){let j=o.originalElements.get(B.id);if(j)return _i(B,{x:j.x,y:j.y})}return B}),ee=this.props.onDuplicate?.(U,v),_=m4(ee||U,z6(P));Vn(()=>{if(o.hit.element){let B=O.get(o.hit.element.id),j=B&&A.get(B);o.hit.element=j||null}o.hit.allHitElements=o.hit.allHitElements.reduce((B,j)=>{let V=O.get(j.id),Y=V&&A.get(V);return Y&&B.push(Y),B},[]),o.drag.origin=qe(n,this.state),this.setState(B=>({...GK(P,this.scene.getNonDeletedElements(),B)})),this.scene.replaceAllElements(_),this.maybeCacheVisibleGaps(n,M,!0),this.maybeCacheReferenceSnapPoints(n,M,!0)})}return}}if(this.state.selectionElement)o.lastCoords.x=r.x,o.lastCoords.y=r.y,n.altKey?Vn(()=>{this.setActiveTool({type:"lasso",fromSelection:!0},n.shiftKey),this.lassoTrail.startPath(o.origin.x,o.origin.y,n.shiftKey),this.setAppState({selectionElement:null})}):this.maybeDragNewGenericElement(o,n);else if(this.state.activeTool.type==="lasso")!n.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",o),o.lastCoords.x=r.x,o.lastCoords.y=r.y,this.maybeDragNewGenericElement(o,n),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,n.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,g=r.x-p.x,b=r.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===g&&x[1]===b)){let E=p.simulatePressure?p.pressures:[...p.pressures,n.pressure];this.scene.mutateElement(p,{points:[...u,he(g,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Ao(p)){o.drag.hasOccurred=!0;let u=p.points,g=l-p.x,b=s-p.y;ox(n)&&u.length===2&&({width:g,height:b}=q6(p.x,p.y,r.x,r.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,he(g,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&at(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),he(g,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),ux(p,!1)&&this.setState({suggestedBindings:G6(p,[r],this.scene,this.state.zoom,this.state.startBoundElement)})}else o.lastCoords.x=r.x,o.lastCoords.y=r.y,this.maybeDragNewGenericElement(o,n,!1)}if(this.state.activeTool.type==="selection"){o.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)De.handleBoxSelection(n,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!n.shiftKey&&Le(p,this.state)&&(o.withCmdOrCtrl&&o.hit.element?this.setState(b=>qo({...b,selectedElementIds:{[o.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let g=this.state.selectionElement?Qx(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...g.reduce((w,E)=>(w[E.id]=!0,w),{})};return o.hit.element&&(g.length?delete x[o.hit.element.id]:x[o.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...qo({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:g.length===1&&Ao(g[0])?new De(g[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:g.length===1&&(g[0].link||Wr(g[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(o,n){if(n.scrollbars.isOverHorizontal){let r=o.clientX,i=r-n.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(uc.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.x=r,!0}if(n.scrollbars.isOverVertical){let r=o.clientY,i=r-n.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(uc.vertical?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(o){return Ge(n=>{this.removePointer(n),o.eventListeners.onMove&&o.eventListeners.onMove.flush();let{newElement:r,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:c,isRotating:d,isCropping:m}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:ic(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Io.setReferenceSnapPoints(null),Io.setVisibleGaps(null),this.savePointer(n.clientX,n.clientY,"up");let p=o.hit.allHitElements,u=qe({clientX:n.clientX,clientY:n.clientY},this.state);if(this.state.activeTool.type==="selection"&&!o.boxSelection.hasOccurred&&!o.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}),this.onPointerUpEmitter.trigger(this.state.activeTool,o,n);let g=this.scene.getNonDeletedElementsMap();if(o.drag.hasOccurred&&o.hit?.element?.id){let E=g.get(o.hit.element.id);rK(E)&&E.boundElements?.filter(y=>y.type==="arrow").map(y=>g.get(y.id)).filter(y=>at(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.editingLinearElement)if(!o.boxSelection.hasOccurred&&o.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(Vt);else{let E=De.handlePointerUp(n,this.state.editingLinearElement,this.state,this.scene);E!==this.state.editingLinearElement&&this.setState({editingLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=De.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}o.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(Vt,"ui",{event:n,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(oe.POINTER_MOVE,o.eventListeners.onMove),window.removeEventListener(oe.POINTER_UP,o.eventListeners.onUp),window.removeEventListener(oe.KEYDOWN,o.eventListeners.onKeyDown),window.removeEventListener(oe.KEYUP,o.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,o),this.onPointerUpEmitter.trigger(this.state.activeTool,o,n),r?.type==="freedraw"){let E=qe(n,this.state),y=r.points,T=E.x-r.x,v=E.y-r.y;T===y[0][0]&&v===y[0][1]&&(v+=1e-4,T+=1e-4);let C=r.simulatePressure?[]:[...r.pressures,n.pressure];this.scene.mutateElement(r,{points:[...y,he(T,v)],pressures:C,lastCommittedPoint:he(T,v)}),this.actionManager.executeAction(Vt);return}if(Ao(r)){r.points.length>1&&this.store.scheduleCapture();let E=qe(n,this.state);!o.drag.hasOccurred&&r&&!l?(this.scene.mutateElement(r,{points:[...r.points,he(E.x-r.x,E.y-r.y)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:r,newElement:r})):o.drag.hasOccurred&&!l&&(cx(this.state)&&ux(r,!1)&&this.actionManager.executeAction(Vt,"ui",{event:n,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(y=>({newElement:null})):(fo(this.interactiveCanvas),this.setState(y=>({newElement:null,activeTool:Kn(this.state,{type:"selection"}),selectedElementIds:Ae({...y.selectedElementIds,[r.id]:!0},y),selectedLinearElement:new De(r,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(jo(r)){let E=DK(ix({fontSize:r.fontSize,fontFamily:r.fontFamily}),r.lineHeight);r.width<E&&this.scene.mutateElement(r,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(r,{isExistingElement:!0})}if(s.type!=="selection"&&r&&Q6(r)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==r.id),appState:{newElement:null},captureUpdate:Lt.NEVER});return}if(Lo(r)){let E=hK(this.scene.getElementsIncludingDeleted(),r,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(yx(this.scene.getElementsMapIncludingDeleted(),E,r,this.state))}if(r&&(this.scene.mutateElement(r,iK(r),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),o.drag.hasOccurred){let E=qe(n,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let T=vx(y,g);T&&y&&(fK(y,T,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),gK([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(E),T=this.scene.getSelectedElements(this.state),v=this.scene.getElementsMapIncludingDeleted(),C=M=>{if(M.length>0){for(let k of M){let P=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,P)},{informMutation:!1,isDragging:!1})}v.forEach(k=>{k.groupIds.length&&dc(v,k.groupIds[k.groupIds.length-1]).length<2&&this.scene.mutateElement(k,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(y&&!this.state.selectedElementIds[y.id]){let M=T.filter(k=>k.frameId!==y.id&&l4(k,v,this.state));this.state.editingGroupId&&C(M),v=yx(v,M,y,this.state)}else if(!y&&this.state.editingGroupId){let M=T.filter(k=>k.frameId&&!l4(k,v,this.state));C(M)}v=a4(v,this.state,this),this.scene.replaceAllElements(v)}}if(i&&this.store.scheduleCapture(),i&&Q6(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:Lt.NEVER}),o.resize.isResizing){let E=a4(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(T=>Lo(T));for(let T of y)E=uK(E,wx(this.scene.getElementsIncludingDeleted(),T,this.state,g),T,this);this.scene.replaceAllElements(E)}let b=o.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&Ao(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new De(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!m||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(Ht(this.state)&&x&&w){if(this.eraserTrail.endPath(),dl(he(x.clientX,x.clientY),he(w.clientX,w.clientY))===0){let y=qe({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(v=>this.elementsPendingErasure.add(v.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!o.drag.hasOccurred&&!o.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!o.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(n.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[b.id]?HK(this.state,b)?this.setState(E=>{let y={...E.selectedElementIds};for(let T of b.groupIds.flatMap(v=>dc(this.scene.getNonDeletedElements(),v)))delete y[T.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(T=>({[T]:!1})).reduce((T,v)=>({...T,...v}),{})},selectedElementIds:Ae(y,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let y={...E.selectedElementIds};delete y[b.id];let T=J(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...qo({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:T.length===1&&Ao(T[0])?new De(T[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(T=>dc(this.scene.getNonDeletedElements(),T)).forEach(T=>{delete y[T.id]}),{...qo({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||Wr(b)?"info":!1}}):this.setState(E=>({selectedElementIds:Ae({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...qo({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:Ao(b)&&E.selectedLinearElement?.elementId!==b.id?new De(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&at(b))&&!o.drag.hasOccurred&&!this.state.isResizing&&(b&&wK({point:he(o.origin.x,o.origin.y),element:b,elementsMap:g,threshold:this.getElementHitThreshold(b),frameNameBound:Lo(b)?this.frameNameBoundsCache.get(b):null},g)||!b&&o.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Ae({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),Se(this.interactiveCanvas,Ye.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&r&&this.setState(E=>({selectedElementIds:Ae({...E.selectedElementIds,[r.id]:!0},E),showHyperlinkPopup:Wr(r)&&!r.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||Le(this.scene.getNonDeletedElements(),this.state)||!HV(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),o.drag.hasOccurred&&!this.state.selectedLinearElement||c||d||m){let E=this.scene.getSelectedElements(this.state).filter(Ao);Y6(E,cx(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)?(fo(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Kn(this.state,{type:"selection"})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&we.pointers.size<=1&&lc(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,o.origin.x,o.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(o){this.setState(n=>({selectedElementIds:Ae({},n),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:n.editingGroupId&&o!=null&&d4(o,n.editingGroupId)?n.editingGroupId:null})),this.setState({selectedElementIds:Ae({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(o,n,r,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Ex(i,r,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(o-a,n-l)<EV){let{x:m,y:p}=Cu({sceneX:a,sceneY:l},r);return{viewportX:m,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let o=this.excalidrawContainerRef.current,{left:n,top:r}=o.getBoundingClientRect();return{offsetLeft:n,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let o=zi.find(n=>n.code===this.props.langCode)||Qo;await Rc(o),this.setAppState({})}},jK=()=>{(Mx()||y4())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(w4(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};jK();var C4=Lx;import{useEffect as JK,useState as QK}from"react";import{jsx as eX}from"react/jsx-runtime";var S4=e=>{let[t,o]=QK(!0);return JK(()=>{let n=async()=>{await Rc(r),o(!1)},r=zi.find(i=>i.code===e.langCode)||Qo;n()},[e.langCode]),t?eX(Lp,{theme:e.theme}):e.children};import tX from"clsx";import{jsx as k4}from"react/jsx-runtime";var M4=({children:e})=>{let{FooterCenterTunnel:t}=Ne(),o=Te();return k4(t.In,{children:k4("div",{className:tX("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":o.zenModeEnabled}),children:e})})},oX=M4;M4.displayName="FooterCenter";import nX from"clsx";import{jsx as iX,jsxs as aX}from"react/jsx-runtime";var L4=({isCollaborating:e,onSelect:t,...o})=>{let n=Te(),r=n.width<830;return aX(lo,{...o,className:nX("collab-button",{active:e}),type:"button",onSelect:t,style:{position:"relative",width:r?void 0:"auto"},title:f("labels.liveCollaboration"),children:[r?xg:f("labels.share"),n.collaborators.size>0&&iX("div",{className:"CollabButton-collaborators",children:n.collaborators.size})]})},rX=L4;L4.displayName="LiveCollaborationTrigger";import{jsx as Xr,jsxs as P4}from"react/jsx-runtime";var lX=()=>Xr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Xr("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),sX=()=>P4("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Xr("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)"}),Xr("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)"}),Xr("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)"}),Xr("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)"})]}),A4=({style:e,size:t="small",withText:o})=>P4("div",{className:`ExcalidrawLogo is-${t}`,style:e,children:[Xr(lX,{}),o&&Xr(sX,{})]});import{Fragment as R4,jsx as lt,jsxs as Bx}from"react/jsx-runtime";var Ox=({icon:e,shortcut:t,children:o})=>{let n=me();return Bx(R4,{children:[lt("div",{className:"welcome-screen-menu-item__icon",children:e}),lt("div",{className:"welcome-screen-menu-item__text",children:o}),t&&!n.editor.isMobile&<("div",{className:"welcome-screen-menu-item__shortcut",children:t})]})};Ox.displayName="WelcomeScreenMenuItemContent";var fc=({onSelect:e,children:t,icon:o,shortcut:n,className:r="",...i})=>lt("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:lt(Ox,{icon:o,shortcut:n,children:t})});fc.displayName="WelcomeScreenMenuItem";var _4=({children:e,href:t,icon:o,shortcut:n,className:r="",...i})=>lt("a",{...i,className:`welcome-screen-menu-item ${r}`,href:t,target:"_blank",rel:"noopener",children:lt(Ox,{icon:o,shortcut:n,children:e})});_4.displayName="WelcomeScreenMenuItemLink";var Po=({children:e})=>{let{WelcomeScreenCenterTunnel:t}=Ne();return lt(t.In,{children:lt("div",{className:"welcome-screen-center",children:e||Bx(R4,{children:[lt(Fx,{}),lt(Hx,{children:f("welcomeScreen.defaults.center_heading")}),Bx(zx,{children:[lt(Ux,{}),lt(Gx,{})]})]})})})};Po.displayName="Center";var Fx=({children:e})=>lt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||lt(A4,{withText:!0})});Fx.displayName="Logo";var Hx=({children:e})=>lt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Hx.displayName="Heading";var zx=({children:e})=>lt("div",{className:"welcome-screen-menu",children:e});zx.displayName="Menu";var Gx=()=>{let e=nt();return lt(fc,{onSelect:()=>e.executeAction(gr),shortcut:"?",icon:oi,children:f("helpDialog.title")})};Gx.displayName="MenuItemHelp";var Ux=()=>{let e=Te(),t=nt();return e.viewModeEnabled?null:lt(fc,{onSelect:()=>t.executeAction(ui),shortcut:Xe("loadScene"),icon:ni,children:f("buttons.load")})};Ux.displayName="MenuItemLoadScene";var D4=({onSelect:e})=>{let{t}=Je();return lt(fc,{shortcut:null,onSelect:e,icon:Al,children:t("labels.liveCollaboration")})};D4.displayName="MenuItemLiveCollaborationTrigger";Po.Logo=Fx;Po.Heading=Hx;Po.Menu=zx;Po.MenuItem=fc;Po.MenuItemLink=_4;Po.MenuItemHelp=Gx;Po.MenuItemLoadScene=Ux;Po.MenuItemLiveCollaborationTrigger=D4;import{jsx as hl,jsxs as Yx}from"react/jsx-runtime";var Lu=({children:e})=>{let{WelcomeScreenMenuHintTunnel:t}=Ne();return hl(t.In,{children:Yx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[Ju,hl("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};Lu.displayName="MenuHint";var Au=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:t}=Ne();return hl(t.In,{children:Yx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[hl("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),eg]})})};Au.displayName="ToolbarHint";var Pu=({children:e})=>{let{WelcomeScreenHelpHintTunnel:t}=Ne();return hl(t.In,{children:Yx("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[hl("div",{children:e||f("welcomeScreen.defaults.helpHint")}),Qu]})})};Pu.displayName="HelpHint";import{Fragment as N4,jsx as bc,jsxs as dX}from"react/jsx-runtime";var _u=e=>bc(N4,{children:e.children||dX(N4,{children:[bc(Po,{}),bc(Lu,{}),bc(Au,{}),bc(Pu,{})]})});_u.displayName="WelcomeScreen";_u.Center=Po;_u.Hints={MenuHint:Lu,ToolbarHint:Au,HelpHint:Pu};var cX=_u;var mX=()=>{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)})},B4=mX;import{getSceneVersion as J9e,hashElementsVersion as Q9e,hashString as eNe,getNonDeletedElements as ev}from"@excalidraw/element";import{getTextFromElements as oNe}from"@excalidraw/element";import{isInvisiblySmallElement as rNe}from"@excalidraw/element";import pX from"lodash.throttle";import{arrayToMap as uX,isDevEnv as O4,isTestEnv as F4}from"@excalidraw/common";import{orderByFractionalIndex as gX,syncInvalidIndices as H4,validateFractionalIndices as hX}from"@excalidraw/element";var fX=(e,t,o)=>!!(t&&(t.id===e.editingTextElement?.id||t.id===e.resizingElement?.id||t.id===e.newElement?.id||t.version>o.version||t.version===o.version&&t.versionNonce<o.versionNonce)),bX=pX((e,t,o)=>{if(O4()||F4()||window?.DEBUG_FRACTIONAL_INDICES){let n=H4(e.map(r=>({...r})));hX(n,{shouldThrow:F4()||O4(),includeBoundTextValidation:!0,reconciliationContext:{localElements:t,remoteElements:o}})}},1e3*60,{leading:!0,trailing:!1}),xX=(e,t,o)=>{let n=uX(e),r=[],i=new Set;for(let l of t)if(!i.has(l.id)){let s=n.get(l.id),c=fX(o,s,l);s&&c?(r.push(s),i.add(s.id)):(r.push(l),i.add(l.id))}for(let l of e)i.has(l.id)||(r.push(l),i.add(l.id));let a=gX(r);return bX(a,e,t),H4(a),a};import{getFreeDrawSvgPath as pNe}from"@excalidraw/element";import{isLinearElement as hNe}from"@excalidraw/element";import{FONT_FAMILY as bNe,THEME as xNe,MIME_TYPES as ENe,ROUNDNESS as xm,DEFAULT_LASER_COLOR as yNe,UserIdleState as wNe,normalizeLink as vNe}from"@excalidraw/common";import{mutateElement as ym,newElementWith as INe,bumpVersion as Ca}from"@excalidraw/element";import{CaptureUpdateAction as SNe}from"@excalidraw/element";import{sceneCoordsToViewportCoords as $2,viewportCoordsToSceneCoords as LNe}from"@excalidraw/common";import{jsx as z4,jsxs as EX}from"react/jsx-runtime";var G4=({children:e,icon:t})=>{let{TTDDialogTriggerTunnel:o}=Ne(),n=pe();return z4(o.In,{children:EX(Ie.Item,{onSelect:()=>{ae("ai","dialog open","ttd"),n({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:t??ph,children:[e??f("labels.textToDiagram"),z4(Ie.Item.Badge,{children:"AI"})]})})};G4.displayName="TTDDialogTrigger";import{getCommonBounds as UNe,getVisibleSceneBounds as YNe}from"@excalidraw/element";import{useLayoutEffect as yX}from"react";var wX=e=>{let t=Ke();return yX(()=>{t.setPlugins({diagramToCode:{generate:e.generate}})},[t,e.generate]),null};import{isElementLink as $Ne}from"@excalidraw/element";import{setCustomTextMetricsProvider as jNe}from"@excalidraw/element";import{ORIG_ID as CX,randomId as Y4,randomInteger as SX,arrayToMap as kX,castArray as Wx,findLastIndex as xc,getUpdatedTimestamp as MX,isTestEnv as LX}from"@excalidraw/common";import{arrayToMapWithIndex as vX}from"@excalidraw/common";var TX=e=>{let t=e.slice(),o=new Set,n=i=>{let a=i[0]?.groupIds?.join(""),l=[i[0]],s=[];for(let c of i.slice(1))c.groupIds?.join("")===a?l.push(c):s.push(c);return s.length?[...l,...n(s)]:l},r=new Map;return t.forEach((i,a)=>{if(!r.has(i.id))if(i.groupIds?.length){let l=i.groupIds[i.groupIds.length-1],s=t.slice(a).filter(c=>{let d=c?.groupIds?.some(m=>m===l);return d&&r.set(c.id,!0),d});for(let c of n(s))o.add(c)}else o.add(i)}),o.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...o]},IX=e=>{let t=vX(e),o=e.slice(),n=new Set;return o.forEach((r,i)=>{r&&(r.boundElements?.length?(n.add(r),o[i]=null,r.boundElements.forEach(a=>{let l=t.get(a.id);l&&a.type==="text"&&(n.add(l[0]),o[l[1]]=null)})):r.type==="text"&&r.containerId&&t.get(r.containerId)?.[0].boundElements?.find(l=>l.id===r.id)||(n.add(r),o[i]=null))}),n.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...n]},U4=e=>IX(TX(e));var W4=(e,t,o,n)=>{let r=PX(o);return LX()&&_X(r,o.id),r.id=Y4(),r.updated=MX(),n&&(r.seed=SX(),O3(r)),r.groupIds=v3(r.groupIds,e,i=>(t.has(i)||t.set(i,Y4()),t.get(i))),r},AX=e=>{let{elements:t}=e,o="appState"in e?e.appState:{editingGroupId:null,selectedGroupIds:{}},n=new Map,r=new Map,i=[],a=[],l=new Map,s=new Map,c=new Map,d=kX(t),m=e.type==="in-place"?e.idsOfElementsToDuplicate:new Map(t.map(x=>[x.id,x]));if(e.type==="in-place")for(let x of Object.keys(e.appState.selectedGroupIds))t.filter(w=>w.groupIds?.includes(x)).forEach(w=>m.set(w.id,w));t=U4(t);let p=t.slice(),u=x=>{let E=Wx(x).reduce((y,T)=>{if(n.has(T.id))return y;n.set(T.id,!0);let v=W4(o.editingGroupId,r,T,e.randomizeSeed);return n.set(v.id,!0),c.set(v.id,v),l.set(T.id,v.id),s.set(v.id,T),a.push(T),i.push(v),y.push(v),y},[]);return Array.isArray(x)?E:E[0]||null},g=(x,w)=>{if(w){if(x>p.length-1){p.push(...Wx(w));return}p.splice(x+1,0,...Wx(w))}},b=new Set(t.filter(x=>m.has(x.id)&&Uo(x)).map(x=>x.id));for(let x of t){if(n.has(x.id)||!m.has(x.id))continue;let w=w3(o,x);if(w){let E=y0(t,w).flatMap(T=>Uo(T)?[...Bs(t,T.id),T]:[T]),y=xc(p,T=>T.groupIds?.includes(w));g(y,u(E));continue}if(!(x.frameId&&b.has(x.frameId))){if(Uo(x)){let E=x.id,y=Bs(t,E),T=xc(p,v=>v.frameId===E||v.id===E);g(T,u([...y,x]));continue}if(Xm(x)){let E=jt(x,d),y=xc(p,T=>T.id===x.id||"containerId"in T&&T.containerId===x.id);E?g(y,u([x,E])):g(y,u(x));continue}if(Dn(x)){let E=Ha(x,d),y=xc(p,T=>T.id===x.id||T.id===E?.id);E?g(y,u([E,x])):g(y,u(x));continue}g(xc(p,E=>E.id===x.id),u(x))}}if(o3(i,l,c),T3(p,a,l),e.overrides)for(let x of i){let w=s.get(x.id);w&&Object.assign(x,e.overrides({duplicateElement:x,origElement:w,origIdToDuplicateId:l}))}return{duplicatedElements:i,duplicateElementsMap:c,elementsWithDuplicates:p,origIdToDuplicateId:l}},Vx=(e,t=0)=>{if(e==null||typeof e!="object")return e;let o=Object.prototype.toString.call(e);if(o==="[object Object]"){let n=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let r in e)if(e.hasOwnProperty(r)){if(t===0&&(r==="shape"||r==="canvas"))continue;n[r]=Vx(e[r],t+1)}return n}if(Array.isArray(e)){let n=e.length,r=new Array(n);for(;n--;)r[n]=Vx(e[n],t+1);return r}return I.DEV&&o!=="[object Object]"&&o!=="[object Array]"&&o.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${o}. This value will not be cloned!`),e},PX=e=>Vx(e),_X=(e,t)=>{Object.defineProperty(e,CX,{value:t,writable:!1,enumerable:!1})};import{parseMermaidToExcalidraw as tBe}from"@excalidraw/mermaid-to-excalidraw";import{jsx as Kx}from"react/jsx-runtime";B4();var BX=e=>{let{className:t,onChange:o,onIncrement:n,initialData:r,excalidrawAPI:i,isCollaborating:a=!1,onPointerUpdate:l,renderTopRightUI:s,langCode:c=Qo.code,viewModeEnabled:d,zenModeEnabled:m,gridModeEnabled:p,libraryReturnUrl:u,theme:g,name:b,renderCustomStats:x,onPaste:w,detectScroll:E=!0,handleKeyboardGlobally:y=!1,onLibraryChange:T,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:M,generateLinkForSelection:k,onPointerDown:P,onPointerUp:A,onScrollChange:R,onDuplicate:O,id:U,onHomeButtonClick:ee,children:_,validateEmbeddable:B,renderEmbeddable:j,aiEnabled:V,showDeprecatedFonts:Y,renderScrollbars:le,ui:xe,interactive:ue,activeTool:gt}=e,Ft=e.UIOptions?.canvasActions,_o={...e.UIOptions,canvasActions:{...V4.canvasActions,...Ft},tools:{image:e.UIOptions?.tools?.image??!0}};return Ft?.export&&(_o.canvasActions.export.saveFileToDisk=Ft.export?.saveFileToDisk??V4.canvasActions.export.saveFileToDisk),_o.canvasActions.toggleTheme===null&&typeof g>"u"&&(_o.canvasActions.toggleTheme=!0),RX(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let Zr=jr=>{typeof jr.scale=="number"&&jr.scale!==1&&jr.preventDefault()};return document.addEventListener("touchmove",Zr,{passive:!1}),()=>{document.removeEventListener("touchmove",Zr)}},[]),Kx(TE,{store:et,children:Kx(S4,{langCode:c,theme:g,children:Kx(C4,{id:U,className:t,onChange:o,onIncrement:n,initialData:r,excalidrawAPI:i,isCollaborating:a,onPointerUpdate:l,renderTopRightUI:s,langCode:c,viewModeEnabled:ue===!1?!0:d,zenModeEnabled:m,gridModeEnabled:p,libraryReturnUrl:u,theme:g,name:b,renderCustomStats:x,UIOptions:_o,onPaste:w,detectScroll:E,handleKeyboardGlobally:y,onLibraryChange:T,autoFocus:v,generateIdForFile:C,onLinkOpen:M,generateLinkForSelection:k,onPointerDown:P,onPointerUp:A,onScrollChange:R,onDuplicate:O,validateEmbeddable:B,renderEmbeddable:j,aiEnabled:V!==!1,showDeprecatedFonts:Y,renderScrollbars:le,onHomeButtonClick:ee,ui:xe,interactive:ue,activeTool:gt,children:_})})})},OX=(e,t)=>{if(e.children!==t.children)return!1;let{initialData:o,UIOptions:n={},...r}=e,{initialData:i,UIOptions:a={},...l}=t,s=Object.keys(n),c=Object.keys(a);return s.length!==c.length?!1:s.every(m=>m==="canvasActions"?Object.keys(n.canvasActions).every(u=>u==="export"&&n?.canvasActions?.export&&a?.canvasActions?.export?n.canvasActions.export.saveFileToDisk===a.canvasActions.export.saveFileToDisk:n?.canvasActions?.[u]===a?.canvasActions?.[u]):n[m]===a[m])&&NX(r,l)},FX=DX.memo(BX,OX);FX.displayName="Excalidraw";export{lo as Button,SNe as CaptureUpdateAction,i9 as CommandPalette,yNe as DEFAULT_LASER_COLOR,qp as DefaultSidebar,wX as DiagramToCodePlugin,Zl as Ellipsify,FX as Excalidraw,bNe as FONT_FAMILY,oX as Footer,rX as LiveCollaborationTrigger,ENe as MIME_TYPES,Mt as MainMenu,xm as ROUNDNESS,Mo as Sidebar,Qs as Stats,xNe as THEME,Mb as TTDDialog,G4 as TTDDialogTrigger,wNe as UserIdleState,cX as WelcomeScreen,W3 as actions,Ca as bumpVersion,Z4 as cleanAppStateForExport,$4 as clearAppStateForLocalStorage,Ja as convertToExcalidrawElements,Qo as defaultLang,W4 as duplicateElement,AX as duplicateElements,E3 as elementPartiallyOverlapsWithOrContainsBBox,y3 as elementsOverlappingBBox,Q2 as exportToBlob,jn as exportToCanvas,FD as exportToClipboard,La as exportToSvg,UNe as getCommonBounds,Vu as getDataURL,Jr as getDefaultAppState,pNe as getFreeDrawSvgPath,Sm as getLibraryItemsHash,ev as getNonDeletedElements,J9e as getSceneVersion,oNe as getTextFromElements,YNe as getVisibleSceneBounds,Q9e as hashElementsVersion,eNe as hashString,LE as icons,x0 as isElementInsideBBox,$Ne as isElementLink,rNe as isInvisiblySmallElement,hNe as isLinearElement,zi as languages,br as libraryItemsAtom,Lc as loadFromBlob,Wu as loadLibraryFromBlob,Yu as loadSceneOrLibraryFromBlob,cv as mergeLibraryItems,ym as mutateElement,INe as newElementWith,vNe as normalizeLink,s1 as parseLibraryTokensFromUrl,tBe as parseMermaidToExcalidraw,xX as reconcileElements,yl as restore,j4 as restoreAppState,Uu as restoreElements,wl as restoreLibraryItems,$2 as sceneCoordsToViewportCoords,bl as serializeAsJSON,Gu as serializeLibraryAsJSON,jNe as setCustomTextMetricsProvider,me as useDevice,t7 as useHandleLibrary,Je as useI18n,LNe as viewportCoordsToSceneCoords,Zy as zoomToFitBounds};
|