@excalidraw/excalidraw 0.18.0-298812e → 0.18.0-3085f4a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/dev/chunk-5EDE7GFX.js +5677 -0
  2. package/dist/dev/chunk-5EDE7GFX.js.map +7 -0
  3. package/dist/dev/chunk-CP5DND7P.js +7 -0
  4. package/dist/dev/chunk-CP5DND7P.js.map +7 -0
  5. package/dist/dev/{chunk-JCUIYZXF.js → chunk-QF5FRM6O.js} +6 -2
  6. package/dist/dev/chunk-QF5FRM6O.js.map +7 -0
  7. package/dist/dev/data/{image-CB4ZYE3A.js → image-7AP4KED2.js} +3 -3
  8. package/dist/dev/index.css +51 -20
  9. package/dist/dev/index.css.map +3 -3
  10. package/dist/dev/index.js +7101 -4376
  11. package/dist/dev/index.js.map +4 -4
  12. package/dist/dev/locales/{en-ZDTPSZNL.js → en-SMAPCEOQ.js} +2 -2
  13. package/dist/dev/subset-shared.chunk.js +1 -1
  14. package/dist/dev/subset-worker.chunk.js +1 -1
  15. package/dist/prod/chunk-A66AFZZU.js +7 -0
  16. package/dist/prod/{chunk-GCFVWREF.js → chunk-I4UNSFV6.js} +4 -4
  17. package/dist/prod/chunk-YHEOD47Q.js +4 -0
  18. package/dist/prod/data/image-G3CCQ4CB.js +1 -0
  19. package/dist/prod/index.css +1 -1
  20. package/dist/prod/index.js +25 -18
  21. package/dist/prod/locales/{en-MHZ26NAR.js → en-TYY6KWIJ.js} +1 -1
  22. package/dist/prod/subset-shared.chunk.js +1 -1
  23. package/dist/prod/subset-worker.chunk.js +1 -1
  24. package/dist/types/common/src/constants.d.ts +21 -3
  25. package/dist/types/common/src/utils.d.ts +3 -5
  26. package/dist/types/element/src/Scene.d.ts +7 -3
  27. package/dist/types/element/src/align.d.ts +2 -1
  28. package/dist/types/element/src/binding.d.ts +10 -7
  29. package/dist/types/element/src/bounds.d.ts +11 -3
  30. package/dist/types/element/src/collision.d.ts +18 -12
  31. package/dist/types/element/src/cropElement.d.ts +1 -1
  32. package/dist/types/element/src/delta.d.ts +41 -9
  33. package/dist/types/element/src/distance.d.ts +2 -2
  34. package/dist/types/element/src/distribute.d.ts +2 -1
  35. package/dist/types/element/src/fractionalIndex.d.ts +8 -2
  36. package/dist/types/element/src/frame.d.ts +2 -2
  37. package/dist/types/element/src/groups.d.ts +1 -0
  38. package/dist/types/element/src/index.d.ts +1 -3
  39. package/dist/types/element/src/linearElementEditor.d.ts +14 -23
  40. package/dist/types/element/src/mutateElement.d.ts +1 -1
  41. package/dist/types/element/src/newElement.d.ts +2 -1
  42. package/dist/types/element/src/resizeElements.d.ts +1 -0
  43. package/dist/types/element/src/selection.d.ts +1 -1
  44. package/dist/types/element/src/shape.d.ts +42 -0
  45. package/dist/types/element/src/sizeHelpers.d.ts +2 -1
  46. package/dist/types/element/src/store.d.ts +19 -9
  47. package/dist/types/element/src/transformHandles.d.ts +4 -4
  48. package/dist/types/element/src/typeChecks.d.ts +15 -1
  49. package/dist/types/element/src/types.d.ts +8 -3
  50. package/dist/types/element/src/utils.d.ts +16 -6
  51. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +21 -15
  52. package/dist/types/excalidraw/actions/actionAlign.d.ts +8 -8
  53. package/dist/types/excalidraw/actions/actionBoundText.d.ts +14 -10
  54. package/dist/types/excalidraw/actions/actionCanvas.d.ts +195 -155
  55. package/dist/types/excalidraw/actions/actionClipboard.d.ts +50 -36
  56. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +7 -5
  57. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +27 -20
  58. package/dist/types/excalidraw/actions/actionDistribute.d.ts +4 -4
  59. package/dist/types/excalidraw/actions/actionDuplicateSelection.d.ts +2 -2
  60. package/dist/types/excalidraw/actions/actionElementLink.d.ts +6 -4
  61. package/dist/types/excalidraw/actions/actionElementLock.d.ts +29 -26
  62. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +7 -5
  63. package/dist/types/excalidraw/actions/actionExport.d.ts +147 -129
  64. package/dist/types/excalidraw/actions/actionFinalize.d.ts +65 -20
  65. package/dist/types/excalidraw/actions/actionFlip.d.ts +4 -4
  66. package/dist/types/excalidraw/actions/actionFrame.d.ts +78 -70
  67. package/dist/types/excalidraw/actions/actionGroup.d.ts +20 -16
  68. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +533 -7
  69. package/dist/types/excalidraw/actions/actionLink.d.ts +8 -6
  70. package/dist/types/excalidraw/actions/actionMenu.d.ts +22 -16
  71. package/dist/types/excalidraw/actions/actionNavigate.d.ts +14 -10
  72. package/dist/types/excalidraw/actions/actionProperties.d.ts +119 -81
  73. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +10 -8
  74. package/dist/types/excalidraw/actions/actionStyles.d.ts +11 -9
  75. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +9 -7
  76. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +9 -7
  77. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +8 -6
  78. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +9 -7
  79. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +9 -7
  80. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +9 -7
  81. package/dist/types/excalidraw/actions/actionZindex.d.ts +8 -8
  82. package/dist/types/excalidraw/actions/types.d.ts +2 -1
  83. package/dist/types/excalidraw/appState.d.ts +29 -20
  84. package/dist/types/excalidraw/components/Actions.d.ts +0 -4
  85. package/dist/types/excalidraw/components/App.d.ts +19 -16
  86. package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
  87. package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
  88. package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
  89. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +11 -1
  90. package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
  91. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +1 -0
  92. package/dist/types/excalidraw/components/icons.d.ts +2 -0
  93. package/dist/types/excalidraw/components/shapes.d.ts +129 -1
  94. package/dist/types/excalidraw/data/blob.d.ts +1 -1
  95. package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
  96. package/dist/types/excalidraw/data/restore.d.ts +6 -1
  97. package/dist/types/excalidraw/eraser/index.d.ts +0 -2
  98. package/dist/types/excalidraw/history.d.ts +21 -5
  99. package/dist/types/excalidraw/index.d.ts +2 -1
  100. package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
  101. package/dist/types/excalidraw/renderer/helpers.d.ts +4 -4
  102. package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
  103. package/dist/types/excalidraw/scene/Renderer.d.ts +0 -1
  104. package/dist/types/excalidraw/types.d.ts +17 -8
  105. package/dist/types/math/src/angle.d.ts +2 -0
  106. package/dist/types/math/src/constants.d.ts +3 -0
  107. package/dist/types/math/src/curve.d.ts +32 -0
  108. package/dist/types/math/src/index.d.ts +1 -0
  109. package/dist/types/math/src/point.d.ts +1 -1
  110. package/dist/types/math/src/rectangle.d.ts +2 -0
  111. package/dist/types/math/src/vector.d.ts +4 -2
  112. package/history.ts +107 -44
  113. package/package.json +13 -10
  114. package/dist/dev/chunk-JCUIYZXF.js.map +0 -7
  115. package/dist/dev/chunk-RQWTCZLD.js +0 -7
  116. package/dist/dev/chunk-RQWTCZLD.js.map +0 -7
  117. package/dist/dev/chunk-ZPGIVNNG.js +0 -23482
  118. package/dist/dev/chunk-ZPGIVNNG.js.map +0 -7
  119. package/dist/prod/chunk-7TMLMBQX.js +0 -7
  120. package/dist/prod/chunk-WFJFO6F4.js +0 -33
  121. package/dist/prod/data/image-XJI4SWH2.js +0 -1
  122. package/dist/types/element/src/Shape.d.ts +0 -17
  123. package/dist/types/element/src/ShapeCache.d.ts +0 -25
  124. package/dist/types/element/src/shapes.d.ts +0 -23
  125. package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
  126. package/dist/types/excalidraw/visualdebug.d.ts +0 -41
  127. package/dist/types/utils/src/collision.d.ts +0 -8
  128. /package/dist/dev/data/{image-CB4ZYE3A.js.map → image-7AP4KED2.js.map} +0 -0
  129. /package/dist/dev/locales/{en-ZDTPSZNL.js.map → en-SMAPCEOQ.js.map} +0 -0
@@ -1,26 +1,33 @@
1
- import{$ as Rf,$a as np,$b as Za,$c as S1,$d as Ks,$e as wp,$f as Sb,$g as bc,A as Sf,Aa as Ga,Ab as bi,Ac as Fs,Ad as ja,Ae as Oo,Af as bb,Ag as Bp,Ah as l0,B as Zm,Ba as gr,Bb as _o,Bc as ae,Bd as Ws,Be as ne,Bf as xb,Bg as Gb,Bh as wc,C as we,Ca as _t,Cb as o1,Cc as fe,Cd as up,Ce as Er,Cf as Eb,Cg as pc,Ch as s0,D as Xo,Da as ks,Db as r1,Dc as Re,Dd as a5,De as sb,Df as Mp,Dg as Vb,Dh as c0,E as Mn,Ea as je,Eb as Pn,Ec as le,Ed as l5,Ee as Un,Ef as ac,Eg as Kn,Eh as d0,F as Ba,Fa as Hr,Fb as De,Fc as g1,Fd as s5,Fe as Js,Ff as lc,Fg as er,Fh as sl,G as Rt,Ga as Yf,Gb as R,Gc as br,Gd as G1,Ge as Qs,Gf as sc,Gg as Yb,Gh as Zp,H as dt,Ha as Wa,Hb as Fe,Hc as f1,Hd as nt,He as qa,Hf as Vn,Hg as Ri,Hh as m0,I as re,Ia as Vt,Ib as It,Ic as b1,Id as Vs,Ie as ec,If as yb,Ig as Kb,Ih as p0,J as At,Ja as mt,Jb as Ka,Jc as xr,Jd as Ro,Je as Ja,Jf as Kt,Jg as Hp,Jh as u0,K as hr,Ka as Kf,Kb as Gr,Kc as x1,Kd as W1,Ke as Zr,Kf as Lp,Kg as Qr,Kh as h0,L as zr,La as Zf,Lb as Ds,Lc as Hs,Ld as V1,Le as cb,Lf as vb,Lg as en,M as xs,Ma as Ao,Mb as n1,Mc as ut,Md as Ii,Me as Xr,Mf as Ai,Mg as Zt,N as Xm,Na as Xf,Nb as Rn,Nc as tt,Nd as $e,Ne as $r,Nf as rl,Ng as Bo,O as Es,Oa as se,Ob as i1,Oc as E1,Od as Y1,Oe as jr,Of as Ot,Og as Ni,P as Mf,Pa as y,Pb as a1,Pc as Yr,Pd as K1,Pe as Ep,Pf as wb,Pg as uc,Q as Fa,Qa as Ss,Qb as l1,Qc as y1,Qd as Z1,Qe as yp,Qf as Tb,Qg as Up,R as Lf,Ra as Ln,Rb as s1,Rc as v1,Rd as hp,Re as tc,Rf as bo,Rg as nl,S as Af,Sa as op,Sb as J,Sc as zn,Sd as X1,Se as oc,Sf as Jr,Sg as hc,T as $m,Ta as hi,Tb as c1,Tc as w1,Td as Kr,Te as X,Tf as cc,Tg as Gp,U as Ha,Ua as Ms,Ub as jo,Uc as wi,Ud as $1,Ue as yr,Uf as Ap,Ug as Wp,V as ce,Va as Et,Vb as pt,Vc as T1,Vd as j1,Ve as db,Vf as Yn,Vg as Zb,W as _f,Wa as ho,Wb as d1,Wc as C1,Wd as gp,We as mb,Wf as Cb,Wg as Xb,X as ys,Xa as $f,Xb as Ps,Xc as I1,Xd as Ne,Xe as Qa,Xf as _i,Xg as $b,Y as Br,Ya as rp,Yb as xi,Yc as pp,Yd as j,Ye as qr,Yf as _p,Yg as gc,Z as Df,Za as gi,Zb as m1,Zc as k1,Zd as Ys,Ze as el,Zf as Ib,Zg as il,_ as Pf,_a as fi,_b as Wr,_c as Bn,_d as Ce,_e as vp,_f as kb,_g as fc,a as ps,aa as Nf,ab as Ls,ac as rt,ad as M1,ae as q1,af as Tp,ag as Mb,ah as jb,b as gf,ba as Of,bb as ip,bc as Vr,bd as Xa,be as fp,bf as Cp,bg as Lb,bh as qb,c as kn,ca as ui,cb as ap,cc as Ei,cd as L1,ce as J1,cf as Mi,cg as Ab,ch as al,d as ff,da as jm,db as jf,dc as dp,dd as A1,de as No,df as ht,dg as Dp,dh as Jb,e as bf,ea as qm,eb as lp,ec as p1,ed as vt,ee as Q1,ef as rc,eg as _b,eh as Qb,f as xf,fa as zf,fb as L,fc as Rs,fd as _1,fe as eb,ff as Te,fg as Db,fh as e0,g as uo,ga as Bf,gb as Oe,gc as Yt,gd as D1,ge as ki,gf as nc,gg as Pb,gh as xc,h as us,ha as vs,hb as An,hc as yi,hd as P1,he as tb,hf as vr,hg as Rb,hh as Oi,i as hs,ia as ws,ib as As,ic as He,id as Fn,ie as Hn,if as Ip,ig as Di,ih as t0,j as gs,ja as Jm,jb as _s,jc as u1,jd as R1,je as ob,jf as Gn,jg as Nb,jh as Vp,k as Ef,ka as Ff,kb as qf,kc as h1,kd as N1,ke as Si,kf as tl,kg as dc,kh as m5,l as yf,la as Hf,lb as Jf,lc as Ns,ld as i5,le as Zs,lf as Li,lg as Ob,lh as zi,m as vf,ma as Uf,mb as to,mc as mp,md as O1,me as rb,mf as kp,mg as zb,mh as ll,n as wf,na as Gf,nb as Va,nc as Os,nd as Ti,ne as Xs,nf as pb,ng as mc,o as Lo,oa as Ts,ob as Ya,oc as Nn,od as Ye,oe as qo,of as ub,og as Pp,oh as o0,p as fs,pa as Fr,pb as Qf,pc as Do,pd as z1,pe as bp,pf as Wn,pg as Rp,q as ur,qa as Wf,qb as yt,qc as Po,qd as Us,qe as xp,qf as zo,qg as Np,qh as r0,r as Tf,ra as Qm,rb as sp,rc as zs,rd as $a,re as nb,rf as A,rg as Pi,rh as n0,s as Cf,sa as ep,sb as Ur,sc as Bs,sd as Ee,se as $s,sf as hb,sg as Bb,sh as Ec,t as If,ta as Vf,tb as e1,tc as go,td as fo,te as js,tf as gb,tg as Fb,th as i0,u as Oa,ua as Cs,ub as cp,uc as fr,ud as Gs,ue as ib,uf as Sp,ug as Hb,uh as yc,v as za,va as tp,vb as t1,vc as Me,vd as B1,ve as ab,vf as fb,vg as Ub,vh as Yp,w as Sn,wa as Wt,wb as $o,wc as Nt,wd as F1,we as lb,wf as ic,wg as d5,wh as vc,x as bs,xa as Ua,xb as _n,xc as On,xd as H1,xe as c5,xf as Qo,xg as Op,xh as a0,y as kf,ya as xt,yb as qe,yc as vi,yd as U1,ye as Jo,yf as wr,yg as zp,yh as Kp,z as Km,za as Is,zb as Dn,zc as Y,zd as Ci,ze as qs,zf as ol,zg as ue,zh as Tr}from"./chunk-WFJFO6F4.js";import{a as C}from"./chunk-7TMLMBQX.js";import{J as Fp}from"./chunk-GCFVWREF.js";import{c as Wb}from"./chunk-Z3N5DIM6.js";import{b as uf,c as hf,d as I}from"./chunk-SRAX5OIU.js";import E7,{useEffect as y7}from"react";import z3 from"clsx";import Z8 from"lodash.throttle";import pr,{useContext as Cn}from"react";import{flushSync as Nr}from"react-dom";import X8 from"roughjs/bin/rough";import{nanoid as $8}from"nanoid";import{atom as Ie,createStore as p5}from"jotai";import{createIsolation as u5}from"jotai-scope";var g0=u5();var{useAtom:he,useSetAtom:tn,useAtomValue:Tc,useStore:k7}=g0,f0=g0.Provider,it=p5();var h5=uf({"./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-MHZ26NAR.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 g5=85,tr={code:"en",label:"English"},Fi=[tr,...[{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=>Wb[e.code]>=g5).sort((e,o)=>e.label>o.label?1:-1)],Ic="__test__";pt()&&Fi.unshift({code:Ic,label:"test language"},{code:`${Ic}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Bi=tr,Cc={},kc=async e=>{if(Bi=e,document.documentElement.dir=Bi.rtl?"rtl":"ltr",document.documentElement.lang=Bi.code,e.code.startsWith(Ic))Cc={};else try{Cc=await h5(`./locales/${Bi.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Cc=Fp}it.set(x0,e.code)},Cr=()=>Bi,b0=(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},g=(e,o,t)=>{if(Bi.code.startsWith(Ic))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=b0(Cc,r)||b0(Fp,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(C.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},x0=Ie(tr.code),ot=()=>{let e=Tc(x0);return{t:g,langCode:e}};import f5 from"clsx";import b5 from"open-color";import kt from"react";import{Fragment as Pe,jsx as h,jsxs as N}from"react/jsx-runtime";var Fo=e=>"var(--icon-fill-color)",E0=e=>e===re.LIGHT?b5.white:"#1e1e1e",_=(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:f5({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},G={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},ie={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},G7=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),G),Hi=_(N("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"})]}),G),y0=_(N("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),G),v0=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),G),w0=_(N("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),G),Zn=_(N("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),ie),Ui=_(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),ie),T0=_(N(Pe,{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"}),C0=_(N(Pe,{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"}),I0=_(N(Pe,{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"}),W7=_(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"}),k0=_(N("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}),cl=_(N("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}),Sc=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),G),Mc=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),G),Lc=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),G),S0=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),G),Ac=_(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),ie),M0=_(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),G),on=_(N("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),ie),Gi=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),G),L0=_(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),ie),A0=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),G),Xp=_(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),ie),$p=_(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),ie),_0=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),h("path",{d:"M3 4v4h4"})]}),G),oo=_(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),ie),jp=_(N("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),ie),dl=_(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),ie),ml=_(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),ie),pl=_(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...ie,strokeWidth:1.5}),_c=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),G),Xn=_(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),ie),Wi=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),G),D0=_(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),G),qp=_(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),ie),Dc=_(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),ie),P0=_(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),ie),R0=_(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),G),N0=_(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),ul=_(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),ie),O0=_("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}),z0=_("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}),Vi=_(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),ie),V7=_("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}),B0=_("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"),Pc=_(N("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"})]}),G),F0=_(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),G),Rc=_(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),G),H0=_("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}),Y7=_("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}),K7=_("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}),U0=_("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"),Z7=_("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"),Jp=_(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),ie),Qp=_(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),ie),G0=_("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}),W0=_(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),ie),X7=_("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"),$7=_("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}),j7=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),G),q7=_(N(Pe,{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}),J7=_(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}),V0=N("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"})]}),Y0=N("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"})]}),eu=_(Y0,G),tu=_(Y0,{...G,style:{transform:"rotate(180deg)"}}),ou=_(V0,G),ru=_(V0,{...G,style:{transform:"rotate(180deg)"}}),nu=_(N(Pe,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),iu=_(N(Pe,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),au=_(N(Pe,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),lu=_(N(Pe,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),K0=_(N(Pe,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),Z0=_(N(Pe,{children:[N("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),su=_(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),ie),cu=_(N("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),ie),Nc=_(N("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),G),Q7=_("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"),eL=_("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"),xo=_(N(Pe,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),tL=_("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}),oL=_("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}),rL=_("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}),du=kt.memo(({theme:e})=>_(N(Pe,{children:[h("path",{d:"M25 26H111V111H25",fill:Fo(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:Fo(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Fo(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:Fo(e),strokeWidth:"2"}),N("g",{fill:E0(e),stroke:Fo(e),strokeWidth:"6",children:[h("rect",{x:"2.5",y:"2.5",width:"30",height:"30"}),h("rect",{x:"2.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"149.5",width:"30",height:"30"}),h("rect",{x:"147.5",y:"2.5",width:"30",height:"30"})]})]}),{width:182,height:182,mirror:!0})),mu=kt.memo(({theme:e})=>_(N(Pe,{children:[h("path",{d:"M25 26H111V111H25",fill:Fo(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:Fo(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Fo(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:Fo(e),strokeWidth:"2"}),N("g",{fill:E0(e),stroke:Fo(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})),X0=_(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),ie),$0=_(N(Pe,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),ie),j0=_(N(Pe,{children:[N("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),q0=_(N(Pe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...ie,fill:"currentColor"}),pu=_(h(Pe,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ie),J0=_(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),ie),Q0=_(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),ie),nL=kt.memo(({theme:e})=>_(h("path",{d:"M6 10H34",stroke:Fo(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),ex=_(N("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),G),tx=_(N("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),G),ox=_(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),ie),rx=_(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),ie),nx=_(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),ie),ix=_(N("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),ie),ax=_(N("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),G),lx=_(N("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"})]}),G),sx=kt.memo(({flip:e=!1})=>_(N("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})),cx=kt.memo(({flip:e=!1})=>_(N("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})),dx=kt.memo(({flip:e=!1})=>_(N("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})),mx=kt.memo(({flip:e=!1})=>_(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})),px=kt.memo(({flip:e=!1})=>_(N("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})),ux=kt.memo(({flip:e=!1})=>_(N("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})),hx=kt.memo(({flip:e=!1})=>_(N("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})),gx=kt.memo(({flip:e=!1})=>_(N("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})),fx=kt.memo(({flip:e=!1})=>_(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})),bx=kt.memo(({flip:e=!1})=>_(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})),xx=kt.memo(({flip:e=!1})=>_(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})),Ex=_(N(Pe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),yx=_(N(Pe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),vx=_(N(Pe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),ie),wx=_(h(Pe,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),ie),$n=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),G),Tx=_(h(Pe,{children:N("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),G),hl=_(h(Pe,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),ie),Oc=_(N(Pe,{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"})})})]}),ie),Cx=_(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),G),Ix=_(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),G),kx=_(N("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),G),Sx=kt.memo(({theme:e})=>_(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),G)),Mx=kt.memo(({theme:e})=>_(N("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),G)),Lx=kt.memo(({theme:e})=>_(N("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),G)),zc=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),G),Ax=_(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}),iL=_(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"})),Bc=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),G),uu=_(N(Pe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),G),Yi=_(N(Pe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),G),_x=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),G),Dx=_(N(Pe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),G),aL=_(N(Pe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),G),lL=_(N(Pe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),G),Px=_(N(Pe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),G),Rx=_(N(Pe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),G),Nx=_(N("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"})]}),G),Ox=_(N("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"})]}),G),jn=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),G),Fc=_(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"})),Ki=_(N("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),ie),gl=_(N("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),Hc=_(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),G),sL=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),G),cL=_(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),G),zx=_(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),G),Zi=_(N("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),G),Bx=_(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),h("path",{d:"M3 3l18 18"})]}),G),Fx=_(N("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),G),Hx=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),G),ro=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),G),Ux=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),G),Gx=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),G),Wx=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),G),fl=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),G),Vx=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),G),Yx=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),G),Kx=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),G),Zx=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),G),hu=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),G),Uc=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),G),Xx=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),G),$x=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),G),jx=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),G),qx=_(N("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),G),Jx=_(N("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...G,strokeWidth:1.5}),dL=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),G),Qx=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),G),eE=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),G),tE=_(N("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),G),Gc=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),G),Wc=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),G),Vc=_(N("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),G),Yc=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),G),oE=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),G),rE=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),G),gu=_(N("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),G),Kc=_(N("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),G);import nE from"clsx";import bu,{useEffect as y5,useRef as iE,useState as v5}from"react";import x5 from"react";import{jsx as fu}from"react/jsx-runtime";var E5=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(x5.useRef(Date.now()).current%1600);return fu("div",{className:`Spinner ${r}`,children:fu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:fu("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},St=E5;import{jsx as bl,jsxs as xl}from"react/jsx-runtime";var $=bu.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=at(),a=bu.useRef(null);bu.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=v5(!1),m=iE(!0),d=async u=>{let f="onClick"in r&&r.onClick?.(u);if(Wr(f))try{c(!0),await f}catch(b){if(b instanceof Ri)console.warn(b);else throw b}finally{m.current&&c(!1)}};y5(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=iE(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return xl("button",{className:nE("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)&&xl("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&bl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&bl(St,{})]}),r.showAriaLabel&&xl("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&bl(St,{})]}),r.children]})}return xl("label",{className:nE("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[bl("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}),xl("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&bl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});$.displayName="ToolButton";var Zc=[],z=e=>(Zc=Zc.concat(e),e);import{jsx as T5}from"react/jsx-runtime";var w5=(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=No(e,m);for(let p of d)if(!a.has(p.id)){if(tt(p)){let u=fo(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=tt(m)?fo(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&&le(u)&&t.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),ne(m,{isDeleted:!0}))}return m.frameId&&r.has(m.frameId)?(l=!1,tt(m)||(n[m.id]=!0),ne(m,{frameId:null})):tt(m)&&o.selectedElementIds[m.containerId]?ne(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=$e(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(f=>f===o.editingGroupId),u=d.groupIds[p+1];if(u){let f=$e(s,u).filter(b=>!b.isDeleted);f.length>1&&(c=u,f.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...nt({selectedElementIds:n,editingGroupId:c},s,o,null)}}},aE=(e,o)=>{if(e.editingGroupId){let t=$e(ue(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},El=z({name:"deleteSelectedElements",label:"labels.delete",icon:oo,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=X.getElement(a,m);if(!d||l==null)return!1;if(d.points.length<2){let u=e.map(b=>b.id===d.id?ne(b,{isDeleted:!0}):b),f=aE(o,u);return{elements:u,appState:{...f,editingLinearElement:null},captureUpdate:A.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:c};return X.deletePoints(d,r.scene,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}=w5(e,o,r);return tc(n,n.filter(a=>a.isDeleted)),i=aE(i,n),{elements:n,appState:{...i,activeTool:De(o,{type:"selection"}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ne(ue(e),o)?A.IMMEDIATELY:A.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===y.BACKSPACE||e.key===y.DELETE)&&!e[y.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>T5($,{type:"button",icon:oo,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:Ne(ue(e),o)})});import{jsx as Xc}from"react/jsx-runtime";var xu=z({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:tu,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Bb(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[y.CTRL_OR_CMD]&&!e.shiftKey&&e.code===se.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Xc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${R("CtrlOrCmd+[")}`,children:tu})}),Eu=z({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:eu,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Fb(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[y.CTRL_OR_CMD]&&!e.shiftKey&&e.code===se.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Xc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${R("CtrlOrCmd+]")}`,children:eu})}),yu=z({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:ru,trackEvent:{category:"element"},perform:(e,o)=>({elements:Hb(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Lo?e[y.CTRL_OR_CMD]&&e.altKey&&e.code===se.BRACKET_LEFT:e[y.CTRL_OR_CMD]&&e.shiftKey&&e.code===se.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>Xc("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${Lo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")}`,children:ru})}),vu=z({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:ou,trackEvent:{category:"element"},perform:(e,o)=>({elements:Ub(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Lo?e[y.CTRL_OR_CMD]&&e.altKey&&e.code===se.BRACKET_RIGHT:e[y.CTRL_OR_CMD]&&e.shiftKey&&e.code===se.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>Xc("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${Lo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")}`,children:ou})});var wu=z({name:"selectAll",label:"labels.selectAll",icon:Vx,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.editingLinearElement)return!1;let n=e.filter(i=>!i.isDeleted&&!(Y(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...nt({editingGroupId:null,selectedElementIds:n},ue(e),o,r),selectedLinearElement:Object.keys(n).length===1&&fe(e[0])?new X(e[0],J(e)):null},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[y.CTRL_OR_CMD]&&e.key===y.A});import{jsx as C5}from"react/jsx-runtime";var Tu=z({name:"duplicateSelection",label:"labels.duplicateSelection",icon:dl,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.editingLinearElement)try{let a=X.duplicateSelectedPoints(o,r.scene);return{elements:e,appState:a,captureUpdate:A.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:i}=Wn({type:"in-place",elements:e,idsOfElementsToDuplicate:J(j(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+$m/2,y:a.y+$m/2,frameId:s??a.frameId}}});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:Qo(i,J(n)),appState:{...o,...Ks(n,ue(i),o)},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[y.CTRL_OR_CMD]&&e.key===y.D,PanelComponent:({elements:e,appState:o,updateData:t})=>C5($,{type:"button",icon:dl,title:`${g("labels.duplicateSelection")} \u2014 ${R("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:Ne(ue(e),o)})});import{useEffect as Vu,useMemo as Q6,useRef as Yu,useState as e4}from"react";var I5=new Set(["command_palette","export"]),de=(e,o,t,r)=>{try{if(typeof window>"u"||C.VITE_WORKER_ID||C.VITE_APP_ENABLE_TRACKING!=="true"||!I5.has(e)||pt())return;C.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 L5 from"clsx";import k5 from"clsx";import{forwardRef as S5}from"react";import{jsx as M5}from"react/jsx-runtime";var $c=S5((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return M5("button",{type:"button",ref:o,title:t,"data-testid":n,className:k5(r,{standalone:a,active:i}),onClick:s,children:l},t)});import{jsx as Cu,jsxs as A5}from"react/jsx-runtime";var Eo=e=>Cu("div",{className:"buttonList",children:e.options.map(o=>e.type==="button"?Cu($c,{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):A5("label",{className:L5({active:e.value===o.value}),title:o.text,children:[Cu("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 td from"@radix-ui/react-popover";import g6 from"clsx";import{useRef as f6}from"react";import{jsx as _5}from"react/jsx-runtime";var jc=()=>_5("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as N5,useRef as O5}from"react";import{createPortal as z5}from"react-dom";import lE from"react";var Iu=lE.createContext(null),Le=()=>lE.useContext(Iu);import{useState as D5,useLayoutEffect as sE}from"react";var qc=e=>{let[o,t]=D5(null),r=be(),{theme:n}=Le(),{container:i}=at();return sE(()=>{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===re.DARK))},[o,n,r.editor.isMobile,e?.className]),sE(()=>{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 P5}from"react";function Xi(e,o,t){P5(()=>{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 R5}from"react";var rn=e=>{let o=R5(e);return Object.assign(o.current,e),o.current};import{jsx as B5}from"react/jsx-runtime";var nn=Ie(null),cE=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=qc({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Le(),a=an(),l=Je(),s=j(a,i),c=rn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=at();N5(()=>{let p=d.current;if(!p||!l.canvas||!n)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:k,clientY:D})=>{let M=f.getImageData((k-i.offsetLeft)*window.devicePixelRatio,(D-i.offsetTop)*window.devicePixelRatio,1,1).data;return wf(M[0],M[1],M[2])},x=({clientX:k,clientY:D,altKey:M})=>{p.style.top=`${D+20}px`,p.style.left=`${k+20}px`;let O=b({clientX:k,clientY:D});u&&c.onChange(r,O,c.selectedElements,{altKey:M}),p.style.background=O},E=()=>{c.onCancel()},w=(k,D)=>{c.onSelect(k,D)},v=k=>{u=!0,k.stopImmediatePropagation()},T=k=>{u=!1,m?.focus(),k.stopImmediatePropagation(),k.preventDefault(),w(b(k),k)},S=k=>{k.key===y.ESCAPE&&(k.preventDefault(),k.stopImmediatePropagation(),E())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",S),n.addEventListener("pointerdown",v),n.addEventListener("pointerup",T),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener("blur",E),()=>{u=!1,n.removeEventListener("keydown",S),n.removeEventListener("pointerdown",v),n.removeEventListener("pointerup",T),window.removeEventListener("pointermove",x),window.removeEventListener("blur",E)}},[c,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let d=O5(null);return Xi(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?z5(B5("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import*as $i from"@radix-ui/react-popover";import G5 from"clsx";import W5 from"react";import F5 from"react";import H5 from"clsx";import{jsx as U5}from"react/jsx-runtime";var gt=F5.forwardRef(({children:e,padding:o,className:t,style:r},n)=>U5("div",{className:H5("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as ku,jsxs as V5}from"react/jsx-runtime";var Jc=W5.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},c)=>{let m=be();return ku($i.Portal,{container:o,children:V5($i.Content,{ref:c,className:G5("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&&!t1(document.activeElement)&&o.focus(),n()},children:[ku(gt,{padding:3,style:r,children:t}),ku($i.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import Y5 from"clsx";import{useCallback as K5,useEffect as Mu,useRef as pE,useState as Z5}from"react";var ln=({palette:e,color:o})=>{if(!o)return null;for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},yl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Su=({color:e,palette:o})=>!Object.values(o).flat().includes(e),mE=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return Su({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,gf)},vo=Ie(null),dE=(e,o,t)=>(e*299+o*587+t*114)/1e3,ji=(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 dE(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 dE(t,r,n)<o};import{Fragment as X5,jsx as Qc,jsxs as uE}from"react/jsx-runtime";var hE=({color:e,onChange:o,label:t,colorPickerType:r,placeholder:n})=>{let i=be(),[a,l]=Z5(e),[s,c]=he(vo);Mu(()=>{l(e)},[e]);let m=K5(b=>{let x=b.toLowerCase(),E=gE(x);E&&o(E),l(x)},[o]),d=pE(null),p=pE(null);Mu(()=>{d.current&&d.current.focus()},[s]);let[u,f]=he(nn);return Mu(()=>()=>{f(null)},[f]),uE("div",{className:"color-picker__input-label",children:[Qc("div",{className:"color-picker__input-hash",children:"#"}),Qc("input",{ref:s==="hex"?d:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{m(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>c("hex"),onKeyDown:b=>{b.key!==y.TAB&&(b.key===y.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:n}),!i.editor.isMobile&&uE(X5,{children:[Qc("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Qc("div",{ref:p,className:Y5("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:r}),title:`${g("labels.eyeDropper")} \u2014 ${y.I.toLocaleUpperCase()} or ${R("Alt")} `,children:Nx})]})]})};import Du,{useEffect as Pu,useImperativeHandle as p6,useState as u6}from"react";import q5 from"clsx";import{useEffect as J5,useRef as Q5}from"react";import{jsxs as j5}from"react/jsx-runtime";var $5=({color:e,keyLabel:o,isShade:t=!1})=>j5("div",{className:"color-picker__button__hotkey-label",style:{color:ji(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),qi=$5;import{jsx as Lu,jsxs as e6}from"react/jsx-runtime";var fE=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=he(vo),a=Q5(null);return J5(()=>{a.current&&a.current.focus()},[o,n]),Lu("div",{className:"color-picker-content--default",children:e.map((l,s)=>e6("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:q5("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:[Lu("div",{className:"color-picker__button-outline"}),Lu(qi,{color:l,keyLabel:s+1})]},s))})};import t6 from"clsx";import{useEffect as o6,useRef as r6}from"react";import{jsx as Au,jsxs as i6}from"react/jsx-runtime";var n6=({palette:e,color:o,onChange:t,activeShade:r})=>{let n=ln({color:o,palette:e}),[i,a]=he(vo),l=r6(null);return o6(()=>{l.current&&i==="baseColors"&&l.current.focus()},[n?.colorName,i]),Au("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,c],m)=>{let d=(Array.isArray(c)?c[r]:c)||"transparent",p=yl[m],u=g(`colors.${s.replace(/\d+/,"")}`,null,"");return i6("button",{ref:n?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:t6("color-picker__button color-picker__button--large has-outline",{active:n?.colorName===s,"is-transparent":d==="transparent"||!d}),onClick:()=>{t(d),a("baseColors")},title:`${u}${d.startsWith("#")?` ${d}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:d?{"--swatch-color":d}:void 0,"data-testid":`color-${s}`,children:[Au("div",{className:"color-picker__button-outline"}),Au(qi,{color:d,keyLabel:p})]},s)})})},bE=n6;import{jsx as l6}from"react/jsx-runtime";var a6=({children:e})=>l6("div",{className:"color-picker__heading",children:e}),Ji=a6;import s6 from"clsx";import{useEffect as c6,useRef as d6}from"react";import{jsx as vl,jsxs as xE}from"react/jsx-runtime";var EE=({color:e,onChange:o,palette:t})=>{let r=ln({color:e||"transparent",palette:t}),[n,i]=he(vo),a=d6(null);if(c6(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,c=t[l];if(Array.isArray(c))return vl("div",{className:"color-picker-content--default shades",children:c.map((m,d)=>xE("button",{ref:d===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:s6("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:[vl("div",{className:"color-picker__button-outline"}),vl(qi,{color:m,keyLabel:d+1,isShade:!0})]},d))})}return xE("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:g("colorPicker.noShades")})]})};var _u=(e,o,t)=>{let r=Math.ceil(t/kn);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+kn;return n>=t?o%kn:n}case"ArrowUp":{let n=o-kn,i=n<0?kn*r+n:n;return i>=t?void 0:i}}},m6=({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(yl.includes(e.key)){let l=yl.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},yE=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[y.CTRL_OR_CMD])return!1;if(e.key===y.ESCAPE)return m(e),!0;if(e.key===y.ALT)return c(!0),!0;if(e.key===y.I)return c(),!0;let d=ln({color:r,palette:t});if(e.key===y.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((w,[v,T])=>(T&&w.push(v),w),[]),f=u.indexOf(o),b=e.shiftKey?-1:1,x=f+b>u.length-1?0:f+b<0?u.length-1:f+b,E=u[x];return E&&a(E),E==="custom"?n(i[0]):E==="baseColors"&&(Object.entries(t).find(([v,T])=>Array.isArray(T)?T.includes(r):T===r?v:null)||n(uo.black)),e.preventDefault(),e.stopPropagation(),!0}if(m6({e,colorObj:d,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&d){let{shade:p}=d,u=_u(e.key,p,kn);if(u!==void 0)return n(t[d.colorName][u]),!0}if(o==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(t),f=u.indexOf(p),b=_u(e.key,f,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=r!=null?i.indexOf(r):0,u=_u(e.key,p,i.length);if(u!==void 0){let f=i[u];return n(f),!0}}return!1};import{jsx as qn,jsxs as ed}from"react/jsx-runtime";var vE=Du.forwardRef(({color:e,onChange:o,type:t,elements:r,palette:n,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},c)=>{let[m]=Du.useState(()=>t==="canvasBackground"?[]:mE(r,t,n)),[d,p]=he(vo),u=ln({color:e,palette:n});Pu(()=>{if(!d){let E=!!e&&Su({color:e,palette:n}),w=E&&!m.includes(e);p(w?null:E?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,n,p,u,m]);let[f,b]=u6(u?.shade??(t==="elementBackground"?xf:bf));Pu(()=>{u?.shade!=null&&b(u.shade);let E=w=>{w.key===y.ALT&&l(!1)};return document.addEventListener("keyup",E,{capture:!0}),()=>{document.removeEventListener("keyup",E,{capture:!0})}},[u,l]);let x=Du.useRef(null);return p6(c,()=>x.current),Pu(()=>{x?.current?.focus()},[]),qn("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:ed("div",{ref:x,onKeyDown:E=>{yE({event:E,activeColorPickerSection:d,palette:n,color:e,onChange:o,onEyeDropperToggle:l,customColors:m,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(E.preventDefault(),E.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!m.length&&ed("div",{children:[qn(Ji,{children:g("colorPicker.mostUsedCustomColors")}),qn(fE,{colors:m,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),ed("div",{children:[qn(Ji,{children:g("colorPicker.colors")}),qn(bE,{color:e,palette:n,onChange:o,activeShade:f})]}),ed("div",{children:[qn(Ji,{children:g("colorPicker.shades")}),qn(EE,{color:e,onChange:o,palette:n})]}),a]})})});import h6 from"clsx";import{jsx as Ru}from"react/jsx-runtime";var wE=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=us),o==="elementBackground"&&(n=hs),o==="canvasBackground"&&(n=gs),r&&(n=r),n?Ru("div",{className:"color-picker__top-picks",children:n.map(i=>Ru("button",{className:h6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!ji(i,ps)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:Ru("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Ho,jsxs as Nu}from"react/jsx-runtime";var TE=e=>{let o=new Option().style;return o.color=e,!!o.color},gE=e=>Rn(e)?e:TE(`#${e}`)?`#${e}`:TE(e)?e:null,b6=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=uo,updateData:a})=>{let{container:l}=at(),[,s]=he(vo),[c,m]=he(nn),d=Nu("div",{children:[Ho(Ji,{children:g("colorPicker.hexCode")}),Ho(hE,{color:o||"",label:r,onChange:f=>{t(f)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),p=f6(null),u=()=>{p.current?.focus()};return Ho(Jc,{container:l,style:{maxWidth:"13rem"},onFocusOutside:f=>{u(),f.preventDefault()},onPointerDownOutside:f=>{c&&f.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?Ho(vE,{ref:p,palette:i,color:o,onChange:f=>{t(f)},onEyeDropperToggle:f=>{m(b=>f?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):f===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:f=>{c?m(null):a({openPopup:null})},type:e,elements:n,updateData:a,children:d}):d})},x6=({label:e,color:o,type:t})=>Ho(td.Trigger,{type:"button",className:g6("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!ji(o,ps)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),children:Ho("div",{className:"color-picker__button-outline",children:!o&&F0})}),wl=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=uo,topPicks:a,updateData:l,appState:s})=>Ho("div",{children:Nu("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[Ho(wE,{activeColor:o,onChange:t,type:e,topPicks:a}),Ho(jc,{}),Nu(td.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[Ho(x6,{color:o,label:r,type:e}),s.openPopup===e&&Ho(b6,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as PE from"@radix-ui/react-popover";import U6,{useCallback as G6,useMemo as W6}from"react";import R6,{useMemo as sn,useState as N6,useRef as O6,useEffect as z6,useCallback as B6}from"react";import E6 from"clsx";import y6 from"react";import{jsx as v6,jsxs as w6}from"react/jsx-runtime";var od=y6.forwardRef(({className:e,placeholder:o,onChange:t},r)=>w6("div",{className:E6("QuickSearch__wrapper",e),children:[ro,v6("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import T6 from"clsx";import{Children as C6}from"react";import{jsx as CE}from"react/jsx-runtime";var rd=({className:e,placeholder:o,children:t})=>{let r=!C6.count(t);return CE("div",{className:T6("ScrollableList__wrapper",e),role:"menu",children:r?CE("div",{className:"empty",children:o}):t})};import{jsx as I6,jsxs as k6}from"react/jsx-runtime";var IE=({children:e,className:o="",style:t,title:r})=>k6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&I6("p",{className:"dropdown-menu-group-title",children:r}),e]}),Tl=IE;IE.displayName="DropdownMenuGroup";import{useEffect as D6,useRef as P6}from"react";import{Fragment as M6,jsx as Ou,jsxs as L6}from"react/jsx-runtime";var S6=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=be();return L6(M6,{children:[o&&Ou("div",{className:"dropdown-menu-item__icon",children:o}),Ou("div",{style:e,className:"dropdown-menu-item__text",children:r}),t&&!n.editor.isMobile&&Ou("div",{className:"dropdown-menu-item__shortcut",children:t})]})},nd=S6;import A6,{useContext as _6}from"react";var zu=A6.createContext({}),id=(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(),ad=(e,o)=>{let t=_6(zu);return Vr(e,r=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as Bu}from"react/jsx-runtime";var Fu=({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=ad(m,c),u=P6(null);return D6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),Bu("button",{...d,ref:u,value:o,onClick:p,className:id(i,l,a),title:d.title??d["aria-label"],children:Bu(nd,{textStyle:s,icon:e,shortcut:n,children:r})})};Fu.displayName="DropdownMenuItem";var Qi={GREEN:"green",RED:"red",BLUE:"blue"},ld=({type:e=Qi.BLUE,children:o})=>{let{theme:t}=or(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===re.LIGHT?"1.5px solid white":"none"};switch(e){case Qi.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case Qi.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case Qi.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return Bu("div",{className:"DropDownMenuItemBadge",style:r,children:o})};ld.displayName="DropdownMenuItemBadge";Fu.Badge=ld;var zt=Fu;var kE=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[y.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===y.F)return o.current?.focus(),!0;if(e.key===y.ESCAPE)return n(),!0;if(e.key===y.ENTER)return t?.value&&i(t.value),!0;if(e.key===y.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===y.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as Cl,jsxs as SE}from"react/jsx-runtime";var F6=e=>{switch(e){case dt.Excalifont:case dt.Virgil:return on;case dt.Nunito:case dt.Helvetica:return hl;case dt["Lilita One"]:return Tx;case dt["Comic Shanns"]:case dt.Cascadia:return Oc;default:return hl}},ME=R6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=at(),{fonts:s}=Je(),{showDeprecatedFonts:c}=rr(),[m,d]=N6(""),p=O6(null),u=sn(()=>Array.from(Qr.registered.entries()).filter(([M,{metadata:O}])=>!O.private&&!O.fallback).map(([M,{metadata:O,fontFaces:P}])=>{let F={value:M,icon:F6(M),text:P[0]?.fontFace?.family??"Unknown"};return O.deprecated&&Object.assign(F,{deprecated:O.deprecated,badge:{type:Qi.RED,placeholder:g("fontList.badge.old")}}),F}).sort((M,O)=>M.text.toLowerCase()>O.text.toLowerCase()?1:-1),[]),f=sn(()=>new Set(s.getSceneFamilies()),[e]),b=sn(()=>u.filter(M=>f.has(M.value)),[u,f]),x=sn(()=>u.filter(M=>!f.has(M.value)&&(c||!M.deprecated)),[u,f,c]),E=sn(()=>c1([...b,...x].filter(M=>M.text?.toLowerCase().includes(m))),[b,x,m]),w=sn(()=>{let M;return o?M=E.find(O=>O.value===o):e&&(M=E.find(O=>O.value===e)),!M&&m&&(E[0]?.value?r(E[0].value):n()),M},[o,e,m,E,r,n]),v=B6(M=>{kE({event:M,inputRef:p,hoveredFont:w,filteredFonts:E,onSelect:t,onHover:r,onClose:a})&&(M.preventDefault(),M.stopPropagation())},[w,E,t,r,a]);z6(()=>(i(),()=>{a()}),[]);let T=sn(()=>E.filter(M=>f.has(M.value)),[E,f]),S=sn(()=>E.filter(M=>!f.has(M.value)),[E,f]),k=(M,O)=>SE(zt,{icon:M.icon,value:M.value,order:O,textStyle:{fontFamily:_n({fontFamily:M.value})},hovered:M.value===w?.value,selected:M.value===e,tabIndex:M.value===e?0:-1,onClick:P=>{t(Number(P.currentTarget.value))},onMouseMove:()=>{w?.value!==M.value&&r(M.value)},children:[M.text,M.badge&&Cl(ld,{type:M.badge.type,children:M.badge.placeholder})]},M.value),D=[];return T.length&&D.push(Cl(Tl,{title:g("fontList.sceneFonts"),children:T.map(k)},"group_1")),S.length&&D.push(Cl(Tl,{title:g("fontList.availableFonts"),children:S.map((M,O)=>k(M,O+T.length))},"group_2")),SE(Jc,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:v,children:[Cl(od,{ref:p,placeholder:g("quickSearch.placeholder"),onChange:Dn(d,20)}),Cl(rd,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:D.length?D:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as LE from"@radix-ui/react-popover";import{useMemo as H6}from"react";import{jsx as Hu}from"react/jsx-runtime";var AE=({selectedFontFamily:e})=>{let o=H6(()=>!!(e&&!_E(e)),[e]);return Hu(LE.Trigger,{asChild:!0,children:Hu("div",{children:Hu($c,{standalone:!0,icon:Gi,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as sd,jsxs as DE}from"react/jsx-runtime";var RE=[{value:dt.Excalifont,icon:on,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:dt.Nunito,icon:hl,text:g("labels.normal"),testId:"font-family-normal"},{value:dt["Comic Shanns"],icon:Oc,text:g("labels.code"),testId:"font-family-code"}],V6=new Set(RE.map(e=>e.value)),_E=e=>e?V6.has(e):!1,NE=U6.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=W6(()=>RE,[]),s=G6(c=>{c&&r(c)},[r]);return DE("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[sd(Eo,{type:"button",options:l,value:o,onClick:s}),sd(jc,{}),DE(PE.Root,{open:e,onOpenChange:a,children:[sd(AE,{selectedFontFamily:o}),e&&sd(ME,{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 ea from"@radix-ui/react-popover";import X6 from"clsx";import cd,{useEffect as $6}from"react";import{jsx as Y6}from"react/jsx-runtime";var cn=({icon:e})=>Y6("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});import{Fragment as Z6,jsx as OE,jsxs as zE}from"react/jsx-runtime";var K6=({label:e,open:o,openTrigger:t,children:r,className:n,showCollapsedIcon:i=!0})=>zE(Z6,{children:[zE("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,i&&OE(cn,{icon:o?oE:Yc})]}),o&&OE("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),Il=K6;import{jsx as Jn,jsxs as Uu}from"react/jsx-runtime";var j6=Ie(!1);function q6({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=be(),l=u=>{let f=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&f)r(f.value),u.preventDefault();else if(u.key===y.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(Ln(u.key)){let b=Cr().rtl,x=e.findIndex(E=>E.value===o);if(x!==-1){let E=e.length,w=x;switch(u.key){case(b?y.ARROW_LEFT:y.ARROW_RIGHT):w=(x+1)%E;break;case(b?y.ARROW_RIGHT:y.ARROW_LEFT):w=(E+x-1)%E;break;case y.ARROW_DOWN:{w=(x+(i??1))%E;break}case y.ARROW_UP:{w=(E+x-(i??1))%E;break}}r(e[w].value)}u.preventDefault()}else(u.key===y.ESCAPE||u.key===y.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,c]=he(j6),m=cd.useMemo(()=>e.slice(0,i),[e,i]),d=cd.useMemo(()=>e.slice(i),[e,i]);$6(()=>{m.some(u=>u.value===o)||c(!0)},[o,m,c]);let p=u=>Jn("div",{className:"picker-content",children:u.map((f,b)=>Uu("button",{type:"button",className:X6("picker-option",{active:o===f.value}),onClick:x=>{r(f.value)},title:`${f.text} ${f.keyBinding&&`\u2014 ${f.keyBinding.toUpperCase()}`}`,"aria-label":f.text||"none","aria-keyshortcuts":f.keyBinding||void 0,ref:x=>{o===f.value&&setTimeout(()=>{x?.focus()},0)},children:[f.icon,f.keyBinding&&Jn("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return Jn(ea.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:Uu("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(m),d.length>0&&Jn(Il,{label:g("labels.more_options"),open:s,openTrigger:()=>{c(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function Gu({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=cd.useState(!1),s=cd.useRef(null);return Jn("div",{children:Uu(ea.Root,{open:a,onOpenChange:c=>l(c),children:[Jn(ea.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&&Jn(q6,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import BE,{useEffect as J6}from"react";import{jsx as Wu,jsxs as FE}from"react/jsx-runtime";var HE=({updateData:e,app:o,testId:t})=>{let r=BE.useRef(null),n=BE.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),c=i.reduce((m,d)=>(m!=null&&m!==d.opacity&&(a=!1),m==null||m>d.opacity?d.opacity:m),l?.opacity??null)??o.state.currentItemOpacity;return J6(()=>{if(r.current&&n.current){let m=r.current,d=n.current,p=m.offsetWidth,u=15,f=c/100*(p-u)+u/2;d.style.left=`${f}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${c}%, var(--button-bg) ${c}%, var(--button-bg) 100%)`}},[c]),FE("label",{className:"control-label",children:[g("labels.opacity"),FE("div",{className:"range-wrapper",children:[Wu("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:r,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:c,className:"range-input","data-testid":t}),Wu("div",{className:"value-bubble",ref:n,children:c!==0?c:null}),Wu("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as WE,jsx as me,jsxs as no}from"react/jsx-runtime";var GE=.1,Bt=(e,o,t,r=!1)=>{let n=J(j(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},Xt=function(e,o,t,r,n){let i=o.state.editingTextElement,a=ue(e),l=null;if(i&&(l=t(i)),!l)if(Ne(a,o.state)){let c=o.scene.getSelectedElements(o.state),m=r===!0?c:c.filter(d=>r(d));l=Os(m,t)??(typeof n=="function"?n(!0):n)}else l=typeof n=="function"?n(!1):n;return l},t4=(e,o,t)=>tt(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),Ku=(e,o,t,r,n)=>{let i=new Set,a=Bt(e,o,l=>{if(Y(l)){let s=r(l);i.add(s);let c=ne(l,{fontSize:s});return Ye(c,t.scene.getContainerElement(l),t.scene),c=t4(l,c,t.scene),c}return l},!0);return j(e,o,{includeBoundTextElement:!0}).forEach(l=>{Y(l)&&$r(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:A.IMMEDIATELY}},o4=z({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:Bt(e,o,r=>el(r.type)?ne(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>no(WE,{children:[me("h3",{"aria-hidden":"true",children:g("labels.stroke")}),me(wl,{topPicks:us,palette:Ef,type:"elementStroke",label:g("labels.stroke"),color:Xt(e,r,n=>n.strokeColor,!0,n=>n?null:o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),r4=z({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemBackgroundColor&&{elements:Bt(e,o,r=>ne(r,{backgroundColor:t.currentItemBackgroundColor}))},appState:{...o,...t},captureUpdate:t.currentItemBackgroundColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>no(WE,{children:[me("h3",{"aria-hidden":"true",children:g("labels.background")}),me(wl,{topPicks:hs,palette:yf,type:"elementBackground",label:g("labels.background"),color:Xt(e,r,n=>n.backgroundColor,!0,n=>n?null:o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),n4=z({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(de("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:Bt(e,o,n=>ne(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=j(e,o),i=n.length>0&&n.every(a=>a.fillStyle==="zigzag");return no("fieldset",{children:[me("legend",{children:g("labels.fill")}),me(Eo,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${R("Alt-Click")})`,icon:i?X0:$0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:j0,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:q0,testId:"fill-solid"}],value:Xt(e,r,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&n.every(c=>c.fillStyle==="hachure")?"zigzag":a;t(s)}})]})}}),i4=z({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:Bt(e,o,r=>ne(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>no("fieldset",{children:[me("legend",{children:g("labels.strokeWidth")}),me(Eo,{group:"stroke-width",options:[{value:Is.thin,text:g("labels.thin"),icon:pu,testId:"strokeWidth-thin"},{value:Is.bold,text:g("labels.bold"),icon:J0,testId:"strokeWidth-bold"},{value:Is.extraBold,text:g("labels.extraBold"),icon:Q0,testId:"strokeWidth-extraBold"}],value:Xt(e,r,n=>n.strokeWidth,n=>n.hasOwnProperty("strokeWidth"),n=>n?null:o.currentItemStrokeWidth),onChange:n=>t(n)})]})}),a4=z({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:Bt(e,o,r=>ne(r,{seed:Nn(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>no("fieldset",{children:[me("legend",{children:g("labels.sloppiness")}),me(Eo,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:ox},{value:1,text:g("labels.artist"),icon:rx},{value:2,text:g("labels.cartoonist"),icon:nx}],value:Xt(e,r,n=>n.roughness,n=>n.hasOwnProperty("roughness"),n=>n?null:o.currentItemRoughness),onChange:n=>t(n)})]})}),eN=z({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:Bt(e,o,r=>ne(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>no("fieldset",{children:[me("legend",{children:g("labels.strokeStyle")}),me(Eo,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:pu},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:ex},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:tx}],value:Xt(e,r,n=>n.strokeStyle,n=>n.hasOwnProperty("strokeStyle"),n=>n?null:o.currentItemStrokeStyle),onChange:n=>t(n)})]})}),l4=z({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:Bt(e,o,r=>ne(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>me(HE,{updateData:o,app:e,testId:"opacity"})}),s4=z({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>Ku(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>no("fieldset",{children:[me("legend",{children:g("labels.fontSize")}),me(Eo,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:Ex,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:yx,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:vx,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:wx,testId:"fontSize-veryLarge"}],value:Xt(e,r,n=>{if(Y(n))return n.fontSize;let i=Ee(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>Y(n)||Ee(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||hr),onChange:n=>t(n)})]})}),Zu=z({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:$n,trackEvent:!1,perform:(e,o,t,r)=>Ku(e,o,r,n=>Math.round(1/(1+GE)*n.fontSize)),keyTest:e=>e[y.CTRL_OR_CMD]&&e.shiftKey&&(e.key===y.CHEVRON_LEFT||e.key===y.COMMA)}),Xu=z({name:"increaseFontSize",label:"labels.increaseFontSize",icon:$n,trackEvent:!1,perform:(e,o,t,r)=>Ku(e,o,r,n=>Math.round(n.fontSize*(1+GE))),keyTest:e=>e[y.CTRL_OR_CMD]&&e.shiftKey&&(e.key===y.CHEVRON_RIGHT||e.key===y.PERIOD)}),c4=z({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:Bt(e,o,b=>{let x=n?.get(b.id);return x?ne(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 f=j(e,o,{includeBoundTextElement:!0}).filter(b=>Y(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let E=f[b];x+=E?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(d&&!p){let f=new Map,b=new Set,x=!1,E=Array.from(Qr.loadedFontsCache.values()),w=Object.entries(dt).find(([S,k])=>k===d)?.[0];c&&w&&E.some(S=>S.startsWith(w))&&(x=!0),Object.assign(u,{elements:Bt(e,o,S=>{if(Y(S)&&(S.fontFamily!==d||s)){let k=ne(S,{fontFamily:d,lineHeight:Ao(d)}),D=n?.get(S.containerId||"")||{},M=r.scene.getContainerElement(S);return a&&M&&D&&r.scene.mutateElement(M,{...D}),x||(b=new Set([...b,...Array.from(k.originalText)])),f.set(k,M),k}return S},!0)});let v=`10px ${_n({fontFamily:d})}`,T=Array.from(b.values()).join();if(x||window.document.fonts.check(v,T))for(let[S,k]of f)Ye(S,k,r.scene);else window.document.fonts.load(v,T).then(S=>{for(let[k,D]of f){let M=r.scene.getElement(k.id),O=D?r.scene.getElement(D.id):null;M&&Ye(M,O,r.scene)}r.fonts.onLoaded(S)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=Yu(new Map),i=Yu(null),[a,l]=e4({}),s=Yu(!0),c=Q6(()=>{let m=(d,p)=>Xt(d,t,u=>{if(Y(u))return u.fontFamily;let f=Ee(u,p);return f?f.fontFamily:null},u=>Y(u)||Ee(u,p)!==null,u=>u?null:o.currentItemFontFamily||zr);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]);return Vu(()=>{i.current=c},[c]),Vu(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),Vu(()=>(s.current=!1,()=>{s.current=!0}),[]),no("fieldset",{children:[me("legend",{children:g("labels.fontFamily")}),me(NE,{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,ne(p||d,{},!0))}else{let p=j(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,ne(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()}}})]})}}),d4=z({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:Bt(e,o,n=>{if(Y(n)){let i=ne(n,{textAlign:t});return Ye(i,r.scene.getContainerElement(n),r.scene),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 no("fieldset",{children:[me("legend",{children:g("labels.textAlign")}),me(Eo,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:Cx,testId:"align-left"},{value:"center",text:g("labels.center"),icon:Ix,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:kx,testId:"align-right"}],value:Xt(e,r,i=>{if(Y(i))return i.textAlign;let a=Ee(i,n);return a?a.textAlign:null},i=>Y(i)||Ee(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})]})}}),m4=z({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Bt(e,o,n=>{if(Y(n)){let i=ne(n,{verticalAlign:t});return Ye(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>me("fieldset",{children:me(Eo,{group:"text-align",options:[{value:Wt.TOP,text:g("labels.alignTop"),icon:me(Sx,{theme:o.theme}),testId:"align-top"},{value:Wt.MIDDLE,text:g("labels.centerVertically"),icon:me(Lx,{theme:o.theme}),testId:"align-middle"},{value:Wt.BOTTOM,text:g("labels.alignBottom"),icon:me(Mx,{theme:o.theme}),testId:"align-bottom"}],value:Xt(e,r,n=>{if(Y(n)&&n.containerId)return n.verticalAlign;let i=Ee(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>Y(n)||Ee(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:Wt.MIDDLE),onChange:n=>t(n)})})}),tN=z({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:Bt(e,o,r=>le(r)?r:ne(r,{roundness:t==="round"?{type:Yr(r.type)?xt.ADAPTIVE_RADIUS:xt.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let i=Ys(ue(e),o).some(a=>a.roundness?.type===xt.LEGACY);return no("fieldset",{children:[me("legend",{children:g("labels.edges")}),me(Eo,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:ix},{value:"round",text:g("labels.round"),icon:ax}],value:Xt(e,r,a=>i?null:a.roundness?"round":"sharp",a=>!Re(a)&&a.hasOwnProperty("roundness"),a=>a?null:o.currentItemRoundness),onChange:a=>t(a)})]})}}),UE=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:lx},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:me(sx,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:me(px,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:me(ux,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:me(cx,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:me(dx,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:me(hx,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:me(gx,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:me(mx,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:me(bx,{flip:e}),keyBinding:"c"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:me(fx,{flip:e}),keyBinding:"x"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:me(xx,{flip:e}),keyBinding:"v"}],oN=z({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:Bt(e,o,r=>{if(fe(r)){let{position:n,type:i}=t;if(n==="start")return ne(r,{startArrowhead:i});if(n==="end")return ne(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Cr().rtl;return no("fieldset",{children:[me("legend",{children:g("labels.arrowheads")}),no("div",{className:"iconSelectList buttonList",children:[me(Gu,{label:"arrowhead_start",options:UE(!n),value:Xt(e,r,i=>fe(i)&&Mi(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),me(Gu,{label:"arrowhead_end",group:"arrowheads",options:UE(!!n),value:Xt(e,r,i=>fe(i)&&Mi(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),rN=z({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=Bt(e,o,l=>{if(!Re(l))return l;let s=ne(l,{roundness:t===mt.round?{type:xt.PROPORTIONAL_RADIUS}:null,elbowed:t===mt.elbow,points:t===mt.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(le(s)){s.fixedSegments=null;let c=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let m=X.getPointAtIndexGlobalCoordinates(s,0,c),d=X.getPointAtIndexGlobalCoordinates(s,-1,c),p=!s.startBinding&&Xr(Gr(m),e,c,o.zoom,!1,!0),u=!s.endBinding&&Xr(Gr(d),e,c,o.zoom,!1,!0),f=p||s.startBinding&&c.get(s.startBinding.elementId),b=u||s.endBinding&&c.get(s.endBinding.elementId),x=p?Ep(s,p,"start"):m,E=u?Ep(s,u,"end"):d;p&&Zr(s,p,"start",r.scene),u&&Zr(s,u,"end",r.scene);let w=f&&s.startBinding?{...s.startBinding,...yp(s,f,"start")}:null,v=b&&s.endBinding?{...s.endBinding,...yp(s,b,"end")}:null;s={...s,startBinding:w,endBinding:v,...qs(s,c,{points:[x,E].map(T=>L(T[0]-s.x,T[1]-s.y)),startBinding:w,endBinding:v,fixedSegments:null})},X.updateEditorMidPointsCache(s,c,r.state)}else{let c=r.scene.getNonDeletedElementsMap();if(s.startBinding){let m=c.get(s.startBinding.elementId);m&&Zr(s,m,"start",r.scene)}if(s.endBinding){let m=c.get(s.endBinding.elementId);m&&Zr(s,m,"end",r.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new X(l,J(e)))}return{elements:n,appState:i,captureUpdate:A.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>no("fieldset",{children:[me("legend",{children:g("labels.arrowtypes")}),me(Eo,{group:"arrowtypes",options:[{value:mt.sharp,text:g("labels.arrowtype_sharp"),icon:Gc,testId:"sharp-arrow"},{value:mt.round,text:g("labels.arrowtype_round"),icon:Vc,testId:"round-arrow"},{value:mt.elbow,text:g("labels.arrowtype_elbowed"),icon:Wc,testId:"elbow-arrow"}],value:Xt(e,r,n=>Re(n)?n.elbowed?mt.elbow:n.roundness?mt.round:mt.sharp:null,n=>Re(n),n=>n?null:o.currentItemArrowType),onChange:n=>t(n)})]})});import{useEffect as p4}from"react";import{jsx as h4}from"react/jsx-runtime";var ta=()=>{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},$u=(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`})},u4=(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();$u(o,n)},io=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(p4(()=>()=>ta().classList.remove("excalidraw-tooltip--visible"),[]),n?null:h4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>u4(i.currentTarget,ta(),o,t),onPointerLeave:()=>ta().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import dd from"open-color";var YE='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',g4='<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"/>',KE='<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"/>',f4=`data:${ce.svg},${encodeURIComponent(`${YE}${KE}</svg>`)}`,b4=`data:${ce.svg},${encodeURIComponent(`${YE}${g4}${KE}</svg>`)}`,ao=e=>{e&&(e.style.cursor="")},ke=(e,o)=>{e&&(e.style.cursor=o)},nr,VE,ju=(e,o)=>{let r=()=>{let n=o===re.DARK;nr=document.createElement("canvas"),nr.theme=o,nr.height=20,nr.width=20;let i=nr.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(nr.width/2,nr.height/2,5,0,2*Math.PI),i.fillStyle=n?dd.black:dd.white,i.fill(),i.strokeStyle=n?dd.white:dd.black,i.stroke(),VE=nr.toDataURL(ce.svg)};(!nr||nr.theme!==o)&&r(),ke(e,`url(${VE}) ${20/2} ${20/2}, auto`)},lo=(e,o)=>{if(e)if(o.activeTool.type==="selection")ao(e);else if(Bo(o))e.style.cursor=we.GRAB;else if(Zt(o))ju(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===re.LIGHT?f4:b4;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=we.AUTO):e.style.cursor=we.CROSSHAIR};var Ir=({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 hd,jsxs as v4}from"react/jsx-runtime";var x4=z({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})=>hd(wl,{palette:null,topPicks:gs,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:n=>t({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),kr=z({name:"clearCanvas",label:"labels.clearCanvas",icon:oo,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=>ne(n,{isDeleted:!0})),appState:{...en(),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})}),md=z({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Xp,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ir({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:er(o.zoom.value+ui)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>hd($,{type:"button",className:"zoom-in-button zoom-button",icon:Xp,title:`${g("buttons.zoomIn")} \u2014 ${R("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=qm,onClick:()=>{e(null)}}),keyTest:e=>(e.code===se.EQUAL||e.code===se.NUM_ADD)&&(e[y.CTRL_OR_CMD]||e.shiftKey)}),pd=z({name:"zoomOut",label:"buttons.zoomOut",icon:$p,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ir({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:er(o.zoom.value-ui)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>hd($,{type:"button",className:"zoom-out-button zoom-button",icon:$p,title:`${g("buttons.zoomOut")} \u2014 ${R("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=jm,onClick:()=>{e(null)}}),keyTest:e=>(e.code===se.MINUS||e.code===se.NUM_SUBTRACT)&&(e[y.CTRL_OR_CMD]||e.shiftKey)}),ud=z({name:"resetZoom",label:"buttons.resetZoom",icon:_0,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ir({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:er(1)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>hd(io,{label:g("buttons.resetZoom"),style:{height:"100%"},children:v4($,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===se.ZERO||e.code===se.NUM_ZERO)&&(e[y.CTRL_OR_CMD]||e.shiftKey)}),E4=(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)*Et(t,.1,1);return Math.min(p,1)},ZE=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=Et(n,jm,qm);let[l,s,c,m]=e,d=(l+c)/2,p=(s+m)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,E=o.width-u-b,w=o.height-f-x,v;if(r){let k=c-l,D=m-s;v=Math.min(E/k,w/D)*n}else v=E4(e,{width:E,height:w},n);let T=er(Et($f(v,ui,"floor"),i,a)),S=Vb({scenePoint:{x:d,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:T}});return{appState:{...o,scrollX:S.scrollX,scrollY:S.scrollY,zoom:{value:T}},captureUpdate:A.EVENTUALLY}},kl=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=Te(ue(o));return ZE({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},FN=z({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:Uc,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return kl({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===se.TWO&&e.shiftKey&&!e.altKey&&!e[y.CTRL_OR_CMD]}),HN=z({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:Uc,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return kl({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===se.THREE&&e.shiftKey&&!e.altKey&&!e[y.CTRL_OR_CMD]}),y4=z({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:Uc,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>kl({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===se.ONE&&e.shiftKey&&!e.altKey&&!e[y.CTRL_OR_CMD]}),Qn=z({name:"toggleTheme",label:(e,o)=>o.theme===re.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===re.LIGHT?ml:pl,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===re.LIGHT?re.DARK:re.LIGHT)},captureUpdate:A.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===se.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),UN=z({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o)=>{let t;return Zt(o)?t=De(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):t=De(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:t},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.key===y.E}),GN=z({name:"toggleLassoTool",label:"toolBar.lasso",icon:cl,trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=De(o,{type:"lasso",fromSelection:!1}),ke(r.interactiveCanvas,we.CROSSHAIR)):n=De(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:A.NEVER}}}),XE=z({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Bc,viewMode:!1,perform:(e,o,t,r)=>{let n;return Bo(o)?n=De(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=De(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),ke(r.interactiveCanvas,we.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:A.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[y.CTRL_OR_CMD]&&e.key===y.H});var w4=z({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=De(o,{type:"embeddable"});return lo(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:De(o,{type:"embeddable"})},captureUpdate:A.EVENTUALLY}}});import{jsx as T4}from"react/jsx-runtime";var so=z({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:f}=o.editingLinearElement,b=X.getElement(p,l);if(b)return br(b)&&Qs(b,u,f,a),{elements:b.points.length<2||Gn(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&&a.mutateElement(c,{isDeleted:!0},{informMutation:!1,isDragging:!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:f}=m;(!f||u[u.length-1]!==f)&&a.mutateElement(m,{points:m.points.slice(0,-1)})}Gn(m)&&(s=s.filter(u=>u.id!==m.id));let p=Qa(m.points,o.zoom.value);if((m.type==="line"||m.type==="freedraw")&&p){let u=m.points,f=u[0];a.mutateElement(m,{points:u.map((b,x)=>x===u.length-1?L(f[0],f[1]):b)})}if(br(m)&&!p&&m.points.length>1){let[u,f]=X.getPointAtIndexGlobalCoordinates(m,-1,J(e));Ja(m,o,{x:u,y:f},a)}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!m)&&ao(n);let d;return o.activeTool.type==="eraser"?d=De(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):d=De(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&&fe(m)?new X(m,J(s)):o.selectedLinearElement,pendingImageElementId:null},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o)=>e.key===y.ESCAPE&&(o.editingLinearElement!==null||!o.newElement&&o.multiElement===null)||(e.key===y.ESCAPE||e.key===y.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>T4($,{type:"button",icon:U0,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import C4 from"clsx";import{jsx as $E,jsxs as I4}from"react/jsx-runtime";var Sl=({children:e,checked:o,onChange:t,className:r})=>I4("div",{className:C4("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[$E("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:N0}),$E("div",{className:"Checkbox-label",children:e})]});import{jsx as Ml}from"react/jsx-runtime";var qE=e=>{let o=e.title||(e.value===re.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return Ml($,{type:"icon",icon:e.value===re.LIGHT?jE.MOON:jE.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===re.DARK?re.LIGHT:re.DARK),"data-testid":"toggle-dark-mode"})},jE={SUN:Ml("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ml("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:Ml("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ml("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 k4}from"react";import{jsx as JE,jsxs as S4}from"react/jsx-runtime";var QE=e=>{let{id:o}=at(),[t,r]=k4(e.value),n=a=>{e.ignoreFocus||l1(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===y.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return S4("div",{className:"ProjectName",children:[JE("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),JE("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};var Uo=32,ze=12,dn=256,t2=50,ei="NOT_SPREADSHEET",oa="VALID_SPREADSHEET",Ll=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},qu=(e,o)=>e.slice(1).every(t=>Ll(t[o])!==null),e2=e=>{let o=e[0].length;if(o>2)return{type:ei,reason:"More than 2 columns"};if(o===1){if(!qu(e,0))return{type:ei,reason:"Value is not numeric"};let s=Ll(e[0][0])===null,c=(s?e.slice(1):e).map(m=>Ll(m[0]));return c.length<2?{type:ei,reason:"Less than two rows"}:{type:oa,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let t=qu(e,0),r=qu(e,1);if(!t&&!r)return{type:ei,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=Ll(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:ei,reason:"Less than 2 rows"}:{type:oa,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>Ll(s[i]))}}},M4=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},o2=e=>{let o=e.trim().split(`
1
+ import{$ as u1,A as hm,B as t1,C as o1,D as n1,E as Pl,F as Vi,G as Al,H as Dl,I as r1,J as i1,K as Xi,L as a1,M as l1,N as s1,O as c1,P as _l,Q as br,R as d1,S as $I,T as gm,U as jI,V as xr,W as Ki,Y as m1,_ as p1,a as qf,aa as Rl,b as Fn,ba as h1,c as uo,ca as Nl,d as Jf,da as fm,e as Ee,ea as Bl,f as Qf,fa as g1,g as j,ga as bm,h as kl,ha as ko,i as Zo,ia as f1,j as sm,ja as xm,k as cm,ka as b1,l as hr,la as x1,m as dm,ma as Fl,n as gr,na as Em,o as e1,oa as E1,p as mm,pa as y1,q as $o,qa as w1,r as jo,ra as v1,s as bt,t as qt,u as fr,v as Ml,w as pm,x as Wi,y as Ll,z as um}from"./chunk-YHEOD47Q.js";import{a as T}from"./chunk-A66AFZZU.js";import{J as lm}from"./chunk-I4UNSFV6.js";import{c as jf}from"./chunk-Z3N5DIM6.js";import{b as Zf,c as $f,d as I}from"./chunk-SRAX5OIU.js";import FG,{useEffect as OG}from"react";import{DEFAULT_UI_OPTIONS as XI,isShallowEqual as zG}from"@excalidraw/common";import C5 from"clsx";import bz from"lodash.throttle";import So,{useContext as Nn}from"react";import{flushSync as Fi}from"react-dom";import xz from"roughjs/bin/rough";import{nanoid as Ez}from"nanoid";import{clamp as S5,pointFrom as re,pointDistance as Pn,vector as k5,pointRotateRads as Qg,vectorScale as yz,vectorFromPoint as ef,vectorSubtract as M5,vectorDot as L5,vectorNormalize as P5}from"@excalidraw/math";import{COLOR_PALETTE as wz,CODES as A5,shouldResizeFromCenter as D5,shouldMaintainAspectRatio as dl,shouldRotateWithDiscreteAngle as tf,isArrowKey as Kd,KEYS as Y,APP_NAME as vz,CURSOR_TYPE as De,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as Tz,DEFAULT_VERTICAL_ALIGN as _5,DRAGGING_THRESHOLD as Iz,ELEMENT_SHIFT_TRANSLATE_AMOUNT as Cz,ELEMENT_TRANSLATE_AMOUNT as R5,EVENT as ee,FRAME_STYLE as An,IMAGE_MIME_TYPES as Sz,IMAGE_RENDER_TIMEOUT as kz,isBrave as Mz,LINE_CONFIRM_THRESHOLD as of,MAX_ALLOWED_FILE_BYTES as N5,MIME_TYPES as Dn,MQ_MAX_HEIGHT_LANDSCAPE as Lz,MQ_MAX_WIDTH_LANDSCAPE as Pz,MQ_MAX_WIDTH_PORTRAIT as Az,MQ_RIGHT_SIDEBAR_MIN_WIDTH as Dz,POINTER_BUTTON as ar,ROUNDNESS as Zd,SCROLL_TIMEOUT as _z,TAP_TWICE_TIMEOUT as Rz,TEXT_TO_CENTER_SNAP_THRESHOLD as Nz,THEME as $d,THEME_FILTER as Bz,TOUCH_CTX_MENU_TIMEOUT as Fz,VERTICAL_ALIGN as Oz,YOUTUBE_STATES as jd,ZOOM_STEP as zz,POINTER_EVENTS as Oi,TOOL_TYPE as Co,isIOS as Hz,supportsResizeObserver as B5,DEFAULT_COLLISION_THRESHOLD as F5,DEFAULT_TEXT_ALIGN as Gz,ARROW_TYPE as _n,DEFAULT_REDUCED_GLOBAL_ALPHA as Uz,isSafari as Yz,isLocalLink as Wz,normalizeLink as nf,toValidURL as Vz,getGridPoint as rt,getLineHeight as O5,debounce as z5,distance as zi,getFontString as rf,getNearestScrollableContainer as Xz,isInputLike as H5,isToolIcon as Kz,isWritableElement as ml,sceneCoordsToViewportCoords as qd,tupleToCoors as af,viewportCoordsToSceneCoords as Oe,wrapEvent as Zz,updateObject as lf,updateActiveTool as Vo,getShortcutKey as $z,isTransparent as jz,easeToValuesRAF as qz,muteFSAbortError as Jz,isTestEnv as Lf,isDevEnv as II,easeOut as Qz,updateStable as pl,addEventListener as _e,normalizeEOL as eH,getDateTime as G5,isShallowEqual as tH,arrayToMap as U5,randomInteger as oH,CLASSES as nH,Emitter as lr,isMobile as rH,MINIMUM_ARROW_SIZE as Y5,DOUBLE_TAP_POSITION_THRESHOLD as iH}from"@excalidraw/common";import{getObservedAppState as aH,getCommonBounds as Hi,maybeSuggestBindingsForLinearElementAtCoords as W5,getElementAbsoluteCoords as V5,bindOrUnbindLinearElements as X5,fixBindingsAfterDeletion as lH,getHoveredElementForBinding as sf,isBindingEnabled as cf,shouldEnableBindingForPointerEvent as sH,updateBoundElements as df,getSuggestedBindingsForArrows as mf,LinearElementEditor as Se,newElementWith as sr,newFrameElement as cH,newFreeDrawElement as dH,newEmbeddableElement as K5,newMagicFrameElement as Z5,newIframeElement as mH,newArrowElement as pH,newElement as uH,newImageElement as hH,newLinearElement as gH,newTextElement as $5,refreshTextDimensions as fH,deepCopyElement as j5,duplicateElements as q5,hasBoundTextElement as J5,isArrowElement as pf,isBindingElement as uf,isBindingElementType as Q5,isBoundToContainer as hf,isFrameLikeElement as Mt,isImageElement as cr,isEmbeddableElement as Xo,isInitializedImageElement as ul,isLinearElement as Zt,isLinearElementType as bH,isUsingAdaptiveRadius as xH,isIframeElement as Gi,isIframeLikeElement as hl,isMagicFrameElement as gf,isTextBindableContainer as eI,isElbowArrow as We,isFlowchartNodeElement as EH,isBindableElement as yH,isTextElement as mo,getLockedLinearCursorAlignSize as tI,getNormalizedDimensions as wH,isElementCompletelyInViewport as ff,isElementInViewport as oI,isInvisiblySmallElement as nI,getCornerRadius as vH,isPathALoop as rI,createSrcDoc as iI,embeddableURLValidator as bf,maybeParseEmbedSrc as TH,getEmbedLink as Jd,getInitializedImageElements as IH,normalizeSVG as aI,updateImageCache as CH,getBoundTextElement as xf,getContainerCenter as Ef,getContainerElement as lI,isValidTextContainer as SH,redrawTextBoundingBox as kH,shouldShowBoundingBox as MH,getFrameChildren as yf,isCursorInFrame as sI,addElementsToFrame as wf,replaceAllElementsInFrame as LH,removeElementsFromFrame as PH,getElementsInResizingFrame as vf,getElementsInNewFrame as AH,getContainingFrame as Tf,elementOverlapsWithFrame as DH,updateFrameMembershipOfSelectedElements as cI,isElementInFrame as dI,getFrameLikeTitle as _H,getElementsOverlappingFrame as RH,filterElementsEligibleAsFrameChildren as NH,hitElementBoundText as BH,hitElementBoundingBoxOnly as FH,hitElementItself as gl,getVisibleSceneBounds as OH,FlowChartCreator as zH,FlowChartNavigator as HH,getLinkDirectionFromKey as mI,cropElement as GH,wrapText as UH,isElementLink as If,parseElementLinkFromURL as YH,isMeasureTextSupported as WH,normalizeText as VH,measureText as pI,getLineHeightInPx as XH,getApproxMinLineWidth as KH,getApproxMinLineHeight as ZH,getMinTextElementWidth as $H,ShapeCache as fl,getRenderOpacity as jH,editGroupForSelectedElement as qH,getElementsInGroup as dr,getSelectedGroupIdForElement as JH,getSelectedGroupIds as QH,isElementInGroup as uI,isSelectedViaGroup as eG,selectGroupsForSelectedElements as $t,syncInvalidIndices as CI,syncMovedIndices as hI,excludeElementsInFramesFromSelection as tG,getSelectionStateForElements as oG,makeNextSelectedElementIds as ye,getResizeOffsetXY as nG,getResizeArrowDirection as rG,transformElements as iG,getCursorForResizingElement as gI,getElementWithTransformHandleType as fI,getTransformHandleTypeFromCoords as bI,dragNewElement as xI,dragSelectedElements as aG,getDragOffsetXY as lG,isNonDeletedElement as EI,Scene as yI,Store as sG,CaptureUpdateAction as mt,hitElementBoundingBox as cG,isLineElement as Cf,isSimpleArrow as dG,StoreDelta as wI}from"@excalidraw/element";import{KEYS as Xm,updateActiveTool as dC}from"@excalidraw/common";import{getNonDeletedElements as Km}from"@excalidraw/element";import{fixBindingsAfterDeletion as mC}from"@excalidraw/element";import{LinearElementEditor as hb}from"@excalidraw/element";import{newElementWith as ms}from"@excalidraw/element";import{getContainerElement as gb}from"@excalidraw/element";import{isBoundToContainer as cs,isElbowArrow as pC,isFrameLikeElement as uC}from"@excalidraw/element";import{getFrameChildren as hC}from"@excalidraw/element";import{getElementsInGroup as Zm,selectGroupsForSelectedElements as gC}from"@excalidraw/element";import{CaptureUpdateAction as ds}from"@excalidraw/element";import{isDevEnv as eC}from"@excalidraw/common";import{atom as me,createStore as qI}from"jotai";import{createIsolation as JI}from"jotai-scope";var T1=JI();var{useAtom:ie,useSetAtom:qo,useAtomValue:Ol,useStore:VG}=T1,I1=T1.Provider,He=qI();var QI=Zf({"./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-TYY6KWIJ.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 tC=85,ho={code:"en",label:"English"},yr=[ho,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>jf[e.code]>=tC).sort((e,o)=>e.label>o.label?1:-1)],Hl="__test__";eC()&&yr.unshift({code:Hl,label:"test language"},{code:`${Hl}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var Er=ho,zl={},Gl=async e=>{if(Er=e,document.documentElement.dir=Er.rtl?"rtl":"ltr",document.documentElement.lang=Er.code,e.code.startsWith(Hl))zl={};else try{zl=await QI(`./locales/${Er.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),zl=lm}He.set(S1,e.code)},Mo=()=>Er,C1=(e,o)=>{for(let t=0;t<o.length;++t){let n=o[t];if(e[n]===void 0)return;e=e[n]}if(typeof e=="string")return e},g=(e,o,t)=>{if(Er.code.startsWith(Hl))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let n=e.split("."),r=C1(zl,n)||C1(lm,n)||t;if(r===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)r=r.replace(`{{${i}}}`,String(o[i]));return r},S1=me(ho.code),ze=()=>{let e=Ol(S1);return{t:g,langCode:e}};import oC from"clsx";import nC from"open-color";import et from"react";import{THEME as rC}from"@excalidraw/common";import{Fragment as be,jsx as h,jsxs as D}from"react/jsx-runtime";var Jt=e=>"var(--icon-fill-color)",k1=e=>e===rC.LIGHT?nC.white:"#1e1e1e",M=(e,o=512)=>{let{width:t=512,height:n=t,mirror:r,style:i,...a}=typeof o=="number"?{width:o}:o;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${n}`,className:oC({"rtl-mirror":r}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},z={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},te={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},lU=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:3,y:8,width:18,height:4,rx:1}),h("line",{x1:12,y1:8,x2:12,y2:21}),h("path",{d:"M19 12v7a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-7"}),h("path",{d:"M7.5 8a2.5 2.5 0 0 1 0 -5a4.8 8 0 0 1 4.5 5a4.8 8 0 0 1 4.5 -5a2.5 2.5 0 0 1 0 5"})]}),z),wr=M(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"})]}),z),M1=M(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"})]}),z),L1=M(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"})]}),z),P1=M(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"})]}),z),ym=M(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"})]}),z),On=M(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"})})]}),te),vr=M(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"})]}),te),A1=M(h("g",{fill:"currentColor",children:h("path",{d:"M12 2a5 5 0 0 1 5 5v3a3 3 0 0 1 3 3v6a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3v-6a3 3 0 0 1 3 -3v-3a5 5 0 0 1 5 -5m0 12a2 2 0 0 0 -1.995 1.85l-.005 .15a2 2 0 1 0 2 -2m0 -10a3 3 0 0 0 -3 3v3h6v-3a3 3 0 0 0 -3 -3"})}),{width:24,height:24}),D1=M(D(be,{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"}),_1=M(D(be,{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"}),R1=M(D(be,{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"}),sU=M(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),wm=M(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}),Zi=M(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}),Ul=M(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"})]}),z),Yl=M(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"})]}),z),Wl=M(D("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),z),N1=M(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"})]}),z),Vl=M(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),te),B1=M(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"})]}),z),Jo=M(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"})]}),te),Tr=M(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"})]}),z),F1=M(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"})]}),te),O1=M(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"})]}),z),vm=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),te),Tm=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),te),z1=M(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"})]}),z),Lt=M(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),te),Im=M(D("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),te),$i=M(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"})]}),te),ji=M(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),te),qi=M(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...te,strokeWidth:1.5}),Xl=M(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"})]}),z),zn=M(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),te),Ir=M(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"})]}),z),H1=M(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"})]}),z),Cm=M(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),te),Kl=M(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),te),G1=M(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"})]}),te),U1=M(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"})]}),z),Y1=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Ji=M(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"})]}),te),W1=M("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),V1=M("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),Cr=M(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),te),cU=M("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),X1=M("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),Zl=M(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"})]}),z),K1=M(h("g",{strokeWidth:1.5,children:h("path",{d:"M6 18l12 -12"})}),z),$l=M(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"})]}),z),Z1=M("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),dU=M("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),mU=M("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),$1=M("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),pU=M("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Sm=M(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),te),km=M(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),te),j1=M("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),q1=M(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"}),te),uU=M("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),hU=M("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),gU=M(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"})]}),z),fU=M(D(be,{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}),bU=M(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),J1=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"})]}),Q1=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"})]}),Mm=M(Q1,z),Lm=M(Q1,{...z,style:{transform:"rotate(180deg)"}}),Pm=M(J1,z),Am=M(J1,{...z,style:{transform:"rotate(180deg)"}}),Dm=M(D(be,{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"})})})]}),te),_m=M(D(be,{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"})})})]}),te),Rm=M(D(be,{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"})})})]}),te),Nm=M(D(be,{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"})})})]}),te),e0=M(D(be,{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"})})})]}),te),t0=M(D(be,{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"})})})]}),te),Bm=M(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"})]}),te),Fm=M(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"})]}),te),jl=M(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"})]}),z),xU=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),EU=M("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),Ft=M(D(be,{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"})})})]}),te),yU=M("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),wU=M("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),vU=M("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Om=et.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:Jt(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:Jt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Jt(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:Jt(e),strokeWidth:"2"}),D("g",{fill:k1(e),stroke:Jt(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})),zm=et.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:Jt(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:Jt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:Jt(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:Jt(e),strokeWidth:"2"}),D("g",{fill:k1(e),stroke:Jt(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})),o0=M(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),te),n0=M(D(be,{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"})})]}),te),r0=M(D(be,{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"})})})]}),te),i0=M(D(be,{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"})})})]}),{...te,fill:"currentColor"}),Hm=M(h(be,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),te),a0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),te),l0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),te),TU=et.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:Jt(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),s0=M(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"})]}),z),c0=M(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"})]}),z),d0=M(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),te),m0=M(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),te),p0=M(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),te),u0=M(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"})]}),te),h0=M(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"})]}),z),g0=M(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"})]}),z),f0=et.memo(({flip:e=!1})=>M(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})),b0=et.memo(({flip:e=!1})=>M(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})),x0=et.memo(({flip:e=!1})=>M(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})),E0=et.memo(({flip:e=!1})=>M(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})),y0=et.memo(({flip:e=!1})=>M(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})),w0=et.memo(({flip:e=!1})=>M(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})),v0=et.memo(({flip:e=!1})=>M(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})),T0=et.memo(({flip:e=!1})=>M(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})),I0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),C0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),S0=et.memo(({flip:e=!1})=>M(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),k0=M(D(be,{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"})})})]}),te),M0=M(D(be,{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"})})})]}),te),L0=M(D(be,{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"})})})]}),te),P0=M(h(be,{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"})}),te),Hn=M(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"})]}),z),A0=M(h(be,{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"})]})}),z),Qi=M(h(be,{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"})})}),te),ql=M(D(be,{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"})})})]}),te),D0=M(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"})]}),z),_0=M(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"})]}),z),R0=M(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"})]}),z),N0=et.memo(({theme:e})=>M(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"})]}),z)),B0=et.memo(({theme:e})=>M(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"})]}),z)),F0=et.memo(({theme:e})=>M(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"})]}),z)),Jl=M(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"})]}),z),O0=M(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),IU=M(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),Ql=M(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"})]}),z),Gm=M(D(be,{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"})]}),z),Sr=M(D(be,{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"})]}),z),z0=M(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"})]}),z),H0=M(D(be,{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"})]}),z),CU=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),z),SU=M(D(be,{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"})]}),z),G0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),z),U0=M(D(be,{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"})]}),z),Y0=M(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"})]}),z),W0=M(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"})]}),z),Gn=M(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"})]}),z),es=M(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"})),kr=M(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"})]}),te),ea=M(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),ts=M(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"})]}),z),kU=M(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"})]}),z),MU=M(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"})]}),z),V0=M(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"})]}),z),Mr=M(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"})]}),z),X0=M(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"})]}),z),K0=M(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"})]}),z),Z0=M(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"})]}),z),Pt=M(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"})]}),z),$0=M(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"})]}),z),j0=M(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"})]}),z),q0=M(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"})]}),z),ta=M(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"})]}),z),J0=M(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"})]}),z),Q0=M(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"})]}),z),eb=M(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"})]}),z),tb=M(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"})]}),z),Um=M(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"})]}),z),os=M(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"})]}),z),ob=M(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"})]}),z),nb=M(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"})]}),z),rb=M(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"})]}),z),ib=M(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"})]}),z),ab=M(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"})]}),{...z,strokeWidth:1.5}),LU=M(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"})]}),z),lb=M(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"})]}),z),sb=M(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"})]}),z),cb=M(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"})]}),z),ns=M(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"})]}),z),rs=M(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"})]}),z),is=M(D("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),z),as=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),z),db=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),mb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),Ym=M(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"})]}),z),ls=M(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"})]}),z);import pb from"clsx";import Vm,{useEffect as lC,useRef as ub,useState as sC}from"react";import{isPromiseLike as cC}from"@excalidraw/common";import iC from"react";import{jsx as Wm}from"react/jsx-runtime";var aC=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:n=""})=>{let i=-(iC.useRef(Date.now()).current%1600);return Wm("div",{className:`Spinner ${n}`,children:Wm("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Wm("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},tt=aC;import{jsx as oa,jsxs as na}from"react/jsx-runtime";var K=Vm.forwardRef(({size:e="medium",visible:o=!0,className:t="",...n},r)=>{let{id:i}=Ge(),a=Vm.useRef(null);Vm.useImperativeHandle(r,()=>a.current);let l=`ToolIcon_size_${e}`,[s,d]=sC(!1),m=ub(!0),c=async u=>{let f="onClick"in n&&n.onClick?.(u);if(cC(f))try{d(!0),await f}catch(b){if(b instanceof gr)console.warn(b);else throw b}finally{m.current&&d(!1)}};lC(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=ub(null);if(n.type==="button"||n.type==="icon"||n.type==="submit"){let u=n.type==="icon"?"button":n.type;return na("button",{className:pb("ToolIcon_type_button",l,t,o&&!n.hidden?"ToolIcon_type_button--show":"ToolIcon_type_button--hide",{ToolIcon:!n.hidden,"ToolIcon--selected":n.selected,"ToolIcon--plain":n.type==="icon"}),style:n.style,"data-testid":n["data-testid"],hidden:n.hidden,title:n.title,"aria-label":n["aria-label"],type:u,onClick:c,ref:a,disabled:s||n.isLoading||!!n.disabled,children:[(n.icon||n.label)&&na("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!n.disabled,children:[n.icon||n.label,n.keyBindingLabel&&oa("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel}),n.isLoading&&oa(tt,{})]}),n.showAriaLabel&&na("div",{className:"ToolIcon__label",children:[n["aria-label"]," ",s&&oa(tt,{})]}),n.children]})}return na("label",{className:pb("ToolIcon",t),title:n.title,onPointerDown:u=>{p.current=u.pointerType||null,n.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[oa("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}),na("div",{className:"ToolIcon__icon",children:[n.icon,n.keyBindingLabel&&oa("span",{className:"ToolIcon__keybinding",children:n.keyBindingLabel})]})]})});K.displayName="ToolButton";var ss=[],B=e=>(ss=ss.concat(e),e);import{jsx as bC}from"react/jsx-runtime";var fC=(e,o,t)=>{let n=new Set(j(e.filter(m=>uC(m)),o).map(m=>m.id)),r={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of n){let c=hC(e,m);for(let p of c)if(!a.has(p.id)){if(cs(p)){let u=gb(p,i);u&&(r[u.id]=!0)}else r[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let c=cs(m)?gb(m,i):null;return m.frameId&&n.has(m.frameId)?(l=!1,r[m.id]=!0,m):c?.frameId&&n.has(c?.frameId)?m:(m.boundElements&&m.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&pC(u)&&t.scene.mutateElement(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding})}),ms(m,{isDeleted:!0}))}return m.frameId&&n.has(m.frameId)?(l=!1,cs(m)||(r[m.id]=!0),ms(m,{frameId:null})):cs(m)&&o.selectedElementIds[m.containerId]?ms(m,{isDeleted:!0}):m}),d=o.editingGroupId;if(l&&o.editingGroupId){let m=Zm(s,o.editingGroupId).filter(c=>!c.isDeleted);if(m.length>1)m[0]&&(r[m[0].id]=!0);else{d=null,m[0]&&(r[m[0].id]=!0);let c=m[0];if(c){let p=c.groupIds.findIndex(f=>f===o.editingGroupId),u=c.groupIds[p+1];if(u){let f=Zm(s,u).filter(b=>!b.isDeleted);f.length>1&&(d=u,f.forEach(b=>{r[b.id]=!0}))}}}}return{elements:s,appState:{...o,...gC({selectedElementIds:r,editingGroupId:d},s,o,null)}}},fb=(e,o)=>{if(e.editingGroupId){let t=Zm(Km(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},ra=B({name:"deleteSelectedElements",label:"labels.delete",icon:Lt,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:d}=o.selectedLinearElement,m=n.scene.getNonDeletedElementsMap(),c=hb.getElement(a,m);if(!c||l==null)return!1;if(l.length>=c.points.length){let u=e.map(b=>b.id===c.id?ms(b,{isDeleted:!0}):b),f=fb(o,u);return{elements:u,appState:{...f,selectedLinearElement:null},captureUpdate:ds.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(c.points.length-1)?null:d};return hb.deletePoints(c,n,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:ds.IMMEDIATELY}}let{elements:r,appState:i}=fC(e,o,n);return mC(r,r.filter(a=>a.isDeleted)),i=fb(i,r),{elements:r,appState:{...i,activeTool:dC(o,{type:n.defaultSelectionTool}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ee(Km(e),o)?ds.IMMEDIATELY:ds.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===Xm.BACKSPACE||e.key===Xm.DELETE)&&!e[Xm.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>bC(K,{type:"button",icon:Lt,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:Ee(Km(e),o)})});import{KEYS as Lr,CODES as Pr,getShortcutKey as Ar,isDarwin as ps}from"@excalidraw/common";import{moveOneLeft as xC,moveOneRight as EC,moveAllLeft as yC,moveAllRight as wC}from"@excalidraw/element";import{CaptureUpdateAction as us}from"@excalidraw/element";import{jsx as hs}from"react/jsx-runtime";var $m=B({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Lm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:xC(e,o,n.scene),appState:o,captureUpdate:us.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Lr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Pr.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${Ar("CtrlOrCmd+[")}`,children:Lm})}),jm=B({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Mm,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:EC(e,o,n.scene),appState:o,captureUpdate:us.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Lr.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Pr.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${Ar("CtrlOrCmd+]")}`,children:Mm})}),qm=B({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Am,trackEvent:{category:"element"},perform:(e,o)=>({elements:yC(e,o),appState:o,captureUpdate:us.IMMEDIATELY}),keyTest:e=>ps?e[Lr.CTRL_OR_CMD]&&e.altKey&&e.code===Pr.BRACKET_LEFT:e[Lr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Pr.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${ps?Ar("CtrlOrCmd+Alt+["):Ar("CtrlOrCmd+Shift+[")}`,children:Am})}),Jm=B({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Pm,trackEvent:{category:"element"},perform:(e,o)=>({elements:wC(e,o),appState:o,captureUpdate:us.IMMEDIATELY}),keyTest:e=>ps?e[Lr.CTRL_OR_CMD]&&e.altKey&&e.code===Pr.BRACKET_RIGHT:e[Lr.CTRL_OR_CMD]&&e.shiftKey&&e.code===Pr.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${ps?Ar("CtrlOrCmd+Alt+]"):Ar("CtrlOrCmd+Shift+]")}`,children:Pm})});import{getNonDeletedElements as vC}from"@excalidraw/element";import{LinearElementEditor as TC}from"@excalidraw/element";import{isLinearElement as IC,isTextElement as CC}from"@excalidraw/element";import{arrayToMap as SC,KEYS as bb}from"@excalidraw/common";import{selectGroupsForSelectedElements as kC}from"@excalidraw/element";import{CaptureUpdateAction as MC}from"@excalidraw/element";var Qm=B({name:"selectAll",label:"labels.selectAll",icon:J0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,n)=>{if(o.selectedLinearElement?.isEditing)return!1;let r=e.filter(i=>!i.isDeleted&&!(CC(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...kC({editingGroupId:null,selectedElementIds:r},vC(e),o,n),selectedLinearElement:Object.keys(r).length===1&&IC(e[0])?new TC(e[0],SC(e)):null},captureUpdate:MC.IMMEDIATELY}},keyTest:e=>e[bb.CTRL_OR_CMD]&&e.key===bb.A});import{DEFAULT_GRID_SIZE as xb,KEYS as Eb,arrayToMap as yb,getShortcutKey as LC}from"@excalidraw/common";import{getNonDeletedElements as wb}from"@excalidraw/element";import{LinearElementEditor as PC}from"@excalidraw/element";import{getSelectedElements as AC,getSelectionStateForElements as DC}from"@excalidraw/element";import{syncMovedIndices as _C}from"@excalidraw/element";import{duplicateElements as RC}from"@excalidraw/element";import{CaptureUpdateAction as vb}from"@excalidraw/element";import{jsx as NC}from"react/jsx-runtime";var ep=B({name:"duplicateSelection",label:"labels.duplicateSelection",icon:$i,trackEvent:{category:"element"},perform:(e,o,t,n)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=PC.duplicateSelectedPoints(o,n.scene);return{elements:e,appState:a,captureUpdate:vb.IMMEDIATELY}}catch{return!1}let{duplicatedElements:r,elementsWithDuplicates:i}=RC({type:"in-place",elements:e,idsOfElementsToDuplicate:yb(AC(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:({origElement:a,origIdToDuplicateId:l})=>{let s=a.frameId&&l.get(a.frameId);return{x:a.x+xb/2,y:a.y+xb/2,frameId:s??a.frameId}}});if(n.props.onDuplicate&&i){let a=n.props.onDuplicate(i,e);a&&(i=a)}return{elements:_C(i,yb(r)),appState:{...o,...DC(r,wb(i),o)},captureUpdate:vb.IMMEDIATELY}},keyTest:e=>e[Eb.CTRL_OR_CMD]&&e.key===Eb.D,PanelComponent:({elements:e,appState:o,updateData:t})=>NC(K,{type:"button",icon:$i,title:`${g("labels.duplicateSelection")} \u2014 ${LC("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:Ee(wb(e),o)})});import{pointFrom as B6}from"@excalidraw/math";import{useEffect as vp,useMemo as F6,useRef as Tp,useState as O6}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as z6,DEFAULT_ELEMENT_BACKGROUND_PICKS as H6,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as G6,DEFAULT_ELEMENT_STROKE_PICKS as U6,ARROW_TYPE as Po,DEFAULT_FONT_FAMILY as Y6,DEFAULT_FONT_SIZE as W6,FONT_FAMILY as V6,ROUNDNESS as As,STROKE_WIDTH as Ip,VERTICAL_ALIGN as Ps,KEYS as Ur,randomInteger as X6,arrayToMap as kp,getFontFamilyString as K6,getShortcutKey as Z6,getLineHeight as $6,isTransparent as j6,reduceToCommonValue as q6}from"@excalidraw/common";import{canBecomePolygon as J6,getNonDeletedElements as cx}from"@excalidraw/element";import{bindLinearElement as ix,calculateFixedPointForElbowArrowBinding as ax,updateBoundElements as Q6}from"@excalidraw/element";import{LinearElementEditor as Cp}from"@excalidraw/element";import{newElementWith as Ke}from"@excalidraw/element";import{getBoundTextElement as ln,redrawTextBoundingBox as ha}from"@excalidraw/element";import{isArrowElement as Ds,isBoundToContainer as e4,isElbowArrow as dx,isLinearElement as Sp,isLineElement as lx,isTextElement as xt,isUsingAdaptiveRadius as t4}from"@excalidraw/element";import{hasStrokeColor as o4}from"@excalidraw/element";import{updateElbowArrowPoints as n4,CaptureUpdateAction as Ze,toggleLinePolygonState as r4}from"@excalidraw/element";import{isDevEnv as BC}from"@excalidraw/common";var FC=new Set(["command_palette","export"]),ne=(e,o,t,n)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!FC.has(e)||BC())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:n}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:n})}catch(r){console.error("error during analytics",r)}};import GC from"clsx";import OC from"clsx";import{forwardRef as zC}from"react";import{jsx as HC}from"react/jsx-runtime";var Dr=zC((e,o)=>{let{title:t,className:n,testId:r,active:i,standalone:a,icon:l,onClick:s}=e;return HC("button",{type:"button",ref:o,title:t,"data-testid":r,className:OC(n,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as YC,jsx as tp,jsxs as UC}from"react/jsx-runtime";var Ot=e=>tp(YC,{children:e.options.map(o=>e.type==="button"?tp(Dr,{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):UC("label",{className:GC({active:e.value===o.value}),title:o.text,children:[tp("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 ws from"@radix-ui/react-popover";import US from"clsx";import{useRef as YS}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as WS,COLOR_PALETTE as Gb,isTransparent as VS}from"@excalidraw/common";import{jsx as WC}from"react/jsx-runtime";var gs=()=>WC("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as $C,useRef as jC}from"react";import{createPortal as qC}from"react-dom";import{EVENT as en,KEYS as JC,rgbToHex as QC}from"@excalidraw/common";import Tb from"react";var op=Tb.createContext(null),ge=()=>Tb.useContext(op);import{useState as VC,useLayoutEffect as Ib}from"react";import{THEME as XC}from"@excalidraw/common";var fs=e=>{let[o,t]=VC(null),n=se(),{theme:r}=ge(),{container:i}=Ge();return Ib(()=>{o&&(o.className="",o.classList.add("excalidraw",...e?.className?.split(/\s+/)||[]),o.classList.toggle("excalidraw--mobile",n.editor.isMobile),o.classList.toggle("theme--dark",r===XC.DARK))},[o,r,n.editor.isMobile,e?.className]),Ib(()=>{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 KC}from"react";import{EVENT as bs}from"@excalidraw/common";function _r(e,o,t){KC(()=>{function n(r){let i=r;if(!e.current)return;let a=t?.(i,e.current);if(a===!0)return;if(a===!1)return o(i);e.current.contains(i.target)||!document.documentElement.contains(i.target)||i.target.closest("[data-radix-portal]")||i.target===document.documentElement&&document.body.style.pointerEvents==="none"||i.target.closest("[data-prevent-outside-click]")||o(i)}return document.addEventListener(bs.POINTER_DOWN,n),document.addEventListener(bs.TOUCH_START,n),()=>{document.removeEventListener(bs.POINTER_DOWN,n),document.removeEventListener(bs.TOUCH_START,n)}},[e,o,t])}import{useRef as ZC}from"react";var Qo=e=>{let o=ZC(e);return Object.assign(o.current,e),o.current};import{jsx as eS}from"react/jsx-runtime";var tn=me(null),Cb=({onCancel:e,onChange:o,onSelect:t,colorPickerType:n})=>{let r=fs({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ge(),a=on(),l=Re(),s=j(a,i),d=Qo({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=Ge();$C(()=>{let p=c.current;if(!p||!l.canvas||!r)return;let u=!1,f=l.canvas.getContext("2d"),b=({clientX:S,clientY:L})=>{let k=f.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(L-i.offsetTop)*window.devicePixelRatio,1,1).data;return QC(k[0],k[1],k[2])},x=({clientX:S,clientY:L,altKey:k})=>{p.style.top=`${L+20}px`,p.style.left=`${S+20}px`;let A=b({clientX:S,clientY:L});u&&d.onChange(n,A,d.selectedElements,{altKey:k}),p.style.background=A},w=()=>{d.onCancel()},E=(S,L)=>{d.onSelect(S,L)},y=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,m?.focus(),S.stopImmediatePropagation(),S.preventDefault(),E(b(S),S)},C=S=>{S.key===JC.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),w())};return r.tabIndex=-1,r.focus(),x({clientX:d.app.lastViewportPosition.x,clientY:d.app.lastViewportPosition.y,altKey:!1}),r.addEventListener(en.KEYDOWN,C),r.addEventListener(en.POINTER_DOWN,y),r.addEventListener(en.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(en.BLUR,w),()=>{u=!1,r.removeEventListener(en.KEYDOWN,C),r.removeEventListener(en.POINTER_DOWN,y),r.removeEventListener(en.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(en.BLUR,w)}},[d,l.canvas,r,n,m,i.offsetLeft,i.offsetTop]);let c=jC(null);return _r(c,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),r?qC(eS("div",{ref:c,className:"excalidraw-eye-dropper-preview"}),r):null};import*as Rr from"@radix-ui/react-popover";import rS from"clsx";import iS from"react";import{isInteractive as aS}from"@excalidraw/common";import tS from"react";import oS from"clsx";import{jsx as nS}from"react/jsx-runtime";var Xe=tS.forwardRef(({children:e,padding:o,className:t,style:n},r)=>nS("div",{className:oS("Island",t),style:{"--padding":o,...n},ref:r,children:e}));import{jsx as np,jsxs as lS}from"react/jsx-runtime";var xs=iS.forwardRef(({className:e,container:o,children:t,style:n,onClose:r,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},d)=>{let m=se();return np(Rr.Portal,{container:o,children:lS(Rr.Content,{ref:d,className:rS("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:c=>{c.stopPropagation(),c.preventDefault(),o&&!aS(document.activeElement)&&o.focus(),r()},children:[np(Xe,{padding:3,style:n,children:t}),np(Rr.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import cS from"clsx";import{useCallback as dS,useEffect as ip,useRef as Mb,useState as mS}from"react";import{KEYS as ap,getShortcutKey as pS}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as sS}from"@excalidraw/common";var nn=({palette:e,color:o})=>{if(!o)return null;for(let[t,n]of Object.entries(e))if(Array.isArray(n)){let r=n.indexOf(o);if(r>-1)return{colorName:t,shade:r}}else if(n===o)return{colorName:t,shade:null};return null},ia=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),rp=({color:e,palette:o})=>!Object.values(o).flat().includes(e),kb=(e,o,t)=>{let n={elementBackground:"backgroundColor",elementStroke:"strokeColor"},r=e.filter(a=>{if(a.isDeleted)return!1;let l=a[n[o]];return rp({color:l,palette:t})}),i=new Map;return r.forEach(a=>{let l=a[n[o]];i.has(l)?i.set(l,i.get(l)+1):i.set(l,1)}),[...i.entries()].sort((a,l)=>l[1]-a[1]).map(a=>a[0]).slice(0,sS)},zt=me(null),Sb=(e,o,t)=>(e*299+o*587+t*114)/1e3,Nr=(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]),d=parseInt(l[1]),m=parseInt(l[2]);return Sb(s,d,m)<o}return!0}let t=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),r=parseInt(e.slice(5,7),16);return Sb(t,n,r)<o};import{Fragment as uS,jsx as Es,jsxs as Lb}from"react/jsx-runtime";var Pb=({color:e,onChange:o,label:t,colorPickerType:n,placeholder:r})=>{let i=se(),[a,l]=mS(e),[s,d]=ie(zt);ip(()=>{l(e)},[e]);let m=dS(b=>{let x=b.toLowerCase(),w=Ab(x);w&&o(w),l(x)},[o]),c=Mb(null),p=Mb(null);ip(()=>{c.current&&c.current.focus()},[s]);let[u,f]=ie(tn);return ip(()=>()=>{f(null)},[f]),Lb("div",{className:"color-picker__input-label",children:[Es("div",{className:"color-picker__input-hash",children:"#"}),Es("input",{ref:s==="hex"?c:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:b=>{m(b.target.value)},value:(a||"").replace(/^#/,""),onBlur:()=>{l(e)},tabIndex:-1,onFocus:()=>d("hex"),onKeyDown:b=>{b.key!==ap.TAB&&(b.key===ap.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:r}),!i.editor.isMobile&&Lb(uS,{children:[Es("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Es("div",{ref:p,className:cS("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:n}),title:`${g("labels.eyeDropper")} \u2014 ${ap.I.toLocaleUpperCase()} or ${pS("Alt")} `,children:Y0})]})]})};import dp,{useEffect as mp,useImperativeHandle as DS,useState as _S}from"react";import{EVENT as Fb}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as RS,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as NS,KEYS as BS}from"@excalidraw/common";import fS from"clsx";import{useEffect as bS,useRef as xS}from"react";import{jsxs as gS}from"react/jsx-runtime";var hS=({color:e,keyLabel:o,isShade:t=!1})=>gS("div",{className:"color-picker__button__hotkey-label",style:{color:Nr(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Br=hS;import{jsx as lp,jsxs as ES}from"react/jsx-runtime";var Db=({colors:e,color:o,onChange:t,label:n})=>{let[r,i]=ie(zt),a=xS(null);return bS(()=>{a.current&&a.current.focus()},[o,r]),lp("div",{className:"color-picker-content--default",children:e.map((l,s)=>ES("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:fS("color-picker__button color-picker__button--large has-outline",{active:o===l,"is-transparent":l==="transparent"||!l}),onClick:()=>{t(l),i("custom")},title:l,"aria-label":n,style:{"--swatch-color":l},children:[lp("div",{className:"color-picker__button-outline"}),lp(Br,{color:l,keyLabel:s+1})]},s))})};import yS from"clsx";import{useEffect as wS,useRef as vS}from"react";import{jsx as sp,jsxs as IS}from"react/jsx-runtime";var TS=({palette:e,color:o,onChange:t,activeShade:n})=>{let r=nn({color:o,palette:e}),[i,a]=ie(zt),l=vS(null);return wS(()=>{l.current&&i==="baseColors"&&l.current.focus()},[r?.colorName,i]),sp("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,d],m)=>{let c=(Array.isArray(d)?d[n]:d)||"transparent",p=ia[m],u=g(`colors.${s.replace(/\d+/,"")}`,null,"");return IS("button",{ref:r?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:yS("color-picker__button color-picker__button--large has-outline",{active:r?.colorName===s,"is-transparent":c==="transparent"||!c}),onClick:()=>{t(c),a("baseColors")},title:`${u}${c.startsWith("#")?` ${c}`:""} \u2014 ${p}`,"aria-label":`${u} \u2014 ${p}`,style:c?{"--swatch-color":c}:void 0,"data-testid":`color-${s}`,children:[sp("div",{className:"color-picker__button-outline"}),sp(Br,{color:c,keyLabel:p})]},s)})})},_b=TS;import{jsx as SS}from"react/jsx-runtime";var CS=({children:e})=>SS("div",{className:"color-picker__heading",children:e}),Fr=CS;import kS from"clsx";import{useEffect as MS,useRef as LS}from"react";import{jsx as aa,jsxs as Rb}from"react/jsx-runtime";var Nb=({color:e,onChange:o,palette:t})=>{let n=nn({color:e||"transparent",palette:t}),[r,i]=ie(zt),a=LS(null);if(MS(()=>{a.current&&r==="shades"&&a.current.focus()},[n,r]),n){let{colorName:l,shade:s}=n,d=t[l];if(Array.isArray(d))return aa("div",{className:"color-picker-content--default shades",children:d.map((m,c)=>Rb("button",{ref:c===s&&r==="shades"?a:void 0,tabIndex:-1,type:"button",className:kS("color-picker__button color-picker__button--large has-outline",{active:c===s}),"aria-label":"Shade",title:`${l} - ${c+1}`,style:m?{"--swatch-color":m}:void 0,onClick:()=>{o(m),i("shades")},children:[aa("div",{className:"color-picker__button-outline"}),aa(Br,{color:m,keyLabel:c+1,isShade:!0})]},c))})}return Rb("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[aa("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),aa("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:g("colorPicker.noShades")})]})};import{COLORS_PER_ROW as Or,COLOR_PALETTE as PS,KEYS as la}from"@excalidraw/common";var cp=(e,o,t)=>{let n=Math.ceil(t/Or);switch(o=o??-1,e){case"ArrowLeft":{let r=o-1;return r<0?t-1:r}case"ArrowRight":return(o+1)%t;case"ArrowDown":{let r=o+Or;return r>=t?o%Or:r}case"ArrowUp":{let r=o-Or,i=r<0?Or*n+r:r;return i>=t?void 0:i}}},AS=({e,colorObj:o,onChange:t,palette:n,customColors:r,setActiveColorPickerSection:i,activeShade:a})=>{if(o?.shade!=null&&["Digit1","Digit2","Digit3","Digit4","Digit5"].includes(e.code)&&e.shiftKey){let l=Number(e.code.slice(-1))-1;return t(n[o.colorName][l]),i("shades"),!0}if(["1","2","3","4","5"].includes(e.key)&&r[Number(e.key)-1])return t(r[Number(e.key)-1]),i("custom"),!0;if(ia.includes(e.key)){let l=ia.indexOf(e.key),s=Object.keys(n)[l],d=n[s],m=Array.isArray(d)?d[a]:d;return t(m),i("baseColors"),!0}return!1},Bb=({event:e,activeColorPickerSection:o,palette:t,color:n,onChange:r,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:d,onEscape:m})=>{if(e[la.CTRL_OR_CMD])return!1;if(e.key===la.ESCAPE)return m(e),!0;if(e.key===la.ALT)return d(!0),!0;if(e.key===la.I)return d(),!0;let c=nn({color:n,palette:t});if(e.key===la.TAB){let p={custom:!!i.length,baseColors:!0,shades:c?.shade!=null,hex:!0},u=Object.entries(p).reduce((E,[y,v])=>(v&&E.push(y),E),[]),f=u.indexOf(o),b=e.shiftKey?-1:1,x=f+b>u.length-1?0:f+b<0?u.length-1:f+b,w=u[x];return w&&a(w),w==="custom"?r(i[0]):w==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(n):v===n?y:null)||r(PS.black)),e.preventDefault(),e.stopPropagation(),!0}if(AS({e,colorObj:c,onChange:r,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&c){let{shade:p}=c,u=cp(e.key,p,Or);if(u!==void 0)return r(t[c.colorName][u]),!0}if(o==="baseColors"&&c){let{colorName:p}=c,u=Object.keys(t),f=u.indexOf(p),b=cp(e.key,f,u.length);if(b!==void 0){let x=u[b],w=t[x];return r(Array.isArray(w)?w[s]:w),!0}}if(o==="custom"){let p=n!=null?i.indexOf(n):0,u=cp(e.key,p,i.length);if(u!==void 0){let f=i[u];return r(f),!0}}return!1};import{jsx as Un,jsxs as ys}from"react/jsx-runtime";var Ob=dp.forwardRef(({color:e,onChange:o,type:t,elements:n,palette:r,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},d)=>{let[m]=dp.useState(()=>t==="canvasBackground"?[]:kb(n,t,r)),[c,p]=ie(zt),u=nn({color:e,palette:r});mp(()=>{if(!c){let w=!!e&&rp({color:e,palette:r}),E=w&&!m.includes(e);p(E?null:w?"custom":u?.shade!=null?"shades":"baseColors")}},[c,e,r,p,u,m]);let[f,b]=_S(u?.shade??(t==="elementBackground"?RS:NS));mp(()=>{u?.shade!=null&&b(u.shade);let w=E=>{E.key===BS.ALT&&l(!1)};return document.addEventListener(Fb.KEYUP,w,{capture:!0}),()=>{document.removeEventListener(Fb.KEYUP,w,{capture:!0})}},[u,l]);let x=dp.useRef(null);return DS(d,()=>x.current),mp(()=>{x?.current?.focus()},[]),Un("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:ys("div",{ref:x,onKeyDown:w=>{Bb({event:w,activeColorPickerSection:c,palette:r,color:e,onChange:o,onEyeDropperToggle:l,customColors:m,setActiveColorPickerSection:p,updateData:i,activeShade:f,onEscape:s})&&(w.preventDefault(),w.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!m.length&&ys("div",{children:[Un(Fr,{children:g("colorPicker.mostUsedCustomColors")}),Un(Db,{colors:m,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),ys("div",{children:[Un(Fr,{children:g("colorPicker.colors")}),Un(_b,{color:e,palette:r,onChange:o,activeShade:f})]}),ys("div",{children:[Un(Fr,{children:g("colorPicker.shades")}),Un(Nb,{color:e,onChange:o,palette:r})]}),a]})})});import FS from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as OS,DEFAULT_CANVAS_BACKGROUND_PICKS as zS,DEFAULT_ELEMENT_BACKGROUND_PICKS as HS,DEFAULT_ELEMENT_STROKE_PICKS as GS}from"@excalidraw/common";import{jsx as pp}from"react/jsx-runtime";var zb=({onChange:e,type:o,activeColor:t,topPicks:n})=>{let r;return o==="elementStroke"&&(r=GS),o==="elementBackground"&&(r=HS),o==="canvasBackground"&&(r=zS),n&&(r=n),r?pp("div",{className:"color-picker__top-picks",children:r.map(i=>pp("button",{className:FS("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!Nr(i,OS)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:pp("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Qt,jsxs as up}from"react/jsx-runtime";var Hb=e=>{let o=new Option().style;return o.color=e,!!o.color},Ab=e=>VS(e)?e:Hb(`#${e}`)?`#${e}`:Hb(e)?e:null,XS=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=Gb,updateData:a})=>{let{container:l}=Ge(),[,s]=ie(zt),[d,m]=ie(tn),c=up("div",{children:[Qt(Fr,{children:g("colorPicker.hexCode")}),Qt(Pb,{color:o||"",label:n,onChange:f=>{t(f)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),p=YS(null),u=()=>{p.current?.focus()};return Qt(xs,{container:l,style:{maxWidth:"13rem"},onFocusOutside:f=>{u(),f.preventDefault()},onPointerDownOutside:f=>{d&&f.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?Qt(Ob,{ref:p,palette:i,color:o,onChange:f=>{t(f)},onEyeDropperToggle:f=>{m(b=>f?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):f===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:f=>{d?m(null):a({openPopup:null})},type:e,elements:r,updateData:a,children:c}):c})},KS=({label:e,color:o,type:t})=>Qt(ws.Trigger,{type:"button",className:US("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!Nr(o,WS)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),children:Qt("div",{className:"color-picker__button-outline",children:!o&&K1})}),sa=({type:e,color:o,onChange:t,label:n,elements:r,palette:i=Gb,topPicks:a,updateData:l,appState:s})=>Qt("div",{children:up("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[Qt(zb,{activeColor:o,onChange:t,type:e,topPicks:a}),Qt(gs,{}),up(ws.Root,{open:s.openPopup===e,onOpenChange:d=>{l({openPopup:d?e:null})},children:[Qt(KS,{color:o,label:n,type:e}),s.openPopup===e&&Qt(XS,{type:e,color:o,onChange:t,label:n,elements:r,palette:i,updateData:l})]})]})});import*as qb from"@radix-ui/react-popover";import T6,{useCallback as I6,useMemo as C6}from"react";import{FONT_FAMILY as xp}from"@excalidraw/common";import u6,{useMemo as rn,useState as h6,useRef as g6,useEffect as f6,useCallback as b6}from"react";import{arrayToList as x6,debounce as E6,FONT_FAMILY as Yn,getFontFamilyString as y6}from"@excalidraw/common";import ZS from"clsx";import $S from"react";import{jsx as jS,jsxs as qS}from"react/jsx-runtime";var vs=$S.forwardRef(({className:e,placeholder:o,onChange:t},n)=>qS("div",{className:ZS("QuickSearch__wrapper",e),children:[Pt,jS("input",{ref:n,className:"QuickSearch__input",type:"text",placeholder:o,onChange:r=>t(r.target.value.trim().toLowerCase())})]}));import JS from"clsx";import{Children as QS}from"react";import{jsx as Ub}from"react/jsx-runtime";var Ts=({className:e,placeholder:o,children:t})=>{let n=!QS.count(t);return Ub("div",{className:JS("ScrollableList__wrapper",e),role:"menu",children:n?Ub("div",{className:"empty",children:o}):t})};import{jsx as e6,jsxs as t6}from"react/jsx-runtime";var Yb=({children:e,className:o="",style:t,title:n})=>t6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[n&&e6("p",{className:"dropdown-menu-group-title",children:n}),e]}),ca=Yb;Yb.displayName="DropdownMenuGroup";import{useEffect as d6,useRef as m6}from"react";import{THEME as p6}from"@excalidraw/common";import{jsx as o6}from"react/jsx-runtime";var da=({children:e,...o})=>o6("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as r6,jsx as Is,jsxs as i6}from"react/jsx-runtime";var n6=({textStyle:e,icon:o,shortcut:t,children:n})=>{let r=se();return i6(r6,{children:[o&&Is("div",{className:"dropdown-menu-item__icon",children:o}),Is("div",{style:e,className:"dropdown-menu-item__text",children:Is(da,{children:n})}),t&&!r.editor.isMobile&&Is("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Cs=n6;import a6,{useContext as l6}from"react";import{EVENT as s6,composeEventHandlers as c6}from"@excalidraw/common";var hp=a6.createContext({}),Ss=(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(),ks=(e,o)=>{let t=l6(hp);return c6(e,n=>{let r=new CustomEvent(s6.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(r),r.defaultPrevented||t.onSelect?.(r)})};import{jsx as gp}from"react/jsx-runtime";var fp=({icon:e,value:o,order:t,children:n,shortcut:r,className:i,hovered:a,selected:l,textStyle:s,onSelect:d,onClick:m,...c})=>{let p=ks(m,d),u=m6(null);return d6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),gp("button",{...c,ref:u,value:o,onClick:p,className:Ss(i,l,a),title:c.title??c["aria-label"],children:gp(Cs,{textStyle:s,icon:e,shortcut:r,children:n})})};fp.displayName="DropdownMenuItem";var zr={GREEN:"green",RED:"red",BLUE:"blue"},Ms=({type:e=zr.BLUE,children:o})=>{let{theme:t}=go(),n={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===p6.LIGHT?"1.5px solid white":"none"};switch(e){case zr.GREEN:Object.assign(n,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case zr.RED:Object.assign(n,{backgroundColor:"pink",color:"darkred"});break;case zr.BLUE:default:Object.assign(n,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return gp("div",{className:"DropDownMenuItemBadge",style:n,children:o})};Ms.displayName="DropdownMenuItemBadge";fp.Badge=Ms;var pt=fp;import{KEYS as Hr}from"@excalidraw/common";var Wb=({event:e,inputRef:o,hoveredFont:t,filteredFonts:n,onClose:r,onSelect:i,onHover:a})=>{if(!e[Hr.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===Hr.F)return o.current?.focus(),!0;if(e.key===Hr.ESCAPE)return r(),!0;if(e.key===Hr.ENTER)return t?.value&&i(t.value),!0;if(e.key===Hr.ARROW_DOWN)return t?.next?a(t.next.value):n[0]?.value&&a(n[0].value),!0;if(e.key===Hr.ARROW_UP)return t?.prev?a(t.prev.value):n[n.length-1]?.value&&a(n[n.length-1].value),!0};import{jsx as ma,jsxs as Vb}from"react/jsx-runtime";var w6=e=>{switch(e){case Yn.Excalifont:case Yn.Virgil:return Jo;case Yn.Nunito:case Yn.Helvetica:return Qi;case Yn["Lilita One"]:return A0;case Yn["Comic Shanns"]:case Yn.Cascadia:return ql;default:return Qi}},Xb=u6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:n,onLeave:r,onOpen:i,onClose:a})=>{let{container:l}=Ge(),{fonts:s}=Re(),{showDeprecatedFonts:d}=fo(),[m,c]=h6(""),p=g6(null),u=rn(()=>Array.from($o.registered.entries()).filter(([k,{metadata:A}])=>!A.private&&!A.fallback).map(([k,{metadata:A,fontFaces:P}])=>{let N={value:k,icon:w6(k),text:P[0]?.fontFace?.family??"Unknown"};return A.deprecated&&Object.assign(N,{deprecated:A.deprecated,badge:{type:zr.RED,placeholder:g("fontList.badge.old")}}),N}).sort((k,A)=>k.text.toLowerCase()>A.text.toLowerCase()?1:-1),[]),f=rn(()=>new Set(s.getSceneFamilies()),[e]),b=rn(()=>u.filter(k=>f.has(k.value)),[u,f]),x=rn(()=>u.filter(k=>!f.has(k.value)&&(d||!k.deprecated)),[u,f,d]),w=rn(()=>x6([...b,...x].filter(k=>k.text?.toLowerCase().includes(m))),[b,x,m]),E=rn(()=>{let k;return o?k=w.find(A=>A.value===o):e&&(k=w.find(A=>A.value===e)),!k&&m&&(w[0]?.value?n(w[0].value):r()),k},[o,e,m,w,n,r]),y=b6(k=>{Wb({event:k,inputRef:p,hoveredFont:E,filteredFonts:w,onSelect:t,onHover:n,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[E,w,t,n,a]);f6(()=>(i(),()=>{a()}),[]);let v=rn(()=>w.filter(k=>f.has(k.value)),[w,f]),C=rn(()=>w.filter(k=>!f.has(k.value)),[w,f]),S=(k,A)=>Vb(pt,{icon:k.icon,value:k.value,order:A,textStyle:{fontFamily:y6({fontFamily:k.value})},hovered:k.value===E?.value,selected:k.value===e,tabIndex:k.value===e?0:-1,onClick:P=>{t(Number(P.currentTarget.value))},onMouseMove:()=>{E?.value!==k.value&&n(k.value)},children:[k.text,k.badge&&ma(Ms,{type:k.badge.type,children:k.badge.placeholder})]},k.value),L=[];return v.length&&L.push(ma(ca,{title:g("fontList.sceneFonts"),children:v.map(S)},"group_1")),C.length&&L.push(ma(ca,{title:g("fontList.availableFonts"),children:C.map((k,A)=>S(k,A+v.length))},"group_2")),Vb(xs,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:r,onKeyDown:y,children:[ma(vs,{ref:p,placeholder:g("quickSearch.placeholder"),onChange:E6(c,20)}),ma(Ts,{className:"dropdown-menu fonts manual-hover",placeholder:g("fontList.empty"),children:L.length?L:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Kb from"@radix-ui/react-popover";import{useMemo as v6}from"react";import{jsx as bp}from"react/jsx-runtime";var Zb=({selectedFontFamily:e})=>{let o=v6(()=>!!(e&&!$b(e)),[e]);return bp(Kb.Trigger,{asChild:!0,children:bp("div",{children:bp(Dr,{standalone:!0,icon:Tr,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as pa,jsxs as jb}from"react/jsx-runtime";var Jb=[{value:xp.Excalifont,icon:Jo,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:xp.Nunito,icon:Qi,text:g("labels.normal"),testId:"font-family-normal"},{value:xp["Comic Shanns"],icon:ql,text:g("labels.code"),testId:"font-family-code"}],S6=new Set(Jb.map(e=>e.value)),$b=e=>e?S6.has(e):!1,Qb=T6.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:n,onHover:r,onLeave:i,onPopupChange:a})=>{let l=C6(()=>Jb,[]),s=I6(d=>{d&&n(d)},[n]);return jb("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[pa("div",{className:"buttonList",children:pa(Ot,{type:"button",options:l,value:o,onClick:s})}),pa(gs,{}),jb(qb.Root,{open:e,onOpenChange:a,children:[pa(Zb,{selectedFontFamily:o}),e&&pa(Xb,{selectedFontFamily:o,hoveredFontFamily:t,onSelect:s,onHover:r,onLeave:i,onOpen:()=>a(!0),onClose:()=>a(!1)})]})]})},(e,o)=>e.isOpened===o.isOpened&&e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Gr from"@radix-ui/react-popover";import P6 from"clsx";import Ls,{useEffect as A6}from"react";import{isArrowKey as D6,KEYS as Lo}from"@excalidraw/common";import{jsx as k6}from"react/jsx-runtime";var an=({icon:e})=>k6("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 L6,jsx as ex,jsxs as tx}from"react/jsx-runtime";var M6=({label:e,open:o,openTrigger:t,children:n,className:r,showCollapsedIcon:i=!0})=>tx(L6,{children:[tx("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:r,onClick:t,children:[e,i&&ex(an,{icon:o?db:as})]}),o&&ex("div",{style:{display:"flex",flexDirection:"column"},children:n})]}),ua=M6;import{jsx as Wn,jsxs as Ep}from"react/jsx-runtime";var _6=me(!1);function R6({options:e,value:o,label:t,onChange:n,onClose:r,numberOfOptionsToAlwaysShow:i=e.length}){let a=se(),l=u=>{let f=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&f)n(f.value),u.preventDefault();else if(u.key===Lo.TAB){let b=e.findIndex(w=>w.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;n(e[x].value)}else if(D6(u.key)){let b=Mo().rtl,x=e.findIndex(w=>w.value===o);if(x!==-1){let w=e.length,E=x;switch(u.key){case(b?Lo.ARROW_LEFT:Lo.ARROW_RIGHT):E=(x+1)%w;break;case(b?Lo.ARROW_RIGHT:Lo.ARROW_LEFT):E=(w+x-1)%w;break;case Lo.ARROW_DOWN:{E=(x+(i??1))%w;break}case Lo.ARROW_UP:{E=(w+x-(i??1))%w;break}}n(e[E].value)}u.preventDefault()}else(u.key===Lo.ESCAPE||u.key===Lo.ENTER)&&(u.preventDefault(),r());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,d]=ie(_6),m=Ls.useMemo(()=>e.slice(0,i),[e,i]),c=Ls.useMemo(()=>e.slice(i),[e,i]);A6(()=>{m.some(u=>u.value===o)||d(!0)},[o,m,d]);let p=u=>Wn("div",{className:"picker-content",children:u.map((f,b)=>Ep("button",{type:"button",className:P6("picker-option",{active:o===f.value}),onClick:x=>{n(f.value)},title:`${f.text} ${f.keyBinding&&`\u2014 ${f.keyBinding.toUpperCase()}`}`,"aria-label":f.text||"none","aria-keyshortcuts":f.keyBinding||void 0,ref:x=>{o===f.value&&setTimeout(()=>{x?.focus()},0)},children:[f.icon,f.keyBinding&&Wn("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return Wn(Gr.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:Ep("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(m),c.length>0&&Wn(ua,{label:g("labels.more_options"),open:s,openTrigger:()=>{d(u=>!u)},className:"picker-collapsible",children:p(c)})]})})}function yp({value:e,label:o,options:t,onChange:n,group:r="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Ls.useState(!1),s=Ls.useRef(null);return Wn("div",{children:Ep(Gr.Root,{open:a,onOpenChange:d=>l(d),children:[Wn(Gr.Trigger,{name:r,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(d=>d.value===e)?.icon}),a&&Wn(R6,{options:t,value:e,label:o,onChange:n,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import ox,{useEffect as N6}from"react";import{jsx as wp,jsxs as nx}from"react/jsx-runtime";var rx=({updateData:e,app:o,testId:t})=>{let n=ox.useRef(null),r=ox.useRef(null),i=o.scene.getSelectedElements(o.state),a=!0,l=i.at(0),d=i.reduce((m,c)=>(m!=null&&m!==c.opacity&&(a=!1),m==null||m>c.opacity?c.opacity:m),l?.opacity??null)??o.state.currentItemOpacity;return N6(()=>{if(n.current&&r.current){let m=n.current,c=r.current,p=m.offsetWidth,u=15,f=d/100*(p-u)+u/2;c.style.left=`${f}px`,m.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${d}%, var(--button-bg) ${d}%, var(--button-bg) 100%)`}},[d]),nx("label",{className:"control-label",children:[g("labels.opacity"),nx("div",{className:"range-wrapper",children:[wp("input",{style:{"--color-slider-track":a?void 0:"var(--button-bg)"},ref:n,type:"range",min:"0",max:"100",step:"10",onChange:m=>{e(+m.target.value)},value:d,className:"range-input","data-testid":t}),wp("div",{className:"value-bubble",ref:r,children:d!==0?d:null}),wp("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as px,jsx as Q,jsxs as yt}from"react/jsx-runtime";var mx=.1,ut=(e,o,t,n=!1)=>{let r=kp(j(e,o,{includeBoundTextElement:n}));return e.map(i=>r.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},Et=function(e,o,t,n,r){let i=o.state.editingTextElement,a=cx(e),l=null;if(i&&(l=t(i)),!l)if(Ee(a,o.state)){let d=o.scene.getSelectedElements(o.state),m=n===!0?d:d.filter(c=>n(c));l=q6(m,t)??(typeof r=="function"?r(!0):r)}else l=typeof r=="function"?r(!1):r;return l},i4=(e,o,t)=>e4(o)||!o.autoResize?o:t.mutateElement(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2}),Mp=(e,o,t,n,r)=>{let i=new Set,a=ut(e,o,l=>{if(xt(l)){let s=n(l);i.add(s);let d=Ke(l,{fontSize:s});return ha(d,t.scene.getContainerElement(l),t.scene),d=i4(l,d,t.scene),d}return l},!0);return j(e,o,{includeBoundTextElement:!0}).forEach(l=>{xt(l)&&Q6(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:r??o.currentItemFontSize},captureUpdate:Ze.IMMEDIATELY}},a4=B({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:ut(e,o,n=>o4(n.type)?Ke(n,{strokeColor:t.currentItemStrokeColor}):n,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?Ze.IMMEDIATELY:Ze.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yt(px,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.stroke")}),Q(sa,{topPicks:U6,palette:G6,type:"elementStroke",label:g("labels.stroke"),color:Et(e,n,r=>r.strokeColor,!0,r=>r?null:o.currentItemStrokeColor),onChange:r=>t({currentItemStrokeColor:r}),elements:e,appState:o,updateData:t})]})}),l4=B({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,n)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:Ze.EVENTUALLY};let r,i=n.scene.getSelectedElements(o);if(!j6(t.currentItemBackgroundColor)&&i.every(l=>lx(l)&&J6(l.points))){let l=kp(i);r=e.map(s=>l.has(s.id)&&lx(s)?Ke(s,{backgroundColor:t.currentItemBackgroundColor,...r4(s,!0)}):s)}else r=ut(e,o,l=>Ke(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:r,appState:{...o,...t},captureUpdate:Ze.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yt(px,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.background")}),Q(sa,{topPicks:H6,palette:z6,type:"elementBackground",label:g("labels.background"),color:Et(e,n,r=>r.backgroundColor,!0,r=>r?null:o.currentItemBackgroundColor),onChange:r=>t({currentItemBackgroundColor:r}),elements:e,appState:o,updateData:t})]})}),s4=B({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,n)=>(ne("element","changeFillStyle",`${t} (${n.device.editor.isMobile?"mobile":"desktop"})`),{elements:ut(e,o,r=>Ke(r,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=j(e,o),i=r.length>0&&r.every(a=>a.fillStyle==="zigzag");return yt("fieldset",{children:[Q("legend",{children:g("labels.fill")}),Q("div",{className:"buttonList",children:Q(Ot,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${Z6("Alt-Click")})`,icon:i?o0:n0,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:r0,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:i0,testId:"fill-solid"}],value:Et(e,n,a=>a.fillStyle,a=>a.hasOwnProperty("fillStyle"),a=>a?null:o.currentItemFillStyle),onClick:(a,l)=>{let s=l.altKey&&a==="hachure"&&r.every(d=>d.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),c4=B({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ke(n,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yt("fieldset",{children:[Q("legend",{children:g("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"stroke-width",options:[{value:Ip.thin,text:g("labels.thin"),icon:Hm,testId:"strokeWidth-thin"},{value:Ip.bold,text:g("labels.bold"),icon:a0,testId:"strokeWidth-bold"},{value:Ip.extraBold,text:g("labels.extraBold"),icon:l0,testId:"strokeWidth-extraBold"}],value:Et(e,n,r=>r.strokeWidth,r=>r.hasOwnProperty("strokeWidth"),r=>r?null:o.currentItemStrokeWidth),onChange:r=>t(r)})})]})}),d4=B({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ke(n,{seed:X6(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yt("fieldset",{children:[Q("legend",{children:g("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:d0},{value:1,text:g("labels.artist"),icon:m0},{value:2,text:g("labels.cartoonist"),icon:p0}],value:Et(e,n,r=>r.roughness,r=>r.hasOwnProperty("roughness"),r=>r?null:o.currentItemRoughness),onChange:r=>t(r)})})]})}),v$=B({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ke(n,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yt("fieldset",{children:[Q("legend",{children:g("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:Hm},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:s0},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:c0}],value:Et(e,n,r=>r.strokeStyle,r=>r.hasOwnProperty("strokeStyle"),r=>r?null:o.currentItemStrokeStyle),onChange:r=>t(r)})})]})}),m4=B({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>Ke(n,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>Q(rx,{updateData:o,app:e,testId:"opacity"})}),p4=B({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,n)=>Mp(e,o,n,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yt("fieldset",{children:[Q("legend",{children:g("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:k0,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:M0,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:L0,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:P0,testId:"fontSize-veryLarge"}],value:Et(e,n,r=>{if(xt(r))return r.fontSize;let i=ln(r,n.scene.getNonDeletedElementsMap());return i?i.fontSize:null},r=>xt(r)||ln(r,n.scene.getNonDeletedElementsMap())!==null,r=>r?null:o.currentItemFontSize||W6),onChange:r=>t(r)})})]})}),Lp=B({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Hn,trackEvent:!1,perform:(e,o,t,n)=>Mp(e,o,n,r=>Math.round(1/(1+mx)*r.fontSize)),keyTest:e=>e[Ur.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ur.CHEVRON_LEFT||e.key===Ur.COMMA)}),Pp=B({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Hn,trackEvent:!1,perform:(e,o,t,n)=>Mp(e,o,n,r=>Math.round(r.fontSize*(1+mx))),keyTest:e=>e[Ur.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Ur.CHEVRON_RIGHT||e.key===Ur.PERIOD)}),u4=B({name:"changeFontFamily",label:"labels.fontFamily",trackEvent:!1,perform:(e,o,t,n)=>{let{cachedElements:r,resetAll:i,resetContainers:a,...l}=t;if(i)return{elements:ut(e,o,b=>{let x=r?.get(b.id);return x?Ke(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:Ze.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:d}=t,m=Ze.EVENTUALLY,c,p=!1;if(s)c=s,m=Ze.IMMEDIATELY;else if(d){c=d,m=Ze.EVENTUALLY;let f=j(e,o,{includeBoundTextElement:!0}).filter(b=>xt(b));if(f.length>200)p=!0;else{let b=0,x=0;for(;b<f.length&&x<5e3;){let w=f[b];x+=w?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(c&&!p){let f=new Map,b=new Set,x=!1,w=Array.from($o.loadedFontsCache.values()),E=Object.entries(V6).find(([C,S])=>S===c)?.[0];d&&E&&w.some(C=>C.startsWith(E))&&(x=!0),Object.assign(u,{elements:ut(e,o,C=>{if(xt(C)&&(C.fontFamily!==c||s)){let S=Ke(C,{fontFamily:c,lineHeight:$6(c)}),L=r?.get(C.containerId||"")||{},k=n.scene.getContainerElement(C);return a&&k&&L&&n.scene.mutateElement(k,{...L}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,k),S}return C},!0)});let y=`10px ${K6({fontFamily:c})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,S]of f)ha(C,S,n.scene);else window.document.fonts.load(y,v).then(C=>{for(let[S,L]of f){let k=n.scene.getElement(S.id),A=L?n.scene.getElement(L.id):null;k&&ha(k,A,n.scene)}n.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:n})=>{let r=Tp(new Map),i=Tp(null),[a,l]=O6({}),s=Tp(!0),d=F6(()=>{let m=(c,p)=>Et(c,t,u=>{if(xt(u))return u.fontFamily;let f=ln(u,p);return f?f.fontFamily:null},u=>xt(u)||ln(u,p)!==null,u=>u?null:o.currentItemFontFamily||Y6);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?m(Array.from(r.current?.values()??[]),r.current):!a.openPopup&&o.openPopup!=="fontFamily"?m(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t]);return vp(()=>{i.current=d},[d]),vp(()=>{Object.keys(a).length&&(n(a),l({}))},[a]),vp(()=>(s.current=!1,()=>{s.current=!0}),[]),yt("fieldset",{children:[Q("legend",{children:g("labels.fontFamily")}),Q(Qb,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:d,hoveredFontFamily:o.currentHoveredFontFamily,onSelect:m=>{l({openPopup:null,currentHoveredFontFamily:null,currentItemFontFamily:m}),r.current.clear()},onHover:m=>{l({currentHoveredFontFamily:m,cachedElements:new Map(r.current),resetContainers:!0})},onLeave:()=>{l({currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0})},onPopupChange:m=>{if(m){r.current.clear();let{editingTextElement:c}=o;if(c?.type==="text"){let p=t.scene.getElement(c.id);r.current.set(c.id,Ke(p||c,{},!0))}else{let p=j(e,o,{includeBoundTextElement:!0});for(let u of p)r.current.set(u.id,Ke(u,{},!0))}l({openPopup:"fontFamily"})}else{let c={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(r.current),resetAll:!0};s.current?n({...a,...c}):l(c),r.current.clear()}}})]})}}),h4=B({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,n)=>({elements:ut(e,o,r=>{if(xt(r)){let i=Ke(r,{textAlign:t});return ha(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=n.scene.getNonDeletedElementsMap();return yt("fieldset",{children:[Q("legend",{children:g("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:D0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:_0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:R0,testId:"align-right"}],value:Et(e,n,i=>{if(xt(i))return i.textAlign;let a=ln(i,r);return a?a.textAlign:null},i=>xt(i)||ln(i,r)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})})]})}}),g4=B({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:ut(e,o,r=>{if(xt(r)){let i=Ke(r,{verticalAlign:t});return ha(i,n.scene.getContainerElement(r),n.scene),i}return r},!0),appState:{...o},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Ot,{group:"text-align",options:[{value:Ps.TOP,text:g("labels.alignTop"),icon:Q(N0,{theme:o.theme}),testId:"align-top"},{value:Ps.MIDDLE,text:g("labels.centerVertically"),icon:Q(F0,{theme:o.theme}),testId:"align-middle"},{value:Ps.BOTTOM,text:g("labels.alignBottom"),icon:Q(B0,{theme:o.theme}),testId:"align-bottom"}],value:Et(e,n,r=>{if(xt(r)&&r.containerId)return r.verticalAlign;let i=ln(r,n.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},r=>xt(r)||ln(r,n.scene.getNonDeletedElementsMap())!==null,r=>r?null:Ps.MIDDLE),onChange:r=>t(r)})})})}),T$=B({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>dx(n)?n:Ke(n,{roundness:t==="round"?{type:t4(n.type)?As.ADAPTIVE_RADIUS:As.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n,renderAction:r})=>{let a=kl(cx(e),o).some(l=>l.roundness?.type===As.LEGACY);return yt("fieldset",{children:[Q("legend",{children:g("labels.edges")}),yt("div",{className:"buttonList",children:[Q(Ot,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:u0},{value:"round",text:g("labels.round"),icon:h0}],value:Et(e,n,l=>a?null:l.roundness?"round":"sharp",l=>!Ds(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),r("togglePolygon")]})]})}}),sx=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:g0},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(f0,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:Q(y0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:Q(w0,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:Q(b0,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(x0,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:Q(v0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:Q(T0,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:Q(E0,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:Q(C0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:Q(I0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:Q(S0,{flip:e}),keyBinding:"v"}],I$=B({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,n=>{if(Sp(n)){let{position:r,type:i}=t;if(r==="start")return Ke(n,{startArrowhead:i});if(r==="end")return Ke(n,{endArrowhead:i})}return n}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>{let r=Mo().rtl;return yt("fieldset",{children:[Q("legend",{children:g("labels.arrowheads")}),yt("div",{className:"iconSelectList buttonList",children:[Q(yp,{label:"arrowhead_start",options:sx(!r),value:Et(e,n,i=>Sp(i)&&hr(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),Q(yp,{label:"arrowhead_end",group:"arrowheads",options:sx(!!r),value:Et(e,n,i=>Sp(i)&&hr(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),C$=B({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,n)=>{let r=ut(e,o,l=>{if(!Ds(l))return l;let s=Ke(l,{roundness:t===Po.round?{type:As.PROPORTIONAL_RADIUS}:null,elbowed:t===Po.elbow,points:t===Po.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(dx(s)){s.fixedSegments=null;let d=n.scene.getNonDeletedElementsMap();n.dismissLinearEditor();let m=Cp.getPointAtIndexGlobalCoordinates(s,0,d),c=Cp.getPointAtIndexGlobalCoordinates(s,-1,d),p=s.startBinding&&d.get(s.startBinding.elementId),u=s.endBinding&&d.get(s.endBinding.elementId),f=p&&s.startBinding?{...s.startBinding,...ax(s,p,"start",d)}:null,b=u&&s.endBinding?{...s.endBinding,...ax(s,u,"end",d)}:null;s={...s,startBinding:f,endBinding:b,...n4(s,d,{points:[m,c].map(x=>B6(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let d=n.scene.getNonDeletedElementsMap();if(s.startBinding){let m=d.get(s.startBinding.elementId);m&&ix(s,m,"start",n.scene)}if(s.endBinding){let m=d.get(s.endBinding.elementId);m&&ix(s,m,"end",n.scene)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=r.find(s=>s.id===a);l&&(i.selectedLinearElement=new Cp(l,kp(e)))}return{elements:r,appState:i,captureUpdate:Ze.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>yt("fieldset",{children:[Q("legend",{children:g("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Ot,{group:"arrowtypes",options:[{value:Po.sharp,text:g("labels.arrowtype_sharp"),icon:ns,testId:"sharp-arrow"},{value:Po.round,text:g("labels.arrowtype_round"),icon:is,testId:"round-arrow"},{value:Po.elbow,text:g("labels.arrowtype_elbowed"),icon:rs,testId:"elbow-arrow"}],value:Et(e,n,r=>Ds(r)?r.elbowed?Po.elbow:r.roundness?Po.round:Po.sharp:null,r=>Ds(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})})]})});import{clamp as Np,roundToStep as v4}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as T4,CURSOR_TYPE as bx,MAX_ZOOM as xx,MIN_ZOOM as Ex,THEME as ga,ZOOM_STEP as Bp,getShortcutKey as yx,updateActiveTool as Wr,CODES as xo,KEYS as Do}from"@excalidraw/common";import{getNonDeletedElements as I4}from"@excalidraw/element";import{newElementWith as C4}from"@excalidraw/element";import{getCommonBounds as S4}from"@excalidraw/element";import{CaptureUpdateAction as eo}from"@excalidraw/element";import{useEffect as f4}from"react";import{jsx as x4}from"react/jsx-runtime";var Yr=()=>{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},Ap=(e,o,t="bottom")=>{let n=e.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=5,l=o.left+o.width/2-n.width/2;l<0?l=a:l+n.width>=r&&(l=r-n.width-a);let s;t==="bottom"?(s=o.top+o.height+a,s+n.height>=i&&(s=o.top-n.height-a)):(s=o.top-n.height-a,s<0&&(s=o.top+o.height+a)),Object.assign(e.style,{top:`${s}px`,left:`${l}px`})},b4=(e,o,t,n)=>{o.classList.add("excalidraw-tooltip--visible"),o.style.minWidth=n?"50ch":"10ch",o.style.maxWidth=n?"50ch":"15ch",o.textContent=t;let r=e.getBoundingClientRect();Ap(o,r)},At=({children:e,label:o,long:t=!1,style:n,disabled:r})=>(f4(()=>()=>Yr().classList.remove("excalidraw-tooltip--visible"),[]),r?null:x4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>b4(i.currentTarget,Yr(),o,t),onPointerLeave:()=>Yr().classList.remove("excalidraw-tooltip--visible"),style:n,children:e}));import _s from"open-color";import{CURSOR_TYPE as Dp,MIME_TYPES as _p,THEME as hx}from"@excalidraw/common";var gx='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',E4='<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"/>',fx='<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"/>',y4=`data:${_p.svg},${encodeURIComponent(`${gx}${fx}</svg>`)}`,w4=`data:${_p.svg},${encodeURIComponent(`${gx}${E4}${fx}</svg>`)}`,Ht=e=>{e&&(e.style.cursor="")},xe=(e,o)=>{e&&(e.style.cursor=o)},bo,ux,Rp=(e,o)=>{let n=()=>{let r=o===hx.DARK;bo=document.createElement("canvas"),bo.theme=o,bo.height=20,bo.width=20;let i=bo.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(bo.width/2,bo.height/2,5,0,2*Math.PI),i.fillStyle=r?_s.black:_s.white,i.fill(),i.strokeStyle=r?_s.white:_s.black,i.stroke(),ux=bo.toDataURL(_p.svg)};(!bo||bo.theme!==o)&&n(),xe(e,`url(${ux}) ${20/2} ${20/2}, auto`)},Dt=(e,o)=>{if(e)if(o.activeTool.type==="selection")Ht(e);else if(qt(o))e.style.cursor=Dp.GRAB;else if(bt(o))Rp(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===hx.LIGHT?y4:w4;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Dp.AUTO):e.style.cursor=Dp.CROSSHAIR};var Ao=({viewportX:e,viewportY:o,nextZoom:t},n)=>{let r=e-n.offsetLeft,i=o-n.offsetTop,a=n.zoom.value,l=n.scrollX+(r-r/a),s=n.scrollY+(i-i/a),d=-(r-r/t),m=-(i-i/t);return{scrollX:l+d,scrollY:s+m,zoom:{value:t}}};import{jsx as Fs,jsxs as P4}from"react/jsx-runtime";var k4=B({name:"changeViewBackgroundColor",label:"labels.canvasBackground",trackEvent:!1,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.changeViewBackgroundColor&&!o.viewModeEnabled,perform:(e,o,t)=>({appState:{...o,...t},captureUpdate:t.viewBackgroundColor?eo.IMMEDIATELY:eo.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:n})=>Fs(sa,{palette:null,topPicks:T4,label:g("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:r=>t({viewBackgroundColor:r}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),_o=B({name:"clearCanvas",label:"labels.clearCanvas",icon:Lt,trackEvent:{category:"canvas"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.clearCanvas&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector",perform:(e,o,t,n)=>(n.imageCache.clear(),{elements:e.map(r=>C4(r,{isDeleted:!0})),appState:{...jo(),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:n.defaultSelectionTool}:o.activeTool},captureUpdate:eo.IMMEDIATELY})}),Rs=B({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:vm,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(o.zoom.value+Bp)},o),userToFollow:null},captureUpdate:eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Fs(K,{type:"button",className:"zoom-in-button zoom-button",icon:vm,title:`${g("buttons.zoomIn")} \u2014 ${yx("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=xx,onClick:()=>{e(null)}}),keyTest:e=>(e.code===xo.EQUAL||e.code===xo.NUM_ADD)&&(e[Do.CTRL_OR_CMD]||e.shiftKey)}),Ns=B({name:"zoomOut",label:"buttons.zoomOut",icon:Tm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(o.zoom.value-Bp)},o),userToFollow:null},captureUpdate:eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Fs(K,{type:"button",className:"zoom-out-button zoom-button",icon:Tm,title:`${g("buttons.zoomOut")} \u2014 ${yx("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=Ex,onClick:()=>{e(null)}}),keyTest:e=>(e.code===xo.MINUS||e.code===xo.NUM_SUBTRACT)&&(e[Do.CTRL_OR_CMD]||e.shiftKey)}),Bs=B({name:"resetZoom",label:"buttons.resetZoom",icon:z1,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(1)},o),userToFollow:null},captureUpdate:eo.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Fs(At,{label:g("buttons.resetZoom"),style:{height:"100%"},children:P4(K,{type:"button",className:"reset-zoom-button zoom-button",title:g("buttons.resetZoom"),"aria-label":g("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===xo.ZERO||e.code===xo.NUM_ZERO)&&(e[Do.CTRL_OR_CMD]||e.shiftKey)}),M4=(e,o,t=1)=>{let[n,r,i,a]=e,l=i-n,s=o.width/l,d=a-r,m=o.height/d,p=Math.min(s,m)*Np(t,.1,1);return Math.min(p,1)},wx=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:n=!1,viewportZoomFactor:r=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{r=Np(r,Ex,xx);let[l,s,d,m]=e,c=(l+d)/2,p=(s+m)/2,u=t?.left??0,f=t?.top??0,b=t?.right??0,x=t?.bottom??0,w=o.width-u-b,E=o.height-f-x,y;if(n){let S=d-l,L=m-s;y=Math.min(w/S,E/L)*r}else y=M4(e,{width:w,height:E},r);let v=uo(Np(v4(y,Bp,"floor"),i,a)),C=qf({scenePoint:{x:c,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:eo.EVENTUALLY}},fa=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})=>{let l=S4(I4(o));return wx({canvasOffsets:e,bounds:l,appState:t,fitToViewport:n,viewportZoomFactor:r,minZoom:i,maxZoom:a})},lj=B({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:os,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return fa({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===xo.TWO&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),sj=B({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:os,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return fa({targetElements:r.length?r:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:n.getEditorUIOffsets()})},keyTest:e=>e.code===xo.THREE&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),L4=B({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:os,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,n)=>fa({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:n.getEditorUIOffsets()}),keyTest:e=>e.code===xo.ONE&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),Vn=B({name:"toggleTheme",label:(e,o)=>o.theme===ga.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===ga.LIGHT?ji:qi,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===ga.LIGHT?ga.DARK:ga.LIGHT)},captureUpdate:eo.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===xo.D,predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.toggleTheme}),cj=B({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o,t,n)=>{let r;return bt(o)?r=Wr(o,{...o.activeTool.lastActiveTool||{type:n.defaultSelectionTool},lastActiveToolBeforeEraser:null}):r=Wr(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:eo.IMMEDIATELY}},keyTest:e=>e.key===Do.E}),dj=B({name:"toggleLassoTool",label:"toolBar.lasso",icon:Zi,trackEvent:{category:"toolbar"},predicate:(e,o,t,n)=>n.defaultSelectionTool!=="lasso",perform:(e,o,t,n)=>{let r;return o.activeTool.type!=="lasso"?(r=Wr(o,{type:"lasso",fromSelection:!1}),xe(n.interactiveCanvas,bx.CROSSHAIR)):r=Wr(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:eo.NEVER}}}),vx=B({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Ql,viewMode:!1,perform:(e,o,t,n)=>{let r;return qt(o)?r=Wr(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(r=Wr(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),xe(n.interactiveCanvas,bx.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:r},captureUpdate:eo.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Do.CTRL_OR_CMD]&&e.key===Do.H});import{updateActiveTool as Tx}from"@excalidraw/common";import{CaptureUpdateAction as A4}from"@excalidraw/element";var D4=B({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,n)=>{let r=Tx(o,{type:"embeddable"});return Dt(n.canvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:Tx(o,{type:"embeddable"})},captureUpdate:A4.EVENTUALLY}}});import{pointFrom as _4}from"@excalidraw/math";import{maybeBindLinearElement as R4,bindOrUnbindLinearElement as Ix,isBindingEnabled as N4}from"@excalidraw/element/binding";import{isValidPolygon as Cx,LinearElementEditor as ba,newElementWith as Fp}from"@excalidraw/element";import{isBindingElement as Os,isFreeDrawElement as Sx,isLinearElement as kx,isLineElement as zs}from"@excalidraw/element";import{KEYS as Op,arrayToMap as zp,tupleToCoors as B4,updateActiveTool as Mx}from"@excalidraw/common";import{isPathALoop as F4}from"@excalidraw/element";import{isInvisiblySmallElement as Hp}from"@excalidraw/element";import{CaptureUpdateAction as Gp}from"@excalidraw/element";import{jsx as O4}from"react/jsx-runtime";var wt=B({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,n)=>{let{interactiveCanvas:r,focusContainer:i,scene:a}=n,{event:l,sceneCoords:s}=t??{},d=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=ba.handlePointerUp(l,o.selectedLinearElement,o,n.scene),{startBindingElement:f,endBindingElement:b}=u,x=n.scene.getElement(u.elementId);if(Os(x)&&Ix(x,f,b,n.scene),u!==o.selectedLinearElement){let w=e;return x&&Hp(x)&&(w=w.map(E=>E.id===x.id?Fp(E,{isDeleted:!0}):E)),{elements:w,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:Gp.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=ba.getElement(u,d);if(x)return Os(x)&&Ix(x,f,b,a),zs(x)&&!Cx(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||Hp(x)?e.map(w=>w.id===x.id?Fp(w,{isDeleted:!0}):w):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new ba(x,zp(d),!1)},captureUpdate:Gp.IMMEDIATELY}}let m=e;window.document.activeElement instanceof HTMLElement&&i();let c=null;if(o.multiElement)c=o.multiElement;else if(o.newElement?.type==="freedraw"||Os(o.newElement))c=o.newElement;else if(Object.keys(o.selectedElementIds).length===1){let u=d.get(Object.keys(o.selectedElementIds)[0]);u&&(c=u)}if(c){if(o.multiElement&&c.type!=="freedraw"){let{points:u,lastCommittedPoint:f}=c;(!f||u[u.length-1]!==f)&&a.mutateElement(c,{points:c.points.slice(0,-1)})}if(c&&Hp(c)&&(m=m.map(u=>u.id===c?.id?Fp(u,{isDeleted:!0}):u)),kx(c)||Sx(c)){let u=F4(c.points,o.zoom.value);if(u&&(zs(c)||Sx(c))){let f=c.points,b=f[0],x=f.map((w,E)=>E===f.length-1?_4(b[0],b[1]):w);zs(c)?a.mutateElement(c,{points:x,polygon:!0}):a.mutateElement(c,{points:x})}if(zs(c)&&!Cx(c.points)&&a.mutateElement(c,{polygon:!1}),Os(c)&&!u&&c.points.length>1&&N4(o)){let f=s??B4(ba.getPointAtIndexGlobalCoordinates(c,-1,zp(e)));R4(c,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&Ht(r);let p;return o.activeTool.type==="eraser"?p=Mx(o,{...o.activeTool.lastActiveTool||{type:n.defaultSelectionTool},lastActiveToolBeforeEraser:null}):p=Mx(o,{type:n.defaultSelectionTool}),{elements:m,appState:{...o,cursorButton:"up",activeTool:(o.activeTool.locked||o.activeTool.type==="freedraw")&&c?o.activeTool:p,activeEmbeddable:null,newElement:null,selectionElement:null,multiElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:c&&!o.activeTool.locked&&o.activeTool.type!=="freedraw"?{...o.selectedElementIds,[c.id]:!0}:o.selectedElementIds,selectedLinearElement:c&&kx(c)?new ba(c,zp(m)):o.selectedLinearElement},captureUpdate:Gp.IMMEDIATELY}},keyTest:(e,o)=>e.key===Op.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===Op.ESCAPE||e.key===Op.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>O4(K,{type:"button",icon:$1,title:g("buttons.done"),"aria-label":g("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import{KEYS as Kr,DEFAULT_EXPORT_PADDING as Ik,EXPORT_SCALES as Ck,THEME as Wp}from"@excalidraw/common";import{getNonDeletedElements as Sk}from"@excalidraw/element";import{CaptureUpdateAction as ro}from"@excalidraw/element";import z4 from"clsx";import{jsx as Lx,jsxs as H4}from"react/jsx-runtime";var xa=({children:e,checked:o,onChange:t,className:n})=>H4("div",{className:z4("Checkbox",n,{"is-checked":o}),onClick:r=>{t(!o,r),r.currentTarget.querySelector(".Checkbox-box").focus()},children:[Lx("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:Y1}),Lx("div",{className:"Checkbox-label",children:e})]});import{THEME as Ea}from"@excalidraw/common";import{jsx as ya}from"react/jsx-runtime";var Ax=e=>{let o=e.title||(e.value===Ea.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return ya(K,{type:"icon",icon:e.value===Ea.LIGHT?Px.MOON:Px.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===Ea.DARK?Ea.LIGHT:Ea.DARK),"data-testid":"toggle-dark-mode"})},Px={SUN:ya("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ya("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:ya("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:ya("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 G4}from"react";import{focusNearestParent as U4,KEYS as Y4}from"@excalidraw/common";import{jsx as Dx,jsxs as W4}from"react/jsx-runtime";var _x=e=>{let{id:o}=Ge(),[t,n]=G4(e.value),r=a=>{e.ignoreFocus||U4(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===Y4.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return W4("div",{className:"ProjectName",children:[Dx("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Dx("input",{type:"text",className:"TextInput",onBlur:r,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>n(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as gk,DEFAULT_FILENAME as fk,IMAGE_MIME_TYPES as Zx,isFirefox as bk,MIME_TYPES as xk,cloneJSON as Ek,SVG_DOCUMENT_PREAMBLE as yk}from"@excalidraw/common";import{getNonDeletedElements as wk}from"@excalidraw/element";import{isFrameLikeElement as vk}from"@excalidraw/element";import{getElementsOverlappingFrame as Tk}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as tk,EXPORT_DATA_TYPES as Ta,MIME_TYPES as oo,arrayToMap as ok,isMemberOf as nk,isPromiseLike as rk}from"@excalidraw/common";import{mutateElement as ik}from"@excalidraw/element";import{deepCopyElement as ak}from"@excalidraw/element";import{isFrameLikeElement as lk,isInitializedImageElement as sk}from"@excalidraw/element";import{getContainingFrame as Wx}from"@excalidraw/element";import{pointFrom as sn}from"@excalidraw/math";import{COLOR_PALETTE as Nx,DEFAULT_CHART_COLOR_INDEX as V4,getAllColorsSpecificShade as X4,DEFAULT_FONT_FAMILY as K4,DEFAULT_FONT_SIZE as Bx,VERTICAL_ALIGN as Z4,randomId as Fx,isDevEnv as Ox}from"@excalidraw/common";import{newTextElement as Hs,newLinearElement as va,newElement as Yp}from"@excalidraw/element";var to=32,we=12,cn=256,zx=50,Xn="NOT_SPREADSHEET",Vr="VALID_SPREADSHEET",wa=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},Up=(e,o)=>e.slice(1).every(t=>wa(t[o])!==null),Rx=e=>{let o=e[0].length;if(o>2)return{type:Xn,reason:"More than 2 columns"};if(o===1){if(!Up(e,0))return{type:Xn,reason:"Value is not numeric"};let s=wa(e[0][0])===null,d=(s?e.slice(1):e).map(m=>wa(m[0]));return d.length<2?{type:Xn,reason:"Less than two rows"}:{type:Vr,spreadsheet:{title:s?e[0][0]:null,labels:null,values:d}}}let t=Up(e,0),n=Up(e,1);if(!t&&!n)return{type:Xn,reason:"Value is not numeric"};let[r,i]=n?[0,1]:[1,0],a=wa(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:Xn,reason:"Less than 2 rows"}:{type:Vr,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[r]),values:l.map(s=>wa(s[i]))}}},$4=e=>{let o=[];for(let t=0;t<e[0].length;t++){let n=[];for(let r=0;r<e.length;r++)n.push(e[r][t]);o.push(n)}return o},Hx=e=>{let o=e.trim().split(`
3
3
  `).map(i=>i.trim().split(" "));if(o.length&&o[0].length!==2&&(o=e.trim().split(`
4
- `).map(i=>i.trim().split(","))),o.length===0)return{type:ei,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:ei,reason:"All rows don't have same number of columns"};let n=e2(o);if(n.type!==oa){let i=e2(M4(o));if(i.type===oa)return i}return n},gd=vf(ff),wo={fillStyle:"hachure",fontFamily:zr,fontSize:hr,opacity:100,roughness:1,strokeColor:uo.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Wt.MIDDLE,locked:!1},r2=e=>{let o=(Uo+ze)*e.values.length+ze,t=dn+ze*2;return{chartWidth:o,chartHeight:t}},L4=(e,o,t,r,n)=>e.labels?.map((i,a)=>Ot({groupIds:[r],backgroundColor:n,...wo,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(Uo+ze)+ze*2,y:t+ze/2,width:Uo,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],A4=(e,o,t,r,n)=>{let i=Ot({groupIds:[r],backgroundColor:n,...wo,x:o-ze,y:t-ze,text:"0",textAlign:"right"}),a=Ot({groupIds:[r],backgroundColor:n,...wo,x:o-ze,y:t-dn-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},_4=(e,o,t,r,n)=>{let{chartWidth:i,chartHeight:a}=r2(e),l=bo({backgroundColor:n,groupIds:[r],...wo,type:"line",x:o,y:t,width:i,points:[L(0,0),L(i,0)]}),s=bo({backgroundColor:n,groupIds:[r],...wo,type:"line",x:o,y:t,height:a,points:[L(0,0),L(0,-a)]}),c=bo({backgroundColor:n,groupIds:[r],...wo,type:"line",x:o,y:t-dn-ze,strokeStyle:"dotted",width:i,opacity:t2,points:[L(0,0),L(i,0)]});return[l,s,c]},n2=(e,o,t,r,n,i)=>{let{chartWidth:a,chartHeight:l}=r2(e),s=e.title?Ot({backgroundColor:n,groupIds:[r],...wo,text:e.title,x:o+a/2,y:t-dn-ze*2-hr,roundness:null,textAlign:"center"}):null,c=i?Kt({backgroundColor:n,groupIds:[r],...wo,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:uo.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...s?[s]:[],...L4(e,o,t,r,n),...A4(e,o,t,r,n),..._4(e,o,t,r,n)]},D4=(e,o,t)=>{let r=Math.max(...e.values),n=Do(),i=gd[Math.floor(Math.random()*gd.length)];return[...e.values.map((l,s)=>{let c=l/r*dn;return Kt({backgroundColor:i,groupIds:[n],...wo,type:"rectangle",x:o+s*(Uo+ze)+ze,y:t-c-ze,width:Uo,height:c})}),...n2(e,o,t,n,i,pt())]},P4=(e,o,t)=>{let r=Math.max(...e.values),n=Do(),i=gd[Math.floor(Math.random()*gd.length)],a=0,l=[];for(let b of e.values){let x=a*(Uo+ze),E=-(b/r)*dn;l.push([x,E]),a++}let s=Math.max(...l.map(b=>b[0])),c=Math.max(...l.map(b=>b[1])),m=Math.min(...l.map(b=>b[0])),d=Math.min(...l.map(b=>b[1])),p=bo({backgroundColor:i,groupIds:[n],...wo,type:"line",x:o+ze+Uo/2,y:t-ze,height:c-d,width:s-m,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let E=x*(Uo+ze)+ze/2,w=-(b/r)*dn+ze/2;return Kt({backgroundColor:i,groupIds:[n],...wo,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+E+Uo/2,y:t+w-ze*2,width:ze,height:ze})}),f=e.values.map((b,x)=>{let E=x*(Uo+ze)+ze/2,w=b/r*dn+ze/2+ze;return bo({backgroundColor:i,groupIds:[n],...wo,type:"line",x:o+E+Uo/2+ze/2,y:t-w,height:w,strokeStyle:"dotted",opacity:t2,points:[L(0,0),L(0,w)]})});return[...n2(e,o,t,n,i,pt()),p,...f,...u]},i2=(e,o,t,r)=>e==="line"?P4(o,t,r):D4(o,t,r);var tz="clipboard"in navigator&&"readText"in navigator.clipboard,fd="clipboard"in navigator&&"writeText"in navigator.clipboard,ra="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,R4=e=>!!([Br.excalidraw,Br.excalidrawClipboard,Br.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),a2=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[r,n]of Object.entries(e)){if(typeof n!="string"){o=o||[],o.push(n);continue}try{if(t.clipboardData?.setData(r,n),t.clipboardData?.getData(r)!==n)throw new Error(`Failed to set "${r}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let r=-1;for(let n of o){r++;try{if(t.clipboardData?.items.add(n),t.clipboardData?.files[r]!==n)throw new Error(`Failed to set file "${n.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},N4=({elements:e,files:o})=>{let t=J(e),r=new Set(e.filter(l=>ae(l))),n=!1,i=e.reduce((l,s)=>(fr(s)&&(n=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});n&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Br.excalidrawClipboard,elements:e.map(l=>{if(Hn(l,t)&&!r.has(Hn(l,t))){let s=zo(l);return Oo(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},bd=async(e,o,t)=>{await Go(N4({elements:e,files:o}),t)},O4=e=>{let o=o2(e);return o.type===oa?{spreadsheet:o.spreadsheet}:null};function l2(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let r=t.textContent?.trim();r&&o.push({type:"text",value:r})}else if(t instanceof HTMLImageElement){let r=t.getAttribute("src");r&&r.startsWith("http")&&o.push({type:"imageUrl",value:r})}else o=o.concat(l2(t));return o}var z4=e=>{let o=e.clipboardData?.getData(ce.html);if(!o)return null;try{let t=new DOMParser().parseFromString(o,ce.html),r=l2(t.body);if(r.length)return{type:"mixedContent",value:r}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},s2=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let r=await navigator.clipboard?.readText();if(r)return{[ce.text]:r}}}catch(r){if(navigator.clipboard?.read)console.warn(`navigator.clipboard.readText() failed (${r.message}). Failling back to navigator.clipboard.read()`);else{if(r.name==="DataError")return console.warn(`navigator.clipboard.read() error, clipboard is probably empty: ${r.message}`),e;throw r}}throw t}for(let t of o)for(let r of t.types)if(Rs(_f,r))try{if(r===ce.text||r===ce.html)e[r]=await(await t.getType(r)).text();else if(i0(r)){let n=await t.getType(r),i=u0(n,r,void 0);e[r]=i}else throw new Hp(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof Hp?n.message:`Cannot retrieve ${r} from clipboardItem: ${n.message}`)}return Object.keys(e).length===0&&console.warn("No clipboard data found from clipboard.read()."),e},B4=async(e,o=!1)=>{try{let t=!o&&e&&z4(e);return t?t.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData(ce.text)||t.value.map(n=>n.value).join(`
5
- `).trim()}:t:{type:"text",value:(e.clipboardData?.getData(ce.text)||"").trim()}}catch{return{type:"text",value:""}}},xd=async(e,o=!1)=>{let t=await B4(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&O4(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===Br.excalidrawClipboardWithAPI;if(R4(r))return{elements:r.elements,files:r.files,text:o?JSON.stringify(r.elements,null,2):void 0,programmaticAPI:n}}catch{}return{text:t.value}},Ed=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[ce.png]:e})])}catch(o){if(Wr(e))await navigator.clipboard.write([new window.ClipboardItem({[ce.png]:await e})]);else throw o}},Go=async(e,o)=>{if(fd)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(ce.text,e||""),o.clipboardData?.getData(ce.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!F4(e))throw new Error("Error copying to clipboard.")},F4=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let r=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${r}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let n=!1;try{t.select(),t.setSelectionRange(0,t.value.length),n=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),n};var ti=(e,{selectedElementIds:o},t)=>{e=ue(e);let r=t&&Ne(e,{selectedElementIds:o}),n=null,i=r?j(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(i.length===1&&ae(i[0])?(n=i[0],i=$s(e,n)):i.length>1&&(i=j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:Yt(i)}},oi=async(e,o,t,r,{exportBackground:n,exportPadding:i=Fr,viewBackgroundColor:a,name:l=t.name||Yf,fileHandle:s=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let d=Oi(o,{exportBackground:n,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},r,{exportingFrame:c});if(e==="svg")return Up(d.then(p=>new Blob([Vf+p.outerHTML],{type:ce.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Ha.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await d.then(u=>u.outerHTML);try{await Go(p)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let m=xc(o,t,r,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let d=Tr(m);return t.exportEmbedScene&&(d=d.then(p=>import("./data/image-XJI4SWH2.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:nl(o,t,r,"local")})))),Up(d,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Ha.png],fileHandle:s})}else if(e==="clipboard")try{let d=Tr(m);await Ed(d)}catch(d){throw console.warn(d),d.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):ur&&d.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
4
+ `).map(i=>i.trim().split(","))),o.length===0)return{type:Xn,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:Xn,reason:"All rows don't have same number of columns"};let r=Rx(o);if(r.type!==Vr){let i=Rx($4(o));if(i.type===Vr)return i}return r},Gs=X4(V4),Gt={fillStyle:"hachure",fontFamily:K4,fontSize:Bx,opacity:100,roughness:1,strokeColor:Nx.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Z4.MIDDLE,locked:!1},Gx=e=>{let o=(to+we)*e.values.length+we,t=cn+we*2;return{chartWidth:o,chartHeight:t}},j4=(e,o,t,n,r)=>e.labels?.map((i,a)=>Hs({groupIds:[n],backgroundColor:r,...Gt,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(to+we)+we*2,y:t+we/2,width:to,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],q4=(e,o,t,n,r)=>{let i=Hs({groupIds:[n],backgroundColor:r,...Gt,x:o-we,y:t-we,text:"0",textAlign:"right"}),a=Hs({groupIds:[n],backgroundColor:r,...Gt,x:o-we,y:t-cn-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},J4=(e,o,t,n,r)=>{let{chartWidth:i,chartHeight:a}=Gx(e),l=va({backgroundColor:r,groupIds:[n],...Gt,type:"line",x:o,y:t,width:i,points:[sn(0,0),sn(i,0)]}),s=va({backgroundColor:r,groupIds:[n],...Gt,type:"line",x:o,y:t,height:a,points:[sn(0,0),sn(0,-a)]}),d=va({backgroundColor:r,groupIds:[n],...Gt,type:"line",x:o,y:t-cn-we,strokeStyle:"dotted",width:i,opacity:zx,points:[sn(0,0),sn(i,0)]});return[l,s,d]},Ux=(e,o,t,n,r,i)=>{let{chartWidth:a,chartHeight:l}=Gx(e),s=e.title?Hs({backgroundColor:r,groupIds:[n],...Gt,text:e.title,x:o+a/2,y:t-cn-we*2-Bx,roundness:null,textAlign:"center"}):null,d=i?Yp({backgroundColor:r,groupIds:[n],...Gt,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:Nx.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...s?[s]:[],...j4(e,o,t,n,r),...q4(e,o,t,n,r),...J4(e,o,t,n,r)]},Q4=(e,o,t)=>{let n=Math.max(...e.values),r=Fx(),i=Gs[Math.floor(Math.random()*Gs.length)];return[...e.values.map((l,s)=>{let d=l/n*cn;return Yp({backgroundColor:i,groupIds:[r],...Gt,type:"rectangle",x:o+s*(to+we)+we,y:t-d-we,width:to,height:d})}),...Ux(e,o,t,r,i,Ox())]},ek=(e,o,t)=>{let n=Math.max(...e.values),r=Fx(),i=Gs[Math.floor(Math.random()*Gs.length)],a=0,l=[];for(let b of e.values){let x=a*(to+we),w=-(b/n)*cn;l.push([x,w]),a++}let s=Math.max(...l.map(b=>b[0])),d=Math.max(...l.map(b=>b[1])),m=Math.min(...l.map(b=>b[0])),c=Math.min(...l.map(b=>b[1])),p=va({backgroundColor:i,groupIds:[r],...Gt,type:"line",x:o+we+to/2,y:t-we,height:d-c,width:s-m,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let w=x*(to+we)+we/2,E=-(b/n)*cn+we/2;return Yp({backgroundColor:i,groupIds:[r],...Gt,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+w+to/2,y:t+E-we*2,width:we,height:we})}),f=e.values.map((b,x)=>{let w=x*(to+we)+we/2,E=b/n*cn+we/2+we;return va({backgroundColor:i,groupIds:[r],...Gt,type:"line",x:o+w+to/2+we/2,y:t-E,height:E,strokeStyle:"dotted",opacity:zx,points:[sn(0,0),sn(0,E)]})});return[...Ux(e,o,t,r,i,Ox()),p,...f,...u]},Yx=(e,o,t,n)=>e==="line"?ek(o,t,n):Q4(o,t,n);var Tq="clipboard"in navigator&&"readText"in navigator.clipboard,Us="clipboard"in navigator&&"writeText"in navigator.clipboard,Xr="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,ck=e=>!!([Ta.excalidraw,Ta.excalidrawClipboard,Ta.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Vx=({types:e,files:o})=>{!e&&!o&&console.warn("createPasteEvent: no types or files provided");let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});if(e)for(let[n,r]of Object.entries(e)){if(typeof r!="string"){o=o||[],o.push(r);continue}try{if(t.clipboardData?.setData(n,r),t.clipboardData?.getData(n)!==r)throw new Error(`Failed to set "${n}" as clipboardData item`)}catch(i){throw new Error(i.message)}}if(o){let n=-1;for(let r of o){n++;try{if(t.clipboardData?.items.add(r),t.clipboardData?.files[n]!==r)throw new Error(`Failed to set file "${r.name}" as clipboardData item`)}catch(i){throw new Error(i.message)}}}return t},dk=({elements:e,files:o})=>{let t=ok(e),n=new Set(e.filter(l=>lk(l))),r=!1,i=e.reduce((l,s)=>(sk(s)&&(r=!0,o&&o[s.fileId]&&(l[s.fileId]=o[s.fileId])),l),{});r&&!o&&console.warn("copyToClipboard: attempting to file element(s) without providing associated `files` object.");let a={type:Ta.excalidrawClipboard,elements:e.map(l=>{if(Wx(l,t)&&!n.has(Wx(l,t))){let s=ak(l);return ik(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},Ys=async(e,o,t)=>{await no(dk({elements:e,files:o}),t)},mk=e=>{let o=Hx(e);return o.type===Vr?{spreadsheet:o.spreadsheet}:null};function Xx(e){let o=[];for(let t of e.childNodes)if(t.nodeType===3){let n=t.textContent?.trim();n&&o.push({type:"text",value:n})}else if(t instanceof HTMLImageElement){let n=t.getAttribute("src");n&&n.startsWith("http")&&o.push({type:"imageUrl",value:n})}else o=o.concat(Xx(t));return o}var pk=e=>{let o=e.clipboardData?.getData(oo.html);if(!o)return null;try{let t=new DOMParser().parseFromString(o,oo.html),n=Xx(t.body);if(n.length)return{type:"mixedContent",value:n}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Kx=async()=>{let e={},o;try{o=await navigator.clipboard?.read()}catch(t){try{if(navigator.clipboard?.readText){console.warn(`navigator.clipboard.readText() failed (${t.message}). Failling back to navigator.clipboard.read()`);let n=await navigator.clipboard?.readText();if(n)return{[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 t}for(let t of o)for(let n of t.types)if(nk(tk,n))try{if(n===oo.text||n===oo.html)e[n]=await(await t.getType(n)).text();else if(h1(n)){let r=await t.getType(n),i=w1(r,n,void 0);e[n]=i}else throw new mm(`Unsupported clipboard type: ${n}`)}catch(r){console.warn(r instanceof mm?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},uk=async(e,o=!1)=>{try{let t=!o&&e&&pk(e);return t?t.value.every(r=>r.type==="text")?{type:"text",value:e.clipboardData?.getData(oo.text)||t.value.map(r=>r.value).join(`
5
+ `).trim()}:t:{type:"text",value:(e.clipboardData?.getData(oo.text)||"").trim()}}catch{return{type:"text",value:""}}},Ws=async(e,o=!1)=>{let t=await uk(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let n=!o&&mk(t.value);if(n)return n}catch(n){console.error(n)}try{let n=JSON.parse(t.value),r=n.type===Ta.excalidrawClipboardWithAPI;if(ck(n))return{elements:n.elements,files:n.files,text:o?JSON.stringify(n.elements,null,2):void 0,programmaticAPI:r}}catch{}return{text:t.value}},Vs=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[oo.png]:e})])}catch(o){if(rk(e))await navigator.clipboard.write([new window.ClipboardItem({[oo.png]:await e})]);else throw o}},no=async(e,o)=>{if(Us)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(oo.text,e||""),o.clipboardData?.getData(oo.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!hk(e))throw new Error("Error copying to clipboard.")},hk=e=>{e||(e=" ");let o=document.documentElement.getAttribute("dir")==="rtl",t=document.createElement("textarea");t.style.border="0",t.style.padding="0",t.style.margin="0",t.style.position="absolute",t.style[o?"right":"left"]="-9999px";let n=window.pageYOffset||document.documentElement.scrollTop;t.style.top=`${n}px`,t.style.fontSize="12pt",t.setAttribute("readonly",""),t.value=e,document.body.appendChild(t);let r=!1;try{t.select(),t.setSelectionRange(0,t.value.length),r=document.execCommand("copy")}catch(i){console.error(i)}return t.remove(),r};var Kn=(e,{selectedElementIds:o},t)=>{e=wk(e);let n=t&&Ee(e,{selectedElementIds:o}),r=null,i=n?j(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return n&&(i.length===1&&vk(i[0])?(r=i[0],i=Tk(e,r)):i.length>1&&(i=j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:r,exportedElements:Ek(i)}},Zn=async(e,o,t,n,{exportBackground:r,exportPadding:i=gk,viewBackgroundColor:a,name:l=t.name||fk,fileHandle:s=null,exportingFrame:d=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let c=br(o,{exportBackground:r,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},n,{exportingFrame:d});if(e==="svg")return pm(c.then(p=>new Blob([yk+p.outerHTML],{type:xk.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Zx.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await c.then(u=>u.outerHTML);try{await no(p)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let m=_l(o,t,n,{exportBackground:r,viewBackgroundColor:a,exportPadding:i,exportingFrame:d});if(e==="png"){let c=ko(m);return t.exportEmbedScene&&(c=c.then(p=>import("./data/image-G3CCQ4CB.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:Wi(o,t,n,"local")})))),pm(c,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Zx.png],fileHandle:s})}else if(e==="clipboard")try{let c=ko(m);await Vs(c)}catch(c){throw console.warn(c),c.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):bk&&c.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
6
6
 
7
- ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var c2=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=r0(a);if(!a||!n0(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}=ti(e,o,!1);return await oi(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:c}),{fileHandle:a}};import{Fragment as H4,jsx as Sr,jsxs as U4}from"react/jsx-runtime";var Ju=z({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})=>Sr(QE,{label:g("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),d2=z({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=ue(e),i=Ne(r,o)?j(r,o):r;return Sr(H4,{children:Ts.map(a=>{let[l,s]=t0(i,Fr,a),c=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Sr($,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:c,"aria-label":c,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),Qu=z({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})=>Sr(Sl,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),yd=z({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})=>U4(Sl,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),Sr(io,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:Sr("div",{className:"excalidraw-tooltip-icon",children:G0})})]})}),ri=z({name:"saveToActiveFile",label:"buttons.save",icon:Xn,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}=Ec(o.fileHandle)?await c2(e,o,r.files,r.getName()):await hc(e,o,r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):g("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>e.key===y.S&&e[y.CTRL_OR_CMD]&&!e.shiftKey}),Al=z({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Xn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await hc(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:g("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>e.key===y.S&&e.shiftKey&&e[y.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Sr($,{type:"button",icon:z0,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:be().editor.isMobile,hidden:!Ni,onClick:()=>e(null),"data-testid":"save-as-button"})}),na=z({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 Gp(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[y.CTRL_OR_CMD]&&e.key===y.O}),m2=z({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})=>Sr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Sr(qE,{value:e.exportWithDarkMode?re.DARK:re.LIGHT,onChange:t=>{o(t===re.DARK)},title:g("imageExportDialog.label.darkMode")})})});var p2="{}",eh=z({name:"copyStyles",label:"labels.copyStyles",icon:hu,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&ut(i)){let a=Ee(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(p2=JSON.stringify(n)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:A.EVENTUALLY}},keyTest:e=>e[y.CTRL_OR_CMD]&&e.altKey&&e.code===se.C}),th=z({name:"pasteStyles",label:"labels.pasteStyles",icon:hu,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(p2),i=n[0],a=n[1];if(!x1(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(Y(c)&&c.containerId&&(m=a),!m)return c;let d=ne(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?y1(m.roundness.type,c)?m.roundness:v1(c):null});if(Y(d)){let p=m.fontSize||hr,u=m.fontFamily||zr;d=ne(d,{fontSize:p,fontFamily:u,textAlign:m.textAlign||xs,lineHeight:m.lineHeight||Ao(u)});let f=null;d.containerId&&(f=l.find(b=>Y(d)&&b.id===d.containerId)||null),Ye(d,f,r.scene)}return d.type==="arrow"&&Re(m)&&(d=ne(d,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),ae(c)&&(d=ne(d,{roundness:null,backgroundColor:"transparent"})),d}return c}),captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[y.CTRL_OR_CMD]&&e.altKey&&e.code===se.V});import{jsx as u2}from"react/jsx-runtime";var G4=z({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})=>u2($,{type:"button",icon:_c,"aria-label":g("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),W4=z({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})=>u2($,{visible:Pi(o,ue(e)),type:"button",icon:B0,"aria-label":g("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),ni=z({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:D0,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===y.QUESTION_MARK});import{jsx as ia}from"react/jsx-runtime";var V4=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&Ii(n,t),!0))return!0}return!1},h2=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!V4(r)&&!js(r)},oh=z({name:"group",label:"labels.group",icon:e=>ia(du,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=eb(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let i=Ro(o);if(i.length===1){let x=i[0],E=new Set($e(e,x).map(T=>T.id)),w=new Set(n.map(T=>T.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&&J1(n).forEach((E,w)=>{Zs(E,r.scene.getNonDeletedElementsMap())});let s=Do(),c=J(n);a=a.map(x=>c.get(x.id)?ne(x,{groupIds:K1(x.groupIds,s,o.editingGroupId)}):x);let m=$e(a,s),d=m[m.length-1],p=a.lastIndexOf(d),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!Ii(x,s)),b=Qo([...f,...m,...u],J(m));return{appState:{...o,...G1(s,{...o,selectedGroupIds:{}},ue(a))},elements:b,captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>h2(e,o,r),keyTest:e=>!e.shiftKey&&e[y.CTRL_OR_CMD]&&e.key===y.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>ia($,{hidden:!h2(e,o,r),type:"button",icon:ia(du,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${R("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:Ne(ue(e),o)})}),rh=z({name:"ungroup",label:"labels.ungroup",icon:e=>ia(mu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Ro(o),i=J(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{tt(p)&&l.push(p.id);let u=Z1(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:ne(p,{groupIds:u})});let s=nt(o,ue(a),o,null),c=r.scene.getSelectedElements(o),m=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return Q1(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=Xs(a,ki(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[y.CTRL_OR_CMD]&&e.key===y.G.toUpperCase(),predicate:(e,o)=>Ro(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>ia($,{type:"button",hidden:Ro(o).length===0,icon:ia(mu,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${R("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:Ne(ue(e),o)})});import X4 from"clsx";var vd=(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 Y4(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 ii=(e,o)=>`hsl(${Math.abs(Y4(o?.id||e))%37*10}, 100%, 83%)`,g2=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},f2=({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=ii(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f==="idle"||f==="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===re.DARK?"#2f6330":Af,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=Fa,e.strokeStyle=Fa,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 v=(E?l+0:l)+m/2,T=(E?s+0:s)+d+2,S=5,k=3,D=e.measureText(w),M=D.actualBoundingBoxDescent+D.actualBoundingBoxAscent,O=Math.max(M,12),P=v-1,F=T-1,K=D.width+2+S*2+2,V=O+2+k*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,F,K,V,8),e.fillStyle=u,e.fill(),e.strokeStyle=Fa,e.stroke(),E&&(e.beginPath(),e.roundRect(P-2,F-2,K+4,V+4,8),e.strokeStyle=x,e.stroke())):vd(e,P,F,K,V,8,Fa),e.fillStyle=Lf,e.fillText(w,v+S+1,T+k+D.actualBoundingBoxAscent+Math.floor((O-M)/2)+2),E){e.fillStyle=x;let te=8,H=8,B=5;e.fillRect(P+K+H,F+(V/2-te/2),2,te),e.fillRect(P+K+H+B,F+(V/2-te*2/2),2,te*2),e.fillRect(P+K+H+B*2,F+(V/2-te/2),2,te)}}e.restore(),e.closePath()}};import K4 from"clsx";import{useState as Z4}from"react";import{jsx as b2}from"react/jsx-runtime";var nh=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=g2(t),[a,l]=Z4(!1),s=!a&&r,c=s?void 0:{background:e};return b2("div",{className:K4("Avatar",n),style:c,onClick:o,children:s?b2("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as ir,jsxs as wd}from"react/jsx-runtime";var $4=z({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=ii(r,n),s=X4({"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?wd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[ir("div",{}),ir("div",{}),ir("div",{})]}):n.isMuted?ir("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:Wx}):ir("div",{title:g("userList.hint.inCall"),children:Gx}):null;return i?wd("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[ir(nh,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),ir("div",{className:"UserList__collaborator-name",children:n.username}),wd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&ir("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:Zi}),c]})]}):wd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[ir(nh,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&ir("div",{className:"UserList__collaborator-status-icon",children:c})]})}});var ih=z({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 ks)if(n.some(a=>a.type===i))return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:Do(),status:"unpublished",elements:n.map(zo),created:Date.now()},...i])).then(()=>({captureUpdate:A.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{jsx as la}from"react/jsx-runtime";var $t=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ae(r))},aa=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=ub(n,r,t.scene),a=J(i);return qo(e.map(l=>a.get(l.id)||l),o,t)},j4=z({name:"alignTop",label:"labels.alignTop",icon:nu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>$t(o,r),perform:(e,o,t,r)=>({appState:o,elements:aa(e,o,r,{position:"start",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[y.CTRL_OR_CMD]&&e.shiftKey&&e.key===y.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>la($,{hidden:!$t(o,r),type:"button",icon:nu,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${R("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:Ne(ue(e),o)})}),q4=z({name:"alignBottom",label:"labels.alignBottom",icon:iu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>$t(o,r),perform:(e,o,t,r)=>({appState:o,elements:aa(e,o,r,{position:"end",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[y.CTRL_OR_CMD]&&e.shiftKey&&e.key===y.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>la($,{hidden:!$t(o,r),type:"button",icon:iu,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${R("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:Ne(ue(e),o)})}),J4=z({name:"alignLeft",label:"labels.alignLeft",icon:au,trackEvent:{category:"element"},predicate:(e,o,t,r)=>$t(o,r),perform:(e,o,t,r)=>({appState:o,elements:aa(e,o,r,{position:"start",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[y.CTRL_OR_CMD]&&e.shiftKey&&e.key===y.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>la($,{hidden:!$t(o,r),type:"button",icon:au,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${R("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:Ne(ue(e),o)})}),Q4=z({name:"alignRight",label:"labels.alignRight",icon:lu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>$t(o,r),perform:(e,o,t,r)=>({appState:o,elements:aa(e,o,r,{position:"end",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[y.CTRL_OR_CMD]&&e.shiftKey&&e.key===y.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>la($,{hidden:!$t(o,r),type:"button",icon:lu,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${R("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:Ne(ue(e),o)})}),eT=z({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:su,trackEvent:{category:"element"},predicate:(e,o,t,r)=>$t(o,r),perform:(e,o,t,r)=>({appState:o,elements:aa(e,o,r,{position:"center",axis:"y"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>la($,{hidden:!$t(o,r),type:"button",icon:su,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:Ne(ue(e),o)})}),tT=z({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:cu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>$t(o,r),perform:(e,o,t,r)=>({appState:o,elements:aa(e,o,r,{position:"center",axis:"x"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>la($,{hidden:!$t(o,r),type:"button",icon:cu,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:Ne(ue(e),o)})});import{jsx as y2}from"react/jsx-runtime";var x2=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ae(r))},E2=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=bb(n,t.scene.getNonDeletedElementsMap(),r),a=J(i);return qo(e.map(l=>a.get(l.id)||l),o,t)},oT=z({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:E2(e,o,r,{space:"between",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[y.CTRL_OR_CMD]&&e.altKey&&e.code===se.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>y2($,{hidden:!x2(o,r),type:"button",icon:K0,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${R("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:Ne(ue(e),o)})}),rT=z({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:E2(e,o,r,{space:"between",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[y.CTRL_OR_CMD]&&e.altKey&&e.code===se.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>y2($,{hidden:!x2(o,r),type:"button",icon:Z0,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${R("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:Ne(ue(e),o)})});var ah=z({name:"flipHorizontal",label:"labels.flipHorizontal",icon:Zx,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:qo(v2(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===se.H}),lh=z({name:"flipVertical",label:"labels.flipVertical",icon:Kx,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:qo(v2(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===se.V&&!e[y.CTRL_OR_CMD]}),v2=(e,o,t,r,n)=>{let i=j(ue(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=nT(i,o,t,r,n),l=J(a);return e.map(s=>l.get(s.id)||s)},nT=(e,o,t,r,n)=>{if(e.every(u=>Re(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return ne(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=vr(e);Nb(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,zo(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),qa(e.filter(fe),Un(t),[],n.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>le(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:m}=vr(e),[d,p]=[i-c,a-m];return s.forEach(u=>n.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),l.forEach(u=>n.scene.mutateElement(u,{x:u.x+d,y:u.y+p})),e};var sa=z({name:"copy",label:"labels.copy",icon:dl,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await bd(n,r.files,t)}catch(i){return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),sh=z({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await s2()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),ur?{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(a2({types:n}))}catch(i){return console.error(i),{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),Td=z({name:"cut",label:"labels.cut",icon:_x,trackEvent:{category:"element"},perform:(e,o,t,r)=>(sa.perform(e,o,t,r),El.perform(e,o,null,r)),keyTest:e=>e[y.CTRL_OR_CMD]&&e.key===y.X}),Cd=z({name:"copyAsSvg",label:"labels.copyAsSvg",icon:Xx,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:A.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=ti(e,o,!0);try{await oi("clipboard-svg",n,o,r.files,{...o,exportingFrame:i,name:r.getName()});let a=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:A.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:A.EVENTUALLY}}},predicate:e=>fd&&e.length>0,keywords:["svg","clipboard","copy"]}),Id=z({name:"copyAsPng",label:"labels.copyAsPng",icon:$x,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}=ti(e,o,!0);try{return await oi("clipboard",i,o,r.files,{...o,exportingFrame:a,name:r.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:n.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("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===se.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),kd=z({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{Go(up(n))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>fd&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(Y),keywords:["text","clipboard","copy"]});var Sd=z({name:"gridMode",icon:eE,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[y.CTRL_OR_CMD]&&e.code===se.QUOTE});var ca=z({name:"zenMode",label:"buttons.zenMode",icon:qx,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[y.CTRL_OR_CMD]&&e.altKey&&e.code===se.Z});var ch=z({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:jx,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[y.CTRL_OR_CMD]&&e.altKey&&e.code===se.S});var da=z({name:"stats",label:"stats.fullTitle",icon:Yx,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[y.CTRL_OR_CMD]&&e.altKey&&e.code===se.SLASH});var dh=z({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>ut(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=Ee(a,i);if(l){let{width:s,height:c}=vt(l.originalText,qe(l),l.lineHeight),m=A1(a.id);L1(a.id);let{x:d,y:p}=Us(a,l,i);r.scene.mutateElement(l,{containerId:null,width:s,height:c,text:l.originalText,x:d,y:p}),r.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:A.IMMEDIATELY}}}),mh=z({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=Y(n[0])||Y(n[1]),a;if(xr(n[0])?a=n[0]:xr(n[1])&&(a=n[1]),i&&a&&Ee(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;Y(n[0])&&xr(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),r.scene.mutateElement(i,{containerId:a.id,verticalAlign:Wt.MIDDLE,textAlign:Ua.CENTER,autoResize:!0,angle:Re(a)?0:a?.angle??0}),r.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Ye(i,a,r.scene),Xa(a.id,l),{elements:iT(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:A.IMMEDIATELY}}}),iT=(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),Qo(r,J([o,t])),r},aT=(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),Qo(r,J([o,t])),r},w2=z({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>Y(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(Y(l)){let s=Kt({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:Yr("rectangle")?xt.ADAPTIVE_RADIUS:xt.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-tp,y:l.y-tp,width:Ci(l.width,"rectangle"),height:Ci(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)&&r.scene.mutateElement(d,{startBinding:p,endBinding:u})})}r.scene.mutateElement(l,{containerId:s.id,verticalAlign:Wt.MIDDLE,boundElements:null,textAlign:Ua.CENTER,autoResize:!0}),Ye(l,s,r.scene),i=aT([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:A.IMMEDIATELY}}});import lT from"clsx";import{useCallback as T2,useEffect as C2,useLayoutEffect as sT,useRef as cT,useState as dT}from"react";import{jsx as ma,jsxs as I2}from"react/jsx-runtime";var hh=380,mT=42,ph=5,k2=85,pT=500,uh=!1,Md=new Map,S2=({element:e,scene:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=or(),s=rr(),c=be(),m=e.link||"",[d,p]=dT(m),u=cT(null),f=l.showHyperlinkPopup==="editor",b=T2(()=>{if(!u.current)return;let T=Po(u.current.value)||null;if(!e.link&&T&&de("hyperlink","create"),Nt(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!T){o.mutateElement(e,{link:null}),i(e,!1);return}if(!_i(T,s.validateEmbeddable))T&&n({message:g("toast.unableToEmbed"),closable:!0}),e.link&&Md.set(e.id,e.link),o.mutateElement(e,{link:T}),i(e,!1);else{let{width:S,height:k}=e,D=Yn(T);D?.error instanceof URIError&&n({message:g("toast.unrecognizedLinkFormat"),closable:!0});let M=D?D.intrinsicSize.w/D.intrinsicSize.h:1,O=Md.get(e.id)!==e.link;o.mutateElement(e,{...O?{width:D?.type==="video"?S>k?S:k*M:S,height:D?.type==="video"&&S>k?S/M:k}:{},link:T}),i(e,!0),Md.has(e.id)&&Md.delete(e.id)}}else o.mutateElement(e,{link:T})},[e,o,n,s.validateEmbeddable,l.activeEmbeddable,t,i]);sT(()=>()=>{b()},[b]),C2(()=>{f&&u?.current&&!(c.viewport.isMobile||c.isTouchScreen)&&u.current.select()},[f,c.viewport.isMobile,c.isTouchScreen]),C2(()=>{let T=null,S=k=>{if(f)return;T&&clearTimeout(T),hT(e,a,l,L(k.clientX,k.clientY))&&(T=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},pT))};return window.addEventListener("pointermove",S,!1),()=>{window.removeEventListener("pointermove",S,!1),T&&clearTimeout(T)}},[l,e,f,t,a]);let x=T2(()=>{de("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),E=()=>{de("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:w,y:v}=M2(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:I2("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${v}px`,left:`${w}px`,width:hh,padding:ph},children:[f?ma("input",{className:lT("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:d,onChange:T=>p(T.target.value),autoFocus:!0,onKeyDown:T=>{T.stopPropagation(),T[y.CTRL_OR_CMD]&&T.key===y.K&&T.preventDefault(),(T.key===y.ENTER||T.key===y.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?ma("a",{href:Po(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:zs(e.link)?"_self":"_blank",onClick:T=>{if(e.link&&r){let S=Ps("excalidraw-link",T.nativeEvent);r({...e,link:Po(e.link)},S),S.defaultPrevented&&T.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ma("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),I2("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&ma($,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:E,className:"excalidraw-hyperlinkContainer--edit",icon:on}),ma($,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:Kc}),m&&!Nt(e)&&ma($,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:oo})]})]})},M2=(e,o,t)=>{let[r,n]=ht(e,t),{x:i,y:a}=It({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-hh/2,s=a-o.offsetTop-k2;return{x:l,y:s}},gh=(e,o)=>{let t=j(e,o);return Nt(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},_l=null,L2=(e,o,t)=>{_l&&clearTimeout(_l),_l=window.setTimeout(()=>uT(e,o,t),zf)},uT=(e,o,t)=>{if(!e.link)return;let r=ta();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=Vn(e.link)?g("labels.link.goToElement"):e.link;let[n,i,a,l]=ht(e,t),[s,c,m,d]=Xb([n,i,a,l],e.angle,o),p=It({sceneX:s,sceneY:c},o);$u(r,{left:p.x,top:p.y,width:m,height:d},"top"),de("hyperlink","tooltip","link-icon"),uh=!0},fh=()=>{_l&&clearTimeout(_l),uh&&(uh=!1,ta().classList.remove("excalidraw-tooltip--visible"))},hT=(e,o,t,[r,n])=>{let{x:i,y:a}=Fe({clientX:r,clientY:n},t),l=15/t.zoom.value;if(T1(i,a,e,o))return!1;let[s,c,m]=ht(e,o);if(i>=s&&i<=m&&a>=c-k2&&a<=c)return!1;let{x:d,y:p}=M2(e,t,o);return!(r>=d-l&&r<=d+hh+ph*2+l&&n>=p-l&&n<=p+l+ph*2+mT)};import{jsx as gT}from"react/jsx-runtime";var Dl=z({name:"hyperlink",label:(e,o)=>gh(e,o),icon:ul,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[y.CTRL_OR_CMD]&&e.key===y.K,predicate:(e,o)=>j(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=j(e,o);return gT($,{type:"button",icon:ul,"aria-label":g(gh(e,o)),title:`${Nt(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${R("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});var bh=e=>e.every(o=>!o.locked),xh=z({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":bh(r)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,o)=>{let t=j(o,e);return bh(t)?Ui:Zn},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=bh(n),a=J(n);return{elements:e.map(l=>a.has(l.id)?ne(l,{locked:i}):l),appState:{...o,selectedLinearElement:i?null:o.selectedLinearElement},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===y.L&&e[y.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),A2=z({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Zn,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?ne(r,{locked:!1}):r),appState:{...o,selectedElementIds:Object.fromEntries(t.map(r=>[r.id,!0]))},captureUpdate:A.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import Uy from"clsx";import EI from"fuzzy";import{useEffect as jd,useRef as yI,useState as $d}from"react";import{useEffect as Nl,useMemo as _2,useRef as yh,useState as fT}from"react";import{jsx as Th}from"react/jsx-runtime";var bT=8,xT=10,Pl=["rectangle","diamond","ellipse"],Rl=["line","sharpArrow","curvedArrow","elbowArrow"],ET=new Set(Pl),yT=new Set(Rl),ua=e=>ET.has(e),Ad=e=>e==="arrow"||yT.has(e),Wo=Ie(null),Ol=new Map,zl=new Map,vT=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=yh(null);return Nl(()=>{if(o.length===0){e.updateEditorAtom(Wo,null);return}let r=ha(o);r&&!t.current?t.current=r:(t.current&&!r||t.current&&r!==t.current)&&(e.updateEditorAtom(Wo,null),t.current=null)},[o,e]),Nl(()=>()=>{Ol.clear(),zl.clear()},[]),Th(wT,{app:e,elements:o})},wT=({app:e,elements:o})=>{let t=ha(o),r=_2(()=>t==="generic"?N2(o):[],[t,o]),n=_2(()=>t==="linear"?wh(o):[],[t,o]),i=t==="generic"?r.every(d=>d.type===r[0].type):t==="linear"?n.every(d=>zn(d)===zn(n[0])):!1,[a,l]=fT({x:0,y:0}),s=yh(""),c=yh(null);Nl(()=>{let d=[...r,...n].sort((x,E)=>x.id.localeCompare(E.id)),p=`
8
- ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${d.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(d.length===1){let[x,,,E,w,v]=ht(d[0],e.scene.getNonDeletedElementsMap());u=Oe(L(x,E),L(w,v),d[0].angle)}else{let{minX:x,maxY:E}=vr(d);u=L(x,E)}let{x:f,y:b}=It({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[r,n,e.scene,e.state]),Nl(()=>{for(let d of n){let p=vh(d.id,ST(d));zl.has(p)||zl.set(p,d)}},[n]),Nl(()=>{for(let d of r)if(!Ol.has(d.id)){let p=Ee(d,e.scene.getNonDeletedElementsMap());p&&Ol.set(d.id,{fontSize:p.fontSize})}},[r,e.scene]);let m=t==="linear"?[["line",Ac],["sharpArrow",Gc],["curvedArrow",Vc],["elbowArrow",Wc]]:t==="generic"?[["rectangle",Sc],["diamond",Mc],["ellipse",Lc]]:[];return Th("div",{ref:c,tabIndex:-1,style:{position:"absolute",top:`${a.y+(xT+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-bT}px`,zIndex:2},className:Rt.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([d,p])=>{let u=i&&(t==="generic"&&r[0].type===d||t==="linear"&&zn(n[0])===d);return Th($,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:d,keyBindingLabel:"","aria-label":d,"data-testid":`toolbar-${d}`,onChange:()=>{e.state.activeTool.type!==d&&de("convertElementType",d,"ui"),Ch(e,{conversionType:t,nextType:d}),c.current?.focus()}},`${o[0].id}${o[0].version}_${d}`)})})},TT=(e,o,t)=>{let r=ja(e,o),n=Ws(e,o),i=Ti(o.text,qe(o),r),a=vt(i,qe(o),o.lineHeight),l=o.fontSize;for(;(a.width>r||a.height>n)&&l>0;){l-=1;let s={...o,fontSize:l};a=vt(o.text,qe(s),o.lineHeight)}Oo(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),Ye(o,e,t)},Ch=(e,{conversionType:o,nextType:t,direction:r="right"})=>{if(!o)return!1;let n=e.scene.getSelectedElements(e.state),i=n.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=r==="right"?1:-1;if(o==="generic"){let l=N2(n),c=l.every(m=>m.type===l[0].type)?Pl.indexOf(l[0].type):-1;if(t=t??Pl[(c+Pl.length+a)%Pl.length],t&&ua(t)){let m={};for(let p of l){let u=P2(p,t,e);m[u.id]=u}let d=[];for(let p of e.scene.getElementsIncludingDeleted())m[p.id]?d.push(m[p.id]):d.push(p);e.scene.replaceAllElements(d);for(let p of Object.values(m)){let u=Ee(p,e.scene.getNonDeletedElementsMap());u&&(Ol.get(p.id)&&Oo(u,e.scene.getNonDeletedElementsMap(),{fontSize:Ol.get(p.id)?.fontSize??u.fontSize}),TT(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:De(p,{type:"selection"})}))}}if(o==="linear"){let l=wh(n);if(!t){let c=Os(l,zn),m=c?Rl.indexOf(c):-1;t=Rl[(m+Rl.length+a)%Rl.length]}if(Ad(t)){let c=[],m=e.scene.getElementsMapIncludingDeleted();for(let d of l){let p=zl.get(vh(d.id,t));if(p&&zn(p)===t)m.set(p.id,p),c.push(p);else{let u=P2(d,t,e);m.set(u.id,u),c.push(u)}}e.scene.replaceAllElements(m);for(let d of c)if(fe(d))if(le(d)){let p=CT(d);if(p.length<2)continue;let u=[];for(let b=0;b<p.length-1;b++)u.push({start:p[b],end:p[b+1],index:b+1});let f=qs(d,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});Oo(d,e.scene.getNonDeletedElementsMap(),{...f})}else{let p=n1(["line","sharpArrow","curvedArrow"],u=>zl.get(vh(d.id,u)));if(p){let u=p.points;e.scene.mutateElement(d,{points:u})}}}let s=wh(e.scene.getSelectedElements(e.state));e.setState(c=>({selectedElementIds:i,selectedLinearElement:s.length===1?new X(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:De(c,{type:"selection"})}))}return!0},ha=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(ua(t.type))return"generic";R2(t)&&(o=!0)}return o?"linear":null},R2=e=>fe(e)&&(!Re(e)||!E1(e)&&!ut(e)),vh=(e,o)=>`${e}:${o}`,N2=e=>e.filter(o=>ua(o.type)),wh=e=>e.filter(o=>R2(o)),Ld=20,pa=(e,o)=>e[0]===o[0],Eh=(e,o)=>e[1]===o[1],D2=(e,o)=>pa(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),CT=e=>{let o=[e.points[0]],t=IT(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<Ld?l[0]=a[0]:Math.abs(l[1]-a[1])<Ld&&(l[1]=a[1]),pa(a,l)||Eh(a,l)||o.push(L(a[0],l[1])),o.push(l)}let r=[o[0]];for(let i=1;i<o.length-1;++i)pa(o[i-1],o[i])&&pa(o[i],o[i+1])||Eh(o[i-1],o[i])&&Eh(o[i],o[i+1])||r.push(o[i]);r.push(o[o.length-1]);let n=[r[0]];for(let i=1;i<r.length-1;++i){let a=n[n.length-1],l=r[i],s=r[i+1],c=pa(a,l),m=pa(l,s);if(c!==m){let d=D2(a,l),p=D2(l,s);if(d<Ld||p<Ld){if(p<d)c?s[0]=a[0]:s[1]=a[1];else if(m)for(let u=n.length-1;u>=0&&n[u][0]===a[0];--u)n[u][0]=l[0];else for(let u=n.length-1;u>=0&&n[u][1]===a[1];--u)n[u][1]=l[1];continue}}n.push(l)}return n.push(r[r.length-1]),n},IT=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[r,n]=o[o.length-1],[i,a]=e[t];(r!==i||n!==a)&&o.push(e[t])}return o},P2=(e,o,t)=>{if(!kT(e.type,o)){if(!d1())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(Jo.delete(e),ua(o)){let r=Er(Kt({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:Yr(o)?xt.ADAPTIVE_RADIUS:xt.PROPORTIONAL_RADIUS}:e.roundness}));return jr(r,t.scene),r}if(Ad(o))switch(o){case"line":return Er(bo({...e,type:"line"}));case"sharpArrow":return Er(Jr({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return Er(Jr({...e,type:"arrow",elbowed:!1,roundness:{type:xt.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return Er(Jr({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return Ei(o,`unhandled conversion type: ${o}`),e},kT=(e,o)=>!!(ua(e)&&ua(o)||Ad(e)&&Ad(o)),ST=e=>fe(e)?zn(e):e.type,O2=vT;var z2=z({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,r){return it.set(Wo,{type:"panel"}),{captureUpdate:A.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>ha(e)!==null});var _d=z({name:"copyElementLink",label:"labels.copyElementLink",icon:Yi,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=j(e,o);try{if(window.location){let i=lc(n,o);return i?(await Go(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):ac(i.id,i.type)),{appState:{toast:{message:g("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)=>sc(j(e,o))}),B2=z({name:"linkToElement",label:"labels.linkToElement",icon:Kc,perform:(e,o,t,r)=>{let n=j(e,o);return n.length!==1||!sc(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&&sc(n)},trackEvent:!1});var MT={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+${g("helpDialog.drag")}`)],sendBackward:[R("CtrlOrCmd+[")],bringForward:[R("CtrlOrCmd+]")],sendToBack:[Lo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")],bringToFront:[Lo?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:[]},Qe=(e,o=0)=>{let t=MT[e];return t&&t.length>0?t[o]||t[0]:""};var LT="\\u0300-\\u036f",AT="\\ufe20-\\ufe2f",_T="\\u20d0-\\u20ff",DT=LT+AT+_T,PT=`[${DT}]`,RT=RegExp(PT,"g"),NT=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,OT={\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"},Ih=e=>e.replace(NT,o=>OT[o]||o).replace(RT,"");import eI from"clsx";import{useEffect as tI,useState as oI}from"react";import{useCallback as zT,useState as BT}from"react";var F2=()=>{let[e,o]=BT(null),t=zT(r=>o(r),[]);return[e,t]};import{useState as ky,useCallback as Oh,useMemo as Sy,useEffect as Ty,memo as My,useRef as ZC}from"react";import{useEffect as W2,useRef as V2}from"react";var mn=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=zi({elements:e,appState:o},null,null),{exportBackground:c,viewBackgroundColor:m}=s;return xc(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:c,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(d,p)=>{let u=document.createElement("canvas");if(r){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(d,p),x=r<b?r/b:o?.exportScale??1;return u.width=d*x,u.height=p*x,{canvas:u,scale:x}}let f=n?.(d,p)||{width:d,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},H2=async e=>{let{mimeType:o=ce.png,quality:t}=e;o===ce.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ce.png}" mimeType`),o==="image/jpg"&&(o=ce.jpg),o===ce.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ce.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await mn(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((n,i)=>{r.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===ce.png&&e.appState?.exportEmbedScene&&(a=await o0({blob:a,metadata:nl(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},ga=async({elements:e,appState:o=en(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:c}=zi({elements:e,appState:o},null,null),m={...c,exportPadding:r};return Oi(s,m,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},FT=async e=>{if(e.type==="svg"){let o=await ga(e);await Go(o.outerHTML)}else if(e.type==="png")await Ed(H2(e));else if(e.type==="json")await bd(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as HT,useState as UT}from"react";var kh=Ie(new Map),U2=async e=>await ga({elements:e,appState:{exportBackground:!1,viewBackgroundColor:uo.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),G2=(e,o,t)=>{let[r,n]=UT();return HT(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await U2(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await U2(o);n(i)})()},[e,o,t,n]),r},Dd=()=>{let[e]=he(kh);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var GT=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],K2=new go,ai=Ie({status:"loaded",isInitialized:!1,libraryItems:[]}),Bl=e=>Yt(e),WT=(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)),Z2=(e,o)=>{let t=[];for(let r of o)WT(e,r)&&t.push(r);return[...t,...e]},X2=(e,o)=>{let t=J(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=J(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},Sh=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",Bl(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)it.set(ai,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{it.set(ai,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Bl(this.currLibraryItems);let t=Bl(this.currLibraryItems);this.app.props.onLibraryChange?.(t),K2.trigger(X2(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],it.set(kh,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(Bl(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:_t.name,tab:Ga}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),c;s instanceof Blob?c=await Kp(s,i):c=ll(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),a(r?Z2(this.currLibraryItems,c):c)):l(new Ri)}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=Bl(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}},$2=Sh,Nd=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}=vr(x.elements);return Math.max(b,E)},0),i=u=>{let f=0,b=0,x=0;for(let E of e){if(f%t===0&&(b=0),b===u){let{width:w}=vr(E.elements);x=Math.max(x,w)}f++,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:f,minY:b,width:x,height:E}=vr(u.elements),w=(c-x)/2,v=(s-E)/2;r.push(...u.elements.map(T=>({...T,x:T.x+a+w-f,y:T.y+l+v-b}))),a+=c+50,m++,d++}return r},VT=(e,o=GT)=>{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}"`)},Mh=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(ws.addLibrary)||new URLSearchParams(window.location.search).get(vs.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},pn=class pn{constructor(o){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(ll(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?pn.queue.push(n):n()}getLibraryItems(o){return pn.getLibraryItems(this.adapter,o,!1)}};I(pn,"queue",new Xf),I(pn,"run",async(o,t)=>{let r=new pn(o);return pn.queue.push(()=>t(r))});var fa=pn,Fl=0,Pd=0,Rd=e=>zp(e.map(o=>`${o.id}:${Op(o.elements)}`).sort().join()),Y2=async(e,o)=>{try{return Pd++,await fa.run(e,async t=>{let r=J(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=Rd(i);return a!==Fl&&await e.save({libraryItems:i}),Fl=a,i})}finally{Pd--}},YT=e=>{let{excalidrawAPI:o}=e,t=V2(e);t.current=e;let r=V2(!1);W2(()=>{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=Bs(l),VT(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();d(f)}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(ws.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(ws.addLibrary),window.history.replaceState({},za,`#${d.toString()}`)}else if(window.location.search.includes(vs.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(vs.addLibrary),window.history.replaceState({},za,`?${d.toString()}`)}}},i=l=>{l.preventDefault();let s=Mh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Mh();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=i1();s?c.resolve(mp(s.load).then(async m=>{let d=null;try{if(!m)return fa.getLibraryItems(l,"load");d=ll(m.libraryItems||[],"published");let p=await Y2(l,X2([],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}`),fa.getLibraryItems(l,"load")))):c.resolve(mp(fa.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:c.then(m=>{let d=m||[];return Fl=Rd(d),d}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[o]),W2(()=>{let n=K2.on(async(a,l)=>{let s=r.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&Fl!==Rd(l)&&await Y2(c,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{Pd&&s1(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),Fl=0,Pd=0}},[])};import XT from"clsx";import{jsx as ZT}from"react/jsx-runtime";var KT=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return ZT("a",{className:"library-menu-browse-button",href:`${C.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${Cs.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},j2=KT;import{jsx as $T,jsxs as jT}from"react/jsx-runtime";var Od=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>jT("div",{className:XT("library-menu-control-buttons",i),style:r,children:[$T(j2,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as Ea,useEffect as GC,useMemo as vy,useRef as WC,useState as VC}from"react";import qT from"lodash.throttle";import{useEffect as JT}from"react";var QT=Ie(0),q2=e=>{let[o,t]=he(QT);return JT(()=>{let{current:r}=e;if(!r)return;let n=qT(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import kC from"clsx";import{useCallback as SC,useState as _h}from"react";import{flushSync as J2}from"react-dom";import eC from"clsx";import{jsx as zd,jsxs as oC}from"react/jsx-runtime";var tC=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return oC("button",{className:eC("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&zd("div",{style:a?{visibility:"hidden"}:{},children:r}),zd("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&zd("div",{style:{position:"absolute",inset:0},children:zd(St,{})})]})},Mr=tC;import{jsx as Q2,jsxs as ey}from"react/jsx-runtime";var rC=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=ye(),c=tn(ba),{container:m}=at();return ey(et,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,ey("div",{className:"confirm-dialog-buttons",children:[Q2(Mr,{label:i,onClick:()=>{s({openMenu:null}),c(!1),J2(()=>{t()}),m?.focus()}}),Q2(Mr,{label:n,onClick:()=>{s({openMenu:null}),c(!1),J2(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},Bd=rC;import Hd from"open-color";import{useCallback as dC,useEffect as Ah,useRef as ty,useState as Lh}from"react";var To=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(To,"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(To,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Fd from"react";var nC=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,iC=/{{([\w-]+)}}/,aC=/<([\w-]+)>/,lC=/<\/([\w-]+)>/,sC=(e,o)=>{let t=[{name:"",children:[]}];return e.split(nC).filter(Boolean).forEach(r=>{let n=r.match(aC),i=r.match(lC),a=r.match(iC);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=Fd.createElement(Fd.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},cC=({i18nKey:e,children:o,...t})=>{let{t:r}=ot();return Fd.createElement(Fd.Fragment,{},...sC(r(e),t))},Ft=cC;import{jsx as ge,jsxs as Dt}from"react/jsx-runtime";var mC=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=r1(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=Hd.white,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let m=await mn({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:d,height:p}=m,u=Math.floor(s/6)*(128+r*2),f=s%6*(128+r*2);l.drawImage(m,f+(128-d)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=Hd.gray[4],l.strokeRect(f+r/2,u+r/2,128+r,128+r)}return await sl(new File([await Tr(a)],"preview",{type:ce.png}),{outputType:ce.jpg,maxWidthOrHeight:5e3})},pC=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=ty(null),a=ty(null);return Ah(()=>{let l=i.current;l&&(async()=>{let s=await ga({elements:e.elements,appState:{...o,viewBackgroundColor:Hd.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),Dt("div",{className:"single-library-item",children:[e.status==="published"&&ge("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),ge("div",{ref:i,className:"single-library-item__svg"}),ge($,{"aria-label":g("buttons.remove"),type:"button",icon:xo,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:g("buttons.remove")}),Dt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[Dt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[Dt("div",{style:{padding:"0.5em 0"},children:[ge("span",{style:{fontWeight:500,color:Hd.gray[6]},children:g("publishDialog.itemName")}),ge("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ge("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),ge("span",{className:"error",children:e.error})]})]})},uC=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Lh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=Lh(!1);Ah(()=>{let v=To.get(Hr.PUBLISH_LIBRARY);v&&s(v)},[]);let[d,p]=Lh(o.slice());Ah(()=>{p(o.slice())},[o]);let u=v=>{s({...l,[v.target.name]:v.target.value})},f=async v=>{v.preventDefault(),m(!0);let T=[],S=!1;if(d.forEach(F=>{let K="";F.name||(K=g("publishDialog.errors.required"),S=!0),T.push({...F,error:K})}),S){p(T),m(!1);return}let k=await mC(d),D={type:Br.excalidrawLibrary,version:Cs.excalidrawLibrary,source:Df,libraryItems:d},M=JSON.stringify(D,null,2),O=new Blob([M],{type:"application/json"}),P=new FormData;P.append("excalidrawLib",O),P.append("previewImage",k),P.append("previewImageType",k.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(`${C.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(F=>F.ok?F.json().then(({url:K})=>{To.delete(Hr.PUBLISH_LIBRARY),r({url:K,authorName:l.authorName,items:d})}):F.json().catch(()=>{throw new Error(F.statusText||"something went wrong")}).then(K=>{throw new Error(K.message||F.statusText||"something went wrong")}),F=>{console.error(F),n(F),m(!1)}).catch(F=>{console.error(F),n(F),m(!1)})},b=()=>{let v=[];return d.forEach((T,S)=>{v.push(ge("div",{className:"single-library-item-wrapper",children:ge(pC,{libItem:T,appState:t,index:S,onChange:(k,D)=>{let M=d.slice();M[D].name=k,p(M)},onRemove:a})},S))}),ge("div",{className:"selected-library-items",children:v})},x=dC(()=>{i(d),To.set(Hr.PUBLISH_LIBRARY,l),e()},[d,e,i,l]),E=!!o.length,w=o.some(v=>v.status==="published");return ge(et,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:E?Dt("form",{onSubmit:f,children:[ge("div",{className:"publish-library-note",children:ge(Ft,{i18nKey:"publishDialog.noteDescription",link:v=>ge("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:v})})}),ge("span",{className:"publish-library-note",children:ge(Ft,{i18nKey:"publishDialog.noteGuidelines",link:v=>ge("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:v})})}),ge("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),w&&ge("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),Dt("div",{className:"publish-library__fields",children:[Dt("label",{children:[Dt("div",{children:[ge("span",{children:g("publishDialog.libraryName")}),ge("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ge("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),Dt("label",{style:{alignItems:"flex-start"},children:[Dt("div",{children:[ge("span",{children:g("publishDialog.libraryDesc")}),ge("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ge("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),Dt("label",{children:[Dt("div",{children:[ge("span",{children:g("publishDialog.authorName")}),ge("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ge("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),Dt("label",{children:[ge("span",{children:g("publishDialog.githubUsername")}),ge("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),Dt("label",{children:[ge("span",{children:g("publishDialog.twitterUsername")}),ge("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),Dt("label",{children:[ge("span",{children:g("publishDialog.website")}),ge("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),ge("span",{className:"publish-library-note",children:ge(Ft,{i18nKey:"publishDialog.noteLicense",link:v=>ge("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:v})})})]}),Dt("div",{className:"publish-library__buttons",children:[ge(Mr,{label:g("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),ge(Mr,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:c})]})]}):ge("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},oy=uC;import fC from"clsx";import{useEffect as bC,useRef as xC}from"react";import{forwardRef as ry}from"react";import ny from"clsx";import{jsx as iy}from"react/jsx-runtime";var hC=ry(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>iy("div",{className:ny("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),gC=ry(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>iy("div",{className:ny("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...i},ref:a,children:e})),wt={Row:hC,Col:gC};import{jsx as Ud}from"react/jsx-runtime";var ay=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=be(),a=xC(null),l=rn({onClickOutside:o});Xi(a,()=>{l.onClickOutside?.()}),bC(()=>{let c=d=>{d.key===y.ESCAPE&&(d.stopImmediatePropagation(),l.onClickOutside?.())},m={capture:!0};return document.addEventListener("keydown",c,m),()=>{document.removeEventListener("keydown",c,m)}},[l]);let s=fC(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Ud(zu.Provider,{value:{onSelect:r},children:Ud("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?Ud(wt.Col,{className:"dropdown-menu-container",children:e}):Ud(gt,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};ay.displayName="DropdownMenuContent";var ly=ay;import{jsx as yC}from"react/jsx-runtime";var EC=({children:e,className:o="",selected:t,...r})=>yC("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),sy=EC;import{jsx as cy}from"react/jsx-runtime";var dy=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noopener",...s})=>{let c=ad(s.onClick,n);return cy("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:id(i,a),title:s.title??s["aria-label"],onClick:c,children:cy(nd,{icon:e,shortcut:o,children:r})})},xa=dy;dy.displayName="DropdownMenuItemLink";import{jsx as vC}from"react/jsx-runtime";var my=()=>vC("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),py=my;my.displayName="DropdownMenuSeparator";import wC from"clsx";import{jsx as TC}from"react/jsx-runtime";var uy=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=be(),a=wC(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return TC("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},hy=uy;uy.displayName="DropdownMenuTrigger";import Gd from"react";var gy=e=>{let o=Gd.Children.toArray(e).find(t=>Gd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},fy=e=>{let o=Gd.Children.toArray(e).find(t=>Gd.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as CC,jsxs as IC}from"react/jsx-runtime";var Lr=({children:e,open:o})=>{let t=gy(e),r=fy(e);return IC(CC,{children:[t,o&&r]})};Lr.Trigger=hy;Lr.Content=ly;Lr.Item=zt;Lr.ItemLink=xa;Lr.ItemCustom=sy;Lr.Group=Tl;Lr.Separator=py;var Ae=Lr;Lr.displayName="DropdownMenu";import{jsx as jt,jsxs as Wd}from"react/jsx-runtime";var MC=(e,o)=>e.filter(t=>o.includes(t.id)),LC=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=he(ai),[c,m]=he(ba),d=()=>{let P=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),F=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return jt(Bd,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:F,children:jt("p",{children:P})})},[p,u]=_h(!1),f=!!o.length,b=f?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[E,w]=_h(!1),[v,T]=_h(null),S=SC(()=>Wd(et,{onCloseRequest:()=>T(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[jt("p",{children:jt(Ft,{i18nKey:"publishSuccessDialog.content",authorName:v.authorName,link:P=>jt("a",{href:v?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),jt($,{type:"button",title:g("buttons.close"),"aria-label":g("buttons.close"),label:g("buttons.close"),onClick:()=>T(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[T,v]),k=(P,F)=>{w(!1),T({url:P.url,authorName:P.authorName});let K=F.slice();K.forEach(V=>{o.includes(V.id)&&(V.status="published")}),t.setLibrary(K)},D=async()=>{try{await t.updateLibrary({libraryItems:uc({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:g("errors.importLibraryError")})}},M=async()=>{let P=f?b:await t.getLatestLibrary();Zb(P).catch(Ds).catch(F=>{e({errorMessage:F.message})})},O=()=>Wd(Ae,{open:c,children:[jt(Ae.Trigger,{onToggle:()=>m(!c),children:v0}),Wd(Ae.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!f&&jt(Ae.Item,{onSelect:D,icon:Vi,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&jt(Ae.Item,{onSelect:M,icon:Xn,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),!!b.length&&jt(Ae.Item,{onSelect:()=>u(!0),icon:oo,children:x}),f&&jt(Ae.Item,{icon:Ax,onSelect:()=>w(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")})]})]});return Wd("div",{className:kC("library-menu-dropdown-container",l),children:[O(),o.length>0&&jt("div",{className:"library-actions-counter",children:o.length}),p&&d(),E&&jt(oy,{onClose:()=>w(!1),libraryItems:MC(s.libraryItems,o),appState:a,onSuccess:P=>k(P,s.libraryItems),onError:P=>window.alert(P),updateItemsInStorage:()=>t.setLibrary(s.libraryItems),onRemove:P=>i(o.filter(F=>F!==P))}),v&&S()]})},Dh=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=Je(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=Dd(),a=Le(),l=ye(),[s]=he(ai),c=async d=>{let p=d.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return jt(LC,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as BC,useEffect as FC,useState as HC}from"react";import AC,{useCallback as _C}from"react";function DC(){return[!1,_C(o=>o(),[])]}var by=AC.useTransition||DC;import xy from"clsx";import{memo as PC,useEffect as RC,useRef as NC,useState as OC}from"react";import{jsx as Vd,jsxs as zC}from"react/jsx-runtime";var Ey=PC(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=NC(null),c=G2(e,o,l);RC(()=>{let f=s.current;if(f)return c&&(f.innerHTML=c.outerHTML),()=>{f.innerHTML=""}},[c]);let[m,d]=OC(!1),p=be().editor.isMobile,u=t&&Vd("div",{className:"library-unit__adder",children:y0});return zC("div",{className:xy("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:[Vd("div",{className:xy("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):r(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}d(!1),a(e,f)}}),u,e&&o&&(m||p||n)&&Vd(Sl,{checked:n,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),yy=()=>Vd("div",{className:"library-unit library-unit--skeleton"});import{Fragment as UC,jsx as Yd}from"react/jsx-runtime";var Ph=({children:e})=>Yd("div",{className:"library-menu-items-container__grid",children:e}),Kd=BC(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=by(),[s,c]=HC(0);return FC(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),Yd(UC,{children:e.map((m,d)=>d<s?Yd(Ey,{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):Yd(yy,{},d))})});import{Fragment as wy,jsx as qt,jsxs as ya}from"react/jsx-runtime";var YC=17,KC=64;function Rh({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let m=WC(null),d=q2(m);GC(()=>{d>0&&m.current?.scrollTo(0,d)},[]);let{svgCache:p}=Dd(),u=vy(()=>o.filter(P=>P.status!=="published"),[o]),f=vy(()=>o.filter(P=>P.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!f.length,[E,w]=VC(null),v=Ea((P,F)=>{let K=!c.includes(P),V=[...u,...f];if(K){if(F.shiftKey&&E){let te=V.findIndex(oe=>oe.id===E),H=V.findIndex(oe=>oe.id===P);if(te===-1||H===-1){s([...c,P]);return}let B=J(c),ee=V.reduce((oe,Z,pe)=>((pe>=te&&pe<=H||B.has(Z.id))&&oe.push(Z.id),oe),[]);s(ee)}else s([...c,P]);w(P)}else w(null),s(c.filter(te=>te!==P))},[E,s,f,c,u]),T=Ea(P=>{let F;return c.includes(P)?F=o.filter(K=>c.includes(K.id)):F=o.filter(K=>K.id===P),F.map(K=>({...K,elements:Wn({type:"everything",elements:K.elements,randomizeSeed:!0}).duplicatedElements}))},[o,c]),S=Ea((P,F)=>{F.dataTransfer.setData(ce.excalidrawlib,Wp(T(P)))},[T]),k=Ea(P=>P?c.includes(P):!1,[c]),D=Ea(()=>{t(n)},[n,t]),M=Ea(P=>{P&&r(T(P))},[T,r]),O=p.size>=o.length?KC:YC;return ya("div",{className:"library-menu-items-container",style:n.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&qt(Dh,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),ya(wt.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:f.length>0?1:"0 1 auto",marginBottom:0},ref:m,children:[ya(wy,{children:[!x&&qt("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),e&&qt("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:qt(St,{})}),!n.length&&!u.length?ya("div",{className:"library-menu-items__no-items",children:[qt("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),qt("div",{className:"library-menu-items__no-items__hint",children:f.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):ya(Ph,{children:[n.length>0&&qt(Kd,{itemsRenderedPerBatch:O,items:[{id:null,elements:n}],onItemSelectToggle:v,onItemDrag:S,onClick:D,isItemSelected:k,svgCache:p}),qt(Kd,{itemsRenderedPerBatch:O,items:u,onItemSelectToggle:v,onItemDrag:S,onClick:M,isItemSelected:k,svgCache:p})]})]}),ya(wy,{children:[(f.length>0||n.length>0||u.length>0)&&qt("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:g("labels.excalidrawLib")}),f.length>0?qt(Ph,{children:qt(Kd,{itemsRenderedPerBatch:O,items:f,onItemSelectToggle:v,onItemDrag:S,onClick:M,isItemSelected:k,svgCache:p})}):u.length>0?qt("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:g("library.noItems")}):null]}),b&&qt(Od,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:qt(Dh,{selectedItems:c,onSelectItems:s})})]})]})}import{jsx as un,jsxs as Iy}from"react/jsx-runtime";var ba=Ie(!1),Cy=({children:e})=>un("div",{className:"layer-ui__library",children:e}),XC=My(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=he(ai),d=Oh(f=>{(async(x,E)=>{de("element","addToLibrary","ui");for(let v of ks)if(x.some(T=>T.type===v))return r({errorMessage:g(`errors.libraryElementTypeError.${v}`)});let w=[{status:"unpublished",elements:x,id:Do(),created:Date.now()},...E];t(),i.setLibrary(w).catch(()=>{r({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,m.libraryItems)},[t,i,r,m.libraryItems]),p=Sy(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return un(Cy,{children:un("div",{className:"layer-ui__library-message",children:Iy("div",{children:[un(St,{size:"2em"}),un("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return Iy(Cy,{children:[un(Rh,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),u&&un(Od,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Nh=(e,o)=>({elements:e,pending:j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),$C=(e,o)=>{let t=an(),[r,n]=ky(()=>Nh(t,e.selectedElementIds)),i=ZC(new Map);return Ty(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),Ty(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!rt(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Nh(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 Nh(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},Ly=My(()=>{let e=Je(),{onInsertElements:o}=e,t=rr(),r=Le(),n=ye(),[i,a]=ky([]),l=Sy(()=>e.library,[e.library]),s=$C(r,e),c=Oh(d=>{o(Nd(d))},[o]),m=Oh(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return un(XC,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import jC from"clsx";import{useRef as qC}from"react";import{createPortal as JC}from"react-dom";import{jsx as Ay,jsxs as QC}from"react/jsx-runtime";var _y=e=>{let{closeOnClickOutside:o=!0}=e,t=qc({className:"excalidraw-modal-container"}),r=qC(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===y.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return JC(QC("div",{className:jC("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[Ay("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),Ay("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Hl,jsxs as nI}from"react/jsx-runtime";function rI(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var et=e=>{let[o,t]=F2(),[r]=oI(document.activeElement),{id:n}=at(),i=be().viewport.isMobile;tI(()=>{if(!o)return;let c=Za(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=d=>{if(d.key===y.TAB){let p=Za(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):f===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=ye(),l=tn(ba),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return Hl(_y,{className:eI("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:rI(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:nI(gt,{ref:t,children:[e.title&&Hl("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:Hl("span",{className:"Dialog__titleContent",children:e.title})}),i&&Hl("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:xo}),Hl("div",{className:"Dialog__content",children:e.children})]})})};import zh from"clsx";import{forwardRef as lI,useRef as sI,useImperativeHandle as cI,useLayoutEffect as dI,useState as mI}from"react";import iI from"clsx";import{jsx as aI}from"react/jsx-runtime";var co=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>aI("button",{onClick:Vr(i.onClick,a=>{o()}),type:e,className:iI("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as Bh,jsxs as Dy}from"react/jsx-runtime";var va=lI(({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=sI(null);cI(d,()=>p.current),dI(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=mI(!1);return Dy("div",{className:zh("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&Bh("div",{className:"ExcTextField__label",children:o}),Dy("div",{className:zh("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[Bh("input",{className:zh({"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&&Bh(co,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?Bx:Zi})]})]})});var Ul=[{icon:k0,value:"selection",key:y.V,numericKey:y[1],fillable:!0},{icon:Sc,value:"rectangle",key:y.R,numericKey:y[2],fillable:!0},{icon:Mc,value:"diamond",key:y.D,numericKey:y[3],fillable:!0},{icon:Lc,value:"ellipse",key:y.O,numericKey:y[4],fillable:!0},{icon:S0,value:"arrow",key:y.A,numericKey:y[5],fillable:!0},{icon:Ac,value:"line",key:y.L,numericKey:y[6],fillable:!0},{icon:on,value:"freedraw",key:[y.P,y.X],numericKey:y[7],fillable:!1},{icon:Gi,value:"text",key:y.T,numericKey:y[8],fillable:!1},{icon:L0,value:"image",key:null,numericKey:y[9],fillable:!1},{icon:A0,value:"eraser",key:y.E,numericKey:y[0],fillable:!1}],Py=e=>Ul.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 Uh from"clsx";import{useState as hI}from"react";import{createIsolation as pI}from"jotai-scope";import Fh from"react";import ar from"tunnel-rat";var Hh=Fh.createContext(null),Ue=()=>Fh.useContext(Hh),uI=pI(),Ry=()=>Fh.useMemo(()=>({MainMenuTunnel:ar(),WelcomeScreenMenuHintTunnel:ar(),WelcomeScreenToolbarHintTunnel:ar(),WelcomeScreenHelpHintTunnel:ar(),WelcomeScreenCenterTunnel:ar(),FooterCenterTunnel:ar(),DefaultSidebarTriggerTunnel:ar(),DefaultSidebarTabTriggersTunnel:ar(),OverwriteConfirmDialogTunnel:ar(),TTDDialogTriggerTunnel:ar(),tunnelsJotai:uI}),[]);import{Fragment as Ar,jsx as Be,jsxs as ft}from"react/jsx-runtime";var Gh=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return el(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>el(r.type))},Wh=(e,o)=>qr(e.activeTool.type)||o.some(t=>qr(t.type)),Zd=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=Ys(o,e),i=!1;n.length===2&&(ut(n[0])||ut(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=be(),s=document.documentElement.getAttribute("dir")==="rtl",c=qr(e.activeTool.type)&&!Rn(e.currentItemBackgroundColor)||n.some(f=>qr(f.type)&&!Rn(f.backgroundColor)),m=n.length===1||i,d=!e.editingLinearElement&&n.length===1&&fe(n[0])&&!le(n[0]),p=!e.croppingElementId&&n.length===1&&Me(n[0]),u=!i&&$t(e,r);return ft("div",{className:"panelColumn",children:[Be("div",{children:Gh(e,n)&&t("changeStrokeColor")}),Wh(e,n)&&Be("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(vp(e.activeTool.type)||n.some(f=>vp(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(wp(e.activeTool.type)||n.some(f=>wp(f.type)))&&ft(Ar,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Tp(e.activeTool.type)||n.some(f=>Tp(f.type)))&&Be(Ar,{children:t("changeRoundness")}),(Cp(e.activeTool.type)||n.some(f=>Cp(f.type)))&&Be(Ar,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(Y))&&ft(Ar,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||H1(n,o))&&t("changeTextAlign")]}),F1(n,o)&&t("changeVerticalAlign"),(Mi(e.activeTool.type)||n.some(f=>Mi(f.type)))&&Be(Ar,{children:t("changeArrowhead")}),t("changeOpacity"),ft("fieldset",{children:[Be("legend",{children:g("labels.layers")}),ft("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&ft("fieldset",{children:[Be("legend",{children:g("labels.align")}),ft("div",{className:"buttonList",children:[s?ft(Ar,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):ft(Ar,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),Be("div",{style:{flexBasis:"100%",height:0}}),ft("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&&ft("fieldset",{children:[Be("legend",{children:g("labels.actions")}),ft("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")]})]})]})},Xd=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=hI(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso",c=e.type==="embeddable",{TTDDialogTriggerTunnel:m}=Ue();return ft(Ar,{children:[Ul.map(({value:d,icon:p,key:u,numericKey:f,fillable:b},x)=>{if(r.tools?.[d]===!1)return null;let E=g(`toolBar.${d}`),w=u&&Ur(typeof u=="string"?u:u[0]),v=w?`${w} ${g("helpDialog.or")} ${f}`:`${f}`;return Be($,{className:Uh("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===d,name:"editor-current-shape",title:`${Ur(E)} \u2014 ${v}`,keyBindingLabel:f||w,"aria-label":Ur(E),"aria-keyshortcuts":v,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:T})=>{!o.penDetected&&T==="pen"&&t.togglePenMode(!0),d==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:T})=>{o.activeTool.type!==d&&de("toolbar",d,"ui"),d==="image"?t.setActiveTool({type:d,insertOnCanvasDirectly:T!=="mouse"}):t.setActiveTool({type:d})}},d)}),Be("div",{className:"App-toolbar__divider"}),ft(Ae,{open:n,children:[Be(Ae.Trigger,{className:Uh("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||c||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!n),title:g("toolBar.extraTools"),children:a?jn:c?jp:l&&!t.props.isCollaborating?gl:s?cl:Ox}),ft(Ae.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Be(Ae.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:jn,shortcut:y.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:g("toolBar.frame")}),Be(Ae.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:jp,"data-testid":"toolbar-embeddable",selected:c,children:g("toolBar.embeddable")}),Be(Ae.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:gl,"data-testid":"toolbar-laser",selected:l,shortcut:y.K.toLocaleUpperCase(),children:g("toolBar.laser")}),Be(Ae.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:cl,"data-testid":"toolbar-lasso",selected:s,children:g("toolBar.lasso")}),Be("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&Be(m.Out,{}),Be(Ae.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:Fc,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&Be(Ar,{children:ft(Ae.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:Hc,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),Be(Ae.Item.Badge,{children:"AI"})]})})]})]})]})},Ny=({renderAction:e,zoom:o})=>Be(wt.Col,{gap:1,className:Rt.ZOOM_ACTIONS,children:ft(wt.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),Oy=({renderAction:e,className:o})=>ft("div",{className:`undo-redo-buttons ${o}`,children:[Be("div",{className:"undo-button-container",children:Be(io,{label:g("buttons.undo"),children:e("undo")})}),Be("div",{className:"redo-button-container",children:ft(io,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),zy=({actionManager:e,showExitZenModeBtn:o})=>Be("button",{type:"button",className:Uh("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(ca),children:g("buttons.exitZenMode")}),By=({renderAction:e,className:o})=>Be("div",{className:`finalize-button ${o}`,children:e("finalize",{size:"small"})});import{useRef as gI}from"react";var Vh=e=>{let o=gI({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as bI,jsxs as fI}from"react/jsx-runtime";var li=Ie(null),Fy=()=>{let[e,o]=he(li),t=lt();return e&&e==="clearCanvas"?bI(Bd,{onConfirm:()=>{t.executeAction(kr),o(null)},onCancel:()=>o(null),title:g("clearCanvasDialog.title"),children:fI("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var Yh={};hf(Yh,{toggleTheme:()=>xI});var xI={...Qn,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Qn,"commandPalette")}};import{jsx as Ht,jsxs as lr}from"react/jsx-runtime";var vI=Ie(null),Ke={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},wI=e=>{switch(e){case Ke.app:return 1;case Ke.export:return 2;case Ke.editor:return 3;case Ke.tools:return 4;case Ke.elements:return 5;case Ke.links:return 6;default:return 10}},qd=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return lr("div",{className:Uy("shortcut",o),children:[r.map((n,i)=>Ht("div",{className:"shortcut-wrapper",children:Ht("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),Ht("div",{className:"shortcut-desc",children:t})]})},Gy=e=>!e.altKey&&e[y.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===y.P||e.key===y.SLASH),JX=Object.assign(e=>{let o=Le(),t=ye();return jd(()=>{let r=n=>{Gy(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&de("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:Ht(TI,{...e})},{defaultItems:Yh});function TI({customCommandPaletteItems:e}){let o=Je(),t=Le(),r=ye(),n=rr(),i=lt(),[a,l]=he(vI),[s,c]=$d(null),m=yI(null),d=rn({uiAppState:t,customCommandPaletteItems:e,appProps:n});jd(()=>{let{uiAppState:k,customCommandPaletteItems:D,appProps:M}=d,O=V=>{let te="";return V.label&&(typeof V.label=="function"?te=g(V.label(o.scene.getNonDeletedElements(),k,o)):te=g(V.label)),te},P=V=>typeof V.icon=="function"?V.icon(k,o.scene.getNonDeletedElements()):V.icon,F=[],K=(V,te,H)=>{let B={label:O(V),icon:P(V),category:te,shortcut:Qe(V.name),keywords:V.keywords,predicate:V.predicate,viewMode:V.viewMode,perform:()=>{i.executeAction(V,"commandPalette")}};return H?H(B,V):B};if(k&&o.scene&&i){let V=[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,Dl,_d,B2].map(Z=>K(Z,Ke.elements,(pe,xe)=>({...pe,predicate:xe.predicate?xe.predicate:(ve,Lt,Zo,mi)=>j(ve,Lt).length>0}))),te=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(Z=>K(Z,Ke.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(Z=>K(Z,Ke.editor)),B=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(Z=>K(Z,Ke.export));F=[...V,...H,{label:O(kr),icon:P(kr),shortcut:Qe(kr.name),category:Ke.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{it.set(li,"clearCanvas")}},{label:g("buttons.exportImage"),category:Ke.export,icon:Rc,shortcut:Qe("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...B];let ee=[{label:g("toolBar.library"),category:Ke.app,icon:Hi,viewMode:!1,perform:()=>{k.openSidebar?r({openSidebar:null}):r({openSidebar:{name:_t.name,tab:_t.defaultTab}})}},{label:g("search.title"),category:Ke.app,icon:ro,viewMode:!0,perform:()=>{i.executeAction(Gl)}},{label:g("labels.shapeSwitch"),category:Ke.elements,icon:fl,perform:()=>{i.executeAction(z2)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:Ke.elements,icon:Pc,viewMode:!1,predicate:(Z,pe)=>{let xe=j(Z,pe);return xe.length>0&&Gh(pe,xe)},perform:()=>{r(Z=>({openMenu:Z.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:Pc,category:Ke.elements,viewMode:!1,predicate:(Z,pe)=>{let xe=j(Z,pe);return xe.length>0&&Wh(pe,xe)},perform:()=>{r(Z=>({openMenu:Z.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:Pc,category:Ke.editor,viewMode:!1,perform:()=>{r(Z=>({openMenu:Z.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Ul.reduce((Z,pe)=>{let{value:xe,icon:ve,key:Lt,numericKey:Zo}=pe;if(M.UIOptions.tools?.[xe]===!1)return Z;let pi=Lt&&Ur(typeof Lt=="string"?Lt:Lt[0])||Zo,cs={label:g(`toolBar.${xe}`),category:Ke.tools,shortcut:pi,icon:ve,keywords:["toolbar"],viewMode:!1,perform:({event:ds})=>{xe==="image"?o.setActiveTool({type:xe,insertOnCanvasDirectly:ds.type==="keydown"}):o.setActiveTool({type:xe})}};return Z.push(cs),Z},[]),...te,{label:g("toolBar.lock"),category:Ke.tools,icon:k.activeTool.locked?Ui:Zn,shortcut:y.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:Ke.tools,icon:Hx,viewMode:!1,predicate:M.aiEnabled,perform:()=>{r(Z=>({...Z,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:Ke.tools,icon:Fc,viewMode:!1,predicate:M.aiEnabled,perform:()=>{r(Z=>({...Z,openDialog:{name:"ttd",tab:"mermaid"}}))}}],oe=[...F,...ee,...D||[]].map(Z=>({...Z,icon:Z.icon||fl,order:Z.order??wI(Z.category),haystack:`${Ih(Z.label.toLocaleLowerCase())} ${Z.keywords?.join(" ")||""}`}));c(oe),l(oe.find(Z=>Z.label===a?.label)??null)}},[d,o,i,c,a?.label,l,r]);let[p,u]=$d(""),[f,b]=$d(null),[x,E]=$d({}),w=k=>{r({openDialog:null},k),u("")},v=(k,D)=>{t.openDialog?.name==="commandPalette"&&(D.stopPropagation(),D.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{k.perform({actionManager:i,event:D}),l(k),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},T=Vh(k=>k.viewMode===!1&&t.viewModeEnabled?!1:typeof k.predicate=="function"?k.predicate(o.scene.getNonDeletedElements(),t,n,o):k.predicate===void 0||k.predicate),S=Vh(k=>{let D=$o(k.target)||Gy(k)||k.key===y.ESCAPE;if(D&&k.key!==y.ARROW_UP&&k.key!==y.ARROW_DOWN&&k.key!==y.ENTER)return;let M=Object.values(x).flat(),O=a&&!p&&T(a);if(k.key===y.ARROW_UP){k.preventDefault();let P=M.findIndex(V=>V.label===f?.label);if(O){if(P===0){b(a);return}if(f===a){let V=M[M.length-1];V&&b(V);return}}let F;P===-1?F=M.length-1:F=P===0?M.length-1:(P-1)%M.length;let K=M[F];K&&b(K);return}if(k.key===y.ARROW_DOWN){k.preventDefault();let P=M.findIndex(V=>V.label===f?.label);if(O){if(!f||P===M.length-1){b(a);return}if(f===a){let V=M[0];V&&b(V);return}}let F=(P+1)%M.length,K=M[F];K&&b(K);return}if(k.key===y.ENTER&&f&&setTimeout(()=>{v(f,k)}),!D){if(k.stopPropagation(),/^[a-zA-Z0-9]$/.test(k.key)){m?.current?.focus();return}k.preventDefault()}});return jd(()=>(window.addEventListener("keydown",S,{capture:!0}),()=>window.removeEventListener("keydown",S,{capture:!0})),[S]),jd(()=>{if(!s)return;let k=P=>{let F={};for(let K of P)F[K.category]?F[K.category].push(K):F[K.category]=[K];return F},D=s.filter(T).sort((P,F)=>P.order-F.order),M=!p&&a&&T(a);if(!p){E(k(M?D.filter(P=>P.label!==a?.label):D)),b(M?a:D[0]||null);return}let O=Ih(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));D=EI.filter(O,D,{extract:P=>P.haystack}).sort((P,F)=>F.score-P.score).map(P=>P.original),E(k(D)),b(D[0]??null)},[p,s,T,a]),lr(et,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Ht(va,{value:p,placeholder:g("commandPalette.search.placeholder"),onChange:k=>{u(k)},selectOnRender:!0,ref:m}),!o.device.viewport.isMobile&&lr("div",{className:"shortcuts-wrapper",children:[Ht(qd,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),Ht(qd,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),Ht(qd,{shortcut:R("Esc"),children:g("commandPalette.shortcuts.close")})]}),lr("div",{className:"commands",children:[a&&!p&&lr("div",{className:"command-category",children:[lr("div",{className:"command-category-title",children:[g("commandPalette.recents"),Ht("div",{className:"icon",style:{marginLeft:"6px"},children:Ux})]}),Ht(Hy,{command:a,isSelected:a.label===f?.label,onClick:k=>v(a,k),disabled:!T(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((k,D)=>lr("div",{className:"command-category",children:[Ht("div",{className:"command-category-title",children:k}),x[k].map(M=>Ht(Hy,{command:M,isSelected:M.label===f?.label,onClick:O=>v(M,O),onMouseMove:()=>b(M),showShortcut:!o.device.viewport.isMobile,appState:t},M.label))]},k)):s?lr("div",{className:"no-match",children:[Ht("div",{className:"icon",children:ro})," ",g("commandPalette.search.noMatch")]}):null]})]})}var Hy=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return lr("div",{className:Uy("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?g("commandPalette.itemNotAvailable"):"",children:[lr("div",{className:"name",children:[e.icon&&Ht(cn,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&Ht(qd,{shortcut:e.shortcut})]})};import{jsx as CI}from"react/jsx-runtime";var Kh=z({name:"toggleLinearEditor",category:Ke.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&&fe(n[0])&&!le(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 X(n,J(e));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=g(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return CI($,{type:"button",icon:tE,title:n,"aria-label":n,onClick:()=>o(null)})}});var Gl=z({name:"searchMenu",icon:ro,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===_t.name&&o.openSidebar.tab===gr){let n=r.excalidrawContainerValue.container?.querySelector(`.${Rt.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...o,openSidebar:{name:_t.name,tab:gr},openDialog:null},captureUpdate:A.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[y.CTRL_OR_CMD]&&e.key===y.F});import{jsx as II}from"react/jsx-runtime";var Zh=z({name:"cropEditor",label:"helpDialog.cropStart",icon:gu,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&&Me(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=g("helpDialog.cropStart");return II($,{type:"button",icon:gu,title:r,"aria-label":r,onClick:()=>o(null)})}});var Wy=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&ae(t[0])},Vy=z({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=No(ue(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)=>Wy(o,r)}),Yy=z({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:rb(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:A.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>Wy(o,r)}),Ej=z({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}),yj=z({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:jn,viewMode:!1,perform:(e,o,t,r)=>{let n=De(o,{type:"frame"});return lo(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:De(o,{type:"frame"})},captureUpdate:A.EVENTUALLY}},keyTest:e=>!e[y.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===y.F}),Ky=z({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=r.scene.getNonDeletedElementsMap(),[a,l,s,c]=Te(n,i),m=16,d=Ai({x:a-m,y:l-m,width:s-a+m*2,height:c-l+m*2});if(o.editingGroupId){let u=$e(n,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);Oo(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:Si([...r.scene.getElementsIncludingDeleted(),d],n,d,o),appState:{selectedElementIds:{[d.id]:!0}},captureUpdate:A.IMMEDIATELY}}});var wa=class extends Sp{},si=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},Wl=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new go);I(this,"undoStack",[]);I(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof wa)return;let t=wa.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new si(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r,o))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r,o))}perform(o,t,r,n){try{let i=r();if(i===null)return;let a=A.IMMEDIATELY,l=this.store.snapshot,s=o,c=t,m=!1;for(;i;){try{[s,c,m]=Sp.applyTo(i,s,c,l);let d=l.maybeClone(a,s,c);this.store.scheduleMicroAction({action:a,change:gb.create(l,d),delta:i}),l=d}finally{n(i)}if(m)break;i=r()}return[s,c]}finally{this.onHistoryChangedEmitter.trigger(new si(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=wa.inverse(t),i=wa.applyLatestChanges(n,r,"inserted");return o.push(i)}};import{useEffect as kI,useState as SI}from"react";var Xh=(e,o)=>{let[t,r]=SI(o);return kI(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as jy}from"react/jsx-runtime";var Zy=(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=ic(Array.from(n.values()));return{appState:i,elements:a,captureUpdate:A.NEVER}}return{captureUpdate:A.EVENTUALLY}},Xy=e=>({name:"undo",label:"buttons.undo",icon:Jp,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>Zy(n,t,()=>e.undo(J(o),t)),keyTest:o=>o[y.CTRL_OR_CMD]&&Ss(o,y.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:r}=Xh(e.onHistoryChangedEmitter,new si(e.isUndoStackEmpty,e.isRedoStackEmpty));return jy($,{type:"button",icon:Jp,"aria-label":g("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-undo"})}}),$y=e=>({name:"redo",label:"buttons.redo",icon:Qp,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>Zy(n,t,()=>e.redo(J(o),t)),keyTest:o=>o[y.CTRL_OR_CMD]&&o.shiftKey&&Ss(o,y.Z)||fs&&o.ctrlKey&&!o.shiftKey&&Ss(o,y.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:r}=Xh(e.onHistoryChangedEmitter,new si(e.isUndoStackEmpty,e.isRedoStackEmpty));return jy($,{type:"button",icon:Qp,"aria-label":g("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-redo"})}});var qy=z({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=j(e,o);return n.length===1&&Y(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&&Y(i)){let a=vt(i.originalText,qe(i),i.lineHeight);return ne(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:A.IMMEDIATELY}}});var $h=z({name:"viewMode",label:"labels.viewMode",icon:Zi,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[y.CTRL_OR_CMD]&&e.altKey&&e.code===se.R});import{jsx as MI}from"react/jsx-runtime";var jh=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&de(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Jd=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=>{jh(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return MI(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(Wr(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 jh(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();jh(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var Qd=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 qh=e=>{let o=Array.from(e.values());return{x:Jy(o,t=>t.x)/o.length,y:Jy(o,t=>t.y)/o.length}},Jh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),Jy=(e,o)=>e.reduce((t,r)=>t+o(r),0);var LI=8,Qy=99999,em=e=>LI/e,Ut=class Ut{};I(Ut,"referenceSnapPoints",null),I(Ut,"visibleGaps",null),I(Ut,"setReferenceSnapPoints",o=>{Ut.referenceSnapPoints=o}),I(Ut,"getReferenceSnapPoints",()=>Ut.referenceSnapPoints),I(Ut,"setVisibleGaps",o=>{Ut.visibleGaps=o}),I(Ut,"getVisibleGaps",()=>Ut.visibleGaps),I(Ut,"destroy",()=>{Ut.referenceSnapPoints=null,Ut.visibleGaps=null});var Co=Ut,hn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,_r=({event:e,app:o,selectedElements:t})=>e?o.state.objectsSnapModeEnabled&&!e[y.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[y.CTRL_OR_CMD]&&!e.altKey&&!hn(o):t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled,AI=(e,o,t=.01)=>Math.abs(e-o)<=t,Vl=(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]=ht(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,f=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=Oe(L(l,s+f),L(d,p),a.angle),x=Oe(L(l+u,s),L(d,p),a.angle),E=Oe(L(c,s+f),L(d,p),a.angle),w=Oe(L(l+u,m),L(d,p),a.angle),v=L(d,p);i=t?[b,x,E,w]:[b,x,E,w,v]}else{let b=Oe(L(l,s),L(d,p),a.angle),x=Oe(L(c,s),L(d,p),a.angle),E=Oe(L(l,m),L(d,p),a.angle),w=Oe(L(c,m),L(d,p),a.angle),v=L(d,p);i=t?[b,x,E,w]:[b,x,E,w,v]}}else if(e.length>1){let[a,l,s,c]=nc(e,n??{x:0,y:0}),m=s-a,d=c-l,p=L(a,l),u=L(s,l),f=L(a,c),b=L(s,c),x=L(a+m/2,l+d/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>L(Ze(a[0]),Ze(a[1])))},ov=(e,o,t,r)=>{let n=o.filter(i=>ae(i)).map(i=>i.id);return gp(e,o,t,r).filter(i=>!(i.frameId&&n.includes(i.frameId)))},rv=(e,o,t,r)=>{let n=ov(e,o,t,r),i=hp(n,r).filter(d=>!(d.length===1&&tt(d[0]))).map(d=>Te(d).map(p=>Ze(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>Qy)break e;let f=a[u],[,b,x,E]=p,[w,v,,T]=f;x<w&&Va(to(b,E),to(v,T))&&l.push({startBounds:p,endBounds:f,startSide:[L(x,b),L(x,E)],endSide:[L(w,v),L(w,T)],length:w-x,overlap:Ya(to(b,E),to(v,T))})}}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>Qy)break e;let f=c[u],[b,,x,E]=p,[w,v,T]=f;E<v&&Va(to(b,x),to(w,T))&&m.push({startBounds:p,endBounds:f,startSide:[L(b,E),L(x,E)],endSide:[L(w,v),L(T,v)],length:v-E,overlap:Ya(to(b,x),to(w,T))})}}return{horizontalGaps:l,verticalGaps:m}},ev=(e,o,t,r,n,i,a)=>{if(!_r({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=Co.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[m,d,p,u]=nc(e,o).map(x=>Ze(x)),f=(m+p)/2,b=(d+u)/2;for(let x of s){if(!Va(to(d,u),x.overlap))continue;let E=x.startSide[0][0]+x.length/2,w=Ze(E-f);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[,,T]=x.endBounds,S=m-T,k=Ze(x.length-S);if(Math.abs(k)<=a.x){Math.abs(k)<a.x&&(n.length=0),a.x=Math.abs(k);let P={type:"gap",direction:"side_right",gap:x,offset:k};n.push(P);continue}let[D,,,]=x.startBounds,M=D-p,O=Ze(M-x.length);if(Math.abs(O)<=a.x){Math.abs(O)<a.x&&(n.length=0),a.x=Math.abs(O);let P={type:"gap",direction:"side_left",gap:x,offset:O};n.push(P);continue}}for(let x of c){if(!Va(to(m,p),x.overlap))continue;let E=x.startSide[0][1]+x.length/2,w=Ze(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[,T,,]=x.startBounds,S=T-u,k=Ze(S-x.length);if(Math.abs(k)<=a.y){Math.abs(k)<a.y&&(i.length=0),a.y=Math.abs(k);let P={type:"gap",direction:"side_top",gap:x,offset:k};i.push(P);continue}let[,,,D]=x.endBounds,M=Ze(d-D),O=x.length-M;if(Math.abs(O)<=a.y){Math.abs(O)<a.y&&(i.length=0),a.y=Math.abs(O);let P={type:"gap",direction:"side_bottom",gap:x,offset:O};i.push(P);continue}}}},nv=(e,o,t,r)=>{let n=ov(e,o,t,r);return hp(n,r).filter(i=>!(i.length===1&&tt(i[0]))).flatMap(i=>Vl(i,r))},Ta=(e,o,t,r,n,i,a)=>{if(!_r({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Co.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))}},iv=(e,o,t,r,n)=>{let i=t.state,a=j(e,i);if(!_r({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Ze(o.x),o.y=Ze(o.y);let l=[],s=[],c=em(i.zoom.value),m={x:c,y:c},d=Vl(a,n,{dragOffset:o});Ta(a,d,t,r,l,s,m),ev(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:Ze(o.x+p.x),y:Ze(o.y+p.y)};Ta(a,Vl(a,n,{dragOffset:u}),t,r,l,s,m),ev(a,u,t,r,l,s,m);let f=Qh(l,s),b=DI(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Ze=e=>Math.round(e*10**6)/10**6,tv=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())},Qh=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=Ze(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>L(Ze(a[0]),Ze(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=Ze(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>L(Ze(a[0]),Ze(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:tv(i.map(a=>L(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:tv(i.map(a=>L(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},_I=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[Ze(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},DI=(e,o,t)=>{let[r,n,i,a]=nc(e,o),l=[];for(let s of t){let[c,m,d,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,E=Ya(to(n,a),s.gap.overlap),w=Ya(to(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(E){let v=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[L(s.gap.startSide[0][0],v),L(r,v)]},{type:"gap",direction:"horizontal",points:[L(i,v),L(s.gap.endSide[0][0],v)]})}break}case"center_vertical":{if(w){let v=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[L(v,s.gap.startSide[0][1]),L(v,n)]},{type:"gap",direction:"vertical",points:[L(v,a),L(v,s.gap.endSide[0][1])]})}break}case"side_right":{if(E){let v=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[L(d,v),L(u,v)]},{type:"gap",direction:"horizontal",points:[L(b,v),L(r,v)]})}break}case"side_left":{if(E){let v=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[L(i,v),L(c,v)]},{type:"gap",direction:"horizontal",points:[L(d,v),L(u,v)]})}break}case"side_top":{if(w){let v=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[L(v,a),L(v,m)]},{type:"gap",direction:"vertical",points:[L(v,p),L(v,f)]})}break}case"side_bottom":{if(w){let v=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[L(v,p),L(v,f)]},{type:"gap",direction:"vertical",points:[L(v,x),L(v,n)]})}break}}}return _I(l.map(s=>({...s,points:s.points.map(c=>L(Ze(c[0]),Ze(c[1])))})))},eg=(e,o,t,r,n,i)=>{if(!_r({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!AI(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=Te(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(L(s,l),L(s,c));break}case"w":{m.push(L(a,l),L(a,c));break}case"n":{m.push(L(a,l),L(s,l));break}case"s":{m.push(L(a,c),L(s,c));break}case"ne":{m.push(L(s,l));break}case"nw":{m.push(L(a,l));break}case"se":{m.push(L(s,c));break}case"sw":{m.push(L(a,c));break}}let d=em(t.state.zoom.value),p={x:d,y:d},u=[],f=[];Ta(o,m,t,r,u,f,p);let b={x:u[0]?.offset??0,y:f[0]?.offset??0};p.x=0,p.y=0,u.length=0,f.length=0;let[x,E,w,v]=Te(e).map(k=>Ze(k)),T=[L(x,E),L(x,v),L(w,E),L(w,v)];Ta(e,T,t,r,u,f,p);let S=Qh(u,f);return{snapOffset:b,snapLines:S}},av=(e,o,t,r,n,i)=>{if(!_r({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[L(r.x+n.x,r.y+n.y)],l=em(o.state.zoom.value),s={x:l,y:l},c=[],m=[];Ta([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=Vl([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ta([e],p,o,t,c,m,s);let u=Qh(c,m);return{snapOffset:d,snapLines:u}},lv=(e,o,t,r,n)=>{if(!_r({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=gp(e,[],o.state,n),a=em(o.state.zoom.value),l={x:a,y:a},s=[],c=[];for(let m of i){let d=Vl([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,L(p[0],t.y)],direction:"vertical"}),l.x=u);let f=p[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,L(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},sv=e=>e===je.rectangle||e===je.ellipse||e===je.diamond||e===je.frame||e===je.magicframe||e===je.image||e===je.text;var tm={width:100,height:0},gn=100,PI=(e,o,t)=>{let r=Ot({x:0,y:0,textAlign:Ua.CENTER,verticalAlign:Wt.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),Ye(r,e,t),[e,r]},cv=(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??gn,d=o?.height??gn,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,f=o.y||e.y-d/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=Ot({x:u,y:f,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=Kt({x:u,y:f,width:m,height:d,...p,...o,type:b});break}default:Ei(e,`Unhandled element start type "${o.type}"`,!0)}Zr(e,i,"start",n)}}if(t){let m=t?.height??gn,d=t?.width??gn,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,f=t.y||e.y-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=Ot({x:u,y:f,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=Kt({x:u,y:f,width:d,height:m,...p,...t,type:b});break}default:Ei(e,`Unhandled element end type "${b}"`,!0)}Zr(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=Yt(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,X.getNormalizedPoints({...e,points:c})),{linearElement:e,startBoundElement:i,endBoundElement:a}},tg=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>wr(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>Ns(J(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Ca=(e,o)=>{if(!e)return[];let t=Yt(e),r=new tg,n=new Map,i=new Map;for(let s of t){let c,m=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:Do()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||gn,u=s?.label?.text&&s.height===void 0?0:s?.height||gn;c=Kt({...s,width:p,height:u});break}case"line":{let p=s.width||tm.width,u=s.height||tm.height;c=bo({width:p,height:u,points:[L(0,0),L(p,u)],...s});break}case"arrow":{let p=s.width||tm.width,u=s.height||tm.height;c=Jr({width:p,height:u,endArrowhead:"arrow",points:[L(0,0),L(p,u)],...s,type:"arrow"}),Object.assign(c,Qf(c.points));break}case"text":{let p=s?.fontFamily||zr,u=s?.fontSize||hr,f=s?.lineHeight||Ao(p),b=s.text??"",x=Fn(b),E=vt(x,qe({fontFamily:p,fontSize:u}),f);c=Ot({width:E.width,height:E.height,fontFamily:p,fontSize:u,...s});break}case"image":{c=cc({width:s?.width||gn,height:s?.height||gn,...s});break}case"frame":{c=Ai({x:0,y:0,...s});break}case"magicframe":{c=rl({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{c=s;break}default:c=s,Ei(s,`Unhandled element type "${s.type}"`,!0)}r.getElement(c.id)?console.error(`Duplicate id found for ${c.id}`):(r.add(c),n.set(c.id,s),m&&i.set(m,c.id))}let a=r.getElementsMap(),l=new ol(a);for(let[s,c]of n){let m=r.getElement(s);switch(c.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(c.label?.text){let[d,p]=PI(m,c?.label,l);if(r.add(d),r.add(p),Re(d)){let u=c.type==="arrow"?c?.start:void 0,f=c.type==="arrow"?c?.end:void 0;if(u&&u.id){let w=i.get(u.id);w&&Object.assign(u,{id:w})}if(f&&f.id){let w=i.get(f.id);w&&Object.assign(f,{id:w})}let{linearElement:b,startBoundElement:x,endBoundElement:E}=cv(d,u,f,r,l);d=b,r.add(b),r.add(x),r.add(E)}}else switch(c.type){case"arrow":{let{start:d,end:p}=c;if(d&&d.id){let x=i.get(d.id);Object.assign(d,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=cv(m,d,p,r,l);r.add(u),r.add(f),r.add(b);break}}break}}}for(let[s,c]of n){if(c.type!=="frame"&&c.type!=="magicframe")continue;let m=r.getElement(s);if(!m)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let d=[];c.children.forEach(S=>{let k=i.get(S);if(!k)throw new Error(`Element with ${S} wasn't mapped correctly`);let D=r.getElement(k);if(!D)throw new Error(`Frame element with id ${k} doesn't exist`);Object.assign(D,{frameId:m.id}),D?.boundElements?.forEach(M=>{let O=r.getElement(M.id);if(!O)throw new Error(`Bound element with id ${M.id} doesn't exist`);Object.assign(O,{frameId:m.id}),d.push(O)}),d.push(D)});let[p,u,f,b]=Te(d),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let E=m?.x||p,w=m?.y||u,v=m?.width||f-p,T=m?.height||b-u;Object.assign(m,{x:E,y:w,width:v,height:T}),pt()&&c.children.length&&(m?.x||m?.y||m?.width||m?.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 om from"open-color";var RI="#ff6b6b",NI="#ff0000",dv=1,mv=2,pv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===re.LIGHT||o.zenModeEnabled?RI:NI,r=(o.zenModeEnabled?dv*1.5:dv)/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,zI(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,BI(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,OI(n,e,o));e.restore()},OI=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];Io(r,n,o)}for(let r of e.points)uv(r,t,o)},zI=(e,o,t)=>{uv(e.points[0],t,o),t.zenModeEnabled||Io(e.points[0],e.points[1],o)},uv=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?mv*1.5:mv)/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()},Io=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},BI=(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||Io(L(e[0],e[1]-i),L(e[0],e[1]+i),n),Io(L(s[0]-l,s[1]-a),L(s[0]-l,s[1]+a),n),Io(L(s[0]+l,s[1]-a),L(s[0]+l,s[1]+a),n),r.zenModeEnabled||(Io(L(o[0],o[1]-i),L(o[0],o[1]+i),n),Io(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||Io(L(e[0]-i,e[1]),L(e[0]+i,e[1]),n),Io(L(s[0]-a,s[1]-l),L(s[0]+a,s[1]-l),n),Io(L(s[0]-a,s[1]+l),L(s[0]+a,s[1]+l),n),r.zenModeEnabled||(Io(L(o[0]-i,o[1]),L(o[0]+i,o[1]),n),Io(e,o,n))}};var Vo=4,Jt=6,hv="rgba(0,0,0,0.3)",gv=(e,o,t,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,i,a,l]=Te(e),s=o/r.zoom.value,c=t/r.zoom.value,m={top:parseInt(Ka("sat"))||0,bottom:parseInt(Ka("sab"))||0,left:parseInt(Ka("sal"))||0,right:parseInt(Ka("sar"))||0},d=Cr().rtl,p=-r.scrollX+m.left,u=-r.scrollY+m.top,f=p+s-m.right,b=u+c-m.bottom,x=Math.min(n,p),E=Math.min(i,u),w=Math.max(a,f),v=Math.max(l,b),T=a-n,S=l-i,k=w-x,D=v-E,M=Math.max(Vo*2,m.left+m.right)+Jt*2,O=o*(s/k)-M,P=Math.max(Vo*2,m.top+m.bottom)+Jt*2,F=t*(c/D)-P,K=k>T?k*r.zoom.value/(O+M):o/(O+M),V=D>S?D*r.zoom.value/(F+P):t/(F+P);return{horizontal:p===x&&f===w?null:{x:Math.max(m.left,Vo)+Jt+(p-x)/k*o,y:t-Jt-Math.max(Vo,m.bottom),width:O,height:Jt,deltaMultiplier:K},vertical:u===E&&b===v?null:{x:d?Math.max(m.left,Vo):o-Jt-Math.max(m.right,Vo),y:Math.max(m.top,Vo)+Jt+(u-E)/D*t,width:Jt,height:F,deltaMultiplier:V}}},og=(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 FI=(e,o)=>{dp(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;dp(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),bv(t,e,o),e.restore()},HI=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=X.getElement(r,t);if(!i)return;let a=X.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),bv(a,e,o),e.restore()},bv=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",il(o,e[0],e[1],X.POINT_HANDLE_SIZE/t.zoom.value,!1)},rg=(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)"),il(e,t[0],t[1],r/o.zoom.value,!i)},UI=(e,o,t,r)=>{let[n,i,a,l]=ht(o,t),s=a-n,c=l-i;e.strokeStyle="rgba(0,0,0,.05)",e.fillStyle="rgba(0,0,0,.05)";let m=oc(o,o.width,o.height,r);switch(o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":jb(e,o,m);break;case"diamond":Jb(e,m,o);break;case"ellipse":e.lineWidth=oc(o,o.width,o.height,r)-Js,qb(e,s+m+Js,c+m+Js,n+s/2,i+c/2,o.angle);break}},GI=(e,o,t,r)=>{let[n,i,a]=o,l=oc(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]=X.getPointAtIndexGlobalCoordinates(n,c,t);il(e,m,d,l)})},xv=(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,f=l-i,x=(t.padding??Es*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 v=s.length;for(let T=0;T<v;++T)e.strokeStyle=s[T],d&&e.setLineDash([E,w+(E+w)*(v-1)]),e.lineDashOffset=(E+w)*T,al(e,n-x,i-x,u+x*2,f+x*2,c,m,r);e.restore()},WI=(e,o,t,r)=>{let n=Array.isArray(t)?GI:UI;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},VI=(e,o,t,r)=>{let[n,i,a,l]=ht(t,r),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=At.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),al(e,n,i,s,c,n+s/2,i+c/2,t.angle,!1,At.radius/o.zoom.value),e.restore()},YI=(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]=Te(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=$e(t,l);return i(s)};Object.entries(W1(n,o)).filter(([l,s])=>s).map(([l,s])=>l).map(l=>a(l)).concat(r.map(l=>i([l]))).forEach(l=>xv(e,o,l))},ng=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=X.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=X,a=o.editingLinearElement?i:i/2;if(n.forEach((l,s)=>{if(le(t)&&s!==0&&s!==n.length-1)return;let c=!!o.editingLinearElement?.selectedPointsIndices?.includes(s);rg(e,o,l,a,c)}),le(t)){let l=t.fixedSegments?.map(s=>s.index)||[];n.slice(0,-1).forEach((s,c)=>{X.isSegmentTooShort(t,n[c+1],n[c],c,o.zoom)||rg(e,o,L((s[0]+n[c+1][0])/2,(s[1]+n[c+1][1])/2),i/2,!1,!l.includes(c+1))})}else X.getEditorMidPoints(t,r,o).filter((s,c,m)=>s!==null&&!(le(t)&&(c===0||c===m.length-1))).forEach(s=>{(o.editingLinearElement||n.length===2)&&rg(e,o,s,i/2,!1,!0)});e.restore()},fv=(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"?il(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()):al(e,l,s,c,m,l+c/2,s+m/2,n,!0),e.restore()}})},KI=(e,o,t,r,n)=>{let[i,a,,,l,s]=ht(r,n),c=3,m=20,d=c/t.zoom.value,p=d/2,u=l-i+d,f=s-a+d,b=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=d,[[[-u,-f],[0,p],[b,p],[p,0],[p,x]],[[u-p,-f],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,f],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,f],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(w=>{let[[v,T],[S,k],[D,M],[O,P],[F,K]]=w;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(v+S,T+k),e.lineTo(v+D,T+M),e.stroke(),e.beginPath(),e.moveTo(v+O,T+P),e.lineTo(v+F,T+K),e.stroke(),e.restore()}),e.restore()},ZI=(e,o,t,r)=>{o.save();let n=Es*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()},Ev=({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]=fc(e,i),d=bc({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&&ng(d,a,p,o),a.selectionElement&&!a.isCropping)try{ab(a.selectionElement,d,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Y(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&ZI(b,d,a,l.selectionColor)}a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{WI(d,a,b,o)}),a.frameToHighlight&&VI(d,a,a.frameToHighlight,o),a.elementsToHighlight&&YI(d,a,a.elementsToHighlight);let u=r.some(b=>ae(b));if(r.length===1&&a.editingLinearElement?.elementId===r[0].id&&ng(d,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(E=>E.id===b.elementId);b.segmentMidPointHoveredCoords?FI(d,a):(le(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&HI(d,a,o)}if(!a.multiElement&&!a.editingLinearElement){let b=mc(r,a),x=r.length===1&&fe(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&ng(d,a,r[0],o);let E=l.selectionColor||om.black;if(b){let w=J(r),v=[];for(let S of o.values()){let k=[],D=l.remoteSelectedElementIds.get(S.id);if(x&&le(S)&&(S.startBinding||S.endBinding)||(w.has(S.id)&&!Vs(a,S)&&k.push(E),D&&k.push(...D.map(M=>ii(M,a.collaborators.get(M))))),k.length){let[M,O,P,F,K,V]=ht(S,o,!0);v.push({angle:S.angle,x1:M,y1:O,x2:P,y2:F,selectionColors:k,dashed:!!D,cx:K,cy:V,activeEmbeddable:a.activeEmbeddable?.element===S&&a.activeEmbeddable.state==="active",padding:S.id===a.croppingElementId||Me(S)?0:void 0})}}let T=S=>{let k=$e(o,S),[D,M,O,P]=Te(k);v.push({angle:0,x1:D,x2:O,y1:M,y2:P,selectionColors:[om.black],dashed:!0,cx:D+(O-D)/2,cy:M+(P-M)/2,activeEmbeddable:!1})};for(let S of Ro(a))T(S);a.editingGroupId&&T(a.editingGroupId),v.forEach(S=>xv(d,a,S))}if(d.save(),d.translate(a.scrollX,a.scrollY),r.length===1){d.fillStyle=om.white;let w=zb(r[0],a.zoom,o,"mouse",dc(s));if(!a.viewModeEnabled&&b&&!Y(a.editingTextElement)&&!a.croppingElementId&&fv(d,l,a,w,r[0].angle),a.croppingElementId&&!a.isCropping){let v=o.get(a.croppingElementId);v&&Me(v)&&KI(d,l,a,v,o)}}else if(r.length>1&&!a.isRotating){let w=Es*2/a.zoom.value;d.fillStyle=om.white;let[v,T,S,k]=Te(r,o),D=d.getLineDash();d.setLineDash([2/a.zoom.value]);let M=d.lineWidth;d.lineWidth=1/a.zoom.value,d.strokeStyle=E,al(d,v-w,T-w,S-v+w*2,k-T+w*2,(v+S)/2,(T+k)/2,0),d.lineWidth=M,d.setLineDash(D);let O=Ob([v,T,S,k,(v+S)/2,(T+k)/2],0,a.zoom,"mouse",u?{...dc(s),rotation:!0}:dc(s));r.some(P=>!P.locked)&&fv(d,l,a,O,0)}d.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:E})=>{let w=o.get(b);if(w){let[v,T,,,S,k]=ht(w,o,!0);d.save(),a.theme===re.LIGHT?x?d.fillStyle="rgba(255, 124, 0, 0.4)":d.fillStyle="rgba(255, 226, 0, 0.4)":x?d.fillStyle="rgba(229, 82, 0, 0.4)":d.fillStyle="rgba(99, 52, 0, 0.4)";let D=ae(w)?a.zoom.value:1;d.translate(a.scrollX,a.scrollY),d.translate(S,k),d.rotate(w.angle),E.forEach(M=>{(M.showOnCanvas||x)&&d.fillRect(v+M.offsetX/D-S,T+M.offsetY/D-k,M.width/D,M.height/D)}),d.restore()}}),pv(d,a),d.restore(),f2({context:d,renderConfig:l,appState:a,normalizedWidth:c,normalizedHeight:m});let f;return l.renderScrollbars&&(f=gv(o,c,m,a),d.save(),d.fillStyle=hv,d.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&vd(d,b.x,b.y,b.width,b.height,Jt/2)}),d.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},ig=bi(e=>{let o=Ev(e);e.callback?.(o)},{trailing:!0}),yv=(e,o)=>{if(o){ig(e);return}let t=Ev(e);return e.callback(t),t};var Yl=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())tl(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=Ns(new Map);for(let s of r)Me(s)&&a===s.id||i!==s.id&&(!n||n.type!=="text"||s.id!==n.id)&&l.set(s.id,s);return l};return p1(({zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c,editingTextElement:m,newElementId:d,pendingImageElementId:p,sceneNonce:u})=>{let f=this.scene.getNonDeletedElements(),b=t({elements:f,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(){ig.cancel(),Qb.cancel(),this.getRenderableElements.clear()}};import{jsx as jI}from"react/jsx-runtime";var XI=5,$I=(e,o,t)=>{let[r,n]=ht(e,t),{x:i,y:a}=It({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},ag=({children:e,element:o,elementsMap:t})=>{let r=or();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=$I(o,r,t);return jI("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:XI},children:e})};import{LaserPointer as qI}from"@excalidraw/laser-pointer";var Dr=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(ep,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(ep,"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 qI(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=It({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return u1(n,!0)}};var rm=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 Dr(o,t,{...this.getTrailOptions(),fill:()=>Zm})}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(_o(i),_o(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 Dr(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||ii(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 JI}from"react";import{unstable_batchedUpdates as vv}from"react-dom";var Xe=e=>o=>{vv(e,o)},nm=e=>bi(o=>{vv(e,o)}),Ia=(()=>{let e;try{let t=JI.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 QI=(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)`},wv=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let c=(H,B)=>{if(!B.style.fontFamily||!B.style.fontSize)return!1;let ee=B.style.fontFamily.replace(/"/g,"");return _n({fontFamily:H.fontFamily})!==ee||`${H.fontSize}px`!==B.style.fontSize},m=()=>{let H=l.state,B=l.scene.getElement(e);if(!B)return;let{textAlign:ee,verticalAlign:oe}=B,Z=l.scene.getNonDeletedElementsMap();if(B&&Y(B)){let pe=B.x,xe=B.y,ve=fo(B,l.scene.getNonDeletedElementsMap()),Lt=B.width,Zo=B.height,mi=B.width,pi=B.height;if(ve&&B.containerId){if(Re(ve)){let Or=X.getBoundTextElementPosition(ve,B,Z);pe=Or.x,xe=Or.y}let ms=c(B,d),Na;if(ms?Na=Xa(ve.id,ve.height):(Na=M1[ve.id],Na||(Na=Xa(ve.id,ve.height))),mi=ja(ve,B),pi=Ws(ve,B),!Re(ve)&&Zo>pi){let Or=Ci(Zo,ve.type);l.scene.mutateElement(ve,{height:Or});return}else if(!Re(ve)&&ve.height>Na.height&&Zo<pi){let Or=Ci(Zo,ve.type);l.scene.mutateElement(ve,{height:Or})}else{let{y:Or}=Us(ve,B,Z);xe=Or}}let[cs,ds]=r(pe,xe),r5=d.selectionStart,Ym=d.selectionEnd,mf=d.value.length;if(r5===Ym&&Ym!==mf){let ms=mf-Ym;d.selectionStart=d.value.length-ms,d.selectionEnd=d.value.length-ms}ve?Lt+=.5:(mi=(H.width-8-cs)/H.zoom.value,Lt=Math.min(Lt,mi)),Zo*=1.05;let n5=qe(B),pf=(H.height-ds)/H.zoom.value;Object.assign(d.style,{font:n5,lineHeight:B.lineHeight,width:`${Lt}px`,height:`${Zo}px`,left:`${cs}px`,top:`${ds}px`,transform:QI(Lt,Zo,B1(B,ve),H,mi,pf),textAlign:ee,verticalAlign:oe,color:B.strokeColor,opacity:B.opacity/100,filter:"var(--theme-filter)",maxHeight:`${pf}px`}),d.scrollTop=0,jo()&&(d.style.fontFamily=_n(B)),l.scene.mutateElement(B,{x:pe,y:xe})}},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";(tt(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 B=await xd(H,!0);if(!B.text)return;let ee=Fn(B.text);if(!ee)return;let oe=fo(n,l.scene.getNonDeletedElementsMap()),Z=qe({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(oe){let pe=Ee(oe,l.scene.getNonDeletedElementsMap()),xe=Ti(`${d.value}${ee}`,Z,ja(oe,pe)),ve=O1(xe,Z);d.style.width=`${ve}px`}},d.oninput=()=>{let H=Fn(d.value);if(d.value!==H){let B=d.selectionStart;d.value=H,d.selectionStart=B,d.selectionEnd=B}o(d.value)}),d.onkeydown=H=>{if(!H.shiftKey&&md.keyTest(H))H.preventDefault(),l.actionManager.executeAction(md),m();else if(!H.shiftKey&&pd.keyTest(H))H.preventDefault(),l.actionManager.executeAction(pd),m();else if(!H.shiftKey&&ud.keyTest(H))H.preventDefault(),l.actionManager.executeAction(ud),m();else if(Zu.keyTest(H))l.actionManager.executeAction(Zu);else if(Xu.keyTest(H))l.actionManager.executeAction(Xu);else if(H.key===y.ESCAPE)H.preventDefault(),S=!0,k();else if(ri.keyTest(H))H.preventDefault(),k(),l.actionManager.executeAction(ri);else if(H.key===y.ENTER&&H[y.CTRL_OR_CMD]){if(H.preventDefault(),H.isComposing||H.keyCode===229)return;S=!0,k()}else if(H.key===y.TAB||H[y.CTRL_OR_CMD]&&(H.code===se.BRACKET_LEFT||H.code===se.BRACKET_RIGHT)){if(H.preventDefault(),H.isComposing)return;H.shiftKey||H.code===se.BRACKET_LEFT?w():E(),d.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),E=()=>{let{selectionStart:H,selectionEnd:B}=d,ee=v(),oe=d.value;ee.forEach(Z=>{let pe=oe.slice(0,Z),xe=oe.slice(Z);oe=`${pe}${b}${xe}`}),d.value=oe,d.selectionStart=H+f,d.selectionEnd=B+f*ee.length},w=()=>{let{selectionStart:H,selectionEnd:B}=d,ee=v(),oe=[],Z=d.value;ee.forEach(pe=>{let xe=Z.slice(pe,pe+f).match(x);if(xe){let ve=Z.slice(0,pe),Lt=Z.slice(pe+xe[0].length);Z=`${ve}${Lt}`,oe.push(pe)}}),d.value=Z,oe.length&&(H>oe[oe.length-1]?d.selectionStart=Math.max(H-f,oe[oe.length-1]):d.selectionStart=H,d.selectionEnd=Math.max(d.selectionStart,B-f*oe.length))},v=()=>{let{selectionStart:H,selectionEnd:B,value:ee}=d,oe=ee.slice(0,H).match(/[^\n]*$/)[0].length;return H=H-oe,ee.slice(H,B).split(`
9
- `).reduce((pe,xe,ve,Lt)=>pe.concat(ve?pe[ve-1]+Lt[ve-1].length+1:H),[]).reverse()},T=H=>{H.target instanceof HTMLCanvasElement&&(H.preventDefault(),H.stopPropagation())},S=!1,k=()=>{if(V)return;V=!0,D();let H=l.scene.getElement(n.id);if(!H)return;let B=fo(H,l.scene.getNonDeletedElementsMap());if(B){if(d.value.trim()){let ee=$a(B);!ee||ee!==n.id?l.scene.mutateElement(B,{boundElements:(B.boundElements||[]).concat({type:"text",id:n.id})}):Re(B)&&Er(B)}else l.scene.mutateElement(B,{boundElements:B.boundElements?.filter(ee=>!Y(ee))});Ye(H,B,l.scene)}t({viaKeyboard:S,nextOriginalText:d.value})},D=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,te&&te.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",T,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",M),window.removeEventListener("blur",k),window.removeEventListener("beforeunload",k),F(),K(),d.remove()},M=H=>{window.removeEventListener("pointerup",M);let B=H?.target,ee=B instanceof HTMLElement&&B.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=k,ee||d.focus()})},O=()=>{d.onblur=null,window.addEventListener("pointerup",M),window.addEventListener("blur",k)},P=H=>{let B=H?.target;if(H.button===Xo.WHEEL){B instanceof HTMLTextAreaElement&&(H.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(H)),O();return}let ee=B instanceof HTMLElement&&B.classList.contains("properties-trigger");(H.target instanceof HTMLElement||H.target instanceof SVGElement)&&H.target.closest(`.${Rt.SHAPE_ACTIONS_MENU}, .${Rt.ZOOM_ACTIONS}`)&&!$o(H.target)||ee?O():H.target instanceof HTMLCanvasElement&&!jo()&&requestAnimationFrame(()=>{k()})},F=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||d.focus()}),K=l.onScrollChangeEmitter.on(()=>{m()}),V=!1;s&&d.select(),M();let te=null;return i&&"ResizeObserver"in window?(te=new window.ResizeObserver(()=>{m()}),te.observe(i)):window.addEventListener("resize",m),d.onpointerdown=H=>H.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",P,{capture:!0})}),window.addEventListener("beforeunload",k),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d),k};var Tv=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 ek}from"points-on-curve";var Cv=e=>{let{lassoPath:o,elements:t,elementsSegments:r,intersectedElements:n,enclosedElements:i,simplifyDistance:a}=e,l=o;a&&(l=ek(o,a)),i.clear();for(let c of t)!n.has(c.id)&&!i.has(c.id)&&(tk(l,c,r)?i.add(c.id):ok(l,c,r)&&n.add(c.id));return{selectedElementIds:[...n,...i]}},tk=(e,o,t)=>{let r=qf(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>Jf(a,r))):!1},ok=(e,o,t)=>{let r=t.get(o.id);return r?e.reduce((i,a,l)=>(l===0||i.push(As(e[l-1],a)),i),[]).some(i=>r.some(a=>_s(i,a,1)!==null)):!1};var im=class extends Dr{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(_o(s),_o(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,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&&Y(c)){let m=fo(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=No(this.app.scene.getNonDeletedElementsMap(),c.id);for(let d of m)delete n[d.id]}}let i=nt({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&&fe(this.app.scene.getNonDeletedElement(a[0]))?new X(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(n=>L(n[0],n[1])),r={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!rt(r,this.canvasTranslate??{})){this.canvasTranslate=r,this.elementsSegments=new Map;let n=J(this.app.visibleElements);for(let i of this.app.visibleElements){let a=rc(i,n);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:n}=Cv({lassoPath:t,elements:this.app.visibleElements,elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(n)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};var rk=2,am=class extends Dr{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(_o(s),_o(l))},fill:()=>r.state.theme===re.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=>L(l[0],l[1]))||[];r=r?.slice(r.length-rk);let n=this.app.visibleElements.filter(l=>!l.locked),i=J(n),a=r.reduce((l,s,c)=>(c===0||l.push(As(r[c-1],s)),l),[]);if(a.length===0)return[];for(let l of n)if(t&&this.elementsToErase.has(l.id)){if(Iv(a,l,this.segmentsCache,this.geometricShapesCache,i,this.app)){let c=l.groupIds.at(-1);if(this.groupsToErase.has(c)){let m=$e(this.app.scene.getNonDeletedElementsMap(),c);for(let d of m)this.elementsToErase.delete(d.id);this.groupsToErase.delete(c)}if(tt(l)&&this.elementsToErase.delete(l.containerId),ut(l)){let m=$a(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&Iv(a,l,this.segmentsCache,this.geometricShapesCache,i,this.app)){let c=l.groupIds.at(-1);if(!this.groupsToErase.has(c)){let m=$e(this.app.scene.getNonDeletedElementsMap(),c);for(let d of m)this.elementsToErase.add(d.id);this.groupsToErase.add(c)}if(ut(l)){let m=$a(l);m&&this.elementsToErase.add(m)}tt(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()}},Iv=(e,o,t,r,n,i)=>{let a=r.get(o.id);a||(a=yr(o,n),r.set(o.id,a));let l=e[e.length-1][1];if(w1(o)&&pc(l,a))return!0;let s=t.get(o.id);return s||(s=rc(o,n),t.set(o.id,s)),e.some(c=>s?.some(m=>_s(c,m,i.getElementHitThreshold())!==null))};import{jsx as ko,jsxs as kv}from"react/jsx-runtime";var nk=()=>kv("div",{"data-testid":"brave-measure-text-error",children:[ko("p",{children:ko(Ft,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>ko("span",{style:{fontWeight:600},children:e})})}),ko("p",{children:ko(Ft,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>ko("span",{style:{fontWeight:600},children:e})})}),ko("p",{children:ko(Ft,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>ko("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),ko("p",{children:ko(Ft,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>ko("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>kv("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),Sv=nk;import sk from"clsx";import ck from"react";import{useLayoutEffect as ik,useRef as Mv,useEffect as Lv}from"react";import{unstable_batchedUpdates as ak}from"react-dom";import{jsx as lk}from"react/jsx-runtime";var Av=({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=Mv(null);Lv(()=>{let d=c.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=u=>{if(u.key===y.TAB){let f=Za(d),{activeElement:b}=document,x=f.findIndex(E=>E===b);b===d?(u.shiftKey?f[f.length-1]?.focus():f[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(f[f.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===f.length-1&&!u.shiftKey&&(f[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let m=Mv(null);return ik(()=>{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]),Lv(()=>{if(r){let d=p=>{c.current?.contains(p.target)||ak(()=>r(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),lk("div",{className:"popover",ref:c,tabIndex:-1,children:e})};import{jsx as ka,jsxs as dk}from"react/jsx-runtime";var st="separator",_v=ck.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=or(),a=an(),l=o.reduce((s,c)=>(c&&(c===st||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return ka(Av,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:ka("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===st)return!l[c-1]||l[c-1]===st?null:ka("hr",{className:"context-menu-item-separator"},c);let m=s.name,d="";return s.label&&(typeof s.label=="function"?d=g(s.label(a,i,e.app)):d=g(s.label)),ka("li",{"data-testid":m,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:dk("button",{type:"button",className:sk("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[ka("div",{className:"context-menu-item__label",children:d}),ka("kbd",{className:"context-menu-item__shortcut",children:m?Qe(m):""})]})},c)})})})});import{jsx as lg,jsxs as Dv}from"react/jsx-runtime";var mk=({height:e,width:o,userToFollow:t,onDisconnect:r})=>lg("div",{className:"follow-mode",style:{width:o,height:e},children:Dv("div",{className:"follow-mode__badge",children:[Dv("div",{className:"follow-mode__badge__label",children:["Following"," ",lg("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),lg("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:xo})]})}),Pv=mk;import ts from"clsx";import f8 from"react";import pk from"clsx";import{useState as uk,useEffect as hk}from"react";import{jsx as sg,jsxs as gk}from"react/jsx-runtime";var lm=({delay:e,theme:o})=>{let[t,r]=uk(!!e);return hk(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:gk("div",{className:pk("LoadingMessage",{"LoadingMessage--dark":o===re.DARK}),children:[sg("div",{children:sg(St,{})}),sg("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import fk from"clsx";import{jsx as Nv,jsxs as xk}from"react/jsx-runtime";var bk="medium",Rv={CHECKED:Ui,UNCHECKED:Zn},sm=e=>xk("label",{className:fk("ToolIcon ToolIcon__lock",`ToolIcon_size_${bk}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[Nv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),Nv("div",{className:"ToolIcon__icon",children:e.checked?Rv.CHECKED:Rv.UNCHECKED})]});import Ek from"clsx";import{jsx as yk}from"react/jsx-runtime";var cm=({children:e,side:o,className:t})=>yk("div",{className:Ek("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import vk from"clsx";import{jsx as wk}from"react/jsx-runtime";var dm=e=>wk($,{className:vk("Shape",{fillable:!1}),type:"radio",icon:Bc,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:y.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":y.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{jsx as Ov}from"react/jsx-runtime";var Tk=({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===_t.name&&e.openSidebar.tab===gr&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(Zt(e))return g("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?g("hints.linearElementMulti"):n.type==="arrow"?g("hints.arrowTool",{arrowShortcut:R("A")}):g("hints.linearElement");if(n.type==="freedraw")return g("hints.freeDraw");if(n.type==="text")return g("hints.text");if(n.type==="embeddable")return g("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return g("hints.placeImage");let c=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let m=c[0];return fe(m)&&m.points.length===2?g("hints.lockAngle"):Me(m)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(c.length===1&&Y(c[0]))return g("hints.text_selected");if(e.editingTextElement)return g("hints.text_editing");if(e.croppingElementId)return g("hints.leaveCropEditor");if(c.length===1&&Me(c[0]))return g("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.editingLinearElement)return[g("hints.deepBoxSelect")];if(hn(r)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!c.length&&!o)return[g("hints.canvasPanning")];if(c.length===1){if(fe(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&xr(c[0]))return Hs(c[0])?Sb(c[0],r.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},mm=({appState:e,isMobile:o,device:t,app:r})=>{let n=Tk({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 Ov("div",{className:"HintViewer",children:Ov("span",{children:i})})};import Ck from"clsx";import{jsx as zv,jsxs as kk}from"react/jsx-runtime";var Ik="medium",pm=e=>e.penDetected?kk("label",{className:Ck("ToolIcon ToolIcon__penMode",`ToolIcon_size_${Ik}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[zv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),zv("div",{className:"ToolIcon__icon",children:M0})]}):null;import{Fragment as Sk,jsx as Bv,jsxs as Mk}from"react/jsx-runtime";var fn=({heading:e,children:o,...t})=>{let{id:r}=at(),n=Bv("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:g(`headings.${e}`)});return Bv("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):Mk(Sk,{children:[n,o]})})};import{Fragment as Lk,jsx as Mt,jsxs as Pr}from"react/jsx-runtime";var Fv=({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})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=Ue(),E=()=>Pr(cm,{side:"top",className:"App-top-bar",children:[d&&Mt(f.Out,{}),Mt(fn,{heading:"shapes",children:v=>Mt(wt.Col,{gap:4,align:"center",children:Pr(wt.Row,{gap:1,className:"App-toolbar-container",children:[Pr(gt,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[v,Mt(wt.Row,{gap:1,children:Mt(Xd,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Pr("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Mt(x.Out,{}),Mt(pm,{checked:e.penMode,onChange:()=>a(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),Mt(sm,{checked:e.activeTool.locked,onChange:n,title:g("toolBar.lock"),isMobile:!0}),Mt(dm,{checked:Bo(e),onChange:()=>i(),title:g("toolBar.hand"),isMobile:!0})]})]})})}),Mt(mm,{appState:e,isMobile:!0,device:m,app:u})]}),w=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?Mt("div",{className:"App-toolbar-content",children:Mt(b.Out,{})}):Pr("div",{className:"App-toolbar-content",children:[Mt(b.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),Pr("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return Pr(Lk,{children:[c(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&E(),Mt("div",{className:"App-bottom-bar",style:{marginBottom:Jt+Vo*2,marginLeft:Jt+Vo*2,marginRight:Jt+Vo*2},children:Pr(gt,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Pi(e,o)?Mt(fn,{className:"App-mobile-menu",heading:"selectedShapeActions",children:Mt(Zd,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,Pr("footer",{className:"App-toolbar",children:[w(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&Mt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(v=>({...Kn(o,v)}))},children:g("buttons.scrollBackToContent")})]})]})})]})};import Ak from"open-color";import _k,{useLayoutEffect as Dk,useRef as Pk,useState as Rk}from"react";import{jsx as Kl,jsxs as Nk}from"react/jsx-runtime";var Hv=e=>{let o=Pk(null),[t,r]=Rk(null);return Dk(()=>{if(!e.spreadsheet)return;let n=i2(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await Oi(n,{exportBackground:!1,viewBackgroundColor:Ak.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),Kl("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:Kl("div",{ref:o})})},Uv=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=Je(),n=_k.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),de("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Kl(et,{size:"small",onCloseRequest:n,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:Nk("div",{className:"container",children:[Kl(Hv,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),Kl(Hv,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as bn from"@radix-ui/react-popover";import Gv from"clsx";import um,{useLayoutEffect as Ok}from"react";import{Fragment as Uk,jsx as sr,jsxs as hm}from"react/jsx-runtime";var zk=4,Bk=8,Fk=({shouldWrap:e,children:o,username:t})=>e?sr(io,{label:t||"Unknown user",children:o}):sr(Uk,{children:o}),cg=({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 sr(Fk,{username:o.username,shouldWrap:n,children:l},t)},Hk=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],gm=um.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=lt(),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]=um.useState(""),c=a.filter(b=>b.username?.toLowerCase().includes(l)),m=um.useRef(null);Ok(()=>{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),!Oa)return;let x=new ResizeObserver(E=>{for(let w of E){let{width:v}=w.contentRect;b(v)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[d,p]=um.useState(zk),f=a.slice(0,d-1).map(b=>cg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?sr("div",{className:Gv("UserList UserList_mobile",e),children:a.map(b=>cg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):sr("div",{className:"UserList__wrapper",ref:m,children:hm("div",{className:Gv("UserList",e),style:{"--max-avatars":d},children:[f,a.length>d-1&&hm(bn.Root,{children:[hm(bn.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),sr(bn.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:hm(gt,{padding:2,children:[a.length>=Bk&&sr(od,{placeholder:g("quickSearch.placeholder"),onChange:s}),sr(rd,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:c.length>0?[sr("div",{className:"hint",children:g("userList.hint.text")}),c.map(b=>cg({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),sr(bn.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||!rt(n,i,Hk))return!1}return!0});import fm from"clsx";import{jsx as Gk}from"react/jsx-runtime";var Wv=e=>Gk("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Wi});import{jsx as cr,jsxs as dg}from"react/jsx-runtime";var Vv=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=Ue(),a=be(),l=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return dg("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[cr("div",{className:fm("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:cr(wt.Col,{gap:2,children:dg(fn,{heading:"canvasActions",children:[cr(Ny,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&cr(Oy,{renderAction:o.renderAction,className:fm("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),l&&cr(By,{renderAction:o.renderAction,className:fm("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),cr(n.Out,{}),cr("div",{className:fm("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:dg("div",{style:{position:"relative"},children:[r&&cr(i.Out,{}),cr(Wv,{onClick:()=>o.executeAction(ni)})]})}),cr(zy,{actionManager:o,showExitZenModeBtn:t})]})},Yv=Vv;Vv.displayName="Footer";import jk from"clsx";import{useEffect as tw,useLayoutEffect as ow,useRef as Eg,useState as qk,forwardRef as rw,useImperativeHandle as Jk,useCallback as Qv}from"react";import Vk from"clsx";import{useContext as Yk}from"react";import Wk from"react";var bm=Wk.createContext({});import{jsx as mg,jsxs as Kv}from"react/jsx-runtime";var pg=({children:e,className:o})=>{let t=be(),r=Yk(bm),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return Kv("div",{className:Vk("sidebar__header",o),"data-testid":"sidebar-header",children:[e,Kv("div",{className:"sidebar__header__buttons",children:[n&&mg(io,{label:g("labels.sidebarLock"),children:mg(co,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:w0})}),mg(co,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":g("buttons.close"),children:xo})]})]})};pg.displayName="SidebarHeader";import*as Xv from"@radix-ui/react-tabs";import{jsx as Zv}from"react/jsx-runtime";var ug=({children:e,tab:o,onSelect:t,...r})=>Zv(Xv.Trigger,{value:o,asChild:!0,onSelect:t,children:Zv("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});ug.displayName="SidebarTabTrigger";import*as $v from"@radix-ui/react-tabs";import{jsx as Kk}from"react/jsx-runtime";var hg=({children:e,...o})=>Kk($v.List,{className:"sidebar-triggers",...o,children:e});hg.displayName="SidebarTabTriggers";import Zk from"clsx";import{jsx as gg,jsxs as jv}from"react/jsx-runtime";var fg=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=ye(),c=Le();return jv("label",{title:r,className:"sidebar-trigger__label-element",children:[gg("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"}),jv("div",{className:Zk("sidebar-trigger",a),style:l,children:[t&&gg("div",{children:t}),n&&gg("div",{className:"sidebar-trigger__label",children:n})]})]})};fg.displayName="SidebarTrigger";import*as qv from"@radix-ui/react-tabs";import{jsx as Xk}from"react/jsx-runtime";var bg=({children:e,...o})=>{let t=Le(),r=ye();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return Xk(qv.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};bg.displayName="SidebarTabs";import*as Jv from"@radix-ui/react-tabs";import{jsx as $k}from"react/jsx-runtime";var xg=({tab:e,children:o,...t})=>$k(Jv.Content,{...t,value:e,"data-testid":e,children:o});xg.displayName="SidebarTab";import{jsx as ew}from"react/jsx-runtime";import{createElement as Qk}from"react";var Zl=Ie(!1),nw=rw(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{pt()&&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=ye(),s=tn(Zl);ow(()=>(s(!!r),()=>{s(!1)}),[s,r]);let c=Eg({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=xi(c.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let m=Eg(null);Jk(a,()=>m.current);let d=be(),p=Qv(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Xi(m,Qv(u=>{u.target.closest(".sidebar-trigger")||(!r||!d.editor.canFitSidebar)&&p()},[p,r,d.editor.canFitSidebar])),tw(()=>{let u=f=>{f.key===y.ESCAPE&&(!r||!d.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,r,d.editor.canFitSidebar]),ew(gt,{...i,className:jk("sidebar",{"sidebar--docked":r},n),ref:m,children:ew(bm.Provider,{value:c.current,children:o})})});nw.displayName="SidebarInner";var So=Object.assign(rw((e,o)=>{let t=Le(),{onStateChange:r}=e,n=Eg(t.openSidebar);tw(()=>{(!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]=qk(!1);return ow(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?Qk(nw,{...e,ref:o,key:e.name}):null}),{Header:pg,TabTriggers:hg,TabTrigger:ug,Tabs:bg,Tab:xg,Trigger:fg});So.displayName="Sidebar";import{useLayoutEffect as eS,useRef as tS}from"react";import{jsx as oS}from"react/jsx-runtime";var Rr=(e,o)=>{let t=Ie(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=Ue(),[,a]=i(t),l=tS({preferHost:!1,counter:0});return eS(()=>{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:oS(o,{...n})};return r.displayName=e,r};var wg={};hf(wg,{ChangeCanvasBackground:()=>xw,ClearCanvas:()=>fw,CommandPalette:()=>uw,Export:()=>Ew,Help:()=>gw,LiveCollaborationTrigger:()=>vw,LoadScene:()=>dw,SaveAsImage:()=>pw,SaveToActiveFile:()=>mw,SearchMenu:()=>hw,Socials:()=>yw,ToggleTheme:()=>bw});import aS from"clsx";var yg=Ie({active:!1});async function iw({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{it.set(yg,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import rS from"clsx";import{jsx as aw,jsxs as nS}from"react/jsx-runtime";var xm=function({onChange:e,value:o,choices:t,name:r}){return aw("div",{className:"RadioGroup",children:t.map(n=>nS("div",{className:rS("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[aw("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 iS,jsx as vg,jsxs as lw}from"react/jsx-runtime";var sw=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=be();return lw(iS,{children:[lw("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[vg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),vg(xm,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&vg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};sw.displayName="DropdownMenuItemContentRadio";var cw=sw;import{Fragment as lS,jsx as bt,jsxs as ww}from"react/jsx-runtime";var dw=()=>{let{t:e}=ot(),o=lt(),t=an();return o.isActionEnabled(na)?bt(zt,{icon:Vi,onSelect:async()=>{(!t.length||await iw({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:bt(Ft,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>bt("strong",{children:n}),br:()=>bt("br",{})})}))&&o.executeAction(na)},"data-testid":"load-button",shortcut:Qe("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};dw.displayName="LoadScene";var mw=()=>{let{t:e}=ot(),o=lt();return o.isActionEnabled(ri)?bt(zt,{shortcut:Qe("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(ri),icon:O0,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};mw.displayName="SaveToActiveFile";var pw=()=>{let e=ye(),{t:o}=ot();return bt(zt,{icon:Rc,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Qe("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};pw.displayName="SaveAsImage";var uw=e=>{let o=ye(),{t}=ot();return bt(zt,{icon:fl,"data-testid":"command-palette-button",onSelect:()=>{de("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Qe("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};uw.displayName="CommandPalette";var hw=e=>{let{t:o}=ot(),t=lt();return bt(zt,{icon:ro,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(Gl)},shortcut:Qe("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};hw.displayName="SearchMenu";var gw=()=>{let{t:e}=ot(),o=lt();return bt(zt,{"data-testid":"help-menu-item",icon:Wi,onSelect:()=>o.executeAction(ni),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};gw.displayName="Help";var fw=()=>{let{t:e}=ot(),o=tn(li);return lt().isActionEnabled(kr)?bt(zt,{icon:oo,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};fw.displayName="ClearCanvas";var bw=e=>{let{t:o}=ot(),t=Le(),r=lt(),n=Qe("toggleTheme");return r.isActionEnabled(Qn)?e?.allowSystemTheme?bt(cw,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:re.LIGHT,label:pl,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:re.DARK,label:ml,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:Jx,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):bt(zt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===re.DARK?re.LIGHT:re.DARK);else return r.executeAction(Qn)},icon:t.theme===re.DARK?pl:ml,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===re.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===re.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};bw.displayName="ToggleTheme";var xw=()=>{let{t:e}=ot(),o=Le(),t=lt(),r=rr();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:ww("div",{style:{marginTop:"0.5rem"},children:[bt("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),bt("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};xw.displayName="ChangeCanvasBackground";var Ew=()=>{let{t:e}=ot(),o=ye();return bt(zt,{icon:Xn,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};Ew.displayName="Export";var yw=()=>{let{t:e}=ot();return ww(lS,{children:[bt(xa,{icon:Dc,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),bt(xa,{icon:R0,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),bt(xa,{icon:P0,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};yw.displayName="Socials";var vw=({onSelect:e,isCollaborating:o})=>{let{t}=ot();return bt(zt,{"data-testid":"collab-button",icon:Nc,className:aS({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};vw.displayName="LiveCollaborationTrigger";import{jsx as Em,jsxs as Tg}from"react/jsx-runtime";var sS=Object.assign(Rr("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ue(),r=be(),n=Le(),i=ye(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return Em(t.In,{children:Tg(Ae,{open:n.openMenu==="canvas",children:[Em(Ae.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:_c}),Tg(Ae.Content,{onClickOutside:a,onSelect:Vr(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&Tg("fieldset",{className:"UserList-Wrapper",children:[Em("legend",{children:g("labels.collaborators")}),Em(gm,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Ae.Trigger,Item:Ae.Item,ItemLink:Ae.ItemLink,ItemCustom:Ae.ItemCustom,Group:Ae.Group,Separator:Ae.Separator,DefaultItems:wg}),Pt=sS;import cS from"clsx";import{forwardRef as dS,useState as mS}from"react";import{jsx as ym,jsxs as pS}from"react/jsx-runtime";var xn=dS(({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]=mS(!1),u=async b=>{let x=t?.(b);if(Wr(x)){let E=window.setTimeout(()=>{p(!0)},50);try{await x}catch(w){if(w instanceof Ri)console.warn(w);else throw w}finally{clearTimeout(E),p(!1)}}},f=d?"loading":c;return i=f==="success"?"success":i,ym("button",{className:cS("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:m,disabled:f==="loading"||f==="success",children:pS("div",{className:"ExcButton__contents",children:[f==="loading"?ym(St,{className:"ExcButton__statusIcon"}):f==="success"&&ym("div",{className:"ExcButton__statusIcon",children:Px}),o&&ym("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as Sa,jsxs as gS}from"react/jsx-runtime";var vm=({title:e,children:o,actionLabel:t,onClick:r})=>gS("div",{className:"OverwriteConfirm__Actions__Action",children:[Sa("h4",{children:e}),Sa("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Sa(xn,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),uS=()=>{let{t:e}=ot(),o=lt(),t=ye();return Sa(vm,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(yd,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},hS=()=>{let{t:e}=ot(),o=lt();return Sa(vm,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Al,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Cg=Object.assign(({children:e})=>Sa("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:uS,SaveToDisk:hS});import{jsx as En,jsxs as Tw}from"react/jsx-runtime";var wm=Object.assign(Rr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ue(),[t,r]=he(yg);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return En(o.In,{children:En(et,{onCloseRequest:n,title:!1,size:916,children:Tw("div",{className:"OverwriteConfirm",children:[En("h3",{children:t.title}),Tw("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[En("div",{className:"OverwriteConfirm__Description__icon",children:Rx}),En("div",{children:t.description}),En("div",{className:"OverwriteConfirm__Description__spacer"}),En(xn,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),En(Cg,{children:e})]})})})}),{Actions:Cg,Action:vm});import AS from"clsx";import fS from"clsx";import bS from"lodash.debounce";import{Fragment as xS,memo as ES,useEffect as Xl,useMemo as Cw,useRef as Ig,useState as Iw}from"react";import{Fragment as LS,jsx as Tt,jsxs as dr}from"react/jsx-runtime";var yS=Ie(""),kg=Ie(null),vS=350,Lw=()=>{let e=Je(),o=ye(),t=Ig(null),[r,n]=he(yS),i=r.trim(),[a,l]=Iw(!1),[s,c]=Iw({nonce:null,items:[]}),m=Ig(null),d=Ig(void 0),[p,u]=he(kg),f=e.scene.getNonDeletedElementsMap();Xl(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==d.current)&&(m.current=null,Mw(i,e,(v,T)=>{c({nonce:Nn(),items:v}),m.current=i,d.current=e.scene.getSceneNonce(),o({searchMatches:v.length?{focusedId:null,matches:v.map(S=>({id:S.element.id,focus:!1,matchedLines:S.matchedLines}))}:null})}))},[a,i,f,e,o,u,d]);let b=()=>{s.items.length>0&&u(v=>v===null?0:(v+1)%s.items.length)},x=()=>{s.items.length>0&&u(v=>v===null?0:v-1<0?s.items.length-1:v-1)};Xl(()=>{o(v=>v.searchMatches?{searchMatches:{focusedId:p!==null&&v.searchMatches?.matches[p]?.id||null,matches:v.searchMatches.matches.map((S,k)=>k===p?{...S,focus:!0}:{...S,focus:!1})}}:null)},[p,o]),Xl(()=>{if(s.items.length>0&&p!==null){let v=s.items[p];if(v){let T=e.state.zoom.value,S=Ot({text:v.searchQuery,x:v.element.x+(v.matchedLines[0]?.offsetX??0),y:v.element.y+(v.matchedLines[0]?.offsetY??0),width:v.matchedLines[0]?.width,height:v.matchedLines[0]?.height,fontSize:ae(v.element)?At.nameFontSize:v.element.fontSize,fontFamily:ae(v.element)?dt.Assistant:v.element.fontFamily}),k=14,D=S.fontSize,M=D*T<k;if(!Li([S],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||M){let O;M?D>=k?O={fitToContent:!0}:O={fitToViewport:!0,maxZoom:ho(k/D,1)}:O={fitToContent:!0},e.scrollToContent(S,{animate:!0,duration:300,...O,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),Xl(()=>()=>{u(null),m.current=null,d.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let E=rn({goToNextItem:b,goToPreviousItem:x,searchMatches:s});Xl(()=>{let v=T=>{if(T.key===y.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){T.preventDefault(),T.stopPropagation(),o({openSidebar:null});return}T[y.CTRL_OR_CMD]&&T.key===y.F&&(T.preventDefault(),T.stopPropagation(),t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())),T.target instanceof HTMLElement&&T.target.closest(".layer-ui__search")&&E.searchMatches.items.length&&(T.key===y.ENTER&&(T.stopPropagation(),E.goToNextItem()),T.key===y.ARROW_UP?(T.stopPropagation(),E.goToPreviousItem()):T.key===y.ARROW_DOWN&&(T.stopPropagation(),E.goToNextItem()))};return He(window,"keydown",v,{capture:!0,passive:!1})},[o,E,e]);let w=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return dr("div",{className:"layer-ui__search",children:[Tt("div",{className:"layer-ui__search-header",children:Tt(va,{className:Rt.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:g("search.placeholder"),icon:ro,onChange:v=>{n(v),l(!0);let T=v.trim();Mw(T,e,(S,k)=>{c({nonce:Nn(),items:S}),u(k),m.current=T,d.current=e.scene.getSceneNonce(),o({searchMatches:S.length?{focusedId:null,matches:S.map(D=>({id:D.element.id,focus:!1,matchedLines:D.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),dr("div",{className:"layer-ui__search-count",children:[s.items.length>0&&dr(LS,{children:[p!==null&&p>-1?dr("div",{children:[p+1," / ",w]}):Tt("div",{children:w}),dr("div",{className:"result-nav",children:[Tt(co,{onSelect:()=>{b()},className:"result-nav-btn",children:Yc}),Tt(co,{onSelect:()=>{x()},className:"result-nav-btn",children:rE})]})]}),s.items.length===0&&i&&m.current&&Tt("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),Tt(CS,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},kw=e=>{let o=[e.preview.moreBefore?"...":"",e.preview.previewText.slice(0,e.preview.indexInSearchQuery),e.preview.previewText.slice(e.preview.indexInSearchQuery,e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.previewText.slice(e.preview.indexInSearchQuery+e.searchQuery.length),e.preview.moreAfter?"...":""];return Tt("div",{tabIndex:-1,className:fS("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Tt("div",{className:"preview-text",children:o.flatMap((t,r)=>Tt(xS,{children:r===2?Tt("b",{children:t}):t},r))})})},wS=e=>{let o=Cw(()=>e.matches.items.filter(r=>ae(r.element)),[e.matches]),t=Cw(()=>e.matches.items.filter(r=>Y(r.element)),[e.matches]);return dr("div",{children:[o.length>0&&dr("div",{className:"layer-ui__search-result-container",children:[dr("div",{className:"layer-ui__search-result-title",children:[Tt("div",{className:"title-icon",children:jn}),Tt("div",{children:g("search.frames")})]}),o.map((r,n)=>Tt(kw,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.index)),t.length>0&&Tt("div",{className:"layer-ui__divider"})]}),t.length>0&&dr("div",{className:"layer-ui__search-result-container",children:[dr("div",{className:"layer-ui__search-result-title",children:[Tt("div",{className:"title-icon",children:Gi}),Tt("div",{children:g("search.texts")})]}),t.map((r,n)=>Tt(kw,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+o.length===e.focusIndex,onClick:()=>e.onItemClick(n+o.length)},r.element.id+r.index))]})]})},TS=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,CS=ES(wS,TS),Sw=(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(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+b,moreBefore:s>0,moreAfter:p.length>f}},IS=(e,o)=>{let t=e.split(`
10
- `),r=[],n=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=o.indexOf(l,n);if(s>a.length+n){let c=s-(a.length+n);for(;c>0;)a+=" ",c--}}r.push(a),n=n+a.length}return r.join(`
11
- `)},kS=(e,o,t)=>{let n=IS(e.text,e.originalText).split(`
12
- `),i=[],a=0,l=0;for(let d of n){let p=a,u=p+d.length-1;i.push({line:d,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,c=e.originalText.slice(t,t+o.length),m=[];for(let d of i){if(c==="")break;if(s>=d.startIndex&&s<=d.endIndex){let p=d.endIndex+1-s,u=d.line.slice(0,s-d.startIndex),f=c.slice(0,p);c=c.slice(p);let b=vt(u,qe(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&d.line.length>0){let T=vt(d.line,qe(e),e.lineHeight),S=e.textAlign==="center"?(e.width-T.width)/2:e.width-T.width;b.width+=S}let{width:x,height:E}=vt(f,qe(e),e.lineHeight),w=b.width,v=d.lineNumber*b.height;m.push({offsetX:w,offsetY:v,width:x,height:E,showOnCanvas:!0}),s+=p}}return m},SS=(e,o,t,r)=>{let n=e.name??xp(e),i=n.slice(t,t+o.length),a=n.slice(0,t),l=qe({fontSize:At.nameFontSize,fontFamily:dt.Assistant}),s=Ao(dt.Assistant),c=vt(a,l,s);a===""&&(c.width=0);let m=vt(i,l,s),d=c.width,p=-c.height-At.strokeWidth,u=m.width;return[{offsetX:d,offsetY:p,width:u,height:m.height,showOnCanvas:d+u<=e.width*r}]},MS=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),Mw=bS((e,o,t)=>{if(!e||e===""){t([],null);return}let r=o.scene.getNonDeletedElements(),n=r.filter(p=>Y(p)),i=r.filter(p=>ae(p));n.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(MS(e),"gi");for(let p of n){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=Sw(f,u.index,e),x=kS(p,e,u.index);x.length>0&&a.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let s=[];for(let p of i){let u=null,f=p.name??xp(p);for(;(u=l.exec(f))!==null;){let b=Sw(f,u.index,e),x=SS(p,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let c=new Set(o.visibleElements.map(p=>p.id)),m=[...s,...a],d=m.findIndex(p=>c.has(p.element.id))??null;t(m,d)},vS);import{jsx as Yo,jsxs as Aw}from"react/jsx-runtime";import{createElement as _S}from"react";var _w=Rr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ue();return Yo(o.In,{children:Yo(So.Trigger,{...e,className:"default-sidebar-trigger",name:_t.name})})});_w.displayName="DefaultSidebarTrigger";var Dw=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Ue();return Yo(o.In,{children:e})};Dw.displayName="DefaultTabTriggers";var Tm=Object.assign(Rr("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let i=Le(),a=ye(),{DefaultSidebarTabTriggersTunnel:l}=Ue(),s=i.openSidebar?.tab===gr;return _S(So,{...n,name:"default",key:"default",className:AS("default-sidebar",o),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:Vr(t,c=>{a({defaultSidebarDockedPreference:c})})},Aw(So.Tabs,{children:[Yo(So.Header,{children:Aw(So.TabTriggers,{children:[Yo(So.TabTrigger,{tab:gr,children:ro}),Yo(So.TabTrigger,{tab:Ga,children:Hi}),Yo(l.Out,{})]})}),Yo(So.Tab,{tab:Ga,children:Yo(Ly,{})}),Yo(So.Tab,{tab:gr,children:Yo(Lw,{})}),e]}))}),{Trigger:_w,TabTriggers:Dw});import{useEffect as YS,useRef as Lg,useState as Pm}from"react";import{useState as zw,useRef as Bw,useEffect as Fw,useDeferredValue as BS}from"react";import{useEffect as DS,useRef as Pw}from"react";import{jsx as PS}from"react/jsx-runtime";var Cm=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=Pw(null),i=Pw(r);return i.current=r,DS(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[y.CTRL_OR_CMD]&&s.key===y.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener("keydown",l),()=>{a.removeEventListener("keydown",l)}}},[]),PS("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:n})};import{jsx as Im,jsxs as Rw}from"react/jsx-runtime";var RS=({error:e})=>Rw("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Im("p",{children:e})]}),km=({error:e,canvasRef:o,loaded:t})=>Rw("div",{className:"ttd-dialog-output-wrapper",children:[e&&Im(RS,{error:e.message}),t?Im("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Im(St,{size:"2rem"})]});import Nw from"clsx";import{jsx as Sg,jsxs as $l}from"react/jsx-runtime";var Ma=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>$l("div",{className:"ttd-dialog-panel",children:[$l("div",{className:"ttd-dialog-panel__header",children:[Sg("label",{children:e}),i?.()]}),o,$l("div",{className:Nw("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[$l(co,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[$l("div",{className:Nw({invisible:n}),children:[t?.label,t?.icon&&Sg("span",{children:t.icon})]}),n&&Sg(St,{})]}),!r&&!n&&a?.(),l?.()]})]});import{jsx as NS}from"react/jsx-runtime";var Sm=({children:e})=>NS("div",{className:"ttd-dialog-panels",children:e});import{jsx as Ow,jsxs as OS}from"react/jsx-runtime";var Mm=()=>OS("div",{className:"ttd-dialog-submit-shortcut",children:[Ow("div",{className:"ttd-dialog-submit-shortcut__key",children:R("CtrlOrCmd")}),Ow("div",{className:"ttd-dialog-submit-shortcut__key",children:R("Enter")})]});var zS=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},Lm=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){zS({canvasRef:e,setError:r});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:c,files:m}=s;r(null),n.current={elements:Ca(c,{regenerateIds:!0}),files:m};let d=await mn({elements:n.current.elements,files:n.current.files,exportPadding:Fr,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Tr(d)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(d)}catch(l){throw a.style.background="var(--default-bg-color)",t&&r(l),l}}},jl=e=>{To.set(Hr.MERMAID_TO_EXCALIDRAW,e)},Am=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:r})=>{let{elements:n,files:i}=o.current;n.length&&(e.addElementsFromPasteOrLibrary({elements:n,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),r&&t&&jl(t))};import{Fragment as US,jsx as mr,jsxs as Uw}from"react/jsx-runtime";var FS=`flowchart TD
7
+ ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var $x=async(e,o,t,n)=>{let{exportBackground:r,viewBackgroundColor:i,fileHandle:a}=o,l=p1(a);if(!a||!u1(l))throw new Error("fileHandle should exist and should be of type svg or png when resaving");o={...o,exportEmbedScene:!0};let{exportedElements:s,exportingFrame:d}=Kn(e,o,!1);return await Zn(l,s,o,t,{exportBackground:r,viewBackgroundColor:i,name:n,fileHandle:a,exportingFrame:d}),{fileHandle:a}};import{Fragment as kk,jsx as Ro,jsxs as Mk}from"react/jsx-runtime";var Vp=B({name:"changeProjectName",label:"labels.fileTitle",trackEvent:!1,perform:(e,o,t)=>({appState:{...o,name:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o,appProps:t,data:n,app:r})=>Ro(_x,{label:g("labels.fileTitle"),value:r.getName(),onChange:i=>o(i),ignoreFocus:n?.ignoreFocus??!1})}),jx=B({name:"changeExportScale",label:"imageExportDialog.scale",trackEvent:{category:"export",action:"scale"},perform:(e,o,t)=>({appState:{...o,exportScale:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=Sk(e),i=Ee(n,o)?j(n,o):n;return Ro(kk,{children:Ck.map(a=>{let[l,s]=d1(i,Ik,a),d=`${g("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Ro(K,{size:"small",type:"radio",icon:`${a}x`,name:"export-canvas-scale",title:d,"aria-label":d,id:"export-canvas-scale",checked:a===o.exportScale,onChange:()=>t(a)},a)})})}}),Xp=B({name:"changeExportBackground",label:"imageExportDialog.label.withBackground",trackEvent:{category:"export",action:"toggleBackground"},perform:(e,o,t)=>({appState:{...o,exportBackground:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Ro(xa,{checked:e.exportBackground,onChange:t=>o(t),children:g("imageExportDialog.label.withBackground")})}),Xs=B({name:"changeExportEmbedScene",label:"imageExportDialog.tooltip.embedScene",trackEvent:{category:"export",action:"embedScene"},perform:(e,o,t)=>({appState:{...o,exportEmbedScene:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Mk(xa,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),Ro(At,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:Ro("div",{className:"excalidraw-tooltip-icon",children:j1})})]})}),$n=B({name:"saveToActiveFile",label:"buttons.save",icon:zn,trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.saveToActiveFile&&!!o.fileHandle&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{let r=!!o.fileHandle;try{let{fileHandle:i}=Rl(o.fileHandle)?await $x(e,o,n.files,n.getName()):await Ll(e,o,n.files,n.getName());return{captureUpdate:ro.EVENTUALLY,appState:{...o,fileHandle:i,toast:r?{message:i?.name?g("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):g("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:ro.EVENTUALLY}}},keyTest:e=>e.key===Kr.S&&e[Kr.CTRL_OR_CMD]&&!e.shiftKey}),Ia=B({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:zn,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,n)=>{try{let{fileHandle:r}=await Ll(e,{...o,fileHandle:null},n.files,n.getName());return{captureUpdate:ro.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:r,toast:{message:g("toast.fileSaved")}}}}catch(r){return r?.name!=="AbortError"?console.error(r):console.warn(r),{captureUpdate:ro.EVENTUALLY}}},keyTest:e=>e.key===Kr.S&&e.shiftKey&&e[Kr.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Ro(K,{type:"button",icon:V1,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:se().editor.isMobile,hidden:!fr,onClick:()=>e(null),"data-testid":"save-as-button"})}),Zr=B({name:"loadScene",label:"buttons.load",trackEvent:{category:"export"},predicate:(e,o,t,n)=>!!n.props.UIOptions.canvasActions.loadScene&&!o.viewModeEnabled,perform:async(e,o,t,n)=>{try{let{elements:r,appState:i,files:a}=await um(o,e);return{elements:r,appState:i,files:a,captureUpdate:ro.IMMEDIATELY}}catch(r){return r?.name==="AbortError"?(console.warn(r),!1):{elements:e,appState:{...o,errorMessage:r.message},files:n.files,captureUpdate:ro.EVENTUALLY}}},keyTest:e=>e[Kr.CTRL_OR_CMD]&&e.key===Kr.O}),qx=B({name:"exportWithDarkMode",label:"imageExportDialog.label.darkMode",trackEvent:{category:"export",action:"toggleTheme"},perform:(e,o,t)=>({appState:{...o,exportWithDarkMode:t},captureUpdate:ro.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>Ro("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Ro(Ax,{value:e.exportWithDarkMode?Wp.DARK:Wp.LIGHT,onChange:t=>{o(t===Wp.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as Lk,DEFAULT_FONT_FAMILY as Pk,DEFAULT_TEXT_ALIGN as Ak,CODES as Jx,KEYS as Qx,getLineHeight as Dk}from"@excalidraw/common";import{newElementWith as Ks}from"@excalidraw/element";import{hasBoundTextElement as _k,canApplyRoundnessTypeToElement as Rk,getDefaultRoundnessTypeForElement as Nk,isFrameLikeElement as Bk,isArrowElement as Fk,isExcalidrawElement as Ok,isTextElement as Kp}from"@excalidraw/element";import{getBoundTextElement as zk,redrawTextBoundingBox as Hk}from"@excalidraw/element";import{CaptureUpdateAction as Zp}from"@excalidraw/element";var eE="{}",$p=B({name:"copyStyles",label:"labels.copyStyles",icon:Um,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=[],i=e.find(a=>o.selectedElementIds[a.id]);if(r.push(i),i&&_k(i)){let a=zk(i,n.scene.getNonDeletedElementsMap());r.push(a)}return i&&(eE=JSON.stringify(r)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:Zp.EVENTUALLY}},keyTest:e=>e[Qx.CTRL_OR_CMD]&&e.altKey&&e.code===Jx.C}),jp=B({name:"pasteStyles",label:"labels.pasteStyles",icon:Um,trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=JSON.parse(eE),i=r[0],a=r[1];if(!Ok(i))return{elements:e,captureUpdate:Zp.EVENTUALLY};let l=j(e,o,{includeBoundTextElement:!0}),s=l.map(d=>d.id);return{elements:e.map(d=>{if(s.includes(d.id)){let m=i;if(Kp(d)&&d.containerId&&(m=a),!m)return d;let c=Ks(d,{backgroundColor:m?.backgroundColor,strokeWidth:m?.strokeWidth,strokeColor:m?.strokeColor,strokeStyle:m?.strokeStyle,fillStyle:m?.fillStyle,opacity:m?.opacity,roughness:m?.roughness,roundness:m.roundness?Rk(m.roundness.type,d)?m.roundness:Nk(d):null});if(Kp(c)){let p=m.fontSize||Lk,u=m.fontFamily||Pk;c=Ks(c,{fontSize:p,fontFamily:u,textAlign:m.textAlign||Ak,lineHeight:m.lineHeight||Dk(u)});let f=null;c.containerId&&(f=l.find(b=>Kp(c)&&b.id===c.containerId)||null),Hk(c,f,n.scene)}return c.type==="arrow"&&Fk(m)&&(c=Ks(c,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),Bk(d)&&(c=Ks(c,{roundness:null,backgroundColor:"transparent"})),c}return d}),captureUpdate:Zp.IMMEDIATELY}},keyTest:e=>e[Qx.CTRL_OR_CMD]&&e.altKey&&e.code===Jx.V});import{KEYS as Gk}from"@excalidraw/common";import{getNonDeletedElements as Uk}from"@excalidraw/element";import{showSelectedShapeActions as Yk}from"@excalidraw/element";import{CaptureUpdateAction as qp}from"@excalidraw/element";import{jsx as tE}from"react/jsx-runtime";var Wk=B({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:qp.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>tE(K,{type:"button",icon:Xl,"aria-label":g("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),Vk=B({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:qp.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>tE(K,{visible:Yk(o,Uk(e)),type:"button",icon:X1,"aria-label":g("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),jn=B({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:H1,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:n})=>(o.openDialog?.name==="help"&&n(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:qp.EVENTUALLY}),keyTest:e=>e.key===Gk.QUESTION_MARK});import{getNonDeletedElements as $s}from"@excalidraw/element";import{newElementWith as rE}from"@excalidraw/element";import{isBoundToContainer as Xk}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as Kk,getElementsInResizingFrame as Zk,getFrameLikeElements as $k,getRootElements as jk,groupByFrameLikes as qk,removeElementsFromFrame as Jk,replaceAllElementsInFrame as Qk}from"@excalidraw/element";import{KEYS as js,randomId as eM,arrayToMap as Jp,getShortcutKey as iE}from"@excalidraw/common";import{getSelectedGroupIds as Zs,selectGroup as tM,selectGroupsForSelectedElements as oM,getElementsInGroup as oE,addToGroup as nM,removeFromSelectedGroups as rM,isElementInGroup as aE}from"@excalidraw/element";import{syncMovedIndices as iM}from"@excalidraw/element";import{CaptureUpdateAction as Ca}from"@excalidraw/element";import{jsx as $r}from"react/jsx-runtime";var aM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((n,r)=>n&&aE(r,t),!0))return!0}return!1},nE=(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return n.length>=2&&!aM(n)&&!Kk(n)},Qp=B({name:"group",label:"labels.group",icon:e=>$r(Om,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=jk(n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(r.length<2)return{appState:o,elements:e,captureUpdate:Ca.EVENTUALLY};let i=Zs(o);if(i.length===1){let x=i[0],w=new Set(oE(e,x).map(v=>v.id)),E=new Set(r.map(v=>v.id));if(new Set([...Array.from(w),...Array.from(E)]).size===w.size)return{appState:o,elements:e,captureUpdate:Ca.EVENTUALLY}}let a=[...e];new Set(r.map(x=>x.frameId)).size>1&&qk(r).forEach((w,E)=>{Jk(w,n.scene.getNonDeletedElementsMap())});let s=eM(),d=Jp(r);a=a.map(x=>d.get(x.id)?rE(x,{groupIds:nM(x.groupIds,s,o.editingGroupId)}):x);let m=oE(a,s),c=m[m.length-1],p=a.lastIndexOf(c),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!aE(x,s)),b=iM([...f,...m,...u],Jp(m));return{appState:{...o,...tM(s,{...o,selectedGroupIds:{}},$s(a))},elements:b,captureUpdate:Ca.IMMEDIATELY}},predicate:(e,o,t,n)=>nE(e,o,n),keyTest:e=>!e.shiftKey&&e[js.CTRL_OR_CMD]&&e.key===js.G,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>$r(K,{hidden:!nE(e,o,n),type:"button",icon:$r(Om,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${iE("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:Ee($s(e),o)})}),eu=B({name:"ungroup",label:"labels.ungroup",icon:e=>$r(zm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=Zs(o),i=Jp(e);if(r.length===0)return{appState:o,elements:e,captureUpdate:Ca.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{Xk(p)&&l.push(p.id);let u=rM(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:rE(p,{groupIds:u})});let s=oM(o,$s(a),o,null),d=n.scene.getSelectedElements(o),m=new Set(d.filter(p=>p.frameId).map(p=>p.frameId));return $k(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=Qk(a,Zk(a,p,o,i),p,n))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,f])=>(f&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:Ca.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[js.CTRL_OR_CMD]&&e.key===js.G.toUpperCase(),predicate:(e,o)=>Zs(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>$r(K,{type:"button",hidden:Zs(o).length===0,icon:$r(zm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${iE("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:Ee($s(e),o)})});import uM from"clsx";import{CaptureUpdateAction as mE}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as lM,COLOR_VOICE_CALL as sM,COLOR_WHITE as Js,THEME as cM,UserIdleState as lE}from"@excalidraw/common";var qs=(e,o,t,n,r,i,a)=>{e.beginPath(),e.moveTo(o+i,t),e.lineTo(o+n-i,t),e.quadraticCurveTo(o+n,t,o+n,t+i),e.lineTo(o+n,t+r-i),e.quadraticCurveTo(o+n,t+r,o+n-i,t+r),e.lineTo(o+i,t+r),e.quadraticCurveTo(o,t+r,o,t+r-i),e.lineTo(o,t+i),e.quadraticCurveTo(o,t,o+i,t),e.closePath(),e.fill(),a&&(e.strokeStyle=a),e.stroke()};function dM(e){let o=0;if(e.length===0)return o;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);o=(o<<5)-o+n}return o}var qn=(e,o)=>`hsl(${Math.abs(dM(o?.id||e))%37*10}, 100%, 83%)`,sE=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},cE=({context:e,renderConfig:o,appState:t,normalizedWidth:n,normalizedHeight:r})=>{for(let[i,a]of o.remotePointerViewportCoords){let{x:l,y:s}=a,d=t.collaborators.get(i);l-=t.offsetLeft,s-=t.offsetTop;let m=11,c=14,p=l<0||l>n-m||s<0||s>r-c;l=Math.max(l,0),l=Math.min(l,n-m),s=Math.max(s,0),s=Math.min(s,r-c);let u=qn(i,d);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===lE.IDLE||f===lE.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===cM.DARK?"#2f6330":sM,w=d?.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=Js,e.strokeStyle=Js,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let E=o.remotePointerUsernames.get(i)||"";if(!p&&E){e.font="600 12px sans-serif";let y=(w?l+0:l)+m/2,v=(w?s+0:s)+c+2,C=5,S=3,L=e.measureText(E),k=L.actualBoundingBoxDescent+L.actualBoundingBoxAscent,A=Math.max(k,12),P=y-1,N=v-1,O=L.width+2+C*2+2,U=A+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,N,O,U,8),e.fillStyle=u,e.fill(),e.strokeStyle=Js,e.stroke(),w&&(e.beginPath(),e.roundRect(P-2,N-2,O+4,U+4,8),e.strokeStyle=x,e.stroke())):qs(e,P,N,O,U,8,Js),e.fillStyle=lM,e.fillText(E,y+C+1,v+S+L.actualBoundingBoxAscent+Math.floor((A-k)/2)+2),w){e.fillStyle=x;let J=8,_=8,R=5;e.fillRect(P+O+_,N+(U/2-J/2),2,J),e.fillRect(P+O+_+R,N+(U/2-J*2/2),2,J*2),e.fillRect(P+O+_+R*2,N+(U/2-J/2),2,J)}}e.restore(),e.closePath()}};import mM from"clsx";import{useState as pM}from"react";import{jsx as dE}from"react/jsx-runtime";var tu=({color:e,onClick:o,name:t,src:n,className:r})=>{let i=sE(t),[a,l]=pM(!1),s=!a&&n,d=s?void 0:{background:e};return dE("div",{className:mM("Avatar",r),style:d,onClick:o,children:s?dE("img",{className:"Avatar-img",src:n,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as Eo,jsxs as Qs}from"react/jsx-runtime";var hM=B({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:mE.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:mE.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:n,collaborator:r,withName:i,isBeingFollowed:a}=o,l=qn(n,r),s=uM({"is-followed":a,"is-current-user":r.isCurrentUser===!0,"is-speaking":r.isSpeaking,"is-in-call":r.isInCall,"is-muted":r.isMuted}),d=r.isInCall?r.isSpeaking?Qs("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[Eo("div",{}),Eo("div",{}),Eo("div",{})]}):r.isMuted?Eo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:q0}):Eo("div",{title:g("userList.hint.inCall"),children:j0}):null;return i?Qs("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(r),children:[Eo(tu,{color:l,onClick:()=>{},name:r.username||"",src:r.avatarUrl,className:s}),Eo("div",{className:"UserList__collaborator-name",children:r.username}),Qs("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&Eo("div",{className:"UserList__collaborator-status-icon-is-followed",title:g("userList.hint.followStatus"),children:Mr}),d]})]}):Qs("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[Eo(tu,{color:l,onClick:()=>{e(r)},name:r.username||"",src:r.avatarUrl,className:s}),d&&Eo("div",{className:"UserList__collaborator-status-icon",children:d})]})}});import{LIBRARY_DISABLED_TYPES as gM,randomId as fM}from"@excalidraw/common";import{deepCopyElement as bM}from"@excalidraw/element";import{CaptureUpdateAction as ou}from"@excalidraw/element";var nu=B({name:"addToLibrary",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});for(let i of gM)if(r.some(a=>a.type===i))return{captureUpdate:ou.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return n.library.getLatestLibrary().then(i=>n.library.setLibrary([{id:fM(),status:"unpublished",elements:r.map(bM),created:Date.now()},...i])).then(()=>({captureUpdate:ou.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:ou.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as jr}from"@excalidraw/element";import{isFrameLikeElement as xM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as EM}from"@excalidraw/element";import{KEYS as dn,arrayToMap as yM,getShortcutKey as ec}from"@excalidraw/common";import{alignElements as wM}from"@excalidraw/element";import{CaptureUpdateAction as qr}from"@excalidraw/element";import{getSelectedElementsByGroup as vM}from"@excalidraw/element";import{jsx as Qr}from"react/jsx-runtime";var vt=(e,o)=>{let t=o.scene.getSelectedElements(e);return vM(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(n=>xM(n))},Jr=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=wM(r,n,t.scene,o),a=yM(i);return EM(e.map(l=>a.get(l.id)||l),o,t)},TM=B({name:"alignTop",label:"labels.alignTop",icon:Dm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>vt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Jr(e,o,n,{position:"start",axis:"y"}),captureUpdate:qr.IMMEDIATELY}),keyTest:e=>e[dn.CTRL_OR_CMD]&&e.shiftKey&&e.key===dn.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Qr(K,{hidden:!vt(o,n),type:"button",icon:Dm,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${ec("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:Ee(jr(e),o)})}),IM=B({name:"alignBottom",label:"labels.alignBottom",icon:_m,trackEvent:{category:"element"},predicate:(e,o,t,n)=>vt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Jr(e,o,n,{position:"end",axis:"y"}),captureUpdate:qr.IMMEDIATELY}),keyTest:e=>e[dn.CTRL_OR_CMD]&&e.shiftKey&&e.key===dn.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Qr(K,{hidden:!vt(o,n),type:"button",icon:_m,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${ec("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:Ee(jr(e),o)})}),CM=B({name:"alignLeft",label:"labels.alignLeft",icon:Rm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>vt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Jr(e,o,n,{position:"start",axis:"x"}),captureUpdate:qr.IMMEDIATELY}),keyTest:e=>e[dn.CTRL_OR_CMD]&&e.shiftKey&&e.key===dn.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Qr(K,{hidden:!vt(o,n),type:"button",icon:Rm,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${ec("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:Ee(jr(e),o)})}),SM=B({name:"alignRight",label:"labels.alignRight",icon:Nm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>vt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Jr(e,o,n,{position:"end",axis:"x"}),captureUpdate:qr.IMMEDIATELY}),keyTest:e=>e[dn.CTRL_OR_CMD]&&e.shiftKey&&e.key===dn.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Qr(K,{hidden:!vt(o,n),type:"button",icon:Nm,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${ec("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:Ee(jr(e),o)})}),kM=B({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Bm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>vt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Jr(e,o,n,{position:"center",axis:"y"}),captureUpdate:qr.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Qr(K,{hidden:!vt(o,n),type:"button",icon:Bm,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:Ee(jr(e),o)})}),MM=B({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Fm,trackEvent:{category:"element"},predicate:(e,o,t,n)=>vt(o,n),perform:(e,o,t,n)=>({appState:o,elements:Jr(e,o,n,{position:"center",axis:"x"}),captureUpdate:qr.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>Qr(K,{hidden:!vt(o,n),type:"button",icon:Fm,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:Ee(jr(e),o)})});import{getNonDeletedElements as pE}from"@excalidraw/element";import{isFrameLikeElement as LM}from"@excalidraw/element";import{CODES as uE,KEYS as hE,arrayToMap as PM,getShortcutKey as gE}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as AM}from"@excalidraw/element";import{distributeElements as DM}from"@excalidraw/element";import{CaptureUpdateAction as fE}from"@excalidraw/element";import{getSelectedElementsByGroup as _M}from"@excalidraw/element";import{jsx as EE}from"react/jsx-runtime";var bE=(e,o)=>{let t=o.scene.getSelectedElements(e);return _M(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(n=>LM(n))},xE=(e,o,t,n)=>{let r=t.scene.getSelectedElements(o),i=DM(r,t.scene.getNonDeletedElementsMap(),n,o),a=PM(i);return AM(e.map(l=>a.get(l.id)||l),o,t)},RM=B({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:xE(e,o,n,{space:"between",axis:"x"}),captureUpdate:fE.IMMEDIATELY}),keyTest:e=>!e[hE.CTRL_OR_CMD]&&e.altKey&&e.code===uE.H,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>EE(K,{hidden:!bE(o,n),type:"button",icon:e0,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${gE("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:Ee(pE(e),o)})}),NM=B({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,n)=>({appState:o,elements:xE(e,o,n,{space:"between",axis:"y"}),captureUpdate:fE.IMMEDIATELY}),keyTest:e=>!e[hE.CTRL_OR_CMD]&&e.altKey&&e.code===uE.V,PanelComponent:({elements:e,appState:o,updateData:t,app:n})=>EE(K,{hidden:!bE(o,n),type:"button",icon:t0,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${gE("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:Ee(pE(e),o)})});import{getNonDeletedElements as BM}from"@excalidraw/element";import{bindOrUnbindLinearElements as FM,isBindingEnabled as OM}from"@excalidraw/element";import{getCommonBoundingBox as yE}from"@excalidraw/element";import{newElementWith as zM}from"@excalidraw/element";import{deepCopyElement as HM}from"@excalidraw/element";import{resizeMultipleElements as GM}from"@excalidraw/element";import{isArrowElement as UM,isElbowArrow as YM,isLinearElement as WM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as wE}from"@excalidraw/element";import{CODES as vE,KEYS as VM,arrayToMap as XM}from"@excalidraw/common";import{CaptureUpdateAction as TE}from"@excalidraw/element";var ru=B({name:"flipHorizontal",label:"labels.flipHorizontal",icon:tb,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:wE(IE(e,n.scene.getNonDeletedElementsMap(),o,"horizontal",n),o,n),appState:o,captureUpdate:TE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===vE.H}),iu=B({name:"flipVertical",label:"labels.flipVertical",icon:eb,trackEvent:{category:"element"},perform:(e,o,t,n)=>({elements:wE(IE(e,n.scene.getNonDeletedElementsMap(),o,"vertical",n),o,n),appState:o,captureUpdate:TE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===vE.V&&!e[VM.CTRL_OR_CMD]}),IE=(e,o,t,n,r)=>{let i=j(BM(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=KM(i,o,t,n,r),l=XM(a);return e.map(s=>l.get(s.id)||s)},KM=(e,o,t,n,r)=>{if(e.every(u=>UM(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return zM(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=yE(e);GM(e,o,"nw",r.scene,new Map(Array.from(o.values()).map(u=>[u.id,HM(u)])),{flipByX:n==="horizontal",flipByY:n==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),FM(e.filter(WM),OM(t),[],r.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>YM(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:d,midY:m}=yE(e),[c,p]=[i-d,a-m];return s.forEach(u=>r.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),l.forEach(u=>r.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),e};import{isTextElement as ZM}from"@excalidraw/element";import{getTextFromElements as $M}from"@excalidraw/element";import{CODES as jM,KEYS as CE,isFirefox as qM}from"@excalidraw/common";import{CaptureUpdateAction as _t}from"@excalidraw/element";var ei=B({name:"copy",label:"labels.copy",icon:$i,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Ys(r,n.files,t)}catch(i){return{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:_t.EVENTUALLY}},keyTest:void 0}),au=B({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r;try{r=await Kx()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),qM?{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{n.pasteFromClipboard(Vx({types:r}))}catch(i){return console.error(i),{captureUpdate:_t.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:_t.EVENTUALLY}},keyTest:void 0}),tc=B({name:"cut",label:"labels.cut",icon:z0,trackEvent:{category:"element"},perform:(e,o,t,n)=>(ei.perform(e,o,t,n),ra.perform(e,o,null,n)),keyTest:e=>e[CE.CTRL_OR_CMD]&&e.key===CE.X}),oc=B({name:"copyAsSvg",label:"labels.copyAsSvg",icon:ob,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:_t.EVENTUALLY};let{exportedElements:r,exportingFrame:i}=Kn(e,o,!0);try{await Zn("clipboard-svg",r,o,n.files,{...o,exportingFrame:i,name:n.getName()});let a=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});return{appState:{toast:{message:g("toast.copyToClipboardAsSvg",{exportSelection:a.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:_t.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:_t.EVENTUALLY}}},predicate:e=>Us&&e.length>0,keywords:["svg","clipboard","copy"]}),nc=B({name:"copyAsPng",label:"labels.copyAsPng",icon:nb,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{if(!n.canvas)return{captureUpdate:_t.EVENTUALLY};let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Kn(e,o,!0);try{return await Zn("clipboard",i,o,n.files,{...o,exportingFrame:a,name:n.getName()}),{appState:{...o,toast:{message:g("toast.copyToClipboardAsPng",{exportSelection:r.length?g("toast.selection"):g("toast.canvas"),exportColorScheme:o.exportWithDarkMode?g("buttons.darkMode"):g("buttons.lightMode")})}},captureUpdate:_t.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:_t.EVENTUALLY}}},predicate:e=>Xr&&e.length>0,keyTest:e=>e.code===jM.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),rc=B({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{no($M(r))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:_t.EVENTUALLY}},predicate:(e,o,t,n)=>Us&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(ZM),keywords:["text","clipboard","copy"]});import{CODES as JM,KEYS as QM}from"@excalidraw/common";import{CaptureUpdateAction as eL}from"@excalidraw/element";var ic=B({name:"gridMode",icon:sb,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:eL.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[QM.CTRL_OR_CMD]&&e.code===JM.QUOTE});import{CODES as tL,KEYS as oL}from"@excalidraw/common";import{CaptureUpdateAction as nL}from"@excalidraw/element";var ti=B({name:"zenMode",label:"buttons.zenMode",icon:ib,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:nL.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[oL.CTRL_OR_CMD]&&e.altKey&&e.code===tL.Z});import{CODES as rL,KEYS as iL}from"@excalidraw/common";import{CaptureUpdateAction as aL}from"@excalidraw/element";var lu=B({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:rb,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:aL.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[iL.CTRL_OR_CMD]&&e.altKey&&e.code===rL.S});import{CODES as lL,KEYS as sL}from"@excalidraw/common";import{CaptureUpdateAction as cL}from"@excalidraw/element";var oi=B({name:"stats",label:"stats.fullTitle",icon:Q0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:cL.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[sL.CTRL_OR_CMD]&&e.altKey&&e.code===lL.SLASH});import{BOUND_TEXT_PADDING as SE,ROUNDNESS as kE,TEXT_ALIGN as LE,VERTICAL_ALIGN as PE,arrayToMap as AE,getFontString as dL}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as mL,resetOriginalContainerCache as pL,updateOriginalContainerCache as uL}from"@excalidraw/element";import{computeBoundTextPosition as hL,computeContainerDimensionForBoundText as ME,getBoundTextElement as DE,redrawTextBoundingBox as _E}from"@excalidraw/element";import{hasBoundTextElement as gL,isArrowElement as fL,isTextBindableContainer as su,isTextElement as Sa,isUsingAdaptiveRadius as bL}from"@excalidraw/element";import{measureText as xL}from"@excalidraw/element";import{syncMovedIndices as RE}from"@excalidraw/element";import{newElement as EL}from"@excalidraw/element";import{CaptureUpdateAction as cu}from"@excalidraw/element";var du=B({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>n.scene.getSelectedElements(o).some(i=>gL(i)),perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=n.scene.getNonDeletedElementsMap();return r.forEach(a=>{let l=DE(a,i);if(l){let{width:s,height:d}=xL(l.originalText,dL(l),l.lineHeight),m=mL(a.id);pL(a.id);let{x:c,y:p}=hL(a,l,i);n.scene.mutateElement(l,{containerId:null,width:s,height:d,text:l.originalText,x:c,y:p}),n.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:cu.IMMEDIATELY}}}),mu=B({name:"bindText",label:"labels.bindText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);if(r.length===2){let i=Sa(r[0])||Sa(r[1]),a;if(su(r[0])?a=r[0]:su(r[1])&&(a=r[1]),i&&a&&DE(a,n.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i,a;Sa(r[0])&&su(r[1])?(i=r[0],a=r[1]):(i=r[1],a=r[0]),n.scene.mutateElement(i,{containerId:a.id,verticalAlign:PE.MIDDLE,textAlign:LE.CENTER,autoResize:!0,angle:fL(a)?0:a?.angle??0}),n.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return _E(i,a,n.scene),uL(a.id,l),{elements:yL(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:cu.IMMEDIATELY}}}),yL=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===t.id);n.splice(r,1);let i=n.findIndex(a=>a.id===o.id);return n.splice(i+1,0,t),RE(n,AE([o,t])),n},wL=(e,o,t)=>{let n=e.slice(),r=n.findIndex(a=>a.id===o.id);n.splice(r,1);let i=n.findIndex(a=>a.id===t.id);return n.splice(i,0,o),RE(n,AE([o,t])),n},NE=B({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=r.some(a=>Sa(a));return r.length>0&&i},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of r)if(Sa(l)){let s=EL({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:bL("rectangle")?kE.ADAPTIVE_RADIUS:kE.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-SE,y:l.y-SE,width:ME(l.width,"rectangle"),height:ME(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let d=l.boundElements.filter(c=>c.type==="arrow").map(c=>c.id);i.filter(c=>d.includes(c.id)).forEach(c=>{let p=c.startBinding,u=c.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&n.scene.mutateElement(c,{startBinding:p,endBinding:u})})}n.scene.mutateElement(l,{containerId:s.id,verticalAlign:PE.MIDDLE,boundElements:null,textAlign:LE.CENTER,autoResize:!0}),_E(l,s,n.scene),i=wL([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:cu.IMMEDIATELY}}});import{isEmbeddableElement as OL}from"@excalidraw/element";import{KEYS as VE,getShortcutKey as zL}from"@excalidraw/common";import{CaptureUpdateAction as HL}from"@excalidraw/element";import{pointFrom as zE}from"@excalidraw/math";import vL from"clsx";import{useCallback as BE,useEffect as FE,useLayoutEffect as TL,useRef as IL,useState as CL}from"react";import{EVENT as pu,HYPERLINK_TOOLTIP_DELAY as SL,KEYS as ac}from"@excalidraw/common";import{getElementAbsoluteCoords as bu}from"@excalidraw/element";import{hitElementBoundingBox as kL}from"@excalidraw/element";import{isElementLink as ML}from"@excalidraw/element";import{getEmbedLink as LL,embeddableURLValidator as PL}from"@excalidraw/element";import{sceneCoordsToViewportCoords as HE,viewportCoordsToSceneCoords as AL,wrapEvent as DL,isLocalLink as _L,normalizeLink as uu}from"@excalidraw/common";import{isEmbeddableElement as hu}from"@excalidraw/element";import{jsx as ni,jsxs as OE}from"react/jsx-runtime";var xu=380,RL=42,gu=5,GE=85,NL=500,fu=!1,lc=new Map,UE=({element:e,scene:o,setAppState:t,onLinkOpen:n,setToast:r,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=go(),s=fo(),d=se(),m=e.link||"",[c,p]=CL(m),u=IL(null),f=l.showHyperlinkPopup==="editor",b=BE(()=>{if(!u.current)return;let v=uu(u.current.value)||null;if(!e.link&&v&&ne("hyperlink","create"),hu(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!PL(v,s.validateEmbeddable))v&&r({message:g("toast.unableToEmbed"),closable:!0}),e.link&&lc.set(e.id,e.link),o.mutateElement(e,{link:v}),i(e,!1);else{let{width:C,height:S}=e,L=LL(v);L?.error instanceof URIError&&r({message:g("toast.unrecognizedLinkFormat"),closable:!0});let k=L?L.intrinsicSize.w/L.intrinsicSize.h:1,A=lc.get(e.id)!==e.link;o.mutateElement(e,{...A?{width:L?.type==="video"?C>S?C:S*k:C,height:L?.type==="video"&&C>S?C/k:S}:{},link:v}),i(e,!0),lc.has(e.id)&&lc.delete(e.id)}}else o.mutateElement(e,{link:v})},[e,o,r,s.validateEmbeddable,l.activeEmbeddable,t,i]);TL(()=>()=>{b()},[b]),FE(()=>{f&&u?.current&&!(d.viewport.isMobile||d.isTouchScreen)&&u.current.select()},[f,d.viewport.isMobile,d.isTouchScreen]),FE(()=>{let v=null,C=S=>{if(f)return;v&&clearTimeout(v),FL(e,a,l,zE(S.clientX,S.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},NL))};return window.addEventListener(pu.POINTER_MOVE,C,!1),()=>{window.removeEventListener(pu.POINTER_MOVE,C,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=BE(()=>{ne("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),w=()=>{ne("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y}=YE(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:OE("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${E}px`,width:xu,padding:gu},children:[f?ni("input",{className:vL("excalidraw-hyperlinkContainer-input"),placeholder:g("labels.link.hint"),ref:u,value:c,onChange:v=>p(v.target.value),autoFocus:!0,onKeyDown:v=>{v.stopPropagation(),v[ac.CTRL_OR_CMD]&&v.key===ac.K&&v.preventDefault(),(v.key===ac.ENTER||v.key===ac.ESCAPE)&&(b(),t({showHyperlinkPopup:"info"}))}}):e.link?ni("a",{href:uu(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:_L(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&n){let C=DL(pu.EXCALIDRAW_LINK,v.nativeEvent);n({...e,link:uu(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):ni("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),OE("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&ni(K,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:Jo}),ni(K,{type:"button",title:g("labels.linkToElement"),"aria-label":g("labels.linkToElement"),label:g("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:ls}),m&&!hu(e)&&ni(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:Lt})]})]})},YE=(e,o,t)=>{let[n,r]=bu(e,t),{x:i,y:a}=HE({sceneX:n+e.width/2,sceneY:r},o),l=i-o.offsetLeft-xu/2,s=a-o.offsetTop-GE;return{x:l,y:s}},Eu=(e,o)=>{let t=j(e,o);return hu(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},ka=null,WE=(e,o,t)=>{ka&&clearTimeout(ka),ka=window.setTimeout(()=>BL(e,o,t),SL)},BL=(e,o,t)=>{if(!e.link)return;let n=Yr();n.classList.add("excalidraw-tooltip--visible"),n.style.maxWidth="20rem",n.textContent=ML(e.link)?g("labels.link.goToElement"):e.link;let[r,i,a,l]=bu(e,t),[s,d,m,c]=o1([r,i,a,l],e.angle,o),p=HE({sceneX:s,sceneY:d},o);Ap(n,{left:p.x,top:p.y,width:m,height:c},"top"),ne("hyperlink","tooltip","link-icon"),fu=!0},yu=()=>{ka&&clearTimeout(ka),fu&&(fu=!1,Yr().classList.remove("excalidraw-tooltip--visible"))},FL=(e,o,t,[n,r])=>{let{x:i,y:a}=AL({clientX:n,clientY:r},t),l=15/t.zoom.value;if(kL(zE(i,a),e,o))return!1;let[s,d,m]=bu(e,o);if(i>=s&&i<=m&&a>=d-GE&&a<=d)return!1;let{x:c,y:p}=YE(e,t,o);return!(n>=c-l&&n<=c+xu+gu*2+l&&r>=p-l&&r<=p+l+gu*2+RL)};import{jsx as GL}from"react/jsx-runtime";var Ma=B({name:"hyperlink",label:(e,o)=>Eu(e,o),icon:Ji,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:HL.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[VE.CTRL_OR_CMD]&&e.key===VE.K,predicate:(e,o)=>j(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=j(e,o);return GL(K,{type:"button",icon:Ji,"aria-label":g(Eu(e,o)),title:`${OL(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${zL("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:n.length===1&&!!n[0].link})}});import{KEYS as XE,arrayToMap as vu,randomId as UL}from"@excalidraw/common";import{elementsAreInSameGroup as YL,newElementWith as KE,selectGroupsFromGivenElements as ZE}from"@excalidraw/element";import{CaptureUpdateAction as $E}from"@excalidraw/element";var wu=e=>e.every(o=>!o.locked),La=B({name:"toggleElementLock",label:(e,o,t)=>{let n=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return wu(n)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=j(o,e);return wu(t)?vr:On},trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return r.length>0&&!r.some(i=>i.locked&&i.frameId)},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});if(!r.length)return!1;let i=wu(r),a=vu(r),l=r.length>1&&YL(r),d=r.length===1||l?null:UL(),m={...o.lockedMultiSelections};if(i)m={...o.lockedMultiSelections,...d?{[d]:!0}:{}};else if(l){let w=r[0].groupIds.at(-1);delete m[w]}let c=e.map(w=>{if(!a.has(w.id))return w;let E=w.groupIds;return i?d&&(E=[...E,d]):E=E.filter(y=>!o.lockedMultiSelections[y]),KE(w,{locked:i,groupIds:E.length!==w.groupIds.length?E:w.groupIds})}),p=vu(c),u=i?{}:Object.fromEntries(r.map(w=>[w.id,!0])),f=r.map(w=>p.get(w.id)||w),b=i?{}:ZE(f,o),x=i?d||(l?r[0].groupIds.at(-1):r[0].id):null;return{elements:c,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:x},captureUpdate:$E.IMMEDIATELY}},keyTest:(e,o,t,n)=>e.key.toLocaleLowerCase()===XE.L&&e[XE.CTRL_OR_CMD]&&e.shiftKey&&n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),jE=B({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:On,predicate:(e,o)=>j(e,o).length===0&&e.some(n=>n.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),n=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return KE(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),r=vu(n),i=t.map(a=>r.get(a.id)||a);return{elements:n,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:ZE(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:$E.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as rD,isLinearElement as iD,isLineElement as wi}from"@excalidraw/element";import{arrayToMap as aD,invariant as Ih}from"@excalidraw/common";import{toggleLinePolygonState as lD,CaptureUpdateAction as j2}from"@excalidraw/element";import v2 from"clsx";import Q8 from"fuzzy";import{useEffect as Rc,useRef as e7,useState as _c}from"react";import{DEFAULT_SIDEBAR as y2,EVENT as Bc,KEYS as ao,capitalizeString as t7,getShortcutKey as o7,isWritableElement as n7}from"@excalidraw/common";import{CaptureUpdateAction as CP}from"@excalidraw/element";import{useEffect as Da,useMemo as qE,useRef as Su,useState as WL}from"react";import{getLinearElementSubType as ai,updateElbowArrowPoints as VL}from"@excalidraw/element";import{pointFrom as cc,pointRotateRads as XL}from"@excalidraw/math";import{hasBoundTextElement as KL,isArrowBoundToElement as ZL,isArrowElement as $L,isElbowArrow as jL,isLinearElement as Pu,isUsingAdaptiveRadius as qL}from"@excalidraw/element";import{getCommonBoundingBox as JL,getElementAbsoluteCoords as QL}from"@excalidraw/element";import{getBoundTextElement as oy,getBoundTextMaxHeight as eP,getBoundTextMaxWidth as tP,redrawTextBoundingBox as oP}from"@excalidraw/element";import{wrapText as nP}from"@excalidraw/element";import{assertNever as rP,CLASSES as iP,getFontString as Tu,isProdEnv as aP,mapFind as lP,reduceToCommonValue as sP,updateActiveTool as JE}from"@excalidraw/common";import{measureText as QE}from"@excalidraw/element";import{LinearElementEditor as cP}from"@excalidraw/element";import{newArrowElement as Iu,newElement as dP,newLinearElement as mP}from"@excalidraw/element";import{ShapeCache as pP}from"@excalidraw/element";import{updateBindings as uP}from"@excalidraw/element";import{jsx as Lu}from"react/jsx-runtime";var hP=8,gP=10,Pa=["rectangle","diamond","ellipse"],Aa=["line","sharpArrow","curvedArrow","elbowArrow"],fP=new Set(Pa),bP=new Set(Aa),li=e=>fP.has(e),mc=e=>e==="arrow"||bP.has(e),io=me(null),_a=new Map,Ra=new Map,xP=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Su(null);return Da(()=>{if(o.length===0){e.updateEditorAtom(io,null);return}let n=si(o);n&&!t.current?t.current=n:(t.current&&!n||t.current&&n!==t.current)&&(e.updateEditorAtom(io,null),t.current=null)},[o,e]),Da(()=>()=>{_a.clear(),Ra.clear()},[]),Lu(EP,{app:e,elements:o})},EP=({app:e,elements:o})=>{let t=si(o),n=qE(()=>t==="generic"?ry(o):[],[t,o]),r=qE(()=>t==="linear"?Mu(o):[],[t,o]),i=t==="generic"?n.every(c=>c.type===n[0].type):t==="linear"?r.every(c=>ai(c)===ai(r[0])):!1,[a,l]=WL({x:0,y:0}),s=Su(""),d=Su(null);Da(()=>{let c=[...n,...r].sort((x,w)=>x.id.localeCompare(w.id)),p=`
8
+ ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${c.map(x=>x.id).join(",")}`;if(p===s.current)return;s.current=p;let u;if(c.length===1){let[x,,,w,E,y]=QL(c[0],e.scene.getNonDeletedElementsMap());u=XL(cc(x,w),cc(E,y),c[0].angle)}else{let{minX:x,maxY:w}=JL(c);u=cc(x,w)}let{x:f,y:b}=ay({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[n,r,e.scene,e.state]),Da(()=>{for(let c of r){let p=ku(c.id,IP(c));Ra.has(p)||Ra.set(p,c)}},[r]),Da(()=>{for(let c of n)if(!_a.has(c.id)){let p=oy(c,e.scene.getNonDeletedElementsMap());p&&_a.set(c.id,{fontSize:p.fontSize})}},[n,e.scene]);let m=t==="linear"?[["line",Vl],["sharpArrow",ns],["curvedArrow",is],["elbowArrow",rs]]:t==="generic"?[["rectangle",Ul],["diamond",Yl],["ellipse",Wl]]:[];return Lu("div",{ref:d,tabIndex:-1,style:{position:"absolute",top:`${a.y+(gP+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-hP}px`,zIndex:2},className:iP.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([c,p])=>{let u=i&&(t==="generic"&&n[0].type===c||t==="linear"&&ai(r[0])===c);return Lu(K,{className:"Shape",type:"radio",icon:p,checked:u,name:"convertElementType-option",title:c,keyBindingLabel:"","aria-label":c,"data-testid":`toolbar-${c}`,onChange:()=>{e.state.activeTool.type!==c&&ne("convertElementType",c,"ui"),Au(e,{conversionType:t,nextType:c}),d.current?.focus()}},`${o[0].id}${o[0].version}_${c}`)})})},yP=(e,o,t)=>{let n=tP(e,o),r=eP(e,o),i=nP(o.text,Tu(o),n),a=QE(i,Tu(o),o.lineHeight),l=o.fontSize;for(;(a.width>n||a.height>r)&&l>0;){l-=1;let s={...o,fontSize:l};a=QE(o.text,Tu(s),o.lineHeight)}pc(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),oP(o,e,t)},Au=(e,{conversionType:o,nextType:t,direction:n="right"})=>{if(!o)return!1;let r=e.scene.getSelectedElements(e.state),i=r.reduce((l,s)=>({...l,[s.id]:!0}),{}),a=n==="right"?1:-1;if(o==="generic"){let l=ry(r),d=l.every(m=>m.type===l[0].type)?Pa.indexOf(l[0].type):-1;if(t=t??Pa[(d+Pa.length+a)%Pa.length],t&&li(t)){let m={};for(let p of l){let u=ty(p,t,e);m[u.id]=u}let c=[];for(let p of e.scene.getElementsIncludingDeleted())m[p.id]?c.push(m[p.id]):c.push(p);e.scene.replaceAllElements(c);for(let p of Object.values(m)){let u=oy(p,e.scene.getNonDeletedElementsMap());u&&(_a.get(p.id)&&pc(u,e.scene.getNonDeletedElementsMap(),{fontSize:_a.get(p.id)?.fontSize??u.fontSize}),yP(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:JE(p,{type:"selection"})}))}}if(o==="linear"){let l=Mu(r);if(!t){let d=sP(l,ai),m=d?Aa.indexOf(d):-1;t=Aa[(m+Aa.length+a)%Aa.length]}if(mc(t)){let d=[],m=e.scene.getElementsMapIncludingDeleted();for(let c of l){let p=Ra.get(ku(c.id,t));if(p&&ai(p)===t)m.set(p.id,p),d.push(p);else{let u=ty(c,t,e);m.set(u.id,u),d.push(u)}}e.scene.replaceAllElements(m);for(let c of d)if(Pu(c))if(jL(c)){let p=wP(c);if(p.length<2)continue;let u=[];for(let b=1;b<p.length-2;b++)u.push({start:p[b],end:p[b+1],index:b+1});let f=VL(c,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});pc(c,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=lP(["line","sharpArrow","curvedArrow"],u=>Ra.get(ku(c.id,u)));if(p){let u=p.points;e.scene.mutateElement(c,{points:u})}}}let s=Mu(e.scene.getSelectedElements(e.state));e.setState(d=>({selectedElementIds:i,selectedLinearElement:s.length===1?new cP(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:JE(d,{type:"selection"})}))}return!0},si=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(li(t.type))return"generic";ny(t)&&(o=!0)}return o?"linear":null},ny=e=>Pu(e)&&(!$L(e)||!ZL(e)&&!KL(e)),ku=(e,o)=>`${e}:${o}`,ry=e=>e.filter(o=>li(o.type)),Mu=e=>e.filter(o=>ny(o)),sc=20,ri=(e,o)=>e[0]===o[0],Cu=(e,o)=>e[1]===o[1],ey=(e,o)=>ri(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),wP=e=>{let o=[e.points[0]],t=vP(e.points);for(let i=1;i<t.length;++i){let a=o[o.length-1],l=[...t[i]];Math.abs(l[0]-a[0])<sc?l[0]=a[0]:Math.abs(l[1]-a[1])<sc&&(l[1]=a[1]),ri(a,l)||Cu(a,l)||o.push(cc(a[0],l[1])),o.push(l)}let n=[o[0]];for(let i=1;i<o.length-1;++i)ri(o[i-1],o[i])&&ri(o[i],o[i+1])||Cu(o[i-1],o[i])&&Cu(o[i],o[i+1])||n.push(o[i]);n.push(o[o.length-1]);let r=[n[0]];for(let i=1;i<n.length-1;++i){let a=r[r.length-1],l=n[i],s=n[i+1],d=ri(a,l),m=ri(l,s);if(d!==m){let c=ey(a,l),p=ey(l,s);if(c<sc||p<sc){if(p<c)d?s[0]=a[0]:s[1]=a[1];else if(m)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},vP=e=>{if(e.length===0)return[];let o=[e[0]];for(let t=1;t<e.length;t++){let[n,r]=o[o.length-1],[i,a]=e[t];(n!==i||r!==a)&&o.push(e[t])}return o},ty=(e,o,t)=>{if(!TP(e.type,o)){if(!aP())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(pP.delete(e),li(o)){let n=ii(dP({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:qL(o)?dc.ADAPTIVE_RADIUS:dc.PROPORTIONAL_RADIUS}:e.roundness}));return uP(n,t.scene),n}if(mc(o))switch(o){case"line":return ii(mP({...e,type:"line"}));case"sharpArrow":return ii(Iu({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return ii(Iu({...e,type:"arrow",elbowed:!1,roundness:{type:dc.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return ii(Iu({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return rP(o,`unhandled conversion type: ${o}`),e},TP=(e,o)=>!!(li(e)&&li(o)||mc(e)&&mc(o)),IP=e=>Pu(e)?ai(e):e.type,iy=xP;var ly=B({name:"toggleShapeSwitch",label:"labels.shapeSwitch",icon:()=>null,viewMode:!0,trackEvent:{category:"shape_switch",action:"toggle"},keywords:["change","switch","swap"],perform(e,o,t,n){return He.set(io,{type:"panel"}),{captureUpdate:CP.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>si(e)!==null});import{canCreateLinkFromElements as Du,defaultGetElementLinkFromSelection as SP,getLinkIdAndTypeFromSelection as kP}from"@excalidraw/element";import{CaptureUpdateAction as Na}from"@excalidraw/element";var uc=B({name:"copyElementLink",label:"labels.copyElementLink",icon:Sr,trackEvent:{category:"element"},perform:async(e,o,t,n)=>{let r=j(e,o);try{if(window.location){let i=kP(r,o);return i?(await no(n.props.generateLinkForSelection?n.props.generateLinkForSelection(i.id,i.type):SP(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:Na.EVENTUALLY}):{appState:o,elements:e,app:n,captureUpdate:Na.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:n,captureUpdate:Na.EVENTUALLY}},predicate:(e,o)=>Du(j(e,o))}),sy=B({name:"linkToElement",label:"labels.linkToElement",icon:ls,perform:(e,o,t,n)=>{let r=j(e,o);return r.length!==1||!Du(r)?{elements:e,appState:o,app:n,captureUpdate:Na.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:j(e,o)[0].id}},captureUpdate:Na.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=j(e,o);return o.openDialog?.name!=="elementLinkSelector"&&r.length===1&&Du(r)},trackEvent:!1});import{isDarwin as cy,getShortcutKey as oe}from"@excalidraw/common";var MP={toggleTheme:[oe("Shift+Alt+D")],saveScene:[oe("CtrlOrCmd+S")],loadScene:[oe("CtrlOrCmd+O")],clearCanvas:[oe("CtrlOrCmd+Delete")],imageExport:[oe("CtrlOrCmd+Shift+E")],commandPalette:[oe("CtrlOrCmd+/"),oe("CtrlOrCmd+Shift+P")],cut:[oe("CtrlOrCmd+X")],copy:[oe("CtrlOrCmd+C")],paste:[oe("CtrlOrCmd+V")],copyStyles:[oe("CtrlOrCmd+Alt+C")],pasteStyles:[oe("CtrlOrCmd+Alt+V")],selectAll:[oe("CtrlOrCmd+A")],deleteSelectedElements:[oe("Delete")],duplicateSelection:[oe("CtrlOrCmd+D"),oe(`Alt+${g("helpDialog.drag")}`)],sendBackward:[oe("CtrlOrCmd+[")],bringForward:[oe("CtrlOrCmd+]")],sendToBack:[cy?oe("CtrlOrCmd+Alt+["):oe("CtrlOrCmd+Shift+[")],bringToFront:[cy?oe("CtrlOrCmd+Alt+]"):oe("CtrlOrCmd+Shift+]")],copyAsPng:[oe("Shift+Alt+C")],group:[oe("CtrlOrCmd+G")],ungroup:[oe("CtrlOrCmd+Shift+G")],gridMode:[oe("CtrlOrCmd+'")],zenMode:[oe("Alt+Z")],objectsSnapMode:[oe("Alt+S")],stats:[oe("Alt+/")],addToLibrary:[],flipHorizontal:[oe("Shift+H")],flipVertical:[oe("Shift+V")],viewMode:[oe("Alt+R")],hyperlink:[oe("CtrlOrCmd+K")],toggleElementLock:[oe("CtrlOrCmd+Shift+L")],resetZoom:[oe("CtrlOrCmd+0")],zoomOut:[oe("CtrlOrCmd+-")],zoomIn:[oe("CtrlOrCmd++")],zoomToFitSelection:[oe("Shift+3")],zoomToFit:[oe("Shift+1")],zoomToFitSelectionInViewport:[oe("Shift+2")],toggleEraserTool:[oe("E")],toggleHandTool:[oe("H")],setFrameAsActiveTool:[oe("F")],saveFileToDisk:[oe("CtrlOrCmd+S")],saveToActiveFile:[oe("CtrlOrCmd+S")],toggleShortcuts:[oe("?")],searchMenu:[oe("CtrlOrCmd+F")],wrapSelectionInFrame:[]},Ne=(e,o=0)=>{let t=MP[e];return t&&t.length>0?t[o]||t[0]:""};var LP="\\u0300-\\u036f",PP="\\ufe20-\\ufe2f",AP="\\u20d0-\\u20ff",DP=LP+PP+AP,_P=`[${DP}]`,RP=RegExp(_P,"g"),NP=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,BP={\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"},_u=e=>e.replace(NP,o=>BP[o]||o).replace(RP,"");import C8 from"clsx";import{useEffect as S8,useState as k8}from"react";import{KEYS as M8,queryFocusableElements as l2}from"@excalidraw/common";import{useCallback as FP,useState as OP}from"react";var dy=()=>{let[e,o]=OP(null),t=FP(n=>o(n),[]);return[e,t]};import{useState as t2,useCallback as $u,useMemo as o2,useEffect as Jy,memo as n2,useRef as h8}from"react";import{LIBRARY_DISABLED_TYPES as g8,randomId as f8,isShallowEqual as b8}from"@excalidraw/common";import{useEffect as hy,useRef as gy}from"react";import{URL_HASH_KEYS as Bu,URL_QUERY_KEYS as Fu,APP_NAME as fy,EVENT as gc,DEFAULT_SIDEBAR as YP,LIBRARY_SIDEBAR_TAB as WP,arrayToMap as Ou,cloneJSON as VP,preventUnload as XP,promiseTry as by,resolvablePromise as KP,toValidURL as ZP,Queue as $P,Emitter as jP}from"@excalidraw/common";import{hashElementsVersion as qP,hashString as JP}from"@excalidraw/element";import{getCommonBoundingBox as Nu}from"@excalidraw/element";import{MIME_TYPES as Jn}from"@excalidraw/common";var mn=({elements:e,appState:o,files:t,maxWidthOrHeight:n,getDimensions:r,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=xr({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),{exportBackground:d,viewBackgroundColor:m}=s;return _l(l,{...s,offsetTop:0,offsetLeft:0,width:0,height:0},t||{},{exportBackground:d,exportPadding:i,viewBackgroundColor:m,exportingFrame:a},(c,p)=>{let u=document.createElement("canvas");if(n){typeof r=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(c,p),x=n<b?n/b:o?.exportScale??1;return u.width=c*x,u.height=p*x,{canvas:u,scale:x}}let f=r?.(c,p)||{width:c,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},my=async e=>{let{mimeType:o=Jn.png,quality:t}=e;o===Jn.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${Jn.png}" mimeType`),o==="image/jpg"&&(o=Jn.jpg),o===Jn.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${Jn.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let n=await mn(e);return t=t||(/image\/jpe?g/.test(o)?.92:.8),new Promise((r,i)=>{n.toBlob(async a=>{if(!a)return i(new Error("couldn't export to blob"));a&&o===Jn.png&&e.appState?.exportEmbedScene&&(a=await m1({blob:a,metadata:Wi(e.elements,e.appState,e.files||{},"local")})),r(a)},o,t)})},ci=async({elements:e,appState:o=jo(),files:t={},exportPadding:n,renderEmbeddables:r,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:d}=xr({elements:e,appState:o},null,null,{deleteInvisibleElements:!0}),m={...d,exportPadding:n};return br(s,m,t,{exportingFrame:i,renderEmbeddables:r,skipInliningFonts:a,reuseImages:l})},zP=async e=>{if(e.type==="svg"){let o=await ci(e);await no(o.outerHTML)}else if(e.type==="png")await Vs(my(e));else if(e.type==="json")await Ys(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as HP,useState as GP}from"react";import{COLOR_PALETTE as UP}from"@excalidraw/common";var Ru=me(new Map),py=async e=>await ci({elements:e,appState:{exportBackground:!1,viewBackgroundColor:UP.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),uy=(e,o,t)=>{let[n,r]=GP();return HP(()=>{if(o)if(e){let i=t.get(e);i?r(i):(async()=>{let a=await py(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),r(a))})()}else(async()=>{let i=await py(o);r(i)})()},[e,o,t,r]),n},hc=()=>{let[e]=ie(Ru);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:n=>{n.forEach(r=>e.delete(r))},svgCache:e}};var QP=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],Ey=new jP,Qn=me({status:"loaded",isInitialized:!1,libraryItems:[]}),Ba=e=>VP(e),eA=(e,o)=>!e.find(t=>t.elements.length!==o.elements.length?!1:t.elements.every((n,r)=>n.id===o.elements[r].id&&n.versionNonce===o.elements[r].versionNonce)),yy=(e,o)=>{let t=[];for(let n of o)eA(e,n)&&t.push(n);return[...t,...e]},wy=(e,o)=>{let t=Ou(o),n={deletedItems:new Map,addedItems:new Map};for(let i of e)t.has(i.id)||n.deletedItems.set(i.id,i);let r=Ou(e);for(let i of o)r.has(i.id)||n.addedItems.set(i.id,i);return n},zu=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",Ba(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)He.set(Qn,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{He.set(Qn,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Ba(this.currLibraryItems);let t=Ba(this.currLibraryItems);this.app.props.onLibraryChange?.(t),Ey.trigger(wy(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],He.set(Ru,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(Ba(t))}catch{return o(this.currLibraryItems)}}));I(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:n=!1,openLibraryMenu:r=!1,defaultStatus:i="unpublished"})=>(r&&this.app.setState({openSidebar:{name:YP.name,tab:WP}}),this.setLibrary(()=>new Promise(async(a,l)=>{try{let s=await(typeof o=="function"&&!(o instanceof Blob)?o(this.currLibraryItems):o),d;s instanceof Blob?d=await bm(s,i):d=Ki(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:d.length}))?(t&&this.app.focusContainer(),a(n?yy(this.currLibraryItems,d):d)):l(new gr)}catch(s){l(s)}}))));I(this,"setLibrary",o=>{let t=new Promise(async(n,r)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=Ba(await o),n(this.currLibraryItems)}catch(i){r(i)}}).catch(n=>{if(n.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw n}).finally(()=>{this.updateQueue=this.updateQueue.filter(n=>n!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},vy=zu,xc=e=>{let t=Math.ceil(Math.sqrt(e.length)),n=[],r=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:w}=Nu(x.elements);return Math.max(b,w)},0),i=u=>{let f=0,b=0,x=0;for(let w of e){if(f%t===0&&(b=0),b===u){let{width:E}=Nu(w.elements);x=Math.max(x,E)}f++,b++}return x},a=0,l=0,s=0,d=0,m=0,c=0,p=0;for(let u of e){m&&m%t===0&&(l+=s+50,a=0,c=0,p++),c===0&&(s=r(p)),d=i(c);let{minX:f,minY:b,width:x,height:w}=Nu(u.elements),E=(d-x)/2,y=(s-w)/2;n.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+y-b}))),a+=d+50,m++,c++}return n},tA=(e,o=QP)=>{if(typeof o=="function"?o(e):o.some(t=>{let n=new URL(`https://${t.replace(/^https?:\/\//,"")}`),{hostname:r,pathname:i}=new URL(e);return new RegExp(`(^|\\.)${n.hostname}$`).test(r)&&new RegExp(`^${n.pathname.replace(/\/+$/,"")}(/+|$)`).test(i)}))return!0;throw new Error(`Invalid or disallowed library URL: "${e}"`)},Hu=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Bu.addLibrary)||new URLSearchParams(window.location.search).get(Fu.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},pn=class pn{constructor(o){I(this,"adapter");this.adapter=o}static async getLibraryItems(o,t,n=!0){let r=()=>new Promise(async(i,a)=>{try{let l=await o.load({source:t});i(Ki(l?.libraryItems||[],"published"))}catch(l){a(l)}});return n?pn.queue.push(r):r()}getLibraryItems(o){return pn.getLibraryItems(this.adapter,o,!1)}};I(pn,"queue",new $P),I(pn,"run",async(o,t)=>{let n=new pn(o);return pn.queue.push(()=>t(n))});var di=pn,Fa=0,fc=0,bc=e=>JP(e.map(o=>`${o.id}:${qP(o.elements)}`).sort().join()),xy=async(e,o)=>{try{return fc++,await di.run(e,async t=>{let n=Ou(await t.getLibraryItems("save"));for(let[l]of o.deletedItems)n.delete(l);let r=[];for(let[l,s]of o.addedItems)n.has(l)?n.set(l,s):r.push(s);let i=r.concat(Array.from(n.values())),a=bc(i);return a!==Fa&&await e.save({libraryItems:i}),Fa=a,i})}finally{fc--}},oA=e=>{let{excalidrawAPI:o}=e,t=gy(e);t.current=e;let n=gy(!1);hy(()=>{if(!o)return;n.current=!1;let r=async({libraryUrl:l,idToken:s})=>{let d=new Promise(async(c,p)=>{try{l=decodeURIComponent(l),l=ZP(l),tA(l,t.current.validateLibraryUrl);let f=await(await fetch(l)).blob();c(f)}catch(u){p(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(c=>{window.addEventListener("focus",()=>c(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:d,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(c){throw o.updateScene({appState:{errorMessage:c.message}}),c}finally{if(window.location.hash.includes(Bu.addLibrary)){let c=new URLSearchParams(window.location.hash.slice(1));c.delete(Bu.addLibrary),window.history.replaceState({},fy,`#${c.toString()}`)}else if(window.location.search.includes(Fu.addLibrary)){let c=new URLSearchParams(window.location.search);c.delete(Fu.addLibrary),window.history.replaceState({},fy,`?${c.toString()}`)}}},i=l=>{l.preventDefault();let s=Hu();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),r(s))},a=Hu();if(a&&r(a),"getInitialLibraryItems"in t.current&&t.current.getInitialLibraryItems&&(console.warn("useHandleLibrar `opts.getInitialLibraryItems` is deprecated. Use `opts.adapter` instead."),Promise.resolve(t.current.getInitialLibraryItems()).then(l=>{o.updateLibrary({libraryItems:l,merge:!0})}).catch(l=>{console.error(`UseHandeLibrary getInitialLibraryItems failed: ${l?.message}`)})),"adapter"in t.current&&t.current.adapter){let l=t.current.adapter,s=t.current.migrationAdapter,d=KP();s?d.resolve(by(s.load).then(async m=>{let c=null;try{if(!m)return di.getLibraryItems(l,"load");c=Ki(m.libraryItems||[],"published");let p=await xy(l,wy([],c));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}`),c}}).catch(m=>(console.error(`error during library migration: ${m.message}`),di.getLibraryItems(l,"load")))):d.resolve(by(di.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:d.then(m=>{let c=m||[];return Fa=bc(c),c}),merge:!0}).finally(()=>{n.current=!0})}return window.addEventListener(gc.HASHCHANGE,i),()=>{window.removeEventListener(gc.HASHCHANGE,i)}},[o]),hy(()=>{let r=Ey.on(async(a,l)=>{let s=n.current,d="adapter"in t.current&&t.current.adapter||null;try{d&&Fa!==bc(l)&&await xy(d,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:g("errors.saveLibraryError")}})}}),i=a=>{fc&&XP(a)};return window.addEventListener(gc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(gc.BEFORE_UNLOAD,i),r(),Fa=0,fc=0}},[])};import aA from"clsx";import{VERSIONS as nA}from"@excalidraw/common";import{jsx as iA}from"react/jsx-runtime";var rA=({theme:e,id:o,libraryReturnUrl:t})=>{let n=t||window.location.origin+window.location.pathname;return iA("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${n}&useHash=true&token=${o}&theme=${e}&version=${nA.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},Ty=rA;import{jsx as lA,jsxs as sA}from"react/jsx-runtime";var Ec=({libraryReturnUrl:e,theme:o,id:t,style:n,children:r,className:i})=>sA("div",{className:aA("library-menu-control-buttons",i),style:n,children:[lA(Ty,{id:t,libraryReturnUrl:e,theme:o}),r]});import{useCallback as ui,useEffect as a8,useMemo as jy,useRef as l8,useState as s8}from"react";import{MIME_TYPES as c8,arrayToMap as d8}from"@excalidraw/common";import{duplicateElements as m8}from"@excalidraw/element";import cA from"lodash.throttle";import{useEffect as dA}from"react";var mA=me(0),Iy=e=>{let[o,t]=ie(mA);return dA(()=>{let{current:n}=e;if(!n)return;let r=cA(()=>{let{scrollTop:i}=n;t(i)},200);return n.addEventListener("scroll",r),()=>{r.cancel(),n.removeEventListener("scroll",r)}},[e,t]),o};import YA from"clsx";import{useCallback as WA,useState as Wu}from"react";import{muteFSAbortError as VA}from"@excalidraw/common";import{flushSync as Cy}from"react-dom";import pA from"clsx";import{jsx as yc,jsxs as hA}from"react/jsx-runtime";var uA=({label:e,onClick:o,className:t,children:n,actionType:r,type:i="button",isLoading:a,...l})=>{let s=r?`Dialog__action-button--${r}`:"";return hA("button",{className:pA("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[n&&yc("div",{style:a?{visibility:"hidden"}:{},children:n}),yc("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&yc("div",{style:{position:"absolute",inset:0},children:yc(tt,{})})]})},No=uA;import{jsx as Sy,jsxs as ky}from"react/jsx-runtime";var gA=e=>{let{onConfirm:o,onCancel:t,children:n,confirmText:r=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=le(),d=qo(mi),{container:m}=Ge();return ky(Be,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[n,ky("div",{className:"confirm-dialog-buttons",children:[Sy(No,{label:i,onClick:()=>{s({openMenu:null}),d(!1),Cy(()=>{t()}),m?.focus()}}),Sy(No,{label:r,onClick:()=>{s({openMenu:null}),d(!1),Cy(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},wc=gA;import Tc from"open-color";import{useCallback as vA,useEffect as Yu,useRef as My,useState as Gu}from"react";import{EDITOR_LS_KEYS as Uu,EXPORT_DATA_TYPES as TA,MIME_TYPES as Ly,VERSIONS as IA,chunk as CA,getExportSource as SA}from"@excalidraw/common";var Ut=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(Ut,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(n){return console.warn(`localStorage.setItem error: ${n.message}`),!1}}),I(Ut,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import vc from"react";var fA=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,bA=/{{([\w-]+)}}/,xA=/<([\w-]+)>/,EA=/<\/([\w-]+)>/,yA=(e,o)=>{let t=[{name:"",children:[]}];return e.split(fA).filter(Boolean).forEach(n=>{let r=n.match(xA),i=n.match(EA),a=n.match(bA);if(r!==null){let l=r[1];o.hasOwnProperty(l)?t.push({name:l,children:[]}):console.warn(`Trans: missed to pass in prop ${l} for interpolating ${e}`)}else if(i!==null)if(i[1]===t[t.length-1].name){let s=t.pop(),d=vc.createElement(vc.Fragment,{},...s.children),m=o[s.name];typeof m=="function"&&t[t.length-1].children.push(m(d))}else console.warn(`Trans: unexpected end tag ${n} for interpolating ${e}`);else if(a!==null){let l=a[1];o.hasOwnProperty(l)?t[t.length-1].children.push(o[l]):console.warn(`Trans: key ${l} not in props for interpolating ${e}`)}else t[t.length-1].children.push(n)}),t.length!==1&&console.warn(`Trans: stack not empty for interpolating ${e}`),t[0].children},wA=({i18nKey:e,children:o,...t})=>{let{t:n}=ze();return vc.createElement(vc.Fragment,{},...yA(n(e),t))},ht=wA;import{jsx as ae,jsxs as at}from"react/jsx-runtime";var kA=async e=>{let n=Math.round(8),r=Math.max(Math.round(128/64),2),i=CA(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=Tc.white,l.fillRect(0,0,a.width,a.height);for(let[s,d]of e.entries()){let m=await mn({elements:d.elements,files:null,maxWidthOrHeight:128}),{width:c,height:p}=m,u=Math.floor(s/6)*(128+n*2),f=s%6*(128+n*2);l.drawImage(m,f+(128-c)/2+n,u+(128-p)/2+n),l.lineWidth=r,l.strokeStyle=Tc.gray[4],l.strokeRect(f+n/2,u+n/2,128+n,128+n)}return await Fl(new File([await ko(a)],"preview",{type:Ly.png}),{outputType:Ly.jpg,maxWidthOrHeight:5e3})},MA=({libItem:e,appState:o,index:t,onChange:n,onRemove:r})=>{let i=My(null),a=My(null);return Yu(()=>{let l=i.current;l&&(async()=>{let s=await ci({elements:e.elements,appState:{...o,viewBackgroundColor:Tc.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),at("div",{className:"single-library-item",children:[e.status==="published"&&ae("span",{className:"single-library-item-status",children:g("labels.statusPublished")}),ae("div",{ref:i,className:"single-library-item__svg"}),ae(K,{"aria-label":g("buttons.remove"),type:"button",icon:Ft,className:"single-library-item--remove",onClick:r.bind(null,e.id),title:g("buttons.remove")}),at("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[at("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[at("div",{style:{padding:"0.5em 0"},children:[ae("span",{style:{fontWeight:500,color:Tc.gray[6]},children:g("publishDialog.itemName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{n(l.target.value,t)}})]}),ae("span",{className:"error",children:e.error})]})]})},LA=({onClose:e,libraryItems:o,appState:t,onSuccess:n,onError:r,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Gu({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[d,m]=Gu(!1);Yu(()=>{let y=Ut.get(Uu.PUBLISH_LIBRARY);y&&s(y)},[]);let[c,p]=Gu(o.slice());Yu(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},f=async y=>{y.preventDefault(),m(!0);let v=[],C=!1;if(c.forEach(N=>{let O="";N.name||(O=g("publishDialog.errors.required"),C=!0),v.push({...N,error:O})}),C){p(v),m(!1);return}let S=await kA(c),L={type:TA.excalidrawLibrary,version:IA.excalidrawLibrary,source:SA(),libraryItems:c},k=JSON.stringify(L,null,2),A=new Blob([k],{type:"application/json"}),P=new FormData;P.append("excalidrawLib",A),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(`${T.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(N=>N.ok?N.json().then(({url:O})=>{Ut.delete(Uu.PUBLISH_LIBRARY),n({url:O,authorName:l.authorName,items:c})}):N.json().catch(()=>{throw new Error(N.statusText||"something went wrong")}).then(O=>{throw new Error(O.message||N.statusText||"something went wrong")}),N=>{console.error(N),r(N),m(!1)}).catch(N=>{console.error(N),r(N),m(!1)})},b=()=>{let y=[];return c.forEach((v,C)=>{y.push(ae("div",{className:"single-library-item-wrapper",children:ae(MA,{libItem:v,appState:t,index:C,onChange:(S,L)=>{let k=c.slice();k[L].name=S,p(k)},onRemove:a})},C))}),ae("div",{className:"selected-library-items",children:y})},x=vA(()=>{i(c),Ut.set(Uu.PUBLISH_LIBRARY,l),e()},[c,e,i,l]),w=!!o.length,E=o.some(y=>y.status==="published");return ae(Be,{onCloseRequest:x,title:g("publishDialog.title"),className:"publish-library",children:w?at("form",{onSubmit:f,children:[ae("div",{className:"publish-library-note",children:ae(ht,{i18nKey:"publishDialog.noteDescription",link:y=>ae("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener",children:y})})}),ae("span",{className:"publish-library-note",children:ae(ht,{i18nKey:"publishDialog.noteGuidelines",link:y=>ae("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),ae("div",{className:"publish-library-note",children:g("publishDialog.noteItems")}),E&&ae("span",{className:"publish-library-note publish-library-warning",children:g("publishDialog.republishWarning")}),b(),at("div",{className:"publish-library__fields",children:[at("label",{children:[at("div",{children:[ae("span",{children:g("publishDialog.libraryName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:g("publishDialog.placeholder.libraryName")})]}),at("label",{style:{alignItems:"flex-start"},children:[at("div",{children:[ae("span",{children:g("publishDialog.libraryDesc")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:g("publishDialog.placeholder.libraryDesc")})]}),at("label",{children:[at("div",{children:[ae("span",{children:g("publishDialog.authorName")}),ae("span",{"aria-hidden":"true",className:"required",children:"*"})]}),ae("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:g("publishDialog.placeholder.authorName")})]}),at("label",{children:[ae("span",{children:g("publishDialog.githubUsername")}),ae("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:g("publishDialog.placeholder.githubHandle")})]}),at("label",{children:[ae("span",{children:g("publishDialog.twitterUsername")}),ae("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:g("publishDialog.placeholder.twitterHandle")})]}),at("label",{children:[ae("span",{children:g("publishDialog.website")}),ae("input",{type:"text",name:"website",pattern:"https?://.+",title:g("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:g("publishDialog.placeholder.website")})]}),ae("span",{className:"publish-library-note",children:ae(ht,{i18nKey:"publishDialog.noteLicense",link:y=>ae("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),at("div",{className:"publish-library__buttons",children:[ae(No,{label:g("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),ae(No,{type:"submit",label:g("buttons.submit"),actionType:"primary",isLoading:d})]})]}):ae("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:g("publishDialog.atleastOneLibItem")})})},Py=LA;import DA from"clsx";import{useEffect as _A,useRef as RA}from"react";import{EVENT as Ry,KEYS as NA}from"@excalidraw/common";import{forwardRef as Ay}from"react";import Dy from"clsx";import{jsx as _y}from"react/jsx-runtime";var PA=Ay(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>_y("div",{className:Dy("Stack Stack_horizontal",r),style:{"--gap":o,alignItems:t,justifyContent:n,...i},ref:a,children:e})),AA=Ay(({children:e,gap:o,align:t,justifyContent:n,className:r,style:i},a)=>_y("div",{className:Dy("Stack Stack_vertical",r),style:{"--gap":o,justifyItems:t,justifyContent:n,...i},ref:a,children:e})),qe={Row:PA,Col:AA};import{jsx as Ic}from"react/jsx-runtime";var Ny=({children:e,onClickOutside:o,className:t="",onSelect:n,style:r})=>{let i=se(),a=RA(null),l=Qo({onClickOutside:o});_r(a,()=>{l.onClickOutside?.()}),_A(()=>{let d=c=>{c.key===NA.ESCAPE&&(c.stopImmediatePropagation(),l.onClickOutside?.())},m={capture:!0};return document.addEventListener(Ry.KEYDOWN,d,m),()=>{document.removeEventListener(Ry.KEYDOWN,d,m)}},[l]);let s=DA(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Ic(hp.Provider,{value:{onSelect:n},children:Ic("div",{ref:a,className:s,style:r,"data-testid":"dropdown-menu",children:i.editor.isMobile?Ic(qe.Col,{className:"dropdown-menu-container",children:e}):Ic(Xe,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};Ny.displayName="DropdownMenuContent";var By=Ny;import{jsx as FA}from"react/jsx-runtime";var BA=({children:e,className:o="",selected:t,...n})=>FA("div",{...n,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),Fy=BA;import{jsx as Oy}from"react/jsx-runtime";var zy=({icon:e,shortcut:o,href:t,children:n,onSelect:r,className:i="",selected:a,rel:l="noopener",...s})=>{let d=ks(s.onClick,r);return Oy("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:Ss(i,a),title:s.title??s["aria-label"],onClick:d,children:Oy(Cs,{icon:e,shortcut:o,children:n})})},pi=zy;zy.displayName="DropdownMenuItemLink";import{jsx as OA}from"react/jsx-runtime";var Hy=()=>OA("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),Gy=Hy;Hy.displayName="DropdownMenuSeparator";import zA from"clsx";import{jsx as HA}from"react/jsx-runtime";var Uy=({className:e="",children:o,onToggle:t,title:n,...r})=>{let i=se(),a=zA(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return HA("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:n,...r,children:o})},Yy=Uy;Uy.displayName="DropdownMenuTrigger";import Cc from"react";var Wy=e=>{let o=Cc.Children.toArray(e).find(t=>Cc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},Vy=e=>{let o=Cc.Children.toArray(e).find(t=>Cc.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as GA,jsxs as UA}from"react/jsx-runtime";var Bo=({children:e,open:o})=>{let t=Wy(e),n=Vy(e);return UA(GA,{children:[t,o&&n]})};Bo.Trigger=Yy;Bo.Content=By;Bo.Item=pt;Bo.ItemLink=pi;Bo.ItemCustom=Fy;Bo.Group=ca;Bo.Separator=Gy;var fe=Bo;Bo.displayName="DropdownMenu";import{jsx as Tt,jsxs as Sc}from"react/jsx-runtime";var XA=(e,o)=>e.filter(t=>o.includes(t.id)),KA=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:n,resetLibrary:r,onSelectItems:i,appState:a,className:l})=>{let[s]=ie(Qn),[d,m]=ie(mi),c=()=>{let P=o.length?g("alerts.removeItemsFromsLibrary",{count:o.length}):g("alerts.resetLibrary"),N=o.length?g("confirmDialog.removeItemsFromLib"):g("confirmDialog.resetLibrary");return Tt(wc,{onConfirm:()=>{o.length?n():r(),u(!1)},onCancel:()=>{u(!1)},title:N,children:Tt("p",{children:P})})},[p,u]=Wu(!1),f=!!o.length,b=f?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=f?g("buttons.remove"):g("buttons.resetLibrary"),[w,E]=Wu(!1),[y,v]=Wu(null),C=WA(()=>Sc(Be,{onCloseRequest:()=>v(null),title:g("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[Tt("p",{children:Tt(ht,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:P=>Tt("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),Tt(K,{type:"button",title:g("buttons.close"),"aria-label":g("buttons.close"),label:g("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),S=(P,N)=>{E(!1),v({url:P.url,authorName:P.authorName});let O=N.slice();O.forEach(U=>{o.includes(U.id)&&(U.status="published")}),t.setLibrary(O)},L=async()=>{try{await t.updateLibrary({libraryItems:Ml({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:g("errors.importLibraryError")})}},k=async()=>{let P=f?b:await t.getLatestLibrary();t1(P).catch(VA).catch(N=>{e({errorMessage:N.message})})},A=()=>Sc(fe,{open:d,children:[Tt(fe.Trigger,{onToggle:()=>m(!d),children:L1}),Sc(fe.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!f&&Tt(fe.Item,{onSelect:L,icon:Cr,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&Tt(fe.Item,{onSelect:k,icon:zn,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),!!b.length&&Tt(fe.Item,{onSelect:()=>u(!0),icon:Lt,children:x}),f&&Tt(fe.Item,{icon:O0,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")})]})]});return Sc("div",{className:YA("library-menu-dropdown-container",l),children:[A(),o.length>0&&Tt("div",{className:"library-actions-counter",children:o.length}),p&&c(),w&&Tt(Py,{onClose:()=>E(!1),libraryItems:XA(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(N=>N!==P))}),y&&C()]})},Vu=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:n}=Re(),{clearLibraryCache:r,deleteItemsFromLibraryCache:i}=hc(),a=ge(),l=le(),[s]=ie(Qn),d=async c=>{let p=c.filter(u=>!e.includes(u.id));n.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return Tt(KA,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:n,onRemoveFromLibrary:()=>d(s.libraryItems),resetLibrary:()=>{n.resetLibrary(),r()},className:t})};import{memo as o8,useEffect as n8,useState as r8}from"react";import ZA,{useCallback as $A}from"react";function jA(){return[!1,$A(o=>o(),[])]}var Xy=ZA.useTransition||jA;import Ky from"clsx";import{memo as qA,useEffect as JA,useRef as QA,useState as e8}from"react";import{jsx as kc,jsxs as t8}from"react/jsx-runtime";var Zy=qA(({id:e,elements:o,isPending:t,onClick:n,selected:r,onToggle:i,onDrag:a,svgCache:l})=>{let s=QA(null),d=uy(e,o,l);JA(()=>{let f=s.current;if(f)return d&&(f.innerHTML=d.outerHTML),()=>{f.innerHTML=""}},[d]);let[m,c]=e8(!1),p=se().editor.isMobile,u=t&&kc("div",{className:"library-unit__adder",children:M1});return t8("div",{className:Ky("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":r,"library-unit--skeleton":!d}),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[kc("div",{className:Ky("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?f=>{e&&f.shiftKey?i(e,f):n(e)}:void 0,onDragStart:f=>{if(!e){f.preventDefault();return}c(!1),a(e,f)}}),u,e&&o&&(m||p||r)&&kc(xa,{checked:r,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),$y=()=>kc("div",{className:"library-unit library-unit--skeleton"});import{Fragment as i8,jsx as Mc}from"react/jsx-runtime";var Xu=({children:e})=>Mc("div",{className:"library-menu-items-container__grid",children:e}),Lc=o8(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:n,onClick:r,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=Xy(),[s,d]=r8(0);return n8(()=>{s<e.length&&l(()=>{d(s+a)})},[s,e.length,l,a]),Mc(i8,{children:e.map((m,c)=>c<s?Mc(Zy,{elements:m?.elements,isPending:!m?.id&&!!m?.elements,onClick:r,svgCache:i,id:m?.id,selected:n(m.id),onToggle:o,onDrag:t},m?.id??c):Mc($y,{},c))})});import{Fragment as qy,jsx as It,jsxs as hi}from"react/jsx-runtime";var p8=17,u8=64;function Ku({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:n,pendingElements:r,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:d}){let m=l8(null),c=Iy(m);a8(()=>{c>0&&m.current?.scrollTo(0,c)},[]);let{svgCache:p}=hc(),u=jy(()=>o.filter(P=>P.status!=="published"),[o]),f=jy(()=>o.filter(P=>P.status==="published"),[o]),b=!o.length&&!r.length,x=!r.length&&!u.length&&!f.length,[w,E]=s8(null),y=ui((P,N)=>{let O=!d.includes(P),U=[...u,...f];if(O){if(N.shiftKey&&w){let J=U.findIndex(Z=>Z.id===w),_=U.findIndex(Z=>Z.id===P);if(J===-1||_===-1){s([...d,P]);return}let R=d8(d),V=U.reduce((Z,W,ce)=>((ce>=J&&ce<=_||R.has(W.id))&&Z.push(W.id),Z),[]);s(V)}else s([...d,P]);E(P)}else E(null),s(d.filter(J=>J!==P))},[w,s,f,d,u]),v=ui(P=>{let N;return d.includes(P)?N=o.filter(O=>d.includes(O.id)):N=o.filter(O=>O.id===P),N.map(O=>({...O,elements:m8({type:"everything",elements:O.elements,randomizeSeed:!0}).duplicatedElements}))},[o,d]),C=ui((P,N)=>{N.dataTransfer.setData(c8.excalidrawlib,hm(v(P)))},[v]),S=ui(P=>P?d.includes(P):!1,[d]),L=ui(()=>{t(r)},[r,t]),k=ui(P=>{P&&n(v(P))},[v,n]),A=p.size>=o.length?u8:p8;return hi("div",{className:"library-menu-items-container",style:r.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&It(Vu,{selectedItems:d,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),hi(qe.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:f.length>0?1:"0 1 auto",marginBottom:0},ref:m,children:[hi(qy,{children:[!x&&It("div",{className:"library-menu-items-container__header",children:g("labels.personalLib")}),e&&It("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:It(tt,{})}),!r.length&&!u.length?hi("div",{className:"library-menu-items__no-items",children:[It("div",{className:"library-menu-items__no-items__label",children:g("library.noItems")}),It("div",{className:"library-menu-items__no-items__hint",children:f.length>0?g("library.hint_emptyPrivateLibrary"):g("library.hint_emptyLibrary")})]}):hi(Xu,{children:[r.length>0&&It(Lc,{itemsRenderedPerBatch:A,items:[{id:null,elements:r}],onItemSelectToggle:y,onItemDrag:C,onClick:L,isItemSelected:S,svgCache:p}),It(Lc,{itemsRenderedPerBatch:A,items:u,onItemSelectToggle:y,onItemDrag:C,onClick:k,isItemSelected:S,svgCache:p})]})]}),hi(qy,{children:[(f.length>0||r.length>0||u.length>0)&&It("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:g("labels.excalidrawLib")}),f.length>0?It(Xu,{children:It(Lc,{itemsRenderedPerBatch:A,items:f,onItemSelectToggle:y,onItemDrag:C,onClick:k,isItemSelected:S,svgCache:p})}):u.length>0?It("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:g("library.noItems")}):null]}),b&&It(Ec,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:It(Vu,{selectedItems:d,onSelectItems:s})})]})]})}import{jsx as un,jsxs as e2}from"react/jsx-runtime";var mi=me(!1),Qy=({children:e})=>un("div",{className:"layer-ui__library",children:e}),x8=n2(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:n,libraryReturnUrl:r,library:i,id:a,theme:l,selectedItems:s,onSelectItems:d})=>{let[m]=ie(Qn),c=$u(f=>{(async(x,w)=>{ne("element","addToLibrary","ui");for(let y of g8)if(x.some(v=>v.type===y))return n({errorMessage:g(`errors.libraryElementTypeError.${y}`)});let E=[{status:"unpublished",elements:x,id:f8(),created:Date.now()},...w];t(),i.setLibrary(E).catch(()=>{n({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,m.libraryItems)},[t,i,n,m.libraryItems]),p=o2(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return un(Qy,{children:un("div",{className:"layer-ui__library-message",children:e2("div",{children:[un(tt,{size:"2em"}),un("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return e2(Qy,{children:[un(Ku,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:c,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:r,theme:l,onSelectItems:d,selectedItems:s}),u&&un(Ec,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:r,theme:l})]})}),Zu=(e,o)=>({elements:e,pending:j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),E8=(e,o)=>{let t=on(),[n,r]=t2(()=>Zu(t,e.selectedElementIds)),i=h8(new Map);return Jy(()=>{for(let a of n.pending)i.current.set(a.id,a.version)},[n.pending]),Jy(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&r(a=>{if(!b8(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Zu(t,e.selectedElementIds);let l=o.scene.getNonDeletedElementsMap();for(let s of Object.keys(e.selectedElementIds)){let d=l.get(s)?.version;if(d&&d!==i.current.get(s))return Zu(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),n.pending},r2=n2(()=>{let e=Re(),{onInsertElements:o}=e,t=fo(),n=ge(),r=le(),[i,a]=t2([]),l=o2(()=>e.library,[e.library]),s=E8(n,e),d=$u(c=>{o(xc(c))},[o]),m=$u(()=>{r({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[r]);return un(x8,{pendingElements:s,onInsertLibraryItems:d,onAddToLibrary:m,setAppState:r,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:n.theme,selectedItems:i,onSelectItems:a})});import y8 from"clsx";import{useRef as w8}from"react";import{createPortal as v8}from"react-dom";import{KEYS as T8}from"@excalidraw/common";import{jsx as i2,jsxs as I8}from"react/jsx-runtime";var a2=e=>{let{closeOnClickOutside:o=!0}=e,t=fs({className:"excalidraw-modal-container"}),n=w8(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let r=i=>{i.key===T8.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return v8(I8("div",{className:y8("Modal",e.className,{"animations-disabled":n.current}),role:"dialog","aria-modal":"true",onKeyDown:r,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[i2("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),i2("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Oa,jsxs as P8}from"react/jsx-runtime";function L8(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Be=e=>{let[o,t]=dy(),[n]=k8(document.activeElement),{id:r}=Ge(),i=se().viewport.isMobile;S8(()=>{if(!o)return;let d=l2(o);setTimeout(()=>{d.length>0&&e.autofocus!==!1&&(d[1]||d[0]).focus()});let m=c=>{if(c.key===M8.TAB){let p=l2(o),{activeElement:u}=document,f=p.findIndex(b=>b===u);f===0&&c.shiftKey?(p[p.length-1].focus(),c.preventDefault()):f===p.length-1&&!c.shiftKey&&(p[0].focus(),c.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=le(),l=qo(mi),s=()=>{a({openMenu:null}),l(!1),n.focus(),e.onCloseRequest()};return Oa(a2,{className:C8("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:L8(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:P8(Xe,{ref:t,children:[e.title&&Oa("h2",{id:`${r}-dialog-title`,className:"Dialog__title",children:Oa("span",{className:"Dialog__titleContent",children:e.title})}),i&&Oa("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:Ft}),Oa("div",{className:"Dialog__content",children:e.children})]})})};import ju from"clsx";import{forwardRef as R8,useRef as N8,useImperativeHandle as B8,useLayoutEffect as F8,useState as O8}from"react";import A8 from"clsx";import{composeEventHandlers as D8}from"@excalidraw/common";import{jsx as _8}from"react/jsx-runtime";var Rt=({type:e="button",onSelect:o,selected:t,children:n,className:r="",...i})=>_8("button",{onClick:D8(i.onClick,a=>{o()}),type:e,className:A8("excalidraw-button",r,{selected:t}),...i,children:n});import{jsx as qu,jsxs as s2}from"react/jsx-runtime";var gi=R8(({onChange:e,label:o,fullWidth:t,placeholder:n,readonly:r,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:d,...m},c)=>{let p=N8(null);B8(c,()=>p.current),F8(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=O8(!1);return s2("div",{className:ju("ExcTextField",d,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&qu("div",{className:"ExcTextField__label",children:o}),s2("div",{className:ju("ExcTextField__input",{"ExcTextField__input--readonly":r}),children:[qu("input",{className:ju({"is-redacted":"value"in m&&m.value&&l&&!u}),readOnly:r,value:"value"in m?m.value:void 0,defaultValue:"defaultValue"in m?m.defaultValue:void 0,placeholder:n,ref:p,onChange:b=>e?.(b.target.value),onKeyDown:a}),l&&qu(Rt,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?X0:Mr})]})]})});import{KEYS as Fe}from"@excalidraw/common";var Pc=[{icon:wm,value:"selection",key:Fe.V,numericKey:Fe[1],fillable:!0},{icon:Ul,value:"rectangle",key:Fe.R,numericKey:Fe[2],fillable:!0},{icon:Yl,value:"diamond",key:Fe.D,numericKey:Fe[3],fillable:!0},{icon:Wl,value:"ellipse",key:Fe.O,numericKey:Fe[4],fillable:!0},{icon:N1,value:"arrow",key:Fe.A,numericKey:Fe[5],fillable:!0},{icon:Vl,value:"line",key:Fe.L,numericKey:Fe[6],fillable:!0},{icon:Jo,value:"freedraw",key:[Fe.P,Fe.X],numericKey:Fe[7],fillable:!1},{icon:Tr,value:"text",key:Fe.T,numericKey:Fe[8],fillable:!1},{icon:F1,value:"image",key:null,numericKey:Fe[9],fillable:!1},{icon:O1,value:"eraser",key:Fe.E,numericKey:Fe[0],fillable:!1}],Ju=e=>e.defaultSelectionTool==="lasso"?[{value:"lasso",icon:wm,key:Fe.V,numericKey:Fe[1],fillable:!0},...Pc.slice(1)]:Pc,c2=(e,o)=>Ju(o).find((n,r)=>n.numericKey!=null&&e===n.numericKey.toString()||n.key&&(typeof n.key=="string"?n.key===e:n.key.includes(e)))?.value||null;import oh from"clsx";import{useState as G8}from"react";import{CLASSES as U8,KEYS as m2,capitalizeString as th,isTransparent as p2}from"@excalidraw/common";import{shouldAllowVerticalAlign as Y8,suppportsHorizontalAlign as W8}from"@excalidraw/element";import{hasBoundTextElement as u2,isElbowArrow as V8,isImageElement as X8,isLinearElement as K8,isTextElement as Z8}from"@excalidraw/element";import{hasStrokeColor as h2,toolIsArrow as g2}from"@excalidraw/element";import{createIsolation as z8}from"jotai-scope";import Qu from"react";import yo from"tunnel-rat";var eh=Qu.createContext(null),ve=()=>Qu.useContext(eh),H8=z8(),d2=()=>Qu.useMemo(()=>({MainMenuTunnel:yo(),WelcomeScreenMenuHintTunnel:yo(),WelcomeScreenToolbarHintTunnel:yo(),WelcomeScreenHelpHintTunnel:yo(),WelcomeScreenCenterTunnel:yo(),FooterCenterTunnel:yo(),DefaultSidebarTriggerTunnel:yo(),DefaultSidebarTabTriggersTunnel:yo(),OverwriteConfirmDialogTunnel:yo(),TTDDialogTriggerTunnel:yo(),tunnelsJotai:H8}),[]);import{Fragment as Fo,jsx as Te,jsxs as $e}from"react/jsx-runtime";var nh=(e,o)=>{let t=o[0]?.type||null;for(let n of o)if(n.type!==t){t=null;break}return h2(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(n=>h2(n.type))},rh=(e,o)=>Zo(e.activeTool.type)||o.some(t=>Zo(t.type)),Ac=({appState:e,elementsMap:o,renderAction:t,app:n})=>{let r=kl(o,e),i=!1;r.length===2&&(u2(r[0])||u2(r[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=se(),s=document.documentElement.getAttribute("dir")==="rtl",d=Zo(e.activeTool.type)&&!p2(e.currentItemBackgroundColor)||r.some(f=>Zo(f.type)&&!p2(f.backgroundColor)),m=r.length===1||i,c=!e.selectedLinearElement?.isEditing&&r.length===1&&K8(r[0])&&!V8(r[0]),p=!e.croppingElementId&&r.length===1&&X8(r[0]),u=!i&&vt(e,n);return $e("div",{className:"selected-shape-actions",children:[Te("div",{children:nh(e,r)&&t("changeStrokeColor")}),rh(e,r)&&Te("div",{children:t("changeBackgroundColor")}),d&&t("changeFillStyle"),(sm(e.activeTool.type)||r.some(f=>sm(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||r.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(cm(e.activeTool.type)||r.some(f=>cm(f.type)))&&$e(Fo,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(dm(e.activeTool.type)||r.some(f=>dm(f.type)))&&Te(Fo,{children:t("changeRoundness")}),(g2(e.activeTool.type)||r.some(f=>g2(f.type)))&&Te(Fo,{children:t("changeArrowType")}),(e.activeTool.type==="text"||r.some(Z8))&&$e(Fo,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||W8(r,o))&&t("changeTextAlign")]}),Y8(r,o)&&t("changeVerticalAlign"),(hr(e.activeTool.type)||r.some(f=>hr(f.type)))&&Te(Fo,{children:t("changeArrowhead")}),t("changeOpacity"),$e("fieldset",{children:[Te("legend",{children:g("labels.layers")}),$e("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&$e("fieldset",{children:[Te("legend",{children:g("labels.align")}),$e("div",{className:"buttonList",children:[s?$e(Fo,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):$e(Fo,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),r.length>2&&t("distributeHorizontally"),Te("div",{style:{flexBasis:"100%",height:0}}),$e("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),r.length>2&&t("distributeVertically")]})]})]}),!a&&r.length>0&&$e("fieldset",{children:[Te("legend",{children:g("labels.actions")}),$e("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),p&&t("cropEditor"),c&&t("toggleLinearEditor")]})]})]})},Dc=({activeTool:e,appState:o,app:t,UIOptions:n})=>{let[r,i]=G8(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso"&&t.defaultSelectionTool!=="lasso",d=e.type==="embeddable",{TTDDialogTriggerTunnel:m}=ve();return $e(Fo,{children:[Ju(t).map(({value:c,icon:p,key:u,numericKey:f,fillable:b},x)=>{if(n.tools?.[c]===!1)return null;let w=g(`toolBar.${c}`),E=u&&th(typeof u=="string"?u:u[0]),y=E?`${E} ${g("helpDialog.or")} ${f}`:`${f}`;return Te(K,{className:oh("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===c,name:"editor-current-shape",title:`${th(w)} \u2014 ${y}`,keyBindingLabel:f||E,"aria-label":th(w),"aria-keyshortcuts":y,"data-testid":`toolbar-${c}`,onPointerDown:({pointerType:v})=>{!o.penDetected&&v==="pen"&&t.togglePenMode(!0),c==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:v})=>{o.activeTool.type!==c&&ne("toolbar",c,"ui"),c==="image"?t.setActiveTool({type:c}):t.setActiveTool({type:c})}},c)}),Te("div",{className:"App-toolbar__divider"}),$e(fe,{open:r,children:[Te(fe.Trigger,{className:oh("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||d||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!r),title:g("toolBar.extraTools"),children:a?Gn:d?Im:l&&!t.props.isCollaborating?ea:s?Zi:W0}),$e(fe.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:Gn,shortcut:m2.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:g("toolBar.frame")}),Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:Im,"data-testid":"toolbar-embeddable",selected:d,children:g("toolBar.embeddable")}),Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:ea,"data-testid":"toolbar-laser",selected:l,shortcut:m2.K.toLocaleUpperCase(),children:g("toolBar.laser")}),t.defaultSelectionTool!=="lasso"&&Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:Zi,"data-testid":"toolbar-lasso",selected:s,children:g("toolBar.lasso")}),Te("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&Te(m.Out,{}),Te(fe.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:es,"data-testid":"toolbar-embeddable",children:g("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&Te(Fo,{children:$e(fe.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:ts,"data-testid":"toolbar-magicframe",children:[g("toolBar.magicframe"),Te(fe.Item.Badge,{children:"AI"})]})})]})]})]})},f2=({renderAction:e,zoom:o})=>Te(qe.Col,{gap:1,className:U8.ZOOM_ACTIONS,children:$e(qe.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),b2=({renderAction:e,className:o})=>$e("div",{className:`undo-redo-buttons ${o}`,children:[Te("div",{className:"undo-button-container",children:Te(At,{label:g("buttons.undo"),children:e("undo")})}),Te("div",{className:"redo-button-container",children:$e(At,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),x2=({actionManager:e,showExitZenModeBtn:o})=>Te("button",{type:"button",className:oh("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(ti),children:g("buttons.exitZenMode")});import{useRef as $8}from"react";var ih=e=>{let o=$8({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as q8,jsxs as j8}from"react/jsx-runtime";var er=me(null),E2=()=>{let[e,o]=ie(er),t=Ue();return e&&e==="clearCanvas"?q8(wc,{onConfirm:()=>{t.executeAction(_o),o(null)},onCancel:()=>o(null),title:g("clearCanvasDialog.title"),children:j8("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var ah={};$f(ah,{toggleTheme:()=>J8});var J8={...Vn,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Vn,"commandPalette")}};import{jsx as lt,jsxs as wo}from"react/jsx-runtime";var r7=me(null),ke={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},i7=e=>{switch(e){case ke.app:return 1;case ke.export:return 2;case ke.editor:return 3;case ke.tools:return 4;case ke.elements:return 5;case ke.links:return 6;default:return 10}},Nc=({shortcut:e,className:o,children:t})=>{let n=e.replace("++","+$").split("+");return wo("div",{className:v2("shortcut",o),children:[n.map((r,i)=>lt("div",{className:"shortcut-wrapper",children:lt("div",{className:"shortcut-key",children:r==="$"?"+":r})},r)),lt("div",{className:"shortcut-desc",children:t})]})},T2=e=>!e.altKey&&e[ao.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===ao.P||e.key===ao.SLASH),vce=Object.assign(e=>{let o=ge(),t=le();return Rc(()=>{let n=r=>{T2(r)&&(r.preventDefault(),r.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&ne("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(Bc.KEYDOWN,n,{capture:!0}),()=>window.removeEventListener(Bc.KEYDOWN,n,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:lt(a7,{...e})},{defaultItems:ah});function a7({customCommandPaletteItems:e}){let o=Re(),t=ge(),n=le(),r=fo(),i=Ue(),[a,l]=ie(r7),[s,d]=_c(null),m=e7(null),c=Qo({uiAppState:t,customCommandPaletteItems:e,appProps:r});Rc(()=>{let{uiAppState:S,customCommandPaletteItems:L,appProps:k}=c,A=U=>{let J="";return U.label&&(typeof U.label=="function"?J=g(U.label(o.scene.getNonDeletedElements(),S,o)):J=g(U.label)),J},P=U=>typeof U.icon=="function"?U.icon(S,o.scene.getNonDeletedElements()):U.icon,N=[],O=(U,J,_)=>{let R={label:A(U),icon:P(U),category:J,shortcut:Ne(U.name),keywords:U.keywords,predicate:U.predicate,viewMode:U.viewMode,perform:()=>{i.executeAction(U,"commandPalette")}};return _?_(R,U):R};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,i.actions.togglePolygon,Ma,uc,sy].map(W=>O(W,ke.elements,(ce,he)=>({...ce,predicate:he.predicate?he.predicate:(de,it,po,pr)=>j(de,it).length>0}))),J=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map(W=>O(W,ke.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(W=>O(W,ke.editor)),R=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map(W=>O(W,ke.export));N=[...U,..._,{label:A(_o),icon:P(_o),shortcut:Ne(_o.name),category:ke.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{He.set(er,"clearCanvas")}},{label:g("buttons.exportImage"),category:ke.export,icon:$l,shortcut:Ne("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{n({openDialog:{name:"imageExport"}})}},...R];let V=[{label:g("toolBar.library"),category:ke.app,icon:wr,viewMode:!1,perform:()=>{S.openSidebar?n({openSidebar:null}):n({openSidebar:{name:y2.name,tab:y2.defaultTab}})}},{label:g("search.title"),category:ke.app,icon:Pt,viewMode:!0,perform:()=>{i.executeAction(za)}},{label:g("labels.shapeSwitch"),category:ke.elements,icon:ta,perform:()=>{i.executeAction(ly)}},{label:g("labels.changeStroke"),keywords:["color","outline"],category:ke.elements,icon:Zl,viewMode:!1,predicate:(W,ce)=>{let he=j(W,ce);return he.length>0&&nh(ce,he)},perform:()=>{n(W=>({openMenu:W.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:g("labels.changeBackground"),keywords:["color","fill"],icon:Zl,category:ke.elements,viewMode:!1,predicate:(W,ce)=>{let he=j(W,ce);return he.length>0&&rh(ce,he)},perform:()=>{n(W=>({openMenu:W.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:Zl,category:ke.editor,viewMode:!1,perform:()=>{n(W=>({openMenu:W.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Pc.reduce((W,ce)=>{let{value:he,icon:de,key:it,numericKey:po}=ce;if(k.UIOptions.tools?.[he]===!1)return W;let ur=it&&t7(typeof it=="string"?it:it[0])||po,Cl={label:g(`toolBar.${he}`),category:ke.tools,shortcut:ur,icon:de,keywords:["toolbar"],viewMode:!1,perform:({event:im})=>{he==="image"?o.setActiveTool({type:he}):o.setActiveTool({type:he})}};return W.push(Cl),W},[]),...J,{label:g("toolBar.lock"),category:ke.tools,icon:S.activeTool.locked?vr:On,shortcut:ao.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:ke.tools,icon:Z0,viewMode:!1,predicate:k.aiEnabled,perform:()=>{n(W=>({...W,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:ke.tools,icon:es,viewMode:!1,predicate:k.aiEnabled,perform:()=>{n(W=>({...W,openDialog:{name:"ttd",tab:"mermaid"}}))}}],Z=[...N,...V,...L||[]].map(W=>({...W,icon:W.icon||ta,order:W.order??i7(W.category),haystack:`${_u(W.label.toLocaleLowerCase())} ${W.keywords?.join(" ")||""}`}));d(Z),l(Z.find(W=>W.label===a?.label)??null)}},[c,o,i,d,a?.label,l,n]);let[p,u]=_c(""),[f,b]=_c(null),[x,w]=_c({}),E=S=>{n({openDialog:null},S),u("")},y=(S,L)=>{t.openDialog?.name==="commandPalette"&&(L.stopPropagation(),L.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),E(()=>{S.perform({actionManager:i,event:L}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=ih(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,r,o):S.predicate===void 0||S.predicate),C=ih(S=>{let L=n7(S.target)||T2(S)||S.key===ao.ESCAPE;if(L&&S.key!==ao.ARROW_UP&&S.key!==ao.ARROW_DOWN&&S.key!==ao.ENTER)return;let k=Object.values(x).flat(),A=a&&!p&&v(a);if(S.key===ao.ARROW_UP){S.preventDefault();let P=k.findIndex(U=>U.label===f?.label);if(A){if(P===0){b(a);return}if(f===a){let U=k[k.length-1];U&&b(U);return}}let N;P===-1?N=k.length-1:N=P===0?k.length-1:(P-1)%k.length;let O=k[N];O&&b(O);return}if(S.key===ao.ARROW_DOWN){S.preventDefault();let P=k.findIndex(U=>U.label===f?.label);if(A){if(!f||P===k.length-1){b(a);return}if(f===a){let U=k[0];U&&b(U);return}}let N=(P+1)%k.length,O=k[N];O&&b(O);return}if(S.key===ao.ENTER&&f&&setTimeout(()=>{y(f,S)}),!L){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){m?.current?.focus();return}S.preventDefault()}});return Rc(()=>(window.addEventListener(Bc.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(Bc.KEYDOWN,C,{capture:!0})),[C]),Rc(()=>{if(!s)return;let S=P=>{let N={};for(let O of P)N[O.category]?N[O.category].push(O):N[O.category]=[O];return N},L=s.filter(v).sort((P,N)=>P.order-N.order),k=!p&&a&&v(a);if(!p){w(S(k?L.filter(P=>P.label!==a?.label):L)),b(k?a:L[0]||null);return}let A=_u(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));L=Q8.filter(A,L,{extract:P=>P.haystack}).sort((P,N)=>N.score-P.score).map(P=>P.original),w(S(L)),b(L[0]??null)},[p,s,v,a]),wo(Be,{onCloseRequest:()=>E(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[lt(gi,{value:p,placeholder:g("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:m}),!o.device.viewport.isMobile&&wo("div",{className:"shortcuts-wrapper",children:[lt(Nc,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),lt(Nc,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),lt(Nc,{shortcut:o7("Esc"),children:g("commandPalette.shortcuts.close")})]}),wo("div",{className:"commands",children:[a&&!p&&wo("div",{className:"command-category",children:[wo("div",{className:"command-category-title",children:[g("commandPalette.recents"),lt("div",{className:"icon",style:{marginLeft:"6px"},children:$0})]}),lt(w2,{command:a,isSelected:a.label===f?.label,onClick:S=>y(a,S),disabled:!v(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((S,L)=>wo("div",{className:"command-category",children:[lt("div",{className:"command-category-title",children:S}),x[S].map(k=>lt(w2,{command:k,isSelected:k.label===f?.label,onClick:A=>y(k,A),onMouseMove:()=>b(k),showShortcut:!o.device.viewport.isMobile,appState:t},k.label))]},S)):s?wo("div",{className:"no-match",children:[lt("div",{className:"icon",children:Pt})," ",g("commandPalette.search.noMatch")]}):null]})]})}var w2=({command:e,isSelected:o,disabled:t,onMouseMove:n,onClick:r,showShortcut:i,appState:a})=>{let l=()=>{};return wo("div",{className:v2("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:r,onMouseMove:t?l:n,title:t?g("commandPalette.itemNotAvailable"):"",children:[wo("div",{className:"name",children:[e.icon&&lt(an,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),lt(da,{children:e.label})]}),i&&e.shortcut&&lt(Nc,{shortcut:e.shortcut})]})};import{getSizeFromPoints as m1e,randomInteger as oD,getUpdatedTimestamp as nD}from"@excalidraw/common";import{simplify as X7}from"points-on-curve";import{pointsOnBezierCurves as kce}from"points-on-curve";import{invariant as Lce}from"@excalidraw/common";import{curve as Ace,lineSegment as Dce,pointFrom as _ce,pointDistance as Rce,pointFromArray as Nce,pointFromVector as Bce,pointRotateRads as Fce,polygon as Oce,polygonFromPoints as zce,PRECISION as Hce,segmentsIntersectAt as Gce,vector as Uce,vectorAdd as Yce,vectorFromPoint as Wce,vectorScale as Vce}from"@excalidraw/math";import{getElementAbsoluteCoords as Kce}from"@excalidraw/element";var lh=e=>{if(!e)return[];for(let o of e.sets)if(o.type==="path")return o.ops;return e.sets[0].ops};import{pointFrom as K7,pointDistance as V2,pointRotateRads as $fe}from"@excalidraw/math";import{ROUGHNESS as Z7,isTransparent as Wa,assertNever as $7,COLOR_PALETTE as j7,LINE_POLYGON_POINT_MERGE_DISTANCE as qfe}from"@excalidraw/common";import{RoughGenerator as q7}from"roughjs/bin/generator";import pfe from"roughjs/bin/rough";import{getStroke as z7}from"perfect-freehand";import{isRightAngleRads as gfe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as bfe,DEFAULT_REDUCED_GLOBAL_ALPHA as xfe,ELEMENT_READY_TO_ERASE_OPACITY as Efe,FRAME_STYLE as yfe,MIME_TYPES as G2,THEME as wfe,distance as vfe,getFontString as Tfe,isRTL as Ife,getVerticalOffset as Cfe}from"@excalidraw/common";import Ihe from"roughjs/bin/rough";import{arrayToMap as She,invariant as _2,rescalePoints as khe,sizeOf as Mhe}from"@excalidraw/common";import{degreesToRadians as Eh,lineSegment as Phe,pointDistance as Ahe,pointFrom as ot,pointFromArray as T7,pointRotateRads as yi}from"@excalidraw/math";import{pointsOnBezierCurves as Rhe}from"points-on-curve";import{pointCenter as Uue,pointFrom as Yue,pointRotateRads as Wue,pointsEqual as Vue,pointDistance as Xue,vectorFromPoint as Kue,curveLength as Zue,curvePointAtLength as $ue}from"@excalidraw/math";import{DRAGGING_THRESHOLD as Jue,KEYS as Que,shouldRotateWithDiscreteAngle as ehe,getGridPoint as the,invariant as ohe,tupleToCoors as nhe,viewportCoordsToSceneCoords as rhe}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as ahe,isPathALoop as lhe}from"@excalidraw/element";import{KEYS as Gpe,arrayToMap as Upe,isBindingFallthroughEnabled as Ype,tupleToCoors as Wpe,invariant as Vpe,isDevEnv as Xpe,isTestEnv as Kpe}from"@excalidraw/common";import{lineSegment as $pe,pointFrom as jpe,pointRotateRads as qpe,vectorFromPoint as Jpe,pointDistanceSq as Qpe,clamp as eue,pointDistance as tue,pointFromVector as oue,vectorScale as nue,vectorNormalize as rue,vectorCross as iue,pointsEqual as aue,lineSegmentIntersectionPoints as lue,PRECISION as sue}from"@excalidraw/math";import{isTransparent as bme}from"@excalidraw/common";import{curveIntersectLineSegment as Eme,isPointWithinBounds as yme,lineSegment as wme,lineSegmentIntersectionPoints as vme,pointFrom as Tme,pointFromVector as Ime,pointRotateRads as Cme,pointsEqual as Sme,vectorFromPoint as kme,vectorNormalize as Mme,vectorScale as Lme}from"@excalidraw/math";import{ellipse as Ame,ellipseSegmentInterceptPoints as Dme}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as l7,DEFAULT_PROPORTIONAL_RADIUS as sh,LINE_CONFIRM_THRESHOLD as s7,ROUNDNESS as ch}from"@excalidraw/common";import{curve as Jce,curveCatmullRomCubicApproxPoints as Qce,curveOffsetPoints as ede,lineSegment as tde,pointDistance as c7,pointFrom as ode,pointFromArray as nde,rectangle as rde}from"@excalidraw/math";var Fc=(e,o=1)=>{if(e.length>=3){let[t,n]=[e[0],e[e.length-1]];return c7(t,n)<=s7/o}return!1},Ha=(e,o)=>{if(o.roundness?.type===ch.PROPORTIONAL_RADIUS||o.roundness?.type===ch.LEGACY)return e*sh;if(o.roundness?.type===ch.ADAPTIVE_RADIUS){let t=o.roundness?.value??l7,n=t/sh;return e<=n?e*sh:t}return 0};import{ROUNDNESS as mde,assertNever as pde}from"@excalidraw/common";import{pointsEqual as hde}from"@excalidraw/math";var I2=e=>!!e&&e.type==="embeddable",C2=e=>!!e&&e.type==="iframe",mh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),tr=e=>e!=null&&e.type==="text";var Oc=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var hn=e=>e!=null&&d7(e.type);var fi=e=>e!=null&&e.type==="arrow",Ga=e=>fi(e)&&e.elbowed;var d7=e=>e==="arrow"||e==="line";var bi=e=>e!==null&&"containerId"in e&&e.containerId!==null&&tr(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Yde,ARROW_LABEL_WIDTH_FRACTION as Wde,BOUND_TEXT_PADDING as Vde,DEFAULT_FONT_SIZE as Xde,TEXT_ALIGN as Kde,VERTICAL_ALIGN as Zde,getFontString as $de,isProdEnv as jde,invariant as qde}from"@excalidraw/common";import{BOUND_TEXT_PADDING as yde,DEFAULT_FONT_SIZE as wde,DEFAULT_FONT_FAMILY as vde,getFontString as Tde,isTestEnv as Ide,normalizeEOL as Cde}from"@excalidraw/common";var Sde="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as _de,isTestEnv as Rde}from"@excalidraw/common";import{curvePointDistance as ame,distanceToLineSegment as lme,pointRotateRads as sme}from"@excalidraw/math";import{ellipse as dme,ellipseDistanceFromPoint as mme}from"@excalidraw/math/ellipse";import{invariant as Wme,isDevEnv as Vme,isTestEnv as Xme}from"@excalidraw/common";import{pointFrom as Zme,pointFromVector as $me,pointRotateRads as jme,pointScaleFromOrigin as qme,pointsEqual as Jme,triangleIncludesPoint as Qme,vectorCross as epe,vectorFromPoint as g7,vectorScale as tpe}from"@excalidraw/math";var bh=[1,0],L2=[0,1],xh=[-1,0],P2=[0,-1],zc=e=>{let[o,t]=e,n=Math.abs(o),r=Math.abs(t);return o>r?bh:o<=-r?xh:t>n?L2:P2},A2=(e,o)=>zc(g7(e,o)),Hc=(e,o)=>Gc(A2(e,o)),fh=(e,o)=>e[0]===o[0]&&e[1]===o[1],Gc=e=>fh(e,bh)||fh(e,xh);import{clamp as lpe,pointDistance as spe,pointFrom as cpe,pointScaleFromOrigin as dpe,pointsEqual as mpe,pointTranslate as ppe,vector as upe,vectorCross as hpe,vectorFromPoint as gpe,vectorScale as fpe}from"@excalidraw/math";import{BinaryHeap as xpe,invariant as Epe,isAnyTrue as ype,tupleToCoors as wpe,getSizeFromPoints as vpe,isDevEnv as Tpe,arrayToMap as Ipe}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as Tue,viewportCoordsToSceneCoords as Iue}from"@excalidraw/common";import{normalizeRadians as Sue,radiansBetweenAngles as kue,radiansDifference as Mue}from"@excalidraw/math";import{pointsEqual as Pue}from"@excalidraw/math";var dh=e=>{let o=Math.floor(e.width/2)+1,t=0,n=e.width,r=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,n,r,i,a,0,r]};var I7=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}},C7=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},yh=(e,o,t,n)=>{if(o.length<1)return null;let r=lh(o[0]);if(r.length<1)return null;let i=t==="start"?1:r.length-1,a=r[i].data;_2(a.length===6,"Op data length is not 6");let l=ot(a[4],a[5]),s=ot(a[2],a[3]),d=ot(a[0],a[1]),m=r[i-1],c=ot(0,0);if(m.op==="move"){let _=T7(m.data);_2(_!=null,"Op data is not a point"),c=_}else m.op==="bcurveTo"&&(c=ot(m.data[4],m.data[5]));let p=(_,R)=>Math.pow(1-_,3)*l[R]+3*_*Math.pow(1-_,2)*s[R]+3*Math.pow(_,2)*(1-_)*d[R]+c[R]*Math.pow(_,3),[u,f]=t==="start"?c:l,[b,x]=[p(.3,0),p(.3,1)],w=Math.hypot(u-b,f-x),E=(u-b)/w,y=(f-x)/w,v=I7(n),C=0;{let[_,R]=t==="end"?e.points[e.points.length-1]:e.points[0],[V,Z]=e.points.length>1?t==="end"?e.points[e.points.length-2]:e.points[1]:[0,0];C=Math.hypot(_-V,R-Z)}let L=Math.min(v,C*(n==="diamond"||n==="diamond_outline"?.25:.5)),k=u-E*L,A=f-y*L;if(n==="dot"||n==="circle"||n==="circle_outline"){let _=Math.hypot(A-f,k-u)+e.strokeWidth-2;return[u,f,_]}let P=C7(n);if(n==="crowfoot_many"||n==="crowfoot_one_or_many"){let[_,R]=yi(ot(u,f),ot(k,A),Eh(-P)),[V,Z]=yi(ot(u,f),ot(k,A),Eh(P));return[k,A,_,R,V,Z]}let[N,O]=yi(ot(k,A),ot(u,f),-P*Math.PI/180),[U,J]=yi(ot(k,A),ot(u,f),Eh(P));if(n==="diamond"||n==="diamond_outline"){let _,R;if(t==="start"){let[V,Z]=e.points.length>1?e.points[1]:[0,0];[_,R]=yi(ot(u+L*2,f),ot(u,f),Math.atan2(Z-f,V-u))}else{let[V,Z]=e.points.length>1?e.points[e.points.length-2]:[0,0];[_,R]=yi(ot(u-L*2,f),ot(u,f),Math.atan2(f-Z,u-V))}return[u,f,N,O,_,R,U,J]}return[u,f,N,O,U,J]};import{pointFrom as Zhe,pointCenter as $he,pointRotateRads as jhe,vectorFromPoint as qhe,vectorNormalize as Jhe,vectorSubtract as Qhe,vectorAdd as ege,vectorScale as tge,pointFromVector as oge,clamp as nge,isCloseTo as rge}from"@excalidraw/math";import{arrayToMap as Wge}from"@excalidraw/common";import{isPointWithinBounds as Xge,pointFrom as Kge}from"@excalidraw/math";import{vectorCross as cge,vectorFromPoint as dge}from"@excalidraw/math";import{arrayToMap as S7}from"@excalidraw/common";import{getElementBounds as k7}from"@excalidraw/element";import{isArrowElement as M7,isExcalidrawElement as L7,isFreeDrawElement as P7,isLinearElement as A7,isTextElement as D7}from"@excalidraw/element";import{rangeIncludesValue as Uc,pointFrom as zo,pointRotateRads as _7,rangeInclusive as Yc}from"@excalidraw/math";var R7=e=>e.type==="diamond"?[zo(e.width/2,0),zo(e.width,e.height/2),zo(e.width/2,e.height),zo(0,e.height/2)]:[zo(0,0),zo(0+e.width,0),zo(0+e.width,e.height),zo(0,e.height)],N7=e=>A7(e)||P7(e)?e.points:R7(e),N2=e=>{let o=e.reduce((t,[n,r])=>(t.minY=Math.min(t.minY,r),t.minX=Math.min(t.minX,n),t.maxX=Math.max(t.maxX,n),t.maxY=Math.max(t.maxY,r),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},B2=e=>{let o=N7(e),{cx:t,cy:n}=N2(o),r=zo(t,n),i=o.map(m=>_7(m,r,e.angle)),{minX:a,minY:l,maxX:s,maxY:d}=N2(i);return[a+e.x,l+e.y,s+e.x,d+e.y]},wh=(e,o,t=!1)=>{let n=B2(e),r=o[0]<=n[0]&&o[2]>=n[2]&&o[1]<=n[1]&&o[3]>=n[3];return t?r?!0:n[0]<=o[0]&&n[2]>=o[2]&&n[1]<=o[1]&&n[3]>=o[3]:r},F2=(e,o)=>{let t=B2(e);return(Uc(t[0],Yc(o[0],o[2]))||Uc(o[0],Yc(t[0],t[2])))&&(Uc(t[1],Yc(o[1],o[3]))||Uc(o[1],Yc(t[1],t[3])))},O2=({elements:e,bounds:o,type:t,errorMargin:n=0})=>{L7(o)&&(o=k7(o,S7(e)));let r=[o[0]-n,o[1]-n,o[2]+n,o[3]+n],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?F2(a,r):t==="inside"?wh(a,r):wh(a,r,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);D7(a)&&a.containerId&&i.add(a.containerId),M7(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 Sge,isShallowEqual as F7}from"@excalidraw/common";var B7=function(){let e=null,o=null,t=null,n=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let d={};for(let p of i){let u=p.groupIds;if(l.editingGroupId){let f=u.indexOf(l.editingGroupId);f>-1&&(u=u.slice(0,f))}if(u.length>0){let f=u[u.length-1];d[f]=!0}}let m={},c=a.reduce((p,u)=>{if(u.isDeleted)return p;let f=u.groupIds.find(b=>d[b]);return f&&(p[u.id]=!0,Array.isArray(m[f])?m[f].push(u.id):m[f]=[u.id]),p},{});for(let p of Object.keys(m))m[p].length<2&&d[p]&&(d[p]=!1);return o=a,e=i,t={editingGroupId:l.editingGroupId,selectedGroupIds:d,selectedElementIds:vh({...l.selectedElementIds,...c},s)},t},r=(i,a,l,s)=>{let d=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Th(a,i);return d.length?n(d,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:vh(i.selectedElementIds,l)}};return r.clearCache=()=>{o=null,e=null,t=null},r}();var _ge=function(){let e=null,o=null,t=null,n=(r,i)=>(t!=null&&r===e&&i.selectedElementIds===o||(t=r.some(a=>i.selectedElementIds[a.id]),e=r,o=i.selectedElementIds),t);return n.clearCache=()=>{e=null,o=null,t=null},n}(),Th=(e,o,t)=>{let n=new Set,r=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){r.push(i),n.add(i.id);continue}if(t?.includeBoundTextElement&&bi(i)&&o.selectedElementIds[i?.containerId]){r.push(i),n.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return r.forEach(a=>{Oc(a)&&z2(e,a.id).forEach(l=>!n.has(l.id)&&i.push(l)),i.push(a)}),i}return r};var vh=(e,o)=>F7(o.selectedElementIds,e)?o.selectedElementIds:e;var z2=(e,o)=>{let t=[];for(let n of e.values())n.frameId===o&&t.push(n);return t};var H7=typeof document<"u"?document.createElement("img"):{src:""};H7.src=`data:${G2.svg},${encodeURIComponent('<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="image" class="svg-inline--fa fa-image fa-w-16" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#888" d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"></path></svg>')}`;var G7=typeof document<"u"?document.createElement("img"):{src:""};G7.src=`data:${G2.svg},${encodeURIComponent('<svg viewBox="0 0 668 668" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48ZM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56ZM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.81709 0 0 .81709 124.825 145.825)"/><path d="M256 8C119.034 8 8 119.033 8 256c0 136.967 111.034 248 248 248s248-111.034 248-248S392.967 8 256 8Zm130.108 117.892c65.448 65.448 70 165.481 20.677 235.637L150.47 105.216c70.204-49.356 170.226-44.735 235.638 20.676ZM125.892 386.108c-65.448-65.448-70-165.481-20.677-235.637L361.53 406.784c-70.203 49.356-170.226 44.736-235.638-20.676Z" style="fill:#888;fill-rule:nonzero" transform="matrix(.30366 0 0 .30366 506.822 60.065)"/></svg>')}`;var U2=new WeakMap;var U7=new WeakMap([]);function Y2(e){let o=Y7(e),t=new Path2D(o);return U7.set(e,t),t}function Y7(e){let o=e.simulatePressure?e.points:e.points.length?e.points.map(([n,r],i)=>[n,r,e.pressures[i]]):[[0,0,.5]],t={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 V7(z7(o,t))}function H2(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var W7=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function V7(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,n,r,i)=>(r===o?t.push(n,H2(n,i[0]),"L",i[0],"Z"):t.push(n,H2(n,i[r+1])),t),["M",e[0],"Q"]).join(" ").replace(W7,"$1")}var W2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var st=class st{};I(st,"rg",new q7),I(st,"cache",new WeakMap),I(st,"get",o=>st.cache.get(o)),I(st,"set",(o,t)=>st.cache.set(o,t)),I(st,"delete",o=>st.cache.delete(o)),I(st,"destroy",()=>{st.cache=new WeakMap}),I(st,"generateElementShape",(o,t)=>{let n=t?.isExporting?void 0:st.get(o);if(n!==void 0)return n;U2.delete(o);let r=eD(o,st.rg,t||{isExporting:!1,canvasBackgroundColor:j7.white,embedsValidationStatus:null});return st.cache.set(o,r),r});var Ei=st,J7=e=>[8,8+e],Z2=e=>[1.5,6+e];function Q7(e){let o=e.roughness,t=Math.max(e.width,e.height),n=Math.min(e.width,e.height);return n>=20&&t>=50||n>=15&&e.roundness&&W2(e.type)||hn(e)&&t>=50?o:Math.min(o/(t<10?3:2),2.5)}var Oo=(e,o=!1)=>{let t={seed:e.seed,strokeLineDash:e.strokeStyle==="dashed"?J7(e.strokeWidth):e.strokeStyle==="dotted"?Z2(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:Q7(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<Z7.cartoonist};switch(e.type){case"rectangle":case"iframe":case"embeddable":case"diamond":case"ellipse":return t.fillStyle=e.fillStyle,t.fill=Wa(e.backgroundColor)?void 0:e.backgroundColor,e.type==="ellipse"&&(t.curveFitting=1),t;case"line":case"freedraw":return Fc(e.points)&&(t.fillStyle=e.fillStyle,t.fill=e.backgroundColor==="transparent"?void 0:e.backgroundColor),t;case"arrow":return t;default:throw new Error(`Unimplemented type ${e.type}`)}},X2=(e,o,t)=>mh(e)&&(o||I2(e)&&t?.get(e.id)!==!0)&&Wa(e.backgroundColor)&&Wa(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:C2(e)?{...e,strokeColor:Wa(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Wa(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,K2=(e,o,t,n,r,i,a)=>{let l=yh(e,o,t,n);if(l===null)return[];let s=(d,m)=>{if(d===null)return[];let[,,c,p,u,f]=d;return[r.line(c,p,u,f,m)]};switch(n){case"dot":case"circle":case"circle_outline":{let[d,m,c]=l;return delete i.strokeLineDash,[r.circle(d,m,c,{...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[d,m,c,p,u,f]=l;return delete i.strokeLineDash,[r.polygon([[d,m],[c,p],[u,f],[d,m]],{...i,fill:n==="triangle_outline"?a:e.strokeColor,fillStyle:"solid",roughness:Math.min(1,i.roughness||0)})]}case"diamond":case"diamond_outline":{let[d,m,c,p,u,f,b,x]=l;return delete i.strokeLineDash,[r.polygon([[d,m],[c,p],[u,f],[b,x],[d,m]],{...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[d,m,c,p,u,f]=l;if(e.strokeStyle==="dotted"){let b=Z2(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(c,p,d,m,i),r.line(u,f,d,m,i),...n==="crowfoot_one_or_many"?s(yh(e,o,t,"crowfoot_one"),i):[]]}}};var eD=(e,o,{isExporting:t,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=Ha(Math.min(a,l),e);i=o.path(`M ${s} 0 L ${a-s} 0 Q ${a} 0, ${a} ${s} L ${a} ${l-s} Q ${a} ${l}, ${a-s} ${l} L ${s} ${l} Q 0 ${l}, 0 ${l-s} L 0 ${s} Q 0 0, ${s} 0`,Oo(X2(e,t,r),!0))}else i=o.rectangle(0,0,e.width,e.height,Oo(X2(e,t,r),!1));return i}case"diamond":{let i,[a,l,s,d,m,c,p,u]=dh(e);if(e.roundness){let f=Ha(Math.abs(a-p),e),b=Ha(Math.abs(d-l),e);i=o.path(`M ${a+f} ${l+b} L ${s-f} ${d-b}
9
+ C ${s} ${d}, ${s} ${d}, ${s-f} ${d+b}
10
+ L ${m+f} ${c-b}
11
+ C ${m} ${c}, ${m} ${c}, ${m-f} ${c-b}
12
+ L ${p+f} ${u+b}
13
+ C ${p} ${u}, ${p} ${u}, ${p+f} ${u-b}
14
+ L ${a-f} ${l+b}
15
+ C ${a} ${l}, ${a} ${l}, ${a+f} ${l+b}`,Oo(e,!0))}else i=o.polygon([[a,l],[s,d],[m,c],[p,u]],Oo(e));return i}case"ellipse":return o.ellipse(e.width/2,e.height/2,e.width,e.height,Oo(e));case"line":case"arrow":{let i,a=Oo(e),l=e.points.length?e.points:[K7(0,0)];if(Ga(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(tD(l,16),Oo(e,!0))]:(console.error("Elbow arrow with extreme point positions detected. Arrow not rendered.",e.id,JSON.stringify(l)),i=[]):e.roundness?i=[o.curve(l,a)]:a.fill?i=[o.polygon(l,a)]:i=[o.linearPath(l,a)],e.type==="arrow"){let{startArrowhead:s=null,endArrowhead:d="arrow"}=e;if(s!==null){let m=K2(e,i,"start",s,o,a,n);i.push(...m)}if(d!==null){let m=K2(e,i,"end",d,o,a,n);i.push(...m)}}return i}case"freedraw":{let i;if(Y2(e),Fc(e.points)){let a=X7(e.points,.75);i=o.curve(a,{...Oo(e),stroke:"none"})}else i=null;return i}case"frame":case"magicframe":case"text":case"image":return null;default:return $7(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},tD=(e,o)=>{let t=[];for(let r=1;r<e.length-1;r+=1){let i=e[r-1],a=e[r+1],l=e[r],s=Hc(l,i),d=Hc(a,l),m=Math.min(o,V2(e[r],a)/2,V2(e[r],i)/2);s?i[0]<l[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):i[1]<l[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m]),t.push(e[r]),d?a[0]<l[0]?t.push([e[r][0]-m,e[r][1]]):t.push([e[r][0]+m,e[r][1]]):a[1]<l[1]?t.push([e[r][0],e[r][1]-m]):t.push([e[r][0],e[r][1]+m])}let n=[`M ${e[0][0]} ${e[0][1]}`];for(let r=0;r<t.length;r+=3)n.push(`L ${t[r][0]} ${t[r][1]}`),n.push(`Q ${t[r+1][0]} ${t[r+1][1]}, ${t[r+2][0]} ${t[r+2][1]}`);return n.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),n.join(" ")};var $2=(e,o,t=!1)=>{let n=!1;for(let r in o){let i=o[r];if(typeof i<"u"){if(e[r]===i&&(typeof i!="object"||i===null))continue;n=!0}}return!n&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??oD(),updated:nD()}};import{jsx as q2}from"react/jsx-runtime";var vi=B({name:"toggleLinearEditor",category:ke.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&r.length===1&&iD(r[0])&&!rD(r[0]))},perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];Ih(r,"No selected element found"),Ih(o.selectedLinearElement,"No selected linear element found"),Ih(r.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:j2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],r=g(n.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return q2(K,{type:"button",icon:cb,title:r,"aria-label":r,onClick:()=>o(null)})}}),k1e=B({name:"togglePolygon",category:ke.elements,icon:ym,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!wi(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return r.length>0&&r.every(i=>wi(i)&&i.points.length>=4)},perform(e,o,t,n){let r=n.scene.getSelectedElements(o);if(r.some(s=>!wi(s)))return!1;let i=r,a=i.some(s=>!s.polygon),l=aD(i);return{elements:e.map(s=>!l.has(s.id)||!wi(s)?s:$2(s,{backgroundColor:a?s.backgroundColor:"transparent",...lD(s,a)})),appState:o,captureUpdate:j2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(n.length===0||n.some(a=>!wi(a)||!a.polygon||a.points.length<3))return null;let r=n.every(a=>wi(a)&&a.polygon),i=g(r?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return q2(Dr,{icon:ym,title:i,"aria-label":i,active:r,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as J2,CANVAS_SEARCH_TAB as Q2,CLASSES as sD,DEFAULT_SIDEBAR as ew}from"@excalidraw/common";import{CaptureUpdateAction as cD}from"@excalidraw/element";var za=B({name:"searchMenu",icon:Pt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,n){if(o.openDialog)return!1;if(o.openSidebar?.name===ew.name&&o.openSidebar.tab===Q2){let r=n.excalidrawContainerValue.container?.querySelector(`.${sD.SEARCH_MENU_INPUT_WRAPPER} input`);return r?.focus(),r?.select(),!1}return{appState:{...o,openSidebar:{name:ew.name,tab:Q2},openDialog:null},captureUpdate:cD.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[J2.CTRL_OR_CMD]&&e.key===J2.F});import{isImageElement as dD}from"@excalidraw/element";import{CaptureUpdateAction as mD}from"@excalidraw/element";import{jsx as pD}from"react/jsx-runtime";var Ch=B({name:"cropEditor",label:"helpDialog.cropStart",icon:Ym,viewMode:!0,trackEvent:{category:"menu"},keywords:["image","crop"],perform(e,o,t,n){let r=n.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];return{appState:{...o,isCropping:!1,croppingElementId:r.id},captureUpdate:mD.IMMEDIATELY}},predicate:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o);return!!(!o.croppingElementId&&r.length===1&&dD(r[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let n=g("helpDialog.cropStart");return pD(K,{type:"button",icon:Ym,title:n,"aria-label":n,onClick:()=>o(null)})}});import{getNonDeletedElements as uD}from"@excalidraw/element";import{mutateElement as hD}from"@excalidraw/element";import{newFrameElement as gD}from"@excalidraw/element";import{isFrameLikeElement as Wc}from"@excalidraw/element";import{addElementsToFrame as fD,removeAllElementsFromFrame as bD}from"@excalidraw/element";import{getFrameChildren as xD}from"@excalidraw/element";import{KEYS as tw,updateActiveTool as ow}from"@excalidraw/common";import{getElementsInGroup as ED}from"@excalidraw/element";import{getCommonBounds as yD}from"@excalidraw/element";import{CaptureUpdateAction as or}from"@excalidraw/element";var nw=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&Wc(t[0])},rw=B({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;if(Wc(r)){let i=xD(uD(e),r.id).filter(a=>!(a.type==="text"&&a.containerId));return{elements:e,appState:{...o,selectedElementIds:i.reduce((a,l)=>(a[l.id]=!0,a),{})},captureUpdate:or.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:or.EVENTUALLY}},predicate:(e,o,t,n)=>nw(o,n)}),iw=B({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,n)=>{let r=n.scene.getSelectedElements(o).at(0)||null;return Wc(r)?{elements:bD(e,r),appState:{...o,selectedElementIds:{[r.id]:!0}},captureUpdate:or.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:or.EVENTUALLY}},predicate:(e,o,t,n)=>nw(o,n)}),B0e=B({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:or.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),F0e=B({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Gn,viewMode:!1,perform:(e,o,t,n)=>{let r=ow(o,{type:"frame"});return Dt(n.interactiveCanvas,{...o,activeTool:r}),{elements:e,appState:{...o,activeTool:ow(o,{type:"frame"})},captureUpdate:or.EVENTUALLY}},keyTest:e=>!e[tw.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===tw.F}),aw=B({name:"wrapSelectionInFrame",label:"labels.wrapSelectionInFrame",trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=j(e,o);return r.length>0&&!r.some(i=>Wc(i))},perform:(e,o,t,n)=>{let r=j(e,o),i=n.scene.getNonDeletedElementsMap(),[a,l,s,d]=yD(r,i),m=16,c=gD({x:a-m,y:l-m,width:s-a+m*2,height:d-l+m*2});if(o.editingGroupId){let u=ED(r,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);hD(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:fD([...n.scene.getElementsIncludingDeleted(),c],r,c,o),appState:{selectedElementIds:{[c.id]:!0}},captureUpdate:or.IMMEDIATELY}}});import{isWindows as kD,KEYS as Xa,matchKey as Mh,arrayToMap as lw}from"@excalidraw/common";import{CaptureUpdateAction as kh}from"@excalidraw/element";import{orderByFractionalIndex as MD}from"@excalidraw/element";import{Emitter as wD}from"@excalidraw/common";import{CaptureUpdateAction as vD,StoreChange as TD,StoreDelta as ID}from"@excalidraw/element";var Ti=class extends ID{applyTo(o,t,n){let[r,i]=this.elements.applyTo(o,n.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,r);return[r,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,n,r){return super.applyLatestChanges(o,t,n,r)}},nr=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},Va=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new wD);I(this,"undoStack",[]);I(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o){if(o.isEmpty()||o instanceof Ti)return;let t=Ti.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new nr(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n))}perform(o,t,n,r){try{let i=n();if(i===null)return;let a=vD.IMMEDIATELY,l=this.store.snapshot,s=o,d=t,m=!1;for(;i;){try{[s,d,m]=i.applyTo(s,d,l);let c=l.elements,p=l.maybeClone(a,s,d),u=TD.create(l,p),f=Ti.applyLatestChanges(i,c,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{r(i)}if(m)break;i=n()}return[s,d]}finally{this.onHistoryChangedEmitter.trigger(new nr(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let n=Ti.inverse(t);return o.push(n)}};import{useEffect as CD,useState as SD}from"react";var Sh=(e,o)=>{let[t,n]=SD(o);return CD(()=>{let r=e.on(i=>{n(i)});return()=>{r()}},[e]),t};import{jsx as mw}from"react/jsx-runtime";var sw=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let n=t();if(!n)return{captureUpdate:kh.EVENTUALLY};let[r,i]=n,a=MD(Array.from(r.values()));return{appState:i,elements:a,captureUpdate:kh.NEVER}}return{captureUpdate:kh.EVENTUALLY}},cw=e=>({name:"undo",label:"buttons.undo",icon:Sm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>sw(r,t,()=>e.undo(lw(o),t)),keyTest:o=>o[Xa.CTRL_OR_CMD]&&Mh(o,Xa.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:n}=Sh(e.onHistoryChangedEmitter,new nr(e.isUndoStackEmpty,e.isRedoStackEmpty));return mw(K,{type:"button",icon:Sm,"aria-label":g("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),dw=e=>({name:"redo",label:"buttons.redo",icon:km,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,n,r)=>sw(r,t,()=>e.redo(lw(o),t)),keyTest:o=>o[Xa.CTRL_OR_CMD]&&o.shiftKey&&Mh(o,Xa.Z)||kD&&o.ctrlKey&&!o.shiftKey&&Mh(o,Xa.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:n}=Sh(e.onHistoryChangedEmitter,new nr(e.isUndoStackEmpty,e.isRedoStackEmpty));return mw(K,{type:"button",icon:km,"aria-label":g("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:n,"data-testid":"button-redo"})}});import{getFontString as LD}from"@excalidraw/common";import{newElementWith as PD}from"@excalidraw/element";import{measureText as AD}from"@excalidraw/element";import{isTextElement as pw}from"@excalidraw/element";import{CaptureUpdateAction as DD}from"@excalidraw/element";var uw=B({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,n)=>{let r=j(e,o);return r.length===1&&pw(r[0])&&!r[0].autoResize},perform:(e,o,t,n)=>{let r=j(e,o);return{appState:o,elements:e.map(i=>{if(i.id===r[0].id&&pw(i)){let a=AD(i.originalText,LD(i),i.lineHeight);return PD(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:DD.IMMEDIATELY}}});import{CODES as _D,KEYS as RD}from"@excalidraw/common";import{CaptureUpdateAction as ND}from"@excalidraw/element";var Lh=B({name:"viewMode",label:"labels.viewMode",icon:Mr,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:ND.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[RD.CTRL_OR_CMD]&&e.altKey&&e.code===_D.R});import{isPromiseLike as BD}from"@excalidraw/common";import{jsx as FD}from"react/jsx-runtime";var Ph=(e,o,t,n,r,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,n,i))&&ne(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${r.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Vc=class{constructor(o,t,n,r){I(this,"actions",{});I(this,"updater");I(this,"getAppState");I(this,"getElementsIncludingDeleted");I(this,"app");I(this,"renderAction",(o,t)=>{let n=this.app.props.UIOptions.canvasActions;if(this.actions[o]&&"PanelComponent"in this.actions[o]&&(!(o in n)||n[o])){let r=this.actions[o],i=r.PanelComponent;i.displayName="PanelComponent";let a=this.getElementsIncludingDeleted(),l=this.getAppState(),s=d=>{Ph(r,"ui",l,a,this.app,d),this.updater(r.perform(this.getElementsIncludingDeleted(),this.getAppState(),d,this.app))};return FD(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t,renderAction:this.renderAction})}return null});I(this,"isActionEnabled",o=>{let t=this.getElementsIncludingDeleted(),n=this.getAppState();return!o.predicate||o.predicate(t,n,this.app.props,this.app)});this.updater=i=>{if(BD(i))i.then(a=>o(a));else return o(i)},this.getAppState=t,this.getElementsIncludingDeleted=n,this.app=r}registerAction(o){this.actions[o.name]=o}registerAll(o){o.forEach(t=>this.registerAction(t))}handleKeyDown(o){let t=this.app.props.UIOptions.canvasActions,n=Object.values(this.actions).sort((s,d)=>(d.keyPriority||0)-(s.keyPriority||0)).filter(s=>(s.name in t?t[s.name]:!0)&&s.keyTest&&s.keyTest(o,this.getAppState(),this.getElementsIncludingDeleted(),this.app));if(n.length!==1)return n.length>1&&console.warn("Canceling as multiple actions match this shortcut",n),!1;let r=n[0];if(this.getAppState().viewModeEnabled&&r.viewMode!==!0)return!1;let i=this.getElementsIncludingDeleted(),a=this.getAppState(),l=null;return Ph(r,"keyboard",a,i,this.app,null),o.preventDefault(),o.stopPropagation(),this.updater(n[0].perform(i,a,l,this.app)),!0}executeAction(o,t="api",n=null){let r=this.getElementsIncludingDeleted(),i=this.getAppState();Ph(o,t,i,r,this.app,n),this.updater(o.perform(r,i,n,this.app))}};var Xc=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 n=this.targets.get(o);if(!n)return;let r=this.onFrame(n,t);!n.stopped&&!r?this.scheduleFrame(o):this.cancelFrame(o)}}scheduleFrame(o){let t=requestAnimationFrame(this.constructFrame(o));this.rafIds.set(o,t)}cancelFrame(o){if(this.rafIds.has(o)){let t=this.rafIds.get(o);cancelAnimationFrame(t)}this.rafIds.delete(o)}onFrame(o,t){return o.callback(t)??!1}};var Ah=e=>{let o=Array.from(e.values());return{x:hw(o,t=>t.x)/o.length,y:hw(o,t=>t.y)/o.length}},Dh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),hw=(e,o)=>e.reduce((t,n)=>t+o(n),0);import{pointFrom as H,pointRotateRads as gn,rangeInclusive as Yt,rangeIntersection as Kc,rangesOverlap as Zc}from"@excalidraw/math";import{TOOL_TYPE as rr,KEYS as gw}from"@excalidraw/common";import{getCommonBounds as _h,getDraggedElementsBounds as Rh,getElementAbsoluteCoords as OD}from"@excalidraw/element";import{isBoundToContainer as Ew}from"@excalidraw/element";import{getMaximumGroups as yw}from"@excalidraw/element";import{getSelectedElements as zD,getVisibleAndNonSelectedElements as ww}from"@excalidraw/element";var HD=8,fw=99999,$c=e=>HD/e,gt=class gt{};I(gt,"referenceSnapPoints",null),I(gt,"visibleGaps",null),I(gt,"setReferenceSnapPoints",o=>{gt.referenceSnapPoints=o}),I(gt,"getReferenceSnapPoints",()=>gt.referenceSnapPoints),I(gt,"setVisibleGaps",o=>{gt.visibleGaps=o}),I(gt,"getVisibleGaps",()=>gt.visibleGaps),I(gt,"destroy",()=>{gt.referenceSnapPoints=null,gt.visibleGaps=null});var Wt=gt,fn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Ho=({event:e,app:o,selectedElements:t})=>{if(e){let n=o.state.activeTool.type==="lasso"&&o.state.selectedElementsAreBeingDragged;return(o.state.activeTool.type!=="lasso"||n)&&(o.state.objectsSnapModeEnabled&&!e[gw.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[gw.CTRL_OR_CMD]&&!fn(o))}return t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled},GD=(e,o,t=.01)=>Math.abs(e-o)<=t,Ka=(e,o,{omitCenter:t,boundingBoxCorners:n,dragOffset:r}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,d,m,c,p]=OD(a,o);r&&(l+=r.x,d+=r.x,c+=r.x,s+=r.y,m+=r.y,p+=r.y);let u=(d-l)/2,f=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!n){let b=gn(H(l,s+f),H(c,p),a.angle),x=gn(H(l+u,s),H(c,p),a.angle),w=gn(H(d,s+f),H(c,p),a.angle),E=gn(H(l+u,m),H(c,p),a.angle),y=H(c,p);i=t?[b,x,w,E]:[b,x,w,E,y]}else{let b=gn(H(l,s),H(c,p),a.angle),x=gn(H(d,s),H(c,p),a.angle),w=gn(H(l,m),H(c,p),a.angle),E=gn(H(d,m),H(c,p),a.angle),y=H(c,p);i=t?[b,x,w,E]:[b,x,w,E,y]}}else if(e.length>1){let[a,l,s,d]=Rh(e,r??{x:0,y:0}),m=s-a,c=d-l,p=H(a,l),u=H(s,l),f=H(a,d),b=H(s,d),x=H(a+m/2,l+c/2);i=t?[p,u,f,b]:[p,u,f,b,x]}return i.map(a=>H(Le(a[0]),Le(a[1])))},vw=(e,o,t,n)=>ww(e,o,t,n),Tw=(e,o,t,n)=>{let r=vw(e,o,t,n),i=yw(r,n).filter(c=>!(c.length===1&&Ew(c[0]))).map(c=>_h(c).map(p=>Le(p))),a=i.sort((c,p)=>c[0]-p[0]),l=[],s=0;e:for(let c=0;c<a.length;c++){let p=a[c];for(let u=c+1;u<a.length;u++){if(++s>fw)break e;let f=a[u],[,b,x,w]=p,[E,y,,v]=f;x<E&&Zc(Yt(b,w),Yt(y,v))&&l.push({startBounds:p,endBounds:f,startSide:[H(x,b),H(x,w)],endSide:[H(E,y),H(E,v)],length:E-x,overlap:Kc(Yt(b,w),Yt(y,v))})}}let d=i.sort((c,p)=>c[1]-p[1]),m=[];s=0;e:for(let c=0;c<d.length;c++){let p=d[c];for(let u=c+1;u<d.length;u++){if(++s>fw)break e;let f=d[u],[b,,x,w]=p,[E,y,v]=f;w<y&&Zc(Yt(b,x),Yt(E,v))&&m.push({startBounds:p,endBounds:f,startSide:[H(b,w),H(x,w)],endSide:[H(E,y),H(v,y)],length:y-w,overlap:Kc(Yt(b,x),Yt(E,v))})}}return{horizontalGaps:l,verticalGaps:m}},bw=(e,o,t,n,r,i,a)=>{if(!Ho({app:t,event:n,selectedElements:e}))return[];if(e.length===0)return[];let l=Wt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:d}=l,[m,c,p,u]=Rh(e,o).map(x=>Le(x)),f=(m+p)/2,b=(c+u)/2;for(let x of s){if(!Zc(Yt(c,u),x.overlap))continue;let w=x.startSide[0][0]+x.length/2,E=Le(w-f);if(x.length>p-m&&Math.abs(E)<=a.x){Math.abs(E)<a.x&&(r.length=0),a.x=Math.abs(E);let P={type:"gap",direction:"center_horizontal",gap:x,offset:E};r.push(P);continue}let[,,v]=x.endBounds,C=m-v,S=Le(x.length-C);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(r.length=0),a.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};r.push(P);continue}let[L,,,]=x.startBounds,k=L-p,A=Le(k-x.length);if(Math.abs(A)<=a.x){Math.abs(A)<a.x&&(r.length=0),a.x=Math.abs(A);let P={type:"gap",direction:"side_left",gap:x,offset:A};r.push(P);continue}}for(let x of d){if(!Zc(Yt(m,p),x.overlap))continue;let w=x.startSide[0][1]+x.length/2,E=Le(w-b);if(x.length>u-c&&Math.abs(E)<=a.y){Math.abs(E)<a.y&&(i.length=0),a.y=Math.abs(E);let P={type:"gap",direction:"center_vertical",gap:x,offset:E};i.push(P);continue}let[,v,,]=x.startBounds,C=v-u,S=Le(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[,,,L]=x.endBounds,k=Le(c-L),A=x.length-k;if(Math.abs(A)<=a.y){Math.abs(A)<a.y&&(i.length=0),a.y=Math.abs(A);let P={type:"gap",direction:"side_bottom",gap:x,offset:A};i.push(P);continue}}}},Iw=(e,o,t,n)=>{let r=vw(e,o,t,n);return yw(r,n).filter(i=>!(i.length===1&&Ew(i[0]))).flatMap(i=>Ka(i,n))},Ii=(e,o,t,n,r,i,a)=>{if(!Ho({app:t,event:n,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Wt.getReferenceSnapPoints();if(l)for(let s of o)for(let d of l){let m=d[0]-s[0],c=d[1]-s[1];Math.abs(m)<=a.x&&(Math.abs(m)<a.x&&(r.length=0),r.push({type:"point",points:[s,d],offset:m}),a.x=Math.abs(m)),Math.abs(c)<=a.y&&(Math.abs(c)<a.y&&(i.length=0),i.push({type:"point",points:[s,d],offset:c}),a.y=Math.abs(c))}},Cw=(e,o,t,n,r)=>{let i=t.state,a=zD(e,i);if(!Ho({app:t,event:n,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=Le(o.x),o.y=Le(o.y);let l=[],s=[],d=$c(i.zoom.value),m={x:d,y:d},c=Ka(a,r,{dragOffset:o});Ii(a,c,t,n,l,s,m),bw(a,o,t,n,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:Le(o.x+p.x),y:Le(o.y+p.y)};Ii(a,Ka(a,r,{dragOffset:u}),t,n,l,s,m),bw(a,u,t,n,l,s,m);let f=Nh(l,s),b=YD(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Le=e=>Math.round(e*10**6)/10**6,xw=e=>{let o=new Map;for(let t of e){let n=t.join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},Nh=(e,o)=>{let t={},n={};if(e.length>0){for(let r of e)if(r.type==="point"){let i=Le(r.points[0][0]);t[i]||(t[i]=[]),t[i].push(...r.points.map(a=>H(Le(a[0]),Le(a[1]))))}}if(o.length>0){for(let r of o)if(r.type==="point"){let i=Le(r.points[0][1]);n[i]||(n[i]=[]),n[i].push(...r.points.map(a=>H(Le(a[0]),Le(a[1]))))}}return Object.entries(t).map(([r,i])=>({type:"points",points:xw(i.map(a=>H(Number(r),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(n).map(([r,i])=>({type:"points",points:xw(i.map(a=>H(a[0],Number(r))).sort((a,l)=>a[0]-l[0]))})))},UD=e=>{let o=new Map;for(let t of e){let n=t.points.flat().map(r=>[Le(r)]).join(",");o.has(n)||o.set(n,t)}return Array.from(o.values())},YD=(e,o,t)=>{let[n,r,i,a]=Rh(e,o),l=[];for(let s of t){let[d,m,c,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,w=Kc(Yt(r,a),s.gap.overlap),E=Kc(Yt(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:[H(s.gap.startSide[0][0],y),H(n,y)]},{type:"gap",direction:"horizontal",points:[H(i,y),H(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:[H(y,s.gap.startSide[0][1]),H(y,r)]},{type:"gap",direction:"vertical",points:[H(y,a),H(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:[H(c,y),H(u,y)]},{type:"gap",direction:"horizontal",points:[H(b,y),H(n,y)]})}break}case"side_left":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(i,y),H(d,y)]},{type:"gap",direction:"horizontal",points:[H(c,y),H(u,y)]})}break}case"side_top":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(y,a),H(y,m)]},{type:"gap",direction:"vertical",points:[H(y,p),H(y,f)]})}break}case"side_bottom":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"vertical",points:[H(y,p),H(y,f)]},{type:"gap",direction:"vertical",points:[H(y,x),H(y,r)]})}break}}}return UD(l.map(s=>({...s,points:s.points.map(d=>H(Le(d[0]),Le(d[1])))})))},Bh=(e,o,t,n,r,i)=>{if(!Ho({event:n,selectedElements:e,app:t})||e.length===0||e.length===1&&!GD(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,d]=_h(o);i&&(i.includes("e")?s+=r.x:i.includes("w")&&(a+=r.x),i.includes("n")?l+=r.y:i.includes("s")&&(d+=r.y));let m=[];if(i)switch(i){case"e":{m.push(H(s,l),H(s,d));break}case"w":{m.push(H(a,l),H(a,d));break}case"n":{m.push(H(a,l),H(s,l));break}case"s":{m.push(H(a,d),H(s,d));break}case"ne":{m.push(H(s,l));break}case"nw":{m.push(H(a,l));break}case"se":{m.push(H(s,d));break}case"sw":{m.push(H(a,d));break}}let c=$c(t.state.zoom.value),p={x:c,y:c},u=[],f=[];Ii(o,m,t,n,u,f,p);let b={x:u[0]?.offset??0,y:f[0]?.offset??0};p.x=0,p.y=0,u.length=0,f.length=0;let[x,w,E,y]=_h(e).map(S=>Le(S)),v=[H(x,w),H(x,y),H(E,w),H(E,y)];Ii(e,v,t,n,u,f,p);let C=Nh(u,f);return{snapOffset:b,snapLines:C}},Sw=(e,o,t,n,r,i)=>{if(!Ho({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[H(n.x+r.x,n.y+r.y)],l=$c(o.state.zoom.value),s={x:l,y:l},d=[],m=[];Ii([e],a,o,t,d,m,s);let c={x:d[0]?.offset??0,y:m[0]?.offset??0};s.x=0,s.y=0,d.length=0,m.length=0;let p=Ka([e],i,{boundingBoxCorners:!0,omitCenter:!0});Ii([e],p,o,t,d,m,s);let u=Nh(d,m);return{snapOffset:c,snapLines:u}},kw=(e,o,t,n,r)=>{if(!Ho({event:n,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=ww(e,[],o.state,r),a=$c(o.state.zoom.value),l={x:a,y:a},s=[],d=[];for(let m of i){let c=Ka([m],r);for(let p of c){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(d.length=0),d.push({type:"pointer",points:[p,H(p[0],t.y)],direction:"vertical"}),l.x=u);let f=p[1]-t.y;Math.abs(f)<=Math.abs(l.y)&&(Math.abs(f)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,H(t.x,p[1])],direction:"horizontal"}),l.y=f)}}return{originOffset:{x:d.length>0?d[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...d,...s]}},Mw=e=>e===rr.rectangle||e===rr.ellipse||e===rr.diamond||e===rr.frame||e===rr.magicframe||e===rr.image||e===rr.text;import{pointFrom as jc}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as WD,DEFAULT_FONT_SIZE as VD,TEXT_ALIGN as XD,VERTICAL_ALIGN as KD,getSizeFromPoints as ZD,randomId as $D,arrayToMap as jD,assertNever as Fh,cloneJSON as Aw,getFontString as qD,isDevEnv as JD,toBrandedType as QD,getLineHeight as e_}from"@excalidraw/common";import{bindLinearElement as Lw}from"@excalidraw/element";import{newArrowElement as t_,newElement as Oh,newFrameElement as o_,newImageElement as n_,newLinearElement as r_,newMagicFrameElement as i_,newTextElement as Jc}from"@excalidraw/element";import{measureText as a_,normalizeText as l_}from"@excalidraw/element";import{isArrowElement as s_}from"@excalidraw/element";import{syncInvalidIndices as c_}from"@excalidraw/element";import{redrawTextBoundingBox as d_}from"@excalidraw/element";import{LinearElementEditor as m_}from"@excalidraw/element";import{getCommonBounds as p_}from"@excalidraw/element";import{Scene as u_}from"@excalidraw/element";var qc={width:100,height:0},bn=100,h_=(e,o,t)=>{let n=Jc({x:0,y:0,textAlign:XD.CENTER,verticalAlign:KD.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:n.id})}),d_(n,e,t),[e,n]},Pw=(e,o,t,n,r)=>{let i,a;if(Object.assign(e,{startBinding:e?.startBinding||null,endBinding:e.endBinding||null}),o){let m=o?.width??bn,c=o?.height??bn,p;o.id&&(p=n.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-m,f=o.y||e.y-c/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=Jc({x:u,y:f,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=Oh({x:u,y:f,width:m,height:c,...p,...o,type:b});break}default:Fh(e,`Unhandled element start type "${o.type}"`,!0)}Lw(e,i,"start",r)}}if(t){let m=t?.height??bn,c=t?.width??bn,p;t.id&&(p=n.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,f=t.y||e.y-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=Jc({x:u,y:f,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=Oh({x:u,y:f,width:c,height:m,...p,...t,type:b});break}default:Fh(e,`Unhandled element end type "${b}"`,!0)}Lw(e,a,"end",r)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,d=Aw(e.points);return e.points[l][0]>e.points[l-1][0]&&(d[0][0]=s,d[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(d[0][0]=-s,d[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(d[0][1]=s,d[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(d[0][1]=-s,d[l][1]+=s),Object.assign(e,m_.getNormalizeElementPointsAndCoords({...e,points:d})),{linearElement:e,startBoundElement:i,endBoundElement:a}},zh=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>c_(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>QD(jD(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Ci=(e,o)=>{if(!e)return[];let t=Aw(e),n=new zh,r=new Map,i=new Map;for(let s of t){let d,m=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:$D()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||bn,u=s?.label?.text&&s.height===void 0?0:s?.height||bn;d=Oh({...s,width:p,height:u});break}case"line":{let p=s.width||qc.width,u=s.height||qc.height;d=r_({width:p,height:u,points:[jc(0,0),jc(p,u)],...s});break}case"arrow":{let p=s.width||qc.width,u=s.height||qc.height;d=t_({width:p,height:u,endArrowhead:"arrow",points:[jc(0,0),jc(p,u)],...s,type:"arrow"}),Object.assign(d,ZD(d.points));break}case"text":{let p=s?.fontFamily||WD,u=s?.fontSize||VD,f=s?.lineHeight||e_(p),b=s.text??"",x=l_(b),w=a_(x,qD({fontFamily:p,fontSize:u}),f);d=Jc({width:w.width,height:w.height,fontFamily:p,fontSize:u,...s});break}case"image":{d=n_({width:s?.width||bn,height:s?.height||bn,...s});break}case"frame":{d=o_({x:0,y:0,...s});break}case"magicframe":{d=i_({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{d=s;break}default:d=s,Fh(s,`Unhandled element type "${s.type}"`,!0)}n.getElement(d.id)?console.error(`Duplicate id found for ${d.id}`):(n.add(d),r.set(d.id,s),m&&i.set(m,d.id))}let a=n.getElementsMap(),l=new u_(a);for(let[s,d]of r){let m=n.getElement(s);switch(d.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(d.label?.text){let[c,p]=h_(m,d?.label,l);if(n.add(c),n.add(p),s_(c)){let u=d.type==="arrow"?d?.start:void 0,f=d.type==="arrow"?d?.end:void 0;if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}if(f&&f.id){let E=i.get(f.id);E&&Object.assign(f,{id:E})}let{linearElement:b,startBoundElement:x,endBoundElement:w}=Pw(c,u,f,n,l);c=b,n.add(b),n.add(x),n.add(w)}}else switch(d.type){case"arrow":{let{start:c,end:p}=d;if(c&&c.id){let x=i.get(c.id);Object.assign(c,{id:x})}if(p&&p.id){let x=i.get(p.id);Object.assign(p,{id:x})}let{linearElement:u,startBoundElement:f,endBoundElement:b}=Pw(m,c,p,n,l);n.add(u),n.add(f),n.add(b);break}}break}}}for(let[s,d]of r){if(d.type!=="frame"&&d.type!=="magicframe")continue;let m=n.getElement(s);if(!m)throw new Error(`Excalidraw element with id ${s} doesn't exist`);let c=[];d.children.forEach(C=>{let S=i.get(C);if(!S)throw new Error(`Element with ${C} wasn't mapped correctly`);let L=n.getElement(S);if(!L)throw new Error(`Frame element with id ${S} doesn't exist`);Object.assign(L,{frameId:m.id}),L?.boundElements?.forEach(k=>{let A=n.getElement(k.id);if(!A)throw new Error(`Bound element with id ${k.id} doesn't exist`);Object.assign(A,{frameId:m.id}),c.push(A)}),c.push(L)});let[p,u,f,b]=p_(c),x=10;p=p-x,u=u-x,f=f+x,b=b+x;let w=m?.x||p,E=m?.y||u,y=m?.width||f-p,v=m?.height||b-u;Object.assign(m,{x:w,y:E,width:y,height:v}),JD()&&d.children.length&&(m?.x||m?.y||m?.width||m?.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 W_}from"@excalidraw/element";import{memoize as V_,toBrandedType as X_}from"@excalidraw/common";import{pointFrom as v_,pointsEqual as T_}from"@excalidraw/math";import ed from"open-color";import{arrayToMap as I_,DEFAULT_TRANSFORM_HANDLE_SPACING as Kh,FRAME_STYLE as Ow,invariant as zw,THEME as C_,throttleRAF as S_}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as Gh,maxBindingGap as Vw}from"@excalidraw/element";import{LinearElementEditor as xn}from"@excalidraw/element";import{getOmitSidesForDevice as Uh,getTransformHandles as k_,getTransformHandlesFromCoords as M_,shouldShowBoundingBox as L_}from"@excalidraw/element";import{isElbowArrow as Za,isFrameLikeElement as Hw,isImageElement as Gw,isLinearElement as P_,isLineElement as A_,isTextElement as Uw}from"@excalidraw/element";import{renderSelectionElement as D_}from"@excalidraw/element";import{getElementsInGroup as Vh,getSelectedGroupIds as __,isSelectedViaGroup as R_,selectGroupsFromGivenElements as N_}from"@excalidraw/element";import{getCommonBounds as Xh,getElementAbsoluteCoords as $a}from"@excalidraw/element";import{pointFrom as ct}from"@excalidraw/math";import{THEME as g_}from"@excalidraw/common";var f_="#ff6b6b",b_="#ff0000",Dw=1,_w=2,Rw=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===g_.LIGHT||o.zenModeEnabled?f_:b_,n=(o.zenModeEnabled?Dw*1.5:Dw)/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY);for(let r of o.snapLines)r.type==="pointer"?(e.lineWidth=n,e.strokeStyle=t,E_(r,e,o)):r.type==="gap"?(e.lineWidth=n,e.strokeStyle=t,y_(r.points[0],r.points[1],r.direction,o,e)):r.type==="points"&&(e.lineWidth=n,e.strokeStyle=t,x_(r,e,o));e.restore()},x_=(e,o,t)=>{if(!t.zenModeEnabled){let n=e.points[0],r=e.points[e.points.length-1];Vt(n,r,o)}for(let n of e.points)Nw(n,t,o)},E_=(e,o,t)=>{Nw(e.points[0],t,o),t.zenModeEnabled||Vt(e.points[0],e.points[1],o)},Nw=([e,o],t,n)=>{n.save();let r=(t.zenModeEnabled?_w*1.5:_w)/t.zoom.value;n.beginPath(),n.moveTo(e-r,o-r),n.lineTo(e+r,o+r),n.moveTo(e+r,o-r),n.lineTo(e-r,o+r),n.stroke(),n.restore()},Vt=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},y_=(e,o,t,n,r)=>{let i=8/n.zoom.value,a=i/2,l=i/4;if(t==="horizontal"){let s=[(e[0]+o[0])/2,e[1]];n.zenModeEnabled||Vt(ct(e[0],e[1]-i),ct(e[0],e[1]+i),r),Vt(ct(s[0]-l,s[1]-a),ct(s[0]-l,s[1]+a),r),Vt(ct(s[0]+l,s[1]-a),ct(s[0]+l,s[1]+a),r),n.zenModeEnabled||(Vt(ct(o[0],o[1]-i),ct(o[0],o[1]+i),r),Vt(e,o,r))}else{let s=[e[0],(e[1]+o[1])/2];n.zenModeEnabled||Vt(ct(e[0]-i,e[1]),ct(e[0]+i,e[1]),r),Vt(ct(s[0]-a,s[1]-l),ct(s[0]+a,s[1]-l),r),Vt(ct(s[0]-a,s[1]+l),ct(s[0]+a,s[1]+l),r),n.zenModeEnabled||(Vt(ct(o[0]-i,o[1]),ct(o[0]+i,o[1]),r),Vt(e,o,r))}};import{getGlobalCSSVariable as Qc}from"@excalidraw/common";import{getCommonBounds as w_}from"@excalidraw/element";var lo=4,Ct=6,Bw="rgba(0,0,0,0.3)",Fw=(e,o,t,n)=>{if(!e.size)return{horizontal:null,vertical:null};let[r,i,a,l]=w_(e),s=o/n.zoom.value,d=t/n.zoom.value,m={top:parseInt(Qc("sat"))||0,bottom:parseInt(Qc("sab"))||0,left:parseInt(Qc("sal"))||0,right:parseInt(Qc("sar"))||0},c=Mo().rtl,p=-n.scrollX+m.left,u=-n.scrollY+m.top,f=p+s-m.right,b=u+d-m.bottom,x=Math.min(r,p),w=Math.min(i,u),E=Math.max(a,f),y=Math.max(l,b),v=a-r,C=l-i,S=E-x,L=y-w,k=Math.max(lo*2,m.left+m.right)+Ct*2,A=o*(s/S)-k,P=Math.max(lo*2,m.top+m.bottom)+Ct*2,N=t*(d/L)-P,O=S>v?S*n.zoom.value/(A+k):o/(A+k),U=L>C?L*n.zoom.value/(N+P):t/(N+P);return{horizontal:p===x&&f===E?null:{x:Math.max(m.left,lo)+Ct+(p-x)/S*o,y:t-Ct-Math.max(lo,m.bottom),width:A,height:Ct,deltaMultiplier:O},vertical:u===w&&b===y?null:{x:c?Math.max(m.left,lo):o-Ct-Math.max(m.right,lo),y:Math.max(m.top,lo)+Ct+(u-w)/L*t,width:Ct,height:N,deltaMultiplier:U}}},Hh=(e,o,t)=>{let[n,r]=[e.horizontal,e.vertical].map(a=>a!=null&&a.x<=o&&o<=a.x+a.width&&a.y<=t&&t<=a.y+a.height);return{isOverEither:n||r,isOverHorizontal:n,isOverVertical:r}};var B_=(e,o)=>{zw(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;zw(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Xw(t,e,o),e.restore()},F_=(e,o,t)=>{let{elementId:n,hoverPointIndex:r}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(r))return;let i=xn.getElement(n,t);if(!i)return;let a=xn.getPointAtIndexGlobalCoordinates(i,r,t);e.save(),e.translate(o.scrollX,o.scrollY),Xw(a,e,o),e.restore()},Xw=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Vi(o,e[0],e[1],xn.POINT_HANDLE_SIZE/t.zoom.value,!1)},Yh=(e,o,t,n,r,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",r?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Vi(e,t[0],t[1],(a?n*(o.selectedLinearElement?.isEditing?1.5:2):n)/o.zoom.value,!i,!a||r)},O_=(e,o,t,n)=>{let r=Vw(o,o.width,o.height,n);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":r1(e,o,t,r);break;case"diamond":a1(e,r,o,t);break;case"ellipse":{let[i,a,l,s]=$a(o,t),d=l-i,m=s-a;e.strokeStyle="rgba(0,0,0,.05)",e.lineWidth=r-Gh,i1(e,d+r+Gh,m+r+Gh,i+d/2,a+m/2,o.angle);break}}},z_=(e,o,t,n)=>{let[r,i,a]=o,l=Vw(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(d=>{let[m,c]=xn.getPointAtIndexGlobalCoordinates(r,d,t);Vi(e,m,c,l,!0)})},Kw=(e,o,t)=>{let{angle:n,x1:r,y1:i,x2:a,y2:l,selectionColors:s,cx:d,cy:m,dashed:c,activeEmbeddable:p}=t,u=a-r,f=l-i,x=(t.padding??Kh*2)/o.zoom.value,w=8/o.zoom.value,E=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],c&&e.setLineDash([w,E+(w+E)*(y-1)]),e.lineDashOffset=(w+E)*v,Xi(e,r-x,i-x,u+x*2,f+x*2,d,m,n);e.restore()},H_=(e,o,t,n)=>{let r=Array.isArray(t)?z_:O_;e.save(),e.translate(o.scrollX,o.scrollY),r(e,t,n,o.zoom),e.restore()},G_=(e,o,t,n)=>{let[r,i,a,l]=$a(t,n),s=a-r,d=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Ow.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Xi(e,r,i,s,d,r+s/2,i+d/2,t.angle,!1,Ow.radius/o.zoom.value),e.restore()},Yw=(e,o,t,n)=>{let{colors:r=["rgb(0,118,255)"],dashed:i=!1}=n||{},a=t.filter(m=>m.groupIds.length===0),l=t.filter(m=>m.groupIds.length>0),s=m=>{let[c,p,u,f]=Xh(m);return{angle:0,x1:c,x2:u,y1:p,y2:f,selectionColors:r,dashed:i,cx:c+(u-c)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},d=m=>{let c=Vh(t,m);return s(c)};Object.entries(N_(l,o)).filter(([m,c])=>c).map(([m,c])=>m).map(m=>d(m)).concat(a.map(m=>s([m]))).forEach(m=>Kw(e,o,m))},Wh=(e,o,t,n)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let r=xn.getPointsGlobalCoordinates(t,n),{POINT_HANDLE_SIZE:i}=xn,a=o.selectedLinearElement?.isEditing?i:i/2,l=Za(t),s=A_(t);if(r.forEach((d,m)=>{if(l&&m!==0&&m!==r.length-1)return;let c=m>0&&(m!==r.length-1||!s||!t.polygon)&&T_(d,m===r.length-1?r[0]:r[m-1],2/o.zoom.value),p=!!o.selectedLinearElement?.isEditing&&!!o.selectedLinearElement?.selectedPointsIndices?.includes(m);s&&t.polygon&&!p&&m===t.points.length-1&&o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(0)&&(p=!0),Yh(e,o,d,a,p,!1,c)}),Za(t)){let d=t.fixedSegments?.map(m=>m.index)||[];r.slice(0,-1).forEach((m,c)=>{xn.isSegmentTooShort(t,r[c+1],r[c],c,o.zoom)||Yh(e,o,v_((m[0]+r[c+1][0])/2,(m[1]+r[c+1][1])/2),i/2,!1,!d.includes(c+1),!1)})}else xn.getEditorMidPoints(t,n,o).filter((m,c,p)=>m!==null&&!(Za(t)&&(c===0||c===p.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||r.length===2)&&Yh(e,o,m,i/2,!1,!0,!1)});e.restore()},Ww=(e,o,t,n,r)=>{Object.keys(n).forEach(i=>{let a=n[i];if(a!==void 0){let[l,s,d,m]=a;e.save(),e.lineWidth=1/t.zoom.value,o.selectionColor&&(e.strokeStyle=o.selectionColor),i==="rotation"?Vi(e,l+d/2,s+m/2,d/2,!0):e.roundRect?(e.beginPath(),e.roundRect(l,s,d,m,2/t.zoom.value),e.fill(),e.stroke()):Xi(e,l,s,d,m,l+d/2,s+m/2,r,!0),e.restore()}})},U_=(e,o,t,n,r)=>{let[i,a,,,l,s]=$a(n,r),d=3,m=20,c=d/t.zoom.value,p=c/2,u=l-i+c,f=s-a+c,b=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,f);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=c,[[[-u,-f],[0,p],[b,p],[p,0],[p,x]],[[u-p,-f],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,f],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,f],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(E=>{let[[y,v],[C,S],[L,k],[A,P],[N,O]]=E;e.save(),e.translate(l,s),e.rotate(n.angle),e.beginPath(),e.moveTo(y+C,v+S),e.lineTo(y+L,v+k),e.stroke(),e.beginPath(),e.moveTo(y+A,v+P),e.lineTo(y+N,v+O),e.stroke(),e.restore()}),e.restore()},Y_=(e,o,t,n)=>{o.save();let r=Kh*2/t.zoom.value,i=e.width+r*2,a=e.height+r*2,l=e.x+i/2,s=e.y+a/2,d=-(i/2+r),m=-(a/2+r);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=n,o.strokeRect(d,m,i,a),o.restore()},Zw=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:n,allElementsMap:r,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[d,m]=Al(e,i),c=Dl({canvas:e,scale:i,normalizedWidth:d,normalizedHeight:m});c.save(),c.scale(a.zoom.value,a.zoom.value);let p;if(t.forEach(b=>{a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===b.id&&b&&(p=b)}),p&&Wh(c,a,p,o),a.selectionElement&&!a.isCropping)try{D_(a.selectionElement,c,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Uw(a.editingTextElement)){let b=r.get(a.editingTextElement.id);b&&!b.autoResize&&Y_(b,c,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{H_(c,a,b,o)}),a.frameToHighlight&&G_(c,a,a.frameToHighlight,o),a.elementsToHighlight&&Yw(c,a,a.elementsToHighlight),a.activeLockedId){let b=r.get(a.activeLockedId),x=b?[b]:Vh(r,a.activeLockedId);Yw(c,a,x,{colors:["#ced4da"],dashed:!0})}let u=n.some(b=>Hw(b));if(n.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===n[0].id&&Wh(c,a,n[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=n.find(w=>w.id===b.elementId);b.segmentMidPointHoveredCoords?B_(c,a):(Za(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&F_(c,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=L_(n,a),x=n.length===1&&P_(n[0]);x&&a.selectedLinearElement?.elementId===n[0].id&&!n[0].locked&&Wh(c,a,n[0],o);let w=l.selectionColor||ed.black;if(b){let E=I_(n),y=[];for(let C of o.values()){let S=[],L=l.remoteSelectedElementIds.get(C.id);if(x&&Za(C)&&(C.startBinding||C.endBinding)||(E.has(C.id)&&!R_(a,C)&&S.push(w),L&&S.push(...L.map(k=>qn(k,a.collaborators.get(k))))),S.length){let[k,A,P,N,O,U]=$a(C,o,!0);y.push({angle:C.angle,x1:k,y1:A,x2:P,y2:N,selectionColors:C.locked?["#ced4da"]:S,dashed:!!L||C.locked,cx:O,cy:U,activeEmbeddable:a.activeEmbeddable?.element===C&&a.activeEmbeddable.state==="active",padding:C.id===a.croppingElementId||Gw(C)?0:void 0})}}let v=C=>{let S=Vh(o,C),[L,k,A,P]=Xh(S);y.push({angle:0,x1:L,x2:A,y1:k,y2:P,selectionColors:S.some(N=>N.locked)?["#ced4da"]:[ed.black],dashed:!0,cx:L+(A-L)/2,cy:k+(P-k)/2,activeEmbeddable:!1})};for(let C of __(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>Kw(c,a,C))}if(c.save(),c.translate(a.scrollX,a.scrollY),n.length===1){c.fillStyle=ed.white;let E=k_(n[0],a.zoom,o,"mouse",Uh(s));if(!a.viewModeEnabled&&b&&!Uw(a.editingTextElement)&&!a.croppingElementId&&Ww(c,l,a,E,n[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&Gw(y)&&U_(c,l,a,y,o)}}else if(n.length>1&&!a.isRotating&&!n.some(E=>E.locked)){let E=Kh*2/a.zoom.value;c.fillStyle=ed.white;let[y,v,C,S]=Xh(n,o),L=c.getLineDash();c.setLineDash([2/a.zoom.value]);let k=c.lineWidth;c.lineWidth=1/a.zoom.value,c.strokeStyle=w,Xi(c,y-E,v-E,C-y+E*2,S-v+E*2,(y+C)/2,(v+S)/2,0),c.lineWidth=k,c.setLineDash(L);let A=M_([y,v,C,S,(y+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...Uh(s),rotation:!0}:Uh(s));n.some(P=>!P.locked)&&Ww(c,l,a,A,0)}c.restore()}a.searchMatches?.matches.forEach(({id:b,focus:x,matchedLines:w})=>{let E=o.get(b);if(E){let[y,v,,,C,S]=$a(E,o,!0);c.save(),a.theme===C_.LIGHT?x?c.fillStyle="rgba(255, 124, 0, 0.4)":c.fillStyle="rgba(255, 226, 0, 0.4)":x?c.fillStyle="rgba(229, 82, 0, 0.4)":c.fillStyle="rgba(99, 52, 0, 0.4)";let L=Hw(E)?a.zoom.value:1;c.translate(a.scrollX,a.scrollY),c.translate(C,S),c.rotate(E.angle),w.forEach(k=>{(k.showOnCanvas||x)&&c.fillRect(y+k.offsetX/L-C,v+k.offsetY/L-S,k.width/L,k.height/L)}),c.restore()}}),Rw(c,a),c.restore(),cE({context:c,renderConfig:l,appState:a,normalizedWidth:d,normalizedHeight:m});let f;return l.renderScrollbars&&(f=Fw(o,d,m,a),c.save(),c.fillStyle=Bw,c.strokeStyle="rgba(255,255,255,0.8)",[f.horizontal,f.vertical].forEach(b=>{b&&qs(c,b.x,b.y,b.width,b.height,Ct/2)}),c.restore()),{scrollBars:f,atLeastOneVisibleElement:t.length>0,elementsMap:o}},Zh=S_(e=>{let o=Zw(e);e.callback?.(o)},{trailing:!0}),$w=(e,o)=>{if(o){Zh(e);return}let t=Zw(e);return e.callback(t),t};var ja=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:n,zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:d,width:m})=>{let c=[];for(let p of n.values())W_(p,m,d,{zoom:r,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},n)&&c.push(p);return c},t=({elements:n,editingTextElement:r,newElementId:i})=>{let a=X_(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 V_(({zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:d,editingTextElement:m,newElementId:c,sceneNonce:p})=>{let u=this.scene.getNonDeletedElements(),f=t({elements:u,editingTextElement:m,newElementId:c}),b=o({elementsMap:f,zoom:n,offsetLeft:r,offsetTop:i,scrollX:a,scrollY:l,height:s,width:d});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){Zh.cancel(),s1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as K_}from"@excalidraw/common";import{getElementAbsoluteCoords as Z_}from"@excalidraw/element";import{jsx as q_}from"react/jsx-runtime";var $_=5,j_=(e,o,t)=>{let[n,r]=Z_(e,t),{x:i,y:a}=K_({sceneX:n+e.width,sceneY:r},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},$h=({children:e,element:o,elementsMap:t})=>{let n=go();if(n.contextMenu||n.newElement||n.resizingElement||n.isRotating||n.openMenu||n.viewModeEnabled)return null;let{x:r,y:i}=j_(o,n,t);return q_("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${r}px`,padding:$_},children:e})};import{DEFAULT_LASER_COLOR as tR,easeOut as qw}from"@excalidraw/common";import{LaserPointer as J_}from"@excalidraw/laser-pointer";import{SVG_NS as jw,getSvgPathFromStroke as Q_,sceneCoordsToViewportCoords as eR}from"@excalidraw/common";var Go=class{constructor(o,t,n){this.animationFrameHandler=o;this.app=t;this.options=n;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(jw,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(jw,"animate"),this.trailAnimation.setAttribute("attributeName","stroke-dashoffset"),this.trailElement.setAttribute("stroke-dasharray","7 7"),this.trailElement.setAttribute("stroke-dashoffset","10"),this.trailAnimation.setAttribute("from","0"),this.trailAnimation.setAttribute("to","-14"),this.trailAnimation.setAttribute("dur","0.3s"),this.trailElement.appendChild(this.trailAnimation))}get hasCurrentTrail(){return!!this.currentTrail}hasLastPoint(o,t){if(this.currentTrail){let n=this.currentTrail.originalPoints.length;return this.currentTrail.originalPoints[n-1][0]===o&&this.currentTrail.originalPoints[n-1][1]===t}return!1}start(o){o&&(this.container=o),this.trailElement.parentNode!==this.container&&this.container&&this.container.appendChild(this.trailElement),this.animationFrameHandler.start(this)}stop(){this.animationFrameHandler.stop(this),this.trailElement.parentNode===this.container&&this.container?.removeChild(this.trailElement)}startPath(o,t){this.currentTrail=new J_(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let n of this.pastTrails)o.push(this.drawTrail(n,this.app.state));if(this.currentTrail){let n=this.drawTrail(this.currentTrail,this.app.state);o.push(n)}this.pastTrails=this.pastTrails.filter(n=>n.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let n=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=eR({sceneX:i,sceneY:a},t);return[l.x,l.y]}),r=this.trailAnimation?n.slice(0,n.length/2):n;return Q_(r,!0)}};var td=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 Go(o,t,{...this.getTrailOptions(),fill:()=>tR})}getTrailOptions(){return{simplify:0,streamline:.4,sizeMapping:o=>{let r=Math.max(0,1-(performance.now()-o.pressure)/1e3),i=(50-Math.min(50,o.totalLength-o.currentIndex))/50;return Math.min(qw(i),qw(r))}}}startPath(o,t){this.localTrail.startPath(o,t)}addPointToPath(o,t){this.localTrail.addPointToPath(o,t)}endPath(){this.localTrail.endPath()}start(o){this.container=o,this.animationFrameHandler.start(this),this.localTrail.start(o)}stop(){this.animationFrameHandler.stop(this),this.localTrail.stop()}onFrame(){this.updateCollabTrails()}updateCollabTrails(){if(!(!this.container||this.app.state.collaborators.size===0)){for(let[o,t]of this.app.state.collaborators.entries()){let n;this.collabTrails.has(o)?n=this.collabTrails.get(o):(n=new Go(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||qn(o,t)}),n.start(this.container),this.collabTrails.set(o,n)),t.pointer&&t.pointer.tool==="laser"&&(t.button==="down"&&!n.hasCurrentTrail&&n.startPath(t.pointer.x,t.pointer.y),t.button==="down"&&n.hasCurrentTrail&&!n.hasLastPoint(t.pointer.x,t.pointer.y)&&n.addPointToPath(t.pointer.x,t.pointer.y),t.button==="up"&&n.hasCurrentTrail&&(n.addPointToPath(t.pointer.x,t.pointer.y),n.endPath()))}for(let o of this.collabTrails.keys())this.app.state.collaborators.has(o)||(this.collabTrails.get(o).stop(),this.collabTrails.delete(o))}}};import{version as oR}from"react";import{unstable_batchedUpdates as Jw}from"react-dom";import{throttleRAF as nR}from"@excalidraw/common";var Pe=e=>o=>{Jw(e,o)},od=e=>nR(o=>{Jw(e,o)}),Si=(()=>{let e;try{let t=oR.split(".");e=Number(t[0])>17}catch{e=!1}let o=!1;return()=>window.EXCALIDRAW_THROTTLE_RENDER===!0?e?!0:(o||(o=!0,console.warn("Excalidraw: render throttling is disabled on React versions < 18.")),!1):!1})();import{CODES as jh,KEYS as qa,CLASSES as Qw,POINTER_BUTTON as rR,isWritableElement as iR,getFontString as ev,getFontFamilyString as tv,isTestEnv as ov}from"@excalidraw/common";import{originalContainerCache as aR,updateOriginalContainerCache as nv}from"@excalidraw/element";import{LinearElementEditor as lR}from"@excalidraw/element";import{bumpVersion as sR}from"@excalidraw/element";import{getBoundTextElementId as cR,getContainerElement as qh,getTextElementAngle as dR,redrawTextBoundingBox as mR,getBoundTextMaxHeight as pR,getBoundTextMaxWidth as rv,computeContainerDimensionForBoundText as iv,computeBoundTextPosition as uR,getBoundTextElement as hR}from"@excalidraw/element";import{getTextWidth as gR}from"@excalidraw/element";import{normalizeText as av}from"@excalidraw/element";import{wrapText as fR}from"@excalidraw/element";import{isArrowElement as nd,isBoundToContainer as bR,isTextElement as lv}from"@excalidraw/element";var xR=(e,o,t,n,r,i)=>{let{zoom:a}=n,l=180*t/Math.PI,s=e*(a.value-1)/2,d=o*(a.value-1)/2;return e>r&&a.value!==1&&(s=r*(a.value-1)/2),o>i&&a.value!==1&&(d=i*(a.value-1)/2),`translate(${s}px, ${d}px) scale(${a.value}) rotate(${l}deg)`},sv=({id:e,onChange:o,onSubmit:t,getViewportCoords:n,element:r,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let d=(_,R)=>{if(!R.style.fontFamily||!R.style.fontSize)return!1;let V=R.style.fontFamily.replace(/"/g,"");return tv({fontFamily:_.fontFamily})!==V||`${_.fontSize}px`!==R.style.fontSize},m=()=>{let _=l.state,R=l.scene.getElement(e);if(!R)return;let{textAlign:V,verticalAlign:Z}=R,W=l.scene.getNonDeletedElementsMap();if(R&&lv(R)){let ce=R.x,he=R.y,de=qh(R,l.scene.getNonDeletedElementsMap()),it=R.width,po=R.height,pr=R.width,ur=R.height;if(de&&R.containerId){if(nd(de)){let Ko=lR.getBoundTextElementPosition(de,R,W);ce=Ko.x,he=Ko.y}let Sl=d(R,c),Yi;if(Sl?Yi=nv(de.id,de.height):(Yi=aR[de.id],Yi||(Yi=nv(de.id,de.height))),pr=rv(de,R),ur=pR(de,R),!nd(de)&&po>ur){let Ko=iv(po,de.type);l.scene.mutateElement(de,{height:Ko});return}else if(!nd(de)&&de.height>Yi.height&&po<ur){let Ko=iv(po,de.type);l.scene.mutateElement(de,{height:Ko})}else{let{y:Ko}=uR(de,R,W);he=Ko}}let[Cl,im]=n(ce,he),KI=c.selectionStart,am=c.selectionEnd,Xf=c.value.length;if(KI===am&&am!==Xf){let Sl=Xf-am;c.selectionStart=c.value.length-Sl,c.selectionEnd=c.value.length-Sl}de?it+=.5:(pr=(_.width-8-Cl)/_.zoom.value,it=Math.min(it,pr)),po*=1.05;let ZI=ev(R),Kf=(_.height-im)/_.zoom.value;Object.assign(c.style,{font:ZI,lineHeight:R.lineHeight,width:`${it}px`,height:`${po}px`,left:`${Cl}px`,top:`${im}px`,transform:xR(it,po,dR(R,de),_,pr,Kf),textAlign:V,verticalAlign:Z,color:R.strokeColor,opacity:R.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Kf}px`}),c.scrollTop=0,ov()&&(c.style.fontFamily=tv(R)),l.scene.mutateElement(R,{x:ce,y:he})}},c=document.createElement("textarea");c.dir="auto",c.tabIndex=0,c.dataset.type="wysiwyg",c.wrap="off",c.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(bR(r)||!r.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(c.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"}),c.value=r.originalText,m(),o&&(c.onpaste=async _=>{let R=await Ws(_,!0);if(!R.text)return;let V=av(R.text);if(!V)return;let Z=qh(r,l.scene.getNonDeletedElementsMap()),W=ev({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Z){let ce=hR(Z,l.scene.getNonDeletedElementsMap()),he=fR(`${c.value}${V}`,W,rv(Z,ce)),de=gR(he,W);c.style.width=`${de}px`}},c.oninput=()=>{let _=av(c.value);if(c.value!==_){let R=c.selectionStart;c.value=_,c.selectionStart=R,c.selectionEnd=R}o(c.value)}),c.onkeydown=_=>{if(!_.shiftKey&&Rs.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Rs),m();else if(!_.shiftKey&&Ns.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Ns),m();else if(!_.shiftKey&&Bs.keyTest(_))_.preventDefault(),l.actionManager.executeAction(Bs),m();else if(Lp.keyTest(_))l.actionManager.executeAction(Lp);else if(Pp.keyTest(_))l.actionManager.executeAction(Pp);else if(_.key===qa.ESCAPE)_.preventDefault(),C=!0,S();else if($n.keyTest(_))_.preventDefault(),S(),l.actionManager.executeAction($n);else if(_.key===qa.ENTER&&_[qa.CTRL_OR_CMD]){if(_.preventDefault(),_.isComposing||_.keyCode===229)return;C=!0,S()}else if(_.key===qa.TAB||_[qa.CTRL_OR_CMD]&&(_.code===jh.BRACKET_LEFT||_.code===jh.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===jh.BRACKET_LEFT?E():w(),c.dispatchEvent(new Event("input"))}};let f=4,b=" ".repeat(f),x=new RegExp(`^ {1,${f}}`),w=()=>{let{selectionStart:_,selectionEnd:R}=c,V=y(),Z=c.value;V.forEach(W=>{let ce=Z.slice(0,W),he=Z.slice(W);Z=`${ce}${b}${he}`}),c.value=Z,c.selectionStart=_+f,c.selectionEnd=R+f*V.length},E=()=>{let{selectionStart:_,selectionEnd:R}=c,V=y(),Z=[],W=c.value;V.forEach(ce=>{let he=W.slice(ce,ce+f).match(x);if(he){let de=W.slice(0,ce),it=W.slice(ce+he[0].length);W=`${de}${it}`,Z.push(ce)}}),c.value=W,Z.length&&(_>Z[Z.length-1]?c.selectionStart=Math.max(_-f,Z[Z.length-1]):c.selectionStart=_,c.selectionEnd=Math.max(c.selectionStart,R-f*Z.length))},y=()=>{let{selectionStart:_,selectionEnd:R,value:V}=c,Z=V.slice(0,_).match(/[^\n]*$/)[0].length;return _=_-Z,V.slice(_,R).split(`
16
+ `).reduce((ce,he,de,it)=>ce.concat(de?ce[de-1]+it[de-1].length+1:_),[]).reverse()},v=_=>{_.target instanceof HTMLCanvasElement&&(_.preventDefault(),_.stopPropagation())},C=!1,S=()=>{if(U)return;U=!0,L();let _=l.scene.getElement(r.id);if(!_)return;let R=qh(_,l.scene.getNonDeletedElementsMap());if(R){if(c.value.trim()){let V=cR(R);!V||V!==r.id?l.scene.mutateElement(R,{boundElements:(R.boundElements||[]).concat({type:"text",id:r.id})}):nd(R)&&sR(R)}else l.scene.mutateElement(R,{boundElements:R.boundElements?.filter(V=>!lv(V))});mR(_,R,l.scene)}t({viaKeyboard:C,nextOriginalText:c.value})},L=()=>{c.onblur=null,c.oninput=null,c.onkeydown=null,J&&J.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",k),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),N(),O(),c.remove()},k=_=>{window.removeEventListener("pointerup",k);let R=_?.target,V=R instanceof HTMLElement&&R.classList.contains("properties-trigger");setTimeout(()=>{c.onblur=S,V||c.focus()})},A=()=>{c.onblur=null,window.addEventListener("pointerup",k),window.addEventListener("blur",S)},P=_=>{let R=_?.target;if(_.button===rR.WHEEL){R instanceof HTMLTextAreaElement&&(_.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(_)),A();return}let V=R instanceof HTMLElement&&R.classList.contains("properties-trigger");(_.target instanceof HTMLElement||_.target instanceof SVGElement)&&_.target.closest(`.${Qw.SHAPE_ACTIONS_MENU}, .${Qw.ZOOM_ACTIONS}`)&&!iR(_.target)||V?A():_.target instanceof HTMLCanvasElement&&!ov()&&requestAnimationFrame(()=>{S()})},N=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||c.focus()}),O=l.onScrollChangeEmitter.on(()=>{m()}),U=!1;s&&c.select(),k();let J=null;return i&&"ResizeObserver"in window?(J=new window.ResizeObserver(()=>{m()}),J.observe(i)):window.addEventListener("resize",m),c.onpointerdown=_=>_.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",P,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(c),S};var cv=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(n=>`\\s*${n}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as MR}from"@excalidraw/math";import{getElementLineSegments as LR}from"@excalidraw/element";import{LinearElementEditor as PR}from"@excalidraw/element";import{isFrameLikeElement as AR,isLinearElement as DR,isTextElement as _R}from"@excalidraw/element";import{getFrameChildren as RR}from"@excalidraw/element";import{selectGroupsForSelectedElements as NR}from"@excalidraw/element";import{getContainerElement as BR}from"@excalidraw/element";import{arrayToMap as FR,easeOut as uv,isShallowEqual as OR}from"@excalidraw/common";import{simplify as ER}from"points-on-curve";import{polygonFromPoints as yR,lineSegment as dv,polygonIncludesPointNonZero as wR}from"@excalidraw/math";import{computeBoundTextPosition as vR,doBoundsIntersect as TR,getBoundTextElement as IR,getElementBounds as CR,intersectElementWithLineSegment as mv}from"@excalidraw/element";var pv=e=>{let{lassoPath:o,elements:t,elementsMap:n,elementsSegments:r,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=ER(o,l));let d=t.filter(p=>!p.locked);a.clear(),i.clear();let m=o.reduce((p,u)=>[Math.min(p[0],u[0]),Math.min(p[1],u[1]),Math.max(p[2],u[0]),Math.max(p[3],u[1])],[1/0,1/0,-1/0,-1/0]);for(let p of d){let u=CR(p,n);TR(m,u)&&!i.has(p.id)&&!a.has(p.id)&&(SR(s,p,r)?a.add(p.id):kR(s,p,n)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},SR=(e,o,t)=>{let n=yR(e),r=t.get(o.id);return r?r.some(i=>i.some(a=>wR(a,n))):!1},kR=(e,o,t)=>{let n=e.slice(1).map((i,a)=>dv(e[a],i)).concat([dv(e[e.length-1],e[0])]),r=IR(o,t);return n.some(i=>mv(o,t,i,0,!0).length>0||!!r&&mv({...r,...vR(o,r,t)},t,i,0,!0).length>0)};var rd=class extends Go{constructor(t,n){super(t,n,{animateTrail:!0,streamline:.4,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/(1/0)),s=(5e3-Math.min(5e3,r.totalLength-r.currentIndex))/5e3;return Math.min(uv(s),uv(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});I(this,"intersectedElements",new Set);I(this,"enclosedElements",new Set);I(this,"elementsSegments",null);I(this,"canvasTranslate",null);I(this,"keepPreviousSelection",!1);I(this,"selectElementsFromIds",t=>{this.app.setState(n=>{let r=t.reduce((s,d)=>(s[d]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(n.selectedElementIds))r[s]=!0;for(let[s]of Object.entries(r)){let d=this.app.scene.getNonDeletedElement(s);if(d&&_R(d)){let m=BR(d,this.app.scene.getNonDeletedElementsMap());m&&(r[m.id]=!0,delete r[d.id])}}for(let[s]of Object.entries(r)){let d=this.app.scene.getNonDeletedElement(s);if(d&&AR(d)){let m=RR(this.app.scene.getNonDeletedElementsMap(),d.id);for(let c of m)delete r[c.id]}}let i=NR({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&&DR(this.app.scene.getNonDeletedElement(a[0]))?new PR(this.app.scene.getNonDeletedElement(a[0]),this.app.scene.getNonDeletedElementsMap()):null}})});I(this,"addPointToPath",(t,n,r=!1)=>{super.addPointToPath(t,n),this.keepPreviousSelection=r,this.updateSelection()});I(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>MR(r[0],r[1])),n={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!OR(n,this.canvasTranslate??{})){this.canvasTranslate=n,this.elementsSegments=new Map;let r=FR(this.app.visibleElements);for(let i of this.app.visibleElements){let a=LR(i,r);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:r}=pv({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}startPath(t,n,r=!1){this.endPath(),super.startPath(t,n),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=r,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as zR,easeOut as hv,THEME as HR}from"@excalidraw/common";import{computeBoundTextPosition as GR,getBoundTextElement as UR,intersectElementWithLineSegment as gv,isPointInElement as YR}from"@excalidraw/element";import{lineSegment as WR,pointFrom as VR}from"@excalidraw/math";import{getElementsInGroup as fv}from"@excalidraw/element";import{shouldTestInside as XR}from"@excalidraw/element";import{hasBoundTextElement as bv,isBoundToContainer as xv}from"@excalidraw/element";import{getBoundTextElementId as Ev}from"@excalidraw/element";var id=class extends Go{constructor(t,n){super(t,n,{streamline:.2,size:5,keepHead:!0,sizeMapping:r=>{let l=Math.max(0,1-(performance.now()-r.pressure)/200),s=(10-Math.min(10,r.totalLength-r.currentIndex))/10;return Math.min(hv(s),hv(l))},fill:()=>n.state.theme===HR.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set)}startPath(t,n){this.endPath(),super.startPath(t,n),this.elementsToErase.clear()}addPointToPath(t,n,r=!1){return super.addPointToPath(t,n),this.updateElementsToBeErased(r)}updateElementsToBeErased(t){let n=super.getCurrentTrail()?.originalPoints?.map(l=>VR(l[0],l[1]))||[];if(n.length<2)return[];let r=WR(n[n.length-1],n[n.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=zR(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(yv(r,l,a)){let d=l.groupIds.at(-1);if(this.groupsToErase.has(d)){let m=fv(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.delete(c.id);this.groupsToErase.delete(d)}if(xv(l)&&this.elementsToErase.delete(l.containerId),bv(l)){let m=Ev(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&yv(r,l,a)){let d=l.groupIds.at(-1);if(!this.groupsToErase.has(d)){let m=fv(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.add(c.id);this.groupsToErase.add(d)}if(bv(l)){let m=Ev(l);m&&this.elementsToErase.add(m)}xv(l)&&this.elementsToErase.add(l.containerId),this.elementsToErase.add(l.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear()}},yv=(e,o,t)=>{let n=e[1];if(XR(o)&&YR(n,o,t))return!0;let r=UR(o,t);return gv(o,t,e,0,!0).length>0||!!r&&gv({...r,...GR(o,r,t)},t,e,0,!0).length>0};import{jsx as Xt,jsxs as wv}from"react/jsx-runtime";var KR=()=>wv("div",{"data-testid":"brave-measure-text-error",children:[Xt("p",{children:Xt(ht,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Xt("span",{style:{fontWeight:600},children:e})})}),Xt("p",{children:Xt(ht,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Xt("span",{style:{fontWeight:600},children:e})})}),Xt("p",{children:Xt(ht,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Xt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Xt("p",{children:Xt(ht,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Xt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>wv("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),vv=KR;import QR from"clsx";import e9 from"react";import{useLayoutEffect as ZR,useRef as Tv,useEffect as Iv}from"react";import{unstable_batchedUpdates as $R}from"react-dom";import{KEYS as jR,queryFocusableElements as qR}from"@excalidraw/common";import{jsx as JR}from"react/jsx-runtime";var Cv=({children:e,left:o,top:t,onCloseRequest:n,fitInViewport:r=!1,offsetLeft:i=0,offsetTop:a=0,viewportWidth:l=window.innerWidth,viewportHeight:s=window.innerHeight})=>{let d=Tv(null);Iv(()=>{let c=d.current;if(!c)return;c.contains(document.activeElement)||c.focus();let p=u=>{if(u.key===jR.TAB){let f=qR(c),{activeElement:b}=document,x=f.findIndex(w=>w===b);b===c?(u.shiftKey?f[f.length-1]?.focus():f[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(f[f.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===f.length-1&&!u.shiftKey&&(f[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return c.addEventListener("keydown",p),()=>c.removeEventListener("keydown",p)},[]);let m=Tv(null);return ZR(()=>{if(r&&d.current&&t!=null&&o!=null){let c=d.current,{width:p,height:u}=c.getBoundingClientRect();if(m.current?.top===t&&m.current?.left===o)return;m.current={top:t,left:o},p>=l?(c.style.width=`${l}px`,c.style.left="0px",c.style.overflowX="scroll"):o+p-i>l?c.style.left=`${l-p-10}px`:c.style.left=`${o}px`,u>=s?(c.style.height=`${s-20}px`,c.style.top="10px",c.style.overflowY="scroll"):t+u-a>s?c.style.top=`${s-u}px`:c.style.top=`${t}px`}},[t,o,r,l,s,i,a]),Iv(()=>{if(n){let c=p=>{d.current?.contains(p.target)||$R(()=>n(p))};return document.addEventListener("pointerdown",c,!1),()=>document.removeEventListener("pointerdown",c,!1)}},[n]),JR("div",{className:"popover",ref:d,tabIndex:-1,children:e})};import{jsx as ki,jsxs as t9}from"react/jsx-runtime";var Ye="separator",Sv=e9.memo(({actionManager:e,items:o,top:t,left:n,onClose:r})=>{let i=go(),a=on(),l=o.reduce((s,d)=>(d&&(d===Ye||!d.predicate||d.predicate(a,i,e.app.props,e.app))&&s.push(d),s),[]);return ki(Cv,{onCloseRequest:()=>{r()},top:t,left:n,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:ki("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,d)=>{if(s===Ye)return!l[d-1]||l[d-1]===Ye?null:ki("hr",{className:"context-menu-item-separator"},d);let m=s.name,c="";return s.label&&(typeof s.label=="function"?c=g(s.label(a,i,e.app)):c=g(s.label)),ki("li",{"data-testid":m,onClick:()=>{r(()=>{e.executeAction(s,"contextMenu")})},children:t9("button",{type:"button",className:QR("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[ki("div",{className:"context-menu-item__label",children:c}),ki("kbd",{className:"context-menu-item__shortcut",children:m?Ne(m):""})]})},d)})})})});import{jsx as Jh,jsxs as kv}from"react/jsx-runtime";var o9=({height:e,width:o,userToFollow:t,onDisconnect:n})=>Jh("div",{className:"follow-mode",style:{width:o,height:e},children:kv("div",{className:"follow-mode__badge",children:[kv("div",{className:"follow-mode__badge__label",children:["Following"," ",Jh("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),Jh("button",{type:"button",onClick:n,className:"follow-mode__disconnect-btn",children:Ft})]})}),Mv=o9;import cl from"clsx";import wO from"react";import{CLASSES as vO,DEFAULT_SIDEBAR as jg,TOOL_TYPE as a5,arrayToMap as TO,capitalizeString as IO,isShallowEqual as Vd}from"@excalidraw/common";import{mutateElement as CO}from"@excalidraw/element";import{showSelectedShapeActions as SO}from"@excalidraw/element";import{ShapeCache as kO}from"@excalidraw/element";import n9 from"clsx";import{useState as r9,useEffect as i9}from"react";import{THEME as a9}from"@excalidraw/common";import{jsx as Qh,jsxs as l9}from"react/jsx-runtime";var ad=({delay:e,theme:o})=>{let[t,n]=r9(!!e);return i9(()=>{if(!e)return;let r=setTimeout(()=>{n(!1)},e);return()=>clearTimeout(r)},[e]),t?null:l9("div",{className:n9("LoadingMessage",{"LoadingMessage--dark":o===a9.DARK}),children:[Qh("div",{children:Qh(tt,{})}),Qh("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import s9 from"clsx";import{jsx as Pv,jsxs as d9}from"react/jsx-runtime";var c9="medium",Lv={CHECKED:vr,UNCHECKED:On},ld=e=>d9("label",{className:s9("ToolIcon ToolIcon__lock",`ToolIcon_size_${c9}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[Pv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),Pv("div",{className:"ToolIcon__icon",children:e.checked?Lv.CHECKED:Lv.UNCHECKED})]});import{showSelectedShapeActions as M9}from"@excalidraw/element";import m9 from"clsx";import{jsx as p9}from"react/jsx-runtime";var sd=({children:e,side:o,className:t})=>p9("div",{className:m9("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import u9 from"clsx";import{KEYS as Av}from"@excalidraw/common";import{jsx as h9}from"react/jsx-runtime";var cd=e=>h9(K,{className:u9("Shape",{fillable:!1}),type:"radio",icon:Ql,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:Av.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":Av.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{CANVAS_SEARCH_TAB as g9,DEFAULT_SIDEBAR as f9}from"@excalidraw/common";import{isFlowchartNodeElement as b9,isImageElement as Dv,isLinearElement as _v,isLineElement as x9,isTextBindableContainer as E9,isTextElement as y9}from"@excalidraw/element";import{getShortcutKey as eg}from"@excalidraw/common";import{isNodeInFlowchart as w9}from"@excalidraw/element";import{jsx as Rv}from"react/jsx-runtime";var v9=({appState:e,isMobile:o,device:t,app:n})=>{let{activeTool:r,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===f9.name&&e.openSidebar.tab===g9&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(bt(e))return g("hints.eraserRevert");if(r.type==="arrow"||r.type==="line")return s?g("hints.linearElementMulti"):r.type==="arrow"?g("hints.arrowTool",{arrowShortcut:eg("A")}):g("hints.linearElement");if(r.type==="freedraw")return g("hints.freeDraw");if(r.type==="text")return g("hints.text");if(r.type==="embeddable")return g("hints.embeddable");let d=n.scene.getSelectedElements(e);if(i&&l==="mouse"&&d.length===1){let m=d[0];return _v(m)&&m.points.length===2?g("hints.lockAngle"):Dv(m)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(d.length===1&&y9(d[0]))return g("hints.text_selected");if(e.editingTextElement)return g("hints.text_editing");if(e.croppingElementId)return g("hints.leaveCropEditor");if(d.length===1&&Dv(d[0]))return g("hints.enterCropEditor");if(r.type==="selection"){if(e.selectionElement&&!d.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[g("hints.deepBoxSelect")];if(fn(n)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!d.length&&!o)return[g("hints.canvasPanning")];if(d.length===1){if(_v(d[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):x9(d[0])?g("hints.lineEditor_line_info"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&E9(d[0]))return b9(d[0])?w9(d[0],n.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},dd=({appState:e,isMobile:o,device:t,app:n})=>{let r=v9({appState:e,isMobile:o,device:t,app:n});if(!r)return null;let i=Array.isArray(r)?r.map(a=>eg(a).replace(/\. ?$/,"")).join(". "):eg(r);return Rv("div",{className:"HintViewer",children:Rv("span",{children:i})})};import T9 from"clsx";import{jsx as Nv,jsxs as C9}from"react/jsx-runtime";var I9="medium",md=e=>e.penDetected?C9("label",{className:T9("ToolIcon ToolIcon__penMode",`ToolIcon_size_${I9}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Nv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Nv("div",{className:"ToolIcon__icon",children:B1})]}):null;import{Fragment as S9,jsx as Bv,jsxs as k9}from"react/jsx-runtime";var En=({heading:e,children:o,...t})=>{let{id:n}=Ge(),r=Bv("h2",{className:"visually-hidden",id:`${n}-${e}-title`,children:g(`headings.${e}`)});return Bv("section",{...t,"aria-labelledby":`${n}-${e}-title`,children:typeof o=="function"?o(r):k9(S9,{children:[r,o]})})};import{Fragment as L9,jsx as nt,jsxs as Uo}from"react/jsx-runtime";var Fv=({appState:e,elements:o,actionManager:t,setAppState:n,onLockToggle:r,onHandToolToggle:i,onPenModeToggle:a,renderTopRightUI:l,renderCustomStats:s,renderSidebars:d,device:m,renderWelcomeScreen:c,UIOptions:p,app:u})=>{let{WelcomeScreenCenterTunnel:f,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=ve(),w=()=>Uo(sd,{side:"top",className:"App-top-bar",children:[c&&nt(f.Out,{}),nt(En,{heading:"shapes",children:y=>nt(qe.Col,{gap:4,align:"center",children:Uo(qe.Row,{gap:1,className:"App-toolbar-container",children:[Uo(Xe,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[y,nt(qe.Row,{gap:1,children:nt(Dc,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Uo("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&nt(x.Out,{}),nt(md,{checked:e.penMode,onChange:()=>a(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),nt(ld,{checked:e.activeTool.locked,onChange:r,title:g("toolBar.lock"),isMobile:!0}),nt(cd,{checked:qt(e),onChange:()=>i(),title:g("toolBar.hand"),isMobile:!0})]})]})})}),nt(dd,{appState:e,isMobile:!0,device:m,app:u})]}),E=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?nt("div",{className:"App-toolbar-content",children:nt(b.Out,{})}):Uo("div",{className:"App-toolbar-content",children:[nt(b.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),Uo("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return Uo(L9,{children:[d(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&w(),nt("div",{className:"App-bottom-bar",style:{marginBottom:Ct+lo*2,marginLeft:Ct+lo*2,marginRight:Ct+lo*2},children:Uo(Xe,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&M9(e,o)?nt(En,{className:"App-mobile-menu",heading:"selectedShapeActions",children:nt(Ac,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,Uo("footer",{className:"App-toolbar",children:[E(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&nt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(y=>({...Fn(o,y)}))},children:g("buttons.scrollBackToContent")})]})]})})]})};import P9 from"open-color";import A9,{useLayoutEffect as D9,useRef as _9,useState as R9}from"react";import{jsx as Ja,jsxs as N9}from"react/jsx-runtime";var Ov=e=>{let o=_9(null),[t,n]=R9(null);return D9(()=>{if(!e.spreadsheet)return;let r=Yx(e.chartType,e.spreadsheet,0,0);n(r);let i,a=o.current;return(async()=>(i=await br(r,{exportBackground:!1,viewBackgroundColor:P9.white},null,{skipInliningFonts:!0}),i.querySelector(".style-fonts")?.remove(),a.replaceChildren(),a.appendChild(i),e.selected&&a.parentNode.focus()))(),()=>{a.replaceChildren()}},[e.spreadsheet,e.chartType,e.selected]),Ja("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:Ja("div",{ref:o})})},zv=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:n}=Re(),r=A9.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{n(l),ne("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Ja(Be,{size:"small",onCloseRequest:r,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:N9("div",{className:"container",children:[Ja(Ov,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),Ja(Ov,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as yn from"@radix-ui/react-popover";import Hv from"clsx";import pd,{useLayoutEffect as B9}from"react";import{supportsResizeObserver as F9,isShallowEqual as O9}from"@excalidraw/common";import{Fragment as Y9,jsx as vo,jsxs as ud}from"react/jsx-runtime";var z9=4,H9=8,G9=({shouldWrap:e,children:o,username:t})=>e?vo(At,{label:t||"Unknown user",children:o}):vo(Y9,{children:o}),tg=({actionManager:e,collaborator:o,socketId:t,withName:n=!1,shouldWrapWithTooltip:r=!1,isBeingFollowed:i})=>{let a={socketId:t,collaborator:o,withName:n,isBeingFollowed:i},l=e.renderAction("goToCollaborator",a);return vo(G9,{username:o.username,shouldWrap:r,children:l},t)},U9=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],hd=pd.memo(({className:e,mobile:o,collaborators:t,userToFollow:n})=>{let r=Ue(),i=new Map;t.forEach((b,x)=>{let w=b.id||x;i.set(w,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=pd.useState(""),d=a.filter(b=>b.username?.toLowerCase().includes(l)),m=pd.useRef(null);B9(()=>{if(m.current){let b=w=>{let E=Math.max(1,Math.min(8,Math.floor(w/38)));p(E)};if(b(m.current.clientWidth),!F9)return;let x=new ResizeObserver(w=>{for(let E of w){let{width:y}=E.contentRect;b(y)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[c,p]=pd.useState(z9),f=a.slice(0,c-1).map(b=>tg({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}));return o?vo("div",{className:Hv("UserList UserList_mobile",e),children:a.map(b=>tg({actionManager:r,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===n}))}):vo("div",{className:"UserList__wrapper",ref:m,children:ud("div",{className:Hv("UserList",e),style:{"--max-avatars":c},children:[f,a.length>c-1&&ud(yn.Root,{children:[ud(yn.Trigger,{className:"UserList__more",children:["+",a.length-c+1]}),vo(yn.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:ud(Xe,{padding:2,children:[a.length>=H9&&vo(vs,{placeholder:g("quickSearch.placeholder"),onChange:s}),vo(Ts,{className:"dropdown-menu UserList__collaborators",placeholder:g("userList.empty"),children:d.length>0?[vo("div",{className:"hint",children:g("userList.hint.text")}),d.map(b=>tg({actionManager:r,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===n}))]:[]}),vo(yn.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})]})]})})},(e,o)=>{if(e.collaborators.size!==o.collaborators.size||e.mobile!==o.mobile||e.className!==o.className||e.userToFollow!==o.userToFollow)return!1;let t=o.collaborators.keys();for(let[n,r]of e.collaborators){let i=o.collaborators.get(n);if(!i||n!==t.next().value||!O9(r,i,U9))return!1}return!0});import og from"clsx";import{jsx as W9}from"react/jsx-runtime";var Gv=e=>W9("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Ir});import{jsx as Yo,jsxs as ng}from"react/jsx-runtime";var Uv=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:n})=>{let{FooterCenterTunnel:r,WelcomeScreenHelpHintTunnel:i}=ve();return ng("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Yo("div",{className:og("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Yo(qe.Col,{gap:2,children:ng(En,{heading:"canvasActions",children:[Yo(f2,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Yo(b2,{renderAction:o.renderAction,className:og("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Yo(r.Out,{}),Yo("div",{className:og("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:ng("div",{style:{position:"relative"},children:[n&&Yo(i.Out,{}),Yo(Gv,{onClick:()=>o.executeAction(jn)})]})}),Yo(x2,{actionManager:o,showExitZenModeBtn:t})]})},Yv=Uv;Uv.displayName="Footer";import J9 from"clsx";import{useEffect as e3,useLayoutEffect as t3,useRef as pg,useState as Q9,forwardRef as o3,useImperativeHandle as eN,useCallback as qv}from"react";import{EVENT as Jv,isDevEnv as tN,KEYS as oN,updateObject as nN}from"@excalidraw/common";import X9 from"clsx";import{useContext as K9}from"react";import V9 from"react";var gd=V9.createContext({});import{jsx as rg,jsxs as Wv}from"react/jsx-runtime";var ig=({children:e,className:o})=>{let t=se(),n=K9(gd),r=!!(t.editor.canFitSidebar&&n.shouldRenderDockButton);return Wv("div",{className:X9("sidebar__header",o),"data-testid":"sidebar-header",children:[e,Wv("div",{className:"sidebar__header__buttons",children:[r&&rg(At,{label:g("labels.sidebarLock"),children:rg(Rt,{onSelect:()=>n.onDock?.(!n.docked),selected:!!n.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:P1})}),rg(Rt,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:n.onCloseRequest,"aria-label":g("buttons.close"),children:Ft})]})]})};ig.displayName="SidebarHeader";import*as Xv from"@radix-ui/react-tabs";import{jsx as Vv}from"react/jsx-runtime";var ag=({children:e,tab:o,onSelect:t,...n})=>Vv(Xv.Trigger,{value:o,asChild:!0,onSelect:t,children:Vv("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...n,children:e})});ag.displayName="SidebarTabTrigger";import*as Kv from"@radix-ui/react-tabs";import{jsx as Z9}from"react/jsx-runtime";var lg=({children:e,...o})=>Z9(Kv.List,{className:"sidebar-triggers",...o,children:e});lg.displayName="SidebarTabTriggers";import $9 from"clsx";import{jsx as sg,jsxs as Zv}from"react/jsx-runtime";var cg=({name:e,tab:o,icon:t,title:n,children:r,onToggle:i,className:a,style:l})=>{let s=le(),d=ge();return Zv("label",{title:n,className:"sidebar-trigger__label-element",children:[sg("input",{className:"ToolIcon_type_checkbox",type:"checkbox",onChange:m=>{document.querySelector(".layer-ui__wrapper")?.classList.remove("animate");let c=m.target.checked;s({openSidebar:c?{name:e,tab:o}:null}),i?.(c)},checked:d.openSidebar?.name===e,"aria-label":n,"aria-keyshortcuts":"0"}),Zv("div",{className:$9("sidebar-trigger",a),style:l,children:[t&&sg("div",{children:t}),r&&sg("div",{className:"sidebar-trigger__label",children:r})]})]})};cg.displayName="SidebarTrigger";import*as $v from"@radix-ui/react-tabs";import{jsx as j9}from"react/jsx-runtime";var dg=({children:e,...o})=>{let t=ge(),n=le();if(!t.openSidebar)return null;let{name:r}=t.openSidebar;return j9($v.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>n(a=>({...a,openSidebar:{...a.openSidebar,name:r,tab:i}})),...o,children:e})};dg.displayName="SidebarTabs";import*as jv from"@radix-ui/react-tabs";import{jsx as q9}from"react/jsx-runtime";var mg=({tab:e,children:o,...t})=>q9(jv.Content,{...t,value:e,"data-testid":e,children:o});mg.displayName="SidebarTab";import{jsx as Qv}from"react/jsx-runtime";import{createElement as rN}from"react";var Qa=me(!1),n3=o3(({name:e,children:o,onDock:t,docked:n,className:r,...i},a)=>{tN()&&t&&n==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=le(),s=qo(Qa);t3(()=>(s(!!n),()=>{s(!1)}),[s,n]);let d=pg({});d.current.onCloseRequest=()=>{l({openSidebar:null})},d.current.onDock=u=>t?.(u),d.current=nN(d.current,{docked:n,shouldRenderDockButton:!!t&&n!=null});let m=pg(null);eN(a,()=>m.current);let c=se(),p=qv(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return _r(m,qv(u=>{u.target.closest(".sidebar-trigger")||(!n||!c.editor.canFitSidebar)&&p()},[p,n,c.editor.canFitSidebar])),e3(()=>{let u=f=>{f.key===oN.ESCAPE&&(!n||!c.editor.canFitSidebar)&&p()};return document.addEventListener(Jv.KEYDOWN,u),()=>{document.removeEventListener(Jv.KEYDOWN,u)}},[p,n,c.editor.canFitSidebar]),Qv(Xe,{...i,className:J9("sidebar",{"sidebar--docked":n},r),ref:m,children:Qv(gd.Provider,{value:d.current,children:o})})});n3.displayName="SidebarInner";var Kt=Object.assign(o3((e,o)=>{let t=ge(),{onStateChange:n}=e,r=pg(t.openSidebar);e3(()=>{(!t.openSidebar&&r?.current?.name===e.name||t.openSidebar?.name===e.name&&r?.current?.name!==e.name||r.current?.name===e.name)&&t.openSidebar!==r.current&&n?.(t.openSidebar?.name!==e.name?null:t.openSidebar),r.current=t.openSidebar},[t.openSidebar,n,e.name]);let[i,a]=Q9(!1);return t3(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?rN(n3,{...e,ref:o,key:e.name}):null}),{Header:ig,TabTriggers:lg,TabTrigger:ag,Tabs:dg,Tab:mg,Trigger:cg});Kt.displayName="Sidebar";import{composeEventHandlers as uN}from"@excalidraw/common";import{useLayoutEffect as iN,useRef as aN}from"react";import{jsx as lN}from"react/jsx-runtime";var Wo=(e,o)=>{let t=me(0),n=r=>{let{tunnelsJotai:{useAtom:i}}=ve(),[,a]=i(t),l=aN({preferHost:!1,counter:0});return iN(()=>{let s=l.current;return a(d=>{let m=d+1;return s.counter=m,m}),()=>{a(d=>{let m=d-1;return s.counter=m,m||(s.preferHost=!1),m})}},[a]),r.__fallback||(l.current.preferHost=!0),!l.current.counter&&r.__fallback&&l.current.preferHost||l.current.counter>1&&r.__fallback?null:lN(o,{...r})};return n.displayName=e,n};var gg={};$f(gg,{ChangeCanvasBackground:()=>b3,ClearCanvas:()=>g3,CommandPalette:()=>p3,Export:()=>x3,Help:()=>h3,LiveCollaborationTrigger:()=>y3,LoadScene:()=>c3,SaveAsImage:()=>m3,SaveToActiveFile:()=>d3,SearchMenu:()=>u3,Socials:()=>E3,ToggleTheme:()=>f3});import mN from"clsx";import{THEME as wn}from"@excalidraw/common";var ug=me({active:!1});async function r3({title:e,description:o,actionLabel:t,color:n}){return new Promise(r=>{He.set(ug,{active:!0,onConfirm:()=>r(!0),onClose:()=>r(!1),onReject:()=>r(!1),title:e,description:o,actionLabel:t,color:n})})}import sN from"clsx";import{jsx as i3,jsxs as cN}from"react/jsx-runtime";var fd=function({onChange:e,value:o,choices:t,name:n}){return i3("div",{className:"RadioGroup",children:t.map(r=>cN("div",{className:sN("RadioGroup__choice",{active:r.value===o}),title:r.ariaLabel,children:[i3("input",{name:n,type:"radio",checked:r.value===o,onChange:()=>e(r.value),"aria-label":r.ariaLabel}),r.label]},String(r.value)))})};import{Fragment as dN,jsx as hg,jsxs as a3}from"react/jsx-runtime";var l3=({value:e,shortcut:o,onChange:t,choices:n,children:r,name:i})=>{let a=se();return a3(dN,{children:[a3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[hg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:r}),hg(fd,{name:i,value:e,onChange:t,choices:n})]}),o&&!a.editor.isMobile&&hg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};l3.displayName="DropdownMenuItemContentRadio";var s3=l3;import{Fragment as pN,jsx as je,jsxs as w3}from"react/jsx-runtime";var c3=()=>{let{t:e}=ze(),o=Ue(),t=on();return o.isActionEnabled(Zr)?je(pt,{icon:Cr,onSelect:async()=>{(!t.length||await r3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:je(ht,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:r=>je("strong",{children:r}),br:()=>je("br",{})})}))&&o.executeAction(Zr)},"data-testid":"load-button",shortcut:Ne("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};c3.displayName="LoadScene";var d3=()=>{let{t:e}=ze(),o=Ue();return o.isActionEnabled($n)?je(pt,{shortcut:Ne("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction($n),icon:W1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};d3.displayName="SaveToActiveFile";var m3=()=>{let e=le(),{t:o}=ze();return je(pt,{icon:$l,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:Ne("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};m3.displayName="SaveAsImage";var p3=e=>{let o=le(),{t}=ze();return je(pt,{icon:ta,"data-testid":"command-palette-button",onSelect:()=>{ne("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Ne("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};p3.displayName="CommandPalette";var u3=e=>{let{t:o}=ze(),t=Ue();return je(pt,{icon:Pt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(za)},shortcut:Ne("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};u3.displayName="SearchMenu";var h3=()=>{let{t:e}=ze(),o=Ue();return je(pt,{"data-testid":"help-menu-item",icon:Ir,onSelect:()=>o.executeAction(jn),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};h3.displayName="Help";var g3=()=>{let{t:e}=ze(),o=qo(er);return Ue().isActionEnabled(_o)?je(pt,{icon:Lt,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};g3.displayName="ClearCanvas";var f3=e=>{let{t:o}=ze(),t=ge(),n=Ue(),r=Ne("toggleTheme");return n.isActionEnabled(Vn)?e?.allowSystemTheme?je(s3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:wn.LIGHT,label:qi,ariaLabel:`${o("buttons.lightMode")} - ${r}`},{value:wn.DARK,label:ji,ariaLabel:`${o("buttons.darkMode")} - ${r}`},{value:"system",label:ab,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):je(pt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===wn.DARK?wn.LIGHT:wn.DARK);else return n.executeAction(Vn)},icon:t.theme===wn.DARK?qi:ji,"data-testid":"toggle-dark-mode",shortcut:r,"aria-label":t.theme===wn.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===wn.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};f3.displayName="ToggleTheme";var b3=()=>{let{t:e}=ze(),o=ge(),t=Ue(),n=fo();return o.viewModeEnabled||!n.UIOptions.canvasActions.changeViewBackgroundColor?null:w3("div",{style:{marginTop:"0.5rem"},children:[je("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),je("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};b3.displayName="ChangeCanvasBackground";var x3=()=>{let{t:e}=ze(),o=le();return je(pt,{icon:zn,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};x3.displayName="Export";var E3=()=>{let{t:e}=ze();return w3(pN,{children:[je(pi,{icon:Kl,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),je(pi,{icon:U1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),je(pi,{icon:G1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};E3.displayName="Socials";var y3=({onSelect:e,isCollaborating:o})=>{let{t}=ze();return je(pt,{"data-testid":"collab-button",icon:jl,className:mN({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};y3.displayName="LiveCollaborationTrigger";import{jsx as bd,jsxs as fg}from"react/jsx-runtime";var hN=Object.assign(Wo("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=ve(),n=se(),r=ge(),i=le(),a=n.editor.isMobile?void 0:()=>i({openMenu:null});return bd(t.In,{children:fg(fe,{open:r.openMenu==="canvas",children:[bd(fe.Trigger,{onToggle:()=>{i({openMenu:r.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Xl}),fg(fe.Content,{onClickOutside:a,onSelect:uN(o,()=>{i({openMenu:null})}),children:[e,n.editor.isMobile&&r.collaborators.size>0&&fg("fieldset",{className:"UserList-Wrapper",children:[bd("legend",{children:g("labels.collaborators")}),bd(hd,{mobile:!0,collaborators:r.collaborators,userToFollow:r.userToFollow?.socketId||null})]})]})]})})}),{Trigger:fe.Trigger,Item:fe.Item,ItemLink:fe.ItemLink,ItemCustom:fe.ItemCustom,Group:fe.Group,Separator:fe.Separator,DefaultItems:gg}),dt=hN;import gN from"clsx";import{forwardRef as fN,useState as bN}from"react";import{isPromiseLike as xN}from"@excalidraw/common";import{jsx as xd,jsxs as EN}from"react/jsx-runtime";var vn=fN(({children:e,icon:o,onClick:t,label:n,variant:r="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:d},m)=>{let[c,p]=bN(!1),u=async b=>{let x=t?.(b);if(xN(x)){let w=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof gr)console.warn(E);else throw E}finally{clearTimeout(w),p(!1)}}},f=c?"loading":d;return i=f==="success"?"success":i,xd("button",{className:gN("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${r}`,`ExcButton--size-${a}`,`ExcButton--status-${f}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":n,ref:m,disabled:f==="loading"||f==="success",children:EN("div",{className:"ExcButton__contents",children:[f==="loading"?xd(tt,{className:"ExcButton__statusIcon"}):f==="success"&&xd("div",{className:"ExcButton__statusIcon",children:G0}),o&&xd("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),r!=="icon"&&(e??n)]})})});import{jsx as Mi,jsxs as vN}from"react/jsx-runtime";var Ed=({title:e,children:o,actionLabel:t,onClick:n})=>vN("div",{className:"OverwriteConfirm__Actions__Action",children:[Mi("h4",{children:e}),Mi("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Mi(vn,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:n})]}),yN=()=>{let{t:e}=ze(),o=Ue(),t=le();return Mi(Ed,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Xs,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},wN=()=>{let{t:e}=ze(),o=Ue();return Mi(Ed,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Ia,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},bg=Object.assign(({children:e})=>Mi("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:yN,SaveToDisk:wN});import{jsx as Tn,jsxs as v3}from"react/jsx-runtime";var yd=Object.assign(Wo("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=ve(),[t,n]=ie(ug);if(!t.active)return null;let r=()=>{t.onClose(),n(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),n(a=>({...a,active:!1}))};return Tn(o.In,{children:Tn(Be,{onCloseRequest:r,title:!1,size:916,children:v3("div",{className:"OverwriteConfirm",children:[Tn("h3",{children:t.title}),v3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[Tn("div",{className:"OverwriteConfirm__Description__icon",children:U0}),Tn("div",{children:t.description}),Tn("div",{className:"OverwriteConfirm__Description__spacer"}),Tn(vn,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),Tn(bg,{children:e})]})})})}),{Actions:bg,Action:Ed});import WN from"clsx";import{CANVAS_SEARCH_TAB as vg,DEFAULT_SIDEBAR as VN,LIBRARY_SIDEBAR_TAB as D3,composeEventHandlers as XN}from"@excalidraw/common";import{round as TN}from"@excalidraw/math";import IN from"clsx";import CN from"lodash.debounce";import{Fragment as SN,memo as kN,useEffect as el,useMemo as T3,useRef as xg,useState as I3}from"react";import{CLASSES as MN,EVENT as LN,FONT_FAMILY as Eg,FRAME_STYLE as yg,getLineHeight as PN}from"@excalidraw/common";import{isElementCompletelyInViewport as AN}from"@excalidraw/element";import{measureText as tl}from"@excalidraw/element";import{KEYS as Li,randomInteger as C3,addEventListener as DN,getFontString as wd}from"@excalidraw/common";import{newTextElement as _N}from"@excalidraw/element";import{isTextElement as L3,isFrameLikeElement as vd}from"@excalidraw/element";import{getDefaultFrameName as P3}from"@excalidraw/element/frame";import{Fragment as YN,jsx as Je,jsxs as To}from"react/jsx-runtime";var RN=me(""),wg=me(null),NN=350,A3=()=>{let e=Re(),o=le(),t=xg(null),[n,r]=ie(RN),i=n.trim(),[a,l]=I3(!1),[s,d]=I3({nonce:null,items:[]}),m=xg(null),c=xg(void 0),[p,u]=ie(wg),f=e.scene.getNonDeletedElementsMap();el(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==c.current)&&(m.current=null,M3(i,e,(y,v)=>{d({nonce:C3(),items:y}),m.current=i,c.current=e.scene.getSceneNonce(),o({searchMatches:y.length?{focusedId:null,matches:y.map(C=>({id:C.element.id,focus:!1,matchedLines:C.matchedLines}))}:null})}))},[a,i,f,e,o,u,c]);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)};el(()=>{o(y=>y.searchMatches?{searchMatches:{focusedId:p!==null&&y.searchMatches?.matches[p]?.id||null,matches:y.searchMatches.matches.map((C,S)=>S===p?{...C,focus:!0}:{...C,focus:!1})}}:null)},[p,o]),el(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,C=_N({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:vd(y.element)?yg.nameFontSize:y.element.fontSize,fontFamily:vd(y.element)?Eg.Assistant:y.element.fontFamily}),S=14,L=C.fontSize,k=L*v<S;if(!AN([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())||k){let A;k?L>=S?A={fitToContent:!0}:A={fitToViewport:!0,maxZoom:TN(S/L,1)}:A={fitToContent:!0},e.scrollToContent(C,{animate:!0,duration:300,...A,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),el(()=>()=>{u(null),m.current=null,c.current=void 0,o({searchMatches:null}),l(!1)},[o,u]);let w=Qo({goToNextItem:b,goToPreviousItem:x,searchMatches:s});el(()=>{let y=v=>{if(v.key===Li.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[Li.CTRL_OR_CMD]&&v.key===Li.F){if(v.preventDefault(),v.stopPropagation(),e.state.openDialog)return;t.current?.matches(":focus")||(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())}v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&w.searchMatches.items.length&&(v.key===Li.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===Li.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===Li.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return DN(window,LN.KEYDOWN,y,{capture:!0,passive:!1})},[o,w,e]);let E=`${s.items.length} ${s.items.length===1?g("search.singleResult"):g("search.multipleResults")}`;return To("div",{className:"layer-ui__search",children:[Je("div",{className:"layer-ui__search-header",children:Je(gi,{className:MN.SEARCH_MENU_INPUT_WRAPPER,value:n,ref:t,placeholder:g("search.placeholder"),icon:Pt,onChange:y=>{r(y),l(!0);let v=y.trim();M3(v,e,(C,S)=>{d({nonce:C3(),items:C}),u(S),m.current=v,c.current=e.scene.getSceneNonce(),o({searchMatches:C.length?{focusedId:null,matches:C.map(L=>({id:L.element.id,focus:!1,matchedLines:L.matchedLines}))}:null}),l(!1)})},selectOnRender:!0})}),To("div",{className:"layer-ui__search-count",children:[s.items.length>0&&To(YN,{children:[p!==null&&p>-1?To("div",{children:[p+1," / ",E]}):Je("div",{children:E}),To("div",{className:"result-nav",children:[Je(Rt,{onSelect:()=>{b()},className:"result-nav-btn",children:as}),Je(Rt,{onSelect:()=>{x()},className:"result-nav-btn",children:mb})]})]}),s.items.length===0&&i&&m.current&&Je("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),Je(ON,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},S3=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 Je("div",{tabIndex:-1,className:IN("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:Je("div",{className:"preview-text",children:o.flatMap((t,n)=>Je(SN,{children:n===2?Je("b",{children:t}):t},n))})})},BN=e=>{let o=T3(()=>e.matches.items.filter(n=>vd(n.element)),[e.matches]),t=T3(()=>e.matches.items.filter(n=>L3(n.element)),[e.matches]);return To("div",{children:[o.length>0&&To("div",{className:"layer-ui__search-result-container",children:[To("div",{className:"layer-ui__search-result-title",children:[Je("div",{className:"title-icon",children:Gn}),Je("div",{children:g("search.frames")})]}),o.map((n,r)=>Je(S3,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r===e.focusIndex,onClick:()=>e.onItemClick(r)},n.element.id+n.index)),t.length>0&&Je("div",{className:"layer-ui__divider"})]}),t.length>0&&To("div",{className:"layer-ui__search-result-container",children:[To("div",{className:"layer-ui__search-result-title",children:[Je("div",{className:"title-icon",children:Tr}),Je("div",{children:g("search.texts")})]}),t.map((n,r)=>Je(S3,{searchQuery:e.searchQuery,preview:n.preview,highlighted:r+o.length===e.focusIndex,onClick:()=>e.onItemClick(r+o.length)},n.element.id+n.index))]})]})},FN=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,ON=kN(BN,FN),k3=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),d=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;d=d.length>m?d.slice(-m):d;let c=e.slice(o+t.length),p=c.split(/\s+/),u=!c.startsWith(" "),f=u?6:5,b=(u?"":" ")+p.slice(0,f).join(" ");return{indexInSearchQuery:d.length,previewText:d+t+b,moreBefore:s>0,moreAfter:p.length>f}},zN=(e,o)=>{let t=e.split(`
17
+ `),n=[],r=0;for(let i=0;i<t.length;i++){let a=t[i],l=t[i+1];if(l){let s=o.indexOf(l,r);if(s>a.length+r){let d=s-(a.length+r);for(;d>0;)a+=" ",d--}}n.push(a),r=r+a.length}return n.join(`
18
+ `)},HN=(e,o,t)=>{let r=zN(e.text,e.originalText).split(`
19
+ `),i=[],a=0,l=0;for(let c of r){let p=a,u=p+c.length-1;i.push({line:c,startIndex:p,endIndex:u,lineNumber:l}),a=u+1,l++}let s=t,d=e.originalText.slice(t,t+o.length),m=[];for(let c of i){if(d==="")break;if(s>=c.startIndex&&s<=c.endIndex){let p=c.endIndex+1-s,u=c.line.slice(0,s-c.startIndex),f=d.slice(0,p);d=d.slice(p);let b=tl(u,wd(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&c.line.length>0){let v=tl(c.line,wd(e),e.lineHeight),C=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=C}let{width:x,height:w}=tl(f,wd(e),e.lineHeight),E=b.width,y=c.lineNumber*b.height;m.push({offsetX:E,offsetY:y,width:x,height:w,showOnCanvas:!0}),s+=p}}return m},GN=(e,o,t,n)=>{let r=e.name??P3(e),i=r.slice(t,t+o.length),a=r.slice(0,t),l=wd({fontSize:yg.nameFontSize,fontFamily:Eg.Assistant}),s=PN(Eg.Assistant),d=tl(a,l,s);a===""&&(d.width=0);let m=tl(i,l,s),c=d.width,p=-d.height-yg.strokeWidth,u=m.width;return[{offsetX:c,offsetY:p,width:u,height:m.height,showOnCanvas:c+u<=e.width*n}]},UN=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),M3=CN((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements(),r=n.filter(p=>L3(p)),i=n.filter(p=>vd(p));r.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(UN(e),"gi");for(let p of r){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=k3(f,u.index,e),x=HN(p,e,u.index);x.length>0&&a.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let s=[];for(let p of i){let u=null,f=p.name??P3(p);for(;(u=l.exec(f))!==null;){let b=k3(f,u.index,e),x=GN(p,e,u.index,o.state.zoom.value);x.length>0&&s.push({element:p,searchQuery:e,preview:b,index:u.index,matchedLines:x})}}let d=new Set(o.visibleElements.map(p=>p.id)),m=[...s,...a],c=m.findIndex(p=>d.has(p.element.id))??null;t(m,c)},NN);import{jsx as so,jsxs as _3}from"react/jsx-runtime";import{createElement as KN}from"react";var R3=Wo("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=ve();return so(o.In,{children:so(Kt.Trigger,{...e,className:"default-sidebar-trigger",name:VN.name})})});R3.displayName="DefaultSidebarTrigger";var N3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=ve();return so(o.In,{children:e})};N3.displayName="DefaultTabTriggers";var Td=Object.assign(Wo("DefaultSidebar",({children:e,className:o,onDock:t,docked:n,...r})=>{let i=ge(),a=le(),{DefaultSidebarTabTriggersTunnel:l}=ve(),s=i.openSidebar?.tab===vg;return KN(Kt,{...r,name:"default",key:"default",className:WN("default-sidebar",o),docked:s||(n??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&n!=null?void 0:XN(t,d=>{a({defaultSidebarDockedPreference:d})})},_3(Kt.Tabs,{children:[so(Kt.Header,{children:_3(Kt.TabTriggers,{children:[so(Kt.TabTrigger,{tab:vg,children:Pt}),so(Kt.TabTrigger,{tab:D3,children:wr}),so(l.Out,{})]})}),so(Kt.Tab,{tab:D3,children:so(r2,{})}),so(Kt.Tab,{tab:vg,children:so(A3,{})}),e]}))}),{Trigger:R3,TabTriggers:N3});import{useEffect as uB,useRef as Cg,useState as _d}from"react";import{isFiniteNumber as nT}from"@excalidraw/math";import{useState as Y3,useRef as W3,useEffect as V3,useDeferredValue as oB}from"react";import{EDITOR_LS_KEYS as nB,debounce as rB,isDevEnv as iB}from"@excalidraw/common";import{useEffect as ZN,useRef as B3}from"react";import{EVENT as F3,KEYS as O3}from"@excalidraw/common";import{jsx as $N}from"react/jsx-runtime";var Id=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:n})=>{let r=B3(null),i=B3(n);return i.current=n,ZN(()=>{if(!i.current)return;let a=r.current;if(a){let l=s=>{s[O3.CTRL_OR_CMD]&&s.key===O3.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(F3.KEYDOWN,l),()=>{a.removeEventListener(F3.KEYDOWN,l)}}},[]),$N("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:r})};import{jsx as Cd,jsxs as z3}from"react/jsx-runtime";var jN=({error:e})=>z3("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Cd("p",{children:e})]}),Sd=({error:e,canvasRef:o,loaded:t})=>z3("div",{className:"ttd-dialog-output-wrapper",children:[e&&Cd(jN,{error:e.message}),t?Cd("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Cd(tt,{size:"2rem"})]});import H3 from"clsx";import{jsx as Tg,jsxs as ol}from"react/jsx-runtime";var Pi=({label:e,children:o,panelAction:t,panelActionDisabled:n=!1,onTextSubmitInProgess:r,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>ol("div",{className:"ttd-dialog-panel",children:[ol("div",{className:"ttd-dialog-panel__header",children:[Tg("label",{children:e}),i?.()]}),o,ol("div",{className:H3("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[ol(Rt,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:n||r,children:[ol("div",{className:H3({invisible:r}),children:[t?.label,t?.icon&&Tg("span",{children:t.icon})]}),r&&Tg(tt,{})]}),!n&&!r&&a?.(),l?.()]})]});import{jsx as qN}from"react/jsx-runtime";var kd=({children:e})=>qN("div",{className:"ttd-dialog-panels",children:e});import{getShortcutKey as G3}from"@excalidraw/common";import{jsx as U3,jsxs as JN}from"react/jsx-runtime";var Md=()=>JN("div",{className:"ttd-dialog-submit-shortcut",children:[U3("div",{className:"ttd-dialog-submit-shortcut__key",children:G3("CtrlOrCmd")}),U3("div",{className:"ttd-dialog-submit-shortcut__key",children:G3("Enter")})]});import{DEFAULT_EXPORT_PADDING as QN,EDITOR_LS_KEYS as eB}from"@excalidraw/common";var tB=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let n=t.parentElement;n&&(n.style.background="",o(null),t.replaceChildren())},Ld=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:n,data:r})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){tB({canvasRef:e,setError:n});return}try{let l=await o.api,s;try{s=await l.parseMermaidToExcalidraw(t)}catch{s=await l.parseMermaidToExcalidraw(t.replace(/"/g,"'"))}let{elements:d,files:m}=s;n(null),r.current={elements:Ci(d,{regenerateIds:!0}),files:m};let c=await mn({elements:r.current.elements,files:r.current.files,exportPadding:QN,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await ko(c)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):p}a.style.background="var(--default-bg-color)",i.replaceChildren(c)}catch(l){throw a.style.background="var(--default-bg-color)",t&&n(l),l}}},nl=e=>{Ut.set(eB.MERMAID_TO_EXCALIDRAW,e)},Pd=({app:e,data:o,text:t,shouldSaveMermaidDataToStorage:n})=>{let{elements:r,files:i}=o.current;r.length&&(e.addElementsFromPasteOrLibrary({elements:r,files:i,position:"center",fitToContent:!0}),e.setOpenDialog(null),n&&t&&nl(t))};import{Fragment as sB,jsx as Io,jsxs as K3}from"react/jsx-runtime";var aB=`flowchart TD
13
20
  A[Christmas] -->|Get money| B(Go shopping)
14
21
  B --> C{Let me think}
15
22
  C -->|One| D[Laptop]
16
23
  C -->|Two| E[iPhone]
17
- C -->|Three| F[Car]`,Hw=Dn(jl,300),HS=({mermaidToExcalidrawLib:e})=>{let[o,t]=zw(()=>To.get(Hr.MERMAID_TO_EXCALIDRAW)||FS),r=BS(o.trim()),[n,i]=zw(null),a=Bw(null),l=Bw({elements:[],files:null}),s=Je();Fw(()=>{Lm({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:r}).catch(m=>{pt()&&console.error("Failed to parse mermaid definition",m)}),Hw(r)},[r,e]),Fw(()=>()=>{Hw.flush()},[]);let c=()=>{Am({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return Uw(US,{children:[mr("div",{className:"ttd-dialog-desc",children:mr(Ft,{i18nKey:"mermaid.description",flowchartLink:m=>mr("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:m}),sequenceLink:m=>mr("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:m}),classLink:m=>mr("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:m})})}),Uw(Sm,{children:[mr(Ma,{label:g("mermaid.syntax"),children:mr(Cm,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:m=>t(m.target.value),onKeyboardSubmit:()=>{c()}})}),mr(Ma,{label:g("mermaid.preview"),panelAction:{action:()=>{c()},label:g("mermaid.button"),icon:Ki},renderSubmitShortcut:()=>mr(Mm,{}),children:mr(km,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},Gw=HS;import*as Vw from"@radix-ui/react-tabs";import{useRef as Ww}from"react";import{jsx as GS}from"react/jsx-runtime";var Yw=e=>{let o=ye(),t=Ww(null),r=Ww(0);return GS(Vw.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:n=>{if(!n)return;let i=t.current?.closest(".Modal__content");if(i){let a=i.offsetHeight||0;a>r.current&&(r.current=a,i.style.minHeight=`min(${r.current}px, 100%)`)}e.dialog==="ttd"&&Rs(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};Yw.displayName="TTDDialogTabs";var Kw=Yw;import*as Zw from"@radix-ui/react-tabs";import{jsx as WS}from"react/jsx-runtime";var Mg=({children:e,...o})=>WS(Zw.List,{className:"ttd-dialog-triggers",...o,children:e});Mg.displayName="TTDDialogTabTriggers";import*as $w from"@radix-ui/react-tabs";import{jsx as Xw}from"react/jsx-runtime";var _m=({children:e,tab:o,onSelect:t,...r})=>Xw($w.Trigger,{value:o,asChild:!0,onSelect:t,children:Xw("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});_m.displayName="TTDDialogTabTrigger";import*as jw from"@radix-ui/react-tabs";import{jsx as VS}from"react/jsx-runtime";var Dm=({tab:e,children:o,...t})=>VS(jw.Content,{...t,value:e,children:o});Dm.displayName="TTDDialogTab";import{jsx as Gt,jsxs as yn}from"react/jsx-runtime";var Ag=3,La=1e3,KS=Ie(null),ZS=Ie(null),_g=e=>{let o=Le();return o.openDialog?.name!=="ttd"?null:Gt(XS,{...e,tab:o.openDialog.tab})},XS=Rr("TTDDialogBase",({tab:e,...o})=>{let t=Je(),r=ye(),n=Lg(null),[i,a]=he(ZS),[l,s]=Pm(i?.prompt??""),c=l.trim(),m=k=>{s(k.target.value),a(D=>({generatedResponse:D?.generatedResponse??null,prompt:k.target.value}))},[d,p]=Pm(!1),[u,f]=he(KS),b=async()=>{if(c.length>La||c.length<Ag||d||u?.rateLimitRemaining===0||"__fallback"in o){c.length<Ag&&S(new Error(`Prompt is too short (min ${Ag} characters)`)),c.length>La&&S(new Error(`Prompt is too long (max ${La} characters)`));return}try{p(!0),de("ai","generate","ttd");let{generatedResponse:k,error:D,rateLimit:M,rateLimitRemaining:O}=await o.onTextSubmit(c);if(typeof k=="string"&&a(P=>({generatedResponse:k,prompt:P?.prompt??null})),rp(M)&&rp(O)&&f({rateLimit:M,rateLimitRemaining:O}),D){S(D);return}if(!k){S(new Error("Generation failed"));return}try{await Lm({canvasRef:n,data:v,mermaidToExcalidrawLib:E,setError:S,mermaidDefinition:k}),de("ai","mermaid parse success","ttd")}catch(P){console.info(`%cTTD mermaid render errror: ${P.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
18
- TTD mermaid definition render errror: ${P.message}`,"color: yellow"),de("ai","mermaid parse failed","ttd"),S(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(k){let D=k.message;(!D||D==="Failed to fetch")&&(D="Request failed"),S(new Error(D))}finally{p(!1)}},x=Lg(b);x.current=b;let[E,w]=Pm({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});YS(()=>{(async()=>{await E.api,w(D=>({...D,loaded:!0}))})()},[E.api]);let v=Lg({elements:[],files:null}),[T,S]=Pm(null);return Gt(et,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:yn(Kw,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?Gt("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):yn(Mg,{children:[Gt(_m,{tab:"text-to-diagram",children:yn("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),Gt("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"})]})}),Gt(_m,{tab:"mermaid",children:"Mermaid"})]}),Gt(Dm,{className:"ttd-dialog-content",tab:"mermaid",children:Gt(Gw,{mermaidToExcalidrawLib:E})}),!("__fallback"in o)&&yn(Dm,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[Gt("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."}),yn(Sm,{children:[Gt(Ma,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:Ki},onTextSubmitInProgess:d,panelActionDisabled:c.length>La||u?.rateLimitRemaining===0,renderTopRight:()=>u?yn("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:()=>Gt(Mm,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return yn("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(jl(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",Gt(cn,{icon:Ki})]});let k=c.length/La;return k>.8?yn("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:k>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",La]}):null},children:Gt(Cm,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),Gt(Ma,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Am({app:t,data:v})},label:"Insert",icon:Ki},children:Gt(km,{canvasRef:n,error:T,loaded:E.loaded})})]})]})]})})});import zM from"clsx";import BM from"lodash.throttle";import{useEffect as c3,useMemo as zg,useState as FM,memo as HM}from"react";import $S from"clsx";import{useEffect as Jw,useRef as Rm,useState as jS}from"react";var qw=.01,ql=10,Qt=(e,o)=>!(o==="height"&&Y(e)||o==="width"&&Y(e)||o==="angle"&&ae(e)),Ve=(e,o)=>{let t=e+o/2;return t-t%o},Aa=(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 ci=(e,o,t,r,n,i=!0)=>{let a=r.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,c]=[t.x+t.width/2,t.y+t.height/2],[m,d]=Oe(L(t.x,t.y),L(s,c),t.angle),p=e-m,u=o-d,[f,b]=Oe(L(e,o),L(s+p,c+u),-t.angle);r.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),jr(l,r);let x=Ee(t,n);if(x){let E=a.get(x.id);E&&r.mutateElement(E,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(ae(t)){let E=No(n,t.id);E.forEach(w=>{let v=a.get(w.id);if(!v)return;let[T,S]=[w.x+w.width/2,w.y+w.height/2],[k,D]=Oe(L(w.x,w.y),L(T,S),w.angle),M=Math.round(k+p),O=Math.round(D+u),[P,F]=Oe(L(M,O),L(T+p,S+u),-w.angle);r.mutateElement(v,{x:P,y:F},{informMutation:i,isDragging:!1}),jr(v,r,{simultaneouslyUpdated:E})})}},_a=(e,o)=>{let r=Ro(o).map(n=>$e(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!Kr(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as Dg,jsxs as JS}from"react/jsx-runtime";var qS=({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=Je(),p=Rm(null),u=Rm(null),[f,b]=jS(r.toString()),x=Rm(null);x.current||(x.current={originalAppState:Yt(c),originalElements:n,lastUpdatedValue:f,updatePending:!1}),Jw(()=>{let v=r.toString();b(v),x.current.lastUpdatedValue=v},[r]);let E=(v,T,S)=>{if(!x.current.updatePending)return!1;x.current.updatePending=!1;let k=Number(v);if(isNaN(k)){b(r.toString());return}let D=Number(k.toFixed(2)),M=Number(r);(isNaN(M)||Math.abs(D-M)>=qw)&&(x.current.lastUpdatedValue=v,t({accumulatedChange:0,instantChange:0,originalElements:T,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:D,property:l,originalAppState:S,setInputValue:O=>b(String(O))}),d.syncActionResult({captureUpdate:A.IMMEDIATELY}))},w=Rm({});return w.current.handleInputValue=E,Jw(()=>{let v=p.current,T=w.current;return()=>{let S=v?.value;S&&T.handleInputValue?.(S,x.current.originalElements,x.current.originalAppState),window.removeEventListener("pointermove",T.onPointerMove,!1),window.removeEventListener("pointerup",T.onPointerUp,!1)}},[i]),i?JS("div",{className:$S("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Dg("div",{className:"drag-input-label",ref:u,onPointerDown:v=>{if(p.current&&i){document.body.classList.add("excalidraw-cursor-resize");let T=Number(p.current.value);isNaN(T)&&(T=0);let S=null,k=d.scene.getNonDeletedElements().reduce((V,te)=>(V.set(te.id,zo(te)),V),new Map),D=n.map(V=>k.get(V.id)),M=Yt(c),O=0,P=0,F=V=>{if(S&&k!==null&&D!==null){let te=V.clientX-S.x;te!==0&&(P+=te,Math.abs(P)>=m&&(P=Math.sign(P)*Math.floor(Math.abs(P)/m),O+=P,t({accumulatedChange:O,instantChange:P,originalElements:D,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:V.shiftKey,property:l,scene:s,originalAppState:M,setInputValue:H=>b(String(H))}),P=0))}S={x:V.clientX,y:V.clientY}},K=()=>{window.removeEventListener("pointermove",F,!1),d.syncActionResult({captureUpdate:A.IMMEDIATELY}),S=null,O=0,P=0,D=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener("pointerup",K,!1)};w.current.onPointerMove=F,w.current.onPointerUp=K,window.addEventListener("pointermove",F,!1),window.addEventListener("pointerup",K,!1)}},onPointerEnter:()=>{u.current&&(u.current.style.cursor="ew-resize")},children:o?Dg(cn,{icon:o}):e}),Dg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:v=>{if(i){let T=v.target;T instanceof HTMLInputElement&&v.key===y.ENTER&&(E(T.value,n,c),d.focusContainer())}},ref:p,value:f,onChange:v=>{x.current.updatePending=!0,b(v.target.value)},onFocus:v=>{v.target.select(),x.current.originalElements=n,x.current.originalAppState=Yt(c)},onBlur:v=>{f?i&&E(v.target.value,x.current.originalElements,x.current.originalAppState):b(r.toString())},disabled:!i})]}):null},Ct=qS;import{jsx as oM}from"react/jsx-runtime";var QS=15,eM=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a&&!le(a)){let l=i.get(a.id);if(!l)return;if(r!==void 0){let u=gi(r);n.mutateElement(l,{angle:u}),jr(l,n);let f=Ee(l,i);f&&!Re(l)&&n.mutateElement(f,{angle:u});return}let s=Math.round(fi(a.angle)*100)/100,c=Math.round(e),m=(s+c)%360;t&&(m=Ve(m,QS)),m=m<0?m+360:m;let d=gi(m);n.mutateElement(l,{angle:d}),jr(l,n);let p=Ee(l,i);p&&!Re(l)&&n.mutateElement(p,{angle:d})}},tM=({element:e,scene:o,appState:t,property:r})=>oM(Ct,{label:"A",icon:zc,value:Math.round(fi(e.angle)%360*100)/100,elements:[e],dragInputCallback:eM,editable:Qt(e,"angle"),scene:o,appState:t,property:r}),Qw=tM;import{jsx as nM}from"react/jsx-runtime";var e3=5,rM=({property:e,scene:o,appState:t,setAppState:r})=>nM(Ct,{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?Ve(s.gridStep+e3*Math.sign(i),e3):s.gridStep+i),c?(c=Yb(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),t3=rM;import{jsx as sM}from"react/jsx-runtime";var o3=10,iM=e=>e.type==="image",aM=({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||iM(d),f=d.width/d.height;if(l.croppingElementId===d.id){let v=m.get(d.id);if(!v||!Me(v)||!v.crop)return;let T=v.crop,S={...T},k=v.scale[0]===-1,D=v.scale[1]===-1,{width:M,height:O}=Bn(v),P=T.naturalWidth/M,F=T.naturalHeight/O,K=k?T.width+T.x:T.naturalWidth-T.x,V=D?T.height+T.y:T.naturalHeight-T.y,te=pp*P,H=pp*F;if(i!==void 0){if(a==="width"){let pe=i*P,xe=Et(pe,te,K);S={...S,width:xe,x:k?T.x+T.width-xe:T.x}}else if(a==="height"){let pe=i*F,xe=Et(pe,H,V);S={...S,height:xe,y:D?T.y+T.height-xe:T.y}}c.mutateElement(v,{crop:S,width:S.width/(T.naturalWidth/M),height:S.height/(T.naturalHeight/O)});return}let B=a==="width"?s:0,ee=a==="height"?s:0,oe=Et(T.width+B,te,K),Z=Et(T.height+ee,te,V);S={...T,x:k?T.x+T.width-oe:T.x,y:D?T.y+T.height-Z:T.y,width:oe,height:Z},c.mutateElement(v,{crop:S,width:S.width/(T.naturalWidth/M),height:S.height/(T.naturalHeight/O)});return}if(i!==void 0){let v=Math.max(a==="width"?i:u?i*f:d.width,Vt),T=Math.max(a==="height"?i:u?i/f:d.height,Vt);Di(v,T,p,d,t,c,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=Ve(E,o3):E=Math.round(E));let w=Math.max(0,d.height+x);a==="height"&&(n?w=Ve(w,o3):w=Math.round(w)),u&&(a==="width"?w=Math.round(E/f*100)/100:E=Math.round(w*f*100)/100),w=Math.max(Vt,w),E=Math.max(Vt,E),Di(E,w,p,d,t,c,a==="width"?"e":"s",{shouldMaintainAspectRatio:u})}},lM=({property:e,element:o,scene:t,appState:r})=>{let n=ho(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&Me(o)&&o.crop){let{width:i,height:a}=Bn(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=ho(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=ho(o.crop.height*l,2)}}return sM(Ct,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:aM,value:n,editable:Qt(o,e),scene:t,appState:r,property:e})},Pg=lM;import{jsx as pM}from"react/jsx-runtime";var r3=4,cM=4,dM=({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||!Y(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),r3);else if(a.type==="text"){let c=Math.round(a.fontSize),m=Math.round(e);s=Math.max(c+m,r3),t&&(s=Ve(s,cM))}s&&(n.mutateElement(l,{fontSize:s}),Ye(l,n.getContainerElement(l),n))}},mM=({element:e,scene:o,appState:t,property:r})=>{let n=Y(e)?e:ut(e)?Ee(e,o.getNonDeletedElementsMap()):null;return n?pM(Ct,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:dM,icon:$n,appState:t,scene:o,property:r}):null},n3=mM;import{jsx as fM}from"react/jsx-runtime";var uM=15,hM=({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&&!Kr(c)&&Qt(c,n)),s=o.filter(c=>!Kr(c)&&Qt(c,n));if(r!==void 0){let c=gi(r);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:c});let d=Ee(m,a);d&&!Re(m)&&i.mutateElement(d,{angle:c})}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(fi(d.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=Ve(f,uM)),f=f<0?f+360:f;let b=gi(f);i.mutateElement(m,{angle:b});let x=Ee(m,a);x&&!Re(m)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},gM=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!Kr(s)&&Qt(s,"angle")),i=n.map(s=>Math.round(fi(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>Qt(s,"angle"));return fM(Ct,{label:"A",icon:zc,value:a,elements:e,dragInputCallback:hM,editable:l,appState:t,scene:o,property:r})},i3=gM;import{useMemo as bM}from"react";import{jsx as wM}from"react/jsx-runtime";var Da=10,xM=(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,...Db(r,a,l,!1),...Y(r)?{fontSize:r.fontSize*t}:{}}},EM=(e,o,t,r,n,i,a,l)=>{let s=l.getNonDeletedElementsMap(),c=xM(e,o,r,i);l.mutateElement(n,c);let m=Ee(i,a);if(m){let d=m.fontSize*r;$r(n,l,{newSize:{width:c.width,height:c.height}});let p=s.get(m.id);p&&Y(p)&&(l.mutateElement(p,{fontSize:d}),z1(n,l,t==="width"?"e":"s",!0))}},a3=(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];EM(n[0],n[1],i,m,u,p,s,c)}},yM=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l})=>{let s=a.getNonDeletedElementsMap(),c=_a(o,r);if(i!==void 0){for(let p of c){let u=Aa(p,s,t);if(u.length>1){let f=u.map(O=>O.latest),b=u.map(O=>O.original),[x,E,w,v]=Te(b),T=w-x,S=v-E,k=T/S,D=Math.max(Vt,l==="width"?Math.max(0,i):T),M=Math.max(Vt,l==="height"?Math.max(0,i):S);a3(D,M,S,k,L(x,E),l,f,b,t,a)}else{let[f]=u,b=f?.latest,x=f?.original;if(b&&x&&Qt(b,l)){let E=l==="width"?Math.max(0,i):b.width;l==="width"&&(n?E=Ve(E,Da):E=Math.round(E));let w=l==="height"?Math.max(0,i):b.height;l==="height"&&(n?w=Ve(w,Da):w=Math.round(w)),E=Math.max(Vt,E),w=Math.max(Vt,w),Di(E,w,b,x,t,a,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=Aa(p,s,t);if(u.length>1){let f=u.map(O=>O.latest),b=u.map(O=>O.original),[x,E,w,v]=Te(b),T=w-x,S=v-E,k=T/S,D=Math.max(0,T+m);l==="width"&&(n?D=Ve(D,Da):D=Math.round(D));let M=Math.max(0,S+d);l==="height"&&(n?M=Ve(M,Da):M=Math.round(M)),D=Math.max(Vt,D),M=Math.max(Vt,M),a3(D,M,S,k,L(x,E),l,f,b,t,a)}else{let[f]=u,b=f?.latest,x=f?.original;if(b&&x&&Qt(b,l)){let E=Math.max(0,x.width+m);l==="width"&&(n?E=Ve(E,Da):E=Math.round(E));let w=Math.max(0,x.height+d);l==="height"&&(n?w=Ve(w,Da):w=Math.round(w)),E=Math.max(Vt,E),w=Math.max(Vt,w),Di(E,w,b,x,t,a,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate()},vM=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=bM(()=>r.map(c=>{let m=Aa(c,t);if(m.length>1){let[p,u,f,b]=Te(m.map(x=>x.latest));return Math.round((e==="width"?f-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 wM(Ct,{label:e==="width"?"W":"H",elements:o,dragInputCallback:yM,value:l,editable:s,appState:i,property:e,scene:n})},Rg=vM;import{jsx as SM}from"react/jsx-runtime";var l3=4,TM=4,CM=(e,o)=>e.reduce((t,r)=>{if(!r||Kr(r))return t;if(Y(r))return t.push(r),t;if(ut(r)){let n=Ee(r,o);if(n)return t.push(n),t}return t},[]),IM=({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),l3);for(let s of a)n.mutateElement(s,{fontSize:l}),Ye(s,n.getContainerElement(s),n);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),f=Math.max(p+u,l3);t&&(f=Ve(f,TM)),n.mutateElement(m,{fontSize:f}),Ye(m,n.getContainerElement(m),n)}n.triggerUpdate()}},kM=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=CM(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 SM(Ct,{label:"F",icon:$n,elements:i,dragInputCallback:IM,value:l,editable:s,scene:o,property:r,appState:t})},s3=kM;import{useMemo as MM}from"react";import{jsx as PM}from"react/jsx-runtime";var LM=(e,o,t,r,n,i)=>{for(let a=0;a<r.length;a++){let l=r[a],[s,c]=[l.x+l.width/2,l.y+l.height/2],[m,d]=Oe(L(l.x,l.y),L(s,c),l.angle),p=e==="x"?Math.round(m+o):m,u=e==="y"?Math.round(d+t):d;ci(p,u,l,i,n,!1)}},AM=(e,o,t,r,n)=>{let i=n.getNonDeletedElementsMap(),[a,l,,]=Te(t),s=e-a,c=o-l;for(let m=0;m<t.length;m++){let d=t[m],p=i.get(d.id);if(p&&(!Y(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=Oe(L(p.x,p.y),L(u,f),p.angle);ci(b+s,x+c,d,n,r,!1)}}},_M=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(n!==void 0){for(let p of _a(o,l)){let u=Aa(p,s,t);if(u.length>1){let[f,b,,]=Te(u.map(w=>w.latest));AM(i==="x"?n:f,i==="y"?n:b,u.map(w=>w.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&Qt(b,i)){let[x,E]=[f.x+f.width/2,f.y+f.height/2],[w,v]=Oe(L(f.x,f.y),L(x,E),f.angle);ci(i==="x"?n:w,i==="y"?n:v,f,a,t,!1)}}}a.triggerUpdate();return}let c=r?Ve(e,ql):e;LM(i,i==="x"?c:0,i==="y"?c:0,o,t,a),a.triggerUpdate()},DM=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=MM(()=>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]=Te(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,f]=Oe(L(m.x,m.y),L(d,p),m.angle);return Math.round((e==="x"?u:f)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return PM(Ct,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:_M,value:l,property:e,scene:n,appState:i})},Ng=DM;import{jsx as OM}from"react/jsx-runtime";var RM=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let c=l.getNonDeletedElementsMap(),m=t[0],[d,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=Oe(L(m.x,m.y),L(d,p),m.angle);if(s.croppingElementId===m.id){let v=c.get(m.id);if(!v||!Me(v)||!v.crop)return;let T=v.crop,S=T,k=v.scale[0]===-1,D=v.scale[1]===-1,{width:M,height:O}=Bn(v);if(i!==void 0){if(a==="x"){let K=i*(T.naturalWidth/M);k?S={...T,x:Et(T.naturalWidth-K-T.width,0,T.naturalWidth-T.width)}:S={...T,x:Et(i*(T.naturalWidth/M),0,T.naturalWidth-T.width)}}a==="y"&&(S={...T,y:Et(i*(T.naturalHeight/O),0,T.naturalHeight-T.height)}),l.mutateElement(v,{crop:S});return}let P=(a==="x"?o:0)*(k?-1:1),F=(a==="y"?o:0)*(D?-1:1);S={...T,x:Et(T.x+P,0,T.naturalWidth-T.width),y:Et(T.y+F,0,T.naturalHeight-T.height)},l.mutateElement(v,{crop:S});return}if(i!==void 0){ci(a==="x"?i:u,a==="y"?i:f,m,l,r);return}let b=a==="x"?e:0,x=a==="y"?e:0,E=a==="x"?Math.round(n?Ve(m.x+b,ql):u+b):u,w=a==="y"?Math.round(n?Ve(m.y+x,ql):f+x):f;ci(E,w,m,l,r)},NM=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=Oe(L(o.x,o.y),L(o.x+o.width/2,o.y+o.height/2),o.angle),l=ho(e==="x"?i:a,2);if(n.croppingElementId===o.id&&Me(o)&&o.crop){let s=S1(o);s&&(l=ho(e==="x"?s.x:s.y,2))}return OM(Ct,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:RM,scene:r,value:l,property:e,appState:n})},Og=NM;import{Fragment as Bg,jsx as Q,jsxs as eo}from"react/jsx-runtime";var UM=50,Jl=e=>{let o=or(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=hn(e.app);return Q(GM,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},Ge=({children:e,columns:o=1,heading:t,style:r,...n})=>Q("div",{className:zM("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});Ge.displayName="StatsRow";var Nm=({children:e,order:o,style:t,...r})=>Q("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});Nm.displayName="StatsRows";Jl.StatsRow=Ge;Jl.StatsRows=Nm;var GM=HM(({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=ye(),d=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&Me(d),f=u?Bn(d):null,[b,x]=FM({width:0,height:0}),E=zg(()=>BM(T=>{let S=Te(T);x({width:Math.round(S[2])-Math.round(S[0]),height:Math.round(S[3])-Math.round(S[1])})},UM),[]);c3(()=>{E(s)},[i,s,E]),c3(()=>()=>E.cancel(),[E]);let w=zg(()=>_a(r,n),[r,n]),v=zg(()=>js(r),[r]);return Q("div",{className:"exc-stats",children:eo(gt,{padding:3,children:[eo("div",{className:"title",children:[Q("h2",{children:g("stats.title")}),Q("div",{className:"close",onClick:o,children:xo})]}),eo(Il,{label:Q("h3",{children:g("stats.generalStats")}),open:!!(n.stats.panels&Wa.generalStats),openTrigger:()=>m(T=>({stats:{open:!0,panels:T.stats.panels^Wa.generalStats}})),children:[eo(Nm,{children:[Q(Ge,{heading:!0,children:g("stats.scene")}),eo(Ge,{columns:2,children:[Q("div",{children:g("stats.shapes")}),Q("div",{children:s.length})]}),eo(Ge,{columns:2,children:[Q("div",{children:g("stats.width")}),Q("div",{children:b.width})]}),eo(Ge,{columns:2,children:[Q("div",{children:g("stats.height")}),Q("div",{children:b.height})]}),a&&eo(Bg,{children:[Q(Ge,{heading:!0,children:"Canvas"}),Q(Ge,{children:Q(t3,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),t?.(s,n)]}),!v&&r.length>0&&Q("div",{id:"elementStats",style:{marginTop:12},children:Q(Il,{label:Q("h3",{children:g("stats.elementProperties")}),open:!!(n.stats.panels&Wa.elementProperties),openTrigger:()=>m(T=>({stats:{open:!0,panels:T.stats.panels^Wa.elementProperties}})),children:eo(Nm,{children:[d&&eo(Bg,{children:[u&&Q(Ge,{heading:!0,children:g("labels.unCroppedDimension")}),n.croppingElementId&&Me(d)&&f&&eo(Ge,{columns:2,children:[Q("div",{children:g("stats.width")}),Q("div",{children:ho(f.width,2)})]}),n.croppingElementId&&Me(d)&&f&&eo(Ge,{columns:2,children:[Q("div",{children:g("stats.height")}),Q("div",{children:ho(f.height,2)})]}),Q(Ge,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?g("labels.imageCropping"):g(`element.${d.type}`)}),Q(Ge,{children:Q(Og,{element:d,property:"x",elementsMap:c,scene:l,appState:n})}),Q(Ge,{children:Q(Og,{element:d,property:"y",elementsMap:c,scene:l,appState:n})}),Q(Ge,{children:Q(Pg,{property:"width",element:d,scene:l,appState:n})}),Q(Ge,{children:Q(Pg,{property:"height",element:d,scene:l,appState:n})}),!le(d)&&Q(Ge,{children:Q(Qw,{property:"angle",element:d,scene:l,appState:n})}),Q(Ge,{children:Q(n3,{property:"fontSize",element:d,scene:l,appState:n})})]}),p&&eo(Bg,{children:[X1(p)&&Q(Ge,{heading:!0,children:g("element.group")}),eo(Ge,{columns:2,style:{margin:"0.3125rem 0"},children:[Q("div",{children:g("stats.shapes")}),Q("div",{children:r.length})]}),Q(Ge,{children:Q(Ng,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),Q(Ge,{children:Q(Ng,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),Q(Ge,{children:Q(Rg,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),Q(Ge,{children:Q(Rg,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),Q(Ge,{children:Q(i3,{property:"angle",elements:p,scene:l,appState:n})}),Q(Ge,{children:Q(s3,{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 WM,useEffect as d3,useState as m3}from"react";import{jsx as Pa,jsxs as Om}from"react/jsx-runtime";var VM=({sourceElementId:e,onClose:o,appState:t,scene:r,generateLinkForSelection:n=ac})=>{let i=r.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=m3(a),[c,m]=m3(!1);d3(()=>{let p=j(i,t),u=a;if(p.length>0&&n){let f=lc(p,t);f&&(u=Po(n(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,n]);let d=WM(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&r.mutateElement(p,{link:l})}if(!l&&c&&e){let p=i.get(e);p&&r.mutateElement(p,{link:null})}o?.()},[e,l,i,c,r,o]);return d3(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===y.ENTER&&d(),t.openDialog?.name==="elementLinkSelector"&&u.key===y.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,d]),Om("div",{className:"ElementLinkDialog",children:[Om("div",{className:"ElementLinkDialog__header",children:[Pa("h2",{children:g("elementLink.title")}),Pa("p",{children:g("elementLink.desc")})]}),Om("div",{className:"ElementLinkDialog__input",children:[Pa(va,{value:l??"",onChange:p=>{c||m(!0),s(p)},onKeyDown:p=>{p.key===y.ENTER&&d()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Pa($,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:oo})]}),Om("div",{className:"ElementLinkDialog__actions",children:[Pa(Mr,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Pa(Mr,{label:g("buttons.confirm"),onClick:d,actionType:"primary"})]})]})},p3=VM;import YM,{useState as KM}from"react";import{Fragment as ZM,jsx as Fg}from"react/jsx-runtime";var u3=({children:e,onClose:o})=>{let[t,r]=KM(!!e),{container:n}=at(),i=YM.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return Fg(ZM,{children:t&&Fg(et,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:Fg("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import XM from"react";import{Fragment as g3,jsx as U,jsxs as mo}from"react/jsx-runtime";var $M=()=>mo("div",{className:"HelpDialog__header",children:[mo("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[U("div",{className:"HelpDialog__link-icon",children:qp}),g("helpDialog.documentation")]}),mo("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[U("div",{className:"HelpDialog__link-icon",children:qp}),g("helpDialog.blog")]}),mo("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[U("div",{className:"HelpDialog__link-icon",children:Dc}),g("helpDialog.github")]}),mo("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[U("div",{className:"HelpDialog__link-icon",children:Qx}),"YouTube"]})]}),jM=e=>mo(g3,{children:[U("h3",{children:e.title}),U("div",{className:"HelpDialog__islands-container",children:e.children})]}),Hg=e=>mo("div",{className:`HelpDialog__island ${e.className}`,children:[U("h4",{className:"HelpDialog__island-title",children:e.caption}),U("div",{className:"HelpDialog__island-content",children:e.children})]});function*qM(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var JM=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),W=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>U(QM,{children:JM(a)},a)));return mo("div",{className:"HelpDialog__shortcut",children:[U("div",{children:e}),U("div",{className:"HelpDialog__key-container",children:[...qM(r,t?g("helpDialog.or"):null)]})]})},QM=e=>U("kbd",{className:"HelpDialog__key",...e}),h3=({onClose:e})=>{let o=XM.useCallback(()=>{e&&e()},[e]);return U(g3,{children:mo(et,{onCloseRequest:o,title:g("helpDialog.title"),className:"HelpDialog",children:[U($M,{}),mo(jM,{title:g("helpDialog.shortcuts"),children:[mo(Hg,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[U(W,{label:g("toolBar.hand"),shortcuts:[y.H]}),U(W,{label:g("toolBar.selection"),shortcuts:[y.V,y[1]]}),U(W,{label:g("toolBar.rectangle"),shortcuts:[y.R,y[2]]}),U(W,{label:g("toolBar.diamond"),shortcuts:[y.D,y[3]]}),U(W,{label:g("toolBar.ellipse"),shortcuts:[y.O,y[4]]}),U(W,{label:g("toolBar.arrow"),shortcuts:[y.A,y[5]]}),U(W,{label:g("toolBar.line"),shortcuts:[y.L,y[6]]}),U(W,{label:g("toolBar.freedraw"),shortcuts:[y.P,y[7]]}),U(W,{label:g("toolBar.text"),shortcuts:[y.T,y[8]]}),U(W,{label:g("toolBar.image"),shortcuts:[y[9]]}),U(W,{label:g("toolBar.eraser"),shortcuts:[y.E,y[0]]}),U(W,{label:g("toolBar.frame"),shortcuts:[y.F]}),U(W,{label:g("toolBar.laser"),shortcuts:[y.K]}),U(W,{label:g("labels.eyeDropper"),shortcuts:[y.I,"Shift+S","Shift+G"]}),U(W,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[R("CtrlOrCmd+Enter")]}),U(W,{label:g("helpDialog.editText"),shortcuts:[R("Enter")]}),U(W,{label:g("helpDialog.textNewLine"),shortcuts:[R("Enter"),R("Shift+Enter")]}),U(W,{label:g("helpDialog.textFinish"),shortcuts:[R("Esc"),R("CtrlOrCmd+Enter")]}),U(W,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),U(W,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),U(W,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),R("Enter")],isOr:!0}),U(W,{label:g("helpDialog.cropFinish"),shortcuts:[R("Enter"),R("Escape")],isOr:!0}),U(W,{label:g("toolBar.lock"),shortcuts:[y.Q]}),U(W,{label:g("helpDialog.preventBinding"),shortcuts:[R("CtrlOrCmd")]}),U(W,{label:g("toolBar.link"),shortcuts:[R("CtrlOrCmd+K")]}),U(W,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),mo(Hg,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[U(W,{label:g("buttons.zoomIn"),shortcuts:[R("CtrlOrCmd++")]}),U(W,{label:g("buttons.zoomOut"),shortcuts:[R("CtrlOrCmd+-")]}),U(W,{label:g("buttons.resetZoom"),shortcuts:[R("CtrlOrCmd+0")]}),U(W,{label:g("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),U(W,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),U(W,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),U(W,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),U(W,{label:g("buttons.zenMode"),shortcuts:[R("Alt+Z")]}),U(W,{label:g("buttons.objectsSnapMode"),shortcuts:[R("Alt+S")]}),U(W,{label:g("labels.toggleGrid"),shortcuts:[R("CtrlOrCmd+'")]}),U(W,{label:g("labels.viewMode"),shortcuts:[R("Alt+R")]}),U(W,{label:g("labels.toggleTheme"),shortcuts:[R("Alt+Shift+D")]}),U(W,{label:g("stats.fullTitle"),shortcuts:[R("Alt+/")]}),U(W,{label:g("search.title"),shortcuts:[Qe("searchMenu")]}),U(W,{label:g("commandPalette.title"),shortcuts:ur?[Qe("commandPalette")]:[Qe("commandPalette"),Qe("commandPalette",1)]})]}),mo(Hg,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[U(W,{label:g("helpDialog.createFlowchart"),shortcuts:[R("CtrlOrCmd+Arrow Key")],isOr:!0}),U(W,{label:g("helpDialog.navigateFlowchart"),shortcuts:[R("Alt+Arrow Key")],isOr:!0}),U(W,{label:g("labels.moveCanvas"),shortcuts:[R(`Space+${g("helpDialog.drag")}`),R(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),U(W,{label:g("buttons.clearReset"),shortcuts:[R("CtrlOrCmd+Delete")]}),U(W,{label:g("labels.delete"),shortcuts:[R("Delete")]}),U(W,{label:g("labels.cut"),shortcuts:[R("CtrlOrCmd+X")]}),U(W,{label:g("labels.copy"),shortcuts:[R("CtrlOrCmd+C")]}),U(W,{label:g("labels.paste"),shortcuts:[R("CtrlOrCmd+V")]}),U(W,{label:g("labels.pasteAsPlaintext"),shortcuts:[R("CtrlOrCmd+Shift+V")]}),U(W,{label:g("labels.selectAll"),shortcuts:[R("CtrlOrCmd+A")]}),U(W,{label:g("labels.multiSelect"),shortcuts:[R(`Shift+${g("helpDialog.click")}`)]}),U(W,{label:g("helpDialog.deepSelect"),shortcuts:[R(`CtrlOrCmd+${g("helpDialog.click")}`)]}),U(W,{label:g("helpDialog.deepBoxSelect"),shortcuts:[R(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(ra||ur)&&U(W,{label:g("labels.copyAsPng"),shortcuts:[R("Shift+Alt+C")]}),U(W,{label:g("labels.copyStyles"),shortcuts:[R("CtrlOrCmd+Alt+C")]}),U(W,{label:g("labels.pasteStyles"),shortcuts:[R("CtrlOrCmd+Alt+V")]}),U(W,{label:g("labels.sendToBack"),shortcuts:[Lo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")]}),U(W,{label:g("labels.bringToFront"),shortcuts:[Lo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")]}),U(W,{label:g("labels.sendBackward"),shortcuts:[R("CtrlOrCmd+[")]}),U(W,{label:g("labels.bringForward"),shortcuts:[R("CtrlOrCmd+]")]}),U(W,{label:g("labels.alignTop"),shortcuts:[R("CtrlOrCmd+Shift+Up")]}),U(W,{label:g("labels.alignBottom"),shortcuts:[R("CtrlOrCmd+Shift+Down")]}),U(W,{label:g("labels.alignLeft"),shortcuts:[R("CtrlOrCmd+Shift+Left")]}),U(W,{label:g("labels.alignRight"),shortcuts:[R("CtrlOrCmd+Shift+Right")]}),U(W,{label:g("labels.duplicateSelection"),shortcuts:[R("CtrlOrCmd+D"),R(`Alt+${g("helpDialog.drag")}`)]}),U(W,{label:g("helpDialog.toggleElementLock"),shortcuts:[R("CtrlOrCmd+Shift+L")]}),U(W,{label:g("buttons.undo"),shortcuts:[R("CtrlOrCmd+Z")]}),U(W,{label:g("buttons.redo"),shortcuts:fs?[R("CtrlOrCmd+Y"),R("CtrlOrCmd+Shift+Z")]:[R("CtrlOrCmd+Shift+Z")]}),U(W,{label:g("labels.group"),shortcuts:[R("CtrlOrCmd+G")]}),U(W,{label:g("labels.ungroup"),shortcuts:[R("CtrlOrCmd+Shift+G")]}),U(W,{label:g("labels.flipHorizontal"),shortcuts:[R("Shift+H")]}),U(W,{label:g("labels.flipVertical"),shortcuts:[R("Shift+V")]}),U(W,{label:g("labels.showStroke"),shortcuts:[R("S")]}),U(W,{label:g("labels.showBackground"),shortcuts:[R("G")]}),U(W,{label:g("labels.showFonts"),shortcuts:[R("Shift+F")]}),U(W,{label:g("labels.decreaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+<")]}),U(W,{label:g("labels.increaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as x3,useRef as i8,useState as vn}from"react";import{useCallback as e8,useRef as t8,useState as o8}from"react";var r8=2e3,f3=()=>{let[e,o]=o8(null),t=t8(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},r8)},n=e8(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import n8 from"clsx";import{jsx as b3}from"react/jsx-runtime";var Ql=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>b3("div",{className:n8("Switch",{toggled:t,disabled:n}),children:b3("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 We,jsxs as wn}from"react/jsx-runtime";var a8="filter"in document.createElement("canvas").getContext("2d"),l8=()=>wn("div",{children:[We("h3",{children:g("canvasError.cannotShowPreview")}),We("p",{children:We("span",{children:g("canvasError.canvasTooBig")})}),wn("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),s8=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=Ne(o,e),[l,s]=vn(i),[c,m]=vn(a),[d,p]=vn(e.exportBackground),[u,f]=vn(e.exportWithDarkMode),[b,x]=vn(e.exportEmbedScene),[E,w]=vn(e.exportScale),v=i8(null),[T,S]=vn(null),{onCopy:k,copyStatus:D,resetCopyStatus:M}=f3();x3(()=>{M()},[l,d,u,E,b,M]);let{exportedElements:O,exportingFrame:P}=ti(o,e,c);return x3(()=>{let F=v.current;if(!F)return;let K=F.offsetWidth,V=F.offsetHeight;K&&mn({elements:O,appState:{...e,name:l,exportBackground:d,exportWithDarkMode:u,exportScale:E,exportEmbedScene:b},files:t,exportPadding:Fr,maxWidthOrHeight:Math.max(K,V),exportingFrame:P}).then(te=>(S(null),Tr(te).then(()=>{F.replaceChildren(te)}).catch(H=>{throw H.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):H}))).catch(te=>{console.error(te),S(te)})},[e,t,O,P,l,d,u,E,b]),wn("div",{className:"ImageExportModal",children:[We("h3",{children:g("imageExportDialog.header")}),wn("div",{className:"ImageExportModal__preview",children:[We("div",{className:"ImageExportModal__preview__canvas",ref:v,children:T&&We(l8,{})}),We("div",{className:"ImageExportModal__preview__filename",children:!Ni&&We("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:F=>{s(F.target.value),r.executeAction(Ju,"ui",F.target.value)}})})]}),wn("div",{className:"ImageExportModal__settings",children:[We("h3",{children:g("imageExportDialog.header")}),a&&We(es,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:We(Ql,{name:"exportOnlySelected",checked:c,onChange:F=>{m(F)}})}),We(es,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:We(Ql,{name:"exportBackgroundSwitch",checked:d,onChange:F=>{p(F),r.executeAction(Qu,"ui",F)}})}),a8&&We(es,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:We(Ql,{name:"exportDarkModeSwitch",checked:u,onChange:F=>{f(F),r.executeAction(m2,"ui",F)}})}),We(es,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:We(Ql,{name:"exportEmbedSwitch",checked:b,onChange:F=>{x(F),r.executeAction(yd,"ui",F)}})}),We(es,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:We(xm,{name:"exportScale",value:E,onChange:F=>{w(F),r.executeAction(d2,"ui",F)},choices:Ts.map(F=>({value:F,label:`${F}\xD7`}))})}),wn("div",{className:"ImageExportModal__settings__buttons",children:[We(xn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>n(ys.png,O,{exportingFrame:P}),icon:uu,children:g("imageExportDialog.button.exportToPng")}),We(xn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>n(ys.svg,O,{exportingFrame:P}),icon:uu,children:g("imageExportDialog.button.exportToSvg")}),(ra||ur)&&We(xn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:D,onClick:async()=>{await n(ys.clipboard,O,{exportingFrame:P}),k()},icon:Yi,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},es=({label:e,children:o,tooltip:t,name:r})=>wn("div",{className:"ImageExportModal__settings__setting",title:e,children:[wn("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&We(io,{label:t,long:!0,children:Dx})]}),We("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),E3=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=vn(()=>({appStateSnapshot:Yt(o),elementsSnapshot:Yt(e)}));return We(et,{onCloseRequest:i,size:"wide",title:!1,children:We(s8,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import d8 from"react";import Ug from"open-color";import{jsx as c8}from"react/jsx-runtime";var Gg=({children:e,color:o})=>c8("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":Ug[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":Ug[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":Ug[o][9]},children:e});import{Fragment as p8,jsx as Ko,jsxs as zm}from"react/jsx-runtime";var m8=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return Ko("div",{className:"ExportDialog ExportDialog--json",children:zm("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&zm(Gg,{color:"lime",children:[Ko("div",{className:"Card-icon",children:H0}),Ko("h2",{children:g("exportDialog.disk_title")}),zm("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!Ni&&n.renderAction("changeProjectName")]}),Ko($,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Al,"ui")}})]}),s&&zm(Gg,{color:"pink",children:[Ko("div",{className:"Card-icon",children:ul}),Ko("h2",{children:g("exportDialog.link_title")}),Ko("div",{className:"Card-details",children:g("exportDialog.link_details")}),Ko($,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{de("export","link",`ui (${m1()})`),await s(e,o,r),l()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},y3=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=d8.useCallback(()=>{a({openDialog:null})},[a]);return Ko(p8,{children:o.openDialog?.name==="jsonExport"&&Ko(et,{onCloseRequest:l,title:g("buttons.export"),children:Ko(m8,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import u8 from"clsx";import{jsx as v3,jsxs as g8}from"react/jsx-runtime";var h8="small",w3=e=>g8("label",{className:u8("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${h8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[v3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),v3("div",{className:"ToolIcon__icon",children:gl})]});import{Fragment as C3,jsx as q,jsxs as po}from"react/jsx-runtime";var b8=({UIOptions:e})=>po(Pt,{__fallback:!0,children:[q(Pt.DefaultItems.LoadScene,{}),q(Pt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&q(Pt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&q(Pt.DefaultItems.SaveAsImage,{}),q(Pt.DefaultItems.SearchMenu,{}),q(Pt.DefaultItems.Help,{}),q(Pt.DefaultItems.ClearCanvas,{}),q(Pt.Separator,{}),q(Pt.Group,{title:"Excalidraw links",children:q(Pt.DefaultItems.Socials,{})}),q(Pt.Separator,{}),q(Pt.DefaultItems.ToggleTheme,{}),q(Pt.DefaultItems.ChangeCanvasBackground,{})]}),x8=()=>po(wm,{__fallback:!0,children:[q(wm.Actions.SaveToDisk,{}),q(wm.Actions.ExportToImage,{})]}),E8=({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:f,children:b,app:x,isCollaborating:E,generateLinkForSelection:w})=>{let v=be(),T=Ry(),S=T.tunnelsJotai.Provider,[k,D]=he(nn),M=()=>p.canvasActions.export?q(y3,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,O=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:q(E3,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),P=()=>po("div",{style:{position:"relative"},children:[q(T.MainMenuTunnel.Out,{}),f&&q(T.WelcomeScreenMenuHintTunnel.Out,{})]}),F=()=>q(fn,{heading:"selectedShapeActions",className:ts("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:q(gt,{className:Rt.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:q(Zd,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),K=()=>{let B=Pi(o,n),ee=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return q(cm,{side:"top",children:po("div",{className:"App-menu App-menu_top",children:[po(wt.Col,{gap:6,className:ts("App-menu_top__left"),children:[P(),B&&F()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&q(fn,{heading:"shapes",className:"shapes-section",children:oe=>po("div",{style:{position:"relative"},children:[f&&q(T.WelcomeScreenToolbarHintTunnel.Out,{}),q(wt.Col,{gap:4,align:"start",children:po(wt.Row,{gap:1,className:ts("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[po(gt,{padding:1,className:ts("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[q(mm,{appState:o,isMobile:v.editor.isMobile,device:v,app:x}),oe,po(wt.Row,{gap:1,children:[q(pm,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),q(sm,{checked:o.activeTool.locked,onChange:a,title:g("toolBar.lock")}),q("div",{className:"App-toolbar__divider"}),q(dm,{checked:Bo(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),q(Xd,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),E&&q(gt,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:q(w3,{title:g("toolBar.laser"),checked:o.activeTool.type===je.laser,onChange:()=>x.setActiveTool({type:je.laser}),isMobile:!0})})]})})]})}),po("div",{className:ts("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&q(gm,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),m?.(v.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!te||o.openSidebar?.name!==_t.name)&&q(T.DefaultSidebarTriggerTunnel.Out,{}),ee&&q(Jl,{app:x,onClose:()=>{e.executeAction(da)},renderCustomStats:d})]})]})})},V=()=>q(Tm,{__fallback:!0,onDock:B=>{de("sidebar",`toggleDock (${B?"dock":"undock"})`,`(${v.editor.isMobile?"mobile":"desktop"})`)}}),te=Tc(Zl),H=po(C3,{children:[b,q(b8,{UIOptions:p}),q(Tm.Trigger,{__fallback:!0,icon:Hi,title:Ur(g("toolBar.library")),onToggle:B=>{B&&de("sidebar",`${_t.name} (open)`,`button (${v.editor.isMobile?"mobile":"desktop"})`)},tab:_t.defaultTab,children:g("toolBar.library")}),q(x8,{}),o.openDialog?.name==="ttd"&&q(_g,{__fallback:!0}),o.isLoading&&q(lm,{delay:250}),o.errorMessage&&q(u3,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),k&&!v.editor.isMobile&&q(cE,{colorPickerType:k.colorPickerType,onCancel:()=>{D(null)},onChange:(B,ee,oe,{altKey:Z})=>{if(!(B!=="elementBackground"&&B!=="elementStroke"))if(oe.length){for(let pe of oe)Oo(pe,J(n),{[Z&&k.swapPreviewOnAlt?B==="elementBackground"?"strokeColor":"backgroundColor":B==="elementBackground"?"backgroundColor":"strokeColor"]:ee}),Jo.delete(pe);x.scene.triggerUpdate()}else r(B==="elementBackground"?{currentItemBackgroundColor:ee}:{currentItemStrokeColor:ee})},onSelect:(B,ee)=>{D(oe=>oe?.keepOpenOnAlt&&ee.altKey?oe:null),k?.onSelect?.(B,ee)}}),o.openDialog?.name==="help"&&q(h3,{onClose:()=>{r({openDialog:null})}}),q(Fy,{}),o.openDialog?.name==="elementLinkSelector"&&q(p3,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:w}),q(T.OverwriteConfirmDialogTunnel.Out,{}),O(),M(),o.pasteDialog.shown&&q(Uv,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),v.editor.isMobile&&q(Fv,{app:x,appState:o,elements:n,actionManager:e,renderJSONExportDialog:M,renderImageExportDialog:O,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:m,renderCustomStats:d,renderSidebars:V,device:v,renderWelcomeScreen:f,UIOptions:p}),!v.editor.isMobile&&po(C3,{children:[po("div",{className:"layer-ui__wrapper",style:o.openSidebar&&te&&v.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&q(T.WelcomeScreenCenterTunnel.Out,{}),K(),q(Yv,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:f}),o.scrolledOutside&&q("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(B=>({...Kn(n,B)}))},children:g("buttons.scrollBackToContent")})]}),V()]})]});return q(Iu.Provider,{value:o,children:q(S,{children:q(Hh.Provider,{value:T,children:H})})})},T3=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},y8=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return rt(T3(r),T3(a),{selectedElementIds:rt,selectedGroupIds:rt})&&rt(n,l)},I3=f8.memo(E8,y8);import v8 from"clsx";import{jsx as k3,jsxs as T8}from"react/jsx-runtime";var w8="small",Bm=e=>T8("label",{className:v8("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${w8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[k3("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),k3("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as C8,useRef as I8}from"react";import{jsx as S3}from"react/jsx-runtime";var M3=({trails:e})=>{let o=I8(null);return C8(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),S3("div",{className:"SVGLayer",children:S3("svg",{ref:o})})};import k8,{useEffect as S8,useRef as M8}from"react";import{jsx as _8}from"react/jsx-runtime";var L8=e=>{let o=M8(!1);return S8(()=>{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,It({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";yv({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:t,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Ia())}),_8("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?we.GRAB:we.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:g("labels.drawingCanvas")})},L3=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}),A8=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:rt(L3(e.appState),L3(o.appState)),Wg=k8.memo(L8,A8);import D8,{useEffect as P8,useRef as A3}from"react";import{jsx as O8}from"react/jsx-runtime";var R8=e=>{let o=A3(null),t=A3(!1);return P8(()=>{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),e0({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Ia())}),O8("div",{className:"excalidraw__canvas-wrapper",ref:o})},_3=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}),N8=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:rt(_3(e.appState),_3(o.appState))&&rt(e.renderConfig,o.renderConfig),Vg=D8.memo(R8,N8);import{useEffect as B8,useRef as F8}from"react";var D3=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=fc(e,i),m=bc({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"?lb(t,r,n,o,m,l,a):m.clearRect(0,0,s,c)}},z8=bi(e=>{D3(e)},{trailing:!0}),P3=(e,o)=>{if(o){z8(e);return}D3(e)};import{jsx as U8}from"react/jsx-runtime";var H8=e=>{let o=F8(null);return B8(()=>{o.current&&P3({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},Ia())}),U8("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})},R3=H8;import{useCallback as G8,useEffect as W8,useRef as V8}from"react";import{jsx as N3,jsxs as K8}from"react/jsx-runtime";var Y8=5e3,O3=({message:e,onClose:o,closable:t=!1,duration:r=Y8,style:n})=>{let i=V8(0),a=r!==1/0,l=G8(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return W8(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),K8("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[N3("p",{className:"Toast__message",children:e}),t&&N3($,{icon:xo,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{Fragment as q8,jsx as _e,jsxs as Hm}from"react/jsx-runtime";var H3=pr.createContext(null),U3=pr.createContext(null),G3={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},$g=pr.createContext(G3);$g.displayName="DeviceContext";var jg=pr.createContext({container:null,id:null});jg.displayName="ExcalidrawContainerContext";var qg=pr.createContext([]);qg.displayName="ExcalidrawElementsContext";var Jg=pr.createContext({...en(),width:0,height:0,offsetLeft:0,offsetTop:0});Jg.displayName="ExcalidrawAppStateContext";var Qg=pr.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Qg.displayName="ExcalidrawSetAppStateContext";var ef=pr.createContext(null);ef.displayName="ExcalidrawActionManagerContext";var Je=()=>Cn(H3),rr=()=>Cn(U3),be=()=>Cn($g),at=()=>Cn(jg),an=()=>Cn(qg),or=()=>Cn(Jg),ye=()=>Cn(Qg),lt=()=>Cn(ef),os=!1,Yg=0,di=!1,rs=!1,Kg=!1,ns={horizontal:null,vertical:null},Tn=0,is=!1,Zg=new Map,Fm=!1,B3=0,F3=!1,as=null,Se={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Xg=class e extends pr.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",G3);I(this,"excalidrawContainerRef",pr.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 kb);I(this,"flowChartNavigator",new Ib);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 Qd);I(this,"laserTrails",new rm(this.animationFrameHandler,this));I(this,"eraserTrail",new am(this.animationFrameHandler,this));I(this,"lassoTrail",new im(this.animationFrameHandler,this));I(this,"onChangeEmitter",new go);I(this,"onPointerDownEmitter",new go);I(this,"onPointerUpEmitter",new go);I(this,"onUserFollowEmitter",new go);I(this,"onScrollChangeEmitter",new go);I(this,"missingPointerEventCleanupEmitter",new go);I(this,"onRemoveEventListenersEmitter",new go);I(this,"updateEditorAtom",(t,...r)=>{let n=it.set(t,...r);return this.triggerRender(),n});I(this,"getEffectiveGridSize",()=>hn(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),Jo.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(Nt(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=_i(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else On(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=Fe({clientX:i.x,clientY:i.y},this.state),l=Fe({clientX:i.right,clientY:i.bottom},this.state);return r={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,r),r}return null}return r},_cache:new Map});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===re.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&ae(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return r.map(i=>{if(!tl(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}=It({sceneX:i.x,sceneY:i.y},this.state),s=6,c,m=nb(i);if(i.id===this.state.editingFrame){let d=m;c=_e("input",{autoFocus:!0,value:d,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===y.ESCAPE||p.key===y.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:t?Bf:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${At.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:d.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else c=m;return _e("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+At.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:At.nameFontSize,color:t?At.nameColorDarkTheme:At.nameColorLightTheme,lineHeight:At.nameLineHeight,width:"max-content",maxWidth:n?.id===i.id&&n?.focus?"none":`${i.width*this.state.zoom.value}px`,overflow:i.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:we.MOVE,pointerEvents:this.state.viewModeEnabled?Mn.disabled:Mn.enabled},onPointerDown:d=>this.handleCanvasPointerDown(d),onWheel:d=>this.handleWheel(d),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:c},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,r,n)=>{de("export",t,"ui");let i=await oi(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(Ds).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Ec(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:r}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,r),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:je.magicframe}),de("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&Fs(t[0])&&t[0];if(!r&&t.some(i=>ae(i)||i.frameId)){this.setActiveTool({type:je.magicframe});return}de("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=Te(t),c=50;n=rl({...At,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)this.scene.mutateElement(m,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});I(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(nn,{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]?ne(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:A.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})});I(this,"syncActionResult",Xe(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||re.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&&Bp(m)&&Y(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||this.scene.triggerUpdate()}));I(this,"onBlur",Xe(()=>{di=!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",Xe(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...en(),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=zi(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,...Kn(r.elements,{...r.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...r,captureUpdate:A.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(n=>{this.fonts.onLoaded(n)}),Vn(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileBreakpoint",(t,r)=>t<Ff||r<Uf&&t<Hf);I(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=xi(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:Gf,a=this.device.editor,l=xi(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",Xe(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>Jo.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),Oa||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&&(ns=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",Dn(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},Of));I(this,"onCut",Xe(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||$o(t.target)||(this.actionManager.executeAction(Td,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Xe(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||$o(t.target)||(this.actionManager.executeAction(sa,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(Cf&&t.preventDefault(),!os){os=!0,clearTimeout(Yg),Yg=window.setTimeout(e.resetTapTwice,Rf);return}if(os&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),os=!1,clearTimeout(Yg)}t.touches.length===2&&this.setState({selectedElementIds:Ce({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Ce(this.state.previousSelectedElementIds,this.state)}):Se.pointers.clear()});I(this,"pasteFromClipboard",Xe(async t=>{let r=!!Fm,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)||$o(n)))return;let{x:l,y:s}=Fe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),c=t?.clipboardData?.files[0],m=await xd(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=Zp(d))}}if(yc(c)&&!m.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:g("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:l,sceneY:s});this.insertImageElement(d,c),this.initializeImageDimensions(d),this.setState({selectedElementIds:Ce({[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?Ca(m.elements):m.elements;this.addElementsFromPasteOrLibrary({elements:d,files:m.files||null,position:"cursor",retainSeed:r})}else if(m.text){if(m.text&&Tv(m.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:f,files:b}=await u.parseMermaidToExcalidraw(m.text),x=Ca(f,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:x,files:b,position:"cursor"});return}catch(f){console.warn(`parsing pasted text as mermaid definition failed: ${f.message}`)}}let d=h1(m.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=d.map(u=>Cb(u)).filter(u=>_i(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||Yn(u)?.type==="video"));if(!Fm&&p.length>0&&p.length===d.length){let u=[];for(let f of p){let b=u[u.length-1],x=this.insertEmbeddableElement({sceneX:b?b.x+b.width+20:l,sceneY:s,link:Po(f)});x&&u.push(x)}u.length&&this.setState({selectedElementIds:Object.fromEntries(u.map(f=>[f.id,!0]))});return}this.addTextFromPaste(m.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let r=Vp(t.elements,null,void 0),[n,i,a,l]=Te(r),s=Pn(n,a)/2,c=Pn(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}=Fe({clientX:m,clientY:d},this.state),f=p-s,b=u-c,[x,E]=yt(f,b,this.getEffectiveGridSize()),{duplicatedElements:w}=Wn({type:"everything",elements:r.map(M=>ne(M,{x:M.x+x-n,y:M.y+E-i})),randomizeSeed:!t.retainSeed}),v=this.scene.getElementsIncludingDeleted(),T=[...v,...w];T=this.props.onDuplicate?.(T,v)||T,Qo(T,J(w));let k=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(k){let M=ob(w,k);Si(T,M,k,this.state)}this.scene.replaceAllElements(T),w.forEach(M=>{if(Y(M)&&tt(M)){let O=fo(M,this.scene.getElementsMapIncludingDeleted());Ye(M,O,this.scene)}}),Tf&&Qr.loadElementsFonts(w).then(M=>{this.fonts.onLoaded(M)}),t.files&&this.addMissingFiles(t.files),this.store.scheduleCapture();let D=$1(w);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&it.get(Zl)?this.state.openSidebar:null,...nt({editingGroupId:null,selectedElementIds:D.reduce((M,O)=>(tt(O)||(M[O.id]=!0),M),{})},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=>{Tn&&this.resetContextMenuTimer(),Se.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||de("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...De(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(XE)});I(this,"zoomCanvas",t=>{this.setState({...Ir({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:er(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(Vn(t)?s=yb(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):Vn(t)&&this.setState({toast:{message:g("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}=kl({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=Kn(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=o1({fromValues:{scrollX:s,scrollY:c,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,_o(f))},onStep:({scrollX:p,scrollY:u,zoom:f})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});I(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});I(this,"translateCanvas",t=>{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,za,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Xe(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===ce.svg))try{let s=s0(Dp(d0(l.dataURL)),ce.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",Xe(t=>{let{elements:r,appState:n,collaborators:i,captureUpdate:a}=t,l=r?wr(r):void 0;if(a){let s=r?J(l??[]):void 0,c=n?Object.assign({},this.store.snapshot.appState,n):void 0;this.store.scheduleMicroAction({action:a,elements:s,appState:c})}n&&this.setState(n),l&&this.scene.replaceAllElements(l),i&&this.setState({collaborators:i})}));I(this,"mutateElement",(t,r,n=!0)=>this.scene.mutateElement(t,r,{informMutation:n,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:r,force:n})=>{let i;n===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===r?null:t:i=n?t:null;let a=i?{name:i}:null;return a&&r&&(a.tab=r),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",Xe(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 Cr().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",Xe(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}})),!cp(t.target)){if((t.key===y.ESCAPE||t.key===y.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=j(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&Me(a[0])&&t.key===y.ENTER){this.startImageCropping(a[0]);return}if(t.key===y.ESCAPE)this.updateEditorAtom(Wo,null);else if(t.key===y.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(Rt.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=ha(a);it.get(Wo)?.type==="panel"&&Ch(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(Wo,{type:"panel"})}if(t.key===y.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Ln(t.key);if(t[y.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=j(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&Hs(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,_p(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!Li(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(),_p(t.key));if(c){this.setState(d=>({selectedElementIds:Ce({[c]:!0},d)}));let m=this.scene.getNonDeletedElementsMap().get(c);m&&!Li([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[y.CTRL_OR_CMD]&&t.key===y.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:Qe("commandPalette")})}),t.preventDefault();return}if(t[y.CTRL_OR_CMD]&&t.key.toLowerCase()===y.V&&(Fm=t.shiftKey,clearTimeout(B3),B3=window.setTimeout(()=>{Fm=!1},100)),t[y.CTRL_OR_CMD]&&$o(t.target)&&(t.code===se.MINUS||t.code===se.EQUAL)){t.preventDefault();return}if($o(t.target)&&t.key!==y.ESCAPE||Ln(t.key)&&cp(t.target))return;if(t.key===y.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===y.E&&t.shiftKey&&t[y.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===y.PAGE_UP||t.key===y.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===y.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[y.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Ln(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(le),s=new Set;a.filter(le).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),f=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||f}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?Km:this.getEffectiveGridSize())||(t.shiftKey?kf:Km),m=0,d=0;t.key===y.ARROW_LEFT?m=-c:t.key===y.ARROW_RIGHT?m=c:t.key===y.ARROW_UP?d=-c:t.key===y.ARROW_DOWN&&(d=c),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+m,y:p.y+d},{informMutation:!1,isDragging:!1}),$r(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:ec(a.filter(p=>p.id!==l?.id||c!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===y.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[y.CTRL_OR_CMD])fe(l)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==a[0].id)&&(this.store.scheduleCapture(),le(l)||this.setState({editingLinearElement:new X(l,this.scene.getNonDeletedElementsMap())}));else if(Y(l)||U1(l)){let s;Y(l)||(s=l);let c=Gs(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=Py(t.key);a?(this.state.activeTool.type!==a&&de("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===mt.sharp?mt.round:l.currentItemArrowType===mt.round?mt.elbow:mt.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===y.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===y.SPACE&&Se.pointers.size===0&&(di=!0,ke(this.interactiveCanvas,we.GRAB),t.preventDefault()),(t.key===y.G||t.key===y.S)&&!t.altKey&&!t[y.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===y.G&&(qr(this.state.activeTool.type)||a.some(l=>qr(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===y.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[y.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===y.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=>Y(l)||Ee(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===y.K&&!t.altKey&&!t[y.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[y.CTRL_OR_CMD]&&(t.key===y.BACKSPACE||t.key===y.DELETE)&&this.updateEditorAtom(li,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===y.S&&t.shiftKey,i=t.key===y.I||r===y.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));I(this,"onKeyUp",Xe(t=>{if(t.key===y.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?ke(this.interactiveCanvas,we.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?ao(this.interactiveCanvas):(lo(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Ce({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),di=!1),!t[y.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Ln(t.key)&&(qa(this.scene.getSelectedElements(this.state).filter(fe),Un(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:A.IMMEDIATELY})),!t[y.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:Ce({[r.id]:!0},n)})),Li([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=De(this.state,t);n.type==="hand"?ke(this.interactiveCanvas,we.GRAB):di||lo(this.interactiveCanvas,{...this.state,activeTool:n}),e1(document.activeElement)&&this.focusContainer(),g1(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};return n.type==="freedraw"&&this.store.scheduleCapture(),n.type==="lasso"?{...i,activeTool:n,...r?{}:{selectedElementIds:Ce({},i),selectedGroupIds:Ce({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:Ce({},i),selectedGroupIds:Ce({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{ke(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{ao(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>Se.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${sp()}`);I(this,"onGestureStart",Xe(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Ce({},this.state),activeEmbeddable:null}),Se.initialScale=this.state.zoom.value}));I(this,"onGestureChange",Xe(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=Se.initialScale;r&&this.setState(n=>({...Ir({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:er(r*t.scale)},n)}))}));I(this,"onGestureEnd",Xe(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Ce(this.state.previousSelectedElementIds,this.state)}),Se.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&&(Ee(i,this.scene.getNonDeletedElementsMap())||(l=!0));let c=null,m=this.scene.getSelectedElements(this.state);m.length===1?Y(m[0])?c=m[0]:i?c=Ee(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||Ao(d),u=this.state.currentItemFontSize;if(!c&&l&&i&&!Re(i)){let E=_1(qe({fontSize:u,fontFamily:d}),p),w=N1(u,p),v=Math.max(i.height,w),T=Math.max(i.width,E);this.scene.mutateElement(i,{height:v,width:T}),t=i.x+T/2,r=i.y+v/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=c||Ot({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?Wt.MIDDLE:Xm,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?Re(i)?0:i.angle:0,frameId:f?f.id:null});if(!c&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!c)if(i&&l){let 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.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=Fe(t,this.state);if(r.length===1&&fe(r[0])){if(t[y.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)&&!le(r[0])){this.store.scheduleCapture(),this.setState({editingLinearElement:new X(r[0],this.scene.getNonDeletedElementsMap())});return}else if(this.state.selectedLinearElement&&le(r[0])){let l=X.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),s=l?X.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(s&&s>-1){this.store.scheduleCapture(),X.deleteFixedSegment(r[0],this.scene,s);let c=X.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=c?X.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&&Me(r[0])){this.startImageCropping(r[0]);return}if(ao(this.interactiveCanvas),Ro(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&Y1(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(c=>({...c,...nt({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(ao(this.interactiveCanvas),!t[y.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(vi(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(ut(s)||!Rn(s.backgroundColor)||wi({x:n,y:i,element:s,shape:yr(s,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()}))){let c=Gs(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&&gc(l,this.scene.getNonDeletedElementsMap(),this.state,L(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,r)=>{let n=An(L(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),L(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>Sn)return;let i=Fe(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=gc(this.hitLinkElement,a,this.state,L(i.x,i.y),this.device.editor.isMobile),s=Fe(this.lastPointerUpEvent,this.state),c=gc(this.hitLinkElement,a,this.state,L(s.x,s.y),this.device.editor.isMobile);if(l&&c){fh();let m=this.hitLinkElement.link;if(m){m=Po(m);let d;if(this.props.onLinkOpen&&(d=Ps("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},d)),!d?.defaultPrevented){let p=zs(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=>fp(t,i,r));return n.length?n[n.length-1]:null});I(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,Se.pointers.has(t.pointerId)&&Se.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=Se.initialScale;if(Se.pointers.size===2&&Se.lastCenter&&r&&Se.initialDistance){let u=qh(Se.pointers),f=u.x-Se.lastCenter.x,b=u.y-Se.lastCenter.y;Se.lastCenter=u;let x=Jh(Array.from(Se.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:x/Se.initialDistance,w=E?er(r*E):this.state.zoom.value;this.setState(v=>{let T=Ir({viewportX:u.x,viewportY:u.y,nextZoom:w},v);this.translateCanvas({zoom:T.zoom,scrollX:T.scrollX+2*(f/w),scrollY:T.scrollY+2*(b/w),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else Se.lastCenter=Se.initialDistance=Se.initialScale=null;if(di||rs||Kg||Bo(this.state))return;let i=og(ns,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?ao(this.interactiveCanvas):lo(this.interactiveCanvas,this.state));let a=Fe(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&sv(this.state.activeTool.type)){let{originOffset:u,snapLines:f}=lv(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(b=>{let x=yi(b.snapLines,f),E=b.originSnapOffset?yi(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=X.handlePointerMove(t,l,s,this);u&&u!==this.state.editingLinearElement&&Nr(()=>{this.setState({editingLinearElement:u})}),u?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(a,u.elbowed):Nr(()=>{this.setState({suggestedBindings:[]})})}if(f1(this.state.activeTool.type)){let{newElement:u}=this.state;br(u,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(u,[a],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:u}=this.state,{x:f,y:b}=u,{points:x,lastCommittedPoint:E}=u,w=x[x.length-1];if(lo(this.interactiveCanvas,this.state),w===E)An(L(l-f,s-b),w)>=bs?this.scene.mutateElement(u,{points:[...x,L(l-f,s-b)]},{informMutation:!1,isDragging:!1}):ke(this.interactiveCanvas,we.POINTER);else if(x.length>2&&E&&An(L(l-f,s-b),E)<bs)ke(this.interactiveCanvas,we.POINTER),this.scene.mutateElement(u,{points:x.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,T]=yt(l,s,t[y.CTRL_OR_CMD]||le(u)?null:this.getEffectiveGridSize()),[S,k]=u?.lastCommittedPoint??[0,0],D=v-f-S,M=T-b-k;Ms(t)&&({width:D,height:M}=kp(S+f,k+b,v,T)),Qa(x,this.state.zoom.value)&&ke(this.interactiveCanvas,we.POINTER),this.scene.mutateElement(u,{points:[...x.slice(0,-1),L(S+D,k+M)]},{isDragging:!0,informMutation:!1}),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&&le(d[0]))){let u=Pp(m,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(u&&u.transformHandleType){ke(this.interactiveCanvas,Np(u));return}}}else if(d.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let u=Rp(Te(d),l,s,this.state.zoom,t.pointerType,this.device);if(u){ke(this.interactiveCanvas,Np({transformHandleType:u}));return}}let p=this.getElementAtPosition(a.x,a.y);this.hitLinkElement=this.getElementLinkAtPosition(a,p),!Zt(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(ke(this.interactiveCanvas,we.POINTER),L2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(fh(),p&&(p.link||Nt(p))&&this.state.selectedElementIds[p.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?ke(this.interactiveCanvas,Y(p)?we.TEXT:we.CROSSHAIR):this.state.viewModeEnabled?ke(this.interactiveCanvas,we.GRAB):this.state.openDialog?.name==="elementLinkSelector"?ke(this.interactiveCanvas,we.AUTO):i?ke(this.interactiveCanvas,we.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s):t[y.CTRL_OR_CMD]?ke(this.interactiveCanvas,we.AUTO):(p||this.isHittingCommonBoundingBoxOfSelectedElements(a,d))&&!p?.locked&&(p&&vi(p)&&this.isIframeLikeElementCenter(p,t,l,s)?(ke(this.interactiveCanvas,we.POINTER),this.setState({activeEmbeddable:{element:p,state:"hover"}})):(!p||!le(p)||!(p.startBinding||p.endBinding))&&(ke(this.interactiveCanvas,we.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))),this.state.openDialog?.name==="elementLinkSelector"&&p?this.setState(u=>({hoveredElementIds:yi(u.hoveredElementIds,nt({editingGroupId:u.editingGroupId,selectedElementIds:{[p.id]:!0}},this.scene.getNonDeletedElements(),u,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!p&&this.setState(u=>({hoveredElementIds:yi(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=>{is=!0});I(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(d=>({searchMatches:d.searchMatches&&{focusedId:null,matches:d.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(kg,null)),it.get(Wo)&&this.updateEditorAtom(Wo,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:Ce(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=xi(this.device,{isTouchScreen:!0})),rs||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===Xo.ERASER&&this.state.activeTool.type!==je.eraser){this.setState({activeTool:De(this.state,{type:je.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let d=()=>{p(),u?.(),Zt(this.state)&&this.setState({activeTool:De(this.state,{...this.state.activeTool.lastActiveTool||{type:je.selection},lastActiveToolBeforeEraser:null})})},p=He(window,"pointerup",d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(t.button!==Xo.MAIN&&t.button!==Xo.TOUCH&&t.button!==Xo.ERASER||Se.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso")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"){ke(this.interactiveCanvas,we.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}=Fe(t,this.state),f=this.getTopLayerFrameAtSceneCoords({x:p,y:u});this.scene.mutateElement(d,{x:p,y:u,frameId:f?f.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?lo(this.interactiveCanvas,this.state):this.state.activeTool.type===je.frame||this.state.activeTool.type===je.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=Fe({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(vi(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&&vi(this.hitLinkElement)&&!$b(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,L(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"&&(is=!1,Tn?is=!0:Tn=window.setTimeout(()=>{Tn=0,is||this.handleCanvasContextMenu(t)},Nf))});I(this,"resetContextMenuTimer",()=>{clearTimeout(Tn),Tn=0,is=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{as?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(Se.pointers.size<=1&&(t.button===Xo.WHEEL||t.button===Xo.MAIN&&di||Bo(this.state)||this.state.viewModeEnabled)))return!1;rs=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);ke(this.interactiveCanvas,we.GRABBING);let{clientX:i,clientY:a}=t,l=nm(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=f=>{document.body.removeEventListener("paste",p),f.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=Xe(as=()=>{as=null,rs=!1,di||(this.state.viewModeEnabled?ke(this.interactiveCanvas,we.GRAB):lo(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:Ce({},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&&!le(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=Pp(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=Rp(Te(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=Gr(Pb(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&fe(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=Rb(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let c=this.state.editingLinearElement||this.state.selectedLinearElement,m=X.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:Ce({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(l!=null){if(t[y.CTRL_OR_CMD])return t.altKey||(this.state.selectedElementIds[l.id]||(r.hit.wasAddedToSelection=!0),this.setState(c=>({...V1(c,l),previousSelectedElementIds:this.state.selectedElementIds}))),!1;this.state.selectedElementIds[l.id]||(this.state.editingGroupId&&!Ii(l,this.state.editingGroupId)&&this.setState({selectedElementIds:Ce({},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))No(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(f=>$e(this.scene.getNonDeletedElements(),f)).filter(f=>ae(f)).map(f=>f.id));u.size>0&&d.forEach(f=>{f.frameId&&u.has(f.frameId)&&(delete m[f.id],f.groupIds.flatMap(b=>$e(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})),{...nt({editingGroupId:c.editingGroupId,selectedElementIds:m},this.scene.getNonDeletedElements(),c,this),showHyperlinkPopup:l.link||Nt(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);ut(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}),ao(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:De(this.state,{type:"selection"})})});I(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=yt(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,c=Tb({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:[L(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(d=>{let p={...d.selectedElementIds};return delete p[c.id],{selectedElementIds:Ce(p,d)}});let m=Xr(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]=yt(t,r,this.lastPointerDownEvent?.[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=vb({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]=yt(t,r,this.lastPointerDownEvent?.[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=Yn(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=Lp({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]=yt(t,r,this.lastPointerDownEvent?.[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null;return cc({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"&&Qa(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(so);return}if(le(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(so);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&An(L(n.origin.x-a,n.origin.y-l),s)<bs){this.actionManager.executeAction(so);return}this.setState(c=>({selectedElementIds:Ce({...c.selectedElementIds,[i.id]:!0},c)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),ke(this.interactiveCanvas,we.POINTER)}else{let[i,a]=yt(n.origin.x,n.origin.y,t[y.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"?Jr({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===mt.round?{type:xt.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:d,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===mt.elbow,fixedSegments:this.state.currentItemArrowType===mt.elbow?[]:null}):bo({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:xt.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:Ce(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,L(0,0)]});let u=Xr(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,le(p),le(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=yt(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[y.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=Lp({type:"embeddable",...l}):s=Kt({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]=yt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...At},l=r===je.magicframe?rl(a):Ai(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)||tt(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,ne(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});I(this,"initializeImage",async({imageFile:t,imageElement:r,showCursorImagePreview:n=!1})=>{if(!yc(t))throw new Error(g("errors.unsupportedFileType"));let i=t.type;if(ke(this.interactiveCanvas,"wait"),i===ce.svg)try{t=Zp(Dp(await t.text()),t.name)}catch(m){throw console.warn(m),new Error(g("errors.svgImageInsertError"))}let a=await(this.props.generateIdForFile?.(t)||l0(t));if(!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));if(!this.files[a]?.dataURL){try{t=await sl(t,{maxWidthOrHeight:Wf})}catch(m){console.error("Error trying to resizing image file on insertion",m)}if(t.size>Qm)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(Qm/1024/1024)}MB`}))}if(n){let m=this.files[a]?.dataURL,d=m&&c0(m);this.setImagePreviewCursor(d||t)}let s=this.files[a]?.dataURL||await wc(t),c=this.scene.mutateElement(r,{fileId:a},{informMutation:!1,isDragging:!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(g("errors.imageInsertError")))}finally{n||ao(this.interactiveCanvas)}})});I(this,"insertImageElement",async(t,r,n)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:g("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:n})}catch(i){return this.scene.mutateElement(t,{isDeleted:!0}),this.actionManager.executeAction(so),this.setState({errorMessage:i.message||g("errors.imageInsertError")}),null}});I(this,"setImagePreviewCursor",async t=>{let n;try{n=await sl(t,{maxWidthOrHeight:96})}catch(a){throw a.cause==="UNSUPPORTED"?new Error(g("errors.unsupportedFileType")):a}let i=await wc(n);if(t.type===ce.svg){let a=await Mb(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(ce.svg)}this.state.pendingImageElementId&&ke(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}=Fe({clientX:r,clientY:n},this.state),l=await uc({description:"Image",extensions:Object.keys(Ha)}),s=this.createImageElement({sceneX:i,sceneY:a,addToFrameUnderCursor:!1});t?(this.insertImageElement(s,l),this.initializeImageDimensions(s),this.setState({selectedElementIds:Ce({[s.id]:!0},this.state)},()=>{this.actionManager.executeAction(so)})):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:De(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(so)})}});I(this,"initializeImageDimensions",(t,r=!1)=>{let n=fr(t)&&this.imageCache.get(t.fileId)?.image;if(!n||n instanceof Promise){if(t.width<Sn/this.state.zoom.value&&t.height<Sn/this.state.zoom.value){let i=100/this.state.zoom.value;this.scene.mutateElement(t,{x:t.x-i/2,y:t.y-i/2,width:i,height:i})}return}if(r||t.width<Sn/this.state.zoom.value&&t.height<Sn/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;this.scene.mutateElement(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 Lb({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)&&Jo.delete(a);return i.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>fr(a)&&i.has(a.fileId)?ne(a,{status:"error"}):a)),{updatedFiles:n,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=Ab(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",Z8(()=>{this.addNewImagesToImageCache()},Pf));I(this,"updateBindingEnabledOnPointerMove",t=>{let r=sb(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});I(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=Xr(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=Xr(l,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,le(t),le(t));return s!=null&&!cb(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 p0(t),{x:i,y:a}=Fe(t,this.state);try{if(yc(r)&&this.isToolSupported("image")){if(r?.type===ce.png||r?.type===ce.svg)try{let c=await vc(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(g("alerts.couldNotLoadInvalidFile"))}let s=this.createImageElement({sceneX:i,sceneY:a});this.insertImageElement(s,r),this.initializeImageDimensions(s),this.setState({selectedElementIds:Ce({[s.id]:!0},this.state)});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let l=t.dataTransfer.getData(ce.excalidrawlib);if(l&&typeof l=="string"){try{let s=a0(l);this.addElementsFromPasteOrLibrary({elements:Nd(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&&_i(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||Yn(s)?.type==="video")){let c=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:Po(s)});c&&this.setState({selectedElementIds:{[c.id]:!0}})}}});I(this,"loadFileToCanvas",async(t,r)=>{t=await h0(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await Yp(t,this.state,n,r)}catch(a){let l=a instanceof Kb;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let s=l?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===ce.excalidraw?(wr(n.concat(i.data.elements)),this.store.scheduleMicroAction({action:A.NEVER,elements:J(n),appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:A.IMMEDIATELY})):i.type===ce.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==Xo.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:n}=Fe(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;de("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...nt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:fe(i)?new X(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){Mp({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Pn(t.origin.x,a.x),height:Pn(t.origin.y,a.y),shouldMaintainAspectRatio:hi(r),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,c]=yt(a.x,a.y,r[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=fr(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}=av(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}),Mp({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:Pn(t.originInGrid.x,s),height:Pn(t.originInGrid.y,c),shouldMaintainAspectRatio:Me(l)?!hi(r):hi(r),shouldResizeFromCenter:op(r),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:d,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===je.frame||this.state.activeTool.type===je.magicframe)&&this.setState({elementsToHighlight:ki(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]=yt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&Me(s)){let c=t.originalElements.get(s.id),m=fr(s)&&this.imageCache.get(s.fileId)?.image;if(c&&Me(c)&&m&&!(m instanceof Promise)){let[d,p]=yt(i.x,i.y,r[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:f,snapLines:b}=eg([s],[c],this,r,u,n);this.scene.mutateElement(s,k1(s,n,m.naturalWidth,m.naturalHeight,a+f.x,l+f.y,r.shiftKey?c.width/c.height:void 0)),$r(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:b})}return!0}return!1});I(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(d=>ae(d)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&le(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=yt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(d=>{No(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]=yt(l.x,l.y,r[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=eg(n,j(f,this.state),this,r,u,a);s+=b.x,c+=b.y,this.setState({snapLines:x})}if(_b(t.originalElements,a,n,this.scene,Ms(r),op(r),n.some(d=>Me(d))?!hi(r):hi(r),s,c,t.resize.center.x,t.resize.center.y)){let d=ec(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{ki(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:d}),!0}return!1});I(this,"getContextMenuItems",t=>{let r=[];return r.push(Id,Cd),t==="canvas"?this.state.viewModeEnabled?[...r,Sd,ca,$h,da]:[sh,st,Id,Cd,kd,st,wu,A2,st,Sd,ch,ca,$h,da]:(r.push(kd),this.state.viewModeEnabled?[sa,...r]:[st,Td,sa,sh,st,Vy,Yy,Ky,st,Zh,st,...r,st,eh,th,st,oh,qy,dh,mh,w2,rh,st,ih,st,xu,Eu,yu,vu,st,ah,lh,st,Kh,st,Dl,_d,st,Tu,xh,st,El])});I(this,"handleWheel",Xe(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[y.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),rs)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=>({...Ir({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:er(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}=Fe({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:Se.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",Dn(()=>{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=en(),{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=r.theme,name:m=`${g("labels.untitled")}-${sp()}`}=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=$8(),this.library=new $2(this),this.actionManager=new Jd(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new ol,this.canvas=document.createElement("canvas"),this.rc=X8.canvas(this.canvas),this.renderer=new Yl(this.scene),this.visibleElements=[],this.store=new hb(this),this.history=new Wl(this.store),n){let d={updateScene:this.updateScene,mutateElement:this.mutateElement,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,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 n=="function"?n(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Qr(this.scene),this.history=new Wl(this.store),this.actionManager.registerAll(Zc),this.actionManager.registerAction(Xy(this.history)),this.actionManager.registerAction($y(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(n=a.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values(Ba).includes(i)&&Zg.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),On(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=Zg.get(t.id);switch(n||(Zg.set(t.id,Ba.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case Ba.PLAYING:case Ba.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=>Nt(a)&&this.embedsValidationStatus.get(a.id)===!0||On(a));return _e(q8,{children:i.map(a=>{let{x:l,y:s}=It({sceneX:a.x,sceneY:a.y},this.state),c=tl(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(On(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:()=>Ap(`
24
+ C -->|Three| F[Car]`,X3=rB(nl,300),lB=({mermaidToExcalidrawLib:e})=>{let[o,t]=Y3(()=>Ut.get(nB.MERMAID_TO_EXCALIDRAW)||aB),n=oB(o.trim()),[r,i]=Y3(null),a=W3(null),l=W3({elements:[],files:null}),s=Re();V3(()=>{Ld({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:n}).catch(m=>{iB()&&console.error("Failed to parse mermaid definition",m)}),X3(n)},[n,e]),V3(()=>()=>{X3.flush()},[]);let d=()=>{Pd({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return K3(sB,{children:[Io("div",{className:"ttd-dialog-desc",children:Io(ht,{i18nKey:"mermaid.description",flowchartLink:m=>Io("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:m}),sequenceLink:m=>Io("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:m}),classLink:m=>Io("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:m})})}),K3(kd,{children:[Io(Pi,{label:g("mermaid.syntax"),children:Io(Id,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:m=>t(m.target.value),onKeyboardSubmit:()=>{d()}})}),Io(Pi,{label:g("mermaid.preview"),panelAction:{action:()=>{d()},label:g("mermaid.button"),icon:kr},renderSubmitShortcut:()=>Io(Md,{}),children:Io(Sd,{canvasRef:a,loaded:e.loaded,error:r})})]})]})},Z3=lB;import*as j3 from"@radix-ui/react-tabs";import{useRef as $3}from"react";import{isMemberOf as cB}from"@excalidraw/common";import{jsx as dB}from"react/jsx-runtime";var q3=e=>{let o=le(),t=$3(null),n=$3(0);return dB(j3.Root,{ref:t,className:"ttd-dialog-tabs-root",value:e.tab,onValueChange:r=>{if(!r)return;let i=t.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"&&cB(["text-to-diagram","mermaid"],r)&&o({openDialog:{name:e.dialog,tab:r}})},children:e.children})};q3.displayName="TTDDialogTabs";var J3=q3;import*as Q3 from"@radix-ui/react-tabs";import{jsx as mB}from"react/jsx-runtime";var Ig=({children:e,...o})=>mB(Q3.List,{className:"ttd-dialog-triggers",...o,children:e});Ig.displayName="TTDDialogTabTriggers";import*as tT from"@radix-ui/react-tabs";import{jsx as eT}from"react/jsx-runtime";var Ad=({children:e,tab:o,onSelect:t,...n})=>eT(tT.Trigger,{value:o,asChild:!0,onSelect:t,children:eT("button",{type:"button",className:"ttd-dialog-tab-trigger",...n,children:e})});Ad.displayName="TTDDialogTabTrigger";import*as oT from"@radix-ui/react-tabs";import{jsx as pB}from"react/jsx-runtime";var Dd=({tab:e,children:o,...t})=>pB(oT.Content,{...t,value:e,children:o});Dd.displayName="TTDDialogTab";import{jsx as ft,jsxs as In}from"react/jsx-runtime";var Sg=3,Ai=1e3,hB=me(null),gB=me(null),kg=e=>{let o=ge();return o.openDialog?.name!=="ttd"?null:ft(fB,{...e,tab:o.openDialog.tab})},fB=Wo("TTDDialogBase",({tab:e,...o})=>{let t=Re(),n=le(),r=Cg(null),[i,a]=ie(gB),[l,s]=_d(i?.prompt??""),d=l.trim(),m=S=>{s(S.target.value),a(L=>({generatedResponse:L?.generatedResponse??null,prompt:S.target.value}))},[c,p]=_d(!1),[u,f]=ie(hB),b=async()=>{if(d.length>Ai||d.length<Sg||c||u?.rateLimitRemaining===0||"__fallback"in o){d.length<Sg&&C(new Error(`Prompt is too short (min ${Sg} characters)`)),d.length>Ai&&C(new Error(`Prompt is too long (max ${Ai} characters)`));return}try{p(!0),ne("ai","generate","ttd");let{generatedResponse:S,error:L,rateLimit:k,rateLimitRemaining:A}=await o.onTextSubmit(d);if(typeof S=="string"&&a(P=>({generatedResponse:S,prompt:P?.prompt??null})),nT(k)&&nT(A)&&f({rateLimit:k,rateLimitRemaining:A}),L){C(L);return}if(!S){C(new Error("Generation failed"));return}try{await Ld({canvasRef:r,data:y,mermaidToExcalidrawLib:w,setError:C,mermaidDefinition:S}),ne("ai","mermaid parse success","ttd")}catch(P){console.info(`%cTTD mermaid render errror: ${P.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
25
+ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),ne("ai","mermaid parse failed","ttd"),C(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let L=S.message;(!L||L==="Failed to fetch")&&(L="Request failed"),C(new Error(L))}finally{p(!1)}},x=Cg(b);x.current=b;let[w,E]=_d({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});uB(()=>{(async()=>{await w.api,E(L=>({...L,loaded:!0}))})()},[w.api]);let y=Cg({elements:[],files:null}),[v,C]=_d(null);return ft(Be,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:In(J3,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?ft("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):In(Ig,{children:[ft(Ad,{tab:"text-to-diagram",children:In("div",{style:{display:"flex",alignItems:"center"},children:[g("labels.textToDiagram"),ft("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"})]})}),ft(Ad,{tab:"mermaid",children:"Mermaid"})]}),ft(Dd,{className:"ttd-dialog-content",tab:"mermaid",children:ft(Z3,{mermaidToExcalidrawLib:w})}),!("__fallback"in o)&&In(Dd,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[ft("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."}),In(kd,{children:[ft(Pi,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:kr},onTextSubmitInProgess:c,panelActionDisabled:d.length>Ai||u?.rateLimitRemaining===0,renderTopRight:()=>u?In("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:()=>ft(Md,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return In("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(nl(i.generatedResponse),n({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",ft(an,{icon:kr})]});let S=d.length/Ai;return S>.8?In("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",d.length,"/",Ai]}):null},children:ft(Id,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),ft(Pi,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Pd({app:t,data:y})},label:"Insert",icon:kr},children:ft(Sd,{canvasRef:r,error:v,loaded:w.loaded})})]})]})]})})});import{round as UT}from"@excalidraw/math";import LF from"clsx";import PF from"lodash.throttle";import{useEffect as YT,useMemo as Gg,useState as AF,memo as DF}from"react";import{STATS_PANELS as Gd}from"@excalidraw/common";import{getCommonBounds as _F}from"@excalidraw/element";import{getUncroppedWidthAndHeight as RF}from"@excalidraw/element";import{isElbowArrow as NF,isImageElement as Ug}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as BF}from"@excalidraw/element";import{elementsAreInSameGroup as FF}from"@excalidraw/element";import{degreesToRadians as cT,radiansToDegrees as uT}from"@excalidraw/math";import{getBoundTextElement as dT}from"@excalidraw/element";import{isArrowElement as mT,isElbowArrow as MB}from"@excalidraw/element";import{updateBindings as pT}from"@excalidraw/element";import vB from"clsx";import{useEffect as lT,useRef as Nd,useState as TB}from"react";import{EVENT as Ri,KEYS as IB,cloneJSON as Mg}from"@excalidraw/common";import{deepCopyElement as CB}from"@excalidraw/element";import{CaptureUpdateAction as sT}from"@excalidraw/element";import{pointFrom as Cn,pointRotateRads as Rd}from"@excalidraw/math";import{getBoundTextElement as bB}from"@excalidraw/element";import{isFrameLikeElement as iT}from"@excalidraw/element";import{getSelectedGroupIds as xB,getElementsInGroup as EB,isInGroup as yB}from"@excalidraw/element";import{getFrameChildren as wB}from"@excalidraw/element";import{updateBindings as rT}from"@excalidraw/element";var aT=.01,rl=10,St=(e,o)=>!(o==="angle"&&iT(e)),Me=(e,o)=>{let t=e+o/2;return t-t%o},Di=(e,o,t)=>Object.keys(e).map(n=>({original:(t??o).get(n),latest:o.get(n)})).filter(n=>n.original!==void 0&&n.latest!==void 0);var ir=(e,o,t,n,r,i=!0)=>{let a=n.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,d]=[t.x+t.width/2,t.y+t.height/2],[m,c]=Rd(Cn(t.x,t.y),Cn(s,d),t.angle),p=e-m,u=o-c,[f,b]=Rd(Cn(e,o),Cn(s+p,d+u),-t.angle);n.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),rT(l,n);let x=bB(t,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(iT(t)){let w=wB(r,t.id);w.forEach(E=>{let y=a.get(E.id);if(!y)return;let[v,C]=[E.x+E.width/2,E.y+E.height/2],[S,L]=Rd(Cn(E.x,E.y),Cn(v,C),E.angle),k=Math.round(S+p),A=Math.round(L+u),[P,N]=Rd(Cn(k,A),Cn(v+p,C+u),-E.angle);n.mutateElement(y,{x:P,y:N},{informMutation:i,isDragging:!1}),rT(y,n,{simultaneouslyUpdated:w})})}},_i=(e,o)=>{let n=xB(o).map(r=>EB(e,r).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(r=>!yB(r)).forEach(r=>{n.push({[r.id]:!0})}),n};import{jsx as Lg,jsxs as kB}from"react/jsx-runtime";var SB=({label:e,icon:o,dragInputCallback:t,value:n,elements:r,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:d,sensitivity:m=1,dragFinishedCallback:c})=>{let p=Re(),u=le(),f=Nd(null),b=Nd(null),[x,w]=TB(n.toString()),E=Nd(null);E.current||(E.current={originalAppState:Mg(d),originalElements:r,lastUpdatedValue:x,updatePending:!1}),lT(()=>{let C=n.toString();w(C),E.current.lastUpdatedValue=C},[n]);let y=(C,S,L)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let k=Number(C);if(isNaN(k)){w(n.toString());return}let A=Number(k.toFixed(2)),P=Number(n);(isNaN(P)||Math.abs(A-P)>=aT)&&(E.current.lastUpdatedValue=C,t({accumulatedChange:0,instantChange:0,originalElements:S,originalElementsMap:p.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:A,property:l,originalAppState:L,setInputValue:N=>w(String(N)),app:p,setAppState:u}),p.syncActionResult({captureUpdate:sT.IMMEDIATELY}))},v=Nd({});return v.current.handleInputValue=y,lT(()=>{let C=f.current,S=v.current;return()=>{let L=C?.value;L&&S.handleInputValue?.(L,E.current.originalElements,E.current.originalAppState),window.removeEventListener(Ri.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(Ri.POINTER_UP,S.onPointerUp,!1)}},[i]),i?kB("div",{className:vB("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Lg("div",{className:"drag-input-label",ref:b,onPointerDown:C=>{if(f.current&&i){document.body.classList.add("excalidraw-cursor-resize");let S=Number(f.current.value);isNaN(S)&&(S=0);let L=null,k=p.scene.getNonDeletedElements().reduce((_,R)=>(_.set(R.id,CB(R)),_),new Map),A=r.map(_=>k.get(_.id)),P=Mg(d),N=0,O=0,U=_=>{if(L&&k!==null&&A!==null){let R=_.clientX-L.x;R!==0&&(O+=R,Math.abs(O)>=m&&(O=Math.sign(O)*Math.floor(Math.abs(O)/m),N+=O,t({accumulatedChange:N,instantChange:O,originalElements:A,originalElementsMap:k,shouldKeepAspectRatio:a,shouldChangeByStepSize:_.shiftKey,property:l,scene:s,originalAppState:P,setInputValue:V=>w(String(V)),app:p,setAppState:u}),O=0))}L={x:_.clientX,y:_.clientY}},J=()=>{window.removeEventListener(Ri.POINTER_MOVE,U,!1),p.syncActionResult({captureUpdate:sT.IMMEDIATELY}),c?.({app:p,setAppState:u,originalElements:A,originalAppState:P}),L=null,N=0,O=0,A=null,k=null,document.body.classList.remove("excalidraw-cursor-resize"),window.removeEventListener(Ri.POINTER_UP,J,!1)};v.current.onPointerMove=U,v.current.onPointerUp=J,window.addEventListener(Ri.POINTER_MOVE,U,!1),window.addEventListener(Ri.POINTER_UP,J,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?Lg(an,{icon:o}):e}),Lg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(i){let S=C.target;S instanceof HTMLInputElement&&C.key===IB.ENTER&&(y(S.value,r,d),p.focusContainer())}},ref:f,value:x,onChange:C=>{E.current.updatePending=!0,w(C.target.value)},onFocus:C=>{C.target.select(),E.current.originalElements=r,E.current.originalAppState=Mg(d)},onBlur:C=>{x?i&&y(C.target.value,E.current.originalElements,E.current.originalAppState):w(n.toString())},disabled:!i})]}):null},Qe=SB;import{jsx as DB}from"react/jsx-runtime";var LB=15,PB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a&&!MB(a)){let l=i.get(a.id);if(!l)return;if(n!==void 0){let u=cT(n);r.mutateElement(l,{angle:u}),pT(l,r);let f=dT(l,i);f&&!mT(l)&&r.mutateElement(f,{angle:u});return}let s=Math.round(uT(a.angle)*100)/100,d=Math.round(e),m=(s+d)%360;t&&(m=Me(m,LB)),m=m<0?m+360:m;let c=cT(m);r.mutateElement(l,{angle:c}),pT(l,r);let p=dT(l,i);p&&!mT(l)&&r.mutateElement(p,{angle:c})}},AB=({element:e,scene:o,appState:t,property:n})=>DB(Qe,{label:"A",icon:Jl,value:Math.round(uT(e.angle)%360*100)/100,elements:[e],dragInputCallback:PB,editable:St(e,"angle"),scene:o,appState:t,property:n}),hT=AB;import{jsx as RB}from"react/jsx-runtime";var gT=5,_B=({property:e,scene:o,appState:t,setAppState:n})=>RB(Qe,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:r,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{n(s=>{let d;return r?d=r:i&&(d=a?Me(s.gridStep+gT*Math.sign(i),gT):s.gridStep+i),d?(d=Jf(d),l(d),{gridStep:d}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),fT=_B;import{clamp as Bd,round as Pg}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Fd}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as bT,getUncroppedWidthAndHeight as yT}from"@excalidraw/element";import{resizeSingleElement as xT}from"@excalidraw/element";import{isImageElement as wT}from"@excalidraw/element";import{isFrameLikeElement as Ag}from"@excalidraw/element";import{getElementsInResizingFrame as Dg}from"@excalidraw/element";import{replaceAllElementsInFrame as vT}from"@excalidraw/element";import{jsx as zB}from"react/jsx-runtime";var ET=10,NB=e=>e.type==="image",BB=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:n,shouldChangeByStepSize:r,nextValue:i,property:a,originalAppState:l,instantChange:s,scene:d,app:m,setAppState:c})=>{let p=d.getNonDeletedElementsMap(),u=o[0],f=p.get(u.id);if(u&&f){let b=n||NB(u),x=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!wT(w)||!w.crop)return;let E=w.crop,y={...E},v=w.scale[0]===-1,C=w.scale[1]===-1,{width:S,height:L}=yT(w),k=E.naturalWidth/S,A=E.naturalHeight/L,P=v?E.width+E.x:E.naturalWidth-E.x,N=C?E.height+E.y:E.naturalHeight-E.y,O=bT*k,U=bT*A;if(i!==void 0){if(a==="width"){let Z=i*k,W=Bd(Z,O,P);y={...y,width:W,x:v?E.x+E.width-W:E.x}}else if(a==="height"){let Z=i*A,W=Bd(Z,U,N);y={...y,height:W,y:C?E.y+E.height-W:E.y}}d.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/L)});return}let J=a==="width"?s:0,_=a==="height"?s:0,R=Bd(E.width+J,O,P),V=Bd(E.height+_,O,N);y={...E,x:v?E.x+E.width-R:E.x,y:C?E.y+E.height-V:E.y,width:R,height:V},d.mutateElement(w,{crop:y,width:y.width/(E.naturalWidth/S),height:y.height/(E.naturalHeight/L)});return}if(i!==void 0){let w=Math.max(a==="width"?i:b?i*x:u.width,Fd),E=Math.max(a==="height"?i:b?i/x:u.height,Fd);if(xT(w,E,f,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Ag(f)){let y=Dg(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap()),v=vT(d.getElementsIncludingDeleted(),y,f,m);d.replaceAllElements(v)}return}{let w=a==="width"?e:0,E=a==="height"?e:0,y=Math.max(0,u.width+w);a==="width"&&(r?y=Me(y,ET):y=Math.round(y));let v=Math.max(0,u.height+E);if(a==="height"&&(r?v=Me(v,ET):v=Math.round(v)),b&&(a==="width"?v=Math.round(y/x*100)/100:y=Math.round(v*x*100)/100),v=Math.max(Fd,v),y=Math.max(Fd,y),xT(y,v,f,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),Ag(f)){let C=Dg(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap());c({elementsToHighlight:C})}}}},FB=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Ag(a)){let l=Dg(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=vT(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},OB=({property:e,element:o,scene:t,appState:n})=>{let r=Pg(e==="width"?o.width:o.height,2);if(n.croppingElementId&&n.croppingElementId===o.id&&wT(o)&&o.crop){let{width:i,height:a}=yT(o);if(e==="width"){let l=i/o.crop.naturalWidth;r=Pg(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;r=Pg(o.crop.height*l,2)}}return zB(Qe,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:BB,value:r,editable:St(o,e),scene:t,appState:n,property:e,dragFinishedCallback:FB})},_g=OB;import{getBoundTextElement as HB,redrawTextBoundingBox as GB}from"@excalidraw/element";import{hasBoundTextElement as UB,isTextElement as IT}from"@excalidraw/element";import{jsx as XB}from"react/jsx-runtime";var TT=4,YB=4,WB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!IT(l))return;let s;if(n!==void 0)s=Math.max(Math.round(n),TT);else if(a.type==="text"){let d=Math.round(a.fontSize),m=Math.round(e);s=Math.max(d+m,TT),t&&(s=Me(s,YB))}s&&(r.mutateElement(l,{fontSize:s}),GB(l,r.getContainerElement(l),r))}},VB=({element:e,scene:o,appState:t,property:n})=>{let r=IT(e)?e:UB(e)?HB(e,o.getNonDeletedElementsMap()):null;return r?XB(Qe,{label:"F",value:Math.round(r.fontSize*10)/10,elements:[r],dragInputCallback:WB,icon:Hn,appState:t,scene:o,property:n}):null},CT=VB;import{degreesToRadians as ST,radiansToDegrees as LT}from"@excalidraw/math";import{getBoundTextElement as kT}from"@excalidraw/element";import{isArrowElement as MT}from"@excalidraw/element";import{isInGroup as Rg}from"@excalidraw/element";import{jsx as jB}from"react/jsx-runtime";var KB=15,ZB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,property:r,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(d=>a.get(d.id)).filter(d=>d&&!Rg(d)&&St(d,r)),s=o.filter(d=>!Rg(d)&&St(d,r));if(n!==void 0){let d=ST(n);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:d});let c=kT(m,a);c&&!MT(m)&&i.mutateElement(c,{angle:d})}i.triggerUpdate();return}for(let d=0;d<l.length;d++){let m=l[d];if(!m)continue;let c=s[d],p=Math.round(LT(c.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=Me(f,KB)),f=f<0?f+360:f;let b=ST(f);i.mutateElement(m,{angle:b});let x=kT(m,a);x&&!MT(m)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},$B=({elements:e,scene:o,appState:t,property:n})=>{let r=e.filter(s=>!Rg(s)&&St(s,"angle")),i=r.map(s=>Math.round(LT(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=r.some(s=>St(s,"angle"));return jB(Qe,{label:"A",icon:Jl,value:a,elements:e,dragInputCallback:ZB,editable:l,appState:t,scene:o,property:n})},PT=$B;import{pointFrom as AT}from"@excalidraw/math";import{useMemo as qB}from"react";import{MIN_WIDTH_OR_HEIGHT as Sn}from"@excalidraw/common";import{getElementsInResizingFrame as Ng,isFrameLikeElement as Bg,replaceAllElementsInFrame as RT,updateBoundElements as JB}from"@excalidraw/element";import{rescalePointsInElement as QB,resizeSingleElement as DT}from"@excalidraw/element";import{getBoundTextElement as eF,handleBindTextResize as tF}from"@excalidraw/element";import{isTextElement as NT}from"@excalidraw/element";import{getCommonBounds as Od}from"@excalidraw/element";import{jsx as lF}from"react/jsx-runtime";var Ni=10,oF=(e,o,t,n)=>{let r=n.x-e,i=n.y-o,a=n.width*t,l=n.height*t,s=e+r*t,d=o+i*t;return{width:a,height:l,x:s,y:d,...QB(n,a,l,!1),...NT(n)?{fontSize:n.fontSize*t}:{}}},nF=(e,o,t,n,r,i,a,l)=>{let s=l.getNonDeletedElementsMap(),d=oF(e,o,n,i);l.mutateElement(r,d);let m=eF(i,a);if(m){let c=m.fontSize*n;JB(r,l,{newSize:{width:d.width,height:d.height}});let p=s.get(m.id);p&&NT(p)&&(l.mutateElement(p,{fontSize:c}),tF(r,l,t==="width"?"e":"s",!0))}},_T=(e,o,t,n,r,i,a,l,s,d)=>{i==="width"?o=Math.round(e/n*100)/100:e=Math.round(o*n*100)/100;let m=o/t;for(let c=0;c<l.length;c++){let p=l[c],u=a[c];nF(r[0],r[1],i,m,u,p,s,d)}},rF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:n,shouldChangeByStepSize:r,nextValue:i,scene:a,property:l,setAppState:s,app:d})=>{let m=a.getNonDeletedElementsMap(),c=_i(o,n);if(i!==void 0){for(let b of c){let x=Di(b,m,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=Od(E),L=C-y,k=S-v,A=L/k,P=Math.max(Sn,l==="width"?Math.max(0,i):L),N=Math.max(Sn,l==="height"?Math.max(0,i):k);_T(P,N,k,A,AT(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&St(E,l)){let v=l==="width"?Math.max(0,i):E.width;l==="width"&&(r?v=Me(v,Ni):v=Math.round(v));let C=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(r?C=Me(C,Ni):C=Math.round(C)),v=Math.max(Sn,v),C=Math.max(Sn,C),DT(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Bg(E)){let S=Ng(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap()),L=RT(a.getElementsIncludingDeleted(),S,E,d);a.replaceAllElements(L)}}}}a.triggerUpdate();return}let p=l==="width"?e:0,u=l==="height"?e:0,f=[];for(let b of c){let x=Di(b,m,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=Od(E),L=C-y,k=S-v,A=L/k,P=Math.max(0,L+p);l==="width"&&(r?P=Me(P,Ni):P=Math.round(P));let N=Math.max(0,k+u);l==="height"&&(r?N=Me(N,Ni):N=Math.round(N)),P=Math.max(Sn,P),N=Math.max(Sn,N),_T(P,N,k,A,AT(y,v),l,w,E,t,a)}else{let[w]=x,E=w?.latest,y=w?.original;if(E&&y&&St(E,l)){let v=Math.max(0,y.width+p);l==="width"&&(r?v=Me(v,Ni):v=Math.round(v));let C=Math.max(0,y.height+u);if(l==="height"&&(r?C=Me(C,Ni):C=Math.round(C)),v=Math.max(Sn,v),C=Math.max(Sn,C),DT(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Bg(E)){let S=Ng(a.getElementsIncludingDeleted(),E,n,a.getNonDeletedElementsMap());f.push(...S)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},iF=({setAppState:e,app:o,originalElements:t,originalAppState:n})=>{let r=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&r.get(i.id);if(a&&Bg(a)){let l=Ng(o.scene.getElementsIncludingDeleted(),a,n,o.scene.getNonDeletedElementsMap()),s=RT(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},aF=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=qB(()=>n.map(d=>{let m=Di(d,t);if(m.length>1){let[p,u,f,b]=Od(m.map(x=>x.latest));return Math.round((e==="width"?f-p:b-u)*100)/100}let[c]=m;return Math.round((e==="width"?c.latest.width:c.latest.height)*100)/100}),[t,n,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return lF(Qe,{label:e==="width"?"W":"H",elements:o,dragInputCallback:rF,value:l,editable:s,appState:i,property:e,scene:r,dragFinishedCallback:iF})},Fg=aF;import{getBoundTextElement as sF,redrawTextBoundingBox as BT}from"@excalidraw/element";import{hasBoundTextElement as cF,isTextElement as dF}from"@excalidraw/element";import{isInGroup as mF}from"@excalidraw/element";import{jsx as fF}from"react/jsx-runtime";var FT=4,pF=4,uF=(e,o)=>e.reduce((t,n)=>{if(!n||mF(n))return t;if(dF(n))return t.push(n),t;if(cF(n)){let r=sF(n,o);if(r)return t.push(r),t}return t},[]),hF=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:n,scene:r})=>{let i=r.getNonDeletedElementsMap(),a=o.map(s=>i.get(s.id)),l;if(n){l=Math.max(Math.round(n),FT);for(let s of a)r.mutateElement(s,{fontSize:l}),BT(s,r.getContainerElement(s),r);r.triggerUpdate()}else{let s=o;for(let d=0;d<a.length;d++){let m=a[d],c=s[d],p=Math.round(c.fontSize),u=Math.round(e),f=Math.max(p+u,FT);t&&(f=Me(f,pF)),r.mutateElement(m,{fontSize:f}),BT(m,r.getContainerElement(m),r)}r.triggerUpdate()}},gF=({elements:e,scene:o,appState:t,property:n,elementsMap:r})=>{let i=uF(e,r);if(!i.length)return null;let a=i.map(d=>Math.round(d.fontSize*10)/10),l=new Set(a).size===1?a[0]:"Mixed",s=a.length>0;return fF(Qe,{label:"F",icon:Hn,elements:i,dragInputCallback:hF,value:l,editable:s,scene:o,property:n,appState:t})},OT=gF;import{pointFrom as kn,pointRotateRads as zd}from"@excalidraw/math";import{useMemo as bF}from"react";import{isTextElement as xF}from"@excalidraw/element";import{getCommonBounds as Og}from"@excalidraw/element";import{jsx as TF}from"react/jsx-runtime";var EF=(e,o,t,n,r,i)=>{for(let a=0;a<n.length;a++){let l=n[a],[s,d]=[l.x+l.width/2,l.y+l.height/2],[m,c]=zd(kn(l.x,l.y),kn(s,d),l.angle),p=e==="x"?Math.round(m+o):m,u=e==="y"?Math.round(c+t):c;ir(p,u,l,i,r,!1)}},yF=(e,o,t,n,r)=>{let i=r.getNonDeletedElementsMap(),[a,l,,]=Og(t),s=e-a,d=o-l;for(let m=0;m<t.length;m++){let c=t[m],p=i.get(c.id);if(p&&(!xF(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=zd(kn(p.x,p.y),kn(u,f),p.angle);ir(b+s,x+d,c,r,n,!1)}}},wF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:n,nextValue:r,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap();if(r!==void 0){for(let p of _i(o,l)){let u=Di(p,s,t);if(u.length>1){let[f,b,,]=Og(u.map(E=>E.latest));yF(i==="x"?r:f,i==="y"?r:b,u.map(E=>E.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&St(b,i)){let[x,w]=[f.x+f.width/2,f.y+f.height/2],[E,y]=zd(kn(f.x,f.y),kn(x,w),f.angle);ir(i==="x"?r:E,i==="y"?r:y,f,a,t,!1)}}}a.triggerUpdate();return}let d=n?Me(e,rl):e;EF(i,i==="x"?d:0,i==="y"?d:0,o,t,a),a.triggerUpdate()},vF=({property:e,elements:o,elementsMap:t,atomicUnits:n,scene:r,appState:i})=>{let a=bF(()=>n.map(s=>{let d=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(d.length>1){let[b,x]=Og(d);return Math.round((e==="x"?b:x)*100)/100}let[m]=d,[c,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=zd(kn(m.x,m.y),kn(c,p),m.angle);return Math.round((e==="x"?u:f)*100)/100}),[n,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return TF(Qe,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:wF,value:l,property:e,scene:r,appState:i})},zg=vF;import{clamp as il,pointFrom as Hd,pointRotateRads as HT,round as zT}from"@excalidraw/math";import{getFlipAdjustedCropPosition as IF,getUncroppedWidthAndHeight as CF}from"@excalidraw/element";import{isImageElement as GT}from"@excalidraw/element";import{jsx as MF}from"react/jsx-runtime";var SF=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:n,shouldChangeByStepSize:r,nextValue:i,property:a,scene:l,originalAppState:s})=>{let d=l.getNonDeletedElementsMap(),m=t[0],[c,p]=[m.x+m.width/2,m.y+m.height/2],[u,f]=HT(Hd(m.x,m.y),Hd(c,p),m.angle);if(s.croppingElementId===m.id){let y=d.get(m.id);if(!y||!GT(y)||!y.crop)return;let v=y.crop,C=v,S=y.scale[0]===-1,L=y.scale[1]===-1,{width:k,height:A}=CF(y);if(i!==void 0){if(a==="x"){let O=i*(v.naturalWidth/k);S?C={...v,x:il(v.naturalWidth-O-v.width,0,v.naturalWidth-v.width)}:C={...v,x:il(i*(v.naturalWidth/k),0,v.naturalWidth-v.width)}}a==="y"&&(C={...v,y:il(i*(v.naturalHeight/A),0,v.naturalHeight-v.height)}),l.mutateElement(y,{crop:C});return}let P=(a==="x"?o:0)*(S?-1:1),N=(a==="y"?o:0)*(L?-1:1);C={...v,x:il(v.x+P,0,v.naturalWidth-v.width),y:il(v.y+N,0,v.naturalHeight-v.height)},l.mutateElement(y,{crop:C});return}if(i!==void 0){ir(a==="x"?i:u,a==="y"?i:f,m,l,n);return}let b=a==="x"?e:0,x=a==="y"?e:0,w=a==="x"?Math.round(r?Me(m.x+b,rl):u+b):u,E=a==="y"?Math.round(r?Me(m.y+x,rl):f+x):f;ir(w,E,m,l,n)},kF=({property:e,element:o,elementsMap:t,scene:n,appState:r})=>{let[i,a]=HT(Hd(o.x,o.y),Hd(o.x+o.width/2,o.y+o.height/2),o.angle),l=zT(e==="x"?i:a,2);if(r.croppingElementId===o.id&&GT(o)&&o.crop){let s=IF(o);s&&(l=zT(e==="x"?s.x:s.y,2))}return MF(Qe,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:SF,scene:n,value:l,property:e,appState:r})},Hg=kF;import{Fragment as Yg,jsx as q,jsxs as kt}from"react/jsx-runtime";var OF=50,al=e=>{let o=go(),t=e.app.scene.getSceneNonce()||1,n=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),r=fn(e.app);return q(zF,{...e,appState:o,sceneNonce:t,selectedElements:n,gridModeEnabled:r})},Ie=({children:e,columns:o=1,heading:t,style:n,...r})=>q("div",{className:LF("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...n},...r,children:e});Ie.displayName="StatsRow";var Ud=({children:e,order:o,style:t,...n})=>q("div",{className:"exc-stats__rows",style:{order:o,...t},...n,children:e});Ud.displayName="StatsRows";al.StatsRow=Ie;al.StatsRows=Ud;var zF=DF(({app:e,onClose:o,renderCustomStats:t,selectedElements:n,appState:r,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),d=l.getNonDeletedElementsMap(),m=le(),c=n.length===1?n[0]:null,p=n.length>1?n:null,u=r.croppingElementId&&Ug(c),f=u?RF(c):null,[b,x]=AF({width:0,height:0}),w=Gg(()=>PF(v=>{let C=_F(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},OF),[]);YT(()=>{w(s)},[i,s,w]),YT(()=>()=>w.cancel(),[w]);let E=Gg(()=>_i(n,r),[n,r]),y=Gg(()=>BF(n),[n]);return q("div",{className:"exc-stats",children:kt(Xe,{padding:3,children:[kt("div",{className:"title",children:[q("h2",{children:g("stats.title")}),q("div",{className:"close",onClick:o,children:Ft})]}),kt(ua,{label:q("h3",{children:g("stats.generalStats")}),open:!!(r.stats.panels&Gd.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Gd.generalStats}})),children:[kt(Ud,{children:[q(Ie,{heading:!0,children:g("stats.scene")}),kt(Ie,{columns:2,children:[q("div",{children:g("stats.shapes")}),q("div",{children:s.length})]}),kt(Ie,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:b.width})]}),kt(Ie,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:b.height})]}),a&&kt(Yg,{children:[q(Ie,{heading:!0,children:"Canvas"}),q(Ie,{children:q(fT,{property:"gridStep",scene:l,appState:r,setAppState:m})})]})]}),t?.(s,r)]}),!y&&n.length>0&&q("div",{id:"elementStats",style:{marginTop:12},children:q(ua,{label:q("h3",{children:g("stats.elementProperties")}),open:!!(r.stats.panels&Gd.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Gd.elementProperties}})),children:kt(Ud,{children:[c&&kt(Yg,{children:[u&&q(Ie,{heading:!0,children:g("labels.unCroppedDimension")}),r.croppingElementId&&Ug(c)&&f&&kt(Ie,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:UT(f.width,2)})]}),r.croppingElementId&&Ug(c)&&f&&kt(Ie,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:UT(f.height,2)})]}),q(Ie,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:r.croppingElementId?g("labels.imageCropping"):g(`element.${c.type}`)}),q(Ie,{children:q(Hg,{element:c,property:"x",elementsMap:d,scene:l,appState:r})}),q(Ie,{children:q(Hg,{element:c,property:"y",elementsMap:d,scene:l,appState:r})}),q(Ie,{children:q(_g,{property:"width",element:c,scene:l,appState:r})}),q(Ie,{children:q(_g,{property:"height",element:c,scene:l,appState:r})}),!NF(c)&&q(Ie,{children:q(hT,{property:"angle",element:c,scene:l,appState:r})}),q(Ie,{children:q(CT,{property:"fontSize",element:c,scene:l,appState:r})})]}),p&&kt(Yg,{children:[FF(p)&&q(Ie,{heading:!0,children:g("element.group")}),kt(Ie,{columns:2,style:{margin:"0.3125rem 0"},children:[q("div",{children:g("stats.shapes")}),q("div",{children:n.length})]}),q(Ie,{children:q(zg,{property:"x",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),q(Ie,{children:q(zg,{property:"y",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),q(Ie,{children:q(Fg,{property:"width",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),q(Ie,{children:q(Fg,{property:"height",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:r})}),q(Ie,{children:q(PT,{property:"angle",elements:p,scene:l,appState:r})}),q(Ie,{children:q(OT,{property:"fontSize",elements:p,scene:l,appState:r,elementsMap:d})})]})]})})})]})})},(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 HF,useEffect as WT,useState as VT}from"react";import{normalizeLink as GF,KEYS as Wg}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as UF,getLinkIdAndTypeFromSelection as YF}from"@excalidraw/element";import{jsx as Bi,jsxs as Yd}from"react/jsx-runtime";var WF=({sourceElementId:e,onClose:o,appState:t,scene:n,generateLinkForSelection:r=UF})=>{let i=n.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=VT(a),[d,m]=VT(!1);WT(()=>{let p=j(i,t),u=a;if(p.length>0&&r){let f=YF(p,t);f&&(u=GF(r(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,r]);let c=HF(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&n.mutateElement(p,{link:l})}if(!l&&d&&e){let p=i.get(e);p&&n.mutateElement(p,{link:null})}o?.()},[e,l,i,d,n,o]);return WT(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===Wg.ENTER&&c(),t.openDialog?.name==="elementLinkSelector"&&u.key===Wg.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,c]),Yd("div",{className:"ElementLinkDialog",children:[Yd("div",{className:"ElementLinkDialog__header",children:[Bi("h2",{children:g("elementLink.title")}),Bi("p",{children:g("elementLink.desc")})]}),Yd("div",{className:"ElementLinkDialog__input",children:[Bi(gi,{value:l??"",onChange:p=>{d||m(!0),s(p)},onKeyDown:p=>{p.key===Wg.ENTER&&c()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Bi(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:()=>{s(null),m(!0)},className:"ElementLinkDialog__remove",icon:Lt})]}),Yd("div",{className:"ElementLinkDialog__actions",children:[Bi(No,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Bi(No,{label:g("buttons.confirm"),onClick:c,actionType:"primary"})]})]})},XT=WF;import VF,{useState as XF}from"react";import{Fragment as KF,jsx as Vg}from"react/jsx-runtime";var KT=({children:e,onClose:o})=>{let[t,n]=XF(!!e),{container:r}=Ge(),i=VF.useCallback(()=>{n(!1),o&&o(),r?.focus()},[o,r]);return Vg(KF,{children:t&&Vg(Be,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:Vg("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import ZF from"react";import{isDarwin as ZT,isFirefox as $T,isWindows as $F}from"@excalidraw/common";import{KEYS as Ae,getShortcutKey as X}from"@excalidraw/common";import{Fragment as qT,jsx as F,jsxs as Nt}from"react/jsx-runtime";var jF=()=>Nt("div",{className:"HelpDialog__header",children:[Nt("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:Cm}),g("helpDialog.documentation")]}),Nt("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:Cm}),g("helpDialog.blog")]}),Nt("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}),g("helpDialog.github")]}),Nt("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[F("div",{className:"HelpDialog__link-icon",children:lb}),"YouTube"]})]}),qF=e=>Nt(qT,{children:[F("h3",{children:e.title}),F("div",{className:"HelpDialog__islands-container",children:e.children})]}),Xg=e=>Nt("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*JF(e,o){let t=!0;for(let n of e)t||(yield o),t=!1,yield n}var QF=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),G=({label:e,shortcuts:o,isOr:t=!0})=>{let n=o.map(r=>(r.endsWith("++")?[...r.slice(0,-2).split("+"),"+"]:r.split("+")).map(a=>F(eO,{children:QF(a)},a)));return Nt("div",{className:"HelpDialog__shortcut",children:[F("div",{children:e}),F("div",{className:"HelpDialog__key-container",children:[...JF(n,t?g("helpDialog.or"):null)]})]})},eO=e=>F("kbd",{className:"HelpDialog__key",...e}),jT=({onClose:e})=>{let o=ZF.useCallback(()=>{e&&e()},[e]);return F(qT,{children:Nt(Be,{onCloseRequest:o,title:g("helpDialog.title"),className:"HelpDialog",children:[F(jF,{}),Nt(qF,{title:g("helpDialog.shortcuts"),children:[Nt(Xg,{className:"HelpDialog__island--tools",caption:g("helpDialog.tools"),children:[F(G,{label:g("toolBar.hand"),shortcuts:[Ae.H]}),F(G,{label:g("toolBar.selection"),shortcuts:[Ae.V,Ae[1]]}),F(G,{label:g("toolBar.rectangle"),shortcuts:[Ae.R,Ae[2]]}),F(G,{label:g("toolBar.diamond"),shortcuts:[Ae.D,Ae[3]]}),F(G,{label:g("toolBar.ellipse"),shortcuts:[Ae.O,Ae[4]]}),F(G,{label:g("toolBar.arrow"),shortcuts:[Ae.A,Ae[5]]}),F(G,{label:g("toolBar.line"),shortcuts:[Ae.L,Ae[6]]}),F(G,{label:g("toolBar.freedraw"),shortcuts:[Ae.P,Ae[7]]}),F(G,{label:g("toolBar.text"),shortcuts:[Ae.T,Ae[8]]}),F(G,{label:g("toolBar.image"),shortcuts:[Ae[9]]}),F(G,{label:g("toolBar.eraser"),shortcuts:[Ae.E,Ae[0]]}),F(G,{label:g("toolBar.frame"),shortcuts:[Ae.F]}),F(G,{label:g("toolBar.laser"),shortcuts:[Ae.K]}),F(G,{label:g("labels.eyeDropper"),shortcuts:[Ae.I,"Shift+S","Shift+G"]}),F(G,{label:g("helpDialog.editLineArrowPoints"),shortcuts:[X("CtrlOrCmd+Enter")]}),F(G,{label:g("helpDialog.editText"),shortcuts:[X("Enter")]}),F(G,{label:g("helpDialog.textNewLine"),shortcuts:[X("Enter"),X("Shift+Enter")]}),F(G,{label:g("helpDialog.textFinish"),shortcuts:[X("Esc"),X("CtrlOrCmd+Enter")]}),F(G,{label:g("helpDialog.curvedArrow"),shortcuts:["A",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),F(G,{label:g("helpDialog.curvedLine"),shortcuts:["L",g("helpDialog.click"),g("helpDialog.click"),g("helpDialog.click")],isOr:!1}),F(G,{label:g("helpDialog.cropStart"),shortcuts:[g("helpDialog.doubleClick"),X("Enter")],isOr:!0}),F(G,{label:g("helpDialog.cropFinish"),shortcuts:[X("Enter"),X("Escape")],isOr:!0}),F(G,{label:g("toolBar.lock"),shortcuts:[Ae.Q]}),F(G,{label:g("helpDialog.preventBinding"),shortcuts:[X("CtrlOrCmd")]}),F(G,{label:g("toolBar.link"),shortcuts:[X("CtrlOrCmd+K")]}),F(G,{label:g("toolBar.convertElementType"),shortcuts:["Tab","Shift+Tab"],isOr:!0})]}),Nt(Xg,{className:"HelpDialog__island--view",caption:g("helpDialog.view"),children:[F(G,{label:g("buttons.zoomIn"),shortcuts:[X("CtrlOrCmd++")]}),F(G,{label:g("buttons.zoomOut"),shortcuts:[X("CtrlOrCmd+-")]}),F(G,{label:g("buttons.resetZoom"),shortcuts:[X("CtrlOrCmd+0")]}),F(G,{label:g("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),F(G,{label:g("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),F(G,{label:g("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),F(G,{label:g("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),F(G,{label:g("buttons.zenMode"),shortcuts:[X("Alt+Z")]}),F(G,{label:g("buttons.objectsSnapMode"),shortcuts:[X("Alt+S")]}),F(G,{label:g("labels.toggleGrid"),shortcuts:[X("CtrlOrCmd+'")]}),F(G,{label:g("labels.viewMode"),shortcuts:[X("Alt+R")]}),F(G,{label:g("labels.toggleTheme"),shortcuts:[X("Alt+Shift+D")]}),F(G,{label:g("stats.fullTitle"),shortcuts:[X("Alt+/")]}),F(G,{label:g("search.title"),shortcuts:[Ne("searchMenu")]}),F(G,{label:g("commandPalette.title"),shortcuts:$T?[Ne("commandPalette")]:[Ne("commandPalette"),Ne("commandPalette",1)]})]}),Nt(Xg,{className:"HelpDialog__island--editor",caption:g("helpDialog.editor"),children:[F(G,{label:g("helpDialog.createFlowchart"),shortcuts:[X("CtrlOrCmd+Arrow Key")],isOr:!0}),F(G,{label:g("helpDialog.navigateFlowchart"),shortcuts:[X("Alt+Arrow Key")],isOr:!0}),F(G,{label:g("labels.moveCanvas"),shortcuts:[X(`Space+${g("helpDialog.drag")}`),X(`Wheel+${g("helpDialog.drag")}`)],isOr:!0}),F(G,{label:g("buttons.clearReset"),shortcuts:[X("CtrlOrCmd+Delete")]}),F(G,{label:g("labels.delete"),shortcuts:[X("Delete")]}),F(G,{label:g("labels.cut"),shortcuts:[X("CtrlOrCmd+X")]}),F(G,{label:g("labels.copy"),shortcuts:[X("CtrlOrCmd+C")]}),F(G,{label:g("labels.paste"),shortcuts:[X("CtrlOrCmd+V")]}),F(G,{label:g("labels.pasteAsPlaintext"),shortcuts:[X("CtrlOrCmd+Shift+V")]}),F(G,{label:g("labels.selectAll"),shortcuts:[X("CtrlOrCmd+A")]}),F(G,{label:g("labels.multiSelect"),shortcuts:[X(`Shift+${g("helpDialog.click")}`)]}),F(G,{label:g("helpDialog.deepSelect"),shortcuts:[X(`CtrlOrCmd+${g("helpDialog.click")}`)]}),F(G,{label:g("helpDialog.deepBoxSelect"),shortcuts:[X(`CtrlOrCmd+${g("helpDialog.drag")}`)]}),(Xr||$T)&&F(G,{label:g("labels.copyAsPng"),shortcuts:[X("Shift+Alt+C")]}),F(G,{label:g("labels.copyStyles"),shortcuts:[X("CtrlOrCmd+Alt+C")]}),F(G,{label:g("labels.pasteStyles"),shortcuts:[X("CtrlOrCmd+Alt+V")]}),F(G,{label:g("labels.sendToBack"),shortcuts:[ZT?X("CtrlOrCmd+Alt+["):X("CtrlOrCmd+Shift+[")]}),F(G,{label:g("labels.bringToFront"),shortcuts:[ZT?X("CtrlOrCmd+Alt+]"):X("CtrlOrCmd+Shift+]")]}),F(G,{label:g("labels.sendBackward"),shortcuts:[X("CtrlOrCmd+[")]}),F(G,{label:g("labels.bringForward"),shortcuts:[X("CtrlOrCmd+]")]}),F(G,{label:g("labels.alignTop"),shortcuts:[X("CtrlOrCmd+Shift+Up")]}),F(G,{label:g("labels.alignBottom"),shortcuts:[X("CtrlOrCmd+Shift+Down")]}),F(G,{label:g("labels.alignLeft"),shortcuts:[X("CtrlOrCmd+Shift+Left")]}),F(G,{label:g("labels.alignRight"),shortcuts:[X("CtrlOrCmd+Shift+Right")]}),F(G,{label:g("labels.duplicateSelection"),shortcuts:[X("CtrlOrCmd+D"),X(`Alt+${g("helpDialog.drag")}`)]}),F(G,{label:g("helpDialog.toggleElementLock"),shortcuts:[X("CtrlOrCmd+Shift+L")]}),F(G,{label:g("buttons.undo"),shortcuts:[X("CtrlOrCmd+Z")]}),F(G,{label:g("buttons.redo"),shortcuts:$F?[X("CtrlOrCmd+Y"),X("CtrlOrCmd+Shift+Z")]:[X("CtrlOrCmd+Shift+Z")]}),F(G,{label:g("labels.group"),shortcuts:[X("CtrlOrCmd+G")]}),F(G,{label:g("labels.ungroup"),shortcuts:[X("CtrlOrCmd+Shift+G")]}),F(G,{label:g("labels.flipHorizontal"),shortcuts:[X("Shift+H")]}),F(G,{label:g("labels.flipVertical"),shortcuts:[X("Shift+V")]}),F(G,{label:g("labels.showStroke"),shortcuts:[X("S")]}),F(G,{label:g("labels.showBackground"),shortcuts:[X("G")]}),F(G,{label:g("labels.showFonts"),shortcuts:[X("Shift+F")]}),F(G,{label:g("labels.decreaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+<")]}),F(G,{label:g("labels.increaseFontSize"),shortcuts:[X("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as e5,useRef as aO,useState as Mn}from"react";import{DEFAULT_EXPORT_PADDING as lO,EXPORT_IMAGE_TYPES as Kg,isFirefox as sO,EXPORT_SCALES as cO,cloneJSON as t5}from"@excalidraw/common";import{useCallback as tO,useRef as oO,useState as nO}from"react";var rO=2e3,JT=()=>{let[e,o]=nO(null),t=oO(0),n=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},rO)},r=tO(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:r,onCopy:n}};import iO from"clsx";import{jsx as QT}from"react/jsx-runtime";var ll=({title:e,name:o,checked:t,onChange:n,disabled:r=!1})=>QT("div",{className:iO("Switch",{toggled:t,disabled:r}),children:QT("input",{name:o,id:o,title:e,type:"checkbox",checked:t,disabled:r,onChange:()=>n(!t),onKeyDown:i=>{i.key===" "&&n(!t)}})});import{jsx as Ce,jsxs as Ln}from"react/jsx-runtime";var dO="filter"in document.createElement("canvas").getContext("2d"),mO=()=>Ln("div",{children:[Ce("h3",{children:g("canvasError.cannotShowPreview")}),Ce("p",{children:Ce("span",{children:g("canvasError.canvasTooBig")})}),Ln("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),pO=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:n,onExportImage:r,name:i})=>{let a=Ee(o,e),[l,s]=Mn(i),[d,m]=Mn(a),[c,p]=Mn(e.exportBackground),[u,f]=Mn(e.exportWithDarkMode),[b,x]=Mn(e.exportEmbedScene),[w,E]=Mn(e.exportScale),y=aO(null),[v,C]=Mn(null),{onCopy:S,copyStatus:L,resetCopyStatus:k}=JT();e5(()=>{k()},[l,c,u,w,b,k]);let{exportedElements:A,exportingFrame:P}=Kn(o,e,d);return e5(()=>{let N=y.current;if(!N)return;let O=N.offsetWidth,U=N.offsetHeight;O&&mn({elements:A,appState:{...e,name:l,exportBackground:c,exportWithDarkMode:u,exportScale:w,exportEmbedScene:b},files:t,exportPadding:lO,maxWidthOrHeight:Math.max(O,U),exportingFrame:P}).then(J=>(C(null),ko(J).then(()=>{N.replaceChildren(J)}).catch(_=>{throw _.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(g("canvasError.canvasTooBig")):_}))).catch(J=>{console.error(J),C(J)})},[e,t,A,P,l,c,u,w,b]),Ln("div",{className:"ImageExportModal",children:[Ce("h3",{children:g("imageExportDialog.header")}),Ln("div",{className:"ImageExportModal__preview",children:[Ce("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Ce(mO,{})}),Ce("div",{className:"ImageExportModal__preview__filename",children:!fr&&Ce("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:N=>{s(N.target.value),n.executeAction(Vp,"ui",N.target.value)}})})]}),Ln("div",{className:"ImageExportModal__settings",children:[Ce("h3",{children:g("imageExportDialog.header")}),a&&Ce(sl,{label:g("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Ce(ll,{name:"exportOnlySelected",checked:d,onChange:N=>{m(N)}})}),Ce(sl,{label:g("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Ce(ll,{name:"exportBackgroundSwitch",checked:c,onChange:N=>{p(N),n.executeAction(Xp,"ui",N)}})}),dO&&Ce(sl,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ce(ll,{name:"exportDarkModeSwitch",checked:u,onChange:N=>{f(N),n.executeAction(qx,"ui",N)}})}),Ce(sl,{label:g("imageExportDialog.label.embedScene"),tooltip:g("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Ce(ll,{name:"exportEmbedSwitch",checked:b,onChange:N=>{x(N),n.executeAction(Xs,"ui",N)}})}),Ce(sl,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Ce(fd,{name:"exportScale",value:w,onChange:N=>{E(N),n.executeAction(jx,"ui",N)},choices:cO.map(N=>({value:N,label:`${N}\xD7`}))})}),Ln("div",{className:"ImageExportModal__settings__buttons",children:[Ce(vn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>r(Kg.png,A,{exportingFrame:P}),icon:Gm,children:g("imageExportDialog.button.exportToPng")}),Ce(vn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>r(Kg.svg,A,{exportingFrame:P}),icon:Gm,children:g("imageExportDialog.button.exportToSvg")}),(Xr||sO)&&Ce(vn,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:L,onClick:async()=>{await r(Kg.clipboard,A,{exportingFrame:P}),S()},icon:Sr,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},sl=({label:e,children:o,tooltip:t,name:n})=>Ln("div",{className:"ImageExportModal__settings__setting",title:e,children:[Ln("label",{htmlFor:n,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ce(At,{label:t,long:!0,children:H0})]}),Ce("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),o5=({elements:e,appState:o,files:t,actionManager:n,onExportImage:r,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Mn(()=>({appStateSnapshot:t5(o),elementsSnapshot:t5(e)}));return Ce(Be,{onCloseRequest:i,size:"wide",title:!1,children:Ce(pO,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:n,onExportImage:r,name:a})})};import hO from"react";import{getFrame as gO}from"@excalidraw/common";import Zg from"open-color";import{jsx as uO}from"react/jsx-runtime";var $g=({children:e,color:o})=>uO("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":Zg[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":Zg[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":Zg[o][9]},children:e});import{Fragment as bO,jsx as co,jsxs as Wd}from"react/jsx-runtime";var fO=({elements:e,appState:o,setAppState:t,files:n,actionManager:r,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return co("div",{className:"ExportDialog ExportDialog--json",children:Wd("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Wd($g,{color:"lime",children:[co("div",{className:"Card-icon",children:Z1}),co("h2",{children:g("exportDialog.disk_title")}),Wd("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!fr&&r.renderAction("changeProjectName")]}),co(K,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{r.executeAction(Ia,"ui")}})]}),s&&Wd($g,{color:"pink",children:[co("div",{className:"Card-icon",children:Ji}),co("h2",{children:g("exportDialog.link_title")}),co("div",{className:"Card-details",children:g("exportDialog.link_details")}),co(K,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{ne("export","link",`ui (${gO()})`),await s(e,o,n),l()}catch(d){t({errorMessage:d.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,n,a)]})})},n5=({elements:e,appState:o,files:t,actionManager:n,exportOpts:r,canvas:i,setAppState:a})=>{let l=hO.useCallback(()=>{a({openDialog:null})},[a]);return co(bO,{children:o.openDialog?.name==="jsonExport"&&co(Be,{onCloseRequest:l,title:g("buttons.export"),children:co(fO,{elements:e,appState:o,setAppState:a,files:t,actionManager:n,onCloseRequest:l,exportOpts:r,canvas:i})})})};import xO from"clsx";import{jsx as r5,jsxs as yO}from"react/jsx-runtime";var EO="small",i5=e=>yO("label",{className:xO("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${EO}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[r5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),r5("div",{className:"ToolIcon__icon",children:ea})]});import{Fragment as s5,jsx as $,jsxs as Bt}from"react/jsx-runtime";var MO=({UIOptions:e})=>Bt(dt,{__fallback:!0,children:[$(dt.DefaultItems.LoadScene,{}),$(dt.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&$(dt.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&$(dt.DefaultItems.SaveAsImage,{}),$(dt.DefaultItems.SearchMenu,{}),$(dt.DefaultItems.Help,{}),$(dt.DefaultItems.ClearCanvas,{}),$(dt.Separator,{}),$(dt.Group,{title:"Excalidraw links",children:$(dt.DefaultItems.Socials,{})}),$(dt.Separator,{}),$(dt.DefaultItems.ToggleTheme,{}),$(dt.DefaultItems.ChangeCanvasBackground,{})]}),LO=()=>Bt(yd,{__fallback:!0,children:[$(yd.Actions.SaveToDisk,{}),$(yd.Actions.ExportToImage,{})]}),PO=({actionManager:e,appState:o,files:t,setAppState:n,elements:r,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:d,renderTopRightUI:m,renderCustomStats:c,UIOptions:p,onExportImage:u,renderWelcomeScreen:f,children:b,app:x,isCollaborating:w,generateLinkForSelection:E})=>{let y=se(),v=d2(),C=v.tunnelsJotai.Provider,[S,L]=ie(tn),k=()=>p.canvasActions.export?$(n5,{elements:r,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:n}):null,A=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:$(o5,{elements:r,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>n({openDialog:null}),name:x.getName()}),P=()=>Bt("div",{style:{position:"relative"},children:[$(v.MainMenuTunnel.Out,{}),f&&$(v.WelcomeScreenMenuHintTunnel.Out,{})]}),N=()=>$(En,{heading:"selectedShapeActions",className:cl("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:$(Xe,{className:vO.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:$(Ac,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),O=()=>{let R=SO(o,r),V=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return $(sd,{side:"top",children:Bt("div",{className:"App-menu App-menu_top",children:[Bt(qe.Col,{gap:6,className:cl("App-menu_top__left"),children:[P(),R&&N()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&$(En,{heading:"shapes",className:"shapes-section",children:Z=>Bt("div",{style:{position:"relative"},children:[f&&$(v.WelcomeScreenToolbarHintTunnel.Out,{}),$(qe.Col,{gap:4,align:"start",children:Bt(qe.Row,{gap:1,className:cl("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Bt(Xe,{padding:1,className:cl("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[$(dd,{appState:o,isMobile:y.editor.isMobile,device:y,app:x}),Z,Bt(qe.Row,{gap:1,children:[$(md,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),$(ld,{checked:o.activeTool.locked,onChange:a,title:g("toolBar.lock")}),$("div",{className:"App-toolbar__divider"}),$(cd,{checked:qt(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),$(Dc,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),w&&$(Xe,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:$(i5,{title:g("toolBar.laser"),checked:o.activeTool.type===a5.laser,onChange:()=>x.setActiveTool({type:a5.laser}),isMobile:!0})})]})})]})}),Bt("div",{className:cl("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&$(hd,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),m?.(y.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!J||o.openSidebar?.name!==jg.name)&&$(v.DefaultSidebarTriggerTunnel.Out,{}),V&&$(al,{app:x,onClose:()=>{e.executeAction(oi)},renderCustomStats:c})]})]})})},U=()=>$(Td,{__fallback:!0,onDock:R=>{ne("sidebar",`toggleDock (${R?"dock":"undock"})`,`(${y.editor.isMobile?"mobile":"desktop"})`)}}),J=Ol(Qa),_=Bt(s5,{children:[b,$(MO,{UIOptions:p}),$(Td.Trigger,{__fallback:!0,icon:wr,title:IO(g("toolBar.library")),onToggle:R=>{R&&ne("sidebar",`${jg.name} (open)`,`button (${y.editor.isMobile?"mobile":"desktop"})`)},tab:jg.defaultTab,children:g("toolBar.library")}),$(LO,{}),o.openDialog?.name==="ttd"&&$(kg,{__fallback:!0}),o.isLoading&&$(ad,{delay:250}),o.errorMessage&&$(KT,{onClose:()=>n({errorMessage:null}),children:o.errorMessage}),S&&!y.editor.isMobile&&$(Cb,{colorPickerType:S.colorPickerType,onCancel:()=>{L(null)},onChange:(R,V,Z,{altKey:W})=>{if(!(R!=="elementBackground"&&R!=="elementStroke"))if(Z.length){for(let ce of Z)CO(ce,TO(r),{[W&&S.swapPreviewOnAlt?R==="elementBackground"?"strokeColor":"backgroundColor":R==="elementBackground"?"backgroundColor":"strokeColor"]:V}),kO.delete(ce);x.scene.triggerUpdate()}else n(R==="elementBackground"?{currentItemBackgroundColor:V}:{currentItemStrokeColor:V})},onSelect:(R,V)=>{L(Z=>Z?.keepOpenOnAlt&&V.altKey?Z:null),S?.onSelect?.(R,V)}}),o.openDialog?.name==="help"&&$(jT,{onClose:()=>{n({openDialog:null})}}),$(E2,{}),o.openDialog?.name==="elementLinkSelector"&&$(XT,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{n({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:E}),$(v.OverwriteConfirmDialogTunnel.Out,{}),A(),k(),o.pasteDialog.shown&&$(zv,{setAppState:n,appState:o,onClose:()=>n({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&$(Fv,{app:x,appState:o,elements:r,actionManager:e,renderJSONExportDialog:k,renderImageExportDialog:A,setAppState:n,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:m,renderCustomStats:c,renderSidebars:U,device:y,renderWelcomeScreen:f,UIOptions:p}),!y.editor.isMobile&&Bt(s5,{children:[Bt("div",{className:"layer-ui__wrapper",style:o.openSidebar&&J&&y.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[f&&$(v.WelcomeScreenCenterTunnel.Out,{}),O(),$(Yv,{appState:o,actionManager:e,showExitZenModeBtn:d,renderWelcomeScreen:f}),o.scrolledOutside&&$("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{n(R=>({...Fn(r,R)}))},children:g("buttons.scrollBackToContent")})]}),U()]})]});return $(op.Provider,{value:o,children:$(C,{children:$(eh.Provider,{value:v,children:_})})})},l5=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:n,scrollX:r,scrollY:i,...a}=e;return a},AO=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:n,...r}=e,{canvas:i,appState:a,...l}=o;return Vd(l5(n),l5(a),{selectedElementIds:Vd,selectedGroupIds:Vd})&&Vd(r,l)},c5=wO.memo(PO,AO);import DO from"clsx";import{jsx as d5,jsxs as RO}from"react/jsx-runtime";var _O="small",Xd=e=>RO("label",{className:DO("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${_O}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[d5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),d5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as NO,useRef as BO}from"react";import{jsx as m5}from"react/jsx-runtime";var p5=({trails:e})=>{let o=BO(null);return NO(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),m5("div",{className:"SVGLayer",children:m5("svg",{ref:o})})};import FO,{useEffect as OO,useRef as zO}from"react";import{CURSOR_TYPE as u5,isShallowEqual as HO,sceneCoordsToViewportCoords as GO}from"@excalidraw/common";import{jsx as WO}from"react/jsx-runtime";var UO=e=>{let o=zO(!1);return OO(()=>{if(!o.current){o.current=!0;return}let t=new Map,n=new Map,r=new Map,i=new Map,a=new Map;e.appState.collaborators.forEach((s,d)=>{if(s.selectedElementIds)for(let m of Object.keys(s.selectedElementIds))r.has(m)||r.set(m,[]),r.get(m).push(d);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(d,s.username),s.userState&&a.set(d,s.userState),n.set(d,GO({sceneX:s.pointer.x,sceneY:s.pointer.y},e.appState)),t.set(d,s.button))});let l=e.containerRef?.current&&getComputedStyle(e.containerRef.current).getPropertyValue("--color-selection")||"#6965db";$w({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:t,remoteSelectedElementIds:r,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:e.renderScrollbars},device:e.device,callback:e.renderInteractiveSceneCallback},Si())}),WO("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?u5.GRAB:u5.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:g("labels.drawingCanvas")})},h5=e=>({zoom:e.zoom,scrollX:e.scrollX,scrollY:e.scrollY,width:e.width,height:e.height,viewModeEnabled:e.viewModeEnabled,openDialog:e.openDialog,editingGroupId:e.editingGroupId,selectedElementIds:e.selectedElementIds,frameToHighlight:e.frameToHighlight,offsetLeft:e.offsetLeft,offsetTop:e.offsetTop,theme:e.theme,selectionElement:e.selectionElement,selectedGroupIds:e.selectedGroupIds,selectedLinearElement:e.selectedLinearElement,multiElement:e.multiElement,isBindingEnabled:e.isBindingEnabled,suggestedBindings:e.suggestedBindings,isRotating:e.isRotating,elementsToHighlight:e.elementsToHighlight,collaborators:e.collaborators,activeEmbeddable:e.activeEmbeddable,snapLines:e.snapLines,zenModeEnabled:e.zenModeEnabled,editingTextElement:e.editingTextElement,isCropping:e.isCropping,croppingElementId:e.croppingElementId,searchMatches:e.searchMatches,activeLockedId:e.activeLockedId}),YO=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements||e.renderScrollbars!==o.renderScrollbars?!1:HO(h5(e.appState),h5(o.appState)),qg=FO.memo(UO,YO);import VO,{useEffect as g5,useRef as f5}from"react";import{isShallowEqual as b5}from"@excalidraw/common";import{jsx as ZO}from"react/jsx-runtime";var XO=e=>{let o=f5(null),t=f5(!1);return g5(()=>{e.canvas.style.width=`${e.appState.width}px`,e.canvas.style.height=`${e.appState.height}px`,e.canvas.width=e.appState.width*e.scale,e.canvas.height=e.appState.height*e.scale},[e.appState.height,e.appState.width,e.canvas,e.scale]),g5(()=>{let n=o.current;if(!n)return;let r=e.canvas;t.current||(t.current=!0,n.replaceChildren(r),r.classList.add("excalidraw__canvas","static")),c1({canvas:r,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Si())}),ZO("div",{className:"excalidraw__canvas-wrapper",ref:o})},x5=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}),KO=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:b5(x5(e.appState),x5(o.appState))&&b5(e.renderConfig,o.renderConfig),Jg=VO.memo(XO,KO);import{useEffect as tz,useRef as oz}from"react";import{throttleRAF as $O}from"@excalidraw/common";import{getTargetFrame as jO,isInvisiblySmallElement as qO,renderElement as JO,shouldApplyFrameClip as QO}from"@excalidraw/element";var E5=({canvas:e,rc:o,newElement:t,elementsMap:n,allElementsMap:r,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,d]=Al(e,i),m=Dl({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:d});if(m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"){if(qO(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=jO(t,n,a);p&&QO(t,p,a,n)&&l1(p,m,l,a)}JO(t,n,r,o,m,l,a)}else m.clearRect(0,0,s,d);m.restore()}},ez=$O(e=>{E5(e)},{trailing:!0}),y5=(e,o)=>{if(o){ez(e);return}E5(e)};import{jsx as rz}from"react/jsx-runtime";var nz=e=>{let o=oz(null);return tz(()=>{o.current&&y5({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},Si())}),rz("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})},w5=nz;import{useCallback as iz,useEffect as az,useRef as lz}from"react";import{jsx as v5,jsxs as cz}from"react/jsx-runtime";var sz=5e3,T5=({message:e,onClose:o,closable:t=!1,duration:n=sz,style:r})=>{let i=lz(0),a=n!==1/0,l=iz(()=>{a&&(i.current=window.setTimeout(()=>o(),n))},[o,n,a]);return az(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,n,a]),cz("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:r,children:[v5("p",{className:"Toast__message",children:e}),t&&v5(K,{icon:Ft,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as dz,getElementsInGroup as mz,selectGroupsFromGivenElements as pz}from"@excalidraw/element";import{sceneCoordsToViewportCoords as uz}from"@excalidraw/common";import{flushSync as hz}from"react-dom";import{jsx as fz}from"react/jsx-runtime";var gz=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),n=t?[t]:mz(e.scene.getNonDeletedElementsMap(),o);if(n.length===0)return null;let[r,i]=dz(n),{x:a,y:l}=uz({sceneX:r,sceneY:i},e.state);return fz("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{hz(()=>{let s=pz(n,e.state);e.setState({selectedElementIds:n.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(La)},title:g("labels.elementLock.unlock"),children:A1})},I5=gz;import{Fragment as pG,jsx as ue,jsxs as em}from"react/jsx-runtime";var SI=So.createContext(null),kI=So.createContext(null),MI={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},Af=So.createContext(MI);Af.displayName="DeviceContext";var Df=So.createContext({container:null,id:null});Df.displayName="ExcalidrawContainerContext";var _f=So.createContext([]);_f.displayName="ExcalidrawElementsContext";var Rf=So.createContext({...jo(),width:0,height:0,offsetLeft:0,offsetTop:0});Rf.displayName="ExcalidrawAppStateContext";var Nf=So.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Nf.displayName="ExcalidrawSetAppStateContext";var Bf=So.createContext(null);Bf.displayName="ExcalidrawActionManagerContext";var Re=()=>Nn(SI),fo=()=>Nn(kI),se=()=>Nn(Af),Ge=()=>Nn(Df),on=()=>Nn(_f),go=()=>Nn(Rf),le=()=>Nn(Nf),Ue=()=>Nn(Bf),bl=!1,Sf=0,xl=null,mr=!1,El=!1,kf=!1,yl={horizontal:null,vertical:null},Rn=0,wl=!1,Mf=new Map,Qd=!1,vI=0,TI=!1,vl=null,pe={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Pf=class e extends So.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",MI);I(this,"excalidrawContainerRef",So.createRef());I(this,"scene");I(this,"fonts");I(this,"renderer");I(this,"visibleElements");I(this,"resizeObserver");I(this,"nearestScrollableContainer");I(this,"library");I(this,"libraryItemsFromStorage");I(this,"id");I(this,"store");I(this,"history");I(this,"excalidrawContainerValue");I(this,"files",{});I(this,"imageCache",new Map);I(this,"iFrameRefs",new Map);I(this,"embedsValidationStatus",new Map);I(this,"initializedEmbeds",new Set);I(this,"handleToastClose",()=>{this.setToast(null)});I(this,"elementsPendingErasure",new Set);I(this,"flowChartCreator",new zH);I(this,"flowChartNavigator",new HH);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 Xc);I(this,"laserTrails",new td(this.animationFrameHandler,this));I(this,"eraserTrail",new id(this.animationFrameHandler,this));I(this,"lassoTrail",new rd(this.animationFrameHandler,this));I(this,"onChangeEmitter",new lr);I(this,"onPointerDownEmitter",new lr);I(this,"onPointerUpEmitter",new lr);I(this,"onUserFollowEmitter",new lr);I(this,"onScrollChangeEmitter",new lr);I(this,"missingPointerEventCleanupEmitter",new lr);I(this,"onRemoveEventListenersEmitter",new lr);I(this,"defaultSelectionTool","selection");I(this,"updateEditorAtom",(t,...n)=>{let r=He.set(t,...n);return this.triggerRender(),r});I(this,"getEffectiveGridSize",()=>fn(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,n)=>{this.embedsValidationStatus.set(t.id,n),fl.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,n=!1;this.scene.getNonDeletedElements().filter(r=>{if(Xo(r)){if(t.add(r.id),!this.embedsValidationStatus.has(r.id)){n=!0;let i=bf(r.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(r,i)}}else Gi(r)&&t.add(r.id);return!1}),n&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((r,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});I(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);I(this,"frameNameBoundsCache",{get:t=>{let n=this.frameNameBoundsCache._cache.get(t.id);if(!n||n.zoom!==this.state.zoom.value||n.versionNonce!==t.versionNonce){let r=document.getElementById(this.getFrameNameDOMId(t));if(r){let i=r.getBoundingClientRect(),a=Oe({clientX:i.x,clientY:i.y},this.state),l=Oe({clientX:i.right,clientY:i.bottom},this.state);return n={x:a.x,y:a.y,width:l.x-a.x,height:l.y-a.y,angle:0,zoom:this.state.zoom.value,versionNonce:t.versionNonce},this.frameNameBoundsCache._cache.set(t.id,n),n}return null}return n},_cache:new Map});I(this,"resetEditingFrame",t=>{t&&this.scene.mutateElement(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});I(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===$d.DARK,n=this.scene.getNonDeletedFramesLikes(),r=n.length>0&&this.state.searchMatches?.focusedId&&Mt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return n.map(i=>{if(!oI(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}=qd({sceneX:i.x,sceneY:i.y},this.state),s=6,d,m=_H(i);if(i.id===this.state.editingFrame){let c=m;d=ue("input",{autoFocus:!0,value:c,onChange:p=>{this.scene.mutateElement(i,{name:p.target.value})},onFocus:p=>p.target.select(),onBlur:()=>this.resetEditingFrame(i),onKeyDown:p=>{(p.key===Y.ESCAPE||p.key===Y.ENTER)&&this.resetEditingFrame(i)},style:{background:this.state.viewBackgroundColor,filter:t?Bz:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${An.nameFontSize}px`,transform:`translate(-${s}px, ${s}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-a-s}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else d=m;return ue("div",{id:this.getFrameNameDOMId(i),style:{position:"absolute",bottom:`${this.state.height+An.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:An.nameFontSize,color:t?An.nameColorDarkTheme:An.nameColorLightTheme,lineHeight:An.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:De.MOVE,pointerEvents:this.state.viewModeEnabled?Oi.disabled:Oi.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:i.id})},children:d},i.id)})});I(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});I(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());I(this,"getSceneElementsMapIncludingDeleted",()=>this.scene.getElementsMapIncludingDeleted());I(this,"getSceneElements",()=>this.scene.getNonDeletedElements());I(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});I(this,"onExportImage",async(t,n,r)=>{ne("export",t,"ui");let i=await Zn(t,n,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:r.exportingFrame}).catch(Jz).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Rl(i)&&this.setState({fileHandle:i})});I(this,"magicGenerations",new Map);I(this,"updateMagicGeneration",({frameElement:t,data:n})=>{n.status==="pending"?this.scene.mutateElement(t,{customData:{generationData:void 0}},{informMutation:!1,isDragging:!1}):this.scene.mutateElement(t,{customData:{generationData:n}},{informMutation:!1,isDragging:!1}),this.magicGenerations.set(t.id,n),this.triggerRender()});I(this,"plugins",{});I(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:Co.magicframe}),ne("ai","tool-select (empty-selection)","d2c");else{let n=t.length===1&&gf(t[0])&&t[0];if(!n&&t.some(i=>Mt(i)||i.frameId)){this.setActiveTool({type:Co.magicframe});return}ne("ai","tool-select (existing selection)","d2c");let r;if(n)r=n;else{let[i,a,l,s]=Hi(t),d=50;r=Z5({...An,x:i-d,y:a-d,width:l-i+d*2,height:s-a+d*2,opacity:100,locked:!1}),this.scene.insertElement(r);for(let m of t)this.scene.mutateElement(m,{frameId:r.id});this.setState({selectedElementIds:{[r.id]:!0}})}this.onMagicFrameGenerate(r,"upstream")}});I(this,"openEyeDropper",({type:t})=>{this.updateEditorAtom(tn,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(n,r)=>{let i=t==="background"&&r.altKey||t==="stroke"&&!r.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:n},captureUpdate:mt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:n},captureUpdate:mt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?sr(l,{[i?"strokeColor":"backgroundColor"]:n}):l),captureUpdate:mt.IMMEDIATELY})},keepOpenOnAlt:!1})});I(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,isEditing:!1}})})});I(this,"syncActionResult",Pe(t=>{if(this.unmounted||t===!1)return;this.store.scheduleAction(t.captureUpdate);let n=!1,r=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),n=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||r||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||$d.LIGHT,s=t?.appState?.name??this.state.name,d=t?.appState?.errorMessage??this.state.errorMessage;typeof this.props.viewModeEnabled<"u"&&(i=this.props.viewModeEnabled),typeof this.props.zenModeEnabled<"u"&&(a=this.props.zenModeEnabled),r=t.appState?.editingTextElement||null,t.elements&&r&&t.elements.forEach(m=>{r?.id===m.id&&r!==m&&EI(m)&&mo(m)&&(r=m)}),r?.isDeleted&&(r=null),this.setState(m=>{let c=t.appState||{};return{...m,...c,contextMenu:null,editingTextElement:r,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:d}}),n=!0}n||this.scene.triggerUpdate()}));I(this,"onBlur",Pe(()=>{mr=!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",Pe(t=>{this.scene.replaceAllElements([]),this.setState(n=>({...jo(),isLoading:t?.resetLoadingState?!1:n.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));I(this,"initializeScene",async()=>{"launchQueue"in window&&"LaunchParams"in window&&window.launchQueue.setConsumer(async i=>{if(!i.files.length)return;let a=i.files[0],l=await a.getFile();this.loadFileToCanvas(new File([l],l.name||"",{type:l.type}),a)}),this.props.theme&&this.setState({theme:this.props.theme}),this.state.isLoading||this.setState({isLoading:!0});let t=null;try{typeof this.props.initialData=="function"?t=await this.props.initialData()||null:t=await this.props.initialData||null,t?.libraryItems&&this.library.updateLibrary({libraryItems:t.libraryItems,merge:!0}).catch(i=>{console.error(i)})}catch(i){console.error(i),t={appState:{errorMessage:i.message||"Encountered an error during importing or restoring scene data"}}}let n=xr(t,null,null,{repairBindings:!0,deleteInvisibleElements:!0}),r=n.appState.activeTool;n.appState={...n.appState,theme:this.props.theme||n.appState.theme,openSidebar:n.appState?.openSidebar||this.state.openSidebar,activeTool:r.type==="image"||r.type==="lasso"||r.type==="selection"?{...r,type:this.defaultSelectionTool}:n.appState.activeTool,isLoading:!1,toast:this.state.toast},t?.scrollToContent&&(n.appState={...n.appState,...Fn(n.elements,{...n.appState,width:this.state.width,height:this.state.height,offsetTop:this.state.offsetTop,offsetLeft:this.state.offsetLeft})}),this.resetStore(),this.resetHistory(),this.syncActionResult({...n,captureUpdate:mt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(i=>{this.fonts.onLoaded(i)}),If(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileOrTablet",()=>{let t="ontouchstart"in window||navigator.maxTouchPoints>0,n="matchMedia"in window&&window?.matchMedia("(pointer: coarse)")?.matches;return rH||t&&n});I(this,"isMobileBreakpoint",(t,n)=>t<Az||n<Lz&&t<Pz);I(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:n,clientHeight:r}=document.body,i=this.device.viewport,a=lf(i,{isLandscape:n>r,isMobile:this.isMobileBreakpoint(n,r)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});I(this,"refreshEditorBreakpoints",()=>{let t=this.excalidrawContainerRef.current;if(!t)return;let{width:n,height:r}=t.getBoundingClientRect(),i=this.props.UIOptions.dockedSidebarBreakpoint!=null?this.props.UIOptions.dockedSidebarBreakpoint:Dz,a=this.device.editor,l=lf(a,{isMobile:this.isMobileBreakpoint(n,r),canFitSidebar:n>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});I(this,"onResize",Pe(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>fl.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),B5||this.refreshEditorBreakpoints(),this.setState({})}));I(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});I(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:n,elementsMap:r})=>{n&&(yl=n);let i=this.state.editingTextElement?!1:!t&&r.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",z5(()=>{let{offsetTop:t,offsetLeft:n}=this.getCanvasOffsets();this.setState(r=>r.offsetLeft===n&&r.offsetTop===t?null:{offsetTop:t,offsetLeft:n})},_z));I(this,"onCut",Pe(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ml(t.target)||(this.actionManager.executeAction(tc,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onCopy",Pe(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ml(t.target)||(this.actionManager.executeAction(ei,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(Hz&&t.preventDefault(),!bl){bl=!0,t.touches.length===1&&(xl={x:t.touches[0].clientX,y:t.touches[0].clientY}),clearTimeout(Sf),Sf=window.setTimeout(e.resetTapTwice,Rz);return}if(bl&&t.touches.length===1&&xl){let n=t.touches[0];Pn(re(n.clientX,n.clientY),re(xl.x,xl.y))<=iH&&(this.lassoTrail.endPath(),this.deselectElements(),this.handleCanvasDoubleClick({clientX:n.clientX,clientY:n.clientY})),bl=!1,clearTimeout(Sf)}t.touches.length===2&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null})});I(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}):pe.pointers.clear()});I(this,"pasteFromClipboard",Pe(async t=>{let n=!!Qd,r=document.activeElement,i=this.excalidrawContainerRef.current?.contains(r);if(t&&!i)return;let a=document.elementFromPoint(this.lastViewportPosition.x,this.lastViewportPosition.y);if(t&&(!(a instanceof HTMLCanvasElement)||ml(r)))return;let{x:l,y:s}=Oe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),d=t?.clipboardData?.files[0],m=await Ws(t,n);if(!d&&!n){if(m.mixedContent)return this.addElementsFromMixedContentPaste(m.mixedContent,{isPlainPaste:n,sceneX:l,sceneY:s});if(m.text){let c=m.text.trim();c.startsWith("<svg")&&c.endsWith("</svg>")&&(d=Em(c))}}if(Nl(d)&&!m.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:g("errors.imageToolNotSupported")});return}this.createImageElement({sceneX:l,sceneY:s,imageFile:d});return}if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(c){console.error(c)}if(m.errorMessage)this.setState({errorMessage:m.errorMessage});else if(m.spreadsheet&&!n)this.setState({pasteDialog:{data:m.spreadsheet,shown:!0}});else if(m.elements){let c=m.programmaticAPI?Ci(m.elements):m.elements;this.addElementsFromPasteOrLibrary({elements:c,files:m.files||null,position:this.isMobileOrTablet()?"center":"cursor",retainSeed:n})}else if(m.text){if(m.text&&cv(m.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:f,files:b}=await u.parseMermaidToExcalidraw(m.text),x=Ci(f,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:x,files:b,position:this.isMobileOrTablet()?"center":"cursor"});return}catch(f){console.warn(`parsing pasted text as mermaid definition failed: ${f.message}`)}}let c=eH(m.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=c.map(u=>TH(u)).filter(u=>bf(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||Jd(u)?.type==="video"));if(!Qd&&p.length>0&&p.length===c.length){let u=[];for(let f of p){let b=u[u.length-1],x=this.insertEmbeddableElement({sceneX:b?b.x+b.width+20:l,sceneY:s,link:nf(f)});x&&u.push(x)}u.length&&(this.store.scheduleCapture(),this.setState({selectedElementIds:Object.fromEntries(u.map(f=>[f.id,!0]))}));return}this.addTextFromPaste(m.text,n)}this.setActiveTool({type:this.defaultSelectionTool},!0),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let n=gm(t.elements,null,{deleteInvisibleElements:!0}),[r,i,a,l]=Hi(n),s=zi(r,a)/2,d=zi(i,l)/2,m=typeof t.position=="object"?t.position.clientX:t.position==="cursor"?this.lastViewportPosition.x:this.state.width/2+this.state.offsetLeft,c=typeof t.position=="object"?t.position.clientY:t.position==="cursor"?this.lastViewportPosition.y:this.state.height/2+this.state.offsetTop,{x:p,y:u}=Oe({clientX:m,clientY:c},this.state),f=p-s,b=u-d,[x,w]=rt(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=q5({type:"everything",elements:n.map(k=>sr(k,{x:k.x+x-r,y:k.y+w-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...E];v=this.props.onDuplicate?.(v,y)||v,hI(v,U5(E));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let k=NH(E,S);wf(v,k,S,this.state)}this.scene.replaceAllElements(v),E.forEach(k=>{if(mo(k)&&hf(k)){let A=lI(k,this.scene.getElementsMapIncludingDeleted());kH(k,A,this.scene)}}),Yz&&$o.loadElementsFonts(E).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let L=tG(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&He.get(Qa)?this.state.openSidebar:null,...$t({editingGroupId:null,selectedElementIds:L.reduce((k,A)=>(hf(A)||(k[A.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:this.defaultSelectionTool},!0),t.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,n)=>{this.setState(t,n)});I(this,"removePointer",t=>{Rn&&this.resetContextMenuTimer(),pe.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||ne("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(n=>({activeTool:{...n.activeTool,...Vo(this.state,n.activeTool.locked?{type:this.defaultSelectionTool}:n.activeTool),locked:!n.activeTool.locked}}))});I(this,"updateFrameRendering",t=>{this.setState(n=>{let r=typeof t=="function"?t(n.frameRendering):t;return{frameRendering:{enabled:r?.enabled??n.frameRendering.enabled,clip:r?.clip??n.frameRendering.clip,name:r?.name??n.frameRendering.name,outline:r?.outline??n.frameRendering.outline}}})});I(this,"togglePenMode",t=>{this.setState(n=>({penMode:t??!n.penMode,penDetected:!0}))});I(this,"onHandToolToggle",()=>{this.actionManager.executeAction(vx)});I(this,"zoomCanvas",t=>{this.setState({...Ao({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:uo(t)},this.state)})});I(this,"cancelInProgressAnimation",null);I(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),n)=>{if(typeof t=="string"){let s;if(If(t)?s=YH(t):s=t,s){let d=this.scene.getElementsFromId(s);d?.length?this.scrollToContent(d,{fitToContent:n?.fitToContent??!0,animate:n?.animate??!0}):If(t)&&this.setState({toast:{message:g("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let r=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(n?.fitToContent||n?.fitToViewport){let{appState:s}=fa({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=Fn(r,this.state);a=s.scrollX,l=s.scrollY}if(n?.animate){let s=this.state.scrollX,d=this.state.scrollY,m=this.state.zoom.value,c=qz({fromValues:{scrollX:s,scrollY:d,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,f,b)=>{if(b==="zoom")return p*Math.pow(u/p,Qz(f))},onStep:({scrollX:p,scrollY:u,zoom:f})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:f}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:n?.duration??500});this.cancelInProgressAnimation=()=>{c(),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"),n=await t.match("shared-file");if(n){let r=await n.blob(),i=new File([r],r.name||"",{type:r.type});this.loadFileToCanvas(i,null),await t.delete("shared-file"),window.history.replaceState(null,vz,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Pe(t=>{let{addedFiles:n}=this.addMissingFiles(t);this.clearImageShapeCache(n),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));I(this,"addMissingFiles",(t,n=!1)=>{let r=n?{}:{...this.files},i={},a=Array.isArray(t)?t:Object.values(t);for(let l of a)if(!r[l.id]&&(i[l.id]=l,r[l.id]=l,l.mimeType===Dn.svg))try{let s=b1(aI(x1(l.dataURL)),Dn.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=r,{addedFiles:i}});I(this,"updateScene",Pe(t=>{let{elements:n,appState:r,collaborators:i,captureUpdate:a}=t;if(a){let l=n||void 0,s=r?aH({...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})}));I(this,"applyDeltas",(t,n)=>{let r=wI.squash(...t),i={...this.state},a=new Map(this.scene.getElementsMapIncludingDeleted());return wI.applyTo(r,a,i,n)});I(this,"mutateElement",(t,n,r=!0)=>this.scene.mutateElement(t,n,{informMutation:r,isDragging:!1}));I(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});I(this,"toggleSidebar",({name:t,tab:n,force:r})=>{let i;r===void 0?i=this.state.openSidebar?.name===t&&this.state.openSidebar?.tab===n?null:t:i=r?t:null;let a=i?{name:i}:null;return a&&n&&(a.tab=n),this.setState({openSidebar:a}),!!i});I(this,"updateCurrentCursorPosition",Pe(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,n=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),r=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Mo().rtl?{top:t+i,right:Math.max(this.state.width-(r?.left??this.state.width),0)+i,bottom:i,left:Math.max(n?.right??0,0)+i}:{top:t+i,right:Math.max(this.state.width-(n?.left??this.state.width)+i,0),bottom:i,left:Math.max(r?.right??0,0)+i}});I(this,"onKeyDown",Pe(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}})),!H5(t.target)){if((t.key===Y.ESCAPE||t.key===Y.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=j(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&cr(a[0])&&t.key===Y.ENTER){this.startImageCropping(a[0]);return}if(t.key===Y.ESCAPE)this.updateEditorAtom(io,null);else if(t.key===Y.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(nH.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=si(a);He.get(io)?.type==="panel"&&Au(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(io,{type:"panel"})}if(t.key===Y.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Kd(t.key);if(t[Y.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=j(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&EH(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,mI(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!ff(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 d=this.flowChartNavigator.exploreByDirection(s[0],this.scene.getNonDeletedElementsMap(),mI(t.key));if(d){this.setState(c=>({selectedElementIds:ye({[d]:!0},c)}));let m=this.scene.getNonDeletedElementsMap().get(d);m&&!ff([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[Y.CTRL_OR_CMD]&&t.key===Y.P&&!t.shiftKey&&!t.altKey){this.setToast({message:g("commandPalette.shortcutHint",{shortcut:Ne("commandPalette")})}),t.preventDefault();return}if(t[Y.CTRL_OR_CMD]&&t.key.toLowerCase()===Y.V&&(Qd=t.shiftKey,clearTimeout(vI),vI=window.setTimeout(()=>{Qd=!1},100)),t[Y.CTRL_OR_CMD]&&ml(t.target)&&(t.code===A5.MINUS||t.code===A5.EQUAL)){t.preventDefault();return}if(ml(t.target)&&t.key!==Y.ESCAPE||Kd(t.key)&&H5(t.target))return;if(t.key===Y.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===Y.E&&t.shiftKey&&t[Y.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===Y.PAGE_UP||t.key===Y.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===Y.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[Y.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Kd(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(We),s=new Set;a.filter(We).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),f=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||f}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let d=this.getEffectiveGridSize()&&(t.shiftKey?R5:this.getEffectiveGridSize())||(t.shiftKey?Cz:R5),m=0,c=0;t.key===Y.ARROW_LEFT?m=-d:t.key===Y.ARROW_RIGHT?m=d:t.key===Y.ARROW_UP?c=-d:t.key===Y.ARROW_DOWN&&(c=d),a.forEach(p=>{this.scene.mutateElement(p,{x:p.x+m,y:p.y+c},{informMutation:!1,isDragging:!1}),df(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:mf(a.filter(p=>p.id!==l?.id||d!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===Y.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[Y.CTRL_OR_CMD]||Cf(l))Zt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),We(l)||this.actionManager.executeAction(vi));else if(mo(l)||SH(l)){let s;mo(l)||(s=l);let d=Ef(l,this.state,this.scene.getNonDeletedElementsMap()),m=d.x,c=d.y;this.startTextEditing({sceneX:m,sceneY:c,container:s}),t.preventDefault();return}else Mt(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=c2(t.key,this);a?(this.state.activeTool.type!==a&&ne("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===_n.sharp?_n.round:l.currentItemArrowType===_n.round?_n.elbow:_n.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===Y.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===Y.SPACE&&pe.pointers.size===0&&(mr=!0,xe(this.interactiveCanvas,De.GRAB),t.preventDefault()),(t.key===Y.G||t.key===Y.S)&&!t.altKey&&!t[Y.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===Y.G&&(Zo(this.state.activeTool.type)||a.some(l=>Zo(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===Y.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[Y.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===Y.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=>mo(l)||xf(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===Y.K&&!t.altKey&&!t[Y.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:this.defaultSelectionTool}):this.setActiveTool({type:"laser"});return}t[Y.CTRL_OR_CMD]&&(t.key===Y.BACKSPACE||t.key===Y.DELETE)&&this.updateEditorAtom(er,"clearCanvas");let n=t.key.toLocaleLowerCase(),r=n===Y.S&&t.shiftKey,i=t.key===Y.I||n===Y.G&&t.shiftKey;(r||i)&&this.openEyeDropper({type:r?"stroke":"background"})}));I(this,"onKeyUp",Pe(t=>{if(t.key===Y.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,De.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?Ht(this.interactiveCanvas):(Dt(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),mr=!1),!t[Y.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Kd(t.key)&&(X5(this.scene.getSelectedElements(this.state).filter(Zt),cf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:mt.IMMEDIATELY})),!t[Y.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let n=this.flowChartCreator.pendingNodes?.[0];n&&(this.setState(r=>({selectedElementIds:ye({[n.id]:!0},r)})),ff([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:mt.IMMEDIATELY})}}));I(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);I(this,"setActiveTool",(t,n=!1)=>{if(!this.isToolSupported(t.type)){console.warn(`"${t.type}" tool is disabled via "UIOptions.canvasActions.tools.${t.type}"`);return}let r=Vo(this.state,t);r.type==="hand"?xe(this.interactiveCanvas,De.GRAB):mr||Dt(this.interactiveCanvas,{...this.state,activeTool:r}),Kz(document.activeElement)&&this.focusContainer(),bH(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};return r.type==="freedraw"&&this.store.scheduleCapture(),r.type==="lasso"?{...i,activeTool:r,...n?{}:{selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null},...a}:r.type!=="selection"?{...i,activeTool:r,selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:r,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{xe(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{Ht(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>pe.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${G5()}`);I(this,"onGestureStart",Pe(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null}),pe.initialScale=this.state.zoom.value}));I(this,"onGestureChange",Pe(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let n=pe.initialScale;n&&this.setState(r=>({...Ao({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:uo(n*t.scale)},r)}))}));I(this,"onGestureEnd",Pe(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:ye(this.state.previousSelectedElementIds,this.state)}),pe.initialScale=null}));I(this,"startTextEditing",({sceneX:t,sceneY:n,insertAtParentCenter:r=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=r&&this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i);i&&s&&(xf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let d=null,m=this.scene.getSelectedElements(this.state);m.length===1?mo(m[0])?d=m[0]:i?d=xf(m[0],this.scene.getNonDeletedElementsMap()):d=this.getTextElementAtPosition(t,n):d=this.getTextElementAtPosition(t,n);let c=d?.fontFamily||this.state.currentItemFontFamily,p=d?.lineHeight||O5(c),u=this.state.currentItemFontSize;if(!d&&l&&i&&!pf(i)){let w=KH(rf({fontSize:u,fontFamily:c}),p),E=ZH(u,p),y=Math.max(i.height,E),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:y,width:v}),t=i.x+v/2,n=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,n,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:n}),b=d||$5({x:s?s.elementCenterX:t,y:s?s.elementCenterY:n,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:"",fontSize:u,fontFamily:c,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?Oz.MIDDLE:_5,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?pf(i)?0:i.angle:0,frameId:f?f.id:null});if(!d&&l&&i&&this.scene.mutateElement(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!d)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||d||i?this.handleTextWysiwyg(b,{isExistingElement:!!d}):this.setState({newElement:b,multiElement:null})});I(this,"startImageCropping",t=>{this.store.scheduleCapture(),this.setState({croppingElementId:t.id})});I(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.scheduleCapture(),this.setState({croppingElementId:null}))});I(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!==this.defaultSelectionTool)return;let n=this.scene.getSelectedElements(this.state),{x:r,y:i}=Oe(t,this.state);if(n.length===1&&Zt(n[0])){let l=n[0];if((t[Y.CTRL_OR_CMD]&&dG(l)||Cf(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(vi);return}else if(this.state.selectedLinearElement&&We(n[0])){let s=Se.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),d=s?Se.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,s,this.scene.getNonDeletedElementsMap()):-1;if(d&&d>-1){this.store.scheduleCapture(),Se.deleteFixedSegment(n[0],this.scene,d);let m=Se.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:r,y:i},this.state,this.scene.getNonDeletedElementsMap()),c=m?Se.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,m,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:c,value:s,added:!1}},segmentMidPointHoveredCoords:m}});return}}else if(this.state.selectedLinearElement?.isEditing&&this.state.selectedLinearElement.elementId===l.id&&Cf(l))return}if(n.length===1&&cr(n[0])){this.startImageCropping(n[0]);return}if(Ht(this.interactiveCanvas),QH(this.state).length>0){let l=this.getElementAtPosition(r,i),s=l&&JH(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(d=>({...d,...$t({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),d,this)}));return}}if(Ht(this.interactiveCanvas),!t[Y.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(r,i);if(hl(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(r,i);if(s&&(J5(s)||!jz(s.backgroundColor)||gl({point:re(r,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let d=Ef(s,this.state,this.scene.getNonDeletedElementsMap());r=d.x,i=d.y}this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});I(this,"getElementLinkAtPosition",(t,n)=>{if(n&&n.locked)return;let r=this.scene.getNonDeletedElements(),i=-1;for(let a=r.length-1;a>=0;a--){let l=r[a];if(n&&l.id===n.id&&(i=a),l.link&&a>=i&&Pl(l,this.scene.getNonDeletedElementsMap(),this.state,re(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,n)=>{let r=Pn(re(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),re(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||r>Iz)return;let i=Oe(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Pl(this.hitLinkElement,a,this.state,re(i.x,i.y),this.device.editor.isMobile),s=Oe(this.lastPointerUpEvent,this.state),d=Pl(this.hitLinkElement,a,this.state,re(s.x,s.y),this.device.editor.isMobile);if(l&&d){yu();let m=this.hitLinkElement.link;if(m){m=nf(m);let c;if(this.props.onLinkOpen&&(c=Zz(ee.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},c)),!c?.defaultPrevented){let p=Wz(m)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=m)}}}});I(this,"getTopLayerFrameAtSceneCoords",t=>{let n=this.scene.getNonDeletedElementsMap(),r=this.scene.getNonDeletedFramesLikes().filter(i=>!i.locked&&sI(t,i,n));return r.length?r[r.length-1]:null});I(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,pe.pointers.has(t.pointerId)&&pe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let n=pe.initialScale;if(pe.pointers.size===2&&pe.lastCenter&&n&&pe.initialDistance){let f=Ah(pe.pointers),b=f.x-pe.lastCenter.x,x=f.y-pe.lastCenter.y;pe.lastCenter=f;let w=Dh(Array.from(pe.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/pe.initialDistance,y=E?uo(n*E):this.state.zoom.value;this.setState(v=>{let C=Ao({viewportX:f.x,viewportY:f.y,nextZoom:y},v);this.translateCanvas({zoom:C.zoom,scrollX:C.scrollX+2*(b/y),scrollY:C.scrollY+2*(x/y),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else pe.lastCenter=pe.initialDistance=pe.initialScale=null;if(mr||El||kf||qt(this.state))return;let i=Hh(yl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?Ht(this.interactiveCanvas):Dt(this.interactiveCanvas,this.state));let a=Oe(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Mw(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=kw(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(x=>{let w=pl(x.snapLines,b),E=x.originSnapOffset?pl(x.originSnapOffset,f):f;return x.snapLines===w&&x.originSnapOffset===E?null:{snapLines:w,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(f=>f.snapLines.length?{snapLines:[]}:null);if(this.state.selectedLinearElement?.isEditing&&!this.state.selectedLinearElement.isDragging){let f=Se.handlePointerMove(t,l,s,this),b=f?this.scene.getElement(f.elementId):null;f&&f!==this.state.selectedLinearElement&&Fi(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&Q5(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if(Q5(this.state.activeTool.type)){let{newElement:f}=this.state;uf(f,!1)?this.setState({suggestedBindings:W5(f,[a],this.scene,this.state.zoom,this.state.startBoundElement)}):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:f}=this.state,{x:b,y:x}=f,{points:w,lastCommittedPoint:E}=f,y=w[w.length-1];if(Dt(this.interactiveCanvas,this.state),y===E)Pn(re(l-b,s-x),y)>=of?this.scene.mutateElement(f,{points:[...w,re(l-b,s-x)]},{informMutation:!1,isDragging:!1}):xe(this.interactiveCanvas,De.POINTER);else if(w.length>2&&E&&Pn(re(l-b,s-x),E)<of)xe(this.interactiveCanvas,De.POINTER),this.scene.mutateElement(f,{points:w.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,C]=rt(l,s,t[Y.CTRL_OR_CMD]||We(f)?null:this.getEffectiveGridSize()),[S,L]=f?.lastCommittedPoint??[0,0],k=v-b-S,A=C-x-L;tf(t)&&({width:k,height:A}=tI(S+b,L+x,v,C)),rI(w,this.state.zoom.value)&&xe(this.interactiveCanvas,De.POINTER),this.scene.mutateElement(f,{points:[...w.slice(0,-1),re(S+k,L+A)]},{isDragging:!0,informMutation:!1}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),c=this.scene.getSelectedElements(this.state);if(c.length===1&&!i&&!this.state.selectedLinearElement?.isEditing){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(c.length===1&&We(c[0]))){let f=fI(m,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){xe(this.interactiveCanvas,gI(f));return}}}else if(c.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=bI(Hi(c),l,s,this.state.zoom,t.pointerType,this.device);if(f){xe(this.interactiveCanvas,gI({transformHandleType:f}));return}}let p=this.getElementAtPosition(l,s,{preferSelected:!0,includeLockedElements:!0}),u=null;p&&p.locked?u=null:u=p,this.hitLinkElement=this.getElementLinkAtPosition(a,p),!bt(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(xe(this.interactiveCanvas,De.POINTER),WE(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(yu(),u&&(u.link||Xo(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?xe(this.interactiveCanvas,mo(u)?De.TEXT:De.CROSSHAIR):this.state.viewModeEnabled?xe(this.interactiveCanvas,De.GRAB):this.state.openDialog?.name==="elementLinkSelector"?xe(this.interactiveCanvas,De.AUTO):i?xe(this.interactiveCanvas,De.AUTO):t[Y.CTRL_OR_CMD]?xe(this.interactiveCanvas,De.AUTO):(u||this.isHittingCommonBoundingBoxOfSelectedElements(a,c))&&!u?.locked&&(u&&hl(u)&&this.isIframeLikeElementCenter(u,t,l,s)?(xe(this.interactiveCanvas,De.POINTER),this.setState({activeEmbeddable:{element:u,state:"hover"}})):(!u||!We(u)||!(u.startBinding||u.endBinding))&&((this.state.activeTool.type!=="lasso"||c.length>0)&&xe(this.interactiveCanvas,De.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null}))),this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s)),this.state.openDialog?.name==="elementLinkSelector"&&u?this.setState(f=>({hoveredElementIds:pl(f.hoveredElementIds,$t({editingGroupId:f.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),f,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!u&&this.setState(f=>({hoveredElementIds:pl(f.hoveredElementIds,{})})))});I(this,"handleEraser",(t,n)=>{let r=this.eraserTrail.addPointToPath(n.x,n.y,t.altKey);this.elementsPendingErasure=new Set(r),this.triggerRender()});I(this,"handleTouchMove",t=>{wl=!0});I(this,"handleCanvasPointerDown",t=>{let n=t.target;if(n.setPointerCapture&&n.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(c=>({searchMatches:c.searchMatches&&{focusedId:null,matches:c.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(wg,null)),He.get(io)&&this.updateEditorAtom(io,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 c=this.state.newElement;this.updateScene({...c.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==c.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:ye(Object.keys(this.state.selectedElementIds).filter(p=>p!==c.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?mt.EVENTUALLY:mt.NEVER});return}let r=document.getSelection();if(r?.anchorNode&&r.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(c=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=lf(this.device,{isTouchScreen:!0})),El||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===ar.ERASER&&this.state.activeTool.type!==Co.eraser){this.setState({activeTool:Vo(this.state,{type:Co.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let c=()=>{p(),u?.(),bt(this.state)&&this.setState({activeTool:Vo(this.state,{...this.state.activeTool.lastActiveTool||{type:Co.selection},lastActiveToolBeforeEraser:null})})},p=_e(window,ee.POINTER_UP,c,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(c)})});return}if(t.button!==ar.MAIN&&t.button!==ar.TOUCH&&t.button!==ar.ERASER||pe.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.handleDraggingScrollBar(t,i)||(this.clearSelectionIfNotUsingSelection(),this.updateBindingEnabledOnPointerMove(t),this.handleSelectionOnPointerDown(t,i))||!(!this.state.penMode||t.pointerType!=="touch"||this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"||this.state.activeTool.type==="text"||this.state.activeTool.type==="image"))return;if(this.state.activeTool.type==="lasso"){let c=i.hit.element&&this.isASelectedElement(i.hit.element),p=this.isMobileOrTablet();!i.hit.hasHitCommonBoundingBoxOfSelectedElements&&!i.resize.handleType&&!c&&(this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey),i.drag.blockDragging=!p),p&&i.hit.element&&!c&&(this.setState(u=>{let f={...u.selectedElementIds,[i.hit.element.id]:!0},b=[];Object.keys(u.selectedElementIds).forEach(w=>{let E=this.scene.getElement(w);E&&b.push(E)});let x=i.hit.element;if(Mt(x))yf(b,x.id).forEach(w=>{delete f[w.id]});else if(x.frameId)f[x.frameId]&&delete f[x.id];else{let w=x.groupIds,E=new Set(w.flatMap(y=>dr(this.scene.getNonDeletedElements(),y)).filter(y=>Mt(y)).map(y=>y.id));E.size>0&&b.forEach(y=>{y.frameId&&E.has(y.frameId)&&(delete f[y.id],y.groupIds.flatMap(v=>dr(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete f[v.id]}))})}return{...$t({editingGroupId:u.editingGroupId,selectedElementIds:f},this.scene.getNonDeletedElements(),u,this),showHyperlinkPopup:x.link||Xo(x)?"info":!1}}),i.hit.wasAddedToSelection=!0)}else this.state.activeTool.type==="text"?this.handleTextOnPointerDown(t,i):this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line"?this.handleLinearElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Dt(this.interactiveCanvas,this.state):this.state.activeTool.type===Co.frame||this.state.activeTool.type===Co.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,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),d=this.onKeyDownFromPointerDownHandler(i),m=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(c=>s(c||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener(ee.POINTER_MOVE,l),window.addEventListener(ee.POINTER_UP,s),window.addEventListener(ee.KEYDOWN,d),window.addEventListener(ee.KEYUP,m),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=m,i.eventListeners.onKeyDown=d)});I(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let n=Oe({clientX:t.clientX,clientY:t.clientY},this.state),r=t.timeStamp-(this.lastPointerDownEvent?.timeStamp??0);if(this.device.editor.isMobile&&r<300){let i=this.getElementAtPosition(n.x,n.y);if(hl(i)&&this.isIframeLikeElementCenter(i,t,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&&hl(this.hitLinkElement)&&!n1(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,re(n.x,n.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"&&(wl=!1,Rn?wl=!0:Rn=window.setTimeout(()=>{Rn=0,wl||this.handleCanvasContextMenu(t)},Fz))});I(this,"resetContextMenuTimer",()=>{clearTimeout(Rn),Rn=0,wl=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{vl?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(pe.pointers.size<=1&&(t.button===ar.WHEEL||t.button===ar.MAIN&&mr||qt(this.state)||this.state.viewModeEnabled)))return!1;El=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let n=!1,r=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);xe(this.interactiveCanvas,De.GRABBING);let{clientX:i,clientY:a}=t,l=od(d=>{let m=i-d.clientX,c=a-d.clientY;if(i=d.clientX,a=d.clientY,r&&!n&&(Math.abs(m)>1||Math.abs(c)>1)){n=!0;let p=f=>{document.body.removeEventListener(ee.PASTE,p),f.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener(ee.PASTE,p),window.removeEventListener(ee.POINTER_UP,u)},100)};document.body.addEventListener(ee.PASTE,p),window.addEventListener(ee.POINTER_UP,u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-c/this.state.zoom.value})}),s=Pe(vl=()=>{vl=null,El=!1,mr||(this.state.viewModeEnabled?xe(this.interactiveCanvas,De.GRAB):Dt(this.interactiveCanvas,this.state)),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,l),window.removeEventListener(ee.POINTER_UP,s),window.removeEventListener(ee.BLUR,s),l.flush()});return window.addEventListener(ee.BLUR,s),window.addEventListener(ee.POINTER_MOVE,l,{passive:!0}),window.addEventListener(ee.POINTER_UP,s),!0});I(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});I(this,"handleSelectionOnPointerDown",(t,n)=>{if(this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"){let r=this.scene.getNonDeletedElements(),i=this.scene.getNonDeletedElementsMap(),a=this.scene.getSelectedElements(this.state);if(a.length===1&&!this.state.selectedLinearElement?.isEditing&&!We(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=fI(r,this.state,n.origin.x,n.origin.y,this.state.zoom,t.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=bI(Hi(a),n.origin.x,n.origin.y,this.state.zoom,t.pointerType,this.device));if(n.resize.handleType)n.resize.isResizing=!0,n.resize.offset=af(nG(n.resize.handleType,a,i,n.origin.x,n.origin.y)),a.length===1&&Zt(a[0])&&a[0].points.length===2&&(n.resize.arrowDirection=rG(n.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Se.handlePointerDown(t,this,this.store,n.origin,p,this.scene);if(u.hitElement&&(n.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0}let l=this.getElementsAtPosition(n.origin.x,n.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),d=this.getElementAtPosition(n.origin.x,n.origin.y,{allHitElements:l});if((!d||d.id!==this.state.activeLockedId)&&this.setState({activeLockedId:null}),d&&d.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,d),this.hitLinkElement)return!0;if(this.state.croppingElementId&&n.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),n.hit.element&&this.getElementLinkAtPosition({x:n.origin.x,y:n.origin.y},n.hit.element))return!1;n.hit.allHitElements=s;let m=n.hit.element,c=n.hit.allHitElements.some(p=>this.isASelectedElement(p));if((m===null||!c)&&!t.shiftKey&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(m),this.state.selectedLinearElement?.isEditing)this.setState({selectedElementIds:ye({[this.state.selectedLinearElement.elementId]:!0},this.state)});else if(m!=null){if(t[Y.CTRL_OR_CMD])return t.altKey?(this.state.openDialog?.name==="elementLinkSelector"&&this.setOpenDialog(null),this.lassoTrail.startPath(n.origin.x,n.origin.y,t.shiftKey),this.setActiveTool({type:"lasso",fromSelection:!0}),!1):(this.state.selectedElementIds[m.id]||(n.hit.wasAddedToSelection=!0),this.setState(p=>({...qH(p,m),previousSelectedElementIds:this.state.selectedElementIds})),!1);this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!uI(m,this.state.editingGroupId)&&this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!c&&!n.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(p=>{let u={...p.selectedElementIds,[m.id]:!0},f=[];if(Object.keys(p.selectedElementIds).forEach(b=>{let x=this.scene.getElement(b);x&&f.push(x)}),Mt(m))yf(f,m.id).forEach(b=>{delete u[b.id]});else if(m.frameId)u[m.frameId]&&delete u[m.id];else{let b=m.groupIds,x=new Set(b.flatMap(w=>dr(this.scene.getNonDeletedElements(),w)).filter(w=>Mt(w)).map(w=>w.id));x.size>0&&f.forEach(w=>{w.frameId&&x.has(w.frameId)&&(delete u[w.id],w.groupIds.flatMap(E=>dr(this.scene.getNonDeletedElements(),E)).forEach(E=>{delete u[E.id]}))})}return p.openDialog?.name==="elementLinkSelector"&&(m.groupIds.some(b=>p.selectedGroupIds[b])||(u={[m.id]:!0})),{...$t({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:m.link||Xo(m)?"info":!1}}),n.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});I(this,"handleTextOnPointerDown",(t,n)=>{if(this.state.editingTextElement)return;let r=n.origin.x,i=n.origin.y,a=this.getElementAtPosition(r,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(r,i);J5(a)&&(l=a,r=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:r,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),Ht(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Vo(this.state,{type:this.defaultSelectionTool})})});I(this,"handleFreeDrawElementOnPointerDown",(t,n,r)=>{let[i,a]=rt(r.origin.x,r.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,d=dH({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:[re(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(d),this.setState(c=>{let p={...c.selectedElementIds};return delete p[d.id],{selectedElementIds:ye(p,c)}});let m=sf(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:d,startBoundElement:m,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:n,width:r,height:i})=>{let[a,l]=rt(t,n,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=mH({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});I(this,"insertEmbeddableElement",({sceneX:t,sceneY:n,link:r})=>{let[i,a]=rt(t,n,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=Jd(r);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=K5({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});I(this,"createImageElement",async({sceneX:t,sceneY:n,addToFrameUnderCursor:r=!0,imageFile:i})=>{let[a,l]=rt(t,n,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=r?this.getTopLayerFrameAtSceneCoords({x:a,y:l}):null,d=100/this.state.zoom.value,m=hH({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-d/2,y:l-d/2,width:d,height:d});return await this.insertImageElement(m,i)});I(this,"handleLinearElementOnPointerDown",(t,n,r)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&rI(i.points,this.state.zoom.value)){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(wt);return}if(We(i)&&i.points.length>1){this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(wt);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Pn(re(r.origin.x-a,r.origin.y-l),s)<of){this.actionManager.executeAction(wt);return}this.setState(d=>({selectedElementIds:ye({...d.selectedElementIds,[i.id]:!0},d)})),this.scene.mutateElement(i,{lastCommittedPoint:i.points[i.points.length-1]}),xe(this.interactiveCanvas,De.POINTER)}else{let[i,a]=rt(r.origin.x,r.origin.y,t[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:d}=this.state,[m,c]=n==="arrow"?[s,d]:[null,null],p=n==="arrow"?pH({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===_n.round?{type:Zd.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:c,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===_n.elbow,fixedSegments:this.state.currentItemArrowType===_n.elbow?[]:null}):gH({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:Zd.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(f=>{let b={...f.selectedElementIds};return delete b[p.id],{selectedElementIds:ye(b,f)}}),this.scene.mutateElement(p,{points:[...p.points,re(0,0)]});let u=sf(r.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,We(p),We(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});I(this,"createGenericElementOnPointerDown",(t,n)=>{let[r,i]=rt(n.origin.x,n.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:r,y:i}),l={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=K5({type:"embeddable",...l}):s=uH({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});I(this,"createFrameElementOnPointerDown",(t,n)=>{let[r,i]=rt(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:r,y:i,opacity:this.state.currentItemOpacity,locked:!1,...An},l=n===Co.magicframe?Z5(a):cH(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,n=this.scene.getElementsIncludingDeleted().map(r=>this.elementsPendingErasure.has(r.id)||r.frameId&&this.elementsPendingErasure.has(r.frameId)||hf(r)&&this.elementsPendingErasure.has(r.containerId)?(t=!0,sr(r,{isDeleted:!0})):r);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(n))});I(this,"initializeImage",async(t,n)=>{if(!Nl(n))throw new Error(g("errors.unsupportedFileType"));let r=n.type;if(xe(this.interactiveCanvas,"wait"),r===Dn.svg)try{n=Em(aI(await n.text()),n.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(n)||f1(n));if(!i)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(g("errors.imageInsertError"));if(!this.files[i]?.dataURL){try{n=await Fl(n,{maxWidthOrHeight:Tz})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(n.size>N5)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(N5/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await xm(n);return new Promise(async(s,d)=>{try{let m=this.getLatestInitializedImageElement(t,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([m]);if(p.size)throw new Error("Image cache update resulted with an error.")}let c=await this.imageCache.get(i)?.image;if(c&&this.state.newElement?.id!==m.id){m=this.getLatestInitializedImageElement(t,i);let p=this.getImageNaturalDimensions(m,c);Object.assign(m,p)}s(m)}catch(m){console.error(m),d(new Error(g("errors.imageInsertError")))}})});I(this,"getLatestInitializedImageElement",(t,n)=>{let r=this.scene.getElement(t.id)??t;return sr(r,{fileId:n})});I(this,"insertImageElement",async(t,n)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:g("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{let r=await this.initializeImage(t,n),i=this.scene.getElementsIncludingDeleted().map(a=>a.id===r.id?r:a);return this.updateScene({captureUpdate:mt.IMMEDIATELY,elements:i,appState:{selectedElementIds:ye({[r.id]:!0},this.state)}}),r}catch(r){return this.store.scheduleAction(mt.NEVER),this.scene.mutateElement(t,{isDeleted:!0}),this.actionManager.executeAction(wt),this.setState({errorMessage:r.message||g("errors.imageInsertError")}),null}});I(this,"onImageAction",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,n=this.state.height/2+this.state.offsetTop,{x:r,y:i}=Oe({clientX:t,clientY:n},this.state),a=await Ml({description:"Image",extensions:Object.keys(Sz)});await this.createImageElement({sceneX:r,sceneY:i,addToFrameUnderCursor:!1,imageFile:a}),this.setState({},()=>{this.actionManager.executeAction(wt)})}catch(t){t.name!=="AbortError"?console.error(t):console.warn(t),this.setState({newElement:null,activeTool:Vo(this.state,{type:this.defaultSelectionTool})},()=>{this.actionManager.executeAction(wt)})}});I(this,"getImageNaturalDimensions",(t,n)=>{let r=Math.max(this.state.height-120,160),i=Math.min(r,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(n.naturalHeight,i),l=a*(n.naturalWidth/n.naturalHeight),s=t.x+t.width/2-l/2,d=t.y+t.height/2-a/2;return{x:s,y:d,width:l,height:a,crop:null}});I(this,"updateImageCache",async(t,n=this.files)=>{let{updatedFiles:r,erroredFiles:i}=await CH({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:n});return i.size&&(this.store.scheduleAction(mt.NEVER),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>ul(a)&&i.has(a.fileId)?sr(a,{status:"error"}):a))),{updatedFiles:r,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=IH(this.scene.getNonDeletedElements()),n=this.files)=>{let r=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(r.length){let{updatedFiles:i}=await this.updateImageCache(r,n);if(i.size)for(let a of r)i.has(a.fileId)&&fl.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",bz(()=>{this.addNewImagesToImageCache()},kz));I(this,"updateBindingEnabledOnPointerMove",t=>{let n=sH(t);this.state.isBindingEnabled!==n&&this.setState({isBindingEnabled:n})});I(this,"maybeSuggestBindingAtCursor",(t,n)=>{let r=sf(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,n);this.setState({suggestedBindings:r!=null?[r]:[]})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(ee.TOUCH_START,this.onTouchStart,{passive:!1}),this.interactiveCanvas.addEventListener(ee.TOUCH_END,this.onTouchEnd)):(this.interactiveCanvas?.removeEventListener(ee.TOUCH_START,this.onTouchStart),this.interactiveCanvas?.removeEventListener(ee.TOUCH_END,this.onTouchEnd))});I(this,"handleAppOnDrop",async t=>{let{file:n,fileHandle:r}=await y1(t),{x:i,y:a}=Oe(t,this.state);try{if(Nl(n)&&this.isToolSupported("image")){if(n?.type===Dn.png||n?.type===Dn.svg)try{let s=await Bl(n,this.state,this.scene.getElementsIncludingDeleted(),r);this.syncActionResult({...s,appState:{...s.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:mt.IMMEDIATELY});return}catch(s){if(s.name!=="EncodingError")throw new Error(g("alerts.couldNotLoadInvalidFile"))}this.createImageElement({sceneX:i,sceneY:a,imageFile:n});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let l=t.dataTransfer.getData(Dn.excalidrawlib);if(l&&typeof l=="string"){try{let s=g1(l);this.addElementsFromPasteOrLibrary({elements:xc(s),position:t,files:null})}catch(s){this.setState({errorMessage:s.message})}return}if(n&&await this.loadFileToCanvas(n,r),t.dataTransfer?.types?.includes("text/plain")){let s=t.dataTransfer?.getData("text");if(s&&bf(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||Jd(s)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:nf(s)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,n)=>{t=await v1(t);try{let r=this.scene.getElementsIncludingDeleted(),i;try{i=await fm(t,this.state,r,n)}catch(a){let l=a instanceof e1;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:g("errors.imageToolNotSupported")});return}let s=l?g("alerts.cannotRestoreFromImage"):g("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===Dn.excalidraw?(CI(r.concat(i.data.elements)),this.store.scheduleMicroAction({action:mt.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:mt.IMMEDIATELY})):i.type===Dn.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:g("errors.importLibraryError")})})}catch(r){this.setState({isLoading:!1,errorMessage:r.message})}});I(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==ar.SECONDARY)&&this.state.activeTool.type!==this.defaultSelectionTool)return;let{x:n,y:r}=Oe(t,this.state),i=this.getElementAtPosition(n,r,{preferSelected:!0,includeLockedElements:!0}),a=this.scene.getSelectedElements(this.state),l=this.isHittingCommonBoundingBoxOfSelectedElements({x:n,y:r},a),s=i||l?"element":"canvas",d=this.excalidrawContainerRef.current,{top:m,left:c}=d.getBoundingClientRect(),p=t.clientX-c,u=t.clientY-m;ne("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...$t({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:Zt(i)?new Se(i,this.scene.getNonDeletedElementsMap()):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});I(this,"maybeDragNewGenericElement",(t,n,r=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){xI({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:zi(t.origin.x,a.x),height:zi(t.origin.y,a.y),shouldMaintainAspectRatio:dl(n),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,d]=rt(a.x,a.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=ul(l)&&this.imageCache.get(l.fileId)?.image,c=m&&!(m instanceof Promise)?m.width/m.height:null;this.maybeCacheReferenceSnapPoints(n,[l]);let{snapOffset:p,snapLines:u}=Sw(l,this,n,{x:t.originInGrid.x+(this.state.originSnapOffset?.x??0),y:t.originInGrid.y+(this.state.originSnapOffset?.y??0)},{x:s-t.originInGrid.x,y:d-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,d+=p.y,this.setState({snapLines:u}),xI({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:d,width:zi(t.originInGrid.x,s),height:zi(t.originInGrid.y,d),shouldMaintainAspectRatio:cr(l)?!dl(n):dl(n),shouldResizeFromCenter:D5(n),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:c,originOffset:this.state.originSnapOffset,informMutation:r}),this.setState({newElement:l}),(this.state.activeTool.type===Co.frame||this.state.activeTool.type===Co.magicframe)&&this.setState({elementsToHighlight:vf(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});I(this,"maybeHandleCrop",(t,n)=>{if(!this.state.croppingElementId)return!1;let r=t.resize.handleType,i=t.lastCoords,[a,l]=rt(i.x-t.resize.offset.x,i.y-t.resize.offset.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(r&&s&&cr(s)){let d=t.originalElements.get(s.id),m=ul(s)&&this.imageCache.get(s.fileId)?.image;if(d&&cr(d)&&m&&!(m instanceof Promise)){let[c,p]=rt(i.x,i.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(n,[s]);let{snapOffset:f,snapLines:b}=Bh([s],[d],this,n,u,r);this.scene.mutateElement(s,GH(s,this.scene.getNonDeletedElementsMap(),r,m.naturalWidth,m.naturalHeight,a+f.x,l+f.y,n.shiftKey?d.width/d.height:void 0)),df(s,this.scene,{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:r&&r!=="rotation",snapLines:b})}return!0}return!1});I(this,"maybeHandleResize",(t,n)=>{let r=this.scene.getSelectedElements(this.state),i=r.filter(c=>Mt(c)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||r.length===1&&We(r[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,d]=rt(l.x-t.resize.offset.x,l.y-t.resize.offset.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(c=>{yf(this.scene.getNonDeletedElements(),c.id).forEach(u=>{m.set(c.id+u.id,{x:u.x-c.x,y:u.y-c.y})})}),!this.state.selectedElementsAreBeingDragged){let[c,p]=rt(l.x,l.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(n,r);let{snapOffset:b,snapLines:x}=Bh(r,j(f,this.state),this,n,u,a);s+=b.x,d+=b.y,this.setState({snapLines:x})}if(iG(t.originalElements,a,r,this.scene,tf(n),D5(n),r.some(c=>cr(c))?!dl(n):dl(n),s,d,t.resize.center.x,t.resize.center.y)){let c=mf(r,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{vf(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(f=>p.add(f))}),this.setState({elementsToHighlight:[...p],suggestedBindings:c}),!0}return!1});I(this,"getContextMenuItems",t=>{let n=[];return n.push(nc,oc),t==="canvas"?this.state.viewModeEnabled?[...n,ic,ti,Lh,oi]:[au,Ye,nc,oc,rc,Ye,Qm,jE,Ye,ic,lu,ti,Lh,oi]:(n.push(rc),this.state.viewModeEnabled?[ei,...n]:[Ye,tc,ei,au,Ye,rw,iw,aw,Ye,Ch,Ye,...n,Ye,$p,jp,Ye,Qp,uw,du,mu,NE,eu,Ye,nu,Ye,$m,jm,qm,Jm,Ye,ru,iu,Ye,vi,Ye,Ma,uc,Ye,ep,La,Ye,ra])});I(this,"handleWheel",Pe(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[Y.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),El)return;let{deltaX:n,deltaY:r}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(r),a=zz*100,l=Math.abs(r),s=r;l>a&&(s=a*i);let d=this.state.zoom.value-s/100;d+=Math.log10(Math.max(1,this.state.zoom.value))*-i*Math.min(1,l/20),this.translateCanvas(m=>({...Ao({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:uo(d)},m),shouldCacheIgnoreZoom:!0})),this.resetShouldCacheIgnoreZoomDebounced();return}if(t.shiftKey){this.translateCanvas(({zoom:i,scrollX:a})=>({scrollX:a-(r||n)/i.value}));return}this.translateCanvas(({zoom:i,scrollX:a,scrollY:l})=>({scrollX:a-n/i.value,scrollY:l-r/i.value}))}));I(this,"savePointer",(t,n,r)=>{if(!t||!n)return;let{x:i,y:a}=Oe({clientX:t,clientY:n},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:r,pointersMap:pe.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",z5(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));I(this,"updateDOMRect",t=>{if(this.excalidrawContainerRef?.current){let n=this.excalidrawContainerRef.current,{width:r,height:i,left:a,top:l}=n.getBoundingClientRect(),{width:s,height:d,offsetTop:m,offsetLeft:c}=this.state;if(r===s&&i===d&&a===c&&l===m){t&&t();return}this.setState({width:r,height:i,offsetLeft:a,offsetTop:l},()=>{t&&t()})}});I(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let n=jo();this.defaultSelectionTool=this.isMobileOrTablet()?"lasso":"selection";let{excalidrawAPI:r,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:d=n.theme,name:m=`${g("labels.untitled")}-${G5()}`}=t;if(this.state={...n,theme:d,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??n.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight},this.id=Ez(),this.library=new vy(this),this.actionManager=new Vc(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new yI,this.canvas=document.createElement("canvas"),this.rc=xz.canvas(this.canvas),this.renderer=new ja(this.scene),this.visibleElements=[],this.store=new sG(this),this.history=new Va(this.store),r){let c={updateScene:this.updateScene,applyDeltas:this.applyDeltas,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,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,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(c):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new $o(this.scene),this.history=new Va(this.store),this.actionManager.registerAll(ss),this.actionManager.registerAction(cw(this.history)),this.actionManager.registerAction(dw(this.history))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let n=null;try{n=JSON.parse(t.data)}catch{}if(n)switch(t.origin){case"https://player.vimeo.com":if(n.method==="paused"){let r=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(r=a.contentWindow);r?.postMessage(JSON.stringify({method:n.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(n.event==="infoDelivery"&&n.info&&n.id&&typeof n.info.playerState=="number"){let r=n.id,i=n.info.playerState;Object.values(jd).includes(i)&&Mf.set(r,i)}break}}cacheEmbeddableRef(t,n){n&&this.iFrameRefs.set(t.id,n)}getHTMLIFrameElement(t){return this.iFrameRefs.get(t.id)}handleEmbeddableCenterClick(t){if(this.state.activeEmbeddable?.element===t&&this.state.activeEmbeddable?.state==="active"||(setTimeout(()=>{this.setState({activeEmbeddable:{element:t,state:"active"},selectedElementIds:{[t.id]:!0},newElement:null,selectionElement:null})},100),Gi(t)))return;let n=this.getHTMLIFrameElement(t);if(n?.contentWindow){if(n.src.includes("youtube")){let r=Mf.get(t.id);switch(r||(Mf.set(t.id,jd.UNSTARTED),n.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),r){case jd.PLAYING:case jd.BUFFERING:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"pauseVideo",args:""}),"*");break;default:n.contentWindow?.postMessage(JSON.stringify({event:"command",func:"playVideo",args:""}),"*")}}n.src.includes("player.vimeo.com")&&n.contentWindow.postMessage(JSON.stringify({method:"paused"}),"*")}}isIframeLikeElementCenter(t,n,r,i){return t&&!n.altKey&&!n.shiftKey&&!n.metaKey&&!n.ctrlKey&&(this.state.activeEmbeddable?.element!==t||this.state.activeEmbeddable?.state==="hover"||!this.state.activeEmbeddable)&&r>=t.x+t.width/3&&r<=t.x+2*t.width/3&&i>=t.y+t.height/3&&i<=t.y+2*t.height/3}renderEmbeddables(){let t=this.state.zoom.value,n=this.state.width,r=this.state.height,i=this.scene.getNonDeletedElements().filter(a=>Xo(a)&&this.embedsValidationStatus.get(a.id)===!0||Gi(a));return ue(pG,{children:i.map(a=>{let{x:l,y:s}=qd({sceneX:a.x,sceneY:a.y},this.state),d=oI(a,n,r,this.state,this.scene.getNonDeletedElementsMap()),m=this.initializedEmbeds.has(a.id);if(d&&!m&&this.initializedEmbeds.add(a.id),!(d||m))return null;let p;if(Gi(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:()=>iI(`
19
26
  <style>
20
27
  html, body {
21
28
  width: 100%;
22
29
  height: 100%;
23
- color: ${this.state.theme===re.DARK?"white":"black"};
30
+ color: ${this.state.theme===$d.DARK?"white":"black"};
24
31
  }
25
32
  body {
26
33
  display: flex;
@@ -87,7 +94,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),de("ai","me
87
94
  </svg>
88
95
  </div>
89
96
  <div>Generating...</div>
90
- `)};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:()=>Ap(`
97
+ `)};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:()=>iI(`
91
98
  <style>
92
99
  html, body {
93
100
  height: 100%;
@@ -97,7 +104,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),de("ai","me
97
104
  flex-direction: column;
98
105
  align-items: center;
99
106
  justify-content: center;
100
- color: ${uo.red[3]};
107
+ color: ${wz.red[3]};
101
108
  }
102
109
  h1, h3 {
103
110
  margin-top: 0;
@@ -106,7 +113,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),de("ai","me
106
113
  </style>
107
114
  <h1>Error!</h1>
108
115
  <h3>${x}</h3>
109
- `)}}}else p=Yn(Bs(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return _e("div",{className:z3("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:ib(a,Hn(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?Kf:1),"--embeddable-radius":`${mb(Math.min(a.width,a.height),a)}px`},children:Hm("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?Mn.enabled:Mn.disabled},children:[f&&_e("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),_e("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(Nt(a)?this.props.renderEmbeddable?.(a,this.state):null)??_e("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],d=it.get(Wo)?.type==="panel";return _e("div",{className:z3("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":c?Mn.disabled:Mn.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:_e(H3.Provider,{value:this,children:_e(U3.Provider,{value:this.props,children:_e(jg.Provider,{value:this.excalidrawContainerValue,children:_e($g.Provider,{value:this.device,children:_e(Qg.Provider,{value:this.setAppState,children:_e(Jg.Provider,{value:this.state,children:Hm(qg.Provider,{value:this.scene.getNonDeletedElements(),children:[Hm(ef.Provider,{value:this.actionManager,children:[_e(I3,{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:Cr().code,renderTopRightUI:r,renderCustomStats:n,showExitZenModeBtn:typeof this.props?.zenModeEnabled>"u"&&this.state.zenModeEnabled,UIOptions:this.props.UIOptions,onExportImage:this.onExportImage,renderWelcomeScreen:!this.state.isLoading&&this.state.showWelcomeScreen&&this.state.activeTool.type==="selection"&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),_e("div",{className:"excalidraw-textEditorContainer"}),_e("div",{className:"excalidraw-contextMenuContainer"}),_e("div",{className:"excalidraw-eye-dropper-container"}),_e(M3,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&_e(S2,{element:m,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.props.aiEnabled!==!1&&t.length===1&&Fs(m)&&_e(ag,{element:m,elementsMap:a,children:_e(Bm,{title:g("labels.convertToCode"),icon:Hc,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),t.length===1&&On(m)&&m.customData?.generationData?.status==="done"&&Hm(ag,{element:m,elementsMap:a,children:[_e(Bm,{title:g("labels.copySource"),icon:Yi,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),_e(Bm,{title:"Enter fullscreen",icon:zx,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(m);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:m,state:"active"},selectedElementIds:{[m.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&_e(O3,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&_e(_v,{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?.()})}}),_e(Vg,{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:hn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&_e(R3,{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}}),_e(Wg,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&_e(Pv,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),d&&_e(O2,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=$s(this.scene.getNonDeletedElements(),t).filter(l=>!Fs(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),de("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}}),de("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(de("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){de("ai","generate (failed)","d2c"),this.updateMagicGeneration({frameElement:a,data:{status:"error",code:"ERR_OAI",message:l.message||"Unknown error during generation"}})}}}onIframeSrcCopy(t){t.customData?.generationData?.status==="done"&&(Go(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let r=t??this.files;this.scene.getNonDeletedElements().forEach(n=>{fr(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),Jo.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,jo()||pt()){let n=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(n=>{this.history.record(n.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(n=>{t(n)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),jo()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),Oa&&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),If()&&!P1()&&this.setState({errorMessage:_e(Sv,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new ol,this.fonts=new Qr(this.scene),this.renderer=new Yl(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(),Jo.destroy(),Co.destroy(),clearTimeout(Tn),Ne.clearCache(),nt.clearCache(),Tn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(He(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(He(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),He(window,"message",this.onWindowMessage,!1),He(document,"pointerup",this.removePointer,{passive:!1}),He(document,"copy",this.onCopy,{passive:!1}),He(document,"keyup",this.onKeyUp,{passive:!0}),He(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),He(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),He(document,"gesturestart",this.onGestureStart,!1),He(document,"gesturechange",this.onGestureChange,!1),He(document,"gestureend",this.onGestureEnd,!1),He(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(He(document,"fullscreenchange",this.onFullscreenChange,{passive:!1}),He(document,"paste",this.pasteFromClipboard,{passive:!1}),He(document,"cut",this.onCut,{passive:!1}),He(window,"resize",this.onResize,!1),He(window,"unload",this.onUnload,!1),He(window,"blur",this.onBlur,!1),He(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),He(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),He(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(He(a1(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(),(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&&Zt(this.state)&&this.setState({activeTool:De(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&ju(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(),Zt(r)&&!Zt(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),r.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(r.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&r.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===re.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(so)}),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&&Un(this.state)&&br(s,!1)&&Ja(s,this.state,Gr(X.getPointAtIndexGlobalCoordinates(s,-1,a)),this.scene),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){os=!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 m0(p)}}catch(u){let f=u.message;return u.cause==="FETCH_ERROR"?f=g("errors.failedToFetchImage"):u.cause==="UNSUPPORTED"&&(f=g("errors.unsupportedFileType")),{errorMessage:f}}})),s=i,c=!1,m={};for(let p of l)if(p.file){let u=this.createImageElement({sceneX:n,sceneY:s}),f=await this.insertImageElement(u,p.file);f&&(c||(c=!0,s-=f.height/2),this.scene.mutateElement(f,{y:s},{informMutation:!1,isDragging:!1}),s=u.y+u.height+25,m[u.id]=!0)}this.setState({selectedElementIds:Ce(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(`
116
+ `)}}}else p=Jd(Vz(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",f=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return ue("div",{className:C5("excalidraw__embeddable-container",{"is-hovered":f}),style:{transform:d?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:d?"block":"none",opacity:jH(a,Tf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?Uz:1),"--embeddable-radius":`${vH(Math.min(a.width,a.height),a)}px`},children:em("div",{className:"excalidraw__embeddable-container__inner",style:{width:d?`${a.width}px`:0,height:d?`${a.height}px`:0,transform:d?`rotate(${a.angle}rad)`:"none",pointerEvents:u?Oi.enabled:Oi.disabled},children:[f&&ue("div",{className:"excalidraw__embeddable-hint",children:g("buttons.embeddableInteractionButton")}),ue("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(Xo(a)?this.props.renderEmbeddable?.(a,this.state):null)??ue("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: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(),d="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],c=He.get(io)?.type==="panel";return ue("div",{className:C5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":d?Oi.disabled:Oi.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:ue(SI.Provider,{value:this,children:ue(kI.Provider,{value:this.props,children:ue(Df.Provider,{value:this.excalidrawContainerValue,children:ue(Af.Provider,{value:this.device,children:ue(Nf.Provider,{value:this.setAppState,children:ue(Rf.Provider,{value:this.state,children:em(_f.Provider,{value:this.scene.getNonDeletedElements(),children:[em(Bf.Provider,{value:this.actionManager,children:[ue(c5,{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:Mo().code,renderTopRightUI:n,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===this.defaultSelectionTool&&!this.state.zenModeEnabled&&!this.scene.getElementsIncludingDeleted().length,app:this,isCollaborating:this.props.isCollaborating,generateLinkForSelection:this.props.generateLinkForSelection,children:this.props.children}),ue("div",{className:"excalidraw-textEditorContainer"}),ue("div",{className:"excalidraw-contextMenuContainer"}),ue("div",{className:"excalidraw-eye-dropper-container"}),ue(p5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&ue(UE,{element:m,scene:this.scene,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.props.aiEnabled!==!1&&t.length===1&&gf(m)&&ue($h,{element:m,elementsMap:a,children:ue(Xd,{title:g("labels.convertToCode"),icon:ts,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),t.length===1&&Gi(m)&&m.customData?.generationData?.status==="done"&&em($h,{element:m,elementsMap:a,children:[ue(Xd,{title:g("labels.copySource"),icon:Sr,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),ue(Xd,{title:"Enter fullscreen",icon:V0,checked:!1,onChange:()=>{let p=this.getHTMLIFrameElement(m);if(p)try{p.requestFullscreen(),this.setState({activeEmbeddable:{element:m,state:"active"},selectedElementIds:{[m.id]:!0},newElement:null,selectionElement:null})}catch(u){console.warn(u),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&ue(T5,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&ue(Sv,{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?.()})}}),ue(Jg,{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:fn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&ue(w5,{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}}),ue(qg,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,renderScrollbars:this.props.renderScrollbars===!0,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&ue(Mv,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&ue(I5,{app:this,activeLockedId:this.state.activeLockedId}),c&&ue(iy,{app:this})]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,n){let r=this.plugins.diagramToCode?.generate;if(!r){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=RH(this.scene.getNonDeletedElements(),t).filter(l=>!gf(l));if(!i.length){n==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),ne("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}}),ne("ai","generate (start)","d2c");try{let{html:l}=await r({frame:t,children:i});if(ne("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){ne("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"&&(no(t.customData.generationData.html),this.setToast({message:"copied to clipboard",closable:!1,duration:1500}))}clearImageShapeCache(t){let n=t??this.files;this.scene.getNonDeletedElements().forEach(r=>{ul(r)&&n[r.fileId]&&(this.imageCache.delete(r.fileId),fl.delete(r))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,Lf()||II()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...i)=>this.setState(...i)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onDurableIncrementEmitter.on(r=>{this.history.record(r.delta)});let{onIncrement:t}=this.props;t&&this.store.onStoreIncrementEmitter.on(r=>{t(r)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),Lf()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),B5&&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),Mz()&&!WH()&&this.setState({errorMessage:ue(vv,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new yI,this.fonts=new $o(this.scene),this.renderer=new ja(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(),fl.destroy(),Wt.destroy(),clearTimeout(Rn),Ee.clearCache(),$t.clearCache(),Rn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(_e(document,ee.KEYDOWN,this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(_e(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),_e(window,ee.MESSAGE,this.onWindowMessage,!1),_e(document,ee.POINTER_UP,this.removePointer,{passive:!1}),_e(document,ee.COPY,this.onCopy,{passive:!1}),_e(document,ee.KEYUP,this.onKeyUp,{passive:!0}),_e(document,ee.POINTER_MOVE,this.updateCurrentCursorPosition,{passive:!1}),_e(document.fonts,"loadingdone",t=>{let n=t.fontfaces;this.fonts.onLoaded(n)},{passive:!1}),_e(document,ee.GESTURE_START,this.onGestureStart,!1),_e(document,ee.GESTURE_CHANGE,this.onGestureChange,!1),_e(document,ee.GESTURE_END,this.onGestureEnd,!1),_e(window,ee.FOCUS,()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(_e(document,ee.FULLSCREENCHANGE,this.onFullscreenChange,{passive:!1}),_e(document,ee.PASTE,this.pasteFromClipboard,{passive:!1}),_e(document,ee.CUT,this.onCut,{passive:!1}),_e(window,ee.RESIZE,this.onResize,!1),_e(window,ee.UNLOAD,this.onUnload,!1),_e(window,ee.BLUR,this.onBlur,!1),_e(this.excalidrawContainerRef.current,ee.WHEEL,this.handleWheel,{passive:!1}),_e(this.excalidrawContainerRef.current,ee.DRAG_OVER,this.disableEvent,!1),_e(this.excalidrawContainerRef.current,ee.DROP,this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(_e(Xz(this.excalidrawContainerRef.current),ee.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,n){this.updateEmbeddables();let r=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!this.state.showWelcomeScreen&&!r.length&&this.setState({showWelcomeScreen:!0}),t.UIOptions.dockedSidebarBreakpoint!==this.props.UIOptions.dockedSidebarBreakpoint&&this.refreshEditorBreakpoints(),n.userToFollow&&!this.state.collaborators.has(n.userToFollow.socketId)&&this.maybeUnfollowRemoteUser(),(n.zoom.value!==this.state.zoom.value||n.scrollX!==this.state.scrollX||n.scrollY!==this.state.scrollY)&&(this.props?.onScrollChange?.(this.state.scrollX,this.state.scrollY,this.state.zoom),this.onScrollChangeEmitter.trigger(this.state.scrollX,this.state.scrollY,this.state.zoom)),n.userToFollow!==this.state.userToFollow&&(n.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:n.userToFollow,action:"UNFOLLOW"}),this.state.userToFollow&&this.onUserFollowEmitter.trigger({userToFollow:this.state.userToFollow,action:"FOLLOW"})),Object.keys(this.state.selectedElementIds).length&&bt(this.state)&&this.setState({activeTool:Vo(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&n.theme!==this.state.theme&&Rp(this.interactiveCanvas,this.state.theme),n.activeTool.type==="selection"&&this.state.activeTool.type!=="selection"&&this.state.showHyperlinkPopup&&this.setState({showHyperlinkPopup:!1}),t.langCode!==this.props.langCode&&this.updateLanguage(),bt(n)&&!bt(this.state)&&this.eraserTrail.endPath(),t.viewModeEnabled!==this.props.viewModeEnabled&&this.setState({viewModeEnabled:!!this.props.viewModeEnabled}),n.viewModeEnabled!==this.state.viewModeEnabled&&(this.addEventListeners(),this.deselectElements()),(n.openDialog?.name==="elementLinkSelector"||this.state.openDialog?.name==="elementLinkSelector")&&n.openDialog?.name!==this.state.openDialog?.name&&(this.deselectElements(),this.setState({hoveredElementIds:{}})),t.zenModeEnabled!==this.props.zenModeEnabled&&this.setState({zenModeEnabled:!!this.props.zenModeEnabled}),t.theme!==this.props.theme&&this.props.theme&&this.setState({theme:this.props.theme}),this.excalidrawContainerRef.current?.classList.toggle("theme--dark",this.state.theme===$d.DARK),this.state.selectedLinearElement?.isEditing&&!this.state.selectedElementIds[this.state.selectedLinearElement.elementId]&&setTimeout(()=>{this.state.selectedLinearElement?.isEditing&&this.actionManager.executeAction(wt)}),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.onChangeEmitter.trigger(r,this.state,this.files))}static resetTapTwice(){bl=!1,xl=null}async addElementsFromMixedContentPaste(t,{isPlainPaste:n,sceneX:r,sceneY:i}){if(!n&&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 E1(p)}}catch(u){let f=u.message;return u.cause==="FETCH_ERROR"?f=g("errors.failedToFetchImage"):u.cause==="UNSUPPORTED"&&(f=g("errors.unsupportedFileType")),{errorMessage:f}}})),s=i,d=!1,m={};for(let p of l)if(p.file){let u=await this.createImageElement({sceneX:r,sceneY:s,imageFile:p.file});u&&(d||(d=!0,s-=u.height/2),this.scene.mutateElement(u,{y:s},{informMutation:!1,isDragging:!1}),s=u.y+u.height+25,m[u.id]=!0)}this.setState({selectedElementIds:ye(m,this.state)});let c=l.find(p=>!!p.errorMessage);c&&c.errorMessage&&this.setState({errorMessage:c.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
110
117
 
111
- `),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=Fe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:xs,verticalAlign:Xm,locked:!1},l=qe({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=Ao(a.fontFamily),[c,,m]=Ip(this.state),d=Math.max(Math.min((m-c)*.5,800),200),p=10,u=i,f=r?[t]:t.split(`
112
- `),b=f.reduce((x,E,w)=>{let v=Fn(E).trim();if(v.length){let T=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),S=vt(v,l,s),k=S.width>d,D=k?Ti(v,l,d):v;S=k?vt(D,l,s):S;let M=n-S.width/2,O=u-S.height/2,P=Ot({...a,x:M,y:O,text:D,originalText:v,lineHeight:s,autoResize:!k,frameId:T?T.id:null});x.push(P),u+=P.height+p}else f[w-1]?.trim()&&(u+=R1(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.setState({selectedElementIds:Ce(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&F3===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:R("CtrlOrCmd+Shift+V")}),duration:5e3}),F3=!0),this.store.scheduleCapture())}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&&Y(s)?ne(s,{originalText:a,isDeleted:l??s.isDeleted,...wb(s,fo(s,n),n,a)}):s)])};wv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:c}=It({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:Xe(a=>{i(a,!1),Bp(t)&&$r(t,this.scene)}),onSubmit:Xe(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let c=t.containerId?t.containerId:t.id;Nr(()=>{this.setState(m=>({selectedElementIds:Ce({...m.selectedElementIds,[c]:!0},m)}))})}s&&tc(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.scheduleCapture(),Nr(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&lo(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:Ce({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&Y(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 wi({x:t,y:r,element:a,shape:yr(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||!(Y(c)&&c.containerId)))).filter(c=>this.hitElement(t,r,c)).filter(c=>{let m=Hn(c,l);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?fp({x:t,y:r},m,l):!0}).filter(c=>On(c)?(a.push(c),!1):!0).concat(a)}getElementHitThreshold(){return Mf/this.state.zoom.value}hitElement(t,r,n,i=!0){if(i&&this.state.selectedElementIds[n.id]&&mc([n],this.state)){let l=Gb(n,this.scene.getNonDeletedElementsMap(),Me(n)?0:this.getElementHitThreshold());if(pc(L(t,r),l))return!0}return I1(t,r,db(n,this.scene.getNonDeletedElementsMap()))?!0:wi({x:t,y:r,element:n,shape:yr(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 xr(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]=ht(n[l],this.scene.getNonDeletedElementsMap());if(Re(n[l])&&wi({x:t,y:r,element:n[l],shape:yr(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 xr(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=X.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;wi({x:r,y:n,element:a,shape:yr(a,this.scene.getNonDeletedElementsMap())})?(l=X.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=X.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(le(a)?l===0||l===a.points.length-1:l>=0)||s?ke(this.interactiveCanvas,we.POINTER):this.hitElement(r,n,a)&&(!le(a)||!(a.startBinding||a.endBinding))&&ke(this.interactiveCanvas,we.MOVE)):this.hitElement(r,n,a)&&(!le(a)||!(a.startBinding||a.endBinding))&&ke(this.interactiveCanvas,we.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),X.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else ke(this.interactiveCanvas,we.AUTO)}updateGestureOnPointerDown(t){Se.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),Se.pointers.size===2&&(Se.lastCenter=qh(Se.pointers),Se.initialScale=this.state.zoom.value,Se.initialDistance=Jh(Array.from(Se.pointers.values())))}initialPointerDownState(t){let r=Fe(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=Te(n),c=n.findIndex(le)===0;return{origin:r,withCmdOrCtrl:t[y.CTRL_OR_CMD],originInGrid:Gr(yt(r.x,r.y,t[y.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:og(ns,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((m,d)=>(m.set(d.id,zo(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,origin:{...r}},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;Kg=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=nm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=Xe(()=>{as=null,Kg=!1,lo(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 as=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]=Te(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:Yr(t)?xt.ADAPTIVE_RADIUS:xt.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){_r({event:t,app:this,selectedElements:r})&&(n||!Co.getReferenceSnapPoints())&&Co.setReferenceSnapPoints(nv(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){_r({event:t,app:this,selectedElements:r})&&(n||!Co.getVisibleGaps())&&Co.setVisibleGaps(rv(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Xe(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return Xe(r=>{r.key===y.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return nm(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=Fe(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=yt(n.x,n.y,r[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=X.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?X.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=X.moveFixedSegment(this.state.selectedLinearElement,f,p,u,this.scene);Nr(()=>{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=Gr(Eb(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(Zt(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=yt(n.x,n.y,r[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&An(L(n.x,n.y),L(t.origin.x,t.origin.y))<Sn)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(X.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,c)){let f=X.addMidpoint(this.state.selectedLinearElement,n,this,!r[y.CTRL_OR_CMD],this.scene);if(!f)return;Nr(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=X.handlePointDragging(r,this,n.x,n.y,(f,b)=>{this.maybeSuggestBindingsForLinearElementAtCoords(f,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)),f=this.getTopLayerFrameAtSceneCoords(n),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&Nr(()=>{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.drag.origin.x,y:n.y-t.drag.origin.y},E=[...t.originalElements.values()],w=r.shiftKey;if(w){let S=Math.abs(x.x),k=Math.abs(x.y),D=w&&S<k,M=w&&S>k;D&&(x.x=0),M&&(x.y=0)}if(this.state.croppingElementId){let S=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(S&&Me(S)&&S.crop!==null&&t.hit.element===S){let k=S.crop,D=fr(S)&&this.imageCache.get(S.fileId)?.image;if(D&&!(D instanceof Promise)){let M=jf(np(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[O,P,F,K,V,te]=ht(S,c),H=Ls(Oe(L(O,P),L(V,te),S.angle)),B=Ls(Oe(L(F,P),L(V,te),S.angle)),ee=Ls(Oe(L(O,K),L(V,te),S.angle)),oe=lp(ap(B,H)),Z=lp(ap(ee,H)),pe=np(ip(M,oe),ip(M,Z)),xe={...k,x:Et(k.x-pe[0]*Math.sign(S.scale[0]),0,D.naturalWidth-k.width),y:Et(k.y-pe[1]*Math.sign(S.scale[1]),0,D.naturalHeight-k.height)};this.scene.mutateElement(S,{crop:xe});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:v,snapLines:T}=iv(E,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:T}),this.state.editingFrame||xb(t,p,x,this.scene,v,r[y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!le(p[0]))&&this.setState({suggestedBindings:ec(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let S=this.scene.getElementsIncludingDeleted(),k=t.hit.element,D=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});k&&t.hit.wasAddedToSelection&&!D.find(B=>B.id===k.id)&&D.push(k);let M=new Map(D.map(B=>[B.id,B])),{duplicatedElements:O,duplicateElementsMap:P,elementsWithDuplicates:F,origIdToDuplicateId:K}=Wn({type:"in-place",elements:S,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:M,overrides:({duplicateElement:B,origElement:ee})=>({frameId:B.frameId??ee.frameId,seed:Nn()})});O.forEach(B=>{t.originalElements.set(B.id,zo(B))});let V=F.map(B=>{if(M.has(B.id)){let ee=t.originalElements.get(B.id);if(ee)return ne(B,{x:ee.x,y:ee.y})}return B}),te=this.props.onDuplicate?.(V,S),H=Qo(te||V,J(O));Nr(()=>{if(t.hit.element){let B=K.get(t.hit.element.id),ee=B&&P.get(B);t.hit.element=ee||null}t.hit.allHitElements=t.hit.allHitElements.reduce((B,ee)=>{let oe=K.get(ee.id),Z=oe&&P.get(oe);return Z&&B.push(Z),B},[]),t.drag.origin=Fe(r,this.state),this.setState(B=>({...Ks(O,this.scene.getNonDeletedElements(),B)})),this.scene.replaceAllElements(H),this.maybeCacheVisibleGaps(r,D,!0),this.maybeCacheReferenceSnapPoints(r,D,!0)})}return}}if(this.state.selectionElement)t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey?Nr(()=>{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,f=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let w=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];this.scene.mutateElement(p,{points:[...u,L(f,b)],pressures:w},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(fe(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;Ms(r)&&u.length===2&&({width:f,height:b}=kp(p.x,p.y,n.x,n.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,L(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&le(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),L(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),br(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)X.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&Ne(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>nt({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?j1(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((E,w)=>(E[w.id]=!0,E),{})};return t.hit.element&&(f.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...nt({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&fe(f[0])?new X(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||Nt(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(ns.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(ns.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return Xe(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:yi(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Co.setReferenceSnapPoints(null),Co.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up"),this.setState({selectedElementsAreBeingDragged:!1});let p=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let x=p.get(t.hit.element.id);b1(x)&&x.boundElements?.filter(E=>E.type==="arrow").map(E=>p.get(E.id)).filter(E=>le(E)).forEach(E=>{E&&this.scene.mutateElement(E,{})})}if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(so);else{let x=X.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=X.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&this.scene.mutateElement(x,{})}if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let x=X.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene),{startBindingElement:E,endBindingElement:w}=x,v=this.scene.getElement(x.elementId);br(v)&&Qs(v,E,w,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=Fe(r,this.state),E=n.points,w=x.x-n.x,v=x.y-n.y;w===E[0][0]&&v===E[0][1]&&(v+=1e-4,w+=1e-4);let T=n.simulatePressure?[]:[...n.pressures,r.pressure];this.scene.mutateElement(n,{points:[...E,L(w,v)],pressures:T,lastCommittedPoint:L(w,v)}),this.actionManager.executeAction(so);return}if(Me(n)){let x=n;try{this.initializeImageDimensions(x),this.setState({selectedElementIds:Ce({[x.id]:!0},this.state)},()=>{this.actionManager.executeAction(so)})}catch(E){console.error(E),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(w=>w.id!==x.id)),this.actionManager.executeAction(so)}return}if(fe(n)){n.points.length>1&&this.store.scheduleCapture();let x=Fe(r,this.state);!t.drag.hasOccurred&&n&&!l?(this.scene.mutateElement(n,{points:[...n.points,L(x.x-n.x,x.y-n.y)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:n,newElement:n})):t.drag.hasOccurred&&!l&&(Un(this.state)&&br(n,!1)&&Ja(n,this.state,x,this.scene),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(E=>({newElement:null})):(ao(this.interactiveCanvas),this.setState(E=>({newElement:null,activeTool:De(this.state,{type:"selection"}),selectedElementIds:Ce({...E.selectedElementIds,[n.id]:!0},E),selectedLinearElement:new X(n,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(Y(n)){let x=D1(qe({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<x&&this.scene.mutateElement(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&Gn(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=tb(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Si(this.scene.getElementsMapIncludingDeleted(),x,n,this.state))}if(n&&(this.scene.mutateElement(n,pb(n),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=Fe(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=Hn(E,p);w&&E&&(q1(E,w,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(E,{groupIds:[]}),Zs([E],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let E=this.getTopLayerFrameAtSceneCoords(x),w=this.scene.getSelectedElements(this.state),v=this.scene.getElementsMapIncludingDeleted(),T=S=>{if(S.length>0){for(let k of S){let D=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,D)},{informMutation:!1,isDragging:!1})}v.forEach(k=>{k.groupIds.length&&$e(v,k.groupIds[k.groupIds.length-1]).length<2&&this.scene.mutateElement(k,{groupIds:[]},{informMutation:!1,isDragging:!1})}),this.setState({editingGroupId:null})}};if(E&&!this.state.selectedElementIds[E.id]){let S=w.filter(k=>k.frameId!==E.id&&bp(k,v,this.state));this.state.editingGroupId&&T(S),v=Si(v,S,E,this.state)}else if(!E&&this.state.editingGroupId){let S=w.filter(k=>k.frameId&&!bp(k,v,this.state));T(S)}v=qo(v,this.state,this),this.scene.replaceAllElements(v)}}if(i&&this.store.scheduleCapture(),i&&Gn(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),captureUpdate:A.NEVER}),t.resize.isResizing){let x=qo(this.scene.getElementsIncludingDeleted(),this.state,this),E=this.scene.getSelectedElements(this.state).filter(w=>ae(w));for(let w of E)x=Xs(x,ki(this.scene.getElementsIncludingDeleted(),w,this.state,p),w,this);this.scene.replaceAllElements(x)}let u=t.hit.element;this.state.selectedLinearElement?.elementId!==u?.id&&fe(u)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new X(u,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!u&&!d||u&&u.id!==a))&&this.finishImageCropping();let f=this.lastPointerDownEvent,b=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(Zt(this.state)&&f&&b){if(this.eraserTrail.endPath(),An(L(f.clientX,f.clientY),L(b.clientX,b.clientY))===0){let E=Fe({clientX:b.clientX,clientY:b.clientY},this.state);this.getElementsAtPosition(E.x,E.y).forEach(v=>this.elementsPendingErasure.add(v.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]?Vs(this.state,u)?this.setState(x=>{let E={...x.selectedElementIds};for(let w of u.groupIds.flatMap(v=>$e(this.scene.getNonDeletedElements(),v)))delete E[w.id];return{selectedGroupIds:{...x.selectedElementIds,...u.groupIds.map(w=>({[w]:!1})).reduce((w,v)=>({...w,...v}),{})},selectedElementIds:Ce(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{...nt({editingGroupId:x.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:w.length===1&&fe(w[0])?new X(w[0],this.scene.getNonDeletedElementsMap()):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=>$e(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete E[w.id]}),{...nt({editingGroupId:x.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:u.link||Nt(u)?"info":!1}}):this.setState(x=>({selectedElementIds:Ce({...x.selectedElementIds,[u.id]:!0},x)})):this.setState(x=>({...nt({editingGroupId:x.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:fe(u)&&x.selectedLinearElement?.elementId!==u.id?new X(u,this.scene.getNonDeletedElementsMap()):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(u&&le(u))&&!t.drag.hasOccurred&&!this.state.isResizing&&(u&&C1({x:t.origin.x,y:t.origin.y,element:u,shape:yr(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:Ce({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),ke(this.interactiveCanvas,we.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(x=>({selectedElementIds:Ce({...x.selectedElementIds,[n.id]:!0},x),showHyperlinkPopup:Nt(n)&&!n.link?"editor":x.showHyperlinkPopup})),(s.type!=="selection"||Ne(this.scene.getNonDeletedElements(),this.state)||!rt(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred||c||m||d){let x=this.scene.getSelectedElements(this.state).filter(fe);qa(x,Un(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)?(ao(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:De(this.state,{type:"selection"})})):this.setState({newElement:null,suggestedBindings:[]}),u&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&Se.pointers.size<=1&&vi(u)&&this.isIframeLikeElementCenter(u,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(u)})}clearSelection(t){this.setState(r=>({selectedElementIds:Ce({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&Ii(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Ce({},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=Gs(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<Sf){let{x:d,y:p}=It({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=Fi.find(r=>r.code===this.props.langCode)||tr;await kc(t),this.setAppState({})}},j8=()=>{(jo()||pt())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(wr(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};j8();var W3=Xg;import{useEffect as J8,useState as Q8}from"react";import{jsx as e7}from"react/jsx-runtime";var V3=e=>{let[o,t]=Q8(!0);return J8(()=>{let r=async()=>{await kc(n),t(!1)},n=Fi.find(i=>i.code===e.langCode)||tr;r()},[e.langCode]),o?e7(lm,{theme:e.theme}):e.children};import t7 from"clsx";import{jsx as Y3}from"react/jsx-runtime";var K3=({children:e})=>{let{FooterCenterTunnel:o}=Ue(),t=Le();return Y3(o.In,{children:Y3("div",{className:t7("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},o7=K3;K3.displayName="FooterCenter";import r7 from"clsx";import{jsx as i7,jsxs as a7}from"react/jsx-runtime";var Z3=({isCollaborating:e,onSelect:o,...t})=>{let r=Le(),n=r.width<830;return a7(co,{...t,className:r7("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:g("labels.liveCollaboration"),children:[n?W0:g("labels.share"),r.collaborators.size>0&&i7("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},n7=Z3;Z3.displayName="LiveCollaborationTrigger";import{jsx as In,jsxs as $3}from"react/jsx-runtime";var l7=()=>In("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:In("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"})}),s7=()=>$3("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[In("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)"}),In("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)"}),In("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)"}),In("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)"})]}),X3=({style:e,size:o="small",withText:t})=>$3("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[In(l7,{}),t&&In(s7,{})]});import{Fragment as J3,jsx as ct,jsxs as tf}from"react/jsx-runtime";var of=({icon:e,shortcut:o,children:t})=>{let r=be();return tf(J3,{children:[ct("div",{className:"welcome-screen-menu-item__icon",children:e}),ct("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&ct("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};of.displayName="WelcomeScreenMenuItemContent";var ls=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>ct("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:ct(of,{icon:t,shortcut:r,children:o})});ls.displayName="WelcomeScreenMenuItem";var j3=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>ct("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noopener",children:ct(of,{icon:t,shortcut:r,children:e})});j3.displayName="WelcomeScreenMenuItemLink";var Mo=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Ue();return ct(o.In,{children:ct("div",{className:"welcome-screen-center",children:e||tf(J3,{children:[ct(rf,{}),ct(nf,{children:g("welcomeScreen.defaults.center_heading")}),tf(af,{children:[ct(sf,{}),ct(lf,{})]})]})})})};Mo.displayName="Center";var rf=({children:e})=>ct("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||ct(X3,{withText:!0})});rf.displayName="Logo";var nf=({children:e})=>ct("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});nf.displayName="Heading";var af=({children:e})=>ct("div",{className:"welcome-screen-menu",children:e});af.displayName="Menu";var lf=()=>{let e=lt();return ct(ls,{onSelect:()=>e.executeAction(ni),shortcut:"?",icon:Wi,children:g("helpDialog.title")})};lf.displayName="MenuItemHelp";var sf=()=>{let e=Le(),o=lt();return e.viewModeEnabled?null:ct(ls,{onSelect:()=>o.executeAction(na),shortcut:Qe("loadScene"),icon:Vi,children:g("buttons.load")})};sf.displayName="MenuItemLoadScene";var q3=({onSelect:e})=>{let{t:o}=ot();return ct(ls,{shortcut:null,onSelect:e,icon:Nc,children:o("labels.liveCollaboration")})};q3.displayName="MenuItemLiveCollaborationTrigger";Mo.Logo=rf;Mo.Heading=nf;Mo.Menu=af;Mo.MenuItem=ls;Mo.MenuItemLink=j3;Mo.MenuItemHelp=lf;Mo.MenuItemLoadScene=sf;Mo.MenuItemLiveCollaborationTrigger=q3;import{jsx as Ra,jsxs as cf}from"react/jsx-runtime";var Um=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Ue();return Ra(o.In,{children:cf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[T0,Ra("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};Um.displayName="MenuHint";var Gm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Ue();return Ra(o.In,{children:cf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Ra("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),I0]})})};Gm.displayName="ToolbarHint";var Wm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Ue();return Ra(o.In,{children:cf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Ra("div",{children:e||g("welcomeScreen.defaults.helpHint")}),C0]})})};Wm.displayName="HelpHint";import{Fragment as Q3,jsx as ss,jsxs as d7}from"react/jsx-runtime";var Vm=e=>ss(Q3,{children:e.children||d7(Q3,{children:[ss(Mo,{}),ss(Um,{}),ss(Gm,{}),ss(Wm,{})]})});Vm.displayName="WelcomeScreen";Vm.Center=Mo;Vm.Hints={MenuHint:Um,ToolbarHint:Gm,HelpHint:Wm};var c7=Vm;var m7=()=>{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)})},e5=m7;import p7 from"lodash.throttle";var u7=(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)),h7=p7((e,o,t)=>{if(pt()||jo()||window?.DEBUG_FRACTIONAL_INDICES){let r=wr(e.map(n=>({...n})));fb(r,{shouldThrow:jo()||pt(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),g7=(e,o,t)=>{let r=J(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),c=u7(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=ic(n);return h7(a,e,o),wr(a),a};import{jsx as t5,jsxs as f7}from"react/jsx-runtime";var o5=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=Ue(),r=ye();return t5(t.In,{children:f7(Ae.Item,{onSelect:()=>{de("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??Fx,children:[e??g("labels.textToDiagram"),t5(Ae.Item.Badge,{children:"AI"})]})})};o5.displayName="TTDDialogTrigger";import{useLayoutEffect as b7}from"react";var x7=e=>{let o=Je();return b7(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{jsx as df}from"react/jsx-runtime";e5();var v7=e=>{let{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=tr.code,viewModeEnabled:c,zenModeEnabled:m,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:E=!0,handleKeyboardGlobally:w=!1,onLibraryChange:v,autoFocus:T=!1,generateIdForFile:S,onLinkOpen:k,generateLinkForSelection:D,onPointerDown:M,onPointerUp:O,onScrollChange:P,onDuplicate:F,children:K,validateEmbeddable:V,renderEmbeddable:te,aiEnabled:H,showDeprecatedFonts:B,renderScrollbars:ee}=e,oe=e.UIOptions?.canvasActions,Z={...e.UIOptions,canvasActions:{...Jm.canvasActions,...oe},tools:{image:e.UIOptions?.tools?.image??!0}};return oe?.export&&(Z.canvasActions.export.saveFileToDisk=oe.export?.saveFileToDisk??Jm.canvasActions.export.saveFileToDisk),Z.canvasActions.toggleTheme===null&&typeof u>"u"&&(Z.canvasActions.toggleTheme=!0),y7(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let xe=ve=>{typeof ve.scale=="number"&&ve.scale!==1&&ve.preventDefault()};return document.addEventListener("touchmove",xe,{passive:!1}),()=>{document.removeEventListener("touchmove",xe)}},[]),df(f0,{store:it,children:df(V3,{langCode:s,theme:u,children:df(W3,{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:c,zenModeEnabled:m,gridModeEnabled:d,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:Z,onPaste:x,detectScroll:E,handleKeyboardGlobally:w,onLibraryChange:v,autoFocus:T,generateIdForFile:S,onLinkOpen:k,generateLinkForSelection:D,onPointerDown:M,onPointerUp:O,onScrollChange:P,onDuplicate:F,validateEmbeddable:V,renderEmbeddable:te,aiEnabled:H!==!1,showDeprecatedFonts:B,renderScrollbars:ee,children:K})})})},w7=(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])&&rt(n,l)},T7=E7.memo(v7,w7);T7.displayName="Excalidraw";export{co as Button,A as CaptureUpdateAction,Zm as DEFAULT_LASER_COLOR,Tm as DefaultSidebar,x7 as DiagramToCodePlugin,T7 as Excalidraw,dt as FONT_FAMILY,o7 as Footer,n7 as LiveCollaborationTrigger,ce as MIME_TYPES,Pt as MainMenu,xt as ROUNDNESS,So as Sidebar,Jl as Stats,re as THEME,_g as TTDDialog,o5 as TTDDialogTrigger,Zf as UserIdleState,c7 as WelcomeScreen,Er as bumpVersion,Ca as convertToExcalidrawElements,tr as defaultLang,l5 as elementPartiallyOverlapsWithOrContainsBBox,s5 as elementsOverlappingBBox,H2 as exportToBlob,mn as exportToCanvas,FT as exportToClipboard,ga as exportToSvg,Te as getCommonBounds,wc as getDataURL,c5 as getFreeDrawSvgPath,Rd as getLibraryItemsHash,ue as getNonDeletedElements,d5 as getSceneVersion,up as getTextFromElements,Ip as getVisibleSceneBounds,Op as hashElementsVersion,zp as hashString,a5 as isElementInsideBBox,Vn as isElementLink,Gn as isInvisiblySmallElement,fe as isLinearElement,Fi as languages,vc as loadFromBlob,Kp as loadLibraryFromBlob,Yp as loadSceneOrLibraryFromBlob,Z2 as mergeLibraryItems,Oo as mutateElement,ne as newElementWith,Po as normalizeLink,Mh as parseLibraryTokensFromUrl,g7 as reconcileElements,zi as restore,m5 as restoreAppState,Vp as restoreElements,ll as restoreLibraryItems,It as sceneCoordsToViewportCoords,nl as serializeAsJSON,Wp as serializeLibraryAsJSON,i5 as setCustomTextMetricsProvider,be as useDevice,YT as useHandleLibrary,ot as useI18n,Fe as viewportCoordsToSceneCoords,ZE as zoomToFitBounds};
118
+ `),n)}}addTextFromPaste(t,n=!1){let{x:r,y:i}=Oe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),a={x:r,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roundness:null,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,text:t,fontSize:this.state.currentItemFontSize,fontFamily:this.state.currentItemFontFamily,textAlign:Gz,verticalAlign:_5,locked:!1},l=rf({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=O5(a.fontFamily),[d,,m]=OH(this.state),c=Math.max(Math.min((m-d)*.5,800),200),p=10,u=i,f=n?[t]:t.split(`
119
+ `),b=f.reduce((x,w,E)=>{let y=VH(w).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:r,y:u}),C=pI(y,l,s),S=C.width>c,L=S?UH(y,l,c):y;C=S?pI(L,l,s):C;let k=r-C.width/2,A=u-C.height/2,P=$5({...a,x:k,y:A,text:L,originalText:y,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(P),u+=P.height+p}else f[E-1]?.trim()&&(u+=XH(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.store.scheduleCapture(),this.setState({selectedElementIds:ye(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!n&&b.length>1&&TI===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:$z("CtrlOrCmd+Shift+V")}),duration:5e3}),TI=!0))}handleTextWysiwyg(t,{isExistingElement:n=!1}){let r=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&mo(s)?sr(s,{originalText:a,isDeleted:l??s.isDeleted,...fH(s,lI(s,r),r,a)}):s)])};sv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:d}=qd({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Pe(a=>{i(a,!1),EI(t)&&df(t,this.scene)}),onSubmit:Pe(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let d=t.containerId?t.containerId:t.id;Fi(()=>{this.setState(m=>({selectedElementIds:ye({...m.selectedElementIds,[d]:!0},m)}))})}s&&lH(this.scene.getNonDeletedElements(),[t]),(!s||n)&&this.store.scheduleCapture(),Fi(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Dt(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:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,n){let r=this.getElementAtPosition(t,n,{includeBoundTextElement:!0});return r&&mo(r)&&!r.isDeleted?r:null}getElementAtPosition(t,n,r){let i=[];if(r&&"allHitElements"in r?i=r?.allHitElements||[]:i=this.getElementsAtPosition(t,n,{includeBoundTextElement:r?.includeBoundTextElement,includeLockedElements:r?.includeLockedElements}),i.length>1){if(r?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return gl({point:re(t,n),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Mt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,n,r){let i=[],a=this.scene.getNonDeletedElementsMap();return(r?.includeBoundTextElement&&r?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(r?.includeLockedElements||!s.locked)&&(r?.includeBoundTextElement||!(mo(s)&&s.containerId)))).filter(s=>this.hitElement(t,n,s)).filter(s=>{let d=Tf(s,a);return d&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?sI({x:t,y:n},d,a):!0}).filter(s=>Gi(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(F5/this.state.zoom.value))}hitElement(t,n,r,i=!0){return i&&this.state.selectedElementIds[r.id]&&MH([r],this.state)&&cG(re(t,n),r,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(r))||BH(re(t,n),r,this.scene.getNonDeletedElementsMap())?!0:gl({point:re(t,n),element:r,threshold:this.getElementHitThreshold(r),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Mt(r)?this.frameNameBoundsCache.get(r):null})}getTextBindableContainerAtPosition(t,n){let r=this.scene.getNonDeletedElements(),i=this.scene.getSelectedElements(this.state);if(i.length===1)return eI(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,d,m,c]=V5(r[l],this.scene.getNonDeletedElementsMap());if(pf(r[l])&&gl({point:re(t,n),element:r[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(r[l])})){a=r[l];break}else if(s<t&&t<m&&d<n&&n<c){a=r[l];break}}return eI(a,!1)?a:null}handleHoverSelectedLinearElement(t,n,r){let i=this.scene.getNonDeletedElementsMap(),a=Se.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;gl({point:re(n,r),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Se.getPointIndexUnderCursor(a,i,this.state.zoom,n,r),s=Se.getSegmentMidpointHitCoords(t,{x:n,y:r},this.state,this.scene.getNonDeletedElementsMap()),(We(a)?l===0||l===a.points.length-1:l>=0)||s?xe(this.interactiveCanvas,De.POINTER):this.hitElement(n,r,a)&&(!We(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&xe(this.interactiveCanvas,De.MOVE)):this.hitElement(n,r,a)&&(!We(a)||!(a.startBinding||a.endBinding))&&(this.state.activeTool.type!=="lasso"||Object.keys(this.state.selectedElementIds).length>0)&&xe(this.interactiveCanvas,De.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),Se.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else xe(this.interactiveCanvas,De.AUTO)}updateGestureOnPointerDown(t){pe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),pe.pointers.size===2&&(pe.lastCenter=Ah(pe.pointers),pe.initialScale=this.state.zoom.value,pe.initialDistance=Dh(Array.from(pe.pointers.values())))}initialPointerDownState(t){let n=Oe(t,this.state),r=this.scene.getSelectedElements(this.state),[i,a,l,s]=Hi(r),d=r.findIndex(We)===0;return{origin:n,withCmdOrCtrl:t[Y.CTRL_OR_CMD],originInGrid:af(rt(n.x,n.y,t[Y.CTRL_OR_CMD]||d?null:this.getEffectiveGridSize())),scrollbars:Hh(yl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...n},originalElements:this.scene.getNonDeletedElements().reduce((m,c)=>(m.set(c.id,j5(c)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(n,r)},drag:{hasOccurred:!1,offset:null,origin:{...n},blockDragging:!1},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,n){if(!(n.scrollbars.isOverEither&&!this.state.multiElement))return!1;kf=!0,n.lastCoords.x=t.clientX,n.lastCoords.y=t.clientY;let r=od(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,n)}),i=Pe(()=>{vl=null,kf=!1,Dt(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,r),window.removeEventListener(ee.POINTER_UP,i),r.flush()});return vl=i,window.addEventListener(ee.POINTER_MOVE,r),window.addEventListener(ee.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,n){if(n.length<2)return!1;let r=Math.max(F5/this.state.zoom.value,1),[i,a,l,s]=Hi(n);return t.x>i-r&&t.x<l+r&&t.y>a-r&&t.y<s+r}getCurrentItemRoundness(t){return this.state.currentItemRoundness==="round"?{type:xH(t)?Zd.ADAPTIVE_RADIUS:Zd.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,n,r=!1){Ho({event:t,app:this,selectedElements:n})&&(r||!Wt.getReferenceSnapPoints())&&Wt.setReferenceSnapPoints(Iw(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,n,r=!1){Ho({event:t,app:this,selectedElements:n})&&(r||!Wt.getVisibleGaps())&&Wt.setVisibleGaps(Tw(this.scene.getNonDeletedElements(),n,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Pe(n=>{this.maybeHandleResize(t,n)||this.maybeDragNewGenericElement(t,n)})}onKeyUpFromPointerDownHandler(t){return Pe(n=>{n.key===Y.ALT&&n.preventDefault(),!this.maybeHandleResize(t,n)&&this.maybeDragNewGenericElement(t,n)})}onPointerMoveFromPointerDownHandler(t){return od(n=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let r=Oe(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]=rt(r.x,r.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),f=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(f<0){let x=Se.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());f=x?Se.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=Se.moveFixedSegment(this.state.selectedLinearElement,f,p,u,this.scene);this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:b.segmentMidPointHoveredCoords,pointerDownState:b.pointerDownState}});return}let i=this.lastPointerMoveCoords??t.origin;if(this.lastPointerMoveCoords=r,t.drag.offset===null&&(t.drag.offset=af(lG(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(n.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(n,t))return;if(bt(this.state)){this.handleEraser(n,r);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(r.x,r.y);let[l,s]=rt(r.x,r.y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Pn(re(r.x,r.y),re(t.origin.x,t.origin.y))*this.state.zoom.value<Y5)return;if(t.resize.isResizing&&(t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeHandleCrop(t,n)||this.maybeHandleResize(t,n)))return!0;let d=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Se.shouldAddMidpoint(this.state.selectedLinearElement,r,this.state,d)){let f=Se.addMidpoint(this.state.selectedLinearElement,r,this,!n[Y.CTRL_OR_CMD],this.scene);if(!f)return;Fi(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:f.pointerDownState,selectedPointsIndices:f.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=Se.handlePointDragging(n,this,r.x,r.y,p);if(u){t.lastCoords.x=r.x,t.lastCoords.y=r.y,t.drag.hasOccurred=!0,this.setState(u);return}}let m=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),c=this.state.selectedLinearElement?.isEditing&&n.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c&&!t.drag.blockDragging){let p=this.scene.getSelectedElements(this.state);if(p.length>0&&p.every(x=>x.locked))return;let u=p.find(x=>Mt(x)),f=this.getTopLayerFrameAtSceneCoords(r),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&Fi(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,this.state.activeTool.type==="lasso"&&this.lassoTrail.hasCurrentTrail&&!(this.isMobileOrTablet()&&t.hit.element)&&!this.state.activeTool.fromSelection)return;if(this.state.activeTool.type==="lasso"&&p.length>0&&t.drag.hasOccurred&&!this.state.activeTool.fromSelection&&this.lassoTrail.endPath(),p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:r.x-t.drag.origin.x,y:r.y-t.drag.origin.y},w=[...t.originalElements.values()],E=n.shiftKey;if(E){let C=Math.abs(x.x),S=Math.abs(x.y),L=E&&C<S,k=E&&C>S;L&&(x.x=0),k&&(x.y=0)}if(this.state.croppingElementId){let C=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(C&&cr(C)&&C.crop!==null&&t.hit.element===C){let S=C.crop,L=ul(C)&&this.imageCache.get(C.fileId)?.image;if(L&&!(L instanceof Promise)){let k=yz(k5(r.x-i.x,r.y-i.y),Math.max(this.state.zoom.value,2)),[A,P,N,O,U,J]=V5(C,d),_=ef(Qg(re(A,P),re(U,J),C.angle)),R=ef(Qg(re(N,P),re(U,J),C.angle)),V=ef(Qg(re(A,O),re(U,J),C.angle)),Z=P5(M5(R,_)),W=P5(M5(V,_)),ce=k5(L5(k,Z),L5(k,W)),he={...S,x:S5(S.x-ce[0]*Math.sign(C.scale[0]),0,L.naturalWidth-S.width),y:S5(S.y-ce[1]*Math.sign(C.scale[1]),0,L.naturalHeight-S.height)};this.scene.mutateElement(C,{crop:he});return}}}this.maybeCacheVisibleGaps(n,p),this.maybeCacheReferenceSnapPoints(n,p);let{snapOffset:y,snapLines:v}=Cw(w,x,this,n,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||aG(t,p,x,this.scene,y,n[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!We(p[0]))&&this.setState({suggestedBindings:mf(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),n.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,L=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!L.find(R=>R.id===S.id)&&L.push(S);let k=new Map(L.map(R=>[R.id,R])),{duplicatedElements:A,duplicateElementsMap:P,elementsWithDuplicates:N,origIdToDuplicateId:O}=q5({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:R,origElement:V})=>({frameId:R.frameId??V.frameId,seed:oH()})});A.forEach(R=>{t.originalElements.set(R.id,j5(R))});let U=N.map(R=>{if(k.has(R.id)){let V=t.originalElements.get(R.id);if(V)return sr(R,{x:V.x,y:V.y})}return R}),J=this.props.onDuplicate?.(U,C),_=hI(J||U,U5(A));Fi(()=>{if(t.hit.element){let R=O.get(t.hit.element.id),V=R&&P.get(R);t.hit.element=V||null}t.hit.allHitElements=t.hit.allHitElements.reduce((R,V)=>{let Z=O.get(V.id),W=Z&&P.get(Z);return W&&R.push(W),R},[]),t.drag.origin=Oe(n,this.state),this.setState(R=>({...oG(A,this.scene.getNonDeletedElements(),R)})),this.scene.replaceAllElements(_),this.maybeCacheVisibleGaps(n,L,!0),this.maybeCacheReferenceSnapPoints(n,L,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=r.x,t.lastCoords.y=r.y,n.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},n.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,n.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,n)}else if(this.state.activeTool.type==="lasso")!n.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(r.x,r.y,n.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=r.x-p.x,b=r.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let E=p.simulatePressure?p.pressures:[...p.pressures,n.pressure];this.scene.mutateElement(p,{points:[...u,re(f,b)],pressures:E},{informMutation:!1,isDragging:!1}),this.setState({newElement:p})}}else if(Zt(p)){t.drag.hasOccurred=!0;let u=p.points,f=l-p.x,b=s-p.y;tf(n)&&u.length===2&&({width:f,height:b}=tI(p.x,p.y,r.x,r.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,re(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&We(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),re(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),uf(p,!1)&&this.setState({suggestedBindings:W5(p,[r],this.scene,this.state.zoom,this.state.startBoundElement)})}else t.lastCoords.x=r.x,t.lastCoords.y=r.y,this.maybeDragNewGenericElement(t,n,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Se.handleBoxSelection(n,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!n.shiftKey&&Ee(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>$t({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?Qf(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...f.reduce((w,E)=>(w[E.id]=!0,w),{})};return t.hit.element&&(f.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...$t({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:f.length===1&&Zt(f[0])?new Se(f[0],this.scene.getNonDeletedElementsMap()):null,showHyperlinkPopup:f.length===1&&(f[0].link||Xo(f[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,n){if(n.scrollbars.isOverHorizontal){let r=t.clientX,i=r-n.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i*(yl.horizontal?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.x=r,!0}if(n.scrollbars.isOverVertical){let r=t.clientY,i=r-n.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i*(yl.vertical?.deltaMultiplier||1)/this.state.zoom.value}),n.lastCoords.y=r,!0}return!1}onPointerUpFromPointerDownHandler(t){return Pe(n=>{this.removePointer(n),t.drag.blockDragging=!1,t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:r,resizingElement:i,croppingElementId:a,multiElement:l,activeTool:s,isResizing:d,isRotating:m,isCropping:c}=this.state;this.setState(E=>({isResizing:!1,isRotating:!1,isCropping:!1,resizingElement:null,selectionElement:null,frameToHighlight:null,elementsToHighlight:null,cursorButton:"up",snapLines:pl(E.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,Wt.setReferenceSnapPoints(null),Wt.setVisibleGaps(null),this.savePointer(n.clientX,n.clientY,"up");let p=t.hit.allHitElements,u=Oe({clientX:n.clientX,clientY:n.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!p.some(E=>this.state.selectedElementIds[E.id])){let E=this.getElementAtPosition(u.x,u.y,{includeLockedElements:!0});this.store.scheduleCapture(),E?.locked?this.setState({activeLockedId:E.groupIds.length>0?E.groupIds.at(-1)||"":E.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});this.setState({selectedElementsAreBeingDragged:!1});let f=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let E=f.get(t.hit.element.id);yH(E)&&E.boundElements?.filter(y=>y.type==="arrow").map(y=>f.get(y.id)).filter(y=>We(y)).forEach(y=>{y&&this.scene.mutateElement(y,{})})}if(this.state.selectedLinearElement?.isEditing)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.actionManager.executeAction(wt);else{let E=Se.handlePointerUp(n,this.state.selectedLinearElement,this.state,this.scene);E!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=Se.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());E&&this.scene.mutateElement(E,{})}t.hit?.element?.id!==this.state.selectedLinearElement.elementId?this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null}):this.state.selectedLinearElement.isDragging&&this.actionManager.executeAction(wt,"ui",{event:n,sceneCoords:u})}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener(ee.POINTER_MOVE,t.eventListeners.onMove),window.removeEventListener(ee.POINTER_UP,t.eventListeners.onUp),window.removeEventListener(ee.KEYDOWN,t.eventListeners.onKeyDown),window.removeEventListener(ee.KEYUP,t.eventListeners.onKeyUp),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,n),r?.type==="freedraw"){let E=Oe(n,this.state),y=r.points,v=E.x-r.x,C=E.y-r.y;v===y[0][0]&&C===y[0][1]&&(C+=1e-4,v+=1e-4);let S=r.simulatePressure?[]:[...r.pressures,n.pressure];this.scene.mutateElement(r,{points:[...y,re(v,C)],pressures:S,lastCommittedPoint:re(v,C)}),this.actionManager.executeAction(wt);return}if(Zt(r)){r.points.length>1&&this.store.scheduleCapture();let E=Oe(n,this.state),y=Pn(re(E.x,E.y),re(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||y<Y5)&&r&&!l)if(this.device.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(r,{x:r.x-v/2,points:[re(0,0),re(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(wt)}else{let v=E.x-r.x,C=E.y-r.y;this.scene.mutateElement(r,{points:[...r.points,re(v,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:r,newElement:r})}else t.drag.hasOccurred&&!l&&(cf(this.state)&&uf(r,!1)&&this.actionManager.executeAction(wt,"ui",{event:n,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(Ht(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:Vo(this.state,{type:this.defaultSelectionTool}),selectedElementIds:ye({...v.selectedElementIds,[r.id]:!0},v),selectedLinearElement:new Se(r,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(mo(r)){let E=$H(rf({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&&nI(r)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==r.id),appState:{newElement:null},captureUpdate:mt.NEVER});return}if(Mt(r)){let E=AH(this.scene.getElementsIncludingDeleted(),r,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(wf(this.scene.getElementsMapIncludingDeleted(),E,r,this.state))}if(r&&(this.scene.mutateElement(r,wH(r),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=Oe(n,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let v=Tf(y,f);v&&y&&(DH(y,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),PH([y],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let y=this.getTopLayerFrameAtSceneCoords(E),v=this.scene.getSelectedElements(this.state),C=this.scene.getElementsMapIncludingDeleted(),S=L=>{if(L.length>0){for(let k of L){let A=k.groupIds.indexOf(this.state.editingGroupId);this.scene.mutateElement(k,{groupIds:k.groupIds.slice(0,A)},{informMutation:!1,isDragging:!1})}C.forEach(k=>{k.groupIds.length&&dr(C,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 L=v.filter(k=>k.frameId!==y.id&&dI(k,C,this.state));this.state.editingGroupId&&S(L),C=wf(C,L,y,this.state)}else if(!y&&this.state.editingGroupId){let L=v.filter(k=>k.frameId&&!dI(k,C,this.state));S(L)}C=cI(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&nI(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:mt.NEVER}),t.resize.isResizing){let E=cI(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(v=>Mt(v));for(let v of y)E=LH(E,vf(this.scene.getElementsIncludingDeleted(),v,this.state,f),v,this);this.scene.replaceAllElements(E)}let b=t.hit.element;this.state.selectedLinearElement?.elementId!==b?.id&&Zt(b)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new Se(b,this.scene.getNonDeletedElementsMap())}),(!a||a&&(!b&&!c||b&&b.id!==a))&&this.finishImageCropping();let x=this.lastPointerDownEvent,w=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(bt(this.state)&&x&&w){if(this.eraserTrail.endPath(),Pn(re(x.clientX,x.clientY),re(w.clientX,w.clientY))===0){let y=Oe({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(n.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?eG(this.state,b)?this.setState(E=>{let y={...E.selectedElementIds};for(let v of b.groupIds.flatMap(C=>dr(this.scene.getNonDeletedElements(),C)))delete y[v.id];return{selectedGroupIds:{...E.selectedElementIds,...b.groupIds.map(v=>({[v]:!1})).reduce((v,C)=>({...v,...C}),{})},selectedElementIds:ye(y,E)}}):this.state.selectedLinearElement?.isDragging||this.setState(E=>{let y={...E.selectedElementIds};delete y[b.id];let v=j(this.scene.getNonDeletedElements(),{selectedElementIds:y});return{...$t({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:v.length===1&&Zt(v[0])?new Se(v[0],this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}}):b.frameId&&this.state.selectedElementIds[b.frameId]?this.setState(E=>{let y={...E.selectedElementIds,[b.id]:!0};return delete y[b.frameId],(this.scene.getElement(b.frameId)?.groupIds??[]).flatMap(v=>dr(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete y[v.id]}),{...$t({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||Xo(b)?"info":!1}}):this.setState(E=>({selectedElementIds:ye({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...$t({editingGroupId:E.editingGroupId,selectedElementIds:{[b.id]:!0}},this.scene.getNonDeletedElements(),E,this),selectedLinearElement:Zt(b)&&E.selectedLinearElement?.elementId!==b.id?new Se(b,this.scene.getNonDeletedElementsMap()):E.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(b&&We(b))&&!t.drag.hasOccurred&&!this.state.isResizing&&(b&&FH({point:re(t.origin.x,t.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:Mt(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(vi):this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),xe(this.interactiveCanvas,De.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&r&&this.setState(E=>({selectedElementIds:ye({...E.selectedElementIds,[r.id]:!0},E),showHyperlinkPopup:Xo(r)&&!r.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||Ee(this.scene.getNonDeletedElements(),this.state)||!tH(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.scheduleCapture(),t.drag.hasOccurred&&!this.state.selectedLinearElement||d||m||c){let E=this.scene.getSelectedElements(this.state).filter(Zt);X5(E,cf(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)?(Ht(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Vo(this.state,{type:this.defaultSelectionTool})})):this.setState({newElement:null,suggestedBindings:[]}),b&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&pe.pointers.size<=1&&hl(b)&&this.isIframeLikeElementCenter(b,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(b)})}clearSelection(t){this.setState(n=>({selectedElementIds:ye({},n),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:n.editingGroupId&&t!=null&&uI(t,n.editingGroupId)?n.editingGroupId:null})),this.setState({selectedElementIds:ye({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,n,r,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=Ef(i,r,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,n-l)<Nz){let{x:c,y:p}=qd({sceneX:a,sceneY:l},r);return{viewportX:c,viewportY:p,elementCenterX:a,elementCenterY:l}}}}getCanvasOffsets(){if(this.excalidrawContainerRef?.current){let t=this.excalidrawContainerRef.current,{left:n,top:r}=t.getBoundingClientRect();return{offsetLeft:n,offsetTop:r}}return{offsetLeft:0,offsetTop:0}}async updateLanguage(){let t=yr.find(n=>n.code===this.props.langCode)||ho;await Gl(t),this.setAppState({})}},mG=()=>{(Lf()||II())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(CI(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};mG();var LI=Pf;import{useEffect as uG,useState as hG}from"react";import{jsx as gG}from"react/jsx-runtime";var PI=e=>{let[o,t]=hG(!0);return uG(()=>{let n=async()=>{await Gl(r),t(!1)},r=yr.find(i=>i.code===e.langCode)||ho;n()},[e.langCode]),o?gG(ad,{theme:e.theme}):e.children};import fG from"clsx";import{jsx as AI}from"react/jsx-runtime";var DI=({children:e})=>{let{FooterCenterTunnel:o}=ve(),t=ge();return AI(o.In,{children:AI("div",{className:fG("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},bG=DI;DI.displayName="FooterCenter";import xG from"clsx";import{jsx as yG,jsxs as wG}from"react/jsx-runtime";var _I=({isCollaborating:e,onSelect:o,...t})=>{let n=ge(),r=n.width<830;return wG(Rt,{...t,className:xG("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:r?void 0:"auto"},title:g("labels.liveCollaboration"),children:[r?q1:g("labels.share"),n.collaborators.size>0&&yG("div",{className:"CollabButton-collaborators",children:n.collaborators.size})]})},EG=_I;_I.displayName="LiveCollaborationTrigger";import{jsx as Bn,jsxs as NI}from"react/jsx-runtime";var vG=()=>Bn("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Bn("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"})}),TG=()=>NI("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Bn("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)"}),Bn("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)"}),Bn("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)"}),Bn("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)"})]}),RI=({style:e,size:o="small",withText:t})=>NI("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Bn(vG,{}),t&&Bn(TG,{})]});import{Fragment as OI,jsx as Ve,jsxs as Ff}from"react/jsx-runtime";var Of=({icon:e,shortcut:o,children:t})=>{let n=se();return Ff(OI,{children:[Ve("div",{className:"welcome-screen-menu-item__icon",children:e}),Ve("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!n.editor.isMobile&&Ve("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};Of.displayName="WelcomeScreenMenuItemContent";var Tl=({onSelect:e,children:o,icon:t,shortcut:n,className:r="",...i})=>Ve("button",{...i,type:"button",className:`welcome-screen-menu-item ${r}`,onClick:e,children:Ve(Of,{icon:t,shortcut:n,children:o})});Tl.displayName="WelcomeScreenMenuItem";var BI=({children:e,href:o,icon:t,shortcut:n,className:r="",...i})=>Ve("a",{...i,className:`welcome-screen-menu-item ${r}`,href:o,target:"_blank",rel:"noopener",children:Ve(Of,{icon:t,shortcut:n,children:e})});BI.displayName="WelcomeScreenMenuItemLink";var jt=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=ve();return Ve(o.In,{children:Ve("div",{className:"welcome-screen-center",children:e||Ff(OI,{children:[Ve(zf,{}),Ve(Hf,{children:g("welcomeScreen.defaults.center_heading")}),Ff(Gf,{children:[Ve(Yf,{}),Ve(Uf,{})]})]})})})};jt.displayName="Center";var zf=({children:e})=>Ve("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ve(RI,{withText:!0})});zf.displayName="Logo";var Hf=({children:e})=>Ve("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Hf.displayName="Heading";var Gf=({children:e})=>Ve("div",{className:"welcome-screen-menu",children:e});Gf.displayName="Menu";var Uf=()=>{let e=Ue();return Ve(Tl,{onSelect:()=>e.executeAction(jn),shortcut:"?",icon:Ir,children:g("helpDialog.title")})};Uf.displayName="MenuItemHelp";var Yf=()=>{let e=ge(),o=Ue();return e.viewModeEnabled?null:Ve(Tl,{onSelect:()=>o.executeAction(Zr),shortcut:Ne("loadScene"),icon:Cr,children:g("buttons.load")})};Yf.displayName="MenuItemLoadScene";var FI=({onSelect:e})=>{let{t:o}=ze();return Ve(Tl,{shortcut:null,onSelect:e,icon:jl,children:o("labels.liveCollaboration")})};FI.displayName="MenuItemLiveCollaborationTrigger";jt.Logo=zf;jt.Heading=Hf;jt.Menu=Gf;jt.MenuItem=Tl;jt.MenuItemLink=BI;jt.MenuItemHelp=Uf;jt.MenuItemLoadScene=Yf;jt.MenuItemLiveCollaborationTrigger=FI;import{jsx as Ui,jsxs as Wf}from"react/jsx-runtime";var tm=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=ve();return Ui(o.In,{children:Wf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[D1,Ui("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};tm.displayName="MenuHint";var om=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=ve();return Ui(o.In,{children:Wf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Ui("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),R1]})})};om.displayName="ToolbarHint";var nm=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=ve();return Ui(o.In,{children:Wf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Ui("div",{children:e||g("welcomeScreen.defaults.helpHint")}),_1]})})};nm.displayName="HelpHint";import{Fragment as zI,jsx as Il,jsxs as CG}from"react/jsx-runtime";var rm=e=>Il(zI,{children:e.children||CG(zI,{children:[Il(jt,{}),Il(tm,{}),Il(om,{}),Il(nm,{})]})});rm.displayName="WelcomeScreen";rm.Center=jt;rm.Hints={MenuHint:tm,ToolbarHint:om,HelpHint:nm};var IG=rm;var SG=()=>{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)})},HI=SG;import{getSceneVersion as X8e,hashElementsVersion as K8e,hashString as Z8e,getNonDeletedElements as $8e}from"@excalidraw/element";import{getTextFromElements as q8e}from"@excalidraw/element";import{isInvisiblySmallElement as Q8e}from"@excalidraw/element";import kG from"lodash.throttle";import{arrayToMap as MG,isDevEnv as GI,isTestEnv as UI}from"@excalidraw/common";import{orderByFractionalIndex as LG,syncInvalidIndices as YI,validateFractionalIndices as PG}from"@excalidraw/element";var AG=(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)),DG=kG((e,o,t)=>{if(GI()||UI()||window?.DEBUG_FRACTIONAL_INDICES){let n=YI(e.map(r=>({...r})));PG(n,{shouldThrow:UI()||GI(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),_G=(e,o,t)=>{let n=MG(e),r=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=n.get(l.id),d=AG(t,s,l);s&&d?(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=LG(r);return DG(a,e,o),YI(a),a};import{getFreeDrawSvgPath as l7e}from"@excalidraw/element";import{isLinearElement as d7e}from"@excalidraw/element";import{FONT_FAMILY as p7e,THEME as u7e,MIME_TYPES as h7e,ROUNDNESS as dc,DEFAULT_LASER_COLOR as g7e,UserIdleState as f7e,normalizeLink as b7e}from"@excalidraw/common";import{mutateElement as pc,newElementWith as E7e,bumpVersion as ii}from"@excalidraw/element";import{CaptureUpdateAction as w7e}from"@excalidraw/element";import{sceneCoordsToViewportCoords as ay,viewportCoordsToSceneCoords as I7e}from"@excalidraw/common";import{jsx as WI,jsxs as RG}from"react/jsx-runtime";var VI=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=ve(),n=le();return WI(t.In,{children:RG(fe.Item,{onSelect:()=>{ne("ai","dialog open","ttd"),n({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??K0,children:[e??g("labels.textToDiagram"),WI(fe.Item.Badge,{children:"AI"})]})})};VI.displayName="TTDDialogTrigger";import{getCommonBounds as B7e,getVisibleSceneBounds as F7e}from"@excalidraw/element";import{useLayoutEffect as NG}from"react";var BG=e=>{let o=Re();return NG(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as U7e}from"@excalidraw/element";import{setCustomTextMetricsProvider as W7e}from"@excalidraw/element";import{jsx as Vf}from"react/jsx-runtime";HI();var HG=e=>{let{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i=!1,onPointerUpdate:a,renderTopRightUI:l,langCode:s=ho.code,viewModeEnabled:d,zenModeEnabled:m,gridModeEnabled:c,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,onPaste:x,detectScroll:w=!0,handleKeyboardGlobally:E=!1,onLibraryChange:y,autoFocus:v=!1,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:k,onPointerUp:A,onScrollChange:P,onDuplicate:N,children:O,validateEmbeddable:U,renderEmbeddable:J,aiEnabled:_,showDeprecatedFonts:R,renderScrollbars:V}=e,Z=e.UIOptions?.canvasActions,W={...e.UIOptions,canvasActions:{...XI.canvasActions,...Z},tools:{image:e.UIOptions?.tools?.image??!0}};return Z?.export&&(W.canvasActions.export.saveFileToDisk=Z.export?.saveFileToDisk??XI.canvasActions.export.saveFileToDisk),W.canvasActions.toggleTheme===null&&typeof u>"u"&&(W.canvasActions.toggleTheme=!0),OG(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let he=de=>{typeof de.scale=="number"&&de.scale!==1&&de.preventDefault()};return document.addEventListener("touchmove",he,{passive:!1}),()=>{document.removeEventListener("touchmove",he)}},[]),Vf(I1,{store:He,children:Vf(PI,{langCode:s,theme:u,children:Vf(LI,{onChange:o,onIncrement:t,initialData:n,excalidrawAPI:r,isCollaborating:i,onPointerUpdate:a,renderTopRightUI:l,langCode:s,viewModeEnabled:d,zenModeEnabled:m,gridModeEnabled:c,libraryReturnUrl:p,theme:u,name:f,renderCustomStats:b,UIOptions:W,onPaste:x,detectScroll:w,handleKeyboardGlobally:E,onLibraryChange:y,autoFocus:v,generateIdForFile:C,onLinkOpen:S,generateLinkForSelection:L,onPointerDown:k,onPointerUp:A,onScrollChange:P,onDuplicate:N,validateEmbeddable:U,renderEmbeddable:J,aiEnabled:_!==!1,showDeprecatedFonts:R,renderScrollbars:V,children:O})})})},GG=(e,o)=>{if(e.children!==o.children)return!1;let{initialData:t,UIOptions:n={},...r}=e,{initialData:i,UIOptions:a={},...l}=o,s=Object.keys(n),d=Object.keys(a);return s.length!==d.length?!1:s.every(c=>c==="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[c]===a[c])&&zG(r,l)},UG=FG.memo(HG,GG);UG.displayName="Excalidraw";export{Rt as Button,w7e as CaptureUpdateAction,g7e as DEFAULT_LASER_COLOR,Td as DefaultSidebar,BG as DiagramToCodePlugin,da as Ellipsify,UG as Excalidraw,p7e as FONT_FAMILY,bG as Footer,EG as LiveCollaborationTrigger,h7e as MIME_TYPES,dt as MainMenu,dc as ROUNDNESS,Kt as Sidebar,al as Stats,u7e as THEME,kg as TTDDialog,VI as TTDDialogTrigger,f7e as UserIdleState,IG as WelcomeScreen,ii as bumpVersion,Ci as convertToExcalidrawElements,ho as defaultLang,F2 as elementPartiallyOverlapsWithOrContainsBBox,O2 as elementsOverlappingBBox,my as exportToBlob,mn as exportToCanvas,zP as exportToClipboard,ci as exportToSvg,B7e as getCommonBounds,xm as getDataURL,l7e as getFreeDrawSvgPath,bc as getLibraryItemsHash,$8e as getNonDeletedElements,X8e as getSceneVersion,q8e as getTextFromElements,F7e as getVisibleSceneBounds,K8e as hashElementsVersion,Z8e as hashString,wh as isElementInsideBBox,U7e as isElementLink,Q8e as isInvisiblySmallElement,d7e as isLinearElement,yr as languages,Bl as loadFromBlob,bm as loadLibraryFromBlob,fm as loadSceneOrLibraryFromBlob,yy as mergeLibraryItems,pc as mutateElement,E7e as newElementWith,b7e as normalizeLink,Hu as parseLibraryTokensFromUrl,_G as reconcileElements,xr as restore,jI as restoreAppState,$I as restoreElement,gm as restoreElements,Ki as restoreLibraryItems,ay as sceneCoordsToViewportCoords,Wi as serializeAsJSON,hm as serializeLibraryAsJSON,W7e as setCustomTextMetricsProvider,se as useDevice,oA as useHandleLibrary,ze as useI18n,I7e as viewportCoordsToSceneCoords,wx as zoomToFitBounds};