@excalidraw/excalidraw 0.18.0-58f7d33 → 0.18.0-6d870b1c8

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 (174) hide show
  1. package/dist/dev/chunk-CP5DND7P.js +7 -0
  2. package/dist/dev/chunk-CP5DND7P.js.map +7 -0
  3. package/dist/dev/chunk-D5WIFFIO.js +5678 -0
  4. package/dist/dev/chunk-D5WIFFIO.js.map +7 -0
  5. package/dist/dev/{chunk-X3RYHLJU.js → chunk-QF5FRM6O.js} +15 -5
  6. package/dist/dev/chunk-QF5FRM6O.js.map +7 -0
  7. package/dist/dev/data/{image-U2IPNUKJ.js → image-WMAXQLTI.js} +3 -3
  8. package/dist/dev/index.css +104 -22
  9. package/dist/dev/index.css.map +3 -3
  10. package/dist/dev/index.js +8871 -9726
  11. package/dist/dev/index.js.map +4 -4
  12. package/dist/dev/locales/{en-CKWC2GMK.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-I4UNSFV6.js +12 -0
  17. package/dist/prod/chunk-KK52DCS3.js +4 -0
  18. package/dist/prod/data/image-U3WTNYT7.js +1 -0
  19. package/dist/prod/index.css +1 -1
  20. package/dist/prod/index.js +25 -17
  21. package/dist/prod/locales/{en-SBO6ZHT2.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/{excalidraw → common/src}/emitter.d.ts +1 -1
  26. package/dist/types/common/src/font-metadata.d.ts +4 -2
  27. package/dist/types/common/src/index.d.ts +1 -0
  28. package/dist/types/common/src/utility-types.d.ts +5 -0
  29. package/dist/types/common/src/utils.d.ts +17 -4
  30. package/dist/types/{excalidraw/scene → element/src}/Scene.d.ts +11 -14
  31. package/dist/types/element/src/align.d.ts +4 -3
  32. package/dist/types/element/src/binding.d.ts +26 -16
  33. package/dist/types/element/src/bounds.d.ts +13 -5
  34. package/dist/types/element/src/collision.d.ts +18 -12
  35. package/dist/types/element/src/cropElement.d.ts +1 -1
  36. package/dist/types/{excalidraw/change.d.ts → element/src/delta.d.ts} +74 -39
  37. package/dist/types/element/src/distance.d.ts +2 -2
  38. package/dist/types/element/src/distribute.d.ts +2 -1
  39. package/dist/types/element/src/dragElements.d.ts +3 -2
  40. package/dist/types/element/src/duplicate.d.ts +10 -13
  41. package/dist/types/element/src/elbowArrow.d.ts +1 -1
  42. package/dist/types/element/src/flowchart.d.ts +3 -2
  43. package/dist/types/element/src/fractionalIndex.d.ts +9 -3
  44. package/dist/types/element/src/frame.d.ts +5 -4
  45. package/dist/types/element/src/groups.d.ts +1 -0
  46. package/dist/types/element/src/index.d.ts +43 -2
  47. package/dist/types/element/src/linearElementEditor.d.ts +23 -36
  48. package/dist/types/element/src/mutateElement.d.ts +11 -3
  49. package/dist/types/element/src/newElement.d.ts +4 -3
  50. package/dist/types/element/src/resizeElements.d.ts +5 -4
  51. package/dist/types/element/src/selection.d.ts +11 -5
  52. package/dist/types/element/src/shape.d.ts +42 -0
  53. package/dist/types/element/src/sizeHelpers.d.ts +2 -2
  54. package/dist/types/element/src/store.d.ts +232 -0
  55. package/dist/types/element/src/textElement.d.ts +4 -3
  56. package/dist/types/element/src/typeChecks.d.ts +19 -1
  57. package/dist/types/element/src/types.d.ts +15 -2
  58. package/dist/types/element/src/utils.d.ts +16 -6
  59. package/dist/types/element/src/zindex.d.ts +1 -1
  60. package/dist/types/excalidraw/actions/actionAddToLibrary.d.ts +39 -51
  61. package/dist/types/excalidraw/actions/actionBoundText.d.ts +26 -34
  62. package/dist/types/excalidraw/actions/actionCanvas.d.ts +175 -227
  63. package/dist/types/excalidraw/actions/actionClipboard.d.ts +78 -100
  64. package/dist/types/excalidraw/actions/actionCropEditor.d.ts +13 -17
  65. package/dist/types/excalidraw/actions/actionDeleteSelected.d.ts +39 -50
  66. package/dist/types/excalidraw/actions/actionElementLink.d.ts +12 -16
  67. package/dist/types/excalidraw/actions/actionElementLock.d.ts +41 -50
  68. package/dist/types/excalidraw/actions/actionEmbeddable.d.ts +13 -17
  69. package/dist/types/excalidraw/actions/actionExport.d.ts +127 -163
  70. package/dist/types/excalidraw/actions/actionFinalize.d.ts +73 -40
  71. package/dist/types/excalidraw/actions/actionFrame.d.ts +99 -115
  72. package/dist/types/excalidraw/actions/actionGroup.d.ts +26 -34
  73. package/dist/types/excalidraw/actions/actionHistory.d.ts +1 -2
  74. package/dist/types/excalidraw/actions/actionLinearEditor.d.ts +538 -18
  75. package/dist/types/excalidraw/actions/actionLink.d.ts +12 -16
  76. package/dist/types/excalidraw/actions/actionMenu.d.ts +36 -48
  77. package/dist/types/excalidraw/actions/actionNavigate.d.ts +25 -33
  78. package/dist/types/excalidraw/actions/actionProperties.d.ts +203 -255
  79. package/dist/types/excalidraw/actions/actionSelectAll.d.ts +13 -17
  80. package/dist/types/excalidraw/actions/actionStyles.d.ts +13 -17
  81. package/dist/types/excalidraw/actions/actionToggleGridMode.d.ts +13 -17
  82. package/dist/types/excalidraw/actions/actionToggleObjectsSnapMode.d.ts +13 -17
  83. package/dist/types/excalidraw/actions/actionToggleSearchMenu.d.ts +12 -189
  84. package/dist/types/excalidraw/actions/actionToggleShapeSwitch.d.ts +19 -0
  85. package/dist/types/excalidraw/actions/actionToggleStats.d.ts +13 -17
  86. package/dist/types/excalidraw/actions/actionToggleViewMode.d.ts +13 -17
  87. package/dist/types/excalidraw/actions/actionToggleZenMode.d.ts +13 -17
  88. package/dist/types/excalidraw/actions/types.d.ts +4 -3
  89. package/dist/types/excalidraw/appState.d.ts +19 -10
  90. package/dist/types/excalidraw/components/Actions.d.ts +0 -4
  91. package/dist/types/excalidraw/components/App.d.ts +30 -19
  92. package/dist/types/excalidraw/components/ButtonIcon.d.ts +1 -0
  93. package/dist/types/excalidraw/components/ColorPicker/ColorInput.d.ts +2 -1
  94. package/dist/types/excalidraw/components/ColorPicker/ColorPicker.d.ts +5 -1
  95. package/dist/types/excalidraw/components/ColorPicker/CustomColorList.d.ts +1 -1
  96. package/dist/types/excalidraw/components/ColorPicker/Picker.d.ts +2 -3
  97. package/dist/types/excalidraw/components/ColorPicker/PickerColorList.d.ts +2 -3
  98. package/dist/types/excalidraw/components/ColorPicker/ShadeList.d.ts +2 -2
  99. package/dist/types/excalidraw/components/ColorPicker/TopPicks.d.ts +1 -1
  100. package/dist/types/excalidraw/components/ColorPicker/colorPickerUtils.d.ts +1 -1
  101. package/dist/types/excalidraw/components/ColorPicker/keyboardNavHandlers.d.ts +1 -1
  102. package/dist/types/excalidraw/components/ConvertElementTypePopup.d.ts +23 -0
  103. package/dist/types/excalidraw/components/ElementLinkDialog.d.ts +4 -3
  104. package/dist/types/excalidraw/components/Ellipsify.d.ts +4 -0
  105. package/dist/types/excalidraw/components/{ButtonIconSelect.d.ts → RadioSelection.d.ts} +1 -1
  106. package/dist/types/excalidraw/components/Range.d.ts +3 -3
  107. package/dist/types/excalidraw/components/Stats/Angle.d.ts +1 -1
  108. package/dist/types/excalidraw/components/Stats/CanvasGrid.d.ts +1 -1
  109. package/dist/types/excalidraw/components/Stats/Collapsible.d.ts +2 -1
  110. package/dist/types/excalidraw/components/Stats/Dimension.d.ts +1 -1
  111. package/dist/types/excalidraw/components/Stats/DragInput.d.ts +12 -2
  112. package/dist/types/excalidraw/components/Stats/FontSize.d.ts +1 -1
  113. package/dist/types/excalidraw/components/Stats/MultiAngle.d.ts +1 -1
  114. package/dist/types/excalidraw/components/Stats/MultiDimension.d.ts +1 -1
  115. package/dist/types/excalidraw/components/Stats/MultiFontSize.d.ts +1 -1
  116. package/dist/types/excalidraw/components/Stats/MultiPosition.d.ts +1 -1
  117. package/dist/types/excalidraw/components/Stats/Position.d.ts +1 -1
  118. package/dist/types/excalidraw/components/Stats/utils.d.ts +4 -11
  119. package/dist/types/excalidraw/components/UnlockPopup.d.ts +8 -0
  120. package/dist/types/excalidraw/components/canvases/InteractiveCanvas.d.ts +1 -0
  121. package/dist/types/excalidraw/components/hyperlink/Hyperlink.d.ts +3 -2
  122. package/dist/types/excalidraw/components/hyperlink/helpers.d.ts +2 -1
  123. package/dist/types/excalidraw/components/icons.d.ts +3 -0
  124. package/dist/types/excalidraw/components/shapes.d.ts +1 -1
  125. package/dist/types/excalidraw/data/reconcile.d.ts +1 -0
  126. package/dist/types/excalidraw/data/restore.d.ts +6 -1
  127. package/dist/types/excalidraw/data/transform.d.ts +1 -1
  128. package/dist/types/excalidraw/editor-jotai.d.ts +6 -6
  129. package/dist/types/excalidraw/eraser/index.d.ts +0 -2
  130. package/dist/types/excalidraw/fonts/Fonts.d.ts +1 -1
  131. package/dist/types/excalidraw/history.d.ts +30 -22
  132. package/dist/types/excalidraw/hooks/useEmitter.d.ts +1 -1
  133. package/dist/types/excalidraw/index.d.ts +11 -10
  134. package/dist/types/excalidraw/lasso/index.d.ts +1 -0
  135. package/dist/types/excalidraw/lasso/utils.d.ts +2 -1
  136. package/dist/types/excalidraw/renderer/helpers.d.ts +7 -2
  137. package/dist/types/excalidraw/renderer/staticScene.d.ts +4 -1
  138. package/dist/types/excalidraw/scene/Renderer.d.ts +1 -2
  139. package/dist/types/excalidraw/scene/index.d.ts +2 -2
  140. package/dist/types/excalidraw/scene/scrollbars.d.ts +2 -3
  141. package/dist/types/excalidraw/scene/types.d.ts +2 -0
  142. package/dist/types/excalidraw/snapping.d.ts +2 -2
  143. package/dist/types/excalidraw/types.d.ts +34 -14
  144. package/dist/types/excalidraw/wysiwyg/textWysiwyg.d.ts +3 -1
  145. package/dist/types/math/src/angle.d.ts +2 -0
  146. package/dist/types/math/src/constants.d.ts +3 -0
  147. package/dist/types/math/src/curve.d.ts +34 -0
  148. package/dist/types/math/src/index.d.ts +1 -0
  149. package/dist/types/math/src/point.d.ts +1 -1
  150. package/dist/types/math/src/rectangle.d.ts +2 -0
  151. package/dist/types/math/src/vector.d.ts +8 -2
  152. package/dist/types/utils/src/bbox.d.ts +1 -1
  153. package/dist/types/utils/src/index.d.ts +1 -1
  154. package/dist/types/utils/src/withinBounds.d.ts +1 -1
  155. package/history.ts +147 -110
  156. package/package.json +12 -9
  157. package/dist/dev/chunk-KKJLIRJU.js +0 -7
  158. package/dist/dev/chunk-KKJLIRJU.js.map +0 -7
  159. package/dist/dev/chunk-LEJJ2YZY.js +0 -18711
  160. package/dist/dev/chunk-LEJJ2YZY.js.map +0 -7
  161. package/dist/dev/chunk-X3RYHLJU.js.map +0 -7
  162. package/dist/prod/chunk-IUH5AXLB.js +0 -12
  163. package/dist/prod/chunk-QUX7WTVH.js +0 -7
  164. package/dist/prod/chunk-RQK6WG4F.js +0 -33
  165. package/dist/prod/data/image-UQDATCXC.js +0 -1
  166. package/dist/types/element/src/Shape.d.ts +0 -17
  167. package/dist/types/element/src/ShapeCache.d.ts +0 -25
  168. package/dist/types/element/src/shapes.d.ts +0 -23
  169. package/dist/types/excalidraw/components/ButtonSelect.d.ts +0 -9
  170. package/dist/types/excalidraw/store.d.ts +0 -129
  171. package/dist/types/excalidraw/visualdebug.d.ts +0 -41
  172. package/dist/types/utils/src/collision.d.ts +0 -8
  173. /package/dist/dev/data/{image-U2IPNUKJ.js.map → image-WMAXQLTI.js.map} +0 -0
  174. /package/dist/dev/locales/{en-CKWC2GMK.js.map → en-SMAPCEOQ.js.map} +0 -0
@@ -1,25 +1,33 @@
1
- import{$ as qf,$a as Tt,$b as k1,$c as _e,$d as cn,$e as ze,$f as Xi,$g as d0,A as Kf,Aa as gp,Ab as ht,Ac as ml,Ad as ob,Ae as G5,Af as j,Ag as ii,Ah as Sl,B as ap,Ba as Qt,Bb as Ip,Bc as Lr,Bd as Hi,Be as V5,Bf as Rr,Bg as o0,Bh as nu,C as Zf,Ca as rl,Cb as on,Cc as ro,Cd as Qe,Ce as Y5,Cf as Hb,Cg as n0,Ch as w0,D as Qa,Da as eo,Db as v1,Dc as Wo,Dd as hl,De as xb,Df as Ub,Dg as ai,Dh as T0,E as lp,Ea as Gs,Eb as Sp,Ec as Js,Ed as rc,Ee as Eb,Ef as xc,Eg as dr,Eh as C0,F as Se,Fa as nl,Fb as w1,Fc as Qs,Fd as ko,Fe as cc,Ff as yl,Fg as i0,Fh as I0,G as nr,Ga as Sr,Gb as ir,Gc as Ar,Gd as ge,Ge as zp,Gf as mn,Gg as mr,H as Hn,Ha as At,Hb as Vn,Hc as he,Hd as _t,He as yb,Hf as vl,Hg as no,I as el,Ia as Vs,Ib as qe,Ic as Ft,Id as nc,Ie as Mo,If as Up,Ig as Xo,J as Go,Ja as it,Jb as Yn,Jc as Xn,Jd as rb,Je as vb,Jf as Gp,Jg as Ji,K as Bt,Ka as tn,Kb as Pi,Kc as Oi,Kd as nb,Ke as wb,Kf as Vp,Kg as a0,L as de,La as m1,Lb as Yo,Lc as Z,Ld as ib,Le as Yi,Lf as Yp,Lg as qp,M as Vo,Ma as il,Mb as T1,Mc as O1,Md as ab,Me as Tb,Mf as Zi,Mg as un,N as Rs,Na as to,Nb as C1,Nc as ec,Nd as Ui,Ne as ti,Nf as Wp,Ng as Qi,O as Ir,Oa as Et,Ob as Wn,Oc as ne,Od as Gi,Oe as Cb,Of as Gb,Og as Sc,P as qr,Pa as p1,Pb as He,Pc as Lp,Pd as lb,Pe as Wi,Pf as ri,Pg as Jp,Q as Ns,Qa as u1,Qb as R,Qc as ae,Qd as Ap,Qe as dc,Qf as Vb,Qg as Tl,R as sp,Ra as h1,Rb as $e,Rc as ke,Rd as sb,Re as Ib,Rf as Yb,Rg as kc,S as Jr,Sa as kr,Sb as zt,Sc as te,Sd as Jn,Se as mc,Sf as Wb,Sg as Qp,T as Os,Ta as g1,Tb as cl,Tc as B1,Td as cb,Te as lr,Tf as Kb,Tg as eu,U as Xf,Ua as pe,Ub as rn,Uc as _r,Ud as db,Ue as Fp,Uf as W5,Ug as l0,V as tl,Va as T,Vb as $s,Vc as z1,Vd as ic,Ve as Sb,Vf as pn,Vg as s0,W as $f,Wa as Ys,Wb as kp,Wc as $n,Wd as Qn,We as pc,Wf as We,Wg as c0,X as jf,Xa as Un,Xb as Mr,Xc as Dr,Xd as ac,Xe as uc,Xf as Ec,Xg as Mc,Y as cp,Ya as fp,Yb as Kn,Yc as F1,Yd as gl,Ye as hc,Yf as Zb,Yg as Cl,Z as ol,Za as Ai,Zb as I1,Zc as jn,Zd as Ko,Ze as kb,Zf as ye,Zg as Lc,_ as ue,_a as Ws,_b as S1,_c as pt,_d as mb,_e as Hp,_f as yc,_g as Ac,a as ks,aa as Bs,ab as So,ac as M1,ad as Bi,ae as at,af as Mb,ag as Dt,ah as m0,b as Rf,ba as Qr,bb as f1,bc as L1,bd as H1,be as _p,bf as J,bg as Kp,bh as _c,c as zn,ca as Jf,cb as bp,cc as ee,cd as U1,ce as Dp,cf as gc,cg as Xb,ch as ea,d as Nf,da as Qf,db as al,dc as A1,dd as G1,de as pb,df as Me,dg as vc,dh as p0,e as Of,ea as e1,eb as _i,ec as ar,ed as zi,ee as ub,ef as Lb,eg as Gt,eh as tu,f as Bf,fa as t1,fb as Di,fc as _1,fd as V1,fe as lc,ff as lt,fg as Zp,fh as K5,g as Io,ga as o1,gb as xp,gc as mt,gd as Y1,ge as hb,gf as fc,gg as $b,gh as ta,h as Ms,ha as Li,hb as Ks,hc as Ue,hd as W1,he as gb,hf as Ab,hg as $i,hh as Il,i as Ls,ia as dp,ib as Ep,ic as js,id as K1,ie as fl,if as Zo,ig as wl,j as As,ja as mp,jb as yp,jc as Ri,jd as Z1,je as bl,jf as _b,jg as Vt,jh as u0,k as zf,ka as r1,kb as b1,kc as D1,kd as X1,ke as fb,kf as Db,kg as jb,l as Ff,la as n1,lb as vp,lc as nn,ld as $1,le as sc,lf as Ki,lg as qb,lh as h0,m as Hf,ma as zs,mb as M,mc as dl,md as pl,me as B,mf as Fe,mg as cr,mh as g0,n as Uf,na as Fs,nb as ce,nc as Je,nd as j1,ne as oe,nf as Pb,ng as ji,nh as Dc,o as Uo,oa as pp,ob as wp,oc as an,od as q1,oe as xl,of as Rb,og as wc,oh as f0,p as _s,pa as i1,pb as Gn,pc as Zn,pd as ul,pe as ei,pf as Nb,pg as Xp,ph as Pc,q as Gf,qa as a1,qb as Zs,qc as ln,qd as J1,qe as El,qf as oi,qg as ni,qh as ou,r as Cr,ra as l1,rb as Tp,rc as P1,rd as Q1,re as Vi,rf as Ob,rg as Jb,rh as Rc,s as Vf,sa as s1,sb as Xs,sc as qs,sd as Ht,se as Pp,sf as Bb,sg as qi,sh as b0,t as Ds,ta as Hs,tb as x1,tc as oo,td as tc,te as Rp,tf as sr,tg as Qb,th as ru,u as Yf,ua as en,ub as E1,uc as Ni,ud as Fi,ue as bb,uf as zb,ug as e0,uh as Nr,v as qa,va as c1,vb as po,vc as Ye,vd as eb,ve as U5,vf as Fb,vg as t0,vh as x0,w as Ja,wa as up,wb as ll,wc as R1,wd as qn,we as Np,wf as bc,wg as $p,wh as Nc,x as Wf,xa as hp,xb as sl,xc as N1,xd as tb,xe as Op,xf as Ut,xg as Tc,xh as E0,y as Fn,ya as d1,yb as y1,yc as sn,yd as oc,ye as Ee,yf as Pr,yg as Cc,yh as y0,z as Ps,za as Us,zb as Cp,zc as Mp,zd as H5,ze as Bp,zf as dn,zg as Ic,zh as v0}from"./chunk-RQK6WG4F.js";import{a as k}from"./chunk-QUX7WTVH.js";import{J as jp}from"./chunk-IUH5AXLB.js";import{c as r0}from"./chunk-Z3N5DIM6.js";import{b as Df,c as Pf,d as C}from"./chunk-SRAX5OIU.js";import gA,{useEffect as fA}from"react";import y5 from"clsx";import V8 from"lodash.throttle";import Tr,{useContext as On}from"react";import{flushSync as ki}from"react-dom";import Y8 from"roughjs/bin/rough";import{nanoid as W8}from"nanoid";var Z5=e=>{let o=e.slice(),t=new Set,r=i=>{let a=i[0]?.groupIds?.join(""),l=[i[0]],s=[];for(let c of i.slice(1))c.groupIds?.join("")===a?l.push(c):s.push(c);return s.length?[...l,...r(s)]:l},n=new Map;return o.forEach((i,a)=>{if(!n.has(i.id))if(i.groupIds?.length){let l=i.groupIds[i.groupIds.length-1],s=o.slice(a).filter(c=>{let m=c?.groupIds?.some(d=>d===l);return m&&n.set(c.id,!0),m});for(let c of r(s))t.add(c)}else t.add(i)}),t.size!==e.length?(console.error("normalizeGroupElementOrder: lost some elements... bailing!"),e):[...t]},X5=e=>{let o=A1(e),t=e.slice(),r=new Set;return t.forEach((n,i)=>{n&&(n.boundElements?.length?(r.add(n),t[i]=null,n.boundElements.forEach(a=>{let l=o.get(a.id);l&&a.type==="text"&&(r.add(l[0]),t[l[1]]=null)})):n.type==="text"&&n.containerId&&o.get(n.containerId)?.[0].boundElements?.find(l=>l.id===n.id)||(r.add(n),t[i]=null))}),r.size!==e.length?(console.error("normalizeBoundElementsOrder: lost some elements... bailing!"),e):[...r]},S0=e=>X5(Z5(e));var $5=(e,o,t,r,n)=>{let i=uo(t);return mt()&&j5(i,t.id),i.id=ro(),i.updated=L1(),n&&(i.seed=Lr(),xl(i)),i.groupIds=zb(i.groupIds,e,a=>(o.has(a)||o.set(a,ro()),o.get(a))),r&&(i=Object.assign(i,r)),i},li=e=>{let{elements:o}=e,t="appState"in e?e.appState:{editingGroupId:null,selectedGroupIds:{}},r=e.type==="in-place"?e.reverseOrder:!1,n=new Map,i=new Map,a=[],l=[],s=new Map,c=new Map,m=ee(o),d=e.type==="in-place"?e.idsOfElementsToDuplicate:new Map(o.map(x=>[x.id,x]));if(e.type==="in-place")for(let x of Object.keys(e.appState.selectedGroupIds))o.filter(E=>E.groupIds?.includes(x)).forEach(E=>d.set(E.id,E));o=S0(o);let p=o.slice(),u=x=>{let w=ml(x).reduce((y,v)=>{if(n.has(v.id))return y;n.set(v.id,!0);let I=$5(t.editingGroupId,i,v,e.overrides?.(v),e.randomizeSeed);return n.set(I.id,!0),c.set(I.id,I),s.set(v.id,I.id),l.push(v),a.push(I),y.push(I),y},[]);return Array.isArray(x)?w:w[0]||null},g=(x,E)=>{if(E){if(r&&x<1){p.unshift(...ml(E));return}if(!r&&x>p.length-1){p.push(...ml(E));return}p.splice(x+(r?0:1),0,...ml(E))}},b=new Set(o.filter(x=>d.has(x.id)&&ne(x)).map(x=>x.id));for(let x of o){if(n.has(x.id)||!d.has(x.id))continue;let E=Ab(t,x);if(E){let w=Fe(o,E).flatMap(v=>ne(v)?[...Mo(o,v.id),v]:[v]),y=r?p.findIndex(v=>v.groupIds?.includes(E)):Mr(p,v=>v.groupIds?.includes(E));g(y,u(w));continue}if(!(x.frameId&&b.has(x.frameId))){if(ne(x)){let w=x.id,y=Mo(o,w),v=Mr(p,I=>I.frameId===w||I.id===w);g(v,u([...y,x]));continue}if(pt(x)){let w=ge(x,m),y=Mr(p,v=>v.id===x.id||"containerId"in v&&v.containerId===x.id);w?g(y+(r?-1:0),u([x,w])):g(y,u(x));continue}if(_e(x)){let w=_t(x,m),y=Mr(p,v=>v.id===x.id||v.id===w?.id);w?g(y,u([w,x])):g(y,u(x));continue}g(Mr(p,w=>w.id===x.id),u(x))}}return pb(a,s,c),r&&ub(d,p,s),xb(p,l,s),{newElements:a,elementsWithClones:p}},iu=(e,o=0)=>{if(e==null||typeof e!="object")return e;let t=Object.prototype.toString.call(e);if(t==="[object Object]"){let r=typeof e.constructor=="function"?Object.create(Object.getPrototypeOf(e)):{};for(let n in e)if(e.hasOwnProperty(n)){if(o===0&&(n==="shape"||n==="canvas"))continue;r[n]=iu(e[n],o+1)}return r}if(Array.isArray(e)){let r=e.length,n=new Array(r);for(;r--;)n[r]=iu(e[r],o+1);return n}return k.DEV&&t!=="[object Object]"&&t!=="[object Array]"&&t.startsWith("[object ")&&console.warn(`_deepCloneElement: unexpected object type ${t}. This value will not be cloned!`),e},uo=e=>iu(e),j5=(e,o)=>{Object.defineProperty(e,u1,{value:o,writable:!1,enumerable:!1})};var k0={mouse:8,pen:16,touch:28},q5=16,L0={e:!0,s:!0,n:!0,w:!0};var M0={e:!0,s:!0,n:!0,w:!0,nw:!0,se:!0},au={e:!0,s:!0,n:!0,w:!0},Or=(e,o,t,r,n,i,a)=>{let[l,s]=ce(M(e+t/2,o+r/2),M(n,i),a);return[l-t/2,s-r/2,t,r]},Oc=e=>!(e.viewport.isMobile||e.isTouchScreen&&(Gf||Ds)),si=e=>Oc(e)?L0:{},kl=([e,o,t,r,n,i],a,l,s,c={},m=4,d=Jr)=>{let p=k0[s],u=p/l.value,g=p/l.value,b=p/l.value,x=p/l.value,E=t-e,w=r-o,y=m/l.value,v=(p-d*2)/(2*l.value),I={nw:c.nw?void 0:Or(e-y-b+v,o-y-x+v,u,g,n,i,a),ne:c.ne?void 0:Or(t+y-v,o-y-x+v,u,g,n,i,a),sw:c.sw?void 0:Or(e-y-b+v,r+y-v,u,g,n,i,a),se:c.se?void 0:Or(t+y-v,r+y-v,u,g,n,i,a),rotation:c.rotation?void 0:Or(e+E/2-u/2,o-y-x+v-q5/l.value,u,g,n,i,a)},S=5*k0.mouse/l.value;return Math.abs(E)>S&&(c.n||(I.n=Or(e+E/2-u/2,o-y-x+v,u,g,n,i,a)),c.s||(I.s=Or(e+E/2-u/2,r+y-v,u,g,n,i,a))),Math.abs(w)>S&&(c.w||(I.w=Or(e-y-b+v,o+w/2-g/2,u,g,n,i,a)),c.e||(I.e=Or(t+y-v,o+w/2-g/2,u,g,n,i,a))),I},Bc=(e,o,t,r="mouse",n=L0)=>{if(e.locked||te(e))return{};if(e.type==="freedraw"||ae(e)){if(e.points.length===2){let[,a]=e.points;a[0]===0||a[1]===0?n=au:a[0]>0&&a[1]<0?n=M0:a[0]>0&&a[1]>0?n=au:a[0]<0&&a[1]>0?n=M0:a[0]<0&&a[1]<0&&(n=au)}}else ne(e)&&(n={...n,rotation:!0});let i=ae(e)?Jr+8:he(e)?0:Jr;return kl(We(e,t,!0),e.angle,o,r,n,i,he(e)?0:void 0)},zc=(e,o)=>{if(o.editingLinearElement)return!1;if(e.length>1)return!0;let t=e[0];return te(t)?!1:ae(t)?t.points.length>2:!0};var oa=100,ci=100,cu=e=>{switch(e){case T.ARROW_UP:return"up";case T.ARROW_DOWN:return"down";case T.ARROW_RIGHT:return"right";case T.ARROW_LEFT:return"left";default:return"right"}},A0=(e,o,t,r)=>{let n=[...t.values()].reduce((i,a)=>{let l;if(te(a)&&(l=a[e==="predecessors"?"startBinding":"endBinding"])&&a[e==="predecessors"?"endBinding":"startBinding"]?.elementId===o.id){let s=t.get(l.elementId);if(!s)return i;ln($n(s),"not an ExcalidrawBindableElement");let c=e==="predecessors"?a.points[a.points.length-1]:[0,0],m=j1(o,Ub(o),[c[0]+a.x,c[1]+a.y]);i.push({relative:s,heading:m})}return i},[]);switch(r){case"up":return n.filter(i=>pl(i.heading,$1)).map(i=>i.relative);case"down":return n.filter(i=>pl(i.heading,Z1)).map(i=>i.relative);case"right":return n.filter(i=>pl(i.heading,K1)).map(i=>i.relative);case"left":return n.filter(i=>pl(i.heading,X1)).map(i=>i.relative)}},lu=(e,o,t)=>A0("successors",e,o,t),su=(e,o,t)=>A0("predecessors",e,o,t),J5=(e,o,t)=>{let r=ci+e.width;if(t==="up"||t==="down"){let l=oa+e.height,s=e.x,c=e.x+e.width;if(o.every(m=>m.x+m.width<s||m.x>c))return{x:0,y:l*(t==="up"?-1:1)}}else if(t==="right"||t==="left"){let l=e.y,s=e.y+e.height;if(o.every(c=>c.y+c.height<l||c.y>s))return{x:(ci+e.width)*(t==="left"?-1:1),y:0}}if(t==="up"||t==="down"){let l=oa+e.height,s=(o.length===0,l),c=o.length===0?0:(o.length+1)%2===0?(o.length+1)/2*r:o.length/2*r*-1;return t==="up"?{x:c,y:s*-1}:{x:c,y:s}}let n=oa+e.height,i=(o.length===0,ci+e.width),a=o.length===0?0:(o.length+1)%2===0?(o.length+1)/2*n:o.length/2*n*-1;return t==="left"?{x:i*-1,y:a}:{x:i,y:a}},Q5=(e,o,t,r)=>{let n=lu(e,o,r),i=su(e,o,r),a=J5(e,[...n,...i],r),l=Gt({type:e.type,x:e.x+a.x,y:e.y+a.y,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});ln(jn(l),"not an ExcalidrawFlowchartNodeElement");let s=_0(e,l,o,r,t);return{nextNode:l,bindingArrow:s}},eT=(e,o,t,r,n)=>{let i=[];for(let a=0;a<n;a++){let l,s;if(r==="left"||r==="right"){let d=oa*(n-1)+n*e.height,p=e.y+e.height/2-d/2,u=ci+e.width;r==="left"&&(u*=-1),l=e.x+u;let g=(oa+e.height)*a;s=p+g}else{let d=ci*(n-1)+n*e.width,p=e.x+e.width/2-d/2,u=oa+e.height;r==="up"&&(u*=-1),s=e.y+u;let g=(ci+e.width)*a;l=p+g}let c=Gt({type:e.type,x:l,y:s,width:e.width,height:e.height,roundness:e.roundness,roughness:e.roughness,backgroundColor:e.backgroundColor,strokeColor:e.strokeColor,strokeWidth:e.strokeWidth,opacity:e.opacity,fillStyle:e.fillStyle,strokeStyle:e.strokeStyle});ln(jn(c),"not an ExcalidrawFlowchartNodeElement");let m=_0(e,c,o,r,t);i.push(c),i.push(m)}return i},_0=(e,o,t,r,n)=>{let i,a;switch(r){case"up":{i=e.x+e.width/2,a=e.y-6;break}case"down":{i=e.x+e.width/2,a=e.y+e.height+6;break}case"right":{i=e.x+e.width+6,a=e.y+e.height/2;break}case"left":{i=e.x-6,a=e.y+e.height/2;break}}let s,c;switch(r){case"up":{s=o.x+o.width/2-i,c=o.y+o.height-a+6;break}case"down":{s=o.x+o.width/2-i,c=o.y-a-6;break}case"right":{s=o.x-i-6,c=o.y-a+o.height/2;break}case"left":{s=o.x+o.width-i+6,c=o.y-a+o.height/2;break}}let m=ji({type:"arrow",x:i,y:a,startArrowhead:null,endArrowhead:n.currentItemEndArrowhead,strokeColor:e.strokeColor,strokeStyle:e.strokeStyle,strokeWidth:e.strokeWidth,opacity:e.opacity,roughness:e.roughness,points:[M(0,0),M(s,c)],elbowed:!0});Ko(m,e,"start",t),Ko(m,o,"end",t);let d=new Map;d.set(e.id,e),d.set(o.id,o),d.set(m.id,m),j.movePoints(m,[{index:1,point:m.points[1]}]);let p=sc(m,sn(new Map([...t.entries(),[e.id,e],[o.id,o],[m.id,m]])),{points:m.points});return{...m,...p}},Fc=class{constructor(){C(this,"isExploring",!1);C(this,"sameLevelNodes",[]);C(this,"sameLevelIndex",0);C(this,"direction",null);C(this,"visitedNodes",new Set)}clear(){this.isExploring=!1,this.sameLevelNodes=[],this.sameLevelIndex=0,this.direction=null,this.visitedNodes.clear()}exploreByDirection(o,t,r){if(!$n(o))return null;if(r!==this.direction&&this.clear(),this.visitedNodes.has(o.id)||this.visitedNodes.add(o.id),this.isExploring&&r===this.direction&&this.sameLevelNodes.length>1)return this.sameLevelIndex=(this.sameLevelIndex+1)%this.sameLevelNodes.length,this.sameLevelNodes[this.sameLevelIndex].id;let n=[...lu(o,t,r),...su(o,t,r)];if(n.length>0)return this.sameLevelIndex=0,this.isExploring=!0,this.sameLevelNodes=n,this.direction=r,this.visitedNodes.add(n[0].id),n[0].id;if(r===this.direction||!this.isExploring){this.isExploring||this.visitedNodes.add(o.id);let a=["up","right","down","left"].filter(l=>l!==r).map(l=>[...lu(o,t,l),...su(o,t,l)]).flat().filter(l=>!this.visitedNodes.has(l.id));for(let l of a)if(!this.visitedNodes.has(l.id))return this.visitedNodes.add(l.id),this.isExploring=!0,this.direction=r,l.id}return null}},Hc=class{constructor(){C(this,"isCreatingChart",!1);C(this,"numberOfNodes",0);C(this,"direction","right");C(this,"pendingNodes",null)}createNodes(o,t,r,n){if(n!==this.direction){let{nextNode:i,bindingArrow:a}=Q5(o,t,r,n);this.numberOfNodes=1,this.isCreatingChart=!0,this.direction=n,this.pendingNodes=[i,a]}else{this.numberOfNodes+=1;let i=eT(o,t,r,n,this.numberOfNodes);this.isCreatingChart=!0,this.direction=n,this.pendingNodes=i}if(o.frameId){let i=t.get(o.frameId);ln(i&&O1(i),"not an ExcalidrawFrameElement"),i&&this.pendingNodes.every(a=>Eb([a],i,t)||cc(a,i,t))&&(this.pendingNodes=this.pendingNodes.map(a=>B(a,{frameId:o.frameId},!1)))}}clear(){this.isCreatingChart=!1,this.pendingNodes=null,this.direction=null,this.numberOfNodes=0}},D0=(e,o)=>{for(let[,t]of o)if(t.type==="arrow"&&(t.startBinding?.elementId===e.id||t.endBinding?.elementId===e.id))return!0;return!1};var P0=(e,o,t,r,n,i,a,l,s,c,m,d)=>{if(t.length===1){let[p]=t;if(o==="rotation")te(p)||(tT(p,r,n,s,c,i),at(p,r));else{if(Z(p)&&o)return oT(e,p,r,o,a,s,c),at(p,r),!0;if(o){let u=t[0].id,g=r.get(u),b=e.get(u);if(g&&b){let{nextWidth:x,nextHeight:E}=aT(g,b,r,e,o,s,c,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a});di(x,E,g,b,r,e,o,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a})}}}return!0}else if(t.length>1){if(o==="rotation")return rT(e,t,r,n,s,c,i,m,d),!0;if(o){let{nextWidth:p,nextHeight:u,flipByX:g,flipByY:b,originalBoundingBox:x}=lT(t,e,r,o,s,c,{shouldMaintainAspectRatio:l,shouldResizeFromCenter:a});return mu(t,r,o,n,e,{shouldResizeFromCenter:a,shouldMaintainAspectRatio:l,flipByX:g,flipByY:b,nextWidth:p,nextHeight:u,originalBoundingBox:x}),!0}}return!1},tT=(e,o,t,r,n,i)=>{let[a,l,s,c]=We(e,o),m=(a+s)/2,d=(l+c)/2,p;ne(e)?p=0:(p=5*Math.PI/2+Math.atan2(n-d,r-m),i&&(p=p+Qa/2,p=p-p%Qa),p=al(p));let u=ko(e);if(B(e,{angle:p}),u){let g=t.getElement(u);g&&!ke(e)&&B(g,{angle:p})}},Uc=(e,o,t,r)=>ae(e)||Lp(e)?{points:Cp(0,o,Cp(1,t,e.points,r),r)}:{},du=(e,o,t)=>{let r=e.width;if(_e(e)){let a=_t(e,o);a&&(r=Gi(a,e))}let i=e.fontSize*(t/r);return i<Rs?null:{size:i}},oT=(e,o,t,r,n,i,a)=>{let[l,s,c,m,d,p]=We(o,t),[u,g]=ce(M(i,a),M(d,p),-o.angle),b=0,x=0;r!=="e"&&r!=="w"&&(r.includes("e")&&(b=(u-l)/(c-l)),r.includes("w")&&(b=(c-u)/(c-l)),r.includes("n")&&(x=(m-g)/(m-s)),r.includes("s")&&(x=(g-s)/(m-s)));let E=Math.max(b,x);if(E>0){let w=o.width*E,y=o.height*E,v=du(o,t,w);if(v===null)return;let I=[l,s],S=[c,m],_=[d,p],L=M(l,s);if(["n","w","nw"].includes(r)&&(L=M(S[0]-Math.abs(w),S[1]-Math.abs(y))),r==="ne"){let H=[I[0],S[1]];L=M(H[0],H[1]-Math.abs(y))}if(r==="sw"){let H=[S[0],I[1]];L=M(H[0]-Math.abs(w),H[1])}["s","n"].includes(r)&&(L[0]=_[0]-w/2),["e","w"].includes(r)&&(L[1]=_[1]-y/2),n&&(L[0]=_[0]-Math.abs(w)/2,L[1]=_[1]-Math.abs(y)/2);let N=o.angle,P=ce(L,M(d,p),N),F=M(L[0]+Math.abs(w)/2,L[1]+Math.abs(y)/2),K=ce(F,M(d,p),N);L=ce(P,K,-N);let[U,q]=L;B(o,{fontSize:v.size,width:w,height:y,x:U,y:q})}if(r==="e"||r==="w"){let w=e.get(o.id),[y,v,I,S]=Xi(w,w.width,w.height,!0),_=M(y,v),L=M(I,S),N=wp(_,L),P=ce(M(i,a),N,-w.angle),[F,,K]=Xi(o,o.width,o.height,!0),U=K-F,q=L[0]-_[0],H=Fi(qe({fontSize:o.fontSize,fontFamily:o.fontFamily}),o.lineHeight),G=q/U;r.includes("e")&&(G=(P[0]-_[0])/U),r.includes("w")&&(G=(L[0]-P[0])/U);let V=o.width*G<H?H:o.width*G,ie=Hi(o.originalText,qe(o),Math.abs(V)),$=Ht(ie,qe(o),o.lineHeight),se=$.height,[be,Te,ot,jt]=Xi(w,V,se,!0),Ho=ot-be,or=jt-Te,qt=[..._];["n","w","nw"].includes(r)&&(qt=[L[0]-Math.abs(Ho),_[1]]);let rr=w.angle,Xr=ce(qt,N,rr),Jt=M(qt[0]+Math.abs(Ho)/2,qt[1]+Math.abs(or)/2),$r=ce(Jt,N,rr);qt=ce(Xr,$r,-rr);let mo={width:Math.abs(V),height:Math.abs($.height),x:qt[0],y:qt[1],text:ie,autoResize:!1};B(o,mo)}},rT=(e,o,t,r,n,i,a,l,s)=>{let c=5*Math.PI/2+Math.atan2(i-s,n-l);a&&(c+=Qa/2,c-=c%Qa);for(let m of o)if(!ne(m)){let[d,p,u,g]=We(m,t),b=(d+u)/2,x=(p+g)/2,E=e.get(m.id)?.angle??m.angle,[w,y]=ce(M(b,x),M(l,s),c+E-m.angle);te(m)?B(m,{points:fb(m,t)}):B(m,{x:m.x+(w-b),y:m.y+(y-x),angle:al(c+E)},!1),at(m,t,{simultaneouslyUpdated:o});let v=ge(m,t);v&&!ke(m)&&B(v,{x:v.x+(w-b),y:v.y+(y-x),angle:al(c+E)},!1)}r.triggerUpdate()},R0=(e,o,t,r,n)=>{let[i,a,l,s]=o.length===1?We(o[0],t):ye(o),c=(i+l)/2,m=(a+s)/2,d=o.length===1?o[0].angle:0;switch([r,n]=ce(M(r,n),M(c,m),-d),e){case"n":return ce(M(r-(i+l)/2,n-a),M(0,0),d);case"s":return ce(M(r-(i+l)/2,n-s),M(0,0),d);case"w":return ce(M(r-i,n-(a+s)/2),M(0,0),d);case"e":return ce(M(r-l,n-(a+s)/2),M(0,0),d);case"nw":return ce(M(r-i,n-a),M(0,0),d);case"ne":return ce(M(r-l,n-a),M(0,0),d);case"sw":return ce(M(r-i,n-s),M(0,0),d);case"se":return ce(M(r-l,n-s),M(0,0),d);default:return[0,0]}},N0=(e,o)=>{let[,[t,r]]=o.points;return e==="nw"&&(t<0||r<0)||e==="ne"&&t>=0||e==="sw"&&t<=0||e==="se"&&(t>0||r>0)?"end":"origin"},nT=(e,o,t)=>{if(t)return"center";if(o)switch(e){case"n":return"south-side";case"e":return"west-side";case"s":return"north-side";case"w":return"east-side";case"ne":return"bottom-left";case"nw":return"bottom-right";case"se":return"top-left";case"sw":return"top-right"}return["e","se","s"].includes(e)?"top-left":["n","nw","w"].includes(e)?"bottom-right":e==="ne"?"bottom-left":"top-right"},iT=(e,o,t,r,n,i,a,l,s)=>{let c=nT(a,l,s),[m,d]=e;switch(c){case"top-left":return{x:m+(o-r)/2+(r-o)/2*Math.cos(i)+(t-n)/2*Math.sin(i),y:d+(t-n)/2+(r-o)/2*Math.sin(i)+(n-t)/2*Math.cos(i)};case"top-right":return{x:m+(o-r)/2*(Math.cos(i)+1)+(t-n)/2*Math.sin(i),y:d+(t-n)/2+(o-r)/2*Math.sin(i)+(n-t)/2*Math.cos(i)};case"bottom-left":return{x:m+(o-r)/2*(1-Math.cos(i))+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)+(r-o)/2*Math.sin(i)};case"bottom-right":return{x:m+(o-r)/2*(Math.cos(i)+1)+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)+(o-r)/2*Math.sin(i)};case"center":return{x:m-(r-o)/2,y:d-(n-t)/2};case"east-side":return{x:m+(o-r)/2*(Math.cos(i)+1),y:d+(o-r)/2*Math.sin(i)+(t-n)/2};case"west-side":return{x:m+(o-r)/2*(1-Math.cos(i)),y:d+(r-o)/2*Math.sin(i)+(t-n)/2};case"north-side":return{x:m+(o-r)/2+(t-n)/2*Math.sin(i),y:d+(n-t)/2*(Math.cos(i)-1)};case"south-side":return{x:m+(o-r)/2+(n-t)/2*Math.sin(i),y:d+(t-n)/2*(Math.cos(i)+1)}}},di=(e,o,t,r,n,i,a,{shouldInformMutation:l=!0,shouldMaintainAspectRatio:s=!1,shouldResizeFromCenter:c=!1}={})=>{let m={},d=ge(t,n);if(d){let b=i.get(d.id);if(b&&(m={fontSize:b.fontSize}),s){let x={...t,width:e,height:o},E=du(d,n,Gi(x,d));if(E===null)return;m={fontSize:E.size}}else{let x=tc(qe(d),d.lineHeight),E=oc(d.fontSize,d.lineHeight);e=Math.max(e,x),o=Math.max(o,E)}}let p=Uc(r,e,o,!0),u=M(r.x,r.y);if(ae(r)){let[b,x]=Zb(r,i);u=M(b,x)}let g=iT(u,r.width,r.height,e,o,r.angle,a,s,c);if(ae(r)&&p.points){let b=r.x-u[0],x=r.y-u[1];g.x+=b,g.y+=x;let E=p.points[0][0],w=p.points[0][1];g.x+=E,g.y+=w,p.points=p.points.map(y=>M(y[0]-E,y[1]-w))}if(e<0&&(g.x=g.x+e),o<0&&(g.y=g.y+o),"scale"in t&&"scale"in r&&B(t,{scale:[(Math.sign(e)||r.scale[0])*r.scale[0],(Math.sign(o)||r.scale[1])*r.scale[1]]}),ke(t)&&d&&s){let b=e/t.width*d.fontSize;if(b<Rs)return;m.fontSize=b}if(e!==0&&o!==0&&Number.isFinite(g.x)&&Number.isFinite(g.y)){let b={...g,width:Math.abs(e),height:Math.abs(o),...p};B(t,b,l),at(t,n,{newSize:{width:e,height:o}}),d&&m!=null&&B(d,{fontSize:m.fontSize}),hl(t,n,a,s)}},aT=(e,o,t,r,n,i,a,{shouldMaintainAspectRatio:l=!1,shouldResizeFromCenter:s=!1}={})=>{let[c,m,d,p]=Xi(o,o.width,o.height,!0),u=M(c,m),g=M(d,p),b=wp(u,g),x=ce(M(i,a),b,-o.angle),[E,w,y,v]=Xi(e,e.width,e.height,!0),I=y-E,S=v-w,_=g[0]-u[0],L=g[1]-u[1],N=_/I,P=L/S;n.includes("e")&&(N=(x[0]-u[0])/I),n.includes("s")&&(P=(x[1]-u[1])/S),n.includes("w")&&(N=(g[0]-x[0])/I),n.includes("n")&&(P=(g[1]-x[1])/S);let F=e.width*N,K=e.height*P;if(s&&(F=2*F-o.width,K=2*K-o.height),l){let U=Math.abs(F)/o.width,q=Math.abs(K)/o.height;if(n.length===1&&(K*=U,F*=q),n.length===2){let H=Math.max(U,q);F=o.width*H*Math.sign(F),K=o.height*H*Math.sign(K)}}return{nextWidth:F,nextHeight:K}},lT=(e,o,t,r,n,i,{shouldMaintainAspectRatio:a=!1,shouldResizeFromCenter:l=!1}={})=>{let s=e.map(U=>o.get(U.id)),c=s.reduce((U,q)=>{if(!ae(q))return U;let H=ko(q);if(!H)return U;let G=o.get(H)??null;return _e(G)?[...U,{...G,...j.getBoundTextElementPosition(q,G,t)}]:U},[]),m=Dt(s.map(U=>U).concat(c)),{minX:d,minY:p,maxX:u,maxY:g,midX:b,midY:x}=m,E=u-d,w=g-p,y={ne:[d,g],se:[d,p],sw:[u,p],nw:[u,g],e:[d,p+w/2],w:[u,p+w/2],n:[d+E/2,g],s:[d+E/2,p]},[v,I]=l?[b,x]:y[r],S=l?2:1,_=Math.max(Math.abs(n-v)/E||0,Math.abs(i-I)/w||0)*S,L=r.includes("e")||r.includes("w")?Math.abs(n-v)*S:E,N=r.includes("n")||r.includes("s")?Math.abs(i-I)*S:w;a&&(L=E*_*Math.sign(n-v),N=w*_*Math.sign(i-I));let P={ne:[n<v,i>I],se:[n<v,i<I],sw:[n>v,i<I],nw:[n>v,i>I],e:[n<v,!1],w:[n>v,!1],n:[!1,i>I],s:[!1,i<I]},[F,K]=P[r].map(U=>U);return{originalBoundingBox:m,nextWidth:L,nextHeight:N,flipByX:F,flipByY:K}},mu=(e,o,t,r,n,{shouldMaintainAspectRatio:i=!1,shouldResizeFromCenter:a=!1,flipByX:l=!1,flipByY:s=!1,nextHeight:c,nextWidth:m,originalBoundingBox:d}={})=>{if(m===void 0&&c===void 0&&l===void 0&&s===void 0||c===0||m===0)return;n||(n=o);let p=e.reduce((S,_)=>{let L=n.get(_.id);return L&&S.push({orig:L,latest:_}),S},[]),u;if(d)u=d;else{let S=p.reduce((_,{orig:L})=>{if(!ae(L))return _;let N=ko(L);if(!N)return _;let P=n.get(N)??null;return _e(P)?[..._,{...P,...j.getBoundTextElementPosition(L,P,o)}]:_},[]);u=Dt(p.map(({orig:_})=>_).concat(S))}let{minX:g,minY:b,maxX:x,maxY:E,midX:w,midY:y}=u,v=x-g,I=E-b;if(m===void 0&&c===void 0&&(m=v,c=I),i&&(m===void 0?m=c*(v/I):c===void 0?c=m*(I/v):Math.abs(m/c-v/I)>.001&&(m=c*(v/I))),m&&c){let S=t.includes("e")||t.includes("w")?Math.abs(m)/v:1,_=t.includes("n")||t.includes("s")?Math.abs(c)/I:1,L;t.length===1?L=t.includes("e")||t.includes("w")?S:_:L=Math.max(Math.abs(m)/v||0,Math.abs(c)/I||0);let N={ne:[g,E],se:[g,b],sw:[x,b],nw:[x,E],e:[g,b+I/2],w:[x,b+I/2],n:[g+v/2,E],s:[g+v/2,b]},[P,F]=a?[w,y]:N[t],K=i||p.some(V=>V.latest.angle!==0||Z(V.latest)||sr(V.latest));K&&(S=L,_=L);let[U,q]=[l?-1:1,s?-1:1],H=[];for(let{orig:V,latest:ie}of p){if(Z(V)&&_e(V))continue;let $=V.width*S,se=V.height*_,be=al(V.angle*U*q),Te=ae(V)||Lp(V),ot=V.x-P,jt=V.y-F,Ho=l&&!Te?$:0,or=s&&!Te?se:0,qt=P+U*(ot*S+Ho),rr=F+q*(jt*_+or),Xr=Uc(V,$*U,se*q,!1),Jt={x:qt,y:rr,width:$,height:se,angle:be,...Xr};if(te(V)&&(V.startBinding&&(Jt.startBinding={...V.startBinding,fixedPoint:[l?-V.startBinding.fixedPoint[0]+1:V.startBinding.fixedPoint[0],s?-V.startBinding.fixedPoint[1]+1:V.startBinding.fixedPoint[1]]}),V.endBinding&&(Jt.endBinding={...V.endBinding,fixedPoint:[l?-V.endBinding.fixedPoint[0]+1:V.endBinding.fixedPoint[0],s?-V.endBinding.fixedPoint[1]+1:V.endBinding.fixedPoint[1]]}),V.fixedSegments&&Xr.points&&(Jt.fixedSegments=V.fixedSegments.map(mo=>({...mo,start:Xr.points[mo.index-1],end:Xr.points[mo.index]})))),he(V)&&(Jt.scale=[V.scale[0]*U,V.scale[1]*q]),Z(V)){let mo=du(V,o,$);if(!mo)return;Jt.fontSize=mo.size}let $r=n.get(ko(V)??"");if($r)if(K){let mo=$r.fontSize*L;if(mo<Rs)return;Jt.boundTextFontSize=mo}else Jt.boundTextFontSize=$r.fontSize;H.push({element:ie,update:Jt})}let G=H.map(({element:V})=>V);for(let{element:V,update:{boundTextFontSize:ie,...$}}of H){let{width:se,height:be,angle:Te}=$;B(V,$,!1,{isDragging:!0}),at(V,o,{simultaneouslyUpdated:G,newSize:{width:se,height:be}});let ot=ge(V,o);ot&&ie&&(B(ot,{fontSize:ie,angle:ae(V)?void 0:Te},!1),hl(V,o,t,!0))}r.triggerUpdate()}};var uu=(e,o,t)=>o>=e[0]&&o<=e[0]+e[2]&&t>=e[1]&&t<=e[1]+e[3],sT=(e,o,t,r,n,i,a,l)=>{if(!t.selectedElementIds[e.id])return!1;let{rotation:s,...c}=Bc(e,i,o,a,si(l));if(s&&uu(s,r,n))return"rotation";let m=Object.keys(c).filter(d=>{let p=c[d];return p?uu(p,r,n):!1});if(m.length>0)return m[0];if(Oc(l)){let[d,p,u,g,b,x]=We(e,o);if(!(ae(e)&&e.points.length<=2)){let E=he(e)?0:Os/i.value,w=Os/i.value,y=O0(M(d-E,p-E),M(u+E,g+E),M(b,x),e.angle);for(let[v,I]of Object.entries(y))if(Tp(M(r,n),I,w))return v}}return!1},hu=(e,o,t,r,n,i,a,l)=>e.reduce((s,c)=>{if(s)return s;let m=sT(c,a,o,t,r,n,i,l);return m?{element:c,transformHandleType:m}:null},null),gu=([e,o,t,r],n,i,a,l,s)=>{let c=kl([e,o,t,r,(e+t)/2,(o+r)/2],0,a,l,si(s)),m=Object.keys(c).find(d=>{let p=c[d];return p&&uu(p,n,i)});if(m)return m;if(Oc(s)){let d=(e+t)/2,p=(o+r)/2,u=Os/a.value,g=O0(M(e-u,o-u),M(t+u,r+u),M(d,p),0);for(let[b,x]of Object.entries(g))if(Tp(M(n,i),x,u))return b}return!1},pu=["ns","nesw","ew","nwse"],cT=(e,o)=>{let t=pu.indexOf(e);if(t>=0){let r=Math.round(o/(Math.PI/4));e=pu[(t+r)%pu.length]}return e},fu=e=>{let{element:o,transformHandleType:t}=e,r=o&&Math.sign(o.height)*Math.sign(o.width)===-1,n=null;switch(t){case"n":case"s":n="ns";break;case"w":case"e":n="ew";break;case"nw":case"se":r?n="nesw":n="nwse";break;case"ne":case"sw":r?n="nwse":n="nesw";break;case"rotation":return"grab"}return n&&o&&(n=cT(n,o.angle)),n?`${n}-resize`:""},O0=([e,o],[t,r],n,i)=>{let a=ce(M(e,o),n,i),l=ce(M(t,o),n,i),s=ce(M(e,r),n,i),c=ce(M(t,r),n,i);return{n:[a,l],e:[l,c],s:[c,s],w:[s,a]}};var z0=(e,o,t,r,n,i)=>{if(o.length===1&&te(o[0])&&(o[0].startBinding||o[0].endBinding))return;let a=o.filter(d=>{if(te(d)&&d.startBinding&&d.endBinding){let p=o.find(g=>g.id===d.startBinding?.elementId),u=o.find(g=>g.id===d.endBinding?.elementId);return p&&u}return!0}),l=new Set(a),s=a.filter(d=>ne(d)).map(d=>d.id);if(s.length>0)for(let d of r.getNonDeletedElements())d.frameId!==null&&s.includes(d.frameId)&&l.add(d);let c=[];for(let d of l){let p=e.originalElements.get(d.id);if(!p)return;c.push(p)}let m=dT(ye(c),t,n,i);l.forEach(d=>{if(B0(e,d,m),!ke(d)){let p=ge(d,r.getNonDeletedElementsMap());p&&B0(e,p,m),at(d,r.getElementsMapIncludingDeleted(),{simultaneouslyUpdated:Array.from(l)})}})},dT=(e,o,t,r)=>{let[n,i]=e,a=n+o.x+t.x,l=i+o.y+t.y;if(t.x===0||t.y===0){let[s,c]=ht(n+o.x,i+o.y,r);t.x===0&&(a=s),t.y===0&&(l=c)}return{x:a-n,y:l-i}},B0=(e,o,t)=>{let r=e.originalElements.get(o.id)??o,n=r.x+t.x,i=r.y+t.y;B(o,{x:n,y:i})},F0=(e,o,t)=>{let[r,n]=ye(e);return[o-r,t-n]},bu=({newElement:e,elementType:o,originX:t,originY:r,x:n,y:i,width:a,height:l,shouldMaintainAspectRatio:s,shouldResizeFromCenter:c,zoom:m,widthAspectRatio:d=null,originOffset:p=null,informMutation:u=!0})=>{s&&e.type!=="selection"&&(d?l=a/d:(Math.abs(i-r)>Math.abs(n-t)?{width:a,height:l}=Pp(o,l,n<t?-a:a):{width:a,height:l}=Pp(o,a,i<r?-l:l),l<0&&(l=-l)));let g=n<t?t-a:t,b=i<r?r-l:r;c&&(a+=a,l+=l,g=t-a/2,b=r-l/2);let x=null;if(Z(e)){l=e.height;let E=Fi(qe({fontSize:e.fontSize,fontFamily:e.fontFamily}),e.lineHeight);a=Math.max(a,E),Math.abs(n-t)>Wf/m&&(x={autoResize:!1}),b=r,c&&(g=t-a/2)}if(a!==0&&l!==0){let E=null;he(e)&&(E={initialWidth:a,initialHeight:l}),B(e,{x:g+(p?.x??0),y:b+(p?.y??0),width:a,height:l,...x,...E},u)}};import{atom as De,createStore as mT}from"jotai";import{createIsolation as pT}from"jotai-scope";var H0=pT();var{useAtom:ve,useSetAtom:hn,useAtomValue:Gc,useStore:D7}=H0,U0=H0.Provider,St=mT();var uT=Df({"./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-SBO6ZHT2.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 hT=85,pr={code:"en",label:"English"},na=[pr,...[{code:"ar-SA",label:"\u0627\u0644\u0639\u0631\u0628\u064A\u0629",rtl:!0},{code:"bg-BG",label:"\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"},{code:"ca-ES",label:"Catal\xE0"},{code:"cs-CZ",label:"\u010Cesky"},{code:"de-DE",label:"Deutsch"},{code:"el-GR",label:"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC"},{code:"es-ES",label:"Espa\xF1ol"},{code:"eu-ES",label:"Euskara"},{code:"fa-IR",label:"\u0641\u0627\u0631\u0633\u06CC",rtl:!0},{code:"fi-FI",label:"Suomi"},{code:"fr-FR",label:"Fran\xE7ais"},{code:"gl-ES",label:"Galego"},{code:"he-IL",label:"\u05E2\u05D1\u05E8\u05D9\u05EA",rtl:!0},{code:"hi-IN",label:"\u0939\u093F\u0928\u094D\u0926\u0940"},{code:"hu-HU",label:"Magyar"},{code:"id-ID",label:"Bahasa Indonesia"},{code:"it-IT",label:"Italiano"},{code:"ja-JP",label:"\u65E5\u672C\u8A9E"},{code:"kab-KAB",label:"Taqbaylit"},{code:"kk-KZ",label:"\u049A\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"},{code:"ko-KR",label:"\uD55C\uAD6D\uC5B4"},{code:"ku-TR",label:"Kurd\xEE"},{code:"lt-LT",label:"Lietuvi\u0173"},{code:"lv-LV",label:"Latvie\u0161u"},{code:"my-MM",label:"Burmese"},{code:"nb-NO",label:"Norsk bokm\xE5l"},{code:"nl-NL",label:"Nederlands"},{code:"nn-NO",label:"Norsk nynorsk"},{code:"oc-FR",label:"Occitan"},{code:"pa-IN",label:"\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40"},{code:"pl-PL",label:"Polski"},{code:"pt-BR",label:"Portugu\xEAs Brasileiro"},{code:"pt-PT",label:"Portugu\xEAs"},{code:"ro-RO",label:"Rom\xE2n\u0103"},{code:"ru-RU",label:"\u0420\u0443\u0441\u0441\u043A\u0438\u0439"},{code:"sk-SK",label:"Sloven\u010Dina"},{code:"sv-SE",label:"Svenska"},{code:"sl-SI",label:"Sloven\u0161\u010Dina"},{code:"tr-TR",label:"T\xFCrk\xE7e"},{code:"uk-UA",label:"\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"},{code:"zh-CN",label:"\u7B80\u4F53\u4E2D\u6587"},{code:"zh-TW",label:"\u7E41\u9AD4\u4E2D\u6587"},{code:"vi-VN",label:"Ti\u1EBFng Vi\u1EC7t"},{code:"mr-IN",label:"\u092E\u0930\u093E\u0920\u0940"}].filter(e=>r0[e.code]>=hT).sort((e,o)=>e.label>o.label?1:-1)],Yc="__test__";Ue()&&na.unshift({code:Yc,label:"test language"},{code:`${Yc}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var ra=pr,Vc={},Wc=async e=>{if(ra=e,document.documentElement.dir=ra.rtl?"rtl":"ltr",document.documentElement.lang=ra.code,e.code.startsWith(Yc))Vc={};else try{Vc=await uT(`./locales/${ra.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),Vc=jp}St.set(V0,e.code)},Br=()=>ra,G0=(e,o)=>{for(let t=0;t<o.length;++t){let r=o[t];if(e[r]===void 0)return;e=e[r]}if(typeof e=="string")return e},f=(e,o,t)=>{if(ra.code.startsWith(Yc))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=G0(Vc,r)||G0(jp,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(k.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)n=n.replace(`{{${i}}}`,String(o[i]));return n},V0=De(pr.code),ut=()=>{let e=Gc(V0);return{t:f,langCode:e}};var rt=class e{constructor(o,t){this.deleted=o;this.inserted=t}static create(o,t,r,n){let i=r&&n!=="inserted"?r(o):o,a=r&&n!=="deleted"?r(t):t;return new e(i,a)}static calculate(o,t,r,n){if(o===t)return e.empty();let i={},a={};for(let c of this.distinctKeysIterator("full",o,t))i[c]=o[c],a[c]=t[c];let[l,s]=n?n(i,a):[i,a];return e.create(l,s,r)}static empty(){return new e({},{})}static isEmpty(o){return!Object.keys(o.deleted).length&&!Object.keys(o.inserted).length}static mergeObjects(o,t,r){let n={...o};for(let i of Object.keys(r))delete n[i];return{...n,...t}}static mergeArrays(o,t,r,n){return Object.values(e.mergeObjects(ar(o??[],n),ar(t??[],n),ar(r??[],n)))}static diffObjects(o,t,r,n){if(!(!o[r]&&!t[r])&&(typeof o[r]=="object"||typeof t[r]=="object")){let i=o[r]??{},a=t[r]??{},l=e.getLeftDifferences(i,a).reduce((c,m)=>(c[m]=n(i[m]),c),{}),s=e.getRightDifferences(i,a).reduce((c,m)=>(c[m]=n(a[m]),c),{});Object.keys(l).length||Object.keys(s).length?(Reflect.set(o,r,l),Reflect.set(t,r,s)):(Reflect.deleteProperty(o,r),Reflect.deleteProperty(t,r))}}static diffArrays(o,t,r,n){if(!(!o[r]&&!t[r])&&(Array.isArray(o[r])||Array.isArray(t[r]))){let i=Array.isArray(o[r])?o[r]:[],a=Array.isArray(t[r])?t[r]:[],l=ar(e.getLeftDifferences(ar(i,n),ar(a,n))),s=ar(e.getRightDifferences(ar(i,n),ar(a,n)));if(Object.keys(l).length||Object.keys(s).length){let c=i.filter(d=>l[n?n(d):String(d)]),m=a.filter(d=>s[n?n(d):String(d)]);Reflect.set(o,r,c),Reflect.set(t,r,m)}else Reflect.deleteProperty(o,r),Reflect.deleteProperty(t,r)}}static isLeftDifferent(o,t,r=!1){return!!this.distinctKeysIterator("left",o,t,r).next().value}static isRightDifferent(o,t,r=!1){return!!this.distinctKeysIterator("right",o,t,r).next().value}static getLeftDifferences(o,t,r=!1){return Array.from(this.distinctKeysIterator("left",o,t,r))}static getRightDifferences(o,t,r=!1){return Array.from(this.distinctKeysIterator("right",o,t,r))}static*distinctKeysIterator(o,t,r,n=!1){if(t===r)return;let i=[];o==="left"?i=Object.keys(t):o==="right"?i=Object.keys(r):o==="full"?i=Array.from(new Set([...Object.keys(t),...Object.keys(r)])):Zn(o,`Unknown distinctKeysIterator's join param "${o}"`,!0);for(let a of i){let l=t[a],s=r[a];if(l!==s){if(!n&&typeof l=="object"&&typeof s=="object"&&l!==null&&s!==null&&Je(l,s))continue;yield a}}}},Ml=class e{constructor(o){this.delta=o}static calculate(o,t){let r=rt.calculate(o,t,void 0,e.postProcess);return new e(r)}static empty(){return new e(rt.create({},{}))}inverse(){let o=rt.create(this.delta.inserted,this.delta.deleted);return new e(o)}applyTo(o,t){try{let{selectedElementIds:r={},selectedGroupIds:n={}}=this.delta.deleted,{selectedElementIds:i={},selectedGroupIds:a={},selectedLinearElementId:l,editingLinearElementId:s,...c}=this.delta.inserted,m=rt.mergeObjects(o.selectedElementIds,i,r),d=rt.mergeObjects(o.selectedGroupIds,a,n),p=l&&t.has(l)?new j(t.get(l)):null,u=s&&t.has(s)?new j(t.get(s)):null,g={...o,...c,selectedElementIds:m,selectedGroupIds:d,selectedLinearElement:typeof l<"u"?p:o.selectedLinearElement,editingLinearElement:typeof s<"u"?u:o.editingLinearElement},b=this.filterInvisibleChanges(o,g,t);return[g,b]}catch(r){if(console.error("Couldn't apply appstate change",r),mt()||Ue())throw r;return[o,!1]}}isEmpty(){return rt.isEmpty(this.delta)}static postProcess(o,t){try{rt.diffObjects(o,t,"selectedElementIds",r=>!0),rt.diffObjects(o,t,"selectedGroupIds",r=>r??!1)}catch(r){if(console.error("Couldn't postprocess appstate change deltas."),mt()||Ue())throw r}finally{return[o,t]}}filterInvisibleChanges(o,t,r){let n=Al(o),i=Al(t),a=rt.isRightDifferent(e.stripElementsProps(n),e.stripElementsProps(i)),l=rt.isRightDifferent(e.stripStandaloneProps(n),e.stripStandaloneProps(i));if(!a&&!l)return!1;let s={value:a};if(l){let c=rt.getRightDifferences(e.stripStandaloneProps(n),e.stripStandaloneProps(i)),m=new Set;(c.includes("editingGroupId")||c.includes("selectedGroupIds"))&&(m=Ob(r));for(let d of c)switch(d){case"selectedElementIds":t[d]=e.filterSelectedElements(t[d],r,s);break;case"selectedGroupIds":t[d]=e.filterSelectedGroups(t[d],m,s);break;case"croppingElementId":{let b=t[d],x=b&&r.get(b);x&&!x.isDeleted?s.value=!0:t[d]=null;break}case"editingGroupId":let p=t[d];p?m.has(p)?s.value=!0:t[d]=null:s.value=!0;break;case"selectedLinearElementId":case"editingLinearElementId":let u=e.convertToAppStateKey(d),g=t[u];if(!g)s.value=!0;else{let b=r.get(g.elementId);b&&!b.isDeleted?s.value=!0:t[u]=null}break;default:Zn(d,`Unknown ObservedElementsAppState's key "${d}"`,!0)}}return s.value}static convertToAppStateKey(o){switch(o){case"selectedLinearElementId":return"selectedLinearElement";case"editingLinearElementId":return"editingLinearElement"}}static filterSelectedElements(o,t,r){let n=Object.keys(o);if(!n.length)return r.value=!0,o;let i={...o};for(let a of n){let l=t.get(a);l&&!l.isDeleted?r.value=!0:delete i[a]}return i}static filterSelectedGroups(o,t,r){if(!Object.keys(o).length)return r.value=!0,o;let i={...o};for(let a of Object.keys(i))t.has(a)?r.value=!0:delete i[a];return i}static stripElementsProps(o){let{editingGroupId:t,selectedGroupIds:r,selectedElementIds:n,editingLinearElementId:i,selectedLinearElementId:a,croppingElementId:l,...s}=o;return s}static stripStandaloneProps(o){let{name:t,viewBackgroundColor:r,...n}=o;return n}},Pe=class Pe{constructor(o,t,r){this.added=o;this.removed=t;this.updated=r}static create(o,t,r,n={shouldRedistribute:!1}){let i;if(n.shouldRedistribute){let a=new Map,l=new Map,s=new Map,c=[...o,...t,...r];for(let[m,d]of c)this.satisfiesAddition(d)?a.set(m,d):this.satisfiesRemoval(d)?l.set(m,d):s.set(m,d);i=new Pe(a,l,s)}else i=new Pe(o,t,r);return(mt()||Ue())&&(Pe.validate(i,"added",this.satisfiesAddition),Pe.validate(i,"removed",this.satisfiesRemoval),Pe.validate(i,"updated",this.satisfiesUpdate)),i}static validate(o,t,r){for(let[n,i]of o[t].entries())if(!r(i))throw console.error(`Broken invariant for "${t}" delta, element "${n}", delta:`,i),new Error(`ElementsChange invariant broken for element "${n}".`)}static calculate(o,t){if(o===t)return Pe.empty();let r=new Map,n=new Map,i=new Map;for(let a of o.values())if(!t.get(a.id)){let s={...a,isDeleted:!1},c={isDeleted:!0},m=rt.create(s,c,Pe.stripIrrelevantProps);n.set(a.id,m)}for(let a of t.values()){let l=o.get(a.id);if(!l){let s={isDeleted:!0},c={...a,isDeleted:!1},m=rt.create(s,c,Pe.stripIrrelevantProps);r.set(a.id,m);continue}if(l.versionNonce!==a.versionNonce){let s=rt.calculate(l,a,Pe.stripIrrelevantProps,Pe.postProcess);if(typeof l.isDeleted=="boolean"&&typeof a.isDeleted=="boolean"&&l.isDeleted!==a.isDeleted){l.isDeleted&&!a.isDeleted?r.set(a.id,s):n.set(a.id,s);continue}rt.isEmpty(s)||i.set(a.id,s)}}return Pe.create(r,n,i)}static empty(){return Pe.create(new Map,new Map,new Map)}inverse(){let o=i=>{let a=new Map;for(let[l,s]of i.entries())a.set(l,rt.create(s.inserted,s.deleted));return a},t=o(this.added),r=o(this.removed),n=o(this.updated);return Pe.create(r,t,n)}isEmpty(){return this.added.size===0&&this.removed.size===0&&this.updated.size===0}applyLatestChanges(o){let t=l=>s=>{let c={};for(let m of Object.keys(s))switch(m){case"boundElements":c[m]=s[m];break;default:c[m]=l[m]}return c},r=l=>{let s=new Map;for(let[c,m]of l.entries()){let d=o.get(c);if(d){let p=rt.create(m.deleted,m.inserted,t(d),"inserted");s.set(c,p)}else s.set(c,m)}return s},n=r(this.added),i=r(this.removed),a=r(this.updated);return Pe.create(n,i,a,{shouldRedistribute:!0})}applyTo(o,t){let r=sn(new Map(o)),n,i={containsVisibleDifference:!1,containsZindexDifference:!1};try{let a=Pe.createApplier(r,t,i),l=a(this.added),s=a(this.removed),c=a(this.updated),m=this.resolveConflicts(o,r);n=new Map([...l,...s,...c,...m])}catch(a){if(console.error("Couldn't apply elements change",a),mt()||Ue())throw a;return[o,!0]}try{Pe.redrawTextBoundingBoxes(r,n),r=Pe.reorderElements(r,n,i),Pe.redrawBoundArrows(r,n)}catch(a){if(console.error("Couldn't mutate elements after applying elements change",a),mt()||Ue())throw a}finally{return[r,i.containsVisibleDifference]}}static applyDelta(o,t,r={containsVisibleDifference:!0,containsZindexDifference:!0}){let{boundElements:n,...i}=t.inserted;if(t.deleted.boundElements?.length||t.inserted.boundElements?.length){let a=rt.mergeArrays(o.boundElements,t.inserted.boundElements,t.deleted.boundElements,l=>l.id);Object.assign(i,{boundElements:a})}if(he(o)){let a=t;(a.deleted.crop||a.inserted.crop)&&Object.assign(i,{crop:a.inserted.crop??null})}if(!r.containsVisibleDifference){let{index:a,...l}=i,s=Pe.checkForVisibleDifference(o,l);r.containsVisibleDifference=s}return r.containsZindexDifference||(r.containsZindexDifference=t.deleted.index!==t.inserted.index),oe(o,i)}static checkForVisibleDifference(o,t){return o.isDeleted&&t.isDeleted!==!1?!1:o.isDeleted&&t.isDeleted===!1||o.isDeleted===!1&&t.isDeleted?!0:rt.isRightDifferent(o,t)}resolveConflicts(o,t){let r=new Map,n=(c,m)=>{let d=t.get(c.id);if(!d)return;let p;o.get(c.id)===d?p=oe(d,m):p=B(d,m),r.set(p.id,p),t.set(p.id,p)};for(let[c]of this.removed)Pe.unbindAffected(o,t,c,n);for(let[c]of this.added)Pe.rebindAffected(o,t,c,n);for(let[c]of Array.from(this.updated).filter(([m,d])=>Object.keys({...d.deleted,...d.inserted}).find(p=>gb.has(p)))){let m=t.get(c);!m||m.isDeleted||Pe.rebindAffected(o,t,c,n)}let i=new Map(Array.from(o).filter(([c])=>r.has(c))),{added:a,removed:l,updated:s}=Pe.calculate(i,r);for(let[c,m]of a)this.added.set(c,m);for(let[c,m]of l)this.removed.set(c,m);for(let[c,m]of s)this.updated.set(c,m);return r}static unbindAffected(o,t,r,n){let i=()=>o.get(r),a=()=>t.get(r);fl.unbindAffected(t,i(),n),fl.unbindAffected(t,a(),n),bl.unbindAffected(t,i(),n),bl.unbindAffected(t,a(),n)}static rebindAffected(o,t,r,n){let i=()=>o.get(r),a=()=>t.get(r);fl.unbindAffected(t,i(),n),fl.rebindAffected(t,a(),n),bl.unbindAffected(t,i(),(l,s)=>{Z(l)&&n(l,s)}),bl.rebindAffected(t,a(),n)}static redrawTextBoundingBoxes(o,t){let r=new Map;for(let n of t.values()){if(_e(n)){let{containerId:i}=n,a=i?o.get(i):void 0;a&&r.set(a.id,{container:a,boundText:n})}if(pt(n)){let i=ko(n),a=i?o.get(i):void 0;a&&r.set(n.id,{container:n,boundText:a})}}for(let{container:n,boundText:i}of r.values())n.isDeleted||i.isDeleted||Qe(i,n,o,!1)}static redrawBoundArrows(o,t){for(let r of t.values())!r.isDeleted&&$n(r)&&at(r,o,{changedElements:t})}static reorderElements(o,t,r){if(!r.containsZindexDifference)return o;let n=Array.from(o.values()),i=bc([...n]),a=rt.getRightDifferences(n,i,!0).reduce((l,s)=>{let c=n[Number(s)];return c&&t.has(c.id)&&l.set(c.id,c),l},new Map);return!r.containsVisibleDifference&&a.size&&(r.containsVisibleDifference=!0),ee(Ut(i,a))}static postProcess(o,t){try{rt.diffArrays(o,t,"boundElements",r=>r.id)}catch(r){if(console.error("Couldn't postprocess elements change deltas."),mt()||Ue())throw r}finally{return[o,t]}}static stripIrrelevantProps(o){let{id:t,updated:r,version:n,versionNonce:i,seed:a,...l}=o;return l}};C(Pe,"satisfiesAddition",({deleted:o,inserted:t})=>o.isDeleted===!0&&!t.isDeleted),C(Pe,"satisfiesRemoval",({deleted:o,inserted:t})=>!o.isDeleted&&t.isDeleted===!0),C(Pe,"satisfiesUpdate",({deleted:o,inserted:t})=>!!o.isDeleted==!!t.isDeleted),C(Pe,"createApplier",(o,t,r)=>{let n=Pe.createGetter(o,t,r);return i=>Array.from(i.entries()).reduce((a,[l,s])=>{let c=n(l,s.inserted);if(c){let m=Pe.applyDelta(c,s,r);o.set(m.id,m),a.set(m.id,m)}return a},new Map)}),C(Pe,"createGetter",(o,t,r)=>(n,i)=>{let a=o.get(n);return a||(a=t.get(n),a&&(r.containsZindexDifference=!0,(i.isDeleted===!1||i.isDeleted!==!0&&a.isDeleted===!1)&&(r.containsVisibleDifference=!0))),a});var Ll=Pe;var Pt=class{constructor(){C(this,"subscribers",[])}on(...o){let t=o.flat().filter(r=>typeof r=="function");return this.subscribers.push(...t),()=>this.off(t)}once(...o){let t=o.flat().filter(n=>typeof n=="function");t.push(()=>r());let r=this.on(...t);return r}off(...o){let t=o.flat();this.subscribers=this.subscribers.filter(r=>!t.includes(r))}trigger(...o){for(let t of this.subscribers)t(...o);return this}clear(){this.subscribers=[]}};var Y0="__observedAppState",Al=e=>{let o={name:e.name,editingGroupId:e.editingGroupId,viewBackgroundColor:e.viewBackgroundColor,selectedElementIds:e.selectedElementIds,selectedGroupIds:e.selectedGroupIds,editingLinearElementId:e.editingLinearElement?.elementId||null,selectedLinearElementId:e.selectedLinearElement?.elementId||null,croppingElementId:e.croppingElementId};return Reflect.defineProperty(o,Y0,{value:!0,enumerable:!1}),o},gT=e=>!!Reflect.get(e,Y0),A={IMMEDIATELY:"IMMEDIATELY",NEVER:"NEVER",EVENTUALLY:"EVENTUALLY"},xu=class{constructor(o,t){this.elementsChange=o;this.appStateChange=t}},Kc=class{constructor(){C(this,"onStoreIncrementEmitter",new Pt);C(this,"scheduledActions",new Set);C(this,"_snapshot",Zc.empty());C(this,"shouldCaptureIncrement",()=>{this.scheduleAction(A.IMMEDIATELY)});C(this,"shouldUpdateSnapshot",()=>{this.scheduleAction(A.NEVER)});C(this,"scheduleAction",o=>{this.scheduledActions.add(o),this.satisfiesScheduledActionsInvariant()});C(this,"commit",(o,t)=>{try{this.scheduledActions.has(A.IMMEDIATELY)?this.captureIncrement(o,t):this.scheduledActions.has(A.NEVER)&&this.updateSnapshot(o,t)}finally{this.satisfiesScheduledActionsInvariant(),this.scheduledActions=new Set}});C(this,"captureIncrement",(o,t)=>{let r=this.snapshot,n=this.snapshot.maybeClone(o,t);if(r!==n){let i=n.meta.didElementsChange?Ll.calculate(r.elements,n.elements):Ll.empty(),a=n.meta.didAppStateChange?Ml.calculate(r.appState,n.appState):Ml.empty();(!i.isEmpty()||!a.isEmpty())&&this.onStoreIncrementEmitter.trigger(new xu(i,a)),this.snapshot=n}});C(this,"updateSnapshot",(o,t)=>{let r=this.snapshot.maybeClone(o,t);this.snapshot!==r&&(this.snapshot=r)});C(this,"filterUncomittedElements",(o,t)=>{for(let[r,n]of o.entries()){if(!t.get(r))continue;let a=this.snapshot.elements.get(r);a?a.version<n.version&&t.set(r,a):t.delete(r)}return t});C(this,"clear",()=>{this.snapshot=Zc.empty(),this.scheduledActions=new Set});C(this,"satisfiesScheduledActionsInvariant",()=>{if(!(this.scheduledActions.size>=0&&this.scheduledActions.size<=3)){let o=`There can be at most three store actions scheduled at the same time, but there are "${this.scheduledActions.size}".`;if(console.error(o,this.scheduledActions.values()),mt()||Ue())throw new Error(o)}})}get snapshot(){return this._snapshot}set snapshot(o){this._snapshot=o}},Zc=class e{constructor(o,t,r={didElementsChange:!1,didAppStateChange:!1,isEmpty:!1}){this.elements=o;this.appState=t;this.meta=r}static empty(){return new e(new Map,Al(mr()),{didElementsChange:!1,didAppStateChange:!1,isEmpty:!0})}isEmpty(){return this.meta.isEmpty}maybeClone(o,t){let r=this.maybeCreateElementsSnapshot(o),n=this.maybeCreateAppStateSnapshot(t),i=!1,a=!1;return this.elements!==r&&(i=!0),this.appState!==n&&(a=!0),!i&&!a?this:new e(r,n,{didElementsChange:i,didAppStateChange:a})}maybeCreateAppStateSnapshot(o){if(!o)return this.appState;let t=gT(o)?o:Al(o);return this.detectChangedAppState(t)?t:this.appState}detectChangedAppState(o){return!Je(this.appState,o,{selectedElementIds:Je,selectedGroupIds:Je})}maybeCreateElementsSnapshot(o){return o?this.detectChangedElements(o)?this.createElementsSnapshot(o):this.elements:this.elements}detectChangedElements(o){if(this.elements===o)return!1;if(this.elements.size!==o.size)return!0;let t=Array.from(o.keys());for(let r=t.length-1;r>=0;r--){let n=this.elements.get(t[r]),i=o.get(t[r]);if(!n||!i||n.id!==i.id||n.versionNonce!==i.versionNonce)return!0}return!1}createElementsSnapshot(o){let t=new Map;for(let[r,n]of this.elements.entries())o.get(r)?t.set(r,n):t.set(r,oe(n,{isDeleted:!0}));for(let[r,n]of o.entries()){let i=t.get(r);(!i||i&&i.versionNonce!==n.versionNonce)&&t.set(r,uo(n))}return t}};import fT from"clsx";import bT from"open-color";import kt from"react";import{Fragment as Oe,jsx as h,jsxs as O}from"react/jsx-runtime";var $o=e=>"var(--icon-fill-color)",W0=e=>e===de.LIGHT?bT.white:"#1e1e1e",D=(e,o=512)=>{let{width:t=512,height:r=t,mirror:n,style:i,...a}=typeof o=="number"?{width:o}:o;return h("svg",{"aria-hidden":"true",focusable:"false",role:"img",viewBox:`0 0 ${t} ${r}`,className:fT({"rtl-mirror":n}),style:i,...a,children:typeof e=="string"?h("path",{fill:"currentColor",d:e}):e})},W={width:24,height:24,fill:"none",strokeWidth:2,stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},me={width:20,height:20,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"},x_=D(O("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"})]}),W),ia=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 19a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("path",{d:"M3 6a9 9 0 0 1 9 0a9 9 0 0 1 9 0"}),h("line",{x1:"3",y1:"6",x2:"3",y2:"19"}),h("line",{x1:"12",y1:"6",x2:"12",y2:"19"}),h("line",{x1:"21",y1:"6",x2:"21",y2:"19"})]}),W),K0=D(O("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),W),Z0=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"1"}),h("circle",{cx:"12",cy:"19",r:"1"}),h("circle",{cx:"12",cy:"5",r:"1"})]}),W),X0=D(O("svg",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 4v6l-2 4v2h10v-2l-2 -4v-6"}),h("line",{x1:"12",y1:"16",x2:"12",y2:"21"}),h("line",{x1:"8",y1:"4",x2:"16",y2:"4"})]}),W),mi=D(O("g",{children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z",stroke:"currentColor",strokeWidth:"1.25"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"UnlockedIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:6,y:1,width:9,height:9,children:h("path",{stroke:"none",d:"M6.399 9.561V5.175c0-.93.401-1.823 1.116-2.48a3.981 3.981 0 0 1 2.693-1.028c1.01 0 1.98.37 2.694 1.027.715.658 1.116 1.55 1.116 2.481",fill:"#fff"})}),h("g",{mask:"url(#UnlockedIcon)",children:h("path",{stroke:"none",d:"M5.149 9.561v1.25h2.5v-1.25h-2.5Zm5.06-7.894V.417v1.25Zm2.559 3.508v1.25h2.5v-1.25h-2.5ZM7.648 8.51V5.175h-2.5V8.51h2.5Zm0-3.334c0-.564.243-1.128.713-1.561L6.668 1.775c-.959.883-1.52 2.104-1.52 3.4h2.5Zm.713-1.561a2.732 2.732 0 0 1 1.847-.697v-2.5c-1.31 0-2.585.478-3.54 1.358L8.36 3.614Zm1.847-.697c.71 0 1.374.26 1.847.697l1.694-1.839a5.231 5.231 0 0 0-3.54-1.358v2.5Zm1.847.697c.47.433.713.997.713 1.561h2.5c0-1.296-.56-2.517-1.52-3.4l-1.693 1.839Z",fill:"currentColor"})})]}),me),aa=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M13.542 8.542H6.458a2.5 2.5 0 0 0-2.5 2.5v3.75a2.5 2.5 0 0 0 2.5 2.5h7.084a2.5 2.5 0 0 0 2.5-2.5v-3.75a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{d:"M10 13.958a1.042 1.042 0 1 0 0-2.083 1.042 1.042 0 0 0 0 2.083Z"}),h("path",{d:"M6.667 8.333V5.417C6.667 3.806 8.159 2.5 10 2.5c1.841 0 3.333 1.306 3.333 2.917v2.916"})]}),me),$0=D(O(Oe,{children:[h("path",{d:"M38.5 83.5c-14-2-17.833-10.473-21-22.5C14.333 48.984 12 22 12 12.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m12.005 10.478 7.905 14.423L6 25.75l6.005-15.273Z",fill:"currentColor"}),h("path",{d:"M12.005 10.478c1.92 3.495 3.838 7 7.905 14.423m-7.905-14.423c3.11 5.683 6.23 11.368 7.905 14.423m0 0c-3.68.226-7.35.455-13.91.85m13.91-.85c-5.279.33-10.566.647-13.91.85m0 0c1.936-4.931 3.882-9.86 6.005-15.273M6 25.75c2.069-5.257 4.135-10.505 6.005-15.272",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:41,height:94,fill:"none"}),j0=D(O(Oe,{children:[h("path",{d:"M18.026 1.232c-5.268 13.125-5.548 33.555 3.285 42.311 8.823 8.75 33.31 12.304 42.422 13.523",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m72.181 59.247-13.058-10-2.948 13.62 16.006-3.62Z",fill:"currentColor"}),h("path",{d:"M72.181 59.247c-3.163-2.429-6.337-4.856-13.058-10m13.058 10c-5.145-3.936-10.292-7.882-13.058-10m0 0c-.78 3.603-1.563 7.196-2.948 13.62m2.948-13.62c-1.126 5.168-2.24 10.346-2.948 13.62m0 0c5.168-1.166 10.334-2.343 16.006-3.62m-16.006 3.62c5.51-1.248 11.01-2.495 16.006-3.62",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:85,height:71,fill:"none"}),q0=D(O(Oe,{children:[h("path",{d:"M1 77c14-2 31.833-11.973 35-24 3.167-12.016-6-35-9.5-43.5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"}),h("path",{fillRule:"evenodd",clipRule:"evenodd",d:"m24.165 1.093-2.132 16.309 13.27-4.258-11.138-12.05Z",fill:"currentColor"}),h("path",{d:"M24.165 1.093c-.522 3.953-1.037 7.916-2.132 16.309m2.131-16.309c-.835 6.424-1.68 12.854-2.13 16.308m0 0c3.51-1.125 7.013-2.243 13.27-4.257m-13.27 4.257c5.038-1.608 10.08-3.232 13.27-4.257m0 0c-3.595-3.892-7.197-7.777-11.14-12.05m11.14 12.05c-3.837-4.148-7.667-8.287-11.14-12.05",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})]}),{width:38,height:78,fill:"none"}),E_=D(h("g",{fill:"currentColor",children:h("path",{d:"M39.9 32.889a.326.326 0 0 0-.279-.056c-2.094-3.083-4.774-6-7.343-8.833l-.419-.472a.212.212 0 0 0-.056-.139.586.586 0 0 0-.167-.111l-.084-.083-.056-.056c-.084-.167-.28-.278-.475-.167-.782.39-1.507.973-2.206 1.528-.92.722-1.842 1.445-2.708 2.25a8.405 8.405 0 0 0-.977 1.028c-.14.194-.028.361.14.444-.615.611-1.23 1.223-1.843 1.861a.315.315 0 0 0-.084.223c0 .083.056.166.111.194l1.09.833v.028c1.535 1.528 4.244 3.611 7.12 5.861.418.334.865.667 1.284 1 .195.223.39.473.558.695.084.11.28.139.391.055.056.056.14.111.196.167a.398.398 0 0 0 .167.056.255.255 0 0 0 .224-.111.394.394 0 0 0 .055-.167c.029 0 .028.028.056.028a.318.318 0 0 0 .224-.084l5.082-5.528a.309.309 0 0 0 0-.444Zm-14.63-1.917a.485.485 0 0 0 .111.14c.586.5 1.2 1 1.843 1.555l-2.569-1.945-.251-.166c-.056-.028-.112-.084-.168-.111l-.195-.167.056-.056.055-.055.112-.111c.866-.861 2.346-2.306 3.1-3.028-.81.805-2.43 3.167-2.095 3.944Zm8.767 6.89-2.122-1.612a44.713 44.713 0 0 0-2.625-2.5c1.145.861 2.122 1.611 2.262 1.75 1.117.972 1.06.806 1.815 1.445l.921.666a1.06 1.06 0 0 1-.251.25Zm.558.416-.056-.028c.084-.055.168-.111.252-.194l-.196.222ZM1.089 5.75c.055.361.14.722.195 1.056.335 1.833.67 3.5 1.284 4.75l.252.944c.084.361.223.806.363.917 1.424 1.25 3.602 3.11 5.947 4.889a.295.295 0 0 0 .363 0s0 .027.028.027a.254.254 0 0 0 .196.084.318.318 0 0 0 .223-.084c2.988-3.305 5.221-6.027 6.813-8.305.112-.111.14-.278.14-.417.111-.111.195-.25.307-.333.111-.111.111-.306 0-.39l-.028-.027c0-.055-.028-.139-.084-.167-.698-.666-1.2-1.138-1.731-1.638-.922-.862-1.871-1.75-3.881-3.75l-.028-.028c-.028-.028-.056-.056-.112-.056-.558-.194-1.703-.389-3.127-.639C6.087 2.223 3.21 1.723.614.944c0 0-.168 0-.196.028l-.083.084c-.028.027-.056.055-.224.11h.056-.056c.028.167.028.278.084.473 0 .055.112.5.112.555l.782 3.556Zm15.496 3.278-.335-.334c.084.112.196.195.335.334Zm-3.546 4.666-.056.056c0-.028.028-.056.056-.056Zm-2.038-10c.168.167.866.834 1.033.973-.726-.334-2.54-1.167-3.379-1.445.838.167 1.983.334 2.346.472ZM1.424 2.306c.419.722.754 3.222 1.089 5.666-.196-.778-.335-1.555-.503-2.278-.251-1.277-.503-2.416-.838-3.416.056 0 .14 0 .252.028Zm-.168-.584c-.112 0-.223-.028-.307-.028 0-.027 0-.055-.028-.055.14 0 .223.028.335.083Zm-1.089.222c0-.027 0-.027 0 0ZM39.453 1.333c.028-.11-.558-.61-.363-.639.42-.027.42-.666 0-.666-.558.028-1.144.166-1.675.25-.977.194-1.982.389-2.96.61-2.205.473-4.383.973-6.561 1.557-.67.194-1.424.333-2.066.666-.224.111-.196.333-.084.472-.056.028-.084.028-.14.056-.195.028-.363.056-.558.083-.168.028-.252.167-.224.334 0 .027.028.083.028.11-1.173 1.556-2.485 3.195-3.909 4.945-1.396 1.611-2.876 3.306-4.356 5.056-4.719 5.5-10.052 11.75-15.943 17.25a.268.268 0 0 0 0 .389c.028.027.056.055.084.055-.084.084-.168.14-.252.222-.056.056-.084.111-.084.167a.605.605 0 0 0-.111.139c-.112.111-.112.305.028.389.111.11.307.11.39-.028.029-.028.029-.056.056-.056a.44.44 0 0 1 .615 0c.335.362.67.723.977 1.028l-.698-.583c-.112-.111-.307-.083-.39.028-.113.11-.085.305.027.389l7.427 6.194c.056.056.112.056.196.056s.14-.028.195-.084l.168-.166c.028.027.083.027.111.027.084 0 .14-.027.196-.083 10.052-10.055 18.15-17.639 27.42-24.417.083-.055.111-.166.111-.25.112 0 .196-.083.251-.194 1.704-5.194 2.039-9.806 2.15-12.083v-.028c0-.028.028-.056.028-.083.028-.056.028-.084.028-.084a1.626 1.626 0 0 0-.111-1.028ZM21.472 9.5c.446-.5.893-1.028 1.34-1.5-2.876 3.778-7.65 9.583-14.408 16.5 4.607-5.083 9.242-10.333 13.068-15ZM5.193 35.778h.084-.084Zm3.462 3.194c-.027-.028-.027-.028 0-.028v.028Zm4.16-3.583c.224-.25.448-.472.699-.722 0 0 0 .027.028.027-.252.223-.475.445-.726.695Zm1.146-1.111c.14-.14.279-.334.446-.5l.028-.028c1.648-1.694 3.351-3.389 5.082-5.111l.028-.028c.419-.333.921-.694 1.368-1.028a379.003 379.003 0 0 0-6.952 6.695ZM24.794 6.472c-.921 1.195-1.954 2.778-2.82 4.028-2.736 3.944-11.532 13.583-11.727 13.75a1976.983 1976.983 0 0 1-8.042 7.639l-.167.167c-.14-.167-.14-.417.028-.556C14.49 19.861 22.03 10.167 25.074 5.917c-.084.194-.14.36-.28.555Zm4.83 5.695c-1.116-.64-1.646-1.64-1.34-2.611l.084-.334c.028-.083.084-.194.14-.277.307-.5.754-.917 1.257-1.167.027 0 .055 0 .083-.028-.028-.056-.028-.139-.028-.222.028-.167.14-.278.335-.278.335 0 1.369.306 1.76.639.111.083.223.194.335.305.14.167.363.445.474.667.056.028.112.306.196.445.056.222.111.472.084.694-.028.028 0 .194-.028.194a2.668 2.668 0 0 1-.363 1.028c-.028.028-.028.056-.056.084l-.028.027c-.14.223-.335.417-.53.556-.643.444-1.369.583-2.095.389 0 0-.195-.084-.28-.111Zm8.154-.834a39.098 39.098 0 0 1-.893 3.167c0 .028-.028.083 0 .111-.056 0-.084.028-.14.056-2.206 1.61-4.356 3.305-6.506 5.028 1.843-1.64 3.686-3.306 5.613-4.945.558-.5.949-1.139 1.06-1.861l.28-1.667v-.055c.14-.334.67-.195.586.166Z",fill:"currentColor"})}),{width:40,height:40,fill:"none"}),J0=D(O("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 6l4.153 11.793a0.365 .365 0 0 0 .331 .207a0.366 .366 0 0 0 .332 -.207l2.184 -4.793l4.787 -1.994a0.355 .355 0 0 0 .213 -.323a0.355 .355 0 0 0 -.213 -.323l-11.787 -4.36z"}),h("path",{d:"M13.5 13.5l4.5 4.5"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),_l=D(O("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,children:[h("path",{d:"M4.028 13.252c-.657 -.972 -1.028 -2.078 -1.028 -3.252c0 -3.866 4.03 -7 9 -7s9 3.134 9 7s-4.03 7 -9 7c-1.913 0 -3.686 -.464 -5.144 -1.255"}),h("path",{d:"M5 15m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 17c0 1.42 .316 2.805 1 4"})]}),{fill:"none",width:22,height:22,strokeWidth:1.25}),Q0=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})]}),W),ex=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.5 20.4l-6.9 -6.9c-.781 -.781 -.781 -2.219 0 -3l6.9 -6.9c.781 -.781 2.219 -.781 3 0l6.9 6.9c.781 .781 .781 2.219 0 3l-6.9 6.9c-.781 .781 -2.219 .781 -3 0z"})]}),W),tx=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"})]}),W),ox=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"5",y1:"12",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"16",x2:"19",y2:"12"}),h("line",{x1:"15",y1:"8",x2:"19",y2:"12"})]}),W),rx=D(h("path",{d:"M4.167 10h11.666",strokeWidth:"1.5"}),me),nx=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20 17v-12c0 -1.121 -.879 -2 -2 -2s-2 .879 -2 2v12l2 2l2 -2z"}),h("path",{d:"M16 7h4"}),h("path",{d:"M18 19h-13a2 2 0 1 1 0 -4h4a2 2 0 1 0 0 -4h-3"})]}),W),gn=D(O("g",{strokeWidth:"1.25",children:[h("path",{clipRule:"evenodd",d:"m7.643 15.69 7.774-7.773a2.357 2.357 0 1 0-3.334-3.334L4.31 12.357a3.333 3.333 0 0 0-.977 2.357v1.953h1.953c.884 0 1.732-.352 2.357-.977Z"}),h("path",{d:"m11.25 5.417 3.333 3.333"})]}),me),Xc=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"7",y2:"20"}),h("line",{x1:"14",y1:"20",x2:"21",y2:"20"}),h("line",{x1:"6.9",y1:"15",x2:"13.8",y2:"15"}),h("line",{x1:"10.2",y1:"6.3",x2:"16",y2:"20"}),h("polyline",{points:"5 20 11 4 13 4 20 20"})]}),W),ix=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M12.5 6.667h.01"}),h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z"}),h("path",{d:"m3.333 12.5 3.334-3.333c.773-.745 1.726-.745 2.5 0l4.166 4.166"}),h("path",{d:"m11.667 11.667.833-.834c.774-.744 1.726-.744 2.5 0l1.667 1.667"})]}),me),ax=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M19 20h-10.5l-4.21 -4.3a1 1 0 0 1 0 -1.41l10 -10a1 1 0 0 1 1.41 0l5 5a1 1 0 0 1 0 1.41l-9.2 9.3"}),h("path",{d:"M18 13.3l-6.3 -6.3"})]}),W),Eu=D(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),me),yu=D(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),me),lx=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 21l-6 -6"}),h("path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403"}),h("path",{d:"M3 4v4h4"})]}),W),ho=D(h("path",{strokeWidth:"1.25",d:"M3.333 5.833h13.334M8.333 9.167v5M11.667 9.167v5M4.167 5.833l.833 10c0 .92.746 1.667 1.667 1.667h6.666c.92 0 1.667-.746 1.667-1.667l.833-10M7.5 5.833v-2.5c0-.46.373-.833.833-.833h3.334c.46 0 .833.373.833.833v2.5"}),me),vu=D(O("g",{strokeWidth:"1.5",children:[h("polyline",{points:"12 16 18 10 12 4"}),h("polyline",{points:"8 4 2 10 8 16"})]}),me),Dl=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M14.375 6.458H8.958a2.5 2.5 0 0 0-2.5 2.5v5.417a2.5 2.5 0 0 0 2.5 2.5h5.417a2.5 2.5 0 0 0 2.5-2.5V8.958a2.5 2.5 0 0 0-2.5-2.5Z"}),h("path",{clipRule:"evenodd",d:"M11.667 3.125c.517 0 .986.21 1.325.55.34.338.55.807.55 1.325v1.458H8.333c-.485 0-.927.185-1.26.487-.343.312-.57.75-.609 1.24l-.005 5.357H5a1.87 1.87 0 0 1-1.326-.55 1.87 1.87 0 0 1-.549-1.325V5c0-.518.21-.987.55-1.326.338-.34.807-.549 1.325-.549h6.667Z"})]}),me),Pl=D(h("path",{clipRule:"evenodd",d:"M10 2.5h.328a6.25 6.25 0 0 0 6.6 10.372A7.5 7.5 0 1 1 10 2.493V2.5Z",stroke:"currentColor"}),me),Rl=D(h("g",{stroke:"currentColor",strokeLinejoin:"round",children:h("path",{d:"M10 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM10 4.167V2.5M14.167 5.833l1.166-1.166M15.833 10H17.5M14.167 14.167l1.166 1.166M10 15.833V17.5M5.833 14.167l-1.166 1.166M5 10H3.333M5.833 5.833 4.667 4.667"})}),{...me,strokeWidth:1.5}),$c=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),h("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),W),pi=D(h("path",{strokeWidth:"1.25",d:"M3.333 14.167v1.666c0 .92.747 1.667 1.667 1.667h10c.92 0 1.667-.746 1.667-1.667v-1.666M5.833 9.167 10 13.333l4.167-4.166M10 3.333v10"}),me),la=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),W),sx=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"12",cy:"12",r:"9"}),h("line",{x1:"12",y1:"17",x2:"12",y2:"17.01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),W),wu=D(h("path",{strokeWidth:"1.25",d:"M9.167 5.833H5.833c-1.254 0-2.5 1.282-2.5 2.5v5.834c0 1.283 1.252 2.5 2.5 2.5h5.834c1.251 0 2.5-1.25 2.5-2.5v-3.334M8.333 11.667l8.334-8.334M12.5 3.333h4.167V7.5"}),me),jc=D(h("path",{d:"M7.5 15.833c-3.583 1.167-3.583-2.083-5-2.5m10 4.167v-2.917c0-.833.083-1.166-.417-1.666 2.334-.25 4.584-1.167 4.584-5a3.833 3.833 0 0 0-1.084-2.667 3.5 3.5 0 0 0-.083-2.667s-.917-.25-2.917 1.084a10.25 10.25 0 0 0-5.166 0C5.417 2.333 4.5 2.583 4.5 2.583a3.5 3.5 0 0 0-.083 2.667 3.833 3.833 0 0 0-1.084 2.667c0 3.833 2.25 4.75 4.584 5-.5.5-.5 1-.417 1.666V17.5",strokeWidth:"1.25"}),me),cx=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M7.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM12.5 10.833a.833.833 0 1 0 0-1.666.833.833 0 0 0 0 1.666ZM6.25 6.25c2.917-.833 4.583-.833 7.5 0M5.833 13.75c2.917.833 5.417.833 8.334 0"}),h("path",{d:"M12.917 14.167c0 .833 1.25 2.5 1.666 2.5 1.25 0 2.361-1.39 2.917-2.5.556-1.39.417-4.861-1.25-9.584-1.214-.846-2.5-1.116-3.75-1.25l-.833 2.084M7.083 14.167c0 .833-1.13 2.5-1.526 2.5-1.191 0-2.249-1.39-2.778-2.5-.529-1.39-.397-4.861 1.19-9.584 1.157-.846 2.318-1.116 3.531-1.25l.833 2.084"})]}),me),dx=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 4l11.733 16h4.267l-11.733 -16z"}),h("path",{d:"M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"})]}),W),mx=D(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),Nl=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M8.333 11.667a2.917 2.917 0 0 0 4.167 0l3.333-3.334a2.946 2.946 0 1 0-4.166-4.166l-.417.416"}),h("path",{d:"M11.667 8.333a2.917 2.917 0 0 0-4.167 0l-3.333 3.334a2.946 2.946 0 0 0 4.166 4.166l.417-.416"})]}),me),px=D("M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z",{width:448,height:512}),ux=D("M252 54L203 8a28 27 0 00-20-8H28C12 0 0 12 0 27v195c0 15 12 26 28 26h204c15 0 28-11 28-26V73a28 27 0 00-8-19zM130 213c-21 0-37-16-37-36 0-19 16-35 37-35 20 0 37 16 37 35 0 20-17 36-37 36zm56-169v56c0 4-4 6-7 6H44c-4 0-7-2-7-6V42c0-4 3-7 7-7h133l4 2 3 2a7 7 0 012 5z M296 201l87 95-188 205-78 9c-10 1-19-8-18-20l9-84zm141-14l-41-44a31 31 0 00-46 0l-38 41 87 95 38-42c13-14 13-36 0-50z",{width:448,height:512}),sa=D(h("path",{d:"m9.257 6.351.183.183H15.819c.34 0 .727.182 1.051.506.323.323.505.708.505 1.05v5.819c0 .316-.183.7-.52 1.035-.337.338-.723.522-1.037.522H4.182c-.352 0-.74-.181-1.058-.5-.318-.318-.499-.705-.499-1.057V5.182c0-.351.181-.736.5-1.054.32-.321.71-.503 1.057-.503H6.53l2.726 2.726Z",strokeWidth:"1.25"}),me),y_=D("M384 112v352c0 26.51-21.49 48-48 48H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h80c0-35.29 28.71-64 64-64s64 28.71 64 64h80c26.51 0 48 21.49 48 48zM192 40c-13.255 0-24 10.745-24 24s10.745 24 24 24 24-10.745 24-24-10.745-24-24-24m96 114v-20a6 6 0 0 0-6-6H102a6 6 0 0 0-6 6v20a6 6 0 0 0 6 6h180a6 6 0 0 0 6-6z",{width:384,height:512}),hx=D("M204.3 5C104.9 24.4 24.8 104.3 5.2 203.4c-37 187 131.7 326.4 258.8 306.7 41.2-6.4 61.4-54.6 42.5-91.7-23.1-45.4 9.9-98.4 60.9-98.4h79.7c35.8 0 64.8-29.6 64.9-65.3C511.5 97.1 368.1-26.9 204.3 5zM96 320c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm32-128c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128-64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32zm128 64c-17.7 0-32-14.3-32-32s14.3-32 32-32 32 14.3 32 32-14.3 32-32 32z"),qc=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 16l1.465 1.638a2 2 0 1 1 -3.015 .099l1.55 -1.737z"}),h("path",{d:"M13.737 9.737c2.299 -2.3 3.23 -5.095 2.081 -6.245c-1.15 -1.15 -3.945 -.217 -6.244 2.082c-2.3 2.299 -3.231 5.095 -2.082 6.244c1.15 1.15 3.946 .218 6.245 -2.081z"}),h("path",{d:"M7.492 11.818c.362 .362 .768 .676 1.208 .934l6.895 4.047c1.078 .557 2.255 -.075 3.692 -1.512c1.437 -1.437 2.07 -2.614 1.512 -3.692c-.372 -.718 -1.72 -3.017 -4.047 -6.895a6.015 6.015 0 0 0 -.934 -1.208"})]}),W),Jc=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8h.01"}),h("path",{d:"M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"}),h("path",{d:"M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"}),h("path",{d:"M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"}),h("path",{d:"M19 16v6"}),h("path",{d:"M22 19l-3 3l-3 -3"})]}),W),gx=D("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),v_=D("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),w_=D("M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),fx=D("M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"),T_=D("M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"),Tu=D(h("path",{d:"M7.5 10.833 4.167 7.5 7.5 4.167M4.167 7.5h9.166a3.333 3.333 0 0 1 0 6.667H12.5",strokeWidth:"1.25"}),me),Cu=D(h("path",{d:"M12.5 10.833 15.833 7.5 12.5 4.167M15.833 7.5H6.667a3.333 3.333 0 1 0 0 6.667H7.5",strokeWidth:"1.25"}),me),bx=D("M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zM262.655 90c-54.497 0-89.255 22.957-116.549 63.758-3.536 5.286-2.353 12.415 2.715 16.258l34.699 26.31c5.205 3.947 12.621 3.008 16.665-2.122 17.864-22.658 30.113-35.797 57.303-35.797 20.429 0 45.698 13.148 45.698 32.958 0 14.976-12.363 22.667-32.534 33.976C247.128 238.528 216 254.941 216 296v4c0 6.627 5.373 12 12 12h56c6.627 0 12-5.373 12-12v-1.333c0-28.462 83.186-29.647 83.186-106.667 0-58.002-60.165-102-116.531-102zM256 338c-25.365 0-46 20.635-46 46 0 25.364 20.635 46 46 46s46-20.636 46-46c0-25.365-20.635-46-46-46z",{mirror:!0}),xx=D(h("path",{d:"M5 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 7.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM15 17.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM7.25 8.917l5.5-2.834M7.25 11.083l5.5 2.834",strokeWidth:"1.5"}),me),C_=D("M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"),I_=D("M16 5l-1.42 1.42-1.59-1.59V16h-1.98V4.83L9.42 6.42 8 5l4-4 4 4zm4 5v11c0 1.1-.9 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.11.89-2 2-2h3v2H6v11h12V10h-3V8h3c1.1 0 2 .89 2 2z",{width:24,height:24}),S_=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 9h-1a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-8a2 2 0 0 0 -2 -2h-1"}),h("path",{d:"M12 14v-11"}),h("path",{d:"M9 6l3 -3l3 3"})]}),W),k_=D(O(Oe,{children:[h("path",{fill:"currentColor",d:"M40 5.6v6.1l-4.1.7c-8.9 1.4-16.5 6.9-20.6 15C13 32 10.9 43 12.4 43c.4 0 2.4-1.3 4.4-3 5-3.9 12.1-7 18.2-7.7l5-.6v12.8l11.2-11.3L62.5 22 51.2 10.8 40-.5v6.1zm10.2 22.6L44 34.5v-6.8l-6.9.6c-3.9.3-9.8 1.7-13.2 3.1-3.5 1.4-6.5 2.4-6.7 2.2-.9-1 3-7.5 6.4-10.8C28 18.6 34.4 16 40.1 16c3.7 0 3.9-.1 3.9-3.2V9.5l6.2 6.3 6.3 6.2-6.3 6.2z"}),h("path",{stroke:"currentColor",fill:"currentColor",d:"M0 36v20h48v-6.2c0-6 0-6.1-2-4.3-1.1 1-2 2.9-2 4.2V52H4V34c0-17.3-.1-18-2-18s-2 .7-2 20z"})]}),{width:64,height:64}),M_=D(h("path",{stroke:"currentColor",strokeWidth:"40",fill:"currentColor",d:"M148 560a318 318 0 0 0 522 110 316 316 0 0 0 0-450 316 316 0 0 0-450 0c-11 11-21 22-30 34v4h47c25 0 46 21 46 46s-21 45-46 45H90c-13 0-25-6-33-14-9-9-14-20-14-33V156c0-25 20-45 45-45s45 20 45 45v32l1 1a401 401 0 0 1 623 509l212 212a42 42 0 0 1-59 59L698 757A401 401 0 0 1 65 570a42 42 0 0 1 83-10z"}),{width:1024}),Ex=O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 10l0 10"}),h("path",{d:"M12 10l4 4"}),h("path",{d:"M12 10l-4 4"}),h("path",{d:"M4 4l16 0"})]}),yx=O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 5l0 14"}),h("path",{d:"M16 9l-4 -4"}),h("path",{d:"M8 9l4 -4"})]}),Iu=D(yx,W),Su=D(yx,{...W,style:{transform:"rotate(180deg)"}}),ku=D(Ex,W),Mu=D(Ex,{...W,style:{transform:"rotate(180deg)"}}),Lu=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v7.083c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V8.125c0-.92-.746-1.667-1.666-1.667ZM6.875 6.458h-.417c-.92 0-1.666.747-1.666 1.667v3.75c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667v-3.75c0-.92-.747-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Au=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 3.125h-.417c-.92 0-1.666.746-1.666 1.667v7.083c0 .92.746 1.667 1.666 1.667h.417c.92 0 1.667-.746 1.667-1.667V4.792c0-.92-.747-1.667-1.667-1.667ZM13.542 5.817h-.417c-.92 0-1.667.747-1.667 1.667v4.391c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667V7.484c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),_u=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M15.208 4.792H8.125c-.92 0-1.667.746-1.667 1.666v.417c0 .92.747 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM12.516 11.458H8.125c-.92 0-1.667.746-1.667 1.667v.417c0 .92.747 1.666 1.667 1.666h4.391c.92 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Du=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M11.875 4.792H4.792c-.92 0-1.667.746-1.667 1.666v.417c0 .92.746 1.667 1.667 1.667h7.083c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666ZM11.683 11.458H7.292c-.92 0-1.667.746-1.667 1.667v.417c0 .92.746 1.666 1.667 1.666h4.39c.921 0 1.667-.746 1.667-1.666v-.417c0-.92-.746-1.667-1.666-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),vx=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M16.667 3.333v13.334M3.333 3.333v13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M14.375 10.208v-.416c0-.92-.746-1.667-1.667-1.667H7.292c-.92 0-1.667.746-1.667 1.667v.416c0 .92.746 1.667 1.667 1.667h5.416c.92 0 1.667-.746 1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),wx=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M3.333 3.333h13.334M3.333 16.667h13.334",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10.208 5.625h-.416c-.92 0-1.667.746-1.667 1.667v5.416c0 .92.746 1.667 1.667 1.667h.416c.92 0 1.667-.746 1.667-1.667V7.292c0-.92-.746-1.667-1.667-1.667Z"})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Pu=D(O("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M1.667 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M8.333 10h3.334",strokeLinejoin:"round"}),h("path",{d:"M15.417 10h2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M6.875 4.792h-.417c-.92 0-1.666.746-1.666 1.666v7.084c0 .92.746 1.666 1.666 1.666h.417c.92 0 1.667-.746 1.667-1.666V6.458c0-.92-.747-1.666-1.667-1.666ZM13.542 6.458h-.417c-.92 0-1.667.747-1.667 1.667v3.75c0 .92.746 1.667 1.667 1.667h.417c.92 0 1.666-.746 1.666-1.667v-3.75c0-.92-.746-1.667-1.666-1.667Z"})]}),me),Ru=D(O("g",{stroke:"currentColor",strokeWidth:"1.25",children:[h("path",{d:"M10 18.333v-2.916",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M10 11.667V8.333",strokeLinejoin:"round"}),h("path",{d:"M10 4.583V1.667",strokeLinecap:"round",strokeLinejoin:"round"}),h("path",{d:"M4.792 13.125v.417c0 .92.746 1.666 1.666 1.666h7.084c.92 0 1.666-.746 1.666-1.666v-.417c0-.92-.746-1.667-1.666-1.667H6.458c-.92 0-1.666.746-1.666 1.667ZM6.458 6.458v.417c0 .92.747 1.667 1.667 1.667h3.75c.92 0 1.667-.747 1.667-1.667v-.417c0-.92-.746-1.666-1.667-1.666h-3.75c-.92 0-1.667.746-1.667 1.666Z"})]}),me),Qc=D(O("g",{strokeWidth:"1.5",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("circle",{cx:"9",cy:"7",r:"4"}),h("path",{d:"M3 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2"}),h("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"}),h("path",{d:"M21 21v-2a4 4 0 0 0 -3 -3.85"})]}),W),L_=D("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm115.7 272l-176 101c-15.8 8.8-35.7-2.5-35.7-21V152c0-18.4 19.8-29.8 35.7-21l176 107c16.4 9.2 16.4 32.9 0 42z"),A_=D("M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm96 328c0 8.8-7.2 16-16 16H176c-8.8 0-16-7.2-16-16V176c0-8.8 7.2-16 16-16h160c8.8 0 16 7.2 16 16v160z"),Lo=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M15 5 5 15M5 5l10 10"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),__=D("M464 0c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48H176c-26.51 0-48-21.49-48-48V48c0-26.51 21.49-48 48-48h288M176 416c-44.112 0-80-35.888-80-80V128H48c-26.51 0-48 21.49-48 48v288c0 26.51 21.49 48 48 48h288c26.51 0 48-21.49 48-48v-48H176z",{mirror:!0}),D_=D("M11.553 22.894a.998.998 0 00.894 0s3.037-1.516 5.465-4.097C19.616 16.987 21 14.663 21 12V5a1 1 0 00-.649-.936l-8-3a.998.998 0 00-.702 0l-8 3A1 1 0 003 5v7c0 2.663 1.384 4.987 3.088 6.797 2.428 2.581 5.465 4.097 5.465 4.097zm-1.303-8.481l6.644-6.644a.856.856 0 111.212 1.212l-7.25 7.25a.856.856 0 01-1.212 0l-3.75-3.75a.856.856 0 111.212-1.212l3.144 3.144z",{width:24}),P_=D("M369.9 97.9L286 14C277 5 264.8-.1 252.1-.1H48C21.5 0 0 21.5 0 48v416c0 26.5 21.5 48 48 48h288c26.5 0 48-21.5 48-48V131.9c0-12.7-5.1-25-14.1-34zM332.1 128H256V51.9l76.1 76.1zM48 464V48h160v104c0 13.3 10.7 24 24 24h104v288H48zm32-48h224V288l-23.5-23.5c-4.7-4.7-12.3-4.7-17 0L176 352l-39.5-39.5c-4.7-4.7-12.3-4.7-17 0L80 352v64zm48-240c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z",{width:384,height:512}),Nu=kt.memo(({theme:e})=>D(O(Oe,{children:[h("path",{d:"M25 26H111V111H25",fill:$o(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:$o(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:$o(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:$o(e),strokeWidth:"2"}),O("g",{fill:W0(e),stroke:$o(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})),Ou=kt.memo(({theme:e})=>D(O(Oe,{children:[h("path",{d:"M25 26H111V111H25",fill:$o(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:$o(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:$o(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:$o(e),strokeWidth:"2"}),O("g",{fill:W0(e),stroke:$o(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})),Tx=D(h("g",{strokeWidth:1.25,children:h("path",{d:"M5.879 2.625h8.242a3.27 3.27 0 0 1 3.254 3.254v8.242a3.27 3.27 0 0 1-3.254 3.254H5.88a3.27 3.27 0 0 1-3.254-3.254V5.88A3.27 3.27 0 0 1 5.88 2.626l-.001-.001ZM4.518 16.118l7.608-12.83m.198 13.934 5.051-9.897M2.778 9.675l9.348-6.387m-7.608 12.83 12.857-8.793"})}),me),Cx=D(O(Oe,{children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillHachureIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:2,y:2,width:16,height:16,children:h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"1.25"})}),h("g",{mask:"url(#FillHachureIcon)",children:h("path",{d:"M2.258 15.156 15.156 2.258M7.324 20.222 20.222 7.325m-20.444 5.35L12.675-.222m-8.157 18.34L17.416 5.22",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})})]}),me),Ix=D(O(Oe,{children:[O("g",{clipPath:"url(#a)",children:[h("path",{d:"M5.879 2.625h8.242a3.254 3.254 0 0 1 3.254 3.254v8.242a3.254 3.254 0 0 1-3.254 3.254H5.88a3.254 3.254 0 0 1-3.254-3.254V5.88a3.254 3.254 0 0 1 3.254-3.254Z",stroke:"currentColor",strokeWidth:"1.25"}),h("mask",{id:"FillCrossHatchIcon",style:{maskType:"alpha"},maskUnits:"userSpaceOnUse",x:-1,y:-1,width:22,height:22,children:h("path",{d:"M2.426 15.044 15.044 2.426M7.383 20 20 7.383M0 12.617 12.617 0m-7.98 17.941L17.256 5.324m-2.211 12.25L2.426 4.956M20 12.617 7.383 0m5.234 20L0 7.383m17.941 7.98L5.324 2.745",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("g",{mask:"url(#FillCrossHatchIcon)",children:h("path",{d:"M14.121 2H5.88A3.879 3.879 0 0 0 2 5.879v8.242A3.879 3.879 0 0 0 5.879 18h8.242A3.879 3.879 0 0 0 18 14.121V5.88A3.879 3.879 0 0 0 14.121 2Z",fill:"currentColor"})})]}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Sx=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M4.91 2.625h10.18a2.284 2.284 0 0 1 2.285 2.284v10.182a2.284 2.284 0 0 1-2.284 2.284H4.909a2.284 2.284 0 0 1-2.284-2.284V4.909a2.284 2.284 0 0 1 2.284-2.284Z",stroke:"currentColor",strokeWidth:"1.25"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),{...me,fill:"currentColor"}),Bu=D(h(Oe,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),kx=D(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),me),Mx=D(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),me),R_=kt.memo(({theme:e})=>D(h("path",{d:"M6 10H34",stroke:$o(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),Lx=D(O("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12h2"}),h("path",{d:"M17 12h2"}),h("path",{d:"M11 12h2"})]}),W),Ax=D(O("g",{strokeWidth:"2",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M8 12v.01"}),h("path",{d:"M12 12v.01"}),h("path",{d:"M16 12v.01"}),h("path",{d:"M20 12v.01"})]}),W),_x=D(h("path",{d:"M2.5 12.038c1.655-.885 5.9-3.292 8.568-4.354 2.668-1.063.101 2.821 1.32 3.104 1.218.283 5.112-1.814 5.112-1.814",strokeWidth:"1.25"}),me),Dx=D(h("path",{d:"M2.5 12.563c1.655-.886 5.9-3.293 8.568-4.355 2.668-1.062.101 2.822 1.32 3.105 1.218.283 5.112-1.814 5.112-1.814m-13.469 2.23c2.963-1.586 6.13-5.62 7.468-4.998 1.338.623-1.153 4.11-.132 5.595 1.02 1.487 6.133-1.43 6.133-1.43",strokeWidth:"1.25"}),me),Px=D(h("path",{d:"M2.5 11.936c1.737-.879 8.627-5.346 10.42-5.268 1.795.078-.418 5.138.345 5.736.763.598 3.53-1.789 4.235-2.147M2.929 9.788c1.164-.519 5.47-3.28 6.987-3.114 1.519.165 1 3.827 2.121 4.109 1.122.281 3.839-2.016 4.606-2.42",strokeWidth:"1.25"}),me),Rx=D(O("svg",{strokeWidth:"1.5",children:[h("path",{d:"M3.33334 9.99998V6.66665C3.33334 6.04326 3.33403 4.9332 3.33539 3.33646C4.95233 3.33436 6.06276 3.33331 6.66668 3.33331H10"}),h("path",{d:"M13.3333 3.33331V3.34331"}),h("path",{d:"M16.6667 3.33331V3.34331"}),h("path",{d:"M16.6667 6.66669V6.67669"}),h("path",{d:"M16.6667 10V10.01"}),h("path",{d:"M3.33334 13.3333V13.3433"}),h("path",{d:"M16.6667 13.3333V13.3433"}),h("path",{d:"M3.33334 16.6667V16.6767"}),h("path",{d:"M6.66666 16.6667V16.6767"}),h("path",{d:"M10 16.6667V16.6767"}),h("path",{d:"M13.3333 16.6667V16.6767"}),h("path",{d:"M16.6667 16.6667V16.6767"})]}),me),Nx=D(O("g",{strokeWidth:"1.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 12v-4a4 4 0 0 1 4 -4h4"}),h("line",{x1:"16",y1:"4",x2:"16",y2:"4.01"}),h("line",{x1:"20",y1:"4",x2:"20",y2:"4.01"}),h("line",{x1:"20",y1:"8",x2:"20",y2:"8.01"}),h("line",{x1:"20",y1:"12",x2:"20",y2:"12.01"}),h("line",{x1:"4",y1:"16",x2:"4",y2:"16.01"}),h("line",{x1:"20",y1:"16",x2:"20",y2:"16.01"}),h("line",{x1:"4",y1:"20",x2:"4",y2:"20.01"}),h("line",{x1:"8",y1:"20",x2:"8",y2:"20.01"}),h("line",{x1:"12",y1:"20",x2:"12",y2:"20.01"}),h("line",{x1:"16",y1:"20",x2:"16",y2:"20.01"}),h("line",{x1:"20",y1:"20",x2:"20",y2:"20.01"})]}),W),Ox=D(O("g",{stroke:"currentColor",opacity:.3,strokeWidth:2,children:[h("path",{d:"M12 12l9 0"}),h("path",{d:"M3 9l6 6"}),h("path",{d:"M3 15l6 -6"})]}),W),Bx=kt.memo(({flip:e=!1})=>D(O("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",stroke:"currentColor",strokeWidth:2,fill:"none",children:[h("path",{d:"M34 10H6M34 10L27 5M34 10L27 15"}),h("path",{d:"M27.5 5L34.5 10L27.5 15"})]}),{width:40,height:20})),zx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Fx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,children:[h("path",{d:"M26 10L6 10"}),h("circle",{r:"4",transform:"matrix(-1 0 0 1 30 10)"})]}),{width:40,height:20})),Hx=kt.memo(({flip:e=!1})=>D(h("g",{transform:e?"translate(40, 0) scale(-1, 1)":"",children:h("path",{d:"M34 10H5.99996M34 10L34 5M34 10L34 15",stroke:"currentColor",strokeWidth:2,fill:"none"})}),{width:40,height:20})),Ux=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",children:[h("path",{d:"M32 10L6 10",strokeWidth:2}),h("path",{d:"M27.5 5.5L34.5 10L27.5 14.5L27.5 5.5"})]}),{width:40,height:20})),Gx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeWidth:2,strokeLinejoin:"round",children:[h("path",{d:"M6,9.5H27"}),h("path",{d:"M27,5L34,10L27,14Z",fill:"none"})]}),{width:40,height:20})),Vx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"currentColor",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Yx=kt.memo(({flip:e=!1})=>D(O("g",{stroke:"currentColor",fill:"none",transform:e?"translate(40, 0) scale(-1, 1)":"",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{d:"M6,9.5H20"}),h("path",{d:"M27,5L34,10L27,14L20,9.5Z"})]}),{width:40,height:20})),Wx=kt.memo(({flip:e=!1})=>D(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Kx=kt.memo(({flip:e=!1})=>D(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,15 L15,5"})}),{width:40,height:20})),Zx=kt.memo(({flip:e=!1})=>D(h("g",{stroke:"currentColor",fill:"none",transform:e?"":"translate(40, 0) scale(-1, 1)",strokeLinejoin:"round",strokeWidth:2,children:h("path",{d:"M34,10 H6 M15,10 L15,16 L15,4 M15,10 L7,5 M15,10 L7,15"})}),{width:40,height:20})),Xx=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M14.167 6.667a3.333 3.333 0 0 0-3.334-3.334H9.167a3.333 3.333 0 0 0 0 6.667h1.666a3.333 3.333 0 0 1 0 6.667H9.167a3.333 3.333 0 0 1-3.334-3.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),$x=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5 16.667V3.333L10 15l5-11.667v13.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),jx=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",children:h("path",{d:"M5.833 3.333v13.334h8.334",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),qx=D(h(Oe,{children:h("path",{d:"m1.667 3.333 6.666 13.334M8.333 3.333 1.667 16.667M11.667 3.333v13.334h6.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),me),ui=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 7v-2h13v2"}),h("path",{d:"M10 5v14"}),h("path",{d:"M12 19h-4"}),h("path",{d:"M15 13v-1h6v1"}),h("path",{d:"M18 12v7"}),h("path",{d:"M17 19h2"})]}),W),Jx=D(h(Oe,{children:O("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 12h10"}),h("path",{d:"M7 5v14"}),h("path",{d:"M17 5v14"}),h("path",{d:"M15 19h4"}),h("path",{d:"M15 5h4"}),h("path",{d:"M5 19h4"}),h("path",{d:"M5 5h4"})]})}),W),Ol=D(h(Oe,{children:h("g",{stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 16.667v-10a3.333 3.333 0 0 1 3.334-3.334h1.666a3.333 3.333 0 0 1 3.334 3.334v10M5.833 10.833h8.334"})})}),me),ed=D(O(Oe,{children:[h("g",{clipPath:"url(#a)",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",children:h("path",{d:"M5.833 6.667 2.5 10l3.333 3.333M14.167 6.667 17.5 10l-3.333 3.333M11.667 3.333 8.333 16.667"})}),h("defs",{children:h("clipPath",{id:"a",children:h("path",{fill:"#fff",d:"M0 0h20v20H0z"})})})]}),me),Qx=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"4",y1:"12",x2:"12",y2:"12"}),h("line",{x1:"4",y1:"16",x2:"16",y2:"16"})]}),W),eE=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"8",y1:"12",x2:"16",y2:"12"}),h("line",{x1:"6",y1:"16",x2:"18",y2:"16"})]}),W),tE=D(O("g",{stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"8",x2:"20",y2:"8"}),h("line",{x1:"10",y1:"12",x2:"20",y2:"12"}),h("line",{x1:"8",y1:"16",x2:"20",y2:"16"})]}),W),oE=kt.memo(({theme:e})=>D(O("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"4",x2:"20",y2:"4"}),h("rect",{x:"9",y:"8",width:"6",height:"12",rx:"2"})]}),W)),rE=kt.memo(({theme:e})=>D(O("g",{strokeWidth:"2",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"20",x2:"20",y2:"20"}),h("rect",{x:"9",y:"4",width:"6",height:"12",rx:"2"})]}),W)),nE=kt.memo(({theme:e})=>D(O("g",{strokeWidth:"1.5",stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("line",{x1:"4",y1:"12",x2:"9",y2:"12"}),h("line",{x1:"15",y1:"12",x2:"20",y2:"12"}),h("rect",{x:"9",y:"6",width:"6",height:"12",rx:"2"})]}),W)),td=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M21 19h-18l9 -15"}),h("path",{d:"M20.615 15.171h.015"}),h("path",{d:"M19.515 11.771h.015"}),h("path",{d:"M17.715 8.671h.015"}),h("path",{d:"M15.415 5.971h.015"})]}),W),iE=D(h("path",{d:"M537.6 226.6c4.1-10.7 6.4-22.4 6.4-34.6 0-53-43-96-96-96-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32c-88.4 0-160 71.6-160 160 0 2.7.1 5.4.2 8.1C40.2 219.8 0 273.2 0 336c0 79.5 64.5 144 144 144h368c70.7 0 128-57.3 128-128 0-61.9-44-113.6-102.4-125.4zM393.4 288H328v112c0 8.8-7.2 16-16 16h-48c-8.8 0-16-7.2-16-16V288h-65.4c-14.3 0-21.4-17.2-11.3-27.3l105.4-105.4c6.2-6.2 16.4-6.2 22.6 0l105.4 105.4c10.1 10.1 2.9 27.3-11.3 27.3z",fill:"currentColor"}),{width:640,height:512}),N_=D(h("path",{d:"M480 416C497.7 416 512 430.3 512 448C512 465.7 497.7 480 480 480H150.6C133.7 480 117.4 473.3 105.4 461.3L25.37 381.3C.3786 356.3 .3786 315.7 25.37 290.7L258.7 57.37C283.7 32.38 324.3 32.38 349.3 57.37L486.6 194.7C511.6 219.7 511.6 260.3 486.6 285.3L355.9 416H480zM265.4 416L332.7 348.7L195.3 211.3L70.63 336L150.6 416L265.4 416z"})),od=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 13v-7.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M11 5.5v-2a1.5 1.5 0 1 1 3 0v8.5"}),h("path",{d:"M14 5.5a1.5 1.5 0 0 1 3 0v6.5"}),h("path",{d:"M17 7.5a1.5 1.5 0 0 1 3 0v8.5a6 6 0 0 1 -6 6h-2h.208a6 6 0 0 1 -5.012 -2.7a69.74 69.74 0 0 1 -.196 -.3c-.312 -.479 -1.407 -2.388 -3.286 -5.728a1.5 1.5 0 0 1 .536 -2.022a1.867 1.867 0 0 1 2.28 .28l1.47 1.47"})]}),W),zu=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M7 11l5 5l5 -5"}),h("path",{d:"M12 4l0 12"})]}),W),ca=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"}),h("path",{d:"M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"})]}),W),aE=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M9.15 14.85l8.85 -10.85"}),h("path",{d:"M6 4l8.85 10.85"})]}),W),lE=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0"}),h("path",{d:"M12 17l0 .01"}),h("path",{d:"M12 13.5a1.5 1.5 0 0 1 1 -1.5a2.6 2.6 0 1 0 -3 -4"})]}),W),O_=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),W),B_=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 4h-10a3 3 0 0 0 -3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3 -3v-10a3 3 0 0 0 -3 -3z",strokeWidth:"0",fill:"currentColor"})]}),W),sE=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),W),cE=D(O(Oe,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.24 3.957l-8.422 14.06a1.989 1.989 0 0 0 1.7 2.983h16.845a1.989 1.989 0 0 0 1.7 -2.983l-8.423 -14.06a1.989 1.989 0 0 0 -3.4 0z"}),h("path",{d:"M12 9v4"}),h("path",{d:"M12 17h.01"})]}),W),dE=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11 7l6 6"}),h("path",{d:"M4 16l11.7 -11.7a1 1 0 0 1 1.4 0l2.6 2.6a1 1 0 0 1 0 1.4l-11.7 11.7h-4v-4z"})]}),W),mE=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l-4 7h8z"}),h("path",{d:"M17 17m-3 0a3 3 0 1 0 6 0a3 3 0 1 0 -6 0"}),h("path",{d:"M4 14m0 1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z"})]}),W),Bl=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 7l16 0"}),h("path",{d:"M4 17l16 0"}),h("path",{d:"M7 4l0 16"}),h("path",{d:"M17 4l0 16"})]}),W),rd=D(h("path",{fill:"currentColor",d:"M407.48,111.18C335.587,108.103 269.573,152.338 245.08,220C220.587,152.338 154.573,108.103 82.68,111.18C80.285,168.229 107.577,222.632 154.74,254.82C178.908,271.419 193.35,298.951 193.27,328.27L193.27,379.13L296.9,379.13L296.9,328.27C296.816,298.953 311.255,271.42 335.42,254.82C382.596,222.644 409.892,168.233 407.48,111.18Z"})),da=D(O("g",{strokeWidth:"1.25",children:[h("path",{d:"M4.16602 10H15.8327"}),h("path",{d:"M12.5 13.3333L15.8333 10"}),h("path",{d:"M12.5 6.66666L15.8333 9.99999"})]}),me),zl=D(O("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round",transform:"rotate(90 10 10)",children:[h("path",{clipRule:"evenodd",d:"m9.644 13.69 7.774-7.773a2.357 2.357 0 0 0-3.334-3.334l-7.773 7.774L8 12l1.643 1.69Z"}),h("path",{d:"m13.25 3.417 3.333 3.333M10 10l2-2M5 15l3-3M2.156 17.894l1-1M5.453 19.029l-.144-1.407M2.377 11.887l.866 1.118M8.354 17.273l-1.194-.758M.953 14.652l1.408.13"})]}),20),nd=D(O("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),W),z_=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z"}),h("path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3"}),h("path",{d:"M15 6l3 3"}),h("path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"}),h("path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2"})]}),W),F_=D(O("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M11.217 19.384a3.501 3.501 0 0 0 6.783 -1.217v-5.167l-6 -3.35"}),h("path",{d:"M5.214 15.014a3.501 3.501 0 0 0 4.446 5.266l4.34 -2.534v-6.946"}),h("path",{d:"M6 7.63c-1.391 -.236 -2.787 .395 -3.534 1.689a3.474 3.474 0 0 0 1.271 4.745l4.263 2.514l6 -3.348"}),h("path",{d:"M12.783 4.616a3.501 3.501 0 0 0 -6.783 1.217v5.067l6 3.45"}),h("path",{d:"M18.786 8.986a3.501 3.501 0 0 0 -4.446 -5.266l-4.34 2.534v6.946"}),h("path",{d:"M18 16.302c1.391 .236 2.787 -.395 3.534 -1.689a3.474 3.474 0 0 0 -1.271 -4.745l-4.308 -2.514l-5.955 3.42"})]}),W),pE=D(O("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 8v-2a2 2 0 0 1 2 -2h2"}),h("path",{d:"M4 16v2a2 2 0 0 0 2 2h2"}),h("path",{d:"M16 4h2a2 2 0 0 1 2 2v2"}),h("path",{d:"M16 20h2a2 2 0 0 0 2 -2v-2"})]}),W),ma=D(O("g",{stroke:"currentColor",fill:"none",strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0"}),h("path",{d:"M21 12c-2.4 4 -5.4 6 -9 6c-3.6 0 -6.6 -2 -9 -6c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6"})]}),W),uE=D(O("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10.585 10.587a2 2 0 0 0 2.829 2.828"}),h("path",{d:"M16.681 16.673a8.717 8.717 0 0 1 -4.681 1.327c-3.6 0 -6.6 -2 -9 -6c1.272 -2.12 2.712 -3.678 4.32 -4.674m2.86 -1.146a9.055 9.055 0 0 1 1.82 -.18c3.6 0 6.6 2 9 6c-.666 1.11 -1.379 2.067 -2.138 2.87"}),h("path",{d:"M3 3l18 18"})]}),W),hE=D(O("g",{stroke:"currentColor",fill:"none",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),W),gE=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15.5 13a3.5 3.5 0 0 0 -3.5 3.5v1a3.5 3.5 0 0 0 7 0v-1.8"}),h("path",{d:"M8.5 13a3.5 3.5 0 0 1 3.5 3.5v1a3.5 3.5 0 0 1 -7 0v-1.8"}),h("path",{d:"M17.5 16a3.5 3.5 0 0 0 0 -7h-.5"}),h("path",{d:"M19 9.3v-2.8a3.5 3.5 0 0 0 -7 0"}),h("path",{d:"M6.5 16a3.5 3.5 0 0 1 0 -7h.5"}),h("path",{d:"M5 9.3v-2.8a3.5 3.5 0 0 1 7 0v10"})]}),W),go=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"}),h("path",{d:"M21 21l-6 -6"})]}),W),fE=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M20.984 12.53a9 9 0 1 0 -7.552 8.355"}),h("path",{d:"M12 7v5l3 3"}),h("path",{d:"M19 16l-2 3h4l-2 3"})]}),W),bE=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M9 2m0 3a3 3 0 0 1 3 -3h0a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3h0a3 3 0 0 1 -3 -3z"}),h("path",{d:"M5 10a7 7 0 0 0 14 0"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),W),xE=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 3l18 18"}),h("path",{d:"M9 5a3 3 0 0 1 6 0v5a3 3 0 0 1 -.13 .874m-2 2a3 3 0 0 1 -3.87 -2.872v-1"}),h("path",{d:"M5 10a7 7 0 0 0 10.846 5.85m2 -2a6.967 6.967 0 0 0 1.152 -3.85"}),h("path",{d:"M8 21l8 0"}),h("path",{d:"M12 17l0 4"})]}),W),id=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11"})]}),W),EE=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 8m0 1a1 1 0 0 1 1 -1h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1z"}),h("path",{d:"M12 20v.01"}),h("path",{d:"M16 20v.01"}),h("path",{d:"M8 20v.01"}),h("path",{d:"M4 20v.01"}),h("path",{d:"M4 16v.01"}),h("path",{d:"M4 12v.01"}),h("path",{d:"M4 8v.01"}),h("path",{d:"M4 4v.01"}),h("path",{d:"M8 4v.01"}),h("path",{d:"M12 4v.01"}),h("path",{d:"M16 4v.01"}),h("path",{d:"M20 4v.01"}),h("path",{d:"M20 8v.01"}),h("path",{d:"M20 12v.01"}),h("path",{d:"M20 16v.01"}),h("path",{d:"M20 20v.01"})]}),W),yE=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3v18"}),h("path",{d:"M19 21v-18"}),h("path",{d:"M5 7h14"}),h("path",{d:"M5 15h14"}),h("path",{d:"M8 13v4"}),h("path",{d:"M11 13v4"}),h("path",{d:"M16 13v4"}),h("path",{d:"M14 5v4"}),h("path",{d:"M11 5v4"}),h("path",{d:"M8 5v4"}),h("path",{d:"M3 21h18"})]}),W),vE=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 12l18 0"}),h("path",{d:"M7 16l10 0l-10 5l0 -5"}),h("path",{d:"M7 8l10 0l-10 -5l0 5"})]}),W),wE=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M12 3l0 18"}),h("path",{d:"M16 7l0 10l5 0l-5 -10"}),h("path",{d:"M8 7l0 10l-5 0l5 -10"})]}),W),Fu=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 3m0 2a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2z"}),h("path",{d:"M19 6h1a2 2 0 0 1 2 2a5 5 0 0 1 -5 5l-5 0v2"}),h("path",{d:"M10 15m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"})]}),W),ad=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 15m-5 0a5 5 0 1 0 10 0a5 5 0 1 0 -10 0"}),h("path",{d:"M22 22l-3 -3"}),h("path",{d:"M6 18h-1a2 2 0 0 1 -2 -2v-1"}),h("path",{d:"M3 11v-1"}),h("path",{d:"M3 6v-1a2 2 0 0 1 2 -2h1"}),h("path",{d:"M10 3h1"}),h("path",{d:"M15 3h1a2 2 0 0 1 2 2v1"})]}),W),TE=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M4 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75"}),h("path",{d:"M10 15l2 6l2 -6"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"})]}),W),CE=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"}),h("path",{d:"M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4"}),h("path",{d:"M20 15h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1v-3"}),h("path",{d:"M5 18h1.5a1.5 1.5 0 0 0 0 -3h-1.5v6"}),h("path",{d:"M11 21v-6l3 6v-6"})]}),W),IE=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4 13v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a2 2 0 0 0 6 0v-8a2 2 0 0 1 2 -2h1a2 2 0 0 1 2 2v8a8 8 0 0 1 -16 0"}),h("path",{d:"M4 8l5 0"}),h("path",{d:"M15 8l4 0"})]}),W),SE=D(O("g",{strokeWidth:1.25,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1"}),h("path",{d:"M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2"}),h("path",{d:"M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z"}),h("path",{d:"M16.746 16.726a3 3 0 1 0 .252 -5.555"})]}),W),kE=D(O("g",{stroke:"currentColor",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 5a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-16a1 1 0 0 1-1-1v-10zM7 20h10M9 16v4M15 16v4"})]}),{...W,strokeWidth:1.5}),H_=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M15 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"}),h("path",{d:"M21 12h-13l3 -3"}),h("path",{d:"M11 15l-3 -3"})]}),W),ME=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M2 8a4 4 0 0 1 4 -4h12a4 4 0 0 1 4 4v8a4 4 0 0 1 -4 4h-12a4 4 0 0 1 -4 -4v-8z"}),h("path",{d:"M10 9l5 3l-5 3z"})]}),W),LE=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M3 6h18"}),h("path",{d:"M3 12h18"}),h("path",{d:"M3 18h18"}),h("path",{d:"M6 3v18"}),h("path",{d:"M12 3v18"}),h("path",{d:"M18 3v18"})]}),W),AE=D(O("g",{strokeWidth:1.5,children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M17 3m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M3 17m0 1a1 1 0 0 1 1 -1h2a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-2a1 1 0 0 1 -1 -1z"}),h("path",{d:"M17 5c-6.627 0 -12 5.373 -12 12"})]}),W),_E=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 18l12 -12"}),h("path",{d:"M18 10v-4h-4"})]}),W),DE=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M4,19L10,19C11.097,19 12,18.097 12,17L12,9C12,7.903 12.903,7 14,7L21,7"}),h("path",{d:"M18 4l3 3l-3 3"})]}),W),PE=D(O("g",{children:[h("path",{d:"M16,12L20,9L16,6"}),h("path",{d:"M6 20c0 -6.075 4.925 -11 11 -11h3"})]}),W),ld=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 9l6 6l6 -6"})]}),W),RE=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),W),NE=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),W),Hu=D(O("g",{strokeWidth:"1.25",children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M8 5v10a1 1 0 0 0 1 1h10"}),h("path",{d:"M5 8h10a1 1 0 0 1 1 1v10"})]}),W),sd=D(O("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M19 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"}),h("path",{d:"M5 7l0 10"}),h("path",{d:"M7 5l10 0"}),h("path",{d:"M7 19l10 0"}),h("path",{d:"M19 7l0 10"})]}),W);import OE from"clsx";import Gu,{useEffect as yT,useRef as BE,useState as vT}from"react";import xT from"react";import{jsx as Uu}from"react/jsx-runtime";var ET=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(xT.useRef(Date.now()).current%1600);return Uu("div",{className:`Spinner ${r}`,children:Uu("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Uu("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},Mt=ET;import{jsx as Fl,jsxs as Hl}from"react/jsx-runtime";var Q=Gu.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=gt(),a=Gu.useRef(null);Gu.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,c]=vT(!1),m=BE(!0),d=async u=>{let g="onClick"in r&&r.onClick?.(u);if(nn(g))try{c(!0),await g}catch(b){if(b instanceof Ji)console.warn(b);else throw b}finally{m.current&&c(!1)}};yT(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=BE(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return Hl("button",{className:OE("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)&&Hl("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&Fl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&Fl(Mt,{})]}),r.showAriaLabel&&Hl("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&Fl(Mt,{})]}),r.children]})}return Hl("label",{className:OE("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[Fl("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}),Hl("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&Fl("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});Q.displayName="ToolButton";var cd=[],z=e=>(cd=cd.concat(e),e);import{jsx as TT}from"react/jsx-runtime";var wT=(e,o,t)=>{let r=new Set(J(e.filter(m=>ne(m)),o).map(m=>m.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of r){let d=Mo(e,m);for(let p of d)if(!a.has(p.id)){if(_e(p)){let u=_t(p,i);u&&(n[u.id]=!0)}else n[p.id]=!0;a.add(p.id)}}let l=!0,s=e.map(m=>{if(o.selectedElementIds[m.id]){let d=_e(m)?_t(m,i):null;return m.frameId&&r.has(m.frameId)?(l=!1,n[m.id]=!0,m):d?.frameId&&r.has(d?.frameId)?m:(m.boundElements&&m.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&te(u)&&(B(u,{startBinding:m.id===u.startBinding?.elementId?null:u.startBinding,endBinding:m.id===u.endBinding?.elementId?null:u.endBinding}),B(u,{points:u.points}))}),oe(m,{isDeleted:!0}))}return m.frameId&&r.has(m.frameId)?(l=!1,_e(m)||(n[m.id]=!0),oe(m,{frameId:null})):_e(m)&&o.selectedElementIds[m.containerId]?oe(m,{isDeleted:!0}):m}),c=o.editingGroupId;if(l&&o.editingGroupId){let m=Fe(s,o.editingGroupId).filter(d=>!d.isDeleted);if(m.length>1)m[0]&&(n[m[0].id]=!0);else{c=null,m[0]&&(n[m[0].id]=!0);let d=m[0];if(d){let p=d.groupIds.findIndex(g=>g===o.editingGroupId),u=d.groupIds[p+1];if(u){let g=Fe(s,u).filter(b=>!b.isDeleted);g.length>1&&(c=u,g.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...lt({selectedElementIds:n,editingGroupId:c},s,o,null)}}},zE=(e,o)=>{if(e.editingGroupId){let t=Fe(Ee(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},Ul=z({name:"deleteSelectedElements",label:"labels.delete",icon:ho,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.editingLinearElement){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:c}=o.editingLinearElement,m=r.scene.getNonDeletedElementsMap(),d=j.getElement(a,m);if(!d||l==null)return!1;if(d.points.length<2){let u=e.map(b=>b.id===d.id?oe(b,{isDeleted:!0}):b),g=zE(o,u);return{elements:u,appState:{...g,editingLinearElement:null},captureUpdate:A.IMMEDIATELY}}let p={startBindingElement:l?.includes(0)?null:s,endBindingElement:l?.includes(d.points.length-1)?null:c};return j.deletePoints(d,l),{elements:e,appState:{...o,editingLinearElement:{...o.editingLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:A.IMMEDIATELY}}let{elements:n,appState:i}=wT(e,o,r);return lc(n,n.filter(a=>a.isDeleted)),i=zE(i,n),{elements:n,appState:{...i,activeTool:He(o,{type:"selection"}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:ze(Ee(e),o)?A.IMMEDIATELY:A.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===T.BACKSPACE||e.key===T.DELETE)&&!e[T.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>TT(Q,{type:"button",icon:ho,title:f("labels.delete"),"aria-label":f("labels.delete"),onClick:()=>t(null),visible:ze(Ee(e),o)})});var Vu=(e,o)=>e.frameId===o||e.id===o,HE=(e,o,t)=>{let r=[],n=[],i=null,a=-1,l=ee(t||J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0}));for(;++a<e.length;){let s=e[a];l.get(s.id)?(n.length&&(r=r.concat(n),n=[]),r.push(a),i=a+1):s.isDeleted&&i===a?(i=a+1,n.push(a)):n=[]}return r},CT=e=>{let o=0;return e.reduce((t,r,n)=>(n>0&&e[n-1]!==r-1&&(o=++o),(t[o]||(t[o]=[])).push(r),t),[])},FE=(e,o,t,r)=>{if("containerId"in e&&e.containerId){let n=r.getElement(e.containerId);if(n)return t==="left"?Math.min(o.indexOf(n),o.indexOf(e)):Math.max(o.indexOf(n),o.indexOf(e))}else{let n=e.boundElements?.find(i=>i.type!=="arrow")?.id;if(n){let i=r.getElement(n);if(i)return t==="left"?Math.min(o.indexOf(i),o.indexOf(e)):Math.max(o.indexOf(i),o.indexOf(e))}}},IT=(e,o)=>{let t=-1,r=-1;return e.forEach((n,i)=>{Vu(n,o)&&(t===-1&&(t=i),r=i)}),t===-1?[]:e.slice(t,r+1)},ST=(e,o,t,r,n,i)=>{let a=o[t],l=p=>p.isDeleted?!1:n?p.frameId===n:e.editingGroupId?p.groupIds.includes(e.editingGroupId):!0,s=r==="left"?Mr(o,p=>l(p),Math.max(0,t-1)):kp(o,p=>l(p),t+1),c=o[s];if(!c)return-1;if(e.editingGroupId){if(a?.groupIds.join("")===c?.groupIds.join(""))return FE(c,o,r,i)??s;if(!c?.groupIds.includes(e.editingGroupId))return-1}if(!n&&(c.frameId||ne(c))){let p=IT(o,c.frameId||c.id);return r==="left"?o.indexOf(p[0]):o.indexOf(p[p.length-1])}if(!c.groupIds.length)return FE(c,o,r,i)??s;let m=e.editingGroupId?c.groupIds[c.groupIds.indexOf(e.editingGroupId)-1]:c.groupIds[c.groupIds.length-1],d=Fe(o,m);return d.length?r==="left"?o.indexOf(d[0]):o.indexOf(d[d.length-1]):s},UE=(e,o)=>o.reduce((t,r)=>{let n=e[r];return t.set(n.id,n),t},new Map),GE=(e,o,t,r)=>{let n=HE(e,o),i=UE(e,n),a=CT(n);t==="right"&&(a=a.reverse());let l=new Set(n.filter(s=>ne(e[s])).map(s=>e[s].id));return a.forEach((s,c)=>{let m=s[0],d=s[s.length-1],p=t==="left"?m:d,u=s.some(y=>{let v=e[y];return v.frameId&&l.has(v.frameId)})?null:e[p]?.frameId,g=ST(o,e,p,t,u,r);if(g===-1||p===g)return;let b=t==="left"?e.slice(0,g):e.slice(0,m),x=e.slice(m,d+1),E=t==="left"?e.slice(g,m):e.slice(d+1,g+1),w=t==="left"?e.slice(d+1):e.slice(g+1);e=t==="left"?[...b,...x,...E,...w]:[...b,...E,...x,...w]}),Ut(e,i),e},VE=(e,o,t,r,n)=>{let i=HE(e,o,n),a=UE(e,i),l=[],s,c;if(t==="left"){if(r)s=kp(e,g=>Vu(g,r));else if(o.editingGroupId){let g=Fe(e,o.editingGroupId);if(!g.length)return e;s=e.indexOf(g[0])}else s=0;c=i[i.length-1]}else{if(r)c=Mr(e,g=>Vu(g,r));else if(o.editingGroupId){let g=Fe(e,o.editingGroupId);if(!g.length)return e;c=e.indexOf(g[g.length-1])}else c=e.length-1;s=i[0]}s===-1&&(s=0);for(let g=s;g<c+1;g++)i.includes(g)||l.push(e[g]);let m=Array.from(a.values()),d=e.slice(0,s),p=e.slice(c+1),u=t==="left"?[...d,...m,...l,...p]:[...d,...l,...m,...p];return Ut(u,a),u};function YE(e,o,t,r){let n=ee(J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),i={regularElements:[],frameChildren:new Map},a=new Set;for(let c of e)n.has(c.id)&&ne(c)&&a.add(c.id);for(let c of e)if(n.has(c.id))if(ne(c)||c.frameId&&a.has(c.frameId))i.regularElements.push(c);else if(!c.frameId)i.regularElements.push(c);else{let m=i.frameChildren.get(c.frameId)||[];m.push(c),i.frameChildren.set(c.frameId,m)}let l=e,s=Array.from(i.frameChildren.entries());for(let[c,m]of s)l=r(e,o,t,c,m);return r(l,o,t,null,i.regularElements)}var WE=(e,o,t)=>GE(e,o,"left",t),KE=(e,o,t)=>GE(e,o,"right",t),ZE=(e,o)=>YE(e,o,"left",VE),XE=(e,o)=>YE(e,o,"right",VE);import{jsx as dd}from"react/jsx-runtime";var Yu=z({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:Su,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:WE(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===pe.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>dd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendBackward")} \u2014 ${R("CtrlOrCmd+[")}`,children:Su})}),Wu=z({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Iu,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:KE(e,o,r.scene),appState:o,captureUpdate:A.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[T.CTRL_OR_CMD]&&!e.shiftKey&&e.code===pe.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>dd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.bringForward")} \u2014 ${R("CtrlOrCmd+]")}`,children:Iu})}),Ku=z({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Mu,trackEvent:{category:"element"},perform:(e,o)=>({elements:ZE(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Uo?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.BRACKET_LEFT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===pe.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>dd("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${f("labels.sendToBack")} \u2014 ${Uo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")}`,children:Mu})}),Zu=z({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:ku,trackEvent:{category:"element"},perform:(e,o)=>({elements:XE(e,o),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>Uo?e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.BRACKET_RIGHT:e[T.CTRL_OR_CMD]&&e.shiftKey&&e.code===pe.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>dd("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${f("labels.bringToFront")} \u2014 ${Uo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")}`,children:ku})});var Xu=z({name:"selectAll",label:"labels.selectAll",icon:EE,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.editingLinearElement)return!1;let n=e.filter(i=>!i.isDeleted&&!(Z(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...lt({editingGroupId:null,selectedElementIds:n},Ee(e),o,r),selectedLinearElement:Object.keys(n).length===1&&ae(e[0])?new j(e[0]):null},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.A});import{jsx as MT}from"react/jsx-runtime";var $u=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=j.duplicateSelectedPoints(o,r.scene.getNonDeletedElementsMap());return{elements:e,appState:a,captureUpdate:A.IMMEDIATELY}}catch{return!1}let{newElements:n,elementsWithClones:i}=li({type:"in-place",elements:e,idsOfElementsToDuplicate:ee(J(e,o,{includeBoundTextElement:!0,includeElementsInFrames:!0})),appState:o,randomizeSeed:!0,overrides:a=>({x:a.x+cp/2,y:a.y+cp/2}),reverseOrder:!1});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:Ut(i,ee(n)),appState:{...o,...kT(n),...lt({editingGroupId:o.editingGroupId,selectedElementIds:hc(n).reduce((a,l)=>(_e(l)||(a[l.id]=!0),a),{})},Ee(i),o,null)},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.D,PanelComponent:({elements:e,appState:o,updateData:t})=>MT(Q,{type:"button",icon:Dl,title:`${f("labels.duplicateSelection")} \u2014 ${R("CtrlOrCmd+D")}`,"aria-label":f("labels.duplicateSelection"),onClick:()=>t(null),visible:ze(Ee(e),o)})}),kT=e=>{let o=e.filter(ae);if(o.length===1){let t=o[0],r=t.boundElements?.map(i=>i.id)??[];if(e.every(i=>i.id===t.id||r.includes(i.id)))return{selectedLinearElement:new j(t)}}return{selectedLinearElement:null}};import{useEffect as hh,useMemo as o4,useRef as gh,useState as r4}from"react";var LT=new Set(["command_palette","export"]),xe=(e,o,t,r)=>{try{if(typeof window>"u"||k.VITE_WORKER_ID||k.VITE_APP_ENABLE_TRACKING!=="true"||!LT.has(e)||Ue())return;k.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import PT from"clsx";import AT from"clsx";import{forwardRef as _T}from"react";import{jsx as DT}from"react/jsx-runtime";var md=_T((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return DT("button",{type:"button",ref:o,title:t,"data-testid":n,className:AT(r,{standalone:a,active:i}),onClick:s,children:l},t)});import{jsx as ju,jsxs as RT}from"react/jsx-runtime";var Ao=e=>ju("div",{className:"buttonList",children:e.options.map(o=>e.type==="button"?ju(md,{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):RT("label",{className:PT({active:e.value===o.value}),title:o.text,children:[ju("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 bd from"@radix-ui/react-popover";import x6 from"clsx";import{useRef as E6}from"react";import{jsx as NT}from"react/jsx-runtime";var pd=()=>NT("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as FT,useRef as HT}from"react";import{createPortal as UT}from"react-dom";import $E from"react";var qu=$E.createContext(null),Re=()=>$E.useContext(qu);import{useState as OT,useLayoutEffect as jE}from"react";var ud=e=>{let[o,t]=OT(null),r=Ce(),{theme:n}=Re(),{container:i}=gt();return jE(()=>{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===de.DARK))},[o,n,r.editor.isMobile,e?.className]),jE(()=>{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 BT}from"react";function pa(e,o,t){BT(()=>{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 zT}from"react";var fn=e=>{let o=zT(e);return Object.assign(o.current,e),o.current};import{jsx as GT}from"react/jsx-runtime";var bn=De(null),qE=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=ud({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=Re(),a=xn(),l=st(),s=J(a,i),c=fn({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=gt();FT(()=>{let p=d.current;if(!p||!l.canvas||!n)return;let u=!1,g=l.canvas.getContext("2d"),b=({clientX:S,clientY:_})=>{let L=g.getImageData((S-i.offsetLeft)*window.devicePixelRatio,(_-i.offsetTop)*window.devicePixelRatio,1,1).data;return Uf(L[0],L[1],L[2])},x=({clientX:S,clientY:_,altKey:L})=>{p.style.top=`${_+20}px`,p.style.left=`${S+20}px`;let N=b({clientX:S,clientY:_});u&&c.onChange(r,N,c.selectedElements,{altKey:L}),p.style.background=N},E=()=>{c.onCancel()},w=(S,_)=>{c.onSelect(S,_)},y=S=>{u=!0,S.stopImmediatePropagation()},v=S=>{u=!1,m?.focus(),S.stopImmediatePropagation(),S.preventDefault(),w(b(S),S)},I=S=>{S.key===T.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),E())};return n.tabIndex=-1,n.focus(),x({clientX:c.app.lastViewportPosition.x,clientY:c.app.lastViewportPosition.y,altKey:!1}),n.addEventListener("keydown",I),n.addEventListener("pointerdown",y),n.addEventListener("pointerup",v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener("blur",E),()=>{u=!1,n.removeEventListener("keydown",I),n.removeEventListener("pointerdown",y),n.removeEventListener("pointerup",v),window.removeEventListener("pointermove",x),window.removeEventListener("blur",E)}},[c,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let d=HT(null);return pa(d,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?UT(GT("div",{ref:d,className:"excalidraw-eye-dropper-preview"}),n):null};import*as ua from"@radix-ui/react-popover";import KT from"clsx";import ZT from"react";import VT from"react";import YT from"clsx";import{jsx as WT}from"react/jsx-runtime";var yt=VT.forwardRef(({children:e,padding:o,className:t,style:r},n)=>WT("div",{className:YT("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as Ju,jsxs as XT}from"react/jsx-runtime";var hd=ZT.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},c)=>{let m=Ce();return Ju(ua.Portal,{container:o,children:XT(ua.Content,{ref:c,className:KT("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&&!w1(document.activeElement)&&o.focus(),n()},children:[Ju(yt,{padding:3,style:r,children:t}),Ju(ua.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import $T from"clsx";import{useCallback as jT,useEffect as eh,useRef as ey,useState as qT}from"react";var En=({palette:e,color:o})=>{for(let[t,r]of Object.entries(e))if(Array.isArray(r)){let n=r.indexOf(o);if(n>-1)return{colorName:t,shade:n}}else if(r===o)return{colorName:t,shade:null};return null},Gl=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),Qu=({color:e,palette:o})=>!Object.values(o).flat().includes(e),QE=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return Qu({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,Rf)},Do=De(null),JE=(e,o,t)=>(e*299+o*587+t*114)/1e3,ha=(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 JE(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 JE(t,r,n)<o};import{Fragment as JT,jsx as gd,jsxs as ty}from"react/jsx-runtime";var oy=({color:e,onChange:o,label:t,colorPickerType:r})=>{let n=Ce(),[i,a]=qT(e),[l,s]=ve(Do);eh(()=>{a(e)},[e]);let c=jT(g=>{let b=g.toLowerCase(),x=ry(b);x&&o(x),a(b)},[o]),m=ey(null),d=ey(null);eh(()=>{m.current&&m.current.focus()},[l]);let[p,u]=ve(bn);return eh(()=>()=>{u(null)},[u]),ty("div",{className:"color-picker__input-label",children:[gd("div",{className:"color-picker__input-hash",children:"#"}),gd("input",{ref:l==="hex"?m:void 0,style:{border:0,padding:0},spellCheck:!1,className:"color-picker-input","aria-label":t,onChange:g=>{c(g.target.value)},value:(i||"").replace(/^#/,""),onBlur:()=>{a(e)},tabIndex:-1,onFocus:()=>s("hex"),onKeyDown:g=>{g.key!==T.TAB&&(g.key===T.ESCAPE&&d.current?.focus(),g.stopPropagation())}}),!n.editor.isMobile&&ty(JT,{children:[gd("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),gd("div",{ref:d,className:$T("excalidraw-eye-dropper-trigger",{selected:p}),onClick:()=>u(g=>g?null:{keepOpenOnAlt:!1,onSelect:b=>o(b),colorPickerType:r}),title:`${f("labels.eyeDropper")} \u2014 ${T.I.toLocaleUpperCase()} or ${R("Alt")} `,children:dE})]})]})};import cy,{useEffect as dy,useState as f6}from"react";import t6 from"clsx";import{useEffect as o6,useRef as r6}from"react";import{jsxs as e6}from"react/jsx-runtime";var QT=({color:e,keyLabel:o,isShade:t=!1})=>e6("div",{className:"color-picker__button__hotkey-label",style:{color:ha(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),ga=QT;import{jsx as th,jsxs as n6}from"react/jsx-runtime";var ny=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=ve(Do),a=r6(null);return o6(()=>{a.current&&a.current.focus()},[o,n]),th("div",{className:"color-picker-content--default",children:e.map((l,s)=>n6("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:t6("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:[th("div",{className:"color-picker__button-outline"}),th(ga,{color:l,keyLabel:s+1})]},s))})};import i6 from"clsx";import{useEffect as a6,useRef as l6}from"react";import{jsx as oh,jsxs as c6}from"react/jsx-runtime";var s6=({palette:e,color:o,onChange:t,label:r,activeShade:n})=>{let i=En({color:o||"transparent",palette:e}),[a,l]=ve(Do),s=l6(null);return a6(()=>{s.current&&a==="baseColors"&&s.current.focus()},[i?.colorName,a]),oh("div",{className:"color-picker-content--default",children:Object.entries(e).map(([c,m],d)=>{let p=(Array.isArray(m)?m[n]:m)||"transparent",u=Gl[d],g=f(`colors.${c.replace(/\d+/,"")}`,null,"");return c6("button",{ref:i?.colorName===c?s:void 0,tabIndex:-1,type:"button",className:i6("color-picker__button color-picker__button--large has-outline",{active:i?.colorName===c,"is-transparent":p==="transparent"||!p}),onClick:()=>{t(p),l("baseColors")},title:`${g}${p.startsWith("#")?` ${p}`:""} \u2014 ${u}`,"aria-label":`${g} \u2014 ${u}`,style:p?{"--swatch-color":p}:void 0,"data-testid":`color-${c}`,children:[oh("div",{className:"color-picker__button-outline"}),oh(ga,{color:p,keyLabel:u})]},c)})})},iy=s6;import{jsx as m6}from"react/jsx-runtime";var d6=({children:e})=>m6("div",{className:"color-picker__heading",children:e}),fa=d6;import p6 from"clsx";import{useEffect as u6,useRef as h6}from"react";import{jsx as Vl,jsxs as ay}from"react/jsx-runtime";var ly=({hex:e,onChange:o,palette:t})=>{let r=En({color:e||"transparent",palette:t}),[n,i]=ve(Do),a=h6(null);if(u6(()=>{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)=>ay("button",{ref:d===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:p6("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(ga,{color:m,keyLabel:d+1,isShade:!0})]},d))})}return ay("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[Vl("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),Vl("div",{tabIndex:-1,style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center",fontSize:"0.75rem"},children:f("colorPicker.noShades")})]})};var rh=(e,o,t)=>{let r=Math.ceil(t/zn);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+zn;return n>=t?o%zn:n}case"ArrowUp":{let n=o-zn,i=n<0?zn*r+n:n;return i>=t?void 0:i}}},g6=({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(Gl.includes(e.key)){let l=Gl.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},sy=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:c,onEscape:m})=>{if(e[T.CTRL_OR_CMD])return!1;if(e.key===T.ESCAPE)return m(e),!0;if(e.key===T.ALT)return c(!0),!0;if(e.key===T.I)return c(),!0;let d=En({color:r,palette:t});if(e.key===T.TAB){let p={custom:!!i.length,baseColors:!0,shades:d?.shade!=null,hex:!0},u=Object.entries(p).reduce((w,[y,v])=>(v&&w.push(y),w),[]),g=u.indexOf(o),b=e.shiftKey?-1:1,x=g+b>u.length-1?0:g+b<0?u.length-1:g+b,E=u[x];return E&&a(E),E==="custom"?n(i[0]):E==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(Io.black)),e.preventDefault(),e.stopPropagation(),!0}if(g6({e,colorObj:d,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&d){let{shade:p}=d,u=rh(e.key,p,zn);if(u!==void 0)return n(t[d.colorName][u]),!0}if(o==="baseColors"&&d){let{colorName:p}=d,u=Object.keys(t),g=u.indexOf(p),b=rh(e.key,g,u.length);if(b!==void 0){let x=u[b],E=t[x];return n(Array.isArray(E)?E[s]:E),!0}}if(o==="custom"){let p=i.indexOf(r),u=rh(e.key,p,i.length);if(u!==void 0){let g=i[u];return n(g),!0}}return!1};import{jsx as hi,jsxs as fd}from"react/jsx-runtime";var my=({color:e,onChange:o,label:t,type:r,elements:n,palette:i,updateData:a,children:l,onEyeDropperToggle:s,onEscape:c})=>{let[m]=cy.useState(()=>r==="canvasBackground"?[]:QE(n,r,i)),[d,p]=ve(Do),u=En({color:e,palette:i});dy(()=>{if(!d){let E=Qu({color:e,palette:i}),w=E&&!m.includes(e);p(w?"hex":E?"custom":u?.shade!=null?"shades":"baseColors")}},[d,e,i,p,u,m]);let[g,b]=f6(u?.shade??(r==="elementBackground"?Bf:Of));dy(()=>{u?.shade!=null&&b(u.shade);let E=w=>{w.key===T.ALT&&s(!1)};return document.addEventListener("keyup",E,{capture:!0}),()=>{document.removeEventListener("keyup",E,{capture:!0})}},[u,s]);let x=cy.useRef(null);return hi("div",{role:"dialog","aria-modal":"true","aria-label":f("labels.colorPicker"),children:fd("div",{ref:x,onKeyDown:E=>{sy({event:E,activeColorPickerSection:d,palette:i,color:e,onChange:o,onEyeDropperToggle:s,customColors:m,setActiveColorPickerSection:p,updateData:a,activeShade:g,onEscape:c})&&(E.preventDefault(),E.stopPropagation())},className:"color-picker-content properties-content",tabIndex:-1,children:[!!m.length&&fd("div",{children:[hi(fa,{children:f("colorPicker.mostUsedCustomColors")}),hi(ny,{colors:m,color:e,label:f("colorPicker.mostUsedCustomColors"),onChange:o})]}),fd("div",{children:[hi(fa,{children:f("colorPicker.colors")}),hi(iy,{color:e,label:t,palette:i,onChange:o,activeShade:g})]}),fd("div",{children:[hi(fa,{children:f("colorPicker.shades")}),hi(ly,{hex:e,onChange:o,palette:i})]}),l]})})};import b6 from"clsx";import{jsx as nh}from"react/jsx-runtime";var py=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=Ms),o==="elementBackground"&&(n=Ls),o==="canvasBackground"&&(n=As),r&&(n=r),n?nh("div",{className:"color-picker__top-picks",children:n.map(i=>nh("button",{className:b6("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!ha(i,ks)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:nh("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as jo,jsxs as ih}from"react/jsx-runtime";var uy=e=>{let o=new Option().style;return o.color=e,!!o.color},ry=e=>Kn(e)?e:uy(`#${e}`)?`#${e}`:uy(e)?e:null,y6=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Io,updateData:a})=>{let{container:l}=gt(),[,s]=ve(Do),[c,m]=ve(bn),d=ih("div",{children:[jo(fa,{children:f("colorPicker.hexCode")}),jo(oy,{color:o,label:r,onChange:g=>{t(g)},colorPickerType:e})]}),p=E6(null),u=()=>{p.current?.querySelector(".color-picker-content")?.focus()};return jo(hd,{container:l,style:{maxWidth:"13rem"},onFocusOutside:g=>{u(),g.preventDefault()},onPointerDownOutside:g=>{c&&g.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?jo(my,{palette:i,color:o,onChange:g=>{t(g)},onEyeDropperToggle:g=>{m(b=>g?(b=b||{keepOpenOnAlt:!0,onSelect:t,colorPickerType:e},b.keepOpenOnAlt=!0,b):g===!1||b?null:{keepOpenOnAlt:!1,onSelect:t,colorPickerType:e})},onEscape:g=>{c?m(null):a({openPopup:null})},label:r,type:e,elements:n,updateData:a,children:d}):d})},v6=({label:e,color:o,type:t})=>jo(bd.Trigger,{type:"button",className:x6("color-picker__button active-color properties-trigger",{"is-transparent":o==="transparent"||!o,"has-outline":!ha(o,ks)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?f("labels.showStroke"):f("labels.showBackground"),children:jo("div",{className:"color-picker__button-outline"})}),Yl=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Io,topPicks:a,updateData:l,appState:s})=>jo("div",{children:ih("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[jo(py,{activeColor:o,onChange:t,type:e,topPicks:a}),jo(pd,{}),ih(bd.Root,{open:s.openPopup===e,onOpenChange:c=>{l({openPopup:c?e:null})},children:[jo(v6,{color:o,label:r,type:e}),s.openPopup===e&&jo(y6,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as Ty from"@radix-ui/react-popover";import Y6,{useCallback as W6,useMemo as K6}from"react";import B6,{useMemo as yn,useState as z6,useRef as F6,useEffect as H6,useCallback as U6}from"react";import w6 from"clsx";import T6 from"react";import{jsx as C6,jsxs as I6}from"react/jsx-runtime";var xd=T6.forwardRef(({className:e,placeholder:o,onChange:t},r)=>I6("div",{className:w6("QuickSearch__wrapper",e),children:[go,C6("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import S6 from"clsx";import{Children as k6}from"react";import{jsx as hy}from"react/jsx-runtime";var Ed=({className:e,placeholder:o,children:t})=>{let r=!k6.count(t);return hy("div",{className:S6("ScrollableList__wrapper",e),role:"menu",children:r?hy("div",{className:"empty",children:o}):t})};import{jsx as M6,jsxs as L6}from"react/jsx-runtime";var gy=({children:e,className:o="",style:t,title:r})=>L6("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&M6("p",{className:"dropdown-menu-group-title",children:r}),e]}),Wl=gy;gy.displayName="DropdownMenuGroup";import{useEffect as N6,useRef as O6}from"react";import{Fragment as _6,jsx as ah,jsxs as D6}from"react/jsx-runtime";var A6=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=Ce();return D6(_6,{children:[o&&ah("div",{className:"dropdown-menu-item__icon",children:o}),ah("div",{style:e,className:"dropdown-menu-item__text",children:r}),t&&!n.editor.isMobile&&ah("div",{className:"dropdown-menu-item__shortcut",children:t})]})},yd=A6;import P6,{useContext as R6}from"react";var lh=P6.createContext({}),vd=(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(),wd=(e,o)=>{let t=R6(lh);return an(e,r=>{let n=new CustomEvent("menu.itemSelect",{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as sh}from"react/jsx-runtime";var ch=({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=wd(m,c),u=O6(null);return N6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),sh("button",{...d,ref:u,value:o,onClick:p,className:vd(i,l,a),title:d.title??d["aria-label"],children:sh(yd,{textStyle:s,icon:e,shortcut:n,children:r})})};ch.displayName="DropdownMenuItem";var ba={GREEN:"green",RED:"red",BLUE:"blue"},Td=({type:e=ba.BLUE,children:o})=>{let{theme:t}=ur(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===de.LIGHT?"1.5px solid white":"none"};switch(e){case ba.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case ba.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case ba.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return sh("div",{className:"DropDownMenuItemBadge",style:r,children:o})};Td.displayName="DropdownMenuItemBadge";ch.Badge=Td;var Yt=ch;var fy=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===T.F)return o.current?.focus(),!0;if(e.key===T.ESCAPE)return n(),!0;if(e.key===T.ENTER)return t?.value&&i(t.value),!0;if(e.key===T.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===T.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as Kl,jsxs as by}from"react/jsx-runtime";var G6=e=>{switch(e){case Bt.Excalifont:case Bt.Virgil:return gn;case Bt.Nunito:case Bt.Helvetica:return Ol;case Bt["Lilita One"]:return Jx;case Bt["Comic Shanns"]:case Bt.Cascadia:return ed;default:return Ol}},xy=B6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=gt(),{fonts:s}=st(),{showDeprecatedFonts:c}=hr(),[m,d]=z6(""),p=F6(null),u=yn(()=>Array.from(un.registered.entries()).filter(([L,{metadata:N}])=>!N.serverSide&&!N.fallback).map(([L,{metadata:N,fontFaces:P}])=>{let F={value:L,icon:G6(L),text:P[0]?.fontFace?.family??"Unknown"};return N.deprecated&&Object.assign(F,{deprecated:N.deprecated,badge:{type:ba.RED,placeholder:f("fontList.badge.old")}}),F}).sort((L,N)=>L.text.toLowerCase()>N.text.toLowerCase()?1:-1),[]),g=yn(()=>new Set(s.getSceneFamilies()),[e]),b=yn(()=>u.filter(L=>g.has(L.value)),[u,g]),x=yn(()=>u.filter(L=>!g.has(L.value)&&(c||!L.deprecated)),[u,g,c]),E=yn(()=>_1([...b,...x].filter(L=>L.text?.toLowerCase().includes(m))),[b,x,m]),w=yn(()=>{let L;return o?L=E.find(N=>N.value===o):e&&(L=E.find(N=>N.value===e)),!L&&m&&(E[0]?.value?r(E[0].value):n()),L},[o,e,m,E,r,n]),y=U6(L=>{fy({event:L,inputRef:p,hoveredFont:w,filteredFonts:E,onSelect:t,onHover:r,onClose:a})&&(L.preventDefault(),L.stopPropagation())},[w,E,t,r,a]);H6(()=>(i(),()=>{a()}),[]);let v=yn(()=>E.filter(L=>g.has(L.value)),[E,g]),I=yn(()=>E.filter(L=>!g.has(L.value)),[E,g]),S=(L,N)=>by(Yt,{icon:L.icon,value:L.value,order:N,textStyle:{fontFamily:Vn({fontFamily:L.value})},hovered:L.value===w?.value,selected:L.value===e,tabIndex:L.value===e?0:-1,onClick:P=>{t(Number(P.currentTarget.value))},onMouseMove:()=>{w?.value!==L.value&&r(L.value)},children:[L.text,L.badge&&Kl(Td,{type:L.badge.type,children:L.badge.placeholder})]},L.value),_=[];return v.length&&_.push(Kl(Wl,{title:f("fontList.sceneFonts"),children:v.map(S)},"group_1")),I.length&&_.push(Kl(Wl,{title:f("fontList.availableFonts"),children:I.map((L,N)=>S(L,N+v.length))},"group_2")),by(hd,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:y,children:[Kl(xd,{ref:p,placeholder:f("quickSearch.placeholder"),onChange:Yn(d,20)}),Kl(Ed,{className:"dropdown-menu fonts manual-hover",placeholder:f("fontList.empty"),children:_.length?_:null})]})},(e,o)=>e.selectedFontFamily===o.selectedFontFamily&&e.hoveredFontFamily===o.hoveredFontFamily);import*as Ey from"@radix-ui/react-popover";import{useMemo as V6}from"react";import{jsx as dh}from"react/jsx-runtime";var yy=({selectedFontFamily:e})=>{let o=V6(()=>!!(e&&!vy(e)),[e]);return dh(Ey.Trigger,{asChild:!0,children:dh("div",{children:dh(md,{standalone:!0,icon:Xc,title:f("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as Cd,jsxs as wy}from"react/jsx-runtime";var Cy=[{value:Bt.Excalifont,icon:gn,text:f("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:Bt.Nunito,icon:Ol,text:f("labels.normal"),testId:"font-family-normal"},{value:Bt["Comic Shanns"],icon:ed,text:f("labels.code"),testId:"font-family-code"}],Z6=new Set(Cy.map(e=>e.value)),vy=e=>e?Z6.has(e):!1,Iy=Y6.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=K6(()=>Cy,[]),s=W6(c=>{c&&r(c)},[r]);return wy("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[Cd(Ao,{type:"button",options:l,value:o,onClick:s}),Cd(pd,{}),wy(Ty.Root,{open:e,onOpenChange:a,children:[Cd(yy,{selectedFontFamily:o}),e&&Cd(xy,{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 xa from"@radix-ui/react-popover";import q6 from"clsx";import Id,{useEffect as J6}from"react";import{jsx as X6}from"react/jsx-runtime";var vn=({icon:e})=>X6("span",{style:{width:"1em",margin:"0 0.5ex 0 0.5ex",display:"inline-block",lineHeight:0,verticalAlign:"middle"},children:e});import{Fragment as j6,jsx as Sy,jsxs as ky}from"react/jsx-runtime";var $6=({label:e,open:o,openTrigger:t,children:r,className:n})=>ky(j6,{children:[ky("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,Sy(vn,{icon:o?RE:ld})]}),o&&Sy("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),Zl=$6;import{jsx as gi,jsxs as mh}from"react/jsx-runtime";var Q6=De(!1);function e4({options:e,value:o,label:t,onChange:r,onClose:n,numberOfOptionsToAlwaysShow:i=e.length}){let a=Ce(),l=u=>{let g=e.find(b=>b.keyBinding===u.key.toLowerCase());if(!(u.metaKey||u.altKey||u.ctrlKey)&&g)r(g.value),u.preventDefault();else if(u.key===T.TAB){let b=e.findIndex(E=>E.value===o),x=u.shiftKey?(e.length+b-1)%e.length:(b+1)%e.length;r(e[x].value)}else if(Un(u.key)){let b=Br().rtl,x=e.findIndex(E=>E.value===o);if(x!==-1){let E=e.length,w=x;switch(u.key){case(b?T.ARROW_LEFT:T.ARROW_RIGHT):w=(x+1)%E;break;case(b?T.ARROW_RIGHT:T.ARROW_LEFT):w=(E+x-1)%E;break;case T.ARROW_DOWN:{w=(x+(i??1))%E;break}case T.ARROW_UP:{w=(E+x-(i??1))%E;break}}r(e[w].value)}u.preventDefault()}else(u.key===T.ESCAPE||u.key===T.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,c]=ve(Q6),m=Id.useMemo(()=>e.slice(0,i),[e,i]),d=Id.useMemo(()=>e.slice(i),[e,i]);J6(()=>{m.some(u=>u.value===o)||c(!0)},[o,m,c]);let p=u=>gi("div",{className:"picker-content",children:u.map((g,b)=>mh("button",{type:"button",className:q6("picker-option",{active:o===g.value}),onClick:x=>{r(g.value)},title:`${g.text} ${g.keyBinding&&`\u2014 ${g.keyBinding.toUpperCase()}`}`,"aria-label":g.text||"none","aria-keyshortcuts":g.keyBinding||void 0,ref:x=>{o===g.value&&setTimeout(()=>{x?.focus()},0)},children:[g.icon,g.keyBinding&&gi("span",{className:"picker-keybinding",children:g.keyBinding})]},g.text))});return gi(xa.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:mh("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(m),d.length>0&&gi(Zl,{label:f("labels.more_options"),open:s,openTrigger:()=>{c(u=>!u)},className:"picker-collapsible",children:p(d)})]})})}function ph({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Id.useState(!1),s=Id.useRef(null);return gi("div",{children:mh(xa.Root,{open:a,onOpenChange:c=>l(c),children:[gi(xa.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&&gi(e4,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import My,{useEffect as t4}from"react";import{jsx as uh,jsxs as Ly}from"react/jsx-runtime";var Ay=({updateData:e,appState:o,elements:t,testId:r})=>{let n=My.useRef(null),i=My.useRef(null),a=Rt(t,o,l=>l.opacity,!0,o.currentItemOpacity);return t4(()=>{if(n.current&&i.current){let l=n.current,s=i.current,c=l.offsetWidth,m=15,d=a/100*(c-m)+m/2;s.style.left=`${d}px`,l.style.background=`linear-gradient(to right, var(--color-slider-track) 0%, var(--color-slider-track) ${a}%, var(--button-bg) ${a}%, var(--button-bg) 100%)`}},[a]),Ly("label",{className:"control-label",children:[f("labels.opacity"),Ly("div",{className:"range-wrapper",children:[uh("input",{ref:n,type:"range",min:"0",max:"100",step:"10",onChange:l=>{e(+l.target.value)},value:a,className:"range-input","data-testid":r}),uh("div",{className:"value-bubble",ref:i,children:a!==0?a:null}),uh("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as Py,jsx as fe,jsxs as fo}from"react/jsx-runtime";var Dy=.1,Wt=(e,o,t,r=!1)=>{let n=ee(J(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},Rt=function(e,o,t,r,n){let i=o.editingTextElement,a=Ee(e),l=null;return i&&(l=t(i)),l||(ze(a,o)?l=Mb(r===!0?a:a.filter(c=>r(c)),o,t)??(typeof n=="function"?n(!0):n):l=typeof n=="function"?n(!1):n),l},n4=(e,o)=>_e(o)||!o.autoResize?o:B(o,{x:e.textAlign==="left"?e.x:e.x+(e.width-o.width)/(e.textAlign==="center"?2:1),y:e.y+(e.height-o.height)/2},!1),fh=(e,o,t,r,n)=>{let i=new Set,a=Wt(e,o,s=>{if(Z(s)){let c=r(s);i.add(c);let m=oe(s,{fontSize:c});return Qe(m,t.scene.getContainerElement(s),t.scene.getNonDeletedElementsMap()),m=n4(s,m),m}return s},!0),l=ee(a);return J(e,o,{includeBoundTextElement:!0}).forEach(s=>{Z(s)&&at(s,l)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:A.IMMEDIATELY}},i4=z({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:Wt(e,o,r=>vl(r.type)?oe(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>fo(Py,{children:[fe("h3",{"aria-hidden":"true",children:f("labels.stroke")}),fe(Yl,{topPicks:Ms,palette:zf,type:"elementStroke",label:f("labels.stroke"),color:Rt(e,o,n=>n.strokeColor,!0,o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),a4=z({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemBackgroundColor&&{elements:Wt(e,o,r=>oe(r,{backgroundColor:t.currentItemBackgroundColor}))},appState:{...o,...t},captureUpdate:t.currentItemBackgroundColor?A.IMMEDIATELY:A.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>fo(Py,{children:[fe("h3",{"aria-hidden":"true",children:f("labels.background")}),fe(Yl,{topPicks:Ls,palette:Ff,type:"elementBackground",label:f("labels.background"),color:Rt(e,o,n=>n.backgroundColor,!0,o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),l4=z({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(xe("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:Wt(e,o,n=>oe(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=J(e,o),n=r.length>0&&r.every(i=>i.fillStyle==="zigzag");return fo("fieldset",{children:[fe("legend",{children:f("labels.fill")}),fe(Ao,{type:"button",options:[{value:"hachure",text:`${n?f("labels.zigzag"):f("labels.hachure")} (${R("Alt-Click")})`,icon:n?Tx:Cx,active:n?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:f("labels.crossHatch"),icon:Ix,testId:"fill-cross-hatch"},{value:"solid",text:f("labels.solid"),icon:Sx,testId:"fill-solid"}],value:Rt(e,o,i=>i.fillStyle,i=>i.hasOwnProperty("fillStyle"),i=>i?null:o.currentItemFillStyle),onClick:(i,a)=>{let l=a.altKey&&i==="hachure"&&r.every(s=>s.fillStyle==="hachure")?"zigzag":i;t(l)}})]})}}),s4=z({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>oe(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.strokeWidth")}),fe(Ao,{group:"stroke-width",options:[{value:Gs.thin,text:f("labels.thin"),icon:Bu,testId:"strokeWidth-thin"},{value:Gs.bold,text:f("labels.bold"),icon:kx,testId:"strokeWidth-bold"},{value:Gs.extraBold,text:f("labels.extraBold"),icon:Mx,testId:"strokeWidth-extraBold"}],value:Rt(e,o,r=>r.strokeWidth,r=>r.hasOwnProperty("strokeWidth"),r=>r?null:o.currentItemStrokeWidth),onChange:r=>t(r)})]})}),c4=z({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>oe(r,{seed:Lr(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.sloppiness")}),fe(Ao,{group:"sloppiness",options:[{value:0,text:f("labels.architect"),icon:_x},{value:1,text:f("labels.artist"),icon:Dx},{value:2,text:f("labels.cartoonist"),icon:Px}],value:Rt(e,o,r=>r.roughness,r=>r.hasOwnProperty("roughness"),r=>r?null:o.currentItemRoughness),onChange:r=>t(r)})]})}),FB=z({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>oe(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.strokeStyle")}),fe(Ao,{group:"strokeStyle",options:[{value:"solid",text:f("labels.strokeStyle_solid"),icon:Bu},{value:"dashed",text:f("labels.strokeStyle_dashed"),icon:Lx},{value:"dotted",text:f("labels.strokeStyle_dotted"),icon:Ax}],value:Rt(e,o,r=>r.strokeStyle,r=>r.hasOwnProperty("strokeStyle"),r=>r?null:o.currentItemStrokeStyle),onChange:r=>t(r)})]})}),d4=z({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>oe(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>fe(Ay,{updateData:t,elements:e,appState:o,testId:"opacity"})}),m4=z({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>fh(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fo("fieldset",{children:[fe("legend",{children:f("labels.fontSize")}),fe(Ao,{group:"font-size",options:[{value:16,text:f("labels.small"),icon:Xx,testId:"fontSize-small"},{value:20,text:f("labels.medium"),icon:$x,testId:"fontSize-medium"},{value:28,text:f("labels.large"),icon:jx,testId:"fontSize-large"},{value:36,text:f("labels.veryLarge"),icon:qx,testId:"fontSize-veryLarge"}],value:Rt(e,o,n=>{if(Z(n))return n.fontSize;let i=ge(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>Z(n)||ge(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||Ir),onChange:n=>t(n)})]})}),bh=z({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:ui,trackEvent:!1,perform:(e,o,t,r)=>fh(e,o,r,n=>Math.round(1/(1+Dy)*n.fontSize)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_LEFT||e.key===T.COMMA)}),xh=z({name:"increaseFontSize",label:"labels.increaseFontSize",icon:ui,trackEvent:!1,perform:(e,o,t,r)=>fh(e,o,r,n=>Math.round(n.fontSize*(1+Dy))),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&(e.key===T.CHEVRON_RIGHT||e.key===T.PERIOD)}),p4=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:Wt(e,o,b=>{let x=n?.get(b.id);return x?oe(b,{...x}):b},!0),appState:{...o,...l},captureUpdate:A.NEVER};let{currentItemFontFamily:s,currentHoveredFontFamily:c}=t,m=A.EVENTUALLY,d,p=!1;if(s)d=s,m=A.IMMEDIATELY;else if(c){d=c,m=A.EVENTUALLY;let g=J(e,o,{includeBoundTextElement:!0}).filter(b=>Z(b));if(g.length>200)p=!0;else{let b=0,x=0;for(;b<g.length&&x<5e3;){let E=g[b];x+=E?.originalText.length||0,b++}x>5e3&&(p=!0)}}let u={appState:{...o,...l},captureUpdate:m};if(d&&!p){let g=new Map,b=new Set,x=!1,E=Array.from(un.loadedFontsCache.values()),w=Object.entries(Bt).find(([I,S])=>S===d)?.[0];c&&w&&E.some(I=>I.startsWith(w))&&(x=!0),Object.assign(u,{elements:Wt(e,o,I=>{if(Z(I)&&(I.fontFamily!==d||s)){let S=oe(I,{fontFamily:d,lineHeight:kr(d)}),_=n?.get(I.containerId||"")||{},L=r.scene.getContainerElement(I);return a&&L&&_&&B(L,{..._},!1),x||(b=new Set([...b,...Array.from(S.originalText)])),g.set(S,L),S}return I},!0)});let y=`10px ${Vn({fontFamily:d})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[I,S]of g)Qe(I,S,r.scene.getNonDeletedElementsMap(),!1);else window.document.fonts.load(y,v).then(I=>{for(let[S,_]of g){let L=r.scene.getElement(S.id),N=_?r.scene.getElement(_.id):null;L&&Qe(L,N,r.scene.getNonDeletedElementsMap(),!1)}r.fonts.onLoaded(I)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=gh(new Map),i=gh(null),[a,l]=r4({}),s=gh(!0),c=o4(()=>{let m=(d,p)=>Rt(d,o,u=>{if(Z(u))return u.fontFamily;let g=ge(u,p);return g?g.fontFamily:null},u=>Z(u)||ge(u,p)!==null,u=>u?null:o.currentItemFontFamily||qr);return a.openPopup==="fontFamily"&&o.openPopup==="fontFamily"?m(Array.from(n.current?.values()??[]),n.current):!a.openPopup&&o.openPopup!=="fontFamily"?m(e,t.scene.getNonDeletedElementsMap()):i.current},[a.openPopup,o,e,t.scene]);return hh(()=>{i.current=c},[c]),hh(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),hh(()=>(s.current=!1,()=>{s.current=!0}),[]),fo("fieldset",{children:[fe("legend",{children:f("labels.fontFamily")}),fe(Iy,{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,oe(p||d,{},!0))}else{let p=J(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,oe(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()}}})]})}}),u4=z({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:Wt(e,o,n=>{if(Z(n)){let i=oe(n,{textAlign:t});return Qe(i,r.scene.getContainerElement(n),r.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return fo("fieldset",{children:[fe("legend",{children:f("labels.textAlign")}),fe(Ao,{group:"text-align",options:[{value:"left",text:f("labels.left"),icon:Qx,testId:"align-left"},{value:"center",text:f("labels.center"),icon:eE,testId:"align-horizontal-center"},{value:"right",text:f("labels.right"),icon:tE,testId:"align-right"}],value:Rt(e,o,i=>{if(Z(i))return i.textAlign;let a=ge(i,n);return a?a.textAlign:null},i=>Z(i)||ge(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})]})}}),h4=z({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:Wt(e,o,n=>{if(Z(n)){let i=oe(n,{verticalAlign:t});return Qe(i,r.scene.getContainerElement(n),r.scene.getNonDeletedElementsMap()),i}return n},!0),appState:{...o},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>fe("fieldset",{children:fe(Ao,{group:"text-align",options:[{value:Qt.TOP,text:f("labels.alignTop"),icon:fe(oE,{theme:o.theme}),testId:"align-top"},{value:Qt.MIDDLE,text:f("labels.centerVertically"),icon:fe(nE,{theme:o.theme}),testId:"align-middle"},{value:Qt.BOTTOM,text:f("labels.alignBottom"),icon:fe(rE,{theme:o.theme}),testId:"align-bottom"}],value:Rt(e,o,n=>{if(Z(n)&&n.containerId)return n.verticalAlign;let i=ge(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>Z(n)||ge(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:Qt.MIDDLE),onChange:n=>t(n)})})}),HB=z({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>te(r)?r:oe(r,{roundness:t==="round"?{type:Bi(r.type)?eo.ADAPTIVE_RADIUS:eo.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let n=gc(Ee(e),o).some(i=>i.roundness?.type===eo.LEGACY);return fo("fieldset",{children:[fe("legend",{children:f("labels.edges")}),fe(Ao,{group:"edges",options:[{value:"sharp",text:f("labels.sharp"),icon:Rx},{value:"round",text:f("labels.round"),icon:Nx}],value:Rt(e,o,i=>n?null:i.roundness?"round":"sharp",i=>!ke(i)&&i.hasOwnProperty("roundness"),i=>i?null:o.currentItemRoundness),onChange:i=>t(i)})]})}}),_y=e=>[{value:null,text:f("labels.arrowhead_none"),keyBinding:"q",icon:Ox},{value:"arrow",text:f("labels.arrowhead_arrow"),keyBinding:"w",icon:fe(Bx,{flip:e})},{value:"triangle",text:f("labels.arrowhead_triangle"),icon:fe(Ux,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:f("labels.arrowhead_triangle_outline"),icon:fe(Gx,{flip:e}),keyBinding:"r"},{value:"circle",text:f("labels.arrowhead_circle"),keyBinding:"a",icon:fe(zx,{flip:e})},{value:"circle_outline",text:f("labels.arrowhead_circle_outline"),keyBinding:"s",icon:fe(Fx,{flip:e})},{value:"diamond",text:f("labels.arrowhead_diamond"),icon:fe(Vx,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:f("labels.arrowhead_diamond_outline"),icon:fe(Yx,{flip:e}),keyBinding:"f"},{value:"bar",text:f("labels.arrowhead_bar"),keyBinding:"z",icon:fe(Hx,{flip:e})},{value:"crowfoot_one",text:f("labels.arrowhead_crowfoot_one"),icon:fe(Kx,{flip:e}),keyBinding:"c"},{value:"crowfoot_many",text:f("labels.arrowhead_crowfoot_many"),icon:fe(Wx,{flip:e}),keyBinding:"x"},{value:"crowfoot_one_or_many",text:f("labels.arrowhead_crowfoot_one_or_many"),icon:fe(Zx,{flip:e}),keyBinding:"v"}],UB=z({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:Wt(e,o,r=>{if(ae(r)){let{position:n,type:i}=t;if(n==="start")return oe(r,{startArrowhead:i});if(n==="end")return oe(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=Br().rtl;return fo("fieldset",{children:[fe("legend",{children:f("labels.arrowheads")}),fo("div",{className:"iconSelectList buttonList",children:[fe(ph,{label:"arrowhead_start",options:_y(!r),value:Rt(e,o,n=>ae(n)&&Zi(n.type)?n.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:n=>t({position:"start",type:n}),numberOfOptionsToAlwaysShow:4}),fe(ph,{label:"arrowhead_end",group:"arrowheads",options:_y(!!r),value:Rt(e,o,n=>ae(n)&&Zi(n.type)?n.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:n=>t({position:"end",type:n}),numberOfOptionsToAlwaysShow:4})]})]})}}),GB=z({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=Wt(e,o,l=>{if(!ke(l))return l;let s=oe(l,{roundness:t===Et.round?{type:eo.PROPORTIONAL_RADIUS}:null,elbowed:t===Et.elbow,points:t===Et.elbow||l.elbowed?[l.points[0],l.points[l.points.length-1]]:l.points});if(te(s)){s.fixedSegments=null;let c=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let m=j.getPointAtIndexGlobalCoordinates(s,0,c),d=j.getPointAtIndexGlobalCoordinates(s,-1,c),p=!s.startBinding&&cn(rn(m),e,c,o.zoom,!1,!0),u=!s.endBinding&&cn(rn(d),e,c,o.zoom,!1,!0),g=p||s.startBinding&&c.get(s.startBinding.elementId),b=u||s.endBinding&&c.get(s.endBinding.elementId),x=p?_p(s,p,"start"):m,E=u?_p(s,u,"end"):d;p&&Ko(s,p,"start",c),u&&Ko(s,u,"end",c);let w=g&&s.startBinding?{...s.startBinding,...Dp(s,g,"start",c)}:null,y=b&&s.endBinding?{...s.endBinding,...Dp(s,b,"end",c)}:null;s={...s,startBinding:w,endBinding:y,...sc(s,c,{points:[x,E].map(v=>M(v[0]-s.x,v[1]-s.y)),startBinding:w,endBinding:y,fixedSegments:null})},j.updateEditorMidPointsCache(s,c,r.state)}else{let c=r.scene.getNonDeletedElementsMap();if(s.startBinding){let m=c.get(s.startBinding.elementId);m&&Ko(s,m,"start",c)}if(s.endBinding){let m=c.get(s.endBinding.elementId);m&&Ko(s,m,"end",c)}}return s}),i={...o,currentItemArrowType:t},a=o.selectedLinearElement?.elementId;if(a){let l=n.find(s=>s.id===a);l&&(i.selectedLinearElement=new j(l))}return{elements:n,appState:i,captureUpdate:A.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t})=>fo("fieldset",{children:[fe("legend",{children:f("labels.arrowtypes")}),fe(Ao,{group:"arrowtypes",options:[{value:Et.sharp,text:f("labels.arrowtype_sharp"),icon:_E,testId:"sharp-arrow"},{value:Et.round,text:f("labels.arrowtype_round"),icon:PE,testId:"round-arrow"},{value:Et.elbow,text:f("labels.arrowtype_elbowed"),icon:DE,testId:"elbow-arrow"}],value:Rt(e,o,r=>ke(r)?r.elbowed?Et.elbow:r.roundness?Et.round:Et.sharp:null,r=>ke(r),r=>r?null:o.currentItemArrowType),onChange:r=>t(r)})]})});import{useEffect as g4}from"react";import{jsx as b4}from"react/jsx-runtime";var Ea=()=>{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},Eh=(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`})},f4=(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();Eh(o,n)},bo=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(g4(()=>()=>Ea().classList.remove("excalidraw-tooltip--visible"),[]),n?null:b4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>f4(i.currentTarget,Ea(),o,t),onPointerLeave:()=>Ea().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import Sd from"open-color";var Ny='<svg viewBox="0 0 24 24" stroke-width="1" width="28" height="28" xmlns="http://www.w3.org/2000/svg">',x4='<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"/>',Oy='<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"/>',E4=`data:${ue.svg},${encodeURIComponent(`${Ny}${Oy}</svg>`)}`,y4=`data:${ue.svg},${encodeURIComponent(`${Ny}${x4}${Oy}</svg>`)}`,xo=e=>{e&&(e.style.cursor="")},Le=(e,o)=>{e&&(e.style.cursor=o)},gr,Ry,yh=(e,o)=>{let r=()=>{let n=o===de.DARK;gr=document.createElement("canvas"),gr.theme=o,gr.height=20,gr.width=20;let i=gr.getContext("2d");i.lineWidth=1,i.beginPath(),i.arc(gr.width/2,gr.height/2,5,0,2*Math.PI),i.fillStyle=n?Sd.black:Sd.white,i.fill(),i.strokeStyle=n?Sd.white:Sd.black,i.stroke(),Ry=gr.toDataURL(ue.svg)};(!gr||gr.theme!==o)&&r(),Le(e,`url(${Ry}) ${20/2} ${20/2}, auto`)},Eo=(e,o)=>{if(e)if(o.activeTool.type==="selection")xo(e);else if(Xo(o))e.style.cursor=Se.GRAB;else if(no(o))yh(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===de.LIGHT?E4:y4;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Se.AUTO):e.style.cursor=Se.CROSSHAIR};var zr=({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 Ad,jsxs as C4}from"react/jsx-runtime";var v4=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})=>Ad(Yl,{palette:null,topPicks:As,label:f("labels.canvasBackground"),type:"canvasBackground",color:o.viewBackgroundColor,onChange:n=>t({viewBackgroundColor:n}),"data-testid":"canvas-background-picker",elements:e,appState:o,updateData:t})}),Fr=z({name:"clearCanvas",label:"labels.clearCanvas",icon:ho,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=>oe(n,{isDeleted:!0})),appState:{...mr(),files:{},theme:o.theme,penMode:o.penMode,penDetected:o.penDetected,exportBackground:o.exportBackground,exportEmbedScene:o.exportEmbedScene,gridSize:o.gridSize,gridStep:o.gridStep,gridModeEnabled:o.gridModeEnabled,stats:o.stats,pasteDialog:o.pasteDialog,activeTool:o.activeTool.type==="image"?{...o.activeTool,type:"selection"}:o.activeTool},captureUpdate:A.IMMEDIATELY})}),kd=z({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:Eu,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...zr({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:dr(o.zoom.value+Li)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Ad(Q,{type:"button",className:"zoom-in-button zoom-button",icon:Eu,title:`${f("buttons.zoomIn")} \u2014 ${R("CtrlOrCmd++")}`,"aria-label":f("buttons.zoomIn"),disabled:o.zoom.value>=mp,onClick:()=>{e(null)}}),keyTest:e=>(e.code===pe.EQUAL||e.code===pe.NUM_ADD)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),Md=z({name:"zoomOut",label:"buttons.zoomOut",icon:yu,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...zr({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:dr(o.zoom.value-Li)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Ad(Q,{type:"button",className:"zoom-out-button zoom-button",icon:yu,title:`${f("buttons.zoomOut")} \u2014 ${R("CtrlOrCmd+-")}`,"aria-label":f("buttons.zoomOut"),disabled:o.zoom.value<=dp,onClick:()=>{e(null)}}),keyTest:e=>(e.code===pe.MINUS||e.code===pe.NUM_SUBTRACT)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),Ld=z({name:"resetZoom",label:"buttons.resetZoom",icon:lx,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...zr({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:dr(1)},o),userToFollow:null},captureUpdate:A.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Ad(bo,{label:f("buttons.resetZoom"),style:{height:"100%"},children:C4(Q,{type:"button",className:"reset-zoom-button zoom-button",title:f("buttons.resetZoom"),"aria-label":f("buttons.resetZoom"),onClick:()=>{e(null)},children:[(o.zoom.value*100).toFixed(0),"%"]})}),keyTest:e=>(e.code===pe.ZERO||e.code===pe.NUM_ZERO)&&(e[T.CTRL_OR_CMD]||e.shiftKey)}),w4=(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)*Tt(t,.1,1);return Math.min(p,1)},By=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=Tt(n,dp,mp);let[l,s,c,m]=e,d=(l+c)/2,p=(s+m)/2,u=t?.left??0,g=t?.top??0,b=t?.right??0,x=t?.bottom??0,E=o.width-u-b,w=o.height-g-x,y;if(r){let S=c-l,_=m-s;y=Math.min(E/S,w/_)*n}else y=w4(e,{width:E,height:w},n);let v=dr(Tt(f1(y,Li,"floor"),i,a)),I=n0({scenePoint:{x:d,y:p},viewportDimensions:{width:o.width,height:o.height},offsets:t,zoom:{value:v}});return{appState:{...o,scrollX:I.scrollX,scrollY:I.scrollY,zoom:{value:v}},captureUpdate:A.EVENTUALLY}},Xl=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=ye(Ee(o));return By({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},Cz=z({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:ad,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Xl({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===pe.TWO&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),Iz=z({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:ad,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return Xl({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===pe.THREE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),T4=z({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:ad,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>Xl({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===pe.ONE&&e.shiftKey&&!e.altKey&&!e[T.CTRL_OR_CMD]}),fi=z({name:"toggleTheme",label:(e,o)=>o.theme===de.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===de.LIGHT?Pl:Rl,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===de.LIGHT?de.DARK:de.LIGHT)},captureUpdate:A.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===pe.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),Sz=z({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o)=>{let t;return no(o)?t=He(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):t=He(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:t},captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.key===T.E}),kz=z({name:"toggleLassoTool",label:"toolBar.lasso",icon:_l,trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=He(o,{type:"lasso",fromSelection:!1}),Le(r.interactiveCanvas,Se.CROSSHAIR)):n=He(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:A.NEVER}}}),zy=z({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:od,viewMode:!1,perform:(e,o,t,r)=>{let n;return Xo(o)?n=He(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=He(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),Le(r.interactiveCanvas,Se.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:A.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[T.CTRL_OR_CMD]&&e.key===T.H});var I4=z({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=He(o,{type:"embeddable"});return Eo(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:He(o,{type:"embeddable"})},captureUpdate:A.EVENTUALLY}}});import{jsx as S4}from"react/jsx-runtime";var yo=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:g}=o.editingLinearElement,b=j.getElement(p,l);if(b)return _r(b)&&ic(b,u,g,l,a),{elements:b.points.length<2||ei(b)?e.filter(x=>x.id!==b.id):void 0,appState:{...o,cursorButton:"up",editingLinearElement:null},captureUpdate:A.IMMEDIATELY}}let s=e,c=o.pendingImageElementId&&a.getElement(o.pendingImageElementId);c&&B(c,{isDeleted:!0},!1),window.document.activeElement instanceof HTMLElement&&i();let m=o.multiElement?o.multiElement:o.newElement?.type==="freedraw"?o.newElement:null;if(m){if(m.type!=="freedraw"&&o.lastPointerDownWith!=="touch"){let{points:u,lastCommittedPoint:g}=m;(!g||u[u.length-1]!==g)&&B(m,{points:m.points.slice(0,-1)})}ei(m)&&(s=s.filter(u=>u.id!==m.id));let p=yl(m.points,o.zoom.value);if((m.type==="line"||m.type==="freedraw")&&p){let u=m.points,g=u[0];B(m,{points:u.map((b,x)=>x===u.length-1?M(g[0],g[1]):b)})}if(_r(m)&&!p&&m.points.length>1){let[u,g]=j.getPointAtIndexGlobalCoordinates(m,-1,ee(e));gl(m,o,{x:u,y:g},l,e)}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!m)&&xo(n);let d;return o.activeTool.type==="eraser"?d=He(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):d=He(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&&ae(m)?new j(m):o.selectedLinearElement,pendingImageElementId:null},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o)=>e.key===T.ESCAPE&&(o.editingLinearElement!==null||!o.newElement&&o.multiElement===null)||(e.key===T.ESCAPE||e.key===T.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>S4(Q,{type:"button",icon:fx,title:f("buttons.done"),"aria-label":f("buttons.done"),onClick:o,visible:e.multiElement!=null,size:t?.size||"medium",style:{pointerEvents:"all"}})});import k4 from"clsx";import{jsx as Fy,jsxs as M4}from"react/jsx-runtime";var $l=({children:e,checked:o,onChange:t,className:r})=>M4("div",{className:k4("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[Fy("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:mx}),Fy("div",{className:"Checkbox-label",children:e})]});import{jsx as jl}from"react/jsx-runtime";var Uy=e=>{let o=e.title||(e.value===de.DARK?f("buttons.lightMode"):f("buttons.darkMode"));return jl(Q,{type:"icon",icon:e.value===de.LIGHT?Hy.MOON:Hy.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===de.DARK?de.LIGHT:de.DARK),"data-testid":"toggle-dark-mode"})},Hy={SUN:jl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:jl("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:jl("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:jl("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 L4}from"react";import{jsx as Gy,jsxs as A4}from"react/jsx-runtime";var Vy=e=>{let{id:o}=gt(),[t,r]=L4(e.value),n=a=>{e.ignoreFocus||k1(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===T.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return A4("div",{className:"ProjectName",children:[Gy("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Gy("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};var qo=32,Ge=12,wn=256,Wy=50,bi="NOT_SPREADSHEET",ya="VALID_SPREADSHEET",ql=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},vh=(e,o)=>e.slice(1).every(t=>ql(t[o])!==null),Yy=e=>{let o=e[0].length;if(o>2)return{type:bi,reason:"More than 2 columns"};if(o===1){if(!vh(e,0))return{type:bi,reason:"Value is not numeric"};let s=ql(e[0][0])===null,c=(s?e.slice(1):e).map(m=>ql(m[0]));return c.length<2?{type:bi,reason:"Less than two rows"}:{type:ya,spreadsheet:{title:s?e[0][0]:null,labels:null,values:c}}}let t=vh(e,0),r=vh(e,1);if(!t&&!r)return{type:bi,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=ql(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:bi,reason:"Less than 2 rows"}:{type:ya,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>ql(s[i]))}}},_4=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},Ky=e=>{let o=e.trim().split(`
1
+ import{$ as s1,A as um,B as jf,C as qf,D as Jf,E as Pl,F as Wi,G as Al,H as Dl,I as Qf,J as e1,K as Vi,L as t1,M as o1,N as r1,O as n1,P as _l,Q as fn,R as i1,S as VI,T as hm,U as XI,V as bn,W as Xi,Y as a1,_ as l1,a as Xf,aa as Rl,b as Nr,ba as c1,c as uo,ca as Nl,d as Kf,da as gm,e as Ee,ea as Bl,f as Zf,fa as d1,g as j,ga as fm,h as kl,ha as ko,i as Ko,ia as m1,j as lm,ja as bm,k as sm,ka as p1,l as un,la as u1,m as cm,ma as Fl,n as hn,na as xm,o as $f,oa as h1,p as dm,pa as g1,q as Zo,qa as f1,r as $o,ra as b1,s as bt,t as jt,u as gn,v as Ml,w as mm,x as Yi,y as Ll,z as pm}from"./chunk-KK52DCS3.js";import{a as T}from"./chunk-A66AFZZU.js";import{J as am}from"./chunk-I4UNSFV6.js";import{c as Vf}from"./chunk-Z3N5DIM6.js";import{b as Yf,c as Wf,d as I}from"./chunk-SRAX5OIU.js";import AG,{useEffect as DG}from"react";import{DEFAULT_UI_OPTIONS as UI,isShallowEqual as _G}from"@excalidraw/common";import wT from"clsx";import uz from"lodash.throttle";import So,{useContext as _r}from"react";import{flushSync as Bi}from"react-dom";import hz from"roughjs/bin/rough";import{nanoid as gz}from"nanoid";import{clamp as vT,pointFrom as ne,pointDistance as nn,vector as TT,pointRotateRads as $g,vectorScale as fz,vectorFromPoint as jg,vectorSubtract as IT,vectorDot as CT,vectorNormalize as ST}from"@excalidraw/math";import{COLOR_PALETTE as bz,CODES as kT,shouldResizeFromCenter as MT,shouldMaintainAspectRatio as dl,shouldRotateWithDiscreteAngle as qg,isArrowKey as Xd,KEYS as Y,APP_NAME as xz,CURSOR_TYPE as De,DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT as Ez,DEFAULT_VERTICAL_ALIGN as LT,DRAGGING_THRESHOLD as yz,ELEMENT_SHIFT_TRANSLATE_AMOUNT as wz,ELEMENT_TRANSLATE_AMOUNT as PT,EVENT as ee,FRAME_STYLE as Mr,IMAGE_MIME_TYPES as vz,IMAGE_RENDER_TIMEOUT as Tz,isBrave as Iz,LINE_CONFIRM_THRESHOLD as Jg,MAX_ALLOWED_FILE_BYTES as AT,MIME_TYPES as Lr,MQ_MAX_HEIGHT_LANDSCAPE as Cz,MQ_MAX_WIDTH_LANDSCAPE as Sz,MQ_MAX_WIDTH_PORTRAIT as kz,MQ_RIGHT_SIDEBAR_MIN_WIDTH as Mz,POINTER_BUTTON as an,ROUNDNESS as Kd,SCROLL_TIMEOUT as Lz,TAP_TWICE_TIMEOUT as Pz,TEXT_TO_CENTER_SNAP_THRESHOLD as Az,THEME as Zd,THEME_FILTER as Dz,TOUCH_CTX_MENU_TIMEOUT as _z,VERTICAL_ALIGN as Rz,YOUTUBE_STATES as $d,ZOOM_STEP as Nz,POINTER_EVENTS as Fi,TOOL_TYPE as Co,isIOS as Bz,supportsResizeObserver as DT,DEFAULT_COLLISION_THRESHOLD as _T,DEFAULT_TEXT_ALIGN as Fz,ARROW_TYPE as Pr,DEFAULT_REDUCED_GLOBAL_ALPHA as Oz,isSafari as zz,isLocalLink as Hz,normalizeLink as Qg,toValidURL as Gz,getGridPoint as nt,getLineHeight as RT,debounce as NT,distance as Oi,getFontString as ef,getNearestScrollableContainer as Uz,isInputLike as BT,isToolIcon as Yz,isWritableElement as ml,sceneCoordsToViewportCoords as jd,tupleToCoors as tf,viewportCoordsToSceneCoords as Fe,wrapEvent as Wz,updateObject as of,updateActiveTool as Vo,getShortcutKey as Vz,isTransparent as Xz,easeToValuesRAF as Kz,muteFSAbortError as Zz,isTestEnv as If,isDevEnv as yI,easeOut as $z,updateStable as pl,addEventListener as _e,normalizeEOL as jz,getDateTime as FT,isShallowEqual as qz,arrayToMap as OT,randomInteger as Jz,CLASSES as Qz,Emitter as ln,MINIMUM_ARROW_SIZE as zT}from"@excalidraw/common";import{getObservedAppState as eH,getCommonBounds as zi,maybeSuggestBindingsForLinearElementAtCoords as HT,getElementAbsoluteCoords as GT,bindOrUnbindLinearElements as UT,fixBindingsAfterDeletion as tH,getHoveredElementForBinding as rf,isBindingEnabled as nf,shouldEnableBindingForPointerEvent as oH,updateBoundElements as af,getSuggestedBindingsForArrows as lf,LinearElementEditor as Se,newElementWith as sn,newFrameElement as rH,newFreeDrawElement as nH,newEmbeddableElement as YT,newMagicFrameElement as WT,newIframeElement as iH,newArrowElement as aH,newElement as lH,newImageElement as sH,newLinearElement as cH,newTextElement as VT,refreshTextDimensions as dH,deepCopyElement as XT,duplicateElements as KT,hasBoundTextElement as ZT,isArrowElement as sf,isBindingElement as cf,isBindingElementType as $T,isBoundToContainer as df,isFrameLikeElement as Kt,isImageElement as cn,isEmbeddableElement as Ar,isInitializedImageElement as ul,isLinearElement as Zt,isLinearElementType as mH,isUsingAdaptiveRadius as pH,isIframeElement as Hi,isIframeLikeElement as hl,isMagicFrameElement as mf,isTextBindableContainer as jT,isElbowArrow as We,isFlowchartNodeElement as uH,isBindableElement as hH,isTextElement as co,getLockedLinearCursorAlignSize as qT,getNormalizedDimensions as gH,isElementCompletelyInViewport as pf,isElementInViewport as JT,isInvisiblySmallElement as QT,getCornerRadius as fH,isPathALoop as eI,createSrcDoc as tI,embeddableURLValidator as uf,maybeParseEmbedSrc as bH,getEmbedLink as qd,getInitializedImageElements as xH,normalizeSVG as oI,updateImageCache as EH,getBoundTextElement as hf,getContainerCenter as gf,getContainerElement as rI,isValidTextContainer as yH,redrawTextBoundingBox as wH,shouldShowBoundingBox as vH,getFrameChildren as nI,isCursorInFrame as iI,addElementsToFrame as ff,replaceAllElementsInFrame as TH,removeElementsFromFrame as IH,getElementsInResizingFrame as bf,getElementsInNewFrame as CH,getContainingFrame as xf,elementOverlapsWithFrame as SH,updateFrameMembershipOfSelectedElements as aI,isElementInFrame as lI,getFrameLikeTitle as kH,getElementsOverlappingFrame as MH,filterElementsEligibleAsFrameChildren as LH,hitElementBoundText as PH,hitElementBoundingBoxOnly as AH,hitElementItself as gl,getVisibleSceneBounds as DH,FlowChartCreator as _H,FlowChartNavigator as RH,getLinkDirectionFromKey as sI,cropElement as NH,wrapText as BH,isElementLink as Ef,parseElementLinkFromURL as FH,isMeasureTextSupported as OH,normalizeText as zH,measureText as cI,getLineHeightInPx as HH,getApproxMinLineWidth as GH,getApproxMinLineHeight as UH,getMinTextElementWidth as YH,ShapeCache as fl,getRenderOpacity as WH,editGroupForSelectedElement as VH,getElementsInGroup as bl,getSelectedGroupIdForElement as XH,getSelectedGroupIds as KH,isElementInGroup as dI,isSelectedViaGroup as ZH,selectGroupsForSelectedElements as mo,syncInvalidIndices as wI,syncMovedIndices as mI,excludeElementsInFramesFromSelection as $H,getSelectionStateForElements as jH,makeNextSelectedElementIds as ye,getResizeOffsetXY as qH,getResizeArrowDirection as JH,transformElements as QH,getCursorForResizingElement as pI,getElementWithTransformHandleType as uI,getTransformHandleTypeFromCoords as hI,dragNewElement as gI,dragSelectedElements as eG,getDragOffsetXY as tG,isNonDeletedElement as fI,Scene as bI,Store as oG,CaptureUpdateAction as mt,hitElementBoundingBox as rG,isLineElement as yf,isSimpleArrow as nG}from"@excalidraw/element";import{KEYS as Wm,updateActiveTool as aC}from"@excalidraw/common";import{getNonDeletedElements as Vm}from"@excalidraw/element";import{fixBindingsAfterDeletion as lC}from"@excalidraw/element";import{LinearElementEditor as db}from"@excalidraw/element";import{newElementWith as ms}from"@excalidraw/element";import{getContainerElement as mb}from"@excalidraw/element";import{isBoundToContainer as cs,isElbowArrow as sC,isFrameLikeElement as cC}from"@excalidraw/element";import{getFrameChildren as dC}from"@excalidraw/element";import{getElementsInGroup as Xm,selectGroupsForSelectedElements as mC}from"@excalidraw/element";import{CaptureUpdateAction as ds}from"@excalidraw/element";import{isDevEnv as jI}from"@excalidraw/common";import{atom as me,createStore as KI}from"jotai";import{createIsolation as ZI}from"jotai-scope";var x1=ZI();var{useAtom:ie,useSetAtom:jo,useAtomValue:Ol,useStore:zG}=x1,E1=x1.Provider,ze=KI();var $I=Yf({"./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 qI=85,ho={code:"en",label:"English"},En=[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=>Vf[e.code]>=qI).sort((e,o)=>e.label>o.label?1:-1)],Hl="__test__";jI()&&En.unshift({code:Hl,label:"test language"},{code:`${Hl}.rtl`,label:"\u202Atest language (rtl)\u202C",rtl:!0});var xn=ho,zl={},Gl=async e=>{if(xn=e,document.documentElement.dir=xn.rtl?"rtl":"ltr",document.documentElement.lang=xn.code,e.code.startsWith(Hl))zl={};else try{zl=await $I(`./locales/${xn.code}.json`)}catch(o){console.error(`Failed to load language ${e.code}:`,o.message),zl=am}ze.set(w1,e.code)},Mo=()=>xn,y1=(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(xn.code.startsWith(Hl))return`\u202A[[${o?`${e}(${JSON.stringify(o).slice(1,-1)})`:e}]]\u202C`;let r=e.split("."),n=y1(zl,r)||y1(am,r)||t;if(n===void 0){let i=`Can't find translation for ${e}`;if(T.PROD)return console.warn(i),"";throw new Error(i)}if(o)for(let i in o)n=n.replace(`{{${i}}}`,String(o[i]));return n},w1=me(ho.code),Oe=()=>{let e=Ol(w1);return{t:g,langCode:e}};import JI from"clsx";import QI from"open-color";import et from"react";import{THEME as eC}from"@excalidraw/common";import{Fragment as be,jsx as h,jsxs as D}from"react/jsx-runtime";var qt=e=>"var(--icon-fill-color)",v1=e=>e===eC.LIGHT?QI.white:"#1e1e1e",M=(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:JI({"rtl-mirror":n}),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"},tU=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),yn=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),T1=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),I1=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),C1=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),Em=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),Br=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),wn=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),S1=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}),k1=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"}),M1=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"}),L1=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"}),oU=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"}),P1=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}),Ki=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),A1=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),D1=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),qo=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),vn=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),_1=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),R1=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),ym=M(h("path",{strokeWidth:"1.25",d:"M10 4.167v11.666M4.167 10h11.666"}),te),wm=M(h("path",{d:"M5 10h10",strokeWidth:"1.25"}),te),N1=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),Mt=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),vm=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),Zi=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),$i=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),ji=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),Fr=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),Tn=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),B1=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),Tm=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),F1=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),O1=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),z1=M(h("polyline",{fill:"none",stroke:"currentColor",points:"20 6 9 17 4 12"}),{width:24,height:24}),qi=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),H1=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}),G1=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}),In=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),rU=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}),U1=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),Y1=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),W1=M("M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z",{width:512,height:512}),nU=M("M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z",{width:448,height:512}),iU=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}),V1=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"),aU=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"),Im=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),Cm=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),X1=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}),K1=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),lU=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"),sU=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}),cU=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),dU=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}),mU=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}),Z1=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"})]}),$1=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"})]}),Sm=M($1,z),km=M($1,{...z,style:{transform:"rotate(180deg)"}}),Mm=M(Z1,z),Lm=M(Z1,{...z,style:{transform:"rotate(180deg)"}}),Pm=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),Am=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),Dm=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),_m=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),j1=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),q1=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),Rm=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),Nm=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),pU=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"),uU=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"),Bt=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),hU=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}),gU=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}),fU=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}),Bm=et.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:qt(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:qt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:qt(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:qt(e),strokeWidth:"2"}),D("g",{fill:v1(e),stroke:qt(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})),Fm=et.memo(({theme:e})=>M(D(be,{children:[h("path",{d:"M25 26H111V111H25",fill:qt(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:qt(e),strokeWidth:"2"}),h("path",{d:"M100 100H160V160H100",fill:qt(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:qt(e),strokeWidth:"2"}),D("g",{fill:v1(e),stroke:qt(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})),J1=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),Q1=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),e0=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),t0=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"}),Om=M(h(be,{children:h("path",{d:"M4.167 10h11.666",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"})}),te),o0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"}),te),r0=M(h("path",{d:"M5 10h10",stroke:"currentColor",strokeWidth:"3.75",strokeLinecap:"round",strokeLinejoin:"round"}),te),bU=et.memo(({theme:e})=>M(h("path",{d:"M6 10H34",stroke:qt(e),strokeWidth:2,fill:"none",strokeLinecap:"round"}),{width:40,height:20})),n0=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),i0=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),a0=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),l0=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),s0=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),c0=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),d0=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),m0=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),p0=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})),u0=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})),h0=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})),g0=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})),f0=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})),b0=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})),x0=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})),E0=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})),y0=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})),w0=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})),v0=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})),T0=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),I0=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),C0=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),S0=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),Or=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),k0=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),Ji=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),M0=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),L0=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),P0=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),A0=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)),D0=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)),_0=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),R0=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}),xU=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),zm=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),Cn=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),N0=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),B0=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),EU=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M7 4v16l13 -8z"})]}),z),yU=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),F0=M(D(be,{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M5 12l5 5l10 -10"})]}),z),O0=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),z0=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),H0=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),zr=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"})),Sn=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),Qi=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),wU=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),vU=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),G0=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),kn=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),U0=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),Y0=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),W0=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),Lt=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),V0=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),X0=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),K0=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),ea=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),Z0=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),$0=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),j0=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),q0=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),Hm=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),J0=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),Q0=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),eb=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),tb=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),ob=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}),TU=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),rb=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),nb=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),ib=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),rs=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),ns=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),ab=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),lb=M(D("g",{children:[h("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),h("path",{d:"M6 15l6 -6l6 6"})]}),z),Gm=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 sb from"clsx";import Ym,{useEffect as rC,useRef as cb,useState as nC}from"react";import{isPromiseLike as iC}from"@excalidraw/common";import tC from"react";import{jsx as Um}from"react/jsx-runtime";var oC=({size:e="1em",circleWidth:o=8,synchronized:t=!1,className:r=""})=>{let i=-(tC.useRef(Date.now()).current%1600);return Um("div",{className:`Spinner ${r}`,children:Um("svg",{viewBox:"0 0 100 100",style:{width:e,height:e,"--spinner-delay":t?`${i}ms`:0},children:Um("circle",{cx:"50",cy:"50",r:50-o/2,strokeWidth:o,fill:"none",strokeMiterlimit:"10"})})})},tt=oC;import{jsx as ta,jsxs as oa}from"react/jsx-runtime";var K=Ym.forwardRef(({size:e="medium",visible:o=!0,className:t="",...r},n)=>{let{id:i}=He(),a=Ym.useRef(null);Ym.useImperativeHandle(n,()=>a.current);let l=`ToolIcon_size_${e}`,[s,d]=nC(!1),m=cb(!0),c=async u=>{let f="onClick"in r&&r.onClick?.(u);if(iC(f))try{d(!0),await f}catch(b){if(b instanceof hn)console.warn(b);else throw b}finally{m.current&&d(!1)}};rC(()=>(m.current=!0,()=>{m.current=!1}),[]);let p=cb(null);if(r.type==="button"||r.type==="icon"||r.type==="submit"){let u=r.type==="icon"?"button":r.type;return oa("button",{className:sb("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:c,ref:a,disabled:s||r.isLoading||!!r.disabled,children:[(r.icon||r.label)&&oa("div",{className:"ToolIcon__icon","aria-hidden":"true","aria-disabled":!!r.disabled,children:[r.icon||r.label,r.keyBindingLabel&&ta("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel}),r.isLoading&&ta(tt,{})]}),r.showAriaLabel&&oa("div",{className:"ToolIcon__label",children:[r["aria-label"]," ",s&&ta(tt,{})]}),r.children]})}return oa("label",{className:sb("ToolIcon",t),title:r.title,onPointerDown:u=>{p.current=u.pointerType||null,r.onPointerDown?.({pointerType:u.pointerType||null})},onPointerUp:()=>{requestAnimationFrame(()=>{p.current=null})},children:[ta("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}),oa("div",{className:"ToolIcon__icon",children:[r.icon,r.keyBindingLabel&&ta("span",{className:"ToolIcon__keybinding",children:r.keyBindingLabel})]})]})});K.displayName="ToolButton";var ss=[],B=e=>(ss=ss.concat(e),e);import{jsx as uC}from"react/jsx-runtime";var pC=(e,o,t)=>{let r=new Set(j(e.filter(m=>cC(m)),o).map(m=>m.id)),n={},i=t.scene.getNonDeletedElementsMap(),a=new Set;for(let m of r){let c=dC(e,m);for(let p of c)if(!a.has(p.id)){if(cs(p)){let u=mb(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 c=cs(m)?mb(m,i):null;return m.frameId&&r.has(m.frameId)?(l=!1,n[m.id]=!0,m):c?.frameId&&r.has(c?.frameId)?m:(m.boundElements&&m.boundElements.forEach(p=>{let u=t.scene.getNonDeletedElementsMap().get(p.id);u&&sC(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&&r.has(m.frameId)?(l=!1,cs(m)||(n[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=Xm(s,o.editingGroupId).filter(c=>!c.isDeleted);if(m.length>1)m[0]&&(n[m[0].id]=!0);else{d=null,m[0]&&(n[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=Xm(s,u).filter(b=>!b.isDeleted);f.length>1&&(d=u,f.forEach(b=>{n[b.id]=!0}))}}}}return{elements:s,appState:{...o,...mC({selectedElementIds:n,editingGroupId:d},s,o,null)}}},pb=(e,o)=>{if(e.editingGroupId){let t=Xm(Vm(o),e.editingGroupId);if(t.length)return{...e,selectedElementIds:{[t[0].id]:!0}}}return e},ra=B({name:"deleteSelectedElements",label:"labels.delete",icon:Mt,trackEvent:{category:"element",action:"delete"},perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing){let{elementId:a,selectedPointsIndices:l,startBindingElement:s,endBindingElement:d}=o.selectedLinearElement,m=r.scene.getNonDeletedElementsMap(),c=db.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=pb(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 db.deletePoints(c,r,l),{elements:e,appState:{...o,selectedLinearElement:{...o.selectedLinearElement,...p,selectedPointsIndices:l?.[0]>0?[l[0]-1]:[0]}},captureUpdate:ds.IMMEDIATELY}}let{elements:n,appState:i}=pC(e,o,r);return lC(n,n.filter(a=>a.isDeleted)),i=pb(i,n),{elements:n,appState:{...i,activeTool:aC(o,{type:"selection"}),multiElement:null,activeEmbeddable:null,selectedLinearElement:null},captureUpdate:Ee(Vm(e),o)?ds.IMMEDIATELY:ds.EVENTUALLY}},keyTest:(e,o,t)=>(e.key===Wm.BACKSPACE||e.key===Wm.DELETE)&&!e[Wm.CTRL_OR_CMD],PanelComponent:({elements:e,appState:o,updateData:t})=>uC(K,{type:"button",icon:Mt,title:g("labels.delete"),"aria-label":g("labels.delete"),onClick:()=>t(null),visible:Ee(Vm(e),o)})});import{KEYS as Mn,CODES as Ln,getShortcutKey as Pn,isDarwin as ps}from"@excalidraw/common";import{moveOneLeft as hC,moveOneRight as gC,moveAllLeft as fC,moveAllRight as bC}from"@excalidraw/element";import{CaptureUpdateAction as us}from"@excalidraw/element";import{jsx as hs}from"react/jsx-runtime";var Km=B({name:"sendBackward",label:"labels.sendBackward",keywords:["move down","zindex","layer"],icon:km,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:hC(e,o,r.scene),appState:o,captureUpdate:us.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Mn.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ln.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendBackward")} \u2014 ${Pn("CtrlOrCmd+[")}`,children:km})}),Zm=B({name:"bringForward",label:"labels.bringForward",keywords:["move up","zindex","layer"],icon:Sm,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:gC(e,o,r.scene),appState:o,captureUpdate:us.IMMEDIATELY}),keyPriority:40,keyTest:e=>e[Mn.CTRL_OR_CMD]&&!e.shiftKey&&e.code===Ln.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.bringForward")} \u2014 ${Pn("CtrlOrCmd+]")}`,children:Sm})}),$m=B({name:"sendToBack",label:"labels.sendToBack",keywords:["move down","zindex","layer"],icon:Lm,trackEvent:{category:"element"},perform:(e,o)=>({elements:fC(e,o),appState:o,captureUpdate:us.IMMEDIATELY}),keyTest:e=>ps?e[Mn.CTRL_OR_CMD]&&e.altKey&&e.code===Ln.BRACKET_LEFT:e[Mn.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ln.BRACKET_LEFT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:()=>e(null),title:`${g("labels.sendToBack")} \u2014 ${ps?Pn("CtrlOrCmd+Alt+["):Pn("CtrlOrCmd+Shift+[")}`,children:Lm})}),jm=B({name:"bringToFront",label:"labels.bringToFront",keywords:["move up","zindex","layer"],icon:Mm,trackEvent:{category:"element"},perform:(e,o)=>({elements:bC(e,o),appState:o,captureUpdate:us.IMMEDIATELY}),keyTest:e=>ps?e[Mn.CTRL_OR_CMD]&&e.altKey&&e.code===Ln.BRACKET_RIGHT:e[Mn.CTRL_OR_CMD]&&e.shiftKey&&e.code===Ln.BRACKET_RIGHT,PanelComponent:({updateData:e,appState:o})=>hs("button",{type:"button",className:"zIndexButton",onClick:t=>e(null),title:`${g("labels.bringToFront")} \u2014 ${ps?Pn("CtrlOrCmd+Alt+]"):Pn("CtrlOrCmd+Shift+]")}`,children:Mm})});import{getNonDeletedElements as xC}from"@excalidraw/element";import{LinearElementEditor as EC}from"@excalidraw/element";import{isLinearElement as yC,isTextElement as wC}from"@excalidraw/element";import{arrayToMap as vC,KEYS as ub}from"@excalidraw/common";import{selectGroupsForSelectedElements as TC}from"@excalidraw/element";import{CaptureUpdateAction as IC}from"@excalidraw/element";var qm=B({name:"selectAll",label:"labels.selectAll",icon:Z0,trackEvent:{category:"canvas"},viewMode:!1,perform:(e,o,t,r)=>{if(o.selectedLinearElement?.isEditing)return!1;let n=e.filter(i=>!i.isDeleted&&!(wC(i)&&i.containerId)&&!i.locked).reduce((i,a)=>(i[a.id]=!0,i),{});return{appState:{...o,...TC({editingGroupId:null,selectedElementIds:n},xC(e),o,r),selectedLinearElement:Object.keys(n).length===1&&yC(e[0])?new EC(e[0],vC(e)):null},captureUpdate:IC.IMMEDIATELY}},keyTest:e=>e[ub.CTRL_OR_CMD]&&e.key===ub.A});import{DEFAULT_GRID_SIZE as hb,KEYS as gb,arrayToMap as fb,getShortcutKey as CC}from"@excalidraw/common";import{getNonDeletedElements as bb}from"@excalidraw/element";import{LinearElementEditor as SC}from"@excalidraw/element";import{getSelectedElements as kC,getSelectionStateForElements as MC}from"@excalidraw/element";import{syncMovedIndices as LC}from"@excalidraw/element";import{duplicateElements as PC}from"@excalidraw/element";import{CaptureUpdateAction as xb}from"@excalidraw/element";import{jsx as AC}from"react/jsx-runtime";var Jm=B({name:"duplicateSelection",label:"labels.duplicateSelection",icon:Zi,trackEvent:{category:"element"},perform:(e,o,t,r)=>{if(o.selectedElementsAreBeingDragged)return!1;if(o.selectedLinearElement?.isEditing)try{let a=SC.duplicateSelectedPoints(o,r.scene);return{elements:e,appState:a,captureUpdate:xb.IMMEDIATELY}}catch{return!1}let{duplicatedElements:n,elementsWithDuplicates:i}=PC({type:"in-place",elements:e,idsOfElementsToDuplicate:fb(kC(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+hb/2,y:a.y+hb/2,frameId:s??a.frameId}}});if(r.props.onDuplicate&&i){let a=r.props.onDuplicate(i,e);a&&(i=a)}return{elements:LC(i,fb(n)),appState:{...o,...MC(n,bb(i),o)},captureUpdate:xb.IMMEDIATELY}},keyTest:e=>e[gb.CTRL_OR_CMD]&&e.key===gb.D,PanelComponent:({elements:e,appState:o,updateData:t})=>AC(K,{type:"button",icon:Zi,title:`${g("labels.duplicateSelection")} \u2014 ${CC("CtrlOrCmd+D")}`,"aria-label":g("labels.duplicateSelection"),onClick:()=>t(null),visible:Ee(bb(e),o)})});import{pointFrom as D6}from"@excalidraw/math";import{useEffect as yp,useMemo as _6,useRef as wp,useState as R6}from"react";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_PALETTE as N6,DEFAULT_ELEMENT_BACKGROUND_PICKS as B6,DEFAULT_ELEMENT_STROKE_COLOR_PALETTE as F6,DEFAULT_ELEMENT_STROKE_PICKS as O6,ARROW_TYPE as Po,DEFAULT_FONT_FAMILY as z6,DEFAULT_FONT_SIZE as H6,FONT_FAMILY as G6,ROUNDNESS as As,STROKE_WIDTH as vp,VERTICAL_ALIGN as Ps,KEYS as Gn,randomInteger as U6,arrayToMap as Cp,getFontFamilyString as Y6,getShortcutKey as W6,getLineHeight as V6,isTransparent as X6,reduceToCommonValue as K6}from"@excalidraw/common";import{canBecomePolygon as Z6,getNonDeletedElements as ix}from"@excalidraw/element";import{bindLinearElement as tx,calculateFixedPointForElbowArrowBinding as ox,updateBoundElements as $6}from"@excalidraw/element";import{LinearElementEditor as Tp}from"@excalidraw/element";import{newElementWith as Ke}from"@excalidraw/element";import{getBoundTextElement as ir,redrawTextBoundingBox as ua}from"@excalidraw/element";import{isArrowElement as Ds,isBoundToContainer as j6,isElbowArrow as ax,isLinearElement as Ip,isLineElement as rx,isTextElement as xt,isUsingAdaptiveRadius as q6}from"@excalidraw/element";import{hasStrokeColor as J6}from"@excalidraw/element";import{updateElbowArrowPoints as Q6,CaptureUpdateAction as Ze,toggleLinePolygonState as e4}from"@excalidraw/element";import{isDevEnv as DC}from"@excalidraw/common";var _C=new Set(["command_palette","export"]),re=(e,o,t,r)=>{try{if(typeof window>"u"||T.VITE_WORKER_ID||T.VITE_APP_ENABLE_TRACKING!=="true"||!_C.has(e)||DC())return;T.PROD||console.info("trackEvent",{category:e,action:o,label:t,value:r}),window.sa_event&&window.sa_event(o,{category:e,label:t,value:r})}catch(n){console.error("error during analytics",n)}};import FC from"clsx";import RC from"clsx";import{forwardRef as NC}from"react";import{jsx as BC}from"react/jsx-runtime";var An=NC((e,o)=>{let{title:t,className:r,testId:n,active:i,standalone:a,icon:l,onClick:s}=e;return BC("button",{type:"button",ref:o,title:t,"data-testid":n,className:RC(r,{standalone:a,active:i}),onClick:s,style:e.style,children:l},t)});import{Fragment as zC,jsx as Qm,jsxs as OC}from"react/jsx-runtime";var Ft=e=>Qm(zC,{children:e.options.map(o=>e.type==="button"?Qm(An,{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):OC("label",{className:FC({active:e.value===o.value}),title:o.text,children:[Qm("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 OS from"clsx";import{useRef as zS}from"react";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as HS,COLOR_PALETTE as Fb,isTransparent as GS}from"@excalidraw/common";import{jsx as HC}from"react/jsx-runtime";var gs=()=>HC("div",{style:{width:1,height:"1rem",backgroundColor:"var(--default-border-color)",margin:"0 auto"}});import{useEffect as VC,useRef as XC}from"react";import{createPortal as KC}from"react-dom";import{EVENT as Qo,KEYS as ZC,rgbToHex as $C}from"@excalidraw/common";import Eb from"react";var ep=Eb.createContext(null),ge=()=>Eb.useContext(ep);import{useState as GC,useLayoutEffect as yb}from"react";import{THEME as UC}from"@excalidraw/common";var fs=e=>{let[o,t]=GC(null),r=se(),{theme:n}=ge(),{container:i}=He();return yb(()=>{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===UC.DARK))},[o,n,r.editor.isMobile,e?.className]),yb(()=>{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 YC}from"react";import{EVENT as bs}from"@excalidraw/common";function Dn(e,o,t){YC(()=>{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(bs.POINTER_DOWN,r),document.addEventListener(bs.TOUCH_START,r),()=>{document.removeEventListener(bs.POINTER_DOWN,r),document.removeEventListener(bs.TOUCH_START,r)}},[e,o,t])}import{useRef as WC}from"react";var Jo=e=>{let o=WC(e);return Object.assign(o.current,e),o.current};import{jsx as jC}from"react/jsx-runtime";var er=me(null),wb=({onCancel:e,onChange:o,onSelect:t,colorPickerType:r})=>{let n=fs({className:"excalidraw-eye-dropper-backdrop",parentSelector:".excalidraw-eye-dropper-container"}),i=ge(),a=tr(),l=Re(),s=j(a,i),d=Jo({app:l,onCancel:e,onChange:o,onSelect:t,selectedElements:s}),{container:m}=He();VC(()=>{let p=c.current;if(!p||!l.canvas||!n)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 $C(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(r,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===ZC.ESCAPE&&(S.preventDefault(),S.stopImmediatePropagation(),w())};return n.tabIndex=-1,n.focus(),x({clientX:d.app.lastViewportPosition.x,clientY:d.app.lastViewportPosition.y,altKey:!1}),n.addEventListener(Qo.KEYDOWN,C),n.addEventListener(Qo.POINTER_DOWN,y),n.addEventListener(Qo.POINTER_UP,v),window.addEventListener("pointermove",x,{passive:!0}),window.addEventListener(Qo.BLUR,w),()=>{u=!1,n.removeEventListener(Qo.KEYDOWN,C),n.removeEventListener(Qo.POINTER_DOWN,y),n.removeEventListener(Qo.POINTER_UP,v),window.removeEventListener("pointermove",x),window.removeEventListener(Qo.BLUR,w)}},[d,l.canvas,n,r,m,i.offsetLeft,i.offsetTop]);let c=XC(null);return Dn(c,()=>{e()},p=>!!p.target.closest(".excalidraw-eye-dropper-trigger, .excalidraw-eye-dropper-backdrop")),n?KC(jC("div",{ref:c,className:"excalidraw-eye-dropper-preview"}),n):null};import*as _n from"@radix-ui/react-popover";import eS from"clsx";import tS from"react";import{isInteractive as oS}from"@excalidraw/common";import qC from"react";import JC from"clsx";import{jsx as QC}from"react/jsx-runtime";var Xe=qC.forwardRef(({children:e,padding:o,className:t,style:r},n)=>QC("div",{className:JC("Island",t),style:{"--padding":o,...r},ref:n,children:e}));import{jsx as tp,jsxs as rS}from"react/jsx-runtime";var xs=tS.forwardRef(({className:e,container:o,children:t,style:r,onClose:n,onKeyDown:i,onFocusOutside:a,onPointerLeave:l,onPointerDownOutside:s},d)=>{let m=se();return tp(_n.Portal,{container:o,children:rS(_n.Content,{ref:d,className:eS("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&&!oS(document.activeElement)&&o.focus(),n()},children:[tp(Xe,{padding:3,style:r,children:t}),tp(_n.Arrow,{width:20,height:10,style:{fill:"var(--popup-bg-color)",filter:"drop-shadow(rgba(0, 0, 0, 0.05) 0px 3px 2px)"}})]})})});import iS from"clsx";import{useCallback as aS,useEffect as rp,useRef as Ib,useState as lS}from"react";import{KEYS as np,getShortcutKey as sS}from"@excalidraw/common";import{MAX_CUSTOM_COLORS_USED_IN_CANVAS as nS}from"@excalidraw/common";var or=({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},na=[["q","w","e","r","t"],["a","s","d","f","g"],["z","x","c","v","b"]].flat(),op=({color:e,palette:o})=>!Object.values(o).flat().includes(e),Tb=(e,o,t)=>{let r={elementBackground:"backgroundColor",elementStroke:"strokeColor"},n=e.filter(a=>{if(a.isDeleted)return!1;let l=a[r[o]];return op({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,nS)},Ot=me(null),vb=(e,o,t)=>(e*299+o*587+t*114)/1e3,Rn=(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 vb(s,d,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 vb(t,r,n)<o};import{Fragment as cS,jsx as Es,jsxs as Cb}from"react/jsx-runtime";var Sb=({color:e,onChange:o,label:t,colorPickerType:r,placeholder:n})=>{let i=se(),[a,l]=lS(e),[s,d]=ie(Ot);rp(()=>{l(e)},[e]);let m=aS(b=>{let x=b.toLowerCase(),w=kb(x);w&&o(w),l(x)},[o]),c=Ib(null),p=Ib(null);rp(()=>{c.current&&c.current.focus()},[s]);let[u,f]=ie(er);return rp(()=>()=>{f(null)},[f]),Cb("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!==np.TAB&&(b.key===np.ESCAPE&&p.current?.focus(),b.stopPropagation())},placeholder:n}),!i.editor.isMobile&&Cb(cS,{children:[Es("div",{style:{width:"1px",height:"1.25rem",backgroundColor:"var(--default-border-color)"}}),Es("div",{ref:p,className:iS("excalidraw-eye-dropper-trigger",{selected:u}),onClick:()=>f(b=>b?null:{keepOpenOnAlt:!1,onSelect:x=>o(x),colorPickerType:r}),title:`${g("labels.eyeDropper")} \u2014 ${np.I.toLocaleUpperCase()} or ${sS("Alt")} `,children:z0})]})]})};import sp,{useEffect as cp,useImperativeHandle as MS,useState as LS}from"react";import{EVENT as _b}from"@excalidraw/common";import{DEFAULT_ELEMENT_BACKGROUND_COLOR_INDEX as PS,DEFAULT_ELEMENT_STROKE_COLOR_INDEX as AS,KEYS as DS}from"@excalidraw/common";import pS from"clsx";import{useEffect as uS,useRef as hS}from"react";import{jsxs as mS}from"react/jsx-runtime";var dS=({color:e,keyLabel:o,isShade:t=!1})=>mS("div",{className:"color-picker__button__hotkey-label",style:{color:Rn(e)?"#fff":"#000"},children:[t&&"\u21E7",o]}),Nn=dS;import{jsx as ip,jsxs as gS}from"react/jsx-runtime";var Mb=({colors:e,color:o,onChange:t,label:r})=>{let[n,i]=ie(Ot),a=hS(null);return uS(()=>{a.current&&a.current.focus()},[o,n]),ip("div",{className:"color-picker-content--default",children:e.map((l,s)=>gS("button",{ref:o===l?a:void 0,tabIndex:-1,type:"button",className:pS("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:[ip("div",{className:"color-picker__button-outline"}),ip(Nn,{color:l,keyLabel:s+1})]},s))})};import fS from"clsx";import{useEffect as bS,useRef as xS}from"react";import{jsx as ap,jsxs as yS}from"react/jsx-runtime";var ES=({palette:e,color:o,onChange:t,activeShade:r})=>{let n=or({color:o,palette:e}),[i,a]=ie(Ot),l=xS(null);return bS(()=>{l.current&&i==="baseColors"&&l.current.focus()},[n?.colorName,i]),ap("div",{className:"color-picker-content--default",children:Object.entries(e).map(([s,d],m)=>{let c=(Array.isArray(d)?d[r]:d)||"transparent",p=na[m],u=g(`colors.${s.replace(/\d+/,"")}`,null,"");return yS("button",{ref:n?.colorName===s?l:void 0,tabIndex:-1,type:"button",className:fS("color-picker__button color-picker__button--large has-outline",{active:n?.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:[ap("div",{className:"color-picker__button-outline"}),ap(Nn,{color:c,keyLabel:p})]},s)})})},Lb=ES;import{jsx as vS}from"react/jsx-runtime";var wS=({children:e})=>vS("div",{className:"color-picker__heading",children:e}),Bn=wS;import TS from"clsx";import{useEffect as IS,useRef as CS}from"react";import{jsx as ia,jsxs as Pb}from"react/jsx-runtime";var Ab=({color:e,onChange:o,palette:t})=>{let r=or({color:e||"transparent",palette:t}),[n,i]=ie(Ot),a=CS(null);if(IS(()=>{a.current&&n==="shades"&&a.current.focus()},[r,n]),r){let{colorName:l,shade:s}=r,d=t[l];if(Array.isArray(d))return ia("div",{className:"color-picker-content--default shades",children:d.map((m,c)=>Pb("button",{ref:c===s&&n==="shades"?a:void 0,tabIndex:-1,type:"button",className:TS("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:[ia("div",{className:"color-picker__button-outline"}),ia(Nn,{color:m,keyLabel:c+1,isShade:!0})]},c))})}return Pb("div",{className:"color-picker-content--default",style:{position:"relative"},tabIndex:-1,children:[ia("button",{type:"button",tabIndex:-1,className:"color-picker__button color-picker__button--large color-picker__button--no-focus-visible"}),ia("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 Fn,COLOR_PALETTE as SS,KEYS as aa}from"@excalidraw/common";var lp=(e,o,t)=>{let r=Math.ceil(t/Fn);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+Fn;return n>=t?o%Fn:n}case"ArrowUp":{let n=o-Fn,i=n<0?Fn*r+n:n;return i>=t?void 0:i}}},kS=({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(na.includes(e.key)){let l=na.indexOf(e.key),s=Object.keys(r)[l],d=r[s],m=Array.isArray(d)?d[a]:d;return t(m),i("baseColors"),!0}return!1},Db=({event:e,activeColorPickerSection:o,palette:t,color:r,onChange:n,customColors:i,setActiveColorPickerSection:a,updateData:l,activeShade:s,onEyeDropperToggle:d,onEscape:m})=>{if(e[aa.CTRL_OR_CMD])return!1;if(e.key===aa.ESCAPE)return m(e),!0;if(e.key===aa.ALT)return d(!0),!0;if(e.key===aa.I)return d(),!0;let c=or({color:r,palette:t});if(e.key===aa.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"?n(i[0]):w==="baseColors"&&(Object.entries(t).find(([y,v])=>Array.isArray(v)?v.includes(r):v===r?y:null)||n(SS.black)),e.preventDefault(),e.stopPropagation(),!0}if(kS({e,colorObj:c,onChange:n,palette:t,customColors:i,setActiveColorPickerSection:a,activeShade:s}))return!0;if(o==="shades"&&c){let{shade:p}=c,u=lp(e.key,p,Fn);if(u!==void 0)return n(t[c.colorName][u]),!0}if(o==="baseColors"&&c){let{colorName:p}=c,u=Object.keys(t),f=u.indexOf(p),b=lp(e.key,f,u.length);if(b!==void 0){let x=u[b],w=t[x];return n(Array.isArray(w)?w[s]:w),!0}}if(o==="custom"){let p=r!=null?i.indexOf(r):0,u=lp(e.key,p,i.length);if(u!==void 0){let f=i[u];return n(f),!0}}return!1};import{jsx as Hr,jsxs as ys}from"react/jsx-runtime";var Rb=sp.forwardRef(({color:e,onChange:o,type:t,elements:r,palette:n,updateData:i,children:a,onEyeDropperToggle:l,onEscape:s},d)=>{let[m]=sp.useState(()=>t==="canvasBackground"?[]:Tb(r,t,n)),[c,p]=ie(Ot),u=or({color:e,palette:n});cp(()=>{if(!c){let w=!!e&&op({color:e,palette:n}),E=w&&!m.includes(e);p(E?null:w?"custom":u?.shade!=null?"shades":"baseColors")}},[c,e,n,p,u,m]);let[f,b]=LS(u?.shade??(t==="elementBackground"?PS:AS));cp(()=>{u?.shade!=null&&b(u.shade);let w=E=>{E.key===DS.ALT&&l(!1)};return document.addEventListener(_b.KEYUP,w,{capture:!0}),()=>{document.removeEventListener(_b.KEYUP,w,{capture:!0})}},[u,l]);let x=sp.useRef(null);return MS(d,()=>x.current),cp(()=>{x?.current?.focus()},[]),Hr("div",{role:"dialog","aria-modal":"true","aria-label":g("labels.colorPicker"),children:ys("div",{ref:x,onKeyDown:w=>{Db({event:w,activeColorPickerSection:c,palette:n,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:[Hr(Bn,{children:g("colorPicker.mostUsedCustomColors")}),Hr(Mb,{colors:m,color:e,label:g("colorPicker.mostUsedCustomColors"),onChange:o})]}),ys("div",{children:[Hr(Bn,{children:g("colorPicker.colors")}),Hr(Lb,{color:e,palette:n,onChange:o,activeShade:f})]}),ys("div",{children:[Hr(Bn,{children:g("colorPicker.shades")}),Hr(Ab,{color:e,onChange:o,palette:n})]}),a]})})});import _S from"clsx";import{COLOR_OUTLINE_CONTRAST_THRESHOLD as RS,DEFAULT_CANVAS_BACKGROUND_PICKS as NS,DEFAULT_ELEMENT_BACKGROUND_PICKS as BS,DEFAULT_ELEMENT_STROKE_PICKS as FS}from"@excalidraw/common";import{jsx as dp}from"react/jsx-runtime";var Nb=({onChange:e,type:o,activeColor:t,topPicks:r})=>{let n;return o==="elementStroke"&&(n=FS),o==="elementBackground"&&(n=BS),o==="canvasBackground"&&(n=NS),r&&(n=r),n?dp("div",{className:"color-picker__top-picks",children:n.map(i=>dp("button",{className:_S("color-picker__button",{active:i===t,"is-transparent":i==="transparent"||!i,"has-outline":!Rn(i,RS)}),style:{"--swatch-color":i},type:"button",title:i,onClick:()=>e(i),"data-testid":`color-top-pick-${i}`,children:dp("div",{className:"color-picker__button-outline"})},i))}):(console.error("Invalid type for TopPicks"),null)};import{jsx as Jt,jsxs as mp}from"react/jsx-runtime";var Bb=e=>{let o=new Option().style;return o.color=e,!!o.color},kb=e=>GS(e)?e:Bb(`#${e}`)?`#${e}`:Bb(e)?e:null,US=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Fb,updateData:a})=>{let{container:l}=He(),[,s]=ie(Ot),[d,m]=ie(er),c=mp("div",{children:[Jt(Bn,{children:g("colorPicker.hexCode")}),Jt(Sb,{color:o||"",label:r,onChange:f=>{t(f)},colorPickerType:e,placeholder:g("colorPicker.color")})]}),p=zS(null),u=()=>{p.current?.focus()};return Jt(xs,{container:l,style:{maxWidth:"13rem"},onFocusOutside:f=>{u(),f.preventDefault()},onPointerDownOutside:f=>{d&&f.preventDefault()},onClose:()=>{a({openPopup:null}),s(null)},children:i?Jt(Rb,{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:n,updateData:a,children:c}):c})},YS=({label:e,color:o,type:t})=>Jt(ws.Trigger,{type:"button",className:OS("color-picker__button active-color properties-trigger",{"is-transparent":!o||o==="transparent","has-outline":!o||!Rn(o,HS)}),"aria-label":e,style:o?{"--swatch-color":o}:void 0,title:t==="elementStroke"?g("labels.showStroke"):g("labels.showBackground"),children:Jt("div",{className:"color-picker__button-outline",children:!o&&Y1})}),la=({type:e,color:o,onChange:t,label:r,elements:n,palette:i=Fb,topPicks:a,updateData:l,appState:s})=>Jt("div",{children:mp("div",{role:"dialog","aria-modal":"true",className:"color-picker-container",children:[Jt(Nb,{activeColor:o,onChange:t,type:e,topPicks:a}),Jt(gs,{}),mp(ws.Root,{open:s.openPopup===e,onOpenChange:d=>{l({openPopup:d?e:null})},children:[Jt(YS,{color:o,label:r,type:e}),s.openPopup===e&&Jt(US,{type:e,color:o,onChange:t,label:r,elements:n,palette:i,updateData:l})]})]})});import*as Kb from"@radix-ui/react-popover";import E6,{useCallback as y6,useMemo as w6}from"react";import{FONT_FAMILY as fp}from"@excalidraw/common";import c6,{useMemo as rr,useState as d6,useRef as m6,useEffect as p6,useCallback as u6}from"react";import{arrayToList as h6,debounce as g6,FONT_FAMILY as Gr,getFontFamilyString as f6}from"@excalidraw/common";import WS from"clsx";import VS from"react";import{jsx as XS,jsxs as KS}from"react/jsx-runtime";var vs=VS.forwardRef(({className:e,placeholder:o,onChange:t},r)=>KS("div",{className:WS("QuickSearch__wrapper",e),children:[Lt,XS("input",{ref:r,className:"QuickSearch__input",type:"text",placeholder:o,onChange:n=>t(n.target.value.trim().toLowerCase())})]}));import ZS from"clsx";import{Children as $S}from"react";import{jsx as Ob}from"react/jsx-runtime";var Ts=({className:e,placeholder:o,children:t})=>{let r=!$S.count(t);return Ob("div",{className:ZS("ScrollableList__wrapper",e),role:"menu",children:r?Ob("div",{className:"empty",children:o}):t})};import{jsx as jS,jsxs as qS}from"react/jsx-runtime";var zb=({children:e,className:o="",style:t,title:r})=>qS("div",{className:`dropdown-menu-group ${o}`,style:t,children:[r&&jS("p",{className:"dropdown-menu-group-title",children:r}),e]}),sa=zb;zb.displayName="DropdownMenuGroup";import{useEffect as a6,useRef as l6}from"react";import{THEME as s6}from"@excalidraw/common";import{jsx as JS}from"react/jsx-runtime";var ca=({children:e,...o})=>JS("span",{...o,style:{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",...o.style},children:e});import{Fragment as e6,jsx as Is,jsxs as t6}from"react/jsx-runtime";var QS=({textStyle:e,icon:o,shortcut:t,children:r})=>{let n=se();return t6(e6,{children:[o&&Is("div",{className:"dropdown-menu-item__icon",children:o}),Is("div",{style:e,className:"dropdown-menu-item__text",children:Is(ca,{children:r})}),t&&!n.editor.isMobile&&Is("div",{className:"dropdown-menu-item__shortcut",children:t})]})},Cs=QS;import o6,{useContext as r6}from"react";import{EVENT as n6,composeEventHandlers as i6}from"@excalidraw/common";var pp=o6.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=r6(pp);return i6(e,r=>{let n=new CustomEvent(n6.MENU_ITEM_SELECT,{bubbles:!0,cancelable:!0});o?.(n),n.defaultPrevented||t.onSelect?.(n)})};import{jsx as up}from"react/jsx-runtime";var hp=({icon:e,value:o,order:t,children:r,shortcut:n,className:i,hovered:a,selected:l,textStyle:s,onSelect:d,onClick:m,...c})=>{let p=ks(m,d),u=l6(null);return a6(()=>{a&&(t===0?u.current?.scrollIntoView({block:"end"}):u.current?.scrollIntoView({block:"nearest"}))},[a,t]),up("button",{...c,ref:u,value:o,onClick:p,className:Ss(i,l,a),title:c.title??c["aria-label"],children:up(Cs,{textStyle:s,icon:e,shortcut:n,children:r})})};hp.displayName="DropdownMenuItem";var On={GREEN:"green",RED:"red",BLUE:"blue"},Ms=({type:e=On.BLUE,children:o})=>{let{theme:t}=go(),r={display:"inline-flex",marginLeft:"auto",padding:"2px 4px",borderRadius:6,fontSize:9,fontFamily:"Cascadia, monospace",border:t===s6.LIGHT?"1.5px solid white":"none"};switch(e){case On.GREEN:Object.assign(r,{backgroundColor:"var(--background-color-badge)",color:"var(--color-badge)"});break;case On.RED:Object.assign(r,{backgroundColor:"pink",color:"darkred"});break;case On.BLUE:default:Object.assign(r,{background:"var(--color-promo)",color:"var(--color-surface-lowest)"})}return up("div",{className:"DropDownMenuItemBadge",style:r,children:o})};Ms.displayName="DropdownMenuItemBadge";hp.Badge=Ms;var pt=hp;import{KEYS as zn}from"@excalidraw/common";var Hb=({event:e,inputRef:o,hoveredFont:t,filteredFonts:r,onClose:n,onSelect:i,onHover:a})=>{if(!e[zn.CTRL_OR_CMD]&&e.shiftKey&&e.key.toLowerCase()===zn.F)return o.current?.focus(),!0;if(e.key===zn.ESCAPE)return n(),!0;if(e.key===zn.ENTER)return t?.value&&i(t.value),!0;if(e.key===zn.ARROW_DOWN)return t?.next?a(t.next.value):r[0]?.value&&a(r[0].value),!0;if(e.key===zn.ARROW_UP)return t?.prev?a(t.prev.value):r[r.length-1]?.value&&a(r[r.length-1].value),!0};import{jsx as da,jsxs as Gb}from"react/jsx-runtime";var b6=e=>{switch(e){case Gr.Excalifont:case Gr.Virgil:return qo;case Gr.Nunito:case Gr.Helvetica:return Ji;case Gr["Lilita One"]:return k0;case Gr["Comic Shanns"]:case Gr.Cascadia:return ql;default:return Ji}},Ub=c6.memo(({selectedFontFamily:e,hoveredFontFamily:o,onSelect:t,onHover:r,onLeave:n,onOpen:i,onClose:a})=>{let{container:l}=He(),{fonts:s}=Re(),{showDeprecatedFonts:d}=fo(),[m,c]=d6(""),p=m6(null),u=rr(()=>Array.from(Zo.registered.entries()).filter(([k,{metadata:A}])=>!A.private&&!A.fallback).map(([k,{metadata:A,fontFaces:P}])=>{let N={value:k,icon:b6(k),text:P[0]?.fontFace?.family??"Unknown"};return A.deprecated&&Object.assign(N,{deprecated:A.deprecated,badge:{type:On.RED,placeholder:g("fontList.badge.old")}}),N}).sort((k,A)=>k.text.toLowerCase()>A.text.toLowerCase()?1:-1),[]),f=rr(()=>new Set(s.getSceneFamilies()),[e]),b=rr(()=>u.filter(k=>f.has(k.value)),[u,f]),x=rr(()=>u.filter(k=>!f.has(k.value)&&(d||!k.deprecated)),[u,f,d]),w=rr(()=>h6([...b,...x].filter(k=>k.text?.toLowerCase().includes(m))),[b,x,m]),E=rr(()=>{let k;return o?k=w.find(A=>A.value===o):e&&(k=w.find(A=>A.value===e)),!k&&m&&(w[0]?.value?r(w[0].value):n()),k},[o,e,m,w,r,n]),y=u6(k=>{Hb({event:k,inputRef:p,hoveredFont:E,filteredFonts:w,onSelect:t,onHover:r,onClose:a})&&(k.preventDefault(),k.stopPropagation())},[E,w,t,r,a]);p6(()=>(i(),()=>{a()}),[]);let v=rr(()=>w.filter(k=>f.has(k.value)),[w,f]),C=rr(()=>w.filter(k=>!f.has(k.value)),[w,f]),S=(k,A)=>Gb(pt,{icon:k.icon,value:k.value,order:A,textStyle:{fontFamily:f6({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&&r(k.value)},children:[k.text,k.badge&&da(Ms,{type:k.badge.type,children:k.badge.placeholder})]},k.value),L=[];return v.length&&L.push(da(sa,{title:g("fontList.sceneFonts"),children:v.map(S)},"group_1")),C.length&&L.push(da(sa,{title:g("fontList.availableFonts"),children:C.map((k,A)=>S(k,A+v.length))},"group_2")),Gb(xs,{className:"properties-content",container:l,style:{width:"15rem"},onClose:a,onPointerLeave:n,onKeyDown:y,children:[da(vs,{ref:p,placeholder:g("quickSearch.placeholder"),onChange:g6(c,20)}),da(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 Yb from"@radix-ui/react-popover";import{useMemo as x6}from"react";import{jsx as gp}from"react/jsx-runtime";var Wb=({selectedFontFamily:e})=>{let o=x6(()=>!!(e&&!Vb(e)),[e]);return gp(Yb.Trigger,{asChild:!0,children:gp("div",{children:gp(An,{standalone:!0,icon:vn,title:g("labels.showFonts"),className:"properties-trigger",testId:"font-family-show-fonts",active:o,onClick:()=>{}})})})};import{jsx as ma,jsxs as Xb}from"react/jsx-runtime";var Zb=[{value:fp.Excalifont,icon:qo,text:g("labels.handDrawn"),testId:"font-family-hand-drawn"},{value:fp.Nunito,icon:Ji,text:g("labels.normal"),testId:"font-family-normal"},{value:fp["Comic Shanns"],icon:ql,text:g("labels.code"),testId:"font-family-code"}],v6=new Set(Zb.map(e=>e.value)),Vb=e=>e?v6.has(e):!1,$b=E6.memo(({isOpened:e,selectedFontFamily:o,hoveredFontFamily:t,onSelect:r,onHover:n,onLeave:i,onPopupChange:a})=>{let l=w6(()=>Zb,[]),s=y6(d=>{d&&r(d)},[r]);return Xb("div",{role:"dialog","aria-modal":"true",className:"FontPicker__container",children:[ma("div",{className:"buttonList",children:ma(Ft,{type:"button",options:l,value:o,onClick:s})}),ma(gs,{}),Xb(Kb.Root,{open:e,onOpenChange:a,children:[ma(Wb,{selectedFontFamily:o}),e&&ma(Ub,{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 Hn from"@radix-ui/react-popover";import S6 from"clsx";import Ls,{useEffect as k6}from"react";import{isArrowKey as M6,KEYS as Lo}from"@excalidraw/common";import{jsx as T6}from"react/jsx-runtime";var nr=({icon:e})=>T6("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 C6,jsx as jb,jsxs as qb}from"react/jsx-runtime";var I6=({label:e,open:o,openTrigger:t,children:r,className:n,showCollapsedIcon:i=!0})=>qb(C6,{children:[qb("div",{style:{cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center"},className:n,onClick:t,children:[e,i&&jb(nr,{icon:o?ab:as})]}),o&&jb("div",{style:{display:"flex",flexDirection:"column"},children:r})]}),pa=I6;import{jsx as Ur,jsxs as bp}from"react/jsx-runtime";var L6=me(!1);function P6({options:e,value:o,label:t,onChange:r,onClose:n,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)r(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;r(e[x].value)}else if(M6(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}}r(e[E].value)}u.preventDefault()}else(u.key===Lo.ESCAPE||u.key===Lo.ENTER)&&(u.preventDefault(),n());u.nativeEvent.stopImmediatePropagation(),u.stopPropagation()},[s,d]=ie(L6),m=Ls.useMemo(()=>e.slice(0,i),[e,i]),c=Ls.useMemo(()=>e.slice(i),[e,i]);k6(()=>{m.some(u=>u.value===o)||d(!0)},[o,m,d]);let p=u=>Ur("div",{className:"picker-content",children:u.map((f,b)=>bp("button",{type:"button",className:S6("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&&Ur("span",{className:"picker-keybinding",children:f.keyBinding})]},f.text))});return Ur(Hn.Content,{side:a.editor.isMobile&&!a.viewport.isLandscape?"top":"bottom",align:"start",sideOffset:12,style:{zIndex:"var(--zIndex-popup)"},onKeyDown:l,children:bp("div",{className:"picker",role:"dialog","aria-modal":"true","aria-label":t,children:[p(m),c.length>0&&Ur(pa,{label:g("labels.more_options"),open:s,openTrigger:()=>{d(u=>!u)},className:"picker-collapsible",children:p(c)})]})})}function xp({value:e,label:o,options:t,onChange:r,group:n="",numberOfOptionsToAlwaysShow:i}){let[a,l]=Ls.useState(!1),s=Ls.useRef(null);return Ur("div",{children:bp(Hn.Root,{open:a,onOpenChange:d=>l(d),children:[Ur(Hn.Trigger,{name:n,type:"button","aria-label":o,onClick:()=>l(!a),ref:s,className:a?"active":"",children:t.find(d=>d.value===e)?.icon}),a&&Ur(P6,{options:t,value:e,label:o,onChange:r,onClose:()=>{l(!1)},numberOfOptionsToAlwaysShow:i})]})})}import Jb,{useEffect as A6}from"react";import{jsx as Ep,jsxs as Qb}from"react/jsx-runtime";var ex=({updateData:e,app:o,testId:t})=>{let r=Jb.useRef(null),n=Jb.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 A6(()=>{if(r.current&&n.current){let m=r.current,c=n.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]),Qb("label",{className:"control-label",children:[g("labels.opacity"),Qb("div",{className:"range-wrapper",children:[Ep("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:d,className:"range-input","data-testid":t}),Ep("div",{className:"value-bubble",ref:n,children:d!==0?d:null}),Ep("div",{className:"zero-label",children:"0"})]})]})};import{Fragment as sx,jsx as Q,jsxs as yt}from"react/jsx-runtime";var lx=.1,ut=(e,o,t,r=!1)=>{let n=Cp(j(e,o,{includeBoundTextElement:r}));return e.map(i=>n.get(i.id)||i.id===o.editingTextElement?.id?t(i):i)},Et=function(e,o,t,r,n){let i=o.state.editingTextElement,a=ix(e),l=null;if(i&&(l=t(i)),!l)if(Ee(a,o.state)){let d=o.scene.getSelectedElements(o.state),m=r===!0?d:d.filter(c=>r(c));l=K6(m,t)??(typeof n=="function"?n(!0):n)}else l=typeof n=="function"?n(!1):n;return l},t4=(e,o,t)=>j6(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}),Sp=(e,o,t,r,n)=>{let i=new Set,a=ut(e,o,l=>{if(xt(l)){let s=r(l);i.add(s);let d=Ke(l,{fontSize:s});return ua(d,t.scene.getContainerElement(l),t.scene),d=t4(l,d,t.scene),d}return l},!0);return j(e,o,{includeBoundTextElement:!0}).forEach(l=>{xt(l)&&$6(l,t.scene)}),{elements:a,appState:{...o,currentItemFontSize:i.size===1?[...i][0]:n??o.currentItemFontSize},captureUpdate:Ze.IMMEDIATELY}},o4=B({name:"changeStrokeColor",label:"labels.stroke",trackEvent:!1,perform:(e,o,t)=>({...t.currentItemStrokeColor&&{elements:ut(e,o,r=>J6(r.type)?Ke(r,{strokeColor:t.currentItemStrokeColor}):r,!0)},appState:{...o,...t},captureUpdate:t.currentItemStrokeColor?Ze.IMMEDIATELY:Ze.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt(sx,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.stroke")}),Q(la,{topPicks:O6,palette:F6,type:"elementStroke",label:g("labels.stroke"),color:Et(e,r,n=>n.strokeColor,!0,n=>n?null:o.currentItemStrokeColor),onChange:n=>t({currentItemStrokeColor:n}),elements:e,appState:o,updateData:t})]})}),r4=B({name:"changeBackgroundColor",label:"labels.changeBackground",trackEvent:!1,perform:(e,o,t,r)=>{if(!t.currentItemBackgroundColor)return{appState:{...o,...t},captureUpdate:Ze.EVENTUALLY};let n,i=r.scene.getSelectedElements(o);if(!X6(t.currentItemBackgroundColor)&&i.every(l=>rx(l)&&Z6(l.points))){let l=Cp(i);n=e.map(s=>l.has(s.id)&&rx(s)?Ke(s,{backgroundColor:t.currentItemBackgroundColor,...e4(s,!0)}):s)}else n=ut(e,o,l=>Ke(l,{backgroundColor:t.currentItemBackgroundColor}));return{elements:n,appState:{...o,...t},captureUpdate:Ze.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt(sx,{children:[Q("h3",{"aria-hidden":"true",children:g("labels.background")}),Q(la,{topPicks:B6,palette:N6,type:"elementBackground",label:g("labels.background"),color:Et(e,r,n=>n.backgroundColor,!0,n=>n?null:o.currentItemBackgroundColor),onChange:n=>t({currentItemBackgroundColor:n}),elements:e,appState:o,updateData:t})]})}),n4=B({name:"changeFillStyle",label:"labels.fill",trackEvent:!1,perform:(e,o,t,r)=>(re("element","changeFillStyle",`${t} (${r.device.editor.isMobile?"mobile":"desktop"})`),{elements:ut(e,o,n=>Ke(n,{fillStyle:t})),appState:{...o,currentItemFillStyle:t},captureUpdate:Ze.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 yt("fieldset",{children:[Q("legend",{children:g("labels.fill")}),Q("div",{className:"buttonList",children:Q(Ft,{type:"button",options:[{value:"hachure",text:`${i?g("labels.zigzag"):g("labels.hachure")} (${W6("Alt-Click")})`,icon:i?J1:Q1,active:i?!0:void 0,testId:"fill-hachure"},{value:"cross-hatch",text:g("labels.crossHatch"),icon:e0,testId:"fill-cross-hatch"},{value:"solid",text:g("labels.solid"),icon:t0,testId:"fill-solid"}],value:Et(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(d=>d.fillStyle==="hachure")?"zigzag":a;t(s)}})})]})}}),i4=B({name:"changeStrokeWidth",label:"labels.strokeWidth",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>Ke(r,{strokeWidth:t})),appState:{...o,currentItemStrokeWidth:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.strokeWidth")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"stroke-width",options:[{value:vp.thin,text:g("labels.thin"),icon:Om,testId:"strokeWidth-thin"},{value:vp.bold,text:g("labels.bold"),icon:o0,testId:"strokeWidth-bold"},{value:vp.extraBold,text:g("labels.extraBold"),icon:r0,testId:"strokeWidth-extraBold"}],value:Et(e,r,n=>n.strokeWidth,n=>n.hasOwnProperty("strokeWidth"),n=>n?null:o.currentItemStrokeWidth),onChange:n=>t(n)})})]})}),a4=B({name:"changeSloppiness",label:"labels.sloppiness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>Ke(r,{seed:U6(),roughness:t})),appState:{...o,currentItemRoughness:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.sloppiness")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"sloppiness",options:[{value:0,text:g("labels.architect"),icon:a0},{value:1,text:g("labels.artist"),icon:l0},{value:2,text:g("labels.cartoonist"),icon:s0}],value:Et(e,r,n=>n.roughness,n=>n.hasOwnProperty("roughness"),n=>n?null:o.currentItemRoughness),onChange:n=>t(n)})})]})}),f$=B({name:"changeStrokeStyle",label:"labels.strokeStyle",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>Ke(r,{strokeStyle:t})),appState:{...o,currentItemStrokeStyle:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.strokeStyle")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"strokeStyle",options:[{value:"solid",text:g("labels.strokeStyle_solid"),icon:Om},{value:"dashed",text:g("labels.strokeStyle_dashed"),icon:n0},{value:"dotted",text:g("labels.strokeStyle_dotted"),icon:i0}],value:Et(e,r,n=>n.strokeStyle,n=>n.hasOwnProperty("strokeStyle"),n=>n?null:o.currentItemStrokeStyle),onChange:n=>t(n)})})]})}),l4=B({name:"changeOpacity",label:"labels.opacity",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>Ke(r,{opacity:t}),!0),appState:{...o,currentItemOpacity:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({app:e,updateData:o})=>Q(ex,{updateData:o,app:e,testId:"opacity"})}),s4=B({name:"changeFontSize",label:"labels.fontSize",trackEvent:!1,perform:(e,o,t,r)=>Sp(e,o,r,()=>t,t),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.fontSize")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"font-size",options:[{value:16,text:g("labels.small"),icon:T0,testId:"fontSize-small"},{value:20,text:g("labels.medium"),icon:I0,testId:"fontSize-medium"},{value:28,text:g("labels.large"),icon:C0,testId:"fontSize-large"},{value:36,text:g("labels.veryLarge"),icon:S0,testId:"fontSize-veryLarge"}],value:Et(e,r,n=>{if(xt(n))return n.fontSize;let i=ir(n,r.scene.getNonDeletedElementsMap());return i?i.fontSize:null},n=>xt(n)||ir(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:o.currentItemFontSize||H6),onChange:n=>t(n)})})]})}),kp=B({name:"decreaseFontSize",label:"labels.decreaseFontSize",icon:Or,trackEvent:!1,perform:(e,o,t,r)=>Sp(e,o,r,n=>Math.round(1/(1+lx)*n.fontSize)),keyTest:e=>e[Gn.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Gn.CHEVRON_LEFT||e.key===Gn.COMMA)}),Mp=B({name:"increaseFontSize",label:"labels.increaseFontSize",icon:Or,trackEvent:!1,perform:(e,o,t,r)=>Sp(e,o,r,n=>Math.round(n.fontSize*(1+lx))),keyTest:e=>e[Gn.CTRL_OR_CMD]&&e.shiftKey&&(e.key===Gn.CHEVRON_RIGHT||e.key===Gn.PERIOD)}),c4=B({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:ut(e,o,b=>{let x=n?.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(Zo.loadedFontsCache.values()),E=Object.entries(G6).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:V6(c)}),L=n?.get(C.containerId||"")||{},k=r.scene.getContainerElement(C);return a&&k&&L&&r.scene.mutateElement(k,{...L}),x||(b=new Set([...b,...Array.from(S.originalText)])),f.set(S,k),S}return C},!0)});let y=`10px ${Y6({fontFamily:c})}`,v=Array.from(b.values()).join();if(x||window.document.fonts.check(y,v))for(let[C,S]of f)ua(C,S,r.scene);else window.document.fonts.load(y,v).then(C=>{for(let[S,L]of f){let k=r.scene.getElement(S.id),A=L?r.scene.getElement(L.id):null;k&&ua(k,A,r.scene)}r.fonts.onLoaded(C)})}return u},PanelComponent:({elements:e,appState:o,app:t,updateData:r})=>{let n=wp(new Map),i=wp(null),[a,l]=R6({}),s=wp(!0),d=_6(()=>{let m=(c,p)=>Et(c,t,u=>{if(xt(u))return u.fontFamily;let f=ir(u,p);return f?f.fontFamily:null},u=>xt(u)||ir(u,p)!==null,u=>u?null:o.currentItemFontFamily||z6);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 yp(()=>{i.current=d},[d]),yp(()=>{Object.keys(a).length&&(r(a),l({}))},[a]),yp(()=>(s.current=!1,()=>{s.current=!0}),[]),yt("fieldset",{children:[Q("legend",{children:g("labels.fontFamily")}),Q($b,{isOpened:o.openPopup==="fontFamily",selectedFontFamily:d,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:c}=o;if(c?.type==="text"){let p=t.scene.getElement(c.id);n.current.set(c.id,Ke(p||c,{},!0))}else{let p=j(e,o,{includeBoundTextElement:!0});for(let u of p)n.current.set(u.id,Ke(u,{},!0))}l({openPopup:"fontFamily"})}else{let c={openPopup:null,currentHoveredFontFamily:null,cachedElements:new Map(n.current),resetAll:!0};s.current?r({...a,...c}):l(c),n.current.clear()}}})]})}}),d4=B({name:"changeTextAlign",label:"Change text alignment",trackEvent:!1,perform:(e,o,t,r)=>({elements:ut(e,o,n=>{if(xt(n)){let i=Ke(n,{textAlign:t});return ua(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o,currentItemTextAlign:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=r.scene.getNonDeletedElementsMap();return yt("fieldset",{children:[Q("legend",{children:g("labels.textAlign")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"text-align",options:[{value:"left",text:g("labels.left"),icon:M0,testId:"align-left"},{value:"center",text:g("labels.center"),icon:L0,testId:"align-horizontal-center"},{value:"right",text:g("labels.right"),icon:P0,testId:"align-right"}],value:Et(e,r,i=>{if(xt(i))return i.textAlign;let a=ir(i,n);return a?a.textAlign:null},i=>xt(i)||ir(i,n)!==null,i=>i?null:o.currentItemTextAlign),onChange:i=>t(i)})})]})}}),m4=B({name:"changeVerticalAlign",label:"Change vertical alignment",trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:ut(e,o,n=>{if(xt(n)){let i=Ke(n,{verticalAlign:t});return ua(i,r.scene.getContainerElement(n),r.scene),i}return n},!0),appState:{...o},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Q("fieldset",{children:Q("div",{className:"buttonList",children:Q(Ft,{group:"text-align",options:[{value:Ps.TOP,text:g("labels.alignTop"),icon:Q(A0,{theme:o.theme}),testId:"align-top"},{value:Ps.MIDDLE,text:g("labels.centerVertically"),icon:Q(_0,{theme:o.theme}),testId:"align-middle"},{value:Ps.BOTTOM,text:g("labels.alignBottom"),icon:Q(D0,{theme:o.theme}),testId:"align-bottom"}],value:Et(e,r,n=>{if(xt(n)&&n.containerId)return n.verticalAlign;let i=ir(n,r.scene.getNonDeletedElementsMap());return i?i.verticalAlign:null},n=>xt(n)||ir(n,r.scene.getNonDeletedElementsMap())!==null,n=>n?null:Ps.MIDDLE),onChange:n=>t(n)})})})}),b$=B({name:"changeRoundness",label:"Change edge roundness",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>ax(r)?r:Ke(r,{roundness:t==="round"?{type:q6(r.type)?As.ADAPTIVE_RADIUS:As.PROPORTIONAL_RADIUS}:null})),appState:{...o,currentItemRoundness:t},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r,renderAction:n})=>{let a=kl(ix(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(Ft,{group:"edges",options:[{value:"sharp",text:g("labels.sharp"),icon:c0},{value:"round",text:g("labels.round"),icon:d0}],value:Et(e,r,l=>a?null:l.roundness?"round":"sharp",l=>!Ds(l)&&l.hasOwnProperty("roundness"),l=>l?null:o.currentItemRoundness),onChange:l=>t(l)}),n("togglePolygon")]})]})}}),nx=e=>[{value:null,text:g("labels.arrowhead_none"),keyBinding:"q",icon:m0},{value:"arrow",text:g("labels.arrowhead_arrow"),keyBinding:"w",icon:Q(p0,{flip:e})},{value:"triangle",text:g("labels.arrowhead_triangle"),icon:Q(f0,{flip:e}),keyBinding:"e"},{value:"triangle_outline",text:g("labels.arrowhead_triangle_outline"),icon:Q(b0,{flip:e}),keyBinding:"r"},{value:"circle",text:g("labels.arrowhead_circle"),keyBinding:"a",icon:Q(u0,{flip:e})},{value:"circle_outline",text:g("labels.arrowhead_circle_outline"),keyBinding:"s",icon:Q(h0,{flip:e})},{value:"diamond",text:g("labels.arrowhead_diamond"),icon:Q(x0,{flip:e}),keyBinding:"d"},{value:"diamond_outline",text:g("labels.arrowhead_diamond_outline"),icon:Q(E0,{flip:e}),keyBinding:"f"},{value:"bar",text:g("labels.arrowhead_bar"),keyBinding:"z",icon:Q(g0,{flip:e})},{value:"crowfoot_one",text:g("labels.arrowhead_crowfoot_one"),icon:Q(w0,{flip:e}),keyBinding:"x"},{value:"crowfoot_many",text:g("labels.arrowhead_crowfoot_many"),icon:Q(y0,{flip:e}),keyBinding:"c"},{value:"crowfoot_one_or_many",text:g("labels.arrowhead_crowfoot_one_or_many"),icon:Q(v0,{flip:e}),keyBinding:"v"}],x$=B({name:"changeArrowhead",label:"Change arrowheads",trackEvent:!1,perform:(e,o,t)=>({elements:ut(e,o,r=>{if(Ip(r)){let{position:n,type:i}=t;if(n==="start")return Ke(r,{startArrowhead:i});if(n==="end")return Ke(r,{endArrowhead:i})}return r}),appState:{...o,[t.position==="start"?"currentItemStartArrowhead":"currentItemEndArrowhead"]:t.type},captureUpdate:Ze.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>{let n=Mo().rtl;return yt("fieldset",{children:[Q("legend",{children:g("labels.arrowheads")}),yt("div",{className:"iconSelectList buttonList",children:[Q(xp,{label:"arrowhead_start",options:nx(!n),value:Et(e,r,i=>Ip(i)&&un(i.type)?i.startArrowhead:o.currentItemStartArrowhead,!0,o.currentItemStartArrowhead),onChange:i=>t({position:"start",type:i}),numberOfOptionsToAlwaysShow:4}),Q(xp,{label:"arrowhead_end",group:"arrowheads",options:nx(!!n),value:Et(e,r,i=>Ip(i)&&un(i.type)?i.endArrowhead:o.currentItemEndArrowhead,!0,o.currentItemEndArrowhead),onChange:i=>t({position:"end",type:i}),numberOfOptionsToAlwaysShow:4})]})]})}}),E$=B({name:"changeArrowType",label:"Change arrow types",trackEvent:!1,perform:(e,o,t,r)=>{let n=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(ax(s)){s.fixedSegments=null;let d=r.scene.getNonDeletedElementsMap();r.dismissLinearEditor();let m=Tp.getPointAtIndexGlobalCoordinates(s,0,d),c=Tp.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,...ox(s,p,"start",d)}:null,b=u&&s.endBinding?{...s.endBinding,...ox(s,u,"end",d)}:null;s={...s,startBinding:f,endBinding:b,...Q6(s,d,{points:[m,c].map(x=>D6(x[0]-s.x,x[1]-s.y)),startBinding:f,endBinding:b,fixedSegments:null})}}else{let d=r.scene.getNonDeletedElementsMap();if(s.startBinding){let m=d.get(s.startBinding.elementId);m&&tx(s,m,"start",r.scene)}if(s.endBinding){let m=d.get(s.endBinding.elementId);m&&tx(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 Tp(l,Cp(e)))}return{elements:n,appState:i,captureUpdate:Ze.IMMEDIATELY}},PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>yt("fieldset",{children:[Q("legend",{children:g("labels.arrowtypes")}),Q("div",{className:"buttonList",children:Q(Ft,{group:"arrowtypes",options:[{value:Po.sharp,text:g("labels.arrowtype_sharp"),icon:rs,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:ns,testId:"elbow-arrow"}],value:Et(e,r,n=>Ds(n)?n.elbowed?Po.elbow:n.roundness?Po.round:Po.sharp:null,n=>Ds(n),n=>n?null:o.currentItemArrowType),onChange:n=>t(n)})})]})});import{clamp as _p,roundToStep as x4}from"@excalidraw/math";import{DEFAULT_CANVAS_BACKGROUND_PICKS as E4,CURSOR_TYPE as ux,MAX_ZOOM as hx,MIN_ZOOM as gx,THEME as ha,ZOOM_STEP as Rp,getShortcutKey as fx,updateActiveTool as Yn,CODES as xo,KEYS as Do}from"@excalidraw/common";import{getNonDeletedElements as y4}from"@excalidraw/element";import{newElementWith as w4}from"@excalidraw/element";import{getCommonBounds as v4}from"@excalidraw/element";import{CaptureUpdateAction as Qt}from"@excalidraw/element";import{useEffect as p4}from"react";import{jsx as h4}from"react/jsx-runtime";var Un=()=>{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},Lp=(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();Lp(o,n)},Pt=({children:e,label:o,long:t=!1,style:r,disabled:n})=>(p4(()=>()=>Un().classList.remove("excalidraw-tooltip--visible"),[]),n?null:h4("div",{className:"excalidraw-tooltip-wrapper",onPointerEnter:i=>u4(i.currentTarget,Un(),o,t),onPointerLeave:()=>Un().classList.remove("excalidraw-tooltip--visible"),style:r,children:e}));import _s from"open-color";import{CURSOR_TYPE as Pp,MIME_TYPES as Ap,THEME as dx}from"@excalidraw/common";var mx='<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"/>',px='<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:${Ap.svg},${encodeURIComponent(`${mx}${px}</svg>`)}`,b4=`data:${Ap.svg},${encodeURIComponent(`${mx}${g4}${px}</svg>`)}`,zt=e=>{e&&(e.style.cursor="")},xe=(e,o)=>{e&&(e.style.cursor=o)},bo,cx,Dp=(e,o)=>{let r=()=>{let n=o===dx.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=n?_s.black:_s.white,i.fill(),i.strokeStyle=n?_s.white:_s.black,i.stroke(),cx=bo.toDataURL(Ap.svg)};(!bo||bo.theme!==o)&&r(),xe(e,`url(${cx}) ${20/2} ${20/2}, auto`)},At=(e,o)=>{if(e)if(o.activeTool.type==="selection")zt(e);else if(jt(o))e.style.cursor=Pp.GRAB;else if(bt(o))Dp(e,o.theme);else if(o.activeTool.type==="laser"){let t=o.theme===dx.LIGHT?f4:b4;e.style.cursor=`url(${t}), auto`}else["image","custom"].includes(o.activeTool.type)?o.activeTool.type!=="image"&&(e.style.cursor=Pp.AUTO):e.style.cursor=Pp.CROSSHAIR};var Ao=({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),d=-(n-n/t),m=-(i-i/t);return{scrollX:l+d,scrollY:s+m,zoom:{value:t}}};import{jsx as Fs,jsxs as S4}from"react/jsx-runtime";var T4=B({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?Qt.IMMEDIATELY:Qt.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t,appProps:r})=>Fs(la,{palette:null,topPicks:E4,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})}),_o=B({name:"clearCanvas",label:"labels.clearCanvas",icon:Mt,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=>w4(n,{isDeleted:!0})),appState:{...$o(),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:Qt.IMMEDIATELY})}),Rs=B({name:"zoomIn",label:"buttons.zoomIn",viewMode:!0,icon:ym,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(o.zoom.value+Rp)},o),userToFollow:null},captureUpdate:Qt.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Fs(K,{type:"button",className:"zoom-in-button zoom-button",icon:ym,title:`${g("buttons.zoomIn")} \u2014 ${fx("CtrlOrCmd++")}`,"aria-label":g("buttons.zoomIn"),disabled:o.zoom.value>=hx,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:wm,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(o.zoom.value-Rp)},o),userToFollow:null},captureUpdate:Qt.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Fs(K,{type:"button",className:"zoom-out-button zoom-button",icon:wm,title:`${g("buttons.zoomOut")} \u2014 ${fx("CtrlOrCmd+-")}`,"aria-label":g("buttons.zoomOut"),disabled:o.zoom.value<=gx,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:N1,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>({appState:{...o,...Ao({viewportX:o.width/2+o.offsetLeft,viewportY:o.height/2+o.offsetTop,nextZoom:uo(1)},o),userToFollow:null},captureUpdate:Qt.EVENTUALLY}),PanelComponent:({updateData:e,appState:o})=>Fs(Pt,{label:g("buttons.resetZoom"),style:{height:"100%"},children:S4(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)}),I4=(e,o,t=1)=>{let[r,n,i,a]=e,l=i-r,s=o.width/l,d=a-n,m=o.height/d,p=Math.min(s,m)*_p(t,.1,1);return Math.min(p,1)},bx=({bounds:e,appState:o,canvasOffsets:t,fitToViewport:r=!1,viewportZoomFactor:n=1,minZoom:i=-1/0,maxZoom:a=1/0})=>{n=_p(n,gx,hx);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(r){let S=d-l,L=m-s;y=Math.min(w/S,E/L)*n}else y=I4(e,{width:w,height:E},n);let v=uo(_p(x4(y,Rp,"floor"),i,a)),C=Xf({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:Qt.EVENTUALLY}},ga=({canvasOffsets:e,targetElements:o,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})=>{let l=v4(y4(o));return bx({canvasOffsets:e,bounds:l,appState:t,fitToViewport:r,viewportZoomFactor:n,minZoom:i,maxZoom:a})},tj=B({name:"zoomToFitSelectionInViewport",label:"labels.zoomToFitViewport",icon:os,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return ga({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===xo.TWO&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),oj=B({name:"zoomToFitSelection",label:"helpDialog.zoomToSelection",icon:os,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return ga({targetElements:n.length?n:e,appState:{...o,userToFollow:null},fitToViewport:!0,canvasOffsets:r.getEditorUIOffsets()})},keyTest:e=>e.code===xo.THREE&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),C4=B({name:"zoomToFit",label:"helpDialog.zoomToFit",icon:os,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t,r)=>ga({targetElements:e,appState:{...o,userToFollow:null},fitToViewport:!1,canvasOffsets:r.getEditorUIOffsets()}),keyTest:e=>e.code===xo.ONE&&e.shiftKey&&!e.altKey&&!e[Do.CTRL_OR_CMD]}),Yr=B({name:"toggleTheme",label:(e,o)=>o.theme===ha.DARK?"buttons.lightMode":"buttons.darkMode",keywords:["toggle","dark","light","mode","theme"],icon:e=>e.theme===ha.LIGHT?$i:ji,viewMode:!0,trackEvent:{category:"canvas"},perform:(e,o,t)=>({appState:{...o,theme:t||(o.theme===ha.LIGHT?ha.DARK:ha.LIGHT)},captureUpdate:Qt.EVENTUALLY}),keyTest:e=>e.altKey&&e.shiftKey&&e.code===xo.D,predicate:(e,o,t,r)=>!!r.props.UIOptions.canvasActions.toggleTheme}),rj=B({name:"toggleEraserTool",label:"toolBar.eraser",trackEvent:{category:"toolbar"},perform:(e,o)=>{let t;return bt(o)?t=Yn(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):t=Yn(o,{type:"eraser",lastActiveToolBeforeEraser:o.activeTool}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:t},captureUpdate:Qt.IMMEDIATELY}},keyTest:e=>e.key===Do.E}),nj=B({name:"toggleLassoTool",label:"toolBar.lasso",icon:Ki,trackEvent:{category:"toolbar"},perform:(e,o,t,r)=>{let n;return o.activeTool.type!=="lasso"?(n=Yn(o,{type:"lasso",fromSelection:!1}),xe(r.interactiveCanvas,ux.CROSSHAIR)):n=Yn(o,{type:"selection"}),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:Qt.NEVER}}}),xx=B({name:"toggleHandTool",label:"toolBar.hand",trackEvent:{category:"toolbar"},icon:Ql,viewMode:!1,perform:(e,o,t,r)=>{let n;return jt(o)?n=Yn(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):(n=Yn(o,{type:"hand",lastActiveToolBeforeEraser:o.activeTool}),xe(r.interactiveCanvas,ux.GRAB)),{appState:{...o,selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null,activeTool:n},captureUpdate:Qt.IMMEDIATELY}},keyTest:e=>!e.altKey&&!e[Do.CTRL_OR_CMD]&&e.key===Do.H});import{updateActiveTool as Ex}from"@excalidraw/common";import{CaptureUpdateAction as k4}from"@excalidraw/element";var M4=B({name:"setEmbeddableAsActiveTool",trackEvent:{category:"toolbar"},target:"Tool",label:"toolBar.embeddable",perform:(e,o,t,r)=>{let n=Ex(o,{type:"embeddable"});return At(r.canvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:Ex(o,{type:"embeddable"})},captureUpdate:k4.EVENTUALLY}}});import{pointFrom as L4}from"@excalidraw/math";import{maybeBindLinearElement as P4,bindOrUnbindLinearElement as yx,isBindingEnabled as A4}from"@excalidraw/element/binding";import{isValidPolygon as wx,LinearElementEditor as fa}from"@excalidraw/element";import{isBindingElement as Os,isFreeDrawElement as vx,isLinearElement as Tx,isLineElement as zs}from"@excalidraw/element";import{KEYS as Np,arrayToMap as Bp,tupleToCoors as D4,updateActiveTool as Ix}from"@excalidraw/common";import{isPathALoop as _4}from"@excalidraw/element";import{isInvisiblySmallElement as Fp}from"@excalidraw/element";import{CaptureUpdateAction as Op}from"@excalidraw/element";import{jsx as R4}from"react/jsx-runtime";var wt=B({name:"finalize",label:"",trackEvent:!1,perform:(e,o,t,r)=>{let{interactiveCanvas:n,focusContainer:i,scene:a}=r,{event:l,sceneCoords:s}=t??{},d=a.getNonDeletedElementsMap();if(l&&o.selectedLinearElement){let u=fa.handlePointerUp(l,o.selectedLinearElement,o,r.scene),{startBindingElement:f,endBindingElement:b}=u,x=r.scene.getElement(u.elementId);if(Os(x)&&yx(x,f,b,r.scene),u!==o.selectedLinearElement){let w=e;return x&&Fp(x)&&(w=w.filter(E=>E.id!==x.id)),{elements:w,appState:{selectedLinearElement:{...u,selectedPointsIndices:null},suggestedBindings:[]},captureUpdate:Op.IMMEDIATELY}}}if(o.selectedLinearElement?.isEditing){let{elementId:u,startBindingElement:f,endBindingElement:b}=o.selectedLinearElement,x=fa.getElement(u,d);if(x)return Os(x)&&yx(x,f,b,a),zs(x)&&!wx(x.points)&&a.mutateElement(x,{polygon:!1}),{elements:x.points.length<2||Fp(x)?e.filter(w=>w.id!==x.id):void 0,appState:{...o,cursorButton:"up",selectedLinearElement:new fa(x,Bp(d),!1)},captureUpdate:Op.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&&Fp(c)&&(m=m.filter(u=>u.id!==c.id)),Tx(c)||vx(c)){let u=_4(c.points,o.zoom.value);if(u&&(zs(c)||vx(c))){let f=c.points,b=f[0],x=f.map((w,E)=>E===f.length-1?L4(b[0],b[1]):w);zs(c)?a.mutateElement(c,{points:x,polygon:!0}):a.mutateElement(c,{points:x})}if(zs(c)&&!wx(c.points)&&a.mutateElement(c,{polygon:!1}),Os(c)&&!u&&c.points.length>1&&A4(o)){let f=s??D4(fa.getPointAtIndexGlobalCoordinates(c,-1,Bp(e)));P4(c,o,f,a)}}}(!o.activeTool.locked&&o.activeTool.type!=="freedraw"||!c)&&zt(n);let p;return o.activeTool.type==="eraser"?p=Ix(o,{...o.activeTool.lastActiveTool||{type:"selection"},lastActiveToolBeforeEraser:null}):p=Ix(o,{type:"selection"}),{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&&Tx(c)?new fa(c,Bp(m)):o.selectedLinearElement},captureUpdate:Op.IMMEDIATELY}},keyTest:(e,o)=>e.key===Np.ESCAPE&&(o.selectedLinearElement?.isEditing||!o.newElement&&o.multiElement===null)||(e.key===Np.ESCAPE||e.key===Np.ENTER)&&o.multiElement!==null,PanelComponent:({appState:e,updateData:o,data:t})=>R4(K,{type:"button",icon:V1,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 Xn,DEFAULT_EXPORT_PADDING as yk,EXPORT_SCALES as wk,THEME as Gp}from"@excalidraw/common";import{getNonDeletedElements as vk}from"@excalidraw/element";import{CaptureUpdateAction as ro}from"@excalidraw/element";import N4 from"clsx";import{jsx as Cx,jsxs as B4}from"react/jsx-runtime";var ba=({children:e,checked:o,onChange:t,className:r})=>B4("div",{className:N4("Checkbox",r,{"is-checked":o}),onClick:n=>{t(!o,n),n.currentTarget.querySelector(".Checkbox-box").focus()},children:[Cx("button",{type:"button",className:"Checkbox-box",role:"checkbox","aria-checked":o,children:z1}),Cx("div",{className:"Checkbox-label",children:e})]});import{THEME as xa}from"@excalidraw/common";import{jsx as Ea}from"react/jsx-runtime";var kx=e=>{let o=e.title||(e.value===xa.DARK?g("buttons.lightMode"):g("buttons.darkMode"));return Ea(K,{type:"icon",icon:e.value===xa.LIGHT?Sx.MOON:Sx.SUN,title:o,"aria-label":o,onClick:()=>e.onChange(e.value===xa.DARK?xa.LIGHT:xa.DARK),"data-testid":"toggle-dark-mode"})},Sx={SUN:Ea("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ea("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:Ea("svg",{width:"512",height:"512",className:"rtl-mirror",viewBox:"0 0 512 512",children:Ea("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 F4}from"react";import{focusNearestParent as O4,KEYS as z4}from"@excalidraw/common";import{jsx as Mx,jsxs as H4}from"react/jsx-runtime";var Lx=e=>{let{id:o}=He(),[t,r]=F4(e.value),n=a=>{e.ignoreFocus||O4(a.target);let l=a.target.value;l!==e.value&&e.onChange(l)},i=a=>{if(a.key===z4.ENTER){if(a.preventDefault(),a.nativeEvent.isComposing||a.keyCode===229)return;a.currentTarget.blur()}};return H4("div",{className:"ProjectName",children:[Mx("label",{className:"ProjectName-label",htmlFor:"filename",children:`${e.label}:`}),Mx("input",{type:"text",className:"TextInput",onBlur:n,onKeyDown:i,id:`${o}-filename`,value:t,onChange:a=>r(a.target.value)})]})};import{DEFAULT_EXPORT_PADDING as mk,DEFAULT_FILENAME as pk,IMAGE_MIME_TYPES as Wx,isFirefox as uk,MIME_TYPES as hk,cloneJSON as gk,SVG_DOCUMENT_PREAMBLE as fk}from"@excalidraw/common";import{getNonDeletedElements as bk}from"@excalidraw/element";import{isFrameLikeElement as xk}from"@excalidraw/element";import{getElementsOverlappingFrame as Ek}from"@excalidraw/element";import{ALLOWED_PASTE_MIME_TYPES as q4,EXPORT_DATA_TYPES as va,MIME_TYPES as to,arrayToMap as J4,isMemberOf as Q4,isPromiseLike as ek}from"@excalidraw/common";import{mutateElement as tk}from"@excalidraw/element";import{deepCopyElement as ok}from"@excalidraw/element";import{isFrameLikeElement as rk,isInitializedImageElement as nk}from"@excalidraw/element";import{getContainingFrame as Hx}from"@excalidraw/element";import{pointFrom as ar}from"@excalidraw/math";import{COLOR_PALETTE as Ax,DEFAULT_CHART_COLOR_INDEX as G4,getAllColorsSpecificShade as U4,DEFAULT_FONT_FAMILY as Y4,DEFAULT_FONT_SIZE as Dx,VERTICAL_ALIGN as W4,randomId as _x,isDevEnv as Rx}from"@excalidraw/common";import{newTextElement as Hs,newLinearElement as wa,newElement as Hp}from"@excalidraw/element";var eo=32,we=12,lr=256,Nx=50,Wr="NOT_SPREADSHEET",Wn="VALID_SPREADSHEET",ya=e=>{let o=/^([-+]?)[$€£¥₩]?([-+]?)([\d.,]+)[%]?$/.exec(e);return o?parseFloat(`${(o[1]||o[2])+o[3]}`.replace(/,/g,"")):null},zp=(e,o)=>e.slice(1).every(t=>ya(t[o])!==null),Px=e=>{let o=e[0].length;if(o>2)return{type:Wr,reason:"More than 2 columns"};if(o===1){if(!zp(e,0))return{type:Wr,reason:"Value is not numeric"};let s=ya(e[0][0])===null,d=(s?e.slice(1):e).map(m=>ya(m[0]));return d.length<2?{type:Wr,reason:"Less than two rows"}:{type:Wn,spreadsheet:{title:s?e[0][0]:null,labels:null,values:d}}}let t=zp(e,0),r=zp(e,1);if(!t&&!r)return{type:Wr,reason:"Value is not numeric"};let[n,i]=r?[0,1]:[1,0],a=ya(e[0][i])===null,l=a?e.slice(1):e;return l.length<2?{type:Wr,reason:"Less than 2 rows"}:{type:Wn,spreadsheet:{title:a?e[0][i]:null,labels:l.map(s=>s[n]),values:l.map(s=>ya(s[i]))}}},V4=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},Bx=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:bi,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:bi,reason:"All rows don't have same number of columns"};let n=Yy(o);if(n.type!==ya){let i=Yy(_4(o));if(i.type===ya)return i}return n},_d=Hf(Nf),Po={fillStyle:"hachure",fontFamily:qr,fontSize:Ir,opacity:100,roughness:1,strokeColor:Io.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:Qt.MIDDLE,locked:!1},Zy=e=>{let o=(qo+Ge)*e.values.length+Ge,t=wn+Ge*2;return{chartWidth:o,chartHeight:t}},D4=(e,o,t,r,n)=>e.labels?.map((i,a)=>Vt({groupIds:[r],backgroundColor:n,...Po,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(qo+Ge)+Ge*2,y:t+Ge/2,width:qo,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],P4=(e,o,t,r,n)=>{let i=Vt({groupIds:[r],backgroundColor:n,...Po,x:o-Ge,y:t-Ge,text:"0",textAlign:"right"}),a=Vt({groupIds:[r],backgroundColor:n,...Po,x:o-Ge,y:t-wn-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},R4=(e,o,t,r,n)=>{let{chartWidth:i,chartHeight:a}=Zy(e),l=cr({backgroundColor:n,groupIds:[r],...Po,type:"line",x:o,y:t,width:i,points:[M(0,0),M(i,0)]}),s=cr({backgroundColor:n,groupIds:[r],...Po,type:"line",x:o,y:t,height:a,points:[M(0,0),M(0,-a)]}),c=cr({backgroundColor:n,groupIds:[r],...Po,type:"line",x:o,y:t-wn-Ge,strokeStyle:"dotted",width:i,opacity:Wy,points:[M(0,0),M(i,0)]});return[l,s,c]},Xy=(e,o,t,r,n,i)=>{let{chartWidth:a,chartHeight:l}=Zy(e),s=e.title?Vt({backgroundColor:n,groupIds:[r],...Po,text:e.title,x:o+a/2,y:t-wn-Ge*2-Ir,roundness:null,textAlign:"center"}):null,c=i?Gt({backgroundColor:n,groupIds:[r],...Po,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:Io.black,fillStyle:"solid",opacity:6}):null;return[...c?[c]:[],...s?[s]:[],...D4(e,o,t,r,n),...P4(e,o,t,r,n),...R4(e,o,t,r,n)]},N4=(e,o,t)=>{let r=Math.max(...e.values),n=ro(),i=_d[Math.floor(Math.random()*_d.length)];return[...e.values.map((l,s)=>{let c=l/r*wn;return Gt({backgroundColor:i,groupIds:[n],...Po,type:"rectangle",x:o+s*(qo+Ge)+Ge,y:t-c-Ge,width:qo,height:c})}),...Xy(e,o,t,n,i,Ue())]},O4=(e,o,t)=>{let r=Math.max(...e.values),n=ro(),i=_d[Math.floor(Math.random()*_d.length)],a=0,l=[];for(let b of e.values){let x=a*(qo+Ge),E=-(b/r)*wn;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=cr({backgroundColor:i,groupIds:[n],...Po,type:"line",x:o+Ge+qo/2,y:t-Ge,height:c-d,width:s-m,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let E=x*(qo+Ge)+Ge/2,w=-(b/r)*wn+Ge/2;return Gt({backgroundColor:i,groupIds:[n],...Po,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+E+qo/2,y:t+w-Ge*2,width:Ge,height:Ge})}),g=e.values.map((b,x)=>{let E=x*(qo+Ge)+Ge/2,w=b/r*wn+Ge/2+Ge;return cr({backgroundColor:i,groupIds:[n],...Po,type:"line",x:o+E+qo/2+Ge/2,y:t-w,height:w,strokeStyle:"dotted",opacity:Wy,points:[M(0,0),M(0,w)]})});return[...Xy(e,o,t,n,i,Ue()),p,...g,...u]},$y=(e,o,t,r)=>e==="line"?O4(o,t,r):N4(o,t,r);var UF="clipboard"in navigator&&"readText"in navigator.clipboard,Dd="clipboard"in navigator&&"writeText"in navigator.clipboard,va="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,B4=e=>!!([Qr.excalidraw,Qr.excalidrawClipboard,Qr.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),jy=({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},z4=({elements:e,files:o})=>{let t=ee(e),r=new Set(e.filter(l=>ne(l))),n=!1,i=e.reduce((l,s)=>(Ar(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:Qr.excalidrawClipboard,elements:e.map(l=>{if(ti(l,t)&&!r.has(ti(l,t))){let s=uo(l);return B(s,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},Pd=async(e,o,t)=>{await Jo(z4({elements:e,files:o}),t)},F4=e=>{let o=Ky(e);return o.type===ya?{spreadsheet:o.spreadsheet}:null};function qy(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(qy(t));return o}var H4=e=>{let o=e.clipboardData?.getData(ue.html);if(!o)return null;try{let t=new DOMParser().parseFromString(o,ue.html),r=qy(t.body);if(r.length)return{type:"mixedContent",value:r}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Jy=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{[ue.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(qs(qf,r))try{if(r===ue.text||r===ue.html)e[r]=await(await t.getType(r)).text();else if(f0(r)){let n=await t.getType(r),i=C0(n,r,void 0);e[r]=i}else throw new qp(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof qp?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},U4=async(e,o=!1)=>{try{let t=!o&&e&&H4(e);return t?t.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData(ue.text)||t.value.map(n=>n.value).join(`
5
- `).trim()}:t:{type:"text",value:(e.clipboardData?.getData(ue.text)||"").trim()}}catch{return{type:"text",value:""}}},Rd=async(e,o=!1)=>{let t=await U4(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&F4(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===Qr.excalidrawClipboardWithAPI;if(B4(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}},Nd=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[ue.png]:e})])}catch(o){if(nn(e))await navigator.clipboard.write([new window.ClipboardItem({[ue.png]:await e})]);else throw o}},Jo=async(e,o)=>{if(Dd)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(ue.text,e||""),o.clipboardData?.getData(ue.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!G4(e))throw new Error("Error copying to clipboard.")},G4=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 xi=(e,{selectedElementIds:o},t)=>{e=Ee(e);let r=t&&ze(e,{selectedElementIds:o}),n=null,i=r?J(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(i.length===1&&ne(i[0])?(n=i[0],i=pc(e,n)):i.length>1&&(i=J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:oo(i)}},Ei=async(e,o,t,r,{exportBackground:n,exportPadding:i=en,viewBackgroundColor:a,name:l=t.name||m1,fileHandle:s=null,exportingFrame:c=null})=>{if(o.length===0)throw new Error(f("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let d=ea(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 Jp(d.then(p=>new Blob([d1+p.outerHTML],{type:ue.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[ol.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await d.then(u=>u.outerHTML);try{await Jo(p)}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return}}let m=_c(o,t,r,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:c});if(e==="png"){let d=Nr(m);return t.exportEmbedScene&&(d=d.then(p=>import("./data/image-UQDATCXC.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:Tl(o,t,r,"local")})))),Jp(d,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[ol.png],fileHandle:s})}else if(e==="clipboard")try{let d=Nr(m);await Nd(d)}catch(d){throw console.warn(d),d.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):Cr&&d.name==="TypeError"?new Error(`${f("alerts.couldNotCopyToClipboard")}
4
+ `).map(i=>i.trim().split(","))),o.length===0)return{type:Wr,reason:"No values"};let t=o[0].length;if(!o.every(i=>i.length===t))return{type:Wr,reason:"All rows don't have same number of columns"};let n=Px(o);if(n.type!==Wn){let i=Px(V4(o));if(i.type===Wn)return i}return n},Gs=U4(G4),Ht={fillStyle:"hachure",fontFamily:Y4,fontSize:Dx,opacity:100,roughness:1,strokeColor:Ax.black,roundness:null,strokeStyle:"solid",strokeWidth:1,verticalAlign:W4.MIDDLE,locked:!1},Fx=e=>{let o=(eo+we)*e.values.length+we,t=lr+we*2;return{chartWidth:o,chartHeight:t}},X4=(e,o,t,r,n)=>e.labels?.map((i,a)=>Hs({groupIds:[r],backgroundColor:n,...Ht,text:i.length>8?`${i.slice(0,5)}...`:i,x:o+a*(eo+we)+we*2,y:t+we/2,width:eo,angle:5.87,fontSize:16,textAlign:"center",verticalAlign:"top"}))||[],K4=(e,o,t,r,n)=>{let i=Hs({groupIds:[r],backgroundColor:n,...Ht,x:o-we,y:t-we,text:"0",textAlign:"right"}),a=Hs({groupIds:[r],backgroundColor:n,...Ht,x:o-we,y:t-lr-i.height/2,text:Math.max(...e.values).toLocaleString(),textAlign:"right"});return[i,a]},Z4=(e,o,t,r,n)=>{let{chartWidth:i,chartHeight:a}=Fx(e),l=wa({backgroundColor:n,groupIds:[r],...Ht,type:"line",x:o,y:t,width:i,points:[ar(0,0),ar(i,0)]}),s=wa({backgroundColor:n,groupIds:[r],...Ht,type:"line",x:o,y:t,height:a,points:[ar(0,0),ar(0,-a)]}),d=wa({backgroundColor:n,groupIds:[r],...Ht,type:"line",x:o,y:t-lr-we,strokeStyle:"dotted",width:i,opacity:Nx,points:[ar(0,0),ar(i,0)]});return[l,s,d]},Ox=(e,o,t,r,n,i)=>{let{chartWidth:a,chartHeight:l}=Fx(e),s=e.title?Hs({backgroundColor:n,groupIds:[r],...Ht,text:e.title,x:o+a/2,y:t-lr-we*2-Dx,roundness:null,textAlign:"center"}):null,d=i?Hp({backgroundColor:n,groupIds:[r],...Ht,type:"rectangle",x:o,y:t-l,width:a,height:l,strokeColor:Ax.black,fillStyle:"solid",opacity:6}):null;return[...d?[d]:[],...s?[s]:[],...X4(e,o,t,r,n),...K4(e,o,t,r,n),...Z4(e,o,t,r,n)]},$4=(e,o,t)=>{let r=Math.max(...e.values),n=_x(),i=Gs[Math.floor(Math.random()*Gs.length)];return[...e.values.map((l,s)=>{let d=l/r*lr;return Hp({backgroundColor:i,groupIds:[n],...Ht,type:"rectangle",x:o+s*(eo+we)+we,y:t-d-we,width:eo,height:d})}),...Ox(e,o,t,n,i,Rx())]},j4=(e,o,t)=>{let r=Math.max(...e.values),n=_x(),i=Gs[Math.floor(Math.random()*Gs.length)],a=0,l=[];for(let b of e.values){let x=a*(eo+we),w=-(b/r)*lr;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=wa({backgroundColor:i,groupIds:[n],...Ht,type:"line",x:o+we+eo/2,y:t-we,height:d-c,width:s-m,strokeWidth:2,points:l}),u=e.values.map((b,x)=>{let w=x*(eo+we)+we/2,E=-(b/r)*lr+we/2;return Hp({backgroundColor:i,groupIds:[n],...Ht,fillStyle:"solid",strokeWidth:2,type:"ellipse",x:o+w+eo/2,y:t+E-we*2,width:we,height:we})}),f=e.values.map((b,x)=>{let w=x*(eo+we)+we/2,E=b/r*lr+we/2+we;return wa({backgroundColor:i,groupIds:[n],...Ht,type:"line",x:o+w+eo/2+we/2,y:t-E,height:E,strokeStyle:"dotted",opacity:Nx,points:[ar(0,0),ar(0,E)]})});return[...Ox(e,o,t,n,i,Rx()),p,...f,...u]},zx=(e,o,t,r)=>e==="line"?j4(o,t,r):$4(o,t,r);var bq="clipboard"in navigator&&"readText"in navigator.clipboard,Us="clipboard"in navigator&&"writeText"in navigator.clipboard,Vn="clipboard"in navigator&&"write"in navigator.clipboard&&"ClipboardItem"in window&&"toBlob"in HTMLCanvasElement.prototype,ik=e=>!!([va.excalidraw,va.excalidrawClipboard,va.excalidrawClipboardWithAPI].includes(e?.type)&&Array.isArray(e.elements)),Gx=({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},ak=({elements:e,files:o})=>{let t=J4(e),r=new Set(e.filter(l=>rk(l))),n=!1,i=e.reduce((l,s)=>(nk(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:va.excalidrawClipboard,elements:e.map(l=>{if(Hx(l,t)&&!r.has(Hx(l,t))){let s=ok(l);return tk(s,t,{frameId:null}),s}return l}),files:o?i:void 0};return JSON.stringify(a)},Ys=async(e,o,t)=>{await oo(ak({elements:e,files:o}),t)},lk=e=>{let o=Bx(e);return o.type===Wn?{spreadsheet:o.spreadsheet}:null};function Ux(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(Ux(t));return o}var sk=e=>{let o=e.clipboardData?.getData(to.html);if(!o)return null;try{let t=new DOMParser().parseFromString(o,to.html),r=Ux(t.body);if(r.length)return{type:"mixedContent",value:r}}catch(t){console.error(`error in parseHTMLFromPaste: ${t.message}`)}return null},Yx=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{[to.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(Q4(q4,r))try{if(r===to.text||r===to.html)e[r]=await(await t.getType(r)).text();else if(c1(r)){let n=await t.getType(r),i=f1(n,r,void 0);e[r]=i}else throw new dm(`Unsupported clipboard type: ${r}`)}catch(n){console.warn(n instanceof dm?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},ck=async(e,o=!1)=>{try{let t=!o&&e&&sk(e);return t?t.value.every(n=>n.type==="text")?{type:"text",value:e.clipboardData?.getData(to.text)||t.value.map(n=>n.value).join(`
5
+ `).trim()}:t:{type:"text",value:(e.clipboardData?.getData(to.text)||"").trim()}}catch{return{type:"text",value:""}}},Ws=async(e,o=!1)=>{let t=await ck(e,o);if(t.type==="mixedContent")return{mixedContent:t.value};try{let r=!o&&lk(t.value);if(r)return r}catch(r){console.error(r)}try{let r=JSON.parse(t.value),n=r.type===va.excalidrawClipboardWithAPI;if(ik(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}},Vs=async e=>{try{await navigator.clipboard.write([new window.ClipboardItem({[to.png]:e})])}catch(o){if(ek(e))await navigator.clipboard.write([new window.ClipboardItem({[to.png]:await e})]);else throw o}},oo=async(e,o)=>{if(Us)try{await navigator.clipboard.writeText(e||"");return}catch(t){console.error(t)}try{if(o){if(o.clipboardData?.setData(to.text,e||""),o.clipboardData?.getData(to.text)!==e)throw new Error("Failed to setData on clipboardEvent");return}}catch(t){console.error(t)}if(!dk(e))throw new Error("Error copying to clipboard.")},dk=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 Vr=(e,{selectedElementIds:o},t)=>{e=bk(e);let r=t&&Ee(e,{selectedElementIds:o}),n=null,i=r?j(e,{selectedElementIds:o},{includeBoundTextElement:!0}):e;return r&&(i.length===1&&xk(i[0])?(n=i[0],i=Ek(e,n)):i.length>1&&(i=j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}))),{exportingFrame:n,exportedElements:gk(i)}},Xr=async(e,o,t,r,{exportBackground:n,exportPadding:i=mk,viewBackgroundColor:a,name:l=t.name||pk,fileHandle:s=null,exportingFrame:d=null})=>{if(o.length===0)throw new Error(g("alerts.cannotExportEmptyCanvas"));if(e==="svg"||e==="clipboard-svg"){let c=fn(o,{exportBackground:n,exportWithDarkMode:t.exportWithDarkMode,viewBackgroundColor:a,exportPadding:i,exportScale:t.exportScale,exportEmbedScene:t.exportEmbedScene&&e==="svg"},r,{exportingFrame:d});if(e==="svg")return mm(c.then(p=>new Blob([fk+p.outerHTML],{type:hk.svg})),{description:"Export to SVG",name:l,extension:t.exportEmbedScene?"excalidraw.svg":"svg",mimeTypes:[Wx.svg],fileHandle:s});if(e==="clipboard-svg"){let p=await c.then(u=>u.outerHTML);try{await oo(p)}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return}}let m=_l(o,t,r,{exportBackground:n,viewBackgroundColor:a,exportPadding:i,exportingFrame:d});if(e==="png"){let c=ko(m);return t.exportEmbedScene&&(c=c.then(p=>import("./data/image-U3WTNYT7.js").then(({encodePngMetadata:u})=>u({blob:p,metadata:Yi(o,t,r,"local")})))),mm(c,{description:"Export to PNG",name:l,extension:t.exportEmbedScene?"excalidraw.png":"png",mimeTypes:[Wx.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")):uk&&c.name==="TypeError"?new Error(`${g("alerts.couldNotCopyToClipboard")}
6
6
 
7
- ${f("hints.firefox_clipboard_write")}`):new Error(f("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Qy=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=h0(a);if(!a||!g0(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}=xi(e,o,!1);return await Ei(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:c}),{fileHandle:a}};import{Fragment as V4,jsx as Hr,jsxs as Y4}from"react/jsx-runtime";var wh=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})=>Hr(Vy,{label:f("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),e2=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=Ee(e),i=ze(r,o)?J(r,o):r;return Hr(V4,{children:Hs.map(a=>{let[l,s]=p0(i,en,a),c=`${f("imageExportDialog.label.scale")} ${a}x (${l}x${s})`;return Hr(Q,{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)})})}}),Th=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})=>Hr($l,{checked:e.exportBackground,onChange:t=>o(t),children:f("imageExportDialog.label.withBackground")})}),Od=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})=>Y4($l,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[f("imageExportDialog.label.embedScene"),Hr(bo,{label:f("imageExportDialog.tooltip.embedScene"),long:!0,children:Hr("div",{className:"excalidraw-tooltip-icon",children:bx})})]})}),yi=z({name:"saveToActiveFile",label:"buttons.save",icon:pi,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}=Dc(o.fileHandle)?await Qy(e,o,r.files,r.getName()):await kc(e,o,r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,fileHandle:i,toast:n?{message:i?.name?f("toast.fileSavedToFilename").replace("{filename}",`"${i.name}"`):f("toast.fileSaved")}:null}}}catch(i){return i?.name!=="AbortError"?console.error(i):console.warn(i),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e[T.CTRL_OR_CMD]&&!e.shiftKey}),Jl=z({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:pi,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await kc(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:A.EVENTUALLY,appState:{...o,openDialog:null,fileHandle:n,toast:{message:f("toast.fileSaved")}}}}catch(n){return n?.name!=="AbortError"?console.error(n):console.warn(n),{captureUpdate:A.EVENTUALLY}}},keyTest:e=>e.key===T.S&&e.shiftKey&&e[T.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Hr(Q,{type:"button",icon:ux,title:f("buttons.saveAs"),"aria-label":f("buttons.saveAs"),showAriaLabel:Ce().editor.isMobile,hidden:!Qi,onClick:()=>e(null),"data-testid":"save-as-button"})}),wa=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 Qp(o,e);return{elements:n,appState:i,files:a,captureUpdate:A.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:A.EVENTUALLY}}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.O}),t2=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})=>Hr("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"-45px",marginBottom:"10px"},children:Hr(Uy,{value:e.exportWithDarkMode?de.DARK:de.LIGHT,onChange:t=>{o(t===de.DARK)},title:f("imageExportDialog.label.darkMode")})})});var o2="{}",Ch=z({name:"copyStyles",label:"labels.copyStyles",icon:Fu,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&pt(i)){let a=ge(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(o2=JSON.stringify(n)),{appState:{...o,toast:{message:f("toast.copyStyles")}},captureUpdate:A.EVENTUALLY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.C}),Ih=z({name:"pasteStyles",label:"labels.pasteStyles",icon:Fu,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(o2),i=n[0],a=n[1];if(!F1(i))return{elements:e,captureUpdate:A.EVENTUALLY};let l=J(e,o,{includeBoundTextElement:!0}),s=l.map(c=>c.id);return{elements:e.map(c=>{if(s.includes(c.id)){let m=i;if(Z(c)&&c.containerId&&(m=a),!m)return c;let d=oe(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?H1(m.roundness.type,c)?m.roundness:U1(c):null});if(Z(d)){let p=m.fontSize||Ir,u=m.fontFamily||qr;d=oe(d,{fontSize:p,fontFamily:u,textAlign:m.textAlign||Ns,lineHeight:m.lineHeight||kr(u)});let g=null;d.containerId&&(g=l.find(b=>Z(d)&&b.id===d.containerId)||null),Qe(d,g,r.scene.getNonDeletedElementsMap())}return d.type==="arrow"&&ke(m)&&(d=oe(d,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),ne(c)&&(d=oe(d,{roundness:null,backgroundColor:"transparent"})),d}return c}),captureUpdate:A.IMMEDIATELY}},keyTest:e=>e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.V});var Ta=(e,o)=>!!(!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&(e.activeTool.type!=="custom"&&(e.editingTextElement||e.activeTool.type!=="selection"&&e.activeTool.type!=="lasso"&&e.activeTool.type!=="eraser"&&e.activeTool.type!=="hand"&&e.activeTool.type!=="laser")||J(o,e).length));import{jsx as r2}from"react/jsx-runtime";var W4=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})=>r2(Q,{type:"button",icon:$c,"aria-label":f("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),K4=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})=>r2(Q,{visible:Ta(o,Ee(e)),type:"button",icon:hx,"aria-label":f("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),vi=z({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:sx,viewMode:!0,trackEvent:{category:"menu",action:"toggleHelpDialog"},perform:(e,o,t,{focusContainer:r})=>(o.openDialog?.name==="help"&&r(),{appState:{...o,openDialog:o.openDialog?.name==="help"?null:{name:"help"}},captureUpdate:A.EVENTUALLY}),keyTest:e=>e.key===T.QUESTION_MARK});import{jsx as Ca}from"react/jsx-runtime";var Z4=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&Ki(n,t),!0))return!0}return!1},n2=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!Z4(r)&&!uc(r)},Sh=z({name:"group",label:"labels.group",icon:e=>Ca(Nu,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=wb(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let i=Zo(o);if(i.length===1){let x=i[0],E=new Set(Fe(e,x).map(v=>v.id)),w=new Set(n.map(v=>v.id));if(new Set([...Array.from(E),...Array.from(w)]).size===E.size)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&yb(n).forEach((E,w)=>{dc(E,r.scene.getNonDeletedElementsMap())});let s=ro(),c=ee(n);a=a.map(x=>c.get(x.id)?oe(x,{groupIds:Rb(x.groupIds,s,o.editingGroupId)}):x);let m=Fe(a,s),d=m[m.length-1],p=a.lastIndexOf(d),u=a.slice(p+1),g=a.slice(0,p).filter(x=>!Ki(x,s)),b=Ut([...g,...m,...u],ee(m));return{appState:{...o,...Lb(s,{...o,selectedGroupIds:{}},Ee(a))},elements:b,captureUpdate:A.IMMEDIATELY}},predicate:(e,o,t,r)=>n2(e,o,r),keyTest:e=>!e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Ca(Q,{hidden:!n2(e,o,r),type:"button",icon:Ca(Nu,{theme:o.theme}),onClick:()=>t(null),title:`${f("labels.group")} \u2014 ${R("CtrlOrCmd+G")}`,"aria-label":f("labels.group"),visible:ze(Ee(e),o)})}),kh=z({name:"ungroup",label:"labels.ungroup",icon:e=>Ca(Ou,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Zo(o),i=ee(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:A.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{_e(p)&&l.push(p.id);let u=Nb(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:oe(p,{groupIds:u})});let s=lt(o,Ee(a),o,null),c=r.scene.getSelectedElements(o),m=new Set(c.filter(p=>p.frameId).map(p=>p.frameId));return vb(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=mc(a,Yi(a,p,o,i),p,r))}),s.selectedElementIds=Object.entries(s.selectedElementIds).reduce((p,[u,g])=>(g&&!l.includes(u)&&(p[u]=!0),p),{}),{appState:{...o,...s},elements:a,captureUpdate:A.IMMEDIATELY}},keyTest:e=>e.shiftKey&&e[T.CTRL_OR_CMD]&&e.key===T.G.toUpperCase(),predicate:(e,o)=>Zo(o).length>0,PanelComponent:({elements:e,appState:o,updateData:t})=>Ca(Q,{type:"button",hidden:Zo(o).length===0,icon:Ca(Ou,{theme:o.theme}),onClick:()=>t(null),title:`${f("labels.ungroup")} \u2014 ${R("CtrlOrCmd+Shift+G")}`,"aria-label":f("labels.ungroup"),visible:ze(Ee(e),o)})});import q4 from"clsx";var Bd=(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 X4(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 wi=(e,o)=>`hsl(${Math.abs(X4(o?.id||e))%37*10}, 100%, 83%)`,i2=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},a2=({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=wi(i,c);e.save(),e.strokeStyle=u,e.fillStyle=u;let g=o.remotePointerUserStates.get(i),b=p||g==="idle"||g==="away";b&&(e.globalAlpha=.3),o.remotePointerButton.get(i)==="down"&&(e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=3,e.strokeStyle="#ffffff88",e.stroke(),e.closePath(),e.beginPath(),e.arc(l,s,15,0,2*Math.PI,!1),e.lineWidth=1,e.strokeStyle=u,e.stroke(),e.closePath());let x=t.theme===de.DARK?"#2f6330":jf,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=tl,e.strokeStyle=tl,e.lineWidth=6,e.lineJoin="round",e.beginPath(),e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.stroke(),e.fill(),e.fillStyle=u,e.strokeStyle=u,e.lineWidth=2,e.lineJoin="round",e.beginPath(),b?(e.moveTo(l-1,s-1),e.lineTo(l-1,s+15),e.lineTo(l+5,s+10),e.lineTo(l+12,s+9),e.closePath(),e.fill()):(e.moveTo(l,s),e.lineTo(l+0,s+14),e.lineTo(l+4,s+9),e.lineTo(l+11,s+8),e.closePath(),e.fill(),e.stroke());let w=o.remotePointerUsernames.get(i)||"";if(!p&&w){e.font="600 12px sans-serif";let y=(E?l+0:l)+m/2,v=(E?s+0:s)+d+2,I=5,S=3,_=e.measureText(w),L=_.actualBoundingBoxDescent+_.actualBoundingBoxAscent,N=Math.max(L,12),P=y-1,F=v-1,K=_.width+2+I*2+2,U=N+2+S*2+2;if(e.roundRect?(e.beginPath(),e.roundRect(P,F,K,U,8),e.fillStyle=u,e.fill(),e.strokeStyle=tl,e.stroke(),E&&(e.beginPath(),e.roundRect(P-2,F-2,K+4,U+4,8),e.strokeStyle=x,e.stroke())):Bd(e,P,F,K,U,8,tl),e.fillStyle=$f,e.fillText(w,y+I+1,v+S+_.actualBoundingBoxAscent+Math.floor((N-L)/2)+2),E){e.fillStyle=x;let q=8,H=8,G=5;e.fillRect(P+K+H,F+(U/2-q/2),2,q),e.fillRect(P+K+H+G,F+(U/2-q*2/2),2,q*2),e.fillRect(P+K+H+G*2,F+(U/2-q/2),2,q)}}e.restore(),e.closePath()}};import $4 from"clsx";import{useState as j4}from"react";import{jsx as l2}from"react/jsx-runtime";var Mh=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=i2(t),[a,l]=j4(!1),s=!a&&r,c=s?void 0:{background:e};return l2("div",{className:$4("Avatar",n),style:c,onClick:o,children:s?l2("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as fr,jsxs as zd}from"react/jsx-runtime";var J4=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=wi(r,n),s=q4({"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?zd("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:f("userList.hint.isSpeaking"),children:[fr("div",{}),fr("div",{}),fr("div",{})]}):n.isMuted?fr("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:f("userList.hint.micMuted"),children:xE}):fr("div",{title:f("userList.hint.inCall"),children:bE}):null;return i?zd("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[fr(Mh,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),fr("div",{className:"UserList__collaborator-name",children:n.username}),zd("div",{className:"UserList__collaborator-status-icons","aria-hidden":!0,children:[a&&fr("div",{className:"UserList__collaborator-status-icon-is-followed",title:f("userList.hint.followStatus"),children:ma}),c]})]}):zd("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[fr(Mh,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),c&&fr("div",{className:"UserList__collaborator-status-icon",children:c})]})}});var Lh=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 Vs)if(n.some(a=>a.type===i))return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:ro(),status:"unpublished",elements:n.map(uo),created:Date.now()},...i])).then(()=>({captureUpdate:A.EVENTUALLY,appState:{...o,toast:{message:f("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});var s2=(e,o,t,r)=>{let n=oi(e,o),i=Dt(e);return n.flatMap(a=>{let l=Q4(a,i,t);return a.map(s=>{let c=B(s,{x:s.x+l.x,y:s.y+l.y});return at(s,r.getNonDeletedElementsMap(),{simultaneouslyUpdated:a}),c})})},Q4=(e,o,{axis:t,position:r})=>{let n=Dt(e),[i,a]=t==="x"?["minX","maxX"]:["minY","maxY"],l={x:0,y:0};return r==="start"?{...l,[t]:o[i]-n[i]}:r==="end"?{...l,[t]:o[a]-n[a]}:{...l,[t]:(o[i]+o[a])/2-(n[i]+n[a])/2}};import{jsx as Sa}from"react/jsx-runtime";var io=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ne(r))},Ia=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=ee(e),a=s2(n,i,r,t.scene),l=ee(a);return lr(e.map(s=>l.get(s.id)||s),o,t)},eC=z({name:"alignTop",label:"labels.alignTop",icon:Lu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"start",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:Lu,onClick:()=>t(null),title:`${f("labels.alignTop")} \u2014 ${R("CtrlOrCmd+Shift+Up")}`,"aria-label":f("labels.alignTop"),visible:ze(Ee(e),o)})}),tC=z({name:"alignBottom",label:"labels.alignBottom",icon:Au,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"end",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:Au,onClick:()=>t(null),title:`${f("labels.alignBottom")} \u2014 ${R("CtrlOrCmd+Shift+Down")}`,"aria-label":f("labels.alignBottom"),visible:ze(Ee(e),o)})}),oC=z({name:"alignLeft",label:"labels.alignLeft",icon:_u,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"start",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:_u,onClick:()=>t(null),title:`${f("labels.alignLeft")} \u2014 ${R("CtrlOrCmd+Shift+Left")}`,"aria-label":f("labels.alignLeft"),visible:ze(Ee(e),o)})}),rC=z({name:"alignRight",label:"labels.alignRight",icon:Du,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"end",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>e[T.CTRL_OR_CMD]&&e.shiftKey&&e.key===T.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:Du,onClick:()=>t(null),title:`${f("labels.alignRight")} \u2014 ${R("CtrlOrCmd+Shift+Right")}`,"aria-label":f("labels.alignRight"),visible:ze(Ee(e),o)})}),nC=z({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Pu,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"center",axis:"y"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:Pu,onClick:()=>t(null),title:f("labels.centerVertically"),"aria-label":f("labels.centerVertically"),visible:ze(Ee(e),o)})}),iC=z({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Ru,trackEvent:{category:"element"},predicate:(e,o,t,r)=>io(o,r),perform:(e,o,t,r)=>({appState:o,elements:Ia(e,o,r,{position:"center",axis:"x"}),captureUpdate:A.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Sa(Q,{hidden:!io(o,r),type:"button",icon:Ru,onClick:()=>t(null),title:f("labels.centerHorizontally"),"aria-label":f("labels.centerHorizontally"),visible:ze(Ee(e),o)})});var c2=(e,o,t)=>{let[r,n,i,a]=t.axis==="x"?["minX","midX","maxX","width"]:["minY","midY","maxY","height"],l=Dt(e),s=oi(e,o).map(p=>[p,Dt(p)]).sort((p,u)=>p[1][n]-u[1][n]),c=0;for(let p of s)c+=p[1][a];let m=(l[a]-c)/(s.length-1);if(m<0){let p=s.findIndex(x=>x[1][r]===l[r]),u=s.findIndex(x=>x[1][i]===l[i]),g=(s[u][1][n]-s[p][1][n])/(s.length-1),b=s[p][1][n];return s.flatMap(([x,E],w)=>{let y={x:0,y:0};return w!==p&&w!==u&&(b+=g,y[t.axis]=b-E[n]),x.map(v=>oe(v,{x:v.x+y.x,y:v.y+y.y}))})}let d=l[r];return s.flatMap(([p,u])=>{let g={x:0,y:0};return g[t.axis]=d-u[r],d+=m,d+=u[a],p.map(b=>oe(b,{x:b.x+g.x,y:b.y+g.y}))})};import{jsx as p2}from"react/jsx-runtime";var d2=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length>1&&!t.some(r=>ne(r))},m2=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=c2(n,t.scene.getNonDeletedElementsMap(),r),a=ee(i);return lr(e.map(l=>a.get(l.id)||l),o,t)},aC=z({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:m2(e,o,r,{space:"between",axis:"x"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>p2(Q,{hidden:!d2(o,r),type:"button",icon:vx,onClick:()=>t(null),title:`${f("labels.distributeHorizontally")} \u2014 ${R("Alt+H")}`,"aria-label":f("labels.distributeHorizontally"),visible:ze(Ee(e),o)})}),lC=z({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:m2(e,o,r,{space:"between",axis:"y"}),captureUpdate:A.IMMEDIATELY}),keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>p2(Q,{hidden:!d2(o,r),type:"button",icon:wx,onClick:()=>t(null),title:`${f("labels.distributeVertically")} \u2014 ${R("Alt+V")}`,"aria-label":f("labels.distributeVertically"),visible:ze(Ee(e),o)})});var Ah=z({name:"flipHorizontal",label:"labels.flipHorizontal",icon:wE,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:lr(u2(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===pe.H}),_h=z({name:"flipVertical",label:"labels.flipVertical",icon:vE,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:lr(u2(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:A.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===pe.V&&!e[T.CTRL_OR_CMD]}),u2=(e,o,t,r,n)=>{let i=J(Ee(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=sC(i,o,t,r,n),l=ee(a);return e.map(s=>l.get(s.id)||s)},sC=(e,o,t,r,n)=>{if(e.every(u=>ke(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let g=u;return oe(g,{startArrowhead:g.endArrowhead,endArrowhead:g.startArrowhead})});let{midX:i,midY:a}=Dt(e);mu(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,uo(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),Qn(e.filter(ae),o,n.scene.getNonDeletedElements(),n.scene,Jn(t),[],t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,g)=>te(g)?{...u,elbowArrows:u.elbowArrows.concat(g)}:{...u,otherElements:u.otherElements.concat(g)},{elbowArrows:[],otherElements:[]}),{midX:c,midY:m}=Dt(e),[d,p]=[i-c,a-m];return s.forEach(u=>B(u,{x:u.x+d,y:u.y+p})),l.forEach(u=>B(u,{x:u.x+d,y:u.y+p})),e};var ka=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 Pd(n,r.files,t)}catch(i){return{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),Dh=z({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await Jy()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),Cr?{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("hints.firefox_clipboard_write")}}:{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(jy({types:n}))}catch(i){return console.error(i),{captureUpdate:A.EVENTUALLY,appState:{...o,errorMessage:f("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:A.EVENTUALLY}},keyTest:void 0}),Fd=z({name:"cut",label:"labels.cut",icon:aE,trackEvent:{category:"element"},perform:(e,o,t,r)=>(ka.perform(e,o,t,r),Ul.perform(e,o,null,r)),keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.X}),Hd=z({name:"copyAsSvg",label:"labels.copyAsSvg",icon:TE,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:A.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=xi(e,o,!0);try{await Ei("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:f("toast.copyToClipboardAsSvg",{exportSelection:a.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:o.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:A.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:A.EVENTUALLY}}},predicate:e=>Dd&&e.length>0,keywords:["svg","clipboard","copy"]}),Ud=z({name:"copyAsPng",label:"labels.copyAsPng",icon:CE,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}=xi(e,o,!0);try{return await Ei("clipboard",i,o,r.files,{...o,exportingFrame:a,name:r.getName()}),{appState:{...o,toast:{message:f("toast.copyToClipboardAsPng",{exportSelection:n.length?f("toast.selection"):f("toast.canvas"),exportColorScheme:o.exportWithDarkMode?f("buttons.darkMode"):f("buttons.lightMode")})}},captureUpdate:A.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:A.EVENTUALLY}}},predicate:e=>va&&e.length>0,keyTest:e=>e.code===pe.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),Gd=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{Jo(Ap(n))}catch{throw new Error(f("errors.copyToSystemClipboardFailed"))}return{captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>Dd&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(Z),keywords:["text","clipboard","copy"]});var Vd=z({name:"gridMode",icon:LE,keywords:["snap"],label:"labels.toggleGrid",viewMode:!0,trackEvent:{category:"canvas",predicate:e=>e.gridModeEnabled},perform(e,o){return{appState:{...o,gridModeEnabled:!this.checked(o),objectsSnapModeEnabled:!1},captureUpdate:A.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.code===pe.QUOTE});var Ma=z({name:"zenMode",label:"buttons.zenMode",icon:SE,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:A.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.Z});var Ph=z({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:IE,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:A.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.S});var La=z({name:"stats",label:"stats.fullTitle",icon:yE,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:A.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.SLASH});var Rh=z({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>pt(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=ge(a,i);if(l){let{width:s,height:c}=Ht(l.originalText,qe(l),l.lineHeight),m=Q1(a.id);J1(a.id);let{x:d,y:p}=rc(a,l,i);B(l,{containerId:null,width:s,height:c,text:l.originalText,x:d,y:p}),B(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:A.IMMEDIATELY}}}),Nh=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=Z(n[0])||Z(n[1]),a;if(Dr(n[0])?a=n[0]:Dr(n[1])&&(a=n[1]),i&&a&&ge(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;Z(n[0])&&Dr(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),B(i,{containerId:a.id,verticalAlign:Qt.MIDDLE,textAlign:rl.CENTER,autoResize:!0,angle:ke(a)?0:a?.angle??0}),B(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return Qe(i,a,r.scene.getNonDeletedElementsMap()),ul(a.id,l),{elements:cC(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:A.IMMEDIATELY}}}),cC=(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),Ut(r,ee([o,t])),r},dC=(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),Ut(r,ee([o,t])),r},h2=z({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>Z(a));return n.length>0&&i},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=e.slice(),a={};for(let l of n)if(Z(l)){let s=Gt({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:Bi("rectangle")?eo.ADAPTIVE_RADIUS:eo.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-gp,y:l.y-gp,width:Ui(l.width,"rectangle"),height:Ui(l.height,"rectangle"),groupIds:l.groupIds,frameId:l.frameId});if(l.boundElements?.length){let c=l.boundElements.filter(d=>d.type==="arrow").map(d=>d.id);i.filter(d=>c.includes(d.id)).forEach(d=>{let p=d.startBinding,u=d.endBinding;p?.elementId===l.id&&(p={...p,elementId:s.id}),u?.elementId===l.id&&(u={...u,elementId:s.id}),(p||u)&&B(d,{startBinding:p,endBinding:u},!1)})}B(l,{containerId:s.id,verticalAlign:Qt.MIDDLE,boundElements:null,textAlign:rl.CENTER,autoResize:!0},!1),Qe(l,s,r.scene.getNonDeletedElementsMap()),i=dC([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:A.IMMEDIATELY}}});import mC from"clsx";import{useCallback as g2,useEffect as f2,useLayoutEffect as pC,useRef as uC,useState as hC}from"react";import{jsx as Aa,jsxs as b2}from"react/jsx-runtime";var zh=380,gC=42,Oh=5,x2=85,fC=500,Bh=!1,Yd=new Map,E2=({element:e,elementsMap:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=ur(),l=hr(),s=Ce(),c=e.link||"",[m,d]=hC(c),p=uC(null),u=a.showHyperlinkPopup==="editor",g=g2(()=>{if(!p.current)return;let y=Wo(p.current.value)||null;if(!e.link&&y&&xe("hyperlink","create"),Ft(e)){if(a.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!y){B(e,{link:null}),i(e,!1);return}if(!qi(y,l.validateEmbeddable))y&&n({message:f("toast.unableToEmbed"),closable:!0}),e.link&&Yd.set(e.id,e.link),B(e,{link:y}),i(e,!1);else{let{width:v,height:I}=e,S=ni(y);S?.error instanceof URIError&&n({message:f("toast.unrecognizedLinkFormat"),closable:!0});let _=S?S.intrinsicSize.w/S.intrinsicSize.h:1,L=Yd.get(e.id)!==e.link;B(e,{...L?{width:S?.type==="video"?v>I?v:I*_:v,height:S?.type==="video"&&v>I?v/_:I}:{},link:y}),i(e,!0),Yd.has(e.id)&&Yd.delete(e.id)}}else B(e,{link:y})},[e,n,l.validateEmbeddable,a.activeEmbeddable,t,i]);pC(()=>()=>{g()},[g]),f2(()=>{u&&p?.current&&!(s.viewport.isMobile||s.isTouchScreen)&&p.current.select()},[u,s.viewport.isMobile,s.isTouchScreen]),f2(()=>{let y=null,v=I=>{if(u)return;y&&clearTimeout(y),xC(e,o,a,M(I.clientX,I.clientY))&&(y=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},fC))};return window.addEventListener("pointermove",v,!1),()=>{window.removeEventListener("pointermove",v,!1),y&&clearTimeout(y)}},[a,e,u,t,o]);let b=g2(()=>{xe("hyperlink","delete"),B(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e]),x=()=>{xe("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y:w}=y2(e,a,o);return a.contextMenu||a.selectedElementsAreBeingDragged||a.resizingElement||a.isRotating||a.openMenu||a.viewModeEnabled?null:b2("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${w}px`,left:`${E}px`,width:zh,padding:Oh},children:[u?Aa("input",{className:mC("excalidraw-hyperlinkContainer-input"),placeholder:f("labels.link.hint"),ref:p,value:m,onChange:y=>d(y.target.value),autoFocus:!0,onKeyDown:y=>{y.stopPropagation(),y[T.CTRL_OR_CMD]&&y.key===T.K&&y.preventDefault(),(y.key===T.ENTER||y.key===T.ESCAPE)&&(g(),t({showHyperlinkPopup:"info"}))}}):e.link?Aa("a",{href:Wo(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:Js(e.link)?"_self":"_blank",onClick:y=>{if(e.link&&r){let v=js("excalidraw-link",y.nativeEvent);r({...e,link:Wo(e.link)},v),v.defaultPrevented&&y.preventDefault()}},rel:"noopener noreferrer",children:e.link}):Aa("div",{className:"excalidraw-hyperlinkContainer-link",children:f("labels.link.empty")}),b2("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!u&&Aa(Q,{type:"button",title:f("buttons.edit"),"aria-label":f("buttons.edit"),label:f("buttons.edit"),onClick:x,className:"excalidraw-hyperlinkContainer--edit",icon:gn}),Aa(Q,{type:"button",title:f("labels.linkToElement"),"aria-label":f("labels.linkToElement"),label:f("labels.linkToElement"),onClick:()=>{t({openDialog:{name:"elementLinkSelector",sourceElementId:e.id}})},icon:sd}),c&&!Ft(e)&&Aa(Q,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:b,className:"excalidraw-hyperlinkContainer--remove",icon:ho})]})]})},y2=(e,o,t)=>{let[r,n]=We(e,t),{x:i,y:a}=zt({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-zh/2,s=a-o.offsetTop-x2;return{x:l,y:s}},Fh=(e,o)=>{let t=J(e,o);return Ft(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Ql=null,v2=(e,o,t)=>{Ql&&clearTimeout(Ql),Ql=window.setTimeout(()=>bC(e,o,t),r1)},bC=(e,o,t)=>{if(!e.link)return;let r=Ea();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=ii(e.link)?f("labels.link.goToElement"):e.link;let[n,i,a,l]=We(e,t),[s,c,m,d]=s0([n,i,a,l],e.angle,o),p=zt({sceneX:s,sceneY:c},o);Eh(r,{left:p.x,top:p.y,width:m,height:d},"top"),xe("hyperlink","tooltip","link-icon"),Bh=!0},Hh=()=>{Ql&&clearTimeout(Ql),Bh&&(Bh=!1,Ea().classList.remove("excalidraw-tooltip--visible"))},xC=(e,o,t,[r,n])=>{let{x:i,y:a}=$e({clientX:r,clientY:n},t),l=15/t.zoom.value;if(V1(i,a,e,o))return!1;let[s,c,m]=We(e,o);if(i>=s&&i<=m&&a>=c-x2&&a<=c)return!1;let{x:d,y:p}=y2(e,t,o);return!(r>=d-l&&r<=d+zh+Oh*2+l&&n>=p-l&&n<=p+l+Oh*2+gC)};import{jsx as EC}from"react/jsx-runtime";var es=z({name:"hyperlink",label:(e,o)=>Fh(e,o),icon:Nl,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:A.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.K,predicate:(e,o)=>J(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=J(e,o);return EC(Q,{type:"button",icon:Nl,"aria-label":f(Fh(e,o)),title:`${Ft(e[0])?f("labels.link.labelEmbed"):f("labels.link.label")} - ${R("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});var Uh=e=>e.every(o=>!o.locked),Gh=z({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return r.length===1&&!ne(r[0])?r[0].locked?"labels.elementLock.unlock":"labels.elementLock.lock":Uh(r)?"labels.elementLock.lockAll":"labels.elementLock.unlockAll"},icon:(e,o)=>{let t=J(o,e);return Uh(t)?aa:mi},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=Uh(n),a=ee(n);return{elements:e.map(l=>a.has(l.id)?oe(l,{locked:i}):l),appState:{...o,selectedLinearElement:i?null:o.selectedLinearElement},captureUpdate:A.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===T.L&&e[T.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),w2=z({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:mi,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?oe(r,{locked:!1}):r),appState:{...o,selectedElementIds:Object.fromEntries(t.map(r=>[r.id,!0]))},captureUpdate:A.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import Sv from"clsx";import mS from"fuzzy";import{useEffect as dm,useRef as pS,useState as cm}from"react";var Wd=z({name:"copyElementLink",label:"labels.copyElementLink",icon:ca,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=J(e,o);try{if(window.location){let i=Cc(n,o);return i?(await Jo(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):Tc(i.id,i.type)),{appState:{toast:{message:f("toast.elementLinkCopied"),closable:!0}},captureUpdate:A.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:A.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:A.EVENTUALLY}},predicate:(e,o)=>Ic(J(e,o))}),T2=z({name:"linkToElement",label:"labels.linkToElement",icon:sd,perform:(e,o,t,r)=>{let n=J(e,o);return n.length!==1||!Ic(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&&Ic(n)},trackEvent:!1});var yC={toggleTheme:[R("Shift+Alt+D")],saveScene:[R("CtrlOrCmd+S")],loadScene:[R("CtrlOrCmd+O")],clearCanvas:[R("CtrlOrCmd+Delete")],imageExport:[R("CtrlOrCmd+Shift+E")],commandPalette:[R("CtrlOrCmd+/"),R("CtrlOrCmd+Shift+P")],cut:[R("CtrlOrCmd+X")],copy:[R("CtrlOrCmd+C")],paste:[R("CtrlOrCmd+V")],copyStyles:[R("CtrlOrCmd+Alt+C")],pasteStyles:[R("CtrlOrCmd+Alt+V")],selectAll:[R("CtrlOrCmd+A")],deleteSelectedElements:[R("Delete")],duplicateSelection:[R("CtrlOrCmd+D"),R(`Alt+${f("helpDialog.drag")}`)],sendBackward:[R("CtrlOrCmd+[")],bringForward:[R("CtrlOrCmd+]")],sendToBack:[Uo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")],bringToFront:[Uo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")],copyAsPng:[R("Shift+Alt+C")],group:[R("CtrlOrCmd+G")],ungroup:[R("CtrlOrCmd+Shift+G")],gridMode:[R("CtrlOrCmd+'")],zenMode:[R("Alt+Z")],objectsSnapMode:[R("Alt+S")],stats:[R("Alt+/")],addToLibrary:[],flipHorizontal:[R("Shift+H")],flipVertical:[R("Shift+V")],viewMode:[R("Alt+R")],hyperlink:[R("CtrlOrCmd+K")],toggleElementLock:[R("CtrlOrCmd+Shift+L")],resetZoom:[R("CtrlOrCmd+0")],zoomOut:[R("CtrlOrCmd+-")],zoomIn:[R("CtrlOrCmd++")],zoomToFitSelection:[R("Shift+3")],zoomToFit:[R("Shift+1")],zoomToFitSelectionInViewport:[R("Shift+2")],toggleEraserTool:[R("E")],toggleHandTool:[R("H")],setFrameAsActiveTool:[R("F")],saveFileToDisk:[R("CtrlOrCmd+S")],saveToActiveFile:[R("CtrlOrCmd+S")],toggleShortcuts:[R("?")],searchMenu:[R("CtrlOrCmd+F")],wrapSelectionInFrame:[]},ct=(e,o=0)=>{let t=yC[e];return t&&t.length>0?t[o]||t[0]:""};var vC="\\u0300-\\u036f",wC="\\ufe20-\\ufe2f",TC="\\u20d0-\\u20ff",CC=vC+wC+TC,IC=`[${CC}]`,SC=RegExp(IC,"g"),kC=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,MC={\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"},Vh=e=>e.replace(kC,o=>MC[o]||o).replace(SC,"");import KI from"clsx";import{useEffect as ZI,useState as XI}from"react";import{useCallback as LC,useState as AC}from"react";var C2=()=>{let[e,o]=AC(null),t=LC(r=>o(r),[]);return[e,t]};import{useState as mv,useCallback as eg,useMemo as pv,useEffect as sv,memo as uv,useRef as FI}from"react";import{useEffect as M2,useRef as L2}from"react";var Tn=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=ta({elements:e,appState:o},null,null),{exportBackground:c,viewBackgroundColor:m}=s;return _c(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 g=n?.(d,p)||{width:d,height:p};return u.width=g.width,u.height=g.height,{canvas:u,scale:g.scale??1}})},I2=async e=>{let{mimeType:o=ue.png,quality:t}=e;o===ue.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${ue.png}" mimeType`),o==="image/jpg"&&(o=ue.jpg),o===ue.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${ue.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await Tn(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===ue.png&&e.appState?.exportEmbedScene&&(a=await u0({blob:a,metadata:Tl(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},_a=async({elements:e,appState:o=mr(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:c}=ta({elements:e,appState:o},null,null),m={...c,exportPadding:r};return ea(s,m,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},_C=async e=>{if(e.type==="svg"){let o=await _a(e);await Jo(o.outerHTML)}else if(e.type==="png")await Nd(I2(e));else if(e.type==="json")await Pd(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as DC,useState as PC}from"react";var Yh=De(new Map),S2=async e=>await _a({elements:e,appState:{exportBackground:!1,viewBackgroundColor:Io.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),k2=(e,o,t)=>{let[r,n]=PC();return DC(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await S2(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await S2(o);n(i)})()},[e,o,t,n]),r},Kd=()=>{let[e]=ve(Yh);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var RC=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],_2=new Pt,Ti=De({status:"loaded",isInitialized:!1,libraryItems:[]}),ts=e=>oo(e),NC=(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)),D2=(e,o)=>{let t=[];for(let r of o)NC(e,r)&&t.push(r);return[...t,...e]},P2=(e,o)=>{let t=ee(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=ee(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},Wh=class{constructor(o){C(this,"currLibraryItems",[]);C(this,"prevLibraryItems",ts(this.currLibraryItems));C(this,"app");C(this,"updateQueue",[]);C(this,"getLastUpdateTask",()=>this.updateQueue[this.updateQueue.length-1]);C(this,"notifyListeners",()=>{if(this.updateQueue.length>0)St.set(Ti,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{St.set(Ti,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=ts(this.currLibraryItems);let t=ts(this.currLibraryItems);this.app.props.onLibraryChange?.(t),_2.trigger(P2(o,t),t)}catch(o){console.error(o)}}});C(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],St.set(Yh,new Map)});C(this,"resetLibrary",()=>this.setLibrary([]));C(this,"getLatestLibrary",()=>new Promise(async o=>{try{let t=await(this.getLastUpdateTask()||this.currLibraryItems);this.updateQueue.length>0?o(this.getLatestLibrary()):o(ts(t))}catch{return o(this.currLibraryItems)}}));C(this,"updateLibrary",async({libraryItems:o,prompt:t=!1,merge:r=!1,openLibraryMenu:n=!1,defaultStatus:i="unpublished"})=>(n&&this.app.setState({openSidebar:{name:At.name,tab:nl}}),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 ru(s,i):c=Il(s,i),!t||window.confirm(f("alerts.confirmAddLibrary",{numShapes:c.length}))?(t&&this.app.focusContainer(),a(r?D2(this.currLibraryItems,c):c)):l(new Ji)}catch(s){l(s)}}))));C(this,"setLibrary",o=>{let t=new Promise(async(r,n)=>{try{await this.getLastUpdateTask(),typeof o=="function"&&(o=o(this.currLibraryItems)),this.currLibraryItems=ts(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}},R2=Wh,$d=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:E}=Dt(x.elements);return Math.max(b,E)},0),i=u=>{let g=0,b=0,x=0;for(let E of e){if(g%t===0&&(b=0),b===u){let{width:w}=Dt(E.elements);x=Math.max(x,w)}g++,b++}return x},a=0,l=0,s=0,c=0,m=0,d=0,p=0;for(let u of e){m&&m%t===0&&(l+=s+50,a=0,d=0,p++),d===0&&(s=n(p)),c=i(d);let{minX:g,minY:b,width:x,height:E}=Dt(u.elements),w=(c-x)/2,y=(s-E)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+w-g,y:v.y+l+y-b}))),a+=c+50,m++,d++}return r},OC=(e,o=RC)=>{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}"`)},Kh=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(Fs.addLibrary)||new URLSearchParams(window.location.search).get(zs.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},Cn=class Cn{constructor(o){C(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(Il(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?Cn.queue.push(n):n()}getLibraryItems(o){return Cn.getLibraryItems(this.adapter,o,!1)}};C(Cn,"queue",new g1),C(Cn,"run",async(o,t)=>{let r=new Cn(o);return Cn.queue.push(()=>t(r))});var Da=Cn,os=0,Zd=0,Xd=e=>Op(e.map(o=>`${o.id}:${Np(o.elements)}`).sort().join()),A2=async(e,o)=>{try{return Zd++,await Da.run(e,async t=>{let r=ee(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=Xd(i);return a!==os&&await e.save({libraryItems:i}),os=a,i})}finally{Zd--}},BC=e=>{let{excalidrawAPI:o}=e,t=L2(e);t.current=e;let r=L2(!1);M2(()=>{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=Qs(l),OC(l,t.current.validateLibraryUrl);let g=await(await fetch(l)).blob();d(g)}catch(u){p(u)}}),m=s!==o.id;await(m&&document.hidden?new Promise(d=>{window.addEventListener("focus",()=>d(),{once:!0})}):null);try{await o.updateLibrary({libraryItems:c,prompt:m,merge:!0,defaultStatus:"published",openLibraryMenu:!0})}catch(d){throw o.updateScene({appState:{errorMessage:d.message}}),d}finally{if(window.location.hash.includes(Fs.addLibrary)){let d=new URLSearchParams(window.location.hash.slice(1));d.delete(Fs.addLibrary),window.history.replaceState({},Ja,`#${d.toString()}`)}else if(window.location.search.includes(zs.addLibrary)){let d=new URLSearchParams(window.location.search);d.delete(zs.addLibrary),window.history.replaceState({},Ja,`?${d.toString()}`)}}},i=l=>{l.preventDefault();let s=Kh();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Kh();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 Da.getLibraryItems(l,"load");d=Il(m.libraryItems||[],"published");let p=await A2(l,P2([],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}`),Da.getLibraryItems(l,"load")))):c.resolve(Mp(Da.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:c.then(m=>{let d=m||[];return os=Xd(d),d}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener("hashchange",i),()=>{window.removeEventListener("hashchange",i)}},[o]),M2(()=>{let n=_2.on(async(a,l)=>{let s=r.current,c="adapter"in t.current&&t.current.adapter||null;try{c&&os!==Xd(l)&&await A2(c,a)}catch(m){console.error(`couldn't persist library update: ${m.message}`,a),s&&t.current.excalidrawAPI&&t.current.excalidrawAPI.updateScene({appState:{errorMessage:f("errors.saveLibraryError")}})}}),i=a=>{Zd&&M1(a)};return window.addEventListener("beforeunload",i),()=>{window.removeEventListener("beforeunload",i),n(),os=0,Zd=0}},[])};import HC from"clsx";import{jsx as FC}from"react/jsx-runtime";var zC=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return FC("a",{className:"library-menu-browse-button",href:`${k.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${Us.excalidrawLibrary}`,target:"_excalidraw_libraries",children:f("labels.libraries")})},N2=zC;import{jsx as UC,jsxs as GC}from"react/jsx-runtime";var jd=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>GC("div",{className:HC("library-menu-control-buttons",i),style:r,children:[UC(N2,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as Na,useEffect as RI,useMemo as av,useRef as NI,useState as OI}from"react";import VC from"lodash.throttle";import{useEffect as YC}from"react";var WC=De(0),O2=e=>{let[o,t]=ve(WC);return YC(()=>{let{current:r}=e;if(!r)return;let n=VC(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import xI from"clsx";import{useCallback as EI,useState as $h}from"react";import{flushSync as B2}from"react-dom";import KC from"clsx";import{jsx as qd,jsxs as XC}from"react/jsx-runtime";var ZC=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return XC("button",{className:KC("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&qd("div",{style:a?{visibility:"hidden"}:{},children:r}),qd("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&qd("div",{style:{position:"absolute",inset:0},children:qd(Mt,{})})]})},Ur=ZC;import{jsx as z2,jsxs as F2}from"react/jsx-runtime";var $C=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=f("buttons.confirm"),cancelText:i=f("buttons.cancel"),className:a="",...l}=e,s=Ie(),c=hn(Pa),{container:m}=gt();return F2(dt,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,F2("div",{className:"confirm-dialog-buttons",children:[z2(Ur,{label:i,onClick:()=>{s({openMenu:null}),c(!1),B2(()=>{t()}),m?.focus()}}),z2(Ur,{label:n,onClick:()=>{s({openMenu:null}),c(!1),B2(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},Jd=$C;import em from"open-color";import{useCallback as oI,useEffect as Xh,useRef as H2,useState as Zh}from"react";var Ro=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}}};C(Ro,"set",(o,t)=>{try{return window.localStorage.setItem(o,JSON.stringify(t)),!0}catch(r){return console.warn(`localStorage.setItem error: ${r.message}`),!1}}),C(Ro,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import Qd from"react";var jC=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,qC=/{{([\w-]+)}}/,JC=/<([\w-]+)>/,QC=/<\/([\w-]+)>/,eI=(e,o)=>{let t=[{name:"",children:[]}];return e.split(jC).filter(Boolean).forEach(r=>{let n=r.match(JC),i=r.match(QC),a=r.match(qC);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=Qd.createElement(Qd.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},tI=({i18nKey:e,children:o,...t})=>{let{t:r}=ut();return Qd.createElement(Qd.Fragment,{},...eI(r(e),t))},Kt=tI;import{jsx as we,jsxs as Nt}from"react/jsx-runtime";var rI=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=C1(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=em.white,l.fillRect(0,0,a.width,a.height);for(let[s,c]of e.entries()){let m=await Tn({elements:c.elements,files:null,maxWidthOrHeight:128}),{width:d,height:p}=m,u=Math.floor(s/6)*(128+r*2),g=s%6*(128+r*2);l.drawImage(m,g+(128-d)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=em.gray[4],l.strokeRect(g+r/2,u+r/2,128+r,128+r)}return await Sl(new File([await Nr(a)],"preview",{type:ue.png}),{outputType:ue.jpg,maxWidthOrHeight:5e3})},nI=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=H2(null),a=H2(null);return Xh(()=>{let l=i.current;l&&(async()=>{let s=await _a({elements:e.elements,appState:{...o,viewBackgroundColor:em.white,exportBackground:!0},files:null,skipInliningFonts:!0});l.innerHTML=s.outerHTML})()},[e.elements,o]),Nt("div",{className:"single-library-item",children:[e.status==="published"&&we("span",{className:"single-library-item-status",children:f("labels.statusPublished")}),we("div",{ref:i,className:"single-library-item__svg"}),we(Q,{"aria-label":f("buttons.remove"),type:"button",icon:Lo,className:"single-library-item--remove",onClick:n.bind(null,e.id),title:f("buttons.remove")}),Nt("div",{style:{display:"flex",margin:"0.8rem 0",width:"100%",fontSize:"14px",fontWeight:500,flexDirection:"column"},children:[Nt("label",{style:{display:"flex",justifyContent:"space-between",flexDirection:"column"},children:[Nt("div",{style:{padding:"0.5em 0"},children:[we("span",{style:{fontWeight:500,color:em.gray[6]},children:f("publishDialog.itemName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",ref:a,style:{width:"80%",padding:"0.2rem"},defaultValue:e.name,placeholder:"Item name",onChange:l=>{r(l.target.value,t)}})]}),we("span",{className:"error",children:e.error})]})]})},iI=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Zh({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[c,m]=Zh(!1);Xh(()=>{let y=Ro.get(tn.PUBLISH_LIBRARY);y&&s(y)},[]);let[d,p]=Zh(o.slice());Xh(()=>{p(o.slice())},[o]);let u=y=>{s({...l,[y.target.name]:y.target.value})},g=async y=>{y.preventDefault(),m(!0);let v=[],I=!1;if(d.forEach(F=>{let K="";F.name||(K=f("publishDialog.errors.required"),I=!0),v.push({...F,error:K})}),I){p(v),m(!1);return}let S=await rI(d),_={type:Qr.excalidrawLibrary,version:Us.excalidrawLibrary,source:Jf,libraryItems:d},L=JSON.stringify(_,null,2),N=new Blob([L],{type:"application/json"}),P=new FormData;P.append("excalidrawLib",N),P.append("previewImage",S),P.append("previewImageType",S.type),P.append("title",l.name),P.append("authorName",l.authorName),P.append("githubHandle",l.githubHandle),P.append("name",l.name),P.append("description",l.description),P.append("twitterHandle",l.twitterHandle),P.append("website",l.website),fetch(`${k.VITE_APP_LIBRARY_BACKEND}/submit`,{method:"post",body:P}).then(F=>F.ok?F.json().then(({url:K})=>{Ro.delete(tn.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 y=[];return d.forEach((v,I)=>{y.push(we("div",{className:"single-library-item-wrapper",children:we(nI,{libItem:v,appState:t,index:I,onChange:(S,_)=>{let L=d.slice();L[_].name=S,p(L)},onRemove:a})},I))}),we("div",{className:"selected-library-items",children:y})},x=oI(()=>{i(d),Ro.set(tn.PUBLISH_LIBRARY,l),e()},[d,e,i,l]),E=!!o.length,w=o.some(y=>y.status==="published");return we(dt,{onCloseRequest:x,title:f("publishDialog.title"),className:"publish-library",children:E?Nt("form",{onSubmit:g,children:[we("div",{className:"publish-library-note",children:we(Kt,{i18nKey:"publishDialog.noteDescription",link:y=>we("a",{href:"https://libraries.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:y})})}),we("span",{className:"publish-library-note",children:we(Kt,{i18nKey:"publishDialog.noteGuidelines",link:y=>we("a",{href:"https://github.com/excalidraw/excalidraw-libraries#guidelines",target:"_blank",rel:"noopener noreferrer",children:y})})}),we("div",{className:"publish-library-note",children:f("publishDialog.noteItems")}),w&&we("span",{className:"publish-library-note publish-library-warning",children:f("publishDialog.republishWarning")}),b(),Nt("div",{className:"publish-library__fields",children:[Nt("label",{children:[Nt("div",{children:[we("span",{children:f("publishDialog.libraryName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",name:"name",required:!0,value:l.name,onChange:u,placeholder:f("publishDialog.placeholder.libraryName")})]}),Nt("label",{style:{alignItems:"flex-start"},children:[Nt("div",{children:[we("span",{children:f("publishDialog.libraryDesc")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("textarea",{name:"description",rows:4,required:!0,value:l.description,onChange:u,placeholder:f("publishDialog.placeholder.libraryDesc")})]}),Nt("label",{children:[Nt("div",{children:[we("span",{children:f("publishDialog.authorName")}),we("span",{"aria-hidden":"true",className:"required",children:"*"})]}),we("input",{type:"text",name:"authorName",required:!0,value:l.authorName,onChange:u,placeholder:f("publishDialog.placeholder.authorName")})]}),Nt("label",{children:[we("span",{children:f("publishDialog.githubUsername")}),we("input",{type:"text",name:"githubHandle",value:l.githubHandle,onChange:u,placeholder:f("publishDialog.placeholder.githubHandle")})]}),Nt("label",{children:[we("span",{children:f("publishDialog.twitterUsername")}),we("input",{type:"text",name:"twitterHandle",value:l.twitterHandle,onChange:u,placeholder:f("publishDialog.placeholder.twitterHandle")})]}),Nt("label",{children:[we("span",{children:f("publishDialog.website")}),we("input",{type:"text",name:"website",pattern:"https?://.+",title:f("publishDialog.errors.website"),value:l.website,onChange:u,placeholder:f("publishDialog.placeholder.website")})]}),we("span",{className:"publish-library-note",children:we(Kt,{i18nKey:"publishDialog.noteLicense",link:y=>we("a",{href:"https://github.com/excalidraw/excalidraw-libraries/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",children:y})})})]}),Nt("div",{className:"publish-library__buttons",children:[we(Ur,{label:f("buttons.cancel"),onClick:x,"data-testid":"cancel-clear-canvas-button"}),we(Ur,{type:"submit",label:f("buttons.submit"),actionType:"primary",isLoading:c})]})]}):we("p",{style:{padding:"1em",textAlign:"center",fontWeight:500},children:f("publishDialog.atleastOneLibItem")})})},U2=iI;import sI from"clsx";import{useEffect as cI,useRef as dI}from"react";import{forwardRef as G2}from"react";import V2 from"clsx";import{jsx as Y2}from"react/jsx-runtime";var aI=G2(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>Y2("div",{className:V2("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),lI=G2(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>Y2("div",{className:V2("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...i},ref:a,children:e})),Ct={Row:aI,Col:lI};import{jsx as tm}from"react/jsx-runtime";var W2=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=Ce(),a=dI(null),l=fn({onClickOutside:o});pa(a,()=>{l.onClickOutside?.()}),cI(()=>{let c=d=>{d.key===T.ESCAPE&&(d.stopImmediatePropagation(),l.onClickOutside?.())},m={capture:!0};return document.addEventListener("keydown",c,m),()=>{document.removeEventListener("keydown",c,m)}},[l]);let s=sI(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return tm(lh.Provider,{value:{onSelect:r},children:tm("div",{ref:a,className:s,style:n,"data-testid":"dropdown-menu",children:i.editor.isMobile?tm(Ct.Col,{className:"dropdown-menu-container",children:e}):tm(yt,{className:"dropdown-menu-container",padding:2,style:{zIndex:2},children:e})})})};W2.displayName="DropdownMenuContent";var K2=W2;import{jsx as pI}from"react/jsx-runtime";var mI=({children:e,className:o="",selected:t,...r})=>pI("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),Z2=mI;import{jsx as X2}from"react/jsx-runtime";var $2=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noreferrer",...s})=>{let c=wd(s.onClick,n);return X2("a",{...s,href:t,target:"_blank",rel:"noreferrer",className:vd(i,a),title:s.title??s["aria-label"],onClick:c,children:X2(yd,{icon:e,shortcut:o,children:r})})},Ra=$2;$2.displayName="DropdownMenuItemLink";import{jsx as uI}from"react/jsx-runtime";var j2=()=>uI("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),q2=j2;j2.displayName="DropdownMenuSeparator";import hI from"clsx";import{jsx as gI}from"react/jsx-runtime";var J2=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=Ce(),a=hI(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return gI("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},Q2=J2;J2.displayName="DropdownMenuTrigger";import om from"react";var ev=e=>{let o=om.Children.toArray(e).find(t=>om.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuTrigger");return o||null},tv=e=>{let o=om.Children.toArray(e).find(t=>om.isValidElement(t)&&typeof t.type!="string"&&t?.type.displayName&&t.type.displayName==="DropdownMenuContent");return o||null};import{Fragment as fI,jsxs as bI}from"react/jsx-runtime";var Gr=({children:e,open:o})=>{let t=ev(e),r=tv(e);return bI(fI,{children:[t,o&&r]})};Gr.Trigger=Q2;Gr.Content=K2;Gr.Item=Yt;Gr.ItemLink=Ra;Gr.ItemCustom=Z2;Gr.Group=Wl;Gr.Separator=q2;var Ne=Gr;Gr.displayName="DropdownMenu";import{jsx as ao,jsxs as rm}from"react/jsx-runtime";var yI=(e,o)=>e.filter(t=>o.includes(t.id)),vI=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=ve(Ti),[c,m]=ve(Pa),d=()=>{let P=o.length?f("alerts.removeItemsFromsLibrary",{count:o.length}):f("alerts.resetLibrary"),F=o.length?f("confirmDialog.removeItemsFromLib"):f("confirmDialog.resetLibrary");return ao(Jd,{onConfirm:()=>{o.length?r():n(),u(!1)},onCancel:()=>{u(!1)},title:F,children:ao("p",{children:P})})},[p,u]=$h(!1),g=!!o.length,b=g?s.libraryItems.filter(P=>o.includes(P.id)):s.libraryItems,x=g?f("buttons.remove"):f("buttons.resetLibrary"),[E,w]=$h(!1),[y,v]=$h(null),I=EI(()=>rm(dt,{onCloseRequest:()=>v(null),title:f("publishSuccessDialog.title"),className:"publish-library-success",size:"small",children:[ao("p",{children:ao(Kt,{i18nKey:"publishSuccessDialog.content",authorName:y.authorName,link:P=>ao("a",{href:y?.url,target:"_blank",rel:"noopener noreferrer",children:P})})}),ao(Q,{type:"button",title:f("buttons.close"),"aria-label":f("buttons.close"),label:f("buttons.close"),onClick:()=>v(null),"data-testid":"publish-library-success-close",className:"publish-library-success-close"})]}),[v,y]),S=(P,F)=>{w(!1),v({url:P.url,authorName:P.authorName});let K=F.slice();K.forEach(U=>{o.includes(U.id)&&(U.status="published")}),t.setLibrary(K)},_=async()=>{try{await t.updateLibrary({libraryItems:Sc({description:"Excalidraw library files"}),merge:!0,openLibraryMenu:!0})}catch(P){if(P?.name==="AbortError"){console.warn(P);return}e({errorMessage:f("errors.importLibraryError")})}},L=async()=>{let P=g?b:await t.getLatestLibrary();l0(P).catch($s).catch(F=>{e({errorMessage:F.message})})},N=()=>rm(Ne,{open:c,children:[ao(Ne.Trigger,{onToggle:()=>m(!c),children:Z0}),rm(Ne.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!g&&ao(Ne.Item,{onSelect:_,icon:sa,"data-testid":"lib-dropdown--load",children:f("buttons.load")}),!!b.length&&ao(Ne.Item,{onSelect:L,icon:pi,"data-testid":"lib-dropdown--export",children:f("buttons.export")}),!!b.length&&ao(Ne.Item,{onSelect:()=>u(!0),icon:ho,children:x}),g&&ao(Ne.Item,{icon:iE,onSelect:()=>w(!0),"data-testid":"lib-dropdown--remove",children:f("buttons.publishLibrary")})]})]});return rm("div",{className:xI("library-menu-dropdown-container",l),children:[N(),o.length>0&&ao("div",{className:"library-actions-counter",children:o.length}),p&&d(),E&&ao(U2,{onClose:()=>w(!1),libraryItems:yI(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(F=>F!==P))}),y&&I()]})},jh=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=st(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=Kd(),a=Re(),l=Ie(),[s]=ve(Ti),c=async d=>{let p=d.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:f("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return ao(vI,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>c(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as AI,useEffect as _I,useState as DI}from"react";import wI,{useCallback as TI}from"react";function CI(){return[!1,TI(o=>o(),[])]}var ov=wI.useTransition||CI;import rv from"clsx";import{memo as II,useEffect as SI,useRef as kI,useState as MI}from"react";import{jsx as nm,jsxs as LI}from"react/jsx-runtime";var nv=II(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=kI(null),c=k2(e,o,l);SI(()=>{let g=s.current;if(g)return c&&(g.innerHTML=c.outerHTML),()=>{g.innerHTML=""}},[c]);let[m,d]=MI(!1),p=Ce().editor.isMobile,u=t&&nm("div",{className:"library-unit__adder",children:K0});return LI("div",{className:rv("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:[nm("div",{className:rv("library-unit__dragger",{"library-unit__pulse":!!t}),ref:s,draggable:!!o,onClick:o||t?g=>{e&&g.shiftKey?i(e,g):r(e)}:void 0,onDragStart:g=>{if(!e){g.preventDefault();return}d(!1),a(e,g)}}),u,e&&o&&(m||p||n)&&nm($l,{checked:n,onChange:(g,b)=>i(e,b),className:"library-unit__checkbox"})]})}),iv=()=>nm("div",{className:"library-unit library-unit--skeleton"});import{Fragment as PI,jsx as im}from"react/jsx-runtime";var qh=({children:e})=>im("div",{className:"library-menu-items-container__grid",children:e}),am=AI(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=ov(),[s,c]=DI(0);return _I(()=>{s<e.length&&l(()=>{c(s+a)})},[s,e.length,l,a]),im(PI,{children:e.map((m,d)=>d<s?im(nv,{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):im(iv,{},d))})});import{Fragment as lv,jsx as lo,jsxs as Oa}from"react/jsx-runtime";var BI=17,zI=64;function Jh({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:c}){let m=NI(null),d=O2(m);RI(()=>{d>0&&m.current?.scrollTo(0,d)},[]);let{svgCache:p}=Kd(),u=av(()=>o.filter(P=>P.status!=="published"),[o]),g=av(()=>o.filter(P=>P.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!g.length,[E,w]=OI(null),y=Na((P,F)=>{let K=!c.includes(P),U=[...u,...g];if(K){if(F.shiftKey&&E){let q=U.findIndex(ie=>ie.id===E),H=U.findIndex(ie=>ie.id===P);if(q===-1||H===-1){s([...c,P]);return}let G=ee(c),V=U.reduce((ie,$,se)=>((se>=q&&se<=H||G.has($.id))&&ie.push($.id),ie),[]);s(V)}else s([...c,P]);w(P)}else w(null),s(c.filter(q=>q!==P))},[E,s,g,c,u]),v=Na(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:li({type:"everything",elements:K.elements,randomizeSeed:!0}).newElements}))},[o,c]),I=Na((P,F)=>{F.dataTransfer.setData(ue.excalidrawlib,eu(v(P)))},[v]),S=Na(P=>P?c.includes(P):!1,[c]),_=Na(()=>{t(n)},[n,t]),L=Na(P=>{P&&r(v(P))},[v,r]),N=p.size>=o.length?zI:BI;return Oa("div",{className:"library-menu-items-container",style:n.length||u.length||g.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&lo(jh,{selectedItems:c,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),Oa(Ct.Col,{className:"library-menu-items-container__items",align:"start",gap:1,style:{flex:g.length>0?1:"0 1 auto",marginBottom:0},ref:m,children:[Oa(lv,{children:[!x&&lo("div",{className:"library-menu-items-container__header",children:f("labels.personalLib")}),e&&lo("div",{style:{position:"absolute",top:"var(--container-padding-y)",right:"var(--container-padding-x)",transform:"translateY(50%)"},children:lo(Mt,{})}),!n.length&&!u.length?Oa("div",{className:"library-menu-items__no-items",children:[lo("div",{className:"library-menu-items__no-items__label",children:f("library.noItems")}),lo("div",{className:"library-menu-items__no-items__hint",children:g.length>0?f("library.hint_emptyPrivateLibrary"):f("library.hint_emptyLibrary")})]}):Oa(qh,{children:[n.length>0&&lo(am,{itemsRenderedPerBatch:N,items:[{id:null,elements:n}],onItemSelectToggle:y,onItemDrag:I,onClick:_,isItemSelected:S,svgCache:p}),lo(am,{itemsRenderedPerBatch:N,items:u,onItemSelectToggle:y,onItemDrag:I,onClick:L,isItemSelected:S,svgCache:p})]})]}),Oa(lv,{children:[(g.length>0||n.length>0||u.length>0)&&lo("div",{className:"library-menu-items-container__header library-menu-items-container__header--excal",children:f("labels.excalidrawLib")}),g.length>0?lo(qh,{children:lo(am,{itemsRenderedPerBatch:N,items:g,onItemSelectToggle:y,onItemDrag:I,onClick:L,isItemSelected:S,svgCache:p})}):u.length>0?lo("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",fontSize:".9rem"},children:f("library.noItems")}):null]}),b&&lo(jd,{style:{padding:"16px 0",width:"100%"},id:a,libraryReturnUrl:l,theme:i,children:lo(jh,{selectedItems:c,onSelectItems:s})})]})]})}import{jsx as In,jsxs as dv}from"react/jsx-runtime";var Pa=De(!1),cv=({children:e})=>In("div",{className:"layer-ui__library",children:e}),HI=uv(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:c})=>{let[m]=ve(Ti),d=eg(g=>{(async(x,E)=>{xe("element","addToLibrary","ui");for(let y of Vs)if(x.some(v=>v.type===y))return r({errorMessage:f(`errors.libraryElementTypeError.${y}`)});let w=[{status:"unpublished",elements:x,id:ro(),created:Date.now()},...E];t(),i.setLibrary(w).catch(()=>{r({errorMessage:f("alerts.errorAddingToLibrary")})})})(g,m.libraryItems)},[t,i,r,m.libraryItems]),p=pv(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return In(cv,{children:In("div",{className:"layer-ui__library-message",children:dv("div",{children:[In(Mt,{size:"2em"}),In("span",{children:f("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return dv(cv,{children:[In(Jh,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:d,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:c,selectedItems:s}),u&&In(jd,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Qh=(e,o)=>({elements:e,pending:J(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),UI=(e,o)=>{let t=xn(),[r,n]=mv(()=>Qh(t,e.selectedElementIds)),i=FI(new Map);return sv(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),sv(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!Je(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Qh(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 Qh(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},hv=uv(()=>{let e=st(),{onInsertElements:o}=e,t=hr(),r=Re(),n=Ie(),[i,a]=mv([]),l=pv(()=>e.library,[e.library]),s=UI(r,e),c=eg(d=>{o($d(d))},[o]),m=eg(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return In(HI,{pendingElements:s,onInsertLibraryItems:c,onAddToLibrary:m,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import GI from"clsx";import{useRef as VI}from"react";import{createPortal as YI}from"react-dom";import{jsx as gv,jsxs as WI}from"react/jsx-runtime";var fv=e=>{let{closeOnClickOutside:o=!0}=e,t=ud({className:"excalidraw-modal-container"}),r=VI(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===T.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return YI(WI("div",{className:GI("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[gv("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),gv("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as rs,jsxs as jI}from"react/jsx-runtime";function $I(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var dt=e=>{let[o,t]=C2(),[r]=XI(document.activeElement),{id:n}=gt(),i=Ce().viewport.isMobile;ZI(()=>{if(!o)return;let c=dl(o);setTimeout(()=>{c.length>0&&e.autofocus!==!1&&(c[1]||c[0]).focus()});let m=d=>{if(d.key===T.TAB){let p=dl(o),{activeElement:u}=document,g=p.findIndex(b=>b===u);g===0&&d.shiftKey?(p[p.length-1].focus(),d.preventDefault()):g===p.length-1&&!d.shiftKey&&(p[0].focus(),d.preventDefault())}};return o.addEventListener("keydown",m),()=>o.removeEventListener("keydown",m)},[o,e.autofocus]);let a=Ie(),l=hn(Pa),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return rs(fv,{className:KI("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:$I(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:jI(yt,{ref:t,children:[e.title&&rs("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:rs("span",{className:"Dialog__titleContent",children:e.title})}),i&&rs("button",{className:"Dialog__close",onClick:s,title:f("buttons.close"),"aria-label":f("buttons.close"),type:"button",children:Lo}),rs("div",{className:"Dialog__content",children:e.children})]})})};import tg from"clsx";import{forwardRef as QI,useRef as eS,useImperativeHandle as tS,useLayoutEffect as oS,useState as rS}from"react";import qI from"clsx";import{jsx as JI}from"react/jsx-runtime";var vo=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>JI("button",{onClick:an(i.onClick,a=>{o()}),type:e,className:qI("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as og,jsxs as bv}from"react/jsx-runtime";var Ba=QI(({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=eS(null);tS(d,()=>p.current),oS(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,g]=rS(!1);return bv("div",{className:tg("ExcTextField",c,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&og("div",{className:"ExcTextField__label",children:o}),bv("div",{className:tg("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[og("input",{className:tg({"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&&og(vo,{onSelect:()=>g(!u),style:{border:0,userSelect:"none"},children:u?uE:ma})]})]})});var ns=[{icon:J0,value:"selection",key:T.V,numericKey:T[1],fillable:!0},{icon:Q0,value:"rectangle",key:T.R,numericKey:T[2],fillable:!0},{icon:ex,value:"diamond",key:T.D,numericKey:T[3],fillable:!0},{icon:tx,value:"ellipse",key:T.O,numericKey:T[4],fillable:!0},{icon:ox,value:"arrow",key:T.A,numericKey:T[5],fillable:!0},{icon:rx,value:"line",key:T.L,numericKey:T[6],fillable:!0},{icon:gn,value:"freedraw",key:[T.P,T.X],numericKey:T[7],fillable:!1},{icon:Xc,value:"text",key:T.T,numericKey:T[8],fillable:!1},{icon:ix,value:"image",key:null,numericKey:T[9],fillable:!1},{icon:ax,value:"eraser",key:T.E,numericKey:T[0],fillable:!1}],xv=e=>ns.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 ig from"clsx";import{useState as aS}from"react";import{createIsolation as nS}from"jotai-scope";import rg from"react";import br from"tunnel-rat";var ng=rg.createContext(null),Ke=()=>rg.useContext(ng),iS=nS(),Ev=()=>rg.useMemo(()=>({MainMenuTunnel:br(),WelcomeScreenMenuHintTunnel:br(),WelcomeScreenToolbarHintTunnel:br(),WelcomeScreenHelpHintTunnel:br(),WelcomeScreenCenterTunnel:br(),FooterCenterTunnel:br(),DefaultSidebarTriggerTunnel:br(),DefaultSidebarTabTriggersTunnel:br(),OverwriteConfirmDialogTunnel:br(),TTDDialogTriggerTunnel:br(),tunnelsJotai:iS}),[]);import{Fragment as Vr,jsx as Ve,jsxs as vt}from"react/jsx-runtime";var ag=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return vl(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>vl(r.type))},lg=(e,o)=>mn(e.activeTool.type)||o.some(t=>mn(t.type)),lm=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=gc(o,e),i=!1;n.length===2&&(pt(n[0])||pt(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=Ce(),s=document.documentElement.getAttribute("dir")==="rtl",c=mn(e.activeTool.type)&&!Kn(e.currentItemBackgroundColor)||n.some(g=>mn(g.type)&&!Kn(g.backgroundColor)),m=n.length===1||i,d=!e.editingLinearElement&&n.length===1&&ae(n[0])&&!te(n[0]),p=!e.croppingElementId&&n.length===1&&he(n[0]),u=!i&&io(e,r);return vt("div",{className:"panelColumn",children:[Ve("div",{children:ag(e,n)&&t("changeStrokeColor")}),lg(e,n)&&Ve("div",{children:t("changeBackgroundColor")}),c&&t("changeFillStyle"),(Up(e.activeTool.type)||n.some(g=>Up(g.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(g=>g.type==="freedraw"))&&t("changeStrokeShape"),(Gp(e.activeTool.type)||n.some(g=>Gp(g.type)))&&vt(Vr,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(Vp(e.activeTool.type)||n.some(g=>Vp(g.type)))&&Ve(Vr,{children:t("changeRoundness")}),(Yp(e.activeTool.type)||n.some(g=>Yp(g.type)))&&Ve(Vr,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(Z))&&vt(Vr,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||ib(n,o))&&t("changeTextAlign")]}),nb(n,o)&&t("changeVerticalAlign"),(Zi(e.activeTool.type)||n.some(g=>Zi(g.type)))&&Ve(Vr,{children:t("changeArrowhead")}),t("changeOpacity"),vt("fieldset",{children:[Ve("legend",{children:f("labels.layers")}),vt("div",{className:"buttonList",children:[t("sendToBack"),t("sendBackward"),t("bringForward"),t("bringToFront")]})]}),u&&!i&&vt("fieldset",{children:[Ve("legend",{children:f("labels.align")}),vt("div",{className:"buttonList",children:[s?vt(Vr,{children:[t("alignRight"),t("alignHorizontallyCentered"),t("alignLeft")]}):vt(Vr,{children:[t("alignLeft"),t("alignHorizontallyCentered"),t("alignRight")]}),n.length>2&&t("distributeHorizontally"),Ve("div",{style:{flexBasis:"100%",height:0}}),vt("div",{style:{display:"flex",flexWrap:"wrap",gap:".5rem",marginTop:"-0.5rem"},children:[t("alignTop"),t("alignVerticallyCentered"),t("alignBottom"),n.length>2&&t("distributeVertically")]})]})]}),!a&&n.length>0&&vt("fieldset",{children:[Ve("legend",{children:f("labels.actions")}),vt("div",{className:"buttonList",children:[!l.editor.isMobile&&t("duplicateSelection"),!l.editor.isMobile&&t("deleteSelectedElements"),t("group"),t("ungroup"),m&&t("hyperlink"),p&&t("cropEditor"),d&&t("toggleLinearEditor")]})]})]})},sm=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=aS(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso",c=e.type==="embeddable",{TTDDialogTriggerTunnel:m}=Ke();return vt(Vr,{children:[ns.map(({value:d,icon:p,key:u,numericKey:g,fillable:b},x)=>{if(r.tools?.[d]===!1)return null;let E=f(`toolBar.${d}`),w=u&&on(typeof u=="string"?u:u[0]),y=w?`${w} ${f("helpDialog.or")} ${g}`:`${g}`;return Ve(Q,{className:ig("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===d,name:"editor-current-shape",title:`${on(E)} \u2014 ${y}`,keyBindingLabel:g||w,"aria-label":on(E),"aria-keyshortcuts":y,"data-testid":`toolbar-${d}`,onPointerDown:({pointerType:v})=>{!o.penDetected&&v==="pen"&&t.togglePenMode(!0),d==="selection"&&(o.activeTool.type==="selection"?t.setActiveTool({type:"lasso"}):t.setActiveTool({type:"selection"}))},onChange:({pointerType:v})=>{o.activeTool.type!==d&&xe("toolbar",d,"ui"),d==="image"?t.setActiveTool({type:d,insertOnCanvasDirectly:v!=="mouse"}):t.setActiveTool({type:d})}},d)}),Ve("div",{className:"App-toolbar__divider"}),vt(Ne,{open:n,children:[Ve(Ne.Trigger,{className:ig("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||c||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!n),title:f("toolBar.extraTools"),children:a?Bl:c?vu:l&&!t.props.isCollaborating?zl:s?_l:mE}),vt(Ne.Content,{onClickOutside:()=>i(!1),onSelect:()=>i(!1),className:"App-toolbar__extra-tools-dropdown",children:[Ve(Ne.Item,{onSelect:()=>t.setActiveTool({type:"frame"}),icon:Bl,shortcut:T.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:f("toolBar.frame")}),Ve(Ne.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:vu,"data-testid":"toolbar-embeddable",selected:c,children:f("toolBar.embeddable")}),Ve(Ne.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:zl,"data-testid":"toolbar-laser",selected:l,shortcut:T.K.toLocaleUpperCase(),children:f("toolBar.laser")}),Ve(Ne.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:_l,"data-testid":"toolbar-lasso",selected:s,children:f("toolBar.lasso")}),Ve("div",{style:{margin:"6px 0",fontSize:14,fontWeight:600},children:"Generate"}),t.props.aiEnabled!==!1&&Ve(m.Out,{}),Ve(Ne.Item,{onSelect:()=>t.setOpenDialog({name:"ttd",tab:"mermaid"}),icon:rd,"data-testid":"toolbar-embeddable",children:f("toolBar.mermaidToExcalidraw")}),t.props.aiEnabled!==!1&&t.plugins.diagramToCode&&Ve(Vr,{children:vt(Ne.Item,{onSelect:()=>t.onMagicframeToolSelect(),icon:nd,"data-testid":"toolbar-magicframe",children:[f("toolBar.magicframe"),Ve(Ne.Item.Badge,{children:"AI"})]})})]})]})]})},yv=({renderAction:e,zoom:o})=>Ve(Ct.Col,{gap:1,className:Go.ZOOM_ACTIONS,children:vt(Ct.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),vv=({renderAction:e,className:o})=>vt("div",{className:`undo-redo-buttons ${o}`,children:[Ve("div",{className:"undo-button-container",children:Ve(bo,{label:f("buttons.undo"),children:e("undo")})}),Ve("div",{className:"redo-button-container",children:vt(bo,{label:f("buttons.redo"),children:[" ",e("redo")]})})]}),wv=({actionManager:e,showExitZenModeBtn:o})=>Ve("button",{type:"button",className:ig("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(Ma),children:f("buttons.exitZenMode")}),Tv=({renderAction:e,className:o})=>Ve("div",{className:`finalize-button ${o}`,children:e("finalize",{size:"small"})});import{useRef as lS}from"react";var sg=e=>{let o=lS({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as cS,jsxs as sS}from"react/jsx-runtime";var Ci=De(null),Cv=()=>{let[e,o]=ve(Ci),t=ft();return e&&e==="clearCanvas"?cS(Jd,{onConfirm:()=>{t.executeAction(Fr),o(null)},onCancel:()=>o(null),title:f("clearCanvasDialog.title"),children:sS("p",{className:"clear-canvas__content",children:[" ",f("alerts.clearReset")]})}):null};var cg={};Pf(cg,{toggleTheme:()=>dS});var dS={...fi,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(fi,"commandPalette")}};import{jsx as Zt,jsxs as xr}from"react/jsx-runtime";var uS=De(null),nt={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},hS=e=>{switch(e){case nt.app:return 1;case nt.export:return 2;case nt.editor:return 3;case nt.tools:return 4;case nt.elements:return 5;case nt.links:return 6;default:return 10}},mm=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return xr("div",{className:Sv("shortcut",o),children:[r.map((n,i)=>Zt("div",{className:"shortcut-wrapper",children:Zt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),Zt("div",{className:"shortcut-desc",children:t})]})},kv=e=>!e.altKey&&e[T.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===T.P||e.key===T.SLASH),Cq=Object.assign(e=>{let o=Re(),t=Ie();return dm(()=>{let r=n=>{kv(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&xe("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:Zt(gS,{...e})},{defaultItems:cg});function gS({customCommandPaletteItems:e}){let o=st(),t=Re(),r=Ie(),n=hr(),i=ft(),[a,l]=ve(uS),[s,c]=cm(null),m=pS(null),d=fn({uiAppState:t,customCommandPaletteItems:e,appProps:n});dm(()=>{let{uiAppState:S,customCommandPaletteItems:_,appProps:L}=d,N=U=>{let q="";return U.label&&(typeof U.label=="function"?q=f(U.label(o.scene.getNonDeletedElements(),S,o)):q=f(U.label)),q},P=U=>typeof U.icon=="function"?U.icon(S,o.scene.getNonDeletedElements()):U.icon,F=[],K=(U,q,H)=>{let G={label:N(U),icon:P(U),category:q,shortcut:ct(U.name),keywords:U.keywords,predicate:U.predicate,viewMode:U.viewMode,perform:()=>{i.executeAction(U,"commandPalette")}};return H?H(G,U):G};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,es,Wd,T2].map($=>K($,nt.elements,(se,be)=>({...se,predicate:be.predicate?be.predicate:(Te,ot,jt,Ho)=>J(Te,ot).length>0}))),q=[i.actions.toggleHandTool,i.actions.setFrameAsActiveTool,i.actions.toggleLassoTool].map($=>K($,nt.tools)),H=[i.actions.undo,i.actions.redo,i.actions.zoomIn,i.actions.zoomOut,i.actions.resetZoom,i.actions.zoomToFit,i.actions.zenMode,i.actions.viewMode,i.actions.gridMode,i.actions.objectsSnapMode,i.actions.toggleShortcuts,i.actions.selectAll,i.actions.toggleElementLock,i.actions.unlockAllElements,i.actions.stats].map($=>K($,nt.editor)),G=[i.actions.saveToActiveFile,i.actions.saveFileToDisk,i.actions.copyAsPng,i.actions.copyAsSvg].map($=>K($,nt.export));F=[...U,...H,{label:N(Fr),icon:P(Fr),shortcut:ct(Fr.name),category:nt.editor,keywords:["delete","destroy"],viewMode:!1,perform:()=>{St.set(Ci,"clearCanvas")}},{label:f("buttons.exportImage"),category:nt.export,icon:Jc,shortcut:ct("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...G];let V=[{label:f("toolBar.library"),category:nt.app,icon:ia,viewMode:!1,perform:()=>{S.openSidebar?r({openSidebar:null}):r({openSidebar:{name:At.name,tab:At.defaultTab}})}},{label:f("search.title"),category:nt.app,icon:go,viewMode:!0,perform:()=>{i.executeAction(is)}},{label:f("labels.changeStroke"),keywords:["color","outline"],category:nt.elements,icon:qc,viewMode:!1,predicate:($,se)=>{let be=J($,se);return be.length>0&&ag(se,be)},perform:()=>{r($=>({openMenu:$.openMenu==="shape"?null:"shape",openPopup:"elementStroke"}))}},{label:f("labels.changeBackground"),keywords:["color","fill"],icon:qc,category:nt.elements,viewMode:!1,predicate:($,se)=>{let be=J($,se);return be.length>0&&lg(se,be)},perform:()=>{r($=>({openMenu:$.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:f("labels.canvasBackground"),keywords:["color"],icon:qc,category:nt.editor,viewMode:!1,perform:()=>{r($=>({openMenu:$.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...ns.reduce(($,se)=>{let{value:be,icon:Te,key:ot,numericKey:jt}=se;if(L.UIOptions.tools?.[be]===!1)return $;let or=ot&&on(typeof ot=="string"?ot:ot[0])||jt,qt={label:f(`toolBar.${be}`),category:nt.tools,shortcut:or,icon:Te,keywords:["toolbar"],viewMode:!1,perform:({event:rr})=>{be==="image"?o.setActiveTool({type:be,insertOnCanvasDirectly:rr.type==="keydown"}):o.setActiveTool({type:be})}};return $.push(qt),$},[]),...q,{label:f("toolBar.lock"),category:nt.tools,icon:S.activeTool.locked?aa:mi,shortcut:T.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${f("labels.textToDiagram")}...`,category:nt.tools,icon:gE,viewMode:!1,predicate:L.aiEnabled,perform:()=>{r($=>({...$,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${f("toolBar.mermaidToExcalidraw")}...`,category:nt.tools,icon:rd,viewMode:!1,predicate:L.aiEnabled,perform:()=>{r($=>({...$,openDialog:{name:"ttd",tab:"mermaid"}}))}}],ie=[...F,...V,..._||[]].map($=>({...$,icon:$.icon||id,order:$.order??hS($.category),haystack:`${Vh($.label.toLocaleLowerCase())} ${$.keywords?.join(" ")||""}`}));c(ie),l(ie.find($=>$.label===a?.label)??null)}},[d,o,i,c,a?.label,l,r]);let[p,u]=cm(""),[g,b]=cm(null),[x,E]=cm({}),w=S=>{r({openDialog:null},S),u("")},y=(S,_)=>{t.openDialog?.name==="commandPalette"&&(_.stopPropagation(),_.preventDefault(),document.body.classList.add("excalidraw-animations-disabled"),w(()=>{S.perform({actionManager:i,event:_}),l(S),requestAnimationFrame(()=>{document.body.classList.remove("excalidraw-animations-disabled")})}))},v=sg(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,n,o):S.predicate===void 0||S.predicate),I=sg(S=>{let _=ir(S.target)||kv(S)||S.key===T.ESCAPE;if(_&&S.key!==T.ARROW_UP&&S.key!==T.ARROW_DOWN&&S.key!==T.ENTER)return;let L=Object.values(x).flat(),N=a&&!p&&v(a);if(S.key===T.ARROW_UP){S.preventDefault();let P=L.findIndex(U=>U.label===g?.label);if(N){if(P===0){b(a);return}if(g===a){let U=L[L.length-1];U&&b(U);return}}let F;P===-1?F=L.length-1:F=P===0?L.length-1:(P-1)%L.length;let K=L[F];K&&b(K);return}if(S.key===T.ARROW_DOWN){S.preventDefault();let P=L.findIndex(U=>U.label===g?.label);if(N){if(!g||P===L.length-1){b(a);return}if(g===a){let U=L[0];U&&b(U);return}}let F=(P+1)%L.length,K=L[F];K&&b(K);return}if(S.key===T.ENTER&&g&&setTimeout(()=>{y(g,S)}),!_){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){m?.current?.focus();return}S.preventDefault()}});return dm(()=>(window.addEventListener("keydown",I,{capture:!0}),()=>window.removeEventListener("keydown",I,{capture:!0})),[I]),dm(()=>{if(!s)return;let S=P=>{let F={};for(let K of P)F[K.category]?F[K.category].push(K):F[K.category]=[K];return F},_=s.filter(v).sort((P,F)=>P.order-F.order),L=!p&&a&&v(a);if(!p){E(S(L?_.filter(P=>P.label!==a?.label):_)),b(L?a:_[0]||null);return}let N=Vh(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));_=mS.filter(N,_,{extract:P=>P.haystack}).sort((P,F)=>F.score-P.score).map(P=>P.original),E(S(_)),b(_[0]??null)},[p,s,v,a]),xr(dt,{onCloseRequest:()=>w(),closeOnClickOutside:!0,title:!1,size:720,autofocus:!0,className:"command-palette-dialog",children:[Zt(Ba,{value:p,placeholder:f("commandPalette.search.placeholder"),onChange:S=>{u(S)},selectOnRender:!0,ref:m}),!o.device.viewport.isMobile&&xr("div",{className:"shortcuts-wrapper",children:[Zt(mm,{shortcut:"\u2191\u2193",children:f("commandPalette.shortcuts.select")}),Zt(mm,{shortcut:"\u21B5",children:f("commandPalette.shortcuts.confirm")}),Zt(mm,{shortcut:R("Esc"),children:f("commandPalette.shortcuts.close")})]}),xr("div",{className:"commands",children:[a&&!p&&xr("div",{className:"command-category",children:[xr("div",{className:"command-category-title",children:[f("commandPalette.recents"),Zt("div",{className:"icon",style:{marginLeft:"6px"},children:fE})]}),Zt(Iv,{command:a,isSelected:a.label===g?.label,onClick:S=>y(a,S),disabled:!v(a),onMouseMove:()=>b(a),showShortcut:!o.device.viewport.isMobile,appState:t})]}),Object.keys(x).length>0?Object.keys(x).map((S,_)=>xr("div",{className:"command-category",children:[Zt("div",{className:"command-category-title",children:S}),x[S].map(L=>Zt(Iv,{command:L,isSelected:L.label===g?.label,onClick:N=>y(L,N),onMouseMove:()=>b(L),showShortcut:!o.device.viewport.isMobile,appState:t},L.label))]},S)):s?xr("div",{className:"no-match",children:[Zt("div",{className:"icon",children:go})," ",f("commandPalette.search.noMatch")]}):null]})]})}var Iv=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return xr("div",{className:Sv("command-item",{"item-selected":o,"item-disabled":t}),ref:s=>{o&&!t&&s?.scrollIntoView?.({block:"nearest"})},onClick:t?l:n,onMouseMove:t?l:r,title:t?f("commandPalette.itemNotAvailable"):"",children:[xr("div",{className:"name",children:[e.icon&&Zt(vn,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),e.label]}),i&&e.shortcut&&Zt(mm,{shortcut:e.shortcut})]})};import{jsx as fS}from"react/jsx-runtime";var dg=z({name:"toggleLinearEditor",category:nt.elements,label:(e,o,t)=>t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds})[0]?.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit",keywords:["line"],trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.editingLinearElement&&n.length===1&&ae(n[0])&&!te(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0],i=o.editingLinearElement?.elementId===n.id?null:new j(n);return{appState:{...o,editingLinearElement:i},captureUpdate:A.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds})[0],n=f(r.type==="arrow"?"labels.lineEditor.editArrow":"labels.lineEditor.edit");return fS(Q,{type:"button",icon:AE,title:n,"aria-label":n,onClick:()=>o(null)})}});var is=z({name:"searchMenu",icon:go,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openSidebar?.name===At.name&&o.openSidebar.tab===Sr){let n=r.excalidrawContainerValue.container?.querySelector(`.${Go.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.matches(":focus")?{appState:{...o,openSidebar:null},captureUpdate:A.EVENTUALLY}:(n?.focus(),n?.select(),!1)}return{appState:{...o,openSidebar:{name:At.name,tab:Sr},openDialog:null},captureUpdate:A.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[T.CTRL_OR_CMD]&&e.key===T.F});import{jsx as bS}from"react/jsx-runtime";var mg=z({name:"cropEditor",label:"helpDialog.cropStart",icon:Hu,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&&he(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=f("helpDialog.cropStart");return bS(Q,{type:"button",icon:Hu,title:r,"aria-label":r,onClick:()=>o(null)})}});var Mv=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&ne(t[0])},Lv=z({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(ne(n)){let i=Mo(Ee(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)=>Mv(o,r)}),Av=z({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return ne(n)?{elements:Ib(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:A.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:A.EVENTUALLY}},predicate:(e,o,t,r)=>Mv(o,r)}),YJ=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}),WJ=z({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:Bl,viewMode:!1,perform:(e,o,t,r)=>{let n=He(o,{type:"frame"});return Eo(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:He(o,{type:"frame"})},captureUpdate:A.EVENTUALLY}},keyTest:e=>!e[T.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===T.F}),_v=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=>ne(i))},perform:(e,o,t,r)=>{let n=J(e,o),[i,a,l,s]=ye(n,r.scene.getNonDeletedElementsMap()),c=16,m=$i({x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2});if(o.editingGroupId){let p=Fe(n,o.editingGroupId);for(let u of p){let g=u.groupIds.indexOf(o.editingGroupId);B(u,{groupIds:u.groupIds.slice(0,g)},!1)}}return{elements:Wi([...r.scene.getElementsIncludingDeleted(),m],n,m,o),appState:{selectedElementIds:{[m.id]:!0}},captureUpdate:A.IMMEDIATELY}}});var Ii=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},as=class e{constructor(){C(this,"onHistoryChangedEmitter",new Pt);C(this,"undoStack",[]);C(this,"redoStack",[])}get isUndoStackEmpty(){return this.undoStack.length===0}get isRedoStackEmpty(){return this.redoStack.length===0}clear(){this.undoStack.length=0,this.redoStack.length=0}record(o,t){let r=pg.create(t,o);r.isEmpty()||(this.undoStack.push(r.inverse()),r.elementsChange.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new Ii(this.isUndoStackEmpty,this.isRedoStackEmpty)))}undo(o,t,r){return this.perform(o,t,r,()=>e.pop(this.undoStack),n=>e.push(this.redoStack,n,o))}redo(o,t,r){return this.perform(o,t,r,()=>e.pop(this.redoStack),n=>e.push(this.undoStack,n,o))}perform(o,t,r,n,i){try{let a=n();if(a===null)return;let l=o,s=t,c=!1;for(;a;){try{[l,s,c]=a.applyTo(l,s,r)}finally{i(a)}if(c)break;a=n()}return[l,s]}finally{this.onHistoryChangedEmitter.trigger(new Ii(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t,r){let n=t.inverse().applyLatestChanges(r);return o.push(n)}},pg=class e{constructor(o,t){this.appStateChange=o;this.elementsChange=t}static create(o,t){return new e(o,t)}inverse(){return new e(this.appStateChange.inverse(),this.elementsChange.inverse())}applyTo(o,t,r){let[n,i]=this.elementsChange.applyTo(o,r.elements),[a,l]=this.appStateChange.applyTo(t,n);return[n,a,i||l]}applyLatestChanges(o){let t=this.elementsChange.applyLatestChanges(o);return e.create(this.appStateChange,t)}isEmpty(){return this.appStateChange.isEmpty()&&this.elementsChange.isEmpty()}};import{useEffect as xS,useState as ES}from"react";var ug=(e,o)=>{let[t,r]=ES(o);return xS(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as Nv}from"react/jsx-runtime";var Dv=(e,o,t)=>{if(!o.multiElement&&!o.resizingElement&&!o.editingTextElement&&!o.newElement&&!o.selectedElementsAreBeingDragged&&!o.selectionElement&&!e.flowChartCreator.isCreatingChart){let r=t();if(!r)return{captureUpdate:A.EVENTUALLY};let[n,i]=r,a=Array.from(n.values());return{appState:i,elements:a,captureUpdate:A.NEVER}}return{captureUpdate:A.EVENTUALLY}},Pv=(e,o)=>({name:"undo",label:"buttons.undo",icon:Tu,trackEvent:{category:"history"},viewMode:!1,perform:(t,r,n,i)=>Dv(i,r,()=>e.undo(ee(t),r,o.snapshot)),keyTest:t=>t[T.CTRL_OR_CMD]&&Ys(t,T.Z)&&!t.shiftKey,PanelComponent:({updateData:t,data:r})=>{let{isUndoStackEmpty:n}=ug(e.onHistoryChangedEmitter,new Ii(e.isUndoStackEmpty,e.isRedoStackEmpty));return Nv(Q,{type:"button",icon:Tu,"aria-label":f("buttons.undo"),onClick:t,size:r?.size||"medium",disabled:n,"data-testid":"button-undo"})}}),Rv=(e,o)=>({name:"redo",label:"buttons.redo",icon:Cu,trackEvent:{category:"history"},viewMode:!1,perform:(t,r,n,i)=>Dv(i,r,()=>e.redo(ee(t),r,o.snapshot)),keyTest:t=>t[T.CTRL_OR_CMD]&&t.shiftKey&&Ys(t,T.Z)||_s&&t.ctrlKey&&!t.shiftKey&&Ys(t,T.Y),PanelComponent:({updateData:t,data:r})=>{let{isRedoStackEmpty:n}=ug(e.onHistoryChangedEmitter,new Ii(e.isUndoStackEmpty,e.isRedoStackEmpty));return Nv(Q,{type:"button",icon:Cu,"aria-label":f("buttons.redo"),onClick:t,size:r?.size||"medium",disabled:n,"data-testid":"button-redo"})}});var Ov=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&&Z(n[0])&&!n[0].autoResize},perform:(e,o,t,r)=>{let n=J(e,o);return{appState:o,elements:e.map(i=>{if(i.id===n[0].id&&Z(i)){let a=Ht(i.originalText,qe(i),i.lineHeight);return oe(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:A.IMMEDIATELY}}});var hg=z({name:"viewMode",label:"labels.viewMode",icon:ma,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:A.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[T.CTRL_OR_CMD]&&e.altKey&&e.code===pe.R});import{jsx as yS}from"react/jsx-runtime";var gg=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&xe(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},pm=class{constructor(o,t,r,n){C(this,"actions",{});C(this,"updater");C(this,"getAppState");C(this,"getElementsIncludingDeleted");C(this,"app");C(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=>{gg(n,"ui",l,a,this.app,c),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),c,this.app))};return yS(i,{elements:this.getElementsIncludingDeleted(),appState:this.getAppState(),updateData:s,appProps:this.app.props,app:this.app,data:t})}return null});C(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(nn(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 gg(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();gg(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var um=class{constructor(){C(this,"targets",new WeakMap);C(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 fg=e=>{let o=Array.from(e.values());return{x:Bv(o,t=>t.x)/o.length,y:Bv(o,t=>t.y)/o.length}},bg=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),Bv=(e,o)=>e.reduce((t,r)=>t+o(r),0);var vS=8,zv=99999,hm=e=>vS/e,Xt=class Xt{};C(Xt,"referenceSnapPoints",null),C(Xt,"visibleGaps",null),C(Xt,"setReferenceSnapPoints",o=>{Xt.referenceSnapPoints=o}),C(Xt,"getReferenceSnapPoints",()=>Xt.referenceSnapPoints),C(Xt,"setVisibleGaps",o=>{Xt.visibleGaps=o}),C(Xt,"getVisibleGaps",()=>Xt.visibleGaps),C(Xt,"destroy",()=>{Xt.referenceSnapPoints=null,Xt.visibleGaps=null});var No=Xt,Sn=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Yr=({event:e,app:o,selectedElements:t})=>e?o.state.objectsSnapModeEnabled&&!e[T.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[T.CTRL_OR_CMD]&&!Sn(o):t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled,wS=(e,o,t=.01)=>Math.abs(e-o)<=t,ls=(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]=We(a,o);n&&(l+=n.x,c+=n.x,d+=n.x,s+=n.y,m+=n.y,p+=n.y);let u=(c-l)/2,g=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=ce(M(l,s+g),M(d,p),a.angle),x=ce(M(l+u,s),M(d,p),a.angle),E=ce(M(c,s+g),M(d,p),a.angle),w=ce(M(l+u,m),M(d,p),a.angle),y=M(d,p);i=t?[b,x,E,w]:[b,x,E,w,y]}else{let b=ce(M(l,s),M(d,p),a.angle),x=ce(M(c,s),M(d,p),a.angle),E=ce(M(l,m),M(d,p),a.angle),w=ce(M(c,m),M(d,p),a.angle),y=M(d,p);i=t?[b,x,E,w]:[b,x,E,w,y]}}else if(e.length>1){let[a,l,s,c]=yc(e,n??{x:0,y:0}),m=s-a,d=c-l,p=M(a,l),u=M(s,l),g=M(a,c),b=M(s,c),x=M(a+m/2,l+d/2);i=t?[p,u,g,b]:[p,u,g,b,x]}return i.map(a=>M(et(a[0]),et(a[1])))},Uv=(e,o,t,r)=>{let n=o.filter(i=>ne(i)).map(i=>i.id);return Hp(e,o,t,r).filter(i=>!(i.frameId&&n.includes(i.frameId)))},Gv=(e,o,t,r)=>{let n=Uv(e,o,t,r),i=oi(n,r).filter(d=>!(d.length===1&&_e(d[0]))).map(d=>ye(d).map(p=>et(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>zv)break e;let g=a[u],[,b,x,E]=p,[w,y,,v]=g;x<w&&ll(po(b,E),po(y,v))&&l.push({startBounds:p,endBounds:g,startSide:[M(x,b),M(x,E)],endSide:[M(w,y),M(w,v)],length:w-x,overlap:sl(po(b,E),po(y,v))})}}let c=i.sort((d,p)=>d[1]-p[1]),m=[];s=0;e:for(let d=0;d<c.length;d++){let p=c[d];for(let u=d+1;u<c.length;u++){if(++s>zv)break e;let g=c[u],[b,,x,E]=p,[w,y,v]=g;E<y&&ll(po(b,x),po(w,v))&&m.push({startBounds:p,endBounds:g,startSide:[M(b,E),M(x,E)],endSide:[M(w,y),M(v,y)],length:y-E,overlap:sl(po(b,x),po(w,v))})}}return{horizontalGaps:l,verticalGaps:m}},Fv=(e,o,t,r,n,i,a)=>{if(!Yr({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=No.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:c}=l,[m,d,p,u]=yc(e,o).map(x=>et(x)),g=(m+p)/2,b=(d+u)/2;for(let x of s){if(!ll(po(d,u),x.overlap))continue;let E=x.startSide[0][0]+x.length/2,w=et(E-g);if(x.length>p-m&&Math.abs(w)<=a.x){Math.abs(w)<a.x&&(n.length=0),a.x=Math.abs(w);let P={type:"gap",direction:"center_horizontal",gap:x,offset:w};n.push(P);continue}let[,,v]=x.endBounds,I=m-v,S=et(x.length-I);if(Math.abs(S)<=a.x){Math.abs(S)<a.x&&(n.length=0),a.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};n.push(P);continue}let[_,,,]=x.startBounds,L=_-p,N=et(L-x.length);if(Math.abs(N)<=a.x){Math.abs(N)<a.x&&(n.length=0),a.x=Math.abs(N);let P={type:"gap",direction:"side_left",gap:x,offset:N};n.push(P);continue}}for(let x of c){if(!ll(po(m,p),x.overlap))continue;let E=x.startSide[0][1]+x.length/2,w=et(E-b);if(x.length>u-d&&Math.abs(w)<=a.y){Math.abs(w)<a.y&&(i.length=0),a.y=Math.abs(w);let P={type:"gap",direction:"center_vertical",gap:x,offset:w};i.push(P);continue}let[,v,,]=x.startBounds,I=v-u,S=et(I-x.length);if(Math.abs(S)<=a.y){Math.abs(S)<a.y&&(i.length=0),a.y=Math.abs(S);let P={type:"gap",direction:"side_top",gap:x,offset:S};i.push(P);continue}let[,,,_]=x.endBounds,L=et(d-_),N=x.length-L;if(Math.abs(N)<=a.y){Math.abs(N)<a.y&&(i.length=0),a.y=Math.abs(N);let P={type:"gap",direction:"side_bottom",gap:x,offset:N};i.push(P);continue}}}},Vv=(e,o,t,r)=>{let n=Uv(e,o,t,r);return oi(n,r).filter(i=>!(i.length===1&&_e(i[0]))).flatMap(i=>ls(i,r))},za=(e,o,t,r,n,i,a)=>{if(!Yr({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=No.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))}},Yv=(e,o,t,r,n)=>{let i=t.state,a=J(e,i);if(!Yr({app:t,event:r,selectedElements:a})||a.length===0)return{snapOffset:{x:0,y:0},snapLines:[]};o.x=et(o.x),o.y=et(o.y);let l=[],s=[],c=hm(i.zoom.value),m={x:c,y:c},d=ls(a,n,{dragOffset:o});za(a,d,t,r,l,s,m),Fv(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:et(o.x+p.x),y:et(o.y+p.y)};za(a,ls(a,n,{dragOffset:u}),t,r,l,s,m),Fv(a,u,t,r,l,s,m);let g=xg(l,s),b=CS(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...g,...b]}},et=e=>Math.round(e*10**6)/10**6,Hv=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())},xg=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=et(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>M(et(a[0]),et(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=et(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>M(et(a[0]),et(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:Hv(i.map(a=>M(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:Hv(i.map(a=>M(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},TS=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[et(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},CS=(e,o,t)=>{let[r,n,i,a]=yc(e,o),l=[];for(let s of t){let[c,m,d,p]=s.gap.startBounds,[u,g,b,x]=s.gap.endBounds,E=sl(po(n,a),s.gap.overlap),w=sl(po(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(s.gap.startSide[0][0],y),M(r,y)]},{type:"gap",direction:"horizontal",points:[M(i,y),M(s.gap.endSide[0][0],y)]})}break}case"center_vertical":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,s.gap.startSide[0][1]),M(y,n)]},{type:"gap",direction:"vertical",points:[M(y,a),M(y,s.gap.endSide[0][1])]})}break}case"side_right":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(d,y),M(u,y)]},{type:"gap",direction:"horizontal",points:[M(b,y),M(r,y)]})}break}case"side_left":{if(E){let y=(E[0]+E[1])/2;l.push({type:"gap",direction:"horizontal",points:[M(i,y),M(c,y)]},{type:"gap",direction:"horizontal",points:[M(d,y),M(u,y)]})}break}case"side_top":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,a),M(y,m)]},{type:"gap",direction:"vertical",points:[M(y,p),M(y,g)]})}break}case"side_bottom":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"vertical",points:[M(y,p),M(y,g)]},{type:"gap",direction:"vertical",points:[M(y,x),M(y,n)]})}break}}}return TS(l.map(s=>({...s,points:s.points.map(c=>M(et(c[0]),et(c[1])))})))},Eg=(e,o,t,r,n,i)=>{if(!Yr({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!wS(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,c]=ye(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(c+=n.y));let m=[];if(i)switch(i){case"e":{m.push(M(s,l),M(s,c));break}case"w":{m.push(M(a,l),M(a,c));break}case"n":{m.push(M(a,l),M(s,l));break}case"s":{m.push(M(a,c),M(s,c));break}case"ne":{m.push(M(s,l));break}case"nw":{m.push(M(a,l));break}case"se":{m.push(M(s,c));break}case"sw":{m.push(M(a,c));break}}let d=hm(t.state.zoom.value),p={x:d,y:d},u=[],g=[];za(o,m,t,r,u,g,p);let b={x:u[0]?.offset??0,y:g[0]?.offset??0};p.x=0,p.y=0,u.length=0,g.length=0;let[x,E,w,y]=ye(e).map(S=>et(S)),v=[M(x,E),M(x,y),M(w,E),M(w,y)];za(e,v,t,r,u,g,p);let I=xg(u,g);return{snapOffset:b,snapLines:I}},Wv=(e,o,t,r,n,i)=>{if(!Yr({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[M(r.x+n.x,r.y+n.y)],l=hm(o.state.zoom.value),s={x:l,y:l},c=[],m=[];za([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=ls([e],i,{boundingBoxCorners:!0,omitCenter:!0});za([e],p,o,t,c,m,s);let u=xg(c,m);return{snapOffset:d,snapLines:u}},Kv=(e,o,t,r,n)=>{if(!Yr({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=Hp(e,[],o.state,n),a=hm(o.state.zoom.value),l={x:a,y:a},s=[],c=[];for(let m of i){let d=ls([m],n);for(let p of d){let u=p[0]-t.x;Math.abs(u)<=Math.abs(l.x)&&(Math.abs(u)<Math.abs(l.x)&&(c.length=0),c.push({type:"pointer",points:[p,M(p[0],t.y)],direction:"vertical"}),l.x=u);let g=p[1]-t.y;Math.abs(g)<=Math.abs(l.y)&&(Math.abs(g)<Math.abs(l.y)&&(s.length=0),s.push({type:"pointer",points:[p,M(t.x,p[1])],direction:"horizontal"}),l.y=g)}}return{originOffset:{x:c.length>0?c[0].points[0][0]-t.x:0,y:s.length>0?s[0].points[0][1]-t.y:0},snapLines:[...c,...s]}},Zv=e=>e===it.rectangle||e===it.ellipse||e===it.diamond||e===it.frame||e===it.magicframe||e===it.image||e===it.text;var gm={width:100,height:0},kn=100,IS=(e,o,t)=>{let r=Vt({x:0,y:0,textAlign:rl.CENTER,verticalAlign:Qt.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),Qe(r,e,t),[e,r]},Xv=(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??kn,d=o?.height??kn,p;o.id&&(p=r.getElement(o.id),p||console.error(`No element for start binding with id ${o.id} found`));let u=o.x||e.x-m,g=o.y||e.y-d/2,b=p?p.type:o.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:o.type==="text"&&(x=o.text),x||console.error(`No text found for start binding text element for ${e.id}`),i=Vt({x:u,y:g,type:"text",...p,...o,text:x}),Object.assign(i,{x:o.x||e.x-i.width,y:o.y||e.y-i.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{i=Gt({x:u,y:g,width:m,height:d,...p,...o,type:b});break}default:Zn(e,`Unhandled element start type "${o.type}"`,!0)}Ko(e,i,"start",n)}}if(t){let m=t?.height??kn,d=t?.width??kn,p;t.id&&(p=r.getElement(t.id),p||console.error(`No element for end binding with id ${t.id} found`));let u=t.x||e.x+e.width,g=t.y||e.y-m/2,b=p?p.type:t.type;if(b){if(b==="text"){let x="";p&&p.type==="text"?x=p.text:t.type==="text"&&(x=t.text),x||console.error(`No text found for end binding text element for ${e.id}`),a=Vt({x:u,y:g,type:"text",...p,...t,text:x}),Object.assign(a,{y:t.y||e.y-a.height/2})}else switch(b){case"rectangle":case"ellipse":case"diamond":{a=Gt({x:u,y:g,width:d,height:m,...p,...t,type:b});break}default:Zn(e,`Unhandled element end type "${b}"`,!0)}Ko(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=oo(e.points);return e.points[l][0]>e.points[l-1][0]&&(c[0][0]=s,c[l][0]-=s),e.points[l][0]<e.points[l-1][0]&&(c[0][0]=-s,c[l][0]+=s),e.points[l][1]>e.points[l-1][1]&&(c[0][1]=s,c[l][1]-=s),e.points[l][1]<e.points[l-1][1]&&(c[0][1]=-s,c[l][1]+=s),Object.assign(e,j.getNormalizedPoints({...e,points:c})),{linearElement:e,startBoundElement:i,endBoundElement:a}},yg=class{constructor(){C(this,"excalidrawElements",new Map);C(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});C(this,"getElements",()=>Pr(Array.from(this.excalidrawElements.values())));C(this,"getElementsMap",()=>sn(ee(this.getElements())));C(this,"getElement",o=>this.excalidrawElements.get(o))}},Fa=(e,o)=>{if(!e)return[];let t=oo(e),r=new yg,n=new Map,i=new Map;for(let l of t){let s,c=l.id;switch(o?.regenerateIds!==!1&&Object.assign(l,{id:ro()}),l.type){case"rectangle":case"ellipse":case"diamond":{let d=l?.label?.text&&l.width===void 0?0:l?.width||kn,p=l?.label?.text&&l.height===void 0?0:l?.height||kn;s=Gt({...l,width:d,height:p});break}case"line":{let d=l.width||gm.width,p=l.height||gm.height;s=cr({width:d,height:p,points:[M(0,0),M(d,p)],...l});break}case"arrow":{let d=l.width||gm.width,p=l.height||gm.height;s=ji({width:d,height:p,endArrowhead:"arrow",points:[M(0,0),M(d,p)],...l,type:"arrow"}),Object.assign(s,y1(s.points));break}case"text":{let d=l?.fontFamily||qr,p=l?.fontSize||Ir,u=l?.lineHeight||kr(d),g=l.text??"",b=qn(g),x=Ht(b,qe({fontFamily:d,fontSize:p}),u);s=Vt({width:x.width,height:x.height,fontFamily:d,fontSize:p,...l});break}case"image":{s=wc({width:l?.width||kn,height:l?.height||kn,...l});break}case"frame":{s=$i({x:0,y:0,...l});break}case"magicframe":{s=wl({x:0,y:0,...l});break}case"freedraw":case"iframe":case"embeddable":{s=l;break}default:s=l,Zn(l,`Unhandled element type "${l.type}"`,!0)}r.getElement(s.id)?console.error(`Duplicate id found for ${s.id}`):(r.add(s),n.set(s.id,l),c&&i.set(c,s.id))}let a=r.getElementsMap();for(let[l,s]of n){let c=r.getElement(l);switch(s.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(s.label?.text){let[m,d]=IS(c,s?.label,a);if(r.add(m),r.add(d),ke(m)){let p=s.type==="arrow"?s?.start:void 0,u=s.type==="arrow"?s?.end:void 0;if(p&&p.id){let E=i.get(p.id);E&&Object.assign(p,{id:E})}if(u&&u.id){let E=i.get(u.id);E&&Object.assign(u,{id:E})}let{linearElement:g,startBoundElement:b,endBoundElement:x}=Xv(m,p,u,r,a);m=g,r.add(g),r.add(b),r.add(x)}}else switch(s.type){case"arrow":{let{start:m,end:d}=s;if(m&&m.id){let b=i.get(m.id);Object.assign(m,{id:b})}if(d&&d.id){let b=i.get(d.id);Object.assign(d,{id:b})}let{linearElement:p,startBoundElement:u,endBoundElement:g}=Xv(c,m,d,r,a);r.add(p),r.add(u),r.add(g);break}}break}}}for(let[l,s]of n){if(s.type!=="frame"&&s.type!=="magicframe")continue;let c=r.getElement(l);if(!c)throw new Error(`Excalidraw element with id ${l} doesn't exist`);let m=[];s.children.forEach(v=>{let I=i.get(v);if(!I)throw new Error(`Element with ${v} wasn't mapped correctly`);let S=r.getElement(I);if(!S)throw new Error(`Frame element with id ${I} doesn't exist`);Object.assign(S,{frameId:c.id}),S?.boundElements?.forEach(_=>{let L=r.getElement(_.id);if(!L)throw new Error(`Bound element with id ${_.id} doesn't exist`);Object.assign(L,{frameId:c.id}),m.push(L)}),m.push(S)});let[d,p,u,g]=ye(m),b=10;d=d-b,p=p-b,u=u+b,g=g+b;let x=c?.x||d,E=c?.y||p,w=c?.width||u-d,y=c?.height||g-p;Object.assign(c,{x,y:E,width:w,height:y}),Ue()&&s.children.length&&(c?.x||c?.y||c?.width||c?.height)&&console.info("User provided frame attributes are being considered, if you find this inaccurate, please remove any of the attributes - x, y, width and height so frame coordinates and dimensions are calculated automatically")}return r.getElements()};import fm from"open-color";var SS="#ff6b6b",kS="#ff0000",$v=1,jv=2,qv=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===de.LIGHT||o.zenModeEnabled?SS:kS,r=(o.zenModeEnabled?$v*1.5:$v)/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,LS(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,AS(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,MS(n,e,o));e.restore()},MS=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];Oo(r,n,o)}for(let r of e.points)Jv(r,t,o)},LS=(e,o,t)=>{Jv(e.points[0],t,o),t.zenModeEnabled||Oo(e.points[0],e.points[1],o)},Jv=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?jv*1.5:jv)/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()},Oo=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},AS=(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||Oo(M(e[0],e[1]-i),M(e[0],e[1]+i),n),Oo(M(s[0]-l,s[1]-a),M(s[0]-l,s[1]+a),n),Oo(M(s[0]+l,s[1]-a),M(s[0]+l,s[1]+a),n),r.zenModeEnabled||(Oo(M(o[0],o[1]-i),M(o[0],o[1]+i),n),Oo(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||Oo(M(e[0]-i,e[1]),M(e[0]+i,e[1]),n),Oo(M(s[0]-a,s[1]-l),M(s[0]+a,s[1]-l),n),Oo(M(s[0]-a,s[1]+l),M(s[0]+a,s[1]+l),n),r.zenModeEnabled||(Oo(M(o[0]-i,o[1]),M(o[0]+i,o[1]),n),Oo(e,o,n))}};var Qo=4,Er=6,Qv="rgba(0,0,0,0.3)",ew=(e,o,t,r)=>{if(!e.length)return{horizontal:null,vertical:null};let[n,i,a,l]=ye(e),s=o/r.zoom.value,c=t/r.zoom.value,m=o-s,d=t-c,p={top:parseInt(cl("sat"))||0,bottom:parseInt(cl("sab"))||0,left:parseInt(cl("sal"))||0,right:parseInt(cl("sar"))||0},u=Br().rtl,g=-r.scrollX+m/2+p.left,b=-r.scrollY+d/2+p.top,x=g+s-p.right,E=b+c-p.bottom,w=Math.min(n,g),y=Math.min(i,b),v=Math.max(a,x),I=Math.max(l,E);return{horizontal:g===w&&x===v?null:{x:Math.max(p.left,Qo)+(g-w)/(v-w)*o,y:t-Er-Math.max(Qo,p.bottom),width:(x-g)/(v-w)*o-Math.max(Qo*2,p.left+p.right),height:Er},vertical:b===y&&E===I?null:{x:u?Math.max(p.left,Qo):o-Er-Math.max(p.right,Qo),y:(b-y)/(I-y)*t+Math.max(p.top,Qo),width:Er,height:(E-b)/(I-y)*t-Math.max(Qo*2,p.top+p.bottom)}}},vg=(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 _S=(e,o)=>{ln(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;ln(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),ow(t,e,o),e.restore()},DS=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.editingLinearElement?.selectedPointsIndices?.includes(n))return;let i=j.getElement(r,t);if(!i)return;let a=j.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),ow(a,e,o),e.restore()},ow=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Cl(o,e[0],e[1],j.POINT_HANDLE_SIZE/t.zoom.value,!1)},ss=(e,o,t,r,n,i,a,l,s=!1,c=0)=>{e.save(),e.translate(i,a),e.rotate(l),s&&e.fillRect(o-i,t-a,r,n),c&&e.roundRect?(e.beginPath(),e.roundRect(o-i,t-a,r,n,c),e.stroke(),e.closePath()):e.strokeRect(o-i,t-a,r,n),e.restore()},PS=(e,o,t,r,n,i)=>{e.save(),e.translate(r,n),e.rotate(i),e.beginPath(),e.moveTo(0,t/2),e.lineTo(o/2,0),e.lineTo(0,-t/2),e.lineTo(-o/2,0),e.closePath(),e.stroke(),e.restore()},wg=(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)"),Cl(e,t[0],t[1],r/o.zoom.value,!i)},RS=(e,o,t,r,n,i)=>{e.beginPath(),e.ellipse(r,n,o/2,t/2,i,0,Math.PI*2),e.stroke()},NS=(e,o,t,r)=>{let[n,i,a,l]=We(o,t),s=a-n,c=l-i;e.strokeStyle="rgba(0,0,0,.05)";let m=r.value<1?r.value:1;e.lineWidth=cb/m;let d=e.lineWidth/2+db,p=xc(Math.min(o.width,o.height),o);switch(o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":ss(e,n-d,i-d,s+d*2,c+d*2,n+s/2,i+c/2,o.angle,void 0,p);break;case"diamond":let u=Math.hypot(s,c),g=d*u/c,b=d*u/s;PS(e,s+g*2,c+b*2,n+s/2,i+c/2,o.angle);break;case"ellipse":RS(e,s+d*2,c+d*2,n+s/2,i+c/2,o.angle);break}},OS=(e,o,t,r)=>{let[n,i,a]=o,l=hb(a,a.width,a.height,r);e.strokeStyle="rgba(0,0,0,0)",e.fillStyle="rgba(0,0,0,.05)",(i==="both"?[0,-1]:i==="start"?[0]:[-1]).forEach(c=>{let[m,d]=j.getPointAtIndexGlobalCoordinates(n,c,t);Cl(e,m,d,l)})},rw=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:c,cy:m,dashed:d,activeEmbeddable:p}=t,u=a-n,g=l-i,x=(t.padding??Jr*2)/o.zoom.value,E=8/o.zoom.value,w=4/o.zoom.value;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=(p?4:1)/o.zoom.value;let y=s.length;for(let v=0;v<y;++v)e.strokeStyle=s[v],d&&e.setLineDash([E,w+(E+w)*(y-1)]),e.lineDashOffset=(E+w)*v,ss(e,n-x,i-x,u+x*2,g+x*2,c,m,r);e.restore()},BS=(e,o,t,r)=>{let n=Array.isArray(t)?OS:NS;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},zS=(e,o,t,r)=>{let[n,i,a,l]=We(t,r),s=a-n,c=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Vo.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),ss(e,n,i,s,c,n+s/2,i+c/2,t.angle,!1,Vo.radius/o.zoom.value),e.restore()},FS=(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]=ye(l);return{angle:0,x1:s,x2:m,y1:c,y2:d,selectionColors:["rgb(0,118,255)"],dashed:!1,cx:s+(m-s)/2,cy:c+(d-c)/2,activeEmbeddable:!1}},a=l=>{let s=Fe(t,l);return i(s)};Object.entries(_b(n,o)).filter(([l,s])=>s).map(([l,s])=>l).map(l=>a(l)).concat(r.map(l=>i([l]))).forEach(l=>rw(e,o,l))},Tg=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=j.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=j,a=o.editingLinearElement?i:i/2;if(n.forEach((l,s)=>{if(te(t)&&s!==0&&s!==n.length-1)return;let c=!!o.editingLinearElement?.selectedPointsIndices?.includes(s);wg(e,o,l,a,c)}),te(t)){let l=t.fixedSegments?.map(s=>s.index)||[];n.slice(0,-1).forEach((s,c)=>{j.isSegmentTooShort(t,n[c+1],n[c],c,o.zoom)||wg(e,o,M((s[0]+n[c+1][0])/2,(s[1]+n[c+1][1])/2),i/2,!1,!l.includes(c+1))})}else j.getEditorMidPoints(t,r,o).filter((s,c,m)=>s!==null&&!(te(t)&&(c===0||c===m.length-1))).forEach(s=>{(o.editingLinearElement||n.length===2)&&wg(e,o,s,i/2,!1,!0)});e.restore()},tw=(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"?Cl(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()):ss(e,l,s,c,m,l+c/2,s+m/2,n,!0),e.restore()}})},HS=(e,o,t,r,n)=>{let[i,a,,,l,s]=We(r,n),c=3,m=20,d=c/t.zoom.value,p=d/2,u=l-i+d,g=s-a+d,b=Math.min(m/t.zoom.value,u),x=Math.min(m/t.zoom.value,g);e.save(),e.fillStyle=o.selectionColor,e.strokeStyle=o.selectionColor,e.lineWidth=d,[[[-u,-g],[0,p],[b,p],[p,0],[p,x]],[[u-p,-g],[p,p],[-b+p,p],[0,0],[0,x]],[[-u,g],[0,-p],[b,-p],[p,0],[p,-x]],[[u-p,g],[p,-p],[-b+p,-p],[0,0],[0,-x]]].forEach(w=>{let[[y,v],[I,S],[_,L],[N,P],[F,K]]=w;e.save(),e.translate(l,s),e.rotate(r.angle),e.beginPath(),e.moveTo(y+I,v+S),e.lineTo(y+_,v+L),e.stroke(),e.beginPath(),e.moveTo(y+N,v+P),e.lineTo(y+F,v+K),e.stroke(),e.restore()}),e.restore()},US=(e,o,t,r)=>{o.save();let n=Jr*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,c=-(i/2+n),m=-(a/2+n);o.translate(l+t.scrollX,s+t.scrollY),o.rotate(e.angle),o.lineWidth=1/t.zoom.value,o.strokeStyle=r,o.strokeRect(c,m,i,a),o.restore()},nw=({canvas:e,elementsMap:o,visibleElements:t,selectedElements:r,allElementsMap:n,scale:i,appState:a,renderConfig:l,device:s})=>{if(e===null)return{atLeastOneVisibleElement:!1,elementsMap:o};let[c,m]=Lc(e,i),d=Ac({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&&Tg(d,a,p,o),a.selectionElement&&!a.isCropping)try{Wb(a.selectionElement,d,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Z(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&US(b,d,a,l.selectionColor)}a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{BS(d,a,b,o)}),a.frameToHighlight&&zS(d,a,a.frameToHighlight,o),a.elementsToHighlight&&FS(d,a,a.elementsToHighlight);let u=r.some(b=>ne(b));if(r.length===1&&a.editingLinearElement?.elementId===r[0].id&&Tg(d,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(E=>E.id===b.elementId);b.segmentMidPointHoveredCoords?_S(d,a):(te(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&DS(d,a,o)}if(!a.multiElement&&!a.editingLinearElement){let b=zc(r,a),x=r.length===1&&ae(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Tg(d,a,r[0],o);let E=l.selectionColor||fm.black;if(b){let w=ee(r),y=[];for(let I of o.values()){let S=[],_=l.remoteSelectedElementIds.get(I.id);if(x&&te(I)&&(I.startBinding||I.endBinding)||(w.has(I.id)&&!fc(a,I)&&S.push(E),_&&S.push(..._.map(L=>wi(L,a.collaborators.get(L))))),S.length){let[L,N,P,F,K,U]=We(I,o,!0);y.push({angle:I.angle,x1:L,y1:N,x2:P,y2:F,selectionColors:S,dashed:!!_,cx:K,cy:U,activeEmbeddable:a.activeEmbeddable?.element===I&&a.activeEmbeddable.state==="active",padding:I.id===a.croppingElementId||he(I)?0:void 0})}}let v=I=>{let S=Fe(o,I),[_,L,N,P]=ye(S);y.push({angle:0,x1:_,x2:N,y1:L,y2:P,selectionColors:[fm.black],dashed:!0,cx:_+(N-_)/2,cy:L+(P-L)/2,activeEmbeddable:!1})};for(let I of Zo(a))v(I);a.editingGroupId&&v(a.editingGroupId),y.forEach(I=>rw(d,a,I))}if(d.save(),d.translate(a.scrollX,a.scrollY),r.length===1){d.fillStyle=fm.white;let w=Bc(r[0],a.zoom,o,"mouse",si(s));if(!a.viewModeEnabled&&b&&!Z(a.editingTextElement)&&!a.croppingElementId&&tw(d,l,a,w,r[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&he(y)&&HS(d,l,a,y,o)}}else if(r.length>1&&!a.isRotating){let w=Jr*2/a.zoom.value;d.fillStyle=fm.white;let[y,v,I,S]=ye(r,o),_=d.getLineDash();d.setLineDash([2/a.zoom.value]);let L=d.lineWidth;d.lineWidth=1/a.zoom.value,d.strokeStyle=E,ss(d,y-w,v-w,I-y+w*2,S-v+w*2,(y+I)/2,(v+S)/2,0),d.lineWidth=L,d.setLineDash(_);let N=kl([y,v,I,S,(y+I)/2,(v+S)/2],0,a.zoom,"mouse",u?{...si(s),rotation:!0}:si(s));r.some(P=>!P.locked)&&tw(d,l,a,N,0)}d.restore()}a.searchMatches.forEach(({id:b,focus:x,matchedLines:E})=>{let w=o.get(b);if(w&&Z(w)){let[y,v,,,I,S]=We(w,o,!0);d.save(),a.theme===de.LIGHT?x?d.fillStyle="rgba(255, 124, 0, 0.4)":d.fillStyle="rgba(255, 226, 0, 0.4)":x?d.fillStyle="rgba(229, 82, 0, 0.4)":d.fillStyle="rgba(99, 52, 0, 0.4)",d.translate(a.scrollX,a.scrollY),d.translate(I,S),d.rotate(w.angle),E.forEach(_=>{d.fillRect(y+_.offsetX-I,v+_.offsetY-S,_.width,_.height)}),d.restore()}}),qv(d,a),d.restore(),a2({context:d,renderConfig:l,appState:a,normalizedWidth:c,normalizedHeight:m});let g;return l.renderScrollbars&&(g=ew(t,c,m,a),d.save(),d.fillStyle=Qv,d.strokeStyle="rgba(255,255,255,0.8)",[g.horizontal,g.vertical].forEach(b=>{b&&Bd(d,b.x,b.y,b.width,b.height,Er/2)}),d.restore()),{scrollBars:g,atLeastOneVisibleElement:t.length>0,elementsMap:o}},Cg=Pi(e=>{let o=nw(e);e.callback?.(o)},{trailing:!0}),iw=(e,o)=>{if(o){Cg(e);return}let t=nw(e);return e.callback(t),t};var cs=class{constructor(o){C(this,"scene");C(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())El(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=sn(new Map);for(let s of r)he(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 g=this.scene.getNonDeletedElements(),b=t({elements:g,editingTextElement:m,newElementId:d,pendingImageElementId:p}),x=o({elementsMap:b,zoom:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:c});return{elementsMap:b,visibleElements:x}})})());this.scene=o}destroy(){Cg.cancel(),d0.cancel(),this.getRenderableElements.clear()}};import{jsx as YS}from"react/jsx-runtime";var GS=5,VS=(e,o,t)=>{let[r,n]=We(e,t),{x:i,y:a}=zt({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},Ig=({children:e,element:o,elementsMap:t})=>{let r=ur();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=VS(o,r,t);return YS("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:GS},children:e})};import{LaserPointer as WS}from"@excalidraw/laser-pointer";var Wr=class{constructor(o,t,r){this.animationFrameHandler=o;this.app=t;this.options=r;C(this,"currentTrail");C(this,"pastTrails",[]);C(this,"container");C(this,"trailElement");C(this,"trailAnimation");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.trailElement=document.createElementNS(hp,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(hp,"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 WS(this.options),this.currentTrail.addPoint([o,t,performance.now()]),this.update()}addPointToPath(o,t){this.currentTrail&&(this.currentTrail.addPoint([o,t,performance.now()]),this.update())}endPath(){this.currentTrail&&(this.currentTrail.close(),this.currentTrail.options.keepHead=!1,this.pastTrails.push(this.currentTrail),this.currentTrail=void 0,this.update())}getCurrentTrail(){return this.currentTrail}clearTrails(){this.pastTrails=[],this.currentTrail=void 0,this.update()}update(){this.pastTrails=[],this.start(),this.trailAnimation&&(this.trailAnimation.setAttribute("begin","indefinite"),this.trailAnimation.setAttribute("repeatCount","indefinite"))}onFrame(){let o=[];for(let r of this.pastTrails)o.push(this.drawTrail(r,this.app.state));if(this.currentTrail){let r=this.drawTrail(this.currentTrail,this.app.state);o.push(r)}this.pastTrails=this.pastTrails.filter(r=>r.getStrokeOutline().length!==0),o.length===0&&this.stop();let t=o.join(" ").trim();this.trailElement.setAttribute("d",t),this.trailAnimation?(this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this)),this.trailElement.setAttribute("stroke",(this.options.stroke??(()=>"black"))(this))):this.trailElement.setAttribute("fill",(this.options.fill??(()=>"black"))(this))}drawTrail(o,t){let r=o.getStrokeOutline(o.options.size/t.zoom.value).map(([i,a])=>{let l=zt({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return R1(n,!0)}};var bm=class{constructor(o,t){this.animationFrameHandler=o;this.app=t;C(this,"localTrail");C(this,"collabTrails",new Map);C(this,"container");this.animationFrameHandler.register(this,this.onFrame.bind(this)),this.localTrail=new Wr(o,t,{...this.getTrailOptions(),fill:()=>lp})}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(Yo(i),Yo(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 Wr(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||wi(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 KS}from"react";import{unstable_batchedUpdates as aw}from"react-dom";var tt=e=>o=>{aw(e,o)},xm=e=>Pi(o=>{aw(e,o)}),Ha=(()=>{let e;try{let t=KS.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 ZS=(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)`},lw=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,canvas:i,excalidrawContainer:a,app:l,autoSelect:s=!0})=>{let c=(H,G)=>{if(!G.style.fontFamily||!G.style.fontSize)return!1;let V=G.style.fontFamily.replace(/"/g,"");return Vn({fontFamily:H.fontFamily})!==V||`${H.fontSize}px`!==G.style.fontSize},m=()=>{let H=l.state,G=dn.getScene(n)?.getElement(e);if(!G)return;let{textAlign:V,verticalAlign:ie}=G,$=l.scene.getNonDeletedElementsMap();if(G&&Z(G)){let se=G.x,be=G.y,Te=_t(G,l.scene.getNonDeletedElementsMap()),ot=G.width,jt=G.height,Ho=G.width,or=G.height;if(Te&&G.containerId){if(ke(Te)){let jr=j.getBoundTextElementPosition(Te,G,$);se=jr.x,be=jr.y}let Ss=c(G,d),ja;if(Ss?ja=ul(Te.id,Te.height):(ja=q1[Te.id],ja||(ja=ul(Te.id,Te.height))),Ho=Gi(Te,G),or=lb(Te,G),!ke(Te)&&jt>or){let jr=Ui(jt,Te.type);B(Te,{height:jr});return}else if(!ke(Te)&&Te.height>ja.height&&jt<or){let jr=Ui(jt,Te.type);B(Te,{height:jr})}else{let{y:jr}=rc(Te,G,$);be=jr}}let[qt,rr]=r(se,be),Xr=d.selectionStart,Jt=d.selectionEnd,$r=d.value.length;if(Xr===Jt&&Jt!==$r){let Ss=$r-Jt;d.selectionStart=d.value.length-Ss,d.selectionEnd=d.value.length-Ss}Te?ot+=.5:(Ho=(H.width-8-qt)/H.zoom.value,ot=Math.min(ot,Ho)),jt*=1.05;let mo=qe(G),_f=(H.height-rr)/H.zoom.value;Object.assign(d.style,{font:mo,lineHeight:G.lineHeight,width:`${ot}px`,height:`${jt}px`,left:`${qt}px`,top:`${rr}px`,transform:ZS(ot,jt,rb(G,Te),H,Ho,_f),textAlign:V,verticalAlign:ie,color:G.strokeColor,opacity:G.opacity/100,filter:"var(--theme-filter)",maxHeight:`${_f}px`}),d.scrollTop=0,mt()&&(d.style.fontFamily=Vn(G)),B(G,{x:se,y:be})}},d=document.createElement("textarea");d.dir="auto",d.tabIndex=0,d.dataset.type="wysiwyg",d.wrap="off",d.classList.add("excalidraw-wysiwyg");let p="pre",u="normal";(_e(n)||!n.autoResize)&&(p="pre-wrap",u="break-word"),Object.assign(d.style,{position:"absolute",display:"inline-block",minHeight:"1em",backfaceVisibility:"hidden",margin:0,padding:0,border:0,outline:0,resize:"none",background:"transparent",overflow:"hidden",zIndex:"var(--zIndex-wysiwyg)",wordBreak:u,whiteSpace:p,overflowWrap:"break-word",boxSizing:"content-box"}),d.value=n.originalText,m(),o&&(d.onpaste=async H=>{let G=await Rd(H,!0);if(!G.text)return;let V=qn(G.text);if(!V)return;let ie=_t(n,l.scene.getNonDeletedElementsMap()),$=qe({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(ie){let se=ge(ie,l.scene.getNonDeletedElementsMap()),be=Hi(`${d.value}${V}`,$,Gi(ie,se)),Te=ob(be,$);d.style.width=`${Te}px`}},d.oninput=()=>{let H=qn(d.value);if(d.value!==H){let G=d.selectionStart;d.value=H,d.selectionStart=G,d.selectionEnd=G}o(d.value)}),d.onkeydown=H=>{if(!H.shiftKey&&kd.keyTest(H))H.preventDefault(),l.actionManager.executeAction(kd),m();else if(!H.shiftKey&&Md.keyTest(H))H.preventDefault(),l.actionManager.executeAction(Md),m();else if(!H.shiftKey&&Ld.keyTest(H))H.preventDefault(),l.actionManager.executeAction(Ld),m();else if(bh.keyTest(H))l.actionManager.executeAction(bh);else if(xh.keyTest(H))l.actionManager.executeAction(xh);else if(H.key===T.ESCAPE)H.preventDefault(),I=!0,S();else if(yi.keyTest(H))H.preventDefault(),S(),l.actionManager.executeAction(yi);else if(H.key===T.ENTER&&H[T.CTRL_OR_CMD]){if(H.preventDefault(),H.isComposing||H.keyCode===229)return;I=!0,S()}else if(H.key===T.TAB||H[T.CTRL_OR_CMD]&&(H.code===pe.BRACKET_LEFT||H.code===pe.BRACKET_RIGHT)){if(H.preventDefault(),H.isComposing)return;H.shiftKey||H.code===pe.BRACKET_LEFT?w():E(),d.dispatchEvent(new Event("input"))}};let g=4,b=" ".repeat(g),x=new RegExp(`^ {1,${g}}`),E=()=>{let{selectionStart:H,selectionEnd:G}=d,V=y(),ie=d.value;V.forEach($=>{let se=ie.slice(0,$),be=ie.slice($);ie=`${se}${b}${be}`}),d.value=ie,d.selectionStart=H+g,d.selectionEnd=G+g*V.length},w=()=>{let{selectionStart:H,selectionEnd:G}=d,V=y(),ie=[],$=d.value;V.forEach(se=>{let be=$.slice(se,se+g).match(x);if(be){let Te=$.slice(0,se),ot=$.slice(se+be[0].length);$=`${Te}${ot}`,ie.push(se)}}),d.value=$,ie.length&&(H>ie[ie.length-1]?d.selectionStart=Math.max(H-g,ie[ie.length-1]):d.selectionStart=H,d.selectionEnd=Math.max(d.selectionStart,G-g*ie.length))},y=()=>{let{selectionStart:H,selectionEnd:G,value:V}=d,ie=V.slice(0,H).match(/[^\n]*$/)[0].length;return H=H-ie,V.slice(H,G).split(`
8
- `).reduce((se,be,Te,ot)=>se.concat(Te?se[Te-1]+ot[Te-1].length+1:H),[]).reverse()},v=H=>{H.target instanceof HTMLCanvasElement&&(H.preventDefault(),H.stopPropagation())},I=!1,S=()=>{if(U)return;U=!0,_();let H=dn.getScene(n)?.getElement(n.id);if(!H)return;let G=_t(H,l.scene.getNonDeletedElementsMap());if(G){if(d.value.trim()){let V=ko(G);!V||V!==n.id?B(G,{boundElements:(G.boundElements||[]).concat({type:"text",id:n.id})}):ke(G)&&xl(G)}else B(G,{boundElements:G.boundElements?.filter(V=>!Z(V))});Qe(H,G,l.scene.getNonDeletedElementsMap())}t({viaKeyboard:I,nextOriginalText:d.value})},_=()=>{d.onblur=null,d.oninput=null,d.onkeydown=null,q&&q.disconnect(),window.removeEventListener("resize",m),window.removeEventListener("wheel",v,!0),window.removeEventListener("pointerdown",P),window.removeEventListener("pointerup",L),window.removeEventListener("blur",S),window.removeEventListener("beforeunload",S),F(),K(),d.remove()},L=H=>{window.removeEventListener("pointerup",L);let G=H?.target,V=G instanceof HTMLElement&&G.classList.contains("properties-trigger");setTimeout(()=>{d.onblur=S,V||d.focus()})},N=()=>{d.onblur=null,window.addEventListener("pointerup",L),window.addEventListener("blur",S)},P=H=>{let G=H?.target;if(H.button===nr.WHEEL){G instanceof HTMLTextAreaElement&&(H.preventDefault(),l.handleCanvasPanUsingWheelOrSpaceDrag(H)),N();return}let V=G instanceof HTMLElement&&G.classList.contains("properties-trigger");(H.target instanceof HTMLElement||H.target instanceof SVGElement)&&H.target.closest(`.${Go.SHAPE_ACTIONS_MENU}, .${Go.ZOOM_ACTIONS}`)&&!ir(H.target)||V?N():H.target instanceof HTMLCanvasElement&&!mt()&&requestAnimationFrame(()=>{S()})},F=l.scene.onUpdate(()=>{m(),!!document.activeElement?.closest(".properties-content")||d.focus()}),K=l.onScrollChangeEmitter.on(()=>{m()}),U=!1;s&&d.select(),L();let q=null;i&&"ResizeObserver"in window?(q=new window.ResizeObserver(()=>{m()}),q.observe(i)):window.addEventListener("resize",m),d.onpointerdown=H=>H.stopPropagation(),requestAnimationFrame(()=>{window.addEventListener("pointerdown",P,{capture:!0})}),window.addEventListener("beforeunload",S),a?.querySelector(".excalidraw-textEditorContainer").appendChild(d)};var sw=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 XS}from"points-on-curve";var cw=e=>{let{lassoPath:o,elements:t,elementsSegments:r,intersectedElements:n,enclosedElements:i,simplifyDistance:a}=e,l=o;a&&(l=XS(o,a)),i.clear();for(let c of t)!n.has(c.id)&&!i.has(c.id)&&($S(l,c,r)?i.add(c.id):jS(l,c,r)&&n.add(c.id));return{selectedElementIds:[...n,...i]}},$S=(e,o,t)=>{let r=x1(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>E1(a,r))):!1},jS=(e,o,t)=>{let r=t.get(o.id);return r?e.reduce((i,a,l)=>(l===0||i.push(Zs(e[l-1],a)),i),[]).some(i=>r.some(a=>Xs(i,a,1)!==null)):!1};var Em=class extends Wr{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(Yo(s),Yo(l))},fill:()=>"rgba(105,101,219,0.05)",stroke:()=>"rgba(105,101,219)"});C(this,"intersectedElements",new Set);C(this,"enclosedElements",new Set);C(this,"elementsSegments",null);C(this,"keepPreviousSelection",!1);C(this,"selectElementsFromIds",t=>{this.app.setState(r=>{let n=t.reduce((s,c)=>(s[c]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&Z(c)){let m=_t(c,this.app.scene.getNonDeletedElementsMap());m&&(n[m.id]=!0,delete n[c.id])}}for(let[s]of Object.entries(n)){let c=this.app.scene.getNonDeletedElement(s);if(c&&ne(c)){let m=Mo(this.app.scene.getNonDeletedElementsMap(),c.id);for(let d of m)delete n[d.id]}}let i=lt({editingGroupId:r.editingGroupId,selectedElementIds:n},this.app.scene.getNonDeletedElements(),r,this.app),a=[...Object.keys(i.selectedElementIds)],l=[...Object.keys(i.selectedGroupIds)];return{selectedElementIds:i.selectedElementIds,selectedGroupIds:i.selectedGroupIds,selectedLinearElement:a.length===1&&!l.length&&ae(this.app.scene.getNonDeletedElement(a[0]))?new j(this.app.scene.getNonDeletedElement(a[0])):null}})});C(this,"addPointToPath",(t,r,n=!1)=>{super.addPointToPath(t,r),this.keepPreviousSelection=n,this.updateSelection()});C(this,"updateSelection",()=>{let t=super.getCurrentTrail()?.originalPoints?.map(r=>M(r[0],r[1]));if(!this.elementsSegments){this.elementsSegments=new Map;let r=ee(this.app.visibleElements);for(let n of this.app.visibleElements){let i=Ec(n,r);this.elementsSegments.set(n.id,i)}}if(t){let{selectedElementIds:r}=cw({lassoPath:t,elements:this.app.visibleElements,elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(r)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};var qS=2,ym=class extends Wr{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(Yo(s),Yo(l))},fill:()=>r.state.theme===de.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});C(this,"elementsToErase",new Set);C(this,"groupsToErase",new Set);C(this,"segmentsCache",new Map);C(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(a=>M(a[0],a[1]))||[];r=r?.slice(r.length-qS);let n=ee(this.app.visibleElements),i=r.reduce((a,l,s)=>(s===0||a.push(Zs(r[s-1],l)),a),[]);if(i.length===0)return[];for(let a of this.app.visibleElements)if(t&&this.elementsToErase.has(a.id)){if(dw(i,a,this.segmentsCache,this.geometricShapesCache,n,this.app)){let s=a.groupIds.at(-1);if(this.groupsToErase.has(s)){let c=Fe(this.app.scene.getNonDeletedElementsMap(),s);for(let m of c)this.elementsToErase.delete(m.id);this.groupsToErase.delete(s)}if(_e(a)&&this.elementsToErase.delete(a.containerId),pt(a)){let c=ko(a);c&&this.elementsToErase.delete(c)}this.elementsToErase.delete(a.id)}}else if(!t&&!this.elementsToErase.has(a.id)&&dw(i,a,this.segmentsCache,this.geometricShapesCache,n,this.app)){let s=a.groupIds.at(-1);if(!this.groupsToErase.has(s)){let c=Fe(this.app.scene.getNonDeletedElementsMap(),s);for(let m of c)this.elementsToErase.add(m.id);this.groupsToErase.add(s)}if(pt(a)){let c=ko(a);c&&this.elementsToErase.add(c)}_e(a)&&this.elementsToErase.add(a.containerId),this.elementsToErase.add(a.id)}return Array.from(this.elementsToErase)}endPath(){super.endPath(),super.clearTrails(),this.elementsToErase.clear(),this.groupsToErase.clear(),this.segmentsCache.clear()}},dw=(e,o,t,r=new Map,n=new Map,i)=>{let a=r.get(o.id);a||(a=Rr(o,n),r.set(o.id,a));let l=e[e.length-1][1];if(G1(o)&&vc(l,a))return!0;let s=t.get(o.id);return s||(s=Ec(o,n),t.set(o.id,s)),e.some(c=>s?.some(m=>Xs(c,m,i.getElementHitThreshold())!==null))};import{jsx as Bo,jsxs as mw}from"react/jsx-runtime";var JS=()=>mw("div",{"data-testid":"brave-measure-text-error",children:[Bo("p",{children:Bo(Kt,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Bo("span",{style:{fontWeight:600},children:e})})}),Bo("p",{children:Bo(Kt,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Bo("span",{style:{fontWeight:600},children:e})})}),Bo("p",{children:Bo(Kt,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Bo("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Bo("p",{children:Bo(Kt,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Bo("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>mw("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),pw=JS;import ok from"clsx";import rk from"react";import{useLayoutEffect as QS,useRef as uw,useEffect as hw}from"react";import{unstable_batchedUpdates as ek}from"react-dom";import{jsx as tk}from"react/jsx-runtime";var gw=({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=uw(null);hw(()=>{let d=c.current;if(!d)return;d.contains(document.activeElement)||d.focus();let p=u=>{if(u.key===T.TAB){let g=dl(d),{activeElement:b}=document,x=g.findIndex(E=>E===b);b===d?(u.shiftKey?g[g.length-1]?.focus():g[0].focus(),u.preventDefault(),u.stopImmediatePropagation()):x===0&&u.shiftKey?(g[g.length-1]?.focus(),u.preventDefault(),u.stopImmediatePropagation()):x===g.length-1&&!u.shiftKey&&(g[0]?.focus(),u.preventDefault(),u.stopImmediatePropagation())}};return d.addEventListener("keydown",p),()=>d.removeEventListener("keydown",p)},[]);let m=uw(null);return QS(()=>{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]),hw(()=>{if(r){let d=p=>{c.current?.contains(p.target)||ek(()=>r(p))};return document.addEventListener("pointerdown",d,!1),()=>document.removeEventListener("pointerdown",d,!1)}},[r]),tk("div",{className:"popover",ref:c,tabIndex:-1,children:e})};import{jsx as Ua,jsxs as nk}from"react/jsx-runtime";var bt="separator",fw=rk.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=ur(),a=xn(),l=o.reduce((s,c)=>(c&&(c===bt||!c.predicate||c.predicate(a,i,e.app.props,e.app))&&s.push(c),s),[]);return Ua(gw,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Ua("ul",{className:"context-menu",onContextMenu:s=>s.preventDefault(),children:l.map((s,c)=>{if(s===bt)return!l[c-1]||l[c-1]===bt?null:Ua("hr",{className:"context-menu-item-separator"},c);let m=s.name,d="";return s.label&&(typeof s.label=="function"?d=f(s.label(a,i,e.app)):d=f(s.label)),Ua("li",{"data-testid":m,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:nk("button",{type:"button",className:ok("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Ua("div",{className:"context-menu-item__label",children:d}),Ua("kbd",{className:"context-menu-item__shortcut",children:m?ct(m):""})]})},c)})})})});import{jsx as Sg,jsxs as bw}from"react/jsx-runtime";var ik=({height:e,width:o,userToFollow:t,onDisconnect:r})=>Sg("div",{className:"follow-mode",style:{width:o,height:e},children:bw("div",{className:"follow-mode__badge",children:[bw("div",{className:"follow-mode__badge__label",children:["Following"," ",Sg("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),Sg("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:Lo})]})}),xw=ik;import Es from"clsx";import p8 from"react";import ak from"clsx";import{useState as lk,useEffect as sk}from"react";import{jsx as kg,jsxs as ck}from"react/jsx-runtime";var vm=({delay:e,theme:o})=>{let[t,r]=lk(!!e);return sk(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:ck("div",{className:ak("LoadingMessage",{"LoadingMessage--dark":o===de.DARK}),children:[kg("div",{children:kg(Mt,{})}),kg("div",{className:"LoadingMessage-text",children:f("labels.loadingScene")})]})};import dk from"clsx";import{jsx as yw,jsxs as pk}from"react/jsx-runtime";var mk="medium",Ew={CHECKED:aa,UNCHECKED:mi},wm=e=>pk("label",{className:dk("ToolIcon ToolIcon__lock",`ToolIcon_size_${mk}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[yw("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),yw("div",{className:"ToolIcon__icon",children:e.checked?Ew.CHECKED:Ew.UNCHECKED})]});import uk from"clsx";import{jsx as hk}from"react/jsx-runtime";var Tm=({children:e,side:o,className:t})=>hk("div",{className:uk("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import gk from"clsx";import{jsx as fk}from"react/jsx-runtime";var Cm=e=>fk(Q,{className:gk("Shape",{fillable:!1}),type:"radio",icon:od,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:T.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":T.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{jsx as vw}from"react/jsx-runtime";var bk=({appState:e,isMobile:o,device:t,app:r})=>{let{activeTool:n,isResizing:i,isRotating:a,lastPointerDownWith:l}=e,s=e.multiElement!==null;if(e.openSidebar?.name===At.name&&e.openSidebar.tab===Sr&&e.searchMatches?.length)return f("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(no(e))return f("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?f("hints.linearElementMulti"):n.type==="arrow"?f("hints.arrowTool",{arrowShortcut:R("A")}):f("hints.linearElement");if(n.type==="freedraw")return f("hints.freeDraw");if(n.type==="text")return f("hints.text");if(n.type==="embeddable")return f("hints.embeddable");if(e.activeTool.type==="image"&&e.pendingImageElementId)return f("hints.placeImage");let c=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&c.length===1){let m=c[0];return ae(m)&&m.points.length===2?f("hints.lockAngle"):he(m)?f("hints.resizeImage"):f("hints.resize")}if(a&&l==="mouse")return f("hints.rotate");if(c.length===1&&Z(c[0]))return f("hints.text_selected");if(e.editingTextElement)return f("hints.text_editing");if(e.croppingElementId)return f("hints.leaveCropEditor");if(c.length===1&&he(c[0]))return f("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!c.length&&!e.editingTextElement&&!e.editingLinearElement)return[f("hints.deepBoxSelect")];if(Sn(r)&&e.selectedElementsAreBeingDragged)return f("hints.disableSnapping");if(!c.length&&!o)return[f("hints.canvasPanning")];if(c.length===1){if(ae(c[0]))return e.editingLinearElement?e.editingLinearElement.selectedPointsIndices?f("hints.lineEditor_pointSelected"):f("hints.lineEditor_nothingSelected"):f("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&Dr(c[0]))return jn(c[0])?D0(c[0],r.scene.getNonDeletedElementsMap())?[f("hints.bindTextToElement"),f("hints.createFlowchart")]:[f("hints.bindTextToElement"),f("hints.createFlowchart")]:f("hints.bindTextToElement")}}return null},Im=({appState:e,isMobile:o,device:t,app:r})=>{let n=bk({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 vw("div",{className:"HintViewer",children:vw("span",{children:i})})};import xk from"clsx";import{jsx as ww,jsxs as yk}from"react/jsx-runtime";var Ek="medium",Sm=e=>e.penDetected?yk("label",{className:xk("ToolIcon ToolIcon__penMode",`ToolIcon_size_${Ek}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[ww("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),ww("div",{className:"ToolIcon__icon",children:nx})]}):null;import{Fragment as vk,jsx as Tw,jsxs as wk}from"react/jsx-runtime";var Mn=({heading:e,children:o,...t})=>{let{id:r}=gt(),n=Tw("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:f(`headings.${e}`)});return Tw("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):wk(vk,{children:[n,o]})})};import{Fragment as Tk,jsx as Lt,jsxs as Kr}from"react/jsx-runtime";var Cw=({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:g,MainMenuTunnel:b,DefaultSidebarTriggerTunnel:x}=Ke(),E=()=>Kr(Tm,{side:"top",className:"App-top-bar",children:[d&&Lt(g.Out,{}),Lt(Mn,{heading:"shapes",children:y=>Lt(Ct.Col,{gap:4,align:"center",children:Kr(Ct.Row,{gap:1,className:"App-toolbar-container",children:[Kr(yt,{padding:1,className:"App-toolbar App-toolbar--mobile",children:[y,Lt(Ct.Row,{gap:1,children:Lt(sm,{appState:e,activeTool:e.activeTool,UIOptions:p,app:u})})]}),l&&l(!0,e),Kr("div",{className:"mobile-misc-tools-container",children:[!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Lt(x.Out,{}),Lt(Sm,{checked:e.penMode,onChange:()=>a(null),title:f("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),Lt(wm,{checked:e.activeTool.locked,onChange:n,title:f("toolBar.lock"),isMobile:!0}),Lt(Cm,{checked:Xo(e),onChange:()=>i(),title:f("toolBar.hand"),isMobile:!0})]})]})})}),Lt(Im,{appState:e,isMobile:!0,device:m,app:u})]}),w=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?Lt("div",{className:"App-toolbar-content",children:Lt(b.Out,{})}):Kr("div",{className:"App-toolbar-content",children:[Lt(b.Out,{}),t.renderAction("toggleEditMenu"),t.renderAction(e.multiElement?"finalize":"duplicateSelection"),t.renderAction("deleteSelectedElements"),Kr("div",{children:[t.renderAction("undo"),t.renderAction("redo")]})]});return Kr(Tk,{children:[c(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&E(),Lt("div",{className:"App-bottom-bar",style:{marginBottom:Er+Qo*2,marginLeft:Er+Qo*2,marginRight:Er+Qo*2},children:Kr(yt,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&Ta(e,o)?Lt(Mn,{className:"App-mobile-menu",heading:"selectedShapeActions",children:Lt(lm,{appState:e,elementsMap:u.scene.getNonDeletedElementsMap(),renderAction:t.renderAction,app:u})}):null,Kr("footer",{className:"App-toolbar",children:[w(),e.scrolledOutside&&!e.openMenu&&!e.openSidebar&&Lt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(y=>({...ai(o,y)}))},children:f("buttons.scrollBackToContent")})]})]})})]})};import Ck from"open-color";import Ik,{useLayoutEffect as Sk,useRef as kk,useState as Mk}from"react";import{jsx as ds,jsxs as Lk}from"react/jsx-runtime";var Iw=e=>{let o=kk(null),[t,r]=Mk(null);return Sk(()=>{if(!e.spreadsheet)return;let n=$y(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await ea(n,{exportBackground:!1,viewBackgroundColor:Ck.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]),ds("button",{type:"button",className:"ChartPreview",onClick:()=>{t&&e.onClick(e.chartType,t)},children:ds("div",{ref:o})})},Sw=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=st(),n=Ik.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),xe("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return ds(dt,{size:"small",onCloseRequest:n,title:f("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:Lk("div",{className:"container",children:[ds(Iw,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),ds(Iw,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as Ln from"@radix-ui/react-popover";import kw from"clsx";import km,{useLayoutEffect as Ak}from"react";import{Fragment as Nk,jsx as yr,jsxs as Mm}from"react/jsx-runtime";var _k=4,Dk=8,Pk=({shouldWrap:e,children:o,username:t})=>e?yr(bo,{label:t||"Unknown user",children:o}):yr(Nk,{children:o}),Mg=({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 yr(Pk,{username:o.username,shouldWrap:n,children:l},t)},Rk=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],Lm=km.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=ft(),i=new Map;t.forEach((b,x)=>{let E=b.id||x;i.set(E,{...b,socketId:x})});let a=Array.from(i.values()).filter(b=>b.username?.trim()),[l,s]=km.useState(""),c=a.filter(b=>b.username?.toLowerCase().includes(l)),m=km.useRef(null);Ak(()=>{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),!qa)return;let x=new ResizeObserver(E=>{for(let w of E){let{width:y}=w.contentRect;b(y)}});return x.observe(m.current),()=>{x.disconnect()}}},[]);let[d,p]=km.useState(_k),g=a.slice(0,d-1).map(b=>Mg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?yr("div",{className:kw("UserList UserList_mobile",e),children:a.map(b=>Mg({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):yr("div",{className:"UserList__wrapper",ref:m,children:Mm("div",{className:kw("UserList",e),style:{"--max-avatars":d},children:[g,a.length>d-1&&Mm(Ln.Root,{children:[Mm(Ln.Trigger,{className:"UserList__more",children:["+",a.length-d+1]}),yr(Ln.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:Mm(yt,{padding:2,children:[a.length>=Dk&&yr(xd,{placeholder:f("quickSearch.placeholder"),onChange:s}),yr(Ed,{className:"dropdown-menu UserList__collaborators",placeholder:f("userList.empty"),children:c.length>0?[yr("div",{className:"hint",children:f("userList.hint.text")}),c.map(b=>Mg({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),yr(Ln.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||!Je(n,i,Rk))return!1}return!0});import Am from"clsx";import{jsx as Ok}from"react/jsx-runtime";var Mw=e=>Ok("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${f("helpDialog.title")} \u2014 ?`,"aria-label":f("helpDialog.title"),children:la});import{jsx as vr,jsxs as Lg}from"react/jsx-runtime";var Lw=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=Ke(),a=Ce(),l=!e.viewModeEnabled&&e.multiElement&&a.isTouchScreen;return Lg("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[vr("div",{className:Am("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:vr(Ct.Col,{gap:2,children:Lg(Mn,{heading:"canvasActions",children:[vr(yv,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&vr(vv,{renderAction:o.renderAction,className:Am("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})}),l&&vr(Tv,{renderAction:o.renderAction,className:Am("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled})})]})})}),vr(n.Out,{}),vr("div",{className:Am("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Lg("div",{style:{position:"relative"},children:[r&&vr(i.Out,{}),vr(Mw,{onClick:()=>o.executeAction(vi)})]})}),vr(wv,{actionManager:o,showExitZenModeBtn:t})]})},Aw=Lw;Lw.displayName="Footer";import Yk from"clsx";import{useEffect as Hw,useLayoutEffect as Uw,useRef as zg,useState as Wk,forwardRef as Gw,useImperativeHandle as Kk,useCallback as zw}from"react";import zk from"clsx";import{useContext as Fk}from"react";import Bk from"react";var _m=Bk.createContext({});import{jsx as Ag,jsxs as _w}from"react/jsx-runtime";var _g=({children:e,className:o})=>{let t=Ce(),r=Fk(_m),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return _w("div",{className:zk("sidebar__header",o),"data-testid":"sidebar-header",children:[e,_w("div",{className:"sidebar__header__buttons",children:[n&&Ag(bo,{label:f("labels.sidebarLock"),children:Ag(vo,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":f("labels.sidebarLock"),children:X0})}),Ag(vo,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":f("buttons.close"),children:Lo})]})]})};_g.displayName="SidebarHeader";import*as Pw from"@radix-ui/react-tabs";import{jsx as Dw}from"react/jsx-runtime";var Dg=({children:e,tab:o,onSelect:t,...r})=>Dw(Pw.Trigger,{value:o,asChild:!0,onSelect:t,children:Dw("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});Dg.displayName="SidebarTabTrigger";import*as Rw from"@radix-ui/react-tabs";import{jsx as Hk}from"react/jsx-runtime";var Pg=({children:e,...o})=>Hk(Rw.List,{className:"sidebar-triggers",...o,children:e});Pg.displayName="SidebarTabTriggers";import Uk from"clsx";import{jsx as Rg,jsxs as Nw}from"react/jsx-runtime";var Ng=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=Ie(),c=Re();return Nw("label",{title:r,className:"sidebar-trigger__label-element",children:[Rg("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"}),Nw("div",{className:Uk("sidebar-trigger",a),style:l,children:[t&&Rg("div",{children:t}),n&&Rg("div",{className:"sidebar-trigger__label",children:n})]})]})};Ng.displayName="SidebarTrigger";import*as Ow from"@radix-ui/react-tabs";import{jsx as Gk}from"react/jsx-runtime";var Og=({children:e,...o})=>{let t=Re(),r=Ie();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return Gk(Ow.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};Og.displayName="SidebarTabs";import*as Bw from"@radix-ui/react-tabs";import{jsx as Vk}from"react/jsx-runtime";var Bg=({tab:e,children:o,...t})=>Vk(Bw.Content,{...t,value:e,"data-testid":e,children:o});Bg.displayName="SidebarTab";import{jsx as Fw}from"react/jsx-runtime";import{createElement as Zk}from"react";var ms=De(!1),Vw=Gw(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{Ue()&&t&&r==null&&console.warn("Sidebar: `docked` must be set when `onDock` is supplied for the sidebar to be user-dockable. To hide this message, either pass `docked` or remove `onDock`");let l=Ie(),s=hn(ms);Uw(()=>(s(!!r),()=>{s(!1)}),[s,r]);let c=zg({});c.current.onCloseRequest=()=>{l({openSidebar:null})},c.current.onDock=u=>t?.(u),c.current=Ri(c.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let m=zg(null);Kk(a,()=>m.current);let d=Ce(),p=zw(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return pa(m,zw(u=>{u.target.closest(".sidebar-trigger")||(!r||!d.editor.canFitSidebar)&&p()},[p,r,d.editor.canFitSidebar])),Hw(()=>{let u=g=>{g.key===T.ESCAPE&&(!r||!d.editor.canFitSidebar)&&p()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[p,r,d.editor.canFitSidebar]),Fw(yt,{...i,className:Yk("sidebar",{"sidebar--docked":r},n),ref:m,children:Fw(_m.Provider,{value:c.current,children:o})})});Vw.displayName="SidebarInner";var zo=Object.assign(Gw((e,o)=>{let t=Re(),{onStateChange:r}=e,n=zg(t.openSidebar);Hw(()=>{(!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]=Wk(!1);return Uw(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?Zk(Vw,{...e,ref:o,key:e.name}):null}),{Header:_g,TabTriggers:Pg,TabTrigger:Dg,Tabs:Og,Tab:Bg,Trigger:Ng});zo.displayName="Sidebar";import{useLayoutEffect as Xk,useRef as $k}from"react";import{jsx as jk}from"react/jsx-runtime";var Zr=(e,o)=>{let t=De(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=Ke(),[,a]=i(t),l=$k({preferHost:!1,counter:0});return Xk(()=>{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:jk(o,{...n})};return r.displayName=e,r};var Ug={};Pf(Ug,{ChangeCanvasBackground:()=>r3,ClearCanvas:()=>t3,CommandPalette:()=>Jw,Export:()=>n3,Help:()=>e3,LiveCollaborationTrigger:()=>a3,LoadScene:()=>$w,SaveAsImage:()=>qw,SaveToActiveFile:()=>jw,SearchMenu:()=>Qw,Socials:()=>i3,ToggleTheme:()=>o3});import eM from"clsx";var Fg=De({active:!1});async function Yw({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{St.set(Fg,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import qk from"clsx";import{jsx as Ww,jsxs as Jk}from"react/jsx-runtime";var Dm=function({onChange:e,value:o,choices:t,name:r}){return Ww("div",{className:"RadioGroup",children:t.map(n=>Jk("div",{className:qk("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[Ww("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 Qk,jsx as Hg,jsxs as Kw}from"react/jsx-runtime";var Zw=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=Ce();return Kw(Qk,{children:[Kw("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[Hg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),Hg(Dm,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&Hg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};Zw.displayName="DropdownMenuItemContentRadio";var Xw=Zw;import{Fragment as tM,jsx as wt,jsxs as l3}from"react/jsx-runtime";var $w=()=>{let{t:e}=ut(),o=ft(),t=xn();return o.isActionEnabled(wa)?wt(Yt,{icon:sa,onSelect:async()=>{(!t.length||await Yw({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:wt(Kt,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>wt("strong",{children:n}),br:()=>wt("br",{})})}))&&o.executeAction(wa)},"data-testid":"load-button",shortcut:ct("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};$w.displayName="LoadScene";var jw=()=>{let{t:e}=ut(),o=ft();return o.isActionEnabled(yi)?wt(Yt,{shortcut:ct("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(yi),icon:px,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};jw.displayName="SaveToActiveFile";var qw=()=>{let e=Ie(),{t:o}=ut();return wt(Yt,{icon:Jc,"data-testid":"image-export-button",onSelect:()=>e({openDialog:{name:"imageExport"}}),shortcut:ct("imageExport"),"aria-label":o("buttons.exportImage"),children:o("buttons.exportImage")})};qw.displayName="SaveAsImage";var Jw=e=>{let o=Ie(),{t}=ut();return wt(Yt,{icon:id,"data-testid":"command-palette-button",onSelect:()=>{xe("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:ct("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};Jw.displayName="CommandPalette";var Qw=e=>{let{t:o}=ut(),t=ft();return wt(Yt,{icon:go,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(is)},shortcut:ct("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};Qw.displayName="SearchMenu";var e3=()=>{let{t:e}=ut(),o=ft();return wt(Yt,{"data-testid":"help-menu-item",icon:la,onSelect:()=>o.executeAction(vi),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};e3.displayName="Help";var t3=()=>{let{t:e}=ut(),o=hn(Ci);return ft().isActionEnabled(Fr)?wt(Yt,{icon:ho,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};t3.displayName="ClearCanvas";var o3=e=>{let{t:o}=ut(),t=Re(),r=ft(),n=ct("toggleTheme");return r.isActionEnabled(fi)?e?.allowSystemTheme?wt(Xw,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:de.LIGHT,label:Rl,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:de.DARK,label:Pl,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:kE,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):wt(Yt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===de.DARK?de.LIGHT:de.DARK);else return r.executeAction(fi)},icon:t.theme===de.DARK?Rl:Pl,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===de.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===de.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};o3.displayName="ToggleTheme";var r3=()=>{let{t:e}=ut(),o=Re(),t=ft(),r=hr();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:l3("div",{style:{marginTop:"0.5rem"},children:[wt("div",{"data-testid":"canvas-background-label",style:{fontSize:".75rem",marginBottom:".5rem"},children:e("labels.canvasBackground")}),wt("div",{style:{padding:"0 0.625rem"},children:t.renderAction("changeViewBackgroundColor")})]})};r3.displayName="ChangeCanvasBackground";var n3=()=>{let{t:e}=ut(),o=Ie();return wt(Yt,{icon:pi,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};n3.displayName="Export";var i3=()=>{let{t:e}=ut();return l3(tM,{children:[wt(Ra,{icon:jc,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),wt(Ra,{icon:dx,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),wt(Ra,{icon:cx,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};i3.displayName="Socials";var a3=({onSelect:e,isCollaborating:o})=>{let{t}=ut();return wt(Yt,{"data-testid":"collab-button",icon:Qc,className:eM({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};a3.displayName="LiveCollaborationTrigger";import{jsx as Pm,jsxs as Gg}from"react/jsx-runtime";var oM=Object.assign(Zr("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=Ke(),r=Ce(),n=Re(),i=Ie(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return Pm(t.In,{children:Gg(Ne,{open:n.openMenu==="canvas",children:[Pm(Ne.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:$c}),Gg(Ne.Content,{onClickOutside:a,onSelect:an(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&Gg("fieldset",{className:"UserList-Wrapper",children:[Pm("legend",{children:f("labels.collaborators")}),Pm(Lm,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:Ne.Trigger,Item:Ne.Item,ItemLink:Ne.ItemLink,ItemCustom:Ne.ItemCustom,Group:Ne.Group,Separator:Ne.Separator,DefaultItems:Ug}),Ot=oM;import rM from"clsx";import{forwardRef as nM,useState as iM}from"react";import{jsx as Rm,jsxs as aM}from"react/jsx-runtime";var An=nM(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:c},m)=>{let[d,p]=iM(!1),u=async b=>{let x=t?.(b);if(nn(x)){let E=window.setTimeout(()=>{p(!0)},50);try{await x}catch(w){if(w instanceof Ji)console.warn(w);else throw w}finally{clearTimeout(E),p(!1)}}},g=d?"loading":c;return i=g==="success"?"success":i,Rm("button",{className:rM("ExcButton",`ExcButton--color-${i}`,`ExcButton--variant-${n}`,`ExcButton--size-${a}`,`ExcButton--status-${g}`,{"ExcButton--fullWidth":l},s),onClick:u,type:"button","aria-label":r,ref:m,disabled:g==="loading"||g==="success",children:aM("div",{className:"ExcButton__contents",children:[g==="loading"?Rm(Mt,{className:"ExcButton__statusIcon"}):g==="success"&&Rm("div",{className:"ExcButton__statusIcon",children:sE}),o&&Rm("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as Ga,jsxs as cM}from"react/jsx-runtime";var Nm=({title:e,children:o,actionLabel:t,onClick:r})=>cM("div",{className:"OverwriteConfirm__Actions__Action",children:[Ga("h4",{children:e}),Ga("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),Ga(An,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),lM=()=>{let{t:e}=ut(),o=ft(),t=Ie();return Ga(Nm,{title:e("overwriteConfirm.action.exportToImage.title"),actionLabel:e("overwriteConfirm.action.exportToImage.button"),onClick:()=>{o.executeAction(Od,"ui",!0),t({openDialog:{name:"imageExport"}})},children:e("overwriteConfirm.action.exportToImage.description")})},sM=()=>{let{t:e}=ut(),o=ft();return Ga(Nm,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Jl,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},Vg=Object.assign(({children:e})=>Ga("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:lM,SaveToDisk:sM});import{jsx as _n,jsxs as s3}from"react/jsx-runtime";var Om=Object.assign(Zr("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=Ke(),[t,r]=ve(Fg);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return _n(o.In,{children:_n(dt,{onCloseRequest:n,title:!1,size:916,children:s3("div",{className:"OverwriteConfirm",children:[_n("h3",{children:t.title}),s3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[_n("div",{className:"OverwriteConfirm__Description__icon",children:cE}),_n("div",{children:t.description}),_n("div",{className:"OverwriteConfirm__Description__spacer"}),_n(An,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),_n(Vg,{children:e})]})})})}),{Actions:Vg,Action:Nm});import IM from"clsx";import dM from"clsx";import mM from"lodash.debounce";import{Fragment as pM,memo as uM,useEffect as ps,useRef as Yg,useState as c3}from"react";import{Fragment as CM,jsx as wo,jsxs as us}from"react/jsx-runtime";var hM=De(""),Wg=De(null),gM=350,m3=()=>{let e=st(),o=Ie(),t=Yg(null),[r,n]=ve(hM),i=r.trim(),[a,l]=c3(!1),[s,c]=c3({nonce:null,items:[]}),m=Yg(null),d=Yg(void 0),[p,u]=ve(Wg),g=e.scene.getNonDeletedElementsMap();ps(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==d.current)&&(m.current=null,d3(i,e,(y,v)=>{c({nonce:Lr(),items:y}),m.current=i,d.current=e.scene.getSceneNonce(),o({searchMatches:y.map(I=>({id:I.textElement.id,focus:!1,matchedLines:I.matchedLines}))})}))},[a,i,g,e,o,u,d]);let b=()=>{s.items.length>0&&u(y=>y===null?0:(y+1)%s.items.length)},x=()=>{s.items.length>0&&u(y=>y===null?0:y-1<0?s.items.length-1:y-1)};ps(()=>{o(y=>({searchMatches:y.searchMatches.map((v,I)=>I===p?{...v,focus:!0}:{...v,focus:!1})}))},[p,o]),ps(()=>{if(s.items.length>0&&p!==null){let y=s.items[p];if(y){let v=e.state.zoom.value,I=Vt({text:y.searchQuery,x:y.textElement.x+(y.matchedLines[0]?.offsetX??0),y:y.textElement.y+(y.matchedLines[0]?.offsetY??0),width:y.matchedLines[0]?.width,height:y.matchedLines[0]?.height,fontSize:y.textElement.fontSize,fontFamily:y.textElement.fontFamily}),S=14,_=y.textElement.fontSize,L=_*v<S;if(!Vi([I],e.canvas.width/window.devicePixelRatio,e.canvas.height/window.devicePixelRatio,{offsetLeft:e.state.offsetLeft,offsetTop:e.state.offsetTop,scrollX:e.state.scrollX,scrollY:e.state.scrollY,zoom:e.state.zoom},e.scene.getNonDeletedElementsMap(),e.getEditorUIOffsets())||L){let N;L?_>=S?N={fitToContent:!0}:N={fitToViewport:!0,maxZoom:So(S/_,1)}:N={fitToContent:!0},e.scrollToContent(I,{animate:!0,duration:300,...N,canvasOffsets:e.getEditorUIOffsets()})}}}},[p,s,e]),ps(()=>()=>{u(null),m.current=null,d.current=void 0,o({searchMatches:[]}),l(!1)},[o,u]);let E=fn({goToNextItem:b,goToPreviousItem:x,searchMatches:s});ps(()=>{let y=v=>{if(v.key===T.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}v[T.CTRL_OR_CMD]&&v.key===T.F&&(v.preventDefault(),v.stopPropagation(),t.current?.matches(":focus")?o({openSidebar:null}):(e.state.openDialog&&o({openDialog:null}),t.current?.focus(),t.current?.select())),v.target instanceof HTMLElement&&v.target.closest(".layer-ui__search")&&E.searchMatches.items.length&&(v.key===T.ENTER&&(v.stopPropagation(),E.goToNextItem()),v.key===T.ARROW_UP?(v.stopPropagation(),E.goToPreviousItem()):v.key===T.ARROW_DOWN&&(v.stopPropagation(),E.goToNextItem()))};return Ye(window,"keydown",y,{capture:!0,passive:!1})},[o,E,e]);let w=`${s.items.length} ${s.items.length===1?f("search.singleResult"):f("search.multipleResults")}`;return us("div",{className:"layer-ui__search",children:[wo("div",{className:"layer-ui__search-header",children:wo(Ba,{className:Go.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:f("search.placeholder"),icon:go,onChange:y=>{n(y),l(!0);let v=y.trim();d3(v,e,(I,S)=>{c({nonce:Lr(),items:I}),u(S),m.current=v,d.current=e.scene.getSceneNonce(),o({searchMatches:I.map(_=>({id:_.textElement.id,focus:!1,matchedLines:_.matchedLines}))}),l(!1)})},selectOnRender:!0})}),us("div",{className:"layer-ui__search-count",children:[s.items.length>0&&us(CM,{children:[p!==null&&p>-1?us("div",{children:[p+1," / ",w]}):wo("div",{children:w}),us("div",{className:"result-nav",children:[wo(vo,{onSelect:()=>{b()},className:"result-nav-btn",children:ld}),wo(vo,{onSelect:()=>{x()},className:"result-nav-btn",children:NE})]})]}),s.items.length===0&&i&&m.current&&wo("div",{style:{margin:"1rem auto"},children:f("search.noMatch")})]}),wo(EM,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},fM=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 wo("div",{tabIndex:-1,className:dM("layer-ui__result-item",{active:e.highlighted}),onClick:e.onClick,ref:t=>{e.highlighted&&t?.scrollIntoView({behavior:"auto",block:"nearest"})},children:wo("div",{className:"preview-text",children:o.flatMap((t,r)=>wo(pM,{children:r===2?wo("b",{children:t}):t},r))})})},bM=e=>wo("div",{className:"layer-ui__search-result-container",children:e.matches.items.map((o,t)=>wo(fM,{searchQuery:e.searchQuery,preview:o.preview,highlighted:t===e.focusIndex,onClick:()=>e.onItemClick(t)},o.textElement.id+o.index))}),xM=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,EM=uM(bM,xM),yM=(e,o,t)=>{let i=e.slice(0,o),a=i.split(/\s+/),l=i.endsWith(" "),s=a.length-2-1-(l?0:1),c=a.slice(s<=0?0:s).join(" ")+(l?" ":""),m=20;c=c.length>m?c.slice(-m):c;let d=e.slice(o+t.length),p=d.split(/\s+/),u=!d.startsWith(" "),g=u?6:5,b=(u?"":" ")+p.slice(0,g).join(" ");return{indexInSearchQuery:c.length,previewText:c+t+b,moreBefore:s>0,moreAfter:p.length>g}},vM=(e,o)=>{let t=e.split(`
9
- `),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(`
10
- `)},wM=(e,o,t)=>{let n=vM(e.text,e.originalText).split(`
11
- `),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),g=c.slice(0,p);c=c.slice(p);let b=Ht(u,qe(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&d.line.length>0){let v=Ht(d.line,qe(e),e.lineHeight),I=e.textAlign==="center"?(e.width-v.width)/2:e.width-v.width;b.width+=I}let{width:x,height:E}=Ht(g,qe(e),e.lineHeight),w=b.width,y=d.lineNumber*b.height;m.push({offsetX:w,offsetY:y,width:x,height:E}),s+=p}}return m},TM=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),d3=mM((e,o,t)=>{if(!e||e===""){t([],null);return}let n=o.scene.getNonDeletedElements().filter(c=>Z(c));n.sort((c,m)=>c.y-m.y);let i=[],a=new RegExp(TM(e),"gi");for(let c of n){let m=null,d=c.originalText;for(;(m=a.exec(d))!==null;){let p=yM(d,m.index,e),u=wM(c,e,m.index);u.length>0&&i.push({textElement:c,searchQuery:e,preview:p,index:m.index,matchedLines:u})}}let l=new Set(o.visibleElements.map(c=>c.id)),s=i.findIndex(c=>l.has(c.textElement.id))??null;t(i,s)},gM);import{jsx as er,jsxs as p3}from"react/jsx-runtime";import{createElement as SM}from"react";var u3=Zr("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=Ke();return er(o.In,{children:er(zo.Trigger,{...e,className:"default-sidebar-trigger",name:At.name})})});u3.displayName="DefaultSidebarTrigger";var h3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=Ke();return er(o.In,{children:e})};h3.displayName="DefaultTabTriggers";var Bm=Object.assign(Zr("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let i=Re(),a=Ie(),{DefaultSidebarTabTriggersTunnel:l}=Ke(),s=i.openSidebar?.tab===Sr;return SM(zo,{...n,name:"default",key:"default",className:IM("default-sidebar",o),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:an(t,c=>{a({defaultSidebarDockedPreference:c})})},p3(zo.Tabs,{children:[er(zo.Header,{children:p3(zo.TabTriggers,{children:[er(zo.TabTrigger,{tab:Sr,children:go}),er(zo.TabTrigger,{tab:nl,children:ia}),er(l.Out,{})]})}),er(zo.Tab,{tab:nl,children:er(hv,{})}),er(zo.Tab,{tab:Sr,children:er(m3,{})}),e]}))}),{Trigger:u3,TabTriggers:h3});import{useEffect as HM,useRef as Xg,useState as Zm}from"react";import{useState as E3,useRef as y3,useEffect as v3,useDeferredValue as PM}from"react";import{useEffect as kM,useRef as g3}from"react";import{jsx as MM}from"react/jsx-runtime";var zm=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=g3(null),i=g3(r);return i.current=r,kM(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[T.CTRL_OR_CMD]&&s.key===T.ENTER&&(s.preventDefault(),i.current?.())};return a.addEventListener("keydown",l),()=>{a.removeEventListener("keydown",l)}}},[]),MM("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,autoFocus:!0,ref:n})};import{jsx as Fm,jsxs as f3}from"react/jsx-runtime";var LM=({error:e})=>f3("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Fm("p",{children:e})]}),Hm=({error:e,canvasRef:o,loaded:t})=>f3("div",{className:"ttd-dialog-output-wrapper",children:[e&&Fm(LM,{error:e.message}),t?Fm("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Fm(Mt,{size:"2rem"})]});import b3 from"clsx";import{jsx as Kg,jsxs as hs}from"react/jsx-runtime";var Va=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>hs("div",{className:"ttd-dialog-panel",children:[hs("div",{className:"ttd-dialog-panel__header",children:[Kg("label",{children:e}),i?.()]}),o,hs("div",{className:b3("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[hs(vo,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[hs("div",{className:b3({invisible:n}),children:[t?.label,t?.icon&&Kg("span",{children:t.icon})]}),n&&Kg(Mt,{})]}),!r&&!n&&a?.(),l?.()]})]});import{jsx as AM}from"react/jsx-runtime";var Um=({children:e})=>AM("div",{className:"ttd-dialog-panels",children:e});import{jsx as x3,jsxs as _M}from"react/jsx-runtime";var Gm=()=>_M("div",{className:"ttd-dialog-submit-shortcut",children:[x3("div",{className:"ttd-dialog-submit-shortcut__key",children:R("CtrlOrCmd")}),x3("div",{className:"ttd-dialog-submit-shortcut__key",children:R("Enter")})]});var DM=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},Vm=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){DM({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:Fa(c,{regenerateIds:!0}),files:m};let d=await Tn({elements:n.current.elements,files:n.current.files,exportPadding:en,maxWidthOrHeight:Math.max(a.offsetWidth,a.offsetHeight)*window.devicePixelRatio});try{await Nr(d)}catch(p){throw p.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("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}}},gs=e=>{Ro.set(tn.MERMAID_TO_EXCALIDRAW,e)},Ym=({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&&gs(t))};import{Fragment as OM,jsx as wr,jsxs as T3}from"react/jsx-runtime";var RM=`flowchart TD
7
+ ${g("hints.firefox_clipboard_write")}`):new Error(g("alerts.couldNotCopyToClipboard"))}else throw new Error("Unsupported export type")};var Vx=async(e,o,t,r)=>{let{exportBackground:n,viewBackgroundColor:i,fileHandle:a}=o,l=l1(a);if(!a||!s1(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}=Vr(e,o,!1);return await Xr(l,s,o,t,{exportBackground:n,viewBackgroundColor:i,name:r,fileHandle:a,exportingFrame:d}),{fileHandle:a}};import{Fragment as Tk,jsx as Ro,jsxs as Ik}from"react/jsx-runtime";var Up=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:r,app:n})=>Ro(Lx,{label:g("labels.fileTitle"),value:n.getName(),onChange:i=>o(i),ignoreFocus:r?.ignoreFocus??!1})}),Xx=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 r=vk(e),i=Ee(r,o)?j(r,o):r;return Ro(Tk,{children:wk.map(a=>{let[l,s]=i1(i,yk,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)})})}}),Yp=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(ba,{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})=>Ik(ba,{checked:e.exportEmbedScene,onChange:t=>o(t),children:[g("imageExportDialog.label.embedScene"),Ro(Pt,{label:g("imageExportDialog.tooltip.embedScene"),long:!0,children:Ro("div",{className:"excalidraw-tooltip-icon",children:X1})})]})}),Kr=B({name:"saveToActiveFile",label:"buttons.save",icon:Fr,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}=Rl(o.fileHandle)?await Vx(e,o,r.files,r.getName()):await Ll(e,o,r.files,r.getName());return{captureUpdate:ro.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:ro.EVENTUALLY}}},keyTest:e=>e.key===Xn.S&&e[Xn.CTRL_OR_CMD]&&!e.shiftKey}),Ta=B({name:"saveFileToDisk",label:"exportDialog.disk_title",icon:Fr,viewMode:!0,trackEvent:{category:"export"},perform:async(e,o,t,r)=>{try{let{fileHandle:n}=await Ll(e,{...o,fileHandle:null},r.files,r.getName());return{captureUpdate:ro.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:ro.EVENTUALLY}}},keyTest:e=>e.key===Xn.S&&e.shiftKey&&e[Xn.CTRL_OR_CMD],PanelComponent:({updateData:e})=>Ro(K,{type:"button",icon:G1,title:g("buttons.saveAs"),"aria-label":g("buttons.saveAs"),showAriaLabel:se().editor.isMobile,hidden:!gn,onClick:()=>e(null),"data-testid":"save-as-button"})}),Kn=B({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 pm(o,e);return{elements:n,appState:i,files:a,captureUpdate:ro.IMMEDIATELY}}catch(n){return n?.name==="AbortError"?(console.warn(n),!1):{elements:e,appState:{...o,errorMessage:n.message},files:r.files,captureUpdate:ro.EVENTUALLY}}},keyTest:e=>e[Xn.CTRL_OR_CMD]&&e.key===Xn.O}),Kx=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(kx,{value:e.exportWithDarkMode?Gp.DARK:Gp.LIGHT,onChange:t=>{o(t===Gp.DARK)},title:g("imageExportDialog.label.darkMode")})})});import{DEFAULT_FONT_SIZE as Ck,DEFAULT_FONT_FAMILY as Sk,DEFAULT_TEXT_ALIGN as kk,CODES as Zx,KEYS as $x,getLineHeight as Mk}from"@excalidraw/common";import{newElementWith as Ks}from"@excalidraw/element";import{hasBoundTextElement as Lk,canApplyRoundnessTypeToElement as Pk,getDefaultRoundnessTypeForElement as Ak,isFrameLikeElement as Dk,isArrowElement as _k,isExcalidrawElement as Rk,isTextElement as Wp}from"@excalidraw/element";import{getBoundTextElement as Nk,redrawTextBoundingBox as Bk}from"@excalidraw/element";import{CaptureUpdateAction as Vp}from"@excalidraw/element";var jx="{}",Xp=B({name:"copyStyles",label:"labels.copyStyles",icon:Hm,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=[],i=e.find(a=>o.selectedElementIds[a.id]);if(n.push(i),i&&Lk(i)){let a=Nk(i,r.scene.getNonDeletedElementsMap());n.push(a)}return i&&(jx=JSON.stringify(n)),{appState:{...o,toast:{message:g("toast.copyStyles")}},captureUpdate:Vp.EVENTUALLY}},keyTest:e=>e[$x.CTRL_OR_CMD]&&e.altKey&&e.code===Zx.C}),Kp=B({name:"pasteStyles",label:"labels.pasteStyles",icon:Hm,trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=JSON.parse(jx),i=n[0],a=n[1];if(!Rk(i))return{elements:e,captureUpdate:Vp.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(Wp(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?Pk(m.roundness.type,d)?m.roundness:Ak(d):null});if(Wp(c)){let p=m.fontSize||Ck,u=m.fontFamily||Sk;c=Ks(c,{fontSize:p,fontFamily:u,textAlign:m.textAlign||kk,lineHeight:m.lineHeight||Mk(u)});let f=null;c.containerId&&(f=l.find(b=>Wp(c)&&b.id===c.containerId)||null),Bk(c,f,r.scene)}return c.type==="arrow"&&_k(m)&&(c=Ks(c,{startArrowhead:m.startArrowhead,endArrowhead:m.endArrowhead})),Dk(d)&&(c=Ks(c,{roundness:null,backgroundColor:"transparent"})),c}return d}),captureUpdate:Vp.IMMEDIATELY}},keyTest:e=>e[$x.CTRL_OR_CMD]&&e.altKey&&e.code===Zx.V});import{KEYS as Fk}from"@excalidraw/common";import{getNonDeletedElements as Ok}from"@excalidraw/element";import{showSelectedShapeActions as zk}from"@excalidraw/element";import{CaptureUpdateAction as Zp}from"@excalidraw/element";import{jsx as qx}from"react/jsx-runtime";var Hk=B({name:"toggleCanvasMenu",label:"buttons.menu",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="canvas"?null:"canvas"},captureUpdate:Zp.EVENTUALLY}),PanelComponent:({appState:e,updateData:o})=>qx(K,{type:"button",icon:Xl,"aria-label":g("buttons.menu"),onClick:o,selected:e.openMenu==="canvas"})}),Gk=B({name:"toggleEditMenu",label:"buttons.edit",trackEvent:{category:"menu"},perform:(e,o)=>({appState:{...o,openMenu:o.openMenu==="shape"?null:"shape"},captureUpdate:Zp.EVENTUALLY}),PanelComponent:({elements:e,appState:o,updateData:t})=>qx(K,{visible:zk(o,Ok(e)),type:"button",icon:U1,"aria-label":g("buttons.edit"),onClick:t,selected:o.openMenu==="shape"})}),Zr=B({name:"toggleShortcuts",label:"welcomeScreen.defaults.helpHint",icon:B1,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:Zp.EVENTUALLY}),keyTest:e=>e.key===Fk.QUESTION_MARK});import{getNonDeletedElements as $s}from"@excalidraw/element";import{newElementWith as eE}from"@excalidraw/element";import{isBoundToContainer as Uk}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as Yk,getElementsInResizingFrame as Wk,getFrameLikeElements as Vk,getRootElements as Xk,groupByFrameLikes as Kk,removeElementsFromFrame as Zk,replaceAllElementsInFrame as $k}from"@excalidraw/element";import{KEYS as js,randomId as jk,arrayToMap as $p,getShortcutKey as tE}from"@excalidraw/common";import{getSelectedGroupIds as Zs,selectGroup as qk,selectGroupsForSelectedElements as Jk,getElementsInGroup as Jx,addToGroup as Qk,removeFromSelectedGroups as eM,isElementInGroup as oE}from"@excalidraw/element";import{syncMovedIndices as tM}from"@excalidraw/element";import{CaptureUpdateAction as Ia}from"@excalidraw/element";import{jsx as Zn}from"react/jsx-runtime";var oM=e=>{if(e.length>=2){let o=e[0].groupIds;for(let t of o)if(e.reduce((r,n)=>r&&oE(n,t),!0))return!0}return!1},Qx=(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});return r.length>=2&&!oM(r)&&!Yk(r)},jp=B({name:"group",label:"labels.group",icon:e=>Zn(Bm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Xk(r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}));if(n.length<2)return{appState:o,elements:e,captureUpdate:Ia.EVENTUALLY};let i=Zs(o);if(i.length===1){let x=i[0],w=new Set(Jx(e,x).map(v=>v.id)),E=new Set(n.map(v=>v.id));if(new Set([...Array.from(w),...Array.from(E)]).size===w.size)return{appState:o,elements:e,captureUpdate:Ia.EVENTUALLY}}let a=[...e];new Set(n.map(x=>x.frameId)).size>1&&Kk(n).forEach((w,E)=>{Zk(w,r.scene.getNonDeletedElementsMap())});let s=jk(),d=$p(n);a=a.map(x=>d.get(x.id)?eE(x,{groupIds:Qk(x.groupIds,s,o.editingGroupId)}):x);let m=Jx(a,s),c=m[m.length-1],p=a.lastIndexOf(c),u=a.slice(p+1),f=a.slice(0,p).filter(x=>!oE(x,s)),b=tM([...f,...m,...u],$p(m));return{appState:{...o,...qk(s,{...o,selectedGroupIds:{}},$s(a))},elements:b,captureUpdate:Ia.IMMEDIATELY}},predicate:(e,o,t,r)=>Qx(e,o,r),keyTest:e=>!e.shiftKey&&e[js.CTRL_OR_CMD]&&e.key===js.G,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Zn(K,{hidden:!Qx(e,o,r),type:"button",icon:Zn(Bm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.group")} \u2014 ${tE("CtrlOrCmd+G")}`,"aria-label":g("labels.group"),visible:Ee($s(e),o)})}),qp=B({name:"ungroup",label:"labels.ungroup",icon:e=>Zn(Fm,{theme:e.theme}),trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=Zs(o),i=$p(e);if(n.length===0)return{appState:o,elements:e,captureUpdate:Ia.EVENTUALLY};let a=[...e],l=[];a=a.map(p=>{Uk(p)&&l.push(p.id);let u=eM(p.groupIds,o.selectedGroupIds);return u.length===p.groupIds.length?p:eE(p,{groupIds:u})});let s=Jk(o,$s(a),o,null),d=r.scene.getSelectedElements(o),m=new Set(d.filter(p=>p.frameId).map(p=>p.frameId));return Vk(e).filter(p=>m.has(p.id)).forEach(p=>{p&&(a=$k(a,Wk(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:Ia.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})=>Zn(K,{type:"button",hidden:Zs(o).length===0,icon:Zn(Fm,{theme:o.theme}),onClick:()=>t(null),title:`${g("labels.ungroup")} \u2014 ${tE("CtrlOrCmd+Shift+G")}`,"aria-label":g("labels.ungroup"),visible:Ee($s(e),o)})});import cM from"clsx";import{CaptureUpdateAction as lE}from"@excalidraw/element";import{COLOR_CHARCOAL_BLACK as rM,COLOR_VOICE_CALL as nM,COLOR_WHITE as Js,THEME as iM,UserIdleState as rE}from"@excalidraw/common";var qs=(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 aM(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 $r=(e,o)=>`hsl(${Math.abs(aM(o?.id||e))%37*10}, 100%, 83%)`,nE=e=>{let o=e?.trim()?.codePointAt(0);return(o?String.fromCodePoint(o):"?").toUpperCase()},iE=({context:e,renderConfig:o,appState:t,normalizedWidth:r,normalizedHeight:n})=>{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>r-m||s<0||s>n-c;l=Math.max(l,0),l=Math.min(l,r-m),s=Math.max(s,0),s=Math.min(s,n-c);let u=$r(i,d);e.save(),e.strokeStyle=u,e.fillStyle=u;let f=o.remotePointerUserStates.get(i),b=p||f===rE.IDLE||f===rE.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===iM.DARK?"#2f6330":nM,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=rM,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 lM from"clsx";import{useState as sM}from"react";import{jsx as aE}from"react/jsx-runtime";var Jp=({color:e,onClick:o,name:t,src:r,className:n})=>{let i=nE(t),[a,l]=sM(!1),s=!a&&r,d=s?void 0:{background:e};return aE("div",{className:lM("Avatar",n),style:d,onClick:o,children:s?aE("img",{className:"Avatar-img",src:r,alt:i,referrerPolicy:"no-referrer",onError:()=>l(!0)}):i})};import{jsx as Eo,jsxs as Qs}from"react/jsx-runtime";var dM=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:lE.EVENTUALLY}:{appState:{...o,userToFollow:{socketId:t.socketId,username:t.username||""},openMenu:o.openMenu==="canvas"?null:o.openMenu},captureUpdate:lE.EVENTUALLY},PanelComponent:({updateData:e,data:o,appState:t})=>{let{socketId:r,collaborator:n,withName:i,isBeingFollowed:a}=o,l=$r(r,n),s=cM({"is-followed":a,"is-current-user":n.isCurrentUser===!0,"is-speaking":n.isSpeaking,"is-in-call":n.isInCall,"is-muted":n.isMuted}),d=n.isInCall?n.isSpeaking?Qs("div",{className:"UserList__collaborator-status-icon-speaking-indicator",title:g("userList.hint.isSpeaking"),children:[Eo("div",{}),Eo("div",{}),Eo("div",{})]}):n.isMuted?Eo("div",{className:"UserList__collaborator-status-icon-microphone-muted",title:g("userList.hint.micMuted"),children:K0}):Eo("div",{title:g("userList.hint.inCall"),children:X0}):null;return i?Qs("div",{className:`dropdown-menu-item dropdown-menu-item-base UserList__collaborator ${s}`,style:{"--avatar-size":"1.5rem"},onClick:()=>e(n),children:[Eo(Jp,{color:l,onClick:()=>{},name:n.username||"",src:n.avatarUrl,className:s}),Eo("div",{className:"UserList__collaborator-name",children:n.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:kn}),d]})]}):Qs("div",{className:`UserList__collaborator UserList__collaborator--avatar-only ${s}`,children:[Eo(Jp,{color:l,onClick:()=>{e(n)},name:n.username||"",src:n.avatarUrl,className:s}),d&&Eo("div",{className:"UserList__collaborator-status-icon",children:d})]})}});import{LIBRARY_DISABLED_TYPES as mM,randomId as pM}from"@excalidraw/common";import{deepCopyElement as uM}from"@excalidraw/element";import{CaptureUpdateAction as Qp}from"@excalidraw/element";var eu=B({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 mM)if(n.some(a=>a.type===i))return{captureUpdate:Qp.EVENTUALLY,appState:{...o,errorMessage:g(`errors.libraryElementTypeError.${i}`)}};return r.library.getLatestLibrary().then(i=>r.library.setLibrary([{id:pM(),status:"unpublished",elements:n.map(uM),created:Date.now()},...i])).then(()=>({captureUpdate:Qp.EVENTUALLY,appState:{...o,toast:{message:g("toast.addedToLibrary")}}})).catch(i=>({captureUpdate:Qp.EVENTUALLY,appState:{...o,errorMessage:i.message}}))},label:"labels.addToLibrary"});import{getNonDeletedElements as $n}from"@excalidraw/element";import{isFrameLikeElement as hM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as gM}from"@excalidraw/element";import{KEYS as sr,arrayToMap as fM,getShortcutKey as ec}from"@excalidraw/common";import{alignElements as bM}from"@excalidraw/element";import{CaptureUpdateAction as jn}from"@excalidraw/element";import{getSelectedElementsByGroup as xM}from"@excalidraw/element";import{jsx as Jn}from"react/jsx-runtime";var vt=(e,o)=>{let t=o.scene.getSelectedElements(e);return xM(t,o.scene.getNonDeletedElementsMap(),e).length>1&&!t.some(r=>hM(r))},qn=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=bM(n,r,t.scene,o),a=fM(i);return gM(e.map(l=>a.get(l.id)||l),o,t)},EM=B({name:"alignTop",label:"labels.alignTop",icon:Pm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"start",axis:"y"}),captureUpdate:jn.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_UP,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:Pm,onClick:()=>t(null),title:`${g("labels.alignTop")} \u2014 ${ec("CtrlOrCmd+Shift+Up")}`,"aria-label":g("labels.alignTop"),visible:Ee($n(e),o)})}),yM=B({name:"alignBottom",label:"labels.alignBottom",icon:Am,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"end",axis:"y"}),captureUpdate:jn.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_DOWN,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:Am,onClick:()=>t(null),title:`${g("labels.alignBottom")} \u2014 ${ec("CtrlOrCmd+Shift+Down")}`,"aria-label":g("labels.alignBottom"),visible:Ee($n(e),o)})}),wM=B({name:"alignLeft",label:"labels.alignLeft",icon:Dm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"start",axis:"x"}),captureUpdate:jn.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_LEFT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:Dm,onClick:()=>t(null),title:`${g("labels.alignLeft")} \u2014 ${ec("CtrlOrCmd+Shift+Left")}`,"aria-label":g("labels.alignLeft"),visible:Ee($n(e),o)})}),vM=B({name:"alignRight",label:"labels.alignRight",icon:_m,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"end",axis:"x"}),captureUpdate:jn.IMMEDIATELY}),keyTest:e=>e[sr.CTRL_OR_CMD]&&e.shiftKey&&e.key===sr.ARROW_RIGHT,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:_m,onClick:()=>t(null),title:`${g("labels.alignRight")} \u2014 ${ec("CtrlOrCmd+Shift+Right")}`,"aria-label":g("labels.alignRight"),visible:Ee($n(e),o)})}),TM=B({name:"alignVerticallyCentered",label:"labels.centerVertically",icon:Rm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"center",axis:"y"}),captureUpdate:jn.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:Rm,onClick:()=>t(null),title:g("labels.centerVertically"),"aria-label":g("labels.centerVertically"),visible:Ee($n(e),o)})}),IM=B({name:"alignHorizontallyCentered",label:"labels.centerHorizontally",icon:Nm,trackEvent:{category:"element"},predicate:(e,o,t,r)=>vt(o,r),perform:(e,o,t,r)=>({appState:o,elements:qn(e,o,r,{position:"center",axis:"x"}),captureUpdate:jn.IMMEDIATELY}),PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>Jn(K,{hidden:!vt(o,r),type:"button",icon:Nm,onClick:()=>t(null),title:g("labels.centerHorizontally"),"aria-label":g("labels.centerHorizontally"),visible:Ee($n(e),o)})});import{getNonDeletedElements as sE}from"@excalidraw/element";import{isFrameLikeElement as CM}from"@excalidraw/element";import{CODES as cE,KEYS as dE,arrayToMap as SM,getShortcutKey as mE}from"@excalidraw/common";import{updateFrameMembershipOfSelectedElements as kM}from"@excalidraw/element";import{distributeElements as MM}from"@excalidraw/element";import{CaptureUpdateAction as pE}from"@excalidraw/element";import{getSelectedElementsByGroup as LM}from"@excalidraw/element";import{jsx as gE}from"react/jsx-runtime";var uE=(e,o)=>{let t=o.scene.getSelectedElements(e);return LM(t,o.scene.getNonDeletedElementsMap(),e).length>2&&!t.some(r=>CM(r))},hE=(e,o,t,r)=>{let n=t.scene.getSelectedElements(o),i=MM(n,t.scene.getNonDeletedElementsMap(),r,o),a=SM(i);return kM(e.map(l=>a.get(l.id)||l),o,t)},PM=B({name:"distributeHorizontally",label:"labels.distributeHorizontally",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:hE(e,o,r,{space:"between",axis:"x"}),captureUpdate:pE.IMMEDIATELY}),keyTest:e=>!e[dE.CTRL_OR_CMD]&&e.altKey&&e.code===cE.H,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>gE(K,{hidden:!uE(o,r),type:"button",icon:j1,onClick:()=>t(null),title:`${g("labels.distributeHorizontally")} \u2014 ${mE("Alt+H")}`,"aria-label":g("labels.distributeHorizontally"),visible:Ee(sE(e),o)})}),AM=B({name:"distributeVertically",label:"labels.distributeVertically",trackEvent:{category:"element"},perform:(e,o,t,r)=>({appState:o,elements:hE(e,o,r,{space:"between",axis:"y"}),captureUpdate:pE.IMMEDIATELY}),keyTest:e=>!e[dE.CTRL_OR_CMD]&&e.altKey&&e.code===cE.V,PanelComponent:({elements:e,appState:o,updateData:t,app:r})=>gE(K,{hidden:!uE(o,r),type:"button",icon:q1,onClick:()=>t(null),title:`${g("labels.distributeVertically")} \u2014 ${mE("Alt+V")}`,"aria-label":g("labels.distributeVertically"),visible:Ee(sE(e),o)})});import{getNonDeletedElements as DM}from"@excalidraw/element";import{bindOrUnbindLinearElements as _M,isBindingEnabled as RM}from"@excalidraw/element";import{getCommonBoundingBox as fE}from"@excalidraw/element";import{newElementWith as NM}from"@excalidraw/element";import{deepCopyElement as BM}from"@excalidraw/element";import{resizeMultipleElements as FM}from"@excalidraw/element";import{isArrowElement as OM,isElbowArrow as zM,isLinearElement as HM}from"@excalidraw/element";import{updateFrameMembershipOfSelectedElements as bE}from"@excalidraw/element";import{CODES as xE,KEYS as GM,arrayToMap as UM}from"@excalidraw/common";import{CaptureUpdateAction as EE}from"@excalidraw/element";var tu=B({name:"flipHorizontal",label:"labels.flipHorizontal",icon:q0,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:bE(yE(e,r.scene.getNonDeletedElementsMap(),o,"horizontal",r),o,r),appState:o,captureUpdate:EE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===xE.H}),ou=B({name:"flipVertical",label:"labels.flipVertical",icon:j0,trackEvent:{category:"element"},perform:(e,o,t,r)=>({elements:bE(yE(e,r.scene.getNonDeletedElementsMap(),o,"vertical",r),o,r),appState:o,captureUpdate:EE.IMMEDIATELY}),keyTest:e=>e.shiftKey&&e.code===xE.V&&!e[GM.CTRL_OR_CMD]}),yE=(e,o,t,r,n)=>{let i=j(DM(e),t,{includeBoundTextElement:!0,includeElementsInFrames:!0}),a=YM(i,o,t,r,n),l=UM(a);return e.map(s=>l.get(s.id)||s)},YM=(e,o,t,r,n)=>{if(e.every(u=>OM(u)&&(u.startBinding||u.endBinding)))return e.map(u=>{let f=u;return NM(f,{startArrowhead:f.endArrowhead,endArrowhead:f.startArrowhead})});let{midX:i,midY:a}=fE(e);FM(e,o,"nw",n.scene,new Map(Array.from(o.values()).map(u=>[u.id,BM(u)])),{flipByX:r==="horizontal",flipByY:r==="vertical",shouldResizeFromCenter:!0,shouldMaintainAspectRatio:!0}),_M(e.filter(HM),RM(t),[],n.scene,t.zoom);let{elbowArrows:l,otherElements:s}=e.reduce((u,f)=>zM(f)?{...u,elbowArrows:u.elbowArrows.concat(f)}:{...u,otherElements:u.otherElements.concat(f)},{elbowArrows:[],otherElements:[]}),{midX:d,midY:m}=fE(e),[c,p]=[i-d,a-m];return s.forEach(u=>n.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),l.forEach(u=>n.scene.mutateElement(u,{x:u.x+c,y:u.y+p})),e};import{isTextElement as WM}from"@excalidraw/element";import{getTextFromElements as VM}from"@excalidraw/element";import{CODES as XM,KEYS as wE,isFirefox as KM}from"@excalidraw/common";import{CaptureUpdateAction as Dt}from"@excalidraw/element";var Qn=B({name:"copy",label:"labels.copy",icon:Zi,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});try{await Ys(n,r.files,t)}catch(i){return{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:i.message}}}return{captureUpdate:Dt.EVENTUALLY}},keyTest:void 0}),ru=B({name:"paste",label:"labels.paste",trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n;try{n=await Yx()}catch(i){return i.name==="AbortError"||i.name==="NotAllowedError"?!1:(console.error(`actionPaste ${i.name}: ${i.message}`),KM?{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:g("hints.firefox_clipboard_write")}}:{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnRead")}})}try{r.pasteFromClipboard(Gx({types:n}))}catch(i){return console.error(i),{captureUpdate:Dt.EVENTUALLY,appState:{...o,errorMessage:g("errors.asyncPasteFailedOnParse")}}}return{captureUpdate:Dt.EVENTUALLY}},keyTest:void 0}),tc=B({name:"cut",label:"labels.cut",icon:N0,trackEvent:{category:"element"},perform:(e,o,t,r)=>(Qn.perform(e,o,t,r),ra.perform(e,o,null,r)),keyTest:e=>e[wE.CTRL_OR_CMD]&&e.key===wE.X}),oc=B({name:"copyAsSvg",label:"labels.copyAsSvg",icon:J0,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:Dt.EVENTUALLY};let{exportedElements:n,exportingFrame:i}=Vr(e,o,!0);try{await Xr("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:Dt.EVENTUALLY}}catch(a){return console.error(a),{appState:{errorMessage:a.message},captureUpdate:Dt.EVENTUALLY}}},predicate:e=>Us&&e.length>0,keywords:["svg","clipboard","copy"]}),rc=B({name:"copyAsPng",label:"labels.copyAsPng",icon:Q0,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{if(!r.canvas)return{captureUpdate:Dt.EVENTUALLY};let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),{exportedElements:i,exportingFrame:a}=Vr(e,o,!0);try{return await Xr("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:Dt.EVENTUALLY}}catch(l){return console.error(l),{appState:{...o,errorMessage:l.message},captureUpdate:Dt.EVENTUALLY}}},predicate:e=>Vn&&e.length>0,keyTest:e=>e.code===XM.C&&e.altKey&&e.shiftKey,keywords:["png","clipboard","copy"]}),nc=B({name:"copyText",label:"labels.copyText",trackEvent:{category:"element"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0});try{oo(VM(n))}catch{throw new Error(g("errors.copyToSystemClipboardFailed"))}return{captureUpdate:Dt.EVENTUALLY}},predicate:(e,o,t,r)=>Us&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0}).some(WM),keywords:["text","clipboard","copy"]});import{CODES as ZM,KEYS as $M}from"@excalidraw/common";import{CaptureUpdateAction as jM}from"@excalidraw/element";var ic=B({name:"gridMode",icon:nb,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:jM.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[$M.CTRL_OR_CMD]&&e.code===ZM.QUOTE});import{CODES as qM,KEYS as JM}from"@excalidraw/common";import{CaptureUpdateAction as QM}from"@excalidraw/element";var ei=B({name:"zenMode",label:"buttons.zenMode",icon:tb,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.zenModeEnabled},perform(e,o){return{appState:{...o,zenModeEnabled:!this.checked(o)},captureUpdate:QM.EVENTUALLY}},checked:e=>e.zenModeEnabled,predicate:(e,o,t)=>typeof t.zenModeEnabled>"u",keyTest:e=>!e[JM.CTRL_OR_CMD]&&e.altKey&&e.code===qM.Z});import{CODES as eL,KEYS as tL}from"@excalidraw/common";import{CaptureUpdateAction as oL}from"@excalidraw/element";var nu=B({name:"objectsSnapMode",label:"buttons.objectsSnapMode",icon:eb,viewMode:!1,trackEvent:{category:"canvas",predicate:e=>!e.objectsSnapModeEnabled},perform(e,o){return{appState:{...o,objectsSnapModeEnabled:!this.checked(o),gridModeEnabled:!1},captureUpdate:oL.EVENTUALLY}},checked:e=>e.objectsSnapModeEnabled,predicate:(e,o,t)=>typeof t.objectsSnapModeEnabled>"u",keyTest:e=>!e[tL.CTRL_OR_CMD]&&e.altKey&&e.code===eL.S});import{CODES as rL,KEYS as nL}from"@excalidraw/common";import{CaptureUpdateAction as iL}from"@excalidraw/element";var ti=B({name:"stats",label:"stats.fullTitle",icon:$0,viewMode:!0,trackEvent:{category:"menu"},keywords:["edit","attributes","customize"],perform(e,o){return{appState:{...o,stats:{...o.stats,open:!this.checked(o)}},captureUpdate:iL.EVENTUALLY}},checked:e=>e.stats.open,keyTest:e=>!e[nL.CTRL_OR_CMD]&&e.altKey&&e.code===rL.SLASH});import{BOUND_TEXT_PADDING as vE,ROUNDNESS as TE,TEXT_ALIGN as CE,VERTICAL_ALIGN as SE,arrayToMap as kE,getFontString as aL}from"@excalidraw/common";import{getOriginalContainerHeightFromCache as lL,resetOriginalContainerCache as sL,updateOriginalContainerCache as cL}from"@excalidraw/element";import{computeBoundTextPosition as dL,computeContainerDimensionForBoundText as IE,getBoundTextElement as ME,redrawTextBoundingBox as LE}from"@excalidraw/element";import{hasBoundTextElement as mL,isArrowElement as pL,isTextBindableContainer as iu,isTextElement as Ca,isUsingAdaptiveRadius as uL}from"@excalidraw/element";import{measureText as hL}from"@excalidraw/element";import{syncMovedIndices as PE}from"@excalidraw/element";import{newElement as gL}from"@excalidraw/element";import{CaptureUpdateAction as au}from"@excalidraw/element";var lu=B({name:"unbindText",label:"labels.unbindText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>r.scene.getSelectedElements(o).some(i=>mL(i)),perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=r.scene.getNonDeletedElementsMap();return n.forEach(a=>{let l=ME(a,i);if(l){let{width:s,height:d}=hL(l.originalText,aL(l),l.lineHeight),m=lL(a.id);sL(a.id);let{x:c,y:p}=dL(a,l,i);r.scene.mutateElement(l,{containerId:null,width:s,height:d,text:l.originalText,x:c,y:p}),r.scene.mutateElement(a,{boundElements:a.boundElements?.filter(u=>u.id!==l.id),height:m||a.height})}}),{elements:e,appState:o,captureUpdate:au.IMMEDIATELY}}}),su=B({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=Ca(n[0])||Ca(n[1]),a;if(iu(n[0])?a=n[0]:iu(n[1])&&(a=n[1]),i&&a&&ME(a,r.scene.getNonDeletedElementsMap())===null)return!0}return!1},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i,a;Ca(n[0])&&iu(n[1])?(i=n[0],a=n[1]):(i=n[1],a=n[0]),r.scene.mutateElement(i,{containerId:a.id,verticalAlign:SE.MIDDLE,textAlign:CE.CENTER,autoResize:!0,angle:pL(a)?0:a?.angle??0}),r.scene.mutateElement(a,{boundElements:(a.boundElements||[]).concat({type:"text",id:i.id})});let l=a.height;return LE(i,a,r.scene),cL(a.id,l),{elements:fL(e,a,i),appState:{...o,selectedElementIds:{[a.id]:!0}},captureUpdate:au.IMMEDIATELY}}}),fL=(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),PE(r,kE([o,t])),r},bL=(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),PE(r,kE([o,t])),r},AE=B({name:"wrapTextInContainer",label:"labels.createContainerFromText",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o),i=n.some(a=>Ca(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(Ca(l)){let s=gL({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:uL("rectangle")?TE.ADAPTIVE_RADIUS:TE.PROPORTIONAL_RADIUS}:null,opacity:100,locked:!1,x:l.x-vE,y:l.y-vE,width:IE(l.width,"rectangle"),height:IE(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)&&r.scene.mutateElement(c,{startBinding:p,endBinding:u})})}r.scene.mutateElement(l,{containerId:s.id,verticalAlign:SE.MIDDLE,boundElements:null,textAlign:CE.CENTER,autoResize:!0}),LE(l,s,r.scene),i=bL([...i,s],s,l),a[s.id]=!0}return{elements:i,appState:{...o,selectedElementIds:a},captureUpdate:au.IMMEDIATELY}}});import{isEmbeddableElement as RL}from"@excalidraw/element";import{KEYS as GE,getShortcutKey as NL}from"@excalidraw/common";import{CaptureUpdateAction as BL}from"@excalidraw/element";import{pointFrom as NE}from"@excalidraw/math";import xL from"clsx";import{useCallback as DE,useEffect as _E,useLayoutEffect as EL,useRef as yL,useState as wL}from"react";import{EVENT as cu,HYPERLINK_TOOLTIP_DELAY as vL,KEYS as ac}from"@excalidraw/common";import{getElementAbsoluteCoords as hu}from"@excalidraw/element";import{hitElementBoundingBox as TL}from"@excalidraw/element";import{isElementLink as IL}from"@excalidraw/element";import{getEmbedLink as CL,embeddableURLValidator as SL}from"@excalidraw/element";import{sceneCoordsToViewportCoords as BE,viewportCoordsToSceneCoords as kL,wrapEvent as ML,isLocalLink as LL,normalizeLink as du}from"@excalidraw/common";import{isEmbeddableElement as mu}from"@excalidraw/element";import{jsx as oi,jsxs as RE}from"react/jsx-runtime";var gu=380,PL=42,pu=5,FE=85,AL=500,uu=!1,lc=new Map,OE=({element:e,scene:o,setAppState:t,onLinkOpen:r,setToast:n,updateEmbedValidationStatus:i})=>{let a=o.getNonDeletedElementsMap(),l=go(),s=fo(),d=se(),m=e.link||"",[c,p]=wL(m),u=yL(null),f=l.showHyperlinkPopup==="editor",b=DE(()=>{if(!u.current)return;let v=du(u.current.value)||null;if(!e.link&&v&&re("hyperlink","create"),mu(e)){if(l.activeEmbeddable?.element===e&&t({activeEmbeddable:null}),!v){o.mutateElement(e,{link:null}),i(e,!1);return}if(!SL(v,s.validateEmbeddable))v&&n({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=CL(v);L?.error instanceof URIError&&n({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,n,s.validateEmbeddable,l.activeEmbeddable,t,i]);EL(()=>()=>{b()},[b]),_E(()=>{f&&u?.current&&!(d.viewport.isMobile||d.isTouchScreen)&&u.current.select()},[f,d.viewport.isMobile,d.isTouchScreen]),_E(()=>{let v=null,C=S=>{if(f)return;v&&clearTimeout(v),_L(e,a,l,NE(S.clientX,S.clientY))&&(v=window.setTimeout(()=>{t({showHyperlinkPopup:!1})},AL))};return window.addEventListener(cu.POINTER_MOVE,C,!1),()=>{window.removeEventListener(cu.POINTER_MOVE,C,!1),v&&clearTimeout(v)}},[l,e,f,t,a]);let x=DE(()=>{re("hyperlink","delete"),o.mutateElement(e,{link:null}),t({showHyperlinkPopup:!1})},[t,e,o]),w=()=>{re("hyperlink","edit","popup-ui"),t({showHyperlinkPopup:"editor"})},{x:E,y}=zE(e,l,a);return l.contextMenu||l.selectedElementsAreBeingDragged||l.resizingElement||l.isRotating||l.openMenu||l.viewModeEnabled?null:RE("div",{className:"excalidraw-hyperlinkContainer",style:{top:`${y}px`,left:`${E}px`,width:gu,padding:pu},children:[f?oi("input",{className:xL("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?oi("a",{href:du(e.link||""),className:"excalidraw-hyperlinkContainer-link",target:LL(e.link)?"_self":"_blank",onClick:v=>{if(e.link&&r){let C=ML(cu.EXCALIDRAW_LINK,v.nativeEvent);r({...e,link:du(e.link)},C),C.defaultPrevented&&v.preventDefault()}},rel:"noopener noreferrer",children:e.link}):oi("div",{className:"excalidraw-hyperlinkContainer-link",children:g("labels.link.empty")}),RE("div",{className:"excalidraw-hyperlinkContainer__buttons",children:[!f&&oi(K,{type:"button",title:g("buttons.edit"),"aria-label":g("buttons.edit"),label:g("buttons.edit"),onClick:w,className:"excalidraw-hyperlinkContainer--edit",icon:qo}),oi(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&&!mu(e)&&oi(K,{type:"button",title:g("buttons.remove"),"aria-label":g("buttons.remove"),label:g("buttons.remove"),onClick:x,className:"excalidraw-hyperlinkContainer--remove",icon:Mt})]})]})},zE=(e,o,t)=>{let[r,n]=hu(e,t),{x:i,y:a}=BE({sceneX:r+e.width/2,sceneY:n},o),l=i-o.offsetLeft-gu/2,s=a-o.offsetTop-FE;return{x:l,y:s}},fu=(e,o)=>{let t=j(e,o);return mu(t[0])?"labels.link.editEmbed":t[0]?.link?"labels.link.edit":"labels.link.create"},Sa=null,HE=(e,o,t)=>{Sa&&clearTimeout(Sa),Sa=window.setTimeout(()=>DL(e,o,t),vL)},DL=(e,o,t)=>{if(!e.link)return;let r=Un();r.classList.add("excalidraw-tooltip--visible"),r.style.maxWidth="20rem",r.textContent=IL(e.link)?g("labels.link.goToElement"):e.link;let[n,i,a,l]=hu(e,t),[s,d,m,c]=qf([n,i,a,l],e.angle,o),p=BE({sceneX:s,sceneY:d},o);Lp(r,{left:p.x,top:p.y,width:m,height:c},"top"),re("hyperlink","tooltip","link-icon"),uu=!0},bu=()=>{Sa&&clearTimeout(Sa),uu&&(uu=!1,Un().classList.remove("excalidraw-tooltip--visible"))},_L=(e,o,t,[r,n])=>{let{x:i,y:a}=kL({clientX:r,clientY:n},t),l=15/t.zoom.value;if(TL(NE(i,a),e,o))return!1;let[s,d,m]=hu(e,o);if(i>=s&&i<=m&&a>=d-FE&&a<=d)return!1;let{x:c,y:p}=zE(e,t,o);return!(r>=c-l&&r<=c+gu+pu*2+l&&n>=p-l&&n<=p+l+pu*2+PL)};import{jsx as FL}from"react/jsx-runtime";var ka=B({name:"hyperlink",label:(e,o)=>fu(e,o),icon:qi,perform:(e,o)=>o.showHyperlinkPopup==="editor"?!1:{elements:e,appState:{...o,showHyperlinkPopup:"editor",openMenu:null},captureUpdate:BL.IMMEDIATELY},trackEvent:{category:"hyperlink",action:"click"},keyTest:e=>e[GE.CTRL_OR_CMD]&&e.key===GE.K,predicate:(e,o)=>j(e,o).length===1,PanelComponent:({elements:e,appState:o,updateData:t})=>{let r=j(e,o);return FL(K,{type:"button",icon:qi,"aria-label":g(fu(e,o)),title:`${RL(e[0])?g("labels.link.labelEmbed"):g("labels.link.label")} - ${NL("CtrlOrCmd+K")}`,onClick:()=>t(null),selected:r.length===1&&!!r[0].link})}});import{KEYS as UE,arrayToMap as Eu,randomId as OL}from"@excalidraw/common";import{elementsAreInSameGroup as zL,newElementWith as YE,selectGroupsFromGivenElements as WE}from"@excalidraw/element";import{CaptureUpdateAction as VE}from"@excalidraw/element";var xu=e=>e.every(o=>!o.locked),Ma=B({name:"toggleElementLock",label:(e,o,t)=>{let r=t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1});return xu(r)?"labels.elementLock.lock":"labels.elementLock.unlock"},icon:(e,o)=>{let t=j(o,e);return xu(t)?wn:Br},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=xu(n),a=Eu(n),l=n.length>1&&zL(n),d=n.length===1||l?null:OL(),m={...o.lockedMultiSelections};if(i)m={...o.lockedMultiSelections,...d?{[d]:!0}:{}};else if(l){let w=n[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]),YE(w,{locked:i,groupIds:E.length!==w.groupIds.length?E:w.groupIds})}),p=Eu(c),u=i?{}:Object.fromEntries(n.map(w=>[w.id,!0])),f=n.map(w=>p.get(w.id)||w),b=i?{}:WE(f,o),x=i?d||(l?n[0].groupIds.at(-1):n[0].id):null;return{elements:c,appState:{...o,selectedElementIds:u,selectedGroupIds:b,selectedLinearElement:i?null:o.selectedLinearElement,lockedMultiSelections:m,activeLockedId:x},captureUpdate:VE.IMMEDIATELY}},keyTest:(e,o,t,r)=>e.key.toLocaleLowerCase()===UE.L&&e[UE.CTRL_OR_CMD]&&e.shiftKey&&r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}).length>0}),XE=B({name:"unlockAllElements",trackEvent:{category:"canvas"},viewMode:!1,icon:Br,predicate:(e,o)=>j(e,o).length===0&&e.some(r=>r.locked),perform:(e,o)=>{let t=e.filter(a=>a.locked),r=e.map(a=>{if(a.locked){let l=a.groupIds.filter(s=>!o.lockedMultiSelections[s]);return YE(a,{locked:!1,groupIds:a.groupIds.length!==l.length?l:a.groupIds})}return a}),n=Eu(r),i=t.map(a=>n.get(a.id)||a);return{elements:r,appState:{...o,selectedElementIds:Object.fromEntries(t.map(a=>[a.id,!0])),selectedGroupIds:WE(i,o),lockedMultiSelections:{},activeLockedId:null},captureUpdate:VE.IMMEDIATELY}},label:"labels.elementLock.unlockAll"});import{isElbowArrow as eD,isLinearElement as tD,isLineElement as yi}from"@excalidraw/element";import{arrayToMap as oD,invariant as yh}from"@excalidraw/common";import{toggleLinePolygonState as rD,CaptureUpdateAction as X2}from"@excalidraw/element";import x2 from"clsx";import $8 from"fuzzy";import{useEffect as _c,useRef as j8,useState as Dc}from"react";import{DEFAULT_SIDEBAR as f2,EVENT as Nc,KEYS as io,capitalizeString as q8,getShortcutKey as J8,isWritableElement as Q8}from"@excalidraw/common";import{CaptureUpdateAction as wP}from"@excalidraw/element";import{useEffect as Aa,useMemo as KE,useRef as Tu,useState as HL}from"react";import{getLinearElementSubType as ii,updateElbowArrowPoints as GL}from"@excalidraw/element";import{pointFrom as cc,pointRotateRads as UL}from"@excalidraw/math";import{hasBoundTextElement as YL,isArrowBoundToElement as WL,isArrowElement as VL,isElbowArrow as XL,isLinearElement as ku,isUsingAdaptiveRadius as KL}from"@excalidraw/element";import{getCommonBoundingBox as ZL,getElementAbsoluteCoords as $L}from"@excalidraw/element";import{getBoundTextElement as JE,getBoundTextMaxHeight as jL,getBoundTextMaxWidth as qL,redrawTextBoundingBox as JL}from"@excalidraw/element";import{wrapText as QL}from"@excalidraw/element";import{assertNever as eP,CLASSES as tP,getFontString as yu,isProdEnv as oP,mapFind as rP,reduceToCommonValue as nP,updateActiveTool as ZE}from"@excalidraw/common";import{measureText as $E}from"@excalidraw/element";import{LinearElementEditor as iP}from"@excalidraw/element";import{newArrowElement as wu,newElement as aP,newLinearElement as lP}from"@excalidraw/element";import{ShapeCache as sP}from"@excalidraw/element";import{updateBindings as cP}from"@excalidraw/element";import{jsx as Su}from"react/jsx-runtime";var dP=8,mP=10,La=["rectangle","diamond","ellipse"],Pa=["line","sharpArrow","curvedArrow","elbowArrow"],pP=new Set(La),uP=new Set(Pa),ai=e=>pP.has(e),mc=e=>e==="arrow"||uP.has(e),no=me(null),Da=new Map,_a=new Map,hP=({app:e})=>{let o=e.scene.getSelectedElements(e.state),t=Tu(null);return Aa(()=>{if(o.length===0){e.updateEditorAtom(no,null);return}let r=li(o);r&&!t.current?t.current=r:(t.current&&!r||t.current&&r!==t.current)&&(e.updateEditorAtom(no,null),t.current=null)},[o,e]),Aa(()=>()=>{Da.clear(),_a.clear()},[]),Su(gP,{app:e,elements:o})},gP=({app:e,elements:o})=>{let t=li(o),r=KE(()=>t==="generic"?ey(o):[],[t,o]),n=KE(()=>t==="linear"?Cu(o):[],[t,o]),i=t==="generic"?r.every(c=>c.type===r[0].type):t==="linear"?n.every(c=>ii(c)===ii(n[0])):!1,[a,l]=HL({x:0,y:0}),s=Tu(""),d=Tu(null);Aa(()=>{let c=[...r,...n].sort((x,w)=>x.id.localeCompare(w.id)),p=`
8
+ ${e.state.scrollX}${e.state.scrollY}${e.state.offsetTop}${e.state.offsetLeft}${e.state.zoom.value}${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]=$L(c[0],e.scene.getNonDeletedElementsMap());u=UL(cc(x,w),cc(E,y),c[0].angle)}else{let{minX:x,maxY:w}=ZL(c);u=cc(x,w)}let{x:f,y:b}=oy({sceneX:u[0],sceneY:u[1]},e.state);l({x:f,y:b})},[r,n,e.scene,e.state]),Aa(()=>{for(let c of n){let p=Iu(c.id,yP(c));_a.has(p)||_a.set(p,c)}},[n]),Aa(()=>{for(let c of r)if(!Da.has(c.id)){let p=JE(c,e.scene.getNonDeletedElementsMap());p&&Da.set(c.id,{fontSize:p.fontSize})}},[r,e.scene]);let m=t==="linear"?[["line",Vl],["sharpArrow",rs],["curvedArrow",is],["elbowArrow",ns]]:t==="generic"?[["rectangle",Ul],["diamond",Yl],["ellipse",Wl]]:[];return Su("div",{ref:d,tabIndex:-1,style:{position:"absolute",top:`${a.y+(mP+8)*e.state.zoom.value-e.state.offsetTop}px`,left:`${a.x-e.state.offsetLeft-dP}px`,zIndex:2},className:tP.CONVERT_ELEMENT_TYPE_POPUP,children:m.map(([c,p])=>{let u=i&&(t==="generic"&&r[0].type===c||t==="linear"&&ii(n[0])===c);return Su(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&&re("convertElementType",c,"ui"),Mu(e,{conversionType:t,nextType:c}),d.current?.focus()}},`${o[0].id}${o[0].version}_${c}`)})})},fP=(e,o,t)=>{let r=qL(e,o),n=jL(e,o),i=QL(o.text,yu(o),r),a=$E(i,yu(o),o.lineHeight),l=o.fontSize;for(;(a.width>r||a.height>n)&&l>0;){l-=1;let s={...o,fontSize:l};a=$E(o.text,yu(s),o.lineHeight)}pc(o,t.getNonDeletedElementsMap(),{fontSize:l,width:a.width,height:a.height}),JL(o,e,t)},Mu=(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=ey(n),d=l.every(m=>m.type===l[0].type)?La.indexOf(l[0].type):-1;if(t=t??La[(d+La.length+a)%La.length],t&&ai(t)){let m={};for(let p of l){let u=qE(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=JE(p,e.scene.getNonDeletedElementsMap());u&&(Da.get(p.id)&&pc(u,e.scene.getNonDeletedElementsMap(),{fontSize:Da.get(p.id)?.fontSize??u.fontSize}),fP(p,u,e.scene))}e.setState(p=>({selectedElementIds:i,activeTool:ZE(p,{type:"selection"})}))}}if(o==="linear"){let l=Cu(n);if(!t){let d=nP(l,ii),m=d?Pa.indexOf(d):-1;t=Pa[(m+Pa.length+a)%Pa.length]}if(mc(t)){let d=[],m=e.scene.getElementsMapIncludingDeleted();for(let c of l){let p=_a.get(Iu(c.id,t));if(p&&ii(p)===t)m.set(p.id,p),d.push(p);else{let u=qE(c,t,e);m.set(u.id,u),d.push(u)}}e.scene.replaceAllElements(m);for(let c of d)if(ku(c))if(XL(c)){let p=bP(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=GL(c,e.scene.getNonDeletedElementsMap(),{points:p,fixedSegments:u});pc(c,e.scene.getNonDeletedElementsMap(),{...f,endArrowhead:"arrow"})}else{let p=rP(["line","sharpArrow","curvedArrow"],u=>_a.get(Iu(c.id,u)));if(p){let u=p.points;e.scene.mutateElement(c,{points:u})}}}let s=Cu(e.scene.getSelectedElements(e.state));e.setState(d=>({selectedElementIds:i,selectedLinearElement:s.length===1?new iP(s[0],e.scene.getNonDeletedElementsMap()):null,activeTool:ZE(d,{type:"selection"})}))}return!0},li=e=>{if(e.length===0)return null;let o=!1;for(let t of e){if(ai(t.type))return"generic";QE(t)&&(o=!0)}return o?"linear":null},QE=e=>ku(e)&&(!VL(e)||!WL(e)&&!YL(e)),Iu=(e,o)=>`${e}:${o}`,ey=e=>e.filter(o=>ai(o.type)),Cu=e=>e.filter(o=>QE(o)),sc=20,ri=(e,o)=>e[0]===o[0],vu=(e,o)=>e[1]===o[1],jE=(e,o)=>ri(e,o)?Math.abs(e[1]-o[1]):Math.abs(e[0]-o[0]),bP=e=>{let o=[e.points[0]],t=xP(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)||vu(a,l)||o.push(cc(a[0],l[1])),o.push(l)}let r=[o[0]];for(let i=1;i<o.length-1;++i)ri(o[i-1],o[i])&&ri(o[i],o[i+1])||vu(o[i-1],o[i])&&vu(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],d=ri(a,l),m=ri(l,s);if(d!==m){let c=jE(a,l),p=jE(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=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},xP=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},qE=(e,o,t)=>{if(!EP(e.type,o)){if(!oP())throw Error(`Invalid conversion from ${e.type} to ${o}.`);return e}if(e.type===o)return e;if(sP.delete(e),ai(o)){let r=ni(aP({...e,type:o,roundness:o==="diamond"&&e.roundness?{type:KL(o)?dc.ADAPTIVE_RADIUS:dc.PROPORTIONAL_RADIUS}:e.roundness}));return cP(r,t.scene),r}if(mc(o))switch(o){case"line":return ni(lP({...e,type:"line"}));case"sharpArrow":return ni(wu({...e,type:"arrow",elbowed:!1,roundness:null,startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"curvedArrow":return ni(wu({...e,type:"arrow",elbowed:!1,roundness:{type:dc.PROPORTIONAL_RADIUS},startArrowhead:t.state.currentItemStartArrowhead,endArrowhead:t.state.currentItemEndArrowhead}));case"elbowArrow":return ni(wu({...e,type:"arrow",elbowed:!0,fixedSegments:null,roundness:null}))}return eP(o,`unhandled conversion type: ${o}`),e},EP=(e,o)=>!!(ai(e)&&ai(o)||mc(e)&&mc(o)),yP=e=>ku(e)?ii(e):e.type,ty=hP;var ry=B({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 ze.set(no,{type:"panel"}),{captureUpdate:wP.NEVER}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>li(e)!==null});import{canCreateLinkFromElements as Lu,defaultGetElementLinkFromSelection as vP,getLinkIdAndTypeFromSelection as TP}from"@excalidraw/element";import{CaptureUpdateAction as Ra}from"@excalidraw/element";var uc=B({name:"copyElementLink",label:"labels.copyElementLink",icon:Cn,trackEvent:{category:"element"},perform:async(e,o,t,r)=>{let n=j(e,o);try{if(window.location){let i=TP(n,o);return i?(await oo(r.props.generateLinkForSelection?r.props.generateLinkForSelection(i.id,i.type):vP(i.id,i.type)),{appState:{toast:{message:g("toast.elementLinkCopied"),closable:!0}},captureUpdate:Ra.EVENTUALLY}):{appState:o,elements:e,app:r,captureUpdate:Ra.EVENTUALLY}}}catch(i){console.error(i)}return{appState:o,elements:e,app:r,captureUpdate:Ra.EVENTUALLY}},predicate:(e,o)=>Lu(j(e,o))}),ny=B({name:"linkToElement",label:"labels.linkToElement",icon:ls,perform:(e,o,t,r)=>{let n=j(e,o);return n.length!==1||!Lu(n)?{elements:e,appState:o,app:r,captureUpdate:Ra.EVENTUALLY}:{appState:{...o,openDialog:{name:"elementLinkSelector",sourceElementId:j(e,o)[0].id}},captureUpdate:Ra.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=j(e,o);return o.openDialog?.name!=="elementLinkSelector"&&n.length===1&&Lu(n)},trackEvent:!1});import{isDarwin as iy,getShortcutKey as oe}from"@excalidraw/common";var IP={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:[iy?oe("CtrlOrCmd+Alt+["):oe("CtrlOrCmd+Shift+[")],bringToFront:[iy?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=IP[e];return t&&t.length>0?t[o]||t[0]:""};var CP="\\u0300-\\u036f",SP="\\ufe20-\\ufe2f",kP="\\u20d0-\\u20ff",MP=CP+SP+kP,LP=`[${MP}]`,PP=RegExp(LP,"g"),AP=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,DP={\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"},Pu=e=>e.replace(AP,o=>DP[o]||o).replace(PP,"");import w8 from"clsx";import{useEffect as v8,useState as T8}from"react";import{KEYS as I8,queryFocusableElements as r2}from"@excalidraw/common";import{useCallback as _P,useState as RP}from"react";var ay=()=>{let[e,o]=RP(null),t=_P(r=>o(r),[]);return[e,t]};import{useState as qy,useCallback as Xu,useMemo as Jy,useEffect as Zy,memo as Qy,useRef as d8}from"react";import{LIBRARY_DISABLED_TYPES as m8,randomId as p8,isShallowEqual as u8}from"@excalidraw/common";import{useEffect as dy,useRef as my}from"react";import{URL_HASH_KEYS as _u,URL_QUERY_KEYS as Ru,APP_NAME as py,EVENT as gc,DEFAULT_SIDEBAR as zP,LIBRARY_SIDEBAR_TAB as HP,arrayToMap as Nu,cloneJSON as GP,preventUnload as UP,promiseTry as uy,resolvablePromise as YP,toValidURL as WP,Queue as VP,Emitter as XP}from"@excalidraw/common";import{hashElementsVersion as KP,hashString as ZP}from"@excalidraw/element";import{getCommonBoundingBox as Du}from"@excalidraw/element";import{MIME_TYPES as jr}from"@excalidraw/common";var cr=({elements:e,appState:o,files:t,maxWidthOrHeight:r,getDimensions:n,exportPadding:i,exportingFrame:a})=>{let{elements:l,appState:s}=bn({elements:e,appState:o},null,null,{deleteEmptyTextElements:!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(r){typeof n=="function"&&console.warn("`getDimensions()` is ignored when `maxWidthOrHeight` is supplied.");let b=Math.max(c,p),x=r<b?r/b:o?.exportScale??1;return u.width=c*x,u.height=p*x,{canvas:u,scale:x}}let f=n?.(c,p)||{width:c,height:p};return u.width=f.width,u.height=f.height,{canvas:u,scale:f.scale??1}})},ly=async e=>{let{mimeType:o=jr.png,quality:t}=e;o===jr.png&&typeof t=="number"&&console.warn(`"quality" will be ignored for "${jr.png}" mimeType`),o==="image/jpg"&&(o=jr.jpg),o===jr.jpg&&!e.appState?.exportBackground&&(console.warn(`Defaulting "exportBackground" to "true" for "${jr.jpg}" mimeType`),e={...e,appState:{...e.appState,exportBackground:!0}});let r=await cr(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===jr.png&&e.appState?.exportEmbedScene&&(a=await a1({blob:a,metadata:Yi(e.elements,e.appState,e.files||{},"local")})),n(a)},o,t)})},si=async({elements:e,appState:o=$o(),files:t={},exportPadding:r,renderEmbeddables:n,exportingFrame:i,skipInliningFonts:a,reuseImages:l})=>{let{elements:s,appState:d}=bn({elements:e,appState:o},null,null,{deleteEmptyTextElements:!0}),m={...d,exportPadding:r};return fn(s,m,t,{exportingFrame:i,renderEmbeddables:n,skipInliningFonts:a,reuseImages:l})},NP=async e=>{if(e.type==="svg"){let o=await si(e);await oo(o.outerHTML)}else if(e.type==="png")await Vs(ly(e));else if(e.type==="json")await Ys(e.elements,e.files);else throw new Error("Invalid export type")};import{useEffect as BP,useState as FP}from"react";import{COLOR_PALETTE as OP}from"@excalidraw/common";var Au=me(new Map),sy=async e=>await si({elements:e,appState:{exportBackground:!1,viewBackgroundColor:OP.white},files:null,renderEmbeddables:!1,skipInliningFonts:!0}),cy=(e,o,t)=>{let[r,n]=FP();return BP(()=>{if(o)if(e){let i=t.get(e);i?n(i):(async()=>{let a=await sy(o);a.querySelector(".style-fonts")?.remove(),a&&(t.set(e,a),n(a))})()}else(async()=>{let i=await sy(o);n(i)})()},[e,o,t,n]),r},hc=()=>{let[e]=ie(Au);return{clearLibraryCache:()=>e.clear(),deleteItemsFromLibraryCache:r=>{r.forEach(n=>e.delete(n))},svgCache:e}};var $P=["excalidraw.com","raw.githubusercontent.com/excalidraw/excalidraw-libraries"],gy=new XP,qr=me({status:"loaded",isInitialized:!1,libraryItems:[]}),Na=e=>GP(e),jP=(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)),fy=(e,o)=>{let t=[];for(let r of o)jP(e,r)&&t.push(r);return[...t,...e]},by=(e,o)=>{let t=Nu(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=Nu(e);for(let i of o)n.has(i.id)||r.addedItems.set(i.id,i);return r},Bu=class{constructor(o){I(this,"currLibraryItems",[]);I(this,"prevLibraryItems",Na(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)ze.set(qr,o=>({status:"loading",libraryItems:this.currLibraryItems,isInitialized:o.isInitialized}));else{ze.set(qr,{status:"loaded",libraryItems:this.currLibraryItems,isInitialized:!0});try{let o=this.prevLibraryItems;this.prevLibraryItems=Na(this.currLibraryItems);let t=Na(this.currLibraryItems);this.app.props.onLibraryChange?.(t),gy.trigger(by(o,t),t)}catch(o){console.error(o)}}});I(this,"destroy",()=>{this.updateQueue=[],this.currLibraryItems=[],ze.set(Au,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(Na(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:zP.name,tab:HP}}),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 fm(s,i):d=Xi(s,i),!t||window.confirm(g("alerts.confirmAddLibrary",{numShapes:d.length}))?(t&&this.app.focusContainer(),a(r?fy(this.currLibraryItems,d):d)):l(new hn)}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=Na(await o),r(this.currLibraryItems)}catch(i){n(i)}}).catch(r=>{if(r.name==="AbortError")return console.warn("Library update aborted by user"),this.currLibraryItems;throw r}).finally(()=>{this.updateQueue=this.updateQueue.filter(r=>r!==t),this.notifyListeners()});return this.updateQueue.push(t),this.notifyListeners(),t});this.app=o}},xy=Bu,xc=e=>{let t=Math.ceil(Math.sqrt(e.length)),r=[],n=u=>e.slice(u*t,u*t+t).reduce((b,x)=>{let{height:w}=Du(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}=Du(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=n(p)),d=i(c);let{minX:f,minY:b,width:x,height:w}=Du(u.elements),E=(d-x)/2,y=(s-w)/2;r.push(...u.elements.map(v=>({...v,x:v.x+a+E-f,y:v.y+l+y-b}))),a+=d+50,m++,c++}return r},qP=(e,o=$P)=>{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}"`)},Fu=()=>{let e=new URLSearchParams(window.location.hash.slice(1)).get(_u.addLibrary)||new URLSearchParams(window.location.search).get(Ru.addLibrary),o=e?new URLSearchParams(window.location.hash.slice(1)).get("token"):null;return e?{libraryUrl:e,idToken:o}:null},dr=class dr{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(Xi(l?.libraryItems||[],"published"))}catch(l){a(l)}});return r?dr.queue.push(n):n()}getLibraryItems(o){return dr.getLibraryItems(this.adapter,o,!1)}};I(dr,"queue",new VP),I(dr,"run",async(o,t)=>{let r=new dr(o);return dr.queue.push(()=>t(r))});var ci=dr,Ba=0,fc=0,bc=e=>ZP(e.map(o=>`${o.id}:${KP(o.elements)}`).sort().join()),hy=async(e,o)=>{try{return fc++,await ci.run(e,async t=>{let r=Nu(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=bc(i);return a!==Ba&&await e.save({libraryItems:i}),Ba=a,i})}finally{fc--}},JP=e=>{let{excalidrawAPI:o}=e,t=my(e);t.current=e;let r=my(!1);dy(()=>{if(!o)return;r.current=!1;let n=async({libraryUrl:l,idToken:s})=>{let d=new Promise(async(c,p)=>{try{l=decodeURIComponent(l),l=WP(l),qP(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(_u.addLibrary)){let c=new URLSearchParams(window.location.hash.slice(1));c.delete(_u.addLibrary),window.history.replaceState({},py,`#${c.toString()}`)}else if(window.location.search.includes(Ru.addLibrary)){let c=new URLSearchParams(window.location.search);c.delete(Ru.addLibrary),window.history.replaceState({},py,`?${c.toString()}`)}}},i=l=>{l.preventDefault();let s=Fu();s&&(l.stopImmediatePropagation(),window.history.replaceState({},"",l.oldURL),n(s))},a=Fu();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,d=YP();s?d.resolve(uy(s.load).then(async m=>{let c=null;try{if(!m)return ci.getLibraryItems(l,"load");c=Xi(m.libraryItems||[],"published");let p=await hy(l,by([],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}`),ci.getLibraryItems(l,"load")))):d.resolve(uy(ci.getLibraryItems,l,"load")),o.updateLibrary({libraryItems:d.then(m=>{let c=m||[];return Ba=bc(c),c}),merge:!0}).finally(()=>{r.current=!0})}return window.addEventListener(gc.HASHCHANGE,i),()=>{window.removeEventListener(gc.HASHCHANGE,i)}},[o]),dy(()=>{let n=gy.on(async(a,l)=>{let s=r.current,d="adapter"in t.current&&t.current.adapter||null;try{d&&Ba!==bc(l)&&await hy(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&&UP(a)};return window.addEventListener(gc.BEFORE_UNLOAD,i),()=>{window.removeEventListener(gc.BEFORE_UNLOAD,i),n(),Ba=0,fc=0}},[])};import oA from"clsx";import{VERSIONS as QP}from"@excalidraw/common";import{jsx as tA}from"react/jsx-runtime";var eA=({theme:e,id:o,libraryReturnUrl:t})=>{let r=t||window.location.origin+window.location.pathname;return tA("a",{className:"library-menu-browse-button",href:`${T.VITE_APP_LIBRARY_URL}?target=${window.name||"_blank"}&referrer=${r}&useHash=true&token=${o}&theme=${e}&version=${QP.excalidrawLibrary}`,target:"_excalidraw_libraries",children:g("labels.libraries")})},Ey=eA;import{jsx as rA,jsxs as nA}from"react/jsx-runtime";var Ec=({libraryReturnUrl:e,theme:o,id:t,style:r,children:n,className:i})=>nA("div",{className:oA("library-menu-control-buttons",i),style:r,children:[rA(Ey,{id:t,libraryReturnUrl:e,theme:o}),n]});import{useCallback as pi,useEffect as o8,useMemo as Xy,useRef as r8,useState as n8}from"react";import{MIME_TYPES as i8,arrayToMap as a8}from"@excalidraw/common";import{duplicateElements as l8}from"@excalidraw/element";import iA from"lodash.throttle";import{useEffect as aA}from"react";var lA=me(0),yy=e=>{let[o,t]=ie(lA);return aA(()=>{let{current:r}=e;if(!r)return;let n=iA(()=>{let{scrollTop:i}=r;t(i)},200);return r.addEventListener("scroll",n),()=>{n.cancel(),r.removeEventListener("scroll",n)}},[e,t]),o};import zA from"clsx";import{useCallback as HA,useState as Gu}from"react";import{muteFSAbortError as GA}from"@excalidraw/common";import{flushSync as wy}from"react-dom";import sA from"clsx";import{jsx as yc,jsxs as dA}from"react/jsx-runtime";var cA=({label:e,onClick:o,className:t,children:r,actionType:n,type:i="button",isLoading:a,...l})=>{let s=n?`Dialog__action-button--${n}`:"";return dA("button",{className:sA("Dialog__action-button",s,t),type:i,"aria-label":e,onClick:o,...l,children:[r&&yc("div",{style:a?{visibility:"hidden"}:{},children:r}),yc("div",{style:a?{visibility:"hidden"}:{},children:e}),a&&yc("div",{style:{position:"absolute",inset:0},children:yc(tt,{})})]})},No=cA;import{jsx as vy,jsxs as Ty}from"react/jsx-runtime";var mA=e=>{let{onConfirm:o,onCancel:t,children:r,confirmText:n=g("buttons.confirm"),cancelText:i=g("buttons.cancel"),className:a="",...l}=e,s=le(),d=jo(di),{container:m}=He();return Ty(Be,{onCloseRequest:t,size:"small",...l,className:`confirm-dialog ${a}`,children:[r,Ty("div",{className:"confirm-dialog-buttons",children:[vy(No,{label:i,onClick:()=>{s({openMenu:null}),d(!1),wy(()=>{t()}),m?.focus()}}),vy(No,{label:n,onClick:()=>{s({openMenu:null}),d(!1),wy(()=>{o()}),m?.focus()},actionType:"danger"})]})]})},wc=mA;import Tc from"open-color";import{useCallback as xA,useEffect as Hu,useRef as Iy,useState as Ou}from"react";import{EDITOR_LS_KEYS as zu,EXPORT_DATA_TYPES as EA,MIME_TYPES as Cy,VERSIONS as yA,chunk as wA,getExportSource as vA}from"@excalidraw/common";var Gt=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(Gt,"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(Gt,"delete",o=>{try{window.localStorage.removeItem(o)}catch(t){console.warn(`localStorage.removeItem error: ${t.message}`)}});import vc from"react";var pA=/({{[\w-]+}})|(<[\w-]+>)|(<\/[\w-]+>)/g,uA=/{{([\w-]+)}}/,hA=/<([\w-]+)>/,gA=/<\/([\w-]+)>/,fA=(e,o)=>{let t=[{name:"",children:[]}];return e.split(pA).filter(Boolean).forEach(r=>{let n=r.match(hA),i=r.match(gA),a=r.match(uA);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(),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 ${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},bA=({i18nKey:e,children:o,...t})=>{let{t:r}=Oe();return vc.createElement(vc.Fragment,{},...fA(r(e),t))},ht=bA;import{jsx as ae,jsxs as at}from"react/jsx-runtime";var TA=async e=>{let r=Math.round(8),n=Math.max(Math.round(128/64),2),i=wA(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=Tc.white,l.fillRect(0,0,a.width,a.height);for(let[s,d]of e.entries()){let m=await cr({elements:d.elements,files:null,maxWidthOrHeight:128}),{width:c,height:p}=m,u=Math.floor(s/6)*(128+r*2),f=s%6*(128+r*2);l.drawImage(m,f+(128-c)/2+r,u+(128-p)/2+r),l.lineWidth=n,l.strokeStyle=Tc.gray[4],l.strokeRect(f+r/2,u+r/2,128+r,128+r)}return await Fl(new File([await ko(a)],"preview",{type:Cy.png}),{outputType:Cy.jpg,maxWidthOrHeight:5e3})},IA=({libItem:e,appState:o,index:t,onChange:r,onRemove:n})=>{let i=Iy(null),a=Iy(null);return Hu(()=>{let l=i.current;l&&(async()=>{let s=await si({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:Bt,className:"single-library-item--remove",onClick:n.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=>{r(l.target.value,t)}})]}),ae("span",{className:"error",children:e.error})]})]})},CA=({onClose:e,libraryItems:o,appState:t,onSuccess:r,onError:n,updateItemsInStorage:i,onRemove:a})=>{let[l,s]=Ou({authorName:"",githubHandle:"",name:"",description:"",twitterHandle:"",website:""}),[d,m]=Ou(!1);Hu(()=>{let y=Gt.get(zu.PUBLISH_LIBRARY);y&&s(y)},[]);let[c,p]=Ou(o.slice());Hu(()=>{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 TA(c),L={type:EA.excalidrawLibrary,version:yA.excalidrawLibrary,source:vA(),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})=>{Gt.delete(zu.PUBLISH_LIBRARY),r({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),n(N),m(!1)}).catch(N=>{console.error(N),n(N),m(!1)})},b=()=>{let y=[];return c.forEach((v,C)=>{y.push(ae("div",{className:"single-library-item-wrapper",children:ae(IA,{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=xA(()=>{i(c),Gt.set(zu.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")})})},Sy=CA;import MA from"clsx";import{useEffect as LA,useRef as PA}from"react";import{EVENT as Py,KEYS as AA}from"@excalidraw/common";import{forwardRef as ky}from"react";import My from"clsx";import{jsx as Ly}from"react/jsx-runtime";var SA=ky(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>Ly("div",{className:My("Stack Stack_horizontal",n),style:{"--gap":o,alignItems:t,justifyContent:r,...i},ref:a,children:e})),kA=ky(({children:e,gap:o,align:t,justifyContent:r,className:n,style:i},a)=>Ly("div",{className:My("Stack Stack_vertical",n),style:{"--gap":o,justifyItems:t,justifyContent:r,...i},ref:a,children:e})),qe={Row:SA,Col:kA};import{jsx as Ic}from"react/jsx-runtime";var Ay=({children:e,onClickOutside:o,className:t="",onSelect:r,style:n})=>{let i=se(),a=PA(null),l=Jo({onClickOutside:o});Dn(a,()=>{l.onClickOutside?.()}),LA(()=>{let d=c=>{c.key===AA.ESCAPE&&(c.stopImmediatePropagation(),l.onClickOutside?.())},m={capture:!0};return document.addEventListener(Py.KEYDOWN,d,m),()=>{document.removeEventListener(Py.KEYDOWN,d,m)}},[l]);let s=MA(`dropdown-menu ${t}`,{"dropdown-menu--mobile":i.editor.isMobile}).trim();return Ic(pp.Provider,{value:{onSelect:r},children:Ic("div",{ref:a,className:s,style:n,"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})})})};Ay.displayName="DropdownMenuContent";var Dy=Ay;import{jsx as _A}from"react/jsx-runtime";var DA=({children:e,className:o="",selected:t,...r})=>_A("div",{...r,className:`dropdown-menu-item-base dropdown-menu-item-custom ${o} ${t?"dropdown-menu-item--selected":""}`.trim(),children:e}),_y=DA;import{jsx as Ry}from"react/jsx-runtime";var Ny=({icon:e,shortcut:o,href:t,children:r,onSelect:n,className:i="",selected:a,rel:l="noopener",...s})=>{let d=ks(s.onClick,n);return Ry("a",{...s,href:t,target:"_blank",rel:l||"noopener",className:Ss(i,a),title:s.title??s["aria-label"],onClick:d,children:Ry(Cs,{icon:e,shortcut:o,children:r})})},mi=Ny;Ny.displayName="DropdownMenuItemLink";import{jsx as RA}from"react/jsx-runtime";var By=()=>RA("div",{style:{height:"1px",backgroundColor:"var(--default-border-color)",margin:".5rem 0"}}),Fy=By;By.displayName="DropdownMenuSeparator";import NA from"clsx";import{jsx as BA}from"react/jsx-runtime";var Oy=({className:e="",children:o,onToggle:t,title:r,...n})=>{let i=se(),a=NA(`dropdown-menu-button ${e}`,"zen-mode-transition",{"dropdown-menu-button--mobile":i.editor.isMobile}).trim();return BA("button",{"data-prevent-outside-click":!0,className:a,onClick:t,type:"button","data-testid":"dropdown-menu-button",title:r,...n,children:o})},zy=Oy;Oy.displayName="DropdownMenuTrigger";import Cc from"react";var Hy=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},Gy=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 FA,jsxs as OA}from"react/jsx-runtime";var Bo=({children:e,open:o})=>{let t=Hy(e),r=Gy(e);return OA(FA,{children:[t,o&&r]})};Bo.Trigger=zy;Bo.Content=Dy;Bo.Item=pt;Bo.ItemLink=mi;Bo.ItemCustom=_y;Bo.Group=sa;Bo.Separator=Fy;var fe=Bo;Bo.displayName="DropdownMenu";import{jsx as Tt,jsxs as Sc}from"react/jsx-runtime";var UA=(e,o)=>e.filter(t=>o.includes(t.id)),YA=({setAppState:e,selectedItems:o,library:t,onRemoveFromLibrary:r,resetLibrary:n,onSelectItems:i,appState:a,className:l})=>{let[s]=ie(qr),[d,m]=ie(di),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?r():n(),u(!1)},onCancel:()=>{u(!1)},title:N,children:Tt("p",{children:P})})},[p,u]=Gu(!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]=Gu(!1),[y,v]=Gu(null),C=HA(()=>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();jf(P).catch(GA).catch(N=>{e({errorMessage:N.message})})},A=()=>Sc(fe,{open:d,children:[Tt(fe.Trigger,{onToggle:()=>m(!d),children:I1}),Sc(fe.Content,{onClickOutside:()=>m(!1),onSelect:()=>m(!1),className:"library-menu",children:[!f&&Tt(fe.Item,{onSelect:L,icon:In,"data-testid":"lib-dropdown--load",children:g("buttons.load")}),!!b.length&&Tt(fe.Item,{onSelect:k,icon:Fr,"data-testid":"lib-dropdown--export",children:g("buttons.export")}),!!b.length&&Tt(fe.Item,{onSelect:()=>u(!0),icon:Mt,children:x}),f&&Tt(fe.Item,{icon:R0,onSelect:()=>E(!0),"data-testid":"lib-dropdown--remove",children:g("buttons.publishLibrary")})]})]});return Sc("div",{className:zA("library-menu-dropdown-container",l),children:[A(),o.length>0&&Tt("div",{className:"library-actions-counter",children:o.length}),p&&c(),w&&Tt(Sy,{onClose:()=>E(!1),libraryItems:UA(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()]})},Uu=({selectedItems:e,onSelectItems:o,className:t})=>{let{library:r}=Re(),{clearLibraryCache:n,deleteItemsFromLibraryCache:i}=hc(),a=ge(),l=le(),[s]=ie(qr),d=async c=>{let p=c.filter(u=>!e.includes(u.id));r.setLibrary(p).catch(()=>{l({errorMessage:g("alerts.errorRemovingFromLibrary")})}),i(e),o([])};return Tt(YA,{appState:a,setAppState:l,selectedItems:e,onSelectItems:o,library:r,onRemoveFromLibrary:()=>d(s.libraryItems),resetLibrary:()=>{r.resetLibrary(),n()},className:t})};import{memo as JA,useEffect as QA,useState as e8}from"react";import WA,{useCallback as VA}from"react";function XA(){return[!1,VA(o=>o(),[])]}var Uy=WA.useTransition||XA;import Yy from"clsx";import{memo as KA,useEffect as ZA,useRef as $A,useState as jA}from"react";import{jsx as kc,jsxs as qA}from"react/jsx-runtime";var Wy=KA(({id:e,elements:o,isPending:t,onClick:r,selected:n,onToggle:i,onDrag:a,svgCache:l})=>{let s=$A(null),d=cy(e,o,l);ZA(()=>{let f=s.current;if(f)return d&&(f.innerHTML=d.outerHTML),()=>{f.innerHTML=""}},[d]);let[m,c]=jA(!1),p=se().editor.isMobile,u=t&&kc("div",{className:"library-unit__adder",children:T1});return qA("div",{className:Yy("library-unit",{"library-unit__active":o,"library-unit--hover":o&&m,"library-unit--selected":n,"library-unit--skeleton":!d}),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[kc("div",{className:Yy("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}c(!1),a(e,f)}}),u,e&&o&&(m||p||n)&&kc(ba,{checked:n,onChange:(f,b)=>i(e,b),className:"library-unit__checkbox"})]})}),Vy=()=>kc("div",{className:"library-unit library-unit--skeleton"});import{Fragment as t8,jsx as Mc}from"react/jsx-runtime";var Yu=({children:e})=>Mc("div",{className:"library-menu-items-container__grid",children:e}),Lc=JA(({items:e,onItemSelectToggle:o,onItemDrag:t,isItemSelected:r,onClick:n,svgCache:i,itemsRenderedPerBatch:a})=>{let[,l]=Uy(),[s,d]=e8(0);return QA(()=>{s<e.length&&l(()=>{d(s+a)})},[s,e.length,l,a]),Mc(t8,{children:e.map((m,c)=>c<s?Mc(Wy,{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??c):Mc(Vy,{},c))})});import{Fragment as Ky,jsx as It,jsxs as ui}from"react/jsx-runtime";var s8=17,c8=64;function Wu({isLoading:e,libraryItems:o,onAddToLibrary:t,onInsertLibraryItems:r,pendingElements:n,theme:i,id:a,libraryReturnUrl:l,onSelectItems:s,selectedItems:d}){let m=r8(null),c=yy(m);o8(()=>{c>0&&m.current?.scrollTo(0,c)},[]);let{svgCache:p}=hc(),u=Xy(()=>o.filter(P=>P.status!=="published"),[o]),f=Xy(()=>o.filter(P=>P.status==="published"),[o]),b=!o.length&&!n.length,x=!n.length&&!u.length&&!f.length,[w,E]=n8(null),y=pi((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=a8(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=pi(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:l8({type:"everything",elements:O.elements,randomizeSeed:!0}).duplicatedElements}))},[o,d]),C=pi((P,N)=>{N.dataTransfer.setData(i8.excalidrawlib,um(v(P)))},[v]),S=pi(P=>P?d.includes(P):!1,[d]),L=pi(()=>{t(n)},[n,t]),k=pi(P=>{P&&r(v(P))},[v,r]),A=p.size>=o.length?c8:s8;return ui("div",{className:"library-menu-items-container",style:n.length||u.length||f.length?{justifyContent:"flex-start"}:{borderBottom:0},children:[!x&&It(Uu,{selectedItems:d,onSelectItems:s,className:"library-menu-dropdown-container--in-heading"}),ui(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:[ui(Ky,{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,{})}),!n.length&&!u.length?ui("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")})]}):ui(Yu,{children:[n.length>0&&It(Lc,{itemsRenderedPerBatch:A,items:[{id:null,elements:n}],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})]})]}),ui(Ky,{children:[(f.length>0||n.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(Yu,{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(Uu,{selectedItems:d,onSelectItems:s})})]})]})}import{jsx as mr,jsxs as jy}from"react/jsx-runtime";var di=me(!1),$y=({children:e})=>mr("div",{className:"layer-ui__library",children:e}),h8=Qy(({onInsertLibraryItems:e,pendingElements:o,onAddToLibrary:t,setAppState:r,libraryReturnUrl:n,library:i,id:a,theme:l,selectedItems:s,onSelectItems:d})=>{let[m]=ie(qr),c=Xu(f=>{(async(x,w)=>{re("element","addToLibrary","ui");for(let y of m8)if(x.some(v=>v.type===y))return r({errorMessage:g(`errors.libraryElementTypeError.${y}`)});let E=[{status:"unpublished",elements:x,id:p8(),created:Date.now()},...w];t(),i.setLibrary(E).catch(()=>{r({errorMessage:g("alerts.errorAddingToLibrary")})})})(f,m.libraryItems)},[t,i,r,m.libraryItems]),p=Jy(()=>m.libraryItems,[m]);if(m.status==="loading"&&!m.isInitialized)return mr($y,{children:mr("div",{className:"layer-ui__library-message",children:jy("div",{children:[mr(tt,{size:"2em"}),mr("span",{children:g("labels.libraryLoadingMessage")})]})})});let u=m.libraryItems.length>0||o.length>0;return jy($y,{children:[mr(Wu,{isLoading:m.status==="loading",libraryItems:p,onAddToLibrary:c,onInsertLibraryItems:e,pendingElements:o,id:a,libraryReturnUrl:n,theme:l,onSelectItems:d,selectedItems:s}),u&&mr(Ec,{className:"library-menu-control-buttons--at-bottom",style:{padding:"16px 12px 0 12px"},id:a,libraryReturnUrl:n,theme:l})]})}),Vu=(e,o)=>({elements:e,pending:j(e,{selectedElementIds:o},{includeBoundTextElement:!0,includeElementsInFrames:!0}),selectedElementIds:o}),g8=(e,o)=>{let t=tr(),[r,n]=qy(()=>Vu(t,e.selectedElementIds)),i=d8(new Map);return Zy(()=>{for(let a of r.pending)i.current.set(a.id,a.version)},[r.pending]),Zy(()=>{o.state.cursorButton==="up"&&o.state.activeTool.type==="selection"&&n(a=>{if(!u8(a.selectedElementIds,e.selectedElementIds))return i.current.clear(),Vu(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 Vu(t,e.selectedElementIds)}return a})},[o,o.state.cursorButton,o.state.activeTool.type,e.selectedElementIds,t]),r.pending},e2=Qy(()=>{let e=Re(),{onInsertElements:o}=e,t=fo(),r=ge(),n=le(),[i,a]=qy([]),l=Jy(()=>e.library,[e.library]),s=g8(r,e),d=Xu(c=>{o(xc(c))},[o]),m=Xu(()=>{n({selectedElementIds:{},selectedGroupIds:{},activeEmbeddable:null})},[n]);return mr(h8,{pendingElements:s,onInsertLibraryItems:d,onAddToLibrary:m,setAppState:n,libraryReturnUrl:t.libraryReturnUrl,library:l,id:e.id,theme:r.theme,selectedItems:i,onSelectItems:a})});import f8 from"clsx";import{useRef as b8}from"react";import{createPortal as x8}from"react-dom";import{KEYS as E8}from"@excalidraw/common";import{jsx as t2,jsxs as y8}from"react/jsx-runtime";var o2=e=>{let{closeOnClickOutside:o=!0}=e,t=fs({className:"excalidraw-modal-container"}),r=b8(document.body.classList.contains("excalidraw-animations-disabled"));if(!t)return null;let n=i=>{i.key===E8.ESCAPE&&(i.nativeEvent.stopImmediatePropagation(),i.stopPropagation(),e.onCloseRequest())};return x8(y8("div",{className:f8("Modal",e.className,{"animations-disabled":r.current}),role:"dialog","aria-modal":"true",onKeyDown:n,"aria-labelledby":e.labelledBy,"data-prevent-outside-click":!0,children:[t2("div",{className:"Modal__background",onClick:o?e.onCloseRequest:void 0}),t2("div",{className:"Modal__content",style:{"--max-width":`${e.maxWidth}px`},tabIndex:0,children:e.children})]}),t)};import{jsx as Fa,jsxs as S8}from"react/jsx-runtime";function C8(e){if(e&&typeof e=="number")return e;switch(e){case"small":return 550;case"wide":return 1024;case"regular":default:return 800}}var Be=e=>{let[o,t]=ay(),[r]=T8(document.activeElement),{id:n}=He(),i=se().viewport.isMobile;v8(()=>{if(!o)return;let d=r2(o);setTimeout(()=>{d.length>0&&e.autofocus!==!1&&(d[1]||d[0]).focus()});let m=c=>{if(c.key===I8.TAB){let p=r2(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=jo(di),s=()=>{a({openMenu:null}),l(!1),r.focus(),e.onCloseRequest()};return Fa(o2,{className:w8("Dialog",e.className,{"Dialog--fullscreen":i}),labelledBy:"dialog-title",maxWidth:C8(e.size),onCloseRequest:s,closeOnClickOutside:e.closeOnClickOutside,children:S8(Xe,{ref:t,children:[e.title&&Fa("h2",{id:`${n}-dialog-title`,className:"Dialog__title",children:Fa("span",{className:"Dialog__titleContent",children:e.title})}),i&&Fa("button",{className:"Dialog__close",onClick:s,title:g("buttons.close"),"aria-label":g("buttons.close"),type:"button",children:Bt}),Fa("div",{className:"Dialog__content",children:e.children})]})})};import Ku from"clsx";import{forwardRef as P8,useRef as A8,useImperativeHandle as D8,useLayoutEffect as _8,useState as R8}from"react";import k8 from"clsx";import{composeEventHandlers as M8}from"@excalidraw/common";import{jsx as L8}from"react/jsx-runtime";var _t=({type:e="button",onSelect:o,selected:t,children:r,className:n="",...i})=>L8("button",{onClick:M8(i.onClick,a=>{o()}),type:e,className:k8("excalidraw-button",n,{selected:t}),...i,children:r});import{jsx as Zu,jsxs as n2}from"react/jsx-runtime";var hi=P8(({onChange:e,label:o,fullWidth:t,placeholder:r,readonly:n,selectOnRender:i,onKeyDown:a,isRedacted:l=!1,icon:s,className:d,...m},c)=>{let p=A8(null);D8(c,()=>p.current),_8(()=>{i&&(p.current?.focus(),p.current?.select())},[i]);let[u,f]=R8(!1);return n2("div",{className:Ku("ExcTextField",d,{"ExcTextField--fullWidth":t,"ExcTextField--hasIcon":!!s}),onClick:()=>{p.current?.focus()},children:[s,o&&Zu("div",{className:"ExcTextField__label",children:o}),n2("div",{className:Ku("ExcTextField__input",{"ExcTextField__input--readonly":n}),children:[Zu("input",{className:Ku({"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&&Zu(_t,{onSelect:()=>f(!u),style:{border:0,userSelect:"none"},children:u?U0:kn})]})]})});import{KEYS as Ge}from"@excalidraw/common";var Oa=[{icon:P1,value:"selection",key:Ge.V,numericKey:Ge[1],fillable:!0},{icon:Ul,value:"rectangle",key:Ge.R,numericKey:Ge[2],fillable:!0},{icon:Yl,value:"diamond",key:Ge.D,numericKey:Ge[3],fillable:!0},{icon:Wl,value:"ellipse",key:Ge.O,numericKey:Ge[4],fillable:!0},{icon:A1,value:"arrow",key:Ge.A,numericKey:Ge[5],fillable:!0},{icon:Vl,value:"line",key:Ge.L,numericKey:Ge[6],fillable:!0},{icon:qo,value:"freedraw",key:[Ge.P,Ge.X],numericKey:Ge[7],fillable:!1},{icon:vn,value:"text",key:Ge.T,numericKey:Ge[8],fillable:!1},{icon:_1,value:"image",key:null,numericKey:Ge[9],fillable:!1},{icon:R1,value:"eraser",key:Ge.E,numericKey:Ge[0],fillable:!1}],i2=e=>Oa.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 Ju from"clsx";import{useState as F8}from"react";import{CLASSES as O8,KEYS as l2,capitalizeString as qu,isTransparent as s2}from"@excalidraw/common";import{shouldAllowVerticalAlign as z8,suppportsHorizontalAlign as H8}from"@excalidraw/element";import{hasBoundTextElement as c2,isElbowArrow as G8,isImageElement as U8,isLinearElement as Y8,isTextElement as W8}from"@excalidraw/element";import{hasStrokeColor as d2,toolIsArrow as m2}from"@excalidraw/element";import{createIsolation as N8}from"jotai-scope";import $u from"react";import yo from"tunnel-rat";var ju=$u.createContext(null),ve=()=>$u.useContext(ju),B8=N8(),a2=()=>$u.useMemo(()=>({MainMenuTunnel:yo(),WelcomeScreenMenuHintTunnel:yo(),WelcomeScreenToolbarHintTunnel:yo(),WelcomeScreenHelpHintTunnel:yo(),WelcomeScreenCenterTunnel:yo(),FooterCenterTunnel:yo(),DefaultSidebarTriggerTunnel:yo(),DefaultSidebarTabTriggersTunnel:yo(),OverwriteConfirmDialogTunnel:yo(),TTDDialogTriggerTunnel:yo(),tunnelsJotai:B8}),[]);import{Fragment as Fo,jsx as Te,jsxs as $e}from"react/jsx-runtime";var Qu=(e,o)=>{let t=o[0]?.type||null;for(let r of o)if(r.type!==t){t=null;break}return d2(e.activeTool.type)&&t!=="image"&&t!=="frame"&&t!=="magicframe"||o.some(r=>d2(r.type))},eh=(e,o)=>Ko(e.activeTool.type)||o.some(t=>Ko(t.type)),Pc=({appState:e,elementsMap:o,renderAction:t,app:r})=>{let n=kl(o,e),i=!1;n.length===2&&(c2(n[0])||c2(n[1]))&&(i=!0);let a=!!(e.editingTextElement||e.newElement),l=se(),s=document.documentElement.getAttribute("dir")==="rtl",d=Ko(e.activeTool.type)&&!s2(e.currentItemBackgroundColor)||n.some(f=>Ko(f.type)&&!s2(f.backgroundColor)),m=n.length===1||i,c=!e.selectedLinearElement?.isEditing&&n.length===1&&Y8(n[0])&&!G8(n[0]),p=!e.croppingElementId&&n.length===1&&U8(n[0]),u=!i&&vt(e,r);return $e("div",{className:"selected-shape-actions",children:[Te("div",{children:Qu(e,n)&&t("changeStrokeColor")}),eh(e,n)&&Te("div",{children:t("changeBackgroundColor")}),d&&t("changeFillStyle"),(lm(e.activeTool.type)||n.some(f=>lm(f.type)))&&t("changeStrokeWidth"),(e.activeTool.type==="freedraw"||n.some(f=>f.type==="freedraw"))&&t("changeStrokeShape"),(sm(e.activeTool.type)||n.some(f=>sm(f.type)))&&$e(Fo,{children:[t("changeStrokeStyle"),t("changeSloppiness")]}),(cm(e.activeTool.type)||n.some(f=>cm(f.type)))&&Te(Fo,{children:t("changeRoundness")}),(m2(e.activeTool.type)||n.some(f=>m2(f.type)))&&Te(Fo,{children:t("changeArrowType")}),(e.activeTool.type==="text"||n.some(W8))&&$e(Fo,{children:[t("changeFontFamily"),t("changeFontSize"),(e.activeTool.type==="text"||H8(n,o))&&t("changeTextAlign")]}),z8(n,o)&&t("changeVerticalAlign"),(un(e.activeTool.type)||n.some(f=>un(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")]}),n.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"),n.length>2&&t("distributeVertically")]})]})]}),!a&&n.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")]})]})]})},Ac=({activeTool:e,appState:o,app:t,UIOptions:r})=>{let[n,i]=F8(!1),a=e.type==="frame",l=e.type==="laser",s=e.type==="lasso",d=e.type==="embeddable",{TTDDialogTriggerTunnel:m}=ve();return $e(Fo,{children:[Oa.map(({value:c,icon:p,key:u,numericKey:f,fillable:b},x)=>{if(r.tools?.[c]===!1)return null;let w=g(`toolBar.${c}`),E=u&&qu(typeof u=="string"?u:u[0]),y=E?`${E} ${g("helpDialog.or")} ${f}`:`${f}`;return Te(K,{className:Ju("Shape",{fillable:b}),type:"radio",icon:p,checked:e.type===c,name:"editor-current-shape",title:`${qu(w)} \u2014 ${y}`,keyBindingLabel:f||E,"aria-label":qu(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&&re("toolbar",c,"ui"),c==="image"?t.setActiveTool({type:c}):t.setActiveTool({type:c})}},c)}),Te("div",{className:"App-toolbar__divider"}),$e(fe,{open:n,children:[Te(fe.Trigger,{className:Ju("App-toolbar__extra-tools-trigger",{"App-toolbar__extra-tools-trigger--selected":a||d||s||l&&!t.props.isCollaborating}),onToggle:()=>i(!n),title:g("toolBar.extraTools"),children:a?zr:d?vm:l&&!t.props.isCollaborating?Qi:s?Ki:H0}),$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:zr,shortcut:l2.F.toLocaleUpperCase(),"data-testid":"toolbar-frame",selected:a,children:g("toolBar.frame")}),Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"embeddable"}),icon:vm,"data-testid":"toolbar-embeddable",selected:d,children:g("toolBar.embeddable")}),Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"laser"}),icon:Qi,"data-testid":"toolbar-laser",selected:l,shortcut:l2.K.toLocaleUpperCase(),children:g("toolBar.laser")}),Te(fe.Item,{onSelect:()=>t.setActiveTool({type:"lasso"}),icon:Ki,"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"})]})})]})]})]})},p2=({renderAction:e,zoom:o})=>Te(qe.Col,{gap:1,className:O8.ZOOM_ACTIONS,children:$e(qe.Row,{align:"center",children:[e("zoomOut"),e("resetZoom"),e("zoomIn")]})}),u2=({renderAction:e,className:o})=>$e("div",{className:`undo-redo-buttons ${o}`,children:[Te("div",{className:"undo-button-container",children:Te(Pt,{label:g("buttons.undo"),children:e("undo")})}),Te("div",{className:"redo-button-container",children:$e(Pt,{label:g("buttons.redo"),children:[" ",e("redo")]})})]}),h2=({actionManager:e,showExitZenModeBtn:o})=>Te("button",{type:"button",className:Ju("disable-zen-mode",{"disable-zen-mode--visible":o}),onClick:()=>e.executeAction(ei),children:g("buttons.exitZenMode")});import{useRef as V8}from"react";var th=e=>{let o=V8({userFn:e});return o.current.userFn=e,o.current.stableFn||(o.current.stableFn=(...t)=>o.current.userFn(...t)),o.current.stableFn};import{jsx as K8,jsxs as X8}from"react/jsx-runtime";var Jr=me(null),g2=()=>{let[e,o]=ie(Jr),t=Ue();return e&&e==="clearCanvas"?K8(wc,{onConfirm:()=>{t.executeAction(_o),o(null)},onCancel:()=>o(null),title:g("clearCanvasDialog.title"),children:X8("p",{className:"clear-canvas__content",children:[" ",g("alerts.clearReset")]})}):null};var oh={};Wf(oh,{toggleTheme:()=>Z8});var Z8={...Yr,category:"App",label:"Toggle theme",perform:({actionManager:e})=>{e.executeAction(Yr,"commandPalette")}};import{jsx as lt,jsxs as wo}from"react/jsx-runtime";var e7=me(null),ke={app:"App",export:"Export",tools:"Tools",editor:"Editor",elements:"Elements",links:"Links"},t7=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}},Rc=({shortcut:e,className:o,children:t})=>{let r=e.replace("++","+$").split("+");return wo("div",{className:x2("shortcut",o),children:[r.map((n,i)=>lt("div",{className:"shortcut-wrapper",children:lt("div",{className:"shortcut-key",children:n==="$"?"+":n})},n)),lt("div",{className:"shortcut-desc",children:t})]})},E2=e=>!e.altKey&&e[io.CTRL_OR_CMD]&&(e.shiftKey&&e.key.toLowerCase()===io.P||e.key===io.SLASH),fce=Object.assign(e=>{let o=ge(),t=le();return _c(()=>{let r=n=>{E2(n)&&(n.preventDefault(),n.stopPropagation(),t(i=>{let a=i.openDialog?.name==="commandPalette"?null:{name:"commandPalette"};return a&&re("command_palette","open","shortcut"),{openDialog:a}}))};return window.addEventListener(Nc.KEYDOWN,r,{capture:!0}),()=>window.removeEventListener(Nc.KEYDOWN,r,{capture:!0})},[t]),o.openDialog?.name!=="commandPalette"?null:lt(o7,{...e})},{defaultItems:oh});function o7({customCommandPaletteItems:e}){let o=Re(),t=ge(),r=le(),n=fo(),i=Ue(),[a,l]=ie(e7),[s,d]=Dc(null),m=j8(null),c=Jo({uiAppState:t,customCommandPaletteItems:e,appProps:n});_c(()=>{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,ka,uc,ny].map(W=>O(W,ke.elements,(ce,he)=>({...ce,predicate:he.predicate?he.predicate:(de,it,po,mn)=>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:()=>{ze.set(Jr,"clearCanvas")}},{label:g("buttons.exportImage"),category:ke.export,icon:$l,shortcut:Ne("imageExport"),keywords:["export","image","png","jpeg","svg","clipboard","picture"],perform:()=>{r({openDialog:{name:"imageExport"}})}},...R];let V=[{label:g("toolBar.library"),category:ke.app,icon:yn,viewMode:!1,perform:()=>{S.openSidebar?r({openSidebar:null}):r({openSidebar:{name:f2.name,tab:f2.defaultTab}})}},{label:g("search.title"),category:ke.app,icon:Lt,viewMode:!0,perform:()=>{i.executeAction(za)}},{label:g("labels.shapeSwitch"),category:ke.elements,icon:ea,perform:()=>{i.executeAction(ry)}},{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&&Qu(ce,he)},perform:()=>{r(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&&eh(ce,he)},perform:()=>{r(W=>({openMenu:W.openMenu==="shape"?null:"shape",openPopup:"elementBackground"}))}},{label:g("labels.canvasBackground"),keywords:["color"],icon:Zl,category:ke.editor,viewMode:!1,perform:()=>{r(W=>({openMenu:W.openMenu==="canvas"?null:"canvas",openPopup:"canvasBackground"}))}},...Oa.reduce((W,ce)=>{let{value:he,icon:de,key:it,numericKey:po}=ce;if(k.UIOptions.tools?.[he]===!1)return W;let pn=it&&q8(typeof it=="string"?it:it[0])||po,Cl={label:g(`toolBar.${he}`),category:ke.tools,shortcut:pn,icon:de,keywords:["toolbar"],viewMode:!1,perform:({event:nm})=>{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?wn:Br,shortcut:io.Q.toLocaleUpperCase(),viewMode:!1,perform:()=>{o.toggleLock()}},{label:`${g("labels.textToDiagram")}...`,category:ke.tools,icon:W0,viewMode:!1,predicate:k.aiEnabled,perform:()=>{r(W=>({...W,openDialog:{name:"ttd",tab:"text-to-diagram"}}))}},{label:`${g("toolBar.mermaidToExcalidraw")}...`,category:ke.tools,icon:es,viewMode:!1,predicate:k.aiEnabled,perform:()=>{r(W=>({...W,openDialog:{name:"ttd",tab:"mermaid"}}))}}],Z=[...N,...V,...L||[]].map(W=>({...W,icon:W.icon||ea,order:W.order??t7(W.category),haystack:`${Pu(W.label.toLocaleLowerCase())} ${W.keywords?.join(" ")||""}`}));d(Z),l(Z.find(W=>W.label===a?.label)??null)}},[c,o,i,d,a?.label,l,r]);let[p,u]=Dc(""),[f,b]=Dc(null),[x,w]=Dc({}),E=S=>{r({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=th(S=>S.viewMode===!1&&t.viewModeEnabled?!1:typeof S.predicate=="function"?S.predicate(o.scene.getNonDeletedElements(),t,n,o):S.predicate===void 0||S.predicate),C=th(S=>{let L=Q8(S.target)||E2(S)||S.key===io.ESCAPE;if(L&&S.key!==io.ARROW_UP&&S.key!==io.ARROW_DOWN&&S.key!==io.ENTER)return;let k=Object.values(x).flat(),A=a&&!p&&v(a);if(S.key===io.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===io.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===io.ENTER&&f&&setTimeout(()=>{y(f,S)}),!L){if(S.stopPropagation(),/^[a-zA-Z0-9]$/.test(S.key)){m?.current?.focus();return}S.preventDefault()}});return _c(()=>(window.addEventListener(Nc.KEYDOWN,C,{capture:!0}),()=>window.removeEventListener(Nc.KEYDOWN,C,{capture:!0})),[C]),_c(()=>{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=Pu(p.toLocaleLowerCase().replace(/[<>_| -]/g,""));L=$8.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(hi,{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(Rc,{shortcut:"\u2191\u2193",children:g("commandPalette.shortcuts.select")}),lt(Rc,{shortcut:"\u21B5",children:g("commandPalette.shortcuts.confirm")}),lt(Rc,{shortcut:J8("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:V0})]}),lt(b2,{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(b2,{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:Lt})," ",g("commandPalette.search.noMatch")]}):null]})]})}var b2=({command:e,isSelected:o,disabled:t,onMouseMove:r,onClick:n,showShortcut:i,appState:a})=>{let l=()=>{};return wo("div",{className:x2("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:[wo("div",{className:"name",children:[e.icon&&lt(nr,{icon:typeof e.icon=="function"?e.icon(a):e.icon}),lt(ca,{children:e.label})]}),i&&e.shortcut&&lt(Rc,{shortcut:e.shortcut})]})};import{getSizeFromPoints as i1e,randomInteger as J7,getUpdatedTimestamp as Q7}from"@excalidraw/common";import{simplify as U7}from"points-on-curve";import{pointsOnBezierCurves as wce}from"points-on-curve";import{invariant as Tce}from"@excalidraw/common";import{curve as Cce,lineSegment as Sce,pointFrom as kce,pointDistance as Mce,pointFromArray as Lce,pointFromVector as Pce,pointRotateRads as Ace,polygon as Dce,polygonFromPoints as _ce,PRECISION as Rce,segmentsIntersectAt as Nce,vector as Bce,vectorAdd as Fce,vectorFromPoint as Oce,vectorScale as zce}from"@excalidraw/math";import{getElementAbsoluteCoords as Gce}from"@excalidraw/element";var rh=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 Y7,pointDistance as G2,pointRotateRads as Yfe}from"@excalidraw/math";import{ROUGHNESS as W7,isTransparent as Wa,assertNever as V7,COLOR_PALETTE as X7,LINE_POLYGON_POINT_MERGE_DISTANCE as Vfe}from"@excalidraw/common";import{RoughGenerator as K7}from"roughjs/bin/generator";import afe from"roughjs/bin/rough";import{getStroke as N7}from"perfect-freehand";import{isRightAngleRads as cfe}from"@excalidraw/math";import{BOUND_TEXT_PADDING as mfe,DEFAULT_REDUCED_GLOBAL_ALPHA as pfe,ELEMENT_READY_TO_ERASE_OPACITY as ufe,FRAME_STYLE as hfe,MIME_TYPES as F2,THEME as gfe,distance as ffe,getFontString as bfe,isRTL as xfe,getVerticalOffset as Efe}from"@excalidraw/common";import xhe from"roughjs/bin/rough";import{arrayToMap as yhe,invariant as L2,rescalePoints as whe,sizeOf as vhe}from"@excalidraw/common";import{degreesToRadians as gh,lineSegment as Ihe,pointDistance as Che,pointFrom as ot,pointFromArray as E7,pointRotateRads as Ei}from"@excalidraw/math";import{pointsOnBezierCurves as Mhe}from"points-on-curve";import{pointCenter as Bue,pointFrom as Fue,pointRotateRads as Oue,pointsEqual as zue,pointDistance as Hue,vectorFromPoint as Gue,curveLength as Uue,curvePointAtLength as Yue}from"@excalidraw/math";import{DRAGGING_THRESHOLD as Xue,KEYS as Kue,shouldRotateWithDiscreteAngle as Zue,getGridPoint as $ue,invariant as jue,tupleToCoors as que,viewportCoordsToSceneCoords as Jue}from"@excalidraw/common";import{deconstructLinearOrFreeDrawElement as ehe,isPathALoop as the}from"@excalidraw/element";import{KEYS as Npe,arrayToMap as Bpe,isBindingFallthroughEnabled as Fpe,tupleToCoors as Ope,invariant as zpe,isDevEnv as Hpe,isTestEnv as Gpe}from"@excalidraw/common";import{lineSegment as Ype,pointFrom as Wpe,pointRotateRads as Vpe,vectorFromPoint as Xpe,pointDistanceSq as Kpe,clamp as Zpe,pointDistance as $pe,pointFromVector as jpe,vectorScale as qpe,vectorNormalize as Jpe,vectorCross as Qpe,pointsEqual as eue,lineSegmentIntersectionPoints as tue,PRECISION as oue}from"@excalidraw/math";import{isTransparent as mme}from"@excalidraw/common";import{curveIntersectLineSegment as ume,isPointWithinBounds as hme,lineSegment as gme,lineSegmentIntersectionPoints as fme,pointFrom as bme,pointFromVector as xme,pointRotateRads as Eme,pointsEqual as yme,vectorFromPoint as wme,vectorNormalize as vme,vectorScale as Tme}from"@excalidraw/math";import{ellipse as Cme,ellipseSegmentInterceptPoints as Sme}from"@excalidraw/math/ellipse";import{DEFAULT_ADAPTIVE_RADIUS as r7,DEFAULT_PROPORTIONAL_RADIUS as nh,LINE_CONFIRM_THRESHOLD as n7,ROUNDNESS as ih}from"@excalidraw/common";import{curve as Xce,curveCatmullRomCubicApproxPoints as Kce,curveOffsetPoints as Zce,lineSegment as $ce,pointDistance as i7,pointFrom as jce,pointFromArray as qce,rectangle as Jce}from"@excalidraw/math";var Bc=(e,o=1)=>{if(e.length>=3){let[t,r]=[e[0],e[e.length-1]];return i7(t,r)<=n7/o}return!1},Ha=(e,o)=>{if(o.roundness?.type===ih.PROPORTIONAL_RADIUS||o.roundness?.type===ih.LEGACY)return e*nh;if(o.roundness?.type===ih.ADAPTIVE_RADIUS){let t=o.roundness?.value??r7,r=t/nh;return e<=r?e*nh:t}return 0};import{ROUNDNESS as ide,assertNever as ade}from"@excalidraw/common";import{pointsEqual as sde}from"@excalidraw/math";var y2=e=>!!e&&e.type==="embeddable",w2=e=>!!e&&e.type==="iframe",lh=e=>!!e&&(e.type==="iframe"||e.type==="embeddable"),Qr=e=>e!=null&&e.type==="text";var Fc=e=>e!=null&&(e.type==="frame"||e.type==="magicframe");var pr=e=>e!=null&&a7(e.type);var gi=e=>e!=null&&e.type==="arrow",Ga=e=>gi(e)&&e.elbowed;var a7=e=>e==="arrow"||e==="line";var fi=e=>e!==null&&"containerId"in e&&e.containerId!==null&&Qr(e);import{ARROW_LABEL_FONT_SIZE_TO_MIN_WIDTH_RATIO as Fde,ARROW_LABEL_WIDTH_FRACTION as Ode,BOUND_TEXT_PADDING as zde,DEFAULT_FONT_SIZE as Hde,TEXT_ALIGN as Gde,VERTICAL_ALIGN as Ude,getFontString as Yde,isProdEnv as Wde,invariant as Vde}from"@excalidraw/common";import{BOUND_TEXT_PADDING as hde,DEFAULT_FONT_SIZE as gde,DEFAULT_FONT_FAMILY as fde,getFontString as bde,isTestEnv as xde,normalizeEOL as Ede}from"@excalidraw/common";var yde="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toLocaleUpperCase();import{isDevEnv as kde,isTestEnv as Mde}from"@excalidraw/common";import{curvePointDistance as eme,distanceToLineSegment as tme,pointRotateRads as ome}from"@excalidraw/math";import{ellipse as nme,ellipseDistanceFromPoint as ime}from"@excalidraw/math/ellipse";import{invariant as Ome,isDevEnv as zme,isTestEnv as Hme}from"@excalidraw/common";import{pointFrom as Ume,pointFromVector as Yme,pointRotateRads as Wme,pointScaleFromOrigin as Vme,pointsEqual as Xme,triangleIncludesPoint as Kme,vectorCross as Zme,vectorFromPoint as m7,vectorScale as $me}from"@excalidraw/math";var uh=[1,0],C2=[0,1],hh=[-1,0],S2=[0,-1],Oc=e=>{let[o,t]=e,r=Math.abs(o),n=Math.abs(t);return o>n?uh:o<=-n?hh:t>r?C2:S2},k2=(e,o)=>Oc(m7(e,o)),zc=(e,o)=>Hc(k2(e,o)),ph=(e,o)=>e[0]===o[0]&&e[1]===o[1],Hc=e=>ph(e,uh)||ph(e,hh);import{clamp as tpe,pointDistance as ope,pointFrom as rpe,pointScaleFromOrigin as npe,pointsEqual as ipe,pointTranslate as ape,vector as lpe,vectorCross as spe,vectorFromPoint as cpe,vectorScale as dpe}from"@excalidraw/math";import{BinaryHeap as ppe,invariant as upe,isAnyTrue as hpe,tupleToCoors as gpe,getSizeFromPoints as fpe,isDevEnv as bpe,arrayToMap as xpe}from"@excalidraw/common";import{SHIFT_LOCKING_ANGLE as bue,viewportCoordsToSceneCoords as xue}from"@excalidraw/common";import{normalizeRadians as yue,radiansBetweenAngles as wue,radiansDifference as vue}from"@excalidraw/math";import{pointsEqual as Iue}from"@excalidraw/math";var ah=e=>{let o=Math.floor(e.width/2)+1,t=0,r=e.width,n=Math.floor(e.height/2)+1,i=o,a=e.height;return[o,t,r,n,i,a,0,n]};var y7=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}},w7=e=>{switch(e){case"bar":return 90;case"arrow":return 20;default:return 25}},fh=(e,o,t,r)=>{if(o.length<1)return null;let n=rh(o[0]);if(n.length<1)return null;let i=t==="start"?1:n.length-1,a=n[i].data;L2(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=n[i-1],c=ot(0,0);if(m.op==="move"){let _=E7(m.data);L2(_!=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=y7(r),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*(r==="diamond"||r==="diamond_outline"?.25:.5)),k=u-E*L,A=f-y*L;if(r==="dot"||r==="circle"||r==="circle_outline"){let _=Math.hypot(A-f,k-u)+e.strokeWidth-2;return[u,f,_]}let P=w7(r);if(r==="crowfoot_many"||r==="crowfoot_one_or_many"){let[_,R]=Ei(ot(u,f),ot(k,A),gh(-P)),[V,Z]=Ei(ot(u,f),ot(k,A),gh(P));return[k,A,_,R,V,Z]}let[N,O]=Ei(ot(k,A),ot(u,f),-P*Math.PI/180),[U,J]=Ei(ot(k,A),ot(u,f),gh(P));if(r==="diamond"||r==="diamond_outline"){let _,R;if(t==="start"){let[V,Z]=e.points.length>1?e.points[1]:[0,0];[_,R]=Ei(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]=Ei(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 Uhe,pointCenter as Yhe,pointRotateRads as Whe,vectorFromPoint as Vhe,vectorNormalize as Xhe,vectorSubtract as Khe,vectorAdd as Zhe,vectorScale as $he,pointFromVector as jhe,clamp as qhe,isCloseTo as Jhe}from"@excalidraw/math";import{arrayToMap as Oge}from"@excalidraw/common";import{isPointWithinBounds as Hge,pointFrom as Gge}from"@excalidraw/math";import{vectorCross as rge,vectorFromPoint as nge}from"@excalidraw/math";import{arrayToMap as v7}from"@excalidraw/common";import{getElementBounds as T7}from"@excalidraw/element";import{isArrowElement as I7,isExcalidrawElement as C7,isFreeDrawElement as S7,isLinearElement as k7,isTextElement as M7}from"@excalidraw/element";import{rangeIncludesValue as Gc,pointFrom as zo,pointRotateRads as L7,rangeInclusive as Uc}from"@excalidraw/math";var P7=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)],A7=e=>k7(e)||S7(e)?e.points:P7(e),A2=e=>{let o=e.reduce((t,[r,n])=>(t.minY=Math.min(t.minY,n),t.minX=Math.min(t.minX,r),t.maxX=Math.max(t.maxX,r),t.maxY=Math.max(t.maxY,n),t),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,cx:0,cy:0});return o.cx=(o.maxX+o.minX)/2,o.cy=(o.maxY+o.minY)/2,o},D2=e=>{let o=A7(e),{cx:t,cy:r}=A2(o),n=zo(t,r),i=o.map(m=>L7(m,n,e.angle)),{minX:a,minY:l,maxX:s,maxY:d}=A2(i);return[a+e.x,l+e.y,s+e.x,d+e.y]},bh=(e,o,t=!1)=>{let r=D2(e),n=o[0]<=r[0]&&o[2]>=r[2]&&o[1]<=r[1]&&o[3]>=r[3];return t?n?!0:r[0]<=o[0]&&r[2]>=o[2]&&r[1]<=o[1]&&r[3]>=o[3]:n},_2=(e,o)=>{let t=D2(e);return(Gc(t[0],Uc(o[0],o[2]))||Gc(o[0],Uc(t[0],t[2])))&&(Gc(t[1],Uc(o[1],o[3]))||Gc(o[1],Uc(t[1],t[3])))},R2=({elements:e,bounds:o,type:t,errorMargin:r=0})=>{C7(o)&&(o=T7(o,v7(e)));let n=[o[0]-r,o[1]-r,o[2]+r,o[3]+r],i=new Set;for(let a of e){if(i.has(a.id))continue;if(t==="overlap"?_2(a,n):t==="inside"?bh(a,n):bh(a,n,!0)){if(i.add(a.id),a.boundElements)for(let s of a.boundElements)i.add(s.id);M7(a)&&a.containerId&&i.add(a.containerId),I7(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 yge,isShallowEqual as _7}from"@excalidraw/common";var D7=function(){let e=null,o=null,t=null,r=(i,a,l,s)=>{if(t!==void 0&&a===o&&i===e&&l.editingGroupId===t?.editingGroupId)return t;let 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:xh({...l.selectedElementIds,...c},s)},t},n=(i,a,l,s)=>{let d=s?s.scene.getSelectedElements({selectedElementIds:i.selectedElementIds,elements:a}):Eh(a,i);return d.length?r(d,a,i,l):{selectedGroupIds:{},editingGroupId:null,selectedElementIds:xh(i.selectedElementIds,l)}};return n.clearCache=()=>{o=null,e=null,t=null},n}();var kge=function(){let e=null,o=null,t=null,r=(n,i)=>(t!=null&&n===e&&i.selectedElementIds===o||(t=n.some(a=>i.selectedElementIds[a.id]),e=n,o=i.selectedElementIds),t);return r.clearCache=()=>{e=null,o=null,t=null},r}(),Eh=(e,o,t)=>{let r=new Set,n=[];for(let i of e.values()){if(o.selectedElementIds[i.id]){n.push(i),r.add(i.id);continue}if(t?.includeBoundTextElement&&fi(i)&&o.selectedElementIds[i?.containerId]){n.push(i),r.add(i.id);continue}}if(t?.includeElementsInFrames){let i=[];return n.forEach(a=>{Fc(a)&&N2(e,a.id).forEach(l=>!r.has(l.id)&&i.push(l)),i.push(a)}),i}return n};var xh=(e,o)=>_7(o.selectedElementIds,e)?o.selectedElementIds:e;var N2=(e,o)=>{let t=[];for(let r of e.values())r.frameId===o&&t.push(r);return t};var B7=typeof document<"u"?document.createElement("img"):{src:""};B7.src=`data:${F2.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 F7=typeof document<"u"?document.createElement("img"):{src:""};F7.src=`data:${F2.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 O2=new WeakMap;var O7=new WeakMap([]);function z2(e){let o=z7(e),t=new Path2D(o);return O7.set(e,t),t}function z7(e){let o=e.simulatePressure?e.points:e.points.length?e.points.map(([r,n],i)=>[r,n,e.pressures[i]]):[[0,0,.5]],t={simulatePressure:e.simulatePressure,size:e.strokeWidth*4.25,thinning:.6,smoothing:.5,streamline:.5,easing:r=>Math.sin(r*Math.PI/2),last:!!e.lastCommittedPoint};return G7(N7(o,t))}function B2(e,o){return[(e[0]+o[0])/2,(e[1]+o[1])/2]}var H7=/(\s?[A-Z]?,?-?[0-9]*\.[0-9]{0,2})(([0-9]|e|-)*)/g;function G7(e){if(!e.length)return"";let o=e.length-1;return e.reduce((t,r,n,i)=>(n===o?t.push(r,B2(r,i[0]),"L",i[0],"Z"):t.push(r,B2(r,i[n+1])),t),["M",e[0],"Q"]).join(" ").replace(H7,"$1")}var H2=e=>e==="rectangle"||e==="iframe"||e==="embeddable"||e==="line"||e==="diamond"||e==="image";var st=class st{};I(st,"rg",new K7),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 r=t?.isExporting?void 0:st.get(o);if(r!==void 0)return r;O2.delete(o);let n=j7(o,st.rg,t||{isExporting:!1,canvasBackgroundColor:X7.white,embedsValidationStatus:null});return st.cache.set(o,n),n});var xi=st,Z7=e=>[8,8+e],W2=e=>[1.5,6+e];function $7(e){let o=e.roughness,t=Math.max(e.width,e.height),r=Math.min(e.width,e.height);return r>=20&&t>=50||r>=15&&e.roundness&&H2(e.type)||pr(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"?Z7(e.strokeWidth):e.strokeStyle==="dotted"?W2(e.strokeWidth):void 0,disableMultiStroke:e.strokeStyle!=="solid",strokeWidth:e.strokeStyle!=="solid"?e.strokeWidth+.5:e.strokeWidth,fillWeight:e.strokeWidth/2,hachureGap:e.strokeWidth*4,roughness:$7(e),stroke:e.strokeColor,preserveVertices:o||e.roughness<W7.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 Bc(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}`)}},U2=(e,o,t)=>lh(e)&&(o||y2(e)&&t?.get(e.id)!==!0)&&Wa(e.backgroundColor)&&Wa(e.strokeColor)?{...e,roughness:0,backgroundColor:"#d3d3d3",fillStyle:"solid"}:w2(e)?{...e,strokeColor:Wa(e.strokeColor)?"#000000":e.strokeColor,backgroundColor:Wa(e.backgroundColor)?"#f4f4f6":e.backgroundColor}:e,Y2=(e,o,t,r,n,i,a)=>{let l=fh(e,o,t,r);if(l===null)return[];let s=(d,m)=>{if(d===null)return[];let[,,c,p,u,f]=d;return[n.line(c,p,u,f,m)]};switch(r){case"dot":case"circle":case"circle_outline":{let[d,m,c]=l;return delete i.strokeLineDash,[n.circle(d,m,c,{...i,fill:r==="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,[n.polygon([[d,m],[c,p],[u,f],[d,m]],{...i,fill:r==="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,[n.polygon([[d,m],[c,p],[u,f],[b,x],[d,m]],{...i,fill:r==="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=W2(e.strokeWidth-1);i.strokeLineDash=[b[0],b[1]-1]}else delete i.strokeLineDash;return i.roughness=Math.min(1,i.roughness||0),[n.line(c,p,d,m,i),n.line(u,f,d,m,i),...r==="crowfoot_one_or_many"?s(fh(e,o,t,"crowfoot_one"),i):[]]}}};var j7=(e,o,{isExporting:t,canvasBackgroundColor:r,embedsValidationStatus:n})=>{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(U2(e,t,n),!0))}else i=o.rectangle(0,0,e.width,e.height,Oo(U2(e,t,n),!1));return i}case"diamond":{let i,[a,l,s,d,m,c,p,u]=ah(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:[Y7(0,0)];if(Ga(e)?l.every(s=>Math.abs(s[0])<=1e6&&Math.abs(s[1])<=1e6)?i=[o.path(q7(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=Y2(e,i,"start",s,o,a,r);i.push(...m)}if(d!==null){let m=Y2(e,i,"end",d,o,a,r);i.push(...m)}}return i}case"freedraw":{let i;if(z2(e),Bc(e.points)){let a=U7(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 V7(e,`generateElementShape(): Unimplemented type ${e?.type}`),null}},q7=(e,o)=>{let t=[];for(let n=1;n<e.length-1;n+=1){let i=e[n-1],a=e[n+1],l=e[n],s=zc(l,i),d=zc(a,l),m=Math.min(o,G2(e[n],a)/2,G2(e[n],i)/2);s?i[0]<l[0]?t.push([e[n][0]-m,e[n][1]]):t.push([e[n][0]+m,e[n][1]]):i[1]<l[1]?t.push([e[n][0],e[n][1]-m]):t.push([e[n][0],e[n][1]+m]),t.push(e[n]),d?a[0]<l[0]?t.push([e[n][0]-m,e[n][1]]):t.push([e[n][0]+m,e[n][1]]):a[1]<l[1]?t.push([e[n][0],e[n][1]-m]):t.push([e[n][0],e[n][1]+m])}let r=[`M ${e[0][0]} ${e[0][1]}`];for(let n=0;n<t.length;n+=3)r.push(`L ${t[n][0]} ${t[n][1]}`),r.push(`Q ${t[n+1][0]} ${t[n+1][1]}, ${t[n+2][0]} ${t[n+2][1]}`);return r.push(`L ${e[e.length-1][0]} ${e[e.length-1][1]}`),r.join(" ")};var V2=(e,o,t=!1)=>{let r=!1;for(let n in o){let i=o[n];if(typeof i<"u"){if(e[n]===i&&(typeof i!="object"||i===null))continue;r=!0}}return!r&&!t?e:{...e,...o,version:o.version??e.version+1,versionNonce:o.versionNonce??J7(),updated:Q7()}};import{jsx as K2}from"react/jsx-runtime";var wi=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,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.selectedLinearElement?.isEditing&&n.length===1&&tD(n[0])&&!eD(n[0]))},perform(e,o,t,r){let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!0})[0];yh(n,"No selected element found"),yh(o.selectedLinearElement,"No selected linear element found"),yh(n.id===o.selectedLinearElement.elementId,"Selected element ID and linear editor elementId does not match");let i={...o.selectedLinearElement,isEditing:!o.selectedLinearElement.isEditing};return{appState:{...o,selectedLinearElement:i},captureUpdate:X2.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 K2(K,{type:"button",icon:ib,title:n,"aria-label":n,onClick:()=>o(null)})}}),w1e=B({name:"togglePolygon",category:ke.elements,icon:Em,keywords:["loop"],label:(e,o,t)=>!t.scene.getSelectedElements({selectedElementIds:o.selectedElementIds}).some(i=>!yi(i)||!i.polygon)?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon",trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements({selectedElementIds:o.selectedElementIds});return n.length>0&&n.every(i=>yi(i)&&i.points.length>=4)},perform(e,o,t,r){let n=r.scene.getSelectedElements(o);if(n.some(s=>!yi(s)))return!1;let i=n,a=i.some(s=>!s.polygon),l=oD(i);return{elements:e.map(s=>!l.has(s.id)||!yi(s)?s:V2(s,{backgroundColor:a?s.backgroundColor:"transparent",...rD(s,a)})),appState:o,captureUpdate:X2.IMMEDIATELY}},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=t.scene.getSelectedElements({selectedElementIds:e.selectedElementIds});if(r.length===0||r.some(a=>!yi(a)||!a.polygon||a.points.length<3))return null;let n=r.every(a=>yi(a)&&a.polygon),i=g(n?"labels.polygon.breakPolygon":"labels.polygon.convertToPolygon");return K2(An,{icon:Em,title:i,"aria-label":i,active:n,onClick:()=>o(null),style:{marginLeft:"auto"}})}});import{KEYS as Z2,CANVAS_SEARCH_TAB as $2,CLASSES as nD,DEFAULT_SIDEBAR as j2}from"@excalidraw/common";import{CaptureUpdateAction as iD}from"@excalidraw/element";var za=B({name:"searchMenu",icon:Lt,keywords:["search","find"],label:"search.title",viewMode:!0,trackEvent:{category:"search_menu",action:"toggle",predicate:e=>e.gridModeEnabled},perform(e,o,t,r){if(o.openDialog)return!1;if(o.openSidebar?.name===j2.name&&o.openSidebar.tab===$2){let n=r.excalidrawContainerValue.container?.querySelector(`.${nD.SEARCH_MENU_INPUT_WRAPPER} input`);return n?.focus(),n?.select(),!1}return{appState:{...o,openSidebar:{name:j2.name,tab:$2},openDialog:null},captureUpdate:iD.EVENTUALLY}},checked:e=>e.gridModeEnabled,predicate:(e,o,t)=>t.gridModeEnabled===void 0,keyTest:e=>e[Z2.CTRL_OR_CMD]&&e.key===Z2.F});import{isImageElement as aD}from"@excalidraw/element";import{CaptureUpdateAction as lD}from"@excalidraw/element";import{jsx as sD}from"react/jsx-runtime";var wh=B({name:"cropEditor",label:"helpDialog.cropStart",icon:Gm,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:lD.IMMEDIATELY}},predicate:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o);return!!(!o.croppingElementId&&n.length===1&&aD(n[0]))},PanelComponent:({appState:e,updateData:o,app:t})=>{let r=g("helpDialog.cropStart");return sD(K,{type:"button",icon:Gm,title:r,"aria-label":r,onClick:()=>o(null)})}});import{getNonDeletedElements as cD}from"@excalidraw/element";import{mutateElement as dD}from"@excalidraw/element";import{newFrameElement as mD}from"@excalidraw/element";import{isFrameLikeElement as Yc}from"@excalidraw/element";import{addElementsToFrame as pD,removeAllElementsFromFrame as uD}from"@excalidraw/element";import{getFrameChildren as hD}from"@excalidraw/element";import{KEYS as q2,updateActiveTool as J2}from"@excalidraw/common";import{getElementsInGroup as gD}from"@excalidraw/element";import{getCommonBounds as fD}from"@excalidraw/element";import{CaptureUpdateAction as en}from"@excalidraw/element";var Q2=(e,o)=>{let t=o.scene.getSelectedElements(e);return t.length===1&&Yc(t[0])},ew=B({name:"selectAllElementsInFrame",label:"labels.selectAllElementsInFrame",trackEvent:{category:"canvas"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;if(Yc(n)){let i=hD(cD(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:en.IMMEDIATELY}}return{elements:e,appState:o,captureUpdate:en.EVENTUALLY}},predicate:(e,o,t,r)=>Q2(o,r)}),tw=B({name:"removeAllElementsFromFrame",label:"labels.removeAllElementsFromFrame",trackEvent:{category:"history"},perform:(e,o,t,r)=>{let n=r.scene.getSelectedElements(o).at(0)||null;return Yc(n)?{elements:uD(e,n),appState:{...o,selectedElementIds:{[n.id]:!0}},captureUpdate:en.IMMEDIATELY}:{elements:e,appState:o,captureUpdate:en.EVENTUALLY}},predicate:(e,o,t,r)=>Q2(o,r)}),P0e=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:en.EVENTUALLY}),checked:e=>e.frameRendering.enabled}),A0e=B({name:"setFrameAsActiveTool",label:"toolBar.frame",trackEvent:{category:"toolbar"},icon:zr,viewMode:!1,perform:(e,o,t,r)=>{let n=J2(o,{type:"frame"});return At(r.interactiveCanvas,{...o,activeTool:n}),{elements:e,appState:{...o,activeTool:J2(o,{type:"frame"})},captureUpdate:en.EVENTUALLY}},keyTest:e=>!e[q2.CTRL_OR_CMD]&&!e.shiftKey&&!e.altKey&&e.key.toLocaleLowerCase()===q2.F}),ow=B({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=>Yc(i))},perform:(e,o,t,r)=>{let n=j(e,o),i=r.scene.getNonDeletedElementsMap(),[a,l,s,d]=fD(n,i),m=16,c=mD({x:a-m,y:l-m,width:s-a+m*2,height:d-l+m*2});if(o.editingGroupId){let u=gD(n,o.editingGroupId);for(let f of u){let b=f.groupIds.indexOf(o.editingGroupId);dD(f,i,{groupIds:f.groupIds.slice(0,b)})}}return{elements:pD([...r.scene.getElementsIncludingDeleted(),c],n,c,o),appState:{selectedElementIds:{[c.id]:!0}},captureUpdate:en.IMMEDIATELY}}});import{isWindows as TD,KEYS as Xa,matchKey as Ih,arrayToMap as rw}from"@excalidraw/common";import{CaptureUpdateAction as Th}from"@excalidraw/element";import{orderByFractionalIndex as ID}from"@excalidraw/element";import{Emitter as bD}from"@excalidraw/common";import{CaptureUpdateAction as xD,StoreChange as ED,StoreDelta as yD}from"@excalidraw/element";var vi=class extends yD{applyTo(o,t,r){let[n,i]=this.elements.applyTo(o,r.elements,{excludedProperties:new Set(["version","versionNonce"])}),[a,l]=this.appState.applyTo(t,n);return[n,a,i||l]}static calculate(o,t){return super.calculate(o,t)}static inverse(o){return super.inverse(o)}static applyLatestChanges(o,t,r,n){return super.applyLatestChanges(o,t,r,n)}},tn=class{constructor(o=!0,t=!0){this.isUndoStackEmpty=o;this.isRedoStackEmpty=t}},Va=class e{constructor(o){this.store=o;I(this,"onHistoryChangedEmitter",new bD);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 vi)return;let t=vi.inverse(o);this.undoStack.push(t),t.elements.isEmpty()||(this.redoStack.length=0),this.onHistoryChangedEmitter.trigger(new tn(this.isUndoStackEmpty,this.isRedoStackEmpty))}undo(o,t){return this.perform(o,t,()=>e.pop(this.undoStack),r=>e.push(this.redoStack,r))}redo(o,t){return this.perform(o,t,()=>e.pop(this.redoStack),r=>e.push(this.undoStack,r))}perform(o,t,r,n){try{let i=r();if(i===null)return;let a=xD.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=ED.create(l,p),f=vi.applyLatestChanges(i,c,s);f.isEmpty()||(this.store.scheduleMicroAction({action:a,change:u,delta:f}),i=f),l=p}finally{n(i)}if(m)break;i=r()}return[s,d]}finally{this.onHistoryChangedEmitter.trigger(new tn(this.isUndoStackEmpty,this.isRedoStackEmpty))}}static pop(o){if(!o.length)return null;let t=o.pop();return t!==void 0?t:null}static push(o,t){let r=vi.inverse(t);return o.push(r)}};import{useEffect as wD,useState as vD}from"react";var vh=(e,o)=>{let[t,r]=vD(o);return wD(()=>{let n=e.on(i=>{r(i)});return()=>{n()}},[e]),t};import{jsx as lw}from"react/jsx-runtime";var nw=(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:Th.EVENTUALLY};let[n,i]=r,a=ID(Array.from(n.values()));return{appState:i,elements:a,captureUpdate:Th.NEVER}}return{captureUpdate:Th.EVENTUALLY}},iw=e=>({name:"undo",label:"buttons.undo",icon:Im,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>nw(n,t,()=>e.undo(rw(o),t)),keyTest:o=>o[Xa.CTRL_OR_CMD]&&Ih(o,Xa.Z)&&!o.shiftKey,PanelComponent:({updateData:o,data:t})=>{let{isUndoStackEmpty:r}=vh(e.onHistoryChangedEmitter,new tn(e.isUndoStackEmpty,e.isRedoStackEmpty));return lw(K,{type:"button",icon:Im,"aria-label":g("buttons.undo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-undo"})}}),aw=e=>({name:"redo",label:"buttons.redo",icon:Cm,trackEvent:{category:"history"},viewMode:!1,perform:(o,t,r,n)=>nw(n,t,()=>e.redo(rw(o),t)),keyTest:o=>o[Xa.CTRL_OR_CMD]&&o.shiftKey&&Ih(o,Xa.Z)||TD&&o.ctrlKey&&!o.shiftKey&&Ih(o,Xa.Y),PanelComponent:({updateData:o,data:t})=>{let{isRedoStackEmpty:r}=vh(e.onHistoryChangedEmitter,new tn(e.isUndoStackEmpty,e.isRedoStackEmpty));return lw(K,{type:"button",icon:Cm,"aria-label":g("buttons.redo"),onClick:o,size:t?.size||"medium",disabled:r,"data-testid":"button-redo"})}});import{getFontString as CD}from"@excalidraw/common";import{newElementWith as SD}from"@excalidraw/element";import{measureText as kD}from"@excalidraw/element";import{isTextElement as sw}from"@excalidraw/element";import{CaptureUpdateAction as MD}from"@excalidraw/element";var cw=B({name:"autoResize",label:"labels.autoResize",icon:null,trackEvent:{category:"element"},predicate:(e,o,t,r)=>{let n=j(e,o);return n.length===1&&sw(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&&sw(i)){let a=kD(i.originalText,CD(i),i.lineHeight);return SD(i,{autoResize:!0,width:a.width,height:a.height,text:i.originalText})}return i}),captureUpdate:MD.IMMEDIATELY}}});import{CODES as LD,KEYS as PD}from"@excalidraw/common";import{CaptureUpdateAction as AD}from"@excalidraw/element";var Ch=B({name:"viewMode",label:"labels.viewMode",icon:kn,viewMode:!0,trackEvent:{category:"canvas",predicate:e=>!e.viewModeEnabled},perform(e,o){return{appState:{...o,viewModeEnabled:!this.checked(o)},captureUpdate:AD.EVENTUALLY}},checked:e=>e.viewModeEnabled,predicate:(e,o,t)=>typeof t.viewModeEnabled>"u",keyTest:e=>!e[PD.CTRL_OR_CMD]&&e.altKey&&e.code===LD.R});import{isPromiseLike as DD}from"@excalidraw/common";import{jsx as _D}from"react/jsx-runtime";var Sh=(e,o,t,r,n,i)=>{if(e.trackEvent)try{typeof e.trackEvent=="object"&&(!e.trackEvent.predicate||e.trackEvent.predicate(t,r,i))&&re(e.trackEvent.category,e.trackEvent.action||e.name,`${o} (${n.device.editor.isMobile?"mobile":"desktop"})`)}catch(a){console.error("error while logging action:",a)}},Wc=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=d=>{Sh(n,"ui",l,a,this.app,d),this.updater(n.perform(this.getElementsIncludingDeleted(),this.getAppState(),d,this.app))};return _D(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(),r=this.getAppState();return!o.predicate||o.predicate(t,r,this.app.props,this.app)});this.updater=i=>{if(DD(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,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(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 Sh(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();Sh(o,t,i,n,this.app,r),this.updater(o.perform(n,i,r,this.app))}};var Vc=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 kh=e=>{let o=Array.from(e.values());return{x:dw(o,t=>t.x)/o.length,y:dw(o,t=>t.y)/o.length}},Mh=([e,o])=>Math.hypot(e.x-o.x,e.y-o.y),dw=(e,o)=>e.reduce((t,r)=>t+o(r),0);import{pointFrom as H,pointRotateRads as ur,rangeInclusive as Ut,rangeIntersection as Xc,rangesOverlap as Kc}from"@excalidraw/math";import{TOOL_TYPE as on,KEYS as mw}from"@excalidraw/common";import{getCommonBounds as Lh,getDraggedElementsBounds as Ph,getElementAbsoluteCoords as RD}from"@excalidraw/element";import{isBoundToContainer as gw}from"@excalidraw/element";import{getMaximumGroups as fw}from"@excalidraw/element";import{getSelectedElements as ND,getVisibleAndNonSelectedElements as bw}from"@excalidraw/element";var BD=8,pw=99999,Zc=e=>BD/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 Yt=gt,hr=e=>e.props.gridModeEnabled??e.state.gridModeEnabled,Ho=({event:e,app:o,selectedElements:t})=>e?o.state.activeTool.type!=="lasso"&&(o.state.objectsSnapModeEnabled&&!e[mw.CTRL_OR_CMD]||!o.state.objectsSnapModeEnabled&&e[mw.CTRL_OR_CMD]&&!hr(o)):t.length===1&&t[0].type==="arrow"?!1:o.state.objectsSnapModeEnabled,FD=(e,o,t=.01)=>Math.abs(e-o)<=t,Ka=(e,o,{omitCenter:t,boundingBoxCorners:r,dragOffset:n}={omitCenter:!1,boundingBoxCorners:!1})=>{let i=[];if(e.length===1){let a=e[0],[l,s,d,m,c,p]=RD(a,o);n&&(l+=n.x,d+=n.x,c+=n.x,s+=n.y,m+=n.y,p+=n.y);let u=(d-l)/2,f=(m-s)/2;if((a.type==="diamond"||a.type==="ellipse")&&!r){let b=ur(H(l,s+f),H(c,p),a.angle),x=ur(H(l+u,s),H(c,p),a.angle),w=ur(H(d,s+f),H(c,p),a.angle),E=ur(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=ur(H(l,s),H(c,p),a.angle),x=ur(H(d,s),H(c,p),a.angle),w=ur(H(l,m),H(c,p),a.angle),E=ur(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]=Ph(e,n??{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])))},xw=(e,o,t,r)=>bw(e,o,t,r),Ew=(e,o,t,r)=>{let n=xw(e,o,t,r),i=fw(n,r).filter(c=>!(c.length===1&&gw(c[0]))).map(c=>Lh(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>pw)break e;let f=a[u],[,b,x,w]=p,[E,y,,v]=f;x<E&&Kc(Ut(b,w),Ut(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:Xc(Ut(b,w),Ut(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>pw)break e;let f=d[u],[b,,x,w]=p,[E,y,v]=f;w<y&&Kc(Ut(b,x),Ut(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:Xc(Ut(b,x),Ut(E,v))})}}return{horizontalGaps:l,verticalGaps:m}},uw=(e,o,t,r,n,i,a)=>{if(!Ho({app:t,event:r,selectedElements:e}))return[];if(e.length===0)return[];let l=Yt.getVisibleGaps();if(l){let{horizontalGaps:s,verticalGaps:d}=l,[m,c,p,u]=Ph(e,o).map(x=>Le(x)),f=(m+p)/2,b=(c+u)/2;for(let x of s){if(!Kc(Ut(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&&(n.length=0),a.x=Math.abs(E);let P={type:"gap",direction:"center_horizontal",gap:x,offset:E};n.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&&(n.length=0),a.x=Math.abs(S);let P={type:"gap",direction:"side_right",gap:x,offset:S};n.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&&(n.length=0),a.x=Math.abs(A);let P={type:"gap",direction:"side_left",gap:x,offset:A};n.push(P);continue}}for(let x of d){if(!Kc(Ut(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}}}},yw=(e,o,t,r)=>{let n=xw(e,o,t,r);return fw(n,r).filter(i=>!(i.length===1&&gw(i[0]))).flatMap(i=>Ka(i,r))},Ti=(e,o,t,r,n,i,a)=>{if(!Ho({app:t,event:r,selectedElements:e})||e.length===0&&o.length===0)return[];let l=Yt.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&&(n.length=0),n.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))}},ww=(e,o,t,r,n)=>{let i=t.state,a=ND(e,i);if(!Ho({app:t,event:r,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=Zc(i.zoom.value),m={x:d,y:d},c=Ka(a,n,{dragOffset:o});Ti(a,c,t,r,l,s,m),uw(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:Le(o.x+p.x),y:Le(o.y+p.y)};Ti(a,Ka(a,n,{dragOffset:u}),t,r,l,s,m),uw(a,u,t,r,l,s,m);let f=Ah(l,s),b=zD(a,u,[...l,...s].filter(x=>x.type==="gap"));return{snapOffset:p,snapLines:[...f,...b]}},Le=e=>Math.round(e*10**6)/10**6,hw=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())},Ah=(e,o)=>{let t={},r={};if(e.length>0){for(let n of e)if(n.type==="point"){let i=Le(n.points[0][0]);t[i]||(t[i]=[]),t[i].push(...n.points.map(a=>H(Le(a[0]),Le(a[1]))))}}if(o.length>0){for(let n of o)if(n.type==="point"){let i=Le(n.points[0][1]);r[i]||(r[i]=[]),r[i].push(...n.points.map(a=>H(Le(a[0]),Le(a[1]))))}}return Object.entries(t).map(([n,i])=>({type:"points",points:hw(i.map(a=>H(Number(n),a[1])).sort((a,l)=>a[1]-l[1]))})).concat(Object.entries(r).map(([n,i])=>({type:"points",points:hw(i.map(a=>H(a[0],Number(n))).sort((a,l)=>a[0]-l[0]))})))},OD=e=>{let o=new Map;for(let t of e){let r=t.points.flat().map(n=>[Le(n)]).join(",");o.has(r)||o.set(r,t)}return Array.from(o.values())},zD=(e,o,t)=>{let[r,n,i,a]=Ph(e,o),l=[];for(let s of t){let[d,m,c,p]=s.gap.startBounds,[u,f,b,x]=s.gap.endBounds,w=Xc(Ut(n,a),s.gap.overlap),E=Xc(Ut(r,i),s.gap.overlap);switch(s.direction){case"center_horizontal":{if(w){let y=(w[0]+w[1])/2;l.push({type:"gap",direction:"horizontal",points:[H(s.gap.startSide[0][0],y),H(r,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,n)]},{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(r,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,n)]})}break}}}return OD(l.map(s=>({...s,points:s.points.map(d=>H(Le(d[0]),Le(d[1])))})))},Dh=(e,o,t,r,n,i)=>{if(!Ho({event:r,selectedElements:e,app:t})||e.length===0||e.length===1&&!FD(e[0].angle,0))return{snapOffset:{x:0,y:0},snapLines:[]};let[a,l,s,d]=Lh(o);i&&(i.includes("e")?s+=n.x:i.includes("w")&&(a+=n.x),i.includes("n")?l+=n.y:i.includes("s")&&(d+=n.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=Zc(t.state.zoom.value),p={x:c,y:c},u=[],f=[];Ti(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,w,E,y]=Lh(e).map(S=>Le(S)),v=[H(x,w),H(x,y),H(E,w),H(E,y)];Ti(e,v,t,r,u,f,p);let C=Ah(u,f);return{snapOffset:b,snapLines:C}},vw=(e,o,t,r,n,i)=>{if(!Ho({event:t,selectedElements:[e],app:o}))return{snapOffset:{x:0,y:0},snapLines:[]};let a=[H(r.x+n.x,r.y+n.y)],l=Zc(o.state.zoom.value),s={x:l,y:l},d=[],m=[];Ti([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});Ti([e],p,o,t,d,m,s);let u=Ah(d,m);return{snapOffset:c,snapLines:u}},Tw=(e,o,t,r,n)=>{if(!Ho({event:r,selectedElements:[],app:o}))return{originOffset:{x:0,y:0},snapLines:[]};let i=bw(e,[],o.state,n),a=Zc(o.state.zoom.value),l={x:a,y:a},s=[],d=[];for(let m of i){let c=Ka([m],n);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]}},Iw=e=>e===on.rectangle||e===on.ellipse||e===on.diamond||e===on.frame||e===on.magicframe||e===on.image||e===on.text;import{pointFrom as $c}from"@excalidraw/math";import{DEFAULT_FONT_FAMILY as HD,DEFAULT_FONT_SIZE as GD,TEXT_ALIGN as UD,VERTICAL_ALIGN as YD,getSizeFromPoints as WD,randomId as VD,arrayToMap as XD,assertNever as _h,cloneJSON as kw,getFontString as KD,isDevEnv as ZD,toBrandedType as $D,getLineHeight as jD}from"@excalidraw/common";import{bindLinearElement as Cw}from"@excalidraw/element";import{newArrowElement as qD,newElement as Rh,newFrameElement as JD,newImageElement as QD,newLinearElement as e_,newMagicFrameElement as t_,newTextElement as qc}from"@excalidraw/element";import{measureText as o_,normalizeText as r_}from"@excalidraw/element";import{isArrowElement as n_}from"@excalidraw/element";import{syncInvalidIndices as i_}from"@excalidraw/element";import{redrawTextBoundingBox as a_}from"@excalidraw/element";import{LinearElementEditor as l_}from"@excalidraw/element";import{getCommonBounds as s_}from"@excalidraw/element";import{Scene as c_}from"@excalidraw/element";var jc={width:100,height:0},gr=100,d_=(e,o,t)=>{let r=qc({x:0,y:0,textAlign:UD.CENTER,verticalAlign:YD.MIDDLE,...o,containerId:e.id,strokeColor:o.strokeColor||e.strokeColor});return Object.assign(e,{boundElements:(e.boundElements||[]).concat({type:"text",id:r.id})}),a_(r,e,t),[e,r]},Sw=(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??gr,c=o?.height??gr,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-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=qc({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=Rh({x:u,y:f,width:m,height:c,...p,...o,type:b});break}default:_h(e,`Unhandled element start type "${o.type}"`,!0)}Cw(e,i,"start",n)}}if(t){let m=t?.height??gr,c=t?.width??gr,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=qc({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=Rh({x:u,y:f,width:c,height:m,...p,...t,type:b});break}default:_h(e,`Unhandled element end type "${b}"`,!0)}Cw(e,a,"end",n)}}if(e.points.length<2)return{linearElement:e,startBoundElement:i,endBoundElement:a};let l=e.points.length-1,s=.5,d=kw(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,l_.getNormalizeElementPointsAndCoords({...e,points:d})),{linearElement:e,startBoundElement:i,endBoundElement:a}},Nh=class{constructor(){I(this,"excalidrawElements",new Map);I(this,"add",o=>{o&&this.excalidrawElements.set(o.id,o)});I(this,"getElements",()=>i_(Array.from(this.excalidrawElements.values())));I(this,"getElementsMap",()=>$D(XD(this.getElements())));I(this,"getElement",o=>this.excalidrawElements.get(o))}},Ii=(e,o)=>{if(!e)return[];let t=kw(e),r=new Nh,n=new Map,i=new Map;for(let s of t){let d,m=s.id;switch(o?.regenerateIds!==!1&&Object.assign(s,{id:VD()}),s.type){case"rectangle":case"ellipse":case"diamond":{let p=s?.label?.text&&s.width===void 0?0:s?.width||gr,u=s?.label?.text&&s.height===void 0?0:s?.height||gr;d=Rh({...s,width:p,height:u});break}case"line":{let p=s.width||jc.width,u=s.height||jc.height;d=e_({width:p,height:u,points:[$c(0,0),$c(p,u)],...s});break}case"arrow":{let p=s.width||jc.width,u=s.height||jc.height;d=qD({width:p,height:u,endArrowhead:"arrow",points:[$c(0,0),$c(p,u)],...s,type:"arrow"}),Object.assign(d,WD(d.points));break}case"text":{let p=s?.fontFamily||HD,u=s?.fontSize||GD,f=s?.lineHeight||jD(p),b=s.text??"",x=r_(b),w=o_(x,KD({fontFamily:p,fontSize:u}),f);d=qc({width:w.width,height:w.height,fontFamily:p,fontSize:u,...s});break}case"image":{d=QD({width:s?.width||gr,height:s?.height||gr,...s});break}case"frame":{d=JD({x:0,y:0,...s});break}case"magicframe":{d=t_({x:0,y:0,...s});break}case"freedraw":case"iframe":case"embeddable":{d=s;break}default:d=s,_h(s,`Unhandled element type "${s.type}"`,!0)}r.getElement(d.id)?console.error(`Duplicate id found for ${d.id}`):(r.add(d),n.set(d.id,s),m&&i.set(m,d.id))}let a=r.getElementsMap(),l=new c_(a);for(let[s,d]of n){let m=r.getElement(s);switch(d.type){case"rectangle":case"ellipse":case"diamond":case"arrow":{if(d.label?.text){let[c,p]=d_(m,d?.label,l);if(r.add(c),r.add(p),n_(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}=Sw(c,u,f,r,l);c=b,r.add(b),r.add(x),r.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}=Sw(m,c,p,r,l);r.add(u),r.add(f),r.add(b);break}}break}}}for(let[s,d]of n){if(d.type!=="frame"&&d.type!=="magicframe")continue;let m=r.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=r.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=r.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]=s_(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}),ZD()&&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 r.getElements()};import{isElementInViewport as H_}from"@excalidraw/element";import{memoize as G_,toBrandedType as U_}from"@excalidraw/common";import{pointFrom as x_,pointsEqual as E_}from"@excalidraw/math";import Qc from"open-color";import{arrayToMap as y_,DEFAULT_TRANSFORM_HANDLE_SPACING as Yh,FRAME_STYLE as Rw,invariant as Nw,THEME as w_,throttleRAF as v_}from"@excalidraw/common";import{FIXED_BINDING_DISTANCE as Fh,maxBindingGap as Gw}from"@excalidraw/element";import{LinearElementEditor as fr}from"@excalidraw/element";import{getOmitSidesForDevice as Oh,getTransformHandles as T_,getTransformHandlesFromCoords as I_,shouldShowBoundingBox as C_}from"@excalidraw/element";import{isElbowArrow as Za,isFrameLikeElement as Bw,isImageElement as Fw,isLinearElement as S_,isLineElement as k_,isTextElement as Ow}from"@excalidraw/element";import{renderSelectionElement as M_}from"@excalidraw/element";import{getElementsInGroup as Gh,getSelectedGroupIds as L_,isSelectedViaGroup as P_,selectGroupsFromGivenElements as A_}from"@excalidraw/element";import{getCommonBounds as Uh,getElementAbsoluteCoords as $a}from"@excalidraw/element";import{pointFrom as ct}from"@excalidraw/math";import{THEME as m_}from"@excalidraw/common";var p_="#ff6b6b",u_="#ff0000",Mw=1,Lw=2,Pw=(e,o)=>{if(!o.snapLines.length)return;let t=o.theme===m_.LIGHT||o.zenModeEnabled?p_:u_,r=(o.zenModeEnabled?Mw*1.5:Mw)/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,g_(n,e,o)):n.type==="gap"?(e.lineWidth=r,e.strokeStyle=t,f_(n.points[0],n.points[1],n.direction,o,e)):n.type==="points"&&(e.lineWidth=r,e.strokeStyle=t,h_(n,e,o));e.restore()},h_=(e,o,t)=>{if(!t.zenModeEnabled){let r=e.points[0],n=e.points[e.points.length-1];Wt(r,n,o)}for(let r of e.points)Aw(r,t,o)},g_=(e,o,t)=>{Aw(e.points[0],t,o),t.zenModeEnabled||Wt(e.points[0],e.points[1],o)},Aw=([e,o],t,r)=>{r.save();let n=(t.zenModeEnabled?Lw*1.5:Lw)/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()},Wt=(e,o,t)=>{t.beginPath(),t.lineTo(e[0],e[1]),t.lineTo(o[0],o[1]),t.stroke()},f_=(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||Wt(ct(e[0],e[1]-i),ct(e[0],e[1]+i),n),Wt(ct(s[0]-l,s[1]-a),ct(s[0]-l,s[1]+a),n),Wt(ct(s[0]+l,s[1]-a),ct(s[0]+l,s[1]+a),n),r.zenModeEnabled||(Wt(ct(o[0],o[1]-i),ct(o[0],o[1]+i),n),Wt(e,o,n))}else{let s=[e[0],(e[1]+o[1])/2];r.zenModeEnabled||Wt(ct(e[0]-i,e[1]),ct(e[0]+i,e[1]),n),Wt(ct(s[0]-a,s[1]-l),ct(s[0]+a,s[1]-l),n),Wt(ct(s[0]-a,s[1]+l),ct(s[0]+a,s[1]+l),n),r.zenModeEnabled||(Wt(ct(o[0]-i,o[1]),ct(o[0]+i,o[1]),n),Wt(e,o,n))}};import{getGlobalCSSVariable as Jc}from"@excalidraw/common";import{getCommonBounds as b_}from"@excalidraw/element";var ao=4,Ct=6,Dw="rgba(0,0,0,0.3)",_w=(e,o,t,r)=>{if(!e.size)return{horizontal:null,vertical:null};let[n,i,a,l]=b_(e),s=o/r.zoom.value,d=t/r.zoom.value,m={top:parseInt(Jc("sat"))||0,bottom:parseInt(Jc("sab"))||0,left:parseInt(Jc("sal"))||0,right:parseInt(Jc("sar"))||0},c=Mo().rtl,p=-r.scrollX+m.left,u=-r.scrollY+m.top,f=p+s-m.right,b=u+d-m.bottom,x=Math.min(n,p),w=Math.min(i,u),E=Math.max(a,f),y=Math.max(l,b),v=a-n,C=l-i,S=E-x,L=y-w,k=Math.max(ao*2,m.left+m.right)+Ct*2,A=o*(s/S)-k,P=Math.max(ao*2,m.top+m.bottom)+Ct*2,N=t*(d/L)-P,O=S>v?S*r.zoom.value/(A+k):o/(A+k),U=L>C?L*r.zoom.value/(N+P):t/(N+P);return{horizontal:p===x&&f===E?null:{x:Math.max(m.left,ao)+Ct+(p-x)/S*o,y:t-Ct-Math.max(ao,m.bottom),width:A,height:Ct,deltaMultiplier:O},vertical:u===w&&b===y?null:{x:c?Math.max(m.left,ao):o-Ct-Math.max(m.right,ao),y:Math.max(m.top,ao)+Ct+(u-w)/L*t,width:Ct,height:N,deltaMultiplier:U}}},Bh=(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 D_=(e,o)=>{Nw(o.selectedLinearElement,"selectedLinearElement is null");let{segmentMidPointHoveredCoords:t}=o.selectedLinearElement;Nw(t,"midPointCoords is null"),e.save(),e.translate(o.scrollX,o.scrollY),Uw(t,e,o),e.restore()},__=(e,o,t)=>{let{elementId:r,hoverPointIndex:n}=o.selectedLinearElement;if(o.selectedLinearElement?.isEditing&&o.selectedLinearElement?.selectedPointsIndices?.includes(n))return;let i=fr.getElement(r,t);if(!i)return;let a=fr.getPointAtIndexGlobalCoordinates(i,n,t);e.save(),e.translate(o.scrollX,o.scrollY),Uw(a,e,o),e.restore()},Uw=(e,o,t)=>{o.fillStyle="rgba(105, 101, 219, 0.4)",Wi(o,e[0],e[1],fr.POINT_HANDLE_SIZE/t.zoom.value,!1)},zh=(e,o,t,r,n,i,a)=>{e.strokeStyle="#5e5ad8",e.setLineDash([]),e.fillStyle="rgba(255, 255, 255, 0.9)",n?e.fillStyle="rgba(134, 131, 226, 0.9)":i&&(e.fillStyle="rgba(177, 151, 252, 0.7)"),Wi(e,t[0],t[1],(a?r*(o.selectedLinearElement?.isEditing?1.5:2):r)/o.zoom.value,!i,!a||n)},R_=(e,o,t,r)=>{let n=Gw(o,o.width,o.height,r);switch(e.fillStyle="rgba(0,0,0,.05)",o.type){case"rectangle":case"text":case"image":case"iframe":case"embeddable":case"frame":case"magicframe":Qf(e,o,t,n);break;case"diamond":t1(e,n,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=n-Fh,e1(e,d+n+Fh,m+n+Fh,i+d/2,a+m/2,o.angle);break}}},N_=(e,o,t,r)=>{let[n,i,a]=o,l=Gw(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(d=>{let[m,c]=fr.getPointAtIndexGlobalCoordinates(n,d,t);Wi(e,m,c,l,!0)})},Yw=(e,o,t)=>{let{angle:r,x1:n,y1:i,x2:a,y2:l,selectionColors:s,cx:d,cy:m,dashed:c,activeEmbeddable:p}=t,u=a-n,f=l-i,x=(t.padding??Yh*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,Vi(e,n-x,i-x,u+x*2,f+x*2,d,m,r);e.restore()},B_=(e,o,t,r)=>{let n=Array.isArray(t)?N_:R_;e.save(),e.translate(o.scrollX,o.scrollY),n(e,t,r,o.zoom),e.restore()},F_=(e,o,t,r)=>{let[n,i,a,l]=$a(t,r),s=a-n,d=l-i;e.strokeStyle="rgb(0,118,255)",e.lineWidth=Rw.strokeWidth/o.zoom.value,e.save(),e.translate(o.scrollX,o.scrollY),Vi(e,n,i,s,d,n+s/2,i+d/2,t.angle,!1,Rw.radius/o.zoom.value),e.restore()},zw=(e,o,t,r)=>{let{colors:n=["rgb(0,118,255)"],dashed:i=!1}=r||{},a=t.filter(m=>m.groupIds.length===0),l=t.filter(m=>m.groupIds.length>0),s=m=>{let[c,p,u,f]=Uh(m);return{angle:0,x1:c,x2:u,y1:p,y2:f,selectionColors:n,dashed:i,cx:c+(u-c)/2,cy:p+(f-p)/2,activeEmbeddable:!1}},d=m=>{let c=Gh(t,m);return s(c)};Object.entries(A_(l,o)).filter(([m,c])=>c).map(([m,c])=>m).map(m=>d(m)).concat(a.map(m=>s([m]))).forEach(m=>Yw(e,o,m))},Hh=(e,o,t,r)=>{if(!o.selectedLinearElement)return;e.save(),e.translate(o.scrollX,o.scrollY),e.lineWidth=1/o.zoom.value;let n=fr.getPointsGlobalCoordinates(t,r),{POINT_HANDLE_SIZE:i}=fr,a=o.selectedLinearElement?.isEditing?i:i/2,l=Za(t),s=k_(t);if(n.forEach((d,m)=>{if(l&&m!==0&&m!==n.length-1)return;let c=m>0&&(m!==n.length-1||!s||!t.polygon)&&E_(d,m===n.length-1?n[0]:n[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),zh(e,o,d,a,p,!1,c)}),Za(t)){let d=t.fixedSegments?.map(m=>m.index)||[];n.slice(0,-1).forEach((m,c)=>{fr.isSegmentTooShort(t,n[c+1],n[c],c,o.zoom)||zh(e,o,x_((m[0]+n[c+1][0])/2,(m[1]+n[c+1][1])/2),i/2,!1,!d.includes(c+1),!1)})}else fr.getEditorMidPoints(t,r,o).filter((m,c,p)=>m!==null&&!(Za(t)&&(c===0||c===p.length-1))).forEach(m=>{(o.selectedLinearElement?.isEditing||n.length===2)&&zh(e,o,m,i/2,!1,!0,!1)});e.restore()},Hw=(e,o,t,r,n)=>{Object.keys(r).forEach(i=>{let a=r[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"?Wi(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()):Vi(e,l,s,d,m,l+d/2,s+m/2,n,!0),e.restore()}})},O_=(e,o,t,r,n)=>{let[i,a,,,l,s]=$a(r,n),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(r.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()},z_=(e,o,t,r)=>{o.save();let n=Yh*2/t.zoom.value,i=e.width+n*2,a=e.height+n*2,l=e.x+i/2,s=e.y+a/2,d=-(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(d,m,i,a),o.restore()},Ww=({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[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&&Hh(c,a,p,o),a.selectionElement&&!a.isCropping)try{M_(a.selectionElement,c,a,l.selectionColor)}catch(b){console.error(b)}if(a.editingTextElement&&Ow(a.editingTextElement)){let b=n.get(a.editingTextElement.id);b&&!b.autoResize&&z_(b,c,a,l.selectionColor)}if(a.isBindingEnabled&&a.suggestedBindings.filter(b=>b!=null).forEach(b=>{B_(c,a,b,o)}),a.frameToHighlight&&F_(c,a,a.frameToHighlight,o),a.elementsToHighlight&&zw(c,a,a.elementsToHighlight),a.activeLockedId){let b=n.get(a.activeLockedId),x=b?[b]:Gh(n,a.activeLockedId);zw(c,a,x,{colors:["#ced4da"],dashed:!0})}let u=r.some(b=>Bw(b));if(r.length===1&&a.selectedLinearElement?.isEditing&&a.selectedLinearElement.elementId===r[0].id&&Hh(c,a,r[0],o),a.selectedLinearElement){let b=a.selectedLinearElement,x=r.find(w=>w.id===b.elementId);b.segmentMidPointHoveredCoords?D_(c,a):(Za(x)?b.hoverPointIndex===0||b.hoverPointIndex===x.points.length-1:b.hoverPointIndex>=0)&&__(c,a,o)}if(!a.multiElement&&!a.selectedLinearElement?.isEditing){let b=C_(r,a),x=r.length===1&&S_(r[0]);x&&a.selectedLinearElement?.elementId===r[0].id&&!r[0].locked&&Hh(c,a,r[0],o);let w=l.selectionColor||Qc.black;if(b){let E=y_(r),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)&&!P_(a,C)&&S.push(w),L&&S.push(...L.map(k=>$r(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||Fw(C)?0:void 0})}}let v=C=>{let S=Gh(o,C),[L,k,A,P]=Uh(S);y.push({angle:0,x1:L,x2:A,y1:k,y2:P,selectionColors:S.some(N=>N.locked)?["#ced4da"]:[Qc.black],dashed:!0,cx:L+(A-L)/2,cy:k+(P-k)/2,activeEmbeddable:!1})};for(let C of L_(a))v(C);a.editingGroupId&&v(a.editingGroupId),y.forEach(C=>Yw(c,a,C))}if(c.save(),c.translate(a.scrollX,a.scrollY),r.length===1){c.fillStyle=Qc.white;let E=T_(r[0],a.zoom,o,"mouse",Oh(s));if(!a.viewModeEnabled&&b&&!Ow(a.editingTextElement)&&!a.croppingElementId&&Hw(c,l,a,E,r[0].angle),a.croppingElementId&&!a.isCropping){let y=o.get(a.croppingElementId);y&&Fw(y)&&O_(c,l,a,y,o)}}else if(r.length>1&&!a.isRotating&&!r.some(E=>E.locked)){let E=Yh*2/a.zoom.value;c.fillStyle=Qc.white;let[y,v,C,S]=Uh(r,o),L=c.getLineDash();c.setLineDash([2/a.zoom.value]);let k=c.lineWidth;c.lineWidth=1/a.zoom.value,c.strokeStyle=w,Vi(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=I_([y,v,C,S,(y+C)/2,(v+S)/2],0,a.zoom,"mouse",u?{...Oh(s),rotation:!0}:Oh(s));r.some(P=>!P.locked)&&Hw(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===w_.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=Bw(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()}}),Pw(c,a),c.restore(),iE({context:c,renderConfig:l,appState:a,normalizedWidth:d,normalizedHeight:m});let f;return l.renderScrollbars&&(f=_w(o,d,m,a),c.save(),c.fillStyle=Dw,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}},Wh=v_(e=>{let o=Ww(e);e.callback?.(o)},{trailing:!0}),Vw=(e,o)=>{if(o){Wh(e);return}let t=Ww(e);return e.callback(t),t};var ja=class{constructor(o){I(this,"scene");I(this,"getRenderableElements",(()=>{let o=({elementsMap:r,zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s,height:d,width:m})=>{let c=[];for(let p of r.values())H_(p,m,d,{zoom:n,offsetLeft:i,offsetTop:a,scrollX:l,scrollY:s},r)&&c.push(p);return c},t=({elements:r,editingTextElement:n,newElementId:i})=>{let a=U_(new Map);for(let l of r)i!==l.id&&(!n||n.type!=="text"||l.id!==n.id)&&a.set(l.id,l);return a};return G_(({zoom:r,offsetLeft:n,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:r,offsetLeft:n,offsetTop:i,scrollX:a,scrollY:l,height:s,width:d});return{elementsMap:f,visibleElements:b}})})());this.scene=o}destroy(){Wh.cancel(),r1.cancel(),this.getRenderableElements.clear()}};import{sceneCoordsToViewportCoords as Y_}from"@excalidraw/common";import{getElementAbsoluteCoords as W_}from"@excalidraw/element";import{jsx as K_}from"react/jsx-runtime";var V_=5,X_=(e,o,t)=>{let[r,n]=W_(e,t),{x:i,y:a}=Y_({sceneX:r+e.width,sceneY:n},o),l=i-o.offsetLeft+10,s=a-o.offsetTop;return{x:l,y:s}},Vh=({children:e,element:o,elementsMap:t})=>{let r=go();if(r.contextMenu||r.newElement||r.resizingElement||r.isRotating||r.openMenu||r.viewModeEnabled)return null;let{x:n,y:i}=X_(o,r,t);return K_("div",{className:"excalidraw-canvas-buttons",style:{top:`${i}px`,left:`${n}px`,padding:V_},children:e})};import{DEFAULT_LASER_COLOR as q_,easeOut as Kw}from"@excalidraw/common";import{LaserPointer as Z_}from"@excalidraw/laser-pointer";import{SVG_NS as Xw,getSvgPathFromStroke as $_,sceneCoordsToViewportCoords as j_}from"@excalidraw/common";var Go=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(Xw,"path"),this.options.animateTrail&&(this.trailAnimation=document.createElementNS(Xw,"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 Z_(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=j_({sceneX:i,sceneY:a},t);return[l.x,l.y]}),n=this.trailAnimation?r.slice(0,r.length/2):r;return $_(n,!0)}};var ed=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:()=>q_})}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(Kw(i),Kw(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 Go(this.animationFrameHandler,this.app,{...this.getTrailOptions(),fill:()=>t.pointer?.laserColor||$r(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 J_}from"react";import{unstable_batchedUpdates as Zw}from"react-dom";import{throttleRAF as Q_}from"@excalidraw/common";var Pe=e=>o=>{Zw(e,o)},td=e=>Q_(o=>{Zw(e,o)}),Ci=(()=>{let e;try{let t=J_.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 Xh,KEYS as qa,CLASSES as $w,POINTER_BUTTON as eR,isWritableElement as tR,getFontString as jw,getFontFamilyString as qw,isTestEnv as Jw}from"@excalidraw/common";import{originalContainerCache as oR,updateOriginalContainerCache as Qw}from"@excalidraw/element";import{LinearElementEditor as rR}from"@excalidraw/element";import{bumpVersion as nR}from"@excalidraw/element";import{getBoundTextElementId as iR,getContainerElement as Kh,getTextElementAngle as aR,redrawTextBoundingBox as lR,getBoundTextMaxHeight as sR,getBoundTextMaxWidth as ev,computeContainerDimensionForBoundText as tv,computeBoundTextPosition as cR,getBoundTextElement as dR}from"@excalidraw/element";import{getTextWidth as mR}from"@excalidraw/element";import{normalizeText as ov}from"@excalidraw/element";import{wrapText as pR}from"@excalidraw/element";import{isArrowElement as od,isBoundToContainer as uR,isTextElement as rv}from"@excalidraw/element";var hR=(e,o,t,r,n,i)=>{let{zoom:a}=r,l=180*t/Math.PI,s=e*(a.value-1)/2,d=o*(a.value-1)/2;return e>n&&a.value!==1&&(s=n*(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)`},nv=({id:e,onChange:o,onSubmit:t,getViewportCoords:r,element:n,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 qw({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&&rv(R)){let ce=R.x,he=R.y,de=Kh(R,l.scene.getNonDeletedElementsMap()),it=R.width,po=R.height,mn=R.width,pn=R.height;if(de&&R.containerId){if(od(de)){let Xo=rR.getBoundTextElementPosition(de,R,W);ce=Xo.x,he=Xo.y}let Sl=d(R,c),Ui;if(Sl?Ui=Qw(de.id,de.height):(Ui=oR[de.id],Ui||(Ui=Qw(de.id,de.height))),mn=ev(de,R),pn=sR(de,R),!od(de)&&po>pn){let Xo=tv(po,de.type);l.scene.mutateElement(de,{height:Xo});return}else if(!od(de)&&de.height>Ui.height&&po<pn){let Xo=tv(po,de.type);l.scene.mutateElement(de,{height:Xo})}else{let{y:Xo}=cR(de,R,W);he=Xo}}let[Cl,nm]=r(ce,he),YI=c.selectionStart,im=c.selectionEnd,Gf=c.value.length;if(YI===im&&im!==Gf){let Sl=Gf-im;c.selectionStart=c.value.length-Sl,c.selectionEnd=c.value.length-Sl}de?it+=.5:(mn=(_.width-8-Cl)/_.zoom.value,it=Math.min(it,mn)),po*=1.05;let WI=jw(R),Uf=(_.height-nm)/_.zoom.value;Object.assign(c.style,{font:WI,lineHeight:R.lineHeight,width:`${it}px`,height:`${po}px`,left:`${Cl}px`,top:`${nm}px`,transform:hR(it,po,aR(R,de),_,mn,Uf),textAlign:V,verticalAlign:Z,color:R.strokeColor,opacity:R.opacity/100,filter:"var(--theme-filter)",maxHeight:`${Uf}px`}),c.scrollTop=0,Jw()&&(c.style.fontFamily=qw(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";(uR(n)||!n.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=n.originalText,m(),o&&(c.onpaste=async _=>{let R=await Ws(_,!0);if(!R.text)return;let V=ov(R.text);if(!V)return;let Z=Kh(n,l.scene.getNonDeletedElementsMap()),W=jw({fontSize:l.state.currentItemFontSize,fontFamily:l.state.currentItemFontFamily});if(Z){let ce=dR(Z,l.scene.getNonDeletedElementsMap()),he=pR(`${c.value}${V}`,W,ev(Z,ce)),de=mR(he,W);c.style.width=`${de}px`}},c.oninput=()=>{let _=ov(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(kp.keyTest(_))l.actionManager.executeAction(kp);else if(Mp.keyTest(_))l.actionManager.executeAction(Mp);else if(_.key===qa.ESCAPE)_.preventDefault(),C=!0,S();else if(Kr.keyTest(_))_.preventDefault(),S(),l.actionManager.executeAction(Kr);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===Xh.BRACKET_LEFT||_.code===Xh.BRACKET_RIGHT)){if(_.preventDefault(),_.isComposing)return;_.shiftKey||_.code===Xh.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(n.id);if(!_)return;let R=Kh(_,l.scene.getNonDeletedElementsMap());if(R){if(c.value.trim()){let V=iR(R);!V||V!==n.id?l.scene.mutateElement(R,{boundElements:(R.boundElements||[]).concat({type:"text",id:n.id})}):od(R)&&nR(R)}else l.scene.mutateElement(R,{boundElements:R.boundElements?.filter(V=>!rv(V))});lR(_,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===eR.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(`.${$w.SHAPE_ACTIONS_MENU}, .${$w.ZOOM_ACTIONS}`)&&!tR(_.target)||V?A():_.target instanceof HTMLCanvasElement&&!Jw()&&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 iv=e=>{let o=["flowchart","graph","sequenceDiagram","classDiagram","stateDiagram","stateDiagram-v2","erDiagram","journey","gantt","pie","quadrantChart","requirementDiagram","gitGraph","C4Context","mindmap","timeline","zenuml","sankey","xychart","block"];return new RegExp(`^(?:%%{.*?}%%[\\s\\n]*)?\\b(?:${o.map(r=>`\\s*${r}(-beta)?`).join("|")})\\b`).test(e.trim())};import{pointFrom as IR}from"@excalidraw/math";import{getElementLineSegments as CR}from"@excalidraw/element";import{LinearElementEditor as SR}from"@excalidraw/element";import{isFrameLikeElement as kR,isLinearElement as MR,isTextElement as LR}from"@excalidraw/element";import{getFrameChildren as PR}from"@excalidraw/element";import{selectGroupsForSelectedElements as AR}from"@excalidraw/element";import{getContainerElement as DR}from"@excalidraw/element";import{arrayToMap as _R,easeOut as cv,isShallowEqual as RR}from"@excalidraw/common";import{simplify as gR}from"points-on-curve";import{polygonFromPoints as fR,lineSegment as av,polygonIncludesPointNonZero as bR}from"@excalidraw/math";import{computeBoundTextPosition as xR,doBoundsIntersect as ER,getBoundTextElement as yR,getElementBounds as wR,intersectElementWithLineSegment as lv}from"@excalidraw/element";var sv=e=>{let{lassoPath:o,elements:t,elementsMap:r,elementsSegments:n,intersectedElements:i,enclosedElements:a,simplifyDistance:l}=e,s=o;l&&(s=gR(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=wR(p,r);ER(m,u)&&!i.has(p.id)&&!a.has(p.id)&&(vR(s,p,n)?a.add(p.id):TR(s,p,r)&&i.add(p.id))}return{selectedElementIds:[...i,...a]}},vR=(e,o,t)=>{let r=fR(e),n=t.get(o.id);return n?n.some(i=>i.some(a=>bR(a,r))):!1},TR=(e,o,t)=>{let r=e.slice(1).map((i,a)=>av(e[a],i)).concat([av(e[e.length-1],e[0])]),n=yR(o,t);return r.some(i=>lv(o,t,i,0,!0).length>0||!!n&&lv({...n,...xR(o,n,t)},t,i,0,!0).length>0)};var rd=class extends Go{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(cv(s),cv(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,d)=>(s[d]=!0,s),{});if(this.keepPreviousSelection)for(let s of Object.keys(r.selectedElementIds))n[s]=!0;for(let[s]of Object.entries(n)){let d=this.app.scene.getNonDeletedElement(s);if(d&&LR(d)){let m=DR(d,this.app.scene.getNonDeletedElementsMap());m&&(n[m.id]=!0,delete n[d.id])}}for(let[s]of Object.entries(n)){let d=this.app.scene.getNonDeletedElement(s);if(d&&kR(d)){let m=PR(this.app.scene.getNonDeletedElementsMap(),d.id);for(let c of m)delete n[c.id]}}let i=AR({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&&MR(this.app.scene.getNonDeletedElement(a[0]))?new SR(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=>IR(n[0],n[1])),r={scrollX:this.app.state.scrollX,scrollY:this.app.state.scrollY,zoom:this.app.state.zoom.value};if(!this.elementsSegments||!RR(r,this.canvasTranslate??{})){this.canvasTranslate=r,this.elementsSegments=new Map;let n=_R(this.app.visibleElements);for(let i of this.app.visibleElements){let a=CR(i,n);this.elementsSegments.set(i.id,a)}}if(t){let{selectedElementIds:n}=sv({lassoPath:t,elements:this.app.visibleElements,elementsMap:this.app.scene.getNonDeletedElementsMap(),elementsSegments:this.elementsSegments,intersectedElements:this.intersectedElements,enclosedElements:this.enclosedElements,simplifyDistance:5/this.app.state.zoom.value});this.selectElementsFromIds(n)}})}startPath(t,r,n=!1){this.endPath(),super.startPath(t,r),this.intersectedElements.clear(),this.enclosedElements.clear(),this.keepPreviousSelection=n,this.keepPreviousSelection||this.app.setState({selectedElementIds:{},selectedGroupIds:{},selectedLinearElement:null})}endPath(){super.endPath(),super.clearTrails(),this.intersectedElements.clear(),this.enclosedElements.clear(),this.elementsSegments=null}};import{arrayToMap as NR,easeOut as dv,THEME as BR}from"@excalidraw/common";import{computeBoundTextPosition as FR,getBoundTextElement as OR,intersectElementWithLineSegment as mv,isPointInElement as zR}from"@excalidraw/element";import{lineSegment as HR,pointFrom as GR}from"@excalidraw/math";import{getElementsInGroup as pv}from"@excalidraw/element";import{shouldTestInside as UR}from"@excalidraw/element";import{hasBoundTextElement as uv,isBoundToContainer as hv}from"@excalidraw/element";import{getBoundTextElementId as gv}from"@excalidraw/element";var nd=class extends Go{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(dv(s),dv(l))},fill:()=>r.state.theme===BR.LIGHT?"rgba(0, 0, 0, 0.2)":"rgba(255, 255, 255, 0.2)"});I(this,"elementsToErase",new Set);I(this,"groupsToErase",new Set)}startPath(t,r){this.endPath(),super.startPath(t,r),this.elementsToErase.clear()}addPointToPath(t,r,n=!1){return super.addPointToPath(t,r),this.updateElementsToBeErased(n)}updateElementsToBeErased(t){let r=super.getCurrentTrail()?.originalPoints?.map(l=>GR(l[0],l[1]))||[];if(r.length<2)return[];let n=HR(r[r.length-1],r[r.length-2]),i=this.app.visibleElements.filter(l=>!l.locked),a=NR(i);for(let l of i)if(t&&this.elementsToErase.has(l.id)){if(fv(n,l,a)){let d=l.groupIds.at(-1);if(this.groupsToErase.has(d)){let m=pv(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.delete(c.id);this.groupsToErase.delete(d)}if(hv(l)&&this.elementsToErase.delete(l.containerId),uv(l)){let m=gv(l);m&&this.elementsToErase.delete(m)}this.elementsToErase.delete(l.id)}}else if(!t&&!this.elementsToErase.has(l.id)&&fv(n,l,a)){let d=l.groupIds.at(-1);if(!this.groupsToErase.has(d)){let m=pv(this.app.scene.getNonDeletedElementsMap(),d);for(let c of m)this.elementsToErase.add(c.id);this.groupsToErase.add(d)}if(uv(l)){let m=gv(l);m&&this.elementsToErase.add(m)}hv(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()}},fv=(e,o,t)=>{let r=e[1];if(UR(o)&&zR(r,o,t))return!0;let n=OR(o,t);return mv(o,t,e,0,!0).length>0||!!n&&mv({...n,...FR(o,n,t)},t,e,0,!0).length>0};import{jsx as Vt,jsxs as bv}from"react/jsx-runtime";var YR=()=>bv("div",{"data-testid":"brave-measure-text-error",children:[Vt("p",{children:Vt(ht,{i18nKey:"errors.brave_measure_text_error.line1",bold:e=>Vt("span",{style:{fontWeight:600},children:e})})}),Vt("p",{children:Vt(ht,{i18nKey:"errors.brave_measure_text_error.line2",bold:e=>Vt("span",{style:{fontWeight:600},children:e})})}),Vt("p",{children:Vt(ht,{i18nKey:"errors.brave_measure_text_error.line3",link:e=>Vt("a",{href:"http://docs.excalidraw.com/docs/@excalidraw/excalidraw/faq#turning-off-aggresive-block-fingerprinting-in-brave-browser",children:e})})}),Vt("p",{children:Vt(ht,{i18nKey:"errors.brave_measure_text_error.line4",issueLink:e=>Vt("a",{href:"https://github.com/excalidraw/excalidraw/issues/new",children:e}),discordLink:e=>bv("a",{href:"https://discord.gg/UexuTaE",children:[e,"."]})})})]}),xv=YR;import $R from"clsx";import jR from"react";import{useLayoutEffect as WR,useRef as Ev,useEffect as yv}from"react";import{unstable_batchedUpdates as VR}from"react-dom";import{KEYS as XR,queryFocusableElements as KR}from"@excalidraw/common";import{jsx as ZR}from"react/jsx-runtime";var wv=({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 d=Ev(null);yv(()=>{let c=d.current;if(!c)return;c.contains(document.activeElement)||c.focus();let p=u=>{if(u.key===XR.TAB){let f=KR(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=Ev(null);return WR(()=>{if(n&&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,n,l,s,i,a]),yv(()=>{if(r){let c=p=>{d.current?.contains(p.target)||VR(()=>r(p))};return document.addEventListener("pointerdown",c,!1),()=>document.removeEventListener("pointerdown",c,!1)}},[r]),ZR("div",{className:"popover",ref:d,tabIndex:-1,children:e})};import{jsx as Si,jsxs as qR}from"react/jsx-runtime";var Ye="separator",vv=jR.memo(({actionManager:e,items:o,top:t,left:r,onClose:n})=>{let i=go(),a=tr(),l=o.reduce((s,d)=>(d&&(d===Ye||!d.predicate||d.predicate(a,i,e.app.props,e.app))&&s.push(d),s),[]);return Si(wv,{onCloseRequest:()=>{n()},top:t,left:r,fitInViewport:!0,offsetLeft:i.offsetLeft,offsetTop:i.offsetTop,viewportWidth:i.width,viewportHeight:i.height,children:Si("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:Si("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)),Si("li",{"data-testid":m,onClick:()=>{n(()=>{e.executeAction(s,"contextMenu")})},children:qR("button",{type:"button",className:$R("context-menu-item",{dangerous:m==="deleteSelectedElements",checkmark:s.checked?.(i)}),children:[Si("div",{className:"context-menu-item__label",children:c}),Si("kbd",{className:"context-menu-item__shortcut",children:m?Ne(m):""})]})},d)})})})});import{jsx as Zh,jsxs as Tv}from"react/jsx-runtime";var JR=({height:e,width:o,userToFollow:t,onDisconnect:r})=>Zh("div",{className:"follow-mode",style:{width:o,height:e},children:Tv("div",{className:"follow-mode__badge",children:[Tv("div",{className:"follow-mode__badge__label",children:["Following"," ",Zh("span",{className:"follow-mode__badge__username",title:t.username,children:t.username})]}),Zh("button",{type:"button",onClick:r,className:"follow-mode__disconnect-btn",children:Bt})]})}),Iv=JR;import cl from"clsx";import bO from"react";import{CLASSES as xO,DEFAULT_SIDEBAR as Xg,TOOL_TYPE as oT,arrayToMap as EO,capitalizeString as yO,isShallowEqual as Wd}from"@excalidraw/common";import{mutateElement as wO}from"@excalidraw/element";import{showSelectedShapeActions as vO}from"@excalidraw/element";import{ShapeCache as TO}from"@excalidraw/element";import QR from"clsx";import{useState as e9,useEffect as t9}from"react";import{THEME as o9}from"@excalidraw/common";import{jsx as $h,jsxs as r9}from"react/jsx-runtime";var id=({delay:e,theme:o})=>{let[t,r]=e9(!!e);return t9(()=>{if(!e)return;let n=setTimeout(()=>{r(!1)},e);return()=>clearTimeout(n)},[e]),t?null:r9("div",{className:QR("LoadingMessage",{"LoadingMessage--dark":o===o9.DARK}),children:[$h("div",{children:$h(tt,{})}),$h("div",{className:"LoadingMessage-text",children:g("labels.loadingScene")})]})};import n9 from"clsx";import{jsx as Sv,jsxs as a9}from"react/jsx-runtime";var i9="medium",Cv={CHECKED:wn,UNCHECKED:Br},ad=e=>a9("label",{className:n9("ToolIcon ToolIcon__lock",`ToolIcon_size_${i9}`,{"is-mobile":e.isMobile}),title:`${e.title} \u2014 Q`,children:[Sv("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-lock"}),Sv("div",{className:"ToolIcon__icon",children:e.checked?Cv.CHECKED:Cv.UNCHECKED})]});import{showSelectedShapeActions as I9}from"@excalidraw/element";import l9 from"clsx";import{jsx as s9}from"react/jsx-runtime";var ld=({children:e,side:o,className:t})=>s9("div",{className:l9("FixedSideContainer",`FixedSideContainer_side_${o}`,t),children:e});import c9 from"clsx";import{KEYS as kv}from"@excalidraw/common";import{jsx as d9}from"react/jsx-runtime";var sd=e=>d9(K,{className:c9("Shape",{fillable:!1}),type:"radio",icon:Ql,name:"editor-current-shape",checked:e.checked,title:`${e.title} \u2014 H`,keyBindingLabel:e.isMobile?void 0:kv.H.toLocaleUpperCase(),"aria-label":`${e.title} \u2014 H`,"aria-keyshortcuts":kv.H,"data-testid":"toolbar-hand",onChange:()=>e.onChange?.()});import{CANVAS_SEARCH_TAB as m9,DEFAULT_SIDEBAR as p9}from"@excalidraw/common";import{isFlowchartNodeElement as u9,isImageElement as Mv,isLinearElement as Lv,isLineElement as h9,isTextBindableContainer as g9,isTextElement as f9}from"@excalidraw/element";import{getShortcutKey as jh}from"@excalidraw/common";import{isNodeInFlowchart as b9}from"@excalidraw/element";import{jsx as Pv}from"react/jsx-runtime";var x9=({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===p9.name&&e.openSidebar.tab===m9&&e.searchMatches?.matches.length)return g("hints.dismissSearch");if(e.openSidebar&&!t.editor.canFitSidebar)return null;if(bt(e))return g("hints.eraserRevert");if(n.type==="arrow"||n.type==="line")return s?g("hints.linearElementMulti"):n.type==="arrow"?g("hints.arrowTool",{arrowShortcut:jh("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");let d=r.scene.getSelectedElements(e);if(i&&l==="mouse"&&d.length===1){let m=d[0];return Lv(m)&&m.points.length===2?g("hints.lockAngle"):Mv(m)?g("hints.resizeImage"):g("hints.resize")}if(a&&l==="mouse")return g("hints.rotate");if(d.length===1&&f9(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&&Mv(d[0]))return g("hints.enterCropEditor");if(n.type==="selection"){if(e.selectionElement&&!d.length&&!e.editingTextElement&&!e.selectedLinearElement?.isEditing)return[g("hints.deepBoxSelect")];if(hr(r)&&e.selectedElementsAreBeingDragged)return g("hints.disableSnapping");if(!d.length&&!o)return[g("hints.canvasPanning")];if(d.length===1){if(Lv(d[0]))return e.selectedLinearElement?.isEditing?e.selectedLinearElement.selectedPointsIndices?g("hints.lineEditor_pointSelected"):g("hints.lineEditor_nothingSelected"):h9(d[0])?g("hints.lineEditor_line_info"):g("hints.lineEditor_info");if(!e.newElement&&!e.selectedElementsAreBeingDragged&&g9(d[0]))return u9(d[0])?b9(d[0],r.scene.getNonDeletedElementsMap())?[g("hints.bindTextToElement"),g("hints.createFlowchart")]:[g("hints.bindTextToElement"),g("hints.createFlowchart")]:g("hints.bindTextToElement")}}return null},cd=({appState:e,isMobile:o,device:t,app:r})=>{let n=x9({appState:e,isMobile:o,device:t,app:r});if(!n)return null;let i=Array.isArray(n)?n.map(a=>jh(a).replace(/\. ?$/,"")).join(". "):jh(n);return Pv("div",{className:"HintViewer",children:Pv("span",{children:i})})};import E9 from"clsx";import{jsx as Av,jsxs as w9}from"react/jsx-runtime";var y9="medium",dd=e=>e.penDetected?w9("label",{className:E9("ToolIcon ToolIcon__penMode",`ToolIcon_size_${y9}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[Av("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),Av("div",{className:"ToolIcon__icon",children:D1})]}):null;import{Fragment as v9,jsx as Dv,jsxs as T9}from"react/jsx-runtime";var br=({heading:e,children:o,...t})=>{let{id:r}=He(),n=Dv("h2",{className:"visually-hidden",id:`${r}-${e}-title`,children:g(`headings.${e}`)});return Dv("section",{...t,"aria-labelledby":`${r}-${e}-title`,children:typeof o=="function"?o(n):T9(v9,{children:[n,o]})})};import{Fragment as C9,jsx as rt,jsxs as Uo}from"react/jsx-runtime";var _v=({appState:e,elements:o,actionManager:t,setAppState:r,onLockToggle:n,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(ld,{side:"top",className:"App-top-bar",children:[c&&rt(f.Out,{}),rt(br,{heading:"shapes",children:y=>rt(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,rt(qe.Row,{gap:1,children:rt(Ac,{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"&&rt(x.Out,{}),rt(dd,{checked:e.penMode,onChange:()=>a(null),title:g("toolBar.penMode"),isMobile:!0,penDetected:e.penDetected}),rt(ad,{checked:e.activeTool.locked,onChange:n,title:g("toolBar.lock"),isMobile:!0}),rt(sd,{checked:jt(e),onChange:()=>i(),title:g("toolBar.hand"),isMobile:!0})]})]})})}),rt(cd,{appState:e,isMobile:!0,device:m,app:u})]}),E=()=>e.viewModeEnabled||e.openDialog?.name==="elementLinkSelector"?rt("div",{className:"App-toolbar-content",children:rt(b.Out,{})}):Uo("div",{className:"App-toolbar-content",children:[rt(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(C9,{children:[d(),!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&w(),rt("div",{className:"App-bottom-bar",style:{marginBottom:Ct+ao*2,marginLeft:Ct+ao*2,marginRight:Ct+ao*2},children:Uo(Xe,{padding:0,children:[e.openMenu==="shape"&&!e.viewModeEnabled&&e.openDialog?.name!=="elementLinkSelector"&&I9(e,o)?rt(br,{className:"App-mobile-menu",heading:"selectedShapeActions",children:rt(Pc,{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&&rt("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(y=>({...Nr(o,y)}))},children:g("buttons.scrollBackToContent")})]})]})})]})};import S9 from"open-color";import k9,{useLayoutEffect as M9,useRef as L9,useState as P9}from"react";import{jsx as Ja,jsxs as A9}from"react/jsx-runtime";var Rv=e=>{let o=L9(null),[t,r]=P9(null);return M9(()=>{if(!e.spreadsheet)return;let n=zx(e.chartType,e.spreadsheet,0,0);r(n);let i,a=o.current;return(async()=>(i=await fn(n,{exportBackground:!1,viewBackgroundColor:S9.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})})},Nv=({setAppState:e,appState:o,onClose:t})=>{let{onInsertElements:r}=Re(),n=k9.useCallback(()=>{t&&t()},[t]),i=(a,l)=>{r(l),re("paste","chart",a),e({currentChartType:a,pasteDialog:{shown:!1,data:null}})};return Ja(Be,{size:"small",onCloseRequest:n,title:g("labels.pasteCharts"),className:"PasteChartDialog",autofocus:!1,children:A9("div",{className:"container",children:[Ja(Rv,{chartType:"bar",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="bar",onClick:i}),Ja(Rv,{chartType:"line",spreadsheet:o.pasteDialog.data,selected:o.currentChartType==="line",onClick:i})]})})};import*as xr from"@radix-ui/react-popover";import Bv from"clsx";import md,{useLayoutEffect as D9}from"react";import{supportsResizeObserver as _9,isShallowEqual as R9}from"@excalidraw/common";import{Fragment as z9,jsx as vo,jsxs as pd}from"react/jsx-runtime";var N9=4,B9=8,F9=({shouldWrap:e,children:o,username:t})=>e?vo(Pt,{label:t||"Unknown user",children:o}):vo(z9,{children:o}),qh=({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 vo(F9,{username:o.username,shouldWrap:n,children:l},t)},O9=["avatarUrl","id","socketId","username","isInCall","isSpeaking","isMuted"],ud=md.memo(({className:e,mobile:o,collaborators:t,userToFollow:r})=>{let n=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]=md.useState(""),d=a.filter(b=>b.username?.toLowerCase().includes(l)),m=md.useRef(null);D9(()=>{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),!_9)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]=md.useState(N9),f=a.slice(0,c-1).map(b=>qh({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}));return o?vo("div",{className:Bv("UserList UserList_mobile",e),children:a.map(b=>qh({actionManager:n,collaborator:b,socketId:b.socketId,shouldWrapWithTooltip:!0,isBeingFollowed:b.socketId===r}))}):vo("div",{className:"UserList__wrapper",ref:m,children:pd("div",{className:Bv("UserList",e),style:{"--max-avatars":c},children:[f,a.length>c-1&&pd(xr.Root,{children:[pd(xr.Trigger,{className:"UserList__more",children:["+",a.length-c+1]}),vo(xr.Content,{style:{zIndex:2,width:"15rem",textAlign:"left"},align:"end",sideOffset:10,children:pd(Xe,{padding:2,children:[a.length>=B9&&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=>qh({actionManager:n,collaborator:b,socketId:b.socketId,withName:!0,isBeingFollowed:b.socketId===r}))]:[]}),vo(xr.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||!R9(n,i,O9))return!1}return!0});import Jh from"clsx";import{jsx as H9}from"react/jsx-runtime";var Fv=e=>H9("button",{className:"help-icon",onClick:e.onClick,type:"button",title:`${g("helpDialog.title")} \u2014 ?`,"aria-label":g("helpDialog.title"),children:Tn});import{jsx as Yo,jsxs as Qh}from"react/jsx-runtime";var Ov=({appState:e,actionManager:o,showExitZenModeBtn:t,renderWelcomeScreen:r})=>{let{FooterCenterTunnel:n,WelcomeScreenHelpHintTunnel:i}=ve();return Qh("footer",{role:"contentinfo",className:"layer-ui__wrapper__footer App-menu App-menu_bottom",children:[Yo("div",{className:Jh("layer-ui__wrapper__footer-left zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-left":e.zenModeEnabled}),children:Yo(qe.Col,{gap:2,children:Qh(br,{heading:"canvasActions",children:[Yo(p2,{renderAction:o.renderAction,zoom:e.zoom}),!e.viewModeEnabled&&Yo(u2,{renderAction:o.renderAction,className:Jh("zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":e.zenModeEnabled})})]})})}),Yo(n.Out,{}),Yo("div",{className:Jh("layer-ui__wrapper__footer-right zen-mode-transition",{"transition-right":e.zenModeEnabled}),children:Qh("div",{style:{position:"relative"},children:[r&&Yo(i.Out,{}),Yo(Fv,{onClick:()=>o.executeAction(Zr)})]})}),Yo(h2,{actionManager:o,showExitZenModeBtn:t})]})},zv=Ov;Ov.displayName="Footer";import Z9 from"clsx";import{useEffect as jv,useLayoutEffect as qv,useRef as sg,useState as $9,forwardRef as Jv,useImperativeHandle as j9,useCallback as Kv}from"react";import{EVENT as Zv,isDevEnv as q9,KEYS as J9,updateObject as Q9}from"@excalidraw/common";import U9 from"clsx";import{useContext as Y9}from"react";import G9 from"react";var hd=G9.createContext({});import{jsx as eg,jsxs as Hv}from"react/jsx-runtime";var tg=({children:e,className:o})=>{let t=se(),r=Y9(hd),n=!!(t.editor.canFitSidebar&&r.shouldRenderDockButton);return Hv("div",{className:U9("sidebar__header",o),"data-testid":"sidebar-header",children:[e,Hv("div",{className:"sidebar__header__buttons",children:[n&&eg(Pt,{label:g("labels.sidebarLock"),children:eg(_t,{onSelect:()=>r.onDock?.(!r.docked),selected:!!r.docked,className:"sidebar__dock","data-testid":"sidebar-dock","aria-label":g("labels.sidebarLock"),children:C1})}),eg(_t,{"data-testid":"sidebar-close",className:"sidebar__close",onSelect:r.onCloseRequest,"aria-label":g("buttons.close"),children:Bt})]})]})};tg.displayName="SidebarHeader";import*as Uv from"@radix-ui/react-tabs";import{jsx as Gv}from"react/jsx-runtime";var og=({children:e,tab:o,onSelect:t,...r})=>Gv(Uv.Trigger,{value:o,asChild:!0,onSelect:t,children:Gv("button",{type:"button",className:"excalidraw-button sidebar-tab-trigger",...r,children:e})});og.displayName="SidebarTabTrigger";import*as Yv from"@radix-ui/react-tabs";import{jsx as W9}from"react/jsx-runtime";var rg=({children:e,...o})=>W9(Yv.List,{className:"sidebar-triggers",...o,children:e});rg.displayName="SidebarTabTriggers";import V9 from"clsx";import{jsx as ng,jsxs as Wv}from"react/jsx-runtime";var ig=({name:e,tab:o,icon:t,title:r,children:n,onToggle:i,className:a,style:l})=>{let s=le(),d=ge();return Wv("label",{title:r,className:"sidebar-trigger__label-element",children:[ng("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":r,"aria-keyshortcuts":"0"}),Wv("div",{className:V9("sidebar-trigger",a),style:l,children:[t&&ng("div",{children:t}),n&&ng("div",{className:"sidebar-trigger__label",children:n})]})]})};ig.displayName="SidebarTrigger";import*as Vv from"@radix-ui/react-tabs";import{jsx as X9}from"react/jsx-runtime";var ag=({children:e,...o})=>{let t=ge(),r=le();if(!t.openSidebar)return null;let{name:n}=t.openSidebar;return X9(Vv.Root,{className:"sidebar-tabs-root",value:t.openSidebar.tab,onValueChange:i=>r(a=>({...a,openSidebar:{...a.openSidebar,name:n,tab:i}})),...o,children:e})};ag.displayName="SidebarTabs";import*as Xv from"@radix-ui/react-tabs";import{jsx as K9}from"react/jsx-runtime";var lg=({tab:e,children:o,...t})=>K9(Xv.Content,{...t,value:e,"data-testid":e,children:o});lg.displayName="SidebarTab";import{jsx as $v}from"react/jsx-runtime";import{createElement as eN}from"react";var Qa=me(!1),Qv=Jv(({name:e,children:o,onDock:t,docked:r,className:n,...i},a)=>{q9()&&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=le(),s=jo(Qa);qv(()=>(s(!!r),()=>{s(!1)}),[s,r]);let d=sg({});d.current.onCloseRequest=()=>{l({openSidebar:null})},d.current.onDock=u=>t?.(u),d.current=Q9(d.current,{docked:r,shouldRenderDockButton:!!t&&r!=null});let m=sg(null);j9(a,()=>m.current);let c=se(),p=Kv(()=>{document.querySelector(".Dialog")||l({openSidebar:null})},[l]);return Dn(m,Kv(u=>{u.target.closest(".sidebar-trigger")||(!r||!c.editor.canFitSidebar)&&p()},[p,r,c.editor.canFitSidebar])),jv(()=>{let u=f=>{f.key===J9.ESCAPE&&(!r||!c.editor.canFitSidebar)&&p()};return document.addEventListener(Zv.KEYDOWN,u),()=>{document.removeEventListener(Zv.KEYDOWN,u)}},[p,r,c.editor.canFitSidebar]),$v(Xe,{...i,className:Z9("sidebar",{"sidebar--docked":r},n),ref:m,children:$v(hd.Provider,{value:d.current,children:o})})});Qv.displayName="SidebarInner";var Xt=Object.assign(Jv((e,o)=>{let t=ge(),{onStateChange:r}=e,n=sg(t.openSidebar);jv(()=>{(!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]=$9(!1);return qv(()=>(a(!0),()=>a(!1)),[]),i&&t.openSidebar?.name===e.name?eN(Qv,{...e,ref:o,key:e.name}):null}),{Header:tg,TabTriggers:rg,TabTrigger:og,Tabs:ag,Tab:lg,Trigger:ig});Xt.displayName="Sidebar";import{composeEventHandlers as cN}from"@excalidraw/common";import{useLayoutEffect as tN,useRef as oN}from"react";import{jsx as rN}from"react/jsx-runtime";var Wo=(e,o)=>{let t=me(0),r=n=>{let{tunnelsJotai:{useAtom:i}}=ve(),[,a]=i(t),l=oN({preferHost:!1,counter:0});return tN(()=>{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]),n.__fallback||(l.current.preferHost=!0),!l.current.counter&&n.__fallback&&l.current.preferHost||l.current.counter>1&&n.__fallback?null:rN(o,{...n})};return r.displayName=e,r};var mg={};Wf(mg,{ChangeCanvasBackground:()=>u3,ClearCanvas:()=>m3,CommandPalette:()=>s3,Export:()=>h3,Help:()=>d3,LiveCollaborationTrigger:()=>f3,LoadScene:()=>i3,SaveAsImage:()=>l3,SaveToActiveFile:()=>a3,SearchMenu:()=>c3,Socials:()=>g3,ToggleTheme:()=>p3});import lN from"clsx";import{THEME as Er}from"@excalidraw/common";var cg=me({active:!1});async function e3({title:e,description:o,actionLabel:t,color:r}){return new Promise(n=>{ze.set(cg,{active:!0,onConfirm:()=>n(!0),onClose:()=>n(!1),onReject:()=>n(!1),title:e,description:o,actionLabel:t,color:r})})}import nN from"clsx";import{jsx as t3,jsxs as iN}from"react/jsx-runtime";var gd=function({onChange:e,value:o,choices:t,name:r}){return t3("div",{className:"RadioGroup",children:t.map(n=>iN("div",{className:nN("RadioGroup__choice",{active:n.value===o}),title:n.ariaLabel,children:[t3("input",{name:r,type:"radio",checked:n.value===o,onChange:()=>e(n.value),"aria-label":n.ariaLabel}),n.label]},String(n.value)))})};import{Fragment as aN,jsx as dg,jsxs as o3}from"react/jsx-runtime";var r3=({value:e,shortcut:o,onChange:t,choices:r,children:n,name:i})=>{let a=se();return o3(aN,{children:[o3("div",{className:"dropdown-menu-item-base dropdown-menu-item-bare",children:[dg("label",{className:"dropdown-menu-item__text",htmlFor:i,children:n}),dg(gd,{name:i,value:e,onChange:t,choices:r})]}),o&&!a.editor.isMobile&&dg("div",{className:"dropdown-menu-item__shortcut dropdown-menu-item__shortcut--orphaned",children:o})]})};r3.displayName="DropdownMenuItemContentRadio";var n3=r3;import{Fragment as sN,jsx as je,jsxs as b3}from"react/jsx-runtime";var i3=()=>{let{t:e}=Oe(),o=Ue(),t=tr();return o.isActionEnabled(Kn)?je(pt,{icon:In,onSelect:async()=>{(!t.length||await e3({title:e("overwriteConfirm.modal.loadFromFile.title"),actionLabel:e("overwriteConfirm.modal.loadFromFile.button"),color:"warning",description:je(ht,{i18nKey:"overwriteConfirm.modal.loadFromFile.description",bold:n=>je("strong",{children:n}),br:()=>je("br",{})})}))&&o.executeAction(Kn)},"data-testid":"load-button",shortcut:Ne("loadScene"),"aria-label":e("buttons.load"),children:e("buttons.load")}):null};i3.displayName="LoadScene";var a3=()=>{let{t:e}=Oe(),o=Ue();return o.isActionEnabled(Kr)?je(pt,{shortcut:Ne("saveScene"),"data-testid":"save-button",onSelect:()=>o.executeAction(Kr),icon:H1,"aria-label":`${e("buttons.save")}`,children:`${e("buttons.save")}`}):null};a3.displayName="SaveToActiveFile";var l3=()=>{let e=le(),{t:o}=Oe();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")})};l3.displayName="SaveAsImage";var s3=e=>{let o=le(),{t}=Oe();return je(pt,{icon:ea,"data-testid":"command-palette-button",onSelect:()=>{re("command_palette","open","menu"),o({openDialog:{name:"commandPalette"}})},shortcut:Ne("commandPalette"),"aria-label":t("commandPalette.title"),className:e?.className,children:t("commandPalette.title")})};s3.displayName="CommandPalette";var c3=e=>{let{t:o}=Oe(),t=Ue();return je(pt,{icon:Lt,"data-testid":"search-menu-button",onSelect:()=>{t.executeAction(za)},shortcut:Ne("searchMenu"),"aria-label":o("search.title"),className:e?.className,children:o("search.title")})};c3.displayName="SearchMenu";var d3=()=>{let{t:e}=Oe(),o=Ue();return je(pt,{"data-testid":"help-menu-item",icon:Tn,onSelect:()=>o.executeAction(Zr),shortcut:"?","aria-label":e("helpDialog.title"),children:e("helpDialog.title")})};d3.displayName="Help";var m3=()=>{let{t:e}=Oe(),o=jo(Jr);return Ue().isActionEnabled(_o)?je(pt,{icon:Mt,onSelect:()=>o("clearCanvas"),"data-testid":"clear-canvas-button","aria-label":e("buttons.clearReset"),children:e("buttons.clearReset")}):null};m3.displayName="ClearCanvas";var p3=e=>{let{t:o}=Oe(),t=ge(),r=Ue(),n=Ne("toggleTheme");return r.isActionEnabled(Yr)?e?.allowSystemTheme?je(n3,{name:"theme",value:e.theme,onChange:i=>e.onSelect(i),choices:[{value:Er.LIGHT,label:ji,ariaLabel:`${o("buttons.lightMode")} - ${n}`},{value:Er.DARK,label:$i,ariaLabel:`${o("buttons.darkMode")} - ${n}`},{value:"system",label:ob,ariaLabel:o("buttons.systemMode")}],children:o("labels.theme")}):je(pt,{onSelect:i=>{if(i.preventDefault(),e?.onSelect)e.onSelect(t.theme===Er.DARK?Er.LIGHT:Er.DARK);else return r.executeAction(Yr)},icon:t.theme===Er.DARK?ji:$i,"data-testid":"toggle-dark-mode",shortcut:n,"aria-label":t.theme===Er.DARK?o("buttons.lightMode"):o("buttons.darkMode"),children:t.theme===Er.DARK?o("buttons.lightMode"):o("buttons.darkMode")}):null};p3.displayName="ToggleTheme";var u3=()=>{let{t:e}=Oe(),o=ge(),t=Ue(),r=fo();return o.viewModeEnabled||!r.UIOptions.canvasActions.changeViewBackgroundColor?null:b3("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")})]})};u3.displayName="ChangeCanvasBackground";var h3=()=>{let{t:e}=Oe(),o=le();return je(pt,{icon:Fr,onSelect:()=>{o({openDialog:{name:"jsonExport"}})},"data-testid":"json-export-button","aria-label":e("buttons.export"),children:e("buttons.export")})};h3.displayName="Export";var g3=()=>{let{t:e}=Oe();return b3(sN,{children:[je(mi,{icon:Kl,href:"https://github.com/excalidraw/excalidraw","aria-label":"GitHub",children:"GitHub"}),je(mi,{icon:O1,href:"https://x.com/excalidraw","aria-label":"X",children:e("labels.followUs")}),je(mi,{icon:F1,href:"https://discord.gg/UexuTaE","aria-label":"Discord",children:e("labels.discordChat")})]})};g3.displayName="Socials";var f3=({onSelect:e,isCollaborating:o})=>{let{t}=Oe();return je(pt,{"data-testid":"collab-button",icon:jl,className:lN({"active-collab":o}),onSelect:e,children:t("labels.liveCollaboration")})};f3.displayName="LiveCollaborationTrigger";import{jsx as fd,jsxs as pg}from"react/jsx-runtime";var dN=Object.assign(Wo("MainMenu",({children:e,onSelect:o})=>{let{MainMenuTunnel:t}=ve(),r=se(),n=ge(),i=le(),a=r.editor.isMobile?void 0:()=>i({openMenu:null});return fd(t.In,{children:pg(fe,{open:n.openMenu==="canvas",children:[fd(fe.Trigger,{onToggle:()=>{i({openMenu:n.openMenu==="canvas"?null:"canvas"})},"data-testid":"main-menu-trigger",className:"main-menu-trigger",children:Xl}),pg(fe.Content,{onClickOutside:a,onSelect:cN(o,()=>{i({openMenu:null})}),children:[e,r.editor.isMobile&&n.collaborators.size>0&&pg("fieldset",{className:"UserList-Wrapper",children:[fd("legend",{children:g("labels.collaborators")}),fd(ud,{mobile:!0,collaborators:n.collaborators,userToFollow:n.userToFollow?.socketId||null})]})]})]})})}),{Trigger:fe.Trigger,Item:fe.Item,ItemLink:fe.ItemLink,ItemCustom:fe.ItemCustom,Group:fe.Group,Separator:fe.Separator,DefaultItems:mg}),dt=dN;import mN from"clsx";import{forwardRef as pN,useState as uN}from"react";import{isPromiseLike as hN}from"@excalidraw/common";import{jsx as bd,jsxs as gN}from"react/jsx-runtime";var yr=pN(({children:e,icon:o,onClick:t,label:r,variant:n="filled",color:i="primary",size:a="medium",fullWidth:l,className:s,status:d},m)=>{let[c,p]=uN(!1),u=async b=>{let x=t?.(b);if(hN(x)){let w=window.setTimeout(()=>{p(!0)},50);try{await x}catch(E){if(E instanceof hn)console.warn(E);else throw E}finally{clearTimeout(w),p(!1)}}},f=c?"loading":d;return i=f==="success"?"success":i,bd("button",{className:mN("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:gN("div",{className:"ExcButton__contents",children:[f==="loading"?bd(tt,{className:"ExcButton__statusIcon"}):f==="success"&&bd("div",{className:"ExcButton__statusIcon",children:F0}),o&&bd("div",{className:"ExcButton__icon","aria-hidden":!0,children:o}),n!=="icon"&&(e??r)]})})});import{jsx as ki,jsxs as xN}from"react/jsx-runtime";var xd=({title:e,children:o,actionLabel:t,onClick:r})=>xN("div",{className:"OverwriteConfirm__Actions__Action",children:[ki("h4",{children:e}),ki("div",{className:"OverwriteConfirm__Actions__Action__content",children:o}),ki(yr,{variant:"outlined",color:"muted",label:t,size:"large",fullWidth:!0,onClick:r})]}),fN=()=>{let{t:e}=Oe(),o=Ue(),t=le();return ki(xd,{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")})},bN=()=>{let{t:e}=Oe(),o=Ue();return ki(xd,{title:e("overwriteConfirm.action.saveToDisk.title"),actionLabel:e("overwriteConfirm.action.saveToDisk.button"),onClick:()=>{o.executeAction(Ta,"ui")},children:e("overwriteConfirm.action.saveToDisk.description")})},ug=Object.assign(({children:e})=>ki("div",{className:"OverwriteConfirm__Actions",children:e}),{ExportToImage:fN,SaveToDisk:bN});import{jsx as wr,jsxs as x3}from"react/jsx-runtime";var Ed=Object.assign(Wo("OverwriteConfirmDialog",({children:e})=>{let{OverwriteConfirmDialogTunnel:o}=ve(),[t,r]=ie(cg);if(!t.active)return null;let n=()=>{t.onClose(),r(a=>({...a,active:!1}))},i=()=>{t.onConfirm(),r(a=>({...a,active:!1}))};return wr(o.In,{children:wr(Be,{onCloseRequest:n,title:!1,size:916,children:x3("div",{className:"OverwriteConfirm",children:[wr("h3",{children:t.title}),x3("div",{className:`OverwriteConfirm__Description OverwriteConfirm__Description--color-${t.color}`,children:[wr("div",{className:"OverwriteConfirm__Description__icon",children:O0}),wr("div",{children:t.description}),wr("div",{className:"OverwriteConfirm__Description__spacer"}),wr(yr,{color:t.color,size:"large",label:t.actionLabel,onClick:i})]}),wr(ug,{children:e})]})})})}),{Actions:ug,Action:xd});import HN from"clsx";import{CANVAS_SEARCH_TAB as xg,DEFAULT_SIDEBAR as GN,LIBRARY_SIDEBAR_TAB as M3,composeEventHandlers as UN}from"@excalidraw/common";import{round as EN}from"@excalidraw/math";import yN from"clsx";import wN from"lodash.debounce";import{Fragment as vN,memo as TN,useEffect as el,useMemo as E3,useRef as hg,useState as y3}from"react";import{CLASSES as IN,EVENT as CN,FONT_FAMILY as gg,FRAME_STYLE as fg,getLineHeight as SN}from"@excalidraw/common";import{isElementCompletelyInViewport as kN}from"@excalidraw/element";import{measureText as tl}from"@excalidraw/element";import{KEYS as Mi,randomInteger as w3,addEventListener as MN,getFontString as yd}from"@excalidraw/common";import{newTextElement as LN}from"@excalidraw/element";import{isTextElement as C3,isFrameLikeElement as wd}from"@excalidraw/element";import{getDefaultFrameName as S3}from"@excalidraw/element/frame";import{Fragment as zN,jsx as Je,jsxs as To}from"react/jsx-runtime";var PN=me(""),bg=me(null),AN=350,k3=()=>{let e=Re(),o=le(),t=hg(null),[r,n]=ie(PN),i=r.trim(),[a,l]=y3(!1),[s,d]=y3({nonce:null,items:[]}),m=hg(null),c=hg(void 0),[p,u]=ie(bg),f=e.scene.getNonDeletedElementsMap();el(()=>{a||(i!==m.current||e.scene.getSceneNonce()!==c.current)&&(m.current=null,I3(i,e,(y,v)=>{d({nonce:w3(),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=LN({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:wd(y.element)?fg.nameFontSize:y.element.fontSize,fontFamily:wd(y.element)?gg.Assistant:y.element.fontFamily}),S=14,L=C.fontSize,k=L*v<S;if(!kN([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:EN(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=Jo({goToNextItem:b,goToPreviousItem:x,searchMatches:s});el(()=>{let y=v=>{if(v.key===Mi.ESCAPE&&!e.state.openDialog&&!e.state.openPopup){v.preventDefault(),v.stopPropagation(),o({openSidebar:null});return}if(v[Mi.CTRL_OR_CMD]&&v.key===Mi.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===Mi.ENTER&&(v.stopPropagation(),w.goToNextItem()),v.key===Mi.ARROW_UP?(v.stopPropagation(),w.goToPreviousItem()):v.key===Mi.ARROW_DOWN&&(v.stopPropagation(),w.goToNextItem()))};return MN(window,CN.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(hi,{className:IN.SEARCH_MENU_INPUT_WRAPPER,value:r,ref:t,placeholder:g("search.placeholder"),icon:Lt,onChange:y=>{n(y),l(!0);let v=y.trim();I3(v,e,(C,S)=>{d({nonce:w3(),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(zN,{children:[p!==null&&p>-1?To("div",{children:[p+1," / ",E]}):Je("div",{children:E}),To("div",{className:"result-nav",children:[Je(_t,{onSelect:()=>{b()},className:"result-nav-btn",children:as}),Je(_t,{onSelect:()=>{x()},className:"result-nav-btn",children:lb})]})]}),s.items.length===0&&i&&m.current&&Je("div",{style:{margin:"1rem auto"},children:g("search.noMatch")})]}),Je(RN,{matches:s,onItemClick:u,focusIndex:p,searchQuery:i})]})},v3=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:yN("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,r)=>Je(vN,{children:r===2?Je("b",{children:t}):t},r))})})},DN=e=>{let o=E3(()=>e.matches.items.filter(r=>wd(r.element)),[e.matches]),t=E3(()=>e.matches.items.filter(r=>C3(r.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:zr}),Je("div",{children:g("search.frames")})]}),o.map((r,n)=>Je(v3,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n===e.focusIndex,onClick:()=>e.onItemClick(n)},r.element.id+r.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:vn}),Je("div",{children:g("search.texts")})]}),t.map((r,n)=>Je(v3,{searchQuery:e.searchQuery,preview:r.preview,highlighted:n+o.length===e.focusIndex,onClick:()=>e.onItemClick(n+o.length)},r.element.id+r.index))]})]})},_N=(e,o)=>e.matches.nonce===o.matches.nonce&&e.focusIndex===o.focusIndex,RN=TN(DN,_N),T3=(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}},NN=(e,o)=>{let t=e.split(`
17
+ `),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 d=s-(a.length+n);for(;d>0;)a+=" ",d--}}r.push(a),n=n+a.length}return r.join(`
18
+ `)},BN=(e,o,t)=>{let n=NN(e.text,e.originalText).split(`
19
+ `),i=[],a=0,l=0;for(let c of n){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,yd(e),e.lineHeight);if(u===""&&(b.width=0),e.textAlign!=="left"&&c.line.length>0){let v=tl(c.line,yd(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,yd(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},FN=(e,o,t,r)=>{let n=e.name??S3(e),i=n.slice(t,t+o.length),a=n.slice(0,t),l=yd({fontSize:fg.nameFontSize,fontFamily:gg.Assistant}),s=SN(gg.Assistant),d=tl(a,l,s);a===""&&(d.width=0);let m=tl(i,l,s),c=d.width,p=-d.height-fg.strokeWidth,u=m.width;return[{offsetX:c,offsetY:p,width:u,height:m.height,showOnCanvas:c+u<=e.width*r}]},ON=e=>e.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&"),I3=wN((e,o,t)=>{if(!e||e===""){t([],null);return}let r=o.scene.getNonDeletedElements(),n=r.filter(p=>C3(p)),i=r.filter(p=>wd(p));n.sort((p,u)=>p.y-u.y),i.sort((p,u)=>p.y-u.y);let a=[],l=new RegExp(ON(e),"gi");for(let p of n){let u=null,f=p.originalText;for(;(u=l.exec(f))!==null;){let b=T3(f,u.index,e),x=BN(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??S3(p);for(;(u=l.exec(f))!==null;){let b=T3(f,u.index,e),x=FN(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)},AN);import{jsx as lo,jsxs as L3}from"react/jsx-runtime";import{createElement as YN}from"react";var P3=Wo("DefaultSidebarTrigger",e=>{let{DefaultSidebarTriggerTunnel:o}=ve();return lo(o.In,{children:lo(Xt.Trigger,{...e,className:"default-sidebar-trigger",name:GN.name})})});P3.displayName="DefaultSidebarTrigger";var A3=({children:e})=>{let{DefaultSidebarTabTriggersTunnel:o}=ve();return lo(o.In,{children:e})};A3.displayName="DefaultTabTriggers";var vd=Object.assign(Wo("DefaultSidebar",({children:e,className:o,onDock:t,docked:r,...n})=>{let i=ge(),a=le(),{DefaultSidebarTabTriggersTunnel:l}=ve(),s=i.openSidebar?.tab===xg;return YN(Xt,{...n,name:"default",key:"default",className:HN("default-sidebar",o),docked:s||(r??i.defaultSidebarDockedPreference),onDock:s||t===!1||!t&&r!=null?void 0:UN(t,d=>{a({defaultSidebarDockedPreference:d})})},L3(Xt.Tabs,{children:[lo(Xt.Header,{children:L3(Xt.TabTriggers,{children:[lo(Xt.TabTrigger,{tab:xg,children:Lt}),lo(Xt.TabTrigger,{tab:M3,children:yn}),lo(l.Out,{})]})}),lo(Xt.Tab,{tab:M3,children:lo(e2,{})}),lo(Xt.Tab,{tab:xg,children:lo(k3,{})}),e]}))}),{Trigger:P3,TabTriggers:A3});import{useEffect as cB,useRef as wg,useState as Dd}from"react";import{isFiniteNumber as Q3}from"@excalidraw/math";import{useState as z3,useRef as H3,useEffect as G3,useDeferredValue as JN}from"react";import{EDITOR_LS_KEYS as QN,debounce as eB,isDevEnv as tB}from"@excalidraw/common";import{useEffect as WN,useRef as D3}from"react";import{EVENT as _3,KEYS as R3}from"@excalidraw/common";import{jsx as VN}from"react/jsx-runtime";var Td=({input:e,placeholder:o,onChange:t,onKeyboardSubmit:r})=>{let n=D3(null),i=D3(r);return i.current=r,WN(()=>{if(!i.current)return;let a=n.current;if(a){let l=s=>{s[R3.CTRL_OR_CMD]&&s.key===R3.ENTER&&(s.preventDefault(),i.current?.())};return a.focus(),a.addEventListener(_3.KEYDOWN,l),()=>{a.removeEventListener(_3.KEYDOWN,l)}}},[]),VN("textarea",{className:"ttd-dialog-input",onChange:t,value:e,placeholder:o,ref:n})};import{jsx as Id,jsxs as N3}from"react/jsx-runtime";var XN=({error:e})=>N3("div",{"data-testid":"ttd-dialog-output-error",className:"ttd-dialog-output-error",children:["Error! ",Id("p",{children:e})]}),Cd=({error:e,canvasRef:o,loaded:t})=>N3("div",{className:"ttd-dialog-output-wrapper",children:[e&&Id(XN,{error:e.message}),t?Id("div",{ref:o,style:{opacity:e?"0.15":1},className:"ttd-dialog-output-canvas-container"}):Id(tt,{size:"2rem"})]});import B3 from"clsx";import{jsx as Eg,jsxs as ol}from"react/jsx-runtime";var Li=({label:e,children:o,panelAction:t,panelActionDisabled:r=!1,onTextSubmitInProgess:n,renderTopRight:i,renderSubmitShortcut:a,renderBottomRight:l})=>ol("div",{className:"ttd-dialog-panel",children:[ol("div",{className:"ttd-dialog-panel__header",children:[Eg("label",{children:e}),i?.()]}),o,ol("div",{className:B3("ttd-dialog-panel-button-container",{invisible:!t}),style:{display:"flex",alignItems:"center"},children:[ol(_t,{className:"ttd-dialog-panel-button",onSelect:t?t.action:()=>{},disabled:r||n,children:[ol("div",{className:B3({invisible:n}),children:[t?.label,t?.icon&&Eg("span",{children:t.icon})]}),n&&Eg(tt,{})]}),!r&&!n&&a?.(),l?.()]})]});import{jsx as KN}from"react/jsx-runtime";var Sd=({children:e})=>KN("div",{className:"ttd-dialog-panels",children:e});import{getShortcutKey as F3}from"@excalidraw/common";import{jsx as O3,jsxs as ZN}from"react/jsx-runtime";var kd=()=>ZN("div",{className:"ttd-dialog-submit-shortcut",children:[O3("div",{className:"ttd-dialog-submit-shortcut__key",children:F3("CtrlOrCmd")}),O3("div",{className:"ttd-dialog-submit-shortcut__key",children:F3("Enter")})]});import{DEFAULT_EXPORT_PADDING as $N,EDITOR_LS_KEYS as jN}from"@excalidraw/common";var qN=({canvasRef:e,setError:o})=>{let t=e.current;if(!t)return;let r=t.parentElement;r&&(r.style.background="",o(null),t.replaceChildren())},Md=async({canvasRef:e,mermaidToExcalidrawLib:o,mermaidDefinition:t,setError:r,data:n})=>{let i=e.current,a=i?.parentElement;if(!(!i||!a)){if(!t){qN({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:d,files:m}=s;r(null),n.current={elements:Ii(d,{regenerateIds:!0}),files:m};let c=await cr({elements:n.current.elements,files:n.current.files,exportPadding:$N,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&&r(l),l}}},rl=e=>{Gt.set(jN.MERMAID_TO_EXCALIDRAW,e)},Ld=({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&&rl(t))};import{Fragment as nB,jsx as Io,jsxs as Y3}from"react/jsx-runtime";var oB=`flowchart TD
12
20
  A[Christmas] -->|Get money| B(Go shopping)
13
21
  B --> C{Let me think}
14
22
  C -->|One| D[Laptop]
15
23
  C -->|Two| E[iPhone]
16
- C -->|Three| F[Car]`,w3=Yn(gs,300),NM=({mermaidToExcalidrawLib:e})=>{let[o,t]=E3(()=>Ro.get(tn.MERMAID_TO_EXCALIDRAW)||RM),r=PM(o.trim()),[n,i]=E3(null),a=y3(null),l=y3({elements:[],files:null}),s=st();v3(()=>{Vm({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:r}).catch(m=>{Ue()&&console.error("Failed to parse mermaid definition",m)}),w3(r)},[r,e]),v3(()=>()=>{w3.flush()},[]);let c=()=>{Ym({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return T3(OM,{children:[wr("div",{className:"ttd-dialog-desc",children:wr(Kt,{i18nKey:"mermaid.description",flowchartLink:m=>wr("a",{href:"https://mermaid.js.org/syntax/flowchart.html",children:m}),sequenceLink:m=>wr("a",{href:"https://mermaid.js.org/syntax/sequenceDiagram.html",children:m}),classLink:m=>wr("a",{href:"https://mermaid.js.org/syntax/classDiagram.html",children:m})})}),T3(Um,{children:[wr(Va,{label:f("mermaid.syntax"),children:wr(zm,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:m=>t(m.target.value),onKeyboardSubmit:()=>{c()}})}),wr(Va,{label:f("mermaid.preview"),panelAction:{action:()=>{c()},label:f("mermaid.button"),icon:da},renderSubmitShortcut:()=>wr(Gm,{}),children:wr(Hm,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},C3=NM;import*as S3 from"@radix-ui/react-tabs";import{useRef as I3}from"react";import{jsx as BM}from"react/jsx-runtime";var k3=e=>{let o=Ie(),t=I3(null),r=I3(0);return BM(S3.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"&&qs(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};k3.displayName="TTDDialogTabs";var M3=k3;import*as L3 from"@radix-ui/react-tabs";import{jsx as zM}from"react/jsx-runtime";var Zg=({children:e,...o})=>zM(L3.List,{className:"ttd-dialog-triggers",...o,children:e});Zg.displayName="TTDDialogTabTriggers";import*as _3 from"@radix-ui/react-tabs";import{jsx as A3}from"react/jsx-runtime";var Wm=({children:e,tab:o,onSelect:t,...r})=>A3(_3.Trigger,{value:o,asChild:!0,onSelect:t,children:A3("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});Wm.displayName="TTDDialogTabTrigger";import*as D3 from"@radix-ui/react-tabs";import{jsx as FM}from"react/jsx-runtime";var Km=({tab:e,children:o,...t})=>FM(D3.Content,{...t,value:e,children:o});Km.displayName="TTDDialogTab";import{jsx as $t,jsxs as Dn}from"react/jsx-runtime";var $g=3,Ya=1e3,UM=De(null),GM=De(null),jg=e=>{let o=Re();return o.openDialog?.name!=="ttd"?null:$t(VM,{...e,tab:o.openDialog.tab})},VM=Zr("TTDDialogBase",({tab:e,...o})=>{let t=st(),r=Ie(),n=Xg(null),[i,a]=ve(GM),[l,s]=Zm(i?.prompt??""),c=l.trim(),m=S=>{s(S.target.value),a(_=>({generatedResponse:_?.generatedResponse??null,prompt:S.target.value}))},[d,p]=Zm(!1),[u,g]=ve(UM),b=async()=>{if(c.length>Ya||c.length<$g||d||u?.rateLimitRemaining===0||"__fallback"in o){c.length<$g&&I(new Error(`Prompt is too short (min ${$g} characters)`)),c.length>Ya&&I(new Error(`Prompt is too long (max ${Ya} characters)`));return}try{p(!0),xe("ai","generate","ttd");let{generatedResponse:S,error:_,rateLimit:L,rateLimitRemaining:N}=await o.onTextSubmit(c);if(typeof S=="string"&&a(P=>({generatedResponse:S,prompt:P?.prompt??null})),bp(L)&&bp(N)&&g({rateLimit:L,rateLimitRemaining:N}),_){I(_);return}if(!S){I(new Error("Generation failed"));return}try{await Vm({canvasRef:n,data:y,mermaidToExcalidrawLib:E,setError:I,mermaidDefinition:S}),xe("ai","mermaid parse success","ttd")}catch(P){console.info(`%cTTD mermaid render errror: ${P.message}`,"color: red"),console.info(`>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
17
- TTD mermaid definition render errror: ${P.message}`,"color: yellow"),xe("ai","mermaid parse failed","ttd"),I(new Error("Generated an invalid diagram :(. You may also try a different prompt."))}}catch(S){let _=S.message;(!_||_==="Failed to fetch")&&(_="Request failed"),I(new Error(_))}finally{p(!1)}},x=Xg(b);x.current=b;let[E,w]=Zm({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});HM(()=>{(async()=>{await E.api,w(_=>({..._,loaded:!0}))})()},[E.api]);let y=Xg({elements:[],files:null}),[v,I]=Zm(null);return $t(dt,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:Dn(M3,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?$t("p",{className:"dialog-mermaid-title",children:f("mermaid.title")}):Dn(Zg,{children:[$t(Wm,{tab:"text-to-diagram",children:Dn("div",{style:{display:"flex",alignItems:"center"},children:[f("labels.textToDiagram"),$t("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"})]})}),$t(Wm,{tab:"mermaid",children:"Mermaid"})]}),$t(Km,{className:"ttd-dialog-content",tab:"mermaid",children:$t(C3,{mermaidToExcalidrawLib:E})}),!("__fallback"in o)&&Dn(Km,{className:"ttd-dialog-content",tab:"text-to-diagram",children:[$t("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."}),Dn(Um,{children:[$t(Va,{label:f("labels.prompt"),panelAction:{action:b,label:"Generate",icon:da},onTextSubmitInProgess:d,panelActionDisabled:c.length>Ya||u?.rateLimitRemaining===0,renderTopRight:()=>u?Dn("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:()=>$t(Gm,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return Dn("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(gs(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",$t(vn,{icon:da})]});let S=c.length/Ya;return S>.8?Dn("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",c.length,"/",Ya]}):null},children:$t(zm,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),$t(Va,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Ym({app:t,data:y})},label:"Insert",icon:da},children:$t(Hm,{canvasRef:n,error:v,loaded:E.loaded})})]})]})]})})});import PL from"clsx";import RL from"lodash.throttle";import{useEffect as K3,useMemo as of,useState as NL,memo as OL}from"react";import YM from"clsx";import{useEffect as R3,useRef as $m,useState as WM}from"react";var P3=.01,so=(e,o)=>!(o==="height"&&Z(e)||o==="width"&&Z(e)||o==="angle"&&ne(e)),je=(e,o)=>{let t=e+o/2;return t-t%o},Wa=(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 Si=(e,o,t,r,n,i,a,l=!0)=>{let s=r.get(t.id);if(!s)return;let[c,m]=[t.x+t.width/2,t.y+t.height/2],[d,p]=ce(M(t.x,t.y),M(c,m),t.angle),u=e-d,g=o-p,[b,x]=ce(M(e,o),M(c+u,m+g),-t.angle);B(s,{x:b,y:x},l),Xm(s,r,n,i);let E=ge(t,a);if(E){let w=r.get(E.id);w&&B(w,{x:E.x+u,y:E.y+g},l)}},Ka=(e,o)=>{let r=Zo(o).map(n=>Fe(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!sr(n)).forEach(n=>{r.push({[n.id]:!0})}),r},Xm=(e,o,t,r,n)=>{ae(e)?Qn([e],o,t,r,!0,[],n?.zoom):at(e,o,n)};import{jsx as qg,jsxs as ZM}from"react/jsx-runtime";var KM=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:c,sensitivity:m=1})=>{let d=st(),p=$m(null),u=$m(null),[g,b]=WM(r.toString()),x=$m(null);x.current||(x.current={originalAppState:oo(c),originalElements:n,lastUpdatedValue:g,updatePending:!1}),R3(()=>{let y=r.toString();b(y),x.current.lastUpdatedValue=y},[r]);let E=(y,v,I)=>{if(!x.current.updatePending)return!1;x.current.updatePending=!1;let S=Number(y);if(isNaN(S)){b(r.toString());return}let _=Number(S.toFixed(2)),L=Number(r);(isNaN(L)||Math.abs(_-L)>=P3)&&(x.current.lastUpdatedValue=y,t({accumulatedChange:0,instantChange:0,originalElements:v,originalElementsMap:d.scene.getNonDeletedElementsMap(),shouldKeepAspectRatio:a,shouldChangeByStepSize:!1,scene:s,nextValue:_,property:l,originalAppState:I,setInputValue:N=>b(String(N))}),d.syncActionResult({captureUpdate:A.IMMEDIATELY}))},w=$m({});return w.current.handleInputValue=E,R3(()=>{let y=p.current,v=w.current;return()=>{let I=y?.value;I&&v.handleInputValue?.(I,x.current.originalElements,x.current.originalAppState),window.removeEventListener("pointermove",v.onPointerMove,!1),window.removeEventListener("pointerup",v.onPointerUp,!1)}},[i]),i?ZM("div",{className:YM("drag-input-container",!i&&"disabled"),"data-testid":e,children:[qg("div",{className:"drag-input-label",ref:u,onPointerDown:y=>{if(p.current&&i){document.body.classList.add("excalidraw-cursor-resize");let v=Number(p.current.value);isNaN(v)&&(v=0);let I=null,S=d.scene.getNonDeletedElements().reduce((U,q)=>(U.set(q.id,uo(q)),U),new Map),_=n.map(U=>S.get(U.id)),L=oo(c),N=0,P=0,F=U=>{if(I&&S!==null&&_!==null){let q=U.clientX-I.x;q!==0&&(P+=q,Math.abs(P)>=m&&(P=Math.sign(P)*Math.floor(Math.abs(P)/m),N+=P,t({accumulatedChange:N,instantChange:P,originalElements:_,originalElementsMap:S,shouldKeepAspectRatio:a,shouldChangeByStepSize:U.shiftKey,property:l,scene:s,originalAppState:L,setInputValue:H=>b(String(H))}),P=0))}I={x:U.clientX,y:U.clientY}},K=()=>{window.removeEventListener("pointermove",F,!1),d.syncActionResult({captureUpdate:A.IMMEDIATELY}),I=null,N=0,P=0,_=null,S=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?qg(vn,{icon:o}):e}),qg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:y=>{if(i){let v=y.target;v instanceof HTMLInputElement&&y.key===T.ENTER&&(E(v.value,n,c),d.focusContainer())}},ref:p,value:g,onChange:y=>{x.current.updatePending=!0,b(y.target.value)},onFocus:y=>{y.target.select(),x.current.originalElements=n,x.current.originalAppState=oo(c)},onBlur:y=>{g?i&&E(y.target.value,x.current.originalElements,x.current.originalAppState):b(r.toString())},disabled:!i})]}):null},It=KM;import{jsx as qM}from"react/jsx-runtime";var XM=15,$M=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=n.getNonDeletedElements(),l=o[0];if(l&&!te(l)){let s=i.get(l.id);if(!s)return;if(r!==void 0){let g=_i(r);B(s,{angle:g}),Xm(s,i,a,n);let b=ge(s,i);b&&!ke(s)&&B(b,{angle:g});return}let c=Math.round(Di(l.angle)*100)/100,m=Math.round(e),d=(c+m)%360;t&&(d=je(d,XM)),d=d<0?d+360:d;let p=_i(d);B(s,{angle:p}),Xm(s,i,a,n);let u=ge(s,i);u&&!ke(s)&&B(u,{angle:p})}},jM=({element:e,scene:o,appState:t,property:r})=>qM(It,{label:"A",icon:td,value:Math.round(Di(e.angle)%360*100)/100,elements:[e],dragInputCallback:$M,editable:so(e,"angle"),scene:o,appState:t,property:r}),N3=jM;import{jsx as QM}from"react/jsx-runtime";var O3=5,JM=({property:e,scene:o,appState:t,setAppState:r})=>QM(It,{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?je(s.gridStep+O3*Math.sign(i),O3):s.gridStep+i),c?(c=i0(c),l(c),{gridStep:c}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),B3=JM;import{jsx as rL}from"react/jsx-runtime";var z3=10,eL=e=>e.type==="image",tL=({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||eL(d),g=d.width/d.height;if(l.croppingElementId===d.id){let y=m.get(d.id);if(!y||!he(y)||!y.crop)return;let v=y.crop,I={...v},S=y.scale[0]===-1,_=y.scale[1]===-1,{width:L,height:N}=ri(y),P=v.naturalWidth/L,F=v.naturalHeight/N,K=S?v.width+v.x:v.naturalWidth-v.x,U=_?v.height+v.y:v.naturalHeight-v.y,q=Wp*P,H=Wp*F;if(i!==void 0){if(a==="width"){let se=i*P,be=Tt(se,q,K);I={...I,width:be,x:S?v.x+v.width-be:v.x}}else if(a==="height"){let se=i*F,be=Tt(se,H,U);I={...I,height:be,y:_?v.y+v.height-be:v.y}}B(y,{crop:I,width:I.width/(v.naturalWidth/L),height:I.height/(v.naturalHeight/N)});return}let G=a==="width"?s:0,V=a==="height"?s:0,ie=Tt(v.width+G,q,K),$=Tt(v.height+V,q,U);I={...v,x:S?v.x+v.width-ie:v.x,y:_?v.y+v.height-$:v.y,width:ie,height:$},B(y,{crop:I,width:I.width/(v.naturalWidth/L),height:I.height/(v.naturalHeight/N)});return}if(i!==void 0){let y=Math.max(a==="width"?i:u?i*g:d.width,to),v=Math.max(a==="height"?i:u?i/g:d.height,to);di(y,v,p,d,m,t,a==="width"?"e":"s",{shouldMaintainAspectRatio:u});return}let b=a==="width"?e:0,x=a==="height"?e:0,E=Math.max(0,d.width+b);a==="width"&&(n?E=je(E,z3):E=Math.round(E));let w=Math.max(0,d.height+x);a==="height"&&(n?w=je(w,z3):w=Math.round(w)),u&&(a==="width"?w=Math.round(E/g*100)/100:E=Math.round(w*g*100)/100),w=Math.max(to,w),E=Math.max(to,E),di(E,w,p,d,m,t,a==="width"?"e":"s",{shouldMaintainAspectRatio:u})}},oL=({property:e,element:o,scene:t,appState:r})=>{let n=So(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&he(o)&&o.crop){let{width:i,height:a}=ri(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=So(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=So(o.crop.height*l,2)}}return rL(It,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:tL,value:n,editable:so(o,e),scene:t,appState:r,property:e})},Jg=oL;import{jsx as lL}from"react/jsx-runtime";var F3=4,nL=4,iL=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a){let l=i.get(a.id);if(!l||!Z(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),F3);else if(a.type==="text"){let c=Math.round(a.fontSize),m=Math.round(e);s=Math.max(c+m,F3),t&&(s=je(s,nL))}s&&(B(l,{fontSize:s}),Qe(l,n.getContainerElement(l),n.getNonDeletedElementsMap()))}},aL=({element:e,scene:o,appState:t,property:r})=>{let n=Z(e)?e:pt(e)?ge(e,o.getNonDeletedElementsMap()):null;return n?lL(It,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:iL,icon:ui,appState:t,scene:o,property:r}):null},H3=aL;import{jsx as mL}from"react/jsx-runtime";var sL=15,cL=({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&&!sr(c)&&so(c,n)),s=o.filter(c=>!sr(c)&&so(c,n));if(r!==void 0){let c=_i(r);for(let m of l){if(!m)continue;B(m,{angle:c},!1);let d=ge(m,a);d&&!ke(m)&&B(d,{angle:c},!1)}i.triggerUpdate();return}for(let c=0;c<l.length;c++){let m=l[c];if(!m)continue;let d=s[c],p=Math.round(Di(d.angle)*100)/100,u=Math.round(e),g=(p+u)%360;t&&(g=je(g,sL)),g=g<0?g+360:g;let b=_i(g);B(m,{angle:b},!1);let x=ge(m,a);x&&!ke(m)&&B(x,{angle:b},!1)}i.triggerUpdate()},dL=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!sr(s)&&so(s,"angle")),i=n.map(s=>Math.round(Di(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>so(s,"angle"));return mL(It,{label:"A",icon:td,value:a,elements:e,dragInputCallback:cL,editable:l,appState:t,scene:o,property:r})},U3=dL;import{useMemo as pL}from"react";import{jsx as bL}from"react/jsx-runtime";var Za=10,uL=(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,...Uc(r,a,l,!1),...Z(r)?{fontSize:r.fontSize*t}:{}}},hL=(e,o,t,r,n,i,a,l)=>{let s=uL(e,o,r,i);B(n,s,!1);let c=ge(i,l);if(c){let m=c.fontSize*r;at(n,a,{newSize:{width:s.width,height:s.height}});let d=a.get(c.id);d&&Z(d)&&(B(d,{fontSize:m},!1),hl(n,a,t==="width"?"e":"s",!0))}},G3=(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];hL(n[0],n[1],i,m,u,p,s,c)}},gL=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l})=>{let s=a.getNonDeletedElementsMap(),c=Ka(o,r);if(i!==void 0){for(let p of c){let u=Wa(p,s,t);if(u.length>1){let g=u.map(N=>N.latest),b=u.map(N=>N.original),[x,E,w,y]=ye(b),v=w-x,I=y-E,S=v/I,_=Math.max(to,l==="width"?Math.max(0,i):v),L=Math.max(to,l==="height"?Math.max(0,i):I);G3(_,L,I,S,M(x,E),l,g,b,s,t)}else{let[g]=u,b=g?.latest,x=g?.original;if(b&&x&&so(b,l)){let E=l==="width"?Math.max(0,i):b.width;l==="width"&&(n?E=je(E,Za):E=Math.round(E));let w=l==="height"?Math.max(0,i):b.height;l==="height"&&(n?w=je(w,Za):w=Math.round(w)),E=Math.max(to,E),w=Math.max(to,w),di(E,w,b,x,s,t,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate();return}let m=l==="width"?e:0,d=l==="height"?e:0;for(let p of c){let u=Wa(p,s,t);if(u.length>1){let g=u.map(N=>N.latest),b=u.map(N=>N.original),[x,E,w,y]=ye(b),v=w-x,I=y-E,S=v/I,_=Math.max(0,v+m);l==="width"&&(n?_=je(_,Za):_=Math.round(_));let L=Math.max(0,I+d);l==="height"&&(n?L=je(L,Za):L=Math.round(L)),_=Math.max(to,_),L=Math.max(to,L),G3(_,L,I,S,M(x,E),l,g,b,s,t)}else{let[g]=u,b=g?.latest,x=g?.original;if(b&&x&&so(b,l)){let E=Math.max(0,x.width+m);l==="width"&&(n?E=je(E,Za):E=Math.round(E));let w=Math.max(0,x.height+d);l==="height"&&(n?w=je(w,Za):w=Math.round(w)),E=Math.max(to,E),w=Math.max(to,w),di(E,w,b,x,s,t,l==="width"?"e":"s",{shouldInformMutation:!1})}}}a.triggerUpdate()},fL=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=pL(()=>r.map(c=>{let m=Wa(c,t);if(m.length>1){let[p,u,g,b]=ye(m.map(x=>x.latest));return Math.round((e==="width"?g-p:b-u)*100)/100}let[d]=m;return Math.round((e==="width"?d.latest.width:d.latest.height)*100)/100}),[t,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return bL(It,{label:e==="width"?"W":"H",elements:o,dragInputCallback:gL,value:l,editable:s,appState:i,property:e,scene:n})},Qg=fL;import{jsx as wL}from"react/jsx-runtime";var V3=4,xL=4,EL=(e,o)=>e.reduce((t,r)=>{if(!r||sr(r))return t;if(Z(r))return t.push(r),t;if(pt(r)){let n=ge(r,o);if(n)return t.push(n),t}return t},[]),yL=({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),V3);for(let s of a)B(s,{fontSize:l},!1),Qe(s,n.getContainerElement(s),i,!1);n.triggerUpdate()}else{let s=o;for(let c=0;c<a.length;c++){let m=a[c],d=s[c],p=Math.round(d.fontSize),u=Math.round(e),g=Math.max(p+u,V3);t&&(g=je(g,xL)),B(m,{fontSize:g},!1),Qe(m,n.getContainerElement(m),i,!1)}n.triggerUpdate()}},vL=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=EL(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 wL(It,{label:"F",icon:ui,elements:i,dragInputCallback:yL,value:l,editable:s,scene:o,property:r,appState:t})},Y3=vL;import{useMemo as TL}from"react";import{jsx as LL}from"react/jsx-runtime";var CL=10,IL=(e,o,t,r,n,i,a,l)=>{for(let s=0;s<r.length;s++){let c=n[s],[m,d]=[c.x+c.width/2,c.y+c.height/2],[p,u]=ce(M(c.x,c.y),M(m,d),c.angle),g=e==="x"?Math.round(p+o):p,b=e==="y"?Math.round(u+t):u;Si(g,b,c,i,r,l,a,!1)}},SL=(e,o,t,r,n,i,a)=>{let[l,s,,]=ye(t),c=e-l,m=o-s;for(let d=0;d<t.length;d++){let p=t[d],u=r.get(p.id);if(u&&(!Z(u)||!u.containerId)){let[g,b]=[u.x+u.width/2,u.y+u.height/2],[x,E]=ce(M(u.x,u.y),M(g,b),u.angle);Si(x+c,E+m,p,r,n,a,i,!1)}}},kL=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldChangeByStepSize:r,nextValue:n,property:i,scene:a,originalAppState:l})=>{let s=a.getNonDeletedElementsMap(),c=a.getNonDeletedElements();if(n!==void 0){for(let u of Ka(o,l)){let g=Wa(u,s,t);if(g.length>1){let[b,x,,]=ye(g.map(y=>y.latest));SL(i==="x"?n:b,i==="y"?n:x,g.map(y=>y.original),s,c,t,a)}else{let b=g[0]?.original,x=g[0]?.latest;if(b&&x&&so(x,i)){let[E,w]=[b.x+b.width/2,b.y+b.height/2],[y,v]=ce(M(b.x,b.y),M(E,w),b.angle);Si(i==="x"?n:y,i==="y"?n:v,b,s,c,a,t,!1)}}}a.triggerUpdate();return}let m=r?je(e,CL):e;IL(i,i==="x"?m:0,i==="y"?m:0,o,o,s,t,a),a.triggerUpdate()},ML=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=TL(()=>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]=ye(c);return Math.round((e==="x"?b:x)*100)/100}let[m]=c,[d,p]=[m.x+m.width/2,m.y+m.height/2],[u,g]=ce(M(m.x,m.y),M(d,p),m.angle);return Math.round((e==="x"?u:g)*100)/100}),[r,t,e]),l=new Set(a).size===1?a[0]:"Mixed";return LL(It,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:kL,value:l,property:e,scene:n,appState:i})},ef=ML;import{jsx as DL}from"react/jsx-runtime";var W3=10,AL=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,nextValue:i,property:a,scene:l,originalAppState:s})=>{let c=l.getNonDeletedElementsMap(),m=l.getNonDeletedElements(),d=t[0],[p,u]=[d.x+d.width/2,d.y+d.height/2],[g,b]=ce(M(d.x,d.y),M(p,u),d.angle);if(s.croppingElementId===d.id){let v=c.get(d.id);if(!v||!he(v)||!v.crop)return;let I=v.crop,S=I,_=v.scale[0]===-1,L=v.scale[1]===-1,{width:N,height:P}=ri(v);if(i!==void 0){if(a==="x"){let U=i*(I.naturalWidth/N);_?S={...I,x:Tt(I.naturalWidth-U-I.width,0,I.naturalWidth-I.width)}:S={...I,x:Tt(i*(I.naturalWidth/N),0,I.naturalWidth-I.width)}}a==="y"&&(S={...I,y:Tt(i*(I.naturalHeight/P),0,I.naturalHeight-I.height)}),B(v,{crop:S});return}let F=(a==="x"?o:0)*(_?-1:1),K=(a==="y"?o:0)*(L?-1:1);S={...I,x:Tt(I.x+F,0,I.naturalWidth-I.width),y:Tt(I.y+K,0,I.naturalHeight-I.height)},B(v,{crop:S});return}if(i!==void 0){Si(a==="x"?i:g,a==="y"?i:b,d,c,m,l,r);return}let x=a==="x"?e:0,E=a==="y"?e:0,w=a==="x"?Math.round(n?je(d.x+x,W3):g+x):g,y=a==="y"?Math.round(n?je(d.y+E,W3):b+E):b;Si(w,y,d,c,m,l,r)},_L=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=ce(M(o.x,o.y),M(o.x+o.width/2,o.y+o.height/2),o.angle),l=So(e==="x"?i:a,2);if(n.croppingElementId===o.id&&he(o)&&o.crop){let s=Vb(o);s&&(l=So(e==="x"?s.x:s.y,2))}return DL(It,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:AL,scene:r,value:l,property:e,appState:n})},tf=_L;import{Fragment as rf,jsx as le,jsxs as co}from"react/jsx-runtime";var BL=50,fs=e=>{let o=ur(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=Sn(e.app);return le(zL,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},Ze=({children:e,columns:o=1,heading:t,style:r,...n})=>le("div",{className:PL("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});Ze.displayName="StatsRow";var jm=({children:e,order:o,style:t,...r})=>le("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});jm.displayName="StatsRows";fs.StatsRow=Ze;fs.StatsRows=jm;var zL=OL(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),c=l.getNonDeletedElementsMap(),m=Ie(),d=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&he(d),g=u?ri(d):null,[b,x]=NL({width:0,height:0}),E=of(()=>RL(v=>{let I=ye(v);x({width:Math.round(I[2])-Math.round(I[0]),height:Math.round(I[3])-Math.round(I[1])})},BL),[]);K3(()=>{E(s)},[i,s,E]),K3(()=>()=>E.cancel(),[E]);let w=of(()=>Ka(r,n),[r,n]),y=of(()=>uc(r),[r]);return le("div",{className:"exc-stats",children:co(yt,{padding:3,children:[co("div",{className:"title",children:[le("h2",{children:f("stats.title")}),le("div",{className:"close",onClick:o,children:Lo})]}),co(Zl,{label:le("h3",{children:f("stats.generalStats")}),open:!!(n.stats.panels&il.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^il.generalStats}})),children:[co(jm,{children:[le(Ze,{heading:!0,children:f("stats.scene")}),co(Ze,{columns:2,children:[le("div",{children:f("stats.shapes")}),le("div",{children:s.length})]}),co(Ze,{columns:2,children:[le("div",{children:f("stats.width")}),le("div",{children:b.width})]}),co(Ze,{columns:2,children:[le("div",{children:f("stats.height")}),le("div",{children:b.height})]}),a&&co(rf,{children:[le(Ze,{heading:!0,children:"Canvas"}),le(Ze,{children:le(B3,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),t?.(s,n)]}),!y&&r.length>0&&le("div",{id:"elementStats",style:{marginTop:12},children:le(Zl,{label:le("h3",{children:f("stats.elementProperties")}),open:!!(n.stats.panels&il.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^il.elementProperties}})),children:co(jm,{children:[d&&co(rf,{children:[u&&le(Ze,{heading:!0,children:f("labels.unCroppedDimension")}),n.croppingElementId&&he(d)&&g&&co(Ze,{columns:2,children:[le("div",{children:f("stats.width")}),le("div",{children:So(g.width,2)})]}),n.croppingElementId&&he(d)&&g&&co(Ze,{columns:2,children:[le("div",{children:f("stats.height")}),le("div",{children:So(g.height,2)})]}),le(Ze,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?f("labels.imageCropping"):f(`element.${d.type}`)}),le(Ze,{children:le(tf,{element:d,property:"x",elementsMap:c,scene:l,appState:n})}),le(Ze,{children:le(tf,{element:d,property:"y",elementsMap:c,scene:l,appState:n})}),le(Ze,{children:le(Jg,{property:"width",element:d,scene:l,appState:n})}),le(Ze,{children:le(Jg,{property:"height",element:d,scene:l,appState:n})}),!te(d)&&le(Ze,{children:le(N3,{property:"angle",element:d,scene:l,appState:n})}),le(Ze,{children:le(H3,{property:"fontSize",element:d,scene:l,appState:n})})]}),p&&co(rf,{children:[Bb(p)&&le(Ze,{heading:!0,children:f("element.group")}),co(Ze,{columns:2,style:{margin:"0.3125rem 0"},children:[le("div",{children:f("stats.shapes")}),le("div",{children:r.length})]}),le(Ze,{children:le(ef,{property:"x",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),le(Ze,{children:le(ef,{property:"y",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),le(Ze,{children:le(Qg,{property:"width",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),le(Ze,{children:le(Qg,{property:"height",elements:p,elementsMap:c,atomicUnits:w,scene:l,appState:n})}),le(Ze,{children:le(U3,{property:"angle",elements:p,scene:l,appState:n})}),le(Ze,{children:le(Y3,{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 FL,useEffect as Z3,useState as X3}from"react";import{jsx as Xa,jsxs as qm}from"react/jsx-runtime";var HL=({sourceElementId:e,onClose:o,elementsMap:t,appState:r,generateLinkForSelection:n=Tc})=>{let i=t.get(e)?.link??null,[a,l]=X3(i),[s,c]=X3(!1);Z3(()=>{let d=J(t,r),p=i;if(d.length>0&&n){let u=Cc(d,r);u&&(p=Wo(n(u.id,u.type)))}l(p)},[t,r,r.selectedElementIds,i,n]);let m=FL(()=>{if(a&&a!==t.get(e)?.link){let d=t.get(e);d&&B(d,{link:a})}if(!a&&s&&e){let d=t.get(e);d&&B(d,{link:null})}o?.()},[e,a,t,s,o]);return Z3(()=>{let d=p=>{r.openDialog?.name==="elementLinkSelector"&&p.key===T.ENTER&&m(),r.openDialog?.name==="elementLinkSelector"&&p.key===T.ESCAPE&&o?.()};return window.addEventListener("keydown",d),()=>{window.removeEventListener("keydown",d)}},[r,o,m]),qm("div",{className:"ElementLinkDialog",children:[qm("div",{className:"ElementLinkDialog__header",children:[Xa("h2",{children:f("elementLink.title")}),Xa("p",{children:f("elementLink.desc")})]}),qm("div",{className:"ElementLinkDialog__input",children:[Xa(Ba,{value:a??"",onChange:d=>{s||c(!0),l(d)},onKeyDown:d=>{d.key===T.ENTER&&m()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),i&&a&&Xa(Q,{type:"button",title:f("buttons.remove"),"aria-label":f("buttons.remove"),label:f("buttons.remove"),onClick:()=>{l(null),c(!0)},className:"ElementLinkDialog__remove",icon:ho})]}),qm("div",{className:"ElementLinkDialog__actions",children:[Xa(Ur,{label:f("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Xa(Ur,{label:f("buttons.confirm"),onClick:m,actionType:"primary"})]})]})},$3=HL;import UL,{useState as GL}from"react";import{Fragment as VL,jsx as nf}from"react/jsx-runtime";var j3=({children:e,onClose:o})=>{let[t,r]=GL(!!e),{container:n}=gt(),i=UL.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return nf(VL,{children:t&&nf(dt,{size:"small",onCloseRequest:i,title:f("errorDialog.title"),children:nf("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import YL from"react";import{Fragment as J3,jsx as Y,jsxs as To}from"react/jsx-runtime";var WL=()=>To("div",{className:"HelpDialog__header",children:[To("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener noreferrer",children:[Y("div",{className:"HelpDialog__link-icon",children:wu}),f("helpDialog.documentation")]}),To("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener noreferrer",children:[Y("div",{className:"HelpDialog__link-icon",children:wu}),f("helpDialog.blog")]}),To("a",{className:"HelpDialog__btn",href:"https://github.com/excalidraw/excalidraw/issues",target:"_blank",rel:"noopener noreferrer",children:[Y("div",{className:"HelpDialog__link-icon",children:jc}),f("helpDialog.github")]}),To("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[Y("div",{className:"HelpDialog__link-icon",children:ME}),"YouTube"]})]}),KL=e=>To(J3,{children:[Y("h3",{children:e.title}),Y("div",{className:"HelpDialog__islands-container",children:e.children})]}),af=e=>To("div",{className:`HelpDialog__island ${e.className}`,children:[Y("h4",{className:"HelpDialog__island-title",children:e.caption}),Y("div",{className:"HelpDialog__island-content",children:e.children})]});function*ZL(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var XL=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),X=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>Y($L,{children:XL(a)},a)));return To("div",{className:"HelpDialog__shortcut",children:[Y("div",{children:e}),Y("div",{className:"HelpDialog__key-container",children:[...ZL(r,t?f("helpDialog.or"):null)]})]})},$L=e=>Y("kbd",{className:"HelpDialog__key",...e}),q3=({onClose:e})=>{let o=YL.useCallback(()=>{e&&e()},[e]);return Y(J3,{children:To(dt,{onCloseRequest:o,title:f("helpDialog.title"),className:"HelpDialog",children:[Y(WL,{}),To(KL,{title:f("helpDialog.shortcuts"),children:[To(af,{className:"HelpDialog__island--tools",caption:f("helpDialog.tools"),children:[Y(X,{label:f("toolBar.hand"),shortcuts:[T.H]}),Y(X,{label:f("toolBar.selection"),shortcuts:[T.V,T[1]]}),Y(X,{label:f("toolBar.rectangle"),shortcuts:[T.R,T[2]]}),Y(X,{label:f("toolBar.diamond"),shortcuts:[T.D,T[3]]}),Y(X,{label:f("toolBar.ellipse"),shortcuts:[T.O,T[4]]}),Y(X,{label:f("toolBar.arrow"),shortcuts:[T.A,T[5]]}),Y(X,{label:f("toolBar.line"),shortcuts:[T.L,T[6]]}),Y(X,{label:f("toolBar.freedraw"),shortcuts:[T.P,T[7]]}),Y(X,{label:f("toolBar.text"),shortcuts:[T.T,T[8]]}),Y(X,{label:f("toolBar.image"),shortcuts:[T[9]]}),Y(X,{label:f("toolBar.eraser"),shortcuts:[T.E,T[0]]}),Y(X,{label:f("toolBar.frame"),shortcuts:[T.F]}),Y(X,{label:f("toolBar.laser"),shortcuts:[T.K]}),Y(X,{label:f("labels.eyeDropper"),shortcuts:[T.I,"Shift+S","Shift+G"]}),Y(X,{label:f("helpDialog.editLineArrowPoints"),shortcuts:[R("CtrlOrCmd+Enter")]}),Y(X,{label:f("helpDialog.editText"),shortcuts:[R("Enter")]}),Y(X,{label:f("helpDialog.textNewLine"),shortcuts:[R("Enter"),R("Shift+Enter")]}),Y(X,{label:f("helpDialog.textFinish"),shortcuts:[R("Esc"),R("CtrlOrCmd+Enter")]}),Y(X,{label:f("helpDialog.curvedArrow"),shortcuts:["A",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Y(X,{label:f("helpDialog.curvedLine"),shortcuts:["L",f("helpDialog.click"),f("helpDialog.click"),f("helpDialog.click")],isOr:!1}),Y(X,{label:f("helpDialog.cropStart"),shortcuts:[f("helpDialog.doubleClick"),R("Enter")],isOr:!0}),Y(X,{label:f("helpDialog.cropFinish"),shortcuts:[R("Enter"),R("Escape")],isOr:!0}),Y(X,{label:f("toolBar.lock"),shortcuts:[T.Q]}),Y(X,{label:f("helpDialog.preventBinding"),shortcuts:[R("CtrlOrCmd")]}),Y(X,{label:f("toolBar.link"),shortcuts:[R("CtrlOrCmd+K")]})]}),To(af,{className:"HelpDialog__island--view",caption:f("helpDialog.view"),children:[Y(X,{label:f("buttons.zoomIn"),shortcuts:[R("CtrlOrCmd++")]}),Y(X,{label:f("buttons.zoomOut"),shortcuts:[R("CtrlOrCmd+-")]}),Y(X,{label:f("buttons.resetZoom"),shortcuts:[R("CtrlOrCmd+0")]}),Y(X,{label:f("helpDialog.zoomToFit"),shortcuts:["Shift+1"]}),Y(X,{label:f("helpDialog.zoomToSelection"),shortcuts:["Shift+2"]}),Y(X,{label:f("helpDialog.movePageUpDown"),shortcuts:["PgUp/PgDn"]}),Y(X,{label:f("helpDialog.movePageLeftRight"),shortcuts:["Shift+PgUp/PgDn"]}),Y(X,{label:f("buttons.zenMode"),shortcuts:[R("Alt+Z")]}),Y(X,{label:f("buttons.objectsSnapMode"),shortcuts:[R("Alt+S")]}),Y(X,{label:f("labels.toggleGrid"),shortcuts:[R("CtrlOrCmd+'")]}),Y(X,{label:f("labels.viewMode"),shortcuts:[R("Alt+R")]}),Y(X,{label:f("labels.toggleTheme"),shortcuts:[R("Alt+Shift+D")]}),Y(X,{label:f("stats.fullTitle"),shortcuts:[R("Alt+/")]}),Y(X,{label:f("search.title"),shortcuts:[ct("searchMenu")]}),Y(X,{label:f("commandPalette.title"),shortcuts:Cr?[ct("commandPalette")]:[ct("commandPalette"),ct("commandPalette",1)]})]}),To(af,{className:"HelpDialog__island--editor",caption:f("helpDialog.editor"),children:[Y(X,{label:f("helpDialog.createFlowchart"),shortcuts:[R("CtrlOrCmd+Arrow Key")],isOr:!0}),Y(X,{label:f("helpDialog.navigateFlowchart"),shortcuts:[R("Alt+Arrow Key")],isOr:!0}),Y(X,{label:f("labels.moveCanvas"),shortcuts:[R(`Space+${f("helpDialog.drag")}`),R(`Wheel+${f("helpDialog.drag")}`)],isOr:!0}),Y(X,{label:f("buttons.clearReset"),shortcuts:[R("CtrlOrCmd+Delete")]}),Y(X,{label:f("labels.delete"),shortcuts:[R("Delete")]}),Y(X,{label:f("labels.cut"),shortcuts:[R("CtrlOrCmd+X")]}),Y(X,{label:f("labels.copy"),shortcuts:[R("CtrlOrCmd+C")]}),Y(X,{label:f("labels.paste"),shortcuts:[R("CtrlOrCmd+V")]}),Y(X,{label:f("labels.pasteAsPlaintext"),shortcuts:[R("CtrlOrCmd+Shift+V")]}),Y(X,{label:f("labels.selectAll"),shortcuts:[R("CtrlOrCmd+A")]}),Y(X,{label:f("labels.multiSelect"),shortcuts:[R(`Shift+${f("helpDialog.click")}`)]}),Y(X,{label:f("helpDialog.deepSelect"),shortcuts:[R(`CtrlOrCmd+${f("helpDialog.click")}`)]}),Y(X,{label:f("helpDialog.deepBoxSelect"),shortcuts:[R(`CtrlOrCmd+${f("helpDialog.drag")}`)]}),(va||Cr)&&Y(X,{label:f("labels.copyAsPng"),shortcuts:[R("Shift+Alt+C")]}),Y(X,{label:f("labels.copyStyles"),shortcuts:[R("CtrlOrCmd+Alt+C")]}),Y(X,{label:f("labels.pasteStyles"),shortcuts:[R("CtrlOrCmd+Alt+V")]}),Y(X,{label:f("labels.sendToBack"),shortcuts:[Uo?R("CtrlOrCmd+Alt+["):R("CtrlOrCmd+Shift+[")]}),Y(X,{label:f("labels.bringToFront"),shortcuts:[Uo?R("CtrlOrCmd+Alt+]"):R("CtrlOrCmd+Shift+]")]}),Y(X,{label:f("labels.sendBackward"),shortcuts:[R("CtrlOrCmd+[")]}),Y(X,{label:f("labels.bringForward"),shortcuts:[R("CtrlOrCmd+]")]}),Y(X,{label:f("labels.alignTop"),shortcuts:[R("CtrlOrCmd+Shift+Up")]}),Y(X,{label:f("labels.alignBottom"),shortcuts:[R("CtrlOrCmd+Shift+Down")]}),Y(X,{label:f("labels.alignLeft"),shortcuts:[R("CtrlOrCmd+Shift+Left")]}),Y(X,{label:f("labels.alignRight"),shortcuts:[R("CtrlOrCmd+Shift+Right")]}),Y(X,{label:f("labels.duplicateSelection"),shortcuts:[R("CtrlOrCmd+D"),R(`Alt+${f("helpDialog.drag")}`)]}),Y(X,{label:f("helpDialog.toggleElementLock"),shortcuts:[R("CtrlOrCmd+Shift+L")]}),Y(X,{label:f("buttons.undo"),shortcuts:[R("CtrlOrCmd+Z")]}),Y(X,{label:f("buttons.redo"),shortcuts:_s?[R("CtrlOrCmd+Y"),R("CtrlOrCmd+Shift+Z")]:[R("CtrlOrCmd+Shift+Z")]}),Y(X,{label:f("labels.group"),shortcuts:[R("CtrlOrCmd+G")]}),Y(X,{label:f("labels.ungroup"),shortcuts:[R("CtrlOrCmd+Shift+G")]}),Y(X,{label:f("labels.flipHorizontal"),shortcuts:[R("Shift+H")]}),Y(X,{label:f("labels.flipVertical"),shortcuts:[R("Shift+V")]}),Y(X,{label:f("labels.showStroke"),shortcuts:[R("S")]}),Y(X,{label:f("labels.showBackground"),shortcuts:[R("G")]}),Y(X,{label:f("labels.showFonts"),shortcuts:[R("Shift+F")]}),Y(X,{label:f("labels.decreaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+<")]}),Y(X,{label:f("labels.increaseFontSize"),shortcuts:[R("CtrlOrCmd+Shift+>")]})]})]})]})})};import{useEffect as t5,useRef as t8,useState as Pn}from"react";import{useCallback as jL,useRef as qL,useState as JL}from"react";var QL=2e3,Q3=()=>{let[e,o]=JL(null),t=qL(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},QL)},n=jL(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import e8 from"clsx";import{jsx as e5}from"react/jsx-runtime";var bs=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>e5("div",{className:e8("Switch",{toggled:t,disabled:n}),children:e5("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 Xe,jsxs as Rn}from"react/jsx-runtime";var o8="filter"in document.createElement("canvas").getContext("2d"),r8=()=>Rn("div",{children:[Xe("h3",{children:f("canvasError.cannotShowPreview")}),Xe("p",{children:Xe("span",{children:f("canvasError.canvasTooBig")})}),Rn("em",{children:["(",f("canvasError.canvasTooBigTip"),")"]})]}),n8=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=ze(o,e),[l,s]=Pn(i),[c,m]=Pn(a),[d,p]=Pn(e.exportBackground),[u,g]=Pn(e.exportWithDarkMode),[b,x]=Pn(e.exportEmbedScene),[E,w]=Pn(e.exportScale),y=t8(null),[v,I]=Pn(null),{onCopy:S,copyStatus:_,resetCopyStatus:L}=Q3();t5(()=>{L()},[l,d,u,E,b,L]);let{exportedElements:N,exportingFrame:P}=xi(o,e,c);return t5(()=>{let F=y.current;if(!F)return;let K=F.offsetWidth,U=F.offsetHeight;K&&Tn({elements:N,appState:{...e,name:l,exportBackground:d,exportWithDarkMode:u,exportScale:E,exportEmbedScene:b},files:t,exportPadding:en,maxWidthOrHeight:Math.max(K,U),exportingFrame:P}).then(q=>(I(null),Nr(q).then(()=>{F.replaceChildren(q)}).catch(H=>{throw H.name==="CANVAS_POSSIBLY_TOO_BIG"?new Error(f("canvasError.canvasTooBig")):H}))).catch(q=>{console.error(q),I(q)})},[e,t,N,P,l,d,u,E,b]),Rn("div",{className:"ImageExportModal",children:[Xe("h3",{children:f("imageExportDialog.header")}),Rn("div",{className:"ImageExportModal__preview",children:[Xe("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Xe(r8,{})}),Xe("div",{className:"ImageExportModal__preview__filename",children:!Qi&&Xe("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:F=>{s(F.target.value),r.executeAction(wh,"ui",F.target.value)}})})]}),Rn("div",{className:"ImageExportModal__settings",children:[Xe("h3",{children:f("imageExportDialog.header")}),a&&Xe(xs,{label:f("imageExportDialog.label.onlySelected"),name:"exportOnlySelected",children:Xe(bs,{name:"exportOnlySelected",checked:c,onChange:F=>{m(F)}})}),Xe(xs,{label:f("imageExportDialog.label.withBackground"),name:"exportBackgroundSwitch",children:Xe(bs,{name:"exportBackgroundSwitch",checked:d,onChange:F=>{p(F),r.executeAction(Th,"ui",F)}})}),o8&&Xe(xs,{label:f("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Xe(bs,{name:"exportDarkModeSwitch",checked:u,onChange:F=>{g(F),r.executeAction(t2,"ui",F)}})}),Xe(xs,{label:f("imageExportDialog.label.embedScene"),tooltip:f("imageExportDialog.tooltip.embedScene"),name:"exportEmbedSwitch",children:Xe(bs,{name:"exportEmbedSwitch",checked:b,onChange:F=>{x(F),r.executeAction(Od,"ui",F)}})}),Xe(xs,{label:f("imageExportDialog.label.scale"),name:"exportScale",children:Xe(Dm,{name:"exportScale",value:E,onChange:F=>{w(F),r.executeAction(e2,"ui",F)},choices:Hs.map(F=>({value:F,label:`${F}\xD7`}))})}),Rn("div",{className:"ImageExportModal__settings__buttons",children:[Xe(An,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToPng"),onClick:()=>n(Bs.png,N,{exportingFrame:P}),icon:zu,children:f("imageExportDialog.button.exportToPng")}),Xe(An,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.exportToSvg"),onClick:()=>n(Bs.svg,N,{exportingFrame:P}),icon:zu,children:f("imageExportDialog.button.exportToSvg")}),(va||Cr)&&Xe(An,{className:"ImageExportModal__settings__buttons__button",label:f("imageExportDialog.title.copyPngToClipboard"),status:_,onClick:async()=>{await n(Bs.clipboard,N,{exportingFrame:P}),S()},icon:ca,children:f("imageExportDialog.button.copyPngToClipboard")})]})]})]})},xs=({label:e,children:o,tooltip:t,name:r})=>Rn("div",{className:"ImageExportModal__settings__setting",title:e,children:[Rn("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Xe(bo,{label:t,long:!0,children:lE})]}),Xe("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),o5=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Pn(()=>({appStateSnapshot:oo(o),elementsSnapshot:oo(e)}));return Xe(dt,{onCloseRequest:i,size:"wide",title:!1,children:Xe(n8,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import a8 from"react";import lf from"open-color";import{jsx as i8}from"react/jsx-runtime";var sf=({children:e,color:o})=>i8("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":lf[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":lf[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":lf[o][9]},children:e});import{Fragment as s8,jsx as tr,jsxs as Jm}from"react/jsx-runtime";var l8=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return tr("div",{className:"ExportDialog ExportDialog--json",children:Jm("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Jm(sf,{color:"lime",children:[tr("div",{className:"Card-icon",children:gx}),tr("h2",{children:f("exportDialog.disk_title")}),Jm("div",{className:"Card-details",children:[f("exportDialog.disk_details"),!Qi&&n.renderAction("changeProjectName")]}),tr(Q,{className:"Card-button",type:"button",title:f("exportDialog.disk_button"),"aria-label":f("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Jl,"ui")}})]}),s&&Jm(sf,{color:"pink",children:[tr("div",{className:"Card-icon",children:Nl}),tr("h2",{children:f("exportDialog.link_title")}),tr("div",{className:"Card-details",children:f("exportDialog.link_details")}),tr(Q,{className:"Card-button",type:"button",title:f("exportDialog.link_button"),"aria-label":f("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{xe("export","link",`ui (${D1()})`),await s(e,o,r),l()}catch(c){t({errorMessage:c.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},r5=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=a8.useCallback(()=>{a({openDialog:null})},[a]);return tr(s8,{children:o.openDialog?.name==="jsonExport"&&tr(dt,{onCloseRequest:l,title:f("buttons.export"),children:tr(l8,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import c8 from"clsx";import{jsx as n5,jsxs as m8}from"react/jsx-runtime";var d8="small",i5=e=>m8("label",{className:c8("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${d8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[n5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),n5("div",{className:"ToolIcon__icon",children:zl})]});import{Fragment as l5,jsx as re,jsxs as Co}from"react/jsx-runtime";var u8=({UIOptions:e})=>Co(Ot,{__fallback:!0,children:[re(Ot.DefaultItems.LoadScene,{}),re(Ot.DefaultItems.SaveToActiveFile,{}),e.canvasActions.export&&re(Ot.DefaultItems.Export,{}),e.canvasActions.saveAsImage&&re(Ot.DefaultItems.SaveAsImage,{}),re(Ot.DefaultItems.SearchMenu,{}),re(Ot.DefaultItems.Help,{}),re(Ot.DefaultItems.ClearCanvas,{}),re(Ot.Separator,{}),re(Ot.Group,{title:"Excalidraw links",children:re(Ot.DefaultItems.Socials,{})}),re(Ot.Separator,{}),re(Ot.DefaultItems.ToggleTheme,{}),re(Ot.DefaultItems.ChangeCanvasBackground,{})]}),h8=()=>Co(Om,{__fallback:!0,children:[re(Om.Actions.SaveToDisk,{}),re(Om.Actions.ExportToImage,{})]}),g8=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,canvas:i,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,showExitZenModeBtn:c,renderTopRightUI:m,renderCustomStats:d,UIOptions:p,onExportImage:u,renderWelcomeScreen:g,children:b,app:x,isCollaborating:E,generateLinkForSelection:w})=>{let y=Ce(),v=Ev(),I=v.tunnelsJotai.Provider,[S,_]=ve(bn),L=()=>p.canvasActions.export?re(r5,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,N=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:re(o5,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),P=()=>Co("div",{style:{position:"relative"},children:[re(v.MainMenuTunnel.Out,{}),g&&re(v.WelcomeScreenMenuHintTunnel.Out,{})]}),F=()=>re(Mn,{heading:"selectedShapeActions",className:Es("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:re(yt,{className:Go.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:re(lm,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),K=()=>{let G=Ta(o,n),V=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return re(Tm,{side:"top",children:Co("div",{className:"App-menu App-menu_top",children:[Co(Ct.Col,{gap:6,className:Es("App-menu_top__left"),children:[P(),G&&F()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&re(Mn,{heading:"shapes",className:"shapes-section",children:ie=>Co("div",{style:{position:"relative"},children:[g&&re(v.WelcomeScreenToolbarHintTunnel.Out,{}),re(Ct.Col,{gap:4,align:"start",children:Co(Ct.Row,{gap:1,className:Es("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Co(yt,{padding:1,className:Es("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[re(Im,{appState:o,isMobile:y.editor.isMobile,device:y,app:x}),ie,Co(Ct.Row,{gap:1,children:[re(Sm,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:f("toolBar.penMode"),penDetected:o.penDetected}),re(wm,{checked:o.activeTool.locked,onChange:a,title:f("toolBar.lock")}),re("div",{className:"App-toolbar__divider"}),re(Cm,{checked:Xo(o),onChange:()=>l(),title:f("toolBar.hand"),isMobile:!0}),re(sm,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),E&&re(yt,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:re(i5,{title:f("toolBar.laser"),checked:o.activeTool.type===it.laser,onChange:()=>x.setActiveTool({type:it.laser}),isMobile:!0})})]})})]})}),Co("div",{className:Es("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&re(Lm,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),m?.(y.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!q||o.openSidebar?.name!==At.name)&&re(v.DefaultSidebarTriggerTunnel.Out,{}),V&&re(fs,{app:x,onClose:()=>{e.executeAction(La)},renderCustomStats:d})]})]})})},U=()=>re(Bm,{__fallback:!0,onDock:G=>{xe("sidebar",`toggleDock (${G?"dock":"undock"})`,`(${y.editor.isMobile?"mobile":"desktop"})`)}}),q=Gc(ms),H=Co(l5,{children:[b,re(u8,{UIOptions:p}),re(Bm.Trigger,{__fallback:!0,icon:ia,title:on(f("toolBar.library")),onToggle:G=>{G&&xe("sidebar",`${At.name} (open)`,`button (${y.editor.isMobile?"mobile":"desktop"})`)},tab:At.defaultTab,children:f("toolBar.library")}),re(h8,{}),o.openDialog?.name==="ttd"&&re(jg,{__fallback:!0}),o.isLoading&&re(vm,{delay:250}),o.errorMessage&&re(j3,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),S&&!y.editor.isMobile&&re(qE,{colorPickerType:S.colorPickerType,onCancel:()=>{_(null)},onChange:(G,V,ie,{altKey:$})=>{if(!(G!=="elementBackground"&&G!=="elementStroke"))if(ie.length){for(let se of ie)B(se,{[$&&S.swapPreviewOnAlt?G==="elementBackground"?"strokeColor":"backgroundColor":G==="elementBackground"?"backgroundColor":"strokeColor"]:V},!1),pn.delete(se);dn.getScene(ie[0])?.triggerUpdate()}else r(G==="elementBackground"?{currentItemBackgroundColor:V}:{currentItemStrokeColor:V})},onSelect:(G,V)=>{_(ie=>ie?.keepOpenOnAlt&&V.altKey?ie:null),S?.onSelect?.(G,V)}}),o.openDialog?.name==="help"&&re(q3,{onClose:()=>{r({openDialog:null})}}),re(Cv,{}),o.openDialog?.name==="elementLinkSelector"&&re($3,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},elementsMap:x.scene.getNonDeletedElementsMap(),appState:o,generateLinkForSelection:w}),re(v.OverwriteConfirmDialogTunnel.Out,{}),N(),L(),o.pasteDialog.shown&&re(Sw,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&re(Cw,{app:x,appState:o,elements:n,actionManager:e,renderJSONExportDialog:L,renderImageExportDialog:N,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:m,renderCustomStats:d,renderSidebars:U,device:y,renderWelcomeScreen:g,UIOptions:p}),!y.editor.isMobile&&Co(l5,{children:[Co("div",{className:"layer-ui__wrapper",style:o.openSidebar&&q&&y.editor.canFitSidebar?{width:"calc(100% - var(--right-sidebar-width))"}:{},children:[g&&re(v.WelcomeScreenCenterTunnel.Out,{}),K(),re(Aw,{appState:o,actionManager:e,showExitZenModeBtn:c,renderWelcomeScreen:g}),o.scrolledOutside&&re("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(G=>({...ai(n,G)}))},children:f("buttons.scrollBackToContent")})]}),U()]})]});return re(qu.Provider,{value:o,children:re(I,{children:re(ng.Provider,{value:v,children:H})})})},a5=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},f8=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return Je(a5(r),a5(a),{selectedElementIds:Je,selectedGroupIds:Je})&&Je(n,l)},s5=p8.memo(g8,f8);import b8 from"clsx";import{jsx as c5,jsxs as E8}from"react/jsx-runtime";var x8="small",Qm=e=>E8("label",{className:b8("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${x8}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[c5("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),c5("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as y8,useRef as v8}from"react";import{jsx as d5}from"react/jsx-runtime";var m5=({trails:e})=>{let o=v8(null);return y8(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),d5("div",{className:"SVGLayer",children:d5("svg",{ref:o})})};import w8,{useEffect as T8,useRef as C8}from"react";import{jsx as k8}from"react/jsx-runtime";var I8=e=>{let o=C8(!1);return T8(()=>{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,zt({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";iw({canvas:e.canvas,elementsMap:e.elementsMap,visibleElements:e.visibleElements,selectedElements:e.selectedElements,allElementsMap:e.allElementsMap,scale:window.devicePixelRatio,appState:e.appState,renderConfig:{remotePointerViewportCoords:r,remotePointerButton:t,remoteSelectedElementIds:n,remotePointerUsernames:i,remotePointerUserStates:a,selectionColor:l,renderScrollbars:!1},device:e.device,callback:e.renderInteractiveSceneCallback},Ha())}),k8("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?Se.GRAB:Se.AUTO},width:e.appState.width*e.scale,height:e.appState.height*e.scale,ref:e.handleCanvasRef,onContextMenu:e.onContextMenu,onPointerMove:e.onPointerMove,onPointerUp:e.onPointerUp,onPointerCancel:e.onPointerCancel,onTouchMove:e.onTouchMove,onPointerDown:e.onPointerDown,onDoubleClick:e.appState.viewModeEnabled?void 0:e.onDoubleClick,children:f("labels.drawingCanvas")})},p5=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}),S8=(e,o)=>e.selectionNonce!==o.selectionNonce||e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements||e.selectedElements!==o.selectedElements?!1:Je(p5(e.appState),p5(o.appState)),cf=w8.memo(I8,S8);import M8,{useEffect as L8,useRef as u5}from"react";import{jsx as D8}from"react/jsx-runtime";var A8=e=>{let o=u5(null),t=u5(!1);return L8(()=>{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),m0({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Ha())}),D8("div",{className:"excalidraw__canvas-wrapper",ref:o})},h5=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}),_8=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:Je(h5(e.appState),h5(o.appState))&&Je(e.renderConfig,o.renderConfig),df=M8.memo(A8,_8);import{useEffect as R8,useRef as N8}from"react";var g5=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,scale:i,appState:a,renderConfig:l})=>{if(e){let[s,c]=Lc(e,i),m=Ac({canvas:e,scale:i,normalizedWidth:s,normalizedHeight:c});m.save(),m.scale(a.zoom.value,a.zoom.value),t&&t.type!=="selection"?Kb(t,r,n,o,m,l,a):m.clearRect(0,0,s,c)}},P8=Pi(e=>{g5(e)},{trailing:!0}),f5=(e,o)=>{if(o){P8(e);return}g5(e)};import{jsx as B8}from"react/jsx-runtime";var O8=e=>{let o=N8(null);return R8(()=>{o.current&&f5({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},Ha())}),B8("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})},b5=O8;import{useCallback as z8,useEffect as F8,useRef as H8}from"react";import{jsx as x5,jsxs as G8}from"react/jsx-runtime";var U8=5e3,E5=({message:e,onClose:o,closable:t=!1,duration:r=U8,style:n})=>{let i=H8(0),a=r!==1/0,l=z8(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return F8(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),G8("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[x5("p",{className:"Toast__message",children:e}),t&&x5(Q,{icon:Lo,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{Fragment as Z8,jsx as Be,jsxs as tp}from"react/jsx-runtime";var T5=Tr.createContext(null),C5=Tr.createContext(null),I5={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},ff=Tr.createContext(I5);ff.displayName="DeviceContext";var bf=Tr.createContext({container:null,id:null});bf.displayName="ExcalidrawContainerContext";var xf=Tr.createContext([]);xf.displayName="ExcalidrawElementsContext";var Ef=Tr.createContext({...mr(),width:0,height:0,offsetLeft:0,offsetTop:0});Ef.displayName="ExcalidrawAppStateContext";var yf=Tr.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});yf.displayName="ExcalidrawSetAppStateContext";var vf=Tr.createContext(null);vf.displayName="ExcalidrawActionManagerContext";var st=()=>On(T5),hr=()=>On(C5),Ce=()=>On(ff),gt=()=>On(bf),xn=()=>On(xf),ur=()=>On(Ef),Ie=()=>On(yf),ft=()=>On(vf),ys=!1,mf=0,Mi=!1,vs=!1,pf=!1,uf={horizontal:null,vertical:null},Nn=0,ws=!1,hf=new Map,ep=!1,v5=0,w5=!1,Ts=null,Ae={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},gf=class e extends Tr.Component{constructor(t){super(t);C(this,"canvas");C(this,"interactiveCanvas",null);C(this,"rc");C(this,"unmounted",!1);C(this,"actionManager");C(this,"device",I5);C(this,"excalidrawContainerRef",Tr.createRef());C(this,"scene");C(this,"fonts");C(this,"renderer");C(this,"visibleElements");C(this,"resizeObserver");C(this,"nearestScrollableContainer");C(this,"library");C(this,"libraryItemsFromStorage");C(this,"id");C(this,"store");C(this,"history");C(this,"excalidrawContainerValue");C(this,"files",{});C(this,"imageCache",new Map);C(this,"iFrameRefs",new Map);C(this,"embedsValidationStatus",new Map);C(this,"initializedEmbeds",new Set);C(this,"elementsPendingErasure",new Set);C(this,"flowChartCreator",new Hc);C(this,"flowChartNavigator",new Fc);C(this,"hitLinkElement");C(this,"lastPointerDownEvent",null);C(this,"lastPointerUpEvent",null);C(this,"lastPointerMoveEvent",null);C(this,"lastPointerMoveCoords",null);C(this,"lastViewportPosition",{x:0,y:0});C(this,"animationFrameHandler",new um);C(this,"laserTrails",new bm(this.animationFrameHandler,this));C(this,"eraserTrail",new ym(this.animationFrameHandler,this));C(this,"lassoTrail",new Em(this.animationFrameHandler,this));C(this,"onChangeEmitter",new Pt);C(this,"onPointerDownEmitter",new Pt);C(this,"onPointerUpEmitter",new Pt);C(this,"onUserFollowEmitter",new Pt);C(this,"onScrollChangeEmitter",new Pt);C(this,"missingPointerEventCleanupEmitter",new Pt);C(this,"onRemoveEventListenersEmitter",new Pt);C(this,"getEffectiveGridSize",()=>Sn(this)?this.state.gridSize:null);C(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),pn.delete(t)});C(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(Ft(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=qi(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else Xn(n)&&t.add(n.id);return!1}),r&&this.scene.triggerUpdate(),this.iFrameRefs.forEach((n,i)=>{t.has(i)||this.iFrameRefs.delete(i)})});C(this,"getFrameNameDOMId",t=>`${this.id}-frame-name-${t.id}`);C(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=$e({clientX:i.x,clientY:i.y},this.state),l=$e({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});C(this,"resetEditingFrame",t=>{t&&B(t,{name:t.name?.trim()||null}),this.setState({editingFrame:null})});C(this,"renderFrameNames",()=>{if(!this.state.frameRendering.enabled||!this.state.frameRendering.name)return this.state.editingFrame&&this.resetEditingFrame(null),null;let t=this.state.theme===de.DARK;return this.scene.getNonDeletedFramesLikes().map(r=>{if(!El(r,this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap()))return this.state.editingFrame===r.id&&this.resetEditingFrame(r),null;let{x:n,y:i}=zt({sceneX:r.x,sceneY:r.y},this.state),a=6,l,s=Sb(r);if(r.id===this.state.editingFrame){let c=s;l=Be("input",{autoFocus:!0,value:c,onChange:m=>{B(r,{name:m.target.value})},onFocus:m=>m.target.select(),onBlur:()=>this.resetEditingFrame(r),onKeyDown:m=>{(m.key===T.ESCAPE||m.key===T.ENTER)&&this.resetEditingFrame(r)},style:{background:this.state.viewBackgroundColor,filter:t?n1:"none",zIndex:2,border:"none",display:"block",padding:`${a}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:"14px",transform:`translate(-${a}px, ${a}px)`,color:"var(--color-gray-80)",overflow:"hidden",maxWidth:`${document.body.clientWidth-n-a}px`},size:c.length+1||1,dir:"auto",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off"})}else l=s;return Be("div",{id:this.getFrameNameDOMId(r),style:{position:"absolute",bottom:`${this.state.height+Vo.nameOffsetY-i+this.state.offsetTop}px`,left:`${n-this.state.offsetLeft}px`,zIndex:2,fontSize:Vo.nameFontSize,color:t?Vo.nameColorDarkTheme:Vo.nameColorLightTheme,lineHeight:Vo.nameLineHeight,width:"max-content",maxWidth:`${r.width}px`,overflow:r.id===this.state.editingFrame?"visible":"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",cursor:Se.MOVE,pointerEvents:this.state.viewModeEnabled?Hn.disabled:Hn.enabled},onPointerDown:c=>this.handleCanvasPointerDown(c),onWheel:c=>this.handleWheel(c),onContextMenu:this.handleCanvasContextMenu,onDoubleClick:()=>{this.setState({editingFrame:r.id})},children:l},r.id)})});C(this,"focusContainer",()=>{this.excalidrawContainerRef.current?.focus()});C(this,"getSceneElementsIncludingDeleted",()=>this.scene.getElementsIncludingDeleted());C(this,"getSceneElements",()=>this.scene.getNonDeletedElements());C(this,"onInsertElements",t=>{this.addElementsFromPasteOrLibrary({elements:t,position:"center",files:null})});C(this,"onExportImage",async(t,r,n)=>{xe("export",t,"ui");let i=await Ei(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch($s).catch(a=>{console.error(a),this.setState({errorMessage:a.message})});this.state.exportEmbedScene&&i&&Dc(i)&&this.setState({fileHandle:i})});C(this,"magicGenerations",new Map);C(this,"updateMagicGeneration",({frameElement:t,data:r})=>{r.status==="pending"?B(t,{customData:{generationData:void 0}},!1):B(t,{customData:{generationData:r}},!1),this.magicGenerations.set(t.id,r),this.triggerRender()});C(this,"plugins",{});C(this,"onMagicframeToolSelect",()=>{let t=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds});if(t.length===0)this.setActiveTool({type:it.magicframe}),xe("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&ec(t[0])&&t[0];if(!r&&t.some(i=>ne(i)||i.frameId)){this.setActiveTool({type:it.magicframe});return}xe("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=ye(t),c=50;n=wl({...Vo,x:i-c,y:a-c,width:l-i+c*2,height:s-a+c*2,opacity:100,locked:!1}),this.scene.insertElement(n);for(let m of t)B(m,{frameId:n.id});this.setState({selectedElementIds:{[n.id]:!0}})}this.onMagicFrameGenerate(n,"upstream")}});C(this,"openEyeDropper",({type:t})=>{St.set(bn,{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]?oe(l,{[i?"strokeColor":"backgroundColor"]:r}):l),captureUpdate:A.IMMEDIATELY})},keepOpenOnAlt:!1})});C(this,"dismissLinearEditor",()=>{setTimeout(()=>{this.setState({editingLinearElement:null})})});C(this,"syncActionResult",tt(t=>{if(this.unmounted||t===!1)return;t.captureUpdate===A.NEVER?this.store.shouldUpdateSnapshot():t.captureUpdate===A.IMMEDIATELY&&this.store.shouldCaptureIncrement();let r=!1,n=null;if(t.elements&&(this.scene.replaceAllElements(t.elements),r=!0),t.files&&(this.addMissingFiles(t.files,t.replaceFiles),this.addNewImagesToImageCache()),t.appState||n||this.state.contextMenu){let i=t?.appState?.viewModeEnabled||!1,a=t?.appState?.zenModeEnabled||!1,l=t?.appState?.theme||this.props.theme||de.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)&&Z(m)&&(n=m)}),n?.isDeleted&&(n=null),this.setState(m=>{let d=t.appState||{};return{...m,...d,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:c}}),r=!0}!r&&t.captureUpdate!==A.EVENTUALLY&&this.scene.triggerUpdate()}));C(this,"onBlur",tt(()=>{Mi=!1,this.setState({isBindingEnabled:!0})}));C(this,"onUnload",()=>{this.onBlur()});C(this,"disableEvent",t=>{t.preventDefault()});C(this,"resetHistory",()=>{this.history.clear()});C(this,"resetStore",()=>{this.store.clear()});C(this,"resetScene",tt(t=>{this.scene.replaceAllElements([]),this.setState(r=>({...mr(),isLoading:t?.resetLoadingState?!1:r.isLoading,theme:this.state.theme})),this.resetStore(),this.resetHistory()}));C(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=ta(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,...ai(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)}),ii(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});C(this,"isMobileBreakpoint",(t,r)=>t<i1||r<l1&&t<a1);C(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=Ri(i,{isLandscape:r>n,isMobile:this.isMobileBreakpoint(r,n)});return i!==a?(this.device={...this.device,viewport:a},!0):!1});C(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:s1,a=this.device.editor,l=Ri(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>i});return a!==l?(this.device={...this.device,editor:l},!0):!1});C(this,"onResize",tt(()=>{this.scene.getElementsIncludingDeleted().forEach(t=>pn.delete(t)),this.refreshViewportBreakpoints(),this.updateDOMRect(),qa||this.refreshEditorBreakpoints(),this.setState({})}));C(this,"onFullscreenChange",()=>{!document.fullscreenElement&&this.state.activeEmbeddable?.state==="active"&&this.setState({activeEmbeddable:null})});C(this,"renderInteractiveSceneCallback",({atLeastOneVisibleElement:t,scrollBars:r,elementsMap:n})=>{r&&(uf=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});C(this,"onScroll",Yn(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},o1));C(this,"onCut",tt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ir(t.target)||(this.actionManager.executeAction(Fd,"keyboard",t),t.preventDefault(),t.stopPropagation())}));C(this,"onCopy",tt(t=>{!this.excalidrawContainerRef.current?.contains(document.activeElement)||ir(t.target)||(this.actionManager.executeAction(ka,"keyboard",t),t.preventDefault(),t.stopPropagation())}));C(this,"onTouchStart",t=>{if(Ds&&t.preventDefault(),!ys){ys=!0,clearTimeout(mf),mf=window.setTimeout(e.resetTapTwice,e1);return}if(ys&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),ys=!1,clearTimeout(mf)}t.touches.length===2&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null})});C(this,"onTouchEnd",t=>{this.resetContextMenuTimer(),t.touches.length>0?this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}):Ae.pointers.clear()});C(this,"pasteFromClipboard",tt(async t=>{let r=!!ep,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)||ir(n)))return;let{x:l,y:s}=$e({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),c=t?.clipboardData?.files[0],m=await Rd(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=nu(d))}}if(Pc(c)&&!m.spreadsheet){if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}let d=this.createImageElement({sceneX:l,sceneY:s});this.insertImageElement(d,c),this.initializeImageDimensions(d),this.setState({selectedElementIds:Me({[d.id]:!0},this.state)});return}if(this.props.onPaste)try{if(await this.props.onPaste(m,t)===!1)return}catch(d){console.error(d)}if(m.errorMessage)this.setState({errorMessage:m.errorMessage});else if(m.spreadsheet&&!r)this.setState({pasteDialog:{data:m.spreadsheet,shown:!0}});else if(m.elements){let d=m.programmaticAPI?Fa(m.elements):m.elements;this.addElementsFromPasteOrLibrary({elements:d,files:m.files||null,position:"cursor",retainSeed:r})}else if(m.text){if(m.text&&sw(m.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:g,files:b}=await u.parseMermaidToExcalidraw(m.text),x=Fa(g,{regenerateIds:!0});this.addElementsFromPasteOrLibrary({elements:x,files:b,position:"cursor"});return}catch(g){console.warn(`parsing pasted text as mermaid definition failed: ${g.message}`)}}let d=N1(m.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=d.map(u=>Jb(u)).filter(u=>qi(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||ni(u)?.type==="video"));if(!ep&&p.length>0&&p.length===d.length){let u=[];for(let g of p){let b=u[u.length-1],x=this.insertEmbeddableElement({sceneX:b?b.x+b.width+20:l,sceneY:s,link:Wo(g)});x&&u.push(x)}u.length&&this.setState({selectedElementIds:Object.fromEntries(u.map(g=>[g.id,!0]))});return}this.addTextFromPaste(m.text,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()}));C(this,"addElementsFromPasteOrLibrary",t=>{let r=tu(t.elements,null,void 0),[n,i,a,l]=ye(r),s=Wn(n,a)/2,c=Wn(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}=$e({clientX:m,clientY:d},this.state),g=p-s,b=u-c,[x,E]=ht(g,b,this.getEffectiveGridSize()),{newElements:w}=li({type:"everything",elements:r.map(L=>oe(L,{x:L.x+x-n,y:L.y+E-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...w];v=this.props.onDuplicate?.(v,y)||v,Ut(v,ee(w));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let L=Cb(w,S);Wi(v,L,S,this.state)}this.scene.replaceAllElements(v),w.forEach(L=>{if(Z(L)&&_e(L)){let N=_t(L,this.scene.getElementsMapIncludingDeleted());Qe(L,N,this.scene.getElementsMapIncludingDeleted())}}),Vf&&un.loadElementsFonts(w).then(L=>{this.fonts.onLoaded(L)}),t.files&&this.addMissingFiles(t.files),this.store.shouldCaptureIncrement();let _=hc(w);this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&St.get(ms)?this.state.openSidebar:null,...lt({editingGroupId:null,selectedElementIds:_.reduce((L,N)=>(_e(N)||(L[N.id]=!0),L),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(w,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});C(this,"setAppState",(t,r)=>{this.setState(t,r)});C(this,"removePointer",t=>{Nn&&this.resetContextMenuTimer(),Ae.pointers.delete(t.pointerId)});C(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||xe("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...He(this.state,r.activeTool.locked?{type:"selection"}:r.activeTool),locked:!r.activeTool.locked}}))});C(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}}})});C(this,"togglePenMode",t=>{this.setState(r=>({penMode:t??!r.penMode,penDetected:!0}))});C(this,"onHandToolToggle",()=>{this.actionManager.executeAction(zy)});C(this,"zoomCanvas",t=>{this.setState({...zr({viewportX:this.state.width/2+this.state.offsetLeft,viewportY:this.state.height/2+this.state.offsetTop,nextZoom:dr(t)},this.state)})});C(this,"cancelInProgressAnimation",null);C(this,"scrollToContent",(t=this.scene.getNonDeletedElements(),r)=>{if(typeof t=="string"){let s;if(ii(t)?s=o0(t):s=t,s){let c=this.scene.getElementsFromId(s);c?.length?this.scrollToContent(c,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):ii(t)&&this.setState({toast:{message:f("elementLink.notFound"),duration:3e3,closable:!0}})}return}this.cancelInProgressAnimation?.();let n=Array.isArray(t)?t:[t],i=this.state.zoom,a=this.state.scrollX,l=this.state.scrollY;if(r?.fitToContent||r?.fitToViewport){let{appState:s}=Xl({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=ai(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=T1({fromValues:{scrollX:s,scrollY:c,zoom:m},toValues:{scrollX:a,scrollY:l,zoom:i.value},interpolateValue:(p,u,g,b)=>{if(b==="zoom")return p*Math.pow(u/p,Yo(g))},onStep:({scrollX:p,scrollY:u,zoom:g})=>{this.setState({scrollX:p,scrollY:u,zoom:{value:g}})},onStart:()=>{this.setState({shouldCacheIgnoreZoom:!0})},onEnd:()=>{this.setState({shouldCacheIgnoreZoom:!1})},onCancel:()=>{this.setState({shouldCacheIgnoreZoom:!1})},duration:r?.duration??500});this.cancelInProgressAnimation=()=>{d(),this.cancelInProgressAnimation=null}}else this.setState({scrollX:a,scrollY:l,zoom:i})});C(this,"maybeUnfollowRemoteUser",()=>{this.state.userToFollow&&this.setState({userToFollow:null})});C(this,"translateCanvas",t=>{this.cancelInProgressAnimation?.(),this.maybeUnfollowRemoteUser(),this.setState(t)});C(this,"setToast",t=>{this.setState({toast:t})});C(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,Ja,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});C(this,"addFiles",tt(t=>{let{addedFiles:r}=this.addMissingFiles(t);this.clearImageShapeCache(r),this.scene.triggerUpdate(),this.addNewImagesToImageCache()}));C(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===ue.svg))try{let s=E0($p(v0(l.dataURL)),ue.svg);l.dataURL!==s&&(l.version=(l.version??1)+1,l.dataURL=s)}catch(s){console.error(s)}return this.files=n,{addedFiles:i}});C(this,"updateScene",tt(t=>{let r=Pr(t.elements??[]);if(t.captureUpdate&&t.captureUpdate!==A.EVENTUALLY){let n=this.store.snapshot.appState,i=this.store.snapshot.elements,a=t.appState?Object.assign({},n,t.appState):n,l=t.elements?this.store.filterUncomittedElements(this.scene.getElementsMapIncludingDeleted(),ee(r)):i;t.captureUpdate===A.IMMEDIATELY?this.store.captureIncrement(l,a):t.captureUpdate===A.NEVER&&this.store.updateSnapshot(l,a)}t.appState&&this.setState(t.appState),t.elements&&this.scene.replaceAllElements(r),t.collaborators&&this.setState({collaborators:t.collaborators})}));C(this,"triggerRender",t=>{t===!0?this.scene.triggerUpdate():this.setState({})});C(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});C(this,"updateCurrentCursorPosition",tt(t=>{this.lastViewportPosition.x=t.clientX,this.lastViewportPosition.y=t.clientY}));C(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 Br().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}});C(this,"onKeyDown",tt(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}})),!Sp(t.target)){if((t.key===T.ESCAPE||t.key===T.ENTER)&&this.state.croppingElementId){this.finishImageCropping();return}let a=J(this.scene.getNonDeletedElementsMap(),this.state);if(a.length===1&&he(a[0])&&t.key===T.ENTER){this.startImageCropping(a[0]);return}if(t.key===T.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Un(t.key);if(t[T.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=J(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&jn(s[0])&&this.flowChartCreator.createNodes(s[0],this.scene.getNonDeletedElementsMap(),this.state,cu(t.key)),this.flowChartCreator.pendingNodes?.length&&!Vi(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(),cu(t.key));if(c){this.setState(d=>({selectedElementIds:Me({[c]:!0},d)}));let m=this.scene.getNonDeletedElementsMap().get(c);m&&!Vi([m],this.canvas.width/window.devicePixelRatio,this.canvas.height/window.devicePixelRatio,{offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,zoom:this.state.zoom},this.scene.getNonDeletedElementsMap(),this.getEditorUIOffsets())&&this.scrollToContent(m,{animate:!0,duration:300,canvasOffsets:this.getEditorUIOffsets()})}return}}}if(t[T.CTRL_OR_CMD]&&t.key===T.P&&!t.shiftKey&&!t.altKey){this.setToast({message:f("commandPalette.shortcutHint",{shortcut:ct("commandPalette")})}),t.preventDefault();return}if(t[T.CTRL_OR_CMD]&&t.key.toLowerCase()===T.V&&(ep=t.shiftKey,clearTimeout(v5),v5=window.setTimeout(()=>{ep=!1},100)),t[T.CTRL_OR_CMD]&&ir(t.target)&&(t.code===pe.MINUS||t.code===pe.EQUAL)){t.preventDefault();return}if(ir(t.target)&&t.key!==T.ESCAPE||Un(t.key)&&Sp(t.target))return;if(t.key===T.QUESTION_MARK){this.setState({openDialog:{name:"help"}});return}else if(t.key.toLowerCase()===T.E&&t.shiftKey&&t[T.CTRL_OR_CMD]){t.preventDefault(),this.setState({openDialog:{name:"imageExport"}});return}if(t.key===T.PAGE_UP||t.key===T.PAGE_DOWN){let a=(t.shiftKey?this.state.width:this.state.height)/this.state.zoom.value;t.key===T.PAGE_DOWN&&(a=-a),t.shiftKey?this.translateCanvas(l=>({scrollX:l.scrollX+a})):this.translateCanvas(l=>({scrollY:l.scrollY+a}))}if(this.state.openDialog?.name==="elementLinkSelector"||this.actionManager.handleKeyDown(t)||this.state.viewModeEnabled)return;if(t[T.CTRL_OR_CMD]&&this.state.isBindingEnabled&&this.setState({isBindingEnabled:!1}),Un(t.key)){let a=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0}),l=a.find(te),s=new Set;a.filter(te).filter(p=>{let u=p.startBinding&&!a.some(b=>b.id===p.startBinding?.elementId),g=p.endBinding&&!a.some(b=>b.id===p.endBinding?.elementId);return u||g}).forEach(p=>s.add(p.id)),a=a.filter(p=>!s.has(p.id));let c=this.getEffectiveGridSize()&&(t.shiftKey?ap:this.getEffectiveGridSize())||(t.shiftKey?Kf:ap),m=0,d=0;t.key===T.ARROW_LEFT?m=-c:t.key===T.ARROW_RIGHT?m=c:t.key===T.ARROW_UP?d=-c:t.key===T.ARROW_DOWN&&(d=c),a.forEach(p=>{B(p,{x:p.x+m,y:p.y+d},!1),at(p,this.scene.getNonDeletedElementsMap(),{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:ac(a.filter(p=>p.id!==l?.id||c!==0),this.scene.getNonDeletedElementsMap(),this.state.zoom)}),this.scene.triggerUpdate(),t.preventDefault()}else if(t.key===T.ENTER){let a=this.scene.getSelectedElements(this.state);if(a.length===1){let l=a[0];if(t[T.CTRL_OR_CMD])ae(l)&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==a[0].id)&&(this.store.shouldCaptureIncrement(),te(l)||this.setState({editingLinearElement:new j(l)}));else if(Z(l)||ab(l)){let s;Z(l)||(s=l);let c=nc(l,this.state,this.scene.getNonDeletedElementsMap()),m=c.x,d=c.y;this.startTextEditing({sceneX:m,sceneY:d,container:s}),t.preventDefault();return}else ne(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=xv(t.key);a?(this.state.activeTool.type!==a&&xe("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Et.sharp?Et.round:l.currentItemArrowType===Et.round?Et.elbow:Et.sharp})),this.setActiveTool({type:a}),t.stopPropagation()):t.key===T.Q&&(this.toggleLock("keyboard"),t.stopPropagation())}if(t.key===T.SPACE&&Ae.pointers.size===0&&(Mi=!0,Le(this.interactiveCanvas,Se.GRAB),t.preventDefault()),(t.key===T.G||t.key===T.S)&&!t.altKey&&!t[T.CTRL_OR_CMD]){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;t.key===T.G&&(mn(this.state.activeTool.type)||a.some(l=>mn(l.type)))&&(this.setState({openPopup:"elementBackground"}),t.stopPropagation()),t.key===T.S&&(this.setState({openPopup:"elementStroke"}),t.stopPropagation())}if(!t[T.CTRL_OR_CMD]&&t.shiftKey&&t.key.toLowerCase()===T.F){let a=this.scene.getSelectedElements(this.state);if(this.state.activeTool.type==="selection"&&!a.length)return;(this.state.activeTool.type==="text"||a.find(l=>Z(l)||ge(l,this.scene.getNonDeletedElementsMap())))&&(t.preventDefault(),this.setState({openPopup:"fontFamily"}))}if(t.key===T.K&&!t.altKey&&!t[T.CTRL_OR_CMD]){this.state.activeTool.type==="laser"?this.setActiveTool({type:"selection"}):this.setActiveTool({type:"laser"});return}t[T.CTRL_OR_CMD]&&(t.key===T.BACKSPACE||t.key===T.DELETE)&&St.set(Ci,"clearCanvas");let r=t.key.toLocaleLowerCase(),n=r===T.S&&t.shiftKey,i=t.key===T.I||r===T.G&&t.shiftKey;(n||i)&&this.openEyeDropper({type:n?"stroke":"background"})}));C(this,"onKeyUp",tt(t=>{if(t.key===T.SPACE&&(this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector"?Le(this.interactiveCanvas,Se.GRAB):this.state.activeTool.type==="selection"||this.state.activeTool.type==="lasso"?xo(this.interactiveCanvas):(Eo(this.interactiveCanvas,this.state),this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),Mi=!1),!t[T.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Un(t.key)&&(Qn(this.scene.getSelectedElements(this.state).filter(ae),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,Jn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom),this.setState({suggestedBindings:[]})),t.altKey||this.flowChartNavigator.isExploring&&(this.flowChartNavigator.clear(),this.syncActionResult({captureUpdate:A.IMMEDIATELY})),!t[T.CTRL_OR_CMD]&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.pendingNodes?.length&&this.scene.insertElements(this.flowChartCreator.pendingNodes);let r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:Me({[r.id]:!0},n)})),Vi([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})}}));C(this,"isToolSupported",t=>this.props.UIOptions.tools?.[t]!==!1);C(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=He(this.state,t);n.type==="hand"?Le(this.interactiveCanvas,Se.GRAB):Mi||Eo(this.interactiveCanvas,{...this.state,activeTool:n}),v1(document.activeElement)&&this.focusContainer(),B1(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.shouldCaptureIncrement(),n.type==="lasso"?{...i,activeTool:n,...r?{}:{selectedElementIds:Me({},i),selectedGroupIds:Me({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:Me({},i),selectedGroupIds:Me({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});C(this,"setOpenDialog",t=>{this.setState({openDialog:t})});C(this,"setCursor",t=>{Le(this.interactiveCanvas,t)});C(this,"resetCursor",()=>{xo(this.interactiveCanvas)});C(this,"isTouchScreenMultiTouchGesture",()=>Ae.pointers.size>=2);C(this,"getName",()=>this.state.name||this.props.name||`${f("labels.untitled")}-${Ip()}`);C(this,"onGestureStart",tt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null}),Ae.initialScale=this.state.zoom.value}));C(this,"onGestureChange",tt(t=>{if(t.preventDefault(),this.isTouchScreenMultiTouchGesture())return;let r=Ae.initialScale;r&&this.setState(n=>({...zr({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:dr(r*t.scale)},n)}))}));C(this,"onGestureEnd",tt(t=>{t.preventDefault(),this.isTouchScreenMultiTouchGesture()&&this.setState({previousSelectedElementIds:{},selectedElementIds:Me(this.state.previousSelectedElementIds,this.state)}),Ae.initialScale=null}));C(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&&(ge(i,this.scene.getNonDeletedElementsMap())||(l=!0));let c=null,m=this.scene.getSelectedElements(this.state);m.length===1?Z(m[0])?c=m[0]:i?c=ge(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||kr(d),u=this.state.currentItemFontSize;if(!c&&l&&i&&!ke(i)){let E=tc(qe({fontSize:u,fontFamily:d}),p),w=oc(u,p),y=Math.max(i.height,w),v=Math.max(i.width,E);B(i,{height:y,width:v}),t=i.x+v/2,r=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let g=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=c||Vt({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?Qt.MIDDLE:sp,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?ke(i)?0:i.angle:0,frameId:g?g.id:null});if(!c&&l&&i&&B(i,{boundElements:(i.boundElements||[]).concat({type:"text",id:b.id})}),this.setState({editingTextElement:b}),!c)if(i&&l){let x=this.scene.getElementIndex(i.id);this.scene.insertElementAtIndex(b,x+1)}else this.scene.insertElement(b);a||c||i?this.handleTextWysiwyg(b,{isExistingElement:!!c}):this.setState({newElement:b,multiElement:null})});C(this,"startImageCropping",t=>{this.store.shouldCaptureIncrement(),this.setState({croppingElementId:t.id})});C(this,"finishImageCropping",()=>{this.state.croppingElementId&&(this.store.shouldCaptureIncrement(),this.setState({croppingElementId:null}))});C(this,"handleCanvasDoubleClick",t=>{if(this.state.multiElement||this.state.activeTool.type!=="selection")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=$e(t,this.state);if(r.length===1&&ae(r[0])){if(t[T.CTRL_OR_CMD]&&(!this.state.editingLinearElement||this.state.editingLinearElement.elementId!==r[0].id)&&!te(r[0])){this.store.shouldCaptureIncrement(),this.setState({editingLinearElement:new j(r[0])});return}else if(this.state.selectedLinearElement&&te(r[0])){let l=j.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),s=l?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,l,this.scene.getNonDeletedElementsMap()):-1;if(s&&s>-1){this.store.shouldCaptureIncrement(),j.deleteFixedSegment(r[0],s);let c=j.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,y:i},this.state,this.scene.getNonDeletedElementsMap()),m=c?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,c,this.scene.getNonDeletedElementsMap()):null;this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:{...this.state.selectedLinearElement.pointerDownState,segmentMidpoint:{index:m,value:l,added:!1}},segmentMidPointHoveredCoords:c}});return}}}if(r.length===1&&he(r[0])){this.startImageCropping(r[0]);return}if(xo(this.interactiveCanvas),Zo(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&Pb(l,this.state.selectedGroupIds);if(s){this.store.shouldCaptureIncrement(),this.setState(c=>({...c,...lt({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),c,this)}));return}}if(xo(this.interactiveCanvas),!t[T.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(Oi(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(pt(s)||!Kn(s.backgroundColor)||zi({x:n,y:i,element:s,shape:Rr(s,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()}))){let c=nc(s,this.state,this.scene.getNonDeletedElementsMap());n=c.x,i=c.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}});C(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&&Mc(l,this.scene.getNonDeletedElementsMap(),this.state,M(t.x,t.y),this.device.editor.isMobile))return l}});C(this,"redirectToLink",(t,r)=>{let n=Gn(M(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),M(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>Fn)return;let i=$e(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Mc(this.hitLinkElement,a,this.state,M(i.x,i.y),this.device.editor.isMobile),s=$e(this.lastPointerUpEvent,this.state),c=Mc(this.hitLinkElement,a,this.state,M(s.x,s.y),this.device.editor.isMobile);if(l&&c){Hh();let m=this.hitLinkElement.link;if(m){m=Wo(m);let d;if(this.props.onLinkOpen&&(d=js("excalidraw-link",t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},d)),!d?.defaultPrevented){let p=Js(m)?"_self":"_blank",u=window.open(void 0,p);u&&(u.opener=null,u.location=m)}}}});C(this,"getTopLayerFrameAtSceneCoords",t=>{let r=this.scene.getNonDeletedElementsMap(),n=this.scene.getNonDeletedFramesLikes().filter(i=>zp(t,i,r));return n.length?n[n.length-1]:null});C(this,"handleCanvasPointerMove",t=>{this.savePointer(t.clientX,t.clientY,this.state.cursorButton),this.lastPointerMoveEvent=t.nativeEvent,Ae.pointers.has(t.pointerId)&&Ae.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=Ae.initialScale;if(Ae.pointers.size===2&&Ae.lastCenter&&r&&Ae.initialDistance){let u=fg(Ae.pointers),g=u.x-Ae.lastCenter.x,b=u.y-Ae.lastCenter.y;Ae.lastCenter=u;let x=bg(Array.from(Ae.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:x/Ae.initialDistance,w=E?dr(r*E):this.state.zoom.value;this.setState(y=>{let v=zr({viewportX:u.x,viewportY:u.y,nextZoom:w},y);this.translateCanvas({zoom:v.zoom,scrollX:v.scrollX+2*(g/w),scrollY:v.scrollY+2*(b/w),shouldCacheIgnoreZoom:!0})}),this.resetShouldCacheIgnoreZoomDebounced()}else Ae.lastCenter=Ae.initialDistance=Ae.initialScale=null;if(Mi||vs||pf||Xo(this.state))return;let i=vg(uf,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop).isOverEither;!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.multiElement&&(i?xo(this.interactiveCanvas):Eo(this.interactiveCanvas,this.state));let a=$e(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Zv(this.state.activeTool.type)){let{originOffset:u,snapLines:g}=Kv(this.scene.getNonDeletedElements(),this,{x:l,y:s},t,this.scene.getNonDeletedElementsMap());this.setState(b=>{let x=Ni(b.snapLines,g),E=b.originSnapOffset?Ni(b.originSnapOffset,u):u;return b.snapLines===x&&b.originSnapOffset===E?null:{snapLines:x,originSnapOffset:E}})}else!this.state.newElement&&!this.state.selectedElementsAreBeingDragged&&!this.state.selectionElement&&this.setState(u=>u.snapLines.length?{snapLines:[]}:null);if(this.state.editingLinearElement&&!this.state.editingLinearElement.isDragging){let u=j.handlePointerMove(t,l,s,this,this.scene.getNonDeletedElementsMap());u&&u!==this.state.editingLinearElement&&ki(()=>{this.setState({editingLinearElement:u})}),u?.lastUncommittedPoint!=null?this.maybeSuggestBindingAtCursor(a,u.elbowed):ki(()=>{this.setState({suggestedBindings:[]})})}if(z1(this.state.activeTool.type)){let{newElement:u}=this.state;_r(u,!1)?this.maybeSuggestBindingsForLinearElementAtCoords(u,[a],this.state.startBoundElement):this.maybeSuggestBindingAtCursor(a,!1)}if(this.state.multiElement){let{multiElement:u}=this.state,{x:g,y:b}=u,{points:x,lastCommittedPoint:E}=u,w=x[x.length-1];if(Eo(this.interactiveCanvas,this.state),w===E)Gn(M(l-g,s-b),w)>=Ps?B(u,{points:[...x,M(l-g,s-b)]},!1):Le(this.interactiveCanvas,Se.POINTER);else if(x.length>2&&E&&Gn(M(l-g,s-b),E)<Ps)Le(this.interactiveCanvas,Se.POINTER),B(u,{points:x.slice(0,-1)},!1);else{let[y,v]=ht(l,s,t[T.CTRL_OR_CMD]||te(u)?null:this.getEffectiveGridSize()),[I,S]=u?.lastCommittedPoint??[0,0],_=y-g-I,L=v-b-S;Ws(t)&&({width:_,height:L}=Rp(I+g,S+b,y,v)),yl(x,this.state.zoom.value)&&Le(this.interactiveCanvas,Se.POINTER),B(u,{points:[...x.slice(0,-1),M(I+_,S+L)]},!1,{isDragging:!0}),this.triggerRender(!1)}return}if(!!t.buttons||this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="text"&&this.state.activeTool.type!=="eraser")return;let m=this.scene.getNonDeletedElements(),d=this.scene.getSelectedElements(this.state);if(d.length===1&&!i&&!this.state.editingLinearElement){if(this.state.selectedLinearElement&&this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s),(!this.state.selectedLinearElement||this.state.selectedLinearElement.hoverPointIndex===-1)&&this.state.openDialog?.name!=="elementLinkSelector"&&!(d.length===1&&te(d[0]))){let u=hu(m,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(u&&u.transformHandleType){Le(this.interactiveCanvas,fu(u));return}}}else if(d.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let u=gu(ye(d),l,s,this.state.zoom,t.pointerType,this.device);if(u){Le(this.interactiveCanvas,fu({transformHandleType:u}));return}}let p=this.getElementAtPosition(a.x,a.y);this.hitLinkElement=this.getElementLinkAtPosition(a,p),!no(this.state)&&(this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?(Le(this.interactiveCanvas,Se.POINTER),v2(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(Hh(),p&&(p.link||Ft(p))&&this.state.selectedElementIds[p.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?Le(this.interactiveCanvas,Z(p)?Se.TEXT:Se.CROSSHAIR):this.state.viewModeEnabled?Le(this.interactiveCanvas,Se.GRAB):this.state.openDialog?.name==="elementLinkSelector"?Le(this.interactiveCanvas,Se.AUTO):i?Le(this.interactiveCanvas,Se.AUTO):this.state.selectedLinearElement?this.handleHoverSelectedLinearElement(this.state.selectedLinearElement,l,s):t[T.CTRL_OR_CMD]?Le(this.interactiveCanvas,Se.AUTO):(p||this.isHittingCommonBoundingBoxOfSelectedElements(a,d))&&!p?.locked&&(p&&Oi(p)&&this.isIframeLikeElementCenter(p,t,l,s)?(Le(this.interactiveCanvas,Se.POINTER),this.setState({activeEmbeddable:{element:p,state:"hover"}})):(!p||!te(p)||!(p.startBinding||p.endBinding))&&(Le(this.interactiveCanvas,Se.MOVE),this.state.activeEmbeddable?.state==="hover"&&this.setState({activeEmbeddable:null})))),this.state.openDialog?.name==="elementLinkSelector"&&p?this.setState(u=>({hoveredElementIds:Ni(u.hoveredElementIds,lt({editingGroupId:u.editingGroupId,selectedElementIds:{[p.id]:!0}},this.scene.getNonDeletedElements(),u,this).selectedElementIds)})):this.state.openDialog?.name==="elementLinkSelector"&&!p&&this.setState(u=>({hoveredElementIds:Ni(u.hoveredElementIds,{})})))});C(this,"handleEraser",(t,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,t.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});C(this,"handleTouchMove",t=>{ws=!0});C(this,"handleCanvasPointerDown",t=>{let r=t.target;if(r.setPointerCapture&&r.setPointerCapture(t.pointerId),this.maybeCleanupAfterMissingPointerUp(t.nativeEvent),this.maybeUnfollowRemoteUser(),this.state.searchMatches&&(this.setState(d=>({searchMatches:d.searchMatches.map(p=>({...p,focus:!1}))})),St.set(Wg,null)),this.state.contextMenu&&this.setState({contextMenu:null}),this.state.snapLines&&this.setAppState({snapLines:[]}),this.updateGestureOnPointerDown(t),t.pointerType==="touch"&&this.state.newElement&&this.state.newElement.type==="freedraw"){let d=this.state.newElement;this.updateScene({...d.points.length<10?{elements:this.scene.getElementsIncludingDeleted().filter(p=>p.id!==d.id)}:{},appState:{newElement:null,editingTextElement:null,startBoundElement:null,suggestedBindings:[],selectedElementIds:Me(Object.keys(this.state.selectedElementIds).filter(p=>p!==d.id).reduce((p,u)=>(p[u]=this.state.selectedElementIds[u],p),{}),this.state)},captureUpdate:this.state.openDialog?.name==="elementLinkSelector"?A.EVENTUALLY:A.NEVER});return}let n=document.getSelection();if(n?.anchorNode&&n.removeAllRanges(),this.maybeOpenContextMenuAfterPointerDownOnTouchDevices(t),!this.state.penDetected&&t.pointerType==="pen"&&this.setState(d=>({penMode:!0,penDetected:!0})),!this.device.isTouchScreen&&["pen","touch"].includes(t.pointerType)&&(this.device=Ri(this.device,{isTouchScreen:!0})),vs||(this.lastPointerDownEvent=t,this.handleCanvasPanUsingWheelOrSpaceDrag(t)))return;if(this.setState({lastPointerDownWith:t.pointerType,cursorButton:"down"}),this.savePointer(t.clientX,t.clientY,"down"),t.button===nr.ERASER&&this.state.activeTool.type!==it.eraser){this.setState({activeTool:He(this.state,{type:it.eraser,lastActiveToolBeforeEraser:this.state.activeTool})},()=>{this.handleCanvasPointerDown(t);let d=()=>{p(),u?.(),no(this.state)&&this.setState({activeTool:He(this.state,{...this.state.activeTool.lastActiveTool||{type:it.selection},lastActiveToolBeforeEraser:null})})},p=Ye(window,"pointerup",d,{once:!0}),u;requestAnimationFrame(()=>{u=this.missingPointerEventCleanupEmitter.once(d)})});return}if(t.button!==nr.MAIN&&t.button!==nr.TOUCH&&t.button!==nr.ERASER||Ae.pointers.size>1)return;let i=this.initialPointerDownState(t);if(this.setState({selectedElementsAreBeingDragged:!1}),this.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"){Le(this.interactiveCanvas,Se.CROSSHAIR);let d=this.state.pendingImageElementId&&this.scene.getElement(this.state.pendingImageElementId);if(!d)return;this.setState({newElement:d,pendingImageElementId:null,multiElement:null});let{x:p,y:u}=$e(t,this.state),g=this.getTopLayerFrameAtSceneCoords({x:p,y:u});B(d,{x:p,y:u,frameId:g?g.id:null})}else this.state.activeTool.type==="freedraw"?this.handleFreeDrawElementOnPointerDown(t,this.state.activeTool.type,i):this.state.activeTool.type==="custom"?Eo(this.interactiveCanvas,this.state):this.state.activeTool.type===it.frame||this.state.activeTool.type===it.magicframe?this.createFrameElementOnPointerDown(i,this.state.activeTool.type):this.state.activeTool.type==="laser"?this.laserTrails.startPath(i.lastCoords.x,i.lastCoords.y):this.state.activeTool.type!=="eraser"&&this.state.activeTool.type!=="hand"&&this.createGenericElementOnPointerDown(this.state.activeTool.type,i);this.props?.onPointerDown?.(this.state.activeTool,i),this.onPointerDownEmitter.trigger(this.state.activeTool,i,t),this.state.activeTool.type==="eraser"&&this.eraserTrail.startPath(i.lastCoords.x,i.lastCoords.y);let l=this.onPointerMoveFromPointerDownHandler(i),s=this.onPointerUpFromPointerDownHandler(i),c=this.onKeyDownFromPointerDownHandler(i),m=this.onKeyUpFromPointerDownHandler(i);this.missingPointerEventCleanupEmitter.once(d=>s(d||t.nativeEvent)),(!this.state.viewModeEnabled||this.state.activeTool.type==="laser")&&(window.addEventListener("pointermove",l),window.addEventListener("pointerup",s),window.addEventListener("keydown",c),window.addEventListener("keyup",m),i.eventListeners.onMove=l,i.eventListeners.onUp=s,i.eventListeners.onKeyUp=m,i.eventListeners.onKeyDown=c)});C(this,"handleCanvasPointerUp",t=>{this.removePointer(t),this.lastPointerUpEvent=t;let r=$e({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(Oi(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&&Oi(this.hitLinkElement)&&!c0(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,M(r.x,r.y))?this.handleEmbeddableCenterClick(this.hitLinkElement):this.redirectToLink(t,this.device.isTouchScreen):this.state.viewModeEnabled&&this.setState({activeEmbeddable:null,selectedElementIds:{}})});C(this,"maybeOpenContextMenuAfterPointerDownOnTouchDevices",t=>{t.pointerType==="touch"&&(ws=!1,Nn?ws=!0:Nn=window.setTimeout(()=>{Nn=0,ws||this.handleCanvasContextMenu(t)},t1))});C(this,"resetContextMenuTimer",()=>{clearTimeout(Nn),Nn=0,ws=!1});C(this,"maybeCleanupAfterMissingPointerUp",t=>{Ts?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});C(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(Ae.pointers.size<=1&&(t.button===nr.WHEEL||t.button===nr.MAIN&&Mi||Xo(this.state)||this.state.viewModeEnabled)))return!1;vs=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);Le(this.interactiveCanvas,Se.GRABBING);let{clientX:i,clientY:a}=t,l=xm(c=>{let m=i-c.clientX,d=a-c.clientY;if(i=c.clientX,a=c.clientY,n&&!r&&(Math.abs(m)>1||Math.abs(d)>1)){r=!0;let p=g=>{document.body.removeEventListener("paste",p),g.stopPropagation()},u=()=>{setTimeout(()=>{document.body.removeEventListener("paste",p),window.removeEventListener("pointerup",u)},100)};document.body.addEventListener("paste",p),window.addEventListener("pointerup",u)}this.translateCanvas({scrollX:this.state.scrollX-m/this.state.zoom.value,scrollY:this.state.scrollY-d/this.state.zoom.value})}),s=tt(Ts=()=>{Ts=null,vs=!1,Mi||(this.state.viewModeEnabled?Le(this.interactiveCanvas,Se.GRAB):Eo(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});C(this,"clearSelectionIfNotUsingSelection",()=>{this.state.activeTool.type!=="selection"&&this.state.activeTool.type!=="lasso"&&this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})});C(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&&!te(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=hu(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=gu(ye(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=rn(R0(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&ae(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=N0(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let c=this.state.editingLinearElement||this.state.selectedLinearElement,m=j.handlePointerDown(t,this,this.store,r.origin,c,this.scene);if(m.hitElement&&(r.hit.element=m.hitElement),m.linearElementEditor&&(this.setState({selectedLinearElement:m.linearElementEditor}),this.state.editingLinearElement&&this.setState({editingLinearElement:m.linearElementEditor})),m.didAddPoint)return!0}if(r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,r.hit.element),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=this.getElementsAtPosition(r.origin.x,r.origin.y);let l=r.hit.element,s=r.hit.allHitElements.some(c=>this.isASelectedElement(c));if((l===null||!s)&&!t.shiftKey&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&this.clearSelection(l),this.state.editingLinearElement)this.setState({selectedElementIds:Me({[this.state.editingLinearElement.elementId]:!0},this.state)});else if(l!=null){if(t[T.CTRL_OR_CMD])return this.state.selectedElementIds[l.id]||(r.hit.wasAddedToSelection=!0),this.setState(c=>({...Db(c,l),previousSelectedElementIds:this.state.selectedElementIds})),!1;this.state.selectedElementIds[l.id]||(this.state.editingGroupId&&!Ki(l,this.state.editingGroupId)&&this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!s&&!r.hit.hasHitCommonBoundingBoxOfSelectedElements&&(this.setState(c=>{let m={...c.selectedElementIds,[l.id]:!0},d=[];if(Object.keys(c.selectedElementIds).forEach(p=>{let u=this.scene.getElement(p);u&&d.push(u)}),ne(l))Mo(d,l.id).forEach(p=>{delete m[p.id]});else if(l.frameId)m[l.frameId]&&delete m[l.id];else{let p=l.groupIds,u=new Set(p.flatMap(g=>Fe(this.scene.getNonDeletedElements(),g)).filter(g=>ne(g)).map(g=>g.id));u.size>0&&d.forEach(g=>{g.frameId&&u.has(g.frameId)&&(delete m[g.id],g.groupIds.flatMap(b=>Fe(this.scene.getNonDeletedElements(),b)).forEach(b=>{delete m[b.id]}))})}return c.openDialog?.name==="elementLinkSelector"&&(l.groupIds.some(p=>c.selectedGroupIds[p])||(m={[l.id]:!0})),{...lt({editingGroupId:c.editingGroupId,selectedElementIds:m},this.scene.getNonDeletedElements(),c,this),showHyperlinkPopup:l.link||Ft(l)?"info":!1}}),r.hit.wasAddedToSelection=!0))}this.setState({previousSelectedElementIds:this.state.selectedElementIds})}}return!1});C(this,"handleTextOnPointerDown",(t,r)=>{if(this.state.editingTextElement)return;let n=r.origin.x,i=r.origin.y,a=this.getElementAtPosition(n,i,{includeBoundTextElement:!0}),l=this.getTextBindableContainerAtPosition(n,i);pt(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),xo(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:He(this.state,{type:"selection"})})});C(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=ht(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,c=qb({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:null,simulatePressure:s,locked:!1,frameId:l?l.id:null,points:[M(0,0)],pressures:s?[]:[t.pressure]});this.scene.insertElement(c),this.setState(d=>{let p={...d.selectedElementIds};return delete p[c.id],{selectedElementIds:Me(p,d)}});let m=cn(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:c,startBoundElement:m,suggestedBindings:[]})});C(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=ht(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=$b({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});C(this,"insertEmbeddableElement",({sceneX:t,sceneY:r,link:n})=>{let[i,a]=ht(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=ni(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:f("toast.unrecognizedLinkFormat"),closable:!0});let s=Zp({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});C(this,"createImageElement",({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0})=>{let[i,a]=ht(t,r,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=n?this.getTopLayerFrameAtSceneCoords({x:i,y:a}):null;return wc({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})});C(this,"handleLinearElementOnPointerDown",(t,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&yl(i.points,this.state.zoom.value)){B(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(yo);return}if(te(i)&&i.points.length>1){B(i,{lastCommittedPoint:i.points[i.points.length-1]}),this.actionManager.executeAction(yo);return}let{x:a,y:l,lastCommittedPoint:s}=i;if(i.points.length>1&&s&&Gn(M(n.origin.x-a,n.origin.y-l),s)<Ps){this.actionManager.executeAction(yo);return}this.setState(c=>({selectedElementIds:Me({...c.selectedElementIds,[i.id]:!0},c)})),B(i,{lastCommittedPoint:i.points[i.points.length-1]}),Le(this.interactiveCanvas,Se.POINTER)}else{let[i,a]=ht(n.origin.x,n.origin.y,t[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),{currentItemStartArrowhead:s,currentItemEndArrowhead:c}=this.state,[m,d]=r==="arrow"?[s,c]:[null,null],p=r==="arrow"?ji({type:r,x:i,y:a,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.state.currentItemArrowType===Et.round?{type:eo.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:d,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Et.elbow,fixedSegments:this.state.currentItemArrowType===Et.elbow?[]:null}):cr({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:eo.PROPORTIONAL_RADIUS}:null,locked:!1,frameId:l?l.id:null});this.setState(g=>{let b={...g.selectedElementIds};return delete b[p.id],{selectedElementIds:Me(b,g)}}),B(p,{points:[...p.points,M(0,0)]});let u=cn(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,te(p),te(p));this.scene.insertElement(p),this.setState({newElement:p,startBoundElement:u,suggestedBindings:[]})}});C(this,"createGenericElementOnPointerDown",(t,r)=>{let[n,i]=ht(r.origin.x,r.origin.y,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a=this.getTopLayerFrameAtSceneCoords({x:n,y:i}),l={x:n,y:i,strokeColor:this.state.currentItemStrokeColor,backgroundColor:this.state.currentItemBackgroundColor,fillStyle:this.state.currentItemFillStyle,strokeWidth:this.state.currentItemStrokeWidth,strokeStyle:this.state.currentItemStrokeStyle,roughness:this.state.currentItemRoughness,opacity:this.state.currentItemOpacity,roundness:this.getCurrentItemRoundness(t),locked:!1,frameId:a?a.id:null},s;t==="embeddable"?s=Zp({type:"embeddable",...l}):s=Gt({type:t,...l}),s.type==="selection"?this.setState({selectionElement:s}):(this.scene.insertElement(s),this.setState({multiElement:null,newElement:s}))});C(this,"createFrameElementOnPointerDown",(t,r)=>{let[n,i]=ht(t.origin.x,t.origin.y,this.lastPointerDownEvent?.[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),a={x:n,y:i,opacity:this.state.currentItemOpacity,locked:!1,...Vo},l=r===it.magicframe?wl(a):$i(a);this.scene.insertElement(l),this.setState({multiElement:null,newElement:l})});C(this,"restoreReadyToEraseElements",()=>{this.elementsPendingErasure=new Set,this.triggerRender()});C(this,"eraseElements",()=>{let t=!1,r=this.scene.getElementsIncludingDeleted().map(n=>this.elementsPendingErasure.has(n.id)||n.frameId&&this.elementsPendingErasure.has(n.frameId)||_e(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,oe(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.shouldCaptureIncrement(),this.scene.replaceAllElements(r))});C(this,"initializeImage",async({imageFile:t,imageElement:r,showCursorImagePreview:n=!1})=>{if(!Pc(t))throw new Error(f("errors.unsupportedFileType"));let i=t.type;if(Le(this.interactiveCanvas,"wait"),i===ue.svg)try{t=nu($p(await t.text()),t.name)}catch(m){throw console.warn(m),new Error(f("errors.svgImageInsertError"))}let a=await(this.props.generateIdForFile?.(t)||x0(t));if(!a)throw console.warn("Couldn't generate file id or the supplied `generateIdForFile` didn't resolve to one."),new Error(f("errors.imageInsertError"));if(!this.files[a]?.dataURL){try{t=await Sl(t,{maxWidthOrHeight:c1})}catch(m){console.error("Error trying to resizing image file on insertion",m)}if(t.size>up)throw new Error(f("errors.fileTooBig",{maxSize:`${Math.trunc(up/1024/1024)}MB`}))}if(n){let m=this.files[a]?.dataURL,d=m&&y0(m);this.setImagePreviewCursor(d||t)}let s=this.files[a]?.dataURL||await Nc(t),c=B(r,{fileId:a},!1);return new Promise(async(m,d)=>{try{this.addMissingFiles([{mimeType:i,id:a,dataURL:s,created:Date.now(),lastRetrieved:Date.now()}]);let p=this.imageCache.get(a);p||(this.addNewImagesToImageCache(),await this.updateImageCache([c])),p?.image instanceof Promise&&await p.image,this.state.pendingImageElementId!==c.id&&this.state.newElement?.id!==c.id&&this.initializeImageDimensions(c,!0),m(c)}catch(p){console.error(p),d(new Error(f("errors.imageInsertError")))}finally{n||xo(this.interactiveCanvas)}})});C(this,"insertImageElement",async(t,r,n)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:f("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{return await this.initializeImage({imageFile:r,imageElement:t,showCursorImagePreview:n})}catch(i){return B(t,{isDeleted:!0}),this.actionManager.executeAction(yo),this.setState({errorMessage:i.message||f("errors.imageInsertError")}),null}});C(this,"setImagePreviewCursor",async t=>{let n;try{n=await Sl(t,{maxWidthOrHeight:96})}catch(a){throw a.cause==="UNSUPPORTED"?new Error(f("errors.unsupportedFileType")):a}let i=await Nc(n);if(t.type===ue.svg){let a=await Qb(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(ue.svg)}this.state.pendingImageElementId&&Le(this.interactiveCanvas,`url(${i}) 4 4, auto`)});C(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}=$e({clientX:r,clientY:n},this.state),l=await Sc({description:"Image",extensions:Object.keys(ol)}),s=this.createImageElement({sceneX:i,sceneY:a,addToFrameUnderCursor:!1});t?(this.insertImageElement(s,l),this.initializeImageDimensions(s),this.setState({selectedElementIds:Me({[s.id]:!0},this.state)},()=>{this.actionManager.executeAction(yo)})):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:He(this.state,{type:"selection"})},()=>{this.actionManager.executeAction(yo)})}});C(this,"initializeImageDimensions",(t,r=!1)=>{let n=Ar(t)&&this.imageCache.get(t.fileId)?.image;if(!n||n instanceof Promise){if(t.width<Fn/this.state.zoom.value&&t.height<Fn/this.state.zoom.value){let i=100/this.state.zoom.value;B(t,{x:t.x-i/2,y:t.y-i/2,width:i,height:i})}return}if(r||t.width<Fn/this.state.zoom.value&&t.height<Fn/this.state.zoom.value){let i=Math.max(this.state.height-120,160),a=Math.min(i,Math.floor(this.state.height*.5)/this.state.zoom.value),l=Math.min(n.naturalHeight,a),s=l*(n.naturalWidth/n.naturalHeight),c=t.x+t.width/2-s/2,m=t.y+t.height/2-l/2;B(t,{x:c,y:m,width:s,height:l,crop:null})}});C(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await e0({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)&&pn.delete(a);return i.size&&this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().map(a=>Ar(a)&&i.has(a.fileId)?oe(a,{status:"error"}):a)),{updatedFiles:n,erroredFiles:i}});C(this,"addNewImagesToImageCache",async(t=t0(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()}});C(this,"scheduleImageRefresh",V8(()=>{this.addNewImagesToImageCache()},Qf));C(this,"updateBindingEnabledOnPointerMove",t=>{let r=sb(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});C(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=cn(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});C(this,"maybeSuggestBindingsForLinearElementAtCoords",(t,r,n)=>{if(!r.length)return;let i=r.reduce((a,l)=>{let s=cn(l,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,te(t),te(t));return s!=null&&!mb(t,n?.id,s)&&a.push(s),a},[]);this.setState({suggestedBindings:i})});C(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))});C(this,"handleAppOnDrop",async t=>{let{file:r,fileHandle:n}=await T0(t),{x:i,y:a}=$e(t,this.state);try{if(Pc(r)&&this.isToolSupported("image")){if(r?.type===ue.png||r?.type===ue.svg)try{let c=await Rc(r,this.state,this.scene.getElementsIncludingDeleted(),n);this.syncActionResult({...c,appState:{...c.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:A.IMMEDIATELY});return}catch(c){if(c.name!=="EncodingError")throw new Error(f("alerts.couldNotLoadInvalidFile"))}let s=this.createImageElement({sceneX:i,sceneY:a});this.insertImageElement(s,r),this.initializeImageDimensions(s),this.setState({selectedElementIds:Me({[s.id]:!0},this.state)});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let l=t.dataTransfer.getData(ue.excalidrawlib);if(l&&typeof l=="string"){try{let s=b0(l);this.addElementsFromPasteOrLibrary({elements:$d(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&&qi(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||ni(s)?.type==="video")){let c=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:Wo(s)});c&&this.setState({selectedElementIds:{[c.id]:!0}})}}});C(this,"loadFileToCanvas",async(t,r)=>{t=await I0(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await ou(t,this.state,n,r)}catch(a){let l=a instanceof a0;if(l&&a.code==="IMAGE_NOT_CONTAINS_SCENE_DATA"&&!this.isToolSupported("image")){this.setState({isLoading:!1,errorMessage:f("errors.imageToolNotSupported")});return}let s=l?f("alerts.cannotRestoreFromImage"):f("alerts.couldNotLoadInvalidFile");this.setState({isLoading:!1,errorMessage:s})}if(!i)return;i.type===ue.excalidraw?(Pr(n.concat(i.data.elements)),this.store.updateSnapshot(ee(n),this.state),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:A.IMMEDIATELY})):i.type===ue.excalidrawlib&&await this.library.updateLibrary({libraryItems:t,merge:!0,openLibraryMenu:!0}).catch(a=>{console.error(a),this.setState({errorMessage:f("errors.importLibraryError")})})}catch(n){this.setState({isLoading:!1,errorMessage:n.message})}});C(this,"handleCanvasContextMenu",t=>{if(t.preventDefault(),("pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="touch"||"pointerType"in t.nativeEvent&&t.nativeEvent.pointerType==="pen"&&t.button!==nr.SECONDARY)&&this.state.activeTool.type!=="selection")return;let{x:r,y:n}=$e(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;xe("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...lt({editingGroupId:this.state.editingGroupId,selectedElementIds:{[i.id]:!0}},this.scene.getNonDeletedElements(),this.state,this),selectedLinearElement:ae(i)?new j(i):null}:this.state,showHyperlinkPopup:!1},()=>{this.setState({contextMenu:{top:u,left:p,items:this.getContextMenuItems(s)}})})});C(this,"maybeDragNewGenericElement",(t,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){bu({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Wn(t.origin.x,a.x),height:Wn(t.origin.y,a.y),shouldMaintainAspectRatio:Ai(r),shouldResizeFromCenter:!1,zoom:this.state.zoom.value,informMutation:n});return}let l=this.state.newElement;if(!l)return;let[s,c]=ht(a.x,a.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=Ar(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}=Wv(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}),bu({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:c,width:Wn(t.originInGrid.x,s),height:Wn(t.originInGrid.y,c),shouldMaintainAspectRatio:he(l)?!Ai(r):Ai(r),shouldResizeFromCenter:fp(r),zoom:this.state.zoom.value,widthAspectRatio:d,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===it.frame||this.state.activeTool.type===it.magicframe)&&this.setState({elementsToHighlight:Yi(this.scene.getNonDeletedElements(),l,this.state,this.scene.getNonDeletedElementsMap())})});C(this,"maybeHandleCrop",(t,r)=>{if(!this.state.croppingElementId)return!1;let n=t.resize.handleType,i=t.lastCoords,[a,l]=ht(i.x-t.resize.offset.x,i.y-t.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(n&&s&&he(s)){let c=t.originalElements.get(s.id),m=Ar(s)&&this.imageCache.get(s.fileId)?.image;if(c&&he(c)&&m&&!(m instanceof Promise)){let[d,p]=ht(i.x,i.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:g,snapLines:b}=Eg([s],[c],this,r,u,n);B(s,Gb(s,n,m.naturalWidth,m.naturalHeight,a+g.x,l+g.y,r.shiftKey?c.width/c.height:void 0)),at(s,this.scene.getNonDeletedElementsMap(),{newSize:{width:s.width,height:s.height}}),this.setState({isCropping:n&&n!=="rotation",snapLines:b})}return!0}return!1});C(this,"maybeHandleResize",(t,r)=>{let n=this.scene.getSelectedElements(this.state),i=n.filter(d=>ne(d)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&te(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,c]=ht(l.x-t.resize.offset.x,l.y-t.resize.offset.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),m=new Map;if(i.forEach(d=>{Mo(this.scene.getNonDeletedElements(),d.id).forEach(u=>{m.set(d.id+u.id,{x:u.x-d.x,y:u.y-d.y})})}),!this.state.selectedElementsAreBeingDragged){let[d,p]=ht(l.x,l.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:d-t.originInGrid.x,y:p-t.originInGrid.y},g=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=Eg(n,J(g,this.state),this,r,u,a);s+=b.x,c+=b.y,this.setState({snapLines:x})}if(P0(t.originalElements,a,n,this.scene.getElementsMapIncludingDeleted(),this.scene,Ws(r),fp(r),n.some(d=>he(d))?!Ai(r):Ai(r),s,c,t.resize.center.x,t.resize.center.y)){let d=ac(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{Yi(this.scene.getNonDeletedElements(),u,this.state,this.scene.getNonDeletedElementsMap()).forEach(g=>p.add(g))}),this.setState({elementsToHighlight:[...p],suggestedBindings:d}),!0}return!1});C(this,"getContextMenuItems",t=>{let r=[];return r.push(Ud,Hd),t==="canvas"?this.state.viewModeEnabled?[...r,Vd,Ma,hg,La]:[Dh,bt,Ud,Hd,Gd,bt,Xu,w2,bt,Vd,Ph,Ma,hg,La]:(r.push(Gd),this.state.viewModeEnabled?[ka,...r]:[bt,Fd,ka,Dh,bt,Lv,Av,_v,bt,mg,bt,...r,bt,Ch,Ih,bt,Sh,Ov,Rh,Nh,h2,kh,bt,Lh,bt,Yu,Wu,Ku,Zu,bt,Ah,_h,bt,dg,bt,es,Wd,bt,$u,Gh,bt,Ul])});C(this,"handleWheel",tt(t=>{if(!(t.target instanceof HTMLCanvasElement||t.target instanceof HTMLTextAreaElement||t.target instanceof HTMLIFrameElement)){t[T.CTRL_OR_CMD]&&t.preventDefault();return}if(t.preventDefault(),vs)return;let{deltaX:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(n),a=Li*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=>({...zr({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:dr(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}))}));C(this,"savePointer",(t,r,n)=>{if(!t||!r)return;let{x:i,y:a}=$e({clientX:t,clientY:r},this.state);isNaN(i)||isNaN(a);let l={x:i,y:a,tool:this.state.activeTool.type==="laser"?"laser":"pointer"};this.props.onPointerUpdate?.({pointer:l,button:n,pointersMap:Ae.pointers})});C(this,"resetShouldCacheIgnoreZoomDebounced",Yn(()=>{this.unmounted||this.setState({shouldCacheIgnoreZoom:!1})},300));C(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()})}});C(this,"refresh",()=>{this.setState({...this.getCanvasOffsets()})});let r=mr(),{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:c=r.theme,name:m=`${f("labels.untitled")}-${Ip()}`}=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=W8(),this.library=new R2(this),this.actionManager=new pm(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new dn,this.canvas=document.createElement("canvas"),this.rc=Y8.canvas(this.canvas),this.renderer=new cs(this.scene),this.visibleElements=[],this.store=new Kc,this.history=new as,n){let d={updateScene:this.updateScene,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,onChange:p=>this.onChangeEmitter.on(p),onPointerDown:p=>this.onPointerDownEmitter.on(p),onPointerUp:p=>this.onPointerUpEmitter.on(p),onScrollChange:p=>this.onScrollChangeEmitter.on(p),onUserFollow:p=>this.onUserFollowEmitter.on(p)};typeof n=="function"?n(d):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new un(this.scene),this.history=new as,this.actionManager.registerAll(cd),this.actionManager.registerAction(Pv(this.history,this.store)),this.actionManager.registerAction(Rv(this.history,this.store))}onWindowMessage(t){if(t.origin!=="https://player.vimeo.com"&&t.origin!=="https://www.youtube.com")return;let r=null;try{r=JSON.parse(t.data)}catch{}if(r)switch(t.origin){case"https://player.vimeo.com":if(r.method==="paused"){let n=null,i=document.body.querySelectorAll("iframe.excalidraw__embeddable");if(!i)break;for(let a of i)a.contentWindow===t.source&&(n=a.contentWindow);n?.postMessage(JSON.stringify({method:r.value?"play":"pause",value:!0}),"*")}break;case"https://www.youtube.com":if(r.event==="infoDelivery"&&r.info&&r.id&&typeof r.info.playerState=="number"){let n=r.id,i=r.info.playerState;Object.values(el).includes(i)&&hf.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),Xn(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=hf.get(t.id);switch(n||(hf.set(t.id,el.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case el.PLAYING:case el.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=>Ft(a)&&this.embedsValidationStatus.get(a.id)===!0||Xn(a));return Be(Z8,{children:i.map(a=>{let{x:l,y:s}=zt({sceneX:a.x,sceneY:a.y},this.state),c=El(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(Xn(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:()=>Xp(`
24
+ C -->|Three| F[Car]`,U3=eB(rl,300),rB=({mermaidToExcalidrawLib:e})=>{let[o,t]=z3(()=>Gt.get(QN.MERMAID_TO_EXCALIDRAW)||oB),r=JN(o.trim()),[n,i]=z3(null),a=H3(null),l=H3({elements:[],files:null}),s=Re();G3(()=>{Md({canvasRef:a,data:l,mermaidToExcalidrawLib:e,setError:i,mermaidDefinition:r}).catch(m=>{tB()&&console.error("Failed to parse mermaid definition",m)}),U3(r)},[r,e]),G3(()=>()=>{U3.flush()},[]);let d=()=>{Ld({app:s,data:l,text:o,shouldSaveMermaidDataToStorage:!0})};return Y3(nB,{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})})}),Y3(Sd,{children:[Io(Li,{label:g("mermaid.syntax"),children:Io(Td,{input:o,placeholder:"Write Mermaid diagram defintion here...",onChange:m=>t(m.target.value),onKeyboardSubmit:()=>{d()}})}),Io(Li,{label:g("mermaid.preview"),panelAction:{action:()=>{d()},label:g("mermaid.button"),icon:Sn},renderSubmitShortcut:()=>Io(kd,{}),children:Io(Cd,{canvasRef:a,loaded:e.loaded,error:n})})]})]})},W3=rB;import*as X3 from"@radix-ui/react-tabs";import{useRef as V3}from"react";import{isMemberOf as iB}from"@excalidraw/common";import{jsx as aB}from"react/jsx-runtime";var K3=e=>{let o=le(),t=V3(null),r=V3(0);return aB(X3.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"&&iB(["text-to-diagram","mermaid"],n)&&o({openDialog:{name:e.dialog,tab:n}})},children:e.children})};K3.displayName="TTDDialogTabs";var Z3=K3;import*as $3 from"@radix-ui/react-tabs";import{jsx as lB}from"react/jsx-runtime";var yg=({children:e,...o})=>lB($3.List,{className:"ttd-dialog-triggers",...o,children:e});yg.displayName="TTDDialogTabTriggers";import*as q3 from"@radix-ui/react-tabs";import{jsx as j3}from"react/jsx-runtime";var Pd=({children:e,tab:o,onSelect:t,...r})=>j3(q3.Trigger,{value:o,asChild:!0,onSelect:t,children:j3("button",{type:"button",className:"ttd-dialog-tab-trigger",...r,children:e})});Pd.displayName="TTDDialogTabTrigger";import*as J3 from"@radix-ui/react-tabs";import{jsx as sB}from"react/jsx-runtime";var Ad=({tab:e,children:o,...t})=>sB(J3.Content,{...t,value:e,children:o});Ad.displayName="TTDDialogTab";import{jsx as ft,jsxs as vr}from"react/jsx-runtime";var vg=3,Pi=1e3,dB=me(null),mB=me(null),Tg=e=>{let o=ge();return o.openDialog?.name!=="ttd"?null:ft(pB,{...e,tab:o.openDialog.tab})},pB=Wo("TTDDialogBase",({tab:e,...o})=>{let t=Re(),r=le(),n=wg(null),[i,a]=ie(mB),[l,s]=Dd(i?.prompt??""),d=l.trim(),m=S=>{s(S.target.value),a(L=>({generatedResponse:L?.generatedResponse??null,prompt:S.target.value}))},[c,p]=Dd(!1),[u,f]=ie(dB),b=async()=>{if(d.length>Pi||d.length<vg||c||u?.rateLimitRemaining===0||"__fallback"in o){d.length<vg&&C(new Error(`Prompt is too short (min ${vg} characters)`)),d.length>Pi&&C(new Error(`Prompt is too long (max ${Pi} characters)`));return}try{p(!0),re("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})),Q3(k)&&Q3(A)&&f({rateLimit:k,rateLimitRemaining:A}),L){C(L);return}if(!S){C(new Error("Generation failed"));return}try{await Md({canvasRef:n,data:y,mermaidToExcalidrawLib:w,setError:C,mermaidDefinition:S}),re("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"),re("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=wg(b);x.current=b;let[w,E]=Dd({loaded:!1,api:import("@excalidraw/mermaid-to-excalidraw")});cB(()=>{(async()=>{await w.api,E(L=>({...L,loaded:!0}))})()},[w.api]);let y=wg({elements:[],files:null}),[v,C]=Dd(null);return ft(Be,{className:"ttd-dialog",onCloseRequest:()=>{t.setOpenDialog(null)},size:1200,title:!1,...o,autofocus:!1,children:vr(Z3,{dialog:"ttd",tab:e,children:["__fallback"in o&&o.__fallback?ft("p",{className:"dialog-mermaid-title",children:g("mermaid.title")}):vr(yg,{children:[ft(Pd,{tab:"text-to-diagram",children:vr("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(Pd,{tab:"mermaid",children:"Mermaid"})]}),ft(Ad,{className:"ttd-dialog-content",tab:"mermaid",children:ft(W3,{mermaidToExcalidrawLib:w})}),!("__fallback"in o)&&vr(Ad,{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."}),vr(Sd,{children:[ft(Li,{label:g("labels.prompt"),panelAction:{action:b,label:"Generate",icon:Sn},onTextSubmitInProgess:c,panelActionDisabled:d.length>Pi||u?.rateLimitRemaining===0,renderTopRight:()=>u?vr("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(kd,{}),renderBottomRight:()=>{if(typeof i?.generatedResponse=="string")return vr("div",{className:"excalidraw-link",style:{marginLeft:"auto",fontSize:14},onClick:()=>{typeof i?.generatedResponse=="string"&&(rl(i.generatedResponse),r({openDialog:{name:"ttd",tab:"mermaid"}}))},children:["View as Mermaid",ft(nr,{icon:Sn})]});let S=d.length/Pi;return S>.8?vr("div",{style:{marginLeft:"auto",fontSize:12,fontFamily:"monospace",color:S>1?"var(--color-danger)":void 0},children:["Length: ",d.length,"/",Pi]}):null},children:ft(Td,{onChange:m,input:l,placeholder:"Describe what you want to see...",onKeyboardSubmit:()=>{x.current()}})}),ft(Li,{label:"Preview",panelAction:{action:()=>{console.info("Panel action clicked"),Ld({app:t,data:y})},label:"Insert",icon:Sn},children:ft(Cd,{canvasRef:n,error:v,loaded:w.loaded})})]})]})]})})});import{round as O5}from"@excalidraw/math";import CF from"clsx";import SF from"lodash.throttle";import{useEffect as z5,useMemo as Fg,useState as kF,memo as MF}from"react";import{STATS_PANELS as Hd}from"@excalidraw/common";import{getCommonBounds as LF}from"@excalidraw/element";import{getUncroppedWidthAndHeight as PF}from"@excalidraw/element";import{isElbowArrow as AF,isImageElement as Og}from"@excalidraw/element";import{frameAndChildrenSelectedTogether as DF}from"@excalidraw/element";import{elementsAreInSameGroup as _F}from"@excalidraw/element";import{degreesToRadians as i5,radiansToDegrees as c5}from"@excalidraw/math";import{getBoundTextElement as a5}from"@excalidraw/element";import{isArrowElement as l5,isElbowArrow as IB}from"@excalidraw/element";import{updateBindings as s5}from"@excalidraw/element";import xB from"clsx";import{useEffect as r5,useRef as Rd,useState as EB}from"react";import{EVENT as _i,KEYS as yB,cloneJSON as Ig}from"@excalidraw/common";import{deepCopyElement as wB}from"@excalidraw/element";import{CaptureUpdateAction as n5}from"@excalidraw/element";import{pointFrom as Tr,pointRotateRads as _d}from"@excalidraw/math";import{getBoundTextElement as uB}from"@excalidraw/element";import{isFrameLikeElement as t5}from"@excalidraw/element";import{getSelectedGroupIds as hB,getElementsInGroup as gB,isInGroup as fB}from"@excalidraw/element";import{getFrameChildren as bB}from"@excalidraw/element";import{updateBindings as e5}from"@excalidraw/element";var o5=.01,nl=10,St=(e,o)=>!(o==="angle"&&t5(e)),Me=(e,o)=>{let t=e+o/2;return t-t%o},Ai=(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 rn=(e,o,t,r,n,i=!0)=>{let a=r.getNonDeletedElementsMap(),l=a.get(t.id);if(!l)return;let[s,d]=[t.x+t.width/2,t.y+t.height/2],[m,c]=_d(Tr(t.x,t.y),Tr(s,d),t.angle),p=e-m,u=o-c,[f,b]=_d(Tr(e,o),Tr(s+p,d+u),-t.angle);r.mutateElement(l,{x:f,y:b},{informMutation:i,isDragging:!1}),e5(l,r);let x=uB(t,n);if(x){let w=a.get(x.id);w&&r.mutateElement(w,{x:x.x+p,y:x.y+u},{informMutation:i,isDragging:!1})}if(t5(t)){let w=bB(n,t.id);w.forEach(E=>{let y=a.get(E.id);if(!y)return;let[v,C]=[E.x+E.width/2,E.y+E.height/2],[S,L]=_d(Tr(E.x,E.y),Tr(v,C),E.angle),k=Math.round(S+p),A=Math.round(L+u),[P,N]=_d(Tr(k,A),Tr(v+p,C+u),-E.angle);r.mutateElement(y,{x:P,y:N},{informMutation:i,isDragging:!1}),e5(y,r,{simultaneouslyUpdated:w})})}},Di=(e,o)=>{let r=hB(o).map(n=>gB(e,n).reduce((i,a)=>(i[a.id]=!0,i),{}));return e.filter(n=>!fB(n)).forEach(n=>{r.push({[n.id]:!0})}),r};import{jsx as Cg,jsxs as TB}from"react/jsx-runtime";var vB=({label:e,icon:o,dragInputCallback:t,value:r,elements:n,editable:i=!0,shouldKeepAspectRatio:a,property:l,scene:s,appState:d,sensitivity:m=1,dragFinishedCallback:c})=>{let p=Re(),u=le(),f=Rd(null),b=Rd(null),[x,w]=EB(r.toString()),E=Rd(null);E.current||(E.current={originalAppState:Ig(d),originalElements:n,lastUpdatedValue:x,updatePending:!1}),r5(()=>{let C=r.toString();w(C),E.current.lastUpdatedValue=C},[r]);let y=(C,S,L)=>{if(!E.current.updatePending)return!1;E.current.updatePending=!1;let k=Number(C);if(isNaN(k)){w(r.toString());return}let A=Number(k.toFixed(2)),P=Number(r);(isNaN(P)||Math.abs(A-P)>=o5)&&(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:n5.IMMEDIATELY}))},v=Rd({});return v.current.handleInputValue=y,r5(()=>{let C=f.current,S=v.current;return()=>{let L=C?.value;L&&S.handleInputValue?.(L,E.current.originalElements,E.current.originalAppState),window.removeEventListener(_i.POINTER_MOVE,S.onPointerMove,!1),window.removeEventListener(_i.POINTER_UP,S.onPointerUp,!1)}},[i]),i?TB("div",{className:xB("drag-input-container",!i&&"disabled"),"data-testid":e,children:[Cg("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,wB(R)),_),new Map),A=n.map(_=>k.get(_.id)),P=Ig(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(_i.POINTER_MOVE,U,!1),p.syncActionResult({captureUpdate:n5.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(_i.POINTER_UP,J,!1)};v.current.onPointerMove=U,v.current.onPointerUp=J,window.addEventListener(_i.POINTER_MOVE,U,!1),window.addEventListener(_i.POINTER_UP,J,!1)}},onPointerEnter:()=>{b.current&&(b.current.style.cursor="ew-resize")},children:o?Cg(nr,{icon:o}):e}),Cg("input",{className:"drag-input",autoComplete:"off",spellCheck:"false",onKeyDown:C=>{if(i){let S=C.target;S instanceof HTMLInputElement&&C.key===yB.ENTER&&(y(S.value,n,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=n,E.current.originalAppState=Ig(d)},onBlur:C=>{x?i&&y(C.target.value,E.current.originalElements,E.current.originalAppState):w(r.toString())},disabled:!i})]}):null},Qe=vB;import{jsx as MB}from"react/jsx-runtime";var CB=15,SB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,scene:n})=>{let i=n.getNonDeletedElementsMap(),a=o[0];if(a&&!IB(a)){let l=i.get(a.id);if(!l)return;if(r!==void 0){let u=i5(r);n.mutateElement(l,{angle:u}),s5(l,n);let f=a5(l,i);f&&!l5(l)&&n.mutateElement(f,{angle:u});return}let s=Math.round(c5(a.angle)*100)/100,d=Math.round(e),m=(s+d)%360;t&&(m=Me(m,CB)),m=m<0?m+360:m;let c=i5(m);n.mutateElement(l,{angle:c}),s5(l,n);let p=a5(l,i);p&&!l5(l)&&n.mutateElement(p,{angle:c})}},kB=({element:e,scene:o,appState:t,property:r})=>MB(Qe,{label:"A",icon:Jl,value:Math.round(c5(e.angle)%360*100)/100,elements:[e],dragInputCallback:SB,editable:St(e,"angle"),scene:o,appState:t,property:r}),d5=kB;import{jsx as PB}from"react/jsx-runtime";var m5=5,LB=({property:e,scene:o,appState:t,setAppState:r})=>PB(Qe,{label:"Grid step",sensitivity:8,elements:[],dragInputCallback:({nextValue:n,instantChange:i,shouldChangeByStepSize:a,setInputValue:l})=>{r(s=>{let d;return n?d=n:i&&(d=a?Me(s.gridStep+m5*Math.sign(i),m5):s.gridStep+i),d?(d=Kf(d),l(d),{gridStep:d}):(l(s.gridStep),null)})},scene:o,value:t.gridStep,property:e,appState:t}),p5=LB;import{clamp as Nd,round as Sg}from"@excalidraw/math";import{MIN_WIDTH_OR_HEIGHT as Bd}from"@excalidraw/common";import{MINIMAL_CROP_SIZE as u5,getUncroppedWidthAndHeight as f5}from"@excalidraw/element";import{resizeSingleElement as h5}from"@excalidraw/element";import{isImageElement as b5}from"@excalidraw/element";import{isFrameLikeElement as kg}from"@excalidraw/element";import{getElementsInResizingFrame as Mg}from"@excalidraw/element";import{replaceAllElementsInFrame as x5}from"@excalidraw/element";import{jsx as NB}from"react/jsx-runtime";var g5=10,AB=e=>e.type==="image",DB=({accumulatedChange:e,originalElements:o,originalElementsMap:t,shouldKeepAspectRatio:r,shouldChangeByStepSize:n,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=r||AB(u),x=u.width/u.height;if(l.croppingElementId===u.id){let w=p.get(u.id);if(!w||!b5(w)||!w.crop)return;let E=w.crop,y={...E},v=w.scale[0]===-1,C=w.scale[1]===-1,{width:S,height:L}=f5(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=u5*k,U=u5*A;if(i!==void 0){if(a==="width"){let Z=i*k,W=Nd(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=Nd(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=Nd(E.width+J,O,P),V=Nd(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,Bd),E=Math.max(a==="height"?i:b?i/x:u.height,Bd);if(h5(w,E,f,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),kg(f)){let y=Mg(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap()),v=x5(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"&&(n?y=Me(y,g5):y=Math.round(y));let v=Math.max(0,u.height+E);if(a==="height"&&(n?v=Me(v,g5):v=Math.round(v)),b&&(a==="width"?v=Math.round(y/x*100)/100:y=Math.round(v*x*100)/100),v=Math.max(Bd,v),y=Math.max(Bd,y),h5(y,v,f,u,t,d,a==="width"?"e":"s",{shouldMaintainAspectRatio:b}),kg(f)){let C=Mg(d.getElementsIncludingDeleted(),f,l,d.getNonDeletedElementsMap());c({elementsToHighlight:C})}}}},_B=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&kg(a)){let l=Mg(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=x5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},RB=({property:e,element:o,scene:t,appState:r})=>{let n=Sg(e==="width"?o.width:o.height,2);if(r.croppingElementId&&r.croppingElementId===o.id&&b5(o)&&o.crop){let{width:i,height:a}=f5(o);if(e==="width"){let l=i/o.crop.naturalWidth;n=Sg(o.crop.width*l,2)}if(e==="height"){let l=a/o.crop.naturalHeight;n=Sg(o.crop.height*l,2)}}return NB(Qe,{label:e==="width"?"W":"H",elements:[o],dragInputCallback:DB,value:n,editable:St(o,e),scene:t,appState:r,property:e,dragFinishedCallback:_B})},Lg=RB;import{getBoundTextElement as BB,redrawTextBoundingBox as FB}from"@excalidraw/element";import{hasBoundTextElement as OB,isTextElement as y5}from"@excalidraw/element";import{jsx as UB}from"react/jsx-runtime";var E5=4,zB=4,HB=({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||!y5(l))return;let s;if(r!==void 0)s=Math.max(Math.round(r),E5);else if(a.type==="text"){let d=Math.round(a.fontSize),m=Math.round(e);s=Math.max(d+m,E5),t&&(s=Me(s,zB))}s&&(n.mutateElement(l,{fontSize:s}),FB(l,n.getContainerElement(l),n))}},GB=({element:e,scene:o,appState:t,property:r})=>{let n=y5(e)?e:OB(e)?BB(e,o.getNonDeletedElementsMap()):null;return n?UB(Qe,{label:"F",value:Math.round(n.fontSize*10)/10,elements:[n],dragInputCallback:HB,icon:Or,appState:t,scene:o,property:r}):null},w5=GB;import{degreesToRadians as v5,radiansToDegrees as C5}from"@excalidraw/math";import{getBoundTextElement as T5}from"@excalidraw/element";import{isArrowElement as I5}from"@excalidraw/element";import{isInGroup as Pg}from"@excalidraw/element";import{jsx as XB}from"react/jsx-runtime";var YB=15,WB=({accumulatedChange:e,originalElements:o,shouldChangeByStepSize:t,nextValue:r,property:n,scene:i})=>{let a=i.getNonDeletedElementsMap(),l=o.map(d=>a.get(d.id)).filter(d=>d&&!Pg(d)&&St(d,n)),s=o.filter(d=>!Pg(d)&&St(d,n));if(r!==void 0){let d=v5(r);for(let m of l){if(!m)continue;i.mutateElement(m,{angle:d});let c=T5(m,a);c&&!I5(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(C5(c.angle)*100)/100,u=Math.round(e),f=(p+u)%360;t&&(f=Me(f,YB)),f=f<0?f+360:f;let b=v5(f);i.mutateElement(m,{angle:b});let x=T5(m,a);x&&!I5(m)&&i.mutateElement(x,{angle:b})}i.triggerUpdate()},VB=({elements:e,scene:o,appState:t,property:r})=>{let n=e.filter(s=>!Pg(s)&&St(s,"angle")),i=n.map(s=>Math.round(C5(s.angle)%360*100)/100),a=new Set(i).size===1?i[0]:"Mixed",l=n.some(s=>St(s,"angle"));return XB(Qe,{label:"A",icon:Jl,value:a,elements:e,dragInputCallback:WB,editable:l,appState:t,scene:o,property:r})},S5=VB;import{pointFrom as k5}from"@excalidraw/math";import{useMemo as KB}from"react";import{MIN_WIDTH_OR_HEIGHT as Ir}from"@excalidraw/common";import{getElementsInResizingFrame as Ag,isFrameLikeElement as Dg,replaceAllElementsInFrame as P5,updateBoundElements as ZB}from"@excalidraw/element";import{rescalePointsInElement as $B,resizeSingleElement as M5}from"@excalidraw/element";import{getBoundTextElement as jB,handleBindTextResize as qB}from"@excalidraw/element";import{isTextElement as A5}from"@excalidraw/element";import{getCommonBounds as Fd}from"@excalidraw/element";import{jsx as rF}from"react/jsx-runtime";var Ri=10,JB=(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,d=o+i*t;return{width:a,height:l,x:s,y:d,...$B(r,a,l,!1),...A5(r)?{fontSize:r.fontSize*t}:{}}},QB=(e,o,t,r,n,i,a,l)=>{let s=l.getNonDeletedElementsMap(),d=JB(e,o,r,i);l.mutateElement(n,d);let m=jB(i,a);if(m){let c=m.fontSize*r;ZB(n,l,{newSize:{width:d.width,height:d.height}});let p=s.get(m.id);p&&A5(p)&&(l.mutateElement(p,{fontSize:c}),qB(n,l,t==="width"?"e":"s",!0))}},L5=(e,o,t,r,n,i,a,l,s,d)=>{i==="width"?o=Math.round(e/r*100)/100:e=Math.round(o*r*100)/100;let m=o/t;for(let c=0;c<l.length;c++){let p=l[c],u=a[c];QB(n[0],n[1],i,m,u,p,s,d)}},eF=({accumulatedChange:e,originalElements:o,originalElementsMap:t,originalAppState:r,shouldChangeByStepSize:n,nextValue:i,scene:a,property:l,setAppState:s,app:d})=>{let m=a.getNonDeletedElementsMap(),c=Di(o,r);if(i!==void 0){for(let b of c){let x=Ai(b,m,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=Fd(E),L=C-y,k=S-v,A=L/k,P=Math.max(Ir,l==="width"?Math.max(0,i):L),N=Math.max(Ir,l==="height"?Math.max(0,i):k);L5(P,N,k,A,k5(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"&&(n?v=Me(v,Ri):v=Math.round(v));let C=l==="height"?Math.max(0,i):E.height;if(l==="height"&&(n?C=Me(C,Ri):C=Math.round(C)),v=Math.max(Ir,v),C=Math.max(Ir,C),M5(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Dg(E)){let S=Ag(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap()),L=P5(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=Ai(b,m,t);if(x.length>1){let w=x.map(O=>O.latest),E=x.map(O=>O.original),[y,v,C,S]=Fd(E),L=C-y,k=S-v,A=L/k,P=Math.max(0,L+p);l==="width"&&(n?P=Me(P,Ri):P=Math.round(P));let N=Math.max(0,k+u);l==="height"&&(n?N=Me(N,Ri):N=Math.round(N)),P=Math.max(Ir,P),N=Math.max(Ir,N),L5(P,N,k,A,k5(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"&&(n?v=Me(v,Ri):v=Math.round(v));let C=Math.max(0,y.height+u);if(l==="height"&&(n?C=Me(C,Ri):C=Math.round(C)),v=Math.max(Ir,v),C=Math.max(Ir,C),M5(v,C,E,y,t,a,l==="width"?"e":"s",{shouldInformMutation:!1}),Dg(E)){let S=Ag(a.getElementsIncludingDeleted(),E,r,a.getNonDeletedElementsMap());f.push(...S)}}}}s({elementsToHighlight:f}),a.triggerUpdate()},tF=({setAppState:e,app:o,originalElements:t,originalAppState:r})=>{let n=o.scene.getNonDeletedElementsMap(),i=t?.[0],a=i&&n.get(i.id);if(a&&Dg(a)){let l=Ag(o.scene.getElementsIncludingDeleted(),a,r,o.scene.getNonDeletedElementsMap()),s=P5(o.scene.getElementsIncludingDeleted(),l,a,o);o.scene.replaceAllElements(s),e({elementsToHighlight:null})}},oF=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=KB(()=>r.map(d=>{let m=Ai(d,t);if(m.length>1){let[p,u,f,b]=Fd(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,r,e]),l=new Set(a).size===1?Math.round(a[0]*100)/100:"Mixed",s=a.length>0;return rF(Qe,{label:e==="width"?"W":"H",elements:o,dragInputCallback:eF,value:l,editable:s,appState:i,property:e,scene:n,dragFinishedCallback:tF})},_g=oF;import{getBoundTextElement as nF,redrawTextBoundingBox as D5}from"@excalidraw/element";import{hasBoundTextElement as iF,isTextElement as aF}from"@excalidraw/element";import{isInGroup as lF}from"@excalidraw/element";import{jsx as pF}from"react/jsx-runtime";var _5=4,sF=4,cF=(e,o)=>e.reduce((t,r)=>{if(!r||lF(r))return t;if(aF(r))return t.push(r),t;if(iF(r)){let n=nF(r,o);if(n)return t.push(n),t}return t},[]),dF=({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),_5);for(let s of a)n.mutateElement(s,{fontSize:l}),D5(s,n.getContainerElement(s),n);n.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,_5);t&&(f=Me(f,sF)),n.mutateElement(m,{fontSize:f}),D5(m,n.getContainerElement(m),n)}n.triggerUpdate()}},mF=({elements:e,scene:o,appState:t,property:r,elementsMap:n})=>{let i=cF(e,n);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 pF(Qe,{label:"F",icon:Or,elements:i,dragInputCallback:dF,value:l,editable:s,scene:o,property:r,appState:t})},R5=mF;import{pointFrom as Cr,pointRotateRads as Od}from"@excalidraw/math";import{useMemo as uF}from"react";import{isTextElement as hF}from"@excalidraw/element";import{getCommonBounds as Rg}from"@excalidraw/element";import{jsx as EF}from"react/jsx-runtime";var gF=(e,o,t,r,n,i)=>{for(let a=0;a<r.length;a++){let l=r[a],[s,d]=[l.x+l.width/2,l.y+l.height/2],[m,c]=Od(Cr(l.x,l.y),Cr(s,d),l.angle),p=e==="x"?Math.round(m+o):m,u=e==="y"?Math.round(c+t):c;rn(p,u,l,i,n,!1)}},fF=(e,o,t,r,n)=>{let i=n.getNonDeletedElementsMap(),[a,l,,]=Rg(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&&(!hF(p)||!p.containerId)){let[u,f]=[p.x+p.width/2,p.y+p.height/2],[b,x]=Od(Cr(p.x,p.y),Cr(u,f),p.angle);rn(b+s,x+d,c,n,r,!1)}}},bF=({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 Di(o,l)){let u=Ai(p,s,t);if(u.length>1){let[f,b,,]=Rg(u.map(E=>E.latest));fF(i==="x"?n:f,i==="y"?n:b,u.map(E=>E.original),t,a)}else{let f=u[0]?.original,b=u[0]?.latest;if(f&&b&&St(b,i)){let[x,w]=[f.x+f.width/2,f.y+f.height/2],[E,y]=Od(Cr(f.x,f.y),Cr(x,w),f.angle);rn(i==="x"?n:E,i==="y"?n:y,f,a,t,!1)}}}a.triggerUpdate();return}let d=r?Me(e,nl):e;gF(i,i==="x"?d:0,i==="y"?d:0,o,t,a),a.triggerUpdate()},xF=({property:e,elements:o,elementsMap:t,atomicUnits:r,scene:n,appState:i})=>{let a=uF(()=>r.map(s=>{let d=Object.keys(s).map(b=>t.get(b)).filter(b=>b!==void 0);if(d.length>1){let[b,x]=Rg(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]=Od(Cr(m.x,m.y),Cr(c,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 EF(Qe,{label:e==="x"?"X":"Y",elements:o,dragInputCallback:bF,value:l,property:e,scene:n,appState:i})},Ng=xF;import{clamp as il,pointFrom as zd,pointRotateRads as B5,round as N5}from"@excalidraw/math";import{getFlipAdjustedCropPosition as yF,getUncroppedWidthAndHeight as wF}from"@excalidraw/element";import{isImageElement as F5}from"@excalidraw/element";import{jsx as IF}from"react/jsx-runtime";var vF=({accumulatedChange:e,instantChange:o,originalElements:t,originalElementsMap:r,shouldChangeByStepSize:n,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]=B5(zd(m.x,m.y),zd(c,p),m.angle);if(s.croppingElementId===m.id){let y=d.get(m.id);if(!y||!F5(y)||!y.crop)return;let v=y.crop,C=v,S=y.scale[0]===-1,L=y.scale[1]===-1,{width:k,height:A}=wF(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){rn(a==="x"?i:u,a==="y"?i:f,m,l,r);return}let b=a==="x"?e:0,x=a==="y"?e:0,w=a==="x"?Math.round(n?Me(m.x+b,nl):u+b):u,E=a==="y"?Math.round(n?Me(m.y+x,nl):f+x):f;rn(w,E,m,l,r)},TF=({property:e,element:o,elementsMap:t,scene:r,appState:n})=>{let[i,a]=B5(zd(o.x,o.y),zd(o.x+o.width/2,o.y+o.height/2),o.angle),l=N5(e==="x"?i:a,2);if(n.croppingElementId===o.id&&F5(o)&&o.crop){let s=yF(o);s&&(l=N5(e==="x"?s.x:s.y,2))}return IF(Qe,{label:e==="x"?"X":"Y",elements:[o],dragInputCallback:vF,scene:r,value:l,property:e,appState:n})},Bg=TF;import{Fragment as zg,jsx as q,jsxs as kt}from"react/jsx-runtime";var RF=50,al=e=>{let o=go(),t=e.app.scene.getSceneNonce()||1,r=e.app.scene.getSelectedElements({selectedElementIds:o.selectedElementIds,includeBoundTextElement:!1}),n=hr(e.app);return q(NF,{...e,appState:o,sceneNonce:t,selectedElements:r,gridModeEnabled:n})},Ie=({children:e,columns:o=1,heading:t,style:r,...n})=>q("div",{className:CF("exc-stats__row",{"exc-stats__row--heading":t}),style:{gridTemplateColumns:`repeat(${o}, 1fr)`,...r},...n,children:e});Ie.displayName="StatsRow";var Gd=({children:e,order:o,style:t,...r})=>q("div",{className:"exc-stats__rows",style:{order:o,...t},...r,children:e});Gd.displayName="StatsRows";al.StatsRow=Ie;al.StatsRows=Gd;var NF=MF(({app:e,onClose:o,renderCustomStats:t,selectedElements:r,appState:n,sceneNonce:i,gridModeEnabled:a})=>{let l=e.scene,s=l.getNonDeletedElements(),d=l.getNonDeletedElementsMap(),m=le(),c=r.length===1?r[0]:null,p=r.length>1?r:null,u=n.croppingElementId&&Og(c),f=u?PF(c):null,[b,x]=kF({width:0,height:0}),w=Fg(()=>SF(v=>{let C=LF(v);x({width:Math.round(C[2])-Math.round(C[0]),height:Math.round(C[3])-Math.round(C[1])})},RF),[]);z5(()=>{w(s)},[i,s,w]),z5(()=>()=>w.cancel(),[w]);let E=Fg(()=>Di(r,n),[r,n]),y=Fg(()=>DF(r),[r]);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:Bt})]}),kt(pa,{label:q("h3",{children:g("stats.generalStats")}),open:!!(n.stats.panels&Hd.generalStats),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Hd.generalStats}})),children:[kt(Gd,{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(zg,{children:[q(Ie,{heading:!0,children:"Canvas"}),q(Ie,{children:q(p5,{property:"gridStep",scene:l,appState:n,setAppState:m})})]})]}),t?.(s,n)]}),!y&&r.length>0&&q("div",{id:"elementStats",style:{marginTop:12},children:q(pa,{label:q("h3",{children:g("stats.elementProperties")}),open:!!(n.stats.panels&Hd.elementProperties),openTrigger:()=>m(v=>({stats:{open:!0,panels:v.stats.panels^Hd.elementProperties}})),children:kt(Gd,{children:[c&&kt(zg,{children:[u&&q(Ie,{heading:!0,children:g("labels.unCroppedDimension")}),n.croppingElementId&&Og(c)&&f&&kt(Ie,{columns:2,children:[q("div",{children:g("stats.width")}),q("div",{children:O5(f.width,2)})]}),n.croppingElementId&&Og(c)&&f&&kt(Ie,{columns:2,children:[q("div",{children:g("stats.height")}),q("div",{children:O5(f.height,2)})]}),q(Ie,{heading:!0,"data-testid":"stats-element-type",style:{margin:"0.3125rem 0"},children:n.croppingElementId?g("labels.imageCropping"):g(`element.${c.type}`)}),q(Ie,{children:q(Bg,{element:c,property:"x",elementsMap:d,scene:l,appState:n})}),q(Ie,{children:q(Bg,{element:c,property:"y",elementsMap:d,scene:l,appState:n})}),q(Ie,{children:q(Lg,{property:"width",element:c,scene:l,appState:n})}),q(Ie,{children:q(Lg,{property:"height",element:c,scene:l,appState:n})}),!AF(c)&&q(Ie,{children:q(d5,{property:"angle",element:c,scene:l,appState:n})}),q(Ie,{children:q(w5,{property:"fontSize",element:c,scene:l,appState:n})})]}),p&&kt(zg,{children:[_F(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:r.length})]}),q(Ie,{children:q(Ng,{property:"x",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(Ng,{property:"y",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(_g,{property:"width",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(_g,{property:"height",elements:p,elementsMap:d,atomicUnits:E,scene:l,appState:n})}),q(Ie,{children:q(S5,{property:"angle",elements:p,scene:l,appState:n})}),q(Ie,{children:q(R5,{property:"fontSize",elements:p,scene:l,appState:n,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 BF,useEffect as H5,useState as G5}from"react";import{normalizeLink as FF,KEYS as Hg}from"@excalidraw/common";import{defaultGetElementLinkFromSelection as OF,getLinkIdAndTypeFromSelection as zF}from"@excalidraw/element";import{jsx as Ni,jsxs as Ud}from"react/jsx-runtime";var HF=({sourceElementId:e,onClose:o,appState:t,scene:r,generateLinkForSelection:n=OF})=>{let i=r.getNonDeletedElementsMap(),a=i.get(e)?.link??null,[l,s]=G5(a),[d,m]=G5(!1);H5(()=>{let p=j(i,t),u=a;if(p.length>0&&n){let f=zF(p,t);f&&(u=FF(n(f.id,f.type)))}s(u)},[i,t,t.selectedElementIds,a,n]);let c=BF(()=>{if(l&&l!==i.get(e)?.link){let p=i.get(e);p&&r.mutateElement(p,{link:l})}if(!l&&d&&e){let p=i.get(e);p&&r.mutateElement(p,{link:null})}o?.()},[e,l,i,d,r,o]);return H5(()=>{let p=u=>{t.openDialog?.name==="elementLinkSelector"&&u.key===Hg.ENTER&&c(),t.openDialog?.name==="elementLinkSelector"&&u.key===Hg.ESCAPE&&o?.()};return window.addEventListener("keydown",p),()=>{window.removeEventListener("keydown",p)}},[t,o,c]),Ud("div",{className:"ElementLinkDialog",children:[Ud("div",{className:"ElementLinkDialog__header",children:[Ni("h2",{children:g("elementLink.title")}),Ni("p",{children:g("elementLink.desc")})]}),Ud("div",{className:"ElementLinkDialog__input",children:[Ni(hi,{value:l??"",onChange:p=>{d||m(!0),s(p)},onKeyDown:p=>{p.key===Hg.ENTER&&c()},className:"ElementLinkDialog__input-field",selectOnRender:!0}),a&&l&&Ni(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:Mt})]}),Ud("div",{className:"ElementLinkDialog__actions",children:[Ni(No,{label:g("buttons.cancel"),onClick:()=>{o?.()},style:{marginRight:10}}),Ni(No,{label:g("buttons.confirm"),onClick:c,actionType:"primary"})]})]})},U5=HF;import GF,{useState as UF}from"react";import{Fragment as YF,jsx as Gg}from"react/jsx-runtime";var Y5=({children:e,onClose:o})=>{let[t,r]=UF(!!e),{container:n}=He(),i=GF.useCallback(()=>{r(!1),o&&o(),n?.focus()},[o,n]);return Gg(YF,{children:t&&Gg(Be,{size:"small",onCloseRequest:i,title:g("errorDialog.title"),children:Gg("div",{style:{whiteSpace:"pre-wrap"},children:e})})})};import WF from"react";import{isDarwin as W5,isFirefox as V5,isWindows as VF}from"@excalidraw/common";import{KEYS as Ae,getShortcutKey as X}from"@excalidraw/common";import{Fragment as K5,jsx as F,jsxs as Rt}from"react/jsx-runtime";var XF=()=>Rt("div",{className:"HelpDialog__header",children:[Rt("a",{className:"HelpDialog__btn",href:"https://docs.excalidraw.com",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:Tm}),g("helpDialog.documentation")]}),Rt("a",{className:"HelpDialog__btn",href:"https://plus.excalidraw.com/blog",target:"_blank",rel:"noopener",children:[F("div",{className:"HelpDialog__link-icon",children:Tm}),g("helpDialog.blog")]}),Rt("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")]}),Rt("a",{className:"HelpDialog__btn",href:"https://youtube.com/@excalidraw",target:"_blank",rel:"noopener noreferrer",children:[F("div",{className:"HelpDialog__link-icon",children:rb}),"YouTube"]})]}),KF=e=>Rt(K5,{children:[F("h3",{children:e.title}),F("div",{className:"HelpDialog__islands-container",children:e.children})]}),Ug=e=>Rt("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*ZF(e,o){let t=!0;for(let r of e)t||(yield o),t=!1,yield r}var $F=e=>e.replace(/\b[a-z]\b/,o=>o.toUpperCase()),G=({label:e,shortcuts:o,isOr:t=!0})=>{let r=o.map(n=>(n.endsWith("++")?[...n.slice(0,-2).split("+"),"+"]:n.split("+")).map(a=>F(jF,{children:$F(a)},a)));return Rt("div",{className:"HelpDialog__shortcut",children:[F("div",{children:e}),F("div",{className:"HelpDialog__key-container",children:[...ZF(r,t?g("helpDialog.or"):null)]})]})},jF=e=>F("kbd",{className:"HelpDialog__key",...e}),X5=({onClose:e})=>{let o=WF.useCallback(()=>{e&&e()},[e]);return F(K5,{children:Rt(Be,{onCloseRequest:o,title:g("helpDialog.title"),className:"HelpDialog",children:[F(XF,{}),Rt(KF,{title:g("helpDialog.shortcuts"),children:[Rt(Ug,{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})]}),Rt(Ug,{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:V5?[Ne("commandPalette")]:[Ne("commandPalette"),Ne("commandPalette",1)]})]}),Rt(Ug,{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")}`)]}),(Vn||V5)&&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:[W5?X("CtrlOrCmd+Alt+["):X("CtrlOrCmd+Shift+[")]}),F(G,{label:g("labels.bringToFront"),shortcuts:[W5?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:VF?[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 j5,useRef as oO,useState as Sr}from"react";import{DEFAULT_EXPORT_PADDING as rO,EXPORT_IMAGE_TYPES as Yg,isFirefox as nO,EXPORT_SCALES as iO,cloneJSON as q5}from"@excalidraw/common";import{useCallback as qF,useRef as JF,useState as QF}from"react";var eO=2e3,Z5=()=>{let[e,o]=QF(null),t=JF(0),r=()=>{clearTimeout(t.current),o("success"),t.current=window.setTimeout(()=>{o(null)},eO)},n=qF(()=>{o(null)},[]);return{copyStatus:e,resetCopyStatus:n,onCopy:r}};import tO from"clsx";import{jsx as $5}from"react/jsx-runtime";var ll=({title:e,name:o,checked:t,onChange:r,disabled:n=!1})=>$5("div",{className:tO("Switch",{toggled:t,disabled:n}),children:$5("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 Ce,jsxs as kr}from"react/jsx-runtime";var aO="filter"in document.createElement("canvas").getContext("2d"),lO=()=>kr("div",{children:[Ce("h3",{children:g("canvasError.cannotShowPreview")}),Ce("p",{children:Ce("span",{children:g("canvasError.canvasTooBig")})}),kr("em",{children:["(",g("canvasError.canvasTooBigTip"),")"]})]}),sO=({appStateSnapshot:e,elementsSnapshot:o,files:t,actionManager:r,onExportImage:n,name:i})=>{let a=Ee(o,e),[l,s]=Sr(i),[d,m]=Sr(a),[c,p]=Sr(e.exportBackground),[u,f]=Sr(e.exportWithDarkMode),[b,x]=Sr(e.exportEmbedScene),[w,E]=Sr(e.exportScale),y=oO(null),[v,C]=Sr(null),{onCopy:S,copyStatus:L,resetCopyStatus:k}=Z5();j5(()=>{k()},[l,c,u,w,b,k]);let{exportedElements:A,exportingFrame:P}=Vr(o,e,d);return j5(()=>{let N=y.current;if(!N)return;let O=N.offsetWidth,U=N.offsetHeight;O&&cr({elements:A,appState:{...e,name:l,exportBackground:c,exportWithDarkMode:u,exportScale:w,exportEmbedScene:b},files:t,exportPadding:rO,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]),kr("div",{className:"ImageExportModal",children:[Ce("h3",{children:g("imageExportDialog.header")}),kr("div",{className:"ImageExportModal__preview",children:[Ce("div",{className:"ImageExportModal__preview__canvas",ref:y,children:v&&Ce(lO,{})}),Ce("div",{className:"ImageExportModal__preview__filename",children:!gn&&Ce("input",{type:"text",className:"TextInput",value:l,style:{width:"30ch"},onChange:N=>{s(N.target.value),r.executeAction(Up,"ui",N.target.value)}})})]}),kr("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),r.executeAction(Yp,"ui",N)}})}),aO&&Ce(sl,{label:g("imageExportDialog.label.darkMode"),name:"exportDarkModeSwitch",children:Ce(ll,{name:"exportDarkModeSwitch",checked:u,onChange:N=>{f(N),r.executeAction(Kx,"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),r.executeAction(Xs,"ui",N)}})}),Ce(sl,{label:g("imageExportDialog.label.scale"),name:"exportScale",children:Ce(gd,{name:"exportScale",value:w,onChange:N=>{E(N),r.executeAction(Xx,"ui",N)},choices:iO.map(N=>({value:N,label:`${N}\xD7`}))})}),kr("div",{className:"ImageExportModal__settings__buttons",children:[Ce(yr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToPng"),onClick:()=>n(Yg.png,A,{exportingFrame:P}),icon:zm,children:g("imageExportDialog.button.exportToPng")}),Ce(yr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.exportToSvg"),onClick:()=>n(Yg.svg,A,{exportingFrame:P}),icon:zm,children:g("imageExportDialog.button.exportToSvg")}),(Vn||nO)&&Ce(yr,{className:"ImageExportModal__settings__buttons__button",label:g("imageExportDialog.title.copyPngToClipboard"),status:L,onClick:async()=>{await n(Yg.clipboard,A,{exportingFrame:P}),S()},icon:Cn,children:g("imageExportDialog.button.copyPngToClipboard")})]})]})]})},sl=({label:e,children:o,tooltip:t,name:r})=>kr("div",{className:"ImageExportModal__settings__setting",title:e,children:[kr("label",{htmlFor:r,className:"ImageExportModal__settings__setting__label",children:[e,t&&Ce(Pt,{label:t,long:!0,children:B0})]}),Ce("div",{className:"ImageExportModal__settings__setting__content",children:o})]}),J5=({elements:e,appState:o,files:t,actionManager:r,onExportImage:n,onCloseRequest:i,name:a})=>{let[{appStateSnapshot:l,elementsSnapshot:s}]=Sr(()=>({appStateSnapshot:q5(o),elementsSnapshot:q5(e)}));return Ce(Be,{onCloseRequest:i,size:"wide",title:!1,children:Ce(sO,{elementsSnapshot:s,appStateSnapshot:l,files:t,actionManager:r,onExportImage:n,name:a})})};import dO from"react";import{getFrame as mO}from"@excalidraw/common";import Wg from"open-color";import{jsx as cO}from"react/jsx-runtime";var Vg=({children:e,color:o})=>cO("div",{className:"Card",style:{"--card-color":o==="primary"?"var(--color-primary)":Wg[o][7],"--card-color-darker":o==="primary"?"var(--color-primary-darker)":Wg[o][8],"--card-color-darkest":o==="primary"?"var(--color-primary-darkest)":Wg[o][9]},children:e});import{Fragment as uO,jsx as so,jsxs as Yd}from"react/jsx-runtime";var pO=({elements:e,appState:o,setAppState:t,files:r,actionManager:n,exportOpts:i,canvas:a,onCloseRequest:l})=>{let{onExportToBackend:s}=i;return so("div",{className:"ExportDialog ExportDialog--json",children:Yd("div",{className:"ExportDialog-cards",children:[i.saveFileToDisk&&Yd(Vg,{color:"lime",children:[so("div",{className:"Card-icon",children:W1}),so("h2",{children:g("exportDialog.disk_title")}),Yd("div",{className:"Card-details",children:[g("exportDialog.disk_details"),!gn&&n.renderAction("changeProjectName")]}),so(K,{className:"Card-button",type:"button",title:g("exportDialog.disk_button"),"aria-label":g("exportDialog.disk_button"),showAriaLabel:!0,onClick:()=>{n.executeAction(Ta,"ui")}})]}),s&&Yd(Vg,{color:"pink",children:[so("div",{className:"Card-icon",children:qi}),so("h2",{children:g("exportDialog.link_title")}),so("div",{className:"Card-details",children:g("exportDialog.link_details")}),so(K,{className:"Card-button",type:"button",title:g("exportDialog.link_button"),"aria-label":g("exportDialog.link_button"),showAriaLabel:!0,onClick:async()=>{try{re("export","link",`ui (${mO()})`),await s(e,o,r),l()}catch(d){t({errorMessage:d.message})}}})]}),i.renderCustomUI&&i.renderCustomUI(e,o,r,a)]})})},Q5=({elements:e,appState:o,files:t,actionManager:r,exportOpts:n,canvas:i,setAppState:a})=>{let l=dO.useCallback(()=>{a({openDialog:null})},[a]);return so(uO,{children:o.openDialog?.name==="jsonExport"&&so(Be,{onCloseRequest:l,title:g("buttons.export"),children:so(pO,{elements:e,appState:o,setAppState:a,files:t,actionManager:r,onCloseRequest:l,exportOpts:n,canvas:i})})})};import hO from"clsx";import{jsx as eT,jsxs as fO}from"react/jsx-runtime";var gO="small",tT=e=>fO("label",{className:hO("ToolIcon ToolIcon__LaserPointer",`ToolIcon_size_${gO}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[eT("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title,"data-testid":"toolbar-LaserPointer"}),eT("div",{className:"ToolIcon__icon",children:Qi})]});import{Fragment as nT,jsx as $,jsxs as Nt}from"react/jsx-runtime";var IO=({UIOptions:e})=>Nt(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,{})]}),CO=()=>Nt(Ed,{__fallback:!0,children:[$(Ed.Actions.SaveToDisk,{}),$(Ed.Actions.ExportToImage,{})]}),SO=({actionManager:e,appState:o,files:t,setAppState:r,elements:n,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=a2(),C=v.tunnelsJotai.Provider,[S,L]=ie(er),k=()=>p.canvasActions.export?$(Q5,{elements:n,appState:o,files:t,actionManager:e,exportOpts:p.canvasActions.export,canvas:i,setAppState:r}):null,A=()=>!p.canvasActions.saveAsImage||o.openDialog?.name!=="imageExport"?null:$(J5,{elements:n,appState:o,files:t,actionManager:e,onExportImage:u,onCloseRequest:()=>r({openDialog:null}),name:x.getName()}),P=()=>Nt("div",{style:{position:"relative"},children:[$(v.MainMenuTunnel.Out,{}),f&&$(v.WelcomeScreenMenuHintTunnel.Out,{})]}),N=()=>$(br,{heading:"selectedShapeActions",className:cl("selected-shape-actions zen-mode-transition",{"transition-left":o.zenModeEnabled}),children:$(Xe,{className:xO.SHAPE_ACTIONS_MENU,padding:2,style:{maxHeight:`${o.height-166}px`},children:$(Pc,{appState:o,elementsMap:x.scene.getNonDeletedElementsMap(),renderAction:e.renderAction,app:x})})}),O=()=>{let R=vO(o,n),V=o.stats.open&&!o.zenModeEnabled&&!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector";return $(ld,{side:"top",children:Nt("div",{className:"App-menu App-menu_top",children:[Nt(qe.Col,{gap:6,className:cl("App-menu_top__left"),children:[P(),R&&N()]}),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&$(br,{heading:"shapes",className:"shapes-section",children:Z=>Nt("div",{style:{position:"relative"},children:[f&&$(v.WelcomeScreenToolbarHintTunnel.Out,{}),$(qe.Col,{gap:4,align:"start",children:Nt(qe.Row,{gap:1,className:cl("App-toolbar-container",{"zen-mode":o.zenModeEnabled}),children:[Nt(Xe,{padding:1,className:cl("App-toolbar",{"zen-mode":o.zenModeEnabled}),children:[$(cd,{appState:o,isMobile:y.editor.isMobile,device:y,app:x}),Z,Nt(qe.Row,{gap:1,children:[$(dd,{zenModeEnabled:o.zenModeEnabled,checked:o.penMode,onChange:()=>s(null),title:g("toolBar.penMode"),penDetected:o.penDetected}),$(ad,{checked:o.activeTool.locked,onChange:a,title:g("toolBar.lock")}),$("div",{className:"App-toolbar__divider"}),$(sd,{checked:jt(o),onChange:()=>l(),title:g("toolBar.hand"),isMobile:!0}),$(Ac,{appState:o,activeTool:o.activeTool,UIOptions:p,app:x})]})]}),w&&$(Xe,{style:{marginLeft:8,alignSelf:"center",height:"fit-content"},children:$(tT,{title:g("toolBar.laser"),checked:o.activeTool.type===oT.laser,onChange:()=>x.setActiveTool({type:oT.laser}),isMobile:!0})})]})})]})}),Nt("div",{className:cl("layer-ui__wrapper__top-right zen-mode-transition",{"transition-right":o.zenModeEnabled}),children:[o.collaborators.size>0&&$(ud,{collaborators:o.collaborators,userToFollow:o.userToFollow?.socketId||null}),m?.(y.editor.isMobile,o),!o.viewModeEnabled&&o.openDialog?.name!=="elementLinkSelector"&&(!J||o.openSidebar?.name!==Xg.name)&&$(v.DefaultSidebarTriggerTunnel.Out,{}),V&&$(al,{app:x,onClose:()=>{e.executeAction(ti)},renderCustomStats:c})]})]})})},U=()=>$(vd,{__fallback:!0,onDock:R=>{re("sidebar",`toggleDock (${R?"dock":"undock"})`,`(${y.editor.isMobile?"mobile":"desktop"})`)}}),J=Ol(Qa),_=Nt(nT,{children:[b,$(IO,{UIOptions:p}),$(vd.Trigger,{__fallback:!0,icon:yn,title:yO(g("toolBar.library")),onToggle:R=>{R&&re("sidebar",`${Xg.name} (open)`,`button (${y.editor.isMobile?"mobile":"desktop"})`)},tab:Xg.defaultTab,children:g("toolBar.library")}),$(CO,{}),o.openDialog?.name==="ttd"&&$(Tg,{__fallback:!0}),o.isLoading&&$(id,{delay:250}),o.errorMessage&&$(Y5,{onClose:()=>r({errorMessage:null}),children:o.errorMessage}),S&&!y.editor.isMobile&&$(wb,{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)wO(ce,EO(n),{[W&&S.swapPreviewOnAlt?R==="elementBackground"?"strokeColor":"backgroundColor":R==="elementBackground"?"backgroundColor":"strokeColor"]:V}),TO.delete(ce);x.scene.triggerUpdate()}else r(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"&&$(X5,{onClose:()=>{r({openDialog:null})}}),$(g2,{}),o.openDialog?.name==="elementLinkSelector"&&$(U5,{sourceElementId:o.openDialog.sourceElementId,onClose:()=>{r({openDialog:null})},scene:x.scene,appState:o,generateLinkForSelection:E}),$(v.OverwriteConfirmDialogTunnel.Out,{}),A(),k(),o.pasteDialog.shown&&$(Nv,{setAppState:r,appState:o,onClose:()=>r({pasteDialog:{shown:!1,data:null}})}),y.editor.isMobile&&$(_v,{app:x,appState:o,elements:n,actionManager:e,renderJSONExportDialog:k,renderImageExportDialog:A,setAppState:r,onLockToggle:a,onHandToolToggle:l,onPenModeToggle:s,renderTopRightUI:m,renderCustomStats:c,renderSidebars:U,device:y,renderWelcomeScreen:f,UIOptions:p}),!y.editor.isMobile&&Nt(nT,{children:[Nt("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(),$(zv,{appState:o,actionManager:e,showExitZenModeBtn:d,renderWelcomeScreen:f}),o.scrolledOutside&&$("button",{type:"button",className:"scroll-back-to-content",onClick:()=>{r(R=>({...Nr(n,R)}))},children:g("buttons.scrollBackToContent")})]}),U()]})]});return $(ep.Provider,{value:o,children:$(C,{children:$(ju.Provider,{value:v,children:_})})})},rT=e=>{let{suggestedBindings:o,startBoundElement:t,cursorButton:r,scrollX:n,scrollY:i,...a}=e;return a},kO=(e,o)=>{if(e.children!==o.children)return!1;let{canvas:t,appState:r,...n}=e,{canvas:i,appState:a,...l}=o;return Wd(rT(r),rT(a),{selectedElementIds:Wd,selectedGroupIds:Wd})&&Wd(n,l)},iT=bO.memo(SO,kO);import MO from"clsx";import{jsx as aT,jsxs as PO}from"react/jsx-runtime";var LO="small",Vd=e=>PO("label",{className:MO("ToolIcon ToolIcon__MagicButton",`ToolIcon_size_${LO}`,{"is-mobile":e.isMobile}),title:`${e.title}`,children:[aT("input",{className:"ToolIcon_type_checkbox",type:"checkbox",name:e.name,onChange:e.onChange,checked:e.checked,"aria-label":e.title}),aT("div",{className:"ToolIcon__icon",children:e.icon})]});import{useEffect as AO,useRef as DO}from"react";import{jsx as lT}from"react/jsx-runtime";var sT=({trails:e})=>{let o=DO(null);return AO(()=>{if(o.current)for(let t of e)t.start(o.current);return()=>{for(let t of e)t.stop()}},e),lT("div",{className:"SVGLayer",children:lT("svg",{ref:o})})};import _O,{useEffect as RO,useRef as NO}from"react";import{CURSOR_TYPE as cT,isShallowEqual as BO,sceneCoordsToViewportCoords as FO}from"@excalidraw/common";import{jsx as HO}from"react/jsx-runtime";var OO=e=>{let o=NO(!1);return RO(()=>{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,d)=>{if(s.selectedElementIds)for(let m of Object.keys(s.selectedElementIds))n.has(m)||n.set(m,[]),n.get(m).push(d);!s.pointer||s.pointer.renderCursor===!1||(s.username&&i.set(d,s.username),s.userState&&a.set(d,s.userState),r.set(d,FO({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";Vw({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},Ci())}),HO("canvas",{className:"excalidraw__canvas interactive",style:{width:e.appState.width,height:e.appState.height,cursor:e.appState.viewModeEnabled?cT.GRAB:cT.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")})},dT=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}),zO=(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:BO(dT(e.appState),dT(o.appState)),Kg=_O.memo(OO,zO);import GO,{useEffect as mT,useRef as pT}from"react";import{isShallowEqual as uT}from"@excalidraw/common";import{jsx as WO}from"react/jsx-runtime";var UO=e=>{let o=pT(null),t=pT(!1);return mT(()=>{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]),mT(()=>{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")),n1({canvas:n,rc:e.rc,scale:e.scale,elementsMap:e.elementsMap,allElementsMap:e.allElementsMap,visibleElements:e.visibleElements,appState:e.appState,renderConfig:e.renderConfig},Ci())}),WO("div",{className:"excalidraw__canvas-wrapper",ref:o})},hT=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}),YO=(e,o)=>e.sceneNonce!==o.sceneNonce||e.scale!==o.scale||e.elementsMap!==o.elementsMap||e.visibleElements!==o.visibleElements?!1:uT(hT(e.appState),hT(o.appState))&&uT(e.renderConfig,o.renderConfig),Zg=GO.memo(UO,YO);import{useEffect as qO,useRef as JO}from"react";import{throttleRAF as VO}from"@excalidraw/common";import{getTargetFrame as XO,isInvisiblySmallElement as KO,renderElement as ZO,shouldApplyFrameClip as $O}from"@excalidraw/element";var gT=({canvas:e,rc:o,newElement:t,elementsMap:r,allElementsMap:n,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(KO(t))return;if((t.frameId||a.frameToHighlight?.id)&&a.frameRendering.enabled&&a.frameRendering.clip){let p=XO(t,r,a);p&&$O(t,p,a,r)&&o1(p,m,l,a)}ZO(t,r,n,o,m,l,a)}else m.clearRect(0,0,s,d);m.restore()}},jO=VO(e=>{gT(e)},{trailing:!0}),fT=(e,o)=>{if(o){jO(e);return}gT(e)};import{jsx as ez}from"react/jsx-runtime";var QO=e=>{let o=JO(null);return qO(()=>{o.current&&fT({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},Ci())}),ez("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})},bT=QO;import{useCallback as tz,useEffect as oz,useRef as rz}from"react";import{jsx as xT,jsxs as iz}from"react/jsx-runtime";var nz=5e3,ET=({message:e,onClose:o,closable:t=!1,duration:r=nz,style:n})=>{let i=rz(0),a=r!==1/0,l=tz(()=>{a&&(i.current=window.setTimeout(()=>o(),r))},[o,r,a]);return oz(()=>{if(a)return l(),()=>clearTimeout(i.current)},[l,e,r,a]),iz("div",{className:"Toast",onMouseEnter:a?()=>clearTimeout(i?.current):void 0,onMouseLeave:a?l:void 0,style:n,children:[xT("p",{className:"Toast__message",children:e}),t&&xT(K,{icon:Bt,"aria-label":"close",type:"icon",onClick:o,className:"close"})]})};import{getCommonBounds as az,getElementsInGroup as lz,selectGroupsFromGivenElements as sz}from"@excalidraw/element";import{sceneCoordsToViewportCoords as cz}from"@excalidraw/common";import{flushSync as dz}from"react-dom";import{jsx as pz}from"react/jsx-runtime";var mz=({app:e,activeLockedId:o})=>{let t=e.scene.getElement(o),r=t?[t]:lz(e.scene.getNonDeletedElementsMap(),o);if(r.length===0)return null;let[n,i]=az(r),{x:a,y:l}=cz({sceneX:n,sceneY:i},e.state);return pz("div",{className:"UnlockPopup",style:{bottom:`${e.state.height+12-l+e.state.offsetTop}px`,left:`${a-e.state.offsetLeft}px`},onClick:()=>{dz(()=>{let s=sz(r,e.state);e.setState({selectedElementIds:r.reduce((d,m)=>({...d,[m.id]:!0}),{}),selectedGroupIds:s,activeLockedId:null})}),e.actionManager.executeAction(Ma)},title:g("labels.elementLock.unlock"),children:S1})},yT=mz;import{Fragment as aG,jsx as ue,jsxs as Qd}from"react/jsx-runtime";var vI=So.createContext(null),TI=So.createContext(null),II={viewport:{isMobile:!1,isLandscape:!1},editor:{isMobile:!1,canFitSidebar:!1},isTouchScreen:!1},Sf=So.createContext(II);Sf.displayName="DeviceContext";var kf=So.createContext({container:null,id:null});kf.displayName="ExcalidrawContainerContext";var Mf=So.createContext([]);Mf.displayName="ExcalidrawElementsContext";var Lf=So.createContext({...$o(),width:0,height:0,offsetLeft:0,offsetTop:0});Lf.displayName="ExcalidrawAppStateContext";var Pf=So.createContext(()=>{console.warn("Uninitialized ExcalidrawSetAppStateContext context!")});Pf.displayName="ExcalidrawSetAppStateContext";var Af=So.createContext(null);Af.displayName="ExcalidrawActionManagerContext";var Re=()=>_r(vI),fo=()=>_r(TI),se=()=>_r(Sf),He=()=>_r(kf),tr=()=>_r(Mf),go=()=>_r(Lf),le=()=>_r(Pf),Ue=()=>_r(Af),xl=!1,wf=0,dn=!1,El=!1,vf=!1,yl={horizontal:null,vertical:null},Dr=0,wl=!1,Tf=new Map,Jd=!1,xI=0,EI=!1,vl=null,pe={pointers:new Map,lastCenter:null,initialDistance:null,initialScale:null},Cf=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",II);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 _H);I(this,"flowChartNavigator",new RH);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 Vc);I(this,"laserTrails",new ed(this.animationFrameHandler,this));I(this,"eraserTrail",new nd(this.animationFrameHandler,this));I(this,"lassoTrail",new rd(this.animationFrameHandler,this));I(this,"onChangeEmitter",new ln);I(this,"onPointerDownEmitter",new ln);I(this,"onPointerUpEmitter",new ln);I(this,"onUserFollowEmitter",new ln);I(this,"onScrollChangeEmitter",new ln);I(this,"missingPointerEventCleanupEmitter",new ln);I(this,"onRemoveEventListenersEmitter",new ln);I(this,"updateEditorAtom",(t,...r)=>{let n=ze.set(t,...r);return this.triggerRender(),n});I(this,"getEffectiveGridSize",()=>hr(this)?this.state.gridSize:null);I(this,"updateEmbedValidationStatus",(t,r)=>{this.embedsValidationStatus.set(t.id,r),fl.delete(t)});I(this,"updateEmbeddables",()=>{let t=new Set,r=!1;this.scene.getNonDeletedElements().filter(n=>{if(Ar(n)){if(t.add(n.id),!this.embedsValidationStatus.has(n.id)){r=!0;let i=uf(n.link,this.props.validateEmbeddable);this.updateEmbedValidationStatus(n,i)}}else Hi(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===Zd.DARK,r=this.scene.getNonDeletedFramesLikes(),n=r.length>0&&this.state.searchMatches?.focusedId&&Kt(this.scene.getElement(this.state.searchMatches.focusedId))?this.state.searchMatches.matches.find(i=>i.focus):null;return r.map(i=>{if(!JT(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}=jd({sceneX:i.x,sceneY:i.y},this.state),s=6,d,m=kH(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?Dz:"none",zIndex:2,border:"none",display:"block",padding:`${s}px`,borderRadius:4,boxShadow:"inset 0 0 0 1px var(--color-primary)",fontFamily:"Assistant",fontSize:`${Mr.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+Mr.nameOffsetY-l+this.state.offsetTop}px`,left:`${a-this.state.offsetLeft}px`,zIndex:2,fontSize:Mr.nameFontSize,color:t?Mr.nameColorDarkTheme:Mr.nameColorLightTheme,lineHeight:Mr.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:De.MOVE,pointerEvents:this.state.viewModeEnabled?Fi.disabled:Fi.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,r,n)=>{re("export",t,"ui");let i=await Xr(t,r,this.state,this.files,{exportBackground:this.state.exportBackground,name:this.getName(),viewBackgroundColor:this.state.viewBackgroundColor,exportingFrame:n.exportingFrame}).catch(Zz).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: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:Co.magicframe}),re("ai","tool-select (empty-selection)","d2c");else{let r=t.length===1&&mf(t[0])&&t[0];if(!r&&t.some(i=>Kt(i)||i.frameId)){this.setActiveTool({type:Co.magicframe});return}re("ai","tool-select (existing selection)","d2c");let n;if(r)n=r;else{let[i,a,l,s]=zi(t),d=50;n=WT({...Mr,x:i-d,y:a-d,width:l-i+d*2,height:s-a+d*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(er,{swapPreviewOnAlt:!0,colorPickerType:t==="stroke"?"elementStroke":"elementBackground",onSelect:(r,n)=>{let i=t==="background"&&n.altKey||t==="stroke"&&!n.altKey;!this.scene.getSelectedElements(this.state).length||this.state.activeTool.type!=="selection"?i?this.syncActionResult({appState:{...this.state,currentItemStrokeColor:r},captureUpdate:mt.IMMEDIATELY}):this.syncActionResult({appState:{...this.state,currentItemBackgroundColor:r},captureUpdate:mt.IMMEDIATELY}):this.updateScene({elements:this.scene.getElementsIncludingDeleted().map(l=>this.state.selectedElementIds[l.id]?sn(l,{[i?"strokeColor":"backgroundColor"]:r}):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 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||Zd.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),n=t.appState?.editingTextElement||null,t.elements&&n&&t.elements.forEach(m=>{n?.id===m.id&&n!==m&&fI(m)&&co(m)&&(n=m)}),n?.isDeleted&&(n=null),this.setState(m=>{let c=t.appState||{};return{...m,...c,contextMenu:null,editingTextElement:n,viewModeEnabled:i,zenModeEnabled:a,theme:l,name:s,errorMessage:d}}),r=!0}r||this.scene.triggerUpdate()}));I(this,"onBlur",Pe(()=>{dn=!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(r=>({...$o(),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=bn(t,null,null,{repairBindings:!0,deleteEmptyTextElements:!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,...Nr(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:mt.NEVER}),this.clearImageShapeCache(),this.fonts.loadSceneFonts().then(n=>{this.fonts.onLoaded(n)}),Ef(window.location.href)&&this.scrollToContent(window.location.href,{animate:!1})});I(this,"isMobileBreakpoint",(t,r)=>t<kz||r<Cz&&t<Sz);I(this,"refreshViewportBreakpoints",()=>{if(!this.excalidrawContainerRef.current)return;let{clientWidth:r,clientHeight:n}=document.body,i=this.device.viewport,a=of(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:Mz,a=this.device.editor,l=of(a,{isMobile:this.isMobileBreakpoint(r,n),canFitSidebar:r>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(),DT||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&&(yl=r);let i=this.state.editingTextElement?!1:!t&&n.size>0;this.state.scrolledOutside!==i&&this.setState({scrolledOutside:i}),this.scheduleImageRefresh()});I(this,"onScroll",NT(()=>{let{offsetTop:t,offsetLeft:r}=this.getCanvasOffsets();this.setState(n=>n.offsetLeft===r&&n.offsetTop===t?null:{offsetTop:t,offsetLeft:r})},Lz));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(Qn,"keyboard",t),t.preventDefault(),t.stopPropagation())}));I(this,"onTouchStart",t=>{if(Bz&&t.preventDefault(),!xl){xl=!0,clearTimeout(wf),wf=window.setTimeout(e.resetTapTwice,Pz);return}if(xl&&t.touches.length===1){let r=t.touches[0];this.handleCanvasDoubleClick({clientX:r.clientX,clientY:r.clientY}),xl=!1,clearTimeout(wf)}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 r=!!Jd,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)||ml(n)))return;let{x:l,y:s}=Fe({clientX:this.lastViewportPosition.x,clientY:this.lastViewportPosition.y},this.state),d=t?.clipboardData?.files[0],m=await Ws(t,r);if(!d&&!r){if(m.mixedContent)return this.addElementsFromMixedContentPaste(m.mixedContent,{isPlainPaste:r,sceneX:l,sceneY:s});if(m.text){let c=m.text.trim();c.startsWith("<svg")&&c.endsWith("</svg>")&&(d=xm(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&&!r)this.setState({pasteDialog:{data:m.spreadsheet,shown:!0}});else if(m.elements){let c=m.programmaticAPI?Ii(m.elements):m.elements;this.addElementsFromPasteOrLibrary({elements:c,files:m.files||null,position:"cursor",retainSeed:r})}else if(m.text){if(m.text&&iv(m.text)){let u=await import("@excalidraw/mermaid-to-excalidraw");try{let{elements:f,files:b}=await u.parseMermaidToExcalidraw(m.text),x=Ii(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 c=jz(m.text).split(/\n+/).map(u=>u.trim()).filter(Boolean),p=c.map(u=>bH(u)).filter(u=>uf(u,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(u)||qd(u)?.type==="video"));if(!Jd&&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:Qg(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,r)}this.setActiveTool({type:"selection"}),t?.preventDefault()}));I(this,"addElementsFromPasteOrLibrary",t=>{let r=hm(t.elements,null,{deleteEmptyTextElements:!0}),[n,i,a,l]=zi(r),s=Oi(n,a)/2,d=Oi(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}=Fe({clientX:m,clientY:c},this.state),f=p-s,b=u-d,[x,w]=nt(f,b,this.getEffectiveGridSize()),{duplicatedElements:E}=KT({type:"everything",elements:r.map(k=>sn(k,{x:k.x+x-n,y:k.y+w-i})),randomizeSeed:!t.retainSeed}),y=this.scene.getElementsIncludingDeleted(),v=[...y,...E];v=this.props.onDuplicate?.(v,y)||v,mI(v,OT(E));let S=this.getTopLayerFrameAtSceneCoords({x:p,y:u});if(S){let k=LH(E,S);ff(v,k,S,this.state)}this.scene.replaceAllElements(v),E.forEach(k=>{if(co(k)&&df(k)){let A=rI(k,this.scene.getElementsMapIncludingDeleted());wH(k,A,this.scene)}}),zz&&Zo.loadElementsFonts(E).then(k=>{this.fonts.onLoaded(k)}),t.files&&this.addMissingFiles(t.files);let L=$H(E);this.store.scheduleCapture(),this.setState({...this.state,openSidebar:this.state.openSidebar&&this.device.editor.canFitSidebar&&ze.get(Qa)?this.state.openSidebar:null,...mo({editingGroupId:null,selectedElementIds:L.reduce((k,A)=>(df(A)||(k[A.id]=!0),k),{})},this.scene.getNonDeletedElements(),this.state,this)},()=>{t.files&&this.addNewImagesToImageCache()}),this.setActiveTool({type:"selection"}),t.fitToContent&&this.scrollToContent(E,{fitToContent:!0,canvasOffsets:this.getEditorUIOffsets()})});I(this,"setAppState",(t,r)=>{this.setState(t,r)});I(this,"removePointer",t=>{Dr&&this.resetContextMenuTimer(),pe.pointers.delete(t.pointerId)});I(this,"toggleLock",(t="ui")=>{this.state.activeTool.locked||re("toolbar","toggleLock",`${t} (${this.device.editor.isMobile?"mobile":"desktop"})`),this.setState(r=>({activeTool:{...r.activeTool,...Vo(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(xx)});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(),r)=>{if(typeof t=="string"){let s;if(Ef(t)?s=FH(t):s=t,s){let d=this.scene.getElementsFromId(s);d?.length?this.scrollToContent(d,{fitToContent:r?.fitToContent??!0,animate:r?.animate??!0}):Ef(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}=ga({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=Nr(n,this.state);a=s.scrollX,l=s.scrollY}if(r?.animate){let s=this.state.scrollX,d=this.state.scrollY,m=this.state.zoom.value,c=Kz({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,$z(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=()=>{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"),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,xz,window.location.pathname)}}catch(t){this.setState({errorMessage:t.message})}});I(this,"addFiles",Pe(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===Lr.svg))try{let s=p1(oI(u1(l.dataURL)),Lr.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",Pe(t=>{let{elements:r,appState:n,collaborators:i,captureUpdate:a}=t;if(a){let l=r||void 0,s=n?eH({...this.store.snapshot.appState,...n}):void 0;this.store.scheduleMicroAction({action:a,elements:l,appState:s})}n&&this.setState(n),r&&this.scene.replaceAllElements(r),i&&this.setState({collaborators:i})}));I(this,"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",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,r=this.excalidrawContainerRef?.current?.querySelector(".sidebar")?.getBoundingClientRect(),n=this.excalidrawContainerRef?.current?.querySelector(".App-menu__left")?.getBoundingClientRect(),i=16;return Mo().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",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}})),!BT(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&&cn(a[0])&&t.key===Y.ENTER){this.startImageCropping(a[0]);return}if(t.key===Y.ESCAPE)this.updateEditorAtom(no,null);else if(t.key===Y.TAB&&(document.activeElement===this.excalidrawContainerRef?.current||document.activeElement?.classList.contains(Qz.CONVERT_ELEMENT_TYPE_POPUP))){t.preventDefault();let s=li(a);ze.get(no)?.type==="panel"&&Mu(this,{conversionType:s,direction:t.shiftKey?"left":"right"})&&this.store.scheduleCapture(),s&&this.updateEditorAtom(no,{type:"panel"})}if(t.key===Y.ESCAPE&&this.flowChartCreator.isCreatingChart){this.flowChartCreator.clear(),this.triggerRender(!0);return}let l=Xd(t.key);if(t[Y.CTRL_OR_CMD]&&l&&!t.shiftKey){t.preventDefault();let s=j(this.scene.getNonDeletedElementsMap(),this.state);s.length===1&&uH(s[0])&&this.flowChartCreator.createNodes(s[0],this.state,sI(t.key),this.scene),this.flowChartCreator.pendingNodes?.length&&!pf(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(),sI(t.key));if(d){this.setState(c=>({selectedElementIds:ye({[d]:!0},c)}));let m=this.scene.getNonDeletedElementsMap().get(d);m&&!pf([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&&(Jd=t.shiftKey,clearTimeout(xI),xI=window.setTimeout(()=>{Jd=!1},100)),t[Y.CTRL_OR_CMD]&&ml(t.target)&&(t.code===kT.MINUS||t.code===kT.EQUAL)){t.preventDefault();return}if(ml(t.target)&&t.key!==Y.ESCAPE||Xd(t.key)&&BT(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}),Xd(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?PT:this.getEffectiveGridSize())||(t.shiftKey?wz:PT),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}),af(p,this.scene,{simultaneouslyUpdated:a})}),this.setState({suggestedBindings:lf(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]||yf(l))Zt(l)&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)&&(this.store.scheduleCapture(),We(l)||this.actionManager.executeAction(wi));else if(co(l)||yH(l)){let s;co(l)||(s=l);let d=gf(l,this.state,this.scene.getNonDeletedElementsMap()),m=d.x,c=d.y;this.startTextEditing({sceneX:m,sceneY:c,container:s}),t.preventDefault();return}else Kt(l)&&this.setState({editingFrame:l.id})}}else if(!t.ctrlKey&&!t.altKey&&!t.metaKey&&!this.state.newElement&&!this.state.selectionElement&&!this.state.selectedElementsAreBeingDragged){let a=i2(t.key);a?(this.state.activeTool.type!==a&&re("toolbar",a,`keyboard (${this.device.editor.isMobile?"mobile":"desktop"})`),a==="arrow"&&this.state.activeTool.type==="arrow"&&this.setState(l=>({currentItemArrowType:l.currentItemArrowType===Pr.sharp?Pr.round:l.currentItemArrowType===Pr.round?Pr.elbow:Pr.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&&(dn=!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&&(Ko(this.state.activeTool.type)||a.some(l=>Ko(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=>co(l)||hf(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(Jr,"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",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"?zt(this.interactiveCanvas):(At(this.interactiveCanvas,this.state),this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})),dn=!1),!t[Y.CTRL_OR_CMD]&&!this.state.isBindingEnabled&&this.setState({isBindingEnabled:!0}),Xd(t.key)&&(UT(this.scene.getSelectedElements(this.state).filter(Zt),nf(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 r=this.flowChartCreator.pendingNodes?.[0];r&&(this.setState(n=>({selectedElementIds:ye({[r.id]:!0},n)})),pf([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:mt.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=Vo(this.state,t);n.type==="hand"?xe(this.interactiveCanvas,De.GRAB):dn||At(this.interactiveCanvas,{...this.state,activeTool:n}),Yz(document.activeElement)&&this.focusContainer(),mH(n.type)||this.setState({suggestedBindings:[]}),n.type==="image"&&this.onImageAction(),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:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null},...a}:n.type!=="selection"?{...i,activeTool:n,selectedElementIds:ye({},i),selectedGroupIds:ye({},i),editingGroupId:null,multiElement:null,...a}:{...i,activeTool:n,...a}})});I(this,"setOpenDialog",t=>{this.setState({openDialog:t})});I(this,"setCursor",t=>{xe(this.interactiveCanvas,t)});I(this,"resetCursor",()=>{zt(this.interactiveCanvas)});I(this,"isTouchScreenMultiTouchGesture",()=>pe.pointers.size>=2);I(this,"getName",()=>this.state.name||this.props.name||`${g("labels.untitled")}-${FT()}`);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 r=pe.initialScale;r&&this.setState(n=>({...Ao({viewportX:this.lastViewportPosition.x,viewportY:this.lastViewportPosition.y,nextZoom:uo(r*t.scale)},n)}))}));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:r,insertAtParentCenter:n=!0,container:i,autoEdit:a=!0})=>{let l=!1,s=n&&this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i);i&&s&&(hf(i,this.scene.getNonDeletedElementsMap())||(l=!0));let d=null,m=this.scene.getSelectedElements(this.state);m.length===1?co(m[0])?d=m[0]:i?d=hf(m[0],this.scene.getNonDeletedElementsMap()):d=this.getTextElementAtPosition(t,r):d=this.getTextElementAtPosition(t,r);let c=d?.fontFamily||this.state.currentItemFontFamily,p=d?.lineHeight||RT(c),u=this.state.currentItemFontSize;if(!d&&l&&i&&!sf(i)){let w=GH(ef({fontSize:u,fontFamily:c}),p),E=UH(u,p),y=Math.max(i.height,E),v=Math.max(i.width,w);this.scene.mutateElement(i,{height:y,width:v}),t=i.x+v/2,r=i.y+y/2,s&&(s=this.getTextWysiwygSnappedToCenterPosition(t,r,this.state,i))}let f=this.getTopLayerFrameAtSceneCoords({x:t,y:r}),b=d||VT({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:c,textAlign:s?"center":this.state.currentItemTextAlign,verticalAlign:s?Rz.MIDDLE:LT,containerId:l?i?.id:void 0,groupIds:i?.groupIds??[],lineHeight:p,angle:i?sf(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!=="selection")return;let r=this.scene.getSelectedElements(this.state),{x:n,y:i}=Fe(t,this.state);if(r.length===1&&Zt(r[0])){let l=r[0];if((t[Y.CTRL_OR_CMD]&&nG(l)||yf(l))&&(!this.state.selectedLinearElement?.isEditing||this.state.selectedLinearElement.elementId!==l.id)){this.actionManager.executeAction(wi);return}else if(this.state.selectedLinearElement&&We(r[0])){let s=Se.getSegmentMidpointHitCoords(this.state.selectedLinearElement,{x:n,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(r[0],this.scene,d);let m=Se.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:n,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&&yf(l))return}if(r.length===1&&cn(r[0])){this.startImageCropping(r[0]);return}if(zt(this.interactiveCanvas),KH(this.state).length>0){let l=this.getElementAtPosition(n,i),s=l&&XH(l,this.state.selectedGroupIds);if(s){this.store.scheduleCapture(),this.setState(d=>({...d,...mo({editingGroupId:s,selectedElementIds:{[l.id]:!0}},this.scene.getNonDeletedElements(),d,this)}));return}}if(zt(this.interactiveCanvas),!t[Y.CTRL_OR_CMD]&&!this.state.viewModeEnabled){let l=this.getElementAtPosition(n,i);if(hl(l)){this.setState({activeEmbeddable:{element:l,state:"active"}});return}if(!this.state.selectedLinearElement?.isEditing){let s=this.getTextBindableContainerAtPosition(n,i);if(s&&(ZT(s)||!Xz(s.backgroundColor)||gl({point:ne(n,i),element:s,elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(s)}))){let d=gf(s,this.state,this.scene.getNonDeletedElementsMap());n=d.x,i=d.y}this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:s})}}});I(this,"getElementLinkAtPosition",(t,r)=>{if(r&&r.locked)return;let n=this.scene.getNonDeletedElements(),i=-1;for(let a=n.length-1;a>=0;a--){let l=n[a];if(r&&l.id===r.id&&(i=a),l.link&&a>=i&&Pl(l,this.scene.getNonDeletedElementsMap(),this.state,ne(t.x,t.y),this.device.editor.isMobile))return l}});I(this,"redirectToLink",(t,r)=>{let n=nn(ne(this.lastPointerDownEvent.clientX,this.lastPointerDownEvent.clientY),ne(this.lastPointerUpEvent.clientX,this.lastPointerUpEvent.clientY));if(!this.hitLinkElement||n>yz)return;let i=Fe(this.lastPointerDownEvent,this.state),a=this.scene.getNonDeletedElementsMap(),l=Pl(this.hitLinkElement,a,this.state,ne(i.x,i.y),this.device.editor.isMobile),s=Fe(this.lastPointerUpEvent,this.state),d=Pl(this.hitLinkElement,a,this.state,ne(s.x,s.y),this.device.editor.isMobile);if(l&&d){bu();let m=this.hitLinkElement.link;if(m){m=Qg(m);let c;if(this.props.onLinkOpen&&(c=Wz(ee.EXCALIDRAW_LINK,t.nativeEvent),this.props.onLinkOpen({...this.hitLinkElement,link:m},c)),!c?.defaultPrevented){let p=Hz(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=>iI(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,pe.pointers.has(t.pointerId)&&pe.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY});let r=pe.initialScale;if(pe.pointers.size===2&&pe.lastCenter&&r&&pe.initialDistance){let f=kh(pe.pointers),b=f.x-pe.lastCenter.x,x=f.y-pe.lastCenter.y;pe.lastCenter=f;let w=Mh(Array.from(pe.pointers.values())),E=this.state.activeTool.type==="freedraw"&&this.state.penMode?1:w/pe.initialDistance,y=E?uo(r*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(dn||El||vf||jt(this.state))return;let i=Bh(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?zt(this.interactiveCanvas):At(this.interactiveCanvas,this.state));let a=Fe(t,this.state),{x:l,y:s}=a;if(!this.state.newElement&&Iw(this.state.activeTool.type)){let{originOffset:f,snapLines:b}=Tw(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&&Bi(()=>{this.setState({selectedLinearElement:f})}),f?.lastUncommittedPoint!=null&&b&&$T(b.type)?this.maybeSuggestBindingAtCursor(a,f.elbowed):this.state.suggestedBindings.length&&this.setState({suggestedBindings:[]})}if($T(this.state.activeTool.type)){let{newElement:f}=this.state;cf(f,!1)?this.setState({suggestedBindings:HT(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(At(this.interactiveCanvas,this.state),y===E)nn(ne(l-b,s-x),y)>=Jg?this.scene.mutateElement(f,{points:[...w,ne(l-b,s-x)]},{informMutation:!1,isDragging:!1}):xe(this.interactiveCanvas,De.POINTER);else if(w.length>2&&E&&nn(ne(l-b,s-x),E)<Jg)xe(this.interactiveCanvas,De.POINTER),this.scene.mutateElement(f,{points:w.slice(0,-1)},{informMutation:!1,isDragging:!1});else{let[v,C]=nt(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;qg(t)&&({width:k,height:A}=qT(S+b,L+x,v,C)),eI(w,this.state.zoom.value)&&xe(this.interactiveCanvas,De.POINTER),this.scene.mutateElement(f,{points:[...w.slice(0,-1),ne(S+k,L+A)]},{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(),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=uI(m,this.state,l,s,this.state.zoom,t.pointerType,this.scene.getNonDeletedElementsMap(),this.device);if(f&&f.transformHandleType){xe(this.interactiveCanvas,pI(f));return}}}else if(c.length>1&&!i&&this.state.openDialog?.name!=="elementLinkSelector"){let f=hI(zi(c),l,s,this.state.zoom,t.pointerType,this.device);if(f){xe(this.interactiveCanvas,pI({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),HE(this.hitLinkElement,this.state,this.scene.getNonDeletedElementsMap())):(bu(),u&&(u.link||Ar(u))&&this.state.selectedElementIds[u.id]&&!this.state.contextMenu&&!this.state.showHyperlinkPopup?this.setState({showHyperlinkPopup:"info"}):this.state.activeTool.type==="text"?xe(this.interactiveCanvas,co(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))&&(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,mo({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,r)=>{let n=this.eraserTrail.addPointToPath(r.x,r.y,t.altKey);this.elementsPendingErasure=new Set(n),this.triggerRender()});I(this,"handleTouchMove",t=>{wl=!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(c=>({searchMatches:c.searchMatches&&{focusedId:null,matches:c.searchMatches.matches.map(p=>({...p,focus:!1}))}})),this.updateEditorAtom(bg,null)),ze.get(no)&&this.updateEditorAtom(no,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 n=document.getSelection();if(n?.anchorNode&&n.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=of(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===an.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!==an.MAIN&&t.button!==an.TOUCH&&t.button!==an.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;this.state.activeTool.type==="lasso"?this.lassoTrail.startPath(i.origin.x,i.origin.y,t.shiftKey):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"?At(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 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(hl(i)&&this.isIframeLikeElementCenter(i,t,r.x,r.y)){this.handleEmbeddableCenterClick(i);return}}if(this.device.isTouchScreen){let i=this.getElementAtPosition(r.x,r.y,{includeLockedElements:!0});this.hitLinkElement=this.getElementLinkAtPosition(r,i)}this.hitLinkElement&&!this.state.selectedElementIds[this.hitLinkElement.id]?n<300&&hl(this.hitLinkElement)&&!Jf(this.hitLinkElement,this.scene.getNonDeletedElementsMap(),this.state,ne(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"&&(wl=!1,Dr?wl=!0:Dr=window.setTimeout(()=>{Dr=0,wl||this.handleCanvasContextMenu(t)},_z))});I(this,"resetContextMenuTimer",()=>{clearTimeout(Dr),Dr=0,wl=!1});I(this,"maybeCleanupAfterMissingPointerUp",t=>{vl?.(),this.missingPointerEventCleanupEmitter.trigger(t).clear()});I(this,"handleCanvasPanUsingWheelOrSpaceDrag",t=>{if(!(pe.pointers.size<=1&&(t.button===an.WHEEL||t.button===an.MAIN&&dn||jt(this.state)||this.state.viewModeEnabled)))return!1;El=!0,this.focusContainer(),this.state.editingTextElement||t.preventDefault();let r=!1,n=typeof window===void 0?!1:/Linux/.test(window.navigator.platform);xe(this.interactiveCanvas,De.GRABBING);let{clientX:i,clientY:a}=t,l=td(d=>{let m=i-d.clientX,c=a-d.clientY;if(i=d.clientX,a=d.clientY,n&&!r&&(Math.abs(m)>1||Math.abs(c)>1)){r=!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,dn||(this.state.viewModeEnabled?xe(this.interactiveCanvas,De.GRAB):At(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,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.selectedLinearElement?.isEditing&&!We(a[0])&&!(this.state.selectedLinearElement&&this.state.selectedLinearElement.hoverPointIndex!==-1)){let l=uI(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=hI(zi(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=tf(qH(r.resize.handleType,a,i,r.origin.x,r.origin.y)),a.length===1&&Zt(a[0])&&a[0].points.length===2&&(r.resize.arrowDirection=JH(r.resize.handleType,a[0]));else{if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement,u=Se.handlePointerDown(t,this,this.store,r.origin,p,this.scene);if(u.hitElement&&(r.hit.element=u.hitElement),u.linearElementEditor&&this.setState({selectedLinearElement:u.linearElementEditor}),u.didAddPoint)return!0}let l=this.getElementsAtPosition(r.origin.x,r.origin.y,{includeLockedElements:!0}),s=l.filter(p=>!p.locked),d=this.getElementAtPosition(r.origin.x,r.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])?r.hit.element=null:r.hit.element=r.hit.element??this.getElementAtPosition(r.origin.x,r.origin.y),this.hitLinkElement=this.getElementLinkAtPosition(r.origin,d),this.hitLinkElement)return!0;if(this.state.croppingElementId&&r.hit.element?.id!==this.state.croppingElementId&&this.finishImageCropping(),r.hit.element&&this.getElementLinkAtPosition({x:r.origin.x,y:r.origin.y},r.hit.element))return!1;r.hit.allHitElements=s;let m=r.hit.element,c=r.hit.allHitElements.some(p=>this.isASelectedElement(p));if((m===null||!c)&&!t.shiftKey&&!r.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.selectedElementIds[m.id]||(r.hit.wasAddedToSelection=!0),this.setState(p=>({...VH(p,m),previousSelectedElementIds:this.state.selectedElementIds}))),!1;this.state.selectedElementIds[m.id]||(this.state.editingGroupId&&!dI(m,this.state.editingGroupId)&&this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),!c&&!r.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)}),Kt(m))nI(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=>bl(this.scene.getNonDeletedElements(),w)).filter(w=>Kt(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=>bl(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})),{...mo({editingGroupId:p.editingGroupId,selectedElementIds:u},this.scene.getNonDeletedElements(),p,this),showHyperlinkPopup:m.link||Ar(m)?"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);ZT(a)&&(l=a,n=a.x+a.width/2,i=a.y+a.height/2),this.startTextEditing({sceneX:n,sceneY:i,insertAtParentCenter:!t.altKey,container:l,autoEdit:!1}),zt(this.interactiveCanvas),this.state.activeTool.locked||this.setState({activeTool:Vo(this.state,{type:"selection"})})});I(this,"handleFreeDrawElementOnPointerDown",(t,r,n)=>{let[i,a]=nt(n.origin.x,n.origin.y,null),l=this.getTopLayerFrameAtSceneCoords({x:i,y:a}),s=t.pressure===.5,d=nH({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:[ne(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=rf(n.origin,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom);this.setState({newElement:d,startBoundElement:m,suggestedBindings:[]})});I(this,"insertIframeElement",({sceneX:t,sceneY:r,width:n,height:i})=>{let[a,l]=nt(t,r,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=iH({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]=nt(t,r,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),l=qd(n);if(!l)return;l.error instanceof URIError&&this.setToast({message:g("toast.unrecognizedLinkFormat"),closable:!0});let s=YT({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",async({sceneX:t,sceneY:r,addToFrameUnderCursor:n=!0,imageFile:i})=>{let[a,l]=nt(t,r,this.lastPointerDownEvent?.[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),s=n?this.getTopLayerFrameAtSceneCoords({x:a,y:l}):null,d=100/this.state.zoom.value,m=sH({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,r,n)=>{if(this.state.multiElement){let{multiElement:i}=this.state;if(i.type==="line"&&eI(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&&nn(ne(n.origin.x-a,n.origin.y-l),s)<Jg){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]=nt(n.origin.x,n.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]=r==="arrow"?[s,d]:[null,null],p=r==="arrow"?aH({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===Pr.round?{type:Kd.PROPORTIONAL_RADIUS}:null,startArrowhead:m,endArrowhead:c,locked:!1,frameId:l?l.id:null,elbowed:this.state.currentItemArrowType===Pr.elbow,fixedSegments:this.state.currentItemArrowType===Pr.elbow?[]:null}):cH({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:Kd.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,ne(0,0)]});let u=rf(n.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,r)=>{let[n,i]=nt(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=YT({type:"embeddable",...l}):s=lH({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]=nt(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,...Mr},l=r===Co.magicframe?WT(a):rH(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)||df(n)&&this.elementsPendingErasure.has(n.containerId)?(t=!0,sn(n,{isDeleted:!0})):n);this.elementsPendingErasure=new Set,t&&(this.store.scheduleCapture(),this.scene.replaceAllElements(r))});I(this,"initializeImage",async(t,r)=>{if(!Nl(r))throw new Error(g("errors.unsupportedFileType"));let n=r.type;if(xe(this.interactiveCanvas,"wait"),n===Lr.svg)try{r=xm(oI(await r.text()),r.name)}catch(s){throw console.warn(s),new Error(g("errors.svgImageInsertError"))}let i=await(this.props.generateIdForFile?.(r)||m1(r));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{r=await Fl(r,{maxWidthOrHeight:Ez})}catch(s){console.error("Error trying to resizing image file on insertion",s)}if(r.size>AT)throw new Error(g("errors.fileTooBig",{maxSize:`${Math.trunc(AT/1024/1024)}MB`}))}let l=this.files[i]?.dataURL||await bm(r);return new Promise(async(s,d)=>{try{let m=this.getLatestInitializedImageElement(t,i);if(this.addMissingFiles([{mimeType:n,id:i,dataURL:l,created:Date.now(),lastRetrieved:Date.now()}]),!this.imageCache.get(i)){this.addNewImagesToImageCache();let{erroredFiles:p}=await this.updateImageCache([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,r)=>{let n=this.scene.getElement(t.id)??t;return sn(n,{fileId:r})});I(this,"insertImageElement",async(t,r)=>{if(!this.isToolSupported("image")){this.setState({errorMessage:g("errors.imageToolNotSupported")});return}this.scene.insertElement(t);try{let n=await this.initializeImage(t,r),i=this.scene.getElementsIncludingDeleted().map(a=>a.id===n.id?n:a);return this.updateScene({captureUpdate:mt.IMMEDIATELY,elements:i,appState:{selectedElementIds:ye({[n.id]:!0},this.state)}}),n}catch(n){return this.store.scheduleAction(mt.NEVER),this.scene.mutateElement(t,{isDeleted:!0}),this.actionManager.executeAction(wt),this.setState({errorMessage:n.message||g("errors.imageInsertError")}),null}});I(this,"onImageAction",async()=>{try{let t=this.state.width/2+this.state.offsetLeft,r=this.state.height/2+this.state.offsetTop,{x:n,y:i}=Fe({clientX:t,clientY:r},this.state),a=await Ml({description:"Image",extensions:Object.keys(vz)});await this.createImageElement({sceneX:n,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:"selection"})},()=>{this.actionManager.executeAction(wt)})}});I(this,"getImageNaturalDimensions",(t,r)=>{let n=Math.max(this.state.height-120,160),i=Math.min(n,Math.floor(this.state.height*.5)/this.state.zoom.value),a=Math.min(r.naturalHeight,i),l=a*(r.naturalWidth/r.naturalHeight),s=t.x+t.width/2-l/2,d=t.y+t.height/2-a/2;return{x:s,y:d,width:l,height:a,crop:null}});I(this,"updateImageCache",async(t,r=this.files)=>{let{updatedFiles:n,erroredFiles:i}=await EH({imageCache:this.imageCache,fileIds:t.map(a=>a.fileId),files:r});return i.size&&(this.store.scheduleAction(mt.NEVER),this.scene.replaceAllElements(t.map(a=>ul(a)&&i.has(a.fileId)?sn(a,{status:"error"}):a))),{updatedFiles:n,erroredFiles:i}});I(this,"addNewImagesToImageCache",async(t=xH(this.scene.getNonDeletedElements()),r=this.files)=>{let n=t.filter(i=>!i.isDeleted&&!this.imageCache.has(i.fileId));if(n.length){let{updatedFiles:i}=await this.updateImageCache(n,r);if(i.size)for(let a of n)i.has(a.fileId)&&fl.delete(a);i.size&&this.scene.triggerUpdate()}});I(this,"scheduleImageRefresh",uz(()=>{this.addNewImagesToImageCache()},Tz));I(this,"updateBindingEnabledOnPointerMove",t=>{let r=oH(t);this.state.isBindingEnabled!==r&&this.setState({isBindingEnabled:r})});I(this,"maybeSuggestBindingAtCursor",(t,r)=>{let n=rf(t,this.scene.getNonDeletedElements(),this.scene.getNonDeletedElementsMap(),this.state.zoom,!1,r);this.setState({suggestedBindings:n!=null?[n]:[]})});I(this,"handleInteractiveCanvasRef",t=>{t!==null?(this.interactiveCanvas=t,this.interactiveCanvas.addEventListener(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:r,fileHandle:n}=await g1(t),{x:i,y:a}=Fe(t,this.state);try{if(Nl(r)&&this.isToolSupported("image")){if(r?.type===Lr.png||r?.type===Lr.svg)try{let s=await Bl(r,this.state,this.scene.getElementsIncludingDeleted(),n);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:r});return}}catch(s){return this.setState({isLoading:!1,errorMessage:s.message})}let l=t.dataTransfer.getData(Lr.excalidrawlib);if(l&&typeof l=="string"){try{let s=d1(l);this.addElementsFromPasteOrLibrary({elements:xc(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&&uf(s,this.props.validateEmbeddable)&&(/^(http|https):\/\/[^\s/$.?#].[^\s]*$/.test(s)||qd(s)?.type==="video")){let d=this.insertEmbeddableElement({sceneX:i,sceneY:a,link:Qg(s)});d&&(this.store.scheduleCapture(),this.setState({selectedElementIds:{[d.id]:!0}}))}}});I(this,"loadFileToCanvas",async(t,r)=>{t=await b1(t);try{let n=this.scene.getElementsIncludingDeleted(),i;try{i=await gm(t,this.state,n,r)}catch(a){let l=a instanceof $f;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===Lr.excalidraw?(wI(n.concat(i.data.elements)),this.store.scheduleMicroAction({action:mt.NEVER,elements:n,appState:void 0}),this.setState({isLoading:!0}),this.syncActionResult({...i.data,appState:{...i.data.appState||this.state,isLoading:!1},replaceFiles:!0,captureUpdate:mt.IMMEDIATELY})):i.type===Lr.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!==an.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",d=this.excalidrawContainerRef.current,{top:m,left:c}=d.getBoundingClientRect(),p=t.clientX-c,u=t.clientY-m;re("contextMenu","openContextMenu",s),this.setState({...i&&!this.state.selectedElementIds[i.id]?{...this.state,...mo({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,r,n=!0)=>{let i=this.state.selectionElement,a=t.lastCoords;if(i&&this.state.activeTool.type!=="eraser"){gI({newElement:i,elementType:this.state.activeTool.type,originX:t.origin.x,originY:t.origin.y,x:a.x,y:a.y,width:Oi(t.origin.x,a.x),height:Oi(t.origin.y,a.y),shouldMaintainAspectRatio:dl(r),shouldResizeFromCenter:!1,scene:this.scene,zoom:this.state.zoom.value,informMutation:!1});return}let l=this.state.newElement;if(!l)return;let[s,d]=nt(a.x,a.y,r[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(r,[l]);let{snapOffset:p,snapLines:u}=vw(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:d-t.originInGrid.y},this.scene.getNonDeletedElementsMap());s+=p.x,d+=p.y,this.setState({snapLines:u}),gI({newElement:l,elementType:this.state.activeTool.type,originX:t.originInGrid.x,originY:t.originInGrid.y,x:s,y:d,width:Oi(t.originInGrid.x,s),height:Oi(t.originInGrid.y,d),shouldMaintainAspectRatio:cn(l)?!dl(r):dl(r),shouldResizeFromCenter:MT(r),zoom:this.state.zoom.value,scene:this.scene,widthAspectRatio:c,originOffset:this.state.originSnapOffset,informMutation:n}),this.setState({newElement:l}),(this.state.activeTool.type===Co.frame||this.state.activeTool.type===Co.magicframe)&&this.setState({elementsToHighlight:bf(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]=nt(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&&cn(s)){let d=t.originalElements.get(s.id),m=ul(s)&&this.imageCache.get(s.fileId)?.image;if(d&&cn(d)&&m&&!(m instanceof Promise)){let[c,p]=nt(i.x,i.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y};this.maybeCacheReferenceSnapPoints(r,[s]);let{snapOffset:f,snapLines:b}=Dh([s],[d],this,r,u,n);this.scene.mutateElement(s,NH(s,this.scene.getNonDeletedElementsMap(),n,m.naturalWidth,m.naturalHeight,a+f.x,l+f.y,r.shiftKey?d.width/d.height:void 0)),af(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(c=>Kt(c)),a=t.resize.handleType;if(i.length>0&&a==="rotation"||n.length===1&&We(n[0])||this.state.croppingElementId)return!1;this.setState({isResizing:a&&a!=="rotation",isRotating:a==="rotation",activeEmbeddable:null});let l=t.lastCoords,[s,d]=nt(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(c=>{nI(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]=nt(l.x,l.y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),u={x:c-t.originInGrid.x,y:p-t.originInGrid.y},f=[...t.originalElements.values()];this.maybeCacheReferenceSnapPoints(r,n);let{snapOffset:b,snapLines:x}=Dh(n,j(f,this.state),this,r,u,a);s+=b.x,d+=b.y,this.setState({snapLines:x})}if(QH(t.originalElements,a,n,this.scene,qg(r),MT(r),n.some(c=>cn(c))?!dl(r):dl(r),s,d,t.resize.center.x,t.resize.center.y)){let c=lf(n,this.scene.getNonDeletedElementsMap(),this.state.zoom),p=new Set;return i.forEach(u=>{bf(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 r=[];return r.push(rc,oc),t==="canvas"?this.state.viewModeEnabled?[...r,ic,ei,Ch,ti]:[ru,Ye,rc,oc,nc,Ye,qm,XE,Ye,ic,nu,ei,Ch,ti]:(r.push(nc),this.state.viewModeEnabled?[Qn,...r]:[Ye,tc,Qn,ru,Ye,ew,tw,ow,Ye,wh,Ye,...r,Ye,Xp,Kp,Ye,jp,cw,lu,su,AE,qp,Ye,eu,Ye,Km,Zm,$m,jm,Ye,tu,ou,Ye,wi,Ye,ka,uc,Ye,Jm,Ma,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:r,deltaY:n}=t;if(t.metaKey||t.ctrlKey){let i=Math.sign(n),a=Nz*100,l=Math.abs(n),s=n;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-(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:pe.pointers})});I(this,"resetShouldCacheIgnoreZoomDebounced",NT(()=>{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:d,offsetTop:m,offsetLeft:c}=this.state;if(n===s&&i===d&&a===c&&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=$o(),{excalidrawAPI:n,viewModeEnabled:i=!1,zenModeEnabled:a=!1,gridModeEnabled:l=!1,objectsSnapModeEnabled:s=!1,theme:d=r.theme,name:m=`${g("labels.untitled")}-${FT()}`}=t;if(this.state={...r,theme:d,isLoading:!0,...this.getCanvasOffsets(),viewModeEnabled:i,zenModeEnabled:a,objectsSnapModeEnabled:s,gridModeEnabled:l??r.gridModeEnabled,name:m,width:window.innerWidth,height:window.innerHeight},this.id=gz(),this.library=new xy(this),this.actionManager=new Wc(this.syncActionResult,()=>this.state,()=>this.scene.getElementsIncludingDeleted(),this),this.scene=new bI,this.canvas=document.createElement("canvas"),this.rc=hz.canvas(this.canvas),this.renderer=new ja(this.scene),this.visibleElements=[],this.store=new oG(this),this.history=new Va(this.store),n){let c={updateScene:this.updateScene,mutateElement:this.mutateElement,updateLibrary:this.library.updateLibrary,addFiles:this.addFiles,resetScene:this.resetScene,getSceneElementsIncludingDeleted:this.getSceneElementsIncludingDeleted,getSceneElementsMapIncludingDeleted:this.getSceneElementsMapIncludingDeleted,history:{clear:this.resetHistory},scrollToContent:this.scrollToContent,getSceneElements:this.getSceneElements,getAppState:()=>this.state,getFiles:()=>this.files,getName:this.getName,registerAction:p=>{this.actionManager.registerAction(p)},refresh:this.refresh,setToast:this.setToast,id:this.id,setActiveTool:this.setActiveTool,setCursor:this.setCursor,resetCursor:this.resetCursor,updateFrameRendering:this.updateFrameRendering,toggleSidebar:this.toggleSidebar,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(c):console.error("excalidrawAPI should be a function!")}this.excalidrawContainerValue={container:this.excalidrawContainerRef.current,id:this.id},this.fonts=new Zo(this.scene),this.history=new Va(this.store),this.actionManager.registerAll(ss),this.actionManager.registerAction(iw(this.history)),this.actionManager.registerAction(aw(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($d).includes(i)&&Tf.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),Hi(t)))return;let r=this.getHTMLIFrameElement(t);if(r?.contentWindow){if(r.src.includes("youtube")){let n=Tf.get(t.id);switch(n||(Tf.set(t.id,$d.UNSTARTED),r.contentWindow.postMessage(JSON.stringify({event:"listening",id:t.id}),"*")),n){case $d.PLAYING:case $d.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=>Ar(a)&&this.embedsValidationStatus.get(a.id)===!0||Hi(a));return ue(aG,{children:i.map(a=>{let{x:l,y:s}=jd({sceneX:a.x,sceneY:a.y},this.state),d=JT(a,r,n,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(Hi(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:()=>tI(`
18
26
  <style>
19
27
  html, body {
20
28
  width: 100%;
21
29
  height: 100%;
22
- color: ${this.state.theme===de.DARK?"white":"black"};
30
+ color: ${this.state.theme===Zd.DARK?"white":"black"};
23
31
  }
24
32
  body {
25
33
  display: flex;
@@ -86,7 +94,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),xe("ai","me
86
94
  </svg>
87
95
  </div>
88
96
  <div>Generating...</div>
89
- `)};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:()=>Xp(`
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:()=>tI(`
90
98
  <style>
91
99
  html, body {
92
100
  height: 100%;
@@ -96,7 +104,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),xe("ai","me
96
104
  flex-direction: column;
97
105
  align-items: center;
98
106
  justify-content: center;
99
- color: ${Io.red[3]};
107
+ color: ${bz.red[3]};
100
108
  }
101
109
  h1, h3 {
102
110
  margin-top: 0;
@@ -105,7 +113,7 @@ TTD mermaid definition render errror: ${P.message}`,"color: yellow"),xe("ai","me
105
113
  </style>
106
114
  <h1>Error!</h1>
107
115
  <h3>${x}</h3>
108
- `)}}}else p=ni(Qs(a.link||""));let u=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="active",g=this.state.activeEmbeddable?.element===a&&this.state.activeEmbeddable?.state==="hover";return Be("div",{className:y5("excalidraw__embeddable-container",{"is-hovered":g}),style:{transform:c?`translate(${l-this.state.offsetLeft}px, ${s-this.state.offsetTop}px) scale(${t})`:"none",display:c?"block":"none",opacity:Yb(a,ti(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?p1:1),"--embeddable-radius":`${xc(Math.min(a.width,a.height),a)}px`},children:tp("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?Hn.enabled:Hn.disabled},children:[g&&Be("div",{className:"excalidraw__embeddable-hint",children:f("buttons.embeddableInteractionButton")}),Be("div",{className:"excalidraw__embeddable__outer",style:{padding:`${a.strokeWidth}px`},children:(Ft(a)?this.props.renderEmbeddable?.(a,this.state):null)??Be("iframe",{ref:b=>this.cacheEmbeddableRef(a,b),className:"excalidraw__embeddable",srcDoc:p?.type==="document"?p.srcdoc(this.state.theme):void 0,src:p?.type!=="document"?p?.link??"":void 0,scrolling:"no",referrerPolicy:"no-referrer-when-downgrade",title:"Excalidraw Embedded Content",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sandbox:`${p?.sandbox?.allowSameOrigin?"allow-same-origin":""} allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-downloads`})})]})},a.id)})})}toggleOverscrollBehavior(t){document.documentElement.style.overscrollBehaviorX=t.type==="pointerenter"?"none":"auto"}render(){let t=this.scene.getSelectedElements(this.state),{renderTopRightUI:r,renderCustomStats:n}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id,pendingImageElementId:this.state.pendingImageElementId});this.visibleElements=l;let s=this.scene.getNonDeletedElementsMap(),c="setPointerCapture"in HTMLElement.prototype?!1:this.state.selectionElement||this.state.newElement||this.state.selectedElementsAreBeingDragged||this.state.resizingElement||this.state.activeTool.type==="laser"&&this.state.cursorButton==="down",m=t[0];return Be("div",{className:y5("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":c?Hn.disabled:Hn.enabled,"--right-sidebar-width":"302px"},ref:this.excalidrawContainerRef,onDrop:this.handleAppOnDrop,tabIndex:0,onKeyDown:this.props.handleKeyboardGlobally?void 0:this.onKeyDown,onPointerEnter:this.toggleOverscrollBehavior,onPointerLeave:this.toggleOverscrollBehavior,children:Be(T5.Provider,{value:this,children:Be(C5.Provider,{value:this.props,children:Be(bf.Provider,{value:this.excalidrawContainerValue,children:Be(ff.Provider,{value:this.device,children:Be(yf.Provider,{value:this.setAppState,children:Be(Ef.Provider,{value:this.state,children:tp(xf.Provider,{value:this.scene.getNonDeletedElements(),children:[tp(vf.Provider,{value:this.actionManager,children:[Be(s5,{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:Br().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}),Be("div",{className:"excalidraw-textEditorContainer"}),Be("div",{className:"excalidraw-contextMenuContainer"}),Be("div",{className:"excalidraw-eye-dropper-container"}),Be(m5,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&Be(E2,{element:m,elementsMap:s,setAppState:this.setAppState,onLinkOpen:this.props.onLinkOpen,setToast:this.setToast,updateEmbedValidationStatus:this.updateEmbedValidationStatus},m.id),this.props.aiEnabled!==!1&&t.length===1&&ec(m)&&Be(Ig,{element:m,elementsMap:a,children:Be(Qm,{title:f("labels.convertToCode"),icon:nd,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),t.length===1&&Xn(m)&&m.customData?.generationData?.status==="done"&&tp(Ig,{element:m,elementsMap:a,children:[Be(Qm,{title:f("labels.copySource"),icon:ca,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),Be(Qm,{title:"Enter fullscreen",icon:pE,checked:!1,onChange:()=>{let d=this.getHTMLIFrameElement(m);if(d)try{d.requestFullscreen(),this.setState({activeEmbeddable:{element:m,state:"active"},selectedElementIds:{[m.id]:!0},newElement:null,selectionElement:null})}catch(p){console.warn(p),this.setState({errorMessage:"Couldn't enter fullscreen"})}}})]}),this.state.toast!==null&&Be(E5,{message:this.state.toast.message,onClose:()=>this.setToast(null),duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&Be(fw,{items:this.state.contextMenu.items,top:this.state.contextMenu.top,left:this.state.contextMenu.left,actionManager:this.actionManager,onClose:d=>{this.setState({contextMenu:null},()=>{this.focusContainer(),d?.()})}}),Be(df,{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:Sn(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&Be(b5,{appState:this.state,scale:window.devicePixelRatio,rc:this.rc,elementsMap:a,allElementsMap:s,renderConfig:{imageCache:this.imageCache,isExporting:!1,renderGrid:!1,canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:null}}),Be(cf,{containerRef:this.excalidrawContainerRef,canvas:this.interactiveCanvas,elementsMap:a,visibleElements:l,allElementsMap:s,selectedElements:t,sceneNonce:i,selectionNonce:this.state.selectionElement?.versionNonce,scale:window.devicePixelRatio,appState:this.state,device:this.device,renderInteractiveSceneCallback:this.renderInteractiveSceneCallback,handleCanvasRef:this.handleInteractiveCanvasRef,onContextMenu:this.handleCanvasContextMenu,onPointerMove:this.handleCanvasPointerMove,onPointerUp:this.handleCanvasPointerUp,onPointerCancel:this.removePointer,onTouchMove:this.handleTouchMove,onPointerDown:this.handleCanvasPointerDown,onDoubleClick:this.handleCanvasDoubleClick}),this.state.userToFollow&&Be(xw,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames()]}),this.renderEmbeddables()]})})})})})})})})}setPlugins(t){Object.assign(this.plugins,t)}async onMagicFrameGenerate(t,r){let n=this.plugins.diagramToCode?.generate;if(!n){this.setState({errorMessage:"No diagram to code plugin found"});return}let i=pc(this.scene.getNonDeletedElements(),t).filter(l=>!ec(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),xe("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}}),xe("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(xe("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){xe("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"&&(Jo(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=>{Ar(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),pn.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,mt()||Ue()){let r=this.setState.bind(this);Object.defineProperties(window.h,{state:{configurable:!0,get:()=>this.state},setState:{configurable:!0,value:(...n)=>this.setState(...n)},app:{configurable:!0,value:this},history:{configurable:!0,value:this.history},store:{configurable:!0,value:this.store},fonts:{configurable:!0,value:this.fonts}})}this.store.onStoreIncrementEmitter.on(r=>{this.history.record(r.elementsChange,r.appStateChange)}),this.scene.onUpdate(this.triggerRender),this.addEventListeners(),this.props.autoFocus&&this.excalidrawContainerRef.current&&this.focusContainer(),mt()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),qa&&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),Yf()&&!eb()&&this.setState({errorMessage:Be(pw,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new dn,this.fonts=new un(this.scene),this.renderer=new cs(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(),pn.destroy(),No.destroy(),clearTimeout(Nn),ze.clearCache(),lt.clearCache(),Nn=0,document.documentElement.style.overscrollBehaviorX=""}removeEventListeners(){this.onRemoveEventListenersEmitter.trigger()}addEventListeners(){this.removeEventListeners(),this.props.handleKeyboardGlobally&&this.onRemoveEventListenersEmitter.once(Ye(document,"keydown",this.onKeyDown,!1)),this.onRemoveEventListenersEmitter.once(Ye(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Ye(window,"message",this.onWindowMessage,!1),Ye(document,"pointerup",this.removePointer,{passive:!1}),Ye(document,"copy",this.onCopy,{passive:!1}),Ye(document,"keyup",this.onKeyUp,{passive:!0}),Ye(document,"pointermove",this.updateCurrentCursorPosition,{passive:!1}),Ye(document.fonts,"loadingdone",t=>{let r=t.fontfaces;this.fonts.onLoaded(r)},{passive:!1}),Ye(document,"gesturestart",this.onGestureStart,!1),Ye(document,"gesturechange",this.onGestureChange,!1),Ye(document,"gestureend",this.onGestureEnd,!1),Ye(window,"focus",()=>{this.maybeCleanupAfterMissingPointerUp(null),this.triggerRender(!0)},{passive:!1})),!this.state.viewModeEnabled&&(this.onRemoveEventListenersEmitter.once(Ye(document,"fullscreenchange",this.onFullscreenChange,{passive:!1}),Ye(document,"paste",this.pasteFromClipboard,{passive:!1}),Ye(document,"cut",this.onCut,{passive:!1}),Ye(window,"resize",this.onResize,!1),Ye(window,"unload",this.onUnload,!1),Ye(window,"blur",this.onBlur,!1),Ye(this.excalidrawContainerRef.current,"wheel",this.handleWheel,{passive:!1}),Ye(this.excalidrawContainerRef.current,"dragover",this.disableEvent,!1),Ye(this.excalidrawContainerRef.current,"drop",this.disableEvent,!1)),this.props.detectScroll&&this.onRemoveEventListenersEmitter.once(Ye(S1(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&&no(this.state)&&this.setState({activeTool:He(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&yh(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(),no(r)&&!no(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===de.DARK),this.state.editingLinearElement&&!this.state.selectedElementIds[this.state.editingLinearElement.elementId]&&setTimeout(()=>{this.state.editingLinearElement&&this.actionManager.executeAction(yo)}),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&&Jn(this.state)&&_r(s,!1)&&gl(s,this.state,rn(j.getPointAtIndexGlobalCoordinates(s,-1,a)),this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.store.commit(i,this.state),this.state.isLoading||(this.props.onChange?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){ys=!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 w0(p)}}catch(u){let g=u.message;return u.cause==="FETCH_ERROR"?g=f("errors.failedToFetchImage"):u.cause==="UNSUPPORTED"&&(g=f("errors.unsupportedFileType")),{errorMessage:g}}})),s=i,c=!1,m={};for(let p of l)if(p.file){let u=this.createImageElement({sceneX:n,sceneY:s}),g=await this.insertImageElement(u,p.file);g&&(c||(c=!0,s-=g.height/2),B(g,{y:s},!1),s=u.y+u.height+25,m[u.id]=!0)}this.setState({selectedElementIds:Me(m,this.state)});let d=l.find(p=>!!p.errorMessage);d&&d.errorMessage&&this.setState({errorMessage:d.errorMessage})}else{let a=t.filter(l=>l.type==="text");a.length&&this.addTextFromPaste(a.map(l=>l.value).join(`
116
+ `)}}}else p=qd(Gz(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:wT("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:WH(a,xf(a,this.scene.getNonDeletedElementsMap()),this.elementsPendingErasure,null,this.state.openDialog?.name==="elementLinkSelector"?Oz:1),"--embeddable-radius":`${fH(Math.min(a.width,a.height),a)}px`},children:Qd("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?Fi.enabled:Fi.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:(Ar(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:r,renderCustomStats:n}=this.props,i=this.scene.getSceneNonce(),{elementsMap:a,visibleElements:l}=this.renderer.getRenderableElements({sceneNonce:i,zoom:this.state.zoom,offsetLeft:this.state.offsetLeft,offsetTop:this.state.offsetTop,scrollX:this.state.scrollX,scrollY:this.state.scrollY,height:this.state.height,width:this.state.width,editingTextElement:this.state.editingTextElement,newElementId:this.state.newElement?.id});this.visibleElements=l;let s=this.scene.getNonDeletedElementsMap(),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=ze.get(no)?.type==="panel";return ue("div",{className:wT("excalidraw excalidraw-container",{"excalidraw--view-mode":this.state.viewModeEnabled||this.state.openDialog?.name==="elementLinkSelector","excalidraw--mobile":this.device.editor.isMobile}),style:{"--ui-pointerEvents":d?Fi.disabled:Fi.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(vI.Provider,{value:this,children:ue(TI.Provider,{value:this.props,children:ue(kf.Provider,{value:this.excalidrawContainerValue,children:ue(Sf.Provider,{value:this.device,children:ue(Pf.Provider,{value:this.setAppState,children:ue(Lf.Provider,{value:this.state,children:Qd(Mf.Provider,{value:this.scene.getNonDeletedElements(),children:[Qd(Af.Provider,{value:this.actionManager,children:[ue(iT,{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: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}),ue("div",{className:"excalidraw-textEditorContainer"}),ue("div",{className:"excalidraw-contextMenuContainer"}),ue("div",{className:"excalidraw-eye-dropper-container"}),ue(sT,{trails:[this.laserTrails,this.lassoTrail,this.eraserTrail]}),t.length===1&&this.state.openDialog?.name!=="elementLinkSelector"&&this.state.showHyperlinkPopup&&ue(OE,{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&&mf(m)&&ue(Vh,{element:m,elementsMap:a,children:ue(Vd,{title:g("labels.convertToCode"),icon:ts,checked:!1,onChange:()=>this.onMagicFrameGenerate(m,"button")})}),t.length===1&&Hi(m)&&m.customData?.generationData?.status==="done"&&Qd(Vh,{element:m,elementsMap:a,children:[ue(Vd,{title:g("labels.copySource"),icon:Cn,checked:!1,onChange:()=>this.onIframeSrcCopy(m)}),ue(Vd,{title:"Enter fullscreen",icon:G0,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(ET,{message:this.state.toast.message,onClose:this.handleToastClose,duration:this.state.toast.duration,closable:this.state.toast.closable}),this.state.contextMenu&&ue(vv,{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(Zg,{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:hr(this),canvasBackgroundColor:this.state.viewBackgroundColor,embedsValidationStatus:this.embedsValidationStatus,elementsPendingErasure:this.elementsPendingErasure,pendingFlowchartNodes:this.flowChartCreator.pendingNodes}}),this.state.newElement&&ue(bT,{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(Kg,{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(Iv,{width:this.state.width,height:this.state.height,userToFollow:this.state.userToFollow,onDisconnect:this.maybeUnfollowRemoteUser}),this.renderFrameNames(),this.state.activeLockedId&&ue(yT,{app:this,activeLockedId:this.state.activeLockedId}),c&&ue(ty,{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=MH(this.scene.getNonDeletedElements(),t).filter(l=>!mf(l));if(!i.length){r==="button"?(this.setState({errorMessage:"Cannot generate from an empty frame"}),re("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}}),re("ai","generate (start)","d2c");try{let{html:l}=await n({frame:t,children:i});if(re("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){re("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"&&(oo(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=>{ul(n)&&r[n.fileId]&&(this.imageCache.delete(n.fileId),fl.delete(n))})}async componentDidMount(){if(this.unmounted=!1,this.excalidrawContainerValue.container=this.excalidrawContainerRef.current,If()||yI()){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(),If()||(this.refreshViewportBreakpoints(),this.refreshEditorBreakpoints()),DT&&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),Iz()&&!OH()&&this.setState({errorMessage:ue(xv,{})})}componentWillUnmount(){window.launchQueue?.setConsumer(()=>{}),this.renderer.destroy(),this.scene.destroy(),this.scene=new bI,this.fonts=new Zo(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(),Yt.destroy(),clearTimeout(Dr),Ee.clearCache(),mo.clearCache(),Dr=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 r=t.fontfaces;this.fonts.onLoaded(r)},{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(Uz(this.excalidrawContainerRef.current),ee.SCROLL,this.onScroll,{passive:!1})))}componentDidUpdate(t,r){this.updateEmbeddables();let n=this.scene.getElementsIncludingDeleted(),i=this.scene.getElementsMapIncludingDeleted();!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&&bt(this.state)&&this.setState({activeTool:Vo(this.state,{type:"selection"})}),this.state.activeTool.type==="eraser"&&r.theme!==this.state.theme&&Dp(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(),bt(r)&&!bt(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===Zd.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?.(n,this.state,this.files),this.onChangeEmitter.trigger(n,this.state,this.files))}static resetTapTwice(){xl=!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 h1(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:n,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(`
109
117
 
110
- `),r)}}addTextFromPaste(t,r=!1){let{x:n,y:i}=$e({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:Ns,verticalAlign:sp,locked:!1},l=qe({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=kr(a.fontFamily),[c,,m]=Kp(this.state),d=Math.max(Math.min((m-c)*.5,800),200),p=10,u=i,g=r?[t]:t.split(`
111
- `),b=g.reduce((x,E,w)=>{let y=qn(E).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),I=Ht(y,l,s),S=I.width>d,_=S?Hi(y,l,d):y;I=S?Ht(_,l,s):I;let L=n-I.width/2,N=u-I.height/2,P=Vt({...a,x:L,y:N,text:_,originalText:y,lineHeight:s,autoResize:!S,frameId:v?v.id:null});x.push(P),u+=P.height+p}else g[w-1]?.trim()&&(u+=tb(a.fontSize,s)+p);return x},[]);b.length!==0&&(this.scene.insertElements(b),this.setState({selectedElementIds:Me(Object.fromEntries(b.map(x=>[x.id,!0])),this.state)}),!r&&b.length>1&&w5===!1&&!this.device.editor.isMobile&&(this.setToast({message:f("toast.pasteAsSingleElement",{shortcut:R("CtrlOrCmd+Shift+V")}),duration:5e3}),w5=!0),this.store.shouldCaptureIncrement())}handleTextWysiwyg(t,{isExistingElement:r=!1}){let n=this.scene.getElementsMapIncludingDeleted(),i=(a,l)=>{this.scene.replaceAllElements([...this.scene.getElementsIncludingDeleted().map(s=>s.id===t.id&&Z(s)?oe(s,{originalText:a,isDeleted:l??s.isDeleted,...jb(s,_t(s,n),n,a)}):s)])};lw({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:c}=zt({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,c-this.state.offsetTop]},onChange:tt(a=>{i(a,!1),Bp(t)&&at(t,this.scene.getNonDeletedElementsMap())}),onSubmit:tt(({viaKeyboard:a,nextOriginalText:l})=>{let s=!l.trim();if(i(l,s),!s&&a){let c=t.containerId?t.containerId:t.id;ki(()=>{this.setState(m=>({selectedElementIds:Me({...m.selectedElementIds,[c]:!0},m)}))})}s&&lc(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.shouldCaptureIncrement(),ki(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&Eo(this.interactiveCanvas,this.state),this.focusContainer()}),element:t,excalidrawContainer:this.excalidrawContainerRef.current,app:this,autoSelect:!this.device.isTouchScreen}),this.deselectElements(),i(t.originalText,!1)}deselectElements(){this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null})}getTextElementAtPosition(t,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&Z(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=this.getElementsAtPosition(t,r,n?.includeBoundTextElement,n?.includeLockedElements);if(i.length>1){if(n?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return zi({x:t,y:r,element:a,shape:Rr(a,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold()/2,frameNameBound:ne(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n=!1,i=!1){let a=[],l=this.scene.getNonDeletedElementsMap();return(n&&i?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(c=>(i||!c.locked)&&(n||!(Z(c)&&c.containerId)))).filter(c=>this.hitElement(t,r,c)).filter(c=>{let m=ti(c,l);return m&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?zp({x:t,y:r},m,l):!0}).filter(c=>Xn(c)?(a.push(c),!1):!0).concat(a)}getElementHitThreshold(){return Xf/this.state.zoom.value}hitElement(t,r,n,i=!0){if(i&&this.state.selectedElementIds[n.id]&&zc([n],this.state)){let l=Xb(n,this.scene.getNonDeletedElementsMap(),he(n)?0:this.getElementHitThreshold());if(vc(M(t,r),l))return!0}return W1(t,r,Hb(n,this.scene.getNonDeletedElementsMap()))?!0:zi({x:t,y:r,element:n,shape:Rr(n,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:ne(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 Dr(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]=We(n[l],this.scene.getNonDeletedElementsMap());if(ke(n[l])&&zi({x:t,y:r,element:n[l],shape:Rr(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 Dr(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=j.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;zi({x:r,y:n,element:a,shape:Rr(a,this.scene.getNonDeletedElementsMap())})?(l=j.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=j.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(te(a)?l===0||l===a.points.length-1:l>=0)||s?Le(this.interactiveCanvas,Se.POINTER):this.hitElement(r,n,a)&&(!te(a)||!(a.startBinding||a.endBinding))&&Le(this.interactiveCanvas,Se.MOVE)):this.hitElement(r,n,a)&&(!te(a)||!(a.startBinding||a.endBinding))&&Le(this.interactiveCanvas,Se.MOVE),this.state.selectedLinearElement.hoverPointIndex!==l&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,hoverPointIndex:l}}),j.arePointsEqual(this.state.selectedLinearElement.segmentMidPointHoveredCoords,s)||this.setState({selectedLinearElement:{...this.state.selectedLinearElement,segmentMidPointHoveredCoords:s}})}else Le(this.interactiveCanvas,Se.AUTO)}updateGestureOnPointerDown(t){Ae.pointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),Ae.pointers.size===2&&(Ae.lastCenter=fg(Ae.pointers),Ae.initialScale=this.state.zoom.value,Ae.initialDistance=bg(Array.from(Ae.pointers.values())))}initialPointerDownState(t){let r=$e(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=ye(n),c=n.findIndex(te)===0;return{origin:r,withCmdOrCtrl:t[T.CTRL_OR_CMD],originInGrid:rn(ht(r.x,r.y,t[T.CTRL_OR_CMD]||c?null:this.getEffectiveGridSize())),scrollbars:vg(uf,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((m,d)=>(m.set(d.id,uo(d)),m),new Map),resize:{handleType:!1,isResizing:!1,offset:{x:0,y:0},arrowDirection:"origin",center:{x:(l+i)/2,y:(s+a)/2}},hit:{element:null,allHitElements:[],wasAddedToSelection:!1,hasBeenDuplicated:!1,hasHitCommonBoundingBoxOfSelectedElements:this.isHittingCommonBoundingBoxOfSelectedElements(r,n)},drag:{hasOccurred:!1,offset:null},eventListeners:{onMove:null,onUp:null,onKeyUp:null,onKeyDown:null},boxSelection:{hasOccurred:!1}}}handleDraggingScrollBar(t,r){if(!(r.scrollbars.isOverEither&&!this.state.multiElement))return!1;pf=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=xm(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=tt(()=>{Ts=null,pf=!1,Eo(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 Ts=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]=ye(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:Bi(t)?eo.ADAPTIVE_RADIUS:eo.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){Yr({event:t,app:this,selectedElements:r})&&(n||!No.getReferenceSnapPoints())&&No.setReferenceSnapPoints(Vv(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){Yr({event:t,app:this,selectedElements:r})&&(n||!No.getVisibleGaps())&&No.setVisibleGaps(Gv(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return tt(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return tt(r=>{r.key===T.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return xm(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=$e(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=ht(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),g=this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index;if(g<0){let x=j.getSegmentMidpointHitCoords({...this.state.selectedLinearElement,segmentMidPointHoveredCoords:null},{x:p,y:u},this.state,this.scene.getNonDeletedElementsMap());g=x?j.getSegmentMidPointIndex(this.state.selectedLinearElement,this.state,x,this.scene.getNonDeletedElementsMap()):-1}let b=j.moveFixedSegment(this.state.selectedLinearElement,g,p,u,this.scene.getNonDeletedElementsMap());ki(()=>{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=rn(F0(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(no(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=ht(n.x,n.y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize());if(!t.drag.hasOccurred&&(this.state.activeTool.type==="arrow"||this.state.activeTool.type==="line")&&Gn(M(n.x,n.y),M(t.origin.x,t.origin.y))<Fn)return;if(t.resize.isResizing&&(t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeHandleCrop(t,r)||this.maybeHandleResize(t,r)))return!0;let c=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.editingLinearElement||this.state.selectedLinearElement;if(j.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,c)){let g=j.addMidpoint(this.state.selectedLinearElement,n,this,!r[T.CTRL_OR_CMD],c);if(!g)return;ki(()=>{this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...this.state.selectedLinearElement,pointerDownState:g.pointerDownState,selectedPointsIndices:g.selectedPointsIndices,segmentMidPointHoveredCoords:null}}),this.state.editingLinearElement&&this.setState({editingLinearElement:{...this.state.editingLinearElement,pointerDownState:g.pointerDownState,selectedPointsIndices:g.selectedPointsIndices,segmentMidPointHoveredCoords:null}})});return}else if(p.pointerDownState.segmentMidpoint.value!==null&&!p.pointerDownState.segmentMidpoint.added)return;let u=j.handlePointDragging(r,this,n.x,n.y,(g,b)=>{this.maybeSuggestBindingsForLinearElementAtCoords(g,b)},p,this.scene);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState({editingLinearElement:this.state.editingLinearElement?u:null,selectedLinearElement:u});return}}let m=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),d=this.state.editingLinearElement&&r.shiftKey&&this.state.editingLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!d&&this.state.activeTool.type!=="lasso"){let p=this.scene.getSelectedElements(this.state);if(p.every(x=>x.locked))return;let u=p.find(x=>ne(x)),g=this.getTopLayerFrameAtSceneCoords(n),b=g&&!u?g:null;if(this.state.frameToHighlight!==b&&ki(()=>{this.setState({frameToHighlight:b})}),t.drag.hasOccurred=!0,p.length>0&&!t.withCmdOrCtrl&&!this.state.editingTextElement&&this.state.activeEmbeddable?.state!=="active"){let x={x:n.x-t.origin.x,y:n.y-t.origin.y},E=[...t.originalElements.values()],w=r.shiftKey;if(w){let I=Math.abs(x.x),S=Math.abs(x.y),_=w&&I<S,L=w&&I>S;_&&(x.x=0),L&&(x.y=0)}if(this.state.croppingElementId){let I=this.scene.getNonDeletedElementsMap().get(this.state.croppingElementId);if(I&&he(I)&&I.crop!==null&&t.hit.element===I){let S=I.crop,_=Ar(I)&&this.imageCache.get(I.fileId)?.image;if(_&&!(_ instanceof Promise)){let L=b1(xp(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[N,P,F,K,U,q]=We(I,c),H=Ks(ce(M(N,P),M(U,q),I.angle)),G=Ks(ce(M(F,P),M(U,q),I.angle)),V=Ks(ce(M(N,K),M(U,q),I.angle)),ie=vp(yp(G,H)),$=vp(yp(V,H)),se=xp(Ep(L,ie),Ep(L,$)),be={...S,x:Tt(S.x-se[0]*Math.sign(I.scale[0]),0,_.naturalWidth-S.width),y:Tt(S.y-se[1]*Math.sign(I.scale[1]),0,_.naturalHeight-S.height)};B(I,{crop:be});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=Yv(E,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||z0(t,p,x,this.scene,y,r[T.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!te(p[0]))&&this.setState({suggestedBindings:ac(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let I=this.scene.getElementsIncludingDeleted(),S=t.hit.element,_=this.scene.getSelectedElements({selectedElementIds:this.state.selectedElementIds,includeBoundTextElement:!0,includeElementsInFrames:!0});S&&t.hit.wasAddedToSelection&&!_.find(U=>U.id===S.id)&&_.push(S);let L=new Map(_.map(U=>[U.id,U])),{newElements:N,elementsWithClones:P}=li({type:"in-place",elements:I,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:L,overrides:U=>{let q=t.originalElements.get(U.id);return q?{x:q.x,y:q.y,seed:q.seed}:{}},reverseOrder:!0});N.forEach(U=>{t.originalElements.set(U.id,U)});let F=this.props.onDuplicate?.(P,I),K=Ut(F||P,ee(N)).map(U=>L.has(U.id)?oe(U,{seed:Lr()}):U);this.scene.replaceAllElements(K),this.maybeCacheVisibleGaps(r,_,!0),this.maybeCacheReferenceSnapPoints(r,_,!0)}return}}if(this.state.selectionElement)t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey?(this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,r.shiftKey),this.setAppState({selectionElement:null})):this.maybeDragNewGenericElement(t,r);else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,g=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===g&&x[1]===b)){let w=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];B(p,{points:[...u,M(g,b)],pressures:w},!1),this.setState({newElement:p})}}else if(ae(p)){t.drag.hasOccurred=!0;let u=p.points,g=l-p.x,b=s-p.y;Ws(r)&&u.length===2&&({width:g,height:b}=Rp(p.x,p.y,n.x,n.y)),u.length===1?B(p,{points:[...u,M(g,b)]},!1):(u.length===2||u.length>1&&te(p))&&B(p,{points:[...u.slice(0,-1),M(g,b)]},!1,{isDragging:!0}),this.setState({newElement:p}),_r(p,!1)&&this.maybeSuggestBindingsForLinearElementAtCoords(p,[n],this.state.startBoundElement)}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.editingLinearElement)j.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&ze(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>lt({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let g=this.state.selectionElement?kb(p,this.state.selectionElement,this.scene.getNonDeletedElementsMap(),!1):[];this.setState(b=>{let x={...u&&b.selectedElementIds,...g.reduce((E,w)=>(E[w.id]=!0,E),{})};return t.hit.element&&(g.length?delete x[t.hit.element.id]:x[t.hit.element.id]=!0),b=u?b:{...b,selectedGroupIds:{},editingGroupId:null},{...lt({editingGroupId:b.editingGroupId,selectedElementIds:x},this.scene.getNonDeletedElements(),b,this),selectedLinearElement:g.length===1&&ae(g[0])?new j(g[0]):null,showHyperlinkPopup:g.length===1&&(g[0].link||Ft(g[0]))?"info":!1}})}}})}handlePointerMoveOverScrollbars(t,r){if(r.scrollbars.isOverHorizontal){let n=t.clientX,i=n-r.lastCoords.x;return this.translateCanvas({scrollX:this.state.scrollX-i/this.state.zoom.value}),r.lastCoords.x=n,!0}if(r.scrollbars.isOverVertical){let n=t.clientY,i=n-r.lastCoords.y;return this.translateCanvas({scrollY:this.state.scrollY-i/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return tt(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:Ni(x.snapLines,[]),originSnapOffset:null})),this.lassoTrail.endPath(),this.lastPointerMoveCoords=null,No.setReferenceSnapPoints(null),No.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);$n(x)&&x.boundElements?.filter(E=>E.type==="arrow").map(E=>p.get(E.id)).filter(E=>te(E)).forEach(E=>{E&&B(E,{},!0)})}if(this.state.editingLinearElement)if(!t.boxSelection.hasOccurred&&t.hit?.element?.id!==this.state.editingLinearElement.elementId)this.actionManager.executeAction(yo);else{let x=j.handlePointerUp(r,this.state.editingLinearElement,this.state,this.scene);x!==this.state.editingLinearElement&&this.setState({editingLinearElement:x,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let x=j.getElement(this.state.selectedLinearElement.elementId,this.scene.getNonDeletedElementsMap());x&&B(x,{},!0)}if(t.hit?.element?.id!==this.state.selectedLinearElement.elementId)this.scene.getSelectedElements(this.state).length>1&&this.setState({selectedLinearElement:null});else{let x=j.handlePointerUp(r,this.state.selectedLinearElement,this.state,this.scene),{startBindingElement:E,endBindingElement:w}=x,y=this.scene.getElement(x.elementId);_r(y)&&ic(y,E,w,p,this.scene),x!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:{...x,selectedPointsIndices:null},suggestedBindings:[]})}}if(this.missingPointerEventCleanupEmitter.clear(),window.removeEventListener("pointermove",t.eventListeners.onMove),window.removeEventListener("pointerup",t.eventListeners.onUp),window.removeEventListener("keydown",t.eventListeners.onKeyDown),window.removeEventListener("keyup",t.eventListeners.onKeyUp),this.state.pendingImageElementId&&this.setState({pendingImageElementId:null}),this.props?.onPointerUp?.(s,t),this.onPointerUpEmitter.trigger(this.state.activeTool,t,r),n?.type==="freedraw"){let x=$e(r,this.state),E=n.points,w=x.x-n.x,y=x.y-n.y;w===E[0][0]&&y===E[0][1]&&(y+=1e-4,w+=1e-4);let v=n.simulatePressure?[]:[...n.pressures,r.pressure];B(n,{points:[...E,M(w,y)],pressures:v,lastCommittedPoint:M(w,y)}),this.actionManager.executeAction(yo);return}if(he(n)){let x=n;try{this.initializeImageDimensions(x),this.setState({selectedElementIds:Me({[x.id]:!0},this.state)},()=>{this.actionManager.executeAction(yo)})}catch(E){console.error(E),this.scene.replaceAllElements(this.scene.getElementsIncludingDeleted().filter(w=>w.id!==x.id)),this.actionManager.executeAction(yo)}return}if(ae(n)){n.points.length>1&&this.store.shouldCaptureIncrement();let x=$e(r,this.state);!t.drag.hasOccurred&&n&&!l?(B(n,{points:[...n.points,M(x.x-n.x,x.y-n.y)]}),this.setState({multiElement:n,newElement:n})):t.drag.hasOccurred&&!l&&(Jn(this.state)&&_r(n,!1)&&gl(n,this.state,x,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements()),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(E=>({newElement:null})):(xo(this.interactiveCanvas),this.setState(E=>({newElement:null,activeTool:He(this.state,{type:"selection"}),selectedElementIds:Me({...E.selectedElementIds,[n.id]:!0},E),selectedLinearElement:new j(n)}))),this.scene.triggerUpdate());return}if(Z(n)){let x=Fi(qe({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<x&&B(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&ei(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==n.id),appState:{newElement:null},captureUpdate:A.NEVER});return}if(ne(n)){let x=Tb(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(Wi(this.scene.getElementsMapIncludingDeleted(),x,n,this.state))}if(n&&(B(n,bb(n)),this.scene.triggerUpdate()),t.drag.hasOccurred){let x=$e(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=ti(E,p);w&&E&&(cc(E,w,this.scene.getNonDeletedElementsMap())||(B(E,{groupIds:[]}),dc([E],this.scene.getNonDeletedElementsMap()),this.scene.triggerUpdate()))}}else{let E=this.getTopLayerFrameAtSceneCoords(x),w=this.scene.getSelectedElements(this.state),y=this.scene.getElementsMapIncludingDeleted(),v=I=>{if(I.length>0){for(let S of I){let _=S.groupIds.indexOf(this.state.editingGroupId);B(S,{groupIds:S.groupIds.slice(0,_)},!1)}y.forEach(S=>{S.groupIds.length&&Fe(y,S.groupIds[S.groupIds.length-1]).length<2&&B(S,{groupIds:[]},!1)}),this.setState({editingGroupId:null})}};if(E&&!this.state.selectedElementIds[E.id]){let I=w.filter(S=>S.frameId!==E.id&&Fp(S,y,this.state));this.state.editingGroupId&&v(I),y=Wi(y,I,E,this.state)}else if(!E&&this.state.editingGroupId){let I=w.filter(S=>S.frameId&&!Fp(S,y,this.state));v(I)}y=lr(y,this.state,this),this.scene.replaceAllElements(y)}}if(i&&this.store.shouldCaptureIncrement(),i&&ei(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(x=>x.id!==i.id),captureUpdate:A.NEVER}),t.resize.isResizing){let x=lr(this.scene.getElementsIncludingDeleted(),this.state,this),E=this.scene.getSelectedElements(this.state).filter(w=>ne(w));for(let w of E)x=mc(x,Yi(this.scene.getElementsIncludingDeleted(),w,this.state,p),w,this);this.scene.replaceAllElements(x)}let u=t.hit.element;this.state.selectedLinearElement?.elementId!==u?.id&&ae(u)&&this.scene.getSelectedElements(this.state).length===1&&this.setState({selectedLinearElement:new j(u)}),(!a||a&&(!u&&!d||u&&u.id!==a))&&this.finishImageCropping();let g=this.lastPointerDownEvent,b=this.lastPointerUpEvent||this.lastPointerMoveEvent;if(no(this.state)&&g&&b){if(this.eraserTrail.endPath(),Gn(M(g.clientX,g.clientY),M(b.clientX,b.clientY))===0){let E=$e({clientX:b.clientX,clientY:b.clientY},this.state);this.getElementsAtPosition(E.x,E.y).forEach(y=>this.elementsPendingErasure.add(y.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(u&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.editingLinearElement||!t.boxSelection.hasOccurred)&&(r.shiftKey&&!this.state.editingLinearElement?this.state.selectedElementIds[u.id]?fc(this.state,u)?this.setState(x=>{let E={...x.selectedElementIds};for(let w of u.groupIds.flatMap(y=>Fe(this.scene.getNonDeletedElements(),y)))delete E[w.id];return{selectedGroupIds:{...x.selectedElementIds,...u.groupIds.map(w=>({[w]:!1})).reduce((w,y)=>({...w,...y}),{})},selectedElementIds:Me(E,x)}}):this.state.selectedLinearElement?.isDragging||this.setState(x=>{let E={...x.selectedElementIds};delete E[u.id];let w=J(this.scene.getNonDeletedElements(),{selectedElementIds:E});return{...lt({editingGroupId:x.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:w.length===1&&ae(w[0])?new j(w[0]):x.selectedLinearElement}}):u.frameId&&this.state.selectedElementIds[u.frameId]?this.setState(x=>{let E={...x.selectedElementIds,[u.id]:!0};return delete E[u.frameId],(this.scene.getElement(u.frameId)?.groupIds??[]).flatMap(w=>Fe(this.scene.getNonDeletedElements(),w)).forEach(w=>{delete E[w.id]}),{...lt({editingGroupId:x.editingGroupId,selectedElementIds:E},this.scene.getNonDeletedElements(),x,this),showHyperlinkPopup:u.link||Ft(u)?"info":!1}}):this.setState(x=>({selectedElementIds:Me({...x.selectedElementIds,[u.id]:!0},x)})):this.setState(x=>({...lt({editingGroupId:x.editingGroupId,selectedElementIds:{[u.id]:!0}},this.scene.getNonDeletedElements(),x,this),selectedLinearElement:ae(u)&&x.selectedLinearElement?.elementId!==u.id?new j(u):x.selectedLinearElement}))),this.state.activeTool.type!=="lasso"&&!(u&&te(u))&&!t.drag.hasOccurred&&!this.state.isResizing&&(u&&Y1({x:t.origin.x,y:t.origin.y,element:u,shape:Rr(u,this.scene.getNonDeletedElementsMap()),threshold:this.getElementHitThreshold(),frameNameBound:ne(u)?this.frameNameBoundsCache.get(u):null},p)||!u&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.editingLinearElement?this.setState({editingLinearElement:null}):this.setState({selectedElementIds:Me({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),Le(this.interactiveCanvas,Se.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(x=>({selectedElementIds:Me({...x.selectedElementIds,[n.id]:!0},x),showHyperlinkPopup:Ft(n)&&!n.link?"editor":x.showHyperlinkPopup})),(s.type!=="selection"||ze(this.scene.getNonDeletedElements(),this.state)||!Je(this.state.previousSelectedElementIds,this.state.selectedElementIds))&&this.store.shouldCaptureIncrement(),t.drag.hasOccurred||c||m||d){let x=this.scene.getSelectedElements(this.state).filter(ae);Qn(x,this.scene.getNonDeletedElementsMap(),this.scene.getNonDeletedElements(),this.scene,Jn(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(xo(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:He(this.state,{type:"selection"})})):this.setState({newElement:null,suggestedBindings:[]}),u&&this.lastPointerUpEvent&&this.lastPointerDownEvent&&this.lastPointerUpEvent.timeStamp-this.lastPointerDownEvent.timeStamp<300&&Ae.pointers.size<=1&&Oi(u)&&this.isIframeLikeElementCenter(u,this.lastPointerUpEvent,t.origin.x,t.origin.y)&&this.handleEmbeddableCenterClick(u)})}clearSelection(t){this.setState(r=>({selectedElementIds:Me({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&Ki(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:Me({},this.state),activeEmbeddable:null,previousSelectedElementIds:this.state.selectedElementIds})}getTextWysiwygSnappedToCenterPosition(t,r,n,i){if(i){let a=i.x+i.width/2,l=i.y+i.height/2,s=nc(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<Zf){let{x:d,y:p}=zt({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=na.find(r=>r.code===this.props.langCode)||pr;await Wc(t),this.setAppState({})}},K8=()=>{(mt()||Ue())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(Pr(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};K8();var S5=gf;import{useEffect as X8,useState as $8}from"react";import{jsx as j8}from"react/jsx-runtime";var k5=e=>{let[o,t]=$8(!0);return X8(()=>{let r=async()=>{await Wc(n),t(!1)},n=na.find(i=>i.code===e.langCode)||pr;r()},[e.langCode]),o?j8(vm,{theme:e.theme}):e.children};import q8 from"clsx";import{jsx as M5}from"react/jsx-runtime";var L5=({children:e})=>{let{FooterCenterTunnel:o}=Ke(),t=Re();return M5(o.In,{children:M5("div",{className:q8("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},J8=L5;L5.displayName="FooterCenter";import Q8 from"clsx";import{jsx as tA,jsxs as oA}from"react/jsx-runtime";var A5=({isCollaborating:e,onSelect:o,...t})=>{let r=Re(),n=r.width<830;return oA(vo,{...t,className:Q8("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:f("labels.liveCollaboration"),children:[n?xx:f("labels.share"),r.collaborators.size>0&&tA("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},eA=A5;A5.displayName="LiveCollaborationTrigger";import{jsx as Bn,jsxs as D5}from"react/jsx-runtime";var rA=()=>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"})}),nA=()=>D5("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)"})]}),_5=({style:e,size:o="small",withText:t})=>D5("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Bn(rA,{}),t&&Bn(nA,{})]});import{Fragment as N5,jsx as xt,jsxs as wf}from"react/jsx-runtime";var Tf=({icon:e,shortcut:o,children:t})=>{let r=Ce();return wf(N5,{children:[xt("div",{className:"welcome-screen-menu-item__icon",children:e}),xt("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&xt("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};Tf.displayName="WelcomeScreenMenuItemContent";var Cs=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>xt("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:xt(Tf,{icon:t,shortcut:r,children:o})});Cs.displayName="WelcomeScreenMenuItem";var P5=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>xt("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noreferrer",children:xt(Tf,{icon:t,shortcut:r,children:e})});P5.displayName="WelcomeScreenMenuItemLink";var Fo=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=Ke();return xt(o.In,{children:xt("div",{className:"welcome-screen-center",children:e||wf(N5,{children:[xt(Cf,{}),xt(If,{children:f("welcomeScreen.defaults.center_heading")}),wf(Sf,{children:[xt(Mf,{}),xt(kf,{})]})]})})})};Fo.displayName="Center";var Cf=({children:e})=>xt("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||xt(_5,{withText:!0})});Cf.displayName="Logo";var If=({children:e})=>xt("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});If.displayName="Heading";var Sf=({children:e})=>xt("div",{className:"welcome-screen-menu",children:e});Sf.displayName="Menu";var kf=()=>{let e=ft();return xt(Cs,{onSelect:()=>e.executeAction(vi),shortcut:"?",icon:la,children:f("helpDialog.title")})};kf.displayName="MenuItemHelp";var Mf=()=>{let e=Re(),o=ft();return e.viewModeEnabled?null:xt(Cs,{onSelect:()=>o.executeAction(wa),shortcut:ct("loadScene"),icon:sa,children:f("buttons.load")})};Mf.displayName="MenuItemLoadScene";var R5=({onSelect:e})=>{let{t:o}=ut();return xt(Cs,{shortcut:null,onSelect:e,icon:Qc,children:o("labels.liveCollaboration")})};R5.displayName="MenuItemLiveCollaborationTrigger";Fo.Logo=Cf;Fo.Heading=If;Fo.Menu=Sf;Fo.MenuItem=Cs;Fo.MenuItemLink=P5;Fo.MenuItemHelp=kf;Fo.MenuItemLoadScene=Mf;Fo.MenuItemLiveCollaborationTrigger=R5;import{jsx as $a,jsxs as Lf}from"react/jsx-runtime";var op=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=Ke();return $a(o.In,{children:Lf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[$0,$a("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.menuHint")})]})})};op.displayName="MenuHint";var rp=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=Ke();return $a(o.In,{children:Lf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[$a("div",{className:"welcome-screen-decor-hint__label",children:e||f("welcomeScreen.defaults.toolbarHint")}),q0]})})};rp.displayName="ToolbarHint";var np=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=Ke();return $a(o.In,{children:Lf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[$a("div",{children:e||f("welcomeScreen.defaults.helpHint")}),j0]})})};np.displayName="HelpHint";import{Fragment as O5,jsx as Is,jsxs as aA}from"react/jsx-runtime";var ip=e=>Is(O5,{children:e.children||aA(O5,{children:[Is(Fo,{}),Is(op,{}),Is(rp,{}),Is(np,{})]})});ip.displayName="WelcomeScreen";ip.Center=Fo;ip.Hints={MenuHint:op,ToolbarHint:rp,HelpHint:np};var iA=ip;var lA=()=>{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)})},B5=lA;import sA from"lodash.throttle";var cA=(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)),dA=sA((e,o,t)=>{if(Ue()||mt()||window?.DEBUG_FRACTIONAL_INDICES){let r=Pr(e.map(n=>({...n})));Fb(r,{shouldThrow:mt()||Ue(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),mA=(e,o,t)=>{let r=ee(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),c=cA(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=bc(n);return dA(a,e,o),Pr(a),a};import{jsx as z5,jsxs as pA}from"react/jsx-runtime";var F5=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=Ke(),r=Ie();return z5(t.In,{children:pA(Ne.Item,{onSelect:()=>{xe("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??hE,children:[e??f("labels.textToDiagram"),z5(Ne.Item.Badge,{children:"AI"})]})})};F5.displayName="TTDDialogTrigger";import{useLayoutEffect as uA}from"react";var hA=e=>{let o=st();return uA(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{jsx as Af}from"react/jsx-runtime";B5();var bA=e=>{let{onChange:o,initialData:t,excalidrawAPI:r,isCollaborating:n=!1,onPointerUpdate:i,renderTopRightUI:a,langCode:l=pr.code,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:m,libraryReturnUrl:d,theme:p,name:u,renderCustomStats:g,onPaste:b,detectScroll:x=!0,handleKeyboardGlobally:E=!1,onLibraryChange:w,autoFocus:y=!1,generateIdForFile:v,onLinkOpen:I,generateLinkForSelection:S,onPointerDown:_,onPointerUp:L,onScrollChange:N,onDuplicate:P,children:F,validateEmbeddable:K,renderEmbeddable:U,aiEnabled:q,showDeprecatedFonts:H}=e,G=e.UIOptions?.canvasActions,V={...e.UIOptions,canvasActions:{...pp.canvasActions,...G},tools:{image:e.UIOptions?.tools?.image??!0}};return G?.export&&(V.canvasActions.export.saveFileToDisk=G.export?.saveFileToDisk??pp.canvasActions.export.saveFileToDisk),V.canvasActions.toggleTheme===null&&typeof p>"u"&&(V.canvasActions.toggleTheme=!0),fA(()=>{(async()=>{await import("canvas-roundrect-polyfill")})();let $=se=>{typeof se.scale=="number"&&se.scale!==1&&se.preventDefault()};return document.addEventListener("touchmove",$,{passive:!1}),()=>{document.removeEventListener("touchmove",$)}},[]),Af(U0,{store:St,children:Af(k5,{langCode:l,theme:p,children:Af(S5,{onChange:o,initialData:t,excalidrawAPI:r,isCollaborating:n,onPointerUpdate:i,renderTopRightUI:a,langCode:l,viewModeEnabled:s,zenModeEnabled:c,gridModeEnabled:m,libraryReturnUrl:d,theme:p,name:u,renderCustomStats:g,UIOptions:V,onPaste:b,detectScroll:x,handleKeyboardGlobally:E,onLibraryChange:w,autoFocus:y,generateIdForFile:v,onLinkOpen:I,generateLinkForSelection:S,onPointerDown:_,onPointerUp:L,onScrollChange:N,onDuplicate:P,validateEmbeddable:K,renderEmbeddable:U,aiEnabled:q!==!1,showDeprecatedFonts:H,children:F})})})},xA=(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])&&Je(n,l)},EA=gA.memo(bA,xA);EA.displayName="Excalidraw";export{vo as Button,A as CaptureUpdateAction,lp as DEFAULT_LASER_COLOR,Bm as DefaultSidebar,hA as DiagramToCodePlugin,EA as Excalidraw,Bt as FONT_FAMILY,J8 as Footer,eA as LiveCollaborationTrigger,ue as MIME_TYPES,Ot as MainMenu,eo as ROUNDNESS,zo as Sidebar,fs as Stats,de as THEME,jg as TTDDialog,F5 as TTDDialogTrigger,h1 as UserIdleState,iA as WelcomeScreen,xl as bumpVersion,Fa as convertToExcalidrawElements,pr as defaultLang,V5 as elementPartiallyOverlapsWithOrContainsBBox,Y5 as elementsOverlappingBBox,I2 as exportToBlob,Tn as exportToCanvas,_C as exportToClipboard,_a as exportToSvg,ye as getCommonBounds,Nc as getDataURL,W5 as getFreeDrawSvgPath,Xd as getLibraryItemsHash,Ee as getNonDeletedElements,U5 as getSceneVersion,Ap as getTextFromElements,Kp as getVisibleSceneBounds,Np as hashElementsVersion,Op as hashString,G5 as isElementInsideBBox,ii as isElementLink,ei as isInvisiblySmallElement,ae as isLinearElement,na as languages,Rc as loadFromBlob,ru as loadLibraryFromBlob,ou as loadSceneOrLibraryFromBlob,D2 as mergeLibraryItems,B as mutateElement,oe as newElementWith,Wo as normalizeLink,Kh as parseLibraryTokensFromUrl,mA as reconcileElements,ta as restore,K5 as restoreAppState,tu as restoreElements,Il as restoreLibraryItems,zt as sceneCoordsToViewportCoords,Tl as serializeAsJSON,eu as serializeLibraryAsJSON,H5 as setCustomTextMetricsProvider,Ce as useDevice,BC as useHandleLibrary,ut as useI18n,$e as viewportCoordsToSceneCoords,By as zoomToFitBounds};
118
+ `),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:Fz,verticalAlign:LT,locked:!1},l=ef({fontSize:a.fontSize,fontFamily:a.fontFamily}),s=RT(a.fontFamily),[d,,m]=DH(this.state),c=Math.max(Math.min((m-d)*.5,800),200),p=10,u=i,f=r?[t]:t.split(`
119
+ `),b=f.reduce((x,w,E)=>{let y=zH(w).trim();if(y.length){let v=this.getTopLayerFrameAtSceneCoords({x:n,y:u}),C=cI(y,l,s),S=C.width>c,L=S?BH(y,l,c):y;C=S?cI(L,l,s):C;let k=n-C.width/2,A=u-C.height/2,P=VT({...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+=HH(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)}),!r&&b.length>1&&EI===!1&&!this.device.editor.isMobile&&(this.setToast({message:g("toast.pasteAsSingleElement",{shortcut:Vz("CtrlOrCmd+Shift+V")}),duration:5e3}),EI=!0))}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&&co(s)?sn(s,{originalText:a,isDeleted:l??s.isDeleted,...dH(s,rI(s,n),n,a)}):s)])};nv({id:t.id,canvas:this.canvas,getViewportCoords:(a,l)=>{let{x:s,y:d}=jd({sceneX:a,sceneY:l},this.state);return[s-this.state.offsetLeft,d-this.state.offsetTop]},onChange:Pe(a=>{i(a,!1),fI(t)&&af(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;Bi(()=>{this.setState(m=>({selectedElementIds:ye({...m.selectedElementIds,[d]:!0},m)}))})}s&&tH(this.scene.getNonDeletedElements(),[t]),(!s||r)&&this.store.scheduleCapture(),Bi(()=>{this.setState({newElement:null,editingTextElement:null})}),this.state.activeTool.locked&&At(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,r){let n=this.getElementAtPosition(t,r,{includeBoundTextElement:!0});return n&&co(n)&&!n.isDeleted?n:null}getElementAtPosition(t,r,n){let i=[];if(n&&"allHitElements"in n?i=n?.allHitElements||[]:i=this.getElementsAtPosition(t,r,{includeBoundTextElement:n?.includeBoundTextElement,includeLockedElements:n?.includeLockedElements}),i.length>1){if(n?.preferSelected){for(let l=i.length-1;l>-1;l--)if(this.state.selectedElementIds[i[l].id])return i[l]}let a=i[i.length-1];return gl({point:ne(t,r),element:a,threshold:this.getElementHitThreshold(a)/2,elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Kt(a)?this.frameNameBoundsCache.get(a):null})?a:i[i.length-2]}return i.length===1?i[0]:null}getElementsAtPosition(t,r,n){let i=[],a=this.scene.getNonDeletedElementsMap();return(n?.includeBoundTextElement&&n?.includeLockedElements?this.scene.getNonDeletedElements():this.scene.getNonDeletedElements().filter(s=>(n?.includeLockedElements||!s.locked)&&(n?.includeBoundTextElement||!(co(s)&&s.containerId)))).filter(s=>this.hitElement(t,r,s)).filter(s=>{let d=xf(s,a);return d&&this.state.frameRendering.enabled&&this.state.frameRendering.clip?iI({x:t,y:r},d,a):!0}).filter(s=>Hi(s)?(i.push(s),!1):!0).concat(i)}getElementHitThreshold(t){return Math.max(t.strokeWidth/2+.1,.85*(_T/this.state.zoom.value))}hitElement(t,r,n,i=!0){return i&&this.state.selectedElementIds[n.id]&&vH([n],this.state)&&rG(ne(t,r),n,this.scene.getNonDeletedElementsMap(),this.getElementHitThreshold(n))||PH(ne(t,r),n,this.scene.getNonDeletedElementsMap())?!0:gl({point:ne(t,r),element:n,threshold:this.getElementHitThreshold(n),elementsMap:this.scene.getNonDeletedElementsMap(),frameNameBound:Kt(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 jT(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,d,m,c]=GT(n[l],this.scene.getNonDeletedElementsMap());if(sf(n[l])&&gl({point:ne(t,r),element:n[l],elementsMap:this.scene.getNonDeletedElementsMap(),threshold:this.getElementHitThreshold(n[l])})){a=n[l];break}else if(s<t&&t<m&&d<r&&r<c){a=n[l];break}}return jT(a,!1)?a:null}handleHoverSelectedLinearElement(t,r,n){let i=this.scene.getNonDeletedElementsMap(),a=Se.getElement(t.elementId,i);if(a)if(this.state.selectedLinearElement){let l=-1,s=null;gl({point:ne(r,n),element:a,elementsMap:i,threshold:this.getElementHitThreshold(a)})?(l=Se.getPointIndexUnderCursor(a,i,this.state.zoom,r,n),s=Se.getSegmentMidpointHitCoords(t,{x:r,y:n},this.state,this.scene.getNonDeletedElementsMap()),(We(a)?l===0||l===a.points.length-1:l>=0)||s?xe(this.interactiveCanvas,De.POINTER):this.hitElement(r,n,a)&&(!We(a)||!(a.startBinding||a.endBinding))&&xe(this.interactiveCanvas,De.MOVE)):this.hitElement(r,n,a)&&(!We(a)||!(a.startBinding||a.endBinding))&&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=kh(pe.pointers),pe.initialScale=this.state.zoom.value,pe.initialDistance=Mh(Array.from(pe.pointers.values())))}initialPointerDownState(t){let r=Fe(t,this.state),n=this.scene.getSelectedElements(this.state),[i,a,l,s]=zi(n),d=n.findIndex(We)===0;return{origin:r,withCmdOrCtrl:t[Y.CTRL_OR_CMD],originInGrid:tf(nt(r.x,r.y,t[Y.CTRL_OR_CMD]||d?null:this.getEffectiveGridSize())),scrollbars:Bh(yl,t.clientX-this.state.offsetLeft,t.clientY-this.state.offsetTop),lastCoords:{...r},originalElements:this.scene.getNonDeletedElements().reduce((m,c)=>(m.set(c.id,XT(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(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;vf=!0,r.lastCoords.x=t.clientX,r.lastCoords.y=t.clientY;let n=td(a=>{a.target instanceof HTMLElement&&this.handlePointerMoveOverScrollbars(a,r)}),i=Pe(()=>{vl=null,vf=!1,At(this.interactiveCanvas,this.state),this.setState({cursorButton:"up"}),this.savePointer(t.clientX,t.clientY,"up"),window.removeEventListener(ee.POINTER_MOVE,n),window.removeEventListener(ee.POINTER_UP,i),n.flush()});return vl=i,window.addEventListener(ee.POINTER_MOVE,n),window.addEventListener(ee.POINTER_UP,i),!0}isASelectedElement(t){return t!=null&&this.state.selectedElementIds[t.id]}isHittingCommonBoundingBoxOfSelectedElements(t,r){if(r.length<2)return!1;let n=Math.max(_T/this.state.zoom.value,1),[i,a,l,s]=zi(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:pH(t)?Kd.ADAPTIVE_RADIUS:Kd.PROPORTIONAL_RADIUS}:null}maybeCacheReferenceSnapPoints(t,r,n=!1){Ho({event:t,app:this,selectedElements:r})&&(n||!Yt.getReferenceSnapPoints())&&Yt.setReferenceSnapPoints(yw(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}maybeCacheVisibleGaps(t,r,n=!1){Ho({event:t,app:this,selectedElements:r})&&(n||!Yt.getVisibleGaps())&&Yt.setVisibleGaps(Ew(this.scene.getNonDeletedElements(),r,this.state,this.scene.getNonDeletedElementsMap()))}onKeyDownFromPointerDownHandler(t){return Pe(r=>{this.maybeHandleResize(t,r)||this.maybeDragNewGenericElement(t,r)})}onKeyUpFromPointerDownHandler(t){return Pe(r=>{r.key===Y.ALT&&r.preventDefault(),!this.maybeHandleResize(t,r)&&this.maybeDragNewGenericElement(t,r)})}onPointerMoveFromPointerDownHandler(t){return td(r=>{if(this.state.openDialog?.name==="elementLinkSelector")return;let n=Fe(r,this.state);if(this.state.activeLockedId&&this.setState({activeLockedId:null}),this.state.selectedLinearElement&&this.state.selectedLinearElement.elbowed&&this.state.selectedLinearElement.pointerDownState.segmentMidpoint.index){let[p,u]=nt(n.x,n.y,r[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=n,t.drag.offset===null&&(t.drag.offset=tf(tG(this.scene.getSelectedElements(this.state),t.origin.x,t.origin.y))),!(r.target instanceof HTMLElement)||this.handlePointerMoveOverScrollbars(r,t))return;if(bt(this.state)){this.handleEraser(r,n);return}this.state.activeTool.type==="laser"&&this.laserTrails.addPointToPath(n.x,n.y);let[l,s]=nt(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")&&nn(ne(n.x,n.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value<zT)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 d=this.scene.getNonDeletedElementsMap();if(this.state.selectedLinearElement){let p=this.state.selectedLinearElement;if(Se.shouldAddMidpoint(this.state.selectedLinearElement,n,this.state,d)){let f=Se.addMidpoint(this.state.selectedLinearElement,n,this,!r[Y.CTRL_OR_CMD],this.scene);if(!f)return;Bi(()=>{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(r,this,n.x,n.y,p);if(u){t.lastCoords.x=n.x,t.lastCoords.y=n.y,t.drag.hasOccurred=!0,this.setState(u);return}}let m=t.hit.allHitElements.some(p=>this.isASelectedElement(p)),c=this.state.selectedLinearElement?.isEditing&&r.shiftKey&&this.state.selectedLinearElement.elementId===t.hit.element?.id;if((m||t.hit.hasHitCommonBoundingBoxOfSelectedElements)&&!c&&this.state.activeTool.type!=="lasso"){let p=this.scene.getSelectedElements(this.state);if(p.every(x=>x.locked))return;let u=p.find(x=>Kt(x)),f=this.getTopLayerFrameAtSceneCoords(n),b=f&&!u?f:null;if(this.state.frameToHighlight!==b&&Bi(()=>{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},w=[...t.originalElements.values()],E=r.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&&cn(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=fz(TT(n.x-i.x,n.y-i.y),Math.max(this.state.zoom.value,2)),[A,P,N,O,U,J]=GT(C,d),_=jg($g(ne(A,P),ne(U,J),C.angle)),R=jg($g(ne(N,P),ne(U,J),C.angle)),V=jg($g(ne(A,O),ne(U,J),C.angle)),Z=ST(IT(R,_)),W=ST(IT(V,_)),ce=TT(CT(k,Z),CT(k,W)),he={...S,x:vT(S.x-ce[0]*Math.sign(C.scale[0]),0,L.naturalWidth-S.width),y:vT(S.y-ce[1]*Math.sign(C.scale[1]),0,L.naturalHeight-S.height)};this.scene.mutateElement(C,{crop:he});return}}}this.maybeCacheVisibleGaps(r,p),this.maybeCacheReferenceSnapPoints(r,p);let{snapOffset:y,snapLines:v}=ww(w,x,this,r,this.scene.getNonDeletedElementsMap());if(this.setState({snapLines:v}),this.state.editingFrame||eG(t,p,x,this.scene,y,r[Y.CTRL_OR_CMD]?null:this.getEffectiveGridSize()),this.setState({selectedElementsAreBeingDragged:!0,selectionElement:null}),(p.length!==1||!We(p[0]))&&this.setState({suggestedBindings:lf(p,this.scene.getNonDeletedElementsMap(),this.state.zoom)}),r.altKey&&!t.hit.hasBeenDuplicated){t.hit.hasBeenDuplicated=!0;let C=this.scene.getElementsIncludingDeleted(),S=t.hit.element,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}=KT({type:"in-place",elements:C,appState:this.state,randomizeSeed:!0,idsOfElementsToDuplicate:k,overrides:({duplicateElement:R,origElement:V})=>({frameId:R.frameId??V.frameId,seed:Jz()})});A.forEach(R=>{t.originalElements.set(R.id,XT(R))});let U=N.map(R=>{if(k.has(R.id)){let V=t.originalElements.get(R.id);if(V)return sn(R,{x:V.x,y:V.y})}return R}),J=this.props.onDuplicate?.(U,C),_=mI(J||U,OT(A));Bi(()=>{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=Fe(r,this.state),this.setState(R=>({...jH(A,this.scene.getNonDeletedElements(),R)})),this.scene.replaceAllElements(_),this.maybeCacheVisibleGaps(r,L,!0),this.maybeCacheReferenceSnapPoints(r,L,!0)})}return}}if(this.state.selectionElement){if(t.lastCoords.x=n.x,t.lastCoords.y=n.y,r.altKey){this.setActiveTool({type:"lasso",fromSelection:!0},r.shiftKey),this.lassoTrail.startPath(t.origin.x,t.origin.y,r.shiftKey),this.setAppState({selectionElement:null});return}this.maybeDragNewGenericElement(t,r)}else if(this.state.activeTool.type==="lasso")!r.altKey&&this.state.activeTool.fromSelection?(this.setActiveTool({type:"selection"}),this.createGenericElementOnPointerDown("selection",t),t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r),this.lassoTrail.endPath()):this.lassoTrail.addPointToPath(n.x,n.y,r.shiftKey);else{let p=this.state.newElement;if(!p)return;if(p.type==="freedraw"){let u=p.points,f=n.x-p.x,b=n.y-p.y,x=u.length>0&&u[u.length-1];if(!(x&&x[0]===f&&x[1]===b)){let E=p.simulatePressure?p.pressures:[...p.pressures,r.pressure];this.scene.mutateElement(p,{points:[...u,ne(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;qg(r)&&u.length===2&&({width:f,height:b}=qT(p.x,p.y,n.x,n.y)),u.length===1?this.scene.mutateElement(p,{points:[...u,ne(f,b)]},{informMutation:!1,isDragging:!1}):(u.length===2||u.length>1&&We(p))&&this.scene.mutateElement(p,{points:[...u.slice(0,-1),ne(f,b)]},{isDragging:!0,informMutation:!1}),this.setState({newElement:p}),cf(p,!1)&&this.setState({suggestedBindings:HT(p,[n],this.scene,this.state.zoom,this.state.startBoundElement)})}else t.lastCoords.x=n.x,t.lastCoords.y=n.y,this.maybeDragNewGenericElement(t,r,!1)}if(this.state.activeTool.type==="selection"){t.boxSelection.hasOccurred=!0;let p=this.scene.getNonDeletedElements();if(this.state.selectedLinearElement?.isEditing)Se.handleBoxSelection(r,this.state,this.setState.bind(this),this.scene.getNonDeletedElementsMap());else{let u=!0;!r.shiftKey&&Ee(p,this.state)&&(t.withCmdOrCtrl&&t.hit.element?this.setState(b=>mo({...b,selectedElementIds:{[t.hit.element.id]:!0}},this.scene.getNonDeletedElements(),b,this)):u=!1);let f=this.state.selectionElement?Zf(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},{...mo({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||Ar(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*(yl.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*(yl.vertical?.deltaMultiplier||1)/this.state.zoom.value}),r.lastCoords.y=n,!0}return!1}onPointerUpFromPointerDownHandler(t){return Pe(r=>{this.removePointer(r),t.eventListeners.onMove&&t.eventListeners.onMove.flush();let{newElement:n,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,Yt.setReferenceSnapPoints(null),Yt.setVisibleGaps(null),this.savePointer(r.clientX,r.clientY,"up");let p=t.hit.allHitElements,u=Fe({clientX:r.clientX,clientY:r.clientY},this.state);if(this.state.activeTool.type==="selection"&&!t.boxSelection.hasOccurred&&!t.resize.isResizing&&!p.some(E=>this.state.selectedElementIds[E.id])){let E=this.getElementAtPosition(u.x,u.y,{includeLockedElements:!0});this.store.scheduleCapture(),E?.locked?this.setState({activeLockedId:E.groupIds.length>0?E.groupIds.at(-1)||"":E.id}):this.setState({activeLockedId:null})}else this.setState({activeLockedId:null});this.setState({selectedElementsAreBeingDragged:!1});let f=this.scene.getNonDeletedElementsMap();if(t.drag.hasOccurred&&t.hit?.element?.id){let E=f.get(t.hit.element.id);hH(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(r,this.state.selectedLinearElement,this.state,this.scene);E!==this.state.selectedLinearElement&&this.setState({selectedLinearElement:E,suggestedBindings:[]})}else if(this.state.selectedLinearElement){if(this.state.selectedLinearElement.elbowed){let E=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:r,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,r),n?.type==="freedraw"){let E=Fe(r,this.state),y=n.points,v=E.x-n.x,C=E.y-n.y;v===y[0][0]&&C===y[0][1]&&(C+=1e-4,v+=1e-4);let S=n.simulatePressure?[]:[...n.pressures,r.pressure];this.scene.mutateElement(n,{points:[...y,ne(v,C)],pressures:S,lastCommittedPoint:ne(v,C)}),this.actionManager.executeAction(wt);return}if(Zt(n)){n.points.length>1&&this.store.scheduleCapture();let E=Fe(r,this.state),y=nn(ne(E.x,E.y),ne(t.origin.x,t.origin.y))*this.state.zoom.value;if((!t.drag.hasOccurred||y<zT)&&n&&!l)if(this.device.isTouchScreen){let v=Math.min(this.state.width*.7/this.state.zoom.value,100);this.scene.mutateElement(n,{x:n.x-v/2,points:[ne(0,0),ne(v,0)]},{informMutation:!1,isDragging:!1}),this.actionManager.executeAction(wt)}else{let v=E.x-n.x,C=E.y-n.y;this.scene.mutateElement(n,{points:[...n.points,ne(v,C)]},{informMutation:!1,isDragging:!1}),this.setState({multiElement:n,newElement:n})}else t.drag.hasOccurred&&!l&&(nf(this.state)&&cf(n,!1)&&this.actionManager.executeAction(wt,"ui",{event:r,sceneCoords:u}),this.setState({suggestedBindings:[],startBoundElement:null}),s.locked?this.setState(v=>({newElement:null})):(zt(this.interactiveCanvas),this.setState(v=>({newElement:null,activeTool:Vo(this.state,{type:"selection"}),selectedElementIds:ye({...v.selectedElementIds,[n.id]:!0},v),selectedLinearElement:new Se(n,this.scene.getNonDeletedElementsMap())}))),this.scene.triggerUpdate());return}if(co(n)){let E=YH(ef({fontSize:n.fontSize,fontFamily:n.fontFamily}),n.lineHeight);n.width<E&&this.scene.mutateElement(n,{autoResize:!0}),this.resetCursor(),this.handleTextWysiwyg(n,{isExistingElement:!0})}if(s.type!=="selection"&&n&&QT(n)){this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==n.id),appState:{newElement:null},captureUpdate:mt.NEVER});return}if(Kt(n)){let E=CH(this.scene.getElementsIncludingDeleted(),n,this.scene.getNonDeletedElementsMap());this.scene.replaceAllElements(ff(this.scene.getElementsMapIncludingDeleted(),E,n,this.state))}if(n&&(this.scene.mutateElement(n,gH(n),{informMutation:!1,isDragging:!1}),this.scene.triggerUpdate()),t.drag.hasOccurred){let E=Fe(r,this.state);if(this.state.selectedLinearElement&&this.state.selectedLinearElement.isDragging){let y=this.scene.getElement(this.state.selectedLinearElement.elementId);if(y?.frameId){let v=xf(y,f);v&&y&&(SH(y,v,this.scene.getNonDeletedElementsMap())||(this.scene.mutateElement(y,{groupIds:[]}),IH([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&&bl(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&&lI(k,C,this.state));this.state.editingGroupId&&S(L),C=ff(C,L,y,this.state)}else if(!y&&this.state.editingGroupId){let L=v.filter(k=>k.frameId&&!lI(k,C,this.state));S(L)}C=aI(C,this.state,this),this.scene.replaceAllElements(C)}}if(i&&this.store.scheduleCapture(),i&&QT(i)&&this.updateScene({elements:this.scene.getElementsIncludingDeleted().filter(E=>E.id!==i.id),captureUpdate:mt.NEVER}),t.resize.isResizing){let E=aI(this.scene.getElementsIncludingDeleted(),this.state,this),y=this.scene.getSelectedElements(this.state).filter(v=>Kt(v));for(let v of y)E=TH(E,bf(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(),nn(ne(x.clientX,x.clientY),ne(w.clientX,w.clientY))===0){let y=Fe({clientX:w.clientX,clientY:w.clientY},this.state);this.getElementsAtPosition(y.x,y.y).forEach(C=>this.elementsPendingErasure.add(C.id))}this.eraseElements();return}else this.elementsPendingErasure.size&&this.restoreReadyToEraseElements();if(b&&!t.drag.hasOccurred&&!t.hit.wasAddedToSelection&&(!this.state.selectedLinearElement?.isEditing||!t.boxSelection.hasOccurred)&&this.state.activeTool.type!=="lasso"&&(r.shiftKey&&!this.state.selectedLinearElement?.isEditing?this.state.selectedElementIds[b.id]?ZH(this.state,b)?this.setState(E=>{let y={...E.selectedElementIds};for(let v of b.groupIds.flatMap(C=>bl(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{...mo({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=>bl(this.scene.getNonDeletedElements(),v)).forEach(v=>{delete y[v.id]}),{...mo({editingGroupId:E.editingGroupId,selectedElementIds:y},this.scene.getNonDeletedElements(),E,this),showHyperlinkPopup:b.link||Ar(b)?"info":!1}}):this.setState(E=>({selectedElementIds:ye({...E.selectedElementIds,[b.id]:!0},E)})):this.setState(E=>({...mo({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&&AH({point:ne(t.origin.x,t.origin.y),element:b,elementsMap:f,threshold:this.getElementHitThreshold(b),frameNameBound:Kt(b)?this.frameNameBoundsCache.get(b):null},f)||!b&&t.hit.hasHitCommonBoundingBoxOfSelectedElements)){this.state.selectedLinearElement?.isEditing?this.actionManager.executeAction(wi):this.setState({selectedElementIds:ye({},this.state),selectedGroupIds:{},editingGroupId:null,activeEmbeddable:null}),xe(this.interactiveCanvas,De.AUTO);return}if(!s.locked&&s.type!=="freedraw"&&n&&this.setState(E=>({selectedElementIds:ye({...E.selectedElementIds,[n.id]:!0},E),showHyperlinkPopup:Ar(n)&&!n.link?"editor":E.showHyperlinkPopup})),(s.type!=="selection"||Ee(this.scene.getNonDeletedElements(),this.state)||!qz(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);UT(E,nf(this.state),this.state.selectedLinearElement?.selectedPointsIndices??[],this.scene,this.state.zoom)}if(s.type==="laser"){this.laserTrails.endPath();return}!s.locked&&s.type!=="freedraw"&&(s.type!=="lasso"||s.type==="lasso"&&s.fromSelection)?(zt(this.interactiveCanvas),this.setState({newElement:null,suggestedBindings:[],activeTool:Vo(this.state,{type:"selection"})})):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(r=>({selectedElementIds:ye({},r),activeEmbeddable:null,selectedGroupIds:{},editingGroupId:r.editingGroupId&&t!=null&&dI(t,r.editingGroupId)?r.editingGroupId:null})),this.setState({selectedElementIds:ye({},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=gf(i,n,this.scene.getNonDeletedElementsMap());if(s&&(a=s.x,l=s.y),Math.hypot(t-a,r-l)<Az){let{x:c,y:p}=jd({sceneX:a,sceneY:l},n);return{viewportX:c,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=En.find(r=>r.code===this.props.langCode)||ho;await Gl(t),this.setAppState({})}},iG=()=>{(If()||yI())&&(window.h=window.h||{},Object.defineProperties(window.h,{elements:{configurable:!0,get(){return this.app?.scene.getElementsIncludingDeleted()},set(e){return this.app?.scene.replaceAllElements(wI(e))}},scene:{configurable:!0,get(){return this.app?.scene}}}))};iG();var CI=Cf;import{useEffect as lG,useState as sG}from"react";import{jsx as cG}from"react/jsx-runtime";var SI=e=>{let[o,t]=sG(!0);return lG(()=>{let r=async()=>{await Gl(n),t(!1)},n=En.find(i=>i.code===e.langCode)||ho;r()},[e.langCode]),o?cG(id,{theme:e.theme}):e.children};import dG from"clsx";import{jsx as kI}from"react/jsx-runtime";var MI=({children:e})=>{let{FooterCenterTunnel:o}=ve(),t=ge();return kI(o.In,{children:kI("div",{className:dG("footer-center zen-mode-transition",{"layer-ui__wrapper__footer-left--transition-bottom":t.zenModeEnabled}),children:e})})},mG=MI;MI.displayName="FooterCenter";import pG from"clsx";import{jsx as hG,jsxs as gG}from"react/jsx-runtime";var LI=({isCollaborating:e,onSelect:o,...t})=>{let r=ge(),n=r.width<830;return gG(_t,{...t,className:pG("collab-button",{active:e}),type:"button",onSelect:o,style:{position:"relative",width:n?void 0:"auto"},title:g("labels.liveCollaboration"),children:[n?K1:g("labels.share"),r.collaborators.size>0&&hG("div",{className:"CollabButton-collaborators",children:r.collaborators.size})]})},uG=LI;LI.displayName="LiveCollaborationTrigger";import{jsx as Rr,jsxs as AI}from"react/jsx-runtime";var fG=()=>Rr("svg",{viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"ExcalidrawLogo-icon",children:Rr("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"})}),bG=()=>AI("svg",{viewBox:"0 0 450 55",xmlns:"http://www.w3.org/2000/svg",fill:"none",className:"ExcalidrawLogo-text",children:[Rr("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)"}),Rr("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)"}),Rr("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)"}),Rr("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)"})]}),PI=({style:e,size:o="small",withText:t})=>AI("div",{className:`ExcalidrawLogo is-${o}`,style:e,children:[Rr(fG,{}),t&&Rr(bG,{})]});import{Fragment as RI,jsx as Ve,jsxs as Df}from"react/jsx-runtime";var _f=({icon:e,shortcut:o,children:t})=>{let r=se();return Df(RI,{children:[Ve("div",{className:"welcome-screen-menu-item__icon",children:e}),Ve("div",{className:"welcome-screen-menu-item__text",children:t}),o&&!r.editor.isMobile&&Ve("div",{className:"welcome-screen-menu-item__shortcut",children:o})]})};_f.displayName="WelcomeScreenMenuItemContent";var Tl=({onSelect:e,children:o,icon:t,shortcut:r,className:n="",...i})=>Ve("button",{...i,type:"button",className:`welcome-screen-menu-item ${n}`,onClick:e,children:Ve(_f,{icon:t,shortcut:r,children:o})});Tl.displayName="WelcomeScreenMenuItem";var DI=({children:e,href:o,icon:t,shortcut:r,className:n="",...i})=>Ve("a",{...i,className:`welcome-screen-menu-item ${n}`,href:o,target:"_blank",rel:"noopener",children:Ve(_f,{icon:t,shortcut:r,children:e})});DI.displayName="WelcomeScreenMenuItemLink";var $t=({children:e})=>{let{WelcomeScreenCenterTunnel:o}=ve();return Ve(o.In,{children:Ve("div",{className:"welcome-screen-center",children:e||Df(RI,{children:[Ve(Rf,{}),Ve(Nf,{children:g("welcomeScreen.defaults.center_heading")}),Df(Bf,{children:[Ve(Of,{}),Ve(Ff,{})]})]})})})};$t.displayName="Center";var Rf=({children:e})=>Ve("div",{className:"welcome-screen-center__logo excalifont welcome-screen-decor",children:e||Ve(PI,{withText:!0})});Rf.displayName="Logo";var Nf=({children:e})=>Ve("div",{className:"welcome-screen-center__heading welcome-screen-decor excalifont",children:e});Nf.displayName="Heading";var Bf=({children:e})=>Ve("div",{className:"welcome-screen-menu",children:e});Bf.displayName="Menu";var Ff=()=>{let e=Ue();return Ve(Tl,{onSelect:()=>e.executeAction(Zr),shortcut:"?",icon:Tn,children:g("helpDialog.title")})};Ff.displayName="MenuItemHelp";var Of=()=>{let e=ge(),o=Ue();return e.viewModeEnabled?null:Ve(Tl,{onSelect:()=>o.executeAction(Kn),shortcut:Ne("loadScene"),icon:In,children:g("buttons.load")})};Of.displayName="MenuItemLoadScene";var _I=({onSelect:e})=>{let{t:o}=Oe();return Ve(Tl,{shortcut:null,onSelect:e,icon:jl,children:o("labels.liveCollaboration")})};_I.displayName="MenuItemLiveCollaborationTrigger";$t.Logo=Rf;$t.Heading=Nf;$t.Menu=Bf;$t.MenuItem=Tl;$t.MenuItemLink=DI;$t.MenuItemHelp=Ff;$t.MenuItemLoadScene=Of;$t.MenuItemLiveCollaborationTrigger=_I;import{jsx as Gi,jsxs as zf}from"react/jsx-runtime";var em=({children:e})=>{let{WelcomeScreenMenuHintTunnel:o}=ve();return Gi(o.In,{children:zf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--menu",children:[k1,Gi("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.menuHint")})]})})};em.displayName="MenuHint";var tm=({children:e})=>{let{WelcomeScreenToolbarHintTunnel:o}=ve();return Gi(o.In,{children:zf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--toolbar",children:[Gi("div",{className:"welcome-screen-decor-hint__label",children:e||g("welcomeScreen.defaults.toolbarHint")}),L1]})})};tm.displayName="ToolbarHint";var om=({children:e})=>{let{WelcomeScreenHelpHintTunnel:o}=ve();return Gi(o.In,{children:zf("div",{className:"excalifont welcome-screen-decor welcome-screen-decor-hint welcome-screen-decor-hint--help",children:[Gi("div",{children:e||g("welcomeScreen.defaults.helpHint")}),M1]})})};om.displayName="HelpHint";import{Fragment as NI,jsx as Il,jsxs as EG}from"react/jsx-runtime";var rm=e=>Il(NI,{children:e.children||EG(NI,{children:[Il($t,{}),Il(em,{}),Il(tm,{}),Il(om,{})]})});rm.displayName="WelcomeScreen";rm.Center=$t;rm.Hints={MenuHint:em,ToolbarHint:tm,HelpHint:om};var xG=rm;var yG=()=>{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)})},BI=yG;import{getSceneVersion as H8e,hashElementsVersion as G8e,hashString as U8e,getNonDeletedElements as Y8e}from"@excalidraw/element";import{getTextFromElements as V8e}from"@excalidraw/element";import{isInvisiblySmallElement as K8e}from"@excalidraw/element";import wG from"lodash.throttle";import{arrayToMap as vG,isDevEnv as FI,isTestEnv as OI}from"@excalidraw/common";import{orderByFractionalIndex as TG,syncInvalidIndices as zI,validateFractionalIndices as IG}from"@excalidraw/element";var CG=(e,o,t)=>!!(o&&(o.id===e.editingTextElement?.id||o.id===e.resizingElement?.id||o.id===e.newElement?.id||o.version>t.version||o.version===t.version&&o.versionNonce<t.versionNonce)),SG=wG((e,o,t)=>{if(FI()||OI()||window?.DEBUG_FRACTIONAL_INDICES){let r=zI(e.map(n=>({...n})));IG(r,{shouldThrow:OI()||FI(),includeBoundTextValidation:!0,reconciliationContext:{localElements:o,remoteElements:t}})}},1e3*60,{leading:!0,trailing:!1}),kG=(e,o,t)=>{let r=vG(e),n=[],i=new Set;for(let l of o)if(!i.has(l.id)){let s=r.get(l.id),d=CG(t,s,l);s&&d?(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=TG(n);return SG(a,e,o),zI(a),a};import{getFreeDrawSvgPath as t7e}from"@excalidraw/element";import{isLinearElement as n7e}from"@excalidraw/element";import{FONT_FAMILY as a7e,THEME as l7e,MIME_TYPES as s7e,ROUNDNESS as dc,DEFAULT_LASER_COLOR as c7e,UserIdleState as d7e,normalizeLink as m7e}from"@excalidraw/common";import{mutateElement as pc,newElementWith as u7e,bumpVersion as ni}from"@excalidraw/element";import{CaptureUpdateAction as g7e}from"@excalidraw/element";import{sceneCoordsToViewportCoords as oy,viewportCoordsToSceneCoords as x7e}from"@excalidraw/common";import{jsx as HI,jsxs as MG}from"react/jsx-runtime";var GI=({children:e,icon:o})=>{let{TTDDialogTriggerTunnel:t}=ve(),r=le();return HI(t.In,{children:MG(fe.Item,{onSelect:()=>{re("ai","dialog open","ttd"),r({openDialog:{name:"ttd",tab:"text-to-diagram"}})},icon:o??Y0,children:[e??g("labels.textToDiagram"),HI(fe.Item.Badge,{children:"AI"})]})})};GI.displayName="TTDDialogTrigger";import{getCommonBounds as P7e,getVisibleSceneBounds as A7e}from"@excalidraw/element";import{useLayoutEffect as LG}from"react";var PG=e=>{let o=Re();return LG(()=>{o.setPlugins({diagramToCode:{generate:e.generate}})},[o,e.generate]),null};import{isElementLink as B7e}from"@excalidraw/element";import{setCustomTextMetricsProvider as O7e}from"@excalidraw/element";import{jsx as Hf}from"react/jsx-runtime";BI();var RG=e=>{let{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,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:{...UI.canvasActions,...Z},tools:{image:e.UIOptions?.tools?.image??!0}};return Z?.export&&(W.canvasActions.export.saveFileToDisk=Z.export?.saveFileToDisk??UI.canvasActions.export.saveFileToDisk),W.canvasActions.toggleTheme===null&&typeof u>"u"&&(W.canvasActions.toggleTheme=!0),DG(()=>{(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)}},[]),Hf(E1,{store:ze,children:Hf(SI,{langCode:s,theme:u,children:Hf(CI,{onChange:o,onIncrement:t,initialData:r,excalidrawAPI:n,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})})})},NG=(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),d=Object.keys(a);return s.length!==d.length?!1:s.every(c=>c==="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[c]===a[c])&&_G(n,l)},BG=AG.memo(RG,NG);BG.displayName="Excalidraw";export{_t as Button,g7e as CaptureUpdateAction,c7e as DEFAULT_LASER_COLOR,vd as DefaultSidebar,PG as DiagramToCodePlugin,ca as Ellipsify,BG as Excalidraw,a7e as FONT_FAMILY,mG as Footer,uG as LiveCollaborationTrigger,s7e as MIME_TYPES,dt as MainMenu,dc as ROUNDNESS,Xt as Sidebar,al as Stats,l7e as THEME,Tg as TTDDialog,GI as TTDDialogTrigger,d7e as UserIdleState,xG as WelcomeScreen,ni as bumpVersion,Ii as convertToExcalidrawElements,ho as defaultLang,_2 as elementPartiallyOverlapsWithOrContainsBBox,R2 as elementsOverlappingBBox,ly as exportToBlob,cr as exportToCanvas,NP as exportToClipboard,si as exportToSvg,P7e as getCommonBounds,bm as getDataURL,t7e as getFreeDrawSvgPath,bc as getLibraryItemsHash,Y8e as getNonDeletedElements,H8e as getSceneVersion,V8e as getTextFromElements,A7e as getVisibleSceneBounds,G8e as hashElementsVersion,U8e as hashString,bh as isElementInsideBBox,B7e as isElementLink,K8e as isInvisiblySmallElement,n7e as isLinearElement,En as languages,Bl as loadFromBlob,fm as loadLibraryFromBlob,gm as loadSceneOrLibraryFromBlob,fy as mergeLibraryItems,pc as mutateElement,u7e as newElementWith,m7e as normalizeLink,Fu as parseLibraryTokensFromUrl,kG as reconcileElements,bn as restore,XI as restoreAppState,VI as restoreElement,hm as restoreElements,Xi as restoreLibraryItems,oy as sceneCoordsToViewportCoords,Yi as serializeAsJSON,um as serializeLibraryAsJSON,O7e as setCustomTextMetricsProvider,se as useDevice,JP as useHandleLibrary,Oe as useI18n,x7e as viewportCoordsToSceneCoords,bx as zoomToFitBounds};